Creates a dropdown from a list of commands.

@param LibBaseTemplateObjectContainer $commands Container of commands
@param array                          $config   Configuration array

@return string
4992
public function dropdown($commands, $config = array())
    {
        $config['commands'] = $commands;

        if (!isset($config['icon'])) {
            $config['icon'] = 'cog';
        }

        return $this->_render('dropdown', $config);
    }
1179864
protected function getCommands(array $config)
    {
        if (!is_array($config['plugins'])) {
            throw new \RuntimeException(
                'Configuration "plugins" key must reference an array',
                self::ERR_PLUGINS_NONARRAY
            );
        }

        $plugins = array_filter(
            $config['plugins'],
            function($plugin) {
                return $plugin instanceof PluginInterface;
            }
        );
        if (count($plugins) != count($config['plugins'])) {
            throw new \RuntimeException(
                'All configuration "plugins" array values must implement \Phergie\Irc\Bot\React\PluginInterface',
                self::ERR_PLUGINS_NONPLUGINS
            );
        }

        $commands = array();
        foreach ($plugins as $plugin) {
            $events = array_keys($plugin->getSubscribedEvents());
            $commandEvents = array();
            foreach ($events as $event) {
                if (!preg_match('/^command\.(.+)\.help$/', $event, $match)) {
                    continue;
                }
                $commands[$match[1]] = true;
            }
        }

        return $this->alphabetize($commands);
    }
732615
public function setFieldFormatting(&$config)
    {
        $fieldFormatting = array();
        // Parse the column information
        foreach ($this->columns() as $source => $info) {
            if (isset($info['link']) && $info['link']) {
                $fieldFormatting[$source] = '<a href=\"$ObjectRecordLink\">$value</a>';
            }
            if (isset($info['text']) && $info['text']) {
                $fieldFormatting[$source] = $info['text'];
            }
        }
        return $fieldFormatting;
    }
139425
protected function assignRole(array $config)
    {
        if (!($name = ArrayHelper::get($config, 'name')) || !($role  = $this->authManager->getRole($name))){
            return false;
        }
        if (!($child = ArrayHelper::get($config, 'child'))) {
            return $role;
        }
        if ($childRoles = ArrayHelper::get($child, 'roles')) {
            foreach ($childRoles as $name) {
                if ($roleChild = $this->authManager->getRole($name)) {
                    try {
                        $this->authManager->addChild($role, $roleChild);
                        $this->stdout("\tAssign child role: {$name} - success\n", Console::FG_GREEN);
                    } catch(\Exception $e) {
                        $this->stdout("\t- already exist\n");
                    }
                }
            }
        }
        if ($childPermissions = ArrayHelper::get($child, 'permissions')) {
            foreach ($childPermissions as $name) {
                if ($permissionChild = $this->authManager->getPermission($name)) {
                    try {
                        $this->authManager->addChild($role, $permissionChild);
                        $this->stdout("\tAssign child permission: {$name} - success\n", Console::FG_GREEN);
                    } catch(\Exception $e) {
                        $this->stdout("\t- already exist\n");
                    }
                }
            }
        }
        return $role;
    }
952735
public function getConfiguration(array $config, ContainerBuilder $container)
    {
        $configuration = $this->getConfigurationInstance();
        if ($configuration) {
            $container->addObjectResource($configuration);
        }

        return $configuration;
    }
798829
public function radio($config = array())
    {
        $config = new ObjectConfigJson($config);
        $config->append(array(
            'entity'  => null,
            'attribs' => array()
        ));

        if($config->entity->isLockable() && $config->entity->isLocked())
        {
            $html = $this->createHelper('behavior')->tooltip();
            $html .= '<span class="k-icon-lock-locked"
                            data-k-tooltip
                            title="'.$this->creaateHelper('grid')->lock_message(array('entity' => $config->entity)).'">
                    </span>';
        }
        else
        {
            $column = $config->entity->getIdentityColumn();
            $value  = StringEscaper::attr($config->entity->{$column});

            $attribs = $this->buildAttributes($config->attribs);

            $html = '<input type="radio" class="k-js-grid-checkbox" name="%s[]" value="%s" %s />';
            $html = sprintf($html, $column, $value, $attribs);
        }

        return $html;
    }
