Inheritance: extends Cake\View\Helper\HtmlHelper, use trait OptionsAwareTrait
 public function icon($name, array $options = [])
 {
     //TODO: make icon agnostic and as helper config option
     if (!isset($options['iconSet'])) {
         $options['iconSet'] = 'fa';
     }
     return parent::icon($name, $options);
 }
Esempio n. 2
0
 /**
  * Creates an icon.
  *
  * This method surcharges the icon() method from BootstrapUI :
  *  - fixed width by default
  *  - fontAwesome by default
  *
  * Options :
  *  - fixed: bool, If true, an fa-fw class will be applied (default)
  *  - iconSet: string, icon prefix (usually 'glyphicon' or 'fa')
  *  - class: Additionnal classes for the icon.
  *
  * @param string $name Icon name or space separated names (ie: 'home' or 'home 3x')
  * @param array $options An array of options
  *
  * @return string
  */
 public function icon($name, array $options = [])
 {
     $options += ['iconSet' => 'fa', 'fixed' => true, 'class' => null];
     $names = explode(' ', $name);
     foreach ($names as $string) {
         $options = $this->injectClasses($options['iconSet'] . '-' . $string, $options);
     }
     if ($options['fixed']) {
         $options = $this->injectClasses($options['iconSet'] . '-fw', $options);
     }
     unset($options['fixed']);
     return parent::icon($name, $options);
 }
Esempio n. 3
0
 public function testCrumbList()
 {
     $result = $this->Html->addCrumb('jadb')->addCrumb('admad')->addCrumb('joe')->getCrumbList();
     $expected = ['ul' => ['class' => 'breadcrumb'], ['li' => ['class' => 'first']], 'jadb', '/li', '<li', 'admad', '/li', ['li' => ['class' => 'last']], 'joe', '/li', '/ul'];
     $this->assertHtml($expected, $result);
 }
Esempio n. 4
0
 /**
  * Print a link
  * - override HtmlHelper link method
  * - Permits to put an icon in a link
  * - add a class 'activation' if the link matches the current page
  *
  * @param string $title : title of link
  * @param string $url : url
  * @param array $options : options for link
  * @return parent::link
  */
 public function link($title, $url = null, array $options = [])
 {
     $default = ['icon' => null, 'escape' => true];
     $options = array_merge($default, (array) $options);
     if ($options['icon']) {
         if ($options['escape']) {
             $title = h($title);
         }
         $title = $this->bs_icon($options['icon']) . ' ' . $title;
         $options['escape'] = false;
         unset($options['icon']);
     }
     $lang = $this->_View->request->query('lang');
     if (!isset($url['lang']) && is_array($url) && isset($lang) && !empty($lang)) {
         $url['lang'] = $lang;
     }
     // we add class = activation to a link that matches the current page
     if ($url !== null) {
         $urlRouter = $this->Url->build($url);
     }
     //debug($urlRouter);
     if ($this->_View->request->here === $urlRouter) {
         if (!empty($options['class'])) {
             $mixClasses = [$options['class'], 'activation'];
             $options['class'] = implode(' ', $mixClasses);
         } else {
             $options['class'] = 'activation';
         }
     }
     return parent::link($title, $url, $options);
 }