Exemple #1
0
 /**
  * Get page
  *
  * Get the livecam page
  *
  * @access public
  * @return string
  */
 function getPage()
 {
     $this->_objTpl->setTemplate($this->pageContent);
     // load source code if cmd value is integer
     if ($this->_objTpl->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('Livecam');
         // load source code
         $applicationTemplate = \Cx\Core\Core\Controller\Cx::getContentTemplateOfPage($page);
         \LinkGenerator::parseTemplate($applicationTemplate);
         $this->_objTpl->addBlock('APPLICATION_DATA', 'application_data', $applicationTemplate);
     }
     $this->_objTpl->setVariable(array("CMD" => $this->cam));
     $this->_objTpl->setGlobalVariable('LIVECAM_DATE', $this->date);
     switch ($this->_action) {
         case 'today':
             $this->_objTpl->hideBlock('livecamPicture');
             $this->_showArchive($this->date);
             break;
         case 'archive':
             $this->_objTpl->hideBlock('livecamPicture');
             $this->_showArchive($this->date);
             break;
         default:
             $this->_objTpl->hideBlock('livecamArchive');
             $this->_showPicture();
             break;
     }
     if (isset($this->statusMessage)) {
         $this->_objTpl->setVariable('LIVECAM_STATUS_MESSAGE', $this->statusMessage);
     }
     return $this->_objTpl->get();
 }
 function showEntry()
 {
     global $_ARRAYLANG, $_CORELANG;
     $this->_objTpl->setTemplate($this->pageContent, true, true);
     //get ids
     $intCategoryId = isset($_GET['cid']) ? intval($_GET['cid']) : 0;
     $intLevelId = isset($_GET['lid']) ? intval($_GET['lid']) : 0;
     $intEntryId = isset($_GET['eid']) ? intval($_GET['eid']) : 0;
     // load source code if cmd value is integer
     if ($this->_objTpl->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('MediaDir');
         $page->setCmd('detail');
         // load source code
         $applicationTemplate = \Cx\Core\Core\Controller\Cx::getContentTemplateOfPage($page);
         \LinkGenerator::parseTemplate($applicationTemplate);
         $this->_objTpl->addBlock('APPLICATION_DATA', 'application_data', $applicationTemplate);
     }
     //get navtree
     if ($this->_objTpl->blockExists($this->moduleNameLC . 'Navtree') && ($intCategoryId != 0 || $intLevelId != 0)) {
         $this->getNavtree($intCategoryId, $intLevelId);
     }
     if ($intEntryId != 0 && $this->_objTpl->blockExists($this->moduleNameLC . 'EntryList')) {
         $objEntry = new MediaDirectoryEntry($this->moduleName);
         $objEntry->getEntries($intEntryId, $intLevelId, $intCategoryId, null, null, null, 1, null, 1);
         $objEntry->listEntries($this->_objTpl, 2);
         $objEntry->updateHits($intEntryId);
         //set meta title
         $this->metaTitle .= " - " . $objEntry->arrEntries[$intEntryId]['entryFields'][0];
         $this->pageTitle = $objEntry->arrEntries[$intEntryId]['entryFields'][0];
         if (empty($objEntry->arrEntries)) {
             $this->_objTpl->hideBlock($this->moduleNameLC . 'EntryList');
             $this->_objTpl->clearVariables();
             header("Location: index.php?section=" . $this->moduleName);
             exit;
         }
     } else {
         header("Location: index.php?section=" . $this->moduleName);
         exit;
     }
 }