1156247
public function dialog($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'command' => NULL
        ));

        $html = $this->command($config);

        return $html;
    }
1057933
protected function createPartOfStructure(array $config)
  {
    $return_properties    = array();
    $return_configuration = array();

    foreach ($config as $configuration)
    {
      $value = null;
      switch ($configuration->getType())
      {
        case TypeEnum::COLLECTION_TYPE:
          $value = array($this->createPartOfStructure($configuration->getChildren()));
          break;
        case TypeEnum::OBJECT_TYPE:
          $value = $this->createPartOfStructure($configuration->getChildren());
          break;
        case TypeEnum::ARRAY_TYPE:
          $value = array();
          break;
        default:
          break;
      }
      $this->modifyConfiguration($configuration);
      $parameter = new Parameter($configuration->getKey(), $value);

      $return_properties[$configuration->getKey()]    = $parameter;
      $return_configuration[$configuration->getKey()] = $configuration;
    }

    return $this->classBuilder->build('\stdClass', $return_configuration, $return_properties);
  }
270882
protected function getCommandConfig(Config $config, $command)
    {
        $string = '';
        if (isset($config[$command])) {
            /** @var Config $config */
            $config = $config[$command];
            if ($config->count() > 0) {
                $config = $config->toArray();
                /** @var array $config */
                $string .= $this->commands[$command] . PHP_EOL . '{' . PHP_EOL . "\t";
                $string .= $this->getValuesString($config, true);
                $string .= PHP_EOL . '}' . PHP_EOL;
            }
        }
        return $string;
    }
977835
protected function createDatabaseDriver(array $config)
    {
        $connection = $this->app['db']->connection(Arr::get($config, 'connection'));

        return $this->repository(
            new DatabaseStore(
                $connection, $config['table'], $this->getPrefix($config)
            )
        );
    }
792217
public function createNullDriver(array $config)
    {
        return $this->adapt($this->createFlysystem(new \League\Flysystem\Adapter\NullAdapter, $config));
    }
820270
public function radiolist($config = array())
    {
        $config = new ObjectConfigJson($config);
        $config->append(array(
            'options' 	=> array(),
            'legend'    => null,
            'name'   	=> 'id',
            'selected'	=> null,
            'translate'	=> false,
            'attribs'	=> array(),
        ));

        $translator = $this->getObject('translator');
        $attribs    = $this->buildAttributes($config->attribs);

        $html   = array();
        $html[] = '<fieldset  name="'. $config->name .'" '. $attribs .'>';

        if(isset($config->legend)) {
            $html[] = '<legend>'.$config->translate ? $translator->translate( $config->legend ) : $config->legend.'</legend>';
        }

        foreach($config->options as $option)
        {
            $value = $option->value;
            $label = $config->translate ? $translator->translate( $option->label ) : $option->label;

            $extra = ($value == $config->selected ? 'checked="checked"' : '');

            if(isset($option->disabled) && $option->disabled) {
                $extra .= 'disabled="disabled"';
            }

            if(isset($option->attribs)) {
                $attribs = $this->buildAttributes($option->attribs);
            }

            $html[] = '<label class="radio" for="'.$config->name.$option->id.'">';
            $html[] = '<input type="radio" name="'.$config->name.'" id="'.$config->name.$option->id.'" value="'.$value.'" '.$extra.' '.$attribs.' />';
            $html[] = $label;
            $html[] = '</label>';
        }

        $html[] = '</fieldset>';

        return implode(PHP_EOL, $html);
    }
