Exemplo n.º 1
0
 private function parseCategoryDownloads($objCategory, $downloadOrderBy, $downloadOrderDirection, $downloadLimitOffset, $categoryOrderBy, $categoryOrderDirection, $categoryLimitOffset, $searchTerm)
 {
     global $_ARRAYLANG, $_LANGID, $_CONFIG;
     $nr = 0;
     $arrDownloadOrder = $objCategory->getAssociatedDownloadIds();
     $objFWUser = \FWUser::getFWUserObject();
     $sortOrder = $this->downloadsSortingOptions[$this->arrConfig['downloads_sorting_order']];
     $arrSort = empty($downloadOrderBy) ? $sortOrder : array_merge(array($downloadOrderBy => $downloadOrderDirection), $sortOrder);
     $objDownload = new Download();
     $objDownload->loadDownloads(array('category_id' => $objCategory->getId()), $searchTerm, $arrSort, null, $_CONFIG['corePagingLimit'], $downloadLimitOffset, true);
     $downloadsAvailable = $objDownload->EOF ? false : true;
     while (!$objDownload->EOF) {
         //            if (!\Permission::checkAccess(143, 'static', true) && !$objDownload->getVisibility() && $objDownload->getOwnerId() != $objFWUser->objUser->getId()) {
         //                $objDownload->next();
         //                continue;
         //            }
         // parse select checkbox & order box
         if ((\Permission::checkAccess(143, 'static', true) || !$objCategory->getManageFilesAccessId() || \Permission::checkAccess($objCategory->getManageFilesAccessId(), 'dynamic', true) || $objCategory->getOwnerId() == $objFWUser->objUser->getId()) && $objCategory->getId()) {
             // select checkbox
             $this->objTemplate->setVariable('DOWNLOADS_DOWNLOAD_ID', $objDownload->getId());
             $this->objTemplate->parse('downloads_download_checkbox');
             // order box
             $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ID' => $objDownload->getId(), 'DOWNLOADS_DOWNLOAD_ORDER' => $arrDownloadOrder[$objDownload->getId()]));
             $this->objTemplate->parse('downloads_download_orderbox');
             $this->objTemplate->hideBlock('downloads_download_no_orderbox');
             $this->objTemplate->parse('downloads_download_no_save_button');
         } else {
             // select checkbox
             $this->objTemplate->hideBlock('downloads_download_checkbox');
             $this->objTemplate->hideBlock('downloads_download_action_dropdown');
             // order box
             $this->objTemplate->setVariable('DOWNLOADS_DOWNLOAD_ORDER', $objCategory->getId() ? $arrDownloadOrder[$objDownload->getId()] : $objDownload->getOrder());
             $this->objTemplate->parse('downloads_download_no_orderbox');
             $this->objTemplate->hideBlock('downloads_download_orderbox');
             $this->objTemplate->hideBlock('downloads_download_no_save_button');
         }
         // parse status link and modify button
         if (\Permission::checkAccess(143, 'static', true) || $objCategory->getId() && (!$objCategory->getManageFilesAccessId() || \Permission::checkAccess($objCategory->getManageFilesAccessId(), 'dynamic', true) || $objCategory->getModifyAccessByOwner() && $objCategory->getOwnerId() == $objFWUser->objUser->getId()) || $objDownload->getOwnerId() == $objFWUser->objUser->getId()) {
             $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_CATEGORY_SORT' => $categoryOrderDirection, 'DOWNLOADS_DOWNLOAD_CATEGORY_SORT_BY' => $categoryOrderBy, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_SORT' => $downloadOrderDirection, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_BY' => $downloadOrderBy, 'DOWNLOADS_DOWNLOAD_CATEGORY_OFFSET' => $categoryLimitOffset, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_OFFSET' => $downloadLimitOffset, 'DOWNLOADS_DOWNLOAD_ID' => $objDownload->getId(), 'DOWNLOADS_DOWNLOAD_CATEGORY_PARENT_ID' => $objCategory->getId(), 'DOWNLOADS_DOWNLOAD_SWITCH_STATUS_DESC' => $objDownload->getActiveStatus() ? $_ARRAYLANG['TXT_DOWNLOADS_DEACTIVATE_DOWNLOAD_DESC'] : $_ARRAYLANG['TXT_DOWNLOADS_ACTIVATE_DOWNLOAD_DESC'], 'DOWNLOADS_DOWNLOAD_SWITCH_STATUS_IMG_DESC' => $objDownload->getActiveStatus() ? $_ARRAYLANG['TXT_DOWNLOADS_DEACTIVATE_DOWNLOAD_DESC'] : $_ARRAYLANG['TXT_DOWNLOADS_ACTIVATE_DOWNLOAD_DESC']));
             $this->objTemplate->parse('downloads_download_status_link_open');
             $this->objTemplate->touchBlock('downloads_download_status_link_close');
             // parse modify icon
             $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_CATEGORY_SORT' => $categoryOrderDirection, 'DOWNLOADS_DOWNLOAD_CATEGORY_SORT_BY' => $categoryOrderBy, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_SORT' => $downloadOrderDirection, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_BY' => $downloadOrderBy, 'DOWNLOADS_DOWNLOAD_CATEGORY_OFFSET' => $categoryLimitOffset, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_OFFSET' => $downloadLimitOffset, 'DOWNLOADS_DOWNLOAD_ID' => $objDownload->getId(), 'DOWNLOADS_DOWNLOAD_CATEGORY_PARENT_ID' => $objCategory->getId()));
             $this->objTemplate->parse('downloads_download_function_modify_link');
             $this->objTemplate->hideBlock('downloads_download_function_no_modify_link');
             // parse modify link on name attribute
             $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_CATEGORY_SORT' => $categoryOrderDirection, 'DOWNLOADS_DOWNLOAD_CATEGORY_SORT_BY' => $categoryOrderBy, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_SORT' => $downloadOrderDirection, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_BY' => $downloadOrderBy, 'DOWNLOADS_DOWNLOAD_CATEGORY_OFFSET' => $categoryLimitOffset, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_OFFSET' => $downloadLimitOffset, 'DOWNLOADS_DOWNLOAD_ID' => $objDownload->getId(), 'DOWNLOADS_DOWNLOAD_CATEGORY_PARENT_ID' => $objCategory->getId()));
             $this->objTemplate->parse('downloads_download_modify_link_open');
             $this->objTemplate->touchBlock('downloads_download_modify_link_close');
         } else {
             $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_SWITCH_STATUS_DESC' => $objDownload->getActiveStatus() ? $_ARRAYLANG['TXT_DOWNLOADS_ACTIVE'] : $_ARRAYLANG['TXT_DOWNLOADS_INACTIVE'], 'DOWNLOADS_DOWNLOAD_SWITCH_STATUS_IMG_DESC' => $objDownload->getActiveStatus() ? $_ARRAYLANG['TXT_DOWNLOADS_ACTIVE'] : $_ARRAYLANG['TXT_DOWNLOADS_INACTIVE']));
             $this->objTemplate->hideBlock('downloads_download_status_link_open');
             $this->objTemplate->hideBlock('downloads_download_status_link_close');
             // hide modify icon
             $this->objTemplate->touchBlock('downloads_download_function_no_modify_link');
             $this->objTemplate->hideBlock('downloads_download_function_modify_link');
             // hide modify linke on name attribute
             $this->objTemplate->hideBlock('downloads_download_modify_link_open');
             $this->objTemplate->hideBlock('downloads_download_modify_link_close');
         }
         // parse download link
         if (!$objDownload->getAccessId() || $objDownload->getOwnerId() == $objFWUser->objUser->getId() || \Permission::checkAccess($objDownload->getAccessId(), 'dynamic', true) || \Permission::checkAccess(143, 'static', true) || $objCategory->getId() && (!$objCategory->getManageFilesAccessId() || \Permission::checkAccess($objCategory->getManageFilesAccessId(), 'dynamic', true) || $objCategory->getModifyAccessByOwner() && $objCategory->getOwnerId() == $objFWUser->objUser->getId())) {
             $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ID' => $objDownload->getId(), 'DOWNLOADS_DOWNLOAD_DOWNLOAD_ICON' => $objDownload->getIcon(true), 'DOWNLOADS_DOWNLOAD_SOURCE' => htmlentities($objDownload->getSource(), ENT_QUOTES, CONTREXX_CHARSET)));
             $this->objTemplate->parse('downloads_download_function_download_link');
             $this->objTemplate->hideBlock('downloads_download_function_no_download_link');
         } else {
             $this->objTemplate->hideBlock('downloads_download_function_download_link');
             $this->objTemplate->touchBlock('downloads_download_function_no_download_link');
         }
         // parse unlink button
         if (\Permission::checkAccess(143, 'static', true) || $objCategory->getId() && (!$objCategory->getManageFilesAccessId() || \Permission::checkAccess($objCategory->getManageFilesAccessId(), 'dynamic', true) || $objCategory->getOwnerId() == $objFWUser->objUser->getId()) || $objDownload->getOwnerId() == $objFWUser->objUser->getId()) {
             $this->objTemplate->setVariable(array('TXT_DOWNLOADS_UNLINK' => $_ARRAYLANG['TXT_DOWNLOADS_UNLINK'], 'DOWNLOADS_DOWNLOAD_NAME_JS' => htmlspecialchars($objDownload->getName(), ENT_QUOTES, CONTREXX_CHARSET)));
             // parse delete icon
             $this->objTemplate->parse('downloads_download_function_unlink_link');
             $this->objTemplate->hideBlock('downloads_download_function_no_unlink_link');
         } else {
             // hide delete icon
             $this->objTemplate->touchBlock('downloads_download_function_no_unlink_link');
             $this->objTemplate->hideBlock('downloads_download_function_unlink_link');
         }
         $description = $objDownload->getDescription();
         if (strlen($description) > 100) {
             $description = substr($description, 0, 97) . '...';
         }
         $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ID' => $objDownload->getId(), 'DOWNLOADS_DOWNLOAD_NAME' => htmlentities($objDownload->getName(), ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_DOWNLOAD_DESCRIPTION' => htmlentities($description, ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_DOWNLOAD_OWNER' => $this->getParsedUsername($objDownload->getOwnerId()), 'DOWNLOADS_DOWNLOAD_DOWNLOADED' => $objDownload->getDownloadCount(), 'DOWNLOADS_DOWNLOAD_VIEWED' => $objDownload->getViewCount(), 'DOWNLOADS_DOWNLOAD_STATUS_LED' => $objDownload->getActiveStatus() ? 'led_green.gif' : 'led_red.gif', 'DOWNLOADS_DOWNLOAD_ROW_CLASS' => $nr++ % 2 ? 'row1' : 'row2'));
         $this->objTemplate->parse('downloads_download_list');
         $objDownload->next();
     }
     if ($downloadsAvailable && !empty($this->parentCategoryId)) {
         $this->objTemplate->setVariable('TXT_DOWNLOADS_OF_CATEGORY', sprintf($_ARRAYLANG['TXT_DOWNLOADS_DOWNLOADS_OF_CATEGORY'], '„' . htmlentities($objCategory->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET) . '“'));
     } else {
         $this->objTemplate->setVariable('TXT_DOWNLOADS_ALL_DOWNLOADS', $_ARRAYLANG['TXT_DOWNLOADS_ALL_DOWNLOADS']);
     }
     if ($downloadsAvailable) {
         $this->objTemplate->setVariable(array('DOWNLOADS_CONFIRM_UNLINK_DOWNLOADS_TXT' => preg_replace('#\\n#', '\\n', addslashes($_ARRAYLANG['TXT_DOWNLOADS_CONFIRM_UNLINK_DOWNLOADS'])), 'TXT_SAVE_CHANGES_DOWNLOADS' => $_ARRAYLANG['TXT_SAVE_CHANGES'], 'TXT_DOWNLOADS_CHECK_ALL' => $_ARRAYLANG['TXT_DOWNLOADS_CHECK_ALL'], 'TXT_DOWNLOADS_UNCHECK_ALL' => $_ARRAYLANG['TXT_DOWNLOADS_UNCHECK_ALL'], 'TXT_DOWNLOADS_SELECT_ACTION' => $_ARRAYLANG['TXT_DOWNLOADS_SELECT_ACTION'], 'TXT_DOWNLOADS_ORDER' => $_ARRAYLANG['TXT_DOWNLOADS_ORDER'], 'TXT_DOWNLOADS_UNLINK_MULTI' => $_ARRAYLANG['TXT_DOWNLOADS_UNLINK_MULTI']));
         $this->objTemplate->setVariable(array('TXT_DOWNLOADS_OWNER' => $_ARRAYLANG['TXT_DOWNLOADS_OWNER'], 'TXT_DOWNLOADS_FUNCTIONS' => $_ARRAYLANG['TXT_DOWNLOADS_FUNCTIONS'], 'DOWNLOADS_DOWNLOAD_CATEGORY_ID' => $objCategory->getId(), 'DOWNLOADS_DOWNLOAD_SORT_DIRECTION' => $downloadOrderDirection, 'DOWNLOADS_DOWNLOAD_SORT_BY' => $downloadOrderBy, 'DOWNLOADS_DOWNLOAD_SORT_ID' => $downloadOrderBy == 'id' && $downloadOrderDirection == 'asc' ? 'desc' : 'asc', 'DOWNLOADS_DOWNLOAD_SORT_STATUS' => $downloadOrderBy == 'is_active' && $downloadOrderDirection == 'asc' ? 'desc' : 'asc', 'DOWNLOADS_DOWNLOAD_SORT_ORDER' => $downloadOrderBy == 'order' && $downloadOrderDirection == 'asc' ? 'desc' : 'asc', 'DOWNLOADS_DOWNLOAD_SORT_NAME' => $downloadOrderBy == 'name' && $downloadOrderDirection == 'asc' ? 'desc' : 'asc', 'DOWNLOADS_DOWNLOAD_SORT_DESCRIPTION' => $downloadOrderBy == 'description' && $downloadOrderDirection == 'asc' ? 'desc' : 'asc', 'DOWNLOADS_DOWNLOAD_SORT_DOWNLOADED' => $downloadOrderBy == 'download_count' && $downloadOrderDirection == 'desc' ? 'asc' : 'desc', 'DOWNLOADS_DOWNLOAD_SORT_VIEWED' => $downloadOrderBy == 'views' && $downloadOrderDirection == 'desc' ? 'asc' : 'desc', 'DOWNLOADS_DOWNLOAD_SORT_ID_LABEL' => $_ARRAYLANG['TXT_DOWNLOADS_ID'] . ($downloadOrderBy == 'id' ? $downloadOrderDirection == 'asc' ? ' ↑' : ' ↓' : ''), 'DOWNLOADS_DOWNLOAD_SORT_STATUS_LABEL' => $_ARRAYLANG['TXT_DOWNLOADS_STATUS'] . ($downloadOrderBy == 'is_active' ? $downloadOrderDirection == 'asc' ? ' ↑' : ' ↓' : ''), 'DOWNLOADS_DOWNLOAD_SORT_ORDER_LABEL' => $_ARRAYLANG['TXT_DOWNLOADS_ORDER'] . ($downloadOrderBy == 'order' ? $downloadOrderDirection == 'asc' ? ' ↑' : ' ↓' : ''), 'DOWNLOADS_DOWNLOAD_SORT_NAME_LABEL' => $_ARRAYLANG['TXT_DOWNLOADS_NAME'] . ($downloadOrderBy == 'name' ? $downloadOrderDirection == 'asc' ? ' ↑' : ' ↓' : ''), 'DOWNLOADS_DOWNLOAD_SORT_DESCRIPTION_LABEL' => $_ARRAYLANG['TXT_DOWNLOADS_DESCRIPTION'] . ($downloadOrderBy == 'description' ? $downloadOrderDirection == 'asc' ? ' ↑' : ' ↓' : ''), 'DOWNLOADS_DOWNLOAD_SORT_DOWNLOADED_LABEL' => $_ARRAYLANG['TXT_DOWNLOADS_DOWNLOADED'] . ($downloadOrderBy == 'download_count' ? $downloadOrderDirection == 'asc' ? ' ↑' : ' ↓' : ''), 'DOWNLOADS_DOWNLOAD_SORT_VIEWED_LABEL' => $_ARRAYLANG['TXT_DOWNLOADS_VIEWED'] . ($downloadOrderBy == 'views' ? $downloadOrderDirection == 'asc' ? ' ↑' : ' ↓' : ''), 'DOWNLOADS_DOWNLOAD_CATEGORY_SORT' => $categoryOrderDirection, 'DOWNLOADS_DOWNLOAD_CATEGORY_BY' => $categoryOrderBy, 'DOWNLOADS_DOWNLOAD_CATEGORY_OFFSET' => $categoryLimitOffset));
         // parse paging
         $downloadCount = $objDownload->getFilteredSearchDownloadCount();
         if ($downloadCount > $_CONFIG['corePagingLimit']) {
             $pagingLink = "&cmd=Downloads&act=categories&parent_id=" . $objCategory->getId() . "&category_sort=" . htmlspecialchars($categoryOrderDirection) . "&category_by=" . htmlspecialchars($categoryOrderBy) . "&download_sort=" . htmlspecialchars($downloadOrderDirection) . "&download_by=" . htmlspecialchars($downloadOrderBy) . "&category_pos=" . $categoryLimitOffset;
             $this->objTemplate->setVariable('DOWNLOADS_DOWNLOAD_PAGING', getPaging($downloadCount, $downloadLimitOffset, $pagingLink, "<b>" . $_ARRAYLANG['TXT_DOWNLOADS_DOWNLOADS'] . "</b>") . '<br />');
         }
         $this->objTemplate->hideBlock('downloads_no_data');
         $this->objTemplate->parse('downloads_category_downloads');
         $this->objTemplate->parse('downloads_download_action_dropdown');
     } else {
         $this->objTemplate->hideBlock('downloads_category_downloads');
         $this->objTemplate->hideBlock('downloads_download_action_dropdown');
         $this->objTemplate->parse('downloads_no_data');
     }
 }
