protected function getInput() { require_once JPATH_SITE . '/components/com_javoice/models/items.php'; require_once JPATH_SITE . '/components/com_javoice/models/forums.php'; $jaVoiceModelItems = new JAVoiceModelItems(); $model_forums = new JAVoiceModelforums(); $class = (string) $this->element['class']; $multiple = $this->element['multiple'] ? 'multiple="multiple"' : ''; $types = $jaVoiceModelItems->getVoiceTypes(" AND vt.published = 1", "vt.ordering"); $forums = array(); $forums[0] = new stdClass(); $forums[0]->id = '1'; $forums[0]->title = JText::_("Select All"); foreach ($types as $type) { array_push($forums, JHTML::_('select.optgroup', $type->title, 'id', 'title')); $where_more = ' and f.published=1 and ft.voice_types_id=' . $type->id; $join = 'INNER JOIN #__jav_forums_has_voice_types as ft ON f.id=ft.forums_id'; $results = $model_forums->getItems($where_more, 100, 0, 'f.ordering', '', $join); //array_push($forums, $optgroup); foreach ($results as $result) { $result->id = $type->id . '_' . $result->id; array_push($forums, $result); } array_push($forums, JHTML::_('select.optgroup', $type->title, 'id', 'title')); } //jexit(); $out = JHTML::_('select.genericlist', $forums, $this->name, 'class="inputbox ' . $class . '" ' . $multiple, 'id', 'title', $this->value); return $out; }
function getList(&$params) { $mainframe = JFactory::getApplication(); $db = JFactory::getDBO(); $user = JFactory::getUser(); $limit = intval($params->get('numberitems', 5)); $displaymode = intval($params->get('displaymode', 0)); $where_more = ''; $order = ''; if (!$displaymode) { $order = 'i.create_date desc'; } else { $order = 'i.total_vote_up desc'; } /*$forums_id = 0; if($params->get ( 'forums', 0 )){ $forums_id = $params->get ( 'forums', 0 ); if(isset($forums_id) && is_array($forums_id)) $forums_id = implode(',', $forums_id); } if($forums_id)*/ $forums_id = $params->get('forums', ''); $str_forums_id = array(); if ($forums_id && is_array($forums_id)) { foreach ($forums_id as $fid) { if ($fid == 1) { $str_forums_id = array(); break; } $fid = explode('_', $fid); $str_forums_id[$fid[0]][] = $fid[1]; } } if ($str_forums_id) { foreach ($str_forums_id as $k => $row) { if ($row) { $forums = implode(',', $row); $subwhere[] = " ( i.voice_types_id = '{$k}' and i.forums_id in (" . $forums . ") )"; } } $where_more .= ' and ' . implode(' or ', $subwhere); } /* BEGIN: Show items are activing Only */ $model_status = new javoiceModelvoicetypesstatus(); $list_status = $model_status->getListTreeStatus($params->get('voicetypes', 5)); $status_ids = array(0); if ($list_status) { foreach ($list_status as $k => $status) { if ($status->parent_id != 0 && ($status->allow_voting == 1 || $status->allow_voting == -1 && $list_status[$status->parent_id]->allow_voting == 1) || JRequest::getWord('layout') == 'item') { $status_ids[] = $status->id; } } } $where_more .= " and ( i.voice_type_status_id in (" . implode(',', $status_ids) . "))"; $where_more .= ' and i.published=1'; $join = " LEFT JOIN #__jav_voice_type_status as s ON s.id=i.voice_type_status_id"; $fields_join = ' s.title as status_title, s.class_css as status_class_css, s.allow_voting as status_allow_voting, s.parent_id as status_parent_id'; $model = new JAVoiceModelItems(); $items = $model->getItems($where_more, $order, 0, $limit, $fields_join, $join); return $items; }