Esempio n. 1
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     if (!file_exists(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_zoo' . DS . 'zoo.php')) {
         return 'ZOO files not found...';
     }
     $db =& JFactory::getDBO();
     $sql = "SHOW tables like '" . $db->getPrefix() . "zoo_category'";
     $db->setQuery($sql);
     $tables = $db->loadObjectList();
     if (!count($tables)) {
         return 'ZOO category table not found in database...';
     }
     $multiple = $node->attributes('multiple');
     $size = $this->def($node->attributes('size'), 0);
     if (!is_array($value)) {
         $value = explode(',', $value);
     }
     $sql = "SELECT id, name FROM #__zoo_application";
     $db->setQuery($sql);
     $apps = $db->loadObjectList();
     $options = array();
     foreach ($apps as $i => $app) {
         $sql = "SELECT id, parent, name FROM #__zoo_category WHERE published = 1 AND application_id = " . (int) $app->id;
         $db->setQuery($sql);
         $menuItems = $db->loadObjectList();
         if ($i) {
             $options[] = JHTML::_('select.option', '-', ' ', 'value', 'text', 1);
         }
         // establish the hierarchy of the menu
         // TODO: use node model
         $children = array();
         if ($menuItems) {
             // first pass - collect children
             foreach ($menuItems as $v) {
                 $pt = $v->parent;
                 $list = @$children[$pt] ? $children[$pt] : array();
                 array_push($list, $v);
                 $children[$pt] = $list;
             }
         }
         // second pass - get an indent list of the items
         require_once JPATH_LIBRARIES . DS . 'joomla' . DS . 'html' . DS . 'html' . DS . 'menu.php';
         $list = JHTMLMenu::treerecurse(0, '', array(), $children, 9999, 0, 0);
         // assemble items to the array
         $options[] = JHTML::_('select.option', 'app' . $app->id, '[' . $app->name . ']', 'value', 'text', 0);
         foreach ($list as $item) {
             $options[] = JHTML::_('select.option', $item->id, '   ' . $item->treename, 'value', 'text', 0);
         }
     }
     $attribs = 'class="inputbox"';
     if ($size) {
         $attribs .= ' size="' . $size . '"';
     } else {
         $attribs .= ' size="' . (count($options) > 10 ? 10 : count($options)) . '"';
     }
     if ($multiple) {
         $attribs .= ' multiple="multiple"';
     }
     return JHTML::_('select.genericlist', $options, '' . $control_name . '[' . $name . '][]', $attribs, 'value', 'text', $value, $control_name . $name);
 }
 function getInput($name, $id, $value, $params, $children, $j15 = 0)
 {
     $this->params = $params;
     if (!file_exists(JPATH_ADMINISTRATOR . '/components/com_zoo/zoo.php')) {
         return 'ZOO files not found...';
     }
     $db =& JFactory::getDBO();
     $sql = "SHOW tables like '" . $db->getPrefix() . "zoo_category'";
     $db->setQuery($sql);
     $tables = $db->loadObjectList();
     if (!count($tables)) {
         return 'ZOO category table not found in database...';
     }
     $size = (int) $this->def('size');
     $multiple = $this->def('multiple');
     if (!is_array($value)) {
         $value = explode(',', $value);
     }
     $sql = "SELECT id, name FROM #__zoo_application";
     $db->setQuery($sql);
     $apps = $db->loadObjectList();
     $options = array();
     foreach ($apps as $i => $app) {
         if ($j15) {
             $sql = "SELECT id, parent, name FROM #__zoo_category WHERE published = 1 AND application_id = " . (int) $app->id;
         } else {
             $sql = "SELECT id, parent, parent as parent_id, name as title FROM #__zoo_category WHERE published = 1 AND application_id = " . (int) $app->id;
         }
         $db->setQuery($sql);
         $menuItems = $db->loadObjectList();
         if ($i) {
             $options[] = JHTML::_('select.option', '-', ' ', 'value', 'text', 1);
         }
         // establish the hierarchy of the menu
         // TODO: use node model
         $children = array();
         if ($menuItems) {
             // first pass - collect children
             foreach ($menuItems as $v) {
                 $pt = $v->parent;
                 $list = @$children[$pt] ? $children[$pt] : array();
                 array_push($list, $v);
                 $children[$pt] = $list;
             }
         }
         // second pass - get an indent list of the items
         require_once JPATH_LIBRARIES . '/joomla/html/html/menu.php';
         $list = JHTMLMenu::treerecurse(0, '', array(), $children, 9999, 0, 0);
         // assemble items to the array
         $options[] = JHTML::_('select.option', 'app' . $app->id, '[' . $app->name . ']', 'value', 'text', 0);
         foreach ($list as $item) {
             $item_name = '  ' . preg_replace('#^(( )*)- #', '\\1', str_replace(' ', ' ', $item->treename));
             $options[] = JHTML::_('select.option', $item->id, $item_name, 'value', 'text', 0);
         }
     }
     require_once JPATH_PLUGINS . '/system/nnframework/helpers/html.php';
     return nnHTML::selectlist($options, $name, $value, $id, $size, $multiple, 0, $j15);
 }
