コード例 #1
0
ファイル: TabElement.php プロジェクト: contao-bootstrap/tab
 /**
  * Construct. Prepare tab content element.
  *
  * @param \ContentModel $element Content model.
  */
 public function __construct($element)
 {
     parent::__construct($element);
     // load tab definitions
     if ($this->wrapper->isTypeOf(Wrapper\Helper::TYPE_START)) {
         $this->initializeStartElement();
     } elseif ($this->wrapper->isTypeOf(Wrapper\Helper::TYPE_SEPARATOR)) {
         $this->initializeSeparator();
     }
 }
コード例 #2
0
ファイル: Tab.php プロジェクト: Olli/components
 /**
  * prepare tab content element
  * @param $objElement
  */
 public function __construct($objElement)
 {
     parent::__construct($objElement);
     // load tab definitions
     if ($this->wrapper->isTypeOf(Wrapper\Helper::TYPE_START)) {
         $tabs = deserialize($this->bootstrap_tabs, true);
         $tab = null;
         foreach ($tabs as $i => $t) {
             $tabs[$i]['id'] = standardize($t['title']);
             if ($t['type'] != 'dropdown' && !$tab) {
                 $tab = $tabs[$i];
             }
         }
         $this->currentTab = $tab;
         $this->tabs = $tabs;
         $this->fade = $this->bootstrap_fade;
     } elseif ($this->wrapper->isTypeOf(Wrapper\Helper::TYPE_SEPARATOR)) {
         $elements = \Database::getInstance()->prepare('SELECT id FROM tl_content WHERE bootstrap_parentId=? ORDER by sorting')->execute($this->bootstrap_parentId);
         $elements = array_merge(array($this->bootstrap_parentId), $elements->fetchEach('id'));
         $parent = \ContentModel::findByPK($this->bootstrap_parentId);
         $index = 0;
         if ($parent) {
             $this->fade = $parent->bootstrap_fade;
         }
         $tabs = deserialize($parent->bootstrap_tabs, true);
         foreach ($tabs as $i => $t) {
             $tabs[$i]['id'] = standardize($t['title']);
             if ($t['type'] != 'dropdown') {
                 if ($elements[$index] == $this->id) {
                     $this->currentTab = $tabs[$i];
                     break;
                 }
                 $index++;
             }
         }
         $this->tabs = $tabs;
     }
 }