Ejemplo n.º 1
0
 function &getList()
 {
     $db = oseDB::instance();
     $search = JRequest::getString('search', null);
     $search = JString::strtolower($search);
     $msc_id = JRequest::getInt('msc_id', 0);
     $start = JRequest::getInt('start', 0);
     $limit = JRequest::getInt('limit', 20);
     $levellimit = JRequest::getInt('levellimit', 10);
     $where = array();
     $where[] = 'rok.`folder` = 1';
     $where[] = 'rok.`published` = 1';
     if ($search) {
         $searchQuery = ' LOWER(rok.`name`) LIKE ' . $db->Quote('%' . $search . '%');
         $where[] = $searchQuery;
     }
     $access = oseMscJaccess::get_msc_aid(25);
     if (!empty($access)) {
         //$where[] = "m.access <= {$access} ";
     }
     //Added in V 4.4, menu access levels
     // Generate where query
     $where = count($where) ? ' WHERE (' . implode(') AND (', $where) . ')' : '';
     $query = ' SELECT rok.*' . ' FROM `#__rokdownloads` AS rok' . $where . ' ORDER BY rok.id';
     $db->setQuery($query);
     //oseExit($db->_sql);
     $rows = oseDB::loadList('obj');
     $total = count($rows);
     // slice out elements based on limits
     $list = array_slice($rows, $start, $limit);
     foreach ($list as $item) {
         $obj = oseRegistry::call('content')->getInstance('msc')->getItem('rokdownload', 'category', $item->id, 'msc', $msc_id, null, 'obj');
         $item->type = empty($obj->content_type) ? 'category' : $obj->content_type;
         $controlled = empty($obj) ? 0 : $obj->status;
         if ($controlled == '1') {
             $item->controlled = JText::_('SHOW_TO_MEMBERS');
         } elseif ($controlled == '-1') {
             $item->controlled = JText::_('HIDE_TO_MEMBERS');
         } else {
             $item->controlled = JText::_('SHOW_TO_ALL');
         }
     }
     $items = array_values($list);
     $result = array();
     $result['total'] = $total;
     $result['results'] = $items;
     return $result;
 }
Ejemplo n.º 2
0
 function &getList()
 {
     $db = oseDB::instance();
     $search = JRequest::getString('search', null);
     $search = JString::strtolower($search);
     $msc_id = JRequest::getInt('msc_id', 0);
     $start = JRequest::getInt('start', 0);
     $limit = JRequest::getInt('limit', 20);
     $levellimit = JRequest::getInt('levellimit', 10);
     $levellimit = empty($levellimit) ? 10 : $levellimit;
     $where = array();
     $where[] = ' hwd.`published` = 1';
     if ($search) {
         $searchQuery = ' LOWER(hwd.`category_name`) LIKE ' . $db->Quote('%' . $search . '%');
         $where[] = $searchQuery;
         $where = count($where) ? ' WHERE (' . implode(') AND (', $where) . ')' : '';
         $query = ' SELECT hwd.id ' . ' FROM `#__hwdvidscategories` AS hwd' . $where . ' ORDER BY hwd.`id`';
         $db->setQuery($query);
         $search_rows = $db->loadResultArray();
     }
     $access = oseMscJaccess::get_msc_aid(25);
     if (!empty($access)) {
         //$where[] = "m.access <= {$access} ";
     }
     //Added in V 4.4, menu access levels
     // Generate where query
     $query = ' SELECT hwd.*' . ' FROM `#__hwdvidscategories` AS hwd' . ' WHERE hwd.`published` = 1' . ' ORDER BY hwd.`id`';
     $db->setQuery($query);
     //oseExit($db->_sql);
     $rows = oseDB::loadList('obj');
     $total = count($rows);
     // establish the hierarchy of the cats
     $children = array();
     // first pass - collect children
     if (!empty($rows)) {
         foreach ($rows 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
     $list = self::treerecurse(0, '', array(), $children, max(0, $levellimit - 1));
     // eventually only pick out the searched items
     if ($search) {
         $list1 = array();
         $search_rows = count($search_rows) > 0 ? $search_rows : array();
         foreach ($search_rows as $sid) {
             foreach ($list as $item) {
                 if ($item->id == $sid) {
                     $list1[] = $item;
                 }
             }
         }
         // replace full list with found items
         $list = $list1;
     }
     // slice out elements based on limits
     $list = array_slice($list, $start, $limit);
     foreach ($list as $item) {
         $obj = oseRegistry::call('content')->getInstance('msc')->getItem('hwdvideo', 'category', $item->id, 'msc', $msc_id, null, 'obj');
         $item->type = empty($obj->content_type) ? 'category' : $obj->content_type;
         $controlled = empty($obj) ? 0 : $obj->status;
         if ($controlled == '1') {
             $item->controlled = JText::_('SHOW_TO_MEMBERS');
         } elseif ($controlled == '-1') {
             $item->controlled = JText::_('HIDE_TO_MEMBERS');
         } else {
             $item->controlled = JText::_('SHOW_TO_ALL');
         }
     }
     $items = array_values($list);
     $result = array();
     $result['total'] = $total;
     $result['results'] = $items;
     return $result;
 }