Exemple #3
0
 /**
  * Gets the list with the headlines
  *
  * @global    array
  * @global    ADONewConnection
  * @global    array
  * @return    string    parsed content
  */
 private function getHeadlines()
 {
     global $_CONFIG, $objDatabase, $_ARRAYLANG, $_LANGID;
     // load source code if cmd value is integer
     if ($this->_objTpl->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('News');
         // load source code
         $applicationTemplate = \Cx\Core\Core\Controller\Cx::getContentTemplateOfPage($page);
         \LinkGenerator::parseTemplate($applicationTemplate);
         $this->_objTpl->addBlock('APPLICATION_DATA', 'application_data', $applicationTemplate);
     }
     $validToShowList = true;
     $newsCategories = array();
     $menuCategories = array();
     $parameters = array();
     $selectedCat = '';
     $selectedType = '';
     $selectedPublisher = '';
     $selectedAuthor = '';
     $newsfilter = '';
     $paging = '';
     $pos = 0;
     $i = 0;
     if (isset($_GET['pos'])) {
         $pos = intval($_GET['pos']);
     }
     $catFromCmd = !empty($_REQUEST['cmd']) ? explode(',', $_REQUEST['cmd']) : array();
     $catFromReq = !empty($_REQUEST['category']) ? explode(',', $_REQUEST['category']) : array();
     if (!empty($catFromCmd)) {
         $menuCategories = $this->getCatIdsFromNestedSetArray($this->getNestedSetCategories($catFromCmd));
         if ($this->_objTpl->placeholderExists('NEWS_CMD')) {
             $this->_objTpl->setVariable('NEWS_CMD', $_REQUEST['cmd']);
         }
     }
     $newsCategories = $categories = !empty($catFromReq) ? $catFromReq : (!empty($catFromCmd) ? $catFromCmd : array());
     if (count($newsCategories) == 1 && $this->categoryExists($newsCategories[0])) {
         $selectedCat = intval($newsCategories[0]);
     }
     if (empty($newsCategories)) {
         $newsCategories[] = $this->nestedSetRootId;
     }
     $newsCategories = $this->getCatIdsFromNestedSetArray($this->getNestedSetCategories($newsCategories));
     if (!empty($newsCategories)) {
         $newsfilter .= ' AND (`nc`.`category_id` IN (' . implode(',', $newsCategories) . '))';
     }
     if ($this->_objTpl->placeholderExists('NEWS_CAT_DROPDOWNMENU')) {
         $catMenu = '<select onchange="this.form.submit()" name="category">' . "\n";
         $catMenu .= '<option value="">' . $_ARRAYLANG['TXT_CATEGORY'] . '</option>' . "\n";
         $catMenu .= $this->getCategoryMenu(!empty($menuCategories) ? $menuCategories : array(), array($selectedCat)) . "\n";
         $catMenu .= '</select>' . "\n";
         $this->_objTpl->setVariable('NEWS_CAT_DROPDOWNMENU', $catMenu);
     }
     //Filter by types
     if ($this->arrSettings['news_use_types'] == 1) {
         if (!empty($_REQUEST['type'])) {
             $arrTypes = explode(',', $_REQUEST['type']);
             if (!empty($arrTypes)) {
                 $newsfilter .= ' AND (`n`.`typeid` IN (' . implode(', ', contrexx_input2int($arrTypes)) . '))';
             }
             $selectedType = current($arrTypes);
         }
         if ($this->_objTpl->placeholderExists('NEWS_TYPE_DROPDOWNMENU')) {
             $typeMenu = '<select onchange="this.form.submit()" name="type">' . "\n";
             $typeMenu .= '<option value="" selected="selected">' . $_ARRAYLANG['TXT_TYPE'] . '</option>' . "\n";
             $typeMenu .= $this->getTypeMenu($selectedType) . "\n";
             $typeMenu .= '</select>' . "\n";
             $this->_objTpl->setVariable('NEWS_TYPE_DROPDOWNMENU', $typeMenu);
         }
     }
     //Filter by publisher
     if (!empty($_REQUEST['publisher'])) {
         $parameters['filterPublisher'] = $publisher = contrexx_input2raw($_REQUEST['publisher']);
         $arrPublishers = explode(',', $publisher);
         if (!empty($arrPublishers)) {
             $newsfilter .= ' AND (`n`.`publisher_id` IN (' . implode(', ', contrexx_input2int($arrPublishers)) . '))';
         }
         $selectedPublisher = current($arrPublishers);
     }
     if ($this->_objTpl->placeholderExists('NEWS_PUBLISHER_DROPDOWNMENU')) {
         $publisherMenu = '<select onchange="window.location=\'' . \Cx\Core\Routing\Url::fromModuleAndCmd('News', intval($_REQUEST['cmd'])) . '&amp;publisher=\'+this.value" name="publisher">' . "\n";
         $publisherMenu .= '<option value="" selected="selected">' . $_ARRAYLANG['TXT_NEWS_PUBLISHER'] . '</option>' . "\n";
         $publisherMenu .= $this->getPublisherMenu($selectedPublisher, $selectedCat) . "\n";
         $publisherMenu .= '</select>' . "\n";
         $this->_objTpl->setVariable('NEWS_PUBLISHER_DROPDOWNMENU', $publisherMenu);
     }
     //Filter by Author
     if (!empty($_REQUEST['author'])) {
         $parameters['filterAuthor'] = $author = contrexx_input2raw($_REQUEST['author']);
         $arrAuthors = explode(',', $author);
         if (!empty($arrAuthors)) {
             $newsfilter .= ' AND (`n`.`author_id` IN (' . implode(', ', contrexx_input2int($arrAuthors)) . '))';
         }
         $selectedAuthor = current($arrAuthors);
     }
     if ($this->_objTpl->placeholderExists('NEWS_AUTHOR_DROPDOWNMENU')) {
         $authorMenu = '<select onchange="this.form.submit()" name="author">' . "\n";
         $authorMenu .= '<option value="" selected="selected">' . $_ARRAYLANG['TXT_NEWS_AUTHOR'] . '</option>' . "\n";
         $authorMenu .= $this->getAuthorMenu($selectedAuthor) . "\n";
         $authorMenu .= '</select>' . "\n";
         $this->_objTpl->setVariable('NEWS_AUTHOR_DROPDOWNMENU', $authorMenu);
     }
     //Filter by tag
     if (!empty($_REQUEST['tag'])) {
         $parameters['filterTag'] = $searchTag = contrexx_input2raw($_REQUEST['tag']);
         $searchedTag = $this->getNewsTags(null, $searchTag);
         $searchedTagId = current(array_keys($searchedTag['tagList']));
         if (!empty($searchedTag['newsIds'])) {
             $this->incrementViewingCount($searchedTagId);
             $newsfilter .= ' AND n.`id` IN (' . implode(',', $searchedTag['newsIds']) . ')';
             $this->_objTpl->setVariable(array('NEWS_FILTER_TAG_ID' => $searchedTagId, 'NEWS_FILTER_TAG_NAME' => ucfirst(current($searchedTag['tagList']))));
             if ($this->_objTpl->blockExists('tagFilterCont')) {
                 $this->_objTpl->parse('tagFilterCont');
             }
         } else {
             $validToShowList = false;
         }
     }
     $this->_objTpl->setVariable(array('TXT_PERFORM' => $_ARRAYLANG['TXT_PERFORM'], 'TXT_CATEGORY' => $_ARRAYLANG['TXT_CATEGORY'], 'TXT_TYPE' => $this->arrSettings['news_use_types'] == 1 ? $_ARRAYLANG['TXT_TYPE'] : '', 'TXT_DATE' => $_ARRAYLANG['TXT_DATE'], 'TXT_TITLE' => $_ARRAYLANG['TXT_TITLE'], 'TXT_NEWS_MESSAGE' => $_ARRAYLANG['TXT_NEWS_MESSAGE']));
     $query = '  SELECT      n.id                AS newsid,
                             n.userid            AS newsuid,
                             n.date              AS newsdate,
                             n.teaser_image_path,
                             n.teaser_image_thumbnail_path,
                             n.redirect,
                             n.publisher,
                             n.publisher_id,
                             n.author,
                             n.author_id,
                             n.allow_comments AS commentactive,
                             n.enable_tags,
                             nl.title            AS newstitle,
                             nl.text NOT REGEXP \'^(<br type="_moz" />)?$\' AS newscontent,
                             nl.teaser_text
                 FROM        ' . DBPREFIX . 'module_news AS n
                 INNER JOIN  ' . DBPREFIX . 'module_news_locale AS nl ON nl.news_id = n.id
                 INNER JOIN  ' . DBPREFIX . 'module_news_rel_categories AS nc ON nc.news_id = n.id
                 WHERE       status = 1
                             AND nl.is_active=1
                             AND nl.lang_id=' . FRONTEND_LANG_ID . '
                             AND (n.startdate<=\'' . date('Y-m-d H:i:s') . '\' OR n.startdate="0000-00-00 00:00:00")
                             AND (n.enddate>=\'' . date('Y-m-d H:i:s') . '\' OR n.enddate="0000-00-00 00:00:00")
                             ' . $newsfilter . ($this->arrSettings['news_message_protection'] == '1' && !\Permission::hasAllAccess() ? ($objFWUser = \FWUser::getFWUserObject()) && $objFWUser->objUser->login() ? " AND (frontend_access_id IN (" . implode(',', array_merge(array(0), $objFWUser->objUser->getDynamicPermissionIds())) . ") OR userid = " . $objFWUser->objUser->getId() . ") " : " AND frontend_access_id=0 " : '') . ' GROUP BY newsid ' . ' ORDER BY newsdate DESC';
     /***start paging ****/
     $objResult = $objDatabase->Execute($query);
     $count = $objResult->RecordCount();
     $category = '';
     if (!empty($_REQUEST['cmd'])) {
         $parameters['filterCategory'] = contrexx_input2raw($_REQUEST['cmd']);
         $category .= '&cmd=' . $_REQUEST['cmd'];
     }
     if (!empty($_REQUEST['category'])) {
         $parameters['filterCategory'] = contrexx_input2raw($_REQUEST['category']);
         $category .= '&category=' . $_REQUEST['category'];
     }
     $type = '';
     if (!empty($_REQUEST['type'])) {
         $parameters['filterType'] = contrexx_input2raw($_REQUEST['type']);
         $type = '&type=' . $selectedType;
     }
     if ($count > intval($_CONFIG['corePagingLimit'])) {
         $paging = getPaging($count, $pos, '&section=News' . $category . $type, $_ARRAYLANG['TXT_NEWS_MESSAGES'], true);
     }
     $this->_objTpl->setVariable('NEWS_PAGING', $paging);
     $objResult = $objDatabase->SelectLimit($query, $_CONFIG['corePagingLimit'], $pos);
     /*** end paging ***/
     if ($count >= 1 && $validToShowList) {
         while (!$objResult->EOF) {
             $newsid = $objResult->fields['newsid'];
             $newstitle = $objResult->fields['newstitle'];
             $newsCommentActive = $objResult->fields['commentactive'];
             $arrNewsCategories = $this->getCategoriesByNewsId($newsid);
             $parameters['newsid'] = $newsid;
             $newsUrl = empty($objResult->fields['redirect']) ? empty($objResult->fields['newscontent']) ? '' : \Cx\Core\Routing\Url::fromModuleAndCmd('News', $this->findCmdById('details', self::sortCategoryIdByPriorityId(array_keys($arrNewsCategories), $categories)), FRONTEND_LANG_ID, $parameters) : $objResult->fields['redirect'];
             $htmlLink = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml('[' . $_ARRAYLANG['TXT_NEWS_MORE'] . '...]'));
             $htmlLinkTitle = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml($newstitle));
             // in case that the message is a stub, we shall just display the news title instead of a html-a-tag with no href target
             if (empty($htmlLinkTitle)) {
                 $htmlLinkTitle = contrexx_raw2xhtml($newstitle);
             }
             list($image, $htmlLinkImage, $imageSource) = self::parseImageThumbnail($objResult->fields['teaser_image_path'], $objResult->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl);
             $author = \FWUser::getParsedUserTitle($objResult->fields['author_id'], $objResult->fields['author']);
             $publisher = \FWUser::getParsedUserTitle($objResult->fields['publisher_id'], $objResult->fields['publisher']);
             $objSubResult = $objDatabase->Execute('SELECT count(`id`) AS `countComments` FROM `' . DBPREFIX . 'module_news_comments` WHERE `newsid` = ' . $objResult->fields['newsid']);
             if (empty($arrNewsCategories) && $this->_objTpl->blockExists('newsCategories')) {
                 $this->_objTpl->hideBlock('newsCategories');
             }
             $this->_objTpl->setVariable(array('NEWS_ID' => $newsid, 'NEWS_CSS' => 'row' . ($i % 2 + 1), 'NEWS_TEASER' => nl2br($objResult->fields['teaser_text']), 'NEWS_TITLE' => contrexx_raw2xhtml($newstitle), 'NEWS_LONG_DATE' => date(ASCMS_DATE_FORMAT, $objResult->fields['newsdate']), 'NEWS_DATE' => date(ASCMS_DATE_FORMAT_DATE, $objResult->fields['newsdate']), 'NEWS_TIME' => date(ASCMS_DATE_FORMAT_TIME, $objResult->fields['newsdate']), 'NEWS_LINK_TITLE' => $htmlLinkTitle, 'NEWS_LINK' => $htmlLink, 'NEWS_LINK_URL' => contrexx_raw2xhtml($newsUrl), 'NEWS_CATEGORY' => implode(', ', contrexx_raw2xhtml($arrNewsCategories)), 'NEWS_PUBLISHER' => contrexx_raw2xhtml($publisher), 'NEWS_AUTHOR' => contrexx_raw2xhtml($author), 'NEWS_COUNT_COMMENTS' => contrexx_raw2xhtml($objSubResult->fields['countComments'] . ' ' . $_ARRAYLANG['TXT_NEWS_COMMENTS'])));
             if (!$newsCommentActive || !$this->arrSettings['news_comments_activated']) {
                 if ($this->_objTpl->blockExists('news_comments_count')) {
                     $this->_objTpl->hideBlock('news_comments_count');
                 }
             }
             if (!empty($image)) {
                 $this->_objTpl->setVariable(array('NEWS_IMAGE' => $image, 'NEWS_IMAGE_SRC' => contrexx_raw2xhtml($imageSource), 'NEWS_IMAGE_ALT' => contrexx_raw2xhtml($newstitle), 'NEWS_IMAGE_LINK' => $htmlLinkImage));
                 if ($this->_objTpl->blockExists('news_image')) {
                     $this->_objTpl->parse('news_image');
                 }
             } else {
                 if ($this->_objTpl->blockExists('news_image')) {
                     $this->_objTpl->hideBlock('news_image');
                 }
             }
             self::parseImageBlock($this->_objTpl, $objResult->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl, 'image_thumbnail');
             self::parseImageBlock($this->_objTpl, $objResult->fields['teaser_image_path'], $newstitle, $newsUrl, 'image_detail');
             if (!empty($this->arrSettings['news_use_tags']) && !empty($objResult->fields['enable_tags'])) {
                 $this->parseNewsTags($this->_objTpl, $newsid);
             }
             $this->_objTpl->parse('newsrow');
             $i++;
             $objResult->MoveNext();
         }
         if ($this->_objTpl->blockExists('news_list')) {
             $this->_objTpl->parse('news_list');
         }
         if ($this->_objTpl->blockExists('news_menu')) {
             $this->_objTpl->parse('news_menu');
         }
         if ($this->_objTpl->blockExists('news_status_message')) {
             $this->_objTpl->hideBlock('news_status_message');
         }
     } else {
         $this->_objTpl->setVariable('TXT_NEWS_NO_NEWS_FOUND', $_ARRAYLANG['TXT_NEWS_NO_NEWS_FOUND']);
         if ($this->_objTpl->blockExists('news_status_message')) {
             $this->_objTpl->parse('news_status_message');
         }
         if ($this->_objTpl->blockExists('news_menu')) {
             $this->_objTpl->parse('news_menu');
         }
         if ($this->_objTpl->blockExists('news_list')) {
             $this->_objTpl->hideBlock('news_list');
         }
     }
     return $this->_objTpl->get();
 }
