/** * This is called by the default ComponentController and does all the repeating work * * This creates a template of the page content and calls parsePage($template) * @param \Cx\Core\ContentManager\Model\Entity\Page $page Resolved page */ public function getPage(\Cx\Core\ContentManager\Model\Entity\Page $page) { global $_ARRAYLANG; // init component template $componentTemplate = new \Cx\Core\Html\Sigma('.'); $componentTemplate->setErrorHandling(PEAR_ERROR_DIE); $componentTemplate->setTemplate($page->getContent()); // default css and js if (file_exists($this->cx->getClassLoader()->getFilePath($this->getDirectory(false) . '/View/Style/Frontend.css'))) { \JS::registerCSS(substr($this->getDirectory(false, true) . '/View/Style/Frontend.css', 1)); } if (file_exists($this->cx->getClassLoader()->getFilePath($this->getDirectory(false) . '/View/Script/Frontend.js'))) { \JS::registerJS(substr($this->getDirectory(false, true) . '/View/Script/Frontend.js', 1)); } // parse page $componentTemplate->setGlobalVariable($_ARRAYLANG); $this->parsePage($componentTemplate, $page->getCmd()); \Cx\Core\Csrf\Controller\Csrf::add_placeholder($componentTemplate); $page->setContent($componentTemplate->get()); }
/** * Sends an email with the contact details to the responsible persons * * This methode sends an email to all email addresses that are defined in the * option "Receiver address(es)" of the requested contact form. * @access private * @global array * @global array * @param array Details of the contact request * @see _getEmailAdressOfString(), phpmailer::From, phpmailer::FromName, phpmailer::AddReplyTo(), phpmailer::Subject, phpmailer::IsHTML(), phpmailer::Body, phpmailer::AddAddress(), phpmailer::Send(), phpmailer::ClearAddresses() */ private function sendMail($arrFormData) { global $_ARRAYLANG, $_CONFIG; $plaintextBody = ''; $replyAddress = ''; $firstname = ''; $lastname = ''; $senderName = ''; $isHtml = $arrFormData['htmlMail'] == 1 ? true : false; // stop send process in case no real data had been submitted if (!isset($arrFormData['data']) && !isset($arrFormData['uploadedFiles'])) { return false; } // check if we shall send the email as multipart (text/html) if ($isHtml) { // setup html mail template $objTemplate = new \Cx\Core\Html\Sigma('.'); $objTemplate->setErrorHandling(PEAR_ERROR_DIE); $objTemplate->setTemplate($arrFormData['mailTemplate']); $objTemplate->setVariable(array('DATE' => date(ASCMS_DATE_FORMAT, $arrFormData['meta']['time']), 'HOSTNAME' => contrexx_raw2xhtml($arrFormData['meta']['host']), 'IP_ADDRESS' => contrexx_raw2xhtml($arrFormData['meta']['ipaddress']), 'BROWSER_LANGUAGE' => contrexx_raw2xhtml($arrFormData['meta']['lang']), 'BROWSER_VERSION' => contrexx_raw2xhtml($arrFormData['meta']['browser']))); } // TODO: check if we have to excape $arrRecipients later in the code $arrRecipients = $this->getRecipients(intval($_GET['cmd'])); // calculate the longest field label. // this will be used to correctly align all user submitted data in the plaintext e-mail // TODO: check if the label of upload-fields are taken into account as well $maxlength = 0; foreach ($arrFormData['fields'] as $arrField) { $length = strlen($arrField['lang'][FRONTEND_LANG_ID]['name']); $maxlength = $maxlength < $length ? $length : $maxlength; } // try to fetch a user submitted e-mail address to which we will send a copy to if (!empty($arrFormData['fields'])) { foreach ($arrFormData['fields'] as $fieldId => $arrField) { // check if field validation is set to e-mail if ($arrField['check_type'] == '2') { $mail = trim($arrFormData['data'][$fieldId]); if (\FWValidator::isEmail($mail)) { $replyAddress = $mail; break; } } if ($arrField['type'] == 'special') { switch ($arrField['special_type']) { case 'access_firstname': $firstname = trim($arrFormData['data'][$fieldId]); break; case 'access_lastname': $lastname = trim($arrFormData['data'][$fieldId]); break; default: break; } } } } if ($arrFormData['useEmailOfSender'] == 1 && (!empty($firstname) || !empty($lastname))) { $senderName = trim($firstname . ' ' . $lastname); } else { $senderName = $_CONFIG['coreGlobalPageTitle']; } // a recipient mail address which has been picked by sender $chosenMailRecipient = null; // fill the html and plaintext body with the submitted form data foreach ($arrFormData['fields'] as $fieldId => $arrField) { if ($fieldId == 'unique_id') { //generated for uploader. no interesting mail content. continue; } $htmlValue = ''; $plaintextValue = ''; $textAreaKeys = array(); switch ($arrField['type']) { case 'label': case 'fieldset': // TODO: parse TH row instead // TODO: parse TH row instead case 'horizontalLine': // TODO: add visual horizontal line // we need to use a 'continue 2' here to first break out of the switch and then move over to the next iteration of the foreach loop continue 2; break; case 'file': case 'multi_file': $htmlValue = ""; $plaintextValue = ""; if (isset($arrFormData['uploadedFiles'][$fieldId])) { $htmlValue = "<ul>"; foreach ($arrFormData['uploadedFiles'][$fieldId] as $file) { $htmlValue .= "<li><a href='" . ASCMS_PROTOCOL . "://" . $_CONFIG['domainUrl'] . \Env::get('cx')->getWebsiteOffsetPath() . contrexx_raw2xhtml($file['path']) . "' >" . contrexx_raw2xhtml($file['name']) . "</a></li>"; $plaintextValue .= ASCMS_PROTOCOL . "://" . $_CONFIG['domainUrl'] . \Env::get('cx')->getWebsiteOffsetPath() . $file['path'] . "\r\n"; } $htmlValue .= "</ul>"; } break; case 'checkbox': $plaintextValue = !empty($arrFormData['data'][$fieldId]) ? $_ARRAYLANG['TXT_CONTACT_YES'] : $_ARRAYLANG['TXT_CONTACT_NO']; $htmlValue = $plaintextValue; break; case 'recipient': // TODO: check for XSS $plaintextValue = $arrRecipients[$arrFormData['data'][$fieldId]]['lang'][FRONTEND_LANG_ID]; $htmlValue = $plaintextValue; $chosenMailRecipient = $arrRecipients[$arrFormData['data'][$fieldId]]['email']; break; case 'textarea': //we need to know all textareas - they're indented differently then the rest of the other field types $textAreaKeys[] = $fieldId; default: $plaintextValue = isset($arrFormData['data'][$fieldId]) ? $arrFormData['data'][$fieldId] : ''; $htmlValue = contrexx_raw2xhtml($plaintextValue); break; } $fieldLabel = $arrField['lang'][FRONTEND_LANG_ID]['name']; // try to fetch an e-mail address from submitted form date in case we were unable to fetch one from an input type with e-mail validation if (empty($replyAddress)) { $mail = $this->_getEmailAdressOfString($plaintextValue); if (\FWValidator::isEmail($mail)) { $replyAddress = $mail; } } // parse html body if ($isHtml) { if (!empty($htmlValue)) { if ($objTemplate->blockExists('field_' . $fieldId)) { // parse field specific template block $objTemplate->setVariable(array('FIELD_' . $fieldId . '_LABEL' => contrexx_raw2xhtml($fieldLabel), 'FIELD_' . $fieldId . '_VALUE' => $htmlValue)); $objTemplate->parse('field_' . $fieldId); } elseif ($objTemplate->blockExists('form_field')) { // parse regular field template block $objTemplate->setVariable(array('FIELD_LABEL' => contrexx_raw2xhtml($fieldLabel), 'FIELD_VALUE' => $htmlValue)); $objTemplate->parse('form_field'); } } elseif ($objTemplate->blockExists('field_' . $fieldId)) { // hide field specific template block, if present $objTemplate->hideBlock('field_' . $fieldId); } } // parse plaintext body $tabCount = $maxlength - strlen($fieldLabel); $tabs = $tabCount == 0 ? 1 : $tabCount + 1; // TODO: what is this all about? - $value is undefined if ($arrFormData['fields'][$fieldId]['type'] == 'recipient') { $value = $arrRecipients[$value]['lang'][FRONTEND_LANG_ID]; } if (in_array($fieldId, $textAreaKeys)) { // we're dealing with a textarea, don't indent value $plaintextBody .= $fieldLabel . ":\n" . $plaintextValue . "\n"; } else { $plaintextBody .= $fieldLabel . str_repeat(" ", $tabs) . ": " . $plaintextValue . "\n"; } } $arrSettings = $this->getSettings(); // TODO: this is some fixed plaintext message data -> must be ported to html body $message = $_ARRAYLANG['TXT_CONTACT_TRANSFERED_DATA_FROM'] . " " . $_CONFIG['domainUrl'] . "\n\n"; if ($arrSettings['fieldMetaDate']) { $message .= $_ARRAYLANG['TXT_CONTACT_DATE'] . " " . date(ASCMS_DATE_FORMAT, $arrFormData['meta']['time']) . "\n\n"; } $message .= $plaintextBody . "\n\n"; if ($arrSettings['fieldMetaHost']) { $message .= $_ARRAYLANG['TXT_CONTACT_HOSTNAME'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['host']) . "\n"; } if ($arrSettings['fieldMetaIP']) { $message .= $_ARRAYLANG['TXT_CONTACT_IP_ADDRESS'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['ipaddress']) . "\n"; } if ($arrSettings['fieldMetaLang']) { $message .= $_ARRAYLANG['TXT_CONTACT_BROWSER_LANGUAGE'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['lang']) . "\n"; } $message .= $_ARRAYLANG['TXT_CONTACT_BROWSER_VERSION'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['browser']) . "\n"; if (@(include_once \Env::get('cx')->getCodeBaseLibraryPath() . '/phpmailer/class.phpmailer.php')) { $objMail = new \phpmailer(); if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once \Env::get('cx')->getCodeBaseCorePath() . '/SmtpSettings.class.php')) { if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) { $objMail->IsSMTP(); $objMail->Host = $arrSmtp['hostname']; $objMail->Port = $arrSmtp['port']; $objMail->SMTPAuth = true; $objMail->Username = $arrSmtp['username']; $objMail->Password = $arrSmtp['password']; } } $objMail->CharSet = CONTREXX_CHARSET; $objMail->From = $_CONFIG['coreAdminEmail']; $objMail->FromName = $senderName; if (!empty($replyAddress)) { $objMail->AddReplyTo($replyAddress); if ($arrFormData['sendCopy'] == 1) { $objMail->AddAddress($replyAddress); } if ($arrFormData['useEmailOfSender'] == 1) { $objMail->From = $replyAddress; } } $objMail->Subject = $arrFormData['subject']; if ($isHtml) { $objMail->Body = $objTemplate->get(); $objMail->AltBody = $message; } else { $objMail->IsHTML(false); $objMail->Body = $message; } // attach submitted files to email if (count($arrFormData['uploadedFiles']) > 0 && $arrFormData['sendAttachment'] == 1) { foreach ($arrFormData['uploadedFiles'] as $arrFilesOfField) { foreach ($arrFilesOfField as $file) { $objMail->AddAttachment(\Env::get('cx')->getWebsiteDocumentRootPath() . $file['path'], $file['name']); } } } if ($chosenMailRecipient !== null) { if (!empty($chosenMailRecipient)) { $objMail->AddAddress($chosenMailRecipient); $objMail->Send(); $objMail->ClearAddresses(); } } else { foreach ($arrFormData['emails'] as $sendTo) { if (!empty($sendTo)) { $objMail->AddAddress($sendTo); $objMail->Send(); $objMail->ClearAddresses(); } } } } return true; }
/** * send a mail to the email with the message * * @static * @param integer $uploadId the upload id * @param string $subject the subject of the mail for the recipient * @param string $email the recipient's mail address * @param null|string $message the message for the recipient */ public static function sendMail($uploadId, $subject, $emails, $message = null) { global $objDatabase, $_CONFIG; /** * get all file ids from the last upload */ $objResult = $objDatabase->Execute("SELECT `id` FROM " . DBPREFIX . "module_filesharing WHERE `upload_id` = '" . intval($uploadId) . "'"); if ($objResult !== false && $objResult->RecordCount() > 0) { while (!$objResult->EOF) { $files[] = $objResult->fields["id"]; $objResult->MoveNext(); } } if (!is_int($uploadId) && empty($files)) { $files[] = $uploadId; } /** * init mail data. Mail template, Mailsubject and PhpMailer */ $objMail = $objDatabase->SelectLimit("SELECT `subject`, `content` FROM " . DBPREFIX . "module_filesharing_mail_template WHERE `lang_id` = " . FRONTEND_LANG_ID, 1, -1); $content = str_replace(array(']]', '[['), array('}', '{'), $objMail->fields["content"]); if (empty($subject)) { $subject = $objMail->fields["subject"]; } $cx = \Cx\Core\Core\Controller\Cx::instanciate(); if (\Env::get('ClassLoader')->loadFile($cx->getCodeBaseLibraryPath() . '/phpmailer/class.phpmailer.php')) { $objMail = new \phpmailer(); /** * Load mail template and parse it */ $objTemplate = new \Cx\Core\Html\Sigma('.'); $objTemplate->setErrorHandling(PEAR_ERROR_DIE); $objTemplate->setTemplate($content); $objTemplate->setVariable(array("DOMAIN" => $_CONFIG["domainUrl"], 'MESSAGE' => $message)); if ($objTemplate->blockExists('filesharing_file')) { foreach ($files as $file) { $objTemplate->setVariable(array('FILE_DOWNLOAD' => self::getDownloadLink($file))); $objTemplate->parse('filesharing_file'); } } if ($_CONFIG['coreSmtpServer'] > 0 && \Env::get('ClassLoader')->loadFile($cx->getCodeBaseCorePath() . '/SmtpSettings.class.php')) { if (($arrSmtp = SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) { $objMail->IsSMTP(); $objMail->Host = $arrSmtp['hostname']; $objMail->Port = $arrSmtp['port']; $objMail->SMTPAuth = true; $objMail->Username = $arrSmtp['username']; $objMail->Password = $arrSmtp['password']; } } $objMail->CharSet = CONTREXX_CHARSET; $objMail->SetFrom($_CONFIG['coreAdminEmail'], $_CONFIG['coreGlobalPageTitle']); $objMail->Subject = $subject; $objMail->Body = $objTemplate->get(); foreach ($emails as $email) { $objMail->AddAddress($email); $objMail->Send(); $objMail->ClearAddresses(); } } }
/** * Sets up the JavsScript cart * * Searches all $themesPages elements for the first occurrence of the * "shopJsCart" template block. * Generates the structure of the Javascript cart, puts it in the template, * and registers all required JS code. * Note that this is only ever called when the JS cart is enabled in the * extended settings! * @access public * @global array $_ARRAYLANG Language array * @global array $themesPages Theme template array * @return void * @static */ static function setJsCart() { global $_ARRAYLANG, $themesPages; if (!\Cx\Core\Setting\Controller\Setting::getValue('use_js_cart', 'Shop')) { return; } $objTemplate = new \Cx\Core\Html\Sigma('.'); $objTemplate->setErrorHandling(PEAR_ERROR_DIE); $match = null; $div_cart = $div_product = ''; foreach ($themesPages as $index => $content) { //\DBG::log("Shop::setJsCart(): Section $index"); $objTemplate->setTemplate($content, false, false); if (!$objTemplate->blockExists('shopJsCart')) { continue; } //\DBG::log("Shop::setJsCart(): In themespage $index: {$themesPages[$index]}"); $objTemplate->setCurrentBlock('shopJsCart'); // Set all language entries and replace formats $objTemplate->setGlobalVariable($_ARRAYLANG); if ($objTemplate->blockExists('shopJsCartProducts')) { $objTemplate->parse('shopJsCartProducts'); $div_product = $objTemplate->get('shopJsCartProducts'); //\DBG::log("Shop::setJsCart(): Got Product: $div_product"); $objTemplate->replaceBlock('shopJsCartProducts', '[[SHOP_JS_CART_PRODUCTS]]'); } $objTemplate->touchBlock('shopJsCart'); $objTemplate->parse('shopJsCart'); $div_cart = $objTemplate->get('shopJsCart'); //\DBG::log("Shop::setJsCart(): Got Cart: $div_cart"); if (preg_match('#^([\\n\\r]?[^<]*<.*id=["\']shopJsCart["\'][^>]*>)(([\\n\\r].*)*)(</[^>]*>[^<]*[\\n\\r]?)$#', $div_cart, $match)) { //\DBG::log("Shop::setJsCart(): Matched DIV {$match[1]}, content: {$match[2]}"); $themesPages[$index] = preg_replace('@(<!--\\s*BEGIN\\s+(shopJsCart)\\s*-->.*?<!--\\s*END\\s+\\2\\s*-->)@s', $match[1] . $_ARRAYLANG['TXT_SHOP_CART_IS_LOADING'] . $match[4], $content); /* // Template use won't work, because it kills the remaining <!-- blocks -->! $objTemplate->setTemplate($content, false, false); $objTemplate->replaceBlock('shopJsCart', $match[1]. $_ARRAYLANG['TXT_SHOP_CART_IS_LOADING']. $match[4]); $themesPages[$index] = $objTemplate->get(); */ //\DBG::log("Shop::setJsCart(): Out themespage $index: {$themesPages[$index]}"); } // One instance only (mind that there's a unique id attribute) self::$use_js_cart = true; break; } if (!self::$use_js_cart) { return; } self::registerJavascriptCode(); \ContrexxJavascript::getInstance()->setVariable('TXT_SHOP_CART_IS_LOADING', $_ARRAYLANG['TXT_SHOP_CART_IS_LOADING'], 'shop/cart'); \ContrexxJavascript::getInstance()->setVariable('TXT_SHOP_COULD_NOT_LOAD_CART', $_ARRAYLANG['TXT_SHOP_COULD_NOT_LOAD_CART'], 'shop/cart'); \ContrexxJavascript::getInstance()->setVariable('TXT_EMPTY_SHOPPING_CART', $_ARRAYLANG['TXT_EMPTY_SHOPPING_CART'], 'shop/cart'); \ContrexxJavascript::getInstance()->setVariable("url", (string) \Cx\Core\Routing\URL::fromModuleAndCMd('Shop' . MODULE_INDEX, 'cart', FRONTEND_LANG_ID, array('remoteJs' => 'addProduct')), 'shop/cart'); \JS::registerJS(substr(\Cx\Core\Core\Controller\Cx::instanciate()->getModuleFolderName() . '/Shop/View/Script/cart.js', 1)); \JS::registerCode("cartTpl = '" . preg_replace(array('/\'/', '/[\\n\\r]/', '/\\//'), array('\\\'', '\\n', '\\/'), $div_cart) . "';\n" . "cartProductsTpl = '" . preg_replace(array('/\'/', '/[\\n\\r]/', '/\\//'), array('\\\'', '\\n', '\\/'), $div_product) . "';\n"); }
private static function loadTemplate($template) { $objTemplate = new \Cx\Core\Html\Sigma(ASCMS_THEMES_PATH); $objTemplate->setErrorHandling(PEAR_ERROR_DIE); $objTemplate->setTemplate($template[0]); self::parseLoggedInOutBlocks($objTemplate); return $objTemplate->get(); }
/** * This should only be executed when updating from version 2.2.6 or older * Fix for the following tickets: * http://bugs.contrexx.com/contrexx/ticket/1412 * http://bugs.contrexx.com/contrexx/ticket/1043 * @see http://helpdesk.comvation.com/131276-Die-Navigation-meiner-Seite-wird-nicht-mehr-korrekt-angezeigt * * Adds placeholder {LEVELS_FULL} to all non-empty subnavbars * Adds placeholder {LEVELS_BRANCH} to all navbars having a block named 'navigation' but none 'level_1' */ function _updateNavigations() { global $objDatabase, $_CORELANG; $navbars = array('navbar', 'navbar2', 'navbar3'); $subnavbars = array('subnavbar', 'subnavbar2', 'subnavbar3'); // Find all themes $result = $objDatabase->Execute('SELECT `themesname`, `foldername` FROM `' . DBPREFIX . 'skins`'); if ($result->EOF) { \DBG::msg('No themes, really?'); return false; } // Update navigations for all themes $errorMessages = ''; while (!$result->EOF) { if (!is_dir(ASCMS_THEMES_PATH . '/' . $result->fields['foldername'])) { \DBG::msg('Skipping theme "' . $result->fields['themesname'] . '"; No such folder!'); $errorMessages .= '<div class="message-warning">' . sprintf($_CORELANG['TXT_CSS_UPDATE_MISSING_FOLDER'], $result->fields['themesname']) . '</div>'; $result->moveNext(); continue; } \DBG::msg('Updating navigations for theme "' . $result->fields['themesname'] . '" (' . $type . ')'); // add {LEVELS_FULL} to all non-empty subnavbars foreach ($subnavbars as $subnavbar) { try { $objFile = new \Cx\Lib\FileSystem\File(ASCMS_THEMES_PATH . '/' . $result->fields['foldername'] . '/' . $subnavbar . '.html'); $content = $objFile->getData(); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::msg($e->getMessage()); continue; } if (trim($content) == '') { continue; } $content = '{LEVELS_FULL}' . "\r\n" . $content; try { $objFile->write($content); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::msg($e->getMessage()); continue; } \DBG::msg('Updated file ' . $subnavbar . '.html for theme ' . $result->fields['themesname']); } // add {LEVELS_BRANCH} to all navbars matching the following criterias: // 1. blockExists('navigation') // 2. !blockExists('level_1') foreach ($navbars as $navbar) { try { $objFile = new \Cx\Lib\FileSystem\File(ASCMS_THEMES_PATH . '/' . $result->fields['foldername'] . '/' . $navbar . '.html'); $content = $objFile->getData(); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::msg($e->getMessage()); continue; } if (trim($content) == '') { continue; } $template = new \Cx\Core\Html\Sigma('.'); $template->setTemplate($content); if (!$template->blockExists('navigation')) { continue; } if ($template->blockExists('level_1')) { continue; } $content = '{LEVELS_BRANCH}' . "\r\n" . $content; try { $objFile->write($content); } catch (\Cx\Lib\FileSystem\FileSystemException $e) { \DBG::msg($e->getMessage()); continue; } \DBG::msg('Updated file ' . $navbar . '.html for theme ' . $result->fields['themesname']); } $result->moveNext(); } if (!empty($errorMessages)) { setUpdateMsg($errorMessages, 'msg'); setUpdateMsg('<input type="submit" value="' . $_CORELANG['TXT_CONTINUE_UPDATE'] . '" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" />', 'button'); $_SESSION['contrexx_update']['update']['done'][] = 'navigations'; return false; } return true; }
public function getReplacedMessageText($message) { $msgTemplate = new \Cx\Core\Html\Sigma(); $msgTemplate->setTemplate($message->getText()); $this->setLicensePlaceholders($msgTemplate); return $msgTemplate->get(); }
/** * Sets placeholders for the form view. * * @param object $objTpl Template object * @param integer $formId Form id * @param integer $intView request mode frontend or backend * @param integer $arrNumSeating number of seating * * @return null */ function showForm($objTpl, $formId, $intView, $ticketSales = false) { global $_ARRAYLANG, $_LANGID; $objForm = new \Cx\Modules\Calendar\Controller\CalendarForm(intval($formId)); if (!empty($formId)) { $this->formList[$formId] = $objForm; } switch ($intView) { case 1: $this->getFrontendLanguages(); $objTpl->setGlobalVariable(array($this->moduleLangVar . '_FORM_ID' => !empty($formId) ? $objForm->id : '', $this->moduleLangVar . '_FORM_TITLE' => !empty($formId) ? $objForm->title : '')); $i = 0; $formFields = array(); if (!empty($formId)) { $defaultLangId = $_LANGID; if (!in_array($defaultLangId, \FWLanguage::getIdArray())) { $defaultLangId = \FWLanguage::getDefaultLangId(); } foreach ($objForm->inputfields as $key => $arrInputfield) { $i++; $fieldValue = array(); $defaultFieldValue = array(); foreach ($this->arrFrontendLanguages as $key => $arrLang) { $fieldValue[$arrLang['id']] = isset($arrInputfield['name'][$arrLang['id']]) ? $arrInputfield['name'][$arrLang['id']] : ''; $defaultFieldValue[$arrLang['id']] = isset($arrInputfield['default_value'][$arrLang['id']]) ? $arrInputfield['default_value'][$arrLang['id']] : ''; } $formFields[] = array('type' => $arrInputfield['type'], 'id' => $arrInputfield['id'], 'row' => $i % 2 == 0 ? 'row2' : 'row1', 'order' => $arrInputfield['order'], 'name_master' => $fieldValue[$defaultLangId], 'default_value_master' => $defaultFieldValue[$defaultLangId], 'required' => $arrInputfield['required'], 'affiliation' => $arrInputfield['affiliation'], 'field_value' => json_encode($fieldValue), 'default_field_value' => json_encode($defaultFieldValue)); } } foreach ($this->arrFrontendLanguages as $key => $arrLang) { $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_LANG_ID' => $arrLang['id'], $this->moduleLangVar . '_INPUTFIELD_LANG_NAME' => $arrLang['name'], $this->moduleLangVar . '_INPUTFIELD_LANG_SHORTCUT' => $arrLang['lang'])); $objTpl->parse('inputfieldNameList'); $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_LANG_ID' => $arrLang['id'], $this->moduleLangVar . '_INPUTFIELD_LANG_NAME' => $arrLang['name'], $this->moduleLangVar . '_INPUTFIELD_LANG_SHORTCUT' => $arrLang['lang'])); $objTpl->parse('inputfieldDefaultValueList'); $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_LANG_NAME' => $arrLang['name'])); $objTpl->parse('inputfieldLanguagesList'); } foreach ($this->arrInputfieldTypes as $fieldType) { $objTpl->setVariable(array($this->moduleLangVar . '_FORM_FIELD_TYPE' => $fieldType, 'TXT_' . $this->moduleLangVar . '_FORM_FIELD_TYPE' => $_ARRAYLANG['TXT_CALENDAR_FORM_FIELD_' . strtoupper($fieldType)])); $objTpl->parse('inputfieldTypes'); } foreach ($this->arrRegistrationFields as $fieldType) { $objTpl->setVariable(array($this->moduleLangVar . '_FORM_FIELD_TYPE' => $fieldType, 'TXT_' . $this->moduleLangVar . '_FORM_FIELD_TYPE' => $_ARRAYLANG['TXT_CALENDAR_FORM_FIELD_' . strtoupper($fieldType)])); $objTpl->parse('inputRegfieldTypes'); } /* foreach ($this->arrInputfieldAffiliations as $strAffiliation) { $objTpl->setVariable(array( $this->moduleLangVar.'_FORM_FIELD_TYPE' => $strAffiliation, 'TXT_'.$this->moduleLangVar.'_FORM_FIELD_TYPE' => $_ARRAYLANG['TXT_CALENDAR_FORM_FIELD_AFFILIATION_'.strtoupper($strAffiliation)], )); $objTpl->parse('fieldAfflications'); }*/ $objTpl->setVariable(array($this->moduleLangVar . '_FORM_DATA' => json_encode($formFields), $this->moduleLangVar . '_FRONTEND_LANG_COUNT' => count($this->arrFrontendLanguages), $this->moduleLangVar . '_INPUTFIELD_LAST_ID' => $objForm->getLastInputfieldId(), $this->moduleLangVar . '_INPUTFIELD_LAST_ROW' => $i % 2 == 0 ? "'row2'" : "'row1'", $this->moduleLangVar . '_DISPLAY_EXPAND' => count($this->arrFrontendLanguages) > 1 ? "block" : "none")); break; case 2: $objFieldTemplate = new \Cx\Core\Html\Sigma('.'); $objFieldTemplate->setTemplate(self::frontendFieldTemplate, true, true); $objFieldTemplate->setVariable(array('TXT_' . $this->moduleLangVar . '_FIELD_NAME' => $_ARRAYLANG['TXT_CALENDAR_TYPE'] . '<font class="calendarRequired"> *</font>', $this->moduleLangVar . '_FIELD_INPUT' => '<select class="calendarSelect affiliateForm" name="registrationType"><option value="1" selected="selected"/>' . $_ARRAYLANG['TXT_CALENDAR_REG_REGISTRATION'] . '</option><option value="0"/>' . $_ARRAYLANG['TXT_CALENDAR_REG_SIGNOFF'] . '</option></select>', $this->moduleLangVar . '_FIELD_CLASS' => 'affiliationForm')); $objTpl->setVariable($this->moduleLangVar . '_REGISTRATION_FIELD', $objFieldTemplate->get()); $objTpl->parse('calendarRegistrationField'); // $selectBillingAddressStatus = false; foreach ($objForm->inputfields as $key => $arrInputfield) { $objFieldTemplate->setTemplate(self::frontendFieldTemplate, true, true); $options = array(); $options = explode(',', $arrInputfield['default_value'][$_LANGID]); $inputfield = null; $hide = false; $optionSelect = true; $availableSeat = 0; $checkSeating = false; if (isset($_POST['registrationField'][$arrInputfield['id']])) { $value = $_POST['registrationField'][$arrInputfield['id']]; } elseif (\FWUser::getFWUserObject()->objUser->login() && in_array($arrInputfield['type'], array('mail', 'firstname', 'lastname'))) { $value = ''; switch ($arrInputfield['type']) { case 'mail': $value = \FWUser::getFWUserObject()->objUser->getEmail(); break; case 'firstname': $value = \FWUser::getFWUserObject()->objUser->getProfileAttribute('firstname'); break; case 'lastname': $value = \FWUser::getFWUserObject()->objUser->getProfileAttribute('lastname'); break; default: $value = $arrInputfield['default_value'][$_LANGID]; break; } } else { $value = $arrInputfield['default_value'][$_LANGID]; } $affiliationClass = 'affiliation' . ucfirst($arrInputfield['affiliation']); switch ($arrInputfield['type']) { case 'inputtext': case 'mail': case 'firstname': case 'lastname': $inputfield = '<input type="text" class="calendarInputText" name="registrationField[' . $arrInputfield['id'] . ']" value="' . $value . '" /> '; break; case 'textarea': $inputfield = '<textarea class="calendarTextarea" name="registrationField[' . $arrInputfield['id'] . ']">' . $value . '</textarea>'; break; case 'seating': if (!$ticketSales) { $hide = true; } $optionSelect = false; if ($this->event) { $checkSeating = $this->event->registration && $this->event->numSubscriber; $availableSeat = $this->event->getFreePlaces(); } case 'select': case 'salutation': $inputfield = '<select class="calendarSelect" name="registrationField[' . $arrInputfield['id'] . ']">'; $selected = empty($_POST) ? 'selected="selected"' : ''; $inputfield .= $optionSelect ? '<option value="" ' . $selected . '>' . $_ARRAYLANG['TXT_CALENDAR_PLEASE_CHOOSE'] . '</option>' : ''; foreach ($options as $key => $name) { if ($checkSeating && contrexx_input2int($name) > $availableSeat) { continue; } $selected = $key + 1 == $value ? 'selected="selected"' : ''; $inputfield .= '<option value="' . intval($key + 1) . '" ' . $selected . '>' . $name . '</option>'; } $inputfield .= '</select>'; break; case 'radio': foreach ($options as $key => $name) { $checked = $key + 1 == $value || empty($_POST) && $key == 0 ? 'checked="checked"' : ''; $textValue = isset($_POST["registrationFieldAdditional"][$arrInputfield['id']][$key]) ? $_POST["registrationFieldAdditional"][$arrInputfield['id']][$key] : ''; $textfield = '<input type="text" class="calendarInputCheckboxAdditional" name="registrationFieldAdditional[' . $arrInputfield['id'] . '][' . $key . ']" value="' . contrexx_input2xhtml($textValue) . '" />'; $name = str_replace('[[INPUT]]', $textfield, $name); $inputfield .= '<input type="radio" class="calendarInputCheckbox" name="registrationField[' . $arrInputfield['id'] . ']" value="' . intval($key + 1) . '" ' . $checked . '/> ' . $name . '<br />'; } break; case 'checkbox': foreach ($options as $key => $name) { $textValue = isset($_POST["registrationFieldAdditional"][$arrInputfield['id']][$key]) ? $_POST["registrationFieldAdditional"][$arrInputfield['id']][$key] : ''; $textfield = '<input type="text" class="calendarInputCheckboxAdditional" name="registrationFieldAdditional[' . $arrInputfield['id'] . '][' . $key . ']" value="' . contrexx_input2xhtml($textValue) . '" />'; $name = str_replace('[[INPUT]]', $textfield, $name); $checked = in_array($key + 1, $_POST['registrationField'][$arrInputfield['id']]) ? 'checked="checked"' : ''; $inputfield .= '<input ' . $checked . ' type="checkbox" class="calendarInputCheckbox" name="registrationField[' . $arrInputfield['id'] . '][]" value="' . intval($key + 1) . '" /> ' . $name . '<br />'; } break; case 'agb': $inputfield = '<input class="calendarInputCheckbox" type="checkbox" name="registrationField[' . $arrInputfield['id'] . '][]" value="1" /> ' . $_ARRAYLANG['TXT_CALENDAR_AGB'] . '<br />'; break; /* case 'selectBillingAddress': if(!$selectBillingAddressStatus) { if($_REQUEST['registrationField'][$arrInputfield['id']] == 'deviatesFromContact') { $selectDeviatesFromContact = 'selected="selected"'; } else { $selectDeviatesFromContact = ''; } $inputfield = '<select id="calendarSelectBillingAddress" class="calendarSelect" name="registrationField['.$arrInputfield['id'].']">'; $inputfield .= '<option value="sameAsContact">'.$_ARRAYLANG['TXT_CALENDAR_SAME_AS_CONTACT'].'</option>'; $inputfield .= '<option value="deviatesFromContact" '.$selectDeviatesFromContact.'>'.$_ARRAYLANG['TXT_CALENDAR_DEVIATES_FROM_CONTACT'].'</option>'; $inputfield .= '</select>'; $selectBillingAddressStatus = true; } break; */ /* case 'selectBillingAddress': if(!$selectBillingAddressStatus) { if($_REQUEST['registrationField'][$arrInputfield['id']] == 'deviatesFromContact') { $selectDeviatesFromContact = 'selected="selected"'; } else { $selectDeviatesFromContact = ''; } $inputfield = '<select id="calendarSelectBillingAddress" class="calendarSelect" name="registrationField['.$arrInputfield['id'].']">'; $inputfield .= '<option value="sameAsContact">'.$_ARRAYLANG['TXT_CALENDAR_SAME_AS_CONTACT'].'</option>'; $inputfield .= '<option value="deviatesFromContact" '.$selectDeviatesFromContact.'>'.$_ARRAYLANG['TXT_CALENDAR_DEVIATES_FROM_CONTACT'].'</option>'; $inputfield .= '</select>'; $selectBillingAddressStatus = true; } break; */ case 'fieldset': $inputfield = null; break; } $field = ''; if ($arrInputfield['type'] == 'fieldset') { $field = '</fieldset><fieldset><legend>' . $arrInputfield['name'][$_LANGID] . '</legend>'; $hide = true; } else { $required = $arrInputfield['required'] == 1 ? '<font class="calendarRequired"> *</font>' : ''; $label = $arrInputfield['name'][$_LANGID] . $required; } if (!$hide) { $objFieldTemplate->setVariable(array('TXT_' . $this->moduleLangVar . '_FIELD_NAME' => $label, $this->moduleLangVar . '_FIELD_INPUT' => $inputfield, $this->moduleLangVar . '_FIELD_CLASS' => $affiliationClass)); $field = $objFieldTemplate->get(); } $objTpl->setVariable($this->moduleLangVar . '_REGISTRATION_FIELD', $field); $objTpl->parse('calendarRegistrationField'); } break; } }
/** * Do something after content is loaded from DB * * @param \Cx\Core\ContentManager\Model\Entity\Page $page The resolved page */ public function postContentLoad(\Cx\Core\ContentManager\Model\Entity\Page $page) { switch ($this->cx->getMode()) { case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND: // Show the Shop navbar in the Shop, or on every page if configured to do so if (!Shop::isInitialized()) { \Cx\Core\Setting\Controller\Setting::init('Shop', 'config'); if (\Cx\Core\Setting\Controller\Setting::getValue('shopnavbar_on_all_pages', 'Shop')) { Shop::init(); Shop::setNavbar(); } // replace global product blocks $page->setContent(preg_replace_callback('/<!--\\s+BEGIN\\s+(block_shop_products_category_(?:\\d+)\\s+-->).*<!--\\s+END\\s+\\1/s', function ($matches) { $blockTemplate = new \Cx\Core\Html\Sigma(); $blockTemplate->setTemplate($matches[0]); Shop::parse_products_blocks($blockTemplate); return $blockTemplate->get(); }, $page->getContent())); } break; } }