function getHomeTopNews($catId = 0) { global $_CORELANG, $objDatabase; $catId = intval($catId); $i = 0; $this->_objTemplate->setTemplate($this->_pageContent, true, true); if ($this->_objTemplate->blockExists('newsrow')) { $this->_objTemplate->setCurrentBlock('newsrow'); } else { return null; } $newsLimit = intval($this->arrSettings['news_top_limit']); if ($newsLimit > 50) { //limit to a maximum of 50 news $newsLimit = 50; } if ($newsLimit < 1) { //do not get any news if 0 was specified as the limit. $objResult = false; } else { //fetch news $objResult = $objDatabase->SelectLimit("\n SELECT DISTINCT(tblN.id) AS id,\n tblN.`date`, \n tblN.teaser_image_path,\n tblN.teaser_image_thumbnail_path,\n tblN.redirect,\n tblN.publisher,\n tblN.publisher_id,\n tblN.author,\n tblN.author_id,\n tblL.title AS title, \n tblL.teaser_text\n FROM " . DBPREFIX . "module_news AS tblN\n INNER JOIN " . DBPREFIX . "module_news_locale AS tblL ON tblL.news_id=tblN.id\n INNER JOIN " . DBPREFIX . "module_news_rel_categories AS tblC ON tblC.news_id=tblL.news_id\n WHERE tblN.status=1" . ($catId > 0 ? " AND tblC.category_id={$catId}" : '') . "\n AND tblN.teaser_only='0'\n AND tblL.lang_id=" . FRONTEND_LANG_ID . "\n AND (startdate<='" . date('Y-m-d H:i:s') . "' OR startdate='0000-00-00 00:00:00')\n AND (enddate>='" . date('Y-m-d H:i:s') . "' OR enddate='0000-00-00 00:00:00')" . ($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 " : '') . "ORDER BY\n (SELECT COUNT(*) FROM " . DBPREFIX . "module_news_stats_view WHERE news_id=tblN.id AND time>'" . date_format(date_sub(date_create('now'), date_interval_create_from_date_string(intval($this->arrSettings['news_top_days']) . ' day')), 'Y-m-d H:i:s') . "') DESC", $newsLimit); } if ($objResult !== false && $objResult->RecordCount()) { while (!$objResult->EOF) { $newsid = $objResult->fields['id']; $newstitle = $objResult->fields['title']; $author = \FWUser::getParsedUserTitle($objResult->fields['author_id'], $objResult->fields['author']); $publisher = \FWUser::getParsedUserTitle($objResult->fields['publisher_id'], $objResult->fields['publisher']); $newsCategories = $this->getCategoriesByNewsId($newsid); $newsUrl = empty($objResult->fields['redirect']) ? \Cx\Core\Routing\Url::fromModuleAndCmd('News', $this->findCmdById('details', self::sortCategoryIdByPriorityId(array_keys($newsCategories), array($catId))), FRONTEND_LANG_ID, array('newsid' => $newsid)) : $objResult->fields['redirect']; $htmlLink = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml($newstitle)); list($image, $htmlLinkImage, $imageSource) = self::parseImageThumbnail($objResult->fields['teaser_image_path'], $objResult->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl); $this->_objTemplate->setVariable(array('NEWS_ID' => $newsid, 'NEWS_CSS' => 'row' . ($i % 2 + 1), 'NEWS_LONG_DATE' => date(ASCMS_DATE_FORMAT, $objResult->fields['date']), 'NEWS_DATE' => date(ASCMS_DATE_FORMAT_DATE, $objResult->fields['date']), 'NEWS_TIME' => date(ASCMS_DATE_FORMAT_TIME, $objResult->fields['date']), 'NEWS_TITLE' => contrexx_raw2xhtml($newstitle), 'NEWS_TEASER' => nl2br($objResult->fields['teaser_text']), 'NEWS_LINK' => $htmlLink, 'NEWS_LINK_URL' => contrexx_raw2xhtml($newsUrl), 'NEWS_AUTHOR' => contrexx_raw2xhtml($author), 'NEWS_PUBLISHER' => contrexx_raw2xhtml($publisher))); if (!empty($image)) { $this->_objTemplate->setVariable(array('NEWS_IMAGE' => $image, 'NEWS_IMAGE_SRC' => contrexx_raw2xhtml($imageSource), 'NEWS_IMAGE_ALT' => contrexx_raw2xhtml($newstitle), 'NEWS_IMAGE_LINK' => $htmlLinkImage)); if ($this->_objTemplate->blockExists('news_image')) { $this->_objTemplate->parse('news_image'); } } else { if ($this->_objTemplate->blockExists('news_image')) { $this->_objTemplate->hideBlock('news_image'); } } self::parseImageBlock($this->_objTemplate, $objResult->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl, 'image_thumbnail'); self::parseImageBlock($this->_objTemplate, $objResult->fields['teaser_image_path'], $newstitle, $newsUrl, 'image_detail'); $this->_objTemplate->parseCurrentBlock(); $i++; $objResult->MoveNext(); } } else { $this->_objTemplate->hideBlock('newsrow'); } $this->_objTemplate->setVariable("TXT_MORE_NEWS", $_CORELANG['TXT_MORE_NEWS']); return $this->_objTemplate->get(); }
function getHomeHeadlines($catId = 0) { global $_CORELANG, $objDatabase, $_LANGID; $i = 0; $catId = intval($catId); $this->_objTemplate->setTemplate($this->_pageContent, true, true); $newsLimit = intval($this->arrSettings['news_headlines_limit']); if ($newsLimit > 50) { //limit to a maximum of 50 news $newsLimit = 50; } if ($newsLimit < 1) { //do not get any news if 0 was specified as the limit. $objResult = false; } else { //fetch news $objResult = $objDatabase->SelectLimit("\n SELECT DISTINCT(tblN.id) AS id,\n tblN.`date`, \n tblN.teaser_image_path,\n tblN.teaser_image_thumbnail_path,\n tblN.redirect,\n tblN.publisher,\n tblN.publisher_id,\n tblN.author,\n tblN.author_id,\n tblL.text NOT REGEXP '^(<br type=\"_moz\" />)?\$' AS newscontent,\n tblL.title AS title, \n tblL.teaser_text\n FROM " . DBPREFIX . "module_news AS tblN\n INNER JOIN " . DBPREFIX . "module_news_locale AS tblL ON tblL.news_id=tblN.id\n INNER JOIN " . DBPREFIX . "module_news_rel_categories AS tblC ON tblC.news_id=tblL.news_id\n WHERE tblN.status=1" . ($catId > 0 ? " AND tblC.category_id={$catId}" : '') . "\n AND tblN.teaser_only='0'\n AND tblL.lang_id=" . $_LANGID . "\n AND tblL.is_active=1\n AND (startdate<='" . date('Y-m-d H:i:s') . "' OR startdate='0000-00-00 00:00:00')\n AND (enddate>='" . date('Y-m-d H:i:s') . "' OR enddate='0000-00-00 00:00:00')" . ($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 " : '') . "ORDER BY date DESC", $newsLimit); } if ($objResult !== false && $objResult->RecordCount() >= 0) { while (!$objResult->EOF) { $newsid = $objResult->fields['id']; $newstitle = $objResult->fields['title']; $newsCategories = $this->getCategoriesByNewsId($newsid); $newsUrl = empty($objResult->fields['redirect']) ? empty($objResult->fields['newscontent']) ? '' : \Cx\Core\Routing\Url::fromModuleAndCmd('News', $this->findCmdById('details', self::sortCategoryIdByPriorityId(array_keys($newsCategories), array($catId))), FRONTEND_LANG_ID, array('newsid' => $newsid)) : $objResult->fields['redirect']; $htmlLink = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml($newstitle), 'headlineLink'); $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']); $this->_objTemplate->setVariable(array('NEWS_ID' => $newsid, 'NEWS_CSS' => 'row' . ($i % 2 + 1), 'NEWS_LONG_DATE' => date(ASCMS_DATE_FORMAT, $objResult->fields['date']), 'NEWS_DATE' => date(ASCMS_DATE_FORMAT_DATE, $objResult->fields['date']), 'NEWS_TIME' => date(ASCMS_DATE_FORMAT_TIME, $objResult->fields['date']), 'NEWS_TITLE' => contrexx_raw2xhtml($newstitle), 'NEWS_TEASER' => nl2br($objResult->fields['teaser_text']), 'NEWS_LINK_TITLE' => $htmlLinkTitle, 'NEWS_LINK' => $htmlLink, 'NEWS_LINK_URL' => contrexx_raw2xhtml($newsUrl), 'NEWS_AUTHOR' => contrexx_raw2xhtml($author), 'NEWS_PUBLISHER' => contrexx_raw2xhtml($publisher), 'HEADLINE_ID' => $newsid, 'HEADLINE_DATE' => date(ASCMS_DATE_FORMAT_DATE, $objResult->fields['date']), 'HEADLINE_TEXT' => nl2br($objResult->fields['teaser_text']), 'HEADLINE_LINK' => $htmlLinkTitle, 'HEADLINE_AUTHOR' => contrexx_raw2xhtml($author))); if (!empty($image)) { $this->_objTemplate->setVariable(array('NEWS_IMAGE' => $image, 'NEWS_IMAGE_SRC' => contrexx_raw2xhtml($imageSource), 'NEWS_IMAGE_ALT' => contrexx_raw2xhtml($newstitle), 'NEWS_IMAGE_LINK' => $htmlLinkImage, 'HEADLINE_IMAGE_PATH' => contrexx_raw2xhtml($objResult->fields['teaser_image_path']), 'HEADLINE_THUMBNAIL_PATH' => contrexx_raw2xhtml($imageSource))); if ($this->_objTemplate->blockExists('news_image')) { $this->_objTemplate->parse('news_image'); } } else { if ($this->_objTemplate->blockExists('news_image')) { $this->_objTemplate->hideBlock('news_image'); } } self::parseImageBlock($this->_objTemplate, $objResult->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl, 'image_thumbnail'); self::parseImageBlock($this->_objTemplate, $objResult->fields['teaser_image_path'], $newstitle, $newsUrl, 'image_detail'); $this->_objTemplate->parse('headlines_row'); $i++; $objResult->MoveNext(); } } else { $this->_objTemplate->hideBlock('headlines_row'); } $this->_objTemplate->setVariable("TXT_MORE_NEWS", $_CORELANG['TXT_MORE_NEWS']); return $this->_objTemplate->get(); }
/** * Returns the PayPal form for initializing the payment process * @param string $account_email The PayPal account e-mail address * @param string $order_id The Order ID * @param string $currency_code The Currency code * @param string $amount The amount * @param string $item_name The description used for the payment * @return string The HTML code for the PayPal form */ static function getForm($account_email, $order_id, $currency_code, $amount, $item_name) { global $_ARRAYLANG; //DBG::log("getForm($account_email, $order_id, $currency_code, $amount, $item_name): Entered"); $return = \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'success', FRONTEND_LANG_ID, array('handler' => 'paypal', 'result' => '1', 'order_id' => $order_id))->toString(); $cancel_return = \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'success', FRONTEND_LANG_ID, array('handler' => 'paypal', 'result' => '2', 'order_id' => $order_id))->toString(); $notify_url = \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'success', FRONTEND_LANG_ID, array('handler' => 'paypal', 'result' => '-1', 'order_id' => $order_id))->toString(); $retval = (\Cx\Core\Setting\Controller\Setting::getValue('paypal_active', 'Shop') ? '<script type="text/javascript"> // <![CDATA[ function go() { document.paypal.submit(); } window.setTimeout("go()", 3000); // ]]> </script> <form name="paypal" method="post" action="https://www.paypal.com/ch/cgi-bin/webscr"> ' : '<form name="paypal" method="post" action="https://www.sandbox.paypal.com/ch/cgi-bin/webscr"> ') . Html::getHidden('cmd', '_xclick') . Html::getHidden('business', $account_email) . Html::getHidden('item_name', $item_name) . Html::getHidden('currency_code', $currency_code) . Html::getHidden('amount', $amount) . Html::getHidden('custom', $order_id) . Html::getHidden('notify_url', $notify_url) . Html::getHidden('return', $return) . Html::getHidden('cancel_return', $cancel_return) . $_ARRAYLANG['TXT_PAYPAL_SUBMIT'] . '<br /><br />' . '<input type="submit" name="submitbutton" value="' . $_ARRAYLANG['TXT_PAYPAL_SUBMIT_BUTTON'] . "\" />\n</form>\n"; return $retval; }
/** * Global search event listener * Appends the News search results to the search object * * @param array $eventArgs */ private function SearchFindContent(array $eventArgs) { $search = current($eventArgs); $term_db = contrexx_raw2db($search->getTerm()); $query = "SELECT id, text AS content, title, date, redirect,\n MATCH (text,title,teaser_text) AGAINST ('%{$term_db}%') AS score\n FROM " . DBPREFIX . "module_news AS tblN\n INNER JOIN " . DBPREFIX . "module_news_locale AS tblL ON tblL.news_id = tblN.id\n WHERE ( text LIKE ('%{$term_db}%')\n OR title LIKE ('%{$term_db}%')\n OR teaser_text LIKE ('%{$term_db}%'))\n AND lang_id=" . FRONTEND_LANG_ID . "\n AND status=1\n AND is_active=1\n AND (startdate<='" . date('Y-m-d') . "' OR startdate='0000-00-00')\n AND (enddate>='" . date('Y-m-d') . "' OR enddate='0000-00-00')"; $pageUrl = function ($pageUri, $searchData) { static $objNewsLib = null; if (!$objNewsLib) { $objNewsLib = new \Cx\Core_Modules\News\Controller\NewsLibrary(); } if (empty($searchData['redirect'])) { $newsId = $searchData['id']; $newsCategories = $objNewsLib->getCategoriesByNewsId($newsId); $objUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('News', $objNewsLib->findCmdById('details', array_keys($newsCategories)), FRONTEND_LANG_ID, array('newsid' => $newsId)); $pageUrlResult = $objUrl->toString(); } else { $pageUrlResult = $searchData['redirect']; } return $pageUrlResult; }; $result = new \Cx\Core_Modules\Listing\Model\Entity\DataSet($search->getResultArray($query, 'News', '', $pageUrl, $search->getTerm())); $search->appendResult($result); }
/** * Show one category * @param unknown_type $id */ function showCategory($id) { global $_ARRAYLANG; $arrEntries = $this->createEntryArray($this->_intLanguageId); $this->createSettingsArray(); foreach ($arrEntries as $key => $value) { if ($value['active']) { // check date if ($value['release_time'] != 0) { if ($value['release_time'] > time()) { // too old continue; } // if it is not endless (0), check if 'now' is past the given date if ($value['release_time_end'] != 0 && time() > $value['release_time_end']) { continue; } } if ($this->categoryMatches($id, $value['categories'][$this->_intLanguageId])) { $this->_objTpl->setVariable(array("ENTRY_TITLE" => $value['translation'][$this->_intLanguageId]['subject'], "ENTRY_CONTENT" => $this->getIntroductionText($value['translation'][$this->_intLanguageId]['content']), "ENTRY_ID" => $key, "ENTRY_HREF" => \Cx\Core\Routing\Url::fromModuleAndCmd('Data', $this->curCmd, '', array('id' => $key)), "TXT_MORE" => $_ARRAYLANG['TXT_DATA_MORE'], "CMD" => $this->curCmd)); $this->_objTpl->parse("entry"); } } } $this->_objTpl->parse("showDataCategory"); }
/** * Writes RSS feed containing the latest N messages of each category the feed-directory. This is done for every language seperately. * * @global array * @global array * @global FWLanguage */ function writeCategoryRSS() { global $_CONFIG, $_ARRAYLANG; if (intval($this->_arrSettings['blog_rss_activated'])) { $arrCategories = $this->createCategoryArray(); //Iterate over all languages foreach ($this->_arrLanguages as $intLanguageId => $arrLanguageValues) { $arrEntries = $this->createEntryArray($intLanguageId); //If there exist entries in this language go on, otherwise skip if (count($arrEntries) > 0) { //Iterate over all categories foreach ($arrCategories as $intCategoryId => $arrCategoryTranslation) { //If the category is activated in this language, find assigned messages if ($arrCategoryTranslation[$intLanguageId]['is_active']) { $intNumberOfMessages = 0; //Counts found messages for this category $objRSSWriter = new \RSSWriter(); $objRSSWriter->characterEncoding = CONTREXX_CHARSET; $objRSSWriter->channelTitle = $_CONFIG['coreGlobalPageTitle'] . ' - ' . $_ARRAYLANG['TXT_BLOG_LIB_RSS_MESSAGES_TITLE']; $objRSSWriter->channelLink = \Cx\Core\Routing\Url::fromModuleAndCmd('Blog', '', $intLanguageId)->toString(); $objRSSWriter->channelDescription = $_CONFIG['coreGlobalPageTitle'] . ' - ' . $_ARRAYLANG['TXT_BLOG_LIB_RSS_MESSAGES_TITLE'] . ' (' . $arrCategoryTranslation[$intLanguageId]['name'] . ')'; $objRSSWriter->channelCopyright = 'Copyright ' . date('Y') . ', http://' . $_CONFIG['domainUrl']; //Function doesn't exist //$objRSSWriter->channelLanguage = \FWLanguage::getLanguageParameter($intLanguageId, 'lang'); $objRSSWriter->channelWebMaster = $_CONFIG['coreAdminEmail']; //Find assigned messages $entryUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Blog', 'details', $intLanguageId); foreach ($arrEntries as $intEntryId => $arrEntryValues) { if ($this->categoryMatches($intCategoryId, $arrEntryValues['categories'][$intLanguageId])) { //Message is in category, add to feed $entryUrl->setParam('id', $intEntryId); $objRSSWriter->addItem(html_entity_decode($arrEntryValues['subject'], ENT_QUOTES, CONTREXX_CHARSET), contrexx_raw2xhtml($entryUrl->toString()), htmlspecialchars($arrEntryValues['translation'][$intLanguageId]['content'], ENT_QUOTES, CONTREXX_CHARSET), htmlspecialchars($arrEntryValues['user_name'], ENT_QUOTES, CONTREXX_CHARSET), '', '', '', '', $arrEntryValues['time_created_ts'], ''); $intNumberOfMessages++; //Check for message-limit if ($intNumberOfMessages >= intval($this->_arrSettings['blog_rss_messages'])) { break; } } } $objRSSWriter->xmlDocumentPath = \Env::get('cx')->getWebsiteFeedPath() . '/blog_category_' . $intCategoryId . '_' . $arrLanguageValues['short'] . '.xml'; $objRSSWriter->write(); \Cx\Lib\FileSystem\FileSystem::makeWritable(\Env::get('cx')->getWebsiteFeedPath() . '/blog_category_' . $intCategoryId . '_' . $arrLanguageValues['short'] . '.xml'); } } } } } }
/** * Performs the box view * * @return null */ function showThreeBoxes() { global $_ARRAYLANG; $objEventManager = new \Cx\Modules\Calendar\Controller\CalendarEventManager($this->startDate, $this->endDate, $this->categoryId, $this->searchTerm, true, $this->needAuth, true, 0, 'n', $this->sortDirection, true, $this->author); $objEventManager->getEventList(); $this->_objTpl->setTemplate($this->pageContent); if ($_REQUEST['cmd'] == 'boxes') { $objEventManager->calendarBoxUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Calendar', 'boxes')->toString() . "?act=list"; $objEventManager->calendarBoxMonthNavUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Calendar', 'boxes')->toString(); } else { $objEventManager->calendarBoxUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Calendar', '')->toString() . "?act=list"; $objEventManager->calendarBoxMonthNavUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Calendar', '')->toString(); } if (empty($_GET['catid'])) { $catid = 0; } else { $catid = $_GET['catid']; } if (isset($_GET['yearID']) && isset($_GET['monthID']) && isset($_GET['dayID'])) { $day = $_GET['dayID']; $month = $_GET['monthID']; $year = $_GET['yearID']; } elseif (isset($_GET['yearID']) && isset($_GET['monthID']) && !isset($_GET['dayID'])) { $day = 0; $month = $_GET['monthID']; $year = $_GET['yearID']; } elseif (isset($_GET['yearID']) && !isset($_GET['monthID']) && !isset($_GET['dayID'])) { $day = 0; $month = 0; $year = $_GET['yearID']; } else { $day = date("d"); $month = date("m"); $year = date("Y"); } $calendarbox = $objEventManager->getBoxes($this->boxCount, $year, $month, $day, $catid); $objCategoryManager = new \Cx\Modules\Calendar\Controller\CalendarCategoryManager(true); $objCategoryManager->getCategoryList(); $this->_objTpl->setVariable(array("TXT_{$this->moduleLangVar}_ALL_CAT" => $_ARRAYLANG['TXT_CALENDAR_ALL_CAT'], "{$this->moduleLangVar}_BOX" => $calendarbox, "{$this->moduleLangVar}_JAVA_SCRIPT" => $objEventManager->getCalendarBoxJS(), "{$this->moduleLangVar}_CATEGORIES" => $objCategoryManager->getCategoryDropdown($catid, 1))); }
/** * Get a list of all news messages sorted by year and month. * * @access private * @return string parsed content */ private function getArchive() { global $objDatabase, $_ARRAYLANG; $categories = ''; $i = 0; if ($categories = substr($_REQUEST['cmd'], 7)) { $categories = $this->getCatIdsFromNestedSetArray($this->getNestedSetCategories(explode(',', $categories))); } $monthlyStats = $this->getMonthlyNewsStats($categories); if (!empty($monthlyStats)) { foreach ($monthlyStats as $key => $value) { $this->_objTpl->setVariable(array('NEWS_ARCHIVE_MONTH_KEY' => $key, 'NEWS_ARCHIVE_MONTH_NAME' => $value['name'], 'NEWS_ARCHIVE_MONTH_COUNT' => count($value['news']))); $this->_objTpl->parse('news_archive_months_list_item'); foreach ($value['news'] as $news) { $newsid = $news['id']; $newstitle = $news['newstitle']; $newsCategories = $this->getCategoriesByNewsId($newsid); $newsCommentActive = $news['commentactive']; $newsUrl = empty($news['newsredirect']) ? empty($news['newscontent']) ? '' : \Cx\Core\Routing\Url::fromModuleAndCmd('News', $this->findCmdById('details', self::sortCategoryIdByPriorityId(array_keys($newsCategories), $categories)), FRONTEND_LANG_ID, array('newsid' => $newsid)) : $news['newsredirect']; $htmlLink = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml('[' . $_ARRAYLANG['TXT_NEWS_MORE'] . '...]')); list($image, $htmlLinkImage, $imageSource) = self::parseImageThumbnail($news['teaser_image_path'], $news['teaser_image_thumbnail_path'], $newstitle, $newsUrl); $author = \FWUser::getParsedUserTitle($news['author_id'], $news['author']); $publisher = \FWUser::getParsedUserTitle($news['publisher_id'], $news['publisher']); $objResult = $objDatabase->Execute('SELECT count(`id`) AS `countComments` FROM `' . DBPREFIX . 'module_news_comments` WHERE `newsid` = ' . $newsid); $this->_objTpl->setVariable(array('NEWS_ARCHIVE_ID' => $newsid, 'NEWS_ARCHIVE_CSS' => 'row' . ($i % 2 + 1), 'NEWS_ARCHIVE_TEASER' => nl2br($news['teaser_text']), 'NEWS_ARCHIVE_TITLE' => contrexx_raw2xhtml($newstitle), 'NEWS_ARCHIVE_LONG_DATE' => date(ASCMS_DATE_FORMAT, $news['newsdate']), 'NEWS_ARCHIVE_DATE' => date(ASCMS_DATE_FORMAT_DATE, $news['newsdate']), 'NEWS_ARCHIVE_TIME' => date(ASCMS_DATE_FORMAT_TIME, $news['newsdate']), 'NEWS_ARCHIVE_LINK_TITLE' => contrexx_raw2xhtml($newstitle), 'NEWS_ARCHIVE_LINK' => $htmlLink, 'NEWS_ARCHIVE_LINK_URL' => contrexx_raw2xhtml($newsUrl), 'NEWS_ARCHIVE_CATEGORY' => stripslashes($news['name']), 'NEWS_ARCHIVE_AUTHOR' => contrexx_raw2xhtml($author), 'NEWS_ARCHIVE_PUBLISHER' => contrexx_raw2xhtml($publisher), 'NEWS_ARCHIVE_COUNT_COMMENTS' => contrexx_raw2xhtml($objResult->fields['countComments'] . ' ' . $_ARRAYLANG['TXT_NEWS_COMMENTS']))); if (!$newsCommentActive || !$this->arrSettings['news_comments_activated']) { if ($this->_objTpl->blockExists('news_archive_comments_count')) { $this->_objTpl->hideBlock('news_archive_comments_count'); } } if (!empty($image)) { $this->_objTpl->setVariable(array('NEWS_ARCHIVE_IMAGE' => $image, 'NEWS_ARCHIVE_IMAGE_SRC' => contrexx_raw2xhtml($imageSource), 'NEWS_ARCHIVE_IMAGE_ALT' => contrexx_raw2xhtml($newstitle), 'NEWS_ARCHIVE_IMAGE_LINK' => $htmlLinkImage)); if ($this->_objTpl->blockExists('news_archive_image')) { $this->_objTpl->parse('news_archive_image'); } } elseif ($this->_objTpl->blockExists('news_archive_image')) { $this->_objTpl->hideBlock('news_archive_image'); } self::parseImageBlock($this->_objTpl, $news['teaser_image_thumbnail_path'], $newstitle, $newsUrl, 'archive_image_thumbnail'); self::parseImageBlock($this->_objTpl, $news['teaser_image_path'], $newstitle, $newsUrl, 'archive_image_detail'); $this->_objTpl->parse('news_archive_link'); $i++; } $this->_objTpl->setVariable(array('NEWS_ARCHIVE_MONTH_KEY' => $key, 'NEWS_ARCHIVE_MONTH_NAME' => $value['name'])); $this->_objTpl->parse('news_archive_month_list_item'); } $this->_objTpl->parse('news_archive_months_list'); $this->_objTpl->parse('news_archive_month_list'); if ($this->_objTpl->blockExists('news_archive_status_message')) { $this->_objTpl->hideBlock('news_archive_status_message'); } } else { $this->_objTpl->setVariable('TXT_NEWS_NO_NEWS_FOUND', $_ARRAYLANG['TXT_NEWS_NO_NEWS_FOUND']); if ($this->_objTpl->blockExists('news_archive_status_message')) { $this->_objTpl->parse('news_archive_status_message'); } $this->_objTpl->hideblock('news_archive_months_list'); $this->_objTpl->hideBlock('news_archive_month_list'); } return $this->_objTpl->get(); }
/** * Get a single entry view * @param int $id * @return string */ function getDetail($id) { global $_LANGID; if ($this->entryArray === false) { $this->entryArray = $this->createEntryArray(); } $entry = $this->entryArray[$id]; $title = $entry['translation'][$_LANGID]['subject']; $content = $this->getIntroductionText($entry['translation'][$_LANGID]['content']); $this->_objTpl->setTemplate($this->adjustTemplatePlaceholders($this->_arrSettings['data_template_entry'])); $translation = $entry['translation'][$_LANGID]; $image = $this->getThumbnailImage($id, $translation['image'], $translation['thumbnail'], $translation['thumbnail_type']); $lang = $_LANGID; $width = $this->_arrSettings['data_shadowbox_width']; $height = $this->_arrSettings['data_shadowbox_height']; if ($entry['mode'] == "normal") { if ($this->_arrSettings['data_entry_action'] == "content") { $cmd = $this->_arrSettings['data_target_cmd']; $url = \Cx\Core\Routing\Url::fromModuleAndCmd('Data', $cmd, '', array('id' => $id)); } else { $url = \Cx\Core\Routing\Url::fromModuleAndCmd('Data', '', '', array('height' => $height, 'width' => $width, 'id' => $id, 'lang' => $lang)); } } else { $url = $entry['translation'][$_LANGID]['forward_url'] . '&id=' . $id; } $templateVars = array("TITLE" => $title, "IMAGE" => $image, "CONTENT" => $content, "HREF" => $url, "CLASS" => $this->_arrSettings['data_entry_action'] == "overlaybox" && $entry['mode'] == "normal" ? "rel=\"shadowbox;width=" . $width . ";height=" . $height . "\"" : "", "TXT_MORE" => $this->langVars['TXT_DATA_MORE']); $this->_objTpl->setVariable($templateVars); $this->_objTpl->parse("datalist_entry"); return $this->_objTpl->get(); }
/** * Show the cameras * * @access private * @global array * @global array * @global array */ function showCams() { global $_ARRAYLANG, $_CONFIG, $_CORELANG; $this->_pageTitle = $_ARRAYLANG['TXT_SETTINGS']; $this->_objTpl->loadTemplateFile('module_livecam_cams.html'); $amount = $this->arrSettings['amount_of_cams']; $cams = $this->getCamSettings(); $this->_objTpl->setGlobalVariable(array('TXT_SETTINGS' => $_ARRAYLANG['TXT_SETTINGS'], 'TXT_CURRENT_IMAGE_URL' => $_ARRAYLANG['TXT_CURRENT_IMAGE_URL'], 'TXT_ARCHIVE_PATH' => $_ARRAYLANG['TXT_ARCHIVE_PATH'], 'TXT_SAVE' => $_ARRAYLANG['TXT_SAVE'], 'TXT_THUMBNAIL_PATH' => $_ARRAYLANG['TXT_THUMBNAIL_PATH'], 'TXT_SHADOWBOX_ACTIVE' => $_CORELANG['TXT_ACTIVATED'], 'TXT_SHADOWBOX_INACTIVE' => $_CORELANG['TXT_DEACTIVATED'], 'TXT_ACTIVATE_SHADOWBOX' => $_ARRAYLANG['TXT_ACTIVATE_SHADOWBOX'], 'TXT_ACTIVATE_SHADOWBOX_INFO' => $_ARRAYLANG['TXT_ACTIVATE_SHADOWBOX_INFO'], 'TXT_MAKE_A_FRONTEND_PAGE' => $_ARRAYLANG['TXT_MAKE_A_FRONTEND_PAGE'], 'TXT_CURRENT_IMAGE_MAX_SIZE' => $_ARRAYLANG['TXT_CURRENT_IMAGE_MAX_SIZE'], 'TXT_THUMBNAIL_MAX_SIZE' => $_ARRAYLANG['TXT_THUMBNAIL_MAX_SIZE'], 'TXT_CAM' => $_ARRAYLANG['TXT_CAM'], 'TXT_SUCCESS' => $_CORELANG['TXT_SETTINGS_UPDATED'], 'TXT_TO_MODULE' => $_ARRAYLANG['TXT_LIVECAM_TO_MODULE'], 'TXT_SHOWFROM' => $_ARRAYLANG['TXT_LIVECAM_SHOWFROM'], 'TXT_SHOWTILL' => $_ARRAYLANG['TXT_LIVECAM_SHOWTILL'], 'TXT_OCLOCK' => $_ARRAYLANG['TXT_LIVECAM_OCLOCK'])); for ($i = 1; $i <= $amount; $i++) { if ($cams[$i]['shadowboxActivate'] == 1) { $shadowboxActive = 'checked="checked"'; $shadowboxInctive = ''; } else { $shadowboxActive = ''; $shadowboxInctive = 'checked="checked"'; } try { // fetch CMD specific livecam page $camUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Livecam', $i, FRONTEND_LANG_ID, array(), '', false); } catch (\Cx\Core\Routing\UrlException $e) { // fetch generic livecam page $camUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('Livecam'); } $this->_objTpl->setVariable(array('CAM_NUMBER' => $i, 'LIVECAM_CAM_URL' => $camUrl, 'CURRENT_IMAGE_URL' => $cams[$i]['currentImagePath'], 'ARCHIVE_PATH' => $cams[$i]['archivePath'], 'THUMBNAIL_PATH' => $cams[$i]['thumbnailPath'], 'SHADOWBOX_ACTIVE' => $shadowboxActive, 'SHADOWBOX_INACTIVE' => $shadowboxInctive, 'CURRENT_IMAGE_MAX_SIZE' => $cams[$i]['maxImageWidth'], 'THUMBNAIL_MAX_SIZE' => $cams[$i]['thumbMaxSize'], 'HOUR_FROM' => $this->getHourOptions($cams[$i]['showFrom']), 'MINUTE_FROM' => $this->getMinuteOptions($cams[$i]['showFrom']), 'HOUR_TILL' => $this->getHourOptions(!empty($cams[$i]['showTill']) ? $cams[$i]['showTill'] : mktime(23)), 'MINUTE_TILL' => $this->getMinuteOptions(!empty($cams[$i]['showTill']) ? $cams[$i]['showTill'] : mktime(0, 59)))); if (preg_match("/^https{0,1}:\\/\\//", $cams[$i]['currentImagePath'])) { $filepath = $cams[$i]['currentImagePath']; $this->_objTpl->setVariable("PATH", $filepath); $this->_objTpl->parse("current_image"); } else { $filepath = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsitePath() . $cams[$i]['currentImagePath']; if (\Cx\Lib\FileSystem\FileSystem::exists($filepath) && is_file($filepath)) { $this->_objTpl->setVariable("PATH", $cams[$i]['currentImagePath']); $this->_objTpl->parse("current_image"); } else { $this->_objTpl->hideBlock("current_image"); } } $this->_objTpl->parse("cam"); /* $this->_objTpl->setVariable('BLOCK_USE_BLOCK_SYSTEM', $_CONFIG['blockStatus'] == '1' ? 'checked="checked"' : ''); */ } }
/** * Sets up the Order list view * * Sets the $objTemplate parameter to the default backend template, * if empty. * @param \Cx\Core\Html\Sigma $objTemplate The Template, by reference * @param array $filter The optional filter * @return boolean True on success, * false otherwise */ static function view_list(&$objTemplate = null, $filter = NULL) { global $_ARRAYLANG, $objInit; $backend = $objInit->mode == 'backend'; if (!$objTemplate) { $objTemplate = new \Cx\Core\Html\Sigma(\Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseModulePath() . '/Shop/View/Template/Backend'); //DBG::log("Orders::view_list(): new Template: ".$objTemplate->get()); $objTemplate->loadTemplateFile('module_shop_orders.html'); //DBG::log("Orders::view_list(): loaded Template: ".$objTemplate->get()); } $uri = $backend ? \Html::getRelativeUri_entities() : \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'history', NULL); //DBG::log("Orders::view_list(): URI: $uri"); // TODO: Better use a redirect after doing stuff! \Html::stripUriParam($uri, 'act'); \Html::stripUriParam($uri, 'searchterm'); \Html::stripUriParam($uri, 'listletter'); \Html::stripUriParam($uri, 'customer_type'); \Html::stripUriParam($uri, 'status'); \Html::stripUriParam($uri, 'show_pending_orders'); \Html::stripUriParam($uri, 'order_id'); \Html::stripUriParam($uri, 'changeOrderStatus'); \Html::stripUriParam($uri, 'sendMail'); if (!is_array($filter)) { $filter = array(); } if (!empty($_REQUEST['searchterm'])) { $filter['term'] = trim(strip_tags(contrexx_input2raw($_REQUEST['searchterm']))); \Html::replaceUriParameter($uri, 'searchterm=' . $filter['term']); } elseif (!empty($_REQUEST['listletter'])) { $filter['letter'] = trim(strip_tags(contrexx_input2raw($_REQUEST['listletter']))); \Html::replaceUriParameter($uri, 'listletter=' . $filter['letter']); } $customer_type = $usergroup_id = null; // Ignore if (isset($_REQUEST['customer_type']) && $_REQUEST['customer_type'] !== '') { $customer_type = intval($_REQUEST['customer_type']); \Html::replaceUriParameter($uri, 'customer_type=' . $customer_type); if ($customer_type == 0) { $usergroup_id = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_customer', 'Shop'); } if ($customer_type == 1) { $usergroup_id = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_reseller', 'Shop'); } $objFWUser = \FWUser::getFWUserObject(); $objGroup = $objFWUser->objGroup->getGroup($usergroup_id); if ($objGroup) { $filter['customer_id'] = $objGroup->getAssociatedUserIds(); // No customers of that type, so suppress all results if (empty($filter['customer_id'])) { $filter['customer_id'] = array(0); } //DBG::log("Orders::view_list(): Group ID $usergroup_id, Customers: ".var_export($filter['customer_id'], true)); } } $status = null; // Ignore $arrStatus = null; if (isset($_REQUEST['status']) && $_REQUEST['status'] !== '') { $status = intval($_REQUEST['status']); if ($status >= Order::STATUS_PENDING && $status < Order::STATUS_MAX) { $arrStatus = array($status => true); \Html::replaceUriParameter($uri, 'status=' . $status); if ($status == Order::STATUS_PENDING) { $_REQUEST['show_pending_orders'] = true; } } } // Let the user choose whether to see pending orders, too $show_pending_orders = false; if ($backend) { if (empty($_REQUEST['show_pending_orders'])) { if (empty($arrStatus)) { $arrStatus = self::getStatusArray(); unset($arrStatus[Order::STATUS_PENDING]); } } else { if ($arrStatus) { $arrStatus[Order::STATUS_PENDING] = true; } $show_pending_orders = true; \Html::replaceUriParameter($uri, 'show_pending_orders=1'); } } if ($arrStatus) { $filter['status'] = array_keys($arrStatus); } //DBG::log("Orders::view_list(): URI for Sorting: $uri, decoded ".html_entity_decode($uri)); $arrSorting = array('id' => $_ARRAYLANG['TXT_SHOP_ID'], 'date_time' => $_ARRAYLANG['TXT_SHOP_ORDER_DATE'], 'customer_name' => $_ARRAYLANG['TXT_SHOP_CUSTOMER'], 'sum' => $_ARRAYLANG['TXT_SHOP_ORDER_SUM'], 'status' => $_ARRAYLANG['TXT_SHOP_ORDER_STATUS']); $objSorting = new \Sorting($uri, $arrSorting, false, 'order_shop_orders'); $uri_search = $uri; \Html::stripUriParam($uri_search, 'searchterm'); \Html::stripUriParam($uri_search, 'customer_type'); \Html::stripUriParam($uri_search, 'status'); \Html::stripUriParam($uri_search, 'show_pending_orders'); $objTemplate->setGlobalVariable($_ARRAYLANG); if ($backend) { $txt_order_complete = sprintf($_ARRAYLANG['TXT_SEND_TEMPLATE_TO_CUSTOMER'], $_ARRAYLANG['TXT_ORDER_COMPLETE']); $objTemplate->setVariable(array('SHOP_SEND_TEMPLATE_TO_CUSTOMER' => $txt_order_complete, 'SHOP_CUSTOMER_TYPE_MENUOPTIONS' => Customers::getTypeMenuoptions($customer_type, true), 'SHOP_CUSTOMER_SORT_MENUOPTIONS' => Customers::getSortMenuoptions($objSorting->getOrderField()), 'SHOP_SHOW_PENDING_ORDERS_CHECKED' => $show_pending_orders ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_ORDER_STATUS_MENUOPTIONS' => self::getStatusMenuoptions($status, true))); } //DBG::log("Orders::view_list(): Order complete: $txt_order_complete"); //DBG::log("Orders::view_list(): URI: $uri"); $objTemplate->setGlobalVariable(array('SHOP_SEARCH_TERM' => isset($filter['term']) ? $filter['term'] : '', 'SHOP_ORDERS_ORDER_NAME' => $objSorting->getOrderParameterName(), 'SHOP_ORDERS_ORDER_VALUE' => $objSorting->getOrderUriEncoded(), 'SHOP_ACTION_URI_SEARCH_ENCODED' => $uri_search, 'SHOP_ACTION_URI_ENCODED' => $uri, 'SHOP_ACTION_URI' => html_entity_decode($uri), 'SHOP_CURRENCY', Currency::getDefaultCurrencySymbol())); $count = 0; $limit = \Cx\Core\Setting\Controller\Setting::getValue('numof_orders_per_page_backend', 'Shop'); // TODO: Obsolete ASAP if (!$limit) { ShopSettings::errorHandler(); $limit = 25; } $tries = 2; $arrOrders = null; //\DBG::activate(DBG_DB_FIREPHP); while ($tries-- && $count == 0) { $arrOrders = self::getArray($count, $objSorting->getOrder(), $filter, \Paging::getPosition(), $limit); if ($count > 0) { break; } \Paging::reset(); } //DBG::deactivate(DBG_DB); //\DBG::log("Orders: ".count($arrOrders)); $paging = \Paging::get($uri, $_ARRAYLANG['TXT_ORDERS'], $count, $limit, $count > 0); $objTemplate->setVariable(array('SHOP_ORDER_PAGING' => $paging, 'SHOP_CUSTOMER_LISTLETTER' => isset($filter['letter']) ? $filter['letter'] : '', 'SHOP_HEADER_ID' => $objSorting->getHeaderForField('id'), 'SHOP_HEADER_DATE_TIME' => $objSorting->getHeaderForField('date_time'), 'SHOP_HEADER_STATUS' => $objSorting->getHeaderForField('status'), 'SHOP_HEADER_CUSTOMER_NAME' => $objSorting->getHeaderForField('customer_name'), 'SHOP_HEADER_NOTES' => $_ARRAYLANG['TXT_SHOP_ORDER_NOTES'], 'SHOP_HEADER_SUM' => $objSorting->getHeaderForField('sum'), 'SHOP_LISTLETTER_LINKS' => self::getListletterLinks(isset($filter['letter']) ? $filter['letter'] : NULL))); if (empty($arrOrders)) { // $objTemplate->hideBlock('orderTable'); $objTemplate->setVariable('SHOP_ORDER_NONE_FOUND', $_ARRAYLANG['TXT_SHOP_ORDERS_NONE_FOUND']); //\DBG::log("NO Orders!"); return true; } $i = 0; // TODO: For Order export /* $min_date = '9999-00-00 00:00:00'; $max_date = '0000-00-00 00:00:00'; $min_id = 1e10; $max_id = 0;*/ foreach ($arrOrders as $objOrder) { $order_id = $objOrder->id(); // Custom order ID may be created and used as account name. // Adapt the method as needed. // $order_id_custom = ShopLibrary::getCustomOrderId( // $order_id, $objOrder->date_time() // ); // Take billing address from the Order. // No need to load the Customer. $customer_name = ''; $company = $objOrder->billing_company(); $customer_name = $company ? $company : $objOrder->billing_lastname() . ' ' . $objOrder->billing_firstname(); $tipNote = $objOrder->note(); $tipLink = empty($tipNote) ? '' : '<span class="tooltip-trigger icon-comment"></span>' . '<span class="tooltip-message">' . preg_replace('/[\\n\\r]+/', '<br />', nl2br(contrexx_raw2xhtml($tipNote))) . '</span>'; $status = $objOrder->status(); $objTemplate->setVariable(array('SHOP_ROWCLASS' => $status == 0 ? 'rowwarn' : 'row' . (++$i % 2 + 1), 'SHOP_ORDERID' => $order_id, 'SHOP_TIP_LINK' => $tipLink, 'SHOP_DATE' => date(ASCMS_DATE_FORMAT_DATETIME, strtotime($objOrder->date_time())), 'SHOP_NAME' => $customer_name, 'SHOP_ORDER_SUM' => Currency::getDefaultCurrencyPrice($objOrder->sum()), 'SHOP_ORDER_STATUS' => $backend ? self::getStatusMenu(intval($status), false, $order_id, 'changeOrderStatus(' . $order_id . ',' . $status . ',this.value)') : $_ARRAYLANG['TXT_SHOP_ORDER_STATUS_' . $status])); $objTemplate->parse('orderRow'); //\DBG::log("Parsed Order ID $order_id"); // TODO: Order export /* if ($objOrder->date_time() < $min_date) $min_date = $objOrder->date_time(); if ($objOrder->date_time() > $max_date) $max_date = $objOrder->date_time(); if ($objOrder->id() < $min_id) $min_id = $objOrder->id(); if ($objOrder->id() > $max_id) $max_id = $objOrder->id();*/ } $objTemplate->setVariable('SHOP_ORDER_PAGING', $paging); // TODO: Order export /* $arrId = range($min_id-1, $max_id); $arrId = array(0 => "0") + array_combine($arrId, $arrId); $objTemplate->setVariable(array( 'SHOP_ORDER_EXPORT_LAST_ID_MENUOPTIONS' => Html::getOptions($arrId), 'SHOP_ORDER_EXPORT_START_DATE' => Html::getDatepicker('start_date', array( 'defaultDate' => date(ASCMS_DATE_FORMAT_DATE, strtotime($min_date)), 'minDate' => '-7d', 'maxDate' => '+0d', )), 'SHOP_ORDER_EXPORT_END_DATE' => Html::getDatepicker('end_date', array( 'defaultDate' => date(ASCMS_DATE_FORMAT_DATE, strtotime($max_date)+86400), 'minDate' => '-6d', 'maxDate' => '+1d', )), )); //die("Template: ". nl2br(htmlentities(var_export($objTemplate, true)))); //die("Template: ". $objTemplate->get());*/ return true; }
function send() { global $objDatabase, $_ARRAYLANG, $_CONFIG; $this->_objTpl->setTemplate($this->pageContent); // Initialize variables $code = substr(md5(rand()), 1, 10); $url = \Cx\Core\Routing\Url::fromModuleAndCmd('Ecard', 'show', '', array('code' => $code))->toString(); // Initialize POST variables $id = intval($_POST['selectedEcard']); $message = contrexx_addslashes($_POST['ecardMessage']); $recipientSalutation = contrexx_stripslashes($_POST['ecardRecipientSalutation']); $senderName = contrexx_stripslashes($_POST['ecardSenderName']); $senderEmail = \FWValidator::isEmail($_POST['ecardSenderEmail']) ? $_POST['ecardSenderEmail'] : ''; $recipientName = contrexx_stripslashes($_POST['ecardRecipientName']); $recipientEmail = \FWValidator::isEmail($_POST['ecardRecipientEmail']) ? $_POST['ecardRecipientEmail'] : ''; if (empty($senderEmail) || empty($recipientEmail)) { $this->_objTpl->setVariable(array('STATUS_MESSAGE' => $_ARRAYLANG['TXT_ECARD_SENDING_ERROR'])); return false; } $query = "\n SELECT `setting_name`, `setting_value`\n FROM " . DBPREFIX . "module_ecard_settings"; $objResult = $objDatabase->Execute($query); while (!$objResult->EOF) { switch ($objResult->fields['setting_name']) { case 'validdays': $validdays = $objResult->fields['setting_value']; break; // Never used // case 'greetings': // $greetings = $objResult->fields['setting_value']; // break; // Never used // case 'greetings': // $greetings = $objResult->fields['setting_value']; // break; case 'subject': $subject = $objResult->fields['setting_value']; break; case 'emailText': $emailText = strip_tags($objResult->fields['setting_value']); break; } $objResult->MoveNext(); } $timeToLife = $validdays * 86400; // Replace placeholders with used in notification mail with user data $emailText = str_replace('[[ECARD_RECIPIENT_SALUTATION]]', $recipientSalutation, $emailText); $emailText = str_replace('[[ECARD_RECIPIENT_NAME]]', $recipientName, $emailText); $emailText = str_replace('[[ECARD_RECIPIENT_EMAIL]]', $recipientEmail, $emailText); $emailText = str_replace('[[ECARD_SENDER_NAME]]', $senderName, $emailText); $emailText = str_replace('[[ECARD_SENDER_EMAIL]]', $senderEmail, $emailText); $emailText = str_replace('[[ECARD_VALID_DAYS]]', $validdays, $emailText); $emailText = str_replace('[[ECARD_URL]]', $url, $emailText); $body = $emailText; // Insert ecard to DB $query = "\n INSERT INTO `" . DBPREFIX . "module_ecard_ecards` (\n code, date, TTL, salutation,\n senderName, senderEmail,\n recipientName, recipientEmail,\n message\n ) VALUES (\n '" . $code . "',\n '" . time() . "',\n '" . $timeToLife . "',\n '" . addslashes($recipientSalutation) . "',\n '" . addslashes($senderName) . "',\n '" . $senderEmail . "',\n '" . addslashes($recipientName) . "',\n '" . $recipientEmail . "',\n '" . $message . "');"; if ($objDatabase->Execute($query)) { $query = "\n SELECT setting_value\n FROM " . DBPREFIX . "module_ecard_settings\n WHERE setting_name='motive_{$id}'"; $objResult = $objDatabase->SelectLimit($query, 1); // Copy motive to new file with $code as filename $fileExtension = preg_replace('/^.+(\\.[^\\.]+)$/', '$1', $objResult->fields['setting_value']); $fileName = $objResult->fields['setting_value']; $objFile = new \File(); if ($objFile->copyFile(ASCMS_ECARD_OPTIMIZED_PATH . '/', $fileName, ASCMS_ECARD_SEND_ECARDS_PATH . '/', $code . $fileExtension)) { $objMail = new \phpmailer(); // Check e-mail settings if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once ASCMS_CORE_PATH . '/SmtpSettings.class.php')) { $objSmtpSettings = new \SmtpSettings(); if (($arrSmtp = $objSmtpSettings->getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) { $objMail->IsSMTP(); $objMail->Host = $arrSmtp['hostname']; $objMail->Port = $arrSmtp['port']; $objMail->SMTPAuth = true; $objMail->Username = $arrSmtp['username']; $objMail->Password = $arrSmtp['password']; } } // Send notification mail to ecard-recipient $objMail->CharSet = CONTREXX_CHARSET; $objMail->SetFrom($senderEmail, $senderName); $objMail->Subject = $subject; $objMail->IsHTML(false); $objMail->Body = $body; $objMail->AddAddress($recipientEmail); if ($objMail->Send()) { $this->_objTpl->setVariable(array('STATUS_MESSAGE' => $_ARRAYLANG['TXT_ECARD_HAS_BEEN_SENT'])); } else { $this->_objTpl->setVariable(array('STATUS_MESSAGE' => $_ARRAYLANG['TXT_ECARD_MAIL_SENDING_ERROR'])); } } } else { $this->_objTpl->setVariable(array('STATUS_MESSAGE' => $_ARRAYLANG['TXT_ECARD_SENDING_ERROR'])); } }
/** * Restores the Cart from the Order ID given * * Redirects to the login when nobody is logged in. * Redirects to the history overview when the Order cannot be loaded, * or when it does not belong to the current Customer. * When $editable is true, redirects to the detail view of the first * Item for editing. Editing will be disabled otherwise. * @global array $_ARRAYLANG * @param integer $order_id The Order ID * @param boolean $editable Items in the Cart are editable iff true */ static function from_order($order_id, $editable = false) { global $_ARRAYLANG; $objCustomer = Shop::customer(); if (!$objCustomer) { \Message::information($_ARRAYLANG['TXT_SHOP_ORDER_LOGIN_TO_REPEAT']); \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'login') . '?redirect=' . base64_encode(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'cart') . '?order_id=' . $order_id)); } $customer_id = $objCustomer->getId(); $order = Order::getById($order_id); if (!$order || $order->customer_id() != $customer_id) { \Message::warning($_ARRAYLANG['TXT_SHOP_ORDER_INVALID_ID']); \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'history')); } // Optional! self::destroy(); $_SESSION['shop']['shipperId'] = $order->shipment_id(); $_SESSION['shop']['paymentId'] = $order->payment_id(); $order_attributes = $order->getOptionArray(); $count = null; $arrAttributes = Attributes::getArray($count, 0, -1, null, array()); // Find an Attribute and option IDs for the reprint type $attribute_id_reprint = $option_id_reprint = NULL; if (!$editable) { //DBG::log("Cart::from_order(): Checking for reprint..."); foreach ($arrAttributes as $attribute_id => $objAttribute) { if ($objAttribute->getType() == Attribute::TYPE_EZS_REPRINT) { //DBG::log("Cart::from_order(): TYPE reprint"); $options = $objAttribute->getOptionArray(); if ($options) { $option_id_reprint = current(array_keys($options)); $attribute_id_reprint = $attribute_id; //DBG::log("Cart::from_order(): Found reprint Attribute $attribute_id_reprint, option $option_id_reprint"); break; } } } } foreach ($order->getItems() as $item) { $item_id = $item['item_id']; $attributes = $order_attributes[$item_id]; $options = array(); foreach ($attributes as $attribute_id => $attribute) { // foreach (array_keys($attribute['options']) as $option_id) { foreach ($attribute['options'] as $option_id => $option) { //DBG::log("Cart::from_order(): Option: ".var_export($option, true)); switch ($arrAttributes[$attribute_id]->getType()) { case Attribute::TYPE_TEXT_OPTIONAL: case Attribute::TYPE_TEXT_MANDATORY: case Attribute::TYPE_TEXTAREA_OPTIONAL: case Attribute::TYPE_TEXTAREA_MANDATORY: case Attribute::TYPE_EMAIL_OPTIONAL: case Attribute::TYPE_EMAIL_MANDATORY: case Attribute::TYPE_URL_OPTIONAL: case Attribute::TYPE_URL_MANDATORY: case Attribute::TYPE_DATE_OPTIONAL: case Attribute::TYPE_DATE_MANDATORY: case Attribute::TYPE_NUMBER_INT_OPTIONAL: case Attribute::TYPE_NUMBER_INT_MANDATORY: case Attribute::TYPE_NUMBER_FLOAT_OPTIONAL: case Attribute::TYPE_NUMBER_FLOAT_MANDATORY: case Attribute::TYPE_EZS_ACCOUNT_3: case Attribute::TYPE_EZS_ACCOUNT_4: case Attribute::TYPE_EZS_IBAN: case Attribute::TYPE_EZS_IN_FAVOR_OF: case Attribute::TYPE_EZS_REFERENCE: case Attribute::TYPE_EZS_CLEARING: case Attribute::TYPE_EZS_DEPOSIT_FOR_6: case Attribute::TYPE_EZS_DEPOSIT_FOR_2L: case Attribute::TYPE_EZS_DEPOSIT_FOR_2H: case Attribute::TYPE_EZS_PURPOSE_35: case Attribute::TYPE_EZS_PURPOSE_50: $options[$attribute_id][] = $option['name']; break; case Attribute::TYPE_EZS_REDPLATE: case Attribute::TYPE_EZS_CONFIRMATION: if (!$attribute_id_reprint) { //DBG::log("Cart::from_order(): No reprint, adding option {$option['name']}"); $options[$attribute_id][] = $option_id; } break; case Attribute::TYPE_EZS_REPRINT: // Automatically added below when appropriate break; default: // case Attribute::TYPE_EZS_ZEWOLOGO: // case Attribute::TYPE_EZS_EXPRESS: // case Attribute::TYPE_EZS_PURPOSE_BOLD: $options[$attribute_id][] = $option_id; break; } //DBG::log("Cart::from_order(): Added option: ".var_export($options, true)); } } if ($attribute_id_reprint) { $options[$attribute_id_reprint][] = $option_id_reprint; //DBG::log("Cart::from_order(): Item has reprint Attribute, added $attribute_id_reprint => ($option_id_reprint)"); } self::add_product(array('id' => $item['product_id'], 'quantity' => $item['quantity'], 'options' => $options)); } if ($attribute_id_reprint) { // Mark the Cart as being unchanged since the restore, so the // additional cost for some Attributes won't be added again. self::restored_order_id($order_id); } \Message::information($_ARRAYLANG['TXT_SHOP_ORDER_RESTORED']); // Enable for production \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'cart')); }
/** * Checks if this page can be displayed in frontend, redirects to login of not * @param \Cx\Core\ContentManager\Model\Entity\Page $page Page to check * @param int $history (optional) Revision of page to use, 0 means current, default 0 */ public function checkPageFrontendProtection($page, $history = 0) { global $sessionObj; $page_protected = $page->isFrontendProtected(); $pageAccessId = $page->getFrontendAccessId(); if ($history) { $pageAccessId = $page->getBackendAccessId(); } // login pages are unprotected by design $checkLogin = array($page); while (count($checkLogin)) { $currentPage = array_pop($checkLogin); if ($currentPage->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_FALLBACK) { try { array_push($checkLogin, $this->getFallbackPage($currentPage)); } catch (ResolverException $e) { } } if ($currentPage->getModule() == 'Login') { return; } } // Authentification for protected pages if (($page_protected || $history || !empty($_COOKIE['PHPSESSID'])) && (!isset($_REQUEST['section']) || $_REQUEST['section'] != 'Login')) { if (empty($sessionObj)) { $sessionObj = \cmsSession::getInstance(); } $_SESSION->cmsSessionStatusUpdate('frontend'); if (\FWUser::getFWUserObject()->objUser->login()) { if ($page_protected) { if (!\Permission::checkAccess($pageAccessId, 'dynamic', true)) { $link = base64_encode(\Env::get('cx')->getRequest()->getUrl()->toString()); \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . \Cx\Core\Routing\Url::fromModuleAndCmd('Login', 'noaccess', '', array('redirect' => $link))); exit; } } if ($history && !\Permission::checkAccess(78, 'static', true)) { $link = base64_encode(\Env::get('cx')->getRequest()->getUrl()->toString()); \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . \Cx\Core\Routing\Url::fromModuleAndCmd('Login', 'noaccess', '', array('redirect' => $link))); exit; } } elseif (!empty($_COOKIE['PHPSESSID']) && !$page_protected) { unset($_COOKIE['PHPSESSID']); } else { if (isset($_GET['redirect'])) { $link = $_GET['redirect']; } else { $link = base64_encode(\Env::get('cx')->getRequest()->getUrl()->toString()); } \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . \Cx\Core\Routing\Url::fromModuleAndCmd('Login', '', '', array('redirect' => $link))); exit; } } }
/** * List up the news for edit or delete * * @global ADONewConnection * @global array * @global array * @param integer $newsid * @param string $what * @access private * @todo use SQL_CALC_FOUND_ROWS and drop 'n.validated' in where clause instead of calling same query four times */ function overview() { global $objDatabase, $_ARRAYLANG, $_CORELANG, $_CONFIG; if (!$this->hasCategories()) { return $this->manageCategories(); } $query = 'SELECT 1 FROM `' . DBPREFIX . 'module_news_locale` WHERE `is_active` = "1"'; //$query = 'SELECT 1 FROM `'.DBPREFIX.'module_news`'; $objNewsCount = $objDatabase->SelectLimit($query, 1); if ($objNewsCount === false || $objNewsCount->RecordCount() == 0) { return $this->add(); } $objFWUser = \FWUser::getFWUserObject(); // initialize variables $paging = ""; $this->_objTpl->loadTemplateFile('module_news_overview.html', true, true); $this->pageTitle = $_ARRAYLANG['TXT_NEWS_MANAGER']; $messageNr = 0; $validatorNr = 0; $monthlyStats = array(); $dateFilterName = 'date'; $colspanArchive = 10; $colspanInvalidated = 9; if ($this->arrSettings['news_use_types'] == 1) { $colspanArchive++; $colspanInvalidated++; $this->_objTpl->setVariable('TXT_NEWS_TYPE', $_ARRAYLANG['TXT_NEWS_TYPE']); $this->_objTpl->parse('news_type_label'); } else { $this->_objTpl->hideBlock('news_type_label'); } $this->_objTpl->setVariable(array('TXT_EDIT_NEWS_MESSAGE' => $_ARRAYLANG['TXT_EDIT_NEWS_MESSAGE'], 'TXT_EDIT_NEWS_ID' => $_ARRAYLANG['TXT_EDIT_NEWS_ID'], 'TXT_ID' => $_ARRAYLANG['TXT_ID'], 'TXT_DATE' => $_ARRAYLANG['TXT_DATE'], 'TXT_TITLE' => $_ARRAYLANG['TXT_TITLE'], 'TXT_VIEW' => $_ARRAYLANG['TXT_VIEW'], 'TXT_USER' => $_ARRAYLANG['TXT_USER'], 'TXT_ACTION' => $_ARRAYLANG['TXT_ACTION'], 'TXT_CATEGORY' => $_ARRAYLANG['TXT_CATEGORY'], 'TXT_LANGUAGE' => $_ARRAYLANG['TXT_LANGUAGE'], 'COLSPAN_ARCHIVE' => $colspanArchive, 'COLSPAN_INVALIDATED' => $colspanInvalidated, 'TXT_CONFIRM_DELETE_DATA' => $_ARRAYLANG['TXT_NEWS_DELETE_CONFIRM'], 'TXT_ACTION_IS_IRREVERSIBLE' => $_ARRAYLANG['TXT_ACTION_IS_IRREVERSIBLE'], 'TXT_SELECT_ALL' => $_ARRAYLANG['TXT_SELECT_ALL'], 'TXT_REMOVE_SELECTION' => $_ARRAYLANG['TXT_REMOVE_SELECTION'], 'TXT_DELETE_MARKED' => $_ARRAYLANG['TXT_DELETE_MARKED'], 'TXT_MARKED' => $_ARRAYLANG['TXT_MARKED'], 'TXT_ACTIVATE' => $_ARRAYLANG['TXT_ACTIVATE'], 'TXT_DEACTIVATE' => $_ARRAYLANG['TXT_DEACTIVATE'], 'TXT_STATUS' => $_ARRAYLANG['TXT_STATUS'], 'TXT_CONFIRM_AND_ACTIVATE' => $_ARRAYLANG['TXT_CONFIRM_AND_ACTIVATE'], 'TXT_INVALIDATED_ENTRIES' => $_ARRAYLANG['TXT_INVALIDATED_ENTRIES'], 'TXT_NEWS_PREVIEW' => $_ARRAYLANG['TXT_NEWS_PREVIEW'])); $this->_objTpl->setGlobalVariable(array('TXT_ARCHIVE' => $_ARRAYLANG['TXT_ARCHIVE'], 'TXT_EDIT' => $_ARRAYLANG['TXT_EDIT'], 'TXT_COPY' => $_ARRAYLANG['TXT_COPY'], 'TXT_DELETE' => $_ARRAYLANG['TXT_DELETE'], 'TXT_LAST_EDIT' => $_ARRAYLANG['TXT_LAST_EDIT'], 'TXT_NEWS_COMMENTS' => $_ARRAYLANG['TXT_NEWS_COMMENTS'], 'TXT_NEWS_MESSAGE_PROTECTED' => $_ARRAYLANG['TXT_NEWS_MESSAGE_PROTECTED'], 'TXT_NEWS_READ_ALL_ACCESS_DESC' => $_ARRAYLANG['TXT_NEWS_READ_ALL_ACCESS_DESC'], 'TXT_NEWS_NUMBER_OF_COMMENTS' => $_ARRAYLANG['TXT_NEWS_NUMBER_OF_COMMENTS'])); $selectedCategory = !empty($_GET['categoryFilter']) ? intval($_GET['categoryFilter']) : 0; $selectedCategoryNewsIds = array(); if ($selectedCategory !== 0) { $selectedCategoryNewsIds = $this->getCategoryRelNews($selectedCategory); } $whereCategory = !empty($selectedCategoryNewsIds) ? ' AND `id` IN (' . implode(',', $selectedCategoryNewsIds) . ')' : ''; // month filter // archive list $monthCountQuery = ' SELECT `n`.`id`, `n`.`date`, `n`.`changelog` FROM `' . DBPREFIX . 'module_news` `n` WHERE `validated` = "1" ' . $whereCategory . ' ' . ($this->arrSettings['news_message_protection'] == '1' && !\Permission::hasAllAccess() ? ' AND (`backend_access_id` IN (' . implode(',', array_merge(array(0), $objFWUser->objUser->getDynamicPermissionIds())) . ') OR `userid` = ' . $objFWUser->objUser->getId() . ') ' : '') . ' ORDER BY `date` DESC '; $objResult = $objDatabase->Execute($monthCountQuery); if ($objResult !== false) { $arrMonthTxts = explode(',', $_CORELANG['TXT_MONTH_ARRAY']); while (!$objResult->EOF) { $filterDate = $objResult->fields[$dateFilterName]; $newsYear = date('Y', $filterDate); $newsMonth = date('m', $filterDate); if (!isset($monthlyStats[$newsYear])) { $monthlyStats[$newsYear] = array(); $monthlyStats[$newsYear]['name'] = $newsYear; } if (!isset($monthlyStats[$newsYear . '_' . $newsMonth])) { $monthlyStats[$newsYear . '_' . $newsMonth] = array(); $monthlyStats[$newsYear . '_' . $newsMonth]['name'] = $arrMonthTxts[date('n', $filterDate) - 1]; $monthlyStats[$newsYear . '_' . $newsMonth]['archive'] = 0; } $monthlyStats[$newsYear . '_' . $newsMonth]['archive']++; $objResult->MoveNext(); } } $monthLimitQuery = ''; $isFilteredByMonth = false; if (isset($_GET['monthFilter'])) { if (array_key_exists($_GET['monthFilter'], $monthlyStats)) { $isFilteredByMonth = true; $monthInfo = explode('_', $_GET['monthFilter']); $monthLimitQuery = ' AND `' . $dateFilterName . '`'; if (count($monthInfo) == 1) { // month filter $monthLimitQuery .= ' BETWEEN ' . mktime(0, 0, 0, 1, 1, $monthInfo[0]); $monthLimitQuery .= ' AND ' . mktime(23, 59, 59, 12, 31, $monthInfo[0]); } else { $monthLimitQuery .= ' BETWEEN ' . mktime(0, 0, 0, $monthInfo[1], 1, $monthInfo[0]); $monthLimitQuery .= ' AND ' . mktime(23, 59, 59, $monthInfo[1], date('t', mktime(0, 0, 0, $monthInfo[1], 1, $monthInfo[0])), $monthInfo[0]); } } } $activeFrontendLangIds = array_keys(\FWLanguage::getActiveFrontendLanguages()); // set archive list $query = ' SELECT `id`, `date`, `changelog`, `status`, `validated`, `typeid`, `frontend_access_id`, `userid` FROM `' . DBPREFIX . 'module_news` WHERE `validated` = "1" ' . $whereCategory . ' ' . $monthLimitQuery . ' ' . ($this->arrSettings['news_message_protection'] == '1' && !\Permission::hasAllAccess() ? ' AND (`backend_access_id` IN (' . implode(',', array_merge(array(0), $objFWUser->objUser->getDynamicPermissionIds())) . ') OR `userid` = ' . $objFWUser->objUser->getId() . ') ' : '') . ' ORDER BY `date` DESC '; $objResult = $objDatabase->Execute($query); if ($objResult !== false) { $count = $objResult->RecordCount(); if (isset($_GET['pos'])) { $pos = intval($_GET['pos']); } else { $pos = 0; } if ($count > intval($_CONFIG['corePagingLimit'])) { $paging = getPaging($count, $pos, '&cmd=News&show=archive&monthFilter=' . contrexx_input2xhtml($_GET['monthFilter']), $_ARRAYLANG['TXT_NEWS_MESSAGES'], true); } $objResult = $objDatabase->SelectLimit($query, $_CONFIG['corePagingLimit'], $pos); $arrNews = array(); $localeCategories = $this->getCategoryLocale(); while (!$objResult->EOF) { $objLangResult = $objDatabase->Execute('SELECT nl.title as title, nl.lang_id as langid, ntl.name AS typename FROM ' . DBPREFIX . 'module_news_locale AS nl LEFT JOIN ' . DBPREFIX . 'module_news_types_locale AS ntl ON ntl.type_id=' . $objResult->fields['typeid'] . ' WHERE nl.news_id=' . $objResult->fields['id'] . ' AND nl.is_active=1 AND nl.lang_id IN (\'' . implode('\',\'', $activeFrontendLangIds) . '\') ORDER BY nl.lang_id ASC'); if ($objLangResult->RecordCount() > 0) { $newsCategoryIds = $this->getNewsRelCategories($objResult->fields['id']); $newsCategoryIdsFlipped = array_flip($newsCategoryIds); $arrNews[$objResult->fields['id']] = array('date' => $objResult->fields['date'], 'changelog' => $objResult->fields['changelog'], 'status' => $objResult->fields['status'], 'validated' => $objResult->fields['validated'], 'frontend_access_id' => $objResult->fields['frontend_access_id'], 'userid' => $objResult->fields['userid'], 'catIds' => $newsCategoryIds); while (!$objLangResult->EOF) { $combinedNewsCategories = array_intersect_key($localeCategories[$objLangResult->fields['langid']], $newsCategoryIdsFlipped); $arrNews[$objResult->fields['id']]['lang'][$objLangResult->fields['langid']] = array('title' => $objLangResult->fields['title'], 'catname' => implode(', ', contrexx_raw2xhtml($combinedNewsCategories)), 'typename' => $objLangResult->fields['typename']); $objLangResult->MoveNext(); } } $objResult->MoveNext(); } } $count = count($arrNews); if ($count < 1) { $this->_objTpl->hideBlock('newstable'); } else { foreach ($arrNews as $newsId => $news) { if (isset($news['lang'][FRONTEND_LANG_ID])) { $selectedInterfaceLanguage = FRONTEND_LANG_ID; } elseif (isset($news['lang'][\FWLanguage::getDefaultLangId()])) { $selectedInterfaceLanguage = \FWLanguage::getDefaultLangId(); } else { $selectedInterfaceLanguage = key($news['lang']); } $statusPicture = 'status_red.gif'; if ($news['status'] == 1) { $statusPicture = 'status_green.gif'; } $messageNr % 2 ? $class = 'row2' : ($class = 'row1'); $messageNr++; if ($news['userid'] && ($objUser = $objFWUser->objUser->getUser($news['userid']))) { $author = contrexx_raw2xhtml($objUser->getUsername()); } else { $author = $_ARRAYLANG['TXT_ANONYMOUS']; } // TODO: Not in use yet. From r8465@branches/contrexx_2_1 /* require_once('../lib/SocialNetworks.class.php'); $socialNetworkTemplater = new \SocialNetworks(); $socialNetworkTemplater->setUrl($_CONFIG['domainUrl'].ASCMS_PATH_OFFSET.'/index.php?section=News&cmd=details&newsid='.$objResult->fields['id']);*/ // get comments count if ($this->arrSettings['news_comments_activated'] == 1) { $ccResult = $objDatabase->Execute(' SELECT COUNT(1) AS `com_num` FROM `' . DBPREFIX . 'module_news_comments` WHERE `newsid` = ' . $newsId . ' '); if ($ccResult !== false && !empty($ccResult->fields['com_num'])) { $this->_objTpl->setVariable('NEWS_COMMENTS_COUNT', $ccResult->fields['com_num']); $this->_objTpl->parse('news_comments_data'); } else { $this->_objTpl->hideBlock('news_comments_data'); } } else { $this->_objTpl->hideBlock('news_comments_data'); } if ($this->arrSettings['news_use_types'] == 1) { $this->_objTpl->setVariable('NEWS_TYPE', contrexx_raw2xhtml($news['lang'][$selectedInterfaceLanguage]['typename'])); $this->_objTpl->parse('news_type_data'); } else { $this->_objTpl->hideBlock('news_type_data'); } $langString = ''; if (count(\FWLanguage::getActiveFrontendLanguages()) > 1) { $langState = array(); foreach ($news['lang'] as $langId => $langValues) { $langState[$langId] = 'active'; } $langString = \Html::getLanguageIcons($langState, 'index.php?cmd=News&act=edit&newsId=' . $newsId . '&langId=%1$d'); $this->_objTpl->touchBlock('txt_languages_block'); } else { $this->_objTpl->hideBlock('txt_languages_block'); } $previewLink = \Cx\Core\Routing\Url::fromModuleAndCmd('News', $this->findCmdById('details', $news['catIds']), '', array('newsid' => $newsId)); $previewLink .= '&newsPreview=1'; $this->_objTpl->setVariable(array('NEWS_ID' => $newsId, 'NEWS_DATE' => date(ASCMS_DATE_FORMAT, $news['date']), 'NEWS_TITLE' => contrexx_raw2xhtml($news['lang'][$selectedInterfaceLanguage]['title']), 'NEWS_USER' => $author, 'NEWS_CHANGELOG' => date(ASCMS_DATE_FORMAT, $news['changelog']), 'NEWS_LIST_PARSING' => $paging, 'NEWS_CLASS' => $class, 'NEWS_CATEGORY' => contrexx_raw2xhtml($news['lang'][$selectedInterfaceLanguage]['catname']), 'NEWS_STATUS' => $news['status'], 'NEWS_STATUS_PICTURE' => $statusPicture, 'NEWS_LANGUAGES' => $langString, 'NEWS_PREVIEW_LINK_HREF' => $previewLink)); $this->_objTpl->setVariable(array('NEWS_ACTIVATE' => $_ARRAYLANG['TXT_ACTIVATE'], 'NEWS_DEACTIVATE' => $_ARRAYLANG['TXT_DEACTIVATE'])); if ($this->arrSettings['news_message_protection'] == '1' && $news['frontend_access_id']) { $this->_objTpl->touchBlock('news_message_protected_icon'); $this->_objTpl->hideBlock('news_message_not_protected_icon'); } else { $this->_objTpl->touchBlock('news_message_not_protected_icon'); $this->_objTpl->hideBlock('news_message_protected_icon'); } $this->_objTpl->parse('newsrow'); } } // set unvalidated list $query = "SELECT n.id AS id,\n n.date AS date,\n n.changelog AS changelog,\n n.status AS status,\n n.validated AS validated,\n n.typeid AS typeid,\n n.frontend_access_id,\n n.userid\n FROM " . DBPREFIX . "module_news AS n\n WHERE n.validated='0'"; $objResult = $objDatabase->Execute($query); if ($objResult != false) { $count = $objResult->RecordCount(); if (isset($_GET['show']) && $_GET['show'] == 'archive' && isset($_GET['pos'])) { $pos = 0; } else { $pos = isset($_GET['pos']) ? intval($_GET['pos']) : 0; } if ($count > intval($_CONFIG['corePagingLimit'])) { $paging = getPaging($count, $pos, '&cmd=News', $_ARRAYLANG['TXT_NEWS_MESSAGES'], true); } else { $paging = ''; } $objResult = $objDatabase->SelectLimit($query, $_CONFIG['corePagingLimit'], $pos); $arrNews = array(); while (!$objResult->EOF) { $arrNews[$objResult->fields['id']] = array('date' => $objResult->fields['date'], 'changelog' => $objResult->fields['changelog'], 'status' => $objResult->fields['status'], 'validated' => $objResult->fields['validated'], 'frontend_access_id' => $objResult->fields['frontend_access_id'], 'userid' => $objResult->fields['userid']); $objLangResult = $objDatabase->Execute('SELECT nl.title as title, nl.lang_id as langid, ntl.name AS typename FROM ' . DBPREFIX . 'module_news_locale AS nl LEFT JOIN ' . DBPREFIX . 'module_news_types_locale AS ntl ON ntl.type_id=' . $objResult->fields['typeid'] . ' WHERE nl.news_id=' . $objResult->fields['id'] . ' AND nl.is_active=1 ORDER BY nl.lang_id ASC'); $newsCategoryIds = $this->getNewsRelCategories($objResult->fields['id']); $newsCategoryIdsFlipped = array_flip($newsCategoryIds); while (!$objLangResult->EOF) { $combinedNewsCategories = array_intersect_key($localeCategories[$objLangResult->fields['langid']], $newsCategoryIdsFlipped); $arrNews[$objResult->fields['id']]['lang'][$objLangResult->fields['langid']] = array('title' => $objLangResult->fields['title'], 'catname' => implode(', ', contrexx_raw2xhtml($combinedNewsCategories)), 'typename' => $objLangResult->fields['typename']); $objLangResult->MoveNext(); } $objResult->MoveNext(); } } $count = count($arrNews); if ($count < 1) { $this->_objTpl->hideBlock('news_tabmenu'); $this->_objTpl->hideBlock('news_validator'); $this->_objTpl->setVariable('NEWS_ARCHIVE_DISPLAY_STATUS', 'block'); } else { if (isset($_GET['show']) && $_GET['show'] == 'archive') { $this->_objTpl->setVariable(array('NEWS_ARCHIVE_DISPLAY_STATUS' => 'block', 'NEWS_UNVALIDATED_DISPLAY_STATUS' => 'none', 'NEWS_ARCHIVE_TAB_CALSS' => 'class="active"', 'NEWS_UNVALIDATED_TAB_CALSS' => '')); } else { $this->_objTpl->setVariable(array('NEWS_ARCHIVE_DISPLAY_STATUS' => 'none', 'NEWS_UNVALIDATED_DISPLAY_STATUS' => 'block', 'NEWS_ARCHIVE_TAB_CALSS' => '', 'NEWS_UNVALIDATED_TAB_CALSS' => 'class="active"')); } $this->_objTpl->setVariable(array('NEWS_LIST_UNVALIDATED_PARSING' => $paging)); $this->_objTpl->touchBlock('news_tabmenu'); foreach ($arrNews as $newsId => $news) { $validatorNr % 2 ? $class = 'row2' : ($class = 'row1'); $validatorNr++; $statusPicture = 'status_red.gif'; if ($news['status'] == 1) { $statusPicture = 'status_green.gif'; } if ($news['userid'] && ($objUser = $objFWUser->objUser->getUser($news['userid']))) { $author = contrexx_raw2xhtml($objUser->getUsername()); } else { $author = $_ARRAYLANG['TXT_ANONYMOUS']; } if (isset($news['lang'][FRONTEND_LANG_ID])) { $selectedInterfaceLanguage = FRONTEND_LANG_ID; } elseif (isset($news['lang'][\FWLanguage::getDefaultLangId()])) { $selectedInterfaceLanguage = \FWLanguage::getDefaultLangId(); } else { $selectedInterfaceLanguage = key($news['lang']); } $langString = ''; if (count(\FWLanguage::getActiveFrontendLanguages()) > 1) { $langState = array(); foreach ($news['lang'] as $langId => $langValues) { $langState[$langId] = 'active'; } $langString = \Html::getLanguageIcons($langState, 'index.php?cmd=News&act=edit&newsId=' . $newsId . '&langId=%1$d'); $this->_objTpl->touchBlock('txt_languages_block_invalidated'); } else { $this->_objTpl->hideBlock('txt_languages_block_invalidated'); } $this->_objTpl->setVariable(array('NEWS_ID' => $newsId, 'NEWS_DATE' => date(ASCMS_DATE_FORMAT, $news['date']), 'NEWS_TITLE' => contrexx_raw2xhtml($news['lang'][$selectedInterfaceLanguage]['title']), 'NEWS_USER' => $author, 'NEWS_CHANGELOG' => date(ASCMS_DATE_FORMAT, $news['changelog']), 'NEWS_CLASS' => $class, 'NEWS_CATEGORY' => contrexx_raw2xhtml($news['lang'][$selectedInterfaceLanguage]['catname']), 'NEWS_STATUS' => $news['status'], 'NEWS_STATUS_PICTURE' => $statusPicture, 'NEWS_LANGUAGES' => $langString)); $this->_objTpl->parse('news_validator_row'); } } $this->_objTpl->setVariable('NEWS_CATEGORY_OPTIONS', $this->getCategoryMenu($this->nestedSetRootId, array($selectedCategory), array(), true)); // month/year filter if (!empty($monthlyStats)) { foreach ($monthlyStats as $key => $value) { $this->_objTpl->setVariable(array('NEWS_MONTH_NAME' => isset($value['archive']) ? ' ' . $value['name'] . '(' . $value['archive'] . ')' : $value['name'], 'NEWS_MONTH_KEY' => $key, 'NEWS_MONTH_SELECTED' => isset($_GET['monthFilter']) && $_GET['monthFilter'] == $key ? 'selected="selected"' : '')); $this->_objTpl->parse('month_navigation_item'); } } }
/** * Change the customers' password * * If no customer is logged in, redirects to the login page. * Returns true only after the password has been updated successfully. * @return boolean True on success, false otherwise */ static function _changepass() { global $_ARRAYLANG; if (!self::$objCustomer) { \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'login') . '?redirect=' . base64_encode(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'changepass'))); } if (isset($_POST['shopNewPassword'])) { if (empty($_POST['shopCurrentPassword'])) { return \Message::error($_ARRAYLANG['TXT_SHOP_ENTER_CURRENT_PASSWORD']); } $password_old = contrexx_input2raw($_POST['shopCurrentPassword']); if (md5($password_old) != self::$objCustomer->password()) { return \Message::error($_ARRAYLANG['TXT_SHOP_WRONG_CURRENT_PASSWORD']); } $password = contrexx_input2raw($_POST['shopNewPassword']); if (empty($password)) { return \Message::error($_ARRAYLANG['TXT_SHOP_SPECIFY_NEW_PASSWORD']); } if (empty($_POST['shopConfirmPassword'])) { return \Message::error($_ARRAYLANG['TXT_SHOP_PASSWORD_NOT_CONFIRMED']); } $password_confirm = contrexx_input2raw($_POST['shopConfirmPassword']); if ($password != $password_confirm) { return \Message::error($_ARRAYLANG['TXT_SHOP_PASSWORD_NOT_CONFIRMED']); } if (strlen($password) < 6) { return \Message::error($_ARRAYLANG['TXT_PASSWORD_MIN_CHARS']); } if (!self::$objCustomer->password($password)) { return \Message::error($_ARRAYLANG['TXT_SHOP_PASSWORD_INVALID']); } if (!self::$objCustomer->store()) { return \Message::error($_ARRAYLANG['TXT_SHOP_PASSWORD_ERROR_UPDATING']); } return \Message::ok($_ARRAYLANG['TXT_SHOP_PASSWORD_CHANGED_SUCCESSFULLY']); } self::$objTemplate->setVariable(array('SHOP_PASSWORD_CURRENT' => $_ARRAYLANG['SHOP_PASSWORD_CURRENT'], 'SHOP_PASSWORD_NEW' => $_ARRAYLANG['SHOP_PASSWORD_NEW'], 'SHOP_PASSWORD_CONFIRM' => $_ARRAYLANG['SHOP_PASSWORD_CONFIRM'], 'SHOP_PASSWORD_CHANGE' => $_ARRAYLANG['SHOP_PASSWORD_CHANGE'])); return false; }
/** * Parsing the News tags. * * @global type $_ARRAYLANG * @param type $objTpl * @param type $newsId */ public function parseNewsTags($objTpl = null, $newsId = null, $block = 'newsTagList') { global $_ARRAYLANG; if (!empty($newsId)) { $newsTagDetails = $this->getNewsTags($newsId); $newsTags = $newsTagDetails['tagList']; } $tags = $this->getTags(array_keys($newsTags)); if (empty($tags)) { if ($objTpl->blockExists('noTags')) { $objTpl->setVariable('TXT_NEWS_NO_TAGS_FOUND', $_ARRAYLANG['TXT_NEWS_NO_TAGS_FOUND']); $objTpl->showBlock('noTags'); } return; } $tagCount = count($tags); $currentTagCount = 0; if ($objTpl->blockExists($block) && !empty($tags)) { foreach ($tags as $tag) { ++$currentTagCount; $newsLink = \Cx\Core\Routing\Url::fromModuleAndCmd('news', '', FRONTEND_LANG_ID, array('tag' => urlencode($tag))); $objTpl->setVariable(array('NEWS_TAG_NAME' => $tag, 'NEWS_TAG_LINK' => '<a class="tags" href="' . $newsLink . '">' . ucfirst($tag) . '</a>' . ($currentTagCount < $tagCount ? ',' : ''))); $objTpl->parse($block); } if ($objTpl->blockExists('tagsBlock')) { $objTpl->touchBlock('tagsBlock'); } } }
/** * Do something after resolving is done * * @param \Cx\Core\ContentManager\Model\Entity\Page $page The resolved page */ public function postResolve(\Cx\Core\ContentManager\Model\Entity\Page $page) { // TODO: Deactivated license check for now. Implement new behavior. return true; global $plainCmd, $objDatabase, $_CORELANG, $_LANGID, $section; $license = \Cx\Core_Modules\License\License::getCached(\Env::get('config'), $objDatabase); switch ($this->cx->getMode()) { case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND: if (!$license->isInLegalComponents('fulllanguage') && $_LANGID != \FWLanguage::getDefaultLangId()) { $_LANGID = \FWLanguage::getDefaultLangId(); \Env::get('Resolver')->redirectToCorrectLanguageDir(); } if (!empty($section) && !$license->isInLegalFrontendComponents($section)) { 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; } } break; case \Cx\Core\Core\Controller\Cx::MODE_BACKEND: // check if the requested module is active: if (!in_array($plainCmd, array('Login', 'noaccess', ''))) { $query = ' SELECT modules.is_licensed FROM ' . DBPREFIX . 'modules AS modules, ' . DBPREFIX . 'backend_areas AS areas WHERE areas.module_id = modules.id AND ( areas.uri LIKE "%cmd=' . contrexx_raw2db($plainCmd) . '&%" OR areas.uri LIKE "%cmd=' . contrexx_raw2db($plainCmd) . '" ) '; $res = $objDatabase->Execute($query); if (!$res->fields['is_licensed']) { $plainCmd = in_array('LicenseManager', \Env::get('cx')->getLicense()->getLegalComponentsList()) ? 'License' : 'Home'; } } // If logged in if (\Env::get('cx')->getUser()->objUser->login(true)) { $license->check(); if ($license->getState() == \Cx\Core_Modules\License\License::LICENSE_NOK) { $plainCmd = in_array('LicenseManager', \Env::get('cx')->getLicense()->getLegalComponentsList()) ? 'License' : 'Home'; $license->save($objDatabase); } $lc = \Cx\Core_Modules\License\LicenseCommunicator::getInstance(\Env::get('config')); $lc->addJsUpdateCode($_CORELANG, $license, $plainCmd == 'License'); } break; default: break; } }
function _getNewsPreviewPage() { global $objDatabase, $_ARRAYLANG; \JS::activate('cx'); $mailTemplate = isset($_POST['newsletter_mail_template']) ? intval($_POST['newsletter_mail_template']) : '1'; $importTemplate = isset($_POST['newsletter_import_template']) ? intval($_POST['newsletter_mail_template']) : '2'; if (isset($_GET['view']) && $_GET['view'] == 'iframe') { $selectedNews = isset($_POST['selected']) ? contrexx_input2db($_POST['selected']) : ''; $mailTemplate = isset($_POST['emailtemplate']) ? intval($_POST['emailtemplate']) : '1'; $importTemplate = isset($_POST['importtemplate']) ? intval($_POST['importtemplate']) : '2'; $HTML_TemplateSource_Import = $this->_getBodyContent($this->_prepareNewsPreview($this->GetTemplateSource($importTemplate, 'html'))); $_REQUEST['standalone'] = true; $this->_objTpl = new \Cx\Core\Html\Sigma(); \Cx\Core\Csrf\Controller\Csrf::add_placeholder($this->_objTpl); $this->_objTpl->setTemplate($HTML_TemplateSource_Import); $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.catid, nl.title AS newstitle, nl.text AS newscontent, nl.teaser_text, nc.name AS name 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_categories_locale AS nc ON nc.category_id=n.catid WHERE status = 1 AND nl.is_active=1 AND nl.lang_id=' . FRONTEND_LANG_ID . ' AND nc.lang_id=' . FRONTEND_LANG_ID . ' AND n.id IN (' . $selectedNews . ') ORDER BY nc.name ASC, n.date DESC'; $objNews = $objDatabase->Execute($query); $objFWUser = \FWUser::getFWUserObject(); $current_category = ''; if ($this->_objTpl->blockExists('news_list')) { if ($objNews !== false) { while (!$objNews->EOF) { $this->_objTpl->setVariable(array('NEWS_CATEGORY_NAME' => $objNews->fields['name'])); if ($current_category == $objNews->fields['catid']) { $this->_objTpl->hideBlock("news_category"); } $current_category = $objNews->fields['catid']; $newsid = $objNews->fields['newsid']; $newstitle = $objNews->fields['newstitle']; $newsUrl = empty($objNews->fields['redirect']) ? empty($objNews->fields['newscontent']) ? '' : 'index.php?section=News&cmd=details&newsid=' . $newsid : $objNews->fields['redirect']; $newstext = ltrim(strip_tags($objNews->fields['newscontent'])); $newsteasertext = ltrim(strip_tags($objNews->fields['teaser_text'])); $newslink = \Cx\Core\Routing\Url::fromModuleAndCmd('News', 'details', '', array('newsid' => $objNews->fields['newsid'])); if ($objNews->fields['newsuid'] && ($objUser = $objFWUser->objUser->getUser($objNews->fields['newsuid']))) { $author = htmlentities($objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET); } else { $author = $_ARRAYLANG['TXT_ANONYMOUS']; } list($image, $htmlLinkImage, $imageSource) = \Cx\Core_Modules\News\Controller\NewsLibrary::parseImageThumbnail($objNews->fields['teaser_image_path'], $objNews->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl); $this->_objTpl->setVariable(array('NEWS_CATEGORY_NAME' => $objNews->fields['name'], 'NEWS_DATE' => date(ASCMS_DATE_FORMAT_DATE, $objNews->fields['newsdate']), 'NEWS_LONG_DATE' => date(ASCMS_DATE_FORMAT_DATETIME, $objNews->fields['newsdate']), 'NEWS_TITLE' => contrexx_raw2xhtml($newstitle), 'NEWS_URL' => $newslink, 'NEWS_TEASER_TEXT' => $newsteasertext, 'NEWS_TEXT' => $newstext, 'NEWS_AUTHOR' => $author)); $imageTemplateBlock = "news_image"; 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($imageTemplateBlock)) { $this->_objTpl->parse($imageTemplateBlock); } } else { if ($this->_objTpl->blockExists($imageTemplateBlock)) { $this->_objTpl->hideBlock($imageTemplateBlock); } } $this->_objTpl->parse("news_list"); $objNews->MoveNext(); } } $parsedNewsList = $this->_objTpl->get(); } else { if ($objNews !== false) { $parsedNewsList = ''; while (!$objNews->EOF) { $content = $this->_getBodyContent($this->GetTemplateSource($importTemplate, 'html')); $newstext = ltrim(strip_tags($objNews->fields['newscontent'])); $newsteasertext = substr(ltrim(strip_tags($objNews->fields['teaser_text'])), 0, 100); $newslink = \Cx\Core\Routing\Url::fromModuleAndCmd('News', 'detals', '', array('newsid' => $objNews->fields['newsid'])); if ($objNews->fields['newsuid'] && ($objUser = $objFWUser->objUser->getUser($objNews->fields['newsuid']))) { $author = htmlentities($objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET); } else { $author = $_ARRAYLANG['TXT_ANONYMOUS']; } $search = array('[[NEWS_DATE]]', '[[NEWS_LONG_DATE]]', '[[NEWS_TITLE]]', '[[NEWS_URL]]', '[[NEWS_IMAGE_PATH]]', '[[NEWS_TEASER_TEXT]]', '[[NEWS_TEXT]]', '[[NEWS_AUTHOR]]', '[[NEWS_TYPE_NAME]]', '[[NEWS_CATEGORY_NAME]]'); $replace = array(date(ASCMS_DATE_FORMAT_DATE, $objNews->fields['newsdate']), date(ASCMS_DATE_FORMAT_DATETIME, $objNews->fields['newsdate']), $objNews->fields['newstitle'], $newslink, htmlentities($objNews->fields['teaser_image_thumbnail_path'], ENT_QUOTES, CONTREXX_CHARSET), $newsteasertext, $newstext, $author, $objNews->fields['typename'], $objNews->fields['name']); $content = str_replace($search, $replace, $content); if ($parsedNewsList != '') { $parsedNewsList .= "<br/>" . $content; } else { $parsedNewsList = $content; } $objNews->MoveNext(); } } } $previewHTML = str_replace("[[content]]", $parsedNewsList, $this->GetTemplateSource($mailTemplate, 'html')); $this->_objTpl->setTemplate($previewHTML); return $this->_objTpl->get(); } else { $selected = isset($_POST['SelectedNews']) ? $_POST['SelectedNews'] : ''; $selectedNews = implode(",", $selected); $this->_pageTitle = $_ARRAYLANG['TXT_NEWSLETTER_NEWS_IMPORT_PREVIEW']; $this->_objTpl->loadTemplateFile('newsletter_news_preview.html'); $this->_objTpl->setVariable(array('TXT_EMAIL_LAYOUT' => $_ARRAYLANG['TXT_NEWSLETTER_NEWS_EMAIL_LAYOUT'], 'TXT_IMPORT_LAYOUT' => $_ARRAYLANG['TXT_NEWSLETTER_NEWS_IMPORT_LAYOUT'], 'TXT_NEWS_PREVIEW' => $_ARRAYLANG['TXT_NEWSLETTER_NEWS_PREVIEW'], 'TXT_CREATE_EMAIL' => $_ARRAYLANG['TXT_NEWSLETTER_NEWS_CREATE_EMAIL'], 'NEWSLETTER_MAIL_TEMPLATE_MENU' => $this->_getTemplateMenu($mailTemplate, 'id="newsletter_mail_template" name="newsletter_mail_template" style="width:300px;" onchange="refreshIframe();"'), 'NEWSLETTER_IMPORT_TEMPLATE_MENU' => $this->_getTemplateMenu($importTemplate, 'id="newsletter_import_template" name="newsletter_import_template" style="width:300px;" onchange="refreshIframe();"', 'news'), 'NEWSLETTER_SELECTED_NEWS' => $selectedNews, 'NEWSLETTER_SELECTED_EMAIL_TEMPLATE' => $mailTemplate, 'NEWSLETTER_SELECTED_IMPORT_TEMPLATE' => $importTemplate)); } }
/** * Get teaser frame * * Returns the selected teaser frame by $id with its teaserboxes * * @access private * @return string */ function _getTeaserFrame($id, $templateId) { $teaserFrame = ""; $arrTeaserBlocks = array(); if (isset($this->arrTeaserFrameTemplates[$templateId]['html'])) { $teaserFrame = $this->arrTeaserFrameTemplates[$templateId]['html']; if (preg_match_all('/<!-- BEGIN (teaser_[0-9]+) -->/ms', $teaserFrame, $arrTeaserBlocks)) { $funcSort = create_function('$a, $b', '{$aNr = preg_replace("/^[^_]+_/", "", $a);$bNr = preg_replace("/^[^_]+_/", "", $b);if ($aNr == $bNr) {return 0;} return ($aNr < $bNr) ? -1 : 1;}'); usort($arrTeaserBlocks[0], $funcSort); usort($arrTeaserBlocks[1], $funcSort); $arrMatch = array(); foreach ($arrTeaserBlocks[1] as $nr => $teaserBlock) { if (preg_match('/<!-- BEGIN ' . $teaserBlock . ' -->(.*)<!-- END ' . $teaserBlock . ' -->/s', $teaserFrame, $arrMatch)) { $teaserBlockCode = $arrMatch[1]; } else { $teaserBlockCode = ''; } if (isset($this->arrFrameTeaserIds[$id][$nr])) { $teaserBlockCode = str_replace('{TEASER_CATEGORY}', $this->arrTeasers[$this->arrFrameTeaserIds[$id][$nr]]['category'], $teaserBlockCode); $teaserBlockCode = str_replace('{TEASER_LONG_DATE}', date(ASCMS_DATE_FORMAT, $this->arrTeasers[$this->arrFrameTeaserIds[$id][$nr]]['date']), $teaserBlockCode); $teaserBlockCode = str_replace('{TEASER_DATE}', date(ASCMS_DATE_FORMAT_DATE, $this->arrTeasers[$this->arrFrameTeaserIds[$id][$nr]]['date']), $teaserBlockCode); $teaserBlockCode = str_replace('{TEASER_TIME}', date(ASCMS_DATE_FORMAT_TIME, $this->arrTeasers[$this->arrFrameTeaserIds[$id][$nr]]['date']), $teaserBlockCode); $teaserBlockCode = str_replace('{TEASER_TITLE}', contrexx_raw2xhtml($this->arrTeasers[$this->arrFrameTeaserIds[$id][$nr]]['title']), $teaserBlockCode); if ($this->arrTeasers[$this->arrFrameTeaserIds[$id][$nr]]['teaser_show_link']) { $teaserBlockCode = str_replace('{TEASER_URL}', empty($this->arrTeasers[$this->arrFrameTeaserIds[$id][$nr]]['redirect']) ? \Cx\Core\Routing\Url::fromModuleAndCmd('News', $this->findCmdById('details', $this->arrTeasers[$this->arrFrameTeaserIds[$id][$nr]]['category_id']), FRONTEND_LANG_ID, array('newsid' => $this->arrTeasers[$this->arrFrameTeaserIds[$id][$nr]]['id'], 'teaserId' => $this->arrTeaserFrames[$id]['id'])) : $this->arrTeasers[$this->arrFrameTeaserIds[$id][$nr]]['redirect'], $teaserBlockCode); $teaserBlockCode = str_replace('{TEASER_URL_TARGET}', empty($this->arrTeasers[$this->arrFrameTeaserIds[$id][$nr]]['redirect']) ? '_self' : '_blank', $teaserBlockCode); $teaserBlockCode = str_replace('<!-- BEGIN teaser_link -->', '', $teaserBlockCode); $teaserBlockCode = str_replace('<!-- END teaser_link -->', '', $teaserBlockCode); } else { $teaserBlockCode = preg_replace('/<!-- BEGIN teaser_link -->[\\S\\s]*<!-- END teaser_link -->/', '', $teaserBlockCode); } $teaserBlockCode = str_replace('{TEASER_IMAGE_PATH}', $this->arrTeasers[$this->arrFrameTeaserIds[$id][$nr]]['teaser_image_path'], $teaserBlockCode); $teaserBlockCode = str_replace('{TEASER_TEXT}', nl2br($this->arrTeasers[$this->arrFrameTeaserIds[$id][$nr]]['teaser_text']), $teaserBlockCode); $teaserBlockCode = str_replace('{TEASER_FULL_TEXT}', $this->arrTeasers[$this->arrFrameTeaserIds[$id][$nr]]['teaser_full_text'], $teaserBlockCode); $teaserBlockCode = str_replace('{TEASER_AUTHOR}', $this->arrTeasers[$this->arrFrameTeaserIds[$id][$nr]]['author'], $teaserBlockCode); $teaserBlockCode = str_replace('{TEASER_EXT_URL}', $this->arrTeasers[$this->arrFrameTeaserIds[$id][$nr]]['ext_url'], $teaserBlockCode); } elseif ($this->administrate) { $teaserBlockCode = str_replace('{TEASER_CATEGORY}', 'TXT_CATEGORY', $teaserBlockCode); $teaserBlockCode = str_replace('{TEASER_DATE}', 'TXT_DATE', $teaserBlockCode); $teaserBlockCode = str_replace('{TEASER_LONG_DATE}', 'TXT_LONG_DATE', $teaserBlockCode); $teaserBlockCode = str_replace('{TEASER_TITLE}', 'TXT_TITLE', $teaserBlockCode); $teaserBlockCode = str_replace('{TEASER_URL}', 'TXT_URL', $teaserBlockCode); $teaserBlockCode = str_replace('{TEASER_URL_TARGET}', 'TXT_URL_TARGET', $teaserBlockCode); $teaserBlockCode = str_replace('{TEASER_IMAGE_PATH}', 'TXT_IMAGE_PATH', $teaserBlockCode); $teaserBlockCode = str_replace('{TEASER_TEXT}', 'TXT_TEXT', $teaserBlockCode); $teaserBlockCode = str_replace('{TEASER_FULL_TEXT}', 'TXT_FULL_TEXT', $teaserBlockCode); $teaserBlockCode = str_replace('{TEASER_AUTHOR}', 'TEASER_AUTHOR', $teaserBlockCode); $teaserBlockCode = str_replace('{TEASER_EXT_URL}', 'TEASER_EXT_URL', $teaserBlockCode); } else { $teaserBlockCode = ' '; } if (!$this->administrate) { $teaserFrame = preg_replace('/<!-- BEGIN ' . $teaserBlock . ' -->[\\S\\s]*<!-- END ' . $teaserBlock . ' -->/', $teaserBlockCode, $teaserFrame); } else { $teaserFrame = preg_replace('/(<!-- BEGIN ' . $teaserBlock . ' -->)[\\S\\s]*(<!-- END ' . $teaserBlock . ' -->)/', '<table cellspacing="0" cellpadding="0" style="border:1px dotted #aaaaaa;"><tr><td>' . $teaserBlockCode . '</td></tr></table>', $teaserFrame); } } } } return $teaserFrame; }
/** * Returns the Event detail page link * * @param object $objEvent Event object * * @return string link for the detail page */ function _getDetailLink($objEvent) { $url = \Cx\Core\Routing\Url::fromModuleAndCmd($this->moduleName, 'detail'); $url->setParams(array('id' => $objEvent->id, 'date' => intval($objEvent->startDate))); if ($objEvent->external) { $url->setParam('external', 1); } return (string) $url; }
/** * Returns the created path by the given array. * * @param array $matches * @return string created path */ private function getPath($matches) { // The Shop JS Cart escapes pathes because he loads it via JavaScript. // For this reason, we replace escaped slashes by slashes. $matches[\LinkSanitizer::FILE_PATH] = str_replace('\\/', '/', $matches[\LinkSanitizer::FILE_PATH]); // fix empty urls like empty form-action tags if (empty($matches[\LinkSanitizer::FILE_PATH])) { return $matches[\LinkSanitizer::ATTRIBUTE_AND_OPEN_QUOTE] . $this->cx->getRequest()->getUrl() . $matches[\LinkSanitizer::CLOSE_QUOTE]; } $testPath = explode('?', $matches[\LinkSanitizer::FILE_PATH], 2); if ($testPath[0] == 'index.php' || $testPath[0] == '' || $testPath[0] == './') { $ret = $this->cx->getWebsiteOffsetPath(); if (\Env::get('cx')->getMode() == \Cx\Core\Core\Controller\Cx::MODE_BACKEND) { $ret .= \Cx\Core\Core\Controller\Cx::instanciate()->getBackendFolderName(); } $ret .= '/'; if (isset($testPath[1])) { $args = preg_split('/&(amp;)?/', $testPath[1]); $params = array(); foreach ($args as $arg) { $split = explode('=', $arg, 2); $params[$split[0]] = $split[1]; } // frontend case if (isset($params['section'])) { $cmd = ''; if (isset($params['cmd'])) { $cmd = $params['cmd']; unset($params['cmd']); } $ret = \Cx\Core\Routing\Url::fromModuleAndCmd($params['section'], $cmd); unset($params['section']); $ret->setParams($params); return $matches[\LinkSanitizer::ATTRIBUTE_AND_OPEN_QUOTE] . $ret . $matches[\LinkSanitizer::CLOSE_QUOTE]; // backend case } else { if (isset($params['cmd'])) { $ret .= $params['cmd']; unset($params['cmd']); if (isset($params['act'])) { $ret .= '/' . $params['act']; unset($params['act']); } } } if (count($params)) { array_walk($params, function (&$value, $key) { $value = $key . '=' . $value; }); $ret .= '?' . implode('&', $params); } } return $matches[\LinkSanitizer::ATTRIBUTE_AND_OPEN_QUOTE] . $ret . $matches[\LinkSanitizer::CLOSE_QUOTE]; } else { if ($localFile = $this->cx->getClassLoader()->getWebFilePath($this->cx->getCodeBaseDocumentRootPath() . '/' . $matches[\LinkSanitizer::FILE_PATH])) { // this is an existing file, do not add virtual language dir return $matches[\LinkSanitizer::ATTRIBUTE_AND_OPEN_QUOTE] . $localFile . $matches[\LinkSanitizer::CLOSE_QUOTE]; } else { // this is a link to a page, add virtual language dir return $matches[\LinkSanitizer::ATTRIBUTE_AND_OPEN_QUOTE] . $this->offset . $matches[\LinkSanitizer::FILE_PATH] . $matches[\LinkSanitizer::CLOSE_QUOTE]; } } }
function getRecentNewsComments() { global $objDatabase; $this->_objTemplate->setTemplate($this->_pageContent, true, true); // abort if template block is missing if (!$this->_objTemplate->blockExists('news_comments')) { return; } // abort if commenting system is not active if (!$this->arrSettings['news_comments_activated']) { $this->_objTemplate->hideBlock('news_comments'); } else { $_ARRAYLANG = \Env::get('init')->loadLanguageData('News'); $commentsCount = (int) $this->arrSettings['recent_news_message_limit']; $query = "SELECT `nComment`.`title`,\n `nComment`.`date`,\n `nComment`.`poster_name`,\n `nComment`.`userid`,\n `nComment`.`text`,\n `news`.`id`\n FROM \n `" . DBPREFIX . "module_news_comments` AS nComment\n LEFT JOIN \n `" . DBPREFIX . "module_news` AS news\n ON\n `nComment`.newsid = `news`.id\n LEFT JOIN \n `" . DBPREFIX . "module_news_locale` AS nLocale\n ON\n `news`.id = `nLocale`.news_id AND `nLocale`.lang_id = " . FRONTEND_LANG_ID . "\n WHERE\n `news`.status = 1\n AND\n `news`.allow_comments = 1\n AND\n `nLocale`.is_active = 1\n AND\n `nComment`.`is_active` = '1'\n ORDER BY\n `date` DESC \n LIMIT 0, {$commentsCount}"; $objResult = $objDatabase->Execute($query); // no comments for this message found if (!$objResult || $objResult->EOF) { if ($this->_objTemplate->blockExists('news_no_comment')) { $this->_objTemplate->setVariable('TXT_NEWS_COMMENTS_NONE_EXISTING', $_ARRAYLANG['TXT_NEWS_COMMENTS_NONE_EXISTING']); $this->_objTemplate->parse('news_no_comment'); } $this->_objTemplate->hideBlock('news_comment_list'); $this->_objTemplate->parse('news_comments'); return $this->_objTemplate->get(); } $i = 0; while (!$objResult->EOF) { self::parseUserAccountData($this->_objTemplate, $objResult->fields['userid'], $objResult->fields['poster_name'], 'news_comments_poster'); $commentTitle = $objResult->fields['title']; $newsCategories = $this->getCategoriesByNewsId($objResult->fields['id']); $newsUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('News', $this->findCmdById('details', array_keys($newsCategories)), FRONTEND_LANG_ID, array('newsid' => $objResult->fields['id'])); $newsLink = self::parseLink($newsUrl, $commentTitle, contrexx_raw2xhtml($commentTitle)); $this->_objTemplate->setVariable(array('NEWS_COMMENTS_CSS' => 'row' . ($i % 2 + 1), 'NEWS_COMMENTS_TITLE' => contrexx_raw2xhtml($commentTitle), 'NEWS_COMMENTS_MESSAGE' => nl2br(contrexx_raw2xhtml($objResult->fields['text'])), 'NEWS_COMMENTS_LONG_DATE' => date(ASCMS_DATE_FORMAT, $objResult->fields['date']), 'NEWS_COMMENTS_DATE' => date(ASCMS_DATE_FORMAT_DATE, $objResult->fields['date']), 'NEWS_COMMENTS_TIME' => date(ASCMS_DATE_FORMAT_TIME, $objResult->fields['date']), 'NEWS_COMMENT_LINK' => $newsLink, 'NEWS_COMMENT_URL' => $newsUrl)); $this->_objTemplate->parse('news_comment'); $i++; $objResult->MoveNext(); } $this->_objTemplate->parse('news_comment_list'); $this->_objTemplate->hideBlock('news_no_comment'); } return $this->_objTemplate->get(); }
/** * Returns the HTML code for the Saferpay payment form. * @param array $arrCards The optional accepted card types * @return string The HTML code * @static */ static function _SaferpayProcessor() { global $_ARRAYLANG; $arrShopOrder = array('AMOUNT' => str_replace('.', '', $_SESSION['shop']['grand_total_price']), 'CURRENCY' => Currency::getActiveCurrencyCode(), 'ORDERID' => $_SESSION['shop']['order_id'], 'ACCOUNTID' => \Cx\Core\Setting\Controller\Setting::getValue('saferpay_id', 'Shop'), 'SUCCESSLINK' => \Cx\Core\Routing\Url::fromModuleAndCmd('Shop' . MODULE_INDEX, 'success', '', array('result' => 1, 'handler' => 'saferpay'))->toString(), 'FAILLINK' => \Cx\Core\Routing\Url::fromModuleAndCmd('Shop' . MODULE_INDEX, 'success', '', array('result' => 0, 'handler' => 'saferpay'))->toString(), 'BACKLINK' => \Cx\Core\Routing\Url::fromModuleAndCmd('Shop' . MODULE_INDEX, 'success', '', array('result' => 2, 'handler' => 'saferpay'))->toString(), 'DESCRIPTION' => '"' . $_ARRAYLANG['TXT_ORDER_NR'] . ' ' . $_SESSION['shop']['order_id'] . '"', 'LANGID' => \FWLanguage::getLanguageCodeById(FRONTEND_LANG_ID), 'NOTIFYURL' => \Cx\Core\Routing\Url::fromModuleAndCmd('Shop' . MODULE_INDEX, 'success', '', array('result' => '-1', 'handler' => 'saferpay'))->toString(), 'ALLOWCOLLECT' => 'no', 'DELIVERY' => 'no'); $payInitUrl = \Saferpay::payInit($arrShopOrder, \Cx\Core\Setting\Controller\Setting::getValue('saferpay_use_test_account', 'Shop')); //DBG::log("PaymentProcessing::_SaferpayProcessor(): payInit URL: $payInitUrl"); // Fixed: Added check for empty return string, // i.e. on connection problems if (!$payInitUrl) { return "<font color='red'><b>" . $_ARRAYLANG['TXT_SHOP_PSP_FAILED_TO_INITIALISE_SAFERPAY'] . "<br />{$payInitUrl}</b></font>" . "<br />" . \Saferpay::getErrors(); } $return = "<script src='http://www.saferpay.com/OpenSaferpayScript.js'></script>\n"; switch (\Cx\Core\Setting\Controller\Setting::getValue('saferpay_window_option', 'Shop')) { case 0: // iframe return $return . $_ARRAYLANG['TXT_ORDER_PREPARED'] . "<br/><br/>\n" . "<iframe src='{$payInitUrl}' width='580' height='400' scrolling='no' marginheight='0' marginwidth='0' frameborder='0' name='saferpay'></iframe>\n"; case 1: // popup return $return . $_ARRAYLANG['TXT_ORDER_LINK_PREPARED'] . "<br/><br/>\n" . "<script type='text/javascript'>\n function openSaferpay() {\n strUrl = '{$payInitUrl}';\n if (strUrl.indexOf(\"WINDOWMODE=Standalone\") == -1) {\n strUrl += \"&WINDOWMODE=Standalone\";\n }\n oWin = window.open(strUrl, 'SaferpayTerminal',\n 'scrollbars=1,resizable=0,toolbar=0,location=0,directories=0,status=1,menubar=0,width=580,height=400'\n );\n if (oWin == null || typeof(oWin) == \"undefined\") {\n alert(\"The payment couldn't be initialized. It seems like you are using a popup blocker!\");\n }\n }\n </script>\n" . "<input type='button' name='order_now' value='" . $_ARRAYLANG['TXT_ORDER_NOW'] . "' onclick='openSaferpay()' />\n"; default: //case 2: // new window } return $return . $_ARRAYLANG['TXT_ORDER_LINK_PREPARED'] . "<br/><br/>\n" . "<form method='post' action='{$payInitUrl}'>\n<input type='submit' value='" . $_ARRAYLANG['TXT_ORDER_NOW'] . "' />\n</form>\n"; }
/** * Uses the given Entity Manager to retrieve all links for the placeholders * @param EntityManager $em */ public function fetch($em) { if ($this->placeholders === null) { throw new LinkGeneratorException('Seems like scan() was never called before calling fetch().'); } $qb = $em->createQueryBuilder(); $qb->add('select', new Doctrine\ORM\Query\Expr\Select(array('p'))); $qb->add('from', new Doctrine\ORM\Query\Expr\From('Cx\\Core\\ContentManager\\Model\\Entity\\Page', 'p')); //build a big or with all the node ids and pages $arrExprs = null; $fetchedPages = array(); $pIdx = 0; foreach ($this->placeholders as $placeholder => $data) { if ($data['type'] == 'id') { # page is referenced by NODE-ID (i.e.: [[NODE_1]]) if (isset($fetchedPages[$data['nodeid']][$data['lang']])) { continue; } $arrExprs[] = $qb->expr()->andx($qb->expr()->eq('p.node', $data['nodeid']), $qb->expr()->eq('p.lang', $data['lang'])); $fetchedPages[$data['nodeid']][$data['lang']] = true; } else { # page is referenced by module (i.e.: [[NODE_SHOP_CART]]) if (isset($fetchedPages[$data['module']][$data['cmd']][$data['lang']])) { continue; } $arrExprs[] = $qb->expr()->andx($qb->expr()->eq('p.type', ':type'), $qb->expr()->eq('p.module', ':module_' . $pIdx), $qb->expr()->eq('p.cmd', ':cmd_' . $pIdx), $qb->expr()->eq('p.lang', $data['lang'])); $qb->setParameter('module_' . $pIdx, $data['module']); $qb->setParameter('cmd_' . $pIdx, empty($data['cmd']) ? null : $data['cmd']); $qb->setParameter('type', \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION); $fetchedPages[$data['module']][$data['cmd']][$data['lang']] = true; $pIdx++; } } //fetch the nodes if there are any in the query if ($arrExprs) { foreach ($arrExprs as $expr) { $qb->orWhere($expr); } $pages = $qb->getQuery()->getResult(); foreach ($pages as $page) { // build placeholder's value -> URL $url = \Cx\Core\Routing\Url::fromPage($page); $placeholderByApp = ''; $placeholderById = \Cx\Core\ContentManager\Model\Entity\Page::PLACEHOLDER_PREFIX . $page->getNode()->getId(); $this->placeholders[$placeholderById . '_' . $page->getLang()] = $url; if ($page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION) { $module = $page->getModule(); $cmd = $page->getCmd(); $placeholderByApp = \Cx\Core\ContentManager\Model\Entity\Page::PLACEHOLDER_PREFIX; $placeholderByApp .= strtoupper($module . (empty($cmd) ? '' : '_' . $cmd)); $this->placeholders[$placeholderByApp . '_' . $page->getLang()] = $url; } if ($page->getLang() == FRONTEND_LANG_ID) { $this->placeholders[$placeholderById] = $url; if (!empty($placeholderByApp)) { $this->placeholders[$placeholderByApp] = $url; } } } } // there might be some placeholders we were unable to resolve. // try to resolve them by using the fallback-language-reverse-lookup // methode provided by \Cx\Core\Routing\Url::fromModuleAndCmd(). foreach ($this->placeholders as $placeholder => $data) { if (!$data instanceof \Cx\Core\Routing\Url) { if (!empty($data['module'])) { try { $url = \Cx\Core\Routing\Url::fromModuleAndCmd($data['module'], $data['cmd'], $data['lang'], array(), '', false); if ($this->absoluteUris && $this->domain) { $url->setDomain($this->domain); } $this->placeholders[$placeholder] = $url->toString($this->absoluteUris); } catch (\Cx\Core\Routing\UrlException $e) { if ($data['lang'] && $data['cmd']) { $url = \Cx\Core\Routing\Url::fromModuleAndCmd($data['module'], $data['cmd'] . '_' . $data['lang'], FRONTEND_LANG_ID); if ($this->absoluteUris && $this->domain) { $url->setDomain($this->domain); } $this->placeholders[$placeholder] = $url->toString($this->absoluteUris); } else { if ($data['lang'] && empty($data['cmd'])) { $url = \Cx\Core\Routing\Url::fromModuleAndCmd($data['module'], $data['lang'], FRONTEND_LANG_ID); if ($this->absoluteUris && $this->domain) { $url->setDomain($this->domain); } $this->placeholders[$placeholder] = $url->toString($this->absoluteUris); } else { $url = \Cx\Core\Routing\Url::fromModuleAndCmd('Error', '', $data['lang']); if ($this->absoluteUris && $this->domain) { $url->setDomain($this->domain); } $this->placeholders[$placeholder] = $url->toString($this->absoluteUris); } } } } else { $url = \Cx\Core\Routing\Url::fromModuleAndCmd('Error', '', $data['lang']); if ($this->absoluteUris && $this->domain) { $url->setDomain($this->domain); } $this->placeholders[$placeholder] = $url->toString($this->absoluteUris); } } else { if ($this->absoluteUris && $this->domain) { $data->setDomain($this->domain); } $this->placeholders[$placeholder] = $data->toString($this->absoluteUris); } } $this->fetchingDone = true; }
/** * Searchs for an user with the given user id of the social media platform. * If there is no user, create one and directly log in. * * @param string $oauth_id the user id of the social media platform * @return bool * @throws OAuth_Exception */ protected function getContrexxUser($oauth_id) { global $sessionObj; //\DBG::activate(); $arrSettings = \User_Setting::getSettings(); $provider = $this::OAUTH_PROVIDER; $FWUser = \FWUser::getFWUserObject(); $objUser = $FWUser->objUser->getByNetwork($provider, $oauth_id); if (!$objUser) { // check whether the user is already logged in // if the user is logged in just add a new network to the user object if ($FWUser->objUser->login()) { $objUser = $FWUser->objUser; $this->addProviderToUserObject($provider, $oauth_id, $objUser); $objUser->getNetworks()->save(); return true; } // create a new user with the default profile attributes $objUser = new \User(); $objUser->setEmail($this->getEmail()); $objUser->setAdminStatus(0); $objUser->setProfile(array('firstname' => array($this->getFirstname()), 'lastname' => array($this->getLastname()))); $registrationRedirectNeeded = $arrSettings['sociallogin_show_signup']['status']; // if user_account_verification is true (1), then we need to do checkMandatoryCompliance(), because // the required fields must be set. if ($registrationRedirectNeeded == false && $arrSettings['user_account_verification']['value'] === 1) { $registrationRedirectNeeded = !$objUser->checkMandatoryCompliance(); } $objUser->setActiveStatus(!$registrationRedirectNeeded); if ($registrationRedirectNeeded) { $objUser->setRestoreKey(); $objUser->setRestoreKeyTime(intval($arrSettings['sociallogin_activation_timeout']['value']) * 60); } if (!empty($arrSettings['sociallogin_assign_to_groups']['value'])) { $groups = $arrSettings['sociallogin_assign_to_groups']['value']; } else { $groups = $arrSettings['assigne_to_groups']['value']; } $objUser->setGroups(explode(',', $groups)); // if we can create the user without sign up page if (!$objUser->store()) { // if the email address already exists but not with the given oauth-provider throw new OAuth_Exception(); } // add the social network to user $this->addProviderToUserObject($provider, $oauth_id, $objUser); $objUser->getNetworks()->save(); // check whether there are empty mandatory fields or the setting to show sign up everytime if ($registrationRedirectNeeded) { // start session if no session is open if (!isset($sessionObj) || !is_object($sessionObj)) { $sessionObj = \cmsSession::getInstance(); } // write the user id to session so we can pre-fill the sign up form $_SESSION['user_id'] = $objUser->getId(); // generate url for sign up page and redirect $signUpPageUri = \Cx\Core\Routing\Url::fromModuleAndCmd('Access', 'signup'); \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . $signUpPageUri->__toString()); exit; } } $FWUser->loginUser($objUser); }
/** * @static * @param integer $fileId * @return string the download link */ public static function getDeleteLink($fileId) { global $objDatabase; $objResult = $objDatabase->SelectLimit("SELECT `cmd`, `hash`, `check` FROM " . DBPREFIX . "module_filesharing WHERE `id` = " . intval($fileId), 1, 0); if ($objResult !== false) { $params = array('hash' => $objResult->fields['hash'], 'check' => $objResult->fields['check']); try { $objUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('FileSharing', $objResult->fields['cmd'], FRONTEND_LANG_ID, $params, '', false); } catch (\Cx\Core\Routing\UrlException $e) { $objUrl = \Cx\Core\Routing\Url::fromModuleAndCmd('FileSharing', '', FRONTEND_LANG_ID, $params); } return $objUrl->toString(); } else { return false; } }
/** * Initialize the mail functionality to the recipient * * @param \Cx\Modules\Calendar\Controller\CalendarEvent $event Event instance * @param integer $actionId Mail action id * @param integer $regId Registration id * @param string $mailTemplate Mail template id */ function sendMail(CalendarEvent $event, $actionId, $regId = null, $mailTemplate = null) { global $objDatabase, $_ARRAYLANG, $_CONFIG; $this->mailList = array(); // Loads the mail template which needs for this action $this->loadMailList($actionId, $mailTemplate); if (!empty($this->mailList)) { $objRegistration = null; if (!empty($regId)) { $objRegistration = new \Cx\Modules\Calendar\Controller\CalendarRegistration($event->registrationForm, $regId); list($registrationDataText, $registrationDataHtml) = $this->getRegistrationData($objRegistration); $query = 'SELECT `v`.`value`, `n`.`default`, `f`.`type` FROM ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field_value AS `v` INNER JOIN ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field_name AS `n` ON `v`.`field_id` = `n`.`field_id` INNER JOIN ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field AS `f` ON `v`.`field_id` = `f`.`id` WHERE `v`.`reg_id` = ' . $regId . ' AND ( `f`.`type` = "salutation" OR `f`.`type` = "firstname" OR `f`.`type` = "lastname" OR `f`.`type` = "mail" )'; $objResult = $objDatabase->Execute($query); $arrDefaults = array(); $arrValues = array(); if ($objResult !== false) { while (!$objResult->EOF) { if (!empty($objResult->fields['default'])) { $arrDefaults[$objResult->fields['type']] = explode(',', $objResult->fields['default']); } $arrValues[$objResult->fields['type']] = $objResult->fields['value']; $objResult->MoveNext(); } } $regSalutation = !empty($arrValues['salutation']) ? $arrDefaults['salutation'][$arrValues['salutation'] - 1] : ''; $regFirstname = !empty($arrValues['firstname']) ? $arrValues['firstname'] : ''; $regLastname = !empty($arrValues['lastname']) ? $arrValues['lastname'] : ''; $regMail = !empty($arrValues['mail']) ? $arrValues['mail'] : ''; $regType = $objRegistration->type == 1 ? $_ARRAYLANG['TXT_CALENDAR_REG_REGISTRATION'] : $_ARRAYLANG['TXT_CALENDAR_REG_SIGNOFF']; $regSearch = array('[[REGISTRATION_TYPE]]', '[[REGISTRATION_SALUTATION]]', '[[REGISTRATION_FIRSTNAME]]', '[[REGISTRATION_LASTNAME]]', '[[REGISTRATION_EMAIL]]'); $regReplace = array($regType, $regSalutation, $regFirstname, $regLastname, $regMail); } $domain = ASCMS_PROTOCOL . "://" . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET . "/"; $date = $this->format2userDateTime(new \DateTime()); $startDate = $event->startDate; $endDate = $event->endDate; $eventTitle = $event->title; $eventStart = $event->all_day ? $this->format2userDate($startDate) : $this->formatDateTime2user($startDate, $this->getDateFormat() . ' (H:i:s)'); $eventEnd = $event->all_day ? $this->format2userDate($endDate) : $this->formatDateTime2user($endDate, $this->getDateFormat() . ' (H:i:s)'); $placeholder = array('[[TITLE]]', '[[START_DATE]]', '[[END_DATE]]', '[[LINK_EVENT]]', '[[LINK_REGISTRATION]]', '[[USERNAME]]', '[[FIRSTNAME]]', '[[LASTNAME]]', '[[URL]]', '[[DATE]]'); $recipients = $this->getSendMailRecipients($actionId, $event, $regId, $objRegistration); $objMail = new \phpmailer(); if ($_CONFIG['coreSmtpServer'] > 0) { $arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer']); if ($arrSmtp !== false) { $objMail->IsSMTP(); $objMail->Host = $arrSmtp['hostname']; $objMail->Port = $arrSmtp['port']; $objMail->SMTPAuth = true; $objMail->Username = $arrSmtp['username']; $objMail->Password = $arrSmtp['password']; } } $objMail->CharSet = CONTREXX_CHARSET; $objMail->SetFrom($_CONFIG['coreAdminEmail'], $_CONFIG['coreGlobalPageTitle']); foreach ($recipients as $mailAdress => $langId) { if (!empty($mailAdress)) { $langId = $this->getSendMailLangId($actionId, $mailAdress, $langId); if ($objUser = \FWUser::getFWUserObject()->objUser->getUsers($filter = array('email' => $mailAdress, 'is_active' => true))) { $userNick = $objUser->getUsername(); $userFirstname = $objUser->getProfileAttribute('firstname'); $userLastname = $objUser->getProfileAttribute('lastname'); } else { $userNick = $mailAdress; if (!empty($regId) && $mailAdress == $regMail) { $userFirstname = $regFirstname; $userLastname = $regLastname; } else { $userFirstname = ''; $userLastname = ''; } } $mailTitle = $this->mailList[$langId]['mail']->title; $mailContentText = !empty($this->mailList[$langId]['mail']->content_text) ? $this->mailList[$langId]['mail']->content_text : strip_tags($this->mailList[$langId]['mail']->content_html); $mailContentHtml = !empty($this->mailList[$langId]['mail']->content_html) ? $this->mailList[$langId]['mail']->content_html : $this->mailList[$langId]['mail']->content_text; // actual language of selected e-mail template $contentLanguage = $this->mailList[$langId]['lang_id']; if ($actionId == self::MAIL_NOTFY_NEW_APP && $event->arrSettings['confirmFrontendEvents'] == 1) { $eventLink = $domain . "/cadmin/index.php?cmd={$this->moduleName}&act=modify_event&id={$event->id}&confirm=1"; } else { $eventLink = \Cx\Core\Routing\Url::fromModuleAndCmd($this->moduleName, 'detail', $contentLanguage, array('id' => $event->id, 'date' => $event->startDate->getTimestamp()))->toString(); } $regLink = \Cx\Core\Routing\Url::fromModuleAndCmd($this->moduleName, 'register', $contentLanguage, array('id' => $event->id, 'date' => $event->startDate->getTimestamp()))->toString(); $replaceContent = array($eventTitle, $eventStart, $eventEnd, $eventLink, $regLink, $userNick, $userFirstname, $userLastname, $domain, $date); $mailTitle = str_replace($placeholder, $replaceContent, $mailTitle); $mailContentText = str_replace($placeholder, $replaceContent, $mailContentText); $mailContentHtml = str_replace($placeholder, $replaceContent, $mailContentHtml); if (!empty($regId)) { $mailTitle = str_replace($regSearch, $regReplace, $mailTitle); $mailContentText = str_replace($regSearch, $regReplace, $mailContentText); $mailContentHtml = str_replace($regSearch, $regReplace, $mailContentHtml); $mailContentText = str_replace('[[REGISTRATION_DATA]]', $registrationDataText, $mailContentText); $mailContentHtml = str_replace('[[REGISTRATION_DATA]]', $registrationDataHtml, $mailContentHtml); } /*echo "send to: ".$mailAdress."<br />"; echo "send title: ".$mailTitle."<br />";*/ $objMail->Subject = $mailTitle; $objMail->Body = $mailContentHtml; $objMail->AltBody = $mailContentText; $objMail->AddAddress($mailAdress); $objMail->Send(); $objMail->ClearAddresses(); } } } }
/** * Searches the content and returns an array that is built as needed by the search module. * * @param string $searchTerm * * @return array */ public function searchResultsForSearchModule($searchTerm) { $em = \Env::get('cx')->getDb()->getEntityManager(); $pageRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page'); // only list results in case the associated page of the module is active $page = $pageRepo->findOneBy(array('module' => 'MediaDir', 'lang' => FRONTEND_LANG_ID, 'type' => \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION)); //If page is not exists or page is inactive then return empty result if (!$page || !$page->isActive()) { return array(); } //get the config site values \Cx\Core\Setting\Controller\Setting::init('Config', 'site', 'Yaml'); $coreListProtectedPages = \Cx\Core\Setting\Controller\Setting::getValue('coreListProtectedPages', 'Config'); $searchVisibleContentOnly = \Cx\Core\Setting\Controller\Setting::getValue('searchVisibleContentOnly', 'Config'); //get the config otherConfigurations value \Cx\Core\Setting\Controller\Setting::init('Config', 'otherConfigurations', 'Yaml'); $searchDescriptionLength = \Cx\Core\Setting\Controller\Setting::getValue('searchDescriptionLength', 'Config'); $hasPageAccess = true; $isNotVisible = $searchVisibleContentOnly == 'on' && !$page->isVisible(); if ($coreListProtectedPages == 'off' && $page->isFrontendProtected()) { $hasPageAccess = \Permission::checkAccess($page->getFrontendAccessId(), 'dynamic', true); } //If the page is invisible and frontend access is denied then return empty result if ($isNotVisible || !$hasPageAccess) { return array(); } //get the media directory entry by the search term $entries = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry($this->moduleName); $entries->getEntries(null, null, null, $searchTerm); //if no entries found then return empty result if (empty($entries->arrEntries)) { return array(); } $results = array(); $formEntries = array(); $defaultEntries = null; $objForm = new \Cx\Modules\MediaDir\Controller\MediaDirectoryForm(null, $this->moduleName); $numOfEntries = intval($entries->arrSettings['settingsPagingNumEntries']); foreach ($entries->arrEntries as $entry) { $pageUrlResult = null; $entryForm = $objForm->arrForms[$entry['entryFormId']]; //Get the entry's link url //check the entry's form detail view exists if not, //check the entry's form overview exists if not, //check the default overview exists if not, dont show the corresponding entry in entry switch (true) { case $entries->checkPageCmd('detail' . $entry['entryFormId']): $pageUrlResult = \Cx\Core\Routing\Url::fromModuleAndCmd($entries->moduleName, 'detail' . $entry['entryFormId'], FRONTEND_LANG_ID, array('eid' => $entry['entryId'])); break; case $pageCmdExists = $entries->checkPageCmd($entryForm['formCmd']): case $entries->checkPageCmd(''): if ($pageCmdExists && !isset($formEntries[$entryForm['formCmd']])) { $formEntries[$entryForm['formCmd']] = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry($entries->moduleName); $formEntries[$entryForm['formCmd']]->getEntries(null, null, null, null, null, null, 1, null, 'n', null, null, $entryForm['formId']); } if (!$pageCmdExists && !isset($defaultEntries)) { $defaultEntries = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry($entries->moduleName); $defaultEntries->getEntries(); } //get entry's form overview / default page paging position $entriesPerPage = $numOfEntries; if ($pageCmdExists) { $entriesPerPage = !empty($entryForm['formEntriesPerPage']) ? $entryForm['formEntriesPerPage'] : $numOfEntries; } $pageCmd = $pageCmdExists ? $entryForm['formCmd'] : ''; $entryKeys = $pageCmdExists ? array_keys($formEntries[$entryForm['formCmd']]->arrEntries) : array_keys($defaultEntries->arrEntries); $entryPos = array_search($entry['entryId'], $entryKeys); $position = floor($entryPos / $entriesPerPage); $pageUrlResult = \Cx\Core\Routing\Url::fromModuleAndCmd($entries->moduleName, $pageCmd, FRONTEND_LANG_ID, array('pos' => $position * $entriesPerPage)); break; default: break; } //If page url is empty then dont show it in the result if (!$pageUrlResult) { continue; } //Get the search results title and content from the form context field 'title' and 'content' $title = current($entry['entryFields']); $content = ''; $objInputfields = new MediaDirectoryInputfield($entry['entryFormId'], false, $entry['entryTranslationStatus'], $this->moduleName); $inputFields = $objInputfields->getInputfields(); foreach ($inputFields as $arrInputfield) { $contextType = isset($arrInputfield['context_type']) ? $arrInputfield['context_type'] : ''; if (!in_array($contextType, array('title', 'content'))) { 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); if (\Cx\Core\Core\Controller\Cx::instanciate()->getMode() == \Cx\Core\Core\Controller\Cx::MODE_FRONTEND && \Cx\Core\Setting\Controller\Setting::getValue('blockStatus', 'Config')) { $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'] = preg_replace('/\\[\\[(BLOCK_[A-Z0-9_-]+)\\]\\]/', '{\\1}', $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE']); \Cx\Modules\Block\Controller\Block::setBlocks($arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'], \Cx\Core\Core\Controller\Cx::instanciate()->getPage()); } } catch (\Exception $e) { \DBG::log($e->getMessage()); continue; } $inputFieldValue = $arrInputfieldContent[$this->moduleConstVar . '_INPUTFIELD_VALUE']; if (empty($inputFieldValue)) { continue; } if ($contextType == 'title') { $title = $inputFieldValue; } elseif ($contextType == 'content') { $content = \Cx\Core_Modules\Search\Controller\Search::shortenSearchContent($inputFieldValue, $searchDescriptionLength); } } $results[] = array('Score' => 100, 'Title' => html_entity_decode(contrexx_strip_tags($title), ENT_QUOTES, CONTREXX_CHARSET), 'Content' => $content, 'Link' => $pageUrlResult->toString()); } return $results; }
/** * Returns an array of values to be substituted * * Contains the following keys and values: * 'SHOP_COMPANY' => The company name (from the settings) * 'SHOP_HOMEPAGE' => The shop starting page URL * Used primarily for all MailTemplates. * Indexed by placeholder names. * @return array The substitution array */ static function getSubstitutionArray() { return array('SHOP_COMPANY' => \Cx\Core\Setting\Controller\Setting::getValue('company', 'Shop'), 'SHOP_HOMEPAGE' => \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', '', FRONTEND_LANG_ID)->toString()); }