Exemple #4
0
 /**
  * set the placeholders for the category view
  * 
  * @return null
  */
 function showCategoryView()
 {
     global $_ARRAYLANG, $_CORELANG;
     $this->_objTpl->setTemplate($this->pageContent, true, true);
     // load source code if cmd value is integer
     if ($this->_objTpl->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('Calendar');
         // load source code
         $applicationTemplate = \Cx\Core\Core\Controller\Cx::getContentTemplateOfPage($page);
         \LinkGenerator::parseTemplate($applicationTemplate);
         $this->_objTpl->addBlock('APPLICATION_DATA', 'application_data', $applicationTemplate);
     }
     $objCategoryManager = new \Cx\Modules\Calendar\Controller\CalendarCategoryManager(true);
     $objCategoryManager->getCategoryList();
     $this->_objTpl->setGlobalVariable(array('TXT_' . $this->moduleLangVar . '_SEARCH_TERM' => $_ARRAYLANG['TXT_CALENDAR_KEYWORD'], 'TXT_' . $this->moduleLangVar . '_FROM' => $_ARRAYLANG['TXT_CALENDAR_FROM'], 'TXT_' . $this->moduleLangVar . '_TILL' => $_ARRAYLANG['TXT_CALENDAR_TILL'], 'TXT_' . $this->moduleLangVar . '_CATEGORY' => $_ARRAYLANG['TXT_CALENDAR_CAT'], 'TXT_' . $this->moduleLangVar . '_SEARCH' => $_ARRAYLANG['TXT_CALENDAR_SEARCH'], 'TXT_' . $this->moduleLangVar . '_OCLOCK' => $_ARRAYLANG['TXT_CALENDAR_OCLOCK'], $this->moduleLangVar . '_SEARCH_TERM' => isset($_GET['term']) ? contrexx_input2xhtml($_GET['term']) : '', $this->moduleLangVar . '_SEARCH_FROM' => isset($_GET['from']) ? contrexx_input2xhtml($_GET['from']) : '', $this->moduleLangVar . '_SEARCH_TILL' => isset($_GET['till']) ? contrexx_input2xhtml($_GET['till']) : '', $this->moduleLangVar . '_SEARCH_CATEGORIES' => $objCategoryManager->getCategoryDropdown(isset($_GET['catid']) ? intval($_GET['catid']) : 0, 1)));
     if (isset($this->categoryId)) {
         $objCategory = new \Cx\Modules\Calendar\Controller\CalendarCategory($this->categoryId);
         $this->_objTpl->setGlobalVariable(array($this->moduleLangVar . '_CATEGORY_NAME' => $objCategory->name));
         $this->objEventManager->showEventList($this->_objTpl);
         $this->_objTpl->parse('categoryList');
     } else {
         foreach ($objCategoryManager->categoryList as $key => $objCategory) {
             $objEventManager = new \Cx\Modules\Calendar\Controller\CalendarEventManager($this->startDate, $this->endDate, $objCategory->id, $this->searchTerm, true, $this->needAuth, true, $this->startPos, $this->numEvents);
             $objEventManager->getEventList();
             $objEventManager->showEventList($this->_objTpl);
             $this->_objTpl->setGlobalVariable(array($this->moduleLangVar . '_CATEGORY_NAME' => $objCategory->name));
             $this->_objTpl->parse('categoryList');
         }
     }
 }
 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);
 }
