phpMv  -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
IconTrait.php
Go to the documentation of this file.
1 <?php
2 
4 
7 
8 
14 trait IconTrait {
15  private $_hasIcon=false;
16 
17  abstract protected function addToPropertyCtrl($name, $value, $typeCtrl);
18  abstract public function addContent($content,$before=false);
19 
20  public function addIcon($icon,$direction=Direction::LEFT){
21  if($this->_hasIcon===false){
22  $iconO=$icon;
23  if(\is_string($icon)){
24  $iconO=new HtmlIcon("icon-".$this->identifier, $icon);
25  }
26  $this->addToPropertyCtrl("class", $direction." icon", Direction::getConstantValues("icon"));
27  $this->addContent($iconO,$direction===Direction::LEFT);
28  $this->_hasIcon=true;
29  }else{
30  $iconO=$this->getIcon();
31  $iconO->setIcon($icon);
32  $this->addToPropertyCtrl("class", $direction." icon", Direction::getConstantValues("icon"));
33  }
34  return $iconO;
35  }
36 
37  public function getIcon(){
38  if(\is_array($this->content)){
39  foreach ($this->content as $item){
40  if($item instanceof HtmlIcon)
41  return $item;
42  }
43  }
44  }
45 }
Semantic Icon component.
Definition: HtmlIcon.php:14
static getConstantValues($postFix="", $prefixBefore=false)
Definition: BaseEnum.php:29
addToPropertyCtrl($name, $value, $typeCtrl)
addIcon($icon, $before=true)
Definition: BaseTrait.php:92
addContent($content, $before=false)