/** * @override */ public function getXHtml($backend = false) { global $objInit; $uploadPath = $this->getUploadPath('jump'); $tpl = new \Cx\Core\Html\Sigma(ASCMS_CORE_MODULE_PATH . '/Upload/template/uploaders'); $tpl->setErrorHandling(PEAR_ERROR_DIE); $tpl->loadTemplateFile('jump.html'); $basePath = 'index.php?'; $basePath .= $this->isBackendRequest ? 'cmd=Upload&act' : 'section=Upload&cmd'; //act and cmd vary $appletPath = $basePath . '=jumpUploaderApplet'; $l10nPath = $basePath . '=jumpUploaderL10n'; $langId; if (!$this->isBackendRequest) { $langId = $objInit->getFrontendLangId(); } else { //backend $langId = $objInit->getBackendLangId(); } $langCode = \FWLanguage::getLanguageCodeById($langId); if (!file_exists(ASCMS_CORE_MODULE_PATH . '/Upload/ressources/uploaders/jump/messages_' . $langCode . '.zip')) { $langCode = 'en'; } $l10nPath .= '&lang=' . $langCode; $tpl->setVariable('UPLOAD_CHUNK_LENGTH', \FWSystem::getMaxUploadFileSize() - 1000); $tpl->setVariable('UPLOAD_APPLET_URL', $appletPath); $tpl->setVariable('UPLOAD_LANG_URL', $l10nPath); $tpl->setVariable('UPLOAD_URL', $uploadPath); $tpl->setVariable('UPLOAD_ID', $this->uploadId); return $tpl->get(); }
private function __construct() { global $objInit; $backOrFrontend = $objInit->mode; global $objFWUser; $langId; if ($backOrFrontend == "frontend") { $langId = $objInit->getFrontendLangId(); } else { //backend $langId = $objInit->getBackendLangId(); } $langCode = FWLanguage::getLanguageCodeById($langId); $this->setVariable(array('path' => ASCMS_PATH_OFFSET . '/update/' . $langCode . '/', 'basePath' => ASCMS_PATH_OFFSET . '/update/', 'cadminPath' => ASCMS_PATH_OFFSET . ASCMS_BACKEND_PATH . '/', 'mode' => $objInit->mode, 'language' => $langCode), 'contrexx'); //let i18n set it's variables $i18n = new ContrexxJavascriptI18n($langCode); $i18n->variablesTo($this); //determine the correct jquery ui css' path. //the user might have overridden the default css in the theme, so look out for this too. $jQUiCssPath = 'themes/' . $objInit->getCurrentThemesPath() . '/jquery-ui.css'; //customized css would be here if ($objInit->mode != 'frontend' || !file_exists(ASCMS_DOCUMENT_ROOT . '/' . $jQUiCssPath)) { //use standard css $jQUiCssPath = 'lib/javascript/jquery/ui/css/jquery-ui.css'; } $this->setVariable(array('jQueryUiCss' => $jQUiCssPath), 'contrexx-ui'); }
public function __construct($langCode = null, $text = '', $type = 'alertbox', $link = '', $linkTarget = '_blank', $showInDashboard = true) { $this->langCode = $langCode ? $langCode : \FWLanguage::getLanguageCodeById(LANG_ID); $this->text = $text; $this->type = $type; $this->link = $link; $this->linkTarget = $linkTarget; $this->showInDashboard = $showInDashboard; }
/** * Override this to do your representation of the tree. * * @param string $title * @param int $level 0-based level of the element * @param boolean $hasChilds are there children of this element? if yes, they will be processed in the subsequent calls. * @param int $lang language id * @param string $path path to this element, e.g. '/CatA/CatB' * @param boolean $current if a $currentPage has been specified, this will be set to true if either a parent element of the current element or the current element itself is rendered. * * @return string your string representation of the element. */ protected function renderElement($title, $level, $hasChilds, $lang, $path, $current, $page) { $url = (string) \Cx\Core\Routing\NodePlaceholder::fromNode($page->getNode(), null, array()); $pages = $page->getNode()->getPages(); $titles = array(); foreach ($pages as $page) { $titles[\FWLanguage::getLanguageCodeById($page->getLang())] = $page->getTitle(); } $this->return[] = array('click' => "javascript:{setUrl('{$url}',null,null,'" . \FWLanguage::getLanguageCodeById(BACKEND_LANG_ID) . $path . "','page')}", 'name' => $titles, 'extension' => 'Html', 'level' => $level - 1, 'url' => $path, 'node' => $url); }
/** * Initialize the mail template array * * Uses the given language ID, if any, or the language set in the * LANG_ID global constant. * Upon success, stores the language ID used in the $lang_id class * variable. * @param integer $lang_id The optional language ID * @return boolean True on success, false otherwise */ static function init($lang_id = 0) { global $objDatabase; // The array has been initialized with that language already if (self::$lang_id === $lang_id) { return true; } // Reset the language ID used self::$lang_id = false; // Use the current language if none is specified if (empty($lang_id)) { $lang_id = FRONTEND_LANG_ID; } self::$arrTemplate = array(); $arrLanguages = FWLanguage::getLanguageArray(); foreach ($arrLanguages as $arrLanguage) { if ($arrLanguage['frontend'] && $arrLanguage['is_default'] == 'true') { $defaultLangId = $arrLanguage['id']; break; } } $objResult = $objDatabase->Execute("\n SELECT `mail`.`id`, `mail`.`tplname`, `mail`.`protected`\n FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_mail` AS `mail`"); if (!$objResult) { return false; } while (!$objResult->EOF) { $id = $objResult->fields['id']; self::$arrTemplate[$id] = array('id' => $id, 'name' => $objResult->fields['tplname'], 'protected' => $objResult->fields['protected'], 'available' => false); $objResult->MoveNext(); } $objResult = $objDatabase->Execute("\n SELECT `content`.`tpl_id`,\n `content`.`from_mail`, `content`.`xsender`,\n `content`.`subject`, `content`.`message`\n FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_mail_content` AS `content`\n ORDER BY FIELD(`content`.`lang_id`, {$defaultLangId}, {$lang_id}) DESC"); if (!$objResult) { return false; } while (!$objResult->EOF) { $id = $objResult->fields['tpl_id']; if (!self::$arrTemplate[$id]['available']) { self::$arrTemplate[$id]['available'] = true; self::$arrTemplate[$id]['from'] = $objResult->fields['from_mail']; self::$arrTemplate[$id]['sender'] = $objResult->fields['xsender']; self::$arrTemplate[$id]['subject'] = $objResult->fields['subject']; self::$arrTemplate[$id]['message'] = $objResult->fields['message']; } $objResult->MoveNext(); } // Remember the language used self::$lang_id = $lang_id; return true; }
/** * Loads the language config from the database * * This used to be in __construct but is also * called from core/language.class.php to reload * the config, so core/settings.class.php can * rewrite .htaccess (virtual lang dirs). */ static function init() { global $_CONFIG, $objDatabase; $objResult = $objDatabase->Execute("\n SELECT id, lang, name, charset, themesid,\n frontend, backend, is_default\n FROM " . DBPREFIX . "languages\n ORDER BY id ASC"); if ($objResult) { // setting full to true for update $full = true; while (!$objResult->EOF) { self::$arrLanguages[$objResult->fields['id']] = array('id' => $objResult->fields['id'], 'lang' => $objResult->fields['lang'], 'name' => $objResult->fields['name'], 'charset' => $objResult->fields['charset'], 'themesid' => $objResult->fields['themesid'], 'frontend' => $objResult->fields['frontend'], 'backend' => $objResult->fields['backend'], 'is_default' => $objResult->fields['is_default'], 'fallback' => ''); if (!$full && $objResult->fields['is_default'] != 'true') { self::$arrLanguages[$objResult->fields['id']]['frontend'] = 0; self::$arrLanguages[$objResult->fields['id']]['backend'] = 0; } if ($objResult->fields['is_default'] == 'true') { self::$defaultLangId = $objResult->fields['id']; } $objResult->MoveNext(); } } }
/** * Registers the JavaScript code for jQueryUi.Datepicker * * Also activates jQueryUi and tries to load the current language and use * that as the default. * Add element specific defaults and code in your method. */ static function addDatepickerJs() { static $language_code = null; // Only run once if ($language_code) { return; } JS::activate('jqueryui'); $language_code = FWLanguage::getLanguageCodeById(FRONTEND_LANG_ID); //DBG::log("Language ID ".FRONTEND_LANG_ID.", code $language_code"); // Must load timepicker as well, because the region file accesses it JS::registerJS('lib/javascript/jquery/ui/jquery-ui-timepicker-addon.js'); // TODO: Add more languages to the i18n folder! JS::registerJS('lib/javascript/jquery/ui/i18n/' . 'jquery.ui.datepicker-' . $language_code . '.js'); JS::registerCode(' cx.jQuery(function() { cx.jQuery.datepicker.setDefaults(cx.jQuery.datepicker.regional["' . $language_code . '"]); }); '); }
/** * Loads the language config from the database * * This used to be in __construct but is also * called from core/language.class.php to reload * the config, so core/settings.class.php can * rewrite .htaccess (virtual lang dirs). */ static function init() { global $_CONFIG, $objDatabase; $objResult = $objDatabase->Execute("\n SELECT id, lang, name, charset, themesid,\n frontend, backend, is_default, fallback\n FROM " . DBPREFIX . "languages\n ORDER BY id ASC"); if ($objResult) { $license = \Cx\Core_Modules\License\License::getCached($_CONFIG, $objDatabase); $license->check(); $full = $license->isInLegalComponents('fulllanguage'); while (!$objResult->EOF) { self::$arrLanguages[$objResult->fields['id']] = array('id' => $objResult->fields['id'], 'lang' => $objResult->fields['lang'], 'name' => $objResult->fields['name'], 'charset' => $objResult->fields['charset'], 'themesid' => $objResult->fields['themesid'], 'frontend' => $objResult->fields['frontend'], 'backend' => $objResult->fields['backend'], 'is_default' => $objResult->fields['is_default'], 'fallback' => $objResult->fields['fallback']); if (!$full && $objResult->fields['is_default'] != 'true') { self::$arrLanguages[$objResult->fields['id']]['frontend'] = 0; self::$arrLanguages[$objResult->fields['id']]['backend'] = 0; } if ($objResult->fields['is_default'] == 'true') { self::$defaultLangId = $objResult->fields['id']; } $objResult->MoveNext(); } } }
/** * get the email template lang id for sending mail * * @param Array $availableEmailTemp available email template ids * @param String $email recipient email id * * @return Integer */ function getEmailTempLang($availableEmailTemp = array(), $email = '') { $objFWUser = \FWUser::getFWUserObject(); if (empty($email)) { return false; } $defaultLangId = \FWLanguage::getDefaultLangId(); /** * This IF clause fixes #1799, but there has to be a better solution for this! */ if (!$objFWUser->objUser) { return false; } $objUsers = $objFWUser->objUser->getUsers($filter = array('email' => addslashes($email))); if ($objUsers) { $availableLangId = ''; switch (true) { case $objUsers->getBackendLanguage() && in_array($objUsers->getBackendLanguage(), $availableEmailTemp): $availableLangId = $objUsers->getBackendLanguage(); break; case $objUsers->getFrontendLanguage() && in_array($objUsers->getFrontendLanguage(), $availableEmailTemp): $availableLangId = $objUsers->getFrontendLanguage(); break; case $defaultLangId && in_array($defaultLangId, $availableEmailTemp): $availableLangId = $defaultLangId; break; default: $availableLangId = $availableEmailTemp[0]; break; } return $availableLangId; } else { switch (true) { case $defaultLangId && in_array($defaultLangId, $availableEmailTemp): $availableLangId = $defaultLangId; break; default: $availableLangId = $availableEmailTemp[0]; break; } return $availableLangId; } return false; }
/** * Handles database errors * * Also migrates old names to the new structure * @return boolean False. Always. * @static * @throws Cx\Lib\Update_DatabaseException */ static function errorHandler() { // Shipment static $break = false; if ($break) { die("\n Shipment::errorHandler(): Recursion detected while handling an error.<br /><br />\n This should not happen. We are very sorry for the inconvenience.<br />\n Please contact customer support: helpdesk@comvation.com"); } $break = true; //die("Shipment::errorHandler(): Disabled!<br />"); // Fix the Zones table first Zones::errorHandler(); $table_name = DBPREFIX . 'module_shop_shipper'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'ord' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'renamefrom' => 'status')); $table_index = array(); $default_lang_id = \FWLanguage::getDefaultLangId(); if (\Cx\Lib\UpdateUtil::table_exist($table_name)) { if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) { \Text::deleteByKey('Shop', self::TEXT_NAME); $query = "\n SELECT `id`, `name`\n FROM `{$table_name}`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if (!$objResult) { throw new \Cx\Lib\Update_DatabaseException("Failed to query names", $query); } while (!$objResult->EOF) { $id = $objResult->fields['id']; $name = $objResult->fields['name']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate name '{$name}'"); } $objResult->MoveNext(); } } } \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); $table_name = DBPREFIX . 'module_shop_shipment_cost'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'shipper_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'max_weight' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'fee' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'cost'), 'free_from' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'price_free')); $table_index = array(); \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); // Always! return false; }
/** * Handles database errors * * Also migrates text fields to the new structure * @return boolean False. Always. * @static * @throws Cx\Lib\Update_DatabaseException */ static function errorHandler() { // Product // Fix the Text, Discount, and Manufacturer tables first \Text::errorHandler(); // Discount::errorHandler(); // Called by Customer::errorHandler(); Manufacturer::errorHandler(); $table_name = DBPREFIX . 'module_shop_products'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'normalprice' => array('type' => 'DECIMAL(9,2)', 'default' => '0.00'), 'resellerprice' => array('type' => 'DECIMAL(9,2)', 'default' => '0.00'), 'discountprice' => array('type' => 'DECIMAL(9,2)', 'default' => '0.00'), 'discount_active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'is_special_offer'), 'stock' => array('type' => 'INT(10)', 'default' => '10'), 'stock_visible' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'stock_visibility'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'status'), 'b2b' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1'), 'b2c' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1'), 'date_start' => array('type' => 'TIMESTAMP', 'default' => '0000-00-00 00:00:00', 'renamefrom' => 'startdate'), 'date_end' => array('type' => 'TIMESTAMP', 'default' => '0000-00-00 00:00:00', 'renamefrom' => 'enddate'), 'weight' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'category_id' => array('type' => 'VARCHAR(255)', 'default' => '', 'renamefrom' => 'catid'), 'vat_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'manufacturer_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'manufacturer'), 'group_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'article_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'usergroup_ids' => array('type' => 'VARCHAR(4096)', 'notnull' => false, 'default' => null), 'ord' => array('type' => 'INT(10)', 'default' => '0', 'renamefrom' => 'sort_order'), 'distribution' => array('type' => 'VARCHAR(16)', 'default' => '', 'renamefrom' => 'handler'), 'picture' => array('type' => 'VARCHAR(4096)', 'notnull' => false, 'default' => null), 'flags' => array('type' => 'VARCHAR(4096)', 'notnull' => false, 'default' => null), 'minimum_order_quantity' => array('type' => 'INT(10)', 'unsigned' => false, 'default' => '0')); $table_index = array('group_id' => array('fields' => array('group_id')), 'article_id' => array('fields' => array('article_id')), 'flags' => array('fields' => array('flags'), 'type' => 'FULLTEXT')); $default_lang_id = \FWLanguage::getDefaultLangId(); if (\Cx\Lib\UpdateUtil::table_exist($table_name)) { if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'title')) { // Migrate all Product strings to the Text table first \Text::deleteByKey('Shop', self::TEXT_NAME); \Text::deleteByKey('Shop', self::TEXT_SHORT); \Text::deleteByKey('Shop', self::TEXT_LONG); \Text::deleteByKey('Shop', self::TEXT_CODE); \Text::deleteByKey('Shop', self::TEXT_URI); \Text::deleteByKey('Shop', self::TEXT_KEYS); $query = "\n SELECT `id`, `title`, `shortdesc`, `description`,\n `product_id`, `external_link`, `keywords`\n FROM `{$table_name}`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if (!$objResult) { throw new \Cx\Lib\Update_DatabaseException("Failed to query Product strings", $query); } while (!$objResult->EOF) { $id = $objResult->fields['id']; $name = $objResult->fields['title']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product name '{$name}'"); } $short = $objResult->fields['shortdesc']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_SHORT, $short)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product short '{$short}'"); } $long = $objResult->fields['description']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_LONG, $long)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product long '{$long}'"); } $code = $objResult->fields['product_id']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_CODE, $code)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product code '{$code}'"); } $uri = $objResult->fields['external_link']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_URI, $uri)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product uri '{$uri}'"); } $keys = $objResult->fields['keywords']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_KEYS, $keys)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Product keys '{$keys}'"); } $objResult->MoveNext(); } } } \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); // Also fix Customer and some related tables Customer::errorHandler(); // Always return false; }
public function setLangDir($langDir, $page = null) { $this->langDir = $langDir; if ($page) { $langId = \FWLanguage::getLanguageIdByCode($langDir); $page = $page->getNode()->getPage($langId); if ($page) { $this->setPath(substr($page->getPath(), 1)); } } }
public function getCode($tabIndex = null) { $tabIndexAttr = ''; if (isset($tabIndex)) { $tabIndexAttr = "tabindex=\"{$tabIndex}\""; } $widget = <<<HTML <div id="recaptcha_widget" style="display:none"> <div id="recaptcha_image"></div> <div class="recaptcha_only_if_incorrect_sol" style="color:red">Incorrect please try again</div> <span class="recaptcha_only_if_image">Enter the words above:</span> <span class="recaptcha_only_if_audio">Enter the numbers you hear:</span> <input type="text" id="recaptcha_response_field" name="recaptcha_response_field" {$tabIndexAttr} /> <div> <div> <a title="Get a new challenge" href="javascript:Recaptcha.reload()" id="recaptcha_reload_btn"> <img src="http://www.google.com/recaptcha/api/img/clean/refresh.png" id="recaptcha_reload" alt="Get a new challenge" height="18" width="25"> </a> </div> <div class="recaptcha_only_if_image"> <a title="Get an audio challenge" href="javascript:Recaptcha.switch_type('audio');" id="recaptcha_switch_audio_btn" class="recaptcha_only_if_image"> <img src="http://www.google.com/recaptcha/api/img/clean/audio.png" id="recaptcha_switch_audio" alt="Get an audio challenge" height="15" width="25"> </a> </div> <div class="recaptcha_only_if_audio"> <a title="Get a visual challenge" href="javascript:Recaptcha.switch_type('image');" id="recaptcha_switch_img_btn" class="recaptcha_only_if_audio"> <img src="http://www.google.com/recaptcha/api/img/clean/text.png" id="recaptcha_switch_img" alt="Get a visual challenge" height="15" width="25"> </a> </div> <div> <a href="javascript:Recaptcha.showhelp()"title="Help" target="_blank" id="recaptcha_whatsthis_btn"> <img alt="Help" src="http://www.google.com/recaptcha/api/img/clean/help.png" id="recaptcha_whatsthis" height="16" width="25"> </a> </div> </div> </div> <script type="text/javascript" src= "http://www.google.com/recaptcha/api/challenge?k=%1\$s"></script> <noscript> <iframe src="http://www.google.com/recaptcha/api/noscript?k=%1\$s" height="300" width="500" frameborder="0"></iframe><br /> <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea> <input type="hidden" name="recaptcha_response_field" value="manual_challenge"> </noscript> HTML; $lang = \FWLanguage::getLanguageCodeById(FRONTEND_LANG_ID); //\JS::registerCode("var RecaptchaOptions = { lang : '$lang', theme : 'clean' }"); \JS::registerCode("var RecaptchaOptions = { lang : '{$lang}', theme : 'custom', custom_theme_widget: 'recaptcha_widget' }"); //\JS::registerCSS("lib/reCAPTCHA/recaptcha.widget.clean.css"); $code = sprintf($widget, $this->public_key); //$code = recaptcha_get_html($this->public_key, $this->error); return $code; }
/** * Generates a list of pages pointing to $page * @param \Cx\Core\ContentManager\Model\Entity\Page $page Page to get referencing pages for * @param array $subPages (optional, by reference) Do not use, internal * @return array List of pages (ID as key, page object as value) */ protected function getPagesPointingTo($page, &$subPages = array()) { $cx = \Cx\Core\Core\Controller\Cx::instanciate(); $em = $cx->getDb()->getEntityManager(); $pageRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page'); $fallback_lang_codes = \FWLanguage::getFallbackLanguageArray(); $active_langs = \FWLanguage::getActiveFrontendLanguages(); // get all active languages and their fallbacks // $fallbacks[<langId>] = <fallsBackToLangId> // if <langId> has no fallback <fallsBackToLangId> will be null $fallbacks = array(); foreach ($active_langs as $lang) { $fallbacks[\FWLanguage::getLanguageCodeById($lang['id'])] = array_key_exists($lang['id'], $fallback_lang_codes) ? \FWLanguage::getLanguageCodeById($fallback_lang_codes[$lang['id']]) : null; } // get all symlinks and fallbacks to it $query = ' SELECT p FROM Cx\\Core\\ContentManager\\Model\\Entity\\Page p WHERE ( p.type = ?1 AND ( p.target LIKE ?2'; if ($page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION) { $query .= ' OR p.target LIKE ?3'; } $query .= ' ) ) OR ( p.type = ?4 AND p.node = ' . $page->getNode()->getId() . ' ) '; $q = $em->createQuery($query); $q->setParameter(1, 'symlink'); $q->setParameter('2', '%NODE_' . $page->getNode()->getId() . '%'); if ($page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION) { $q->setParameter('3', '%NODE_' . strtoupper($page->getModule()) . '%'); } $q->setParameter(4, 'fallback'); $result = $q->getResult(); if (!$result) { return $subPages; } foreach ($result as $subPage) { if ($subPage->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_SYMLINK) { $subPages[$subPage->getId()] = $subPage; } else { if ($subPage->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_FALLBACK) { // check if $subPage is a fallback to $page $targetLang = \FWLanguage::getLanguageCodeById($page->getLang()); $currentLang = \FWLanguage::getLanguageCodeById($subPage->getLang()); while ($currentLang && $currentLang != $targetLang) { $currentLang = $fallbacks[$currentLang]; } if ($currentLang && !isset($subPages[$subPage->getId()])) { $subPages[$subPage->getId()] = $subPage; // recurse! $this->getPagesPointingTo($subPage, $subPages); } } } } return $subPages; }
/** * Handles database errors * * Also migrates old ProductAttribute to new Attribute structures, * including Text records. * @return boolean false Always! * @throws Cx\Lib\Update_DatabaseException */ static function errorHandler() { // Attribute $default_lang_id = \FWLanguage::getDefaultLangId(); $table_name_old = DBPREFIX . 'module_shop_products_attributes_name'; $table_name_new = DBPREFIX . 'module_shop_attribute'; if (\Cx\Lib\UpdateUtil::table_exist($table_name_new)) { \Cx\Lib\UpdateUtil::drop_table($table_name_old); } else { $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'type' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'display_type')); $table_index = array(); if (\Cx\Lib\UpdateUtil::table_exist($table_name_old)) { if (\Cx\Lib\UpdateUtil::column_exist($table_name_old, 'name')) { // Migrate all Product strings to the Text table first \Text::deleteByKey('Shop', self::TEXT_ATTRIBUTE_NAME); $query = "\n SELECT `id`, `name`\n FROM `{$table_name_old}`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if (!$objResult) { throw new \Cx\Lib\Update_DatabaseException("Failed to to query Attribute names", $query); } while (!$objResult->EOF) { $id = $objResult->fields['id']; $name = $objResult->fields['name']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_ATTRIBUTE_NAME, $name)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Attribute name '{$name}'"); } $objResult->MoveNext(); } } } //DBG::activate(DBG_ADODB); \Cx\Lib\UpdateUtil::table($table_name_old, $table_structure, $table_index); if (!\Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new)) { throw new \Cx\Lib\Update_DatabaseException("Failed to rename Attribute table"); } } $table_name_old = DBPREFIX . 'module_shop_products_attributes_value'; $table_name_new = DBPREFIX . 'module_shop_option'; if (\Cx\Lib\UpdateUtil::table_exist($table_name_new)) { \Cx\Lib\UpdateUtil::drop_table($table_name_old); } else { $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'attribute_id' => array('type' => 'INT(10)', 'unsigned' => true, 'renamefrom' => 'name_id'), 'price' => array('type' => 'DECIMAL(9,2)', 'default' => '0.00')); $table_index = array(); if (\Cx\Lib\UpdateUtil::table_exist($table_name_old)) { if (\Cx\Lib\UpdateUtil::column_exist($table_name_old, 'value')) { // Migrate all Product strings to the Text table first \Text::deleteByKey('Shop', self::TEXT_OPTION_NAME); $query = "\n SELECT `id`, `value`\n FROM `{$table_name_old}`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if (!$objResult) { throw new \Cx\Lib\Update_DatabaseException("Failed to to query option names", $query); } while (!$objResult->EOF) { $id = $objResult->fields['id']; $name = $objResult->fields['value']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_OPTION_NAME, $name)) { throw new \Cx\Lib\Update_DatabaseException("Failed to to migrate option Text '{$name}'"); } $objResult->MoveNext(); } } } \Cx\Lib\UpdateUtil::table($table_name_old, $table_structure, $table_index); if (!\Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new)) { throw new \Cx\Lib\Update_DatabaseException("Failed to rename Option table"); } } $table_name_old = DBPREFIX . 'module_shop_products_attributes'; $table_name_new = DBPREFIX . 'module_shop_rel_product_attribute'; if (\Cx\Lib\UpdateUtil::table_exist($table_name_new)) { \Cx\Lib\UpdateUtil::drop_table($table_name_old); } else { $table_structure = array('product_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true), 'option_id' => array('type' => 'INT(10)', 'unsigned' => true, 'primary' => true, 'renamefrom' => 'attributes_value_id'), 'ord' => array('type' => 'INT(10)', 'default' => '0', 'renamefrom' => 'sort_id')); $table_index = array(); \Cx\Lib\UpdateUtil::table($table_name_old, $table_structure, $table_index); if (!\Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new)) { throw new \Cx\Lib\Update_DatabaseException("Failed to rename Product-Attribute relation table {$table_name_old} to {$table_name_new}"); } } // Always return false; }
/** * Sets the placeholders used for the event list view * * @param object $objTpl Template object * @param integer $type Event type * * @return null */ function showEventList($objTpl, $type = '') { global $objInit, $_ARRAYLANG, $_LANGID; parent::getFrontendLanguages(); //if($objInit->mode == 'backend') { $i = 0; foreach ($this->eventList as $key => $objEvent) { $objCategory = new \Cx\Modules\Calendar\Controller\CalendarCategory(intval($objEvent->catId)); $showIn = explode(",", $objEvent->showIn); $languages = ''; if (count(\FWLanguage::getActiveFrontendLanguages()) > 1) { $langState = array(); foreach ($this->arrFrontendLanguages as $langKey => $arrLang) { if (in_array($arrLang['id'], $showIn)) { $langState[$langKey] = 'active'; } } $languages = \Html::getLanguageIcons($langState, 'index.php?cmd=Calendar&act=modify_event&id=' . $objEvent->id . '&langId=%1$d' . ($type == 'confirm' ? "&confirm=1" : "")); if ($type == 'confirm' && $objTpl->blockExists('txt_languages_block_confirm_list')) { $objTpl->touchBlock('txt_languages_block_confirm_list'); } elseif ($objTpl->blockExists('txt_languages_block')) { $objTpl->touchBlock('txt_languages_block'); } } else { if ($type == 'confirm' && $objTpl->blockExists('txt_languages_block_confirm_list')) { $objTpl->hideBlock('txt_languages_block_confirm_list'); } elseif ($objTpl->blockExists('txt_languages_block')) { $objTpl->hideBlock('txt_languages_block'); } } list($priority, $priorityImg) = $this->getPriorityImage($objEvent); $plainDescription = contrexx_html2plaintext($objEvent->description); if (strlen($plainDescription) > 100) { $points = '...'; } else { $points = ''; } $parts = explode("\n", wordwrap($plainDescription, 100, "\n")); $attachNamePos = strrpos($objEvent->attach, '/'); $attachNamelength = strlen($objEvent->attach); $attachName = substr($objEvent->attach, $attachNamePos + 1, $attachNamelength); if ($objEvent->external) { $objHost = new \Cx\Modules\Calendar\Controller\CalendarHost($objEvent->hostId); if (substr($objHost->uri, -1) != '/') { $hostUri = $objHost->uri . '/'; } else { $hostUri = $objHost->uri; } if (substr($hostUri, 0, 7) != 'http://') { $hostUri = "http://" . $hostUri; } } $copyLink = ''; if ($objInit->mode == 'backend') { $editLink = 'index.php?cmd=' . $this->moduleName . '&act=modify_event&id=' . $objEvent->id . ($type == 'confirm' ? "&confirm=1" : ""); $copyLink = $editLink . "&copy=1"; } else { $editLink = CONTREXX_DIRECTORY_INDEX . '?section=' . $this->moduleName . '&cmd=edit&id=' . $objEvent->id; } $picThumb = file_exists(\Env::get('cx')->getWebsitePath() . "{$objEvent->pic}.thumb") ? "{$objEvent->pic}.thumb" : ($objEvent->pic != '' ? $objEvent->pic : ''); $placeLink = $objEvent->place_link != '' ? "<a href='" . $objEvent->place_link . "' target='_blank' >" . $objEvent->place_link . "</a>" : ""; $placeLinkSource = $objEvent->place_link; if ($this->arrSettings['placeData'] > 1 && $objEvent->locationType == 2) { $objEvent->loadPlaceFromMediadir($objEvent->place_mediadir_id, 'place'); list($placeLink, $placeLinkSource) = $objEvent->loadPlaceLinkFromMediadir($objEvent->place_mediadir_id, 'place'); } $hostLink = $objEvent->org_link != '' ? "<a href='" . $objEvent->org_link . "' target='_blank' >" . $objEvent->org_link . "</a>" : ""; $hostLinkSource = $objEvent->org_link; if ($this->arrSettings['placeDataHost'] > 1 && $objEvent->hostType == 2) { $objEvent->loadPlaceFromMediadir($objEvent->host_mediadir_id, 'host'); list($hostLink, $hostLinkSource) = $objEvent->loadPlaceLinkFromMediadir($objEvent->host_mediadir_id, 'host'); } $objTpl->setVariable(array($this->moduleLangVar . '_EVENT_ROW' => $i % 2 == 0 ? 'row1' : 'row2', $this->moduleLangVar . '_EVENT_LED' => $objEvent->status == 0 ? 'red' : 'green', $this->moduleLangVar . '_EVENT_STATUS' => $objEvent->status == 0 ? $_ARRAYLANG['TXT_CALENDAR_INACTIVE'] : $_ARRAYLANG['TXT_CALENDAR_ACTIVE'], $this->moduleLangVar . '_EVENT_ID' => $objEvent->id, $this->moduleLangVar . '_EVENT_TITLE' => $objEvent->title, $this->moduleLangVar . '_EVENT_PICTURE' => $objEvent->pic != '' ? '<img src="' . $objEvent->pic . '" alt="' . $objEvent->title . '" title="' . $objEvent->title . '" />' : '', $this->moduleLangVar . '_EVENT_PICTURE_SOURCE' => $objEvent->pic, $this->moduleLangVar . '_EVENT_THUMBNAIL' => $objEvent->pic != '' ? '<img src="' . $picThumb . '" alt="' . $objEvent->title . '" title="' . $objEvent->title . '" />' : '', $this->moduleLangVar . '_EVENT_PRIORITY' => $priority, $this->moduleLangVar . '_EVENT_PRIORITY_IMG' => $priorityImg, $this->moduleLangVar . '_EVENT_PLACE' => $objEvent->place, $this->moduleLangVar . '_EVENT_DESCRIPTION' => $objEvent->description, $this->moduleLangVar . '_EVENT_SHORT_DESCRIPTION' => $parts[0] . $points, $this->moduleLangVar . '_EVENT_LINK' => $objEvent->link ? "<a href='" . $objEvent->link . "' target='_blank' >" . $objEvent->link . "</a>" : "", $this->moduleLangVar . '_EVENT_LINK_SOURCE' => $objEvent->link, $this->moduleLangVar . '_EVENT_ATTACHMENT' => $objEvent->attach != '' ? '<a href="' . $hostUri . $objEvent->attach . '" target="_blank" >' . $attachName . '</a>' : '', $this->moduleLangVar . '_EVENT_ATTACHMENT_SOURCE' => $objEvent->attach, $this->moduleLangVar . '_EVENT_START' => date(parent::getDateFormat() . " H:i", $objEvent->startDate), $this->moduleLangVar . '_EVENT_END' => date(parent::getDateFormat() . " H:i", $objEvent->endDate), $this->moduleLangVar . '_EVENT_DATE' => date(parent::getDateFormat(), $objEvent->startDate), $this->moduleLangVar . '_EVENT_START_DATE' => date(parent::getDateFormat(), $objEvent->startDate), $this->moduleLangVar . '_EVENT_START_TIME' => date("H:i", $objEvent->startDate), $this->moduleLangVar . '_EVENT_END_DATE' => date(parent::getDateFormat(), $objEvent->endDate), $this->moduleLangVar . '_EVENT_END_TIME' => date("H:i", $objEvent->endDate), $this->moduleLangVar . '_EVENT_LANGUAGES' => $languages, $this->moduleLangVar . '_EVENT_CATEGORY' => $objCategory->name, $this->moduleLangVar . '_EVENT_DETAIL_LINK' => $objEvent->type == 0 ? self::_getDetailLink($objEvent) : $objEvent->arrData['redirect'][$_LANGID], $this->moduleLangVar . '_EVENT_EDIT_LINK' => $editLink, $this->moduleLangVar . '_EVENT_COPY_LINK' => $copyLink, $this->moduleLangVar . '_EVENT_DETAIL_TARGET' => $objEvent->type == 0 ? '_self' : '_blank', $this->moduleLangVar . '_EVENT_SERIES' => $objEvent->seriesStatus == 1 ? '<img src="' . ASCMS_MODULE_WEB_PATH . '/' . $this->moduleName . '/View/Media/Repeat.png" border="0"/>' : '<i>' . $_ARRAYLANG['TXT_CALENDAR_NO_SERIES'] . '</i>', $this->moduleLangVar . '_EVENT_FREE_PLACES' => $objEvent->freePlaces, $this->moduleLangVar . '_EVENT_ACCESS' => $_ARRAYLANG['TXT_CALENDAR_EVENT_ACCESS_' . $objEvent->access])); $hasPlaceMap = !empty($objEvent->place_map) && file_exists(\Env::get('cx')->getWebsitePath() . $objEvent->place_map); if ($hasPlaceMap) { $arrInfo = getimagesize(\Env::get('cx')->getWebsitePath() . $objEvent->place_map); $picWidth = $arrInfo[0] + 20; $picHeight = $arrInfo[1] + 20; } $map_thumb_name = file_exists(\Env::get('cx')->getWebsitePath() . $objEvent->place_map . ".thumb") ? $objEvent->place_map . ".thumb" : $objEvent->place_map; $objTpl->setVariable(array($this->moduleLangVar . '_EVENT_LOCATION_PLACE' => $objEvent->place, $this->moduleLangVar . '_EVENT_LOCATION_ADDRESS' => $objEvent->place_street, $this->moduleLangVar . '_EVENT_LOCATION_ZIP' => $objEvent->place_zip, $this->moduleLangVar . '_EVENT_LOCATION_CITY' => $objEvent->place_city, $this->moduleLangVar . '_EVENT_LOCATION_COUNTRY' => $objEvent->place_country, $this->moduleLangVar . '_EVENT_LOCATION_LINK' => $placeLink, $this->moduleLangVar . '_EVENT_LOCATION_LINK_SOURCE' => $placeLinkSource, $this->moduleLangVar . '_EVENT_LOCATION_MAP_LINK' => $hasPlaceMap ? '<a href="' . $objEvent->place_map . '" onClick="window.open(this.href,\'\',\'resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,width=' . $picWidth . ',height=' . $picHeight . ',status\'); return false">' . $_ARRAYLANG['TXT_CALENDAR_MAP'] . '</a>' : "", $this->moduleLangVar . '_EVENT_LOCATION_MAP_THUMBNAIL' => $hasPlaceMap ? '<a href="' . $objEvent->place_map . '" onClick="window.open(this.href,\'\',\'resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,width=' . $picWidth . ',height=' . $picHeight . ',status\'); return false"><img src="' . $map_thumb_name . '" border="0" alt="' . $objEvent->place_map . '" /></a>' : "", $this->moduleLangVar . '_EVENT_LOCATION_MAP_SOURCE' => $hasPlaceMap ? $objEvent->place_map : '', $this->moduleLangVar . '_EVENT_HOST' => $objEvent->org_name, $this->moduleLangVar . '_EVENT_HOST_ADDRESS' => $objEvent->org_street, $this->moduleLangVar . '_EVENT_HOST_ZIP' => $objEvent->org_zip, $this->moduleLangVar . '_EVENT_HOST_CITY' => $objEvent->org_city, $this->moduleLangVar . '_EVENT_HOST_COUNTRY' => $objEvent->org_country, $this->moduleLangVar . '_EVENT_HOST_LINK' => $hostLink, $this->moduleLangVar . '_EVENT_HOST_LINK_SOURCE' => $hostLinkSource, $this->moduleLangVar . '_EVENT_HOST_EMAIL' => $objEvent->org_email != '' ? "<a href='mailto:" . $objEvent->org_email . "' >" . $objEvent->org_email . "</a>" : "", $this->moduleLangVar . '_EVENT_HOST_EMAIL_SOURCE' => $objEvent->org_email)); if ($objInit->mode == 'backend') { $objTpl->setVariable(array($this->moduleLangVar . '_EVENT_COUNT_REG' => $objEvent->registrationCount, $this->moduleLangVar . '_EVENT_COUNT_DEREG' => $objEvent->cancellationCount, $this->moduleLangVar . '_EVENT_COUNT_WAITLIST' => $objEvent->waitlistCount)); } $i++; // show date block if ($objTpl->blockExists('calendarDateList')) { $showStartDateList = $objEvent->useCustomDateDisplay ? $objEvent->showStartDateList : $this->arrSettings['showStartDateList'] == 1; $showEndDateList = $objEvent->useCustomDateDisplay ? $objEvent->showEndDateList : $this->arrSettings['showEndDateList'] == 1; $showStartTimeList = $objEvent->all_day ? false : ($objEvent->useCustomDateDisplay ? $objEvent->showStartTimeList : $this->arrSettings['showStartTimeList'] == 1); $showEndTimeList = $objEvent->all_day ? false : ($objEvent->useCustomDateDisplay ? $objEvent->showEndTimeList : $this->arrSettings['showEndTimeList'] == 1); $showTimeTypeList = $objEvent->useCustomDateDisplay ? $objEvent->showTimeTypeList : 1; // get date for several days format > show starttime with startdate and endtime with enddate > only if several days event and all values (dates/times) are displayed if (date(parent::getDateFormat(), $objEvent->startDate) != date(parent::getDateFormat(), $objEvent->endDate) && ($showStartDateList && $showEndDateList && $showStartTimeList && $showEndTimeList)) { //part 1 $part = 1; $this->getMultiDateBlock($objEvent, $this->arrSettings['separatorDateTimeList'], $this->arrSettings['separatorSeveralDaysList'], $this->arrSettings['showClockList'] == 1, $part); $objTpl->setVariable(array($this->moduleLangVar . '_DATE_LIST' => $this->date, $this->moduleLangVar . '_SEP_DATE_TIME_LIST' => $this->sepDateTime, $this->moduleLangVar . '_TIME_LIST' => $this->time, 'TXT_' . $this->moduleLangVar . '_CLOCK_LIST' => $this->clock)); $objTpl->parse('calendarDateList'); //part 2 $part = 2; $this->getMultiDateBlock($objEvent, $this->arrSettings['separatorDateTimeList'], $this->arrSettings['separatorSeveralDaysList'], $this->arrSettings['showClockList'] == 1, $part); $objTpl->setVariable(array($this->moduleLangVar . '_DATE_LIST' => $this->date, $this->moduleLangVar . '_SEP_DATE_TIME_LIST' => $this->sepDateTime, $this->moduleLangVar . '_TIME_LIST' => $this->time, 'TXT_' . $this->moduleLangVar . '_CLOCK_LIST' => $this->clock)); $objTpl->parse('calendarDateList'); } else { // get date for single day format $this->getSingleDateBlock($objEvent, $showStartDateList, $showEndDateList, $this->arrSettings['separatorDateList'], $showTimeTypeList, $showStartTimeList, $showEndTimeList, $this->arrSettings['separatorDateTimeList'], $this->arrSettings['separatorTimeList'], $this->arrSettings['showClockList'] == 1); $objTpl->setVariable(array($this->moduleLangVar . '_DATE_LIST' => $this->date, $this->moduleLangVar . '_SEP_DATE_TIME_LIST' => $this->sepDateTime, $this->moduleLangVar . '_TIME_LIST' => $this->time, 'TXT_' . $this->moduleLangVar . '_CLOCK_LIST' => $this->clock)); $objTpl->parse('calendarDateList'); } } if ($type == 'confirm') { if ($objTpl->blockExists('eventConfirmList')) { $objTpl->parse('eventConfirmList'); } } else { if ($objTpl->blockExists('eventList')) { $objTpl->parse('eventList'); } if ($objTpl->blockExists('calendar_headlines_row')) { $objTpl->parse('calendar_headlines_row'); } } } if (count($this->eventList) == 0 && $type != 'confirm') { $objTpl->hideBlock('eventList'); $objTpl->setVariable(array('TXT_' . $this->moduleLangVar . '_NO_EVENTS' => $_ARRAYLANG['TXT_CALENDAR_EVENTS_NO'])); $objTpl->parse('emptyEventList'); } //} }
/** * Show feed page * @todo Add proper docblock * @global array * @global integer * @return string Template output */ private function _showFeed() { global $_ARRAYLANG, $_LANGID; $serverPort = $_SERVER['SERVER_PORT'] == 80 ? '' : ':' . intval($_SERVER['SERVER_PORT']); $rssFeedUrl = 'http://' . $_SERVER['SERVER_NAME'] . $serverPort . ASCMS_PATH_OFFSET . '/feed/news_headlines_' . \FWLanguage::getLanguageParameter($_LANGID, 'lang') . '.xml'; $jsFeedUrl = 'http://' . $_SERVER['SERVER_NAME'] . $serverPort . ASCMS_PATH_OFFSET . '/feed/news_' . \FWLanguage::getLanguageParameter($_LANGID, 'lang') . '.js'; $hostname = addslashes(htmlspecialchars($_SERVER['SERVER_NAME'], ENT_QUOTES, CONTREXX_CHARSET)); $rss2jsCode = <<<RSS2JSCODE <script language="JavaScript" type="text/javascript"> <!-- // {$_ARRAYLANG['TXT_NEWS_OPTIONAL_VARS']} var rssFeedFontColor = '#000000'; // {$_ARRAYLANG['TXT_NEWS_FONT_COLOR']} var rssFeedFontSize = 8; // {$_ARRAYLANG['TXT_NEWS_FONT_SIZE']} var rssFeedFont = 'Arial, Verdana'; // {$_ARRAYLANG['TXT_NEWS_FONT']} var rssFeedLimit = 10; // {$_ARRAYLANG['TXT_NEWS_DISPLAY_LIMIT']} var rssFeedShowDate = true; // {$_ARRAYLANG['TXT_NEWS_SHOW_NEWS_DATE']} var rssFeedTarget = '_blank'; // _blank | _parent | _self | _top var rssFeedContainer = 'news_rss_feeds'; // --> </script> <script type="text/javascript" language="JavaScript" src="{$jsFeedUrl}"></script> <noscript> <a href="{$rssFeedUrl}">{$hostname} - {$_ARRAYLANG['TXT_NEWS_SHOW_NEWS']}</a> </noscript> <div id="news_rss_feeds"> </div> RSS2JSCODE; $this->_objTpl->setVariable(array('NEWS_HOSTNAME' => $hostname, 'NEWS_RSS2JS_CODE' => $rss2jsCode, 'NEWS_RSS2JS_URL' => $jsFeedUrl, 'NEWS_RSS_FEED_URL' => $rssFeedUrl)); return $this->_objTpl->get(); }
/** * 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()); }
/** * Add / Edit Event * * @param integer $eventId Event id * * @return null */ function modifyEvent($eventId = null) { global $_ARRAYLANG, $_CORELANG, $_LANGID; \JS::activate('cx'); \JS::activate('jqueryui'); \JS::registerJS('modules/Calendar/View/Script/Frontend.js'); $this->getFrontendLanguages(); $this->getSettings(); $this->_objTpl->setTemplate($this->pageContent, true, true); $showFrom = true; $objEvent = new \Cx\Modules\Calendar\Controller\CalendarEvent(); $isEventLoaded = false; if (isset($_POST['submitFormModifyEvent'])) { $arrData = array(); $arrData = $_POST; $arrData['access'] = 0; $arrData['priority'] = 3; if ($objEvent->save($arrData)) { $showFrom = false; $this->_objTpl->hideBlock('calendarEventModifyForm'); $this->_objTpl->touchBlock('calendarEventOkMessage'); // refresh event data after save $objEvent->get($eventId); $objEvent->getData(); $isEventLoaded = true; $objMailManager = new \Cx\Modules\Calendar\Controller\CalendarMailManager(); $objMailManager->sendMail($objEvent, \Cx\Modules\Calendar\Controller\CalendarMailManager::MAIL_NOTFY_NEW_APP); } else { $this->_objTpl->touchBlock('calendarEventErrMessage'); } } if ($eventId && !$isEventLoaded) { $objEvent->get($eventId); $objEvent->getData(); } $dateFormat = $this->getDateFormat(1); $locationType = $this->arrSettings['placeData'] == 3 ? $eventId != 0 ? $objEvent->locationType : 1 : $this->arrSettings['placeData']; $hostType = $this->arrSettings['placeDataHost'] == 3 ? $eventId != 0 ? $objEvent->hostType : 1 : $this->arrSettings['placeDataHost']; \ContrexxJavascript::getInstance()->setVariable(array('language_id' => \FWLanguage::getDefaultLangId(), 'active_lang' => implode(',', \FWLanguage::getIdArray())), 'calendar'); $javascript = <<<EOF <script language="JavaScript" type="text/javascript"> var defaultLang = cx.variables.get('language_id', 'calendar'); var activeLang = [cx.variables.get('active_lang', 'calendar')]; cx.ready(function() { var options = { dateFormat: '{$dateFormat}', timeFormat: 'hh:mm', showSecond: false, onSelect: function(dateText, inst){ var startDate = cx.jQuery( ".startDate" ).datetimepicker("getDate"); var endDate = cx.jQuery( ".endDate" ).datetimepicker("getDate"); if ( cx.jQuery( this )[0].id == 'startDate' ) { var prevStartDate = cx.jQuery( ".startDate" ).data('prevDate'); if (cx.jQuery(".all_day").is(':checked')) { prevStartDate.setHours(0, 0, 0); startDate.setHours(0, 0, 0); endDate.setHours(0, 0, 0); } if (prevStartDate.getTime() != startDate.getTime()) { var timeDiff = Math.abs(endDate.getTime() - prevStartDate.getTime()); endDate = new Date(startDate.getTime() + timeDiff); cx.jQuery( ".endDate" ).datetimepicker('setDate', endDate); } } else if (startDate.getTime() > endDate.getTime()) { endDate = new Date(startDate.getTime() + (30*60*1000)); cx.jQuery(".endDate").datetimepicker('setDate', endDate); } cx.jQuery( ".startDate" ).data('prevDate', cx.jQuery(".startDate").datetimepicker("getDate")); cx.jQuery( ".endDate" ).data('prevDate', cx.jQuery(".endDate").datetimepicker("getDate")); cx.jQuery( this ).datetimepicker('refresh'); } }; cx.jQuery('input[name=startDate]') .datetimepicker(options) .data('prevDate', cx.jQuery(".startDate").datetimepicker("getDate")); cx.jQuery('input[name=endDate]') .datetimepicker(options) .data('prevDate', cx.jQuery(".endDate").datetimepicker("getDate")); if ( \$J(".all_day").is(':checked') ) { modifyEvent._handleAllDayEvent( \$J(".all_day") ); } showOrHidePlaceFields('{$locationType}', 'place'); showOrHidePlaceFields('{$hostType}', 'host'); }); </script> EOF; if ($showFrom) { try { $javascript .= <<<UPLOADER {$this->getUploaderCode(self::PICTURE_FIELD_KEY, 'pictureUpload')} {$this->getUploaderCode(self::MAP_FIELD_KEY, 'mapUpload')} {$this->getUploaderCode(self::ATTACHMENT_FIELD_KEY, 'attachmentUpload', 'uploadFinished', false)} UPLOADER; } catch (Exception $e) { \DBG::msg("Error in initializing uploader"); } } $this->_objTpl->setGlobalVariable(array($this->moduleLangVar . '_EVENT_LANG_ID' => $_LANGID, $this->moduleLangVar . '_JAVASCRIPT' => $javascript)); $objCategoryManager = new \Cx\Modules\Calendar\Controller\CalendarCategoryManager(true); $objCategoryManager->getCategoryList(); if ($eventId) { $startDate = $objEvent->startDate; $endDate = $objEvent->endDate; } else { $startDate = new \DateTime(); $endDate = new \DateTime(); } $eventStartDate = $this->format2userDateTime($startDate); $eventEndDate = $this->format2userDateTime($endDate); $this->_objTpl->setGlobalVariable(array('TXT_' . $this->moduleLangVar . '_EVENT' => $_ARRAYLANG['TXT_CALENDAR_EVENT'], 'TXT_' . $this->moduleLangVar . '_EVENT_DETAILS' => $_ARRAYLANG['TXT_CALENDAR_EVENT_DETAILS'], 'TXT_' . $this->moduleLangVar . '_SAVE' => $_ARRAYLANG['TXT_CALENDAR_SAVE'], 'TXT_' . $this->moduleLangVar . '_EVENT_START' => $_ARRAYLANG['TXT_CALENDAR_START'], 'TXT_' . $this->moduleLangVar . '_EVENT_END' => $_ARRAYLANG['TXT_CALENDAR_END'], 'TXT_' . $this->moduleLangVar . '_EVENT_TITLE' => $_ARRAYLANG['TXT_CALENDAR_TITLE'], 'TXT_' . $this->moduleLangVar . '_EXPAND' => $_ARRAYLANG['TXT_CALENDAR_EXPAND'], 'TXT_' . $this->moduleLangVar . '_MINIMIZE' => $_ARRAYLANG['TXT_CALENDAR_MINIMIZE'], 'TXT_' . $this->moduleLangVar . '_EVENT_PLACE' => $_ARRAYLANG['TXT_CALENDAR_EVENT_PLACE'], 'TXT_' . $this->moduleLangVar . '_EVENT_STREET' => $_ARRAYLANG['TXT_CALENDAR_EVENT_STREET'], 'TXT_' . $this->moduleLangVar . '_EVENT_ZIP' => $_ARRAYLANG['TXT_CALENDAR_EVENT_ZIP'], 'TXT_' . $this->moduleLangVar . '_EVENT_CITY' => $_ARRAYLANG['TXT_CALENDAR_EVENT_CITY'], 'TXT_' . $this->moduleLangVar . '_EVENT_COUNTRY' => $_ARRAYLANG['TXT_CALENDAR_EVENT_COUNTRY'], 'TXT_' . $this->moduleLangVar . '_EVENT_WEBSITE' => $_ARRAYLANG['TXT_CALENDAR_EVENT_WEBSITE'], 'TXT_' . $this->moduleLangVar . '_EVENT_PHONE' => $_ARRAYLANG['TXT_CALENDAR_EVENT_PHONE'], 'TXT_' . $this->moduleLangVar . '_EVENT_MAP' => $_ARRAYLANG['TXT_CALENDAR_EVENT_MAP'], 'TXT_' . $this->moduleLangVar . '_EVENT_USE_GOOGLEMAPS' => $_ARRAYLANG['TXT_CALENDAR_EVENT_USE_GOOGLEMAPS'], 'TXT_' . $this->moduleLangVar . '_EVENT_LINK' => $_ARRAYLANG['TXT_CALENDAR_EVENT_LINK'], 'TXT_' . $this->moduleLangVar . '_EVENT_EMAIL' => $_ARRAYLANG['TXT_CALENDAR_EVENT_EMAIL'], 'TXT_' . $this->moduleLangVar . '_EVENT_PICTURE' => $_ARRAYLANG['TXT_CALENDAR_EVENT_PICTURE'], 'TXT_' . $this->moduleLangVar . '_EVENT_ATTACHMENT' => $_ARRAYLANG['TXT_CALENDAR_EVENT_ATTACHMENT'], 'TXT_' . $this->moduleLangVar . '_EVENT_CATEGORY' => $_ARRAYLANG['TXT_CALENDAR_CAT'], 'TXT_' . $this->moduleLangVar . '_EVENT_DESCRIPTION' => $_ARRAYLANG['TXT_CALENDAR_EVENT_DESCRIPTION'], 'TXT_' . $this->moduleLangVar . '_PLEASE_CHECK_INPUT' => $_ARRAYLANG['TXT_CALENDAR_PLEASE_CHECK_INPUT'], 'TXT_' . $this->moduleLangVar . '_EVENT_HOST' => $_ARRAYLANG['TXT_CALENDAR_EVENT_HOST'], 'TXT_' . $this->moduleLangVar . '_EVENT_NAME' => $_ARRAYLANG['TXT_CALENDAR_EVENT_NAME'], 'TXT_' . $this->moduleLangVar . '_EVENT_ALL_DAY' => $_ARRAYLANG['TXT_CALENDAR_EVENT_ALL_DAY'], 'TXT_' . $this->moduleLangVar . '_LANGUAGE' => $_ARRAYLANG['TXT_CALENDAR_LANG'], 'TXT_' . $this->moduleLangVar . '_EVENT_TYPE' => $_ARRAYLANG['TXT_CALENDAR_EVENT_TYPE'], 'TXT_' . $this->moduleLangVar . '_EVENT_TYPE_EVENT' => $_ARRAYLANG['TXT_CALENDAR_EVENT_TYPE_EVENT'], 'TXT_' . $this->moduleLangVar . '_EVENT_TYPE_REDIRECT' => $_ARRAYLANG['TXT_CALENDAR_EVENT_TYPE_REDIRECT'], 'TXT_' . $this->moduleLangVar . '_EVENT_DESCRIPTION' => $_ARRAYLANG['TXT_CALENDAR_EVENT_DESCRIPTION'], 'TXT_' . $this->moduleLangVar . '_EVENT_REDIRECT' => $_ARRAYLANG['TXT_CALENDAR_EVENT_TYPE_REDIRECT'], 'TXT_' . $this->moduleLangVar . '_PLACE_DATA_DEFAULT' => $_ARRAYLANG['TXT_CALENDAR_PLACE_DATA_DEFAULT'], 'TXT_' . $this->moduleLangVar . '_PLACE_DATA_FROM_MEDIADIR' => $_ARRAYLANG['TXT_CALENDAR_PLACE_DATA_FROM_MEDIADIR'], 'TXT_' . $this->moduleLangVar . '_PREV' => $_ARRAYLANG['TXT_CALENDAR_PREV'], 'TXT_' . $this->moduleLangVar . '_NEXT' => $_ARRAYLANG['TXT_CALENDAR_NEXT'], 'TXT_' . $this->moduleLangVar . '_MORE' => $_ARRAYLANG['TXT_CALENDAR_MORE'], 'TXT_' . $this->moduleLangVar . '_MINIMIZE' => $_ARRAYLANG['TXT_CALENDAR_MINIMIZE'], $this->moduleLangVar . '_EVENT_TYPE_EVENT' => $eventId != 0 ? $objEvent->type == 0 ? 'selected="selected"' : '' : '', $this->moduleLangVar . '_EVENT_TYPE_REDIRECT' => $eventId != 0 ? $objEvent->type == 1 ? 'selected="selected"' : '' : '', $this->moduleLangVar . '_EVENT_START_DATE' => $eventStartDate, $this->moduleLangVar . '_EVENT_END_DATE' => $eventEndDate, $this->moduleLangVar . '_EVENT_PICTURE' => $objEvent->pic, $this->moduleLangVar . '_EVENT_PICTURE_THUMB' => $objEvent->pic != '' ? '<img src="' . $objEvent->pic . '.thumb" alt="' . $objEvent->title . '" title="' . $objEvent->title . '" />' : '', $this->moduleLangVar . '_EVENT_ATTACHMENT' => $objEvent->attach, $this->moduleLangVar . '_EVENT_CATEGORIES' => $objCategoryManager->getCategoryDropdown(intval($objEvent->catId), 2), $this->moduleLangVar . '_EVENT_LINK' => $objEvent->link, $this->moduleLangVar . '_EVENT_PLACE' => $objEvent->place, $this->moduleLangVar . '_EVENT_STREET' => $objEvent->place_street, $this->moduleLangVar . '_EVENT_ZIP' => $objEvent->place_zip, $this->moduleLangVar . '_EVENT_CITY' => $objEvent->place_city, $this->moduleLangVar . '_EVENT_COUNTRY' => $objEvent->place_country, $this->moduleLangVar . '_EVENT_PLACE_WEBSITE' => $objEvent->place_website, $this->moduleLangVar . '_EVENT_PLACE_MAP' => $objEvent->place_map, $this->moduleLangVar . '_EVENT_PLACE_LINK' => $objEvent->place_link, $this->moduleLangVar . '_EVENT_PLACE_PHONE' => $objEvent->place_phone, $this->moduleLangVar . '_EVENT_MAP' => $objEvent->google == 1 ? 'checked="checked"' : '', $this->moduleLangVar . '_EVENT_HOST' => $objEvent->org_name, $this->moduleLangVar . '_EVENT_HOST_ADDRESS' => $objEvent->org_street, $this->moduleLangVar . '_EVENT_HOST_ZIP' => $objEvent->org_zip, $this->moduleLangVar . '_EVENT_HOST_CITY' => $objEvent->org_city, $this->moduleLangVar . '_EVENT_HOST_COUNTRY' => $objEvent->org_country, $this->moduleLangVar . '_EVENT_HOST_WEBSITE' => $objEvent->org_website, $this->moduleLangVar . '_EVENT_HOST_LINK' => $objEvent->org_link, $this->moduleLangVar . '_EVENT_HOST_PHONE' => $objEvent->org_phone, $this->moduleLangVar . '_EVENT_HOST_EMAIL' => $objEvent->org_email, $this->moduleLangVar . '_EVENT_LOCATION_TYPE_MANUAL' => $eventId != 0 ? $objEvent->locationType == 1 ? "checked='checked'" : '' : "checked='checked'", $this->moduleLangVar . '_EVENT_LOCATION_TYPE_MEDIADIR' => $eventId != 0 ? $objEvent->locationType == 2 ? "checked='checked'" : '' : "", $this->moduleLangVar . '_EVENT_HOST_TYPE_MANUAL' => $eventId != 0 ? $objEvent->hostType == 1 ? "checked='checked'" : '' : "checked='checked'", $this->moduleLangVar . '_EVENT_HOST_TYPE_MEDIADIR' => $eventId != 0 ? $objEvent->hostType == 2 ? "checked='checked'" : '' : "", $this->moduleLangVar . '_EVENT_ID' => $eventId, $this->moduleLangVar . '_EVENT_ALL_DAY' => $eventId != 0 && $objEvent->all_day ? 'checked="checked"' : '', $this->moduleLangVar . '_HIDE_ON_SINGLE_LANG' => count($this->arrFrontendLanguages) == 1 ? "display: none;" : "")); $multiLingualFields = array('place', 'place_city', 'place_country', 'org_name', 'org_city', 'org_country'); $isOneActiveLanguage = count($this->arrFrontendLanguages) == 1; foreach ($multiLingualFields as $inputField) { if ($isOneActiveLanguage) { $this->_objTpl->hideBlock('calendar_event_' . $inputField . '_expand'); } else { $this->_objTpl->touchBlock('calendar_event_' . $inputField . '_expand'); } } foreach ($this->arrFrontendLanguages as $arrLang) { //parse globals $this->_objTpl->setGlobalVariable(array($this->moduleLangVar . '_EVENT_LANG_SHORTCUT' => $arrLang['lang'], $this->moduleLangVar . '_EVENT_LANG_ID' => $arrLang['id'], 'TXT_' . $this->moduleLangVar . '_EVENT_LANG_NAME' => $arrLang['name'])); //parse "show in" checkboxes $arrShowIn = explode(",", $objEvent->showIn); $langChecked = false; if ($eventId != 0) { $langChecked = in_array($arrLang['id'], $arrShowIn) ? true : false; } else { $langChecked = $arrLang['is_default'] == 'true'; } //parse eventTabMenuDescTab $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_TAB_DISPLAY' => $langChecked ? 'block' : 'none', $this->moduleLangVar . '_EVENT_TAB_CLASS' => '')); $this->_objTpl->parse('eventTabMenuDescTab'); //parse eventDescTab $eventTitle = !empty($objEvent->arrData['title'][$arrLang['id']]) ? $objEvent->arrData['title'][$arrLang['id']] : (!empty($objEvent->arrData['redirect'][$_LANGID]) ? $objEvent->arrData['redirect'][$_LANGID] : ''); $eventDescription = !empty($objEvent->arrData['description'][$arrLang['id']]) ? $objEvent->arrData['description'][$arrLang['id']] : ''; $eventRedirect = !empty($objEvent->arrData['redirect'][$arrLang['id']]) ? $objEvent->arrData['redirect'][$arrLang['id']] : (!empty($objEvent->arrData['redirect'][$_LANGID]) ? $objEvent->arrData['redirect'][$_LANGID] : ''); $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_TAB_DISPLAY' => $langChecked ? 'block' : 'none', $this->moduleLangVar . '_EVENT_TITLE' => contrexx_raw2xhtml($eventTitle), $this->moduleLangVar . '_EVENT_DESCRIPTION' => new \Cx\Core\Wysiwyg\Wysiwyg("description[{$arrLang['id']}]", contrexx_raw2xhtml($eventDescription), $eventId != 0 ? 'small' : 'bbcode'), $this->moduleLangVar . '_EVENT_REDIRECT' => contrexx_raw2xhtml($eventRedirect), $this->moduleLangVar . '_EVENT_TYPE_EVENT_DISPLAY' => $objEvent->type == 0 ? 'block' : 'none', $this->moduleLangVar . '_EVENT_TYPE_REDIRECT_DISPLAY' => $objEvent->type == 1 ? 'block' : 'none')); $this->_objTpl->parse('eventDescTab'); //parse eventLingualFields foreach ($multiLingualFields as $inputField) { $this->_objTpl->setVariable($this->moduleLangVar . '_EVENT_' . strtoupper($inputField) . '_DEFAULT', $eventId != 0 ? $objEvent->{$inputField} : ''); $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_VALUE' => !empty($objEvent->arrData[$inputField][$arrLang['id']]) ? $objEvent->arrData[$inputField][$arrLang['id']] : ($eventId != 0 ? $objEvent->{$inputField} : ''))); $this->_objTpl->parse('calendar_event_' . $inputField); } $langChecked = $langChecked ? 'checked="checked"' : ''; $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_LANG_CHECKED' => $langChecked)); $this->_objTpl->parse('eventShowIn'); } //parse placeSelect if ((int) $this->arrSettings['placeData'] > 1) { $objMediadirEntries = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry('MediaDir'); $objMediadirEntries->getEntries(null, null, null, null, null, null, true, 0, 'n', null, null, intval($this->arrSettings['placeDataForm'])); $placeOptions = '<option value="">' . $_ARRAYLANG['TXT_CALENDAR_PLEASE_CHOOSE'] . '</option>'; foreach ($objMediadirEntries->arrEntries as $key => $arrEntry) { $selectedPlace = $arrEntry['entryId'] == $objEvent->place_mediadir_id ? 'selected="selected"' : ''; $placeOptions .= '<option ' . $selectedPlace . ' value="' . $arrEntry['entryId'] . '">' . $arrEntry['entryFields'][0] . '</option>'; } $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_PLACE_OPTIONS' => $placeOptions)); $this->_objTpl->parse('eventPlaceSelect'); if ((int) $this->arrSettings['placeData'] == 2) { $this->_objTpl->hideBlock('eventPlaceInput'); $this->_objTpl->hideBlock('eventPlaceTypeRadio'); } else { $this->_objTpl->touchBlock('eventPlaceInput'); $this->_objTpl->touchBlock('eventPlaceTypeRadio'); } } else { $this->_objTpl->touchBlock('eventPlaceInput'); $this->_objTpl->hideBlock('eventPlaceSelect'); $this->_objTpl->hideBlock('eventPlaceTypeRadio'); } //parse placeHostSelect if ((int) $this->arrSettings['placeDataHost'] > 1) { $objMediadirEntries = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry('MediaDir'); $objMediadirEntries->getEntries(null, null, null, null, null, null, true, 0, 'n', null, null, intval($this->arrSettings['placeDataHostForm'])); $placeOptions = '<option value="">' . $_ARRAYLANG['TXT_CALENDAR_PLEASE_CHOOSE'] . '</option>'; foreach ($objMediadirEntries->arrEntries as $key => $arrEntry) { $selectedPlace = $arrEntry['entryId'] == $objEvent->host_mediadir_id ? 'selected="selected"' : ''; $placeOptions .= '<option ' . $selectedPlace . ' value="' . $arrEntry['entryId'] . '">' . $arrEntry['entryFields'][0] . '</option>'; } $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_PLACE_OPTIONS' => $placeOptions)); $this->_objTpl->parse('eventHostSelect'); if ((int) $this->arrSettings['placeDataHost'] == 2) { $this->_objTpl->hideBlock('eventHostInput'); $this->_objTpl->hideBlock('eventHostTypeRadio'); } else { $this->_objTpl->touchBlock('eventHostInput'); $this->_objTpl->touchBlock('eventHostTypeRadio'); } } else { $this->_objTpl->touchBlock('eventHostInput'); $this->_objTpl->hideBlock('eventHostSelect'); $this->_objTpl->hideBlock('eventHostTypeRadio'); } }
private function processCreateDirectory($objCategory) { if (empty($_POST['downloads_category_name'])) { return; } else { $name = contrexx_stripslashes($_POST['downloads_category_name']); } \Cx\Core\Csrf\Controller\Csrf::check_code(); // check for sufficient permissiosn if ($objCategory->getAddSubcategoriesAccessId() && !\Permission::checkAccess($objCategory->getAddSubcategoriesAccessId(), 'dynamic', true) && $objCategory->getOwnerId() != $this->userId) { return; } // parse name and description attributres $arrLanguageIds = array_keys(\FWLanguage::getLanguageArray()); foreach ($arrLanguageIds as $langId) { $arrNames[$langId] = $name; $arrDescriptions[$langId] = ''; } $objSubcategory = new Category(); $objSubcategory->setParentId($objCategory->getId()); $objSubcategory->setActiveStatus(true); $objSubcategory->setVisibility($objCategory->getVisibility()); $objSubcategory->setNames($arrNames); $objSubcategory->setDescriptions($arrDescriptions); $objSubcategory->setPermissions(array('read' => array('protected' => (bool) $objCategory->getAddSubcategoriesAccessId(), 'groups' => array()), 'add_subcategories' => array('protected' => (bool) $objCategory->getAddSubcategoriesAccessId(), 'groups' => array()), 'manage_subcategories' => array('protected' => (bool) $objCategory->getAddSubcategoriesAccessId(), 'groups' => array()), 'add_files' => array('protected' => (bool) $objCategory->getAddSubcategoriesAccessId(), 'groups' => array()), 'manage_files' => array('protected' => (bool) $objCategory->getAddSubcategoriesAccessId(), 'groups' => array()))); // // foreach ($this->arrPermissionTypes as $protectionType) { // $arrCategoryPermissions[$protectionType]['protected'] = isset($_POST['downloads_category_'.$protectionType]) && $_POST['downloads_category_'.$protectionType]; // $arrCategoryPermissions[$protectionType]['groups'] = !empty($_POST['downloads_category_'.$protectionType.'_associated_groups']) ? array_map('intval', $_POST['downloads_category_'.$protectionType.'_associated_groups']) : array(); // } // // $objCategory->setPermissionsRecursive(!empty($_POST['downloads_category_apply_recursive'])); // $objCategory->setPermissions($arrCategoryPermissions); if (!$objSubcategory->store()) { $this->arrStatusMsg['error'] = array_merge($this->arrStatusMsg['error'], $objSubcategory->getErrorMsg()); } }
/** * Handles any kind of database errors * * Includes updating the payments table (I guess from version 1.2.0(?), * note that this is unconfirmed) to the current structure * @return boolean False. Always. * @throws Cx\Lib\Update_DatabaseException */ static function errorHandler() { // Payment // Fix the Text and Zones tables first \Text::errorHandler(); Zones::errorHandler(); \Yellowpay::errorHandler(); $table_name = DBPREFIX . 'module_shop_payment'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'processor_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'fee' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'costs'), 'free_from' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'costs_free_sum'), 'ord' => array('type' => 'INT(5)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'sort_order'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'status')); $table_index = array(); $default_lang_id = \FWLanguage::getDefaultLangId(); if (\Cx\Lib\UpdateUtil::table_exist($table_name)) { if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) { // Migrate all Payment names to the Text table first \Text::deleteByKey('Shop', self::TEXT_NAME); $query = "\n SELECT `id`, `name`\n FROM `{$table_name}`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if (!$objResult) { throw new \Cx\Lib\Update_DatabaseException("Failed to query Payment names", $query); } while (!$objResult->EOF) { $id = $objResult->fields['id']; $name = $objResult->fields['name']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Payment name '{$name}'"); } $objResult->MoveNext(); } } } \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); // Update Payments that use obsolete PSPs: // - 05, 'Internal_CreditCard' // - 06, 'Internal_Debit', // Uses 04, Internal \Cx\Lib\UpdateUtil::sql("UPDATE {$table_name}\n SET `processor_id`=4 WHERE `processor_id` IN (5, 6)"); // - 07, 'Saferpay_Mastercard_Multipay_CAR', // - 08, 'Saferpay_Visa_Multipay_CAR', // Uses 01, Saferpay \Cx\Lib\UpdateUtil::sql("UPDATE {$table_name}\n SET `processor_id`=1 WHERE `processor_id` IN (7, 8)"); $table_name = DBPREFIX . 'module_shop_rel_payment'; $table_structure = array('payment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true), 'zone_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true, 'renamefrom' => 'zones_id')); $table_index = array(); \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); // Always return false; }
/** * Send a confirmation e-mail to the address specified in the form, * if any. * @param $id * @param unknown_type $email * @return unknown */ function sendMail($feedId, $email) { global $_CONFIG, $objDatabase, $_ARRAYLANG, $objInit; $feedId = intval($feedId); $languageId = null; // Get the user ID and entry information $objResult = $objDatabase->Execute("\n SELECT addedby, title, language\n FROM " . DBPREFIX . "module_directory_dir\n WHERE id='{$feedId}'"); if ($objResult && !$objResult->EOF) { $userId = $objResult->fields['addedby']; $feedTitle = $objResult->fields['title']; $languageId = $objResult->fields['language']; } // Get user data if (is_numeric($userId)) { $objFWUser = new \FWUser(); if ($objFWUser->objUser->getUser($userId)) { $userMail = $objFWUser->objUser->getEmail(); $userFirstname = $objFWUser->objUser->getProfileAttribute('firstname'); $userLastname = $objFWUser->objUser->getProfileAttribute('lastname'); $userUsername = $objFWUser->objUser->getUsername(); } } if (!empty($email)) { $sendTo = $email; $mailId = 2; } else { // FIXED: The mail addresses may *both* be empty! // Adding the entry was sucessful, however. So we can probably assume // that it was a success anyway? // Added: if (empty($userMail)) { return true; } // ...and a boolean return value below. $sendTo = $userMail; $mailId = 1; } //get mail content n title $objResult = $objDatabase->Execute("\n SELECT title, content\n FROM " . DBPREFIX . "module_directory_mail\n WHERE id='{$mailId}'"); if ($objResult && !$objResult->EOF) { $subject = $objResult->fields['title']; $message = $objResult->fields['content']; } if ($objInit->mode == 'frontend') { $link = "http://" . $_CONFIG['domainUrl'] . CONTREXX_SCRIPT_PATH . "?section=Directory&cmd=detail&id=" . $feedId; } else { $link = "http://" . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET . '/' . \FWLanguage::getLanguageParameter($languageId, 'lang') . '/' . CONTREXX_DIRECTORY_INDEX . "?section=Directory&cmd=detail&id=" . $feedId; } // replace placeholders $array_1 = array('[[USERNAME]]', '[[FIRSTNAME]]', '[[LASTNAME]]', '[[TITLE]]', '[[LINK]]', '[[URL]]', '[[DATE]]'); $array_2 = array($userUsername, $userFirstname, $userLastname, $feedTitle, $link, $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET, date(ASCMS_DATE_FORMAT)); $subject = str_replace($array_1, $array_2, $subject); $message = str_replace($array_1, $array_2, $message); $sendTo = explode(';', $sendTo); if (@\Env::get('ClassLoader')->loadFile(ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) { $objMail = new \phpmailer(); if ($_CONFIG['coreSmtpServer'] > 0 && @\Env::get('ClassLoader')->loadFile(ASCMS_CORE_PATH . '/SmtpSettings.class.php')) { $arrSmtp = SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer']); if ($arrSmtp !== false) { $objMail->IsSMTP(); $objMail->Host = $arrSmtp['hostname']; $objMail->Port = $arrSmtp['port']; $objMail->SMTPAuth = true; $objMail->Username = $arrSmtp['username']; $objMail->Password = $arrSmtp['password']; } } $objMail->CharSet = CONTREXX_CHARSET; $objMail->From = $_CONFIG['coreAdminEmail']; $objMail->FromName = $_CONFIG['coreAdminName']; $objMail->AddReplyTo($_CONFIG['coreAdminEmail']); $objMail->Subject = $subject; $objMail->IsHTML(false); $objMail->Body = $message; foreach ($sendTo as $mailAdress) { $objMail->ClearAddresses(); $objMail->AddAddress($mailAdress); $objMail->Send(); } } return true; }
private function validateName() { global $_ARRAYLANG; $arrLanguages = \FWLanguage::getLanguageArray(); $namesSet = true; foreach ($arrLanguages as $langId => $arrLanguage) { if ($arrLanguage['frontend'] != 1) { continue; } if (empty($this->names[$langId])) { $namesSet = false; break; } } if ($namesSet) { return true; } else { $this->error_msg[] = $_ARRAYLANG['TXT_DOWNLOADS_EMPTY_NAME_ERROR']; return false; } }
/** * Shows all files / pages in filebrowser */ function _setContent() { global $_FRONTEND_LANGID; $this->_objTpl->addBlockfile('FILEBROWSER_CONTENT', 'fileBrowser_content', 'module_fileBrowser_content.html'); $ckEditorFuncNum = isset($_GET['CKEditorFuncNum']) ? '&CKEditorFuncNum=' . contrexx_raw2xhtml($_GET['CKEditorFuncNum']) : ''; $ckEditor = isset($_GET['CKEditor']) ? '&CKEditor=' . contrexx_raw2xhtml($_GET['CKEditor']) : ''; $rowNr = 0; switch ($this->_mediaType) { case 'webpages': $jd = new \Cx\Core\Json\JsonData(); $data = $jd->data('node', 'getTree', array('get' => array('recursive' => 'true'))); $pageStack = array(); $ref = 0; $data['data']['tree'] = array_reverse($data['data']['tree']); foreach ($data['data']['tree'] as &$entry) { $entry['attr']['level'] = 0; array_push($pageStack, $entry); } while (count($pageStack)) { $entry = array_pop($pageStack); $page = $entry['data'][0]; $arrPage['level'] = $entry['attr']['level']; $arrPage['node_id'] = $entry['attr']['rel_id']; $children = $entry['children']; $children = array_reverse($children); foreach ($children as &$entry) { $entry['attr']['level'] = $arrPage['level'] + 1; array_push($pageStack, $entry); } $arrPage['catname'] = $page['title']; $arrPage['catid'] = $page['attr']['id']; $arrPage['lang'] = BACKEND_LANG_ID; $arrPage['protected'] = $page['attr']['protected']; $arrPage['type'] = \Cx\Core\ContentManager\Model\Entity\Page::TYPE_CONTENT; $arrPage['alias'] = $page['title']; $arrPage['frontend_access_id'] = $page['attr']['frontend_access_id']; $arrPage['backend_access_id'] = $page['attr']['backend_access_id']; // JsonNode does not provide those //$arrPage['level'] = ; //$arrPage['type'] = ; //$arrPage['parcat'] = ; //$arrPage['displaystatus'] = ; //$arrPage['moduleid'] = ; //$arrPage['startdate'] = ; //$arrPage['enddate'] = ; // But we can simulate level and type for our purposes: (level above) $jsondata = json_decode($page['attr']['data-href']); $path = $jsondata->path; if (trim($jsondata->module) != '') { $arrPage['type'] = \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION; $module = explode(' ', $jsondata->module, 2); $arrPage['modulename'] = $module[0]; if (count($module) > 1) { $arrPage['cmd'] = $module[1]; } } $url = "'" . '[[' . \Cx\Core\ContentManager\Model\Entity\Page::PLACEHOLDER_PREFIX; // TODO: This only works for regular application pages. Pages of type fallback that are linked to an application // will be parsed using their node-id ({NODE_<ID>}) if ($arrPage['type'] == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION && $this->_mediaMode !== 'alias') { $url .= $arrPage['modulename']; if (!empty($arrPage['cmd'])) { $url .= '_' . $arrPage['cmd']; } $url = strtoupper($url); } else { $url .= $arrPage['node_id']; } // if language != current language or $alwaysReturnLanguage if ($this->_frontendLanguageId != $_FRONTEND_LANGID || isset($_GET['alwaysReturnLanguage']) && $_GET['alwaysReturnLanguage'] == 'true') { $url .= '_' . $this->_frontendLanguageId; } $url .= "]]'"; $this->_objTpl->setVariable(array('FILEBROWSER_ROW_CLASS' => $rowNr % 2 == 0 ? "row1" : "row2", 'FILEBROWSER_FILE_PATH_CLICK' => "javascript:{setUrl({$url},null,null,'" . \FWLanguage::getLanguageCodeById($this->_frontendLanguageId) . $path . "','page')}", 'FILEBROWSER_FILE_NAME' => $arrPage['catname'], 'FILEBROWSER_FILESIZE' => ' ', 'FILEBROWSER_FILE_ICON' => $this->_iconPath . 'htm.png', 'FILEBROWSER_FILE_DIMENSION' => ' ', 'FILEBROWSER_SPACING_STYLE' => 'style="margin-left: ' . $arrPage['level'] * 15 . 'px;"')); $this->_objTpl->parse('content_files'); $rowNr++; } break; case 'Media1': case 'Media2': case 'Media3': case 'Media4': \Permission::checkAccess(7, 'static'); //Access Media-Archive \Permission::checkAccess(38, 'static'); //Edit Media-Files \Permission::checkAccess(39, 'static'); //Upload Media-Files //Hier soll wirklich kein break stehen! Beabsichtig! //Upload Media-Files //Hier soll wirklich kein break stehen! Beabsichtig! default: if (count($this->_arrDirectories) > 0) { foreach ($this->_arrDirectories as $arrDirectory) { $this->_objTpl->setVariable(array('FILEBROWSER_ROW_CLASS' => $rowNr % 2 == 0 ? "row1" : "row2", 'FILEBROWSER_FILE_PATH_CLICK' => "index.php?cmd=FileBrowser&standalone=true&langId={$this->_frontendLanguageId}&type={$this->_mediaType}&path={$arrDirectory['path']}" . $ckEditor . $ckEditorFuncNum, 'FILEBROWSER_FILE_NAME' => $arrDirectory['name'], 'FILEBROWSER_FILESIZE' => ' ', 'FILEBROWSER_FILE_ICON' => $arrDirectory['icon'], 'FILEBROWSER_FILE_DIMENSION' => ' ')); $this->_objTpl->parse('content_files'); $rowNr++; } } if (count($this->_arrFiles) > 0) { $arrEscapedPaths = array(); foreach ($this->_arrFiles as $arrFile) { $arrEscapedPaths[] = contrexx_raw2encodedUrl($arrFile['path']); $this->_objTpl->setVariable(array('FILEBROWSER_ROW_CLASS' => $rowNr % 2 == 0 ? "row1" : "row2", 'FILEBROWSER_ROW_STYLE' => in_array($arrFile['name'], $this->highlightedFiles) ? ' style="background: ' . $this->highlightColor . ';"' : '', 'FILEBROWSER_FILE_PATH_DBLCLICK' => "setUrl('" . contrexx_raw2xhtml($arrFile['path']) . "'," . $arrFile['width'] . "," . $arrFile['height'] . ",'')", 'FILEBROWSER_FILE_PATH_CLICK' => "javascript:{showPreview(" . (count($arrEscapedPaths) - 1) . "," . $arrFile['width'] . "," . $arrFile['height'] . ")}", 'FILEBROWSER_FILE_NAME' => contrexx_stripslashes($arrFile['name']), 'FILEBROWSER_FILESIZE' => $arrFile['size'] . ' KB', 'FILEBROWSER_FILE_ICON' => $arrFile['icon'], 'FILEBROWSER_FILE_DIMENSION' => empty($arrFile['width']) && empty($arrFile['height']) ? '' : intval($arrFile['width']) . 'x' . intval($arrFile['height']))); $this->_objTpl->parse('content_files'); $rowNr++; } $this->_objTpl->setVariable('FILEBROWSER_FILES_JS', "'" . implode("','", $arrEscapedPaths) . "'"); } if (array_key_exists($this->_mediaType, $this->mediaTypePaths)) { $this->_objTpl->setVariable('FILEBROWSER_IMAGE_PATH', $this->mediaTypePaths[$this->_mediaType][1]); } else { $this->_objTpl->setVariable('FILEBROWSER_IMAGE_PATH', ASCMS_CONTENT_IMAGE_WEB_PATH); } break; } $this->_objTpl->parse('fileBrowser_content'); }
private function performLanguageAction($action, $params) { global $_CORELANG; // Global access check if (!\Permission::checkAccess(6, 'static', true) || !\Permission::checkAccess(35, 'static', true)) { throw new \Cx\Core\ContentManager\ContentManagerException($_CORELANG['TXT_CORE_CM_USAGE_DENIED']); } if (!\Permission::checkAccess(53, 'static', true)) { throw new \Cx\Core\ContentManager\ContentManagerException($_CORELANG['TXT_CORE_CM_COPY_DENIED']); } if (!isset($params['get']) || !isset($params['get']['to'])) { throw new \Cx\Core\ContentManager\ContentManagerException('Illegal parameter list'); } $em = \Env::get('em'); $nodeRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Node'); $targetLang = contrexx_input2raw($params['get']['to']); $fromLang = \FWLanguage::getFallbackLanguageIdById($targetLang); if ($fromLang === false) { throw new \Cx\Core\ContentManager\ContentManagerException('Language has no fallback to copy/link from'); } $toLangCode = \FWLanguage::getLanguageCodeById($targetLang); if ($toLangCode === false) { throw new \Cx\Core\ContentManager\ContentManagerException('Could not get id for language #"' . $targetLang . '"'); } $limit = 0; $offset = 0; if (isset($params['get']['limit'])) { $limit = contrexx_input2raw($params['get']['limit']); } if (isset($params['get']['offset'])) { $offset = contrexx_input2raw($params['get']['offset']); } $result = $nodeRepo->translateRecursive($nodeRepo->getRoot(), $fromLang, $targetLang, $action == 'copy', $limit, $offset); return $result; }
/** * Parsing the related News * * @global object $objDatabase * @global type $_ARRAYLANG * * @param Object $objTpl Template Object * @param Interger $newsId News Id * @param Interger $langId Language id * @param type $blockName Block Name * @param type $limit Limit * * @return null */ public function parseRelatedNews(\Cx\Core\Html\Sigma $objTpl, $newsId = null, $langId = null, $blockName = 'related_news', $limit = 0) { global $_ARRAYLANG, $objDatabase; if (empty($newsId) || !$objTpl->blockExists($blockName)) { return; } //Getting the related news ids $relatedNewsIds = $this->getRelatedNews($newsId); $defaultLangId = \FWLanguage::getDefaultLangId(); //Getting the related news details for the given languages $relatedNewsDetails = $this->getRelatedNewsDetails($relatedNewsIds, array($langId, $defaultLangId)); if (!empty($relatedNewsDetails)) { $defaultImage = \Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseCoreModulePath() . '/News/View/Media/default_news_image.png'; $currentCount = 1; foreach ($relatedNewsIds as $relatedNewsId) { //If the limit is reached then the loop is stopped if (!empty($limit) && $currentCount > $limit) { break; } /* * Checking the related news is available in the current * acitve front-end language if not available then the default * language details are getting used * Comment/Uncomment the following line if this condition * is required */ //$currentRelatedDetails = isset($relatedNewsDetails[$relatedNewsId][$langId]) // ? $relatedNewsDetails[$relatedNewsId][$langId] // : $relatedNewsDetails[$relatedNewsId][$defaultLangId]; /* * Checking the related news is available in the current * acitve front-end language if not available then the related * News not listed Comment/Uncomment the following * line if this condition is required */ $currentRelatedDetails = isset($relatedNewsDetails[$relatedNewsId][$langId]) ? $relatedNewsDetails[$relatedNewsId][$langId] : false; if (!$currentRelatedDetails) { continue; } ++$currentCount; $categories = $this->getCategoriesByNewsId($relatedNewsId); $newsUrl = empty($currentRelatedDetails['redirect']) ? empty($currentRelatedDetails['newscontent']) ? '' : \Cx\Core\Routing\Url::fromModuleAndCmd('news', $this->findCmdById('details', array_keys($categories)), FRONTEND_LANG_ID, array('newsid' => $relatedNewsId)) : $currentRelatedDetails['redirect']; $newstitle = $currentRelatedDetails['title']; $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); } $imagePath = !empty($currentRelatedDetails['teaser_image_path']) ? $currentRelatedDetails['teaser_image_path'] : $defaultImage; $imageThumbPath = !empty($currentRelatedDetails['teaser_image_thumbnail_path']) ? $currentRelatedDetails['teaser_image_thumbnail_path'] : $defaultImage; $this->parseImageBlock($objTpl, $imagePath, $newstitle, $newsUrl, 'related_news_image'); $this->parseImageBlock($objTpl, $imageThumbPath, $newstitle, $newsUrl, 'related_news_image_thumb'); $author = \FWUser::getParsedUserTitle($currentRelatedDetails['author_id'], $currentRelatedDetails['author']); $publisher = \FWUser::getParsedUserTitle($currentRelatedDetails['publisher_id'], $currentRelatedDetails['publisher']); $objSubResult = $objDatabase->Execute(' SELECT count(`id`) AS `countComments` FROM `' . DBPREFIX . 'module_news_comments` WHERE `newsid` = ' . $relatedNewsId); $objTpl->setVariable(array('NEWS_RELATED_NEWS_ID' => contrexx_raw2xhtml($relatedNewsId), 'NEWS_RELATED_NEWS_URL' => contrexx_raw2xhtml($newsUrl), 'NEWS_RELATED_NEWS_LINK' => $htmlLink, 'NEWS_RELATED_NEWS_TITLE' => contrexx_raw2xhtml($currentRelatedDetails['title']), 'NEWS_RELATED_NEWS_TITLE_SHORT' => strlen($currentRelatedDetails['title']) > 35 ? substr(strip_tags($currentRelatedDetails['title']), 0, 35) . '...' : strip_tags($currentRelatedDetails['title']), 'NEWS_RELATED_NEWS_TITLE_LINK' => $htmlLinkTitle, 'NEWS_RELATED_NEWS_TEXT' => $currentRelatedDetails['text'], 'NEWS_RELATED_NEWS_TEXT_SHORT' => strlen($currentRelatedDetails['text']) > 250 ? substr(strip_tags($currentRelatedDetails['text']), 0, 247) . '...' : strip_tags($currentRelatedDetails['text']), 'NEWS_RELATED_NEWS_TEASER_TEXT' => nl2br($currentRelatedDetails['teaser_text']), 'NEWS_RELATED_NEWS_AUTHOR' => contrexx_raw2xhtml($author), 'NEWS_RELATED_NEWS_PUBLISHER' => contrexx_raw2xhtml($publisher), 'NEWS_RELATED_NEWS_CATEGORY_NAMES' => implode(', ', contrexx_raw2xhtml($categories)), 'NEWS_RELATED_NEWS_LONG_DATE' => date(ASCMS_DATE_FORMAT, $currentRelatedDetails['newsdate']), 'NEWS_RELATED_NEWS_DATE' => date(ASCMS_DATE_FORMAT_DATE, $currentRelatedDetails['newsdate']), 'NEWS_RELATED_NEWS_TIME' => date(ASCMS_DATE_FORMAT_TIME, $currentRelatedDetails['newsdate']), 'NEWS_RELATED_NEWS_COUNT_COMMENTS' => $currentRelatedDetails['commentactive'] && $this->arrSettings['news_comments_activated'] ? contrexx_raw2xhtml($objSubResult->fields['countComments'] . ' ' . $_ARRAYLANG['TXT_NEWS_COMMENTS']) : '')); if (!$objSubResult->fields['countComments'] || !$this->arrSettings['news_comments_activated']) { if ($objTpl->blockExists('related_news_comments_count')) { $objTpl->hideBlock('related_news_comments_count'); } } if ($this->arrSettings['news_use_teaser_text'] != '1' && $objTpl->blockExists('news_use_teaser_text')) { $objTpl->hideBlock('news_use_teaser_text'); } $objTpl->parse($blockName); } if ($objTpl->blockExists('related_news_block')) { $objTpl->setVariable('TXT_NEWS_RELATED_NEWS', $_ARRAYLANG['TXT_NEWS_RELATED_NEWS']); $objTpl->touchBlock('related_news_block'); } } }
/** * Return event place url and its source link * * @return array place url and its source link */ function loadPlaceLinkFromMediadir($intMediaDirId = 0, $type = 'place') { global $_LANGID, $_CONFIG; $placeUrl = ''; $placeUrlSource = ''; if (!empty($intMediaDirId)) { $objMediadirEntry = new \Cx\Modules\MediaDir\Controller\MediaDirectoryEntry('MediaDir'); $objMediadirEntry->getEntries(intval($intMediaDirId)); $pageRepo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page'); $pages = $pageRepo->findBy(array('cmd' => contrexx_addslashes('detail' . intval($objMediadirEntry->arrEntries[$intMediaDirId]['entryFormId'])), 'lang' => $_LANGID, 'type' => \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION, 'module' => 'MediaDir')); if (count($pages)) { $strDetailCmd = 'detail' . intval($objMediadirEntry->arrEntries[$intMediaDirId]['entryFormId']); } else { $strDetailCmd = 'detail'; } $pages = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page')->getFromModuleCmdByLang('MediaDir', $strDetailCmd); $arrActiveFrontendLanguages = \FWLanguage::getActiveFrontendLanguages(); if (isset($arrActiveFrontendLanguages[FRONTEND_LANG_ID]) && isset($pages[FRONTEND_LANG_ID])) { $langId = FRONTEND_LANG_ID; } else { if (isset($arrActiveFrontendLanguages[BACKEND_LANG_ID]) && isset($pages[BACKEND_LANG_ID])) { $langId = BACKEND_LANG_ID; } else { foreach ($arrActiveFrontendLanguages as $lang) { if (isset($pages[$lang['id']])) { $langId = $lang['id']; break; } } } } $url = $pages[$langId]->getUrl(ASCMS_PROTOCOL . "://" . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET, "?eid={$intMediaDirId}"); $place = ($type = 'place') ? $this->place : $this->org_name; $placeUrl = "<a href='" . $url . "' target='_blank' >" . (!empty($place) ? $place : $url) . "</a>"; $placeUrlSource = $url; } return array($placeUrl, $placeUrlSource); }
/** * add and modify language values * * @global array * @global ADONewConnection * @return boolean True on success, false on failure */ function modifyLanguage() { global $_ARRAYLANG, $_CONFIG, $objDatabase; $langRemovalStatus = isset($_POST['removeLangVersion']) ? contrexx_input2raw($_POST['removeLangVersion']) : false; if (!empty($_POST['submit']) and isset($_POST['addLanguage']) && $_POST['addLanguage'] == "true") { //----------------------------------------------- // Add new language with all variables //----------------------------------------------- if (!empty($_POST['newLangName']) and !empty($_POST['newLangShortname'])) { $newLangShortname = addslashes(strip_tags($_POST['newLangShortname'])); $newLangName = addslashes(strip_tags($_POST['newLangName'])); $newLangCharset = addslashes(strip_tags($_POST['newLangCharset'])); $objResult = $objDatabase->Execute("SELECT lang FROM " . DBPREFIX . "languages WHERE lang='" . $newLangShortname . "'"); if ($objResult !== false) { if ($objResult->RecordCount() >= 1) { $this->strErrMessage = $_ARRAYLANG['TXT_DATABASE_QUERY_ERROR']; return false; } else { $objDatabase->Execute("INSERT INTO " . DBPREFIX . "languages SET lang='" . $newLangShortname . "',\n name='" . $newLangName . "',\n charset='" . $newLangCharset . "',\n is_default='false'"); $newLanguageId = $objDatabase->Insert_ID(); if (!empty($newLanguageId)) { $objResult = $objDatabase->SelectLimit("SELECT id FROM " . DBPREFIX . "languages WHERE is_default='true'", 1); if ($objResult !== false && !$objResult->EOF) { $defaultLanguage = $objResult->fields['id']; $objResult = $objDatabase->Execute("SELECT varid,content,module FROM " . DBPREFIX . "language_variable_content WHERE 1 AND lang=" . $defaultLanguage); if ($objResult !== false) { while (!$objResult->EOF) { $arrayLanguageContent[$objResult->fields['varid']] = stripslashes($objResult->fields['content']); $arrayLanguageModule[$objResult->fields['varid']] = $objResult->fields['module']; $objResult->MoveNext(); } foreach ($arrayLanguageContent as $varid => $content) { $LanguageModule = $arrayLanguageModule[$varid]; $objDatabase->Execute("INSERT INTO " . DBPREFIX . "language_variable_content SET varid=" . $varid . ", content='" . addslashes($content) . "', module=" . $LanguageModule . ", lang=" . $newLanguageId . ", status=0"); } $this->strOkMessage = $_ARRAYLANG['TXT_NEW_LANGUAGE_ADDED_SUCCESSFUL']; return true; } } } else { $this->strErrMessage = $_ARRAYLANG['TXT_DATABASE_QUERY_ERROR']; return false; } } } } } elseif (!empty($_POST['submit']) and $_POST['modLanguage'] == "true") { $eventArgs = array('langRemovalStatus' => $langRemovalStatus); $frontendLangIds = array_keys(\FWLanguage::getActiveFrontendLanguages()); $postLangIds = array_keys($_POST['langActiveStatus']); foreach (array_keys(\FWLanguage::getLanguageArray()) as $langId) { $isLangInPost = in_array($langId, $postLangIds); $isLangInFrontend = in_array($langId, $frontendLangIds); if ($isLangInPost == $isLangInFrontend) { continue; } $eventArgs['langData'][] = array('langId' => $langId, 'status' => $isLangInPost && !$isLangInFrontend); } //Trigger the event 'languageStatusUpdate' //if the language is activated/deactivated for frontend if (!empty($eventArgs)) { $evm = \Cx\Core\Core\Controller\Cx::instanciate()->getEvents(); $evm->triggerEvent('languageStatusUpdate', array($eventArgs, new \Cx\Core\Model\RecursiveArrayAccess(array()))); } //----------------------------------------------- // Update languages //----------------------------------------------- foreach ($_POST['langName'] as $id => $name) { $active = 0; if (isset($_POST['langActiveStatus'][$id]) && $_POST['langActiveStatus'][$id] == 1) { $languageCode = \FWLanguage::getLanguageCodeById($id); $pageRepo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page'); $alias = $pageRepo->findBy(array('type' => \Cx\Core\ContentManager\Model\Entity\Page::TYPE_ALIAS, 'slug' => $languageCode), true); if (count($alias)) { if (is_array($alias)) { $alias = $alias[0]; } $id = $alias->getNode()->getId(); $config = \Env::get('config'); $link = 'http://' . $config['domainUrl'] . ASCMS_PATH_OFFSET . '/' . $alias->getSlug(); $lang = \Env::get('lang'); $this->strErrMessage = $lang['TXT_CORE_REMOVE_ALIAS_TO_ACTIVATE_LANGUAGE'] . ':<br /> <a href="index.php?cmd=Alias&act=modify&id=' . $id . '" target="_blank">' . $link . '</a>'; return false; } $active = 1; } $status = "false"; if ($_POST['langDefaultStatus'] == $id) { $status = "true"; } $adminstatus = 0; if (isset($_POST['langAdminStatus'][$id]) && $_POST['langAdminStatus'][$id] == 1) { $adminstatus = 1; } $fallBack = isset($_POST['fallBack'][$id]) && $_POST['fallBack'][$id] != "" ? intval($_POST['fallBack'][$id]) : 'NULL'; $objDatabase->Execute("UPDATE " . DBPREFIX . "languages SET \n name='" . $name . "',\n frontend=" . $active . ",\n is_default='" . $status . "',\n backend='" . $adminstatus . "',\n fallback=" . $fallBack . "\n WHERE id=" . $id); } $this->strOkMessage = $_ARRAYLANG['TXT_DATA_RECORD_UPDATED_SUCCESSFUL']; \FWLanguage::init(); return true; } return false; }
/** * Get input field based on language id and value * * @param integer $id Input field id * @param string $value Input field value * @param integer $langId Language id * @param array $arrInputfield Language id * * @return string Return input field based on language id and value */ private function getInput($id = 0, $value = '', $langId = 0, $arrInputfield = array()) { global $_ARRAYLANG; $cx = \Cx\Core\Core\Controller\Cx::instanciate(); $arrValue = explode(",", $value); $filePath = $arrValue[0]; $displayName = null; $strFilePreview = null; if (!empty($filePath) && file_exists(\Env::get('cx')->getWebsitePath() . $filePath)) { $arrFileInfo = pathinfo($filePath); $strFileName = htmlspecialchars($arrFileInfo['basename'], ENT_QUOTES, CONTREXX_CHARSET); if (empty($arrValue[1])) { $displayName = $strFileName; } else { $displayName = strip_tags(htmlspecialchars($arrValue[1], ENT_QUOTES, CONTREXX_CHARSET)); } $strFilePreview = '<a href="' . urldecode($filePath) . '" target="_blank">' . $strFileName . '</a> <input data-id="' . $id . '" type="checkbox" class="' . (!$langId ? 'mediadirInputfieldDefaultDeleteFile' : '') . '" id="mediadirInputfield_delete_' . $id . '_' . $langId . '" value="1" name="deleteMedia[' . $id . '][' . $langId . ']" />' . $_ARRAYLANG['TXT_MEDIADIR_DELETE'] . '<br />'; } $flagPath = $cx->getCodeBaseOffsetPath() . $cx->getCoreFolderName() . '/Country/View/Media/Flag'; $inputStyle = !empty($langId) ? 'background: #ffffff url(\'' . $flagPath . '/flag_' . \FWLanguage::getLanguageCodeById($langId) . '.gif\') no-repeat 3px 3px;' : ''; $inputDefaultClass = empty($langId) ? $this->moduleNameLC . 'InputfieldDefault' : $this->moduleNameLC . 'LangInputfield'; $mode = $cx->getMode(); if ($mode == \Cx\Core\Core\Controller\Cx::MODE_BACKEND) { $strInputfield = <<<INPUT {$strFilePreview} <input type="text" name="{$this->moduleNameLC}Inputfield[{$id}][file][{$langId}]" value="{$filePath}" data-id="{$id}" class="{$inputDefaultClass}" id="{$this->moduleNameLC}Inputfield_{$id}_{$langId}" style="{$inputStyle}" autocomplete="off" onfocus="this.select();" /> <input type="button" onClick="getMediaBrowser(\$J(this));" data-input-id="{$this->moduleNameLC}Inputfield_{$id}_{$langId}" data-views="filebrowser" data-startmediatype="{$this->moduleNameLC}" value="{$_ARRAYLANG['TXT_BROWSE']}" /> <br /> <input type="text" name="{$this->moduleNameLC}Inputfield[{$id}][name][{$langId}]" value="{$displayName}" data-id="{$id}" data-related-field-prefix="{$this->moduleNameLC}InputfieldFileDisplayName" class="{$this->moduleNameLC}InputfieldFileDisplayName {$inputDefaultClass}" id="{$this->moduleNameLC}InputfieldFileDisplayName_{$id}_{$langId}" onfocus="this.select();" /> <i>{$_ARRAYLANG['TXT_MEDIADIR_DISPLAYNAME']}</i> INPUT; } else { if (empty($filePath) || $filePath == "new_image") { $strValueHidden = "new_image"; $filePath = ""; } else { $strValueHidden = $filePath; } $strInfoValue = $strInfoClass = ''; $strInfo = !empty($arrInputfield['info'][$langId]) ? $arrInputfield['info'][$langId] : (!empty($arrInputfield['info'][0]) ? $arrInputfield['info'][0] : ''); if ($strInfo) { $strInfoValue = 'title="' . $strInfo . '"'; $strInfoClass = 'mediadirInputfieldHint'; } $strInputfield = <<<INPUT {$strFilePreview} <input type="text" name="{$this->moduleNameLC}InputfieldSource[{$id}][{$langId}]" value="{$value}" data-id="{$id}" class="{$inputDefaultClass}" id="{$this->moduleNameLC}Inputfield_{$id}_{$langId}" style="{$inputStyle}" autocomplete="off" onfocus="this.select();" /> <input type="button" onClick="getUploader(\$J(this));" data-input-id="{$this->moduleNameLC}Inputfield_{$id}_{$langId}" value="{$_ARRAYLANG['TXT_BROWSE']}" /> <br /> <input id="{$this->moduleNameLC}Inputfield_{$id}_{$langId}_hidden" name="{$this->moduleNameLC}Inputfield[{$id}][file][{$langId}]" value="{$strValueHidden}" type="hidden" /> <br /> <input type="text" name="{$this->moduleNameLC}Inputfield[{$id}][name][{$langId}]" value="{$displayName}" data-id="{$id}" data-related-field-prefix="{$this->moduleNameLC}InputfieldFileDisplayName" class="{$this->moduleNameLC}InputfieldFileDisplayName {$inputDefaultClass}" id="{$this->moduleNameLC}InputfieldFileDisplayName_{$id}_{$langId}" onfocus="this.select();" /> <i>{$_ARRAYLANG['TXT_MEDIADIR_DISPLAYNAME']}</i> INPUT; } return $strInputfield; }
function _editUser() { global $objDatabase, $_ARRAYLANG, $_CORELANG; $activeFrontendlang = \FWLanguage::getActiveFrontendLanguages(); $copy = isset($_REQUEST['copy']) && $_REQUEST['copy'] == 1; $recipientId = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; $recipientEmail = ''; $recipientUri = ''; $recipientSex = ''; $recipientSalutation = 0; $recipientTitle = ''; $recipientPosition = ''; $recipientIndustrySector = ''; $recipientPhoneMobile = ''; $recipientPhonePrivate = ''; $recipientFax = ''; $recipientNotes = ''; $recipientLastname = ''; $recipientFirstname = ''; $recipientCompany = ''; $recipientAddress = ''; $recipientZip = ''; $recipientCity = ''; $recipientCountry = ''; $recipientPhoneOffice = ''; $recipientBirthday = ''; $recipientLanguage = count($activeFrontendlang) == 1 ? key($activeFrontendlang) : ''; $recipientStatus = isset($_POST['newsletter_recipient_status']) ? 1 : (empty($_POST) ? 1 : 0); $arrAssociatedLists = array(); $recipientSendEmailId = isset($_POST['sendEmail']) ? intval($_POST['sendEmail']) : 0; $recipientSendMailDisplay = false; if (isset($_POST['newsletter_recipient_email'])) { $recipientEmail = $_POST['newsletter_recipient_email']; } if (isset($_POST['newsletter_recipient_uri'])) { $recipientUri = $_POST['newsletter_recipient_uri']; } if (isset($_POST['newsletter_recipient_sex'])) { $recipientSex = in_array($_POST['newsletter_recipient_sex'], array('f', 'm')) ? $_POST['newsletter_recipient_sex'] : ''; } if (isset($_POST['newsletter_recipient_salutation'])) { // TODO: use FWUSER $arrRecipientSalutation = $this->_getRecipientTitles(); $recipientSalutation = in_array($_POST['newsletter_recipient_salutation'], array_keys($arrRecipientSalutation)) ? intval($_POST['newsletter_recipient_salutation']) : 0; } if (isset($_POST['newsletter_recipient_lastname'])) { $recipientLastname = $_POST['newsletter_recipient_lastname']; } if (isset($_POST['newsletter_recipient_firstname'])) { $recipientFirstname = $_POST['newsletter_recipient_firstname']; } if (isset($_POST['newsletter_recipient_company'])) { $recipientCompany = $_POST['newsletter_recipient_company']; } if (isset($_POST['newsletter_recipient_address'])) { $recipientAddress = $_POST['newsletter_recipient_address']; } if (isset($_POST['newsletter_recipient_zip'])) { $recipientZip = $_POST['newsletter_recipient_zip']; } if (isset($_POST['newsletter_recipient_city'])) { $recipientCity = $_POST['newsletter_recipient_city']; } if (isset($_POST['newsletter_country_id'])) { $recipientCountry = $_POST['newsletter_country_id']; } if (isset($_POST['newsletter_recipient_phone_office'])) { $recipientPhoneOffice = $_POST['newsletter_recipient_phone_office']; } if (isset($_POST['newsletter_recipient_notes'])) { $recipientNotes = $_POST['newsletter_recipient_notes']; } if (isset($_POST['day']) && isset($_POST['month']) && isset($_POST['year'])) { $recipientBirthday = str_pad(intval($_POST['day']), 2, '0', STR_PAD_LEFT) . '-' . str_pad(intval($_POST['month']), 2, '0', STR_PAD_LEFT) . '-' . intval($_POST['year']); } if (isset($_POST['newsletter_recipient_title'])) { $recipientTitle = $_POST['newsletter_recipient_title']; } if (isset($_POST['newsletter_recipient_position'])) { $recipientPosition = $_POST['newsletter_recipient_position']; } if (isset($_POST['newsletter_recipient_industry_sector'])) { $recipientIndustrySector = $_POST['newsletter_recipient_industry_sector']; } if (isset($_POST['newsletter_recipient_phone_mobile'])) { $recipientPhoneMobile = $_POST['newsletter_recipient_phone_mobile']; } if (isset($_POST['newsletter_recipient_phone_private'])) { $recipientPhonePrivate = $_POST['newsletter_recipient_phone_private']; } if (isset($_POST['newsletter_recipient_fax'])) { $recipientFax = $_POST['newsletter_recipient_fax']; } if (isset($_POST['language'])) { $recipientLanguage = $_POST['language']; } if (isset($_POST['newsletter_recipient_associated_list'])) { foreach ($_POST['newsletter_recipient_associated_list'] as $listId => $status) { if (intval($status) == 1) { array_push($arrAssociatedLists, intval($listId)); } } } // Get interface settings $objInterface = $objDatabase->Execute('SELECT `setvalue` FROM `' . DBPREFIX . 'module_newsletter_settings` WHERE `setname` = "recipient_attribute_status"'); $recipientAttributeStatus = json_decode($objInterface->fields['setvalue'], true); if (isset($_POST['newsletter_recipient_save'])) { $objValidator = new \FWValidator(); if ($objValidator->isEmail($recipientEmail)) { if ($this->_validateRecipientAttributes($recipientAttributeStatus, $recipientUri, $recipientSex, $recipientSalutation, $recipientTitle, $recipientLastname, $recipientFirstname, $recipientPosition, $recipientCompany, $recipientIndustrySector, $recipientAddress, $recipientZip, $recipientCity, $recipientCountry, $recipientPhoneOffice, $recipientPhonePrivate, $recipientPhoneMobile, $recipientFax, $recipientBirthday)) { if ($this->_isUniqueRecipientEmail($recipientEmail, $recipientId, $copy)) { //reset the $recipientId on copy function $recipientId = $copy ? 0 : $recipientId; if ($recipientId > 0) { if ($this->_updateRecipient($recipientAttributeStatus, $recipientId, $recipientEmail, $recipientUri, $recipientSex, $recipientSalutation, $recipientTitle, $recipientLastname, $recipientFirstname, $recipientPosition, $recipientCompany, $recipientIndustrySector, $recipientAddress, $recipientZip, $recipientCity, $recipientCountry, $recipientPhoneOffice, $recipientPhonePrivate, $recipientPhoneMobile, $recipientFax, $recipientNotes, $recipientBirthday, $recipientStatus, $arrAssociatedLists, $recipientLanguage)) { self::$strOkMessage .= $_ARRAYLANG['TXT_NEWSLETTER_RECIPIENT_UPDATED_SUCCESSFULLY']; return $this->_userList(); } else { // fall back to old recipient id, if any error occurs on copy $recipientId = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; self::$strErrMessage .= $_ARRAYLANG['TXT_NEWSLETTER_ERROR_UPDATE_RECIPIENT']; } } else { if ($this->_addRecipient($recipientEmail, $recipientUri, $recipientSex, $recipientSalutation, $recipientTitle, $recipientLastname, $recipientFirstname, $recipientPosition, $recipientCompany, $recipientIndustrySector, $recipientAddress, $recipientZip, $recipientCity, $recipientCountry, $recipientPhoneOffice, $recipientPhonePrivate, $recipientPhoneMobile, $recipientFax, $recipientNotes, $recipientBirthday, $recipientStatus, $arrAssociatedLists, $recipientLanguage)) { if (!empty($recipientSendEmailId)) { $objRecipient = $objDatabase->SelectLimit("SELECT id FROM " . DBPREFIX . "module_newsletter_user WHERE email='" . contrexx_input2db($recipientEmail) . "'", 1); $recipientId = $objRecipient->fields['id']; $this->insertTmpEmail($recipientSendEmailId, $recipientEmail, self::USER_TYPE_NEWSLETTER); // setting TmpEntry=1 will set the newsletter status=1, this will force an imediate stop in the newsletter send procedere. if ($this->SendEmail($recipientId, $recipientSendEmailId, $recipientEmail, 1, self::USER_TYPE_NEWSLETTER) == false) { // fall back to old recipient id, if any error occurs on copy $recipientId = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; self::$strErrMessage .= $_ARRAYLANG['TXT_SENDING_MESSAGE_ERROR']; } else { $objRecipientCount = $objDatabase->execute('SELECT subject FROM ' . DBPREFIX . 'module_newsletter WHERE id=' . intval($recipientSendEmailId)); $newsTitle = $objRecipientCount->fields['subject']; // TODO: Unused // $objUpdateCount = $objDatabase->execute(' UPDATE ' . DBPREFIX . 'module_newsletter SET recipient_count = recipient_count+1 WHERE id=' . intval($recipientSendEmailId)); self::$strOkMessage .= sprintf($_ARRAYLANG['TXT_NEWSLETTER_RECIPIENT_MAIL_SEND_SUCCESSFULLY'] . '<br />', '<strong>' . $newsTitle . '</strong>'); } } self::$strOkMessage .= $_ARRAYLANG['TXT_NEWSLETTER_RECIPIENT_SAVED_SUCCESSFULLY']; return $this->_userList(); } else { // fall back to old recipient id, if any error occurs on copy $recipientId = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; self::$strErrMessage .= $_ARRAYLANG['TXT_NEWSLETTER_ERROR_SAVE_RECIPIENT']; } } } elseif (empty($recipientId)) { $objRecipient = $objDatabase->SelectLimit("SELECT id, language, status, notes FROM " . DBPREFIX . "module_newsletter_user WHERE email='" . contrexx_input2db($recipientEmail) . "'", 1); $recipientId = $objRecipient->fields['id']; $recipientLanguage = $objRecipient->fields['language']; $recipientStatus = $objRecipient->fields['status']; $recipientNotes = !empty($objRecipient->fields['notes']) ? $objRecipient->fields['notes'] . ' ' . $recipientNotes : $recipientNotes; $objList = $objDatabase->Execute("SELECT category FROM " . DBPREFIX . "module_newsletter_rel_user_cat WHERE user="******"SELECT id FROM " . DBPREFIX . "module_newsletter_user WHERE email='" . contrexx_input2db($recipientEmail) . "' AND id!=" . ($copy ? 0 : $recipientId), 1); self::$strErrMessage .= sprintf($_ARRAYLANG['TXT_NEWSLETTER_ERROR_EMAIL_ALREADY_EXISTS'], '<a href="index.php?cmd=Newsletter&act=users&tpl=edit&id=' . $objResult->fields['id'] . '" target="_blank">' . $_ARRAYLANG['TXT_NEWSLETTER_ERROR_EMAIL_ALREADY_EXISTS_CLICK_HERE'] . '</a>'); } } else { self::$strErrMessage .= $_ARRAYLANG['TXT_NEWSLETTER_MANDATORY_FIELD_ERROR']; } } else { self::$strErrMessage .= $_ARRAYLANG['TXT_NEWSLETTER_INVALIDE_EMAIL_ADDRESS']; } } elseif ($recipientId > 0) { $objRecipient = $objDatabase->SelectLimit("SELECT email, uri, sex, salutation, title, lastname, firstname, position, company, industry_sector, address, zip, city, country_id, phone_office, phone_private, phone_mobile, fax, notes, birthday, status, language FROM " . DBPREFIX . "module_newsletter_user WHERE id=" . $recipientId, 1); if ($objRecipient !== false && $objRecipient->RecordCount() == 1) { $recipientEmail = $objRecipient->fields['email']; $recipientUri = $objRecipient->fields['uri']; $recipientSex = $objRecipient->fields['sex']; $recipientSalutation = $objRecipient->fields['salutation']; $recipientTitle = $objRecipient->fields['title']; $recipientLastname = $objRecipient->fields['lastname']; $recipientFirstname = $objRecipient->fields['firstname']; $recipientPosition = $objRecipient->fields['position']; $recipientCompany = $objRecipient->fields['company']; $recipientIndustrySector = $objRecipient->fields['industry_sector']; $recipientAddress = $objRecipient->fields['address']; $recipientZip = $objRecipient->fields['zip']; $recipientCity = $objRecipient->fields['city']; $recipientCountry = $objRecipient->fields['country_id']; $recipientPhoneOffice = $objRecipient->fields['phone_office']; $recipientPhonePrivate = $objRecipient->fields['phone_private']; $recipientPhoneMobile = $objRecipient->fields['phone_mobile']; $recipientFax = $objRecipient->fields['fax']; $recipientBirthday = $objRecipient->fields['birthday']; $recipientLanguage = $objRecipient->fields['language']; $recipientStatus = $objRecipient->fields['status']; $recipientNotes = $objRecipient->fields['notes']; $objList = $objDatabase->Execute("SELECT category FROM " . DBPREFIX . "module_newsletter_rel_user_cat WHERE user="******"checked"' : '')); $this->_objTpl->parse('newsletter_mail_associated_list_' . $column); $listNr++; } if (count($activeFrontendlang) > 1) { foreach ($activeFrontendlang as $lang) { $selected = $lang['id'] == $recipientLanguage ? 'selected="selected"' : ''; $this->_objTpl->setVariable(array('NEWSLETTER_LANGUAGE_ID' => contrexx_raw2xhtml($lang['id']), 'NEWSLETTER_LANGUAGE_NAME' => contrexx_raw2xhtml($lang['name']), 'NEWSLETTER_LANGUAGES_SELECTED' => $selected)); $this->_objTpl->parse('languages'); } $languageOptionDisplay = true; } else { $this->_objTpl->hideBlock('languageOption'); } if (empty($recipientId) || $copy) { $objNewsletterMails = $objDatabase->Execute('SELECT id, subject FROM ' . DBPREFIX . 'module_newsletter ORDER BY status, id DESC'); while (!$objNewsletterMails->EOF) { $selected = $recipientSendEmailId == $objNewsletterMails->fields['id'] ? 'selected="selected"' : ''; $this->_objTpl->setVariable(array('NEWSLETTER_EMAIL_ID' => contrexx_raw2xhtml($objNewsletterMails->fields['id']), 'NEWSLETTER_EMAIL_NAME' => contrexx_raw2xhtml($objNewsletterMails->fields['subject']), 'NEWSLETTER_EMAIL_SELECTED' => $selected)); $this->_objTpl->parse('allMails'); $objNewsletterMails->MoveNext(); } $recipientSendMailDisplay = true; } else { $this->_objTpl->hideBlock('sendEmail'); } // Display settings recipient general attributes $sendMailRowClass = $languageOptionDisplay ? 'row2' : 'row1'; if ($languageOptionDisplay && $recipientSendMailDisplay) { $associatedListRowClass = 'row1'; } elseif ($languageOptionDisplay || $recipientSendMailDisplay) { $associatedListRowClass = 'row2'; } else { $associatedListRowClass = 'row1'; } $recipientNotesRowClass = $associatedListRowClass == 'row1' ? 'row2' : 'row1'; $this->_objTpl->setVariable(array('NEWSLETTER_SEND_EMAIL_ROWCLASS' => $sendMailRowClass, 'NEWSLETTER_ASSOCIATED_LISTS_ROWCLASS' => $associatedListRowClass, 'NEWSLETTER_NOTES_ROWCLASS' => $recipientNotesRowClass)); //display settings recipient profile detials $recipientAttributeDisplay = false; foreach ($recipientAttributeStatus as $value) { if ($value['active']) { $recipientAttributeDisplay = true; break; } } $profileRowCount = 0; $recipientAttributesArray = array('recipient_sex', 'recipient_salutation', 'recipient_title', 'recipient_firstname', 'recipient_lastname', 'recipient_position', 'recipient_company', 'recipient_industry', 'recipient_address', 'recipient_city', 'recipient_zip', 'recipient_country', 'recipient_phone', 'recipient_private', 'recipient_mobile', 'recipient_fax', 'recipient_birthday', 'recipient_website'); if ($recipientAttributeDisplay) { foreach ($recipientAttributesArray as $attribute) { if ($recipientAttributeStatus[$attribute]['active'] && $this->_objTpl->blockExists($attribute)) { $this->_objTpl->touchBlock($attribute); $this->_objTpl->setVariable(array('NEWSLETTER_' . strtoupper($attribute) . '_ROW_CLASS' => $profileRowCount % 2 == 0 ? 'row2' : 'row1', 'NEWSLETTER_' . strtoupper($attribute) . '_MANDATORY' => $recipientAttributeStatus[$attribute]['required'] ? '*' : '')); $profileRowCount++; } else { $this->_objTpl->hideBlock($attribute); } } } else { $this->_objTpl->hideBlock('recipientProfileAttributes'); } $filterParams = (!empty($_GET['newsletterListId']) ? '&newsletterListId=' . contrexx_input2raw($_GET['newsletterListId']) : '') . (!empty($_GET['filterkeyword']) ? '&filterkeyword=' . contrexx_input2raw($_GET['filterkeyword']) : '') . (!empty($_GET['filterattribute']) ? '&filterattribute=' . contrexx_input2raw($_GET['filterattribute']) : '') . (!empty($_GET['filterStatus']) ? '&filterStatus=' . contrexx_input2raw($_GET['filterStatus']) : ''); $this->_objTpl->setVariable(array('NEWSLETTER_RECIPIENT_ID' => $recipientId, 'NEWSLETTER_RECIPIENT_EMAIL' => htmlentities($recipientEmail, ENT_QUOTES, CONTREXX_CHARSET), 'TXT_NEWSLETTER_STATUS' => $_ARRAYLANG['TXT_NEWSLETTER_STATUS'], 'TXT_NEWSLETTER_LANGUAGE' => $_ARRAYLANG['TXT_NEWSLETTER_LANGUAGE'], 'TXT_NEWSLETTER_SEND_EMAIL' => $_ARRAYLANG['TXT_NEWSLETTER_SEND_EMAIL'], 'TXT_NEWSLETTER_ASSOCIATED_LISTS' => $_ARRAYLANG['TXT_NEWSLETTER_ASSOCIATED_LISTS'], 'TXT_NEWSLETTER_NOTES' => $_ARRAYLANG['TXT_NEWSLETTER_NOTES'], 'TXT_NEWSLETTER_PROFILE' => $_ARRAYLANG['TXT_NEWSLETTER_PROFILE'], 'TXT_NEWSLETTER_POSITION' => $_ARRAYLANG['TXT_NEWSLETTER_POSITION'], 'TXT_NEWSLETTER_INDUSTRY_SECTOR' => $_ARRAYLANG['TXT_NEWSLETTER_INDUSTRY_SECTOR'], 'TXT_NEWSLETTER_PHONE_MOBILE' => $_ARRAYLANG['TXT_NEWSLETTER_PHONE_MOBILE'], 'TXT_NEWSLETTER_PHONE_PRIVATE' => $_ARRAYLANG['TXT_NEWSLETTER_PHONE_PRIVATE'], 'TXT_NEWSLETTER_FAX' => $_ARRAYLANG['TXT_NEWSLETTER_FAX'], 'NEWSLETTER_RECIPIENT_STATUS' => $recipientStatus == '1' ? 'checked="checked"' : '', 'NEWSLETTER_RECIPIENT_NOTES' => htmlentities($recipientNotes, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_URI' => htmlentities($recipientUri, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_FEMALE' => $recipientSex == 'f' ? 'checked="checked"' : '', 'NEWSLETTER_RECIPIENT_MALE' => $recipientSex == 'm' ? 'checked="checked"' : '', 'NEWSLETTER_RECIPIENT_SALUTATION' => $this->_getRecipientTitleMenu($recipientSalutation, 'name="newsletter_recipient_salutation" style="width:296px" size="1"'), 'NEWSLETTER_RECIPIENT_TITLE' => htmlentities($recipientTitle, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_FIRSTNAME' => htmlentities($recipientFirstname, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_LASTNAME' => htmlentities($recipientLastname, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_POSITION' => htmlentities($recipientPosition, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_COMPANY' => htmlentities($recipientCompany, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_INDUSTRY_SECTOR' => htmlentities($recipientIndustrySector, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_ADDRESS' => htmlentities($recipientAddress, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_ZIP' => htmlentities($recipientZip, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_CITY' => htmlentities($recipientCity, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_COUNTRY' => $this->getCountryMenu($recipientCountry, $recipientAttributeStatus['recipient_country']['active'] && $recipientAttributeStatus['recipient_country']['required']), 'NEWSLETTER_RECIPIENT_PHONE' => htmlentities($recipientPhoneOffice, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_PHONE_MOBILE' => htmlentities($recipientPhoneMobile, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_PHONE_PRIVATE' => htmlentities($recipientPhonePrivate, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_FAX' => htmlentities($recipientFax, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_BIRTHDAY' => htmlentities($recipientBirthday, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_COPY' => $copy ? 1 : 0, 'TXT_NEWSLETTER_EMAIL_ADDRESS' => $_ARRAYLANG['TXT_NEWSLETTER_EMAIL_ADDRESS'], 'TXT_NEWSLETTER_WEBSITE' => $_ARRAYLANG['TXT_NEWSLETTER_WEBSITE'], 'TXT_NEWSLETTER_SALUTATION' => $_ARRAYLANG['TXT_NEWSLETTER_SALUTATION'], 'TXT_NEWSLETTER_TITLE' => $_ARRAYLANG['TXT_NEWSLETTER_TITLE'], 'TXT_NEWSLETTER_SEX' => $_ARRAYLANG['TXT_NEWSLETTER_SEX'], 'TXT_NEWSLETTER_FEMALE' => $_ARRAYLANG['TXT_NEWSLETTER_FEMALE'], 'TXT_NEWSLETTER_MALE' => $_ARRAYLANG['TXT_NEWSLETTER_MALE'], 'TXT_NEWSLETTER_LASTNAME' => $_ARRAYLANG['TXT_NEWSLETTER_LASTNAME'], 'TXT_NEWSLETTER_FIRSTNAME' => $_ARRAYLANG['TXT_NEWSLETTER_FIRSTNAME'], 'TXT_NEWSLETTER_COMPANY' => $_ARRAYLANG['TXT_NEWSLETTER_COMPANY'], 'TXT_NEWSLETTER_ADDRESS' => $_ARRAYLANG['TXT_NEWSLETTER_ADDRESS'], 'TXT_NEWSLETTER_ZIP' => $_ARRAYLANG['TXT_NEWSLETTER_ZIP'], 'TXT_NEWSLETTER_CITY' => $_ARRAYLANG['TXT_NEWSLETTER_CITY'], 'TXT_NEWSLETTER_COUNTRY' => $_ARRAYLANG['TXT_NEWSLETTER_COUNTRY'], 'TXT_NEWSLETTER_PHONE' => $_ARRAYLANG['TXT_NEWSLETTER_PHONE'], 'TXT_NEWSLETTER_BIRTHDAY' => $_ARRAYLANG['TXT_NEWSLETTER_BIRTHDAY'], 'TXT_NEWSLETTER_SAVE' => $_ARRAYLANG['TXT_NEWSLETTER_SAVE'], 'TXT_CANCEL' => $_CORELANG['TXT_CANCEL'], 'TXT_NEWSLETTER_DO_NOT_SEND_EMAIL' => $_ARRAYLANG['TXT_NEWSLETTER_DO_NOT_SEND_EMAIL'], 'TXT_NEWSLETTER_INFO_ABOUT_SEND_EMAIL' => $_ARRAYLANG['TXT_NEWSLETTER_INFO_ABOUT_SEND_EMAIL'], 'TXT_NEWSLETTER_RECIPIENT_DATE' => $_ARRAYLANG['TXT_NEWSLETTER_RECIPIENT_DATE'], 'TXT_NEWSLETTER_RECIPIENT_MONTH' => $_ARRAYLANG['TXT_NEWSLETTER_RECIPIENT_MONTH'], 'TXT_NEWSLETTER_RECIPIENT_YEAR' => $_ARRAYLANG['TXT_NEWSLETTER_RECIPIENT_YEAR'], 'NEWSLETTER_FILTER_PARAMS' => $filterParams)); $this->_objTpl->parse('module_newsletter_user_edit'); return true; }