Exemplo n.º 2
0
 private function overview()
 {
     global $_LANGID;
     // load source code if cmd value is integer
     if ($this->objTemplate->placeholderExists('APPLICATION_DATA')) {
         $page = new \Cx\Core\ContentManager\Model\Entity\Page();
         $page->setVirtual(true);
         $page->setType(\Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION);
         $page->setModule('Downloads');
         // load source code
         $applicationTemplate = \Cx\Core\Core\Controller\Cx::getContentTemplateOfPage($page);
         \LinkGenerator::parseTemplate($applicationTemplate);
         $this->objTemplate->addBlock('APPLICATION_DATA', 'application_data', $applicationTemplate);
     }
     $objDownload = new Download();
     $objCategory = Category::getCategory($this->categoryId);
     if ($objCategory->getId()) {
         // check access permissions to selected category
         if (!\Permission::checkAccess(143, 'static', true) && $objCategory->getReadAccessId() && !\Permission::checkAccess($objCategory->getReadAccessId(), 'dynamic', true) && $objCategory->getOwnerId() != $this->userId) {
             // TODO: might we have to add a soft noAccess handler in case the output is meant for a regular page (not section=Downloads)
             \Permission::noAccess(base64_encode(CONTREXX_SCRIPT_PATH . $this->moduleParamsJs . '&category=' . $objCategory->getId()));
         }
         // parse crumbtrail
         $this->parseCrumbtrail($objCategory);
         if ($objDownload->load(!empty($_REQUEST['id']) ? intval($_REQUEST['id']) : 0) && (!$objDownload->getExpirationDate() || $objDownload->getExpirationDate() > time()) && $objDownload->getActiveStatus()) {
             /* DOWNLOAD DETAIL PAGE */
             $this->pageTitle = contrexx_raw2xhtml($objDownload->getName(FRONTEND_LANG_ID));
             $metakeys = $objDownload->getMetakeys(FRONTEND_LANG_ID);
             if ($this->arrConfig['use_attr_metakeys'] && !empty($metakeys)) {
                 \Env::get('cx')->getPage()->setMetakeys($metakeys);
             }
             $this->parseRelatedCategories($objDownload);
             $this->parseRelatedDownloads($objDownload, $objCategory->getId());
             $this->parseDownload($objDownload, $objCategory->getId());
             // hide unwanted blocks on the detail page
             if ($this->objTemplate->blockExists('downloads_category')) {
                 $this->objTemplate->hideBlock('downloads_category');
             }
             if ($this->objTemplate->blockExists('downloads_subcategory_list')) {
                 $this->objTemplate->hideBlock('downloads_subcategory_list');
             }
             if ($this->objTemplate->blockExists('downloads_file_list')) {
                 $this->objTemplate->hideBlock('downloads_file_list');
             }
             if ($this->objTemplate->blockExists('downloads_simple_file_upload')) {
                 $this->objTemplate->hideBlock('downloads_simple_file_upload');
             }
             if ($this->objTemplate->blockExists('downloads_advanced_file_upload')) {
                 $this->objTemplate->hideBlock('downloads_advanced_file_upload');
             }
         } else {
             /* CATEGORY DETAIL PAGE */
             $this->pageTitle = htmlentities($objCategory->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET);
             // process create directory
             $this->processCreateDirectory($objCategory);
             // parse selected category
             $this->parseCategory($objCategory);
             // parse subcategories
             $this->parseCategories($objCategory, array('downloads_subcategory_list', 'downloads_subcategory'), null, 'SUB');
             // parse downloads of selected category
             $this->parseDownloads($objCategory);
             // parse upload form
             $this->parseUploadForm($objCategory);
             // parse create directory form
             $this->parseCreateCategoryForm($objCategory);
             // hide unwanted blocks on the category page
             if ($this->objTemplate->blockExists('downloads_download')) {
                 $this->objTemplate->hideBlock('downloads_download');
             }
             if ($this->objTemplate->blockExists('downloads_file_detail')) {
                 $this->objTemplate->hideBlock('downloads_file_detail');
             }
         }
         // hide unwanted blocks on the category/detail page
         if ($this->objTemplate->blockExists('downloads_overview')) {
             $this->objTemplate->hideBlock('downloads_overview');
         }
         if ($this->objTemplate->blockExists('downloads_most_viewed_file_list')) {
             $this->objTemplate->hideBlock('downloads_most_viewed_file_list');
         }
         if ($this->objTemplate->blockExists('downloads_most_downloaded_file_list')) {
             $this->objTemplate->hideBlock('downloads_most_downloaded_file_list');
         }
         if ($this->objTemplate->blockExists('downloads_most_popular_file_list')) {
             $this->objTemplate->hideBlock('downloads_most_popular_file_list');
         }
         if ($this->objTemplate->blockExists('downloads_newest_file_list')) {
             $this->objTemplate->hideBlock('downloads_newest_file_list');
         }
         if ($this->objTemplate->blockExists('downloads_updated_file_list')) {
             $this->objTemplate->hideBlock('downloads_updated_file_list');
         }
     } else {
         /* CATEGORY OVERVIEW PAGE */
         $this->parseCategories($objCategory, array('downloads_overview', 'downloads_overview_category'), null, null, 'downloads_overview_row', array('downloads_overview_subcategory_list', 'downloads_overview_subcategory'), $this->arrConfig['overview_max_subcats']);
         if (!empty($this->searchKeyword)) {
             $this->parseDownloads($objCategory);
         } else {
             if ($this->objTemplate->blockExists('downloads_file_list')) {
                 $this->objTemplate->hideBlock('downloads_file_list');
             }
         }
         /* PARSE MOST VIEWED DOWNLOADS */
         $this->parseSpecialDownloads(array('downloads_most_viewed_file_list', 'downloads_most_viewed_file'), array('is_active' => true, 'expiration' => array('=' => 0, '>' => time())), array('views' => 'desc'), $this->arrConfig['most_viewed_file_count']);
         /* PARSE MOST DOWNLOADED DOWNLOADS */
         $this->parseSpecialDownloads(array('downloads_most_downloaded_file_list', 'downloads_most_downloaded_file'), array('is_active' => true, 'expiration' => array('=' => 0, '>' => time())), array('download_count' => 'desc'), $this->arrConfig['most_downloaded_file_count']);
         /* PARSE MOST POPULAR DOWNLOADS */
         // TODO: Rating system has to be implemented first!
         //$this->parseSpecialDownloads(array('downloads_most_popular_file_list', 'downloads_most_popular_file'), null, array('rating' => 'desc'), $this->arrConfig['most_popular_file_count']);
         /* PARSE RECENTLY UPDATED DOWNLOADS */
         $filter = array('ctime' => array('>=' => time() - $this->arrConfig['new_file_time_limit']), 'expiration' => array('=' => 0, '>' => time()));
         $this->parseSpecialDownloads(array('downloads_newest_file_list', 'downloads_newest_file'), $filter, array('ctime' => 'desc'), $this->arrConfig['newest_file_count']);
         // parse recently updated downloads
         $filter = array('mtime' => array('>=' => time() - $this->arrConfig['updated_file_time_limit']), 'ctime' => array('<' => time() - $this->arrConfig['new_file_time_limit']), 'expiration' => array('=' => 0, '>' => time()));
         $this->parseSpecialDownloads(array('downloads_updated_file_list', 'downloads_updated_file'), $filter, array('mtime' => 'desc'), $this->arrConfig['updated_file_count']);
         // hide unwanted blocks on the overview page
         if ($this->objTemplate->blockExists('downloads_category')) {
             $this->objTemplate->hideBlock('downloads_category');
         }
         if ($this->objTemplate->blockExists('downloads_crumbtrail')) {
             $this->objTemplate->hideBlock('downloads_crumbtrail');
         }
         if ($this->objTemplate->blockExists('downloads_subcategory_list')) {
             $this->objTemplate->hideBlock('downloads_subcategory_list');
         }
         if ($this->objTemplate->blockExists('downloads_file_detail')) {
             $this->objTemplate->hideBlock('downloads_file_detail');
         }
         if ($this->objTemplate->blockExists('downloads_simple_file_upload')) {
             $this->objTemplate->hideBlock('downloads_simple_file_upload');
         }
         if ($this->objTemplate->blockExists('downloads_advanced_file_upload')) {
             $this->objTemplate->hideBlock('downloads_advanced_file_upload');
         }
     }
     $this->parseGlobalStuff($objCategory);
 }
Exemplo n.º 3
0
 public function updateDownloadOrder($arrDownloadOrder)
 {
     global $objDatabase, $_LANGID, $_ARRAYLANG;
     $arrFailedDownloads = array();
     $objDownload = new Download();
     foreach ($arrDownloadOrder as $downloadId => $order) {
         if ($objDatabase->Execute('UPDATE `' . DBPREFIX . 'module_downloads_rel_download_category` SET `order` = ' . intval($order) . ' WHERE `download_id` = ' . $downloadId . ' AND `category_id` = ' . $this->getId()) === false) {
             $objDownload->load($downloadId);
             if (!$objDownload->EOF) {
                 $arrFailedDownloads[] = htmlentities($objDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET);
             }
         }
     }
     if (count($arrFailedDownloads)) {
         $this->error_msg[] = sprintf($_ARRAYLANG['TXT_DOWNLOADS_DOWNLOAD_ORDER_SET_FAILED'], implode(', ', $arrFailedDownloads));
         return false;
     } else {
         return true;
     }
 }