示例#1
0
文件: ui.php 项目: stonyyi/anahita
 /**
  * Renders a command as a link tag. If it has a href, it will use the route to Route the link.
  *
  * @param ComBaseControllerToolbarCommand $command Command to render as a link
  *
  * @return string
  */
 public function command($command)
 {
     $attributes = KConfig::unbox($command->getAttributes());
     if (isset($attributes['icon'])) {
         $icon = 'icon-' . $attributes['icon'];
         $command->label = '<i class="' . $icon . '"></i>&nbsp;' . $command->label;
         unset($attributes['icon']);
     }
     $html = $this->getService('com:base.template.helper.html');
     return (string) $html->tag('a', $command->label, $attributes);
 }
示例#2
0
 /**
  * Get a command by name
  *
  * @param string The command name
  * @param array  An optional associative array of configuration settings
  *
  * @see LibBaseTemplateObject
  *
  * @return LibBaseTemplateObject Return a template object
  */
 public function getCommand($name, $config = array())
 {
     if (!isset($this->_commands[$name])) {
         if (!is_array($config)) {
             $config = array('label' => $config);
         }
         //Create the config object
         $command = ComBaseControllerToolbarCommand::getInstance($name, $config);
         //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->attribs->href)) {
                 $command->append(array('attribs' => array('data-action' => $command->getName())));
             }
         }
     } else {
         $command = $this->_commands[$name];
     }
     return $command;
 }