Exemple #1
0
 public function display($tpl = null)
 {
     $app = Factory::getApplication();
     $component = FreeComponentSite::getInstance();
     $model = $component->getModel('Item');
     $params = $app->getParams('com_osdownloads');
     $id = (int) $params->get("document_id");
     $itemId = (int) $app->input->get('Itemid');
     if (JRequest::getVar("id")) {
         $id = (int) JRequest::getVar("id");
     }
     $item = $model->getItem($id);
     if (empty($item)) {
         JError::raiseWarning(404, JText::_("COM_OSDOWNLOADS_THIS_DOWNLOAD_ISNT_AVAILABLE"));
         return;
     }
     $paths = null;
     $this->buildBreadcrumbs($paths, $item);
     // Load the extension
     $component->loadLibrary();
     $isPro = $component->isPro();
     // Add the agreementLink property
     if (!empty($item)) {
         $item->agreementLink = '';
         if ((bool) $item->require_agree) {
             $item->agreementLink = JRoute::_('index.php?option=com_content&view=article&id=' . (int) $item->agreement_article_id);
         }
     }
     $this->assignRef("item", $item);
     $this->assignRef("itemId", $itemId);
     $this->assignRef("paths", $paths);
     $this->assignRef("params", $params);
     $this->assignRef("isPro", $isPro);
     parent::display($tpl);
 }
 public function display($tpl = null)
 {
     global $option;
     $app = JFactory::getApplication();
     if (!isset($this->flt)) {
         $this->flt = new stdClass();
     }
     $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'int');
     $limitstart = $app->getUserStateFromRequest('osdownloads.request.limitstart', 'limitstart', 0, 'int');
     $this->flt->search = $app->getUserStateFromRequest('osdownloads.email.request.search', 'search', "");
     $this->flt->cate_id = $app->getUserStateFromRequest('osdownloads.email.request.cate_id', 'cate_id');
     $filter_order = $app->getUserStateFromRequest("osdownloads.email.filter_order", 'filter_order', 'email.id', 'cmd');
     $filter_order_Dir = $app->getUserStateFromRequest("osdownloads.email.filter_order_Dir", 'filter_order_Dir', '', 'word');
     $filter_confirmed = $app->getUserStateFromRequest("osdownloads.email.filter_confirmed", 'filter_confirmed', '-1', 'int');
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $query->select("email.*, document.name AS doc_name, cate.title AS cate_name");
     $query->from("#__osdownloads_emails email");
     $query->join("LEFT", "#__osdownloads_documents document ON (email.document_id = document.id)");
     $query->join("LEFT", "#__categories cate ON (cate.id = document.cate_id)");
     if ($this->flt->search) {
         $query->where("email.email LIKE '%{$this->flt->search}%' OR document.name LIKE '%{$this->flt->search}%'");
     }
     if ($this->flt->cate_id) {
         $query->where("cate.id = {$this->flt->cate_id}");
     }
     if ($filter_confirmed >= 0) {
         $query->where('confirmed = ' . $db->quote($filter_confirmed));
     }
     $query->order(" {$filter_order}  {$filter_order_Dir}");
     $db->setQuery($query);
     $db->query();
     $total = $db->getNumRows();
     jimport('joomla.html.pagination');
     $pagination = new JPagination($total, $limitstart, $limit);
     $db->setQuery($query, $pagination->limitstart, $pagination->limit);
     $items = (array) $db->loadObjectList();
     $lists = array();
     $lists['order_Dir'] = $filter_order_Dir;
     $lists['order'] = $filter_order;
     $lists['filter_confirmed'] = $filter_confirmed;
     // Load the extension
     $extension = Alledia\Framework\Factory::getExtension('OSDownloads', 'component');
     $extension->loadLibrary();
     $this->assignRef('lists', $lists);
     $this->assignRef("items", $items);
     $this->assignRef("pagination", $pagination);
     $this->assignRef("extension", $extension);
     $this->assign("isPro", $extension->isPro());
     $this->addToolbar();
     parent::display($tpl);
 }
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $params = clone $app->getParams('com_osdownloads');
     $categoryIDs = (array) $params->get("category_id");
     $includeChildFiles = (bool) $params->get('include_child_files', 0);
     $showChildCategories = (bool) $params->get('show_child_categories', 1);
     // Load the extension
     $extension = Alledia\Framework\Factory::getExtension('OSDownloads', 'component');
     $extension->loadLibrary();
     $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'int');
     $limitstart = $app->getUserStateFromRequest('osdownloads.request.limitstart', 'limitstart', 0, 'int');
     // Paths
     $paths = array();
     $id = JRequest::getVar("id", null, 'default', 'int');
     if (empty($id)) {
         if (count($categoryIDs) == 1) {
             $id = $categoryIDs[0];
         }
     }
     if (!empty($id)) {
         $this->buildPath($paths, $id);
         $categoryIDs = (array) $id;
     }
     $categoryIDsStr = implode(',', $categoryIDs);
     $model = JModelLegacy::getInstance('OSDownloadsModelItem');
     $query = $model->getItemQuery();
     $query->select('cat.access as cat_access');
     if ($includeChildFiles) {
         $query->where("(cate_id IN ({$categoryIDsStr}) OR cat.parent_id IN ({$categoryIDsStr}))");
     } else {
         $query->where("cate_id IN ({$categoryIDsStr})");
     }
     $query->order('doc.ordering');
     $db->setQuery($query);
     // Pagination
     $db->setQuery($query);
     $db->query();
     $total = $db->getNumRows();
     jimport('joomla.html.pagination');
     $pagination = new JPagination($total, $limitstart, $limit);
     // Items
     $db->setQuery($query, $pagination->limitstart, $pagination->limit);
     $items = $db->loadObjectList();
     $user = JFactory::getUser();
     $groups = $user->getAuthorisedViewLevels();
     if (!isset($items) || count($items) && !in_array($items[0]->cat_access, $groups)) {
         JError::raiseWarning(404, JText::_("COM_OSDOWNLOADS_THIS_CATEGORY_ISNT_AVAILABLE"));
         return;
     }
     // Categories
     $extraWhere = '';
     if ($showChildCategories) {
         $extraWhere = " OR c.parent_id IN ({$categoryIDsStr}) ";
     }
     $groupsStr = implode(',', $groups);
     $query = "SELECT *\n                  FROM `#__categories` AS c\n                  WHERE extension='com_osdownloads'\n                    AND published = 1\n                    AND (id IN ({$categoryIDsStr})\n                        {$extraWhere}\n                    )\n                  ORDER BY c.lft ASC";
     $db->setQuery($query);
     $categories = $db->loadObjectList();
     // Category filter
     $showCategoryFilter = $params->get('show_category_filter', false);
     $this->buildBreadcrumbs($paths);
     $this->assignRef("categories", $categories);
     $this->assignRef("showCategoryFilter", $showCategoryFilter);
     $this->assignRef("items", $items);
     $this->assignRef("paths", $paths);
     $this->assignRef("pagination", $pagination);
     $this->assign("isPro", $extension->isPro());
     parent::display($tpl);
 }