function fetchElement()
 {
     $js = NextendJavascript::getInstance();
     $js->addLibraryJsAssetsFile('dojo', 'element.js');
     $js->addLibraryJsAssetsFile('dojo', 'element/menuwithitems.js');
     $html = '';
     $this->_value = $this->_form->get($this->_name, $this->_default);
     $value = explode('|*|', $this->_value);
     $db = JFactory::getDBO();
     $query = "SELECT \r\n            id, \r\n            name,\r\n            name as title,\r\n            0 AS parent,\r\n            0 AS parent_id\r\n            FROM #__js_res_sections ORDER BY name ASC";
     $db->setQuery($query);
     $this->sections = $db->loadObjectList('id');
     if (!isset($this->sections[$value[0]])) {
         $keys = array_keys($this->sections);
         $this->_form->set($this->_name, $keys[0] . '|*|0');
     }
     $html .= parent::fetchElement();
     $this->groupedList = array();
     jimport('joomla.html.html.menu');
     foreach ($this->sections as $section) {
         $this->groupedList[$section->id] = array();
         $query = "SELECT DISTINCT \r\n                id, \r\n                title,\r\n                title AS name,\r\n                parent_id,\r\n                parent_id AS parent\r\n                FROM #__js_res_categories\r\n                WHERE section_id = " . intval($section->id) . " AND published = 1\r\n                ORDER BY name ASC\r\n            ";
         $db->setQuery($query);
         $categories = $db->loadObjectList();
         $children = array();
         if ($categories) {
             foreach ($categories as $v) {
                 $pt = $v->parent_id;
                 $list = isset($children[$pt]) ? $children[$pt] : array();
                 array_push($list, $v);
                 $children[$pt] = $list;
             }
         }
         $options = JHTML::_('menu.treerecurse', 1, '', array(), $children, 9999, 0, 0);
         foreach ($options as $option) {
             $this->groupedList[$section->id][] = array($option->id, $option->treename);
         }
     }
     $js->addLibraryJs('dojo', '
         new NextendElementMenuWithItems({
           hidden: "' . $this->_id . '",
           options: ' . json_encode($this->groupedList) . ',
           value: "' . $this->_value . '"
         });
     ');
     return $html;
 }
示例#2
0
 function fetchElement()
 {
     $js = NextendJavascript::getInstance();
     $js->addLibraryJsAssetsFile('dojo', 'element.js');
     $js->addLibraryJsAssetsFile('dojo', 'element/menuwithitems.js');
     $html = '';
     $html .= parent::fetchElement();
     $db = JFactory::getDBO();
     $where = ' WHERE published = 1 ';
     if (version_compare(JVERSION, '3.0.0', 'ge')) {
         $query = 'SELECT id, parent_id, parent_id as parent, title, menutype, type' . ' FROM #__menu' . $where . ' ORDER BY menutype, lft, parent_id';
     } elseif (version_compare(JVERSION, '1.6.0', 'ge')) {
         $query = 'SELECT id, parent_id, parent_id as parent, title, menutype, type' . ' FROM #__menu' . $where . ' ORDER BY menutype, lft, parent_id, ordering';
     } else {
         $query = 'SELECT id, parent AS parent_id, parent, name, menutype, type' . ' FROM #__menu' . $where . ' ORDER BY menutype, parent, ordering';
     }
     $db->setQuery($query);
     $menuItems = $db->loadObjectList();
     $children = array();
     if ($menuItems) {
         foreach ($menuItems as $v) {
             $pt = $v->parent_id;
             $list = isset($children[$pt]) ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
     }
     jimport('joomla.html.html.menu');
     $options = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0);
     $groupedList = array();
     foreach ($options as $k => $v) {
         $groupedList[$v->menutype][] = array($v->id, $v->treename);
     }
     $js->addLibraryJs('dojo', '
         new NextendElementMenuWithItems({
           hidden: "' . $this->_id . '",
           options: ' . json_encode($groupedList) . ',
           value: "' . $this->_value . '"
         });
     ');
     return $html;
 }
 function fetchElement()
 {
     $js = NextendJavascript::getInstance();
     $js->addLibraryJsAssetsFile('dojo', 'element.js');
     $js->addLibraryJsAssetsFile('dojo', 'element/menuwithitems.js');
     $html = '';
     $this->_value = $this->_form->get($this->_name, $this->_default);
     $value = explode('|*|', $this->_value);
     $zoo = App::getInstance('zoo');
     $table = $zoo->table->application;
     $this->apps = $table->all(array('order' => 'name'));
     if (!isset($this->apps[$value[0]])) {
         $keys = array_keys($this->apps);
         $this->_form->set($this->_name, $keys[0] . '|*|0');
     }
     $html .= parent::fetchElement();
     $this->groupedList = array();
     foreach ($this->apps as $app) {
         $this->groupedList[$app->id] = array();
         $categories = $app->getCategories(true, null, true);
         if (count($categories)) {
             $this->cats = array();
             foreach ($categories as $category) {
                 if (!isset($this->cats[$category->parent])) {
                     $this->cats[$category->parent] = array();
                 }
                 $this->cats[$category->parent][] = $category;
             }
             $this->renderCategory(0, '', $app->id);
         }
     }
     $js->addLibraryJs('dojo', '
         new NextendElementMenuWithItems({
           hidden: "' . $this->_id . '",
           options: ' . json_encode($this->groupedList) . ',
           value: "' . $this->_value . '"
         });
     ');
     return $html;
 }
示例#4
0
 function fetchElement()
 {
     $js = NextendJavascript::getInstance();
     $js->addLibraryJsAssetsFile('dojo', 'element.js');
     $js->addLibraryJsAssetsFile('dojo', 'element/menuwithitems.js');
     $html = '';
     $this->_value = $this->_form->get($this->_name, $this->_default);
     $html .= parent::fetchElement();
     $groupedList = array();
     $menus = get_terms('nav_menu');
     foreach ($menus as $menu) {
         $groupedList[$menu->term_id] = array();
         $items = wp_get_nav_menu_items($menu->term_id, array());
         $pre = array();
         if (count($items)) {
             foreach ($items as $item) {
                 if (!isset($pre[$item->ID])) {
                     if (isset($pre[$item->menu_item_parent])) {
                         $pre[$item->ID] = $pre[$item->menu_item_parent] . '- ';
                     } else {
                         $pre[$item->ID] = '- ';
                     }
                 }
                 $groupedList[$menu->term_id][] = array($item->ID, $pre[$item->ID] . htmlspecialchars($item->title));
             }
         }
     }
     $js->addLibraryJs('dojo', '
         new NextendElementMenuWithItems({
           hidden: "' . $this->_id . '",
           options: ' . json_encode($groupedList) . ',
           value: "' . $this->_value . '"
         });
     ');
     return $html;
 }