982325
public function getCommand($name, $config = array())
    {
        if(!isset($this->__commands[$name]))
        {
            //Create the config object
            $command = new ControllerToolbarCommand($name, $config);

            //Attach the command to the toolbar
            $command->setToolbar($this);

            //Find the command function to call
            if (method_exists($this, '_command' . ucfirst($name)))
            {
                $function = '_command' . ucfirst($name);
                $this->$function($command);
            }
            else
            {
                //Don't set an action for GET commands
                if (!isset($command->href))
                {
                    $command->append(array(
                        'data' => array(
                            'action' => $command->getName()
                        )
                    ));
                }
            }
        }
        else $command = $this->__commands[$name];

        return $command;
    }
358358
public function optionlist($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'options'   => array(),
            'selected'  => null,
            'disabled'  => null,
            'translate' => false,
            'attribs'   => array('size' => 1),
        ));

        $html = array();

        $html[] = '<select name="'. $config->name .'" '. $this->buildAttributes($config->attribs) .'>';

        foreach($config->options as $group => $options)
        {
            if (is_numeric($group)) {
                $options = array($options);
            } else {
                $html[] = '<optgroup label="' . $this->getTemplate()->escape($group) . '">';
            }

            foreach ($options as $option)
            {
                $value = $option->value;
                $label = $config->translate ? $this->getObject('translator')->translate( $option->label ) : $option->label;

                $extra = '';
                if(isset($option->disabled) && $option->disabled) {
                    $extra .= 'disabled="disabled"';
                }

                if(isset($option->attribs)) {
                    $extra .= ' '.$this->buildAttributes($option->attribs);
                }

                if(!is_null($config->selected))
                {
                    if ($config->selected instanceof KObjectConfig)
                    {
                        foreach ($config->selected as $selected)
                        {
                            $sel = is_object($selected) ? $selected->value : $selected;
                            if ((string) $value == (string) $sel)
                            {
                                $extra .= 'selected="selected"';
                                break;
                            }
                        }
                    }
                    else $extra .= ((string) $value == (string) $config->selected ? ' selected="selected"' : '');
                }

                $html[] = '<option value="'. $value .'" '.$extra.'>' . $label . '</option>';
            }

            if (!is_numeric($group)) {
                $html[] = '</optgroup>';
            }
        }

        $html[] = '</select>';

        return implode(PHP_EOL, $html);
    }
124302
public function radio($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'entity'  		=> null,
            'attribs' => array()
        ));

        if($config->entity->isLockable() && $config->entity->isLocked())
        {
            $html = $this->getTemplate()->helper('behavior.tooltip');
            $html .= '<span class="k-icon-lock-locked"
                            data-k-tooltip 
                            title="'.$this->getTemplate()->helper('grid.lock_message', array('entity' => $config->entity)).'">
                    </span>';
        }
        else
        {
            $column = $config->entity->getIdentityColumn();
            $value  = $this->getTemplate()->escape($config->entity->{$column});

            $attribs = $this->buildAttributes($config->attribs);

            $html = '<input type="radio" class="k-js-grid-checkbox" name="%s[]" value="%s" %s />';
            $html = sprintf($html, $column, $value, $attribs);
        }

        return $html;
    }
104962
static public function createObject($type, array $config = [])
	{
		if (is_string($type)) {
			return static::container()->get($type, $config);
		} elseif (is_array($type) && isset($type['class'])) {
			$class = $type['class'];
			unset($type['class']);
			if ($config) $type = array_merge($type, $config); 
			return static::container()->get($class, $type);
		} elseif (is_callable($type, false)) {
			return call_user_func($type, $config);
		} elseif (is_object($type)) {
			return $type;
		} elseif (is_array($type)) {
			throw new InvalidConfigException('object configuration must be an array containing a "class" element.');
		} else {
			throw new InvalidConfigException("Unsupported configuration type: " . gettype($type));
		}
	}
739109
protected function getDblibDsn(array $config)
    {
        return $this->buildConnectString('dblib', array_merge([
            'host' => $this->buildHostString($config, ':'),
            'dbname' => $config['database'],
        ], Arr::only($config, ['appname', 'charset', 'version'])));
    }