Exemple #1
0
/**
 * Create a Tab UI
 * @param array $tabs Multiple Tab Configuration
 * @return \Zbase\Ui\Tabs
 */
function zbase_ui_tabs($tabs)
{
    if (!empty($tabs)) {
        foreach ($tabs as $tab) {
            if (is_array($tab)) {
                $tab = zbase_ui($tab);
            }
        }
        return $tab->group();
    }
}
Exemple #2
0
 /**
  * Process tabs
  */
 protected function _tabs()
 {
     $tabSet = $this->_v('tabs', null);
     /**
      * If $formTag is TRUE, will create a form on each tabs
      */
     $formTag = $this->_v('form_tab', true);
     if (!is_null($tabSet) && is_array($tabSet)) {
         foreach ($tabSet as $tabName => $tab) {
             if (!is_array($tab)) {
                 continue;
             }
             $tab['widgetEntity'] = $this->entity();
             $tabObject = zbase_ui($tab);
             $tabObject->setGroup($this->id() . 'tabs');
             // $tabObject->setAttribute('widgetEntity', $this->entity());
             $enabled = $tabObject->enabled();
             if ($enabled) {
                 if (!empty($tab['elements'])) {
                     $hasFileElement = false;
                     foreach ($tab['elements'] as $elementName => $element) {
                         if (empty($element['id'])) {
                             $element['id'] = $elementName;
                             $element['name'] = $elementName;
                         }
                         if (!empty($element['type']) && $element['type'] == 'file') {
                             $hasFileElement = true;
                         }
                         // var_dump('_tabs: ' . $tabName);
                         $tabObject->addContent($this->_createElement($element, $tabName));
                     }
                     unset($tab['elements']);
                 }
                 if (empty($formTag)) {
                     $tabObject->setForm(clone $this);
                     /**
                      * Form Configuration in a tab
                      */
                     if (!empty($tab['formConfiguration'])) {
                         $tabObject->form()->setAttributes($tab['formConfiguration']);
                     }
                     $this->setFormTag(false);
                 }
                 $tabs[$tabName] = $tabObject;
             }
         }
         //			foreach ($tabs as $tabName => $tab)
         //			{
         //				$tab = zbase_ui($tab);
         //				if(!is_array($tab))
         //				{
         //					continue;
         //				}
         //				$tab['group'] = $this->id() . 'tabs';
         //				if(!empty($tab['elements']))
         //				{
         //					$hasFileElement = false;
         //					foreach ($tab['elements'] as $elementName => $element)
         //					{
         //						if(empty($element['id']))
         //						{
         //							$element['id'] = $elementName;
         //							$element['name'] = $elementName;
         //						}
         //						if(!empty($element['type']) && $element['type'] == 'file')
         //						{
         //							$hasFileElement = true;
         //						}
         //						$tab['contents'][] = $this->_createElement($element, $tabName);
         //					}
         //					unset($tab['elements']);
         //				}
         //				if(empty($formTag))
         //				{
         //					$tab['form'] = clone $this;
         //					/**
         //					 * Form Configuration in a tab
         //					 */
         //					if(!empty($tab['formConfiguration']))
         //					{
         //						$tab['form']->setAttributes($tab['formConfiguration']);
         //					}
         //					$this->setFormTag(false);
         //				}
         //				$tab['widgetEntity'] = $this->entity();
         //				$tabs[$tabName] = $tab;
         //			}
     }
     if (!empty($tabs)) {
         $this->_tabs = zbase_ui_tabs($tabs);
     }
 }