Exemple #6
0
 public function resolve()
 {
     // $this->resolveAlias() also sets $this->page
     $aliaspage = $this->resolveAlias();
     if ($aliaspage != null) {
         $this->lang = $aliaspage->getTargetLangId();
         $aliaspage = clone $aliaspage;
         $aliaspage->setVirtual(true);
     } else {
         $this->lang = \Env::get('init')->getFallbackFrontendLangId();
         //try to find the language in the url
         $extractedLanguage = \FWLanguage::getLanguageIdByCode($this->url->getLangDir());
         $activeLanguages = \FWLanguage::getActiveFrontendLanguages();
         if (!$extractedLanguage) {
             $this->redirectToCorrectLanguageDir();
         }
         if (!in_array($extractedLanguage, array_keys($activeLanguages))) {
             $this->lang = \FWLanguage::getDefaultLangId();
             $this->redirectToCorrectLanguageDir();
         }
         //only set langid according to url if the user has not explicitly requested a language change.
         if (!isset($_REQUEST['setLang'])) {
             $this->lang = $extractedLanguage;
             //the user wants to change the language, but we're still inside the wrong language directory.
         } else {
             if ($this->lang != $extractedLanguage) {
                 $this->redirectToCorrectLanguageDir();
             }
         }
     }
     // used for LinkGenerator
     define('FRONTEND_LANG_ID', $this->lang);
     // used to load template file
     \Env::get('init')->setFrontendLangId($this->lang);
     global $section, $command, $history, $sessionObj, $url, $_CORELANG, $page, $pageId, $themesPages, $page_template, $isRegularPageRequest, $now, $start, $end, $plainSection;
     $section = isset($_REQUEST['section']) ? $_REQUEST['section'] : '';
     $command = isset($_REQUEST['cmd']) ? contrexx_addslashes($_REQUEST['cmd']) : '';
     $history = isset($_REQUEST['history']) ? intval($_REQUEST['history']) : 0;
     // Initialize page meta
     $page = null;
     $pageAccessId = 0;
     $page_protected = $pageId = $themesPages = $page_template = null;
     // If standalone is set, then we will not have to initialize/load any content page related stuff
     $isRegularPageRequest = !isset($_REQUEST['standalone']) || $_REQUEST['standalone'] == 'false';
     // Regular page request
     if ($isRegularPageRequest) {
         // TODO: history (empty($history) ? )
         if (isset($_GET['pagePreview']) && $_GET['pagePreview'] == 1 && empty($sessionObj)) {
             $sessionObj = \cmsSession::getInstance();
         }
         $this->init($url, $this->lang, \Env::get('em'), ASCMS_INSTANCE_OFFSET . \Env::get('virtualLanguageDirectory'), \FWLanguage::getFallbackLanguageArray());
         try {
             $this->resolvePage();
             $page = $this->getPage();
             // TODO: should this check (for type 'application') moved to \Cx\Core\ContentManager\Model\Entity\Page::getCmd()|getModule() ?
             // only set $section and $command if the requested page is an application
             $command = $this->getCmd();
             $section = $this->getSection();
         } catch (\Cx\Core\Routing\ResolverException $e) {
             try {
                 $this->legacyResolve($url, $section, $command);
                 $page = $this->getPage();
                 $command = $this->getCmd();
                 $section = $this->getSection();
             } catch (\Cx\Core\Routing\ResolverException $e) {
                 // legacy resolving also failed.
                 // provoke a 404
                 $page = null;
             }
         }
         if (!$page || !$page->isActive()) {
             //fallback for inexistant error page
             if ($section == 'Error') {
                 // If the error module is not installed, show this
                 die($_CORELANG['TXT_THIS_MODULE_DOESNT_EXISTS']);
             } else {
                 //page not found, redirect to error page.
                 \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . \Cx\Core\Routing\Url::fromModuleAndCmd('Error'));
                 exit;
             }
         }
         // TODO: question: what do we need this for? I think there is no need for this (had been added in r15026)
         //legacy: re-populate cmd and section into $_GET
         $_GET['cmd'] = $command;
         $_GET['section'] = $section;
         // END of TODO question
         //check whether the page is active
         $now = new \DateTime('now');
         $start = $page->getStart();
         $end = $page->getEnd();
         $pageId = $page->getId();
         //access: frontend access id for default requests
         $pageAccessId = $page->getFrontendAccessId();
         //revert the page if a history param has been given
         if ($history) {
             //access: backend access id for history requests
             $pageAccessId = $page->getBackendAccessId();
             $logRepo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\LogEntry');
             try {
                 $logRepo->revert($page, $history);
             } catch (\Gedmo\Exception\UnexpectedValueException $e) {
             }
             $logRepo->revert($page, $history);
         }
         /*
                                     //404 for inactive pages
                                     if(($start > $now && $start != null) || ($now > $end && $end != null)) {
                                         if ($section == 'Error') {
                                             // If the error module is not installed, show this
                                             die($_CORELANG['TXT_THIS_MODULE_DOESNT_EXISTS']);
                                         }
                                         \Cx\Core\Csrf\Controller\Csrf::header('Location: index.php?section=Error&id=404');
                                         exit;
                                         }*/
         \Env::get('init')->setCustomizedTheme($page->getSkin(), $page->getCustomContent(), $page->getUseSkinForAllChannels());
         $themesPages = \Env::get('init')->getTemplates($page);
         //replace the {NODE_<ID>_<LANG>}- placeholders
         \LinkGenerator::parseTemplate($themesPages);
         //TODO: analyze those, take action.
         //$page_protected = $objResult->fields['protected'];
         $page_protected = $page->isFrontendProtected();
         //$page_access_id = $objResult->fields['frontend_access_id'];
         $page_template = $themesPages['content'];
         // Authentification for protected pages
         // This is only done for regular page requests ($isRegularPageRequest == TRUE)
         $this->checkPageFrontendProtection($page, $history);
         //TODO: history
     }
     // TODO: refactor system to be able to remove this backward compatibility
     // Backwards compatibility for code pre Contrexx 3.0 (update)
     $_GET['cmd'] = $_POST['cmd'] = $_REQUEST['cmd'] = $command;
     $_GET['section'] = $_POST['section'] = $_REQUEST['section'] = $section;
     // the system should directly use $this->url->getParamArray() instead of using the super globals
     $qsArr = $this->url->getParamArray();
     foreach ($qsArr as $qsParam => $qsArgument) {
         $_GET[$qsParam] = $_REQUEST[$qsParam] = $qsArgument;
     }
     // To clone any module, use an optional integer cmd suffix.
     // E.g.: "shop2", "gallery5", etc.
     // Mind that you *MUST* copy all necessary database tables, and fix any
     // references to your module (section and cmd parameters, database tables)
     // using the MODULE_INDEX constant in the right place both in your code
     // *AND* templates!
     // See the Shop module for an example.
     $arrMatch = array();
     if (preg_match('/^(\\D+)(\\d+)$/', $section, $arrMatch)) {
         // The plain section/module name, used below
         $plainSection = $arrMatch[1];
     } else {
         $plainSection = $section;
     }
     // The module index.
     // An empty or 1 (one) index represents the same (default) module,
     // values 2 (two) and larger represent distinct instances.
     $moduleIndex = empty($arrMatch[2]) || $arrMatch[2] == 1 ? '' : $arrMatch[2];
     define('MODULE_INDEX', $moduleIndex);
     // Start page or default page for no section
     if ($section == 'Home') {
         if (!\Env::get('init')->hasCustomContent()) {
             $page_template = $themesPages['home'];
         } else {
             $page_template = $themesPages['content'];
         }
     }
     // this is the case for standalone and backend requests
     if (!$this->page) {
         return null;
     }
     $this->page = clone $this->page;
     $this->page->setVirtual();
     // check for further URL parts to resolve
     if ($this->page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION && $this->page->getPath() != '/' . $this->url->getSuggestedTargetPath()) {
         // does this work for fallback(/aliases)?
         $additionalPath = substr('/' . $this->url->getSuggestedTargetPath(), strlen($this->page->getPath()));
         $componentController = $this->em->getRepository('Cx\\Core\\Core\\Model\\Entity\\SystemComponent')->findOneBy(array('name' => $this->page->getModule()));
         if ($componentController) {
             $parts = explode('/', substr($additionalPath, 1));
             $componentController->resolve($parts, $this->page);
         }
     }
     return $this->page;
 }
