static function BuildNest(&$data, $idfield, $parfield, $orderfield, $level_start = 0) { self::$id_field = $idfield; self::$par_field = $parfield; self::$order_field = $orderfield; self::ArrayObjSort($data, $orderfield); self::$data = $data; self::$result = array(); $lft = 0; self::_build_tree(0, $lft, $level_start); self::ArrayObjSort(self::$result, 'lft'); return self::$result; }
function display($tpl = null) { JToolBarHelper::title(JText::_("KNOWLEDGE_BASE_ARTICLES"), 'fss_kb'); JToolBarHelper::custom('resetviews', 'resetviews', 'resetviews', 'KB_RESET_VIEWS', false); JToolBarHelper::custom('resetrating', 'resetrating', 'resetrating', 'KB_RESET_RATING', false); JToolBarHelper::custom('autosort', 'autosort', 'autosort', 'Auto Sort', false); JToolBarHelper::divider(); JToolBarHelper::deleteList(); JToolBarHelper::editList(); JToolBarHelper::addNew(); JToolBarHelper::cancel('cancellist'); FSSAdminHelper::DoSubToolbar(); $lists = $this->get('Lists'); $this->data = $this->get('Data'); $this->pagination = $this->get('Pagination'); $query = 'SELECT id, title, parcatid, ordering FROM #__fss_kb_cat ORDER BY ordering'; $db = JFactory::getDBO(); $categories[] = JHTML::_('select.option', '0', JText::_("SELECT_CATEGORY"), 'id', 'title'); $db->setQuery($query); // nest the data $data = $db->loadObjectList(); require_once JPATH_SITE . DS . 'components' . DS . 'com_fss' . DS . 'helper' . DS . 'nested.php'; $data = FSS_Nested_Helper::BuildNest($data, "id", "parcatid", "ordering"); foreach ($data as &$temp) { $temp->title = str_repeat("|— ", $temp->level) . $temp->title; } $categories = array_merge($categories, $data); $lists['cats'] = JHTML::_('select.genericlist', $categories, 'kb_cat_id', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'id', 'title', $lists['kb_cat_id']); $categories = array(); $categories[] = JHTML::_('select.option', '-1', JText::_("IS_PUBLISHED"), 'id', 'title'); $categories[] = JHTML::_('select.option', '1', JText::_("PUBLISHED"), 'id', 'title'); $categories[] = JHTML::_('select.option', '0', JText::_("UNPUBLISHED"), 'id', 'title'); $lists['published'] = JHTML::_('select.genericlist', $categories, 'ispublished', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'id', 'title', $lists['ispublished']); $query = 'SELECT id, title FROM #__fss_prod ORDER BY ordering'; $db = JFactory::getDBO(); $categories = array(); $categories[] = JHTML::_('select.option', '0', JText::_("SELECT_PRODUCT"), 'id', 'title'); $db->setQuery($query); $categories = array_merge($categories, $db->loadObjectList()); $lists['prods'] = JHTML::_('select.genericlist', $categories, 'prod_id', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'id', 'title', $lists['prod_id']); $this->lists = $lists; parent::display($tpl); }
function LookupInput($field, $item) { if (property_exists($field, "lookup_table") && $field->lookup_table) { $query = "SELECT *\n\t\t\t\t FROM {$field->lookup_table} \n\t\t\t\t ORDER BY {$field->lookup_order}"; $db = JFactory::getDBO(); $db->setQuery($query); $sections = $db->loadObjectList(); if (!empty($field->lookup_nested) && $field->lookup_nested) { require_once JPATH_SITE . DS . 'components' . DS . 'com_fss' . DS . 'helper' . DS . 'nested.php'; $sections = FSS_Nested_Helper::BuildNest($sections, "id", "parcatid", "ordering"); $df = $field->lookup_title; foreach ($sections as &$temp) { $temp->{$df} = str_repeat("|— ", $temp->level) . $temp->{$df}; } } } else { $sections = array(); } if (property_exists($field, 'lookup_extra')) { $extra = array(); foreach ($field->lookup_extra as $key => $value) { $obj = new stdClass(); $id = $field->lookup_id; $title = $field->lookup_title; $obj->{$id} = $key; $obj->{$title} = $value; $extra[] = $obj; } $sections = array_merge($extra, $sections); } return JHTML::_('select.genericlist', $sections, $field->input_name, 'class="inputbox" size="1" ', $field->lookup_id, $field->lookup_title, $item[$field->field]); }
function display($tpl = null) { if (JRequest::getString('task') == "prods") { return $this->displayProds(); } $kbart = $this->get('Data'); $isNew = $kbart->id < 1; $text = $isNew ? JText::_("NEW") : JText::_("EDIT"); JToolBarHelper::title(JText::_("KNOWLEDGE_BASE_ARTICLE") . ': <small><small>[ ' . $text . ' ]</small></small>', 'fss_kb'); JToolBarHelper::apply(); JToolBarHelper::save(); JToolBarHelper::save2new(); if ($isNew) { JToolBarHelper::cancel(); } else { // for existing items the button is renamed `close` JToolBarHelper::cancel('cancel', 'Close'); } FSSAdminHelper::DoSubToolbar(); $this->kbart = $kbart; $query = 'SELECT id, title, parcatid, ordering' . ' FROM #__fss_kb_cat' . ' ORDER BY ordering'; $db = JFactory::getDBO(); $db->setQuery($query); $sections[] = JHTML::_('select.option', '-1', '- ' . JText::_("SELECT_CATEGORY") . ' -', 'id', 'title'); $sections[] = JHTML::_('select.option', '0', JText::_("UNCATEGORIZED"), 'id', 'title'); $data = $db->loadObjectList(); // nest the data require_once JPATH_SITE . DS . 'components' . DS . 'com_fss' . DS . 'helper' . DS . 'nested.php'; $data = FSS_Nested_Helper::BuildNest($data, "id", "parcatid", "ordering"); foreach ($data as &$temp) { $temp->title = str_repeat("|— ", $temp->level) . $temp->title; } $sections = array_merge($sections, $data); $lists['catid'] = JHTML::_('select.genericlist', $sections, 'kb_cat_id', 'class="inputbox" size="1" ', 'id', 'title', intval($kbart->kb_cat_id)); $lists['allprod'] = JHTML::_('select.booleanlist', 'allprods', array('class' => "inputbox", 'size' => "1", 'onclick' => "DoAllProdChange();"), intval($kbart->allprods)); $query = "SELECT * FROM #__fss_prod ORDER BY title"; $db->setQuery($query); $products = $db->loadObjectList(); $query = "SELECT * FROM #__fss_kb_art_prod WHERE kb_art_id = " . FSSJ3Helper::getEscaped($db, $kbart->id); $db->setQuery($query); $selprod = $db->loadAssocList('prod_id'); $this->assign('allprods', $kbart->allprods); $prodcheck = ""; foreach ($products as $product) { $checked = false; if (array_key_exists($product->id, $selprod)) { $prodcheck .= "<input type='checkbox' name='prod_" . $product->id . "' checked />" . $product->title . "<br>"; } else { $prodcheck .= "<input type='checkbox' name='prod_" . $product->id . "' />" . $product->title . "<br>"; } } $lists['products'] = $prodcheck; if (!$isNew) { $db = JFactory::getDBO(); $query = 'SELECT *' . ' FROM #__fss_kb_attach' . ' WHERE kb_art_id = "' . FSSJ3Helper::getEscaped($db, $kbart->id) . '"' . ' ORDER BY title '; $db->setQuery($query); $lists['files'] = $db->loadAssocList(); } else { $lists['files'] = array(); } $query = "SELECT a.id, a.title FROM #__fss_kb_art_related as r LEFT JOIN #__fss_kb_art as a ON r.related_id = a.id WHERE kb_art_id = " . FSSJ3Helper::getEscaped($db, $kbart->id); $db->setQuery($query); $lists['related'] = $db->loadAssocList(); $this->lists = $lists; parent::display($tpl); }
function display($tpl = null) { $kbcat = $this->get('Data'); $isNew = $kbcat->id < 1; $text = $isNew ? JText::_("NEW") : JText::_("EDIT"); JToolBarHelper::title(JText::_("KNOWLEDGE_BASE_CATEGORY") . ': <small><small>[ ' . $text . ' ]</small></small>', 'fss_categories'); JToolBarHelper::apply(); JToolBarHelper::save(); JToolBarHelper::save2new(); if ($isNew) { JToolBarHelper::cancel(); } else { // for existing items the button is renamed `close` JToolBarHelper::cancel('cancel', 'Close'); } FSSAdminHelper::DoSubToolbar(); $db = JFactory::getDBO(); $this->kbcat = $kbcat; $path = JPATH_SITE . DS . 'images' . DS . 'fss' . DS . 'kbcats'; if (!file_exists($path)) { mkdir($path, 0777, true); } $files = JFolder::files($path, '(.png$|.jpg$|.jpeg$|.gif$)'); $sections = array(); $sections[] = JHTML::_('select.option', '', JText::_("NO_IMAGE"), 'id', 'title'); foreach ($files as $file) { $sections[] = JHTML::_('select.option', $file, $file, 'id', 'title'); } $lists['images'] = JHTML::_('select.genericlist', $sections, 'image', 'class="inputbox" size="1" ', 'id', 'title', $kbcat->image); $query = 'SELECT * ' . ' FROM #__fss_kb_cat'; if ($kbcat->id) { $query .= " WHERE id != '" . FSSJ3Helper::getEscaped($db, $kbcat->id) . "' "; } $query .= ' ORDER BY ordering'; $db->setQuery($query); $sections = array(); $sections[] = JHTML::_('select.option', '0', JText::_("NO_PARENT_CATEGORY"), 'id', 'title'); $data = $db->loadObjectList(); // nest the data require_once JPATH_SITE . DS . 'components' . DS . 'com_fss' . DS . 'helper' . DS . 'nested.php'; $data = FSS_Nested_Helper::BuildNest($data, "id", "parcatid", "ordering"); foreach ($data as &$temp) { $temp->title = str_repeat("|— ", $temp->level) . $temp->title; } $sections = array_merge($sections, $data); $lists['parcatid'] = JHTML::_('select.genericlist', $sections, 'parcatid', 'class="inputbox" size="1" ', 'id', 'title', intval($kbcat->parcatid)); $query = "SELECT * FROM #__fss_prod ORDER BY title"; $db->setQuery($query); $products = $db->loadObjectList(); $selprod = array(); if ($kbcat->prodids == "") { $kbcat->allprods = 1; } else { $kbcat->allprods = 0; } $this->allprods = $kbcat->allprods; $selprod = explode(";", $kbcat->prodids); $prodcheck = ""; foreach ($products as $product) { $checked = false; if (in_array($product->id, $selprod)) { $prodcheck .= "<input type='checkbox' name='prod_" . $product->id . "' checked />" . $product->title . "<br>"; } else { $prodcheck .= "<input type='checkbox' name='prod_" . $product->id . "' />" . $product->title . "<br>"; } } $lists['products'] = $prodcheck; $lists['allprod'] = JHTML::_('select.booleanlist', 'allprods', array('class' => "inputbox", 'size' => "1", 'onclick' => "DoAllProdChange();"), intval($this->allprods)); $this->lists = $lists; parent::display($tpl); }