Esempio n. 3
0
 function getInput($name, $id, $value, $params, $children, $j15 = 0)
 {
     $this->params = $params;
     if (!file_exists(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'admin.k2.php')) {
         return 'K2 files not found...';
     }
     $db =& JFactory::getDBO();
     $sql = "SHOW tables like '" . $db->getPrefix() . "k2_categories'";
     $db->setQuery($sql);
     $tables = $db->loadObjectList();
     if (!count($tables)) {
         return 'K2 category table not found in database...';
     }
     $multiple = $this->def('multiple');
     $get_categories = $this->def('getcategories', 1);
     $size = $this->def('size', 0);
     if (!is_array($value)) {
         $value = explode(',', $value);
     }
     $where = 'published = 1';
     if (!$get_categories) {
         $where .= ' AND parent = 0';
     }
     $sql = "SELECT id, parent, name FROM #__k2_categories WHERE " . $where;
     $db->setQuery($sql);
     $menuItems = $db->loadObjectList();
     // establish the hierarchy of the menu
     // TODO: use node model
     $children = array();
     if ($menuItems) {
         // first pass - collect children
         foreach ($menuItems as $v) {
             $pt = $v->parent;
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
     }
     // second pass - get an indent list of the items
     require_once JPATH_LIBRARIES . DS . 'joomla' . DS . 'html' . DS . 'html' . DS . 'menu.php';
     $list = JHTMLMenu::treerecurse(0, '', array(), $children, 9999, 0, 0);
     // assemble items to the array
     $options = array();
     foreach ($list as $item) {
         $options[] = JHTML::_('select.option', $item->id, $item->treename, 'value', 'text', 0);
     }
     $attribs = 'class="inputbox"';
     if ($size) {
         $attribs .= ' size="' . $size . '"';
     } else {
         $attribs .= ' size="' . (count($options) > 10 ? 10 : count($options)) . '"';
     }
     if ($multiple) {
         $attribs .= ' multiple="multiple"';
     }
     return JHTML::_('select.genericlist', $options, '' . $name . '[]', $attribs, 'value', 'text', $value, $id);
 }
Esempio n. 4
0
 function getInput($name, $id, $value, $params, $children, $j15 = 0)
 {
     $this->params = $params;
     if (!file_exists(JPATH_ADMINISTRATOR . '/components/com_resource/resource.php')) {
         return 'Mighty Resource files not found...';
     }
     $db = JFactory::getDBO();
     $sql = "SHOW tables like '" . $db->getPrefix() . "js_res_category'";
     $db->setQuery($sql);
     $tables = $db->loadObjectList();
     if (!count($tables)) {
         return 'Mighty Resource category table not found in database...';
     }
     $size = (int) $this->def('size');
     $multiple = $this->def('multiple');
     $get_categories = $this->def('getcategories', 1);
     $show_ignore = $this->def('show_ignore');
     if (!is_array($value)) {
         $value = explode(',', $value);
     }
     $where = 'published = 1';
     if (!$get_categories) {
         $where .= ' AND parent = 0';
     }
     $sql = "SELECT id, parent, name FROM #__js_res_category WHERE " . $where;
     $db->setQuery($sql);
     $menuItems = $db->loadObjectList();
     // establish the hierarchy of the menu
     // TODO: use node model
     $children = array();
     if ($menuItems) {
         // first pass - collect children
         foreach ($menuItems as $v) {
             $pt = $v->parent;
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
     }
     // second pass - get an indent list of the items
     require_once JPATH_LIBRARIES . '/joomla/html/html/menu.php';
     $list = JHTMLMenu::treerecurse(0, '', array(), $children, 9999, 0, 0);
     // assemble items to the array
     $options = array();
     if ($show_ignore) {
         if (in_array('-1', $value)) {
             $value = array('-1');
         }
         $options[] = JHtml::_('select.option', '-1', '- ' . JText::_('NN_IGNORE') . ' -', 'value', 'text', 0);
     }
     foreach ($list as $item) {
         $item_name = preg_replace('#^(( )*)- #', '\\1', str_replace(' ', ' ', $item->treename));
         $options[] = JHtml::_('select.option', $item->id, $item_name, 'value', 'text', 0);
     }
     require_once JPATH_PLUGINS . '/system/nnframework/helpers/html.php';
     return nnHTML::selectlist($options, $name, $value, $id, $size, $multiple, '', $j15);
 }
Esempio n. 5
0
 function getInput($name, $id, $value, $params, $children, $j15 = 0)
 {
     $this->params = $params;
     $multiple = $this->def('multiple');
     $show_uncategorized = $this->def('show_uncategorized');
     $auto_select_cats = $this->def('auto_select_cats', 1);
     $db =& JFactory::getDBO();
     if (is_array($value)) {
         $value = implode(',', $value);
     }
     $value = str_replace('.', ':', $value);
     $value = explode(',', $value);
     $query = 'SELECT id, 0 as parent, title as name FROM #__sections WHERE published = 1 AND scope = "content" ORDER BY ordering';
     $db->setQuery($query);
     $sections = $db->loadObjectList();
     for ($i = 0; $i < count($sections); $i++) {
         $sec_name = explode("\n", wordwrap($sections[$i]->name, 86, "\n"));
         $sec_name = $sec_name['0'];
         $sec_name = $sec_name != $sections[$i]->name ? $sec_name . '...' : $sec_name;
         $sections[$i]->title = $sec_name;
     }
     $children = array();
     $children[] = $sections;
     foreach ($sections as $section) {
         $query = 'SELECT CONCAT( ' . $section->id . ', ":", id ) as id, section as parent, title as name' . ' FROM #__categories' . ' WHERE published = 1' . ' AND section = ' . $section->id . ' ORDER BY ordering';
         $db->setQuery($query);
         $categories = $db->loadObjectList();
         for ($i = 0; $i < count($categories); $i++) {
             $cat_name = explode("\n", wordwrap($categories[$i]->name, 86, "\n"));
             $cat_name = $cat_name['0'];
             $cat_name = $cat_name != $categories[$i]->name ? $cat_name . '...' : $cat_name;
             $categories[$i]->name = $cat_name;
             if ($auto_select_cats && in_array($section->id, $value)) {
                 $value[] = $categories[$i]->id;
             }
         }
         $children[$section->id] = $categories;
     }
     // second pass - get an indent list of the items
     require_once JPATH_LIBRARIES . DS . 'joomla' . DS . 'html' . DS . 'html' . DS . 'menu.php';
     $list = JHTMLMenu::treerecurse(0, '', array(), $children, 9999, 0, 0);
     // assemble items to the array
     $options = array();
     if ($show_uncategorized) {
         $options[] = JHTML::_('select.option', '0', JText::_('Uncategorized'), 'value', 'text', 0);
     }
     foreach ($list as $item) {
         $options[] = JHTML::_('select.option', $item->id, $item->treename, 'value', 'text', 0);
     }
     $attribs = 'class="inputbox"';
     $attribs .= ' size="' . (count($options) > 10 ? 10 : count($options)) . '"';
     if ($multiple) {
         $attribs .= ' multiple="multiple"';
     }
     return JHTML::_('select.genericlist', $options, '' . $name . '[]', $attribs, 'value', 'text', $value, $id);
 }
Esempio n. 6
0
 function getInput($name, $id, $value, $params, $children, $j15 = 0)
 {
     $this->params = $params;
     $size = (int) $this->def('size');
     $multiple = $this->def('multiple');
     $show_uncategorized = $this->def('show_uncategorized');
     $auto_select_cats = $this->def('auto_select_cats', 1);
     $db =& JFactory::getDBO();
     if (is_array($value)) {
         $value = implode(',', $value);
     }
     $value = str_replace('.', ':', $value);
     $value = explode(',', $value);
     $query = 'SELECT id, 0 as parent, title as name FROM #__sections WHERE published = 1 AND scope = "content" ORDER BY ordering';
     $db->setQuery($query);
     $sections = $db->loadObjectList();
     for ($i = 0; $i < count($sections); $i++) {
         $sec_name = explode("\n", wordwrap($sections[$i]->name, 86, "\n"));
         $sec_name = $sec_name['0'];
         $sec_name = $sec_name != $sections[$i]->name ? $sec_name . '...' : $sec_name;
         $sections[$i]->title = $sec_name;
     }
     $children = array();
     $children[] = $sections;
     foreach ($sections as $section) {
         $query = 'SELECT CONCAT( ' . $section->id . ', ":", id ) as id, section as parent, title as name' . ' FROM #__categories' . ' WHERE published = 1' . ' AND section = ' . $section->id . ' ORDER BY ordering';
         $db->setQuery($query);
         $categories = $db->loadObjectList();
         for ($i = 0; $i < count($categories); $i++) {
             $cat_name = explode("\n", wordwrap($categories[$i]->name, 86, "\n"));
             $cat_name = $cat_name['0'];
             $cat_name = $cat_name != $categories[$i]->name ? $cat_name . '...' : $cat_name;
             $categories[$i]->name = $cat_name;
             if ($auto_select_cats && in_array($section->id, $value)) {
                 $value[] = $categories[$i]->id;
             }
         }
         $children[$section->id] = $categories;
     }
     // second pass - get an indent list of the items
     require_once JPATH_LIBRARIES . '/joomla/html/html/menu.php';
     $list = JHTMLMenu::treerecurse(0, '', array(), $children, 9999, 0, 0);
     // assemble items to the array
     $options = array();
     if ($show_uncategorized) {
         $options[] = JHTML::_('select.option', '0', JText::_('Uncategorized'), 'value', 'text', 0);
     }
     foreach ($list as $item) {
         $item_name = preg_replace('#^((&nbsp;)*)- #', '\\1', str_replace('&#160;', '&nbsp;', $item->treename));
         $options[] = JHTML::_('select.option', $item->id, $item_name, 'value', 'text', 0);
     }
     require_once JPATH_PLUGINS . '/system/nnframework/helpers/html.php';
     return nnHTML::selectlist($options, $name, $value, $id, $size, $multiple, 0, $j15);
 }
Esempio n. 7
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     if (!file_exists(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_resource' . DS . 'models' . DS . 'record.php')) {
         return 'JoomSuite Resources files not found...';
     }
     $conf =& JFactory::getConfig();
     $dbprefix = $conf->getValue('config.dbprefix');
     $db =& JFactory::getDBO();
     $sql = "SHOW tables like '" . $dbprefix . "js_res_category'";
     $db->setQuery($sql);
     $tables = $db->loadObjectList();
     if (!count($tables)) {
         return 'JoomSuite Resources category table not found in database...';
     }
     $multiple = $node->attributes('multiple');
     $get_categories = $this->def($node->attributes('getcategories'), 1);
     if (!is_array($value)) {
         $value = explode(',', $value);
     }
     $where = 'published = 1';
     if (!$get_categories) {
         $where .= ' AND parent = 0';
     }
     $sql = "SELECT id, parent, name FROM #__js_res_category WHERE " . $where;
     $db->setQuery($sql);
     $menuItems = $db->loadObjectList();
     // establish the hierarchy of the menu
     // TODO: use node model
     $children = array();
     if ($menuItems) {
         // first pass - collect children
         foreach ($menuItems as $v) {
             $pt = $v->parent;
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
     }
     // second pass - get an indent list of the items
     require_once JPATH_LIBRARIES . DS . 'joomla' . DS . 'html' . DS . 'html' . DS . 'menu.php';
     $list = JHTMLMenu::treerecurse(0, '', array(), $children, 9999, 0, 0);
     // assemble items to the array
     $options = array();
     foreach ($list as $item) {
         $options[] = JHTML::_('select.option', $item->id, $item->treename, 'value', 'text', 0);
     }
     $attribs = 'class="inputbox"';
     $attribs .= ' size="' . (count($options) > 10 ? 10 : count($options)) . '"';
     if ($multiple) {
         $attribs .= ' multiple';
     }
     return JHTML::_('select.genericlist', $options, '' . $control_name . '[' . $name . '][]', $attribs, 'value', 'text', $value, $control_name . $name);
 }
Esempio n. 8
0
 function getInput()
 {
     $db =& JFactory::getDBO();
     $version = new JVersion();
     $odering = ", m.ordering";
     if ($version->RELEASE >= '3.0') {
         $odering = "";
     }
     $query = 'SELECT m.id, m.parent_id, m.title, m.menutype' . ' FROM #__menu AS m' . ' WHERE m.published = 1' . ' ORDER BY m.menutype, m.parent_id ' . $odering;
     $db->setQuery($query);
     $mitems = $db->loadObjectList();
     $mitems_temp = $mitems;
     $children = array();
     foreach ($mitems as $v) {
         $id = $v->id;
         $pt = $v->parent_id;
         $list = @$children[$pt] ? $children[$pt] : array();
         array_push($list, $v);
         $children[$pt] = $list;
     }
     $list = JHTMLMenu::TreeRecurse(intval($mitems[0]->parent_id), '', array(), $children, 9999, 0, 0);
     $mitems_spacer = $mitems_temp[0]->menutype;
     $mitems = array();
     if (@$all | @$unassigned) {
         $mitems[] = JHTML::_('select.option', '<OPTGROUP>', JText::_('Menus'));
         if ($all) {
             $mitems[] = JHTML::_('select.option', 0, JText::_('All'));
         }
         if ($unassigned) {
             $mitems[] = JHTML::_('select.option', -1, JText::_('Unassigned'));
         }
         $mitems[] = JHTML::_('select.option', '</OPTGROUP>');
     }
     $lastMenuType = null;
     $tmpMenuType = null;
     foreach ($list as $list_a) {
         if ($list_a->menutype != $lastMenuType) {
             if ($tmpMenuType) {
                 $mitems[] = JHTML::_('select.option', '</OPTGROUP>');
             }
             $mitems[] = JHTML::_('select.option', '<OPTGROUP>', $list_a->title);
             $lastMenuType = $list_a->menutype;
             $tmpMenuType = $list_a->menutype;
         }
         $mitems[] = JHTML::_('select.option', $list_a->id, $list_a->treename);
     }
     if ($lastMenuType !== null) {
         $mitems[] = JHTML::_('select.option', '</OPTGROUP>');
     }
     $result = JHTML::_('select.genericlist', $mitems, $this->name . '[]', 'class="inputbox" size="15" multiple="multiple"', 'value', 'text', $this->value);
     return $result;
 }
Esempio n. 9
0
 function getInput($name, $id, $value, $params, $children, $j15 = 0)
 {
     $this->params = $params;
     if (!file_exists(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_resource' . DS . 'models' . DS . 'record.php')) {
         return 'JoomSuite Resources files not found...';
     }
     $db =& JFactory::getDBO();
     $sql = "SHOW tables like '" . $db->getPrefix() . "js_res_category'";
     $db->setQuery($sql);
     $tables = $db->loadObjectList();
     if (!count($tables)) {
         return 'JoomSuite Resources category table not found in database...';
     }
     $size = (int) $this->def('size');
     $multiple = $this->def('multiple');
     $get_categories = $this->def('getcategories', 1);
     if (!is_array($value)) {
         $value = explode(',', $value);
     }
     $where = 'published = 1';
     if (!$get_categories) {
         $where .= ' AND parent = 0';
     }
     $sql = "SELECT id, parent, name FROM #__js_res_category WHERE " . $where;
     $db->setQuery($sql);
     $menuItems = $db->loadObjectList();
     // establish the hierarchy of the menu
     // TODO: use node model
     $children = array();
     if ($menuItems) {
         // first pass - collect children
         foreach ($menuItems as $v) {
             $pt = $v->parent;
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
     }
     // second pass - get an indent list of the items
     require_once JPATH_LIBRARIES . DS . 'joomla' . DS . 'html' . DS . 'html' . DS . 'menu.php';
     $list = JHTMLMenu::treerecurse(0, '', array(), $children, 9999, 0, 0);
     // assemble items to the array
     $options = array();
     foreach ($list as $item) {
         $options[] = JHTML::_('select.option', $item->id, $item->treename, 'value', 'text', 0);
     }
     require_once JPATH_PLUGINS . DS . 'system' . DS . 'nonumberelements' . DS . 'helpers' . DS . 'html.php';
     return nnHTML::selectlist($options, $name, $value, $id, $size, $multiple, 0, $j15);
 }
 function getInput($name, $id, $value, $params, $children, $j15 = 0)
 {
     $this->params = $params;
     if (!file_exists(JPATH_ADMINISTRATOR . '/components/com_flexicontent/admin.flexicontent.php')) {
         return 'Flexicontent files not found...';
     }
     $db =& JFactory::getDBO();
     $sql = "SHOW tables like '" . $db->getPrefix() . "flexicontent_cats_item_relations'";
     $db->setQuery($sql);
     $tables = $db->loadObjectList();
     if (!count($tables)) {
         return 'Flexicontent category-item relations table not found in database...';
     }
     $size = (int) $this->def('size');
     $multiple = $this->def('multiple');
     $get_categories = $this->def('getcategories', 1);
     if (!is_array($value)) {
         $value = explode(',', $value);
     }
     $flexicomp_params =& JComponentHelper::getParams('com_flexicontent');
     $flexi_section = $flexicomp_params->get('flexi_section');
     $sql = 'SELECT  id, parent_id as parent, title as name' . ' FROM #__categories' . ' WHERE published = 1' . ' AND section = ' . $flexi_section . ' ORDER BY ordering';
     $db->setQuery($sql);
     $menuItems = $db->loadObjectList();
     // establish the hierarchy of the menu
     // TODO: use node model
     $children = array();
     if ($menuItems) {
         // first pass - collect children
         foreach ($menuItems as $v) {
             $pt = $v->parent;
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
     }
     // second pass - get an indent list of the items
     require_once JPATH_LIBRARIES . '/joomla/html/html/menu.php';
     $list = JHTMLMenu::treerecurse(0, '', array(), $children, 9999, 0, 1);
     // assemble items to the array
     $options = array();
     foreach ($list as $item) {
         $item_name = preg_replace('#^((&nbsp;)*)- #', '\\1', str_replace('&#160;', '&nbsp;', $item->treename));
         $options[] = JHTML::_('select.option', $item->id, $item_name, 'value', 'text', 0);
     }
     require_once JPATH_PLUGINS . '/system/nnframework/helpers/html.php';
     return nnHTML::selectlist($options, $name, $value, $id, $size, $multiple, 0, $j15);
 }
	function getInput( $name, $id, $value, $params, $children, $j15 = 0 )
	{
		$this->params = $params;

		JHtml::_( 'behavior.modal', 'a.modal' );

		$size = (int) $this->def( 'size' );
		$multiple = $this->def( 'multiple', 1 );
		$showinput = $this->def( 'showinput' );
		$state = $this->def( 'state' );
		$disable_types = $this->def( 'disable' );

		$db = JFactory::getDBO();

		// load the list of menu types
		$query = 'SELECT menutype, title'
			.' FROM #__menu_types'
			.' ORDER BY title';
		$db->setQuery( $query );
		$menuTypes = $db->loadObjectList();

		// load the list of menu items
		if ( $state != '' ) {
			$where = 'WHERE published = '.(int) $state;
		} else {
			$where = 'WHERE published != -2';
		}
		if ( $j15 ) {
			$query = 'SELECT id, parent, name, alias, menutype, type, published, home'
				.' FROM #__menu'
				.' '.$where
				.' ORDER BY menutype, parent, ordering';
		} else {
			$query = 'SELECT id, parent_id, title, alias, menutype, type, published, home'
				.', parent_id as parent, title as name'
				.' FROM #__menu'
				.' '.$where
				.' ORDER BY menutype, parent, ordering';
		}
		$db->setQuery( $query );
		$menuItems = $db->loadObjectList();

		// establish the hierarchy of the menu
		$children = array();

		if ( $menuItems ) {
			// first pass - collect children
			foreach ( $menuItems as $v ) {
				if ( $v->type != 'separator' ) {
					if ( $j15 ) {
						if ( preg_replace( '#[^a-z0-9]#', '', strtolower( $v->name ) ) !== preg_replace( '#[^a-z0-9]#', '', $v->alias ) ) {
							$v->name .= ' ['.$v->alias.']';
						}
					} else {
						if ( preg_replace( '#[^a-z0-9]#', '', strtolower( $v->title ) ) !== preg_replace( '#[^a-z0-9]#', '', $v->alias ) ) {
							$v->title .= ' ['.$v->alias.']';
						}
					}
				}
				$pt = $v->parent;
				$list = @$children[$pt] ? $children[$pt] : array();
				array_push( $list, $v );
				$children[$pt] = $list;
			}
		}

		// second pass - get an indent list of the items
		require_once JPATH_LIBRARIES.'/joomla/html/html/menu.php';
		$list = JHTMLMenu::treerecurse( 0, '', array(), $children, 9999, 0, 0 );

		// assemble into menutype groups
		$groupedList = array();
		foreach ( $list as $k => $v ) {
			$groupedList[$v->menutype][] =& $list[$k];
		}

		// assemble menu items to the array
		$options = array();

		$count = 0;
		foreach ( $menuTypes as $type ) {
			if ( isset( $groupedList[$type->menutype] ) ) {
				if ( $count > 0 ) {
					$options[] = JHtml::_( 'select.option', '-', '&nbsp;', 'value', 'text', true );
				}
				$count++;
				$options[] = JHtml::_( 'select.option', $type->menutype, '[ '.$type->title.' ]', 'value', 'text', true );
				$n = count( $groupedList[$type->menutype] );
				for ( $i = 0; $i < $n; $i++ )
				{
					$item =& $groupedList[$type->menutype][$i];

					//If menutype is changed but item is not saved yet, use the new type in the list
					if ( JRequest::getString( 'option', '', 'get' ) == 'com_menus' ) {
						$currentItemArray = JRequest::getVar( 'cid', array( 0 ), '', 'array' );
						$currentItemId = (int) $currentItemArray['0'];
						$currentItemType = JRequest::getString( 'type', $item->type, 'get' );
						if ( $currentItemId == $item->id && $currentItemType != $item->type ) {
							$item->type = $currentItemType;
						}
					}

					$disable = strpos( $disable_types, $item->type ) !== false ? true : false;
					$item_id = $item->id;
					$item_name = '&nbsp;&nbsp;'.preg_replace( '#^((&nbsp;)*)- #', '\1', str_replace( '&#160;', '&nbsp;', $item->treename ) );

					if ( $item->home ) {
						$item_name .= ' ['.JText::_( $j15 ? 'Default' : 'JDEFAULT' ).']';
					}
					if ( $item->type == 'separator' ) {
						$item_name = '[[:font-weight:normal;font-style:italic;color:grey;:]]'.$item_name;
						if ( !$item->children ) {
							$disable = 1;
						}
					} else if ( $item->published == 0 && !( $state === 0 ) ) {
						$item_name = '[[:font-style:italic;color:grey;:]]*'.$item_name.' ('.JText::_( $j15 ? 'Unpublished' : 'JUNPUBLISHED' ).')';
					}
					if ( $showinput ) {
						$item_name .= ' ['.$item->id.']';
					}

					$options[] = JHtml::_( 'select.option', $item_id, $item_name, 'value', 'text', $disable );
				}
			}
		}

		if ( $showinput ) {
			array_unshift( $options, JHtml::_( 'select.option', '-', '&nbsp;', 'value', 'text', true ) );
			array_unshift( $options, JHtml::_( 'select.option', '-', '- '.JText::_( 'Select Item' ).' -' ) );

			if ( $multiple ) {
				$onchange = 'if ( this.value ) { if ( '.$id.'.value ) { '.$id.'.value+=\',\'; } '.$id.'.value+=this.value; } this.value=\'\';';
			} else {
				$onchange = 'if ( this.value ) { '.$id.'.value=this.value;'.$id.'_text.value=this.options[this.selectedIndex].innerHTML.replace( /^((&|&amp;|&#160;)nbsp;|-)*/gm, \'\' ).trim(); } this.value=\'\';';
			}
			$attribs = 'class="inputbox" onchange="'.$onchange.'"';

			$html = '<table cellpadding="0" cellspacing="0"><tr><td style="padding: 0px;">'."\n";
			if ( !$multiple ) {
				$val_name = $value;
				if ( $value ) {
					foreach ( $menuItems as $item ) {
						if ( $item->id == $value ) {
							$val_name = $item->name.' ['.$value.']';
							;
							break;
						}
					}
				}
				$html .= '<input type="text" id="'.$id.'_text" value="'.$val_name.'" class="inputbox" size="'.$size.'" disabled="disabled" />';
				$html .= '<input type="hidden" name="'.$name.'" id="'.$id.'" value="'.$value.'" />';
			} else {
				$html .= '<input type="text" name="'.$name.'" id="'.$id.'" value="'.$value.'" class="inputbox" size="'.$size.'" />';
			}
			$html .= '</td><td style="padding: 0px;"padding-left: 5px;>'."\n";
			$html .= JHtml::_( 'select.genericlist', $options, '', $attribs, 'value', 'text', '', '' );
			$html .= '</td></tr></table>'."\n";
			return $html;
		} else {
			require_once JPATH_PLUGINS.'/system/nnframework/helpers/html.php';
			return nnHTML::selectlist( $options, $name, $value, $id, $size, $multiple, '', $j15 );
		}
	}
Esempio n. 12
0
 function getListsAdmin($filters)
 {
     $db =& JFactory::getDBO();
     $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
     // get list of Positions for dropdown filter
     $query = 'SELECT m.position AS value, m.position AS text' . ' FROM #__modules as m' . ' WHERE m.client_id = ' . (int) $client->id . ' GROUP BY m.position' . ' ORDER BY m.position';
     $db->setQuery($query);
     $options[] = JHTML::_('select.option', '0', '- ' . JText::_('Position') . ' -');
     $options = array_merge($options, $db->loadObjectList());
     $lists['position'] = JHTML::_('select.genericlist', $options, 'filter_position', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "{$filters->position}");
     // get list of Types for dropdown filter
     $query = 'SELECT module AS value, module AS text' . ' FROM #__modules' . ' WHERE client_id = ' . (int) $client->id . ' GROUP BY module' . ' ORDER BY module';
     $db->setQuery($query);
     $options = array(JHTML::_('select.option', '0', '- ' . JText::_('Type') . ' -'));
     $options = array_merge($options, $db->loadObjectList());
     $lists['type'] = JHTML::_('select.genericlist', $options, 'filter_type', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "{$filters->type}");
     // state filter
     $lists['state'] = JHTML::_('grid.state', $filters->state);
     // state access
     if (true || $client->id == 1) {
         // Administrator modules
         $query = 'SELECT id AS value, name AS text' . ' FROM #__groups' . ' ORDER BY id';
         $db->setQuery($query);
         $options = array(JHTML::_('select.option', '', '- ' . JText::_('AMM_ACCESS_LEVEL') . ' -'));
         $options = array_merge($options, $db->loadObjectList());
         $lists['access'] = JHTML::_('select.genericlist', $options, 'filter_access', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', $filters->access);
     } else {
         // TODO: ... still have to think about this!
         // Site modules
         $options = array();
         $options[] = JHTML::_('select.option', '', '- ' . JText::_('AMM_ACCESS_LEVEL') . ' -');
         $options[] = JHTML::_('select.option', '0', JText::_('NN_NOT_REGISTERED') . ' / ' . JText::_('NN_LOGGED_IN'));
         $acl =& JFactory::getACL();
         $options = array_merge($options, $acl->get_group_children_tree(null, 'USERS', 0));
         $lists['access'] = JHTML::_('select.genericlist', $options, 'filter_access_adv', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', $filters->access_adv);
     }
     // template assignment filter
     if (true || $client->id == 1) {
         // Administrator modules
         $query = 'SELECT DISTINCT( template ) AS text, template AS value' . ' FROM #__templates_menu' . ' WHERE client_id = ' . (int) $client->id;
         $db->setQuery($query);
         $options = array();
         $options[] = JHTML::_('select.option', '0', '- ' . JText::_('Template') . ' -');
         $options = array_merge($options, $db->loadObjectList());
         $lists['template'] = JHTML::_('select.genericlist', $options, 'filter_template', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "{$filters->template}");
     } else {
         // TODO: ... still have to think about this!
         // Site modules
         require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_templates' . DS . 'helpers' . DS . 'template.php';
         $templates = array();
         $templates = TemplatesHelper::parseXMLTemplateFiles(JPATH_ROOT . DS . 'templates');
         $options = array();
         $options[] = JHTML::_('select.option', '0', '- ' . JText::_('Template') . ' -');
         foreach ($templates as $template) {
             $options[] = JHTML::_('select.option', $template->directory, $template->name);
         }
         $lists['template'] = JHTML::_('select.genericlist', $options, 'filter_template', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "{$filters->template}");
     }
     // template assignment filter
     $query = 'SELECT DISTINCT( template ) AS text, template AS value' . ' FROM #__templates_menu' . ' WHERE client_id = ' . (int) $client->id;
     $db->setQuery($query);
     // get list of Menu Item Assignments for dropdown filter
     // load the list of menu types
     $query = 'SELECT menutype, title' . ' FROM #__menu_types' . ' ORDER BY title';
     $db->setQuery($query);
     $menuTypes = $db->loadObjectList();
     $query = 'SELECT m.id, m.parent, m.name, m.menutype, m.type, m.published, mm.moduleid as assignment' . ' FROM #__menu as m' . ' LEFT JOIN #__modules_menu AS mm ON mm.menuid = m.id' . ' WHERE m.published != -2' . ' GROUP BY m.id' . ' ORDER BY m.menutype, m.parent, m.ordering';
     $db->setQuery($query);
     $menuItems = $db->loadObjectList();
     // establish the hierarchy of the menu
     $children = array();
     if ($menuItems) {
         // first pass - collect children
         foreach ($menuItems as $v) {
             $pt = $v->parent;
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
     }
     // second pass - get an indent list of the items
     require_once JPATH_LIBRARIES . DS . 'joomla' . DS . 'html' . DS . 'html' . DS . 'menu.php';
     $list = JHTMLMenu::treerecurse(0, '', array(), $children, 9999, 0, 0);
     // assemble into menutype groups
     $n = count($list);
     $groupedList = array();
     foreach ($list as $k => $v) {
         $groupedList[$v->menutype][] =& $list[$k];
     }
     // assemble menu items to the array
     $options = array();
     $options[] = JHTML::_('select.option', '', '- ' . JText::_('AMM_MENU_ITEM_ASSIGNMENT') . ' -');
     $options[] = JHTML::_('select.option', 'all', JText::_('All'));
     $options[] = JHTML::_('select.option', 'none', JText::_('None'));
     $options[] = JHTML::_('select.option', 'varies', JText::_('Varies'));
     $options[] = JHTML::_('select.option', '-', '----------------------------------------', 'value', 'text', true);
     $count = 0;
     foreach ($menuTypes as $type) {
         if (isset($groupedList[$type->menutype])) {
             if ($count > 0) {
                 $options[] = JHTML::_('select.option', '-', '&nbsp;', 'value', 'text', true);
             }
             $count++;
             $options[] = JHTML::_('select.option', $type->menutype, '[ ' . $type->title . ' ]', 'value', 'text', true);
             $n = count($groupedList[$type->menutype]);
             for ($i = 0; $i < $n; $i++) {
                 $item =& $groupedList[$type->menutype][$i];
                 //If menutype is changed but item is not saved yet, use the new type in the list
                 if (JRequest::getString('option', '', 'get') == 'com_menus') {
                     $currentItemArray = JRequest::getVar('cid', array(0), '', 'array');
                     $currentItemId = (int) $currentItemArray['0'];
                     $currentItemType = JRequest::getString('type', $item->type, 'get');
                     if ($currentItemId == $item->id && $currentItemType != $item->type) {
                         $item->type = $currentItemType;
                     }
                 }
                 $item_name = $item->treename;
                 $item_id = $item->id;
                 if ($item->published == 0) {
                     $item_name = '*' . $item_name . ' (' . JText::_('Unpublished') . ')';
                     $item_id .= '" style="font-style:italic;';
                 }
                 $options[] = JHTML::_('select.option', $item_id, '&nbsp;&nbsp;&nbsp;' . $item_name, 'value', 'text', $item->assignment ? 0 : 1);
             }
         }
     }
     $lists['menuitems'] = JHTML::_('select.genericlist', $options, 'filter_menuitems', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "{$filters->menuitems}");
     // table ordering
     $lists['order_Dir'] = $filters->order_Dir;
     $lists['order'] = $filters->order;
     // search filter
     $lists['search'] = $filters->search;
     return $lists;
 }
Esempio n. 13
0
 function treerecurse($id, $indent, $list, &$children, $maxlevel = 9999, $level = 0, $type = 1)
 {
     if (@$children[$id] && $level <= $maxlevel) {
         foreach ($children[$id] as $v) {
             $id = $v->id;
             if ($type) {
                 $pre = '<sup>|_</sup>&nbsp;';
                 $spacer = '.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
             } else {
                 $pre = '- ';
                 $spacer = '&nbsp;&nbsp;';
             }
             if ($v->parent == 0) {
                 $txt = $v->name;
             } else {
                 $txt = $pre . $v->name;
             }
             $pt = $v->parent;
             $list[$id] = $v;
             $list[$id]->treename = "{$indent}{$txt}";
             $list[$id]->children = count(@$children[$id]);
             $list = JHTMLMenu::TreeRecurse($id, $indent . $spacer, $list, $children, $maxlevel, $level + 1, $type);
         }
     }
     return $list;
 }
Esempio n. 14
0
 function getInput($name, $id, $value, $params, $children, $j15 = 0)
 {
     $this->params = $params;
     if (!file_exists(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_resource' . DS . 'resource.php')) {
         return 'Mighty Resource files not found...';
     }
     $db =& JFactory::getDBO();
     $sql = "SHOW tables like '" . $db->getPrefix() . "js_res_category'";
     $db->setQuery($sql);
     $tables = $db->loadObjectList();
     if (!count($tables)) {
         return 'Mighty Resource category table not found in database...';
     }
     $multiple = $this->def('multiple');
     $get_categories = $this->def('getcategories', 1);
     $size = $this->def('size', 0);
     if (!is_array($value)) {
         $value = explode(',', $value);
     }
     $where = 'published = 1';
     if (!$get_categories) {
         $where .= ' AND parent = 0';
     }
     $sql = "SELECT id, parent, name FROM #__js_res_category WHERE " . $where;
     $db->setQuery($sql);
     $menuItems = $db->loadObjectList();
     // establish the hierarchy of the menu
     // TODO: use node model
     $children = array();
     if ($menuItems) {
         // first pass - collect children
         foreach ($menuItems as $v) {
             $pt = $v->parent;
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
     }
     // second pass - get an indent list of the items
     require_once JPATH_LIBRARIES . DS . 'joomla' . DS . 'html' . DS . 'html' . DS . 'menu.php';
     $list = JHTMLMenu::treerecurse(0, '', array(), $children, 9999, 0, 0);
     // assemble items to the array
     $options = array();
     foreach ($list as $item) {
         $item_name = $item->treename;
         $padding = 0;
         while (strpos($item_name, '&nbsp;&nbsp;') === 0) {
             $padding++;
             $item_name = substr($item_name, 12);
         }
         $item_name = preg_replace('#^- #', '', $item_name);
         $style = 'padding-left:' . $padding . 'em;';
         if ($style) {
             $item_name = '[[:' . $style . ':]]' . $item_name;
         }
         $options[] = JHTML::_('select.option', $item->id, $item_name, 'value', 'text', 0);
     }
     $attribs = 'class="inputbox"';
     if ($size) {
         $attribs .= ' size="' . $size . '"';
     } else {
         $attribs .= ' size="' . (count($options) > 10 ? 10 : count($options)) . '"';
     }
     if ($multiple) {
         $attribs .= ' multiple="multiple"';
     }
     $html = JHTML::_('select.genericlist', $options, '' . $name . '[]', $attribs, 'value', 'text', $value, $id);
     $html = preg_replace('#>\\[\\[\\:(.*?)\\:\\]\\]#si', ' style="\\1">', $html);
     return $html;
 }
Esempio n. 15
0
 function getInput($name, $id, $value, $params, $children, $j15 = 0)
 {
     $this->params = $params;
     JHTML::_('behavior.modal', 'a.modal');
     $size = $this->def('size');
     $multiple = $this->def('multiple', 1);
     $showinput = $this->def('showinput');
     $state = $this->def('state');
     $disable = $this->def('disable');
     $db =& JFactory::getDBO();
     // load the list of menu types
     $query = 'SELECT menutype, title' . ' FROM #__menu_types' . ' ORDER BY title';
     $db->setQuery($query);
     $menuTypes = $db->loadObjectList();
     // load the list of menu items
     if ($state != '') {
         $where = 'WHERE published = ' . (int) $state;
     } else {
         $where = 'WHERE published != -2';
     }
     $query = 'SELECT id, parent, name, menutype, type, published' . ' FROM #__menu' . ' ' . $where . ' ORDER BY menutype, parent, ordering';
     $db->setQuery($query);
     $menuItems = $db->loadObjectList();
     // establish the hierarchy of the menu
     $children = array();
     if ($menuItems) {
         // first pass - collect children
         foreach ($menuItems as $v) {
             $pt = $v->parent;
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
     }
     // second pass - get an indent list of the items
     require_once JPATH_LIBRARIES . DS . 'joomla' . DS . 'html' . DS . 'html' . DS . 'menu.php';
     $list = JHTMLMenu::treerecurse(0, '', array(), $children, 9999, 0, 0);
     // assemble into menutype groups
     $groupedList = array();
     foreach ($list as $k => $v) {
         $groupedList[$v->menutype][] =& $list[$k];
     }
     // assemble menu items to the array
     $options = array();
     $count = 0;
     foreach ($menuTypes as $type) {
         if (isset($groupedList[$type->menutype])) {
             if ($count > 0) {
                 $options[] = JHTML::_('select.option', '-', '&nbsp;', 'value', 'text', true);
             }
             $count++;
             $options[] = JHTML::_('select.option', $type->menutype, '[ ' . $type->title . ' ]', 'value', 'text', true);
             $n = count($groupedList[$type->menutype]);
             for ($i = 0; $i < $n; $i++) {
                 $item =& $groupedList[$type->menutype][$i];
                 //If menutype is changed but item is not saved yet, use the new type in the list
                 if (JRequest::getString('option', '', 'get') == 'com_menus') {
                     $currentItemArray = JRequest::getVar('cid', array(0), '', 'array');
                     $currentItemId = (int) $currentItemArray['0'];
                     $currentItemType = JRequest::getString('type', $item->type, 'get');
                     if ($currentItemId == $item->id && $currentItemType != $item->type) {
                         $item->type = $currentItemType;
                     }
                 }
                 $disable = strpos($disable, $item->type) !== false ? true : false;
                 $item_name = $item->treename;
                 $item_id = $item->id;
                 $style = 'padding-left:1em;';
                 if ($item->published == 0 && !($state === 0)) {
                     $item_name = '*' . $item_name . ' (' . JText::_('Unpublished') . ')';
                     $style .= 'font-style:italic;';
                 }
                 if ($showinput) {
                     $item_name .= ' [' . $item->id . ']';
                 }
                 if ($style) {
                     $item_name = '[[:' . $style . ':]]' . $item_name;
                 }
                 $options[] = JHTML::_('select.option', $item_id, $item_name, 'value', 'text', $disable);
             }
         }
     }
     $attribs = 'class="inputbox"';
     if ($showinput) {
         array_unshift($options, JHTML::_('select.option', '-', '&nbsp;', 'value', 'text', true));
         array_unshift($options, JHTML::_('select.option', '-', '- ' . JText::_('Select Item') . ' -'));
         if ($multiple) {
             $onchange = 'if ( this.value ) { if ( ' . $id . '.value ) { ' . $id . '.value+=\',\'; } ' . $id . '.value+=this.value; } this.value=\'\';';
         } else {
             $onchange = 'if ( this.value ) { ' . $id . '.value=this.value;' . $id . '_text.value=this.options[this.selectedIndex].innerHTML.replace( /^((&|&amp;|&#160;)nbsp;|-)*/gm, \'\' ).trim(); } this.value=\'\';';
         }
         $attribs .= ' onchange="' . $onchange . '"';
         $html = '<table cellpadding="0" cellspacing="0"><tr><td style="padding: 0px;">' . "\n";
         if (!$multiple) {
             $val_name = $value;
             if ($value) {
                 foreach ($menuItems as $item) {
                     if ($item->id == $value) {
                         $val_name = $item->name . ' [' . $value . ']';
                         break;
                     }
                 }
             }
             $html .= '<input type="text" id="' . $id . '_text" value="' . $val_name . '" class="inputbox" size="' . $size . '" disabled="disabled" />';
             $html .= '<input type="hidden" name="' . $name . '" id="' . $id . '" value="' . $value . '" />';
         } else {
             $html .= '<input type="text" name="' . $name . '" id="' . $id . '" value="' . $value . '" class="inputbox" size="' . $size . '" />';
         }
         $html .= '</td><td style="padding: 0px;"padding-left: 5px;>' . "\n";
         $html .= JHTML::_('select.genericlist', $options, '', $attribs, 'value', 'text', '', '');
         $html .= '</td></tr></table>' . "\n";
     } else {
         if ($size) {
             $attribs .= ' size="' . $size . '"';
         } else {
             $attribs .= ' size="' . (count($options) > 10 ? 10 : count($options)) . '"';
         }
         if ($multiple) {
             if (!is_array($value)) {
                 $value = explode(',', $value);
             }
             $attribs .= ' multiple="multiple"';
         }
         $html = JHTML::_('select.genericlist', $options, '' . $name . '[]', $attribs, 'value', 'text', $value, $id);
     }
     $html = preg_replace('#>\\[\\[\\:(.*?)\\:\\]\\]#si', ' style="\\1">', $html);
     return $html;
 }