private function overview() { global $_LANGID; // load source code if cmd value is integer if ($this->objTemplate->placeholderExists('APPLICATION_DATA')) { $page = new \Cx\Core\ContentManager\Model\Entity\Page(); $page->setVirtual(true); $page->setType(\Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION); $page->setModule('Downloads'); // load source code $applicationTemplate = \Cx\Core\Core\Controller\Cx::getContentTemplateOfPage($page); \LinkGenerator::parseTemplate($applicationTemplate); $this->objTemplate->addBlock('APPLICATION_DATA', 'application_data', $applicationTemplate); } $objDownload = new Download(); $objCategory = Category::getCategory($this->categoryId); if ($objCategory->getId()) { // check access permissions to selected category if (!\Permission::checkAccess(143, 'static', true) && $objCategory->getReadAccessId() && !\Permission::checkAccess($objCategory->getReadAccessId(), 'dynamic', true) && $objCategory->getOwnerId() != $this->userId) { // TODO: might we have to add a soft noAccess handler in case the output is meant for a regular page (not section=Downloads) \Permission::noAccess(base64_encode(CONTREXX_SCRIPT_PATH . $this->moduleParamsJs . '&category=' . $objCategory->getId())); } // parse crumbtrail $this->parseCrumbtrail($objCategory); if ($objDownload->load(!empty($_REQUEST['id']) ? intval($_REQUEST['id']) : 0) && (!$objDownload->getExpirationDate() || $objDownload->getExpirationDate() > time()) && $objDownload->getActiveStatus()) { /* DOWNLOAD DETAIL PAGE */ $this->pageTitle = contrexx_raw2xhtml($objDownload->getName(FRONTEND_LANG_ID)); $metakeys = $objDownload->getMetakeys(FRONTEND_LANG_ID); if ($this->arrConfig['use_attr_metakeys'] && !empty($metakeys)) { \Env::get('cx')->getPage()->setMetakeys($metakeys); } $this->parseRelatedCategories($objDownload); $this->parseRelatedDownloads($objDownload, $objCategory->getId()); $this->parseDownload($objDownload, $objCategory->getId()); // hide unwanted blocks on the detail page if ($this->objTemplate->blockExists('downloads_category')) { $this->objTemplate->hideBlock('downloads_category'); } if ($this->objTemplate->blockExists('downloads_subcategory_list')) { $this->objTemplate->hideBlock('downloads_subcategory_list'); } if ($this->objTemplate->blockExists('downloads_file_list')) { $this->objTemplate->hideBlock('downloads_file_list'); } if ($this->objTemplate->blockExists('downloads_simple_file_upload')) { $this->objTemplate->hideBlock('downloads_simple_file_upload'); } if ($this->objTemplate->blockExists('downloads_advanced_file_upload')) { $this->objTemplate->hideBlock('downloads_advanced_file_upload'); } } else { /* CATEGORY DETAIL PAGE */ $this->pageTitle = htmlentities($objCategory->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET); // process create directory $this->processCreateDirectory($objCategory); // parse selected category $this->parseCategory($objCategory); // parse subcategories $this->parseCategories($objCategory, array('downloads_subcategory_list', 'downloads_subcategory'), null, 'SUB'); // parse downloads of selected category $this->parseDownloads($objCategory); // parse upload form $this->parseUploadForm($objCategory); // parse create directory form $this->parseCreateCategoryForm($objCategory); // hide unwanted blocks on the category page if ($this->objTemplate->blockExists('downloads_download')) { $this->objTemplate->hideBlock('downloads_download'); } if ($this->objTemplate->blockExists('downloads_file_detail')) { $this->objTemplate->hideBlock('downloads_file_detail'); } } // hide unwanted blocks on the category/detail page if ($this->objTemplate->blockExists('downloads_overview')) { $this->objTemplate->hideBlock('downloads_overview'); } if ($this->objTemplate->blockExists('downloads_most_viewed_file_list')) { $this->objTemplate->hideBlock('downloads_most_viewed_file_list'); } if ($this->objTemplate->blockExists('downloads_most_downloaded_file_list')) { $this->objTemplate->hideBlock('downloads_most_downloaded_file_list'); } if ($this->objTemplate->blockExists('downloads_most_popular_file_list')) { $this->objTemplate->hideBlock('downloads_most_popular_file_list'); } if ($this->objTemplate->blockExists('downloads_newest_file_list')) { $this->objTemplate->hideBlock('downloads_newest_file_list'); } if ($this->objTemplate->blockExists('downloads_updated_file_list')) { $this->objTemplate->hideBlock('downloads_updated_file_list'); } } else { /* CATEGORY OVERVIEW PAGE */ $this->parseCategories($objCategory, array('downloads_overview', 'downloads_overview_category'), null, null, 'downloads_overview_row', array('downloads_overview_subcategory_list', 'downloads_overview_subcategory'), $this->arrConfig['overview_max_subcats']); if (!empty($this->searchKeyword)) { $this->parseDownloads($objCategory); } else { if ($this->objTemplate->blockExists('downloads_file_list')) { $this->objTemplate->hideBlock('downloads_file_list'); } } /* PARSE MOST VIEWED DOWNLOADS */ $this->parseSpecialDownloads(array('downloads_most_viewed_file_list', 'downloads_most_viewed_file'), array('is_active' => true, 'expiration' => array('=' => 0, '>' => time())), array('views' => 'desc'), $this->arrConfig['most_viewed_file_count']); /* PARSE MOST DOWNLOADED DOWNLOADS */ $this->parseSpecialDownloads(array('downloads_most_downloaded_file_list', 'downloads_most_downloaded_file'), array('is_active' => true, 'expiration' => array('=' => 0, '>' => time())), array('download_count' => 'desc'), $this->arrConfig['most_downloaded_file_count']); /* PARSE MOST POPULAR DOWNLOADS */ // TODO: Rating system has to be implemented first! //$this->parseSpecialDownloads(array('downloads_most_popular_file_list', 'downloads_most_popular_file'), null, array('rating' => 'desc'), $this->arrConfig['most_popular_file_count']); /* PARSE RECENTLY UPDATED DOWNLOADS */ $filter = array('ctime' => array('>=' => time() - $this->arrConfig['new_file_time_limit']), 'expiration' => array('=' => 0, '>' => time())); $this->parseSpecialDownloads(array('downloads_newest_file_list', 'downloads_newest_file'), $filter, array('ctime' => 'desc'), $this->arrConfig['newest_file_count']); // parse recently updated downloads $filter = array('mtime' => array('>=' => time() - $this->arrConfig['updated_file_time_limit']), 'ctime' => array('<' => time() - $this->arrConfig['new_file_time_limit']), 'expiration' => array('=' => 0, '>' => time())); $this->parseSpecialDownloads(array('downloads_updated_file_list', 'downloads_updated_file'), $filter, array('mtime' => 'desc'), $this->arrConfig['updated_file_count']); // hide unwanted blocks on the overview page if ($this->objTemplate->blockExists('downloads_category')) { $this->objTemplate->hideBlock('downloads_category'); } if ($this->objTemplate->blockExists('downloads_crumbtrail')) { $this->objTemplate->hideBlock('downloads_crumbtrail'); } if ($this->objTemplate->blockExists('downloads_subcategory_list')) { $this->objTemplate->hideBlock('downloads_subcategory_list'); } if ($this->objTemplate->blockExists('downloads_file_detail')) { $this->objTemplate->hideBlock('downloads_file_detail'); } if ($this->objTemplate->blockExists('downloads_simple_file_upload')) { $this->objTemplate->hideBlock('downloads_simple_file_upload'); } if ($this->objTemplate->blockExists('downloads_advanced_file_upload')) { $this->objTemplate->hideBlock('downloads_advanced_file_upload'); } } $this->parseGlobalStuff($objCategory); }
function _showEmailFeedbackAnalysis() { global $objDatabase, $_ARRAYLANG, $_CONFIG; $this->_pageTitle = $_ARRAYLANG['TXT_NEWSLETTER_EMAIL_FEEDBACK']; $this->_objTpl->loadTemplateFile('module_newsletter_email_feedback.html'); $rowNr = 0; $pos = isset($_GET['pos']) ? intval($_GET['pos']) : 0; $mailId = isset($_GET['id']) ? intval($_GET['id']) : 0; $email = ''; $objMail = $objDatabase->SelectLimit("SELECT `subject` FROM " . DBPREFIX . "module_newsletter WHERE id=" . $mailId, 1); if ($objMail !== false && $objMail->RecordCount() == 1) { $email = contrexx_raw2xhtml($objMail->fields['subject']); } $this->_objTpl->setVariable(array('TXT_NEWSLETTER_LINK_TITLE' => $_ARRAYLANG['TXT_NEWSLETTER_LINK_TITLE'], 'TXT_NEWSLETTER_FEEDBACK_RECIPIENTS' => $_ARRAYLANG['TXT_NEWSLETTER_FEEDBACK_RECIPIENTS'], 'TXT_NEWSLETTER_LINK_SOURCE' => $_ARRAYLANG['TXT_NEWSLETTER_LINK_SOURCE'], 'TXT_NEWSLETTER_FUNCTIONS' => $_ARRAYLANG['TXT_NEWSLETTER_FUNCTIONS'], 'TXT_NEWSLETTER_BACK' => $_ARRAYLANG['TXT_NEWSLETTER_BACK'], 'TXT_NEWSLETTER_EMAIL_FEEDBACK' => sprintf($_ARRAYLANG['TXT_NEWSLETTER_SELECTED_EMAIL_FEEDBACK'], $email))); $this->_objTpl->setGlobalVariable(array('TXT_NEWSLETTER_OPEN_LINK_IN_NEW_TAB' => $_ARRAYLANG['TXT_NEWSLETTER_OPEN_LINK_IN_NEW_TAB'], 'TXT_NEWSLETTER_LINK_FEEDBACK_ANALYZE' => $_ARRAYLANG['TXT_NEWSLETTER_LINK_FEEDBACK_ANALYZE'])); $objResultCount = $objDatabase->SelectLimit("SELECT COUNT(id) AS link_count FROM " . DBPREFIX . "module_newsletter_email_link\n WHERE email_id = " . $mailId, 1); if ($objResultCount !== false) { $linkCount = $objResultCount->fields['link_count']; } else { $linkCount = 0; } $objResult = $objDatabase->SelectLimit("SELECT\n tblLink.id,\n tblLink.title,\n tblLink.url,\n tblMail.count,\n COUNT(tblMailLinkFB.id) AS feedback_count\n FROM " . DBPREFIX . "module_newsletter_email_link AS tblLink\n INNER JOIN " . DBPREFIX . "module_newsletter AS tblMail ON tblMail.id = " . $mailId . "\n LEFT JOIN " . DBPREFIX . "module_newsletter_email_link_feedback AS tblMailLinkFB ON tblMailLinkFB.link_id = tblLink.id\n WHERE tblLink.email_id = " . $mailId . "\n GROUP BY tblLink.id\n ORDER BY tblLink.title ASC", $_CONFIG['corePagingLimit'], $pos); if ($objResult !== false) { while (!$objResult->EOF) { // parse NODE-Url placeholders in link \LinkGenerator::parseTemplate($objResult->fields['url'], true); $this->_objTpl->setVariable(array('NEWSLETTER_LINK_ROW_CLASS' => $rowNr % 2 == 1 ? 'row1' : 'row2', 'NEWSLETTER_LINK_TITLE' => $objResult->fields['title'], 'NEWSLETTER_LINK_URL' => $objResult->fields['url'], 'NEWSLETTER_MAIL_USERS' => (int) $objResult->fields['feedback_count'], 'NEWSLETTER_LINK_FEEDBACK' => $objResult->fields['count'] > 0 ? round(100 / $objResult->fields['count'] * $objResult->fields['feedback_count']) : 0)); $this->_objTpl->setGlobalVariable('NEWSLETTER_LINK_ID', $objResult->fields['id']); $this->_objTpl->parse("link_list"); $objResult->MoveNext(); $rowNr++; } if ($rowNr > 0) { $paging = getPaging($linkCount, $pos, "&cmd=Newsletter&act=feedback&email_id=" . $mailId, "", false, $_CONFIG['corePagingLimit']); $this->_objTpl->setVariable('NEWSLETTER_LINKS_PAGING', "<br />" . $paging . "<br />"); } } }
/** * track link: save feedback to database * * @return boolean */ public static function trackLink() { global $objDatabase; $recipientId = 0; $realUser = true; if (isset($_GET['m'])) { $recipientId = contrexx_input2raw($_GET['m']); $realUser = false; } else { if (isset($_GET['r'])) { $recipientId = contrexx_input2raw($_GET['r']); } else { return false; } } $emailId = isset($_GET['n']) ? contrexx_input2raw($_GET['n']) : 0; $linkId = isset($_GET['l']) ? contrexx_input2raw($_GET['l']) : 0; if (!empty($recipientId)) { // find out recipient type if ($realUser) { $objUser = \FWUser::getFWUserObject()->objUser->getUser(intval($recipientId)); $recipientId = null; if ($objUser !== false) { $recipientId = $objUser->getId(); $recipientType = self::USER_TYPE_ACCESS; } } else { $objUser = $objDatabase->SelectLimit("SELECT `id` FROM " . DBPREFIX . "module_newsletter_user WHERE id='" . contrexx_raw2db($recipientId) . "'", 1); $recipientId = null; if (!($objUser === false || $objUser->RecordCount() != 1)) { $recipientId = $objUser->fields['id']; $recipientType = self::USER_TYPE_NEWSLETTER; } } } /* * Request must be redirected to the newsletter $linkId URL. If the $linkId * can't be looked up in the database (by what reason so ever), then the request shall be * redirected to the URL provided by the url-modificator s of the request */ $objLink = $objDatabase->SelectLimit("SELECT `url` FROM " . DBPREFIX . "module_newsletter_email_link WHERE id=" . contrexx_raw2db($linkId) . " AND email_id=" . contrexx_raw2db($emailId), 1); if ($objLink === false || $objLink->RecordCount() != 1) { return false; } $url = $objLink->fields['url']; \LinkGenerator::parseTemplate($url); if (!empty($recipientId)) { // save feedback for valid user $query = "\n INSERT IGNORE INTO " . DBPREFIX . "module_newsletter_email_link_feedback (link_id, email_id, recipient_id, recipient_type)\n VALUES (" . contrexx_raw2db($linkId) . ", " . contrexx_raw2db($emailId) . ", " . contrexx_raw2db($recipientId) . ", '" . contrexx_raw2db($recipientType) . "')\n "; $objDatabase->Execute($query); } \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . $url); exit; }
/** * Save the block content * * @param array $params all given params from http request * @throws NoPermissionException * @throws NotEnoughArgumentsException * @throws BlockCouldNotBeSavedException * @return boolean true if everything finished with success */ public function saveBlockContent($params) { global $_CORELANG, $objDatabase; // security check if (!\FWUser::getFWUserObject()->objUser->login() || !\Permission::checkAccess(76, 'static', true)) { throw new NoPermissionException($_CORELANG['TXT_ACCESS_DENIED_DESCRIPTION']); } // check arguments if (empty($params['get']['block']) || empty($params['get']['lang'])) { throw new NotEnoughArgumentsException('not enough arguments'); } // get language and block id $id = intval($params['get']['block']); $lang = \FWLanguage::getLanguageIdByCode($params['get']['lang']); if (!$lang) { $lang = FRONTEND_LANG_ID; } $content = $params['post']['content']; // query to update content in database $query = "UPDATE `" . DBPREFIX . "module_block_rel_lang_content`\n SET content = '" . \contrexx_input2db($content) . "'\n WHERE\n block_id = " . $id . " AND lang_id = " . $lang; $result = $objDatabase->Execute($query); // error handling if ($result === false) { throw new BlockCouldNotBeSavedException('block could not be saved'); } \LinkGenerator::parseTemplate($content); $ls = new \LinkSanitizer(ASCMS_PATH_OFFSET . \Env::get('virtualLanguageDirectory') . '/', $content); $this->messages[] = $_CORELANG['TXT_CORE_SAVED_BLOCK']; return array('content' => $ls->replace()); }
function showEntry() { global $_ARRAYLANG, $_CORELANG; $this->_objTpl->setTemplate($this->pageContent, true, true); //get ids $intCategoryId = isset($_GET['cid']) ? intval($_GET['cid']) : 0; $intLevelId = isset($_GET['lid']) ? intval($_GET['lid']) : 0; $intEntryId = isset($_GET['eid']) ? intval($_GET['eid']) : 0; // load source code if cmd value is integer if ($this->_objTpl->placeholderExists('APPLICATION_DATA')) { $page = new \Cx\Core\ContentManager\Model\Entity\Page(); $page->setVirtual(true); $page->setType(\Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION); $page->setModule('MediaDir'); $page->setCmd('detail'); // load source code $applicationTemplate = \Cx\Core\Core\Controller\Cx::getContentTemplateOfPage($page); \LinkGenerator::parseTemplate($applicationTemplate); $this->_objTpl->addBlock('APPLICATION_DATA', 'application_data', $applicationTemplate); } //get navtree if ($this->_objTpl->blockExists($this->moduleNameLC . 'Navtree') && ($intCategoryId != 0 || $intLevelId != 0)) { $this->getNavtree($intCategoryId, $intLevelId); } if ($intEntryId != 0 && $this->_objTpl->blockExists($this->moduleNameLC . 'EntryList')) { $objEntry = new MediaDirectoryEntry($this->moduleName); $objEntry->getEntries($intEntryId, $intLevelId, $intCategoryId, null, null, null, 1, null, 1); $objEntry->listEntries($this->_objTpl, 2); $objEntry->updateHits($intEntryId); //set meta title $this->metaTitle .= " - " . $objEntry->arrEntries[$intEntryId]['entryFields'][0]; $this->pageTitle = $objEntry->arrEntries[$intEntryId]['entryFields'][0]; if (empty($objEntry->arrEntries)) { $this->_objTpl->hideBlock($this->moduleNameLC . 'EntryList'); $this->_objTpl->clearVariables(); header("Location: index.php?section=" . $this->moduleName); exit; } } else { header("Location: index.php?section=" . $this->moduleName); exit; } }
/** * Set up and send an email * * The array argument is searched for the following indices: * key The key of any mail template to be used * section The module to initialize for (mandatory when key is set) * sender The sender name * from The sender e-mail address * to The recipient e-mail address(es), comma separated * reply The reply-to e-mail address * cc The carbon copy e-mail address(es), comma separated * bcc The blind carbon copy e-mail address(es), comma separated * subject The message subject * message The plain text message body * message_html The HTML message body * html If this evaluates to true, turns on HTML mode * attachments An array of file paths to attach. The array keys may * be used for the paths, and the values for the name. * If the keys are numeric, the values are regarded as paths. * inline An array of inline (image) file paths to attach. * If this is used, HTML mode is switched on automatically. * search The array of patterns to be replaced by... * replace The array of replacements for the patterns * substitution A more complex structure for replacing placeholders * and/or complete blocks, conditionally or repeatedly. * If the key index is present, the corresponding mail template is loaded * first. Other indices present (sender, from, to, subject, message, etc.) * will override the template fields. * Missing mandatory fields are filled with the * default values from the global $_CONFIG array (sender, from, to), * or some core language variables (subject, message). * A simple {@see str_replace()} is used for the search and replace * operation, and the placeholder names are quoted in the substitution, * so you cannot use regular expressions. * More complex substitutions including repeated blocks may be specified * in the substitution subarray of the $arrField parameter value. * The e-mail addresses in the To: field will be used as follows: * - Groups of addresses are separated by semicola (;) * - Single addresses are separated by comma (,) * All recipients of any single group are added to the To: field together, * Groups are processed separately. So, if your To: looks like * a@a.com,b@b.com;c@c.com,d@d.com * a total of two e-mails will be sent; one to a and b, and a second one * to c and d. * Addresses for copies (Cc:) and blind copies (Bcc:) are added to all * e-mails sent, so if your e-mail is in the Cc: or Bcc: field in the * example above, you will receive two copies. * Note: The attachment paths must comply with the requirements for * file paths as defined in the {@see File} class version 2.2.0. * @static * @param array $arrField The array of template fields * @return boolean True if the mail could be sent, * false otherwise * @author Reto Kohli <*****@*****.**> */ static function send($arrField) { global $_CONFIG; //, $_CORELANG; if (!\Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) { \DBG::log("MailTemplate::send(): ERROR: Failed to load phpMailer"); return false; } $objMail = new \phpmailer(); if (!empty($_CONFIG['coreSmtpServer']) && \Env::get('ClassLoader')->loadFile(ASCMS_CORE_PATH . '/SmtpSettings.class.php')) { $arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer']); if ($arrSmtp) { $objMail->IsSMTP(); $objMail->SMTPAuth = true; $objMail->Host = $arrSmtp['hostname']; $objMail->Port = $arrSmtp['port']; $objMail->Username = $arrSmtp['username']; $objMail->Password = $arrSmtp['password']; } } if (empty($arrField['lang_id'])) { $arrField['lang_id'] = FRONTEND_LANG_ID; } $section = isset($arrField['section']) ? $arrField['section'] : null; $arrTemplate = null; if (empty($arrField['key'])) { $arrTemplate = self::getEmpty(); } else { $arrTemplate = self::get($section, $arrField['key'], $arrField['lang_id']); if (empty($arrTemplate)) { \DBG::log("MailTemplate::send(): WARNING: No Template for key {$arrField['key']} (section {$section})"); return false; } } $search = isset($arrField['search']) && is_array($arrField['search']) ? $arrField['search'] : null; $replace = isset($arrField['replace']) && is_array($arrField['replace']) ? $arrField['replace'] : null; $substitution = isset($arrField['substitution']) && is_array($arrField['substitution']) ? $arrField['substitution'] : null; //echo("Substitution:<br />".nl2br(var_export($arrField['substitution'], true))."<hr />"); $strip = empty($arrField['do_not_strip_empty_placeholders']); // Replace node placeholders generated by Wysiwyg $arrTemplate['message_html'] = preg_replace('/\\[\\[NODE_([a-zA-Z_0-9]*)\\]\\]/', '{NODE_$1}', $arrTemplate['message_html']); \LinkGenerator::parseTemplate($arrTemplate['message_html'], true); foreach ($arrTemplate as $field => &$value) { if ($field == 'inline' || $field == 'attachments') { continue; } if (isset($arrField[$field])) { $value = $arrField[$field]; } if (empty($value) || is_numeric($value)) { continue; } // TODO: Fix the regex to produce proper "CR/LF" in any case. // Must handle any of CR, LF, CR/LF, and LF/CR! // preg_replace('/[\015\012]/', "\015\012", $value); if ($search) { // we need to replace raw data with HTML entities // for HTML-body of email if ($field == 'message_html') { foreach ($search as $index => $searchTerm) { $value = str_replace($searchTerm, contrexx_raw2xhtml($replace[$index]), $value); } } else { $value = str_replace($search, $replace, $value); } } if ($substitution) { $convertToHtmlEntities = false; if ($field == 'message_html') { $convertToHtmlEntities = true; } self::substitute($value, $substitution, $convertToHtmlEntities); } if ($strip) { self::clearEmptyPlaceholders($value); } } //DBG::log("MailTemplate::send(): Substituted: ".var_export($arrTemplate, true)); //echo("MailTemplate::send(): Substituted:<br /><pre>".nl2br(htmlentities(var_export($arrTemplate, true), ENT_QUOTES, CONTREXX_CHARSET))."</PRE><hr />"); //die();//return true; // Use defaults for missing mandatory fields // if (empty($arrTemplate['sender'])) // $arrTemplate['sender'] = $_CONFIG['coreAdminName']; if (empty($arrTemplate['from'])) { \DBG::log("MailTemplate::send(): INFO: Empty 'from:', falling back to config"); $arrTemplate['from'] = $_CONFIG['coreAdminEmail']; } if (empty($arrTemplate['to'])) { \DBG::log("MailTemplate::send(): INFO: Empty 'to:', falling back to config"); $arrTemplate['to'] = $_CONFIG['coreAdminEmail']; } // if (empty($arrTemplate['subject'])) // $arrTemplate['subject'] = $_CORELANG['TXT_CORE_MAILTEMPLATE_NO_SUBJECT']; // if (empty($arrTemplate['message'])) // $arrTemplate['message'] = $_CORELANG['TXT_CORE_MAILTEMPLATE_NO_MESSAGE']; $objMail->FromName = $arrTemplate['sender']; $objMail->From = $arrTemplate['from']; $objMail->Subject = $arrTemplate['subject']; $objMail->CharSet = CONTREXX_CHARSET; // $objMail->IsHTML(false); if ($arrTemplate['html']) { $objMail->IsHTML(true); $objMail->Body = $arrTemplate['message_html']; $objMail->AltBody = $arrTemplate['message']; } else { $objMail->Body = $arrTemplate['message']; } foreach (preg_split('/\\s*,\\s*/', $arrTemplate['reply'], null, PREG_SPLIT_NO_EMPTY) as $address) { $objMail->AddReplyTo($address); } // foreach (preg_split('/\s*,\s*/', $arrTemplate['to'], null, PREG_SPLIT_NO_EMPTY) as $address) { // $objMail->AddAddress($address); // } foreach (preg_split('/\\s*,\\s*/', $arrTemplate['cc'], null, PREG_SPLIT_NO_EMPTY) as $address) { $objMail->AddCC($address); } foreach (preg_split('/\\s*,\\s*/', $arrTemplate['bcc'], null, PREG_SPLIT_NO_EMPTY) as $address) { $objMail->AddBCC($address); } // Applicable to attachments stored with the MailTemplate only! $arrTemplate['attachments'] = self::attachmentsToArray($arrTemplate['attachments']); //DBG::log("MailTemplate::send(): Template Attachments: ".var_export($arrTemplate['attachments'], true)); // Now the MailTemplates' attachments index is guaranteed to // contain an array. // Add attachments from the parameter array, if any. if (isset($arrField['attachments']) && is_array($arrField['attachments'])) { foreach ($arrField['attachments'] as $path => $name) { // if (empty($path)) $path = $name; // if (empty($name)) $name = basename($path); $arrTemplate['attachments'][$path] = $name; //DBG::log("MailTemplate::send(): Added Field Attachment: $path / $name"); } } //DBG::log("MailTemplate::send(): All Attachments: ".var_export($arrTemplate['attachments'], true)); foreach ($arrTemplate['attachments'] as $path => $name) { if (is_numeric($path)) { $path = $name; } $objMail->AddAttachment(ASCMS_DOCUMENT_ROOT . '/' . $path, $name); } $arrTemplate['inline'] = self::attachmentsToArray($arrTemplate['inline']); if ($arrTemplate['inline']) { $arrTemplate['html'] = true; } foreach ($arrTemplate['inline'] as $path => $name) { if (is_numeric($path)) { $path = $name; } $objMail->AddEmbeddedImage(ASCMS_DOCUMENT_ROOT . '/' . $path, uniqid(), $name); } if (isset($arrField['inline']) && is_array($arrField['inline'])) { $arrTemplate['html'] = true; foreach ($arrField['inline'] as $path => $name) { if (is_numeric($path)) { $path = $name; } $objMail->AddEmbeddedImage(ASCMS_DOCUMENT_ROOT . '/' . $path, uniqid(), $name); } } //die("MailTemplate::send(): Attachments and inlines<br />".var_export($objMail, true)); $objMail->CharSet = CONTREXX_CHARSET; $objMail->IsHTML($arrTemplate['html']); //DBG::log("MailTemplate::send(): Sending: ".nl2br(htmlentities(var_export($objMail, true), ENT_QUOTES, CONTREXX_CHARSET))."<br />Sending...<hr />"); $result = true; foreach (preg_split('/\\s*;\\s*/', $arrTemplate['to'], null, PREG_SPLIT_NO_EMPTY) as $addresses) { $objMail->ClearAddresses(); foreach (preg_split('/\\s*[,]\\s*/', $addresses, null, PREG_SPLIT_NO_EMPTY) as $address) { $objMail->AddAddress($address); } //DBG::log("MailTemplate::send(): ".var_export($objMail, true)); // TODO: Comment for test only! $result &= $objMail->Send(); // TODO: $objMail->Send() seems to sometimes return true on localhost where // sending the mail is actually impossible. Dunno why. } return $result; }
public function getPage($pos, $page_content) { global $_CONFIG, $_ARRAYLANG; $objTpl = new \Cx\Core\Html\Sigma('.'); \Cx\Core\Csrf\Controller\Csrf::add_placeholder($objTpl); $objTpl->setErrorHandling(PEAR_ERROR_DIE); $objTpl->setTemplate($page_content); $objTpl->setGlobalVariable($_ARRAYLANG); // Load main template even if we have a cmd set if ($objTpl->placeholderExists('APPLICATION_DATA')) { $page = new \Cx\Core\ContentManager\Model\Entity\Page(); $page->setVirtual(true); $page->setType(\Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION); $page->setModule('Search'); // load source code $applicationTemplate = \Cx\Core\Core\Controller\Cx::getContentTemplateOfPage($page); \LinkGenerator::parseTemplate($applicationTemplate); $objTpl->addBlock('APPLICATION_DATA', 'application_data', $applicationTemplate); } $term = isset($_REQUEST['term']) ? trim(contrexx_input2raw($_REQUEST['term'])) : ''; if (strlen($term) >= 3) { $term = trim(contrexx_input2raw($_REQUEST['term'])); $this->setTerm($term); $eventHandlerInstance = \Env::get('cx')->getEvents(); $eventHandlerInstance->triggerEvent('SearchFindContent', array($this)); if ($this->result->size() == 1) { $arraySearchResults[] = $this->result->toArray(); } else { $arraySearchResults = $this->result->toArray(); } usort($arraySearchResults, function ($a, $b) { if ($a['Score'] == $b['Score']) { if (isset($a['Date'])) { if ($a['Date'] == $b['Date']) { return 0; } if ($a['Date'] > $b['Date']) { return -1; } return 1; } return 0; } if ($a['Score'] > $b['Score']) { return -1; } return 1; }); $countResults = sizeof($arraySearchResults); if (!is_numeric($pos)) { $pos = 0; } $paging = getPaging($countResults, $pos, '&section=Search&term=' . contrexx_raw2encodedUrl($term), '<b>' . $_ARRAYLANG['TXT_SEARCH_RESULTS'] . '</b>', true); $objTpl->setVariable('SEARCH_PAGING', $paging); $objTpl->setVariable('SEARCH_TERM', contrexx_raw2xhtml($term)); if ($countResults > 0) { $searchComment = sprintf($_ARRAYLANG['TXT_SEARCH_RESULTS_ORDER_BY_RELEVANCE'], contrexx_raw2xhtml($term), $countResults); $objTpl->setVariable('SEARCH_TITLE', $searchComment); $arraySearchOut = array_slice($arraySearchResults, $pos, $_CONFIG['corePagingLimit']); foreach ($arraySearchOut as $details) { // append search term to result link $link = $details['Link']; if (strpos($link, '?') === false) { $link .= '?'; } else { $link .= '&'; } $link .= 'searchTerm=' . urlencode($term); // parse result into template $objTpl->setVariable(array('COUNT_MATCH' => $_ARRAYLANG['TXT_RELEVANCE'] . ' ' . $details['Score'] . '%', 'LINK' => '<b><a href="' . $link . '" title="' . contrexx_raw2xhtml($details['Title']) . '">' . contrexx_raw2xhtml($details['Title']) . '</a></b>', 'SHORT_CONTENT' => contrexx_raw2xhtml($details['Content']))); $objTpl->parse('search_result'); } return $objTpl->get(); } } $noresult = $term != '' ? sprintf($_ARRAYLANG['TXT_NO_SEARCH_RESULTS'], $term) : $_ARRAYLANG['TXT_PLEASE_ENTER_SEARCHTERM']; $objTpl->setVariable('SEARCH_TITLE', $noresult); return $objTpl->get(); }
/** * Get page * * Get the livecam page * * @access public * @return string */ function getPage() { $this->_objTpl->setTemplate($this->pageContent); // load source code if cmd value is integer if ($this->_objTpl->placeholderExists('APPLICATION_DATA')) { $page = new \Cx\Core\ContentManager\Model\Entity\Page(); $page->setVirtual(true); $page->setType(\Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION); $page->setModule('Livecam'); // load source code $applicationTemplate = \Cx\Core\Core\Controller\Cx::getContentTemplateOfPage($page); \LinkGenerator::parseTemplate($applicationTemplate); $this->_objTpl->addBlock('APPLICATION_DATA', 'application_data', $applicationTemplate); } $this->_objTpl->setVariable(array("CMD" => $this->cam)); $this->_objTpl->setGlobalVariable('LIVECAM_DATE', $this->date); switch ($this->_action) { case 'today': $this->_objTpl->hideBlock('livecamPicture'); $this->_showArchive($this->date); break; case 'archive': $this->_objTpl->hideBlock('livecamPicture'); $this->_showArchive($this->date); break; default: $this->_objTpl->hideBlock('livecamArchive'); $this->_showPicture(); break; } if (isset($this->statusMessage)) { $this->_objTpl->setVariable('LIVECAM_STATUS_MESSAGE', $this->statusMessage); } return $this->_objTpl->get(); }
/** * Checks if the user has been successfully authenticated * * If a user has been successfully authenticated then he will be * redirected to the requested page, otherwise the login page will be displayed * * @access private * @global array * @see cmsSession::cmsSessionStatusUpdate(), contrexx_strip_tags, \Cx\Core\Html\Sigma::get() * @return string \Cx\Core\Html\Sigma::get() */ function _login() { global $_CORELANG, $sessionObj; $objFWUser = \FWUser::getFWUserObject(); if (isset($_REQUEST['redirect'])) { $redirect = contrexx_strip_tags($_REQUEST['redirect']); } elseif (isset($_SESSION['redirect'])) { $redirect = $_SESSION['redirect']; } else { $redirect = ""; } \Cx\Lib\SocialLogin::parseSociallogin($this->_objTpl); $arrSettings = \User_Setting::getSettings(); if (function_exists('curl_init') && $arrSettings['sociallogin']['status'] && !empty($_GET['provider'])) { $providerLogin = $this->loginWithProvider($_GET['provider']); if ($providerLogin) { return $providerLogin; } } if ($objFWUser->objUser->login()) { if (isset($_POST['login']) && $objFWUser->checkLogin() || isset($_GET['auth-token']) && isset($_GET['user-id'])) { $objFWUser->objUser->reset(); $objFWUser->logoutAndDestroySession(); $sessionObj = \cmsSession::getInstance(); } elseif (isset($_POST['login'])) { $_GET['relogin'] = '******'; } } if ((!isset($_GET['relogin']) || $_GET['relogin'] != 'true') && $objFWUser->objUser->login() || $objFWUser->checkAuth()) { $groupRedirect = ($objGroup = $objFWUser->objGroup->getGroup($objFWUser->objUser->getPrimaryGroupId())) && $objGroup->getHomepage() ? preg_replace('/\\[\\[([A-Z0-9_-]+)\\]\\]/', '{\\1}', $objGroup->getHomepage()) : CONTREXX_SCRIPT_PATH; \LinkGenerator::parseTemplate($groupRedirect); if (isset($_SESSION['redirect'])) { unset($_SESSION['redirect']); } if (!empty($redirect)) { $redirect = \FWUser::getRedirectUrl(urlencode(base64_decode($redirect))); } \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . (empty($redirect) ? $groupRedirect : $redirect)); exit; } else { if (isset($_POST['login'])) { $this->_statusMessage = $_CORELANG['TXT_PASSWORD_OR_USERNAME_IS_INCORRECT']; } } if (isset($_SESSION['auth']['loginLastAuthFailed'])) { $this->_objTpl->setVariable(array('TXT_CORE_CAPTCHA' => $_CORELANG['TXT_CORE_CAPTCHA'], 'CAPTCHA_CODE' => \Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->getCode())); $this->_objTpl->parse('captcha'); } else { $this->_objTpl->hideBlock('captcha'); } // TODO: loading the language data of component Access at this // point is a workaround as the integration of the Access // component's functionality itself is hard-coded too and // has not been implemented through the system component // framework. $accessLang = \Env::get('init')->getComponentSpecificLanguageData('Access'); $this->_objTpl->setVariable(array('TXT_ACCESS_SIGNUP_BY_FACEBOOK' => $accessLang['TXT_ACCESS_SIGNUP_BY_FACEBOOK'], 'TXT_ACCESS_SIGNUP_BY_GOOGLE' => $accessLang['TXT_ACCESS_SIGNUP_BY_GOOGLE'], 'TXT_ACCESS_SIGNUP_BY_TWITTER' => $accessLang['TXT_ACCESS_SIGNUP_BY_TWITTER'], 'TXT_CORE_SIGN_UP' => $_CORELANG['TXT_CORE_SIGN_UP'], 'TXT_LOGIN' => $_CORELANG['TXT_LOGIN'], 'TXT_USER_NAME' => $_CORELANG['TXT_USER_NAME'], 'TXT_EMAIL' => $_CORELANG['TXT_EMAIL'], 'TXT_PASSWORD' => $_CORELANG['TXT_PASSWORD'], 'TXT_LOGIN_REMEMBER_ME' => $_CORELANG['TXT_CORE_REMEMBER_ME'], 'TXT_PASSWORD_LOST' => $_CORELANG['TXT_PASSWORD_LOST'], 'LOGIN_REDIRECT' => $redirect, 'LOGIN_STATUS_MESSAGE' => $this->_statusMessage)); return $this->_objTpl->get(); }
/** * Parses the main template in order to finish request * @todo Remove usage of globals * @global type $themesPages * @global null $moduleStyleFile * @global array $_CONFIG * @global type $subMenuTitle * @global type $_CORELANG * @global type $plainCmd * @global type $cmd */ protected function finalize() { global $themesPages, $moduleStyleFile, $_CONFIG, $subMenuTitle, $_CORELANG, $plainCmd, $cmd; if ($this->mode == self::MODE_FRONTEND) { // parse system $parsingTime = $this->stopTimer(); $this->template->setVariable('PARSING_TIME', $parsingTime); $this->parseGlobalPlaceholders($themesPages['sidebar']); $this->template->setVariable(array('SIDEBAR_FILE' => $themesPages['sidebar'], 'JAVASCRIPT_FILE' => $themesPages['javascript'], 'BUILDIN_STYLE_FILE' => $themesPages['buildin_style'], 'DATE_YEAR' => date('Y'), 'DATE_MONTH' => date('m'), 'DATE_DAY' => date('d'), 'DATE_TIME' => date('H:i'), 'BUILDIN_STYLE_FILE' => $themesPages['buildin_style'], 'JAVASCRIPT_LIGHTBOX' => '<script type="text/javascript" src="lib/lightbox/javascript/mootools.js"></script> <script type="text/javascript" src="lib/lightbox/javascript/slimbox.js"></script>', 'JAVASCRIPT_MOBILE_DETECTOR' => '<script type="text/javascript" src="lib/mobiledetector.js"></script>')); if (!empty($moduleStyleFile)) { $this->template->setVariable('STYLE_FILE', "<link rel=\"stylesheet\" href=\"{$moduleStyleFile}\" type=\"text/css\" media=\"screen, projection\" />"); } if (!$this->resolvedPage->getUseSkinForAllChannels() && isset($_GET['pdfview']) && intval($_GET['pdfview']) == 1) { $pageTitle = $this->resolvedPage->getTitle(); $extenstion = empty($pageTitle) ? null : '.pdf'; $objPDF = new \Cx\Core_Modules\Pdf\Model\Entity\PdfDocument(); $objPDF->SetTitle($pageTitle . $extenstion); $objPDF->setContent($this->template->get()); $objPDF->Create(); exit; } // fetch the parsed webpage $this->template->setVariable('JAVASCRIPT', 'javascript_inserting_here'); $endcode = $this->template->get(); /** * Get all javascripts in the code, replace them with nothing, and register the js file * to the javascript lib. This is because we don't want something twice, and there could be * a theme that requires a javascript, which then could be used by a module too and therefore would * be loaded twice. */ /* Finds all uncommented script tags, strips them out of the HTML and * stores them internally so we can put them in the placeholder later * (see JS::getCode() below) */ \JS::findJavascripts($endcode); /* * Proposal: Use this * $endcode = preg_replace_callback('/<script\s.*?src=(["\'])(.*?)(\1).*?\/?>(?:<\/script>)?/i', array('JS', 'registerFromRegex'), $endcode); * and change JS::registerFromRegex to use index 2 */ // i know this is ugly, but is there another way $endcode = str_replace('javascript_inserting_here', \JS::getCode(), $endcode); // do a final replacement of all those node-urls ({NODE_<ID>_<LANG>}- placeholders) that haven't been captured earlier $endcode = preg_replace('/\\[\\[([A-Z0-9_-]+)\\]\\]/', '{\\1}', $endcode); \LinkGenerator::parseTemplate($endcode); // remove the meta tag X-UA-Compatible if the user agent ist neighter internet explorer nor chromeframe if (!preg_match('/(msie|chromeframe)/i', $_SERVER['HTTP_USER_AGENT'])) { $endcode = preg_replace('/<meta.*?X-UA-Compatible.*?>/i', '', $endcode); } // replace links from before contrexx 3 $ls = new \LinkSanitizer($this, $this->getCodeBaseOffsetPath() . \Env::get('virtualLanguageDirectory') . '/', $endcode); $this->endcode = $ls->replace(); } else { // backend meta navigation if ($this->template->blockExists('backend_metanavigation')) { // parse language navigation if ($this->template->blockExists('backend_language_navigation') && $this->template->blockExists('backend_language_navigation_item')) { $backendLanguage = \FWLanguage::getActiveBackendLanguages(); if (count($backendLanguage) > 1) { $this->template->setVariable('TXT_LANGUAGE', $_CORELANG['TXT_LANGUAGE']); foreach ($backendLanguage as $language) { $languageUrl = \Env::get('init')->getUriBy('setLang', $language['id']); $this->template->setVariable(array('LANGUAGE_URL' => contrexx_raw2xhtml($languageUrl), 'LANGUAGE_NAME' => $language['name'], 'LANGUAGE_CSS' => \Env::get('init')->getBackendLangId() == $language['id'] ? 'active' : '')); $this->template->parse('backend_language_navigation_item'); } $this->template->parse('backend_language_navigation'); } else { $this->template->hideBlock('backend_language_navigation'); } } $this->template->touchBlock('backend_metanavigation'); } // page parsing $parsingTime = $this->stopTimer(); // var_dump($parsingTime); /*echo ($finishTime[0] - $startTime[0]) . '<br />'; if (!isset($_SESSION['asdf1']) || isset($_GET['reset'])) { $_SESSION['asdf1'] = 0; $_SESSION['asdf2'] = 0; } echo $_SESSION['asdf1'] . '<br />'; if ($_SESSION['asdf1'] > 0) { echo $_SESSION['asdf2'] / $_SESSION['asdf1']; } $_SESSION['asdf1']++; $_SESSION['asdf2'] += ($finishTime[0] - $startTime[0]);//*/ $objAdminNav = new \adminMenu($plainCmd); $objAdminNav->getAdminNavbar(); $this->template->setVariable(array('SUB_MENU_TITLE' => $subMenuTitle, 'FRONTEND_LANG_MENU' => \Env::get('init')->getUserFrontendLangMenu(), 'TXT_GENERATED_IN' => $_CORELANG['TXT_GENERATED_IN'], 'TXT_SECONDS' => $_CORELANG['TXT_SECONDS'], 'TXT_LOGOUT_WARNING' => $_CORELANG['TXT_LOGOUT_WARNING'], 'PARSING_TIME' => $parsingTime, 'LOGGED_NAME' => htmlentities($this->getUser()->objUser->getProfileAttribute('firstname') . ' ' . $this->getUser()->objUser->getProfileAttribute('lastname'), ENT_QUOTES, CONTREXX_CHARSET), 'TXT_LOGGED_IN_AS' => $_CORELANG['TXT_LOGGED_IN_AS'], 'TXT_LOG_OUT' => $_CORELANG['TXT_LOG_OUT'], 'MODULE_INDEX' => MODULE_INDEX, 'JAVASCRIPT' => \JS::getCode(), 'CX_EDITION' => $_CONFIG['coreCmsEdition'], 'CX_VERSION' => $_CONFIG['coreCmsVersion'], 'CX_CODE_NAME' => $_CONFIG['coreCmsCodeName'], 'CX_STATUS' => $_CONFIG['coreCmsStatus'], 'CX_RELEASE_DATE' => date(ASCMS_DATE_FORMAT_DATE, $_CONFIG['coreCmsReleaseDate']), 'CX_NAME' => $_CONFIG['coreCmsName'])); // Style parsing if (file_exists($this->codeBaseAdminTemplatePath . '/css/' . $cmd . '.css')) { // check if there's a css file in the core section $this->template->setVariable('ADD_STYLE_URL', $this->codeBaseAdminTemplateWebPath . '/css/' . $cmd . '.css'); $this->template->parse('additional_style'); } elseif (file_exists($this->codeBaseModulePath . '/' . $cmd . '/template/backend.css')) { // of maybe in the current module directory $this->template->setVariable('ADD_STYLE_URL', $this->codeBaseModuleWebPath . '/' . $cmd . '/template/backend.css'); $this->template->parse('additional_style'); } elseif (file_exists($this->codeBaseCoreModulePath . '/' . $cmd . '/template/backend.css')) { // or in the core module directory $this->template->setVariable('ADD_STYLE_URL', $this->codeBaseCoreModuleWebPath . '/' . $cmd . '/template/backend.css'); $this->template->parse('additional_style'); } else { $this->template->hideBlock('additional_style'); } /*echo '<pre>'; print_r($_SESSION); /*echo '<b>Overall time: ' . (microtime(true) - $timeAtStart) . 's<br />'; echo 'Max RAM usage: ' . formatBytes(memory_get_peak_usage()) . '<br />'; echo 'End RAM usage: ' . formatBytes(memory_get_usage()) . '<br /></b>';*/ $endcode = $this->template->get(); // replace links from before contrexx 3 $ls = new \LinkSanitizer($this, $this->getCodeBaseOffsetPath() . $this->getBackendFolderName() . '/', $endcode); $this->endcode = $ls->replace(); } \DBG::log("(Cx: {$this->id}) Request parsing completed after {$parsingTime}"); }
/** * Returns the page path of the given target (node placeholder). * If the target page doesn't exist, the path of the error page will be returned. * * @param array $arguments * @return string $path */ public function getPathByTarget($arguments) { global $_CONFIG; $target = contrexx_input2raw($arguments['get']['target']); if (!\FWValidator::hasProto($target)) { $page = new \Cx\Core\ContentManager\Model\Entity\Page(); $page->setTarget($target); if ($page->isTargetInternal()) { $target = str_replace(array('[[', ']]'), array('{', '}'), $target); \LinkGenerator::parseTemplate($target); } elseif (ASCMS_PATH_OFFSET == '' || strpos($target, ASCMS_PATH_OFFSET) === false) { if (!isset($target[0]) || $target[0] !== '/') { $target = '/' . $target; } $target = ASCMS_PATH_OFFSET . $target; } $target = ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . $target; } return $target; }
function showEntry() { global $_ARRAYLANG, $_CORELANG; $this->_objTpl->setTemplate($this->pageContent, true, true); //get ids $intCategoryId = isset($_GET['cid']) ? intval($_GET['cid']) : 0; $intLevelId = isset($_GET['lid']) ? intval($_GET['lid']) : 0; $intEntryId = isset($_GET['eid']) ? intval($_GET['eid']) : 0; // load source code if cmd value is integer if ($this->_objTpl->placeholderExists('APPLICATION_DATA')) { $page = new \Cx\Core\ContentManager\Model\Entity\Page(); $page->setVirtual(true); $page->setType(\Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION); $page->setModule('MediaDir'); $page->setCmd('detail'); // load source code $applicationTemplate = \Cx\Core\Core\Controller\Cx::getContentTemplateOfPage($page); \LinkGenerator::parseTemplate($applicationTemplate); $this->_objTpl->addBlock('APPLICATION_DATA', 'application_data', $applicationTemplate); } //get navtree if ($this->_objTpl->blockExists($this->moduleNameLC . 'Navtree') && ($intCategoryId != 0 || $intLevelId != 0)) { $this->getNavtree($intCategoryId, $intLevelId); } if ($intEntryId != 0 && $this->_objTpl->blockExists($this->moduleNameLC . 'EntryList')) { $objEntry = new MediaDirectoryEntry($this->moduleName); $objEntry->getEntries($intEntryId, $intLevelId, $intCategoryId, null, null, null, 1, null, 1); $objEntry->listEntries($this->_objTpl, 2); $objEntry->updateHits($intEntryId); //set meta attributes $entries = new MediaDirectoryEntry($this->moduleName); $entries->getEntries($intEntryId, $intLevelId, $intCategoryId, null, null, null, 1, null, 1); $entry = $entries->arrEntries[$intEntryId]; $objInputfields = new MediaDirectoryInputfield($entry['entryFormId'], false, $entry['entryTranslationStatus'], $this->moduleName); $inputFields = $objInputfields->getInputfields(); $titleChanged = false; $contentChanged = false; foreach ($inputFields as $arrInputfield) { $contextType = isset($arrInputfield['context_type']) ? $arrInputfield['context_type'] : ''; if (!in_array($contextType, array('title', 'content', 'image'))) { continue; } $strType = isset($arrInputfield['type_name']) ? $arrInputfield['type_name'] : ''; $strInputfieldClass = "\\Cx\\Modules\\MediaDir\\Model\\Entity\\MediaDirectoryInputfield" . ucfirst($strType); try { $objInputfield = safeNew($strInputfieldClass, $this->moduleName); $arrTranslationStatus = contrexx_input2int($arrInputfield['type_multi_lang']) == 1 ? $entry['entryTranslationStatus'] : null; $arrInputfieldContent = $objInputfield->getContent($entry['entryId'], $arrInputfield, $arrTranslationStatus); switch ($contextType) { case 'title': $inputfieldValue = $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE']; if ($inputfieldValue) { $this->metaTitle .= ' - ' . $inputfieldValue; $this->pageTitle = $inputfieldValue; } $titleChanged = true; break; case 'content': $inputfieldValue = $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE']; if ($inputfieldValue) { $this->metaDescription = $inputfieldValue; } $contentChanged = true; break; case 'image': $inputfieldValue = $arrInputfieldContent[$this->moduleLangVar . '_INPUTFIELD_VALUE_SRC']; if ($inputfieldValue) { $this->metaImage = $inputfieldValue; } break; default: break; } } catch (\Exception $e) { \DBG::log($e->getMessage()); continue; } } $firstInputfieldValue = $entries->arrEntries[$intEntryId]['entryFields'][0]; if (!$titleChanged && $firstInputfieldValue) { $this->pageTitle = $firstInputfieldValue; $this->metaTitle = $firstInputfieldValue; } if (!$contentChanged && $firstInputfieldValue) { $this->metaDescription = $firstInputfieldValue; } if (empty($objEntry->arrEntries)) { $this->_objTpl->hideBlock($this->moduleNameLC . 'EntryList'); $this->_objTpl->clearVariables(); header("Location: index.php?section=" . $this->moduleName); exit; } } else { header("Location: index.php?section=" . $this->moduleName); exit; } }
/** * Checks if the user has been successfully authenticated * * If a user has been successfully authenticated then he will be * redirected to the requested page, otherwise the login page will be displayed * * @access private * @global array * @see cmsSession::cmsSessionStatusUpdate(), contrexx_strip_tags, \Cx\Core\Html\Sigma::get() * @return string \Cx\Core\Html\Sigma::get() */ function _login() { global $_CORELANG, $sessionObj; $objFWUser = \FWUser::getFWUserObject(); if (isset($_REQUEST['redirect'])) { $redirect = contrexx_strip_tags($_REQUEST['redirect']); } elseif (isset($_SESSION['redirect'])) { $redirect = $_SESSION['redirect']; } else { $redirect = ""; } \Cx\Lib\SocialLogin::parseSociallogin($this->_objTpl); $arrSettings = \User_Setting::getSettings(); if (function_exists('curl_init') && $arrSettings['sociallogin']['status'] && !empty($_GET['provider'])) { $providerLogin = $this->loginWithProvider($_GET['provider']); if ($providerLogin) { return $providerLogin; } } if ($objFWUser->objUser->login()) { if (isset($_POST['login']) && $objFWUser->checkLogin() || isset($_GET['auth-token']) && isset($_GET['user-id'])) { $objFWUser->objUser->reset(); $objFWUser->logoutAndDestroySession(); $sessionObj = \cmsSession::getInstance(); } else { $_GET['relogin'] = '******'; } } if ((!isset($_GET['relogin']) || $_GET['relogin'] != 'true') && $objFWUser->objUser->login() || $objFWUser->checkAuth()) { $groupRedirect = ($objGroup = $objFWUser->objGroup->getGroup($objFWUser->objUser->getPrimaryGroupId())) && $objGroup->getHomepage() ? preg_replace('/\\[\\[([A-Z0-9_-]+)\\]\\]/', '{\\1}', $objGroup->getHomepage()) : CONTREXX_SCRIPT_PATH; \LinkGenerator::parseTemplate($groupRedirect); if (isset($_SESSION['redirect'])) { unset($_SESSION['redirect']); } if (!empty($redirect)) { $redirect = \FWUser::getRedirectUrl(urlencode(base64_decode($redirect))); } \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . (empty($redirect) ? $groupRedirect : $redirect)); exit; } else { if (isset($_POST['login'])) { $this->_statusMessage = $_CORELANG['TXT_PASSWORD_OR_USERNAME_IS_INCORRECT']; } } if (isset($_SESSION['auth']['loginLastAuthFailed'])) { $this->_objTpl->setVariable(array('TXT_CORE_CAPTCHA' => $_CORELANG['TXT_CORE_CAPTCHA'], 'CAPTCHA_CODE' => \Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->getCode())); $this->_objTpl->parse('captcha'); } else { $this->_objTpl->hideBlock('captcha'); } $this->_objTpl->setVariable(array('TXT_LOGIN' => $_CORELANG['TXT_LOGIN'], 'TXT_USER_NAME' => $_CORELANG['TXT_USER_NAME'], 'TXT_PASSWORD' => $_CORELANG['TXT_PASSWORD'], 'TXT_LOGIN_REMEMBER_ME' => $_CORELANG['TXT_CORE_REMEMBER_ME'], 'TXT_PASSWORD_LOST' => $_CORELANG['TXT_PASSWORD_LOST'], 'LOGIN_REDIRECT' => $redirect, 'LOGIN_STATUS_MESSAGE' => $this->_statusMessage)); return $this->_objTpl->get(); }
/** * Gets the list with the headlines * * @global array * @global ADONewConnection * @global array * @return string parsed content */ private function getHeadlines() { global $_CONFIG, $objDatabase, $_ARRAYLANG, $_LANGID; // load source code if cmd value is integer if ($this->_objTpl->placeholderExists('APPLICATION_DATA')) { $page = new \Cx\Core\ContentManager\Model\Entity\Page(); $page->setVirtual(true); $page->setType(\Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION); $page->setModule('News'); // load source code $applicationTemplate = \Cx\Core\Core\Controller\Cx::getContentTemplateOfPage($page); \LinkGenerator::parseTemplate($applicationTemplate); $this->_objTpl->addBlock('APPLICATION_DATA', 'application_data', $applicationTemplate); } $validToShowList = true; $newsCategories = array(); $menuCategories = array(); $parameters = array(); $selectedCat = ''; $selectedType = ''; $selectedPublisher = ''; $selectedAuthor = ''; $newsfilter = ''; $paging = ''; $pos = 0; $i = 0; if (isset($_GET['pos'])) { $pos = intval($_GET['pos']); } $catFromCmd = !empty($_REQUEST['cmd']) ? explode(',', $_REQUEST['cmd']) : array(); $catFromReq = !empty($_REQUEST['category']) ? explode(',', $_REQUEST['category']) : array(); if (!empty($catFromCmd)) { $menuCategories = $this->getCatIdsFromNestedSetArray($this->getNestedSetCategories($catFromCmd)); if ($this->_objTpl->placeholderExists('NEWS_CMD')) { $this->_objTpl->setVariable('NEWS_CMD', $_REQUEST['cmd']); } } $newsCategories = $categories = !empty($catFromReq) ? $catFromReq : (!empty($catFromCmd) ? $catFromCmd : array()); if (count($newsCategories) == 1 && $this->categoryExists($newsCategories[0])) { $selectedCat = intval($newsCategories[0]); } if (empty($newsCategories)) { $newsCategories[] = $this->nestedSetRootId; } $newsCategories = $this->getCatIdsFromNestedSetArray($this->getNestedSetCategories($newsCategories)); if (!empty($newsCategories)) { $newsfilter .= ' AND (`nc`.`category_id` IN (' . implode(',', $newsCategories) . '))'; } if ($this->_objTpl->placeholderExists('NEWS_CAT_DROPDOWNMENU')) { $catMenu = '<select onchange="this.form.submit()" name="category">' . "\n"; $catMenu .= '<option value="">' . $_ARRAYLANG['TXT_CATEGORY'] . '</option>' . "\n"; $catMenu .= $this->getCategoryMenu(!empty($menuCategories) ? $menuCategories : array(), array($selectedCat)) . "\n"; $catMenu .= '</select>' . "\n"; $this->_objTpl->setVariable('NEWS_CAT_DROPDOWNMENU', $catMenu); } //Filter by types if ($this->arrSettings['news_use_types'] == 1) { if (!empty($_REQUEST['type'])) { $arrTypes = explode(',', $_REQUEST['type']); if (!empty($arrTypes)) { $newsfilter .= ' AND (`n`.`typeid` IN (' . implode(', ', contrexx_input2int($arrTypes)) . '))'; } $selectedType = current($arrTypes); } if ($this->_objTpl->placeholderExists('NEWS_TYPE_DROPDOWNMENU')) { $typeMenu = '<select onchange="this.form.submit()" name="type">' . "\n"; $typeMenu .= '<option value="" selected="selected">' . $_ARRAYLANG['TXT_TYPE'] . '</option>' . "\n"; $typeMenu .= $this->getTypeMenu($selectedType) . "\n"; $typeMenu .= '</select>' . "\n"; $this->_objTpl->setVariable('NEWS_TYPE_DROPDOWNMENU', $typeMenu); } } //Filter by publisher if (!empty($_REQUEST['publisher'])) { $parameters['filterPublisher'] = $publisher = contrexx_input2raw($_REQUEST['publisher']); $arrPublishers = explode(',', $publisher); if (!empty($arrPublishers)) { $newsfilter .= ' AND (`n`.`publisher_id` IN (' . implode(', ', contrexx_input2int($arrPublishers)) . '))'; } $selectedPublisher = current($arrPublishers); } if ($this->_objTpl->placeholderExists('NEWS_PUBLISHER_DROPDOWNMENU')) { $publisherMenu = '<select onchange="window.location=\'' . \Cx\Core\Routing\Url::fromModuleAndCmd('News', intval($_REQUEST['cmd'])) . '&publisher=\'+this.value" name="publisher">' . "\n"; $publisherMenu .= '<option value="" selected="selected">' . $_ARRAYLANG['TXT_NEWS_PUBLISHER'] . '</option>' . "\n"; $publisherMenu .= $this->getPublisherMenu($selectedPublisher, $selectedCat) . "\n"; $publisherMenu .= '</select>' . "\n"; $this->_objTpl->setVariable('NEWS_PUBLISHER_DROPDOWNMENU', $publisherMenu); } //Filter by Author if (!empty($_REQUEST['author'])) { $parameters['filterAuthor'] = $author = contrexx_input2raw($_REQUEST['author']); $arrAuthors = explode(',', $author); if (!empty($arrAuthors)) { $newsfilter .= ' AND (`n`.`author_id` IN (' . implode(', ', contrexx_input2int($arrAuthors)) . '))'; } $selectedAuthor = current($arrAuthors); } if ($this->_objTpl->placeholderExists('NEWS_AUTHOR_DROPDOWNMENU')) { $authorMenu = '<select onchange="this.form.submit()" name="author">' . "\n"; $authorMenu .= '<option value="" selected="selected">' . $_ARRAYLANG['TXT_NEWS_AUTHOR'] . '</option>' . "\n"; $authorMenu .= $this->getAuthorMenu($selectedAuthor) . "\n"; $authorMenu .= '</select>' . "\n"; $this->_objTpl->setVariable('NEWS_AUTHOR_DROPDOWNMENU', $authorMenu); } //Filter by tag if (!empty($_REQUEST['tag'])) { $parameters['filterTag'] = $searchTag = contrexx_input2raw($_REQUEST['tag']); $searchedTag = $this->getNewsTags(null, $searchTag); $searchedTagId = current(array_keys($searchedTag['tagList'])); if (!empty($searchedTag['newsIds'])) { $this->incrementViewingCount($searchedTagId); $newsfilter .= ' AND n.`id` IN (' . implode(',', $searchedTag['newsIds']) . ')'; $this->_objTpl->setVariable(array('NEWS_FILTER_TAG_ID' => $searchedTagId, 'NEWS_FILTER_TAG_NAME' => ucfirst(current($searchedTag['tagList'])))); if ($this->_objTpl->blockExists('tagFilterCont')) { $this->_objTpl->parse('tagFilterCont'); } } else { $validToShowList = false; } } $this->_objTpl->setVariable(array('TXT_PERFORM' => $_ARRAYLANG['TXT_PERFORM'], 'TXT_CATEGORY' => $_ARRAYLANG['TXT_CATEGORY'], 'TXT_TYPE' => $this->arrSettings['news_use_types'] == 1 ? $_ARRAYLANG['TXT_TYPE'] : '', 'TXT_DATE' => $_ARRAYLANG['TXT_DATE'], 'TXT_TITLE' => $_ARRAYLANG['TXT_TITLE'], 'TXT_NEWS_MESSAGE' => $_ARRAYLANG['TXT_NEWS_MESSAGE'])); $query = ' SELECT n.id AS newsid, n.userid AS newsuid, n.date AS newsdate, n.teaser_image_path, n.teaser_image_thumbnail_path, n.redirect, n.publisher, n.publisher_id, n.author, n.author_id, n.allow_comments AS commentactive, n.enable_tags, nl.title AS newstitle, nl.text NOT REGEXP \'^(<br type="_moz" />)?$\' AS newscontent, nl.teaser_text FROM ' . DBPREFIX . 'module_news AS n INNER JOIN ' . DBPREFIX . 'module_news_locale AS nl ON nl.news_id = n.id INNER JOIN ' . DBPREFIX . 'module_news_rel_categories AS nc ON nc.news_id = n.id WHERE status = 1 AND nl.is_active=1 AND nl.lang_id=' . FRONTEND_LANG_ID . ' AND (n.startdate<=\'' . date('Y-m-d H:i:s') . '\' OR n.startdate="0000-00-00 00:00:00") AND (n.enddate>=\'' . date('Y-m-d H:i:s') . '\' OR n.enddate="0000-00-00 00:00:00") ' . $newsfilter . ($this->arrSettings['news_message_protection'] == '1' && !\Permission::hasAllAccess() ? ($objFWUser = \FWUser::getFWUserObject()) && $objFWUser->objUser->login() ? " AND (frontend_access_id IN (" . implode(',', array_merge(array(0), $objFWUser->objUser->getDynamicPermissionIds())) . ") OR userid = " . $objFWUser->objUser->getId() . ") " : " AND frontend_access_id=0 " : '') . ' GROUP BY newsid ' . ' ORDER BY newsdate DESC'; /***start paging ****/ $objResult = $objDatabase->Execute($query); $count = $objResult->RecordCount(); $category = ''; if (!empty($_REQUEST['cmd'])) { $parameters['filterCategory'] = contrexx_input2raw($_REQUEST['cmd']); $category .= '&cmd=' . $_REQUEST['cmd']; } if (!empty($_REQUEST['category'])) { $parameters['filterCategory'] = contrexx_input2raw($_REQUEST['category']); $category .= '&category=' . $_REQUEST['category']; } $type = ''; if (!empty($_REQUEST['type'])) { $parameters['filterType'] = contrexx_input2raw($_REQUEST['type']); $type = '&type=' . $selectedType; } if ($count > intval($_CONFIG['corePagingLimit'])) { $paging = getPaging($count, $pos, '§ion=News' . $category . $type, $_ARRAYLANG['TXT_NEWS_MESSAGES'], true); } $this->_objTpl->setVariable('NEWS_PAGING', $paging); $objResult = $objDatabase->SelectLimit($query, $_CONFIG['corePagingLimit'], $pos); /*** end paging ***/ if ($count >= 1 && $validToShowList) { while (!$objResult->EOF) { $newsid = $objResult->fields['newsid']; $newstitle = $objResult->fields['newstitle']; $newsCommentActive = $objResult->fields['commentactive']; $arrNewsCategories = $this->getCategoriesByNewsId($newsid); $parameters['newsid'] = $newsid; $newsUrl = empty($objResult->fields['redirect']) ? empty($objResult->fields['newscontent']) ? '' : \Cx\Core\Routing\Url::fromModuleAndCmd('News', $this->findCmdById('details', self::sortCategoryIdByPriorityId(array_keys($arrNewsCategories), $categories)), FRONTEND_LANG_ID, $parameters) : $objResult->fields['redirect']; $htmlLink = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml('[' . $_ARRAYLANG['TXT_NEWS_MORE'] . '...]')); $htmlLinkTitle = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml($newstitle)); // in case that the message is a stub, we shall just display the news title instead of a html-a-tag with no href target if (empty($htmlLinkTitle)) { $htmlLinkTitle = contrexx_raw2xhtml($newstitle); } list($image, $htmlLinkImage, $imageSource) = self::parseImageThumbnail($objResult->fields['teaser_image_path'], $objResult->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl); $author = \FWUser::getParsedUserTitle($objResult->fields['author_id'], $objResult->fields['author']); $publisher = \FWUser::getParsedUserTitle($objResult->fields['publisher_id'], $objResult->fields['publisher']); $objSubResult = $objDatabase->Execute('SELECT count(`id`) AS `countComments` FROM `' . DBPREFIX . 'module_news_comments` WHERE `newsid` = ' . $objResult->fields['newsid']); if (empty($arrNewsCategories) && $this->_objTpl->blockExists('newsCategories')) { $this->_objTpl->hideBlock('newsCategories'); } $this->_objTpl->setVariable(array('NEWS_ID' => $newsid, 'NEWS_CSS' => 'row' . ($i % 2 + 1), 'NEWS_TEASER' => nl2br($objResult->fields['teaser_text']), 'NEWS_TITLE' => contrexx_raw2xhtml($newstitle), 'NEWS_LONG_DATE' => date(ASCMS_DATE_FORMAT, $objResult->fields['newsdate']), 'NEWS_DATE' => date(ASCMS_DATE_FORMAT_DATE, $objResult->fields['newsdate']), 'NEWS_TIME' => date(ASCMS_DATE_FORMAT_TIME, $objResult->fields['newsdate']), 'NEWS_LINK_TITLE' => $htmlLinkTitle, 'NEWS_LINK' => $htmlLink, 'NEWS_LINK_URL' => contrexx_raw2xhtml($newsUrl), 'NEWS_CATEGORY' => implode(', ', contrexx_raw2xhtml($arrNewsCategories)), 'NEWS_PUBLISHER' => contrexx_raw2xhtml($publisher), 'NEWS_AUTHOR' => contrexx_raw2xhtml($author), 'NEWS_COUNT_COMMENTS' => contrexx_raw2xhtml($objSubResult->fields['countComments'] . ' ' . $_ARRAYLANG['TXT_NEWS_COMMENTS']))); if (!$newsCommentActive || !$this->arrSettings['news_comments_activated']) { if ($this->_objTpl->blockExists('news_comments_count')) { $this->_objTpl->hideBlock('news_comments_count'); } } if (!empty($image)) { $this->_objTpl->setVariable(array('NEWS_IMAGE' => $image, 'NEWS_IMAGE_SRC' => contrexx_raw2xhtml($imageSource), 'NEWS_IMAGE_ALT' => contrexx_raw2xhtml($newstitle), 'NEWS_IMAGE_LINK' => $htmlLinkImage)); if ($this->_objTpl->blockExists('news_image')) { $this->_objTpl->parse('news_image'); } } else { if ($this->_objTpl->blockExists('news_image')) { $this->_objTpl->hideBlock('news_image'); } } self::parseImageBlock($this->_objTpl, $objResult->fields['teaser_image_thumbnail_path'], $newstitle, $newsUrl, 'image_thumbnail'); self::parseImageBlock($this->_objTpl, $objResult->fields['teaser_image_path'], $newstitle, $newsUrl, 'image_detail'); if (!empty($this->arrSettings['news_use_tags']) && !empty($objResult->fields['enable_tags'])) { $this->parseNewsTags($this->_objTpl, $newsid); } $this->_objTpl->parse('newsrow'); $i++; $objResult->MoveNext(); } if ($this->_objTpl->blockExists('news_list')) { $this->_objTpl->parse('news_list'); } if ($this->_objTpl->blockExists('news_menu')) { $this->_objTpl->parse('news_menu'); } if ($this->_objTpl->blockExists('news_status_message')) { $this->_objTpl->hideBlock('news_status_message'); } } else { $this->_objTpl->setVariable('TXT_NEWS_NO_NEWS_FOUND', $_ARRAYLANG['TXT_NEWS_NO_NEWS_FOUND']); if ($this->_objTpl->blockExists('news_status_message')) { $this->_objTpl->parse('news_status_message'); } if ($this->_objTpl->blockExists('news_menu')) { $this->_objTpl->parse('news_menu'); } if ($this->_objTpl->blockExists('news_list')) { $this->_objTpl->hideBlock('news_list'); } } return $this->_objTpl->get(); }
/** * Shows the Overview of categories * * @global ADONewConnection * @global array * @global array * @param var $intParentId */ function showCategoryOverview($intParentId = 0) { global $objDatabase, $_ARRAYLANG, $_CONFIG, $_CORELANG; $intParentId = intval($intParentId); $this->_objTpl->setTemplate($this->pageContent, true, true); // load source code if cmd value is integer if ($this->_objTpl->placeholderExists('APPLICATION_DATA')) { $page = new \Cx\Core\ContentManager\Model\Entity\Page(); $page->setVirtual(true); $page->setType(\Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION); $page->setModule('Gallery'); // load source code $applicationTemplate = \Cx\Core\Core\Controller\Cx::getContentTemplateOfPage($page); \LinkGenerator::parseTemplate($applicationTemplate); $this->_objTpl->addBlock('APPLICATION_DATA', 'application_data', $applicationTemplate); } $categoryProtected = $this->categoryIsProtected($intParentId); if ($categoryProtected > 0) { if (!\Permission::checkAccess($categoryProtected, 'dynamic', true)) { $link = base64_encode($_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']); \Cx\Core\Csrf\Controller\Csrf::header("Location: " . CONTREXX_DIRECTORY_INDEX . "?section=Login&cmd=noaccess&redirect=" . $link); exit; } } // hide image detail block // $this->_objTpl->hideBlock('galleryImage'); if ($this->arrSettings['header_type'] == 'hierarchy') { $this->_objTpl->setVariable(array('GALLERY_CATEGORY_TREE' => $this->getCategoryTree(), 'TXT_GALLERY_CATEGORY_HINT' => $_ARRAYLANG['TXT_GALLERY_CATEGORY_HINT_HIERARCHY'])); } else { $this->_objTpl->setVariable(array('GALLERY_CATEGORY_TREE' => $this->getSiblingList(), 'TXT_GALLERY_CATEGORY_HINT' => $_ARRAYLANG['TXT_GALLERY_CATEGORY_HINT_FLAT'])); } $objResult = $objDatabase->Execute("SELECT id, catid, path FROM " . DBPREFIX . "module_gallery_pictures " . "ORDER BY catimg ASC, sorting ASC, id ASC"); $showImageSizeOverview = $this->arrSettings['show_image_size'] == 'on'; while (!$objResult->EOF) { $arrImageSizes[$objResult->fields['catid']][$objResult->fields['id']] = $showImageSizeOverview ? round(filesize($this->strImagePath . $objResult->fields['path']) / 1024, 2) : ''; $arrstrImagePaths[$objResult->fields['catid']][$objResult->fields['id']] = $this->strThumbnailWebPath . $objResult->fields['path']; $objResult->MoveNext(); } if (isset($arrImageSizes) && isset($arrstrImagePaths)) { foreach ($arrImageSizes as $keyCat => $valueCat) { $arrCategorySizes[$keyCat] = 0; foreach ($valueCat as $valueImageSize) { $arrCategorySizes[$keyCat] = $arrCategorySizes[$keyCat] + $valueImageSize; } } foreach ($arrstrImagePaths as $keyCat => $valueCat) { $arrCategoryImages[$keyCat] = 0; $arrCategoryImageCounter[$keyCat] = 0; foreach ($valueCat as $valuestrImagePath) { $arrCategoryImages[$keyCat] = $valuestrImagePath; $arrCategoryImageCounter[$keyCat] = $arrCategoryImageCounter[$keyCat] + 1; } } } //$arrCategorySizes -> Sizes of all Categories //$arrCategoryImages -> The First Picture of each category //$arrCategoryImageCounter -> Counts all images in one group //begin category-paging $intPos = isset($_GET['pos']) ? intval($_GET['pos']) : 0; $objResult = $objDatabase->Execute('SELECT count(id) AS countValue FROM ' . DBPREFIX . 'module_gallery_categories WHERE pid=' . $intParentId . ' AND status="1" '); $this->_objTpl->setVariable(array('GALLERY_CATEGORY_PAGING' => getPaging($objResult->fields['countValue'], $intPos, '§ion=Gallery&cid=' . $intParentId . $this->strCmd, '<b>' . $_ARRAYLANG['TXT_GALLERY'] . '</b>', false, intval($_CONFIG['corePagingLimit'])))); //end category-paging $objResult = $objDatabase->SelectLimit('SELECT * FROM ' . DBPREFIX . 'module_gallery_categories WHERE pid=' . $intParentId . ' AND status="1" ORDER BY sorting ASC', intval($_CONFIG['corePagingLimit']), $intPos); if ($objResult->RecordCount() == 0) { // no categories in the database, hide the output //$this->_objTpl->hideBlock('galleryCategoryList'); } else { $i = 1; while (!$objResult->EOF) { $objSubResult = $objDatabase->Execute("SELECT name, value FROM " . DBPREFIX . "module_gallery_language " . "WHERE gallery_id=" . $objResult->fields['id'] . " AND " . "lang_id=" . intval($this->langId) . " ORDER BY name ASC"); unset($arrCategoryLang); while (!$objSubResult->EOF) { $arrCategoryLang[$objSubResult->fields['name']] = $objSubResult->fields['value']; $objSubResult->MoveNext(); } if (empty($arrCategoryImages[$objResult->fields['id']])) { // no pictures in this gallery, show the empty-image $strName = $arrCategoryLang['name']; $strDesc = $arrCategoryLang['desc']; $strImage = '<a href="' . CONTREXX_DIRECTORY_INDEX . '?section=Gallery&cid=' . $objResult->fields['id'] . $this->strCmd . '" target="_self">'; $strImage .= '<img border="0" alt="' . $arrCategoryLang['name'] . '" src="modules/Gallery/View/Media/no_images.gif" /></a>'; $strInfo = $_ARRAYLANG['TXT_IMAGE_COUNT'] . ': 0'; $strInfo .= $showImageSizeOverview ? '<br />' . $_CORELANG['TXT_SIZE'] . ': 0kB' : ''; } else { $strName = $arrCategoryLang['name']; $strDesc = $arrCategoryLang['desc']; $strImage = '<a href="' . CONTREXX_DIRECTORY_INDEX . '?section=Gallery&cid=' . $objResult->fields['id'] . $this->strCmd . '" target="_self">'; $strImage .= '<img border="0" alt="' . $arrCategoryLang['name'] . '" src="' . $arrCategoryImages[$objResult->fields['id']] . '" /></a>'; $strInfo = $_ARRAYLANG['TXT_IMAGE_COUNT'] . ': ' . $arrCategoryImageCounter[$objResult->fields['id']]; $strInfo .= $showImageSizeOverview ? '<br />' . $_CORELANG['TXT_SIZE'] . ': ' . $arrCategorySizes[$objResult->fields['id']] . 'kB' : ''; } $this->_objTpl->setVariable(array('GALLERY_STYLE' => $i % 2 + 1, 'GALLERY_CATEGORY_NAME' => $strName, 'GALLERY_CATEGORY_IMAGE' => $strImage, 'GALLERY_CATEGORY_INFO' => $strInfo, 'GALLERY_CATEGORY_DESCRIPTION' => nl2br($strDesc))); $this->_objTpl->parse('galleryCategoryList'); $i++; $objResult->MoveNext(); } } //images $this->_objTpl->setVariable(array('GALLERY_JAVASCRIPT' => $this->getJavascript())); $objResult = $objDatabase->Execute("SELECT value FROM " . DBPREFIX . "module_gallery_language " . "WHERE gallery_id={$intParentId} AND lang_id={$this->langId} AND name='desc'"); $strCategoryComment = nl2br($objResult->fields['value']); $objResult = $objDatabase->Execute("SELECT comment,voting FROM " . DBPREFIX . "module_gallery_categories " . "WHERE id=" . intval($intParentId)); $boolComment = $objResult->fields['comment']; $boolVoting = $objResult->fields['voting']; // paging $intPos = isset($_GET['pos']) ? intval($_GET['pos']) : 0; $objResult = $objDatabase->Execute("SELECT id, path, link, size_show FROM " . DBPREFIX . "module_gallery_pictures " . "WHERE status='1' AND validated='1' AND catid={$intParentId} " . "ORDER BY sorting"); $intCount = $objResult->RecordCount(); $this->_objTpl->setVariable(array('GALLERY_PAGING' => getPaging($intCount, $intPos, '§ion=Gallery&cid=' . $intParentId . $this->strCmd, '<b>' . $_ARRAYLANG['TXT_IMAGES'] . '</b>', false, intval($this->arrSettings["paging"])))); // end paging $objResult = $objDatabase->SelectLimit("SELECT id, path, link, size_show FROM " . DBPREFIX . "module_gallery_pictures " . "WHERE status='1' AND validated='1' AND catid={$intParentId} " . "ORDER BY sorting", intval($this->arrSettings["paging"]), $intPos); if ($objResult->RecordCount() == 0) { // No images in the category if (empty($strCategoryComment)) { $this->_objTpl->hideBlock('galleryImageBlock'); } else { $this->_objTpl->setVariable(array('GALLERY_CATEGORY_COMMENT' => $strCategoryComment)); } } else { $this->_objTpl->setVariable(array('GALLERY_CATEGORY_COMMENT' => $strCategoryComment)); $intFillLastRow = 1; while (!$objResult->EOF) { $imageVotingOutput = ''; $imageCommentOutput = ''; $objSubResult = $objDatabase->Execute("SELECT p.name, p.desc FROM " . DBPREFIX . "module_gallery_language_pics p " . "WHERE picture_id=" . $objResult->fields['id'] . " AND lang_id={$this->langId} LIMIT 1"); // Never used // $imageReso = getimagesize($this->strImagePath.$objResult->fields['path']); $strImagePath = $this->strImageWebPath . $objResult->fields['path']; $imageThumbPath = $this->strThumbnailWebPath . $objResult->fields['path']; $imageFileName = $this->arrSettings['show_file_name'] == 'on' ? $objResult->fields['path'] : ''; $imageName = $this->arrSettings['show_names'] == 'on' ? $objSubResult->fields['name'] : ''; $imageTitle = $this->arrSettings['show_names'] == 'on' ? $objSubResult->fields['name'] : ($this->arrSettings['show_file_name'] == 'on' ? $objResult->fields['path'] : ''); $imageLinkName = $objSubResult->fields['desc']; $imageLink = $objResult->fields['link']; $showImageSize = $this->arrSettings['show_image_size'] == 'on' && $objResult->fields['size_show']; $imageFileSize = $showImageSize ? round(filesize($this->strImagePath . $objResult->fields['path']) / 1024, 2) : ''; $imageLinkOutput = ''; $imageSizeOutput = ''; $imageTitleTag = ''; // chop the file extension if the settings tell us to do so if ($this->arrSettings['show_ext'] == 'off') { $imageFileName = substr($imageFileName, 0, strrpos($imageFileName, '.')); } if ($this->arrSettings['slide_show'] == 'slideshow') { $optionValue = "slideshowDelay:" . $this->arrSettings['slide_show_seconds']; } else { $optionValue = "counterType:'skip',continuous:true,animSequence:'sync'"; } //calculation starts here $numberOfChars = "60"; if ($imageLinkName != "") { if (strlen($imageLinkName) > $numberOfChars) { $descriptionString = " " . substr($imageLinkName, 0, $numberOfChars); $descriptionString .= " ..."; } else { $descriptionString = " " . $imageLinkName; } } else { $descriptionString = ""; } //Ends here if ($this->arrSettings['show_names'] == 'on' || $this->arrSettings['show_file_name'] == 'on') { $imageSizeOutput = $imageName; $imageTitleTag = $imageName; if ($this->arrSettings['show_file_name'] == 'on' || $showImageSize) { $imageData = array(); if ($this->arrSettings['show_file_name'] == 'on') { if ($this->arrSettings['show_names'] == 'off') { $imageSizeOutput .= $imageFileName; $imageTitleTag .= $imageFileName; } else { $imageData[] = $imageFileName; } } if (!empty($imageData)) { $imageTitleTag .= ' (' . join(' ', $imageData) . ')'; } if ($showImageSize) { // the size of the file has to be shown $imageData[] = $imageFileSize . ' kB'; } if (!empty($imageData)) { $imageSizeOutput .= ' (' . join(' ', $imageData) . ')<br />'; } } } if ($this->arrSettings['enable_popups'] == "on") { $strImageOutput = '<a rel="shadowbox[' . $intParentId . '];options={' . $optionValue . '}" title="' . $imageTitleTag . '" href="' . $strImagePath . '"><img title="' . $imageTitleTag . '" src="' . $imageThumbPath . '" alt="' . $imageTitleTag . '" /></a>'; /* $strImageOutput = '<a rel="shadowbox['.$intParentId.'];options={'.$optionValue. '}" description="'.$imageLinkName.'" title="'.$titleLink.'" href="'. $strImagePath.'"><img title="'.$imageName.'" src="'. $imageThumbPath.'" alt="'.$imageName.'" /></a>'; */ } else { $strImageOutput = '<a href="' . CONTREXX_DIRECTORY_INDEX . '?section=Gallery' . $this->strCmd . '&cid=' . $intParentId . '&pId=' . $objResult->fields['id'] . '">' . '<img title="' . $imageTitleTag . '" src="' . $imageThumbPath . '"' . 'alt="' . $imageTitleTag . '" /></a>'; } if ($this->arrSettings['show_comments'] == 'on' && $boolComment) { $objSubResult = $objDatabase->Execute("SELECT id FROM " . DBPREFIX . "module_gallery_comments " . "WHERE picid=" . $objResult->fields['id']); if ($objSubResult->RecordCount() > 0) { if ($objSubResult->RecordCount() == 1) { $imageCommentOutput = '1 ' . $_ARRAYLANG['TXT_COMMENTS_ADD_TEXT'] . '<br />'; } else { $imageCommentOutput = $objSubResult->RecordCount() . ' ' . $_ARRAYLANG['TXT_COMMENTS_ADD_COMMENTS'] . '<br />'; } } } if ($this->arrSettings['show_voting'] == 'on' && $boolVoting) { $objSubResult = $objDatabase->Execute("SELECT mark FROM " . DBPREFIX . "module_gallery_votes " . "WHERE picid=" . $objResult->fields["id"]); if ($objSubResult->RecordCount() > 0) { $intMark = 0; while (!$objSubResult->EOF) { $intMark = $intMark + $objSubResult->fields['mark']; $objSubResult->MoveNext(); } $imageVotingOutput = $_ARRAYLANG['TXT_VOTING_SCORE'] . ' Ø' . number_format(round($intMark / $objSubResult->RecordCount(), 1), 1, '.', '\'') . '<br />'; } } if (!empty($imageLinkName)) { if (!empty($imageLink)) { $imageLinkOutput = '<a href="' . $imageLink . '" target="_blank">' . $imageLinkName . '</a>'; } else { $imageLinkOutput = $imageLinkName; } } else { if (!empty($imageLink)) { $imageLinkOutput = '<a href="' . $imageLink . '" target="_blank">' . $imageLink . '</a>'; } } $this->_objTpl->setVariable(array('GALLERY_IMAGE_LINK' . $intFillLastRow => $imageSizeOutput . $imageCommentOutput . $imageVotingOutput . $imageLinkOutput, 'GALLERY_IMAGE' . $intFillLastRow => $strImageOutput)); if ($intFillLastRow == 3) { // Parse the data after every third image $this->_objTpl->parse('galleryShowImages'); $intFillLastRow = 1; } else { $intFillLastRow++; } $objResult->MoveNext(); } if ($intFillLastRow == 2) { $this->_objTpl->setVariable(array('GALLERY_IMAGE' . $intFillLastRow => '', 'GALLERY_IMAGE_LINK' . $intFillLastRow => '')); $intFillLastRow++; } if ($intFillLastRow == 3) { $this->_objTpl->setVariable(array('GALLERY_IMAGE' . $intFillLastRow => '', 'GALLERY_IMAGE_LINK' . $intFillLastRow => '')); $this->_objTpl->parse('galleryShowImages'); } } $this->_objTpl->parse('galleryCategories'); }
/** * set the placeholders for the category view * * @return null */ function showCategoryView() { global $_ARRAYLANG, $_CORELANG; $this->_objTpl->setTemplate($this->pageContent, true, true); // load source code if cmd value is integer if ($this->_objTpl->placeholderExists('APPLICATION_DATA')) { $page = new \Cx\Core\ContentManager\Model\Entity\Page(); $page->setVirtual(true); $page->setType(\Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION); $page->setModule('Calendar'); // load source code $applicationTemplate = \Cx\Core\Core\Controller\Cx::getContentTemplateOfPage($page); \LinkGenerator::parseTemplate($applicationTemplate); $this->_objTpl->addBlock('APPLICATION_DATA', 'application_data', $applicationTemplate); } $objCategoryManager = new \Cx\Modules\Calendar\Controller\CalendarCategoryManager(true); $objCategoryManager->getCategoryList(); $this->_objTpl->setGlobalVariable(array('TXT_' . $this->moduleLangVar . '_SEARCH_TERM' => $_ARRAYLANG['TXT_CALENDAR_KEYWORD'], 'TXT_' . $this->moduleLangVar . '_FROM' => $_ARRAYLANG['TXT_CALENDAR_FROM'], 'TXT_' . $this->moduleLangVar . '_TILL' => $_ARRAYLANG['TXT_CALENDAR_TILL'], 'TXT_' . $this->moduleLangVar . '_CATEGORY' => $_ARRAYLANG['TXT_CALENDAR_CAT'], 'TXT_' . $this->moduleLangVar . '_SEARCH' => $_ARRAYLANG['TXT_CALENDAR_SEARCH'], 'TXT_' . $this->moduleLangVar . '_OCLOCK' => $_ARRAYLANG['TXT_CALENDAR_OCLOCK'], $this->moduleLangVar . '_SEARCH_TERM' => isset($_GET['term']) ? contrexx_input2xhtml($_GET['term']) : '', $this->moduleLangVar . '_SEARCH_FROM' => isset($_GET['from']) ? contrexx_input2xhtml($_GET['from']) : '', $this->moduleLangVar . '_SEARCH_TILL' => isset($_GET['till']) ? contrexx_input2xhtml($_GET['till']) : '', $this->moduleLangVar . '_SEARCH_CATEGORIES' => $objCategoryManager->getCategoryDropdown(isset($_GET['catid']) ? intval($_GET['catid']) : 0, 1))); if (isset($this->categoryId)) { $objCategory = new \Cx\Modules\Calendar\Controller\CalendarCategory($this->categoryId); $this->_objTpl->setGlobalVariable(array($this->moduleLangVar . '_CATEGORY_NAME' => $objCategory->name)); $this->objEventManager->showEventList($this->_objTpl); $this->_objTpl->parse('categoryList'); } else { foreach ($objCategoryManager->categoryList as $key => $objCategory) { $objEventManager = new \Cx\Modules\Calendar\Controller\CalendarEventManager($this->startDate, $this->endDate, $objCategory->id, $this->searchTerm, true, $this->needAuth, true, $this->startPos, $this->numEvents); $objEventManager->getEventList(); $objEventManager->showEventList($this->_objTpl); $this->_objTpl->setGlobalVariable(array($this->moduleLangVar . '_CATEGORY_NAME' => $objCategory->name)); $this->_objTpl->parse('categoryList'); } } }
/** * Create the RSS-Feed */ function createRSS() { global $_CONFIG, $objDatabase, $_FRONTEND_LANGID; // languages $arrLanguages = \FWLanguage::getLanguageArray(); if (intval($this->arrSettings['news_feed_status']) == 1) { if (count($arrLanguages > 0)) { $categoryDetails = $this->getCategoryLocale(null, array_keys($arrLanguages)); foreach ($arrLanguages as $LangId => $arrLanguage) { if ($arrLanguage['frontend'] == 1) { $objRSSWriter = new \RSSWriter(); $query = "\n SELECT tblNews.id,\n tblNews.date,\n tblNews.redirect,\n tblNews.source,\n tblNews.teaser_frames AS teaser_frames,\n tblLocale.lang_id,\n tblLocale.title,\n tblLocale.text,\n tblLocale.teaser_text\n FROM " . DBPREFIX . "module_news AS tblNews\n INNER JOIN " . DBPREFIX . "module_news_locale AS tblLocale ON tblLocale.news_id = tblNews.id\n WHERE tblNews.status=1\n AND tblLocale.is_active = 1\n AND tblLocale.lang_id = " . $LangId . " \n AND (tblNews.startdate <= '" . date('Y-m-d') . "' OR tblNews.startdate = '0000-00-00 00:00:00')\n AND (tblNews.enddate >= '" . date('Y-m-d') . "' OR tblNews.enddate = '0000-00-00 00:00:00')" . ($this->arrSettings['news_message_protection'] == '1' ? " AND tblNews.frontend_access_id=0 " : '') . "ORDER BY tblNews.date DESC"; $arrNews = array(); if (($objResult = $objDatabase->SelectLimit($query, 20)) !== false && $objResult->RecordCount() > 0) { while (!$objResult->EOF) { if (empty($objRSSWriter->channelLastBuildDate)) { $objRSSWriter->channelLastBuildDate = date('r', $objResult->fields['date']); } $teaserText = preg_replace('/\\[\\[([A-Z0-9_-]+)\\]\\]/', '{\\1}', $objResult->fields['teaser_text']); $text = preg_replace('/\\[\\[([A-Z0-9_-]+)\\]\\]/', '{\\1}', $objResult->fields['text']); $redirect = preg_replace('/\\[\\[([A-Z0-9_-]+)\\]\\]/', '{\\1}', $objResult->fields['redirect']); \LinkGenerator::parseTemplate($teaserText, true); \LinkGenerator::parseTemplate($text, true); \LinkGenerator::parseTemplate($redirect, true); $arrNews[$objResult->fields['id']] = array('date' => $objResult->fields['date'], 'title' => $objResult->fields['title'], 'text' => empty($redirect) ? (!empty($teaserText) ? nl2br($teaserText) . '<br /><br />' : '') . $text : (!empty($teaserText) ? nl2br($teaserText) : ''), 'redirect' => $redirect, 'source' => $objResult->fields['source'], 'teaser_frames' => explode(';', $objResult->fields['teaser_frames']), 'categoryIds' => $this->getNewsRelCategories($objResult->fields['id'])); $objResult->MoveNext(); } } else { continue; } $objRSSWriter->characterEncoding = CONTREXX_CHARSET; $objRSSWriter->channelTitle = contrexx_raw2xml($this->arrSettings['news_feed_title'][$LangId]); $objRSSWriter->channelDescription = contrexx_raw2xml($this->arrSettings['news_feed_description'][$LangId]); $objRSSWriter->channelLink = 'http://' . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . intval($_SERVER['SERVER_PORT'])) . ASCMS_PATH_OFFSET . '/' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '/' . CONTREXX_DIRECTORY_INDEX . '?section=News'; $objRSSWriter->channelLanguage = \FWLanguage::getLanguageParameter($LangId, 'lang'); $objRSSWriter->channelCopyright = 'Copyright ' . date('Y') . ', http://' . $_CONFIG['domainUrl']; if (!empty($this->arrSettings['news_feed_image'])) { $objRSSWriter->channelImageUrl = 'http://' . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . intval($_SERVER['SERVER_PORT'])) . $this->arrSettings['news_feed_image']; $objRSSWriter->channelImageTitle = $objRSSWriter->channelTitle; $objRSSWriter->channelImageLink = $objRSSWriter->channelLink; } $objRSSWriter->channelWebMaster = $_CONFIG['coreAdminEmail']; $itemLink = 'http://' . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? '' : ':' . intval($_SERVER['SERVER_PORT'])) . ASCMS_PATH_OFFSET . '/' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '/' . CONTREXX_DIRECTORY_INDEX . '?section=News&cmd='; // create rss feed $objRSSWriter->xmlDocumentPath = \Env::get('cx')->getWebsiteFeedPath() . '/news_' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '.xml'; foreach ($arrNews as $newsId => $arrNewsItem) { list($cmdDetail, $categories) = $this->getRssNewsLinks($LangId, $arrNewsItem['categoryIds'], $categoryDetails[$LangId]); $objRSSWriter->addItem(contrexx_raw2xml($arrNewsItem['title']), empty($arrNewsItem['redirect']) ? $itemLink . $cmdDetail . '&newsid=' . $newsId . (isset($arrNewsItem['teaser_frames'][0]) ? '&teaserId=' . $arrNewsItem['teaser_frames'][0] : '') : htmlspecialchars($arrNewsItem['redirect'], ENT_QUOTES, CONTREXX_CHARSET), contrexx_raw2xml($arrNewsItem['text']), '', $categories, '', '', '', $arrNewsItem['date'], array('url' => htmlspecialchars($arrNewsItem['source'], ENT_QUOTES, CONTREXX_CHARSET), 'title' => contrexx_raw2xml($arrNewsItem['title']))); } $objRSSWriter->write(); // create headlines rss feed $objRSSWriter->removeItems(); $objRSSWriter->xmlDocumentPath = \Env::get('cx')->getWebsiteFeedPath() . '/news_headlines_' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '.xml'; foreach ($arrNews as $newsId => $arrNewsItem) { list($cmdDetail, $categories) = $this->getRssNewsLinks($LangId, $arrNewsItem['categoryIds'], $categoryDetails[$LangId]); $objRSSWriter->addItem(contrexx_raw2xml($arrNewsItem['title']), $itemLink . $cmdDetail . '&newsid=' . $newsId . (isset($arrNewsItem['teaser_frames'][0]) ? '&teaserId=' . $arrNewsItem['teaser_frames'][0] : ''), '', '', $categories, '', '', '', $arrNewsItem['date']); } $objRSSWriter->write(); $objRSSWriter->feedType = 'js'; $objRSSWriter->xmlDocumentPath = \Env::get('cx')->getWebsiteFeedPath() . '/news_' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '.js'; $objRSSWriter->write(); if (count($objRSSWriter->arrErrorMsg) > 0) { $this->strErrMessage .= implode('<br />', $objRSSWriter->arrErrorMsg); } if (count($objRSSWriter->arrWarningMsg) > 0) { $this->strErrMessage .= implode('<br />', $objRSSWriter->arrWarningMsg); } } } } } else { if (count($arrLanguages > 0)) { foreach ($arrLanguages as $LangId => $arrLanguage) { if ($arrLanguage['frontend'] == 1) { @unlink(\Env::get('cx')->getWebsiteFeedPath() . '/news_' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '.xml'); @unlink(\Env::get('cx')->getWebsiteFeedPath() . '/news_headlines_' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '.xml'); @unlink(\Env::get('cx')->getWebsiteFeedPath() . '/news_' . \FWLanguage::getLanguageParameter($LangId, 'lang') . '.js'); } } } } }
function getContent($intEntryId, $arrInputfield, $arrTranslationStatus) { global $objDatabase, $_LANGID; $intId = intval($arrInputfield['id']); $objEntryDefaultLang = $objDatabase->Execute("SELECT `lang_id` FROM " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_entries WHERE id=" . intval($intEntryId) . " LIMIT 1"); $intEntryDefaultLang = intval($objEntryDefaultLang->fields['lang_id']); $intLangId = $_LANGID; if ($this->arrSettings['settingsTranslationStatus'] == 1) { $intLangId = in_array($_LANGID, $arrTranslationStatus) ? $_LANGID : $intEntryDefaultLang; } $objInputfieldValue = $objDatabase->Execute("\n SELECT\n `value`\n FROM\n " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_rel_entry_inputfields\n WHERE\n field_id=" . $intId . "\n AND\n entry_id=" . intval($intEntryId) . "\n AND\n lang_id=" . $intLangId . "\n\n LIMIT 1\n "); if (empty($objInputfieldValue->fields['value'])) { $objInputfieldValue = $objDatabase->Execute("\n SELECT\n `value`\n FROM\n " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_rel_entry_inputfields\n WHERE\n field_id=" . $intId . "\n AND\n entry_id=" . intval($intEntryId) . "\n AND\n lang_id=" . intval($intEntryDefaultLang) . "\n LIMIT 1\n "); } $strValue = strip_tags(htmlspecialchars($objInputfieldValue->fields['value'], ENT_QUOTES, CONTREXX_CHARSET)); // replace the links $strValue = preg_replace('/\\[\\[([A-Z0-9_-]+)\\]\\]/', '{\\1}', $strValue); \LinkGenerator::parseTemplate($strValue, true); //make link name without protocol $strValueName = preg_replace('#^.*://#', '', $strValue); if (strlen($strValueName) >= 55) { $strValueName = substr($strValueName, 0, 55) . " [...]"; } //make link href with "http://" $strValueHref = $strValue; if (!preg_match('#^.*://#', $strValueHref)) { $strValueHref = "http://" . $strValueHref; } //make hyperlink with <a> tag $strValueLink = '<a href="' . $strValueHref . '" class="' . $this->moduleNameLC . 'InputfieldLink" target="_blank">' . $strValueName . '</a>'; if (!empty($strValue)) { $arrContent['TXT_' . $this->moduleLangVar . '_INPUTFIELD_NAME'] = htmlspecialchars($arrInputfield['name'][0], ENT_QUOTES, CONTREXX_CHARSET); $arrContent[$this->moduleLangVar . '_INPUTFIELD_VALUE'] = $strValueLink; $arrContent[$this->moduleLangVar . '_INPUTFIELD_VALUE_HREF'] = $strValueHref; $arrContent[$this->moduleLangVar . '_INPUTFIELD_VALUE_NAME'] = $strValueName; } else { $arrContent = null; } return $arrContent; }
public function resolve() { // $this->resolveAlias() also sets $this->page $aliaspage = $this->resolveAlias(); if ($aliaspage != null) { $this->lang = $aliaspage->getTargetLangId(); $aliaspage = clone $aliaspage; $aliaspage->setVirtual(true); } else { $this->lang = \Env::get('init')->getFallbackFrontendLangId(); //try to find the language in the url $extractedLanguage = \FWLanguage::getLanguageIdByCode($this->url->getLangDir()); $activeLanguages = \FWLanguage::getActiveFrontendLanguages(); if (!$extractedLanguage) { $this->redirectToCorrectLanguageDir(); } if (!in_array($extractedLanguage, array_keys($activeLanguages))) { $this->lang = \FWLanguage::getDefaultLangId(); $this->redirectToCorrectLanguageDir(); } //only set langid according to url if the user has not explicitly requested a language change. if (!isset($_REQUEST['setLang'])) { $this->lang = $extractedLanguage; //the user wants to change the language, but we're still inside the wrong language directory. } else { if ($this->lang != $extractedLanguage) { $this->redirectToCorrectLanguageDir(); } } } // used for LinkGenerator define('FRONTEND_LANG_ID', $this->lang); // used to load template file \Env::get('init')->setFrontendLangId($this->lang); global $section, $command, $history, $sessionObj, $url, $_CORELANG, $page, $pageId, $themesPages, $page_template, $isRegularPageRequest, $now, $start, $end, $plainSection; $section = isset($_REQUEST['section']) ? $_REQUEST['section'] : ''; $command = isset($_REQUEST['cmd']) ? contrexx_addslashes($_REQUEST['cmd']) : ''; $history = isset($_REQUEST['history']) ? intval($_REQUEST['history']) : 0; // Initialize page meta $page = null; $pageAccessId = 0; $page_protected = $pageId = $themesPages = $page_template = null; // If standalone is set, then we will not have to initialize/load any content page related stuff $isRegularPageRequest = !isset($_REQUEST['standalone']) || $_REQUEST['standalone'] == 'false'; // Regular page request if ($isRegularPageRequest) { // TODO: history (empty($history) ? ) if (isset($_GET['pagePreview']) && $_GET['pagePreview'] == 1 && empty($sessionObj)) { $sessionObj = \cmsSession::getInstance(); } $this->init($url, $this->lang, \Env::get('em'), ASCMS_INSTANCE_OFFSET . \Env::get('virtualLanguageDirectory'), \FWLanguage::getFallbackLanguageArray()); try { $this->resolvePage(); $page = $this->getPage(); // TODO: should this check (for type 'application') moved to \Cx\Core\ContentManager\Model\Entity\Page::getCmd()|getModule() ? // only set $section and $command if the requested page is an application $command = $this->getCmd(); $section = $this->getSection(); } catch (\Cx\Core\Routing\ResolverException $e) { try { $this->legacyResolve($url, $section, $command); $page = $this->getPage(); $command = $this->getCmd(); $section = $this->getSection(); } catch (\Cx\Core\Routing\ResolverException $e) { // legacy resolving also failed. // provoke a 404 $page = null; } } if (!$page || !$page->isActive()) { //fallback for inexistant error page if ($section == 'Error') { // If the error module is not installed, show this die($_CORELANG['TXT_THIS_MODULE_DOESNT_EXISTS']); } else { //page not found, redirect to error page. \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . \Cx\Core\Routing\Url::fromModuleAndCmd('Error')); exit; } } // TODO: question: what do we need this for? I think there is no need for this (had been added in r15026) //legacy: re-populate cmd and section into $_GET $_GET['cmd'] = $command; $_GET['section'] = $section; // END of TODO question //check whether the page is active $now = new \DateTime('now'); $start = $page->getStart(); $end = $page->getEnd(); $pageId = $page->getId(); //access: frontend access id for default requests $pageAccessId = $page->getFrontendAccessId(); //revert the page if a history param has been given if ($history) { //access: backend access id for history requests $pageAccessId = $page->getBackendAccessId(); $logRepo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\LogEntry'); try { $logRepo->revert($page, $history); } catch (\Gedmo\Exception\UnexpectedValueException $e) { } $logRepo->revert($page, $history); } /* //404 for inactive pages if(($start > $now && $start != null) || ($now > $end && $end != null)) { if ($section == 'Error') { // If the error module is not installed, show this die($_CORELANG['TXT_THIS_MODULE_DOESNT_EXISTS']); } \Cx\Core\Csrf\Controller\Csrf::header('Location: index.php?section=Error&id=404'); exit; }*/ \Env::get('init')->setCustomizedTheme($page->getSkin(), $page->getCustomContent(), $page->getUseSkinForAllChannels()); $themesPages = \Env::get('init')->getTemplates($page); //replace the {NODE_<ID>_<LANG>}- placeholders \LinkGenerator::parseTemplate($themesPages); //TODO: analyze those, take action. //$page_protected = $objResult->fields['protected']; $page_protected = $page->isFrontendProtected(); //$page_access_id = $objResult->fields['frontend_access_id']; $page_template = $themesPages['content']; // Authentification for protected pages // This is only done for regular page requests ($isRegularPageRequest == TRUE) $this->checkPageFrontendProtection($page, $history); //TODO: history } // TODO: refactor system to be able to remove this backward compatibility // Backwards compatibility for code pre Contrexx 3.0 (update) $_GET['cmd'] = $_POST['cmd'] = $_REQUEST['cmd'] = $command; $_GET['section'] = $_POST['section'] = $_REQUEST['section'] = $section; // the system should directly use $this->url->getParamArray() instead of using the super globals $qsArr = $this->url->getParamArray(); foreach ($qsArr as $qsParam => $qsArgument) { $_GET[$qsParam] = $_REQUEST[$qsParam] = $qsArgument; } // To clone any module, use an optional integer cmd suffix. // E.g.: "shop2", "gallery5", etc. // Mind that you *MUST* copy all necessary database tables, and fix any // references to your module (section and cmd parameters, database tables) // using the MODULE_INDEX constant in the right place both in your code // *AND* templates! // See the Shop module for an example. $arrMatch = array(); if (preg_match('/^(\\D+)(\\d+)$/', $section, $arrMatch)) { // The plain section/module name, used below $plainSection = $arrMatch[1]; } else { $plainSection = $section; } // The module index. // An empty or 1 (one) index represents the same (default) module, // values 2 (two) and larger represent distinct instances. $moduleIndex = empty($arrMatch[2]) || $arrMatch[2] == 1 ? '' : $arrMatch[2]; define('MODULE_INDEX', $moduleIndex); // Start page or default page for no section if ($section == 'Home') { if (!\Env::get('init')->hasCustomContent()) { $page_template = $themesPages['home']; } else { $page_template = $themesPages['content']; } } // this is the case for standalone and backend requests if (!$this->page) { return null; } $this->page = clone $this->page; $this->page->setVirtual(); // check for further URL parts to resolve if ($this->page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION && $this->page->getPath() != '/' . $this->url->getSuggestedTargetPath()) { // does this work for fallback(/aliases)? $additionalPath = substr('/' . $this->url->getSuggestedTargetPath(), strlen($this->page->getPath())); $componentController = $this->em->getRepository('Cx\\Core\\Core\\Model\\Entity\\SystemComponent')->findOneBy(array('name' => $this->page->getModule())); if ($componentController) { $parts = explode('/', substr($additionalPath, 1)); $componentController->resolve($parts, $this->page); } } return $this->page; }
/** * Show the contact page * * Parse a contact form submit request and show the contact page * @see _getContactFormData(), _checkValues(), _insertIntoDatabase(), sendMail(), _showError(), _showFeedback(), \Cx\Core\Html\Sigma::get(), \Cx\Core\Html\Sigma::blockExists(), \Cx\Core\Html\Sigma::hideBlock(), \Cx\Core\Html\Sigma::touchBlock() * @return string Parse contact form page */ function getContactPage() { global $_ARRAYLANG, $_LANGID, $objDatabase; \JS::activate('cx'); $formId = isset($_GET['cmd']) ? intval($_GET['cmd']) : 0; $arrFields = $this->getFormFields($formId); $isLoggedin = $this->setProfileData(); $useCaptcha = !$isLoggedin && $this->getContactFormCaptchaStatus($formId); $this->handleUniqueId(); $uploaderCode = ''; // load requested form's source code if required if ($this->objTemplate->placeholderExists('APPLICATION_DATA')) { // load form's source code $applicationTemplate = $this->getSourceCode($formId, $_LANGID); \LinkGenerator::parseTemplate($applicationTemplate); $this->objTemplate->addBlock('APPLICATION_DATA', 'application_data', $applicationTemplate); } $this->objTemplate->setVariable(array('TXT_NEW_ENTRY_ERORR' => $_ARRAYLANG['TXT_NEW_ENTRY_ERORR'], 'TXT_CONTACT_SUBMIT' => $_ARRAYLANG['TXT_CONTACT_SUBMIT'], 'TXT_CONTACT_RESET' => $_ARRAYLANG['TXT_CONTACT_RESET'])); if ($this->objTemplate->blockExists('contact_form')) { $recipients = $this->getRecipients($formId); foreach ($arrFields as $fieldId => $arrField) { /* * Set values for special field types if the user is authenticated */ if ($isLoggedin && empty($_GET[$fieldId]) && empty($_POST['contactFormField_' . $fieldId])) { switch ($arrField['special_type']) { case 'access_email': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_USER_EMAIL]]'; break; case 'access_gender': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_GENDER]]'; break; case 'access_title': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_TITLE]]'; break; case 'access_firstname': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_FIRSTNAME]]'; break; case 'access_lastname': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_LASTNAME]]'; break; case 'access_company': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_COMPANY]]'; break; case 'access_address': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_ADDRESS]]'; break; case 'access_city': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_CITY]]'; break; case 'access_zip': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_ZIP]]'; break; case 'access_country': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_COUNTRY]]'; break; case 'access_phone_office': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_PHONE_OFFICE]]'; break; case 'access_phone_private': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_PHONE_PRIVATE]]'; break; case 'access_phone_mobile': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_PHONE_MOBILE]]'; break; case 'access_phone_fax': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_PHONE_FAX]]'; break; case 'access_birthday': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_BIRTHDAY]]'; break; case 'access_website': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_WEBSITE]]'; break; case 'access_profession': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_PROFESSION]]'; break; case 'access_interests': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_INTERESTS]]'; break; case 'access_signature': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_SIGNATURE]]'; break; default: break; } } $arrField['lang'][$_LANGID]['value'] = preg_replace('/\\[\\[([A-Z0-9_]+)\\]\\]/', '{$1}', $arrField['lang'][$_LANGID]['value']); $this->objTemplate->setVariable(array($formId . '_FORM_NAME' => wordwrap($this->arrForms[$formId]['lang'][$_LANGID]['name'], 90, "<br/>\n", true), $formId . '_FORM_TEXT' => $this->arrForms[$formId]['lang'][$_LANGID]['text'], $fieldId . '_LABEL' => $arrField['lang'][$_LANGID]['name'] != "" ? wordwrap($arrField['lang'][$_LANGID]['name'], 90, "<br/>\n", true) : " ")); /* * Generate values for dropdown checkbox and radio fields */ $userProfileRegExp = '/\\{([A-Z_]+)\\}/'; $accessAttributeId = null; $fieldType = $arrField['type'] != 'special' ? $arrField['type'] : $arrField['special_type']; switch ($fieldType) { case 'checkbox': if ($arrField['lang'][$_LANGID]['value'] == 1 || !empty($_POST['contactFormField_' . $fieldId])) { $this->objTemplate->setVariable('SELECTED_' . $fieldId, 'checked="checked"'); } break; case 'checkboxGroup': case 'radio': $options = explode(',', $arrField['lang'][$_LANGID]['value']); foreach ($options as $index => $option) { if (preg_match($userProfileRegExp, $option)) { $valuePlaceholderBlock = 'contact_value_placeholder_block_' . $fieldId . '_' . $index; $this->objTemplate->addBlock($fieldId . '_' . $index . '_VALUE', $valuePlaceholderBlock, contrexx_raw2xhtml($option)); } else { $this->objTemplate->setVariable($fieldId . '_' . $index . '_VALUE', contrexx_raw2xhtml($option)); } if (!empty($_POST['contactFormField_' . $fieldId])) { if (in_array($option, $_POST['contactFormField_' . $fieldId]) || $option == $_POST['contactFormField_' . $fieldId]) { $this->objTemplate->setVariable('SELECTED_' . $fieldId . '_' . $index, 'checked="checked"'); } } elseif (!empty($_GET[$fieldId])) { if ($option == $_GET[$fieldId]) { $this->objTemplate->setVariable('SELECTED_' . $fieldId . '_' . $index, 'checked="checked"'); } } } break; case 'access_title': case 'access_gender': // collect user attribute options $arrOptions = array(); $accessAttributeId = str_replace('access_', '', $fieldType); $objAttribute = \FWUser::getFWUserObject()->objUser->objAttribute->getById($accessAttributeId); // get options $arrAttribute = $objAttribute->getChildren(); foreach ($arrAttribute as $attributeId) { // in case the selection of the field is mandatory, we shall skip the unknown option of the user profile attribute if ($arrField['is_required'] && strpos($attributeId, '_undefined')) { continue; } $objAttribute = \FWUser::getFWUserObject()->objUser->objAttribute->getById($attributeId); $arrOptions[] = $objAttribute->getName(FRONTEND_LANG_ID); } // options will be used for select input generation $arrField['lang'][FRONTEND_LANG_ID]['value'] = implode(',', $arrOptions); // intentionally no break here!! // intentionally no break here!! case 'select': $options = explode(',', $arrField['lang'][$_LANGID]['value']); $inexOffset = 0; if ($arrField['is_required']) { $options = array_merge(array($_ARRAYLANG['TXT_CONTACT_PLEASE_SELECT']), $options); $inexOffset = 1; } foreach ($options as $index => $option) { if (preg_match($userProfileRegExp, $option)) { $valuePlaceholderBlock = 'contact_value_placeholder_block_' . $fieldId . '_' . $index; $this->objTemplate->addBlock($fieldId . '_VALUE', $valuePlaceholderBlock, contrexx_raw2xhtml($option)); } else { $this->objTemplate->setVariable($fieldId . '_VALUE', contrexx_raw2xhtml($option)); } // pre-selection, based on $_POST value if (!empty($_POST['contactFormField_' . $fieldId])) { if ($index == array_search($_POST['contactFormField_' . $fieldId], explode(',', $arrField['lang'][$_LANGID]['value'])) + $inexOffset) { $this->objTemplate->setVariable('SELECTED_' . $fieldId, 'selected = "selected"'); } // pre-selection, based on $_GET value } elseif (!empty($_GET[$fieldId])) { if ($index == array_search(contrexx_input2raw($_GET[$fieldId]), explode(',', $arrField['lang'][$_LANGID]['value']))) { $this->objTemplate->setVariable('SELECTED_' . $fieldId, 'selected = "selected"'); } // pre-selection, based on profile data of currently signed in user } elseif (isset($this->objTemplate->_globalVariables['ACCESS_PROFILE_ATTRIBUTE_' . strtoupper($accessAttributeId)]) && $option == $this->objTemplate->_globalVariables['ACCESS_PROFILE_ATTRIBUTE_' . strtoupper($accessAttributeId)]) { $this->objTemplate->setVariable('SELECTED_' . $fieldId, 'selected = "selected"'); } $this->objTemplate->parse('field_' . $fieldId); } break; case 'recipient': foreach ($recipients as $index => $recipient) { $recipient['lang'][$_LANGID] = preg_replace('/\\[\\[([A-Z0-9_]+)\\]\\]/', '{$1}', $recipient['lang'][$_LANGID]); if (preg_match($userProfileRegExp, $recipient['lang'][$_LANGID])) { $valuePlaceholderBlock = 'contact_value_placeholder_block_' . $fieldId . '_' . $index; $this->objTemplate->addBlock($fieldId . '_VALUE', $valuePlaceholderBlock, $recipient['lang'][$_LANGID]); } else { $this->objTemplate->setVariable(array($fieldId . '_VALUE' => $recipient['lang'][$_LANGID])); } $this->objTemplate->setVariable(array($fieldId . '_VALUE_ID' => $index)); if (!empty($_POST['contactFormField_' . $fieldId]) && $recipient['lang'][$_LANGID] == $_POST['contactFormField_' . $fieldId]) { $this->objTemplate->setVariable(array('SELECTED_' . $fieldId => 'selected = "selected"')); } elseif (!empty($_GET[$fieldId]) && $recipient['lang'][$_LANGID] == $_GET[$fieldId]) { $this->objTemplate->setVariable(array('SELECTED_' . $fieldId => 'selected = "selected"')); } $this->objTemplate->parse('field_' . $fieldId); } break; case 'access_country': case 'country': if (preg_match($userProfileRegExp, $arrField['lang'][$_LANGID]['value'])) { $arrField['lang'][$_LANGID]['value'] = $this->objTemplate->_globalVariables[trim($arrField['lang'][$_LANGID]['value'], '{}')]; } $lang = $arrField['lang'][$_LANGID]['value']; $country = \Cx\Core\Country\Controller\Country::getNameArray(true, $lang); foreach ($country as $id => $name) { $this->objTemplate->setVariable($fieldId . '_VALUE', $name); if (!empty($_POST['contactFormField_' . $fieldId])) { if (strcasecmp($name, $_POST['contactFormField_' . $fieldId]) == 0) { $this->objTemplate->setVariable('SELECTED_' . $fieldId, 'selected = "selected"'); } } elseif (!empty($_GET[$fieldId])) { if (strcasecmp($name, $_GET[$fieldId]) == 0) { $this->objTemplate->setVariable('SELECTED_' . $fieldId, 'selected = "selected"'); } } elseif ($name == $arrField['lang'][$_LANGID]['value']) { $this->objTemplate->setVariable('SELECTED_' . $fieldId, 'selected = "selected"'); } $this->objTemplate->parse('field_' . $fieldId); } $this->objTemplate->setVariable(array('TXT_CONTACT_PLEASE_SELECT' => $_ARRAYLANG['TXT_CONTACT_PLEASE_SELECT'], 'TXT_CONTACT_NOT_SPECIFIED' => $_ARRAYLANG['TXT_CONTACT_NOT_SPECIFIED'])); break; case 'file': $this->hasFileField = true; $uploaderCode .= $this->initUploader($fieldId, true); break; case 'multi_file': $this->hasFileField = true; $uploaderCode .= $this->initUploader($fieldId, false); break; default: /* * Set default field value through User profile attribute */ $arrField['lang'][$_LANGID]['value'] = preg_replace('/\\[\\[([A-Z0-9_]+)\\]\\]/', '{$1}', $arrField['lang'][$_LANGID]['value']); if (preg_match($userProfileRegExp, $arrField['lang'][$_LANGID]['value'])) { $valuePlaceholderBlock = 'contact_value_placeholder_block_' . $fieldId; $this->objTemplate->addBlock($fieldId . '_VALUE', $valuePlaceholderBlock, contrexx_raw2xhtml($arrField['lang'][$_LANGID]['value'])); } elseif (!empty($_POST['contactFormField_' . $fieldId])) { $this->objTemplate->setVariable($fieldId . '_VALUE', contrexx_raw2xhtml($_POST['contactFormField_' . $fieldId])); } elseif (!empty($_GET[$fieldId])) { $this->objTemplate->setVariable($fieldId . '_VALUE', contrexx_raw2xhtml($_GET[$fieldId])); } else { $this->objTemplate->setVariable($fieldId . '_VALUE', contrexx_raw2xhtml($arrField['lang'][$_LANGID]['value'])); } break; } /* * Parse the blocks created for parsing user profile data using addBlock() */ if (!empty($valuePlaceholderBlock) && $this->objTemplate->blockExists($valuePlaceholderBlock)) { $this->objTemplate->touchBlock($valuePlaceholderBlock); } } } if (isset($_POST['submitContactForm']) || isset($_POST['Submit'])) { //form submitted $this->checkLegacyMode(); $showThanks = isset($_GET['cmd']) && $_GET['cmd'] == 'thanks' ? true : false; $arrFormData = $this->_getContactFormData(); if ($arrFormData) { if ($this->_checkValues($arrFormData, $useCaptcha) && $this->_insertIntoDatabase($arrFormData)) { //validation ok if (!empty($arrFormData['saveDataInCRM'])) { $objCrmLibrary = new \Cx\Modules\Crm\Controller\CrmLibrary('Crm'); $objCrmLibrary->addCrmContact($arrFormData); } $this->sendMail($arrFormData); if (isset($arrFormData['showForm']) && !$arrFormData['showForm']) { $this->objTemplate->hideBlock("formText"); $this->objTemplate->hideBlock('contact_form'); } } else { //found errors while validating $this->setCaptcha($useCaptcha); return $this->_showError(); } if (!$showThanks) { $this->_showFeedback($arrFormData); } else { if ($this->objTemplate->blockExists("formText")) { $this->objTemplate->hideBlock("formText"); } } } } else { //fresh display if ($this->objTemplate->blockExists('formText')) { $this->objTemplate->touchBlock('formText'); } $this->setCaptcha($useCaptcha); } $this->objTemplate->setVariable('CONTACT_JAVASCRIPT', $this->_getJsSourceCode($formId, $arrFields) . $uploaderCode); return $this->objTemplate->get(); }
/** * Set block Random * * Parse the block with the id $id * * @access private * @param integer $id * @param string &$code * @global ADONewConnection * @global integer */ function _setBlockRandom(&$code, $id) { global $objDatabase; $now = time(); $query = " SELECT\r\n tblBlock.id\r\n FROM\r\n " . DBPREFIX . "module_block_blocks AS tblBlock,\r\n " . DBPREFIX . "module_block_rel_lang_content AS tblContent\r\n WHERE\r\n tblContent.block_id = tblBlock.id\r\n AND\r\n (tblContent.lang_id = " . FRONTEND_LANG_ID . " AND tblContent.active = 1)\r\n AND (tblBlock.`start` <= {$now} OR tblBlock.`start` = 0)\r\n AND (tblBlock.`end` >= {$now} OR tblBlock.end = 0)\r\n AND\r\n tblBlock.active = 1 "; //Get Block Name and Status switch ($id) { case '1': $objBlockName = $objDatabase->Execute($query . "AND tblBlock.random=1"); $blockNr = ""; break; case '2': $objBlockName = $objDatabase->Execute($query . "AND tblBlock.random_2=1"); $blockNr = "_2"; break; case '3': $objBlockName = $objDatabase->Execute($query . "AND tblBlock.random_3=1"); $blockNr = "_3"; break; case '4': $objBlockName = $objDatabase->Execute($query . "AND tblBlock.random_4=1"); $blockNr = "_4"; break; } if ($objBlockName !== false && $objBlockName->RecordCount() > 0) { while (!$objBlockName->EOF) { $arrActiveBlocks[] = $objBlockName->fields['id']; $objBlockName->MoveNext(); } $ranId = $arrActiveBlocks[@array_rand($arrActiveBlocks, 1)]; $objBlock = $objDatabase->SelectLimit("SELECT content FROM " . DBPREFIX . "module_block_rel_lang_content WHERE block_id=" . $ranId . " AND lang_id=" . FRONTEND_LANG_ID, 1); if ($objBlock !== false) { $em = \Env::get('cx')->getDb()->getEntityManager(); $systemComponentRepo = $em->getRepository('Cx\\Core\\Core\\Model\\Entity\\SystemComponent'); $frontendEditingComponent = $systemComponentRepo->findOneBy(array('name' => 'FrontendEditing')); $content = $objBlock->fields['content']; $frontendEditingComponent->prepareBlock($objBlockName->fields['id'], $content); \LinkGenerator::parseTemplate($content); $code = str_replace("{" . $this->blockNamePrefix . "RANDOMIZER" . $blockNr . "}", $content, $code); return true; } } return false; }