Exemplo n.º 1
0
 function getItemList(&$ids = null, $cid = null, &$userid = 0)
 {
     $db = JFactory::getDBO();
     if ($ids === null) {
         require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'classes' . DS . 'flexicontent.categories.php';
         require_once JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'models' . DS . 'category.php';
         $saved_cid = JRequest::getVar('cid', '');
         // save cid ...
         $saved_layout = JRequest::getVar('layout');
         // save layout ...
         $saved_option = JRequest::getVar('option');
         // save option ...
         $saved_view = JRequest::getVar('view');
         // save layout ...
         //$target_layout = $mcats_selection || !$catid ? 'mcats' : '';
         //JRequest::setVar('layout', $target_layout);
         //JRequest::setVar($target_layout=='mcats' ? 'cids' : 'cid', $limit_filters_to_cat ? $catid : 0);
         JRequest::setVar('layout', '');
         JRequest::setVar('cid', $cid);
         JRequest::setVar('option', 'com_flexicontent');
         JRequest::setVar('view', 'category');
         // Get/Create current category model ... according to configuaration set above into the JRequest variables ...
         $catmodel = new FlexicontentModelCategory();
         $category = $catmodel->getCategory($pk = null, $raiseErrors = false, $checkAccess = false);
         $query = $catmodel->_buildQuery(false, $count_total = false);
         $db->setQuery($query, 0, 50000);
         $list = $db->loadColumn();
         $list = is_array($list) ? $list : array();
         // Restore variables
         JRequest::setVar('cid', $saved_cid);
         // restore cid
         JRequest::setVar('layout', $saved_layout);
         // restore layout
         JRequest::setVar('option', $saved_option);
         // restore option
         JRequest::setVar('view', $saved_view);
         // restore view
         return $list;
     } else {
         // Retrieving specific item data
         $query = 'SELECT i.*, ie.*,' . ' CASE WHEN CHAR_LENGTH(i.alias) THEN CONCAT_WS(":", i.id, i.alias) ELSE i.id END as slug,' . ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as categoryslug' . ' FROM #__content AS i' . ' JOIN #__flexicontent_items_ext AS ie on ie.item_id = i.id' . ' JOIN #__categories AS cc ON cc.id = ' . $cid . ' WHERE i.id IN (' . implode(',', $ids) . ')';
         $db->setQuery($query);
         try {
             $list = $db->loadObjectList('id');
         } catch (Exception $e) {
             if ($db->getErrorNum()) {
                 JError::raiseWarning($db->getErrorNum(), $db->getErrorMsg() . "<br />" . $query . "<br />");
             }
             return array();
         }
         $list = is_array($list) ? $list : array();
         return $list;
     }
 }