本文整理汇总了PHP中FWLanguage类的典型用法代码示例。如果您正苦于以下问题:PHP FWLanguage类的具体用法?PHP FWLanguage怎么用?PHP FWLanguage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FWLanguage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getXHtml
/**
* @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();
}
示例2: __construct
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');
}
示例3: __construct
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;
}
示例4: renderElement
/**
* 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);
}
示例5: init
/**
* 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;
}
示例6: addDatepickerJs
/**
* 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 . '"]);
});
');
}
示例7: getEmailTempLang
/**
* 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;
}
示例8: errorHandler
/**
* 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;
}
示例9: errorHandler
/**
* 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;
}
示例10: setLangDir
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));
}
}
}
示例11: getCode
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;
}
示例12: getPagesPointingTo
/**
* 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;
}
示例13: errorHandler
/**
* 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;
}
示例14: showEventList
/**
* 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;
//.........这里部分代码省略.........
示例15: _showFeed
/**
* 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();
}