Exemple #7
0
 /**
  * Shows the Overview of categories
  *
  * @global  ADONewConnection
  * @global  array
  * @global  array
  * @param   var     $intParentId
  */
 function showCategoryOverview($intParentId = 0)
 {
     global $objDatabase, $_ARRAYLANG, $_CONFIG, $_CORELANG;
     $intParentId = intval($intParentId);
     $this->_objTpl->setTemplate($this->pageContent, true, true);
     // load source code if cmd value is integer
     if ($this->_objTpl->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('Gallery');
         // load source code
         $applicationTemplate = \Cx\Core\Core\Controller\Cx::getContentTemplateOfPage($page);
         \LinkGenerator::parseTemplate($applicationTemplate);
         $this->_objTpl->addBlock('APPLICATION_DATA', 'application_data', $applicationTemplate);
     }
     $categoryProtected = $this->categoryIsProtected($intParentId);
     if ($categoryProtected > 0) {
         if (!\Permission::checkAccess($categoryProtected, 'dynamic', true)) {
             $link = base64_encode($_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']);
             \Cx\Core\Csrf\Controller\Csrf::header("Location: " . CONTREXX_DIRECTORY_INDEX . "?section=Login&cmd=noaccess&redirect=" . $link);
             exit;
         }
     }
     // hide image detail block
     // $this->_objTpl->hideBlock('galleryImage');
     if ($this->arrSettings['header_type'] == 'hierarchy') {
         $this->_objTpl->setVariable(array('GALLERY_CATEGORY_TREE' => $this->getCategoryTree(), 'TXT_GALLERY_CATEGORY_HINT' => $_ARRAYLANG['TXT_GALLERY_CATEGORY_HINT_HIERARCHY']));
     } else {
         $this->_objTpl->setVariable(array('GALLERY_CATEGORY_TREE' => $this->getSiblingList(), 'TXT_GALLERY_CATEGORY_HINT' => $_ARRAYLANG['TXT_GALLERY_CATEGORY_HINT_FLAT']));
     }
     $objResult = $objDatabase->Execute("SELECT id, catid, path FROM " . DBPREFIX . "module_gallery_pictures " . "ORDER BY catimg ASC, sorting ASC, id ASC");
     $showImageSizeOverview = $this->arrSettings['show_image_size'] == 'on';
     while (!$objResult->EOF) {
         $arrImageSizes[$objResult->fields['catid']][$objResult->fields['id']] = $showImageSizeOverview ? round(filesize($this->strImagePath . $objResult->fields['path']) / 1024, 2) : '';
         $arrstrImagePaths[$objResult->fields['catid']][$objResult->fields['id']] = $this->strThumbnailWebPath . $objResult->fields['path'];
         $objResult->MoveNext();
     }
     if (isset($arrImageSizes) && isset($arrstrImagePaths)) {
         foreach ($arrImageSizes as $keyCat => $valueCat) {
             $arrCategorySizes[$keyCat] = 0;
             foreach ($valueCat as $valueImageSize) {
                 $arrCategorySizes[$keyCat] = $arrCategorySizes[$keyCat] + $valueImageSize;
             }
         }
         foreach ($arrstrImagePaths as $keyCat => $valueCat) {
             $arrCategoryImages[$keyCat] = 0;
             $arrCategoryImageCounter[$keyCat] = 0;
             foreach ($valueCat as $valuestrImagePath) {
                 $arrCategoryImages[$keyCat] = $valuestrImagePath;
                 $arrCategoryImageCounter[$keyCat] = $arrCategoryImageCounter[$keyCat] + 1;
             }
         }
     }
     //$arrCategorySizes            ->        Sizes of all Categories
     //$arrCategoryImages        ->        The First Picture of each category
     //$arrCategoryImageCounter    ->        Counts all images in one group
     //begin category-paging
     $intPos = isset($_GET['pos']) ? intval($_GET['pos']) : 0;
     $objResult = $objDatabase->Execute('SELECT    count(id) AS countValue
                                         FROM     ' . DBPREFIX . 'module_gallery_categories
                                         WHERE     pid=' . $intParentId . ' AND
                                                 status="1"
                                     ');
     $this->_objTpl->setVariable(array('GALLERY_CATEGORY_PAGING' => getPaging($objResult->fields['countValue'], $intPos, '&section=Gallery&cid=' . $intParentId . $this->strCmd, '<b>' . $_ARRAYLANG['TXT_GALLERY'] . '</b>', false, intval($_CONFIG['corePagingLimit']))));
     //end category-paging
     $objResult = $objDatabase->SelectLimit('SELECT         *
                                             FROM         ' . DBPREFIX . 'module_gallery_categories
                                             WHERE         pid=' . $intParentId . ' AND
                                                         status="1"
                                             ORDER BY    sorting ASC', intval($_CONFIG['corePagingLimit']), $intPos);
     if ($objResult->RecordCount() == 0) {
         // no categories in the database, hide the output
         //$this->_objTpl->hideBlock('galleryCategoryList');
     } else {
         $i = 1;
         while (!$objResult->EOF) {
             $objSubResult = $objDatabase->Execute("SELECT name, value FROM " . DBPREFIX . "module_gallery_language " . "WHERE gallery_id=" . $objResult->fields['id'] . " AND " . "lang_id=" . intval($this->langId) . " ORDER BY name ASC");
             unset($arrCategoryLang);
             while (!$objSubResult->EOF) {
                 $arrCategoryLang[$objSubResult->fields['name']] = $objSubResult->fields['value'];
                 $objSubResult->MoveNext();
             }
             if (empty($arrCategoryImages[$objResult->fields['id']])) {
                 // no pictures in this gallery, show the empty-image
                 $strName = $arrCategoryLang['name'];
                 $strDesc = $arrCategoryLang['desc'];
                 $strImage = '<a href="' . CONTREXX_DIRECTORY_INDEX . '?section=Gallery&amp;cid=' . $objResult->fields['id'] . $this->strCmd . '" target="_self">';
                 $strImage .= '<img border="0" alt="' . $arrCategoryLang['name'] . '" src="modules/Gallery/View/Media/no_images.gif" /></a>';
                 $strInfo = $_ARRAYLANG['TXT_IMAGE_COUNT'] . ': 0';
                 $strInfo .= $showImageSizeOverview ? '<br />' . $_CORELANG['TXT_SIZE'] . ': 0kB' : '';
             } else {
                 $strName = $arrCategoryLang['name'];
                 $strDesc = $arrCategoryLang['desc'];
                 $strImage = '<a href="' . CONTREXX_DIRECTORY_INDEX . '?section=Gallery&amp;cid=' . $objResult->fields['id'] . $this->strCmd . '" target="_self">';
                 $strImage .= '<img border="0" alt="' . $arrCategoryLang['name'] . '" src="' . $arrCategoryImages[$objResult->fields['id']] . '" /></a>';
                 $strInfo = $_ARRAYLANG['TXT_IMAGE_COUNT'] . ': ' . $arrCategoryImageCounter[$objResult->fields['id']];
                 $strInfo .= $showImageSizeOverview ? '<br />' . $_CORELANG['TXT_SIZE'] . ': ' . $arrCategorySizes[$objResult->fields['id']] . 'kB' : '';
             }
             $this->_objTpl->setVariable(array('GALLERY_STYLE' => $i % 2 + 1, 'GALLERY_CATEGORY_NAME' => $strName, 'GALLERY_CATEGORY_IMAGE' => $strImage, 'GALLERY_CATEGORY_INFO' => $strInfo, 'GALLERY_CATEGORY_DESCRIPTION' => nl2br($strDesc)));
             $this->_objTpl->parse('galleryCategoryList');
             $i++;
             $objResult->MoveNext();
         }
     }
     //images
     $this->_objTpl->setVariable(array('GALLERY_JAVASCRIPT' => $this->getJavascript()));
     $objResult = $objDatabase->Execute("SELECT value FROM " . DBPREFIX . "module_gallery_language " . "WHERE gallery_id={$intParentId} AND lang_id={$this->langId} AND name='desc'");
     $strCategoryComment = nl2br($objResult->fields['value']);
     $objResult = $objDatabase->Execute("SELECT comment,voting FROM " . DBPREFIX . "module_gallery_categories " . "WHERE id=" . intval($intParentId));
     $boolComment = $objResult->fields['comment'];
     $boolVoting = $objResult->fields['voting'];
     // paging
     $intPos = isset($_GET['pos']) ? intval($_GET['pos']) : 0;
     $objResult = $objDatabase->Execute("SELECT id, path, link, size_show FROM " . DBPREFIX . "module_gallery_pictures " . "WHERE status='1' AND validated='1' AND catid={$intParentId} " . "ORDER BY sorting");
     $intCount = $objResult->RecordCount();
     $this->_objTpl->setVariable(array('GALLERY_PAGING' => getPaging($intCount, $intPos, '&section=Gallery&cid=' . $intParentId . $this->strCmd, '<b>' . $_ARRAYLANG['TXT_IMAGES'] . '</b>', false, intval($this->arrSettings["paging"]))));
     // end paging
     $objResult = $objDatabase->SelectLimit("SELECT id, path, link, size_show FROM " . DBPREFIX . "module_gallery_pictures " . "WHERE status='1' AND validated='1' AND catid={$intParentId} " . "ORDER BY sorting", intval($this->arrSettings["paging"]), $intPos);
     if ($objResult->RecordCount() == 0) {
         // No images in the category
         if (empty($strCategoryComment)) {
             $this->_objTpl->hideBlock('galleryImageBlock');
         } else {
             $this->_objTpl->setVariable(array('GALLERY_CATEGORY_COMMENT' => $strCategoryComment));
         }
     } else {
         $this->_objTpl->setVariable(array('GALLERY_CATEGORY_COMMENT' => $strCategoryComment));
         $intFillLastRow = 1;
         while (!$objResult->EOF) {
             $imageVotingOutput = '';
             $imageCommentOutput = '';
             $objSubResult = $objDatabase->Execute("SELECT p.name, p.desc FROM " . DBPREFIX . "module_gallery_language_pics p " . "WHERE picture_id=" . $objResult->fields['id'] . " AND lang_id={$this->langId} LIMIT 1");
             // Never used
             //                $imageReso = getimagesize($this->strImagePath.$objResult->fields['path']);
             $strImagePath = $this->strImageWebPath . $objResult->fields['path'];
             $imageThumbPath = $this->strThumbnailWebPath . $objResult->fields['path'];
             $imageFileName = $this->arrSettings['show_file_name'] == 'on' ? $objResult->fields['path'] : '';
             $imageName = $this->arrSettings['show_names'] == 'on' ? $objSubResult->fields['name'] : '';
             $imageTitle = $this->arrSettings['show_names'] == 'on' ? $objSubResult->fields['name'] : ($this->arrSettings['show_file_name'] == 'on' ? $objResult->fields['path'] : '');
             $imageLinkName = $objSubResult->fields['desc'];
             $imageLink = $objResult->fields['link'];
             $showImageSize = $this->arrSettings['show_image_size'] == 'on' && $objResult->fields['size_show'];
             $imageFileSize = $showImageSize ? round(filesize($this->strImagePath . $objResult->fields['path']) / 1024, 2) : '';
             $imageLinkOutput = '';
             $imageSizeOutput = '';
             $imageTitleTag = '';
             // chop the file extension if the settings tell us to do so
             if ($this->arrSettings['show_ext'] == 'off') {
                 $imageFileName = substr($imageFileName, 0, strrpos($imageFileName, '.'));
             }
             if ($this->arrSettings['slide_show'] == 'slideshow') {
                 $optionValue = "slideshowDelay:" . $this->arrSettings['slide_show_seconds'];
             } else {
                 $optionValue = "counterType:'skip',continuous:true,animSequence:'sync'";
             }
             //calculation starts here
             $numberOfChars = "60";
             if ($imageLinkName != "") {
                 if (strlen($imageLinkName) > $numberOfChars) {
                     $descriptionString = "&nbsp;&nbsp;&nbsp;" . substr($imageLinkName, 0, $numberOfChars);
                     $descriptionString .= " ...";
                 } else {
                     $descriptionString = "&nbsp;&nbsp;&nbsp;" . $imageLinkName;
                 }
             } else {
                 $descriptionString = "";
             }
             //Ends here
             if ($this->arrSettings['show_names'] == 'on' || $this->arrSettings['show_file_name'] == 'on') {
                 $imageSizeOutput = $imageName;
                 $imageTitleTag = $imageName;
                 if ($this->arrSettings['show_file_name'] == 'on' || $showImageSize) {
                     $imageData = array();
                     if ($this->arrSettings['show_file_name'] == 'on') {
                         if ($this->arrSettings['show_names'] == 'off') {
                             $imageSizeOutput .= $imageFileName;
                             $imageTitleTag .= $imageFileName;
                         } else {
                             $imageData[] = $imageFileName;
                         }
                     }
                     if (!empty($imageData)) {
                         $imageTitleTag .= ' (' . join(' ', $imageData) . ')';
                     }
                     if ($showImageSize) {
                         // the size of the file has to be shown
                         $imageData[] = $imageFileSize . ' kB';
                     }
                     if (!empty($imageData)) {
                         $imageSizeOutput .= ' (' . join(' ', $imageData) . ')<br />';
                     }
                 }
             }
             if ($this->arrSettings['enable_popups'] == "on") {
                 $strImageOutput = '<a rel="shadowbox[' . $intParentId . '];options={' . $optionValue . '}"  title="' . $imageTitleTag . '" href="' . $strImagePath . '"><img title="' . $imageTitleTag . '" src="' . $imageThumbPath . '" alt="' . $imageTitleTag . '" /></a>';
                 /*
                                     $strImageOutput =
                 '<a rel="shadowbox['.$intParentId.'];options={'.$optionValue.
                 '}" description="'.$imageLinkName.'" title="'.$titleLink.'" href="'.
                 $strImagePath.'"><img title="'.$imageName.'" src="'.
                 $imageThumbPath.'" alt="'.$imageName.'" /></a>';
                 */
             } else {
                 $strImageOutput = '<a href="' . CONTREXX_DIRECTORY_INDEX . '?section=Gallery' . $this->strCmd . '&amp;cid=' . $intParentId . '&amp;pId=' . $objResult->fields['id'] . '">' . '<img  title="' . $imageTitleTag . '" src="' . $imageThumbPath . '"' . 'alt="' . $imageTitleTag . '" /></a>';
             }
             if ($this->arrSettings['show_comments'] == 'on' && $boolComment) {
                 $objSubResult = $objDatabase->Execute("SELECT id FROM " . DBPREFIX . "module_gallery_comments " . "WHERE picid=" . $objResult->fields['id']);
                 if ($objSubResult->RecordCount() > 0) {
                     if ($objSubResult->RecordCount() == 1) {
                         $imageCommentOutput = '1 ' . $_ARRAYLANG['TXT_COMMENTS_ADD_TEXT'] . '<br />';
                     } else {
                         $imageCommentOutput = $objSubResult->RecordCount() . ' ' . $_ARRAYLANG['TXT_COMMENTS_ADD_COMMENTS'] . '<br />';
                     }
                 }
             }
             if ($this->arrSettings['show_voting'] == 'on' && $boolVoting) {
                 $objSubResult = $objDatabase->Execute("SELECT mark FROM " . DBPREFIX . "module_gallery_votes " . "WHERE picid=" . $objResult->fields["id"]);
                 if ($objSubResult->RecordCount() > 0) {
                     $intMark = 0;
                     while (!$objSubResult->EOF) {
                         $intMark = $intMark + $objSubResult->fields['mark'];
                         $objSubResult->MoveNext();
                     }
                     $imageVotingOutput = $_ARRAYLANG['TXT_VOTING_SCORE'] . '&nbsp;&Oslash;' . number_format(round($intMark / $objSubResult->RecordCount(), 1), 1, '.', '\'') . '<br />';
                 }
             }
             if (!empty($imageLinkName)) {
                 if (!empty($imageLink)) {
                     $imageLinkOutput = '<a href="' . $imageLink . '" target="_blank">' . $imageLinkName . '</a>';
                 } else {
                     $imageLinkOutput = $imageLinkName;
                 }
             } else {
                 if (!empty($imageLink)) {
                     $imageLinkOutput = '<a href="' . $imageLink . '" target="_blank">' . $imageLink . '</a>';
                 }
             }
             $this->_objTpl->setVariable(array('GALLERY_IMAGE_LINK' . $intFillLastRow => $imageSizeOutput . $imageCommentOutput . $imageVotingOutput . $imageLinkOutput, 'GALLERY_IMAGE' . $intFillLastRow => $strImageOutput));
             if ($intFillLastRow == 3) {
                 // Parse the data after every third image
                 $this->_objTpl->parse('galleryShowImages');
                 $intFillLastRow = 1;
             } else {
                 $intFillLastRow++;
             }
             $objResult->MoveNext();
         }
         if ($intFillLastRow == 2) {
             $this->_objTpl->setVariable(array('GALLERY_IMAGE' . $intFillLastRow => '', 'GALLERY_IMAGE_LINK' . $intFillLastRow => ''));
             $intFillLastRow++;
         }
         if ($intFillLastRow == 3) {
             $this->_objTpl->setVariable(array('GALLERY_IMAGE' . $intFillLastRow => '', 'GALLERY_IMAGE_LINK' . $intFillLastRow => ''));
             $this->_objTpl->parse('galleryShowImages');
         }
     }
     $this->_objTpl->parse('galleryCategories');
 }
Exemple #8
0
 public function getPage($pos, $page_content)
 {
     global $_CONFIG, $_ARRAYLANG;
     $objTpl = new \Cx\Core\Html\Sigma('.');
     \Cx\Core\Csrf\Controller\Csrf::add_placeholder($objTpl);
     $objTpl->setErrorHandling(PEAR_ERROR_DIE);
     $objTpl->setTemplate($page_content);
     $objTpl->setGlobalVariable($_ARRAYLANG);
     // Load main template even if we have a cmd set
     if ($objTpl->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('Search');
         // load source code
         $applicationTemplate = \Cx\Core\Core\Controller\Cx::getContentTemplateOfPage($page);
         \LinkGenerator::parseTemplate($applicationTemplate);
         $objTpl->addBlock('APPLICATION_DATA', 'application_data', $applicationTemplate);
     }
     $term = isset($_REQUEST['term']) ? trim(contrexx_input2raw($_REQUEST['term'])) : '';
     if (strlen($term) >= 3) {
         $term = trim(contrexx_input2raw($_REQUEST['term']));
         $this->setTerm($term);
         $eventHandlerInstance = \Env::get('cx')->getEvents();
         $eventHandlerInstance->triggerEvent('SearchFindContent', array($this));
         if ($this->result->size() == 1) {
             $arraySearchResults[] = $this->result->toArray();
         } else {
             $arraySearchResults = $this->result->toArray();
         }
         usort($arraySearchResults, function ($a, $b) {
             if ($a['Score'] == $b['Score']) {
                 if (isset($a['Date'])) {
                     if ($a['Date'] == $b['Date']) {
                         return 0;
                     }
                     if ($a['Date'] > $b['Date']) {
                         return -1;
                     }
                     return 1;
                 }
                 return 0;
             }
             if ($a['Score'] > $b['Score']) {
                 return -1;
             }
             return 1;
         });
         $countResults = sizeof($arraySearchResults);
         if (!is_numeric($pos)) {
             $pos = 0;
         }
         $paging = getPaging($countResults, $pos, '&amp;section=Search&amp;term=' . contrexx_raw2encodedUrl($term), '<b>' . $_ARRAYLANG['TXT_SEARCH_RESULTS'] . '</b>', true);
         $objTpl->setVariable('SEARCH_PAGING', $paging);
         $objTpl->setVariable('SEARCH_TERM', contrexx_raw2xhtml($term));
         if ($countResults > 0) {
             $searchComment = sprintf($_ARRAYLANG['TXT_SEARCH_RESULTS_ORDER_BY_RELEVANCE'], contrexx_raw2xhtml($term), $countResults);
             $objTpl->setVariable('SEARCH_TITLE', $searchComment);
             $arraySearchOut = array_slice($arraySearchResults, $pos, $_CONFIG['corePagingLimit']);
             foreach ($arraySearchOut as $details) {
                 // append search term to result link
                 $link = $details['Link'];
                 if (strpos($link, '?') === false) {
                     $link .= '?';
                 } else {
                     $link .= '&';
                 }
                 $link .= 'searchTerm=' . urlencode($term);
                 // parse result into template
                 $objTpl->setVariable(array('COUNT_MATCH' => $_ARRAYLANG['TXT_RELEVANCE'] . ' ' . $details['Score'] . '%', 'LINK' => '<b><a href="' . $link . '" title="' . contrexx_raw2xhtml($details['Title']) . '">' . contrexx_raw2xhtml($details['Title']) . '</a></b>', 'SHORT_CONTENT' => contrexx_raw2xhtml($details['Content'])));
                 $objTpl->parse('search_result');
             }
             return $objTpl->get();
         }
     }
     $noresult = $term != '' ? sprintf($_ARRAYLANG['TXT_NO_SEARCH_RESULTS'], $term) : $_ARRAYLANG['TXT_PLEASE_ENTER_SEARCHTERM'];
     $objTpl->setVariable('SEARCH_TITLE', $noresult);
     return $objTpl->get();
 }
 function showEntry()
 {
     global $_ARRAYLANG, $_CORELANG;
     $this->_objTpl->setTemplate($this->pageContent, true, true);
     //get ids
     $intCategoryId = isset($_GET['cid']) ? intval($_GET['cid']) : 0;
     $intLevelId = isset($_GET['lid']) ? intval($_GET['lid']) : 0;
     $intEntryId = isset($_GET['eid']) ? intval($_GET['eid']) : 0;
     // load source code if cmd value is integer
     if ($this->_objTpl->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('MediaDir');
         $page->setCmd('detail');
         // load source code
         $applicationTemplate = \Cx\Core\Core\Controller\Cx::getContentTemplateOfPage($page);
         \LinkGenerator::parseTemplate($applicationTemplate);
         $this->_objTpl->addBlock('APPLICATION_DATA', 'application_data', $applicationTemplate);
     }
     //get navtree
     if ($this->_objTpl->blockExists($this->moduleNameLC . 'Navtree') && ($intCategoryId != 0 || $intLevelId != 0)) {
         $this->getNavtree($intCategoryId, $intLevelId);
     }
     if ($intEntryId != 0 && $this->_objTpl->blockExists($this->moduleNameLC . 'EntryList')) {
         $objEntry = new MediaDirectoryEntry($this->moduleName);
         $objEntry->getEntries($intEntryId, $intLevelId, $intCategoryId, null, null, null, 1, null, 1);
         $objEntry->listEntries($this->_objTpl, 2);
         $objEntry->updateHits($intEntryId);
         //set meta attributes
         $entries = new MediaDirectoryEntry($this->moduleName);
         $entries->getEntries($intEntryId, $intLevelId, $intCategoryId, null, null, null, 1, null, 1);
         $entry = $entries->arrEntries[$intEntryId];
         $objInputfields = new MediaDirectoryInputfield($entry['entryFormId'], false, $entry['entryTranslationStatus'], $this->moduleName);
         $inputFields = $objInputfields->getInputfields();
         $titleChanged = false;
         $contentChanged = false;
         foreach ($inputFields as $arrInputfield) {
             $contextType = isset($arrInputfield['context_type']) ? $arrInputfield['context_type'] : '';
             if (!in_array($contextType, array('title', 'content', 'image'))) {
                 continue;
             }
             $strType = isset($arrInputfield['type_name']) ? $arrInputfield['type_name'] : '';
             $strInputfieldClass = "\\Cx\\Modules\\MediaDir\\Model\\Entity\\MediaDirectoryInputfield" . ucfirst($strType);
             try {
                 $objInputfield = safeNew($strInputfieldClass, $this->moduleName);
                 $arrTranslationStatus = contrexx_input2int($arrInputfield['type_multi_lang']) == 1 ? $entry['entryTranslationStatus'] : null;
                 $arrInputfieldContent = $objInputfield->getContent($entry['entryId'], $arrInputfield, $arrTranslationStatus);
                 switch ($contextType) {
                     case 'title':
                         $inputfieldValue = $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'];
                         if ($inputfieldValue) {
                             $this->metaTitle .= ' - ' . $inputfieldValue;
                             $this->pageTitle = $inputfieldValue;
                         }
                         $titleChanged = true;
                         break;
                     case 'content':
                         $inputfieldValue = $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'];
                         if ($inputfieldValue) {
                             $this->metaDescription = $inputfieldValue;
                         }
                         $contentChanged = true;
                         break;
                     case 'image':
                         $inputfieldValue = $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE_SRC'];
                         if ($inputfieldValue) {
                             $this->metaImage = $inputfieldValue;
                         }
                         break;
                     default:
                         break;
                 }
             } catch (\Exception $e) {
                 \DBG::log($e->getMessage());
                 continue;
             }
         }
         $firstInputfieldValue = $entries->arrEntries[$intEntryId]['entryFields'][0];
         if (!$titleChanged && $firstInputfieldValue) {
             $this->pageTitle = $firstInputfieldValue;
             $this->metaTitle = $firstInputfieldValue;
         }
         if (!$contentChanged && $firstInputfieldValue) {
             $this->metaDescription = $firstInputfieldValue;
         }
         if (empty($objEntry->arrEntries)) {
             $this->_objTpl->hideBlock($this->moduleNameLC . 'EntryList');
             $this->_objTpl->clearVariables();
             header("Location: index.php?section=" . $this->moduleName);
             exit;
         }
     } else {
         header("Location: index.php?section=" . $this->moduleName);
         exit;
     }
 }