本文整理汇总了PHP中FWLanguage::getDefaultLangId方法的典型用法代码示例。如果您正苦于以下问题:PHP FWLanguage::getDefaultLangId方法的具体用法?PHP FWLanguage::getDefaultLangId怎么用?PHP FWLanguage::getDefaultLangId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FWLanguage
的用法示例。
在下文中一共展示了FWLanguage::getDefaultLangId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set
/**
* Handles request from the client
* @todo Clean up usage of $param and $_GET
* @global Array $_CORELANG Core language data
* @param Array $params Client parameters
* @return type
*/
public function set($params)
{
global $_CORELANG;
// Global access check
if (!\Permission::checkAccess(6, 'static', true) || !\Permission::checkAccess(35, 'static', true)) {
throw new \Exception($_CORELANG['TXT_CORE_CM_USAGE_DENIED']);
}
$newPage = false;
$reload = false;
$pg = \Env::get('pageguard');
$dataPost = !empty($params['post']) ? $params['post'] : array();
$pageArray = !empty($dataPost['page']) ? $dataPost['page'] : array();
// Only set in the editing mode.
$pageId = !empty($pageArray['id']) ? intval($pageArray['id']) : (!empty($dataPost['pageId']) ? intval($dataPost['pageId']) : 0);
$nodeId = !empty($pageArray['node']) ? intval($pageArray['node']) : (!empty($dataPost['nodeId']) ? intval($dataPost['nodeId']) : 0);
$lang = !empty($pageArray['lang']) ? contrexx_input2raw($pageArray['lang']) : (!empty($dataPost['lang']) ? contrexx_input2raw($dataPost['lang']) : \FWLanguage::getLanguageCodeById(\FWLanguage::getDefaultLangId()));
$action = !empty($dataPost['action']) ? contrexx_input2raw($dataPost['action']) : '';
$cacheManager = new \Cx\Core_Modules\Cache\Controller\CacheManager();
$cacheManager->deleteSingleFile($pageId);
if (!empty($pageArray)) {
if (!empty($pageArray['target']) && !empty($pageArray['target_protocol'])) {
$pageArray['target'] = $pageArray['target_protocol'] . $pageArray['target'];
} elseif (empty($pageArray['target']) && !empty($pageArray['target_protocol'])) {
$pageArray['target'] = '';
}
$validatedPageArray = $this->validatePageArray($pageArray);
}
// UPDATE
if (!empty($pageId)) {
// If we got a page id, the page already exists and can be updated.
$page = $this->pageRepo->find($pageId, 0, null, false);
$node = $page->getNode();
// TRANSLATE
} else {
if (!empty($nodeId) && !empty($lang)) {
// We are translating the page.
$node = $this->nodeRepo->find($nodeId);
$page = $node->translatePage(true, \FWLanguage::getLanguageIdByCode($lang));
$page->setNodeIdShadowed($node->getId());
$page->setEditingStatus('');
$newPage = true;
$reload = true;
// CREATE
} else {
if (empty($pageId) && !empty($lang)) {
if (!\Permission::checkAccess(5, 'static', true)) {
throw new \Exception($_CORELANG['TXT_CORE_CM_CREATION_DENIED']);
}
// Create a new node/page combination.
$node = new \Cx\Core\ContentManager\Model\Entity\Node();
// CREATE WITHIN
if (isset($dataPost['parent_node'])) {
$parentNode = $this->nodeRepo->find($dataPost['parent_node']);
if (!$parentNode) {
$parentNode = $this->nodeRepo->getRoot();
}
$node->setParent($parentNode);
$parentNode->addChildren($node);
// add parent node to ID, so the node containing the new page is opened
if (!isset($_COOKIE['jstree_open'])) {
$_COOKIE['jstree_open'] = '';
}
$openNodes = explode(',', $_COOKIE['jstree_open']);
if ($openNodes == array(0 => '')) {
$openNodes = array();
}
if (!in_array('#node_' . $parentNode->getId(), $openNodes)) {
$openNodes[] = '#node_' . $parentNode->getId();
}
setcookie('jstree_open', implode(',', $openNodes));
$this->em->persist($node);
$this->em->flush();
// CREATE
} else {
$node->setParent($this->nodeRepo->getRoot());
$this->nodeRepo->getRoot()->addChildren($node);
$this->em->persist($node);
$this->em->flush();
}
$page = new \Cx\Core\ContentManager\Model\Entity\Page();
$page->setNode($node);
$node->addPage($page);
$page->setNodeIdShadowed($node->getId());
$page->setLang(\FWLanguage::getLanguageIdByCode($lang));
$page->setUpdatedBy(\FWUser::getFWUserObject()->objUser->getUsername());
$newPage = true;
$reload = true;
} else {
throw new \Exception('Page cannot be created. There are too little information.');
}
}
}
// Page access check
//.........这里部分代码省略.........
示例2: errorHandler
/**
* 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;
}
示例3: 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;
}
示例4: setupPath
/**
* Sanitize tree.
* Translates all missing parent pages in the desired language
* @param int $targetLang Language ID of the branch to sanitize
* @return type
*/
public function setupPath($targetLang)
{
$node = $this->getNode()->getParent();
$pages = $node->getPagesByLang();
$sourceLang = $this->getLang();
if ($targetLang == $sourceLang) {
$sourceLang = \FWLanguage::getDefaultLangId();
}
if (!empty($pages) && !isset($pages[$targetLang])) {
$page = $pages[$sourceLang]->copyToLang($targetLang, true, true, true, true, true, false, true);
$page->setDisplay(false);
\Env::get('em')->persist($page);
// recursion
return $pages[$sourceLang]->setupPath($targetLang);
} else {
return;
}
}
示例5: parseRelatedNews
/**
* 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');
}
}
}
示例6: getMessageInPreferedLanguage
/**
* Select the prefered locale version of a message
* @param array Array containing all localized versions of a message with its language code as index
* @param string Preferend Language code
* @return mixed Either the prefered message as string or NULL if $messages is empty
*/
private function getMessageInPreferedLanguage($messages, $langCode)
{
// check if a message is available
if (empty($messages)) {
return new Message();
}
// return message in selected (=> current interface) language
if (isset($messages[$langCode])) {
return $messages[$langCode];
}
// return message in default language
if (isset($messages[\FWLanguage::getLanguageCodeById(\FWLanguage::getDefaultLangId())])) {
return $messages[\FWLanguage::getLanguageCodeById(\FWLanguage::getDefaultLangId())];
}
// return message in what ever language it is available
reset($messages);
return current($messages);
}
示例7: postResolve
/**
* Do something after resolving is done
*
* @param \Cx\Core\ContentManager\Model\Entity\Page $page The resolved page
*/
public function postResolve(\Cx\Core\ContentManager\Model\Entity\Page $page)
{
// TODO: Deactivated license check for now. Implement new behavior.
return true;
global $plainCmd, $objDatabase, $_CORELANG, $_LANGID, $section;
$license = \Cx\Core_Modules\License\License::getCached(\Env::get('config'), $objDatabase);
switch ($this->cx->getMode()) {
case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND:
if (!$license->isInLegalComponents('fulllanguage') && $_LANGID != \FWLanguage::getDefaultLangId()) {
$_LANGID = \FWLanguage::getDefaultLangId();
\Env::get('Resolver')->redirectToCorrectLanguageDir();
}
if (!empty($section) && !$license->isInLegalFrontendComponents($section)) {
if ($section == 'Error') {
// If the error module is not installed, show this
die($_CORELANG['TXT_THIS_MODULE_DOESNT_EXISTS']);
} else {
//page not found, redirect to error page.
\Cx\Core\Csrf\Controller\Csrf::header('Location: ' . \Cx\Core\Routing\Url::fromModuleAndCmd('Error'));
exit;
}
}
break;
case \Cx\Core\Core\Controller\Cx::MODE_BACKEND:
// check if the requested module is active:
if (!in_array($plainCmd, array('Login', 'noaccess', ''))) {
$query = '
SELECT
modules.is_licensed
FROM
' . DBPREFIX . 'modules AS modules,
' . DBPREFIX . 'backend_areas AS areas
WHERE
areas.module_id = modules.id
AND (
areas.uri LIKE "%cmd=' . contrexx_raw2db($plainCmd) . '&%"
OR areas.uri LIKE "%cmd=' . contrexx_raw2db($plainCmd) . '"
)
';
$res = $objDatabase->Execute($query);
if (!$res->fields['is_licensed']) {
$plainCmd = in_array('LicenseManager', \Env::get('cx')->getLicense()->getLegalComponentsList()) ? 'License' : 'Home';
}
}
// If logged in
if (\Env::get('cx')->getUser()->objUser->login(true)) {
$license->check();
if ($license->getState() == \Cx\Core_Modules\License\License::LICENSE_NOK) {
$plainCmd = in_array('LicenseManager', \Env::get('cx')->getLicense()->getLegalComponentsList()) ? 'License' : 'Home';
$license->save($objDatabase);
}
$lc = \Cx\Core_Modules\License\LicenseCommunicator::getInstance(\Env::get('config'));
$lc->addJsUpdateCode($_CORELANG, $license, $plainCmd == 'License');
}
break;
default:
break;
}
}
示例8: _editDir
/**
* Modify Dir
*
* @access private
* @global array
* @global ADONewConnection
* @global FWLanguage
*/
function _editDir($copy = false)
{
global $_ARRAYLANG, $objDatabase;
$dirid = !empty($_GET['id']) ? intval($_GET['id']) : 0;
if (isset($this->directories[$dirid])) {
$displayMode = $this->directories[$dirid]['displaymode'];
$name = $this->directories[$dirid]['name'];
$description = $this->directories[$dirid]['description'];
$sort = $this->directories[$dirid]['sort'];
$lang = $this->directories[$dirid]['lang'];
$pic1 = $this->directories[$dirid]['pic1'];
$pic2 = $this->directories[$dirid]['pic2'];
} else {
$dirid = 0;
$displayMode = 0;
$name = '';
$description = '';
$sort = 0;
$lang = \FWLanguage::getDefaultLangId();
$pic1 = '';
$pic2 = '';
}
$this->_objTpl->loadTemplateFile('module_memberdir_modifyDir.html');
$this->pageTitle = $dirid > 0 ? $copy ? $_ARRAYLANG['TXT_MEMBERDIR_COPY_DIR'] : $_ARRAYLANG['TXT_EDIT_DIR'] : $_ARRAYLANG['TXT_NEW_DIR'];
$this->_objTpl->setVariable(array('TXT_PIC_UPLOAD' => $_ARRAYLANG['TXT_PIC_UPLOAD'], 'TXT_TITLE' => $dirid > 0 ? $copy ? $_ARRAYLANG['TXT_MEMBERDIR_COPY_DIR'] : $_ARRAYLANG['TXT_EDIT_DIR'] : $_ARRAYLANG['TXT_NEW_DIR'], 'TXT_ACTIVE' => $_ARRAYLANG['TXT_ACTIVE'], 'TXT_NAME' => $_ARRAYLANG['TXT_NAME'], 'TXT_TYPE' => $_ARRAYLANG['TXT_ROW_TYPE'], 'TXT_SAVE' => $_ARRAYLANG['TXT_SAVE'], 'TXT_FIELDS' => $_ARRAYLANG['TXT_FIELDS'], 'TXT_DIR_NAME' => $_ARRAYLANG['TXT_MEMBERDIR_NAME'], 'TXT_MORE_ROW' => $_ARRAYLANG['TXT_MORE_ROW'], 'TXT_ONE_ROW' => $_ARRAYLANG['TXT_ONE_ROW'], 'TXT_DESCRIPTION' => $_ARRAYLANG['TXT_DESCRIPTION'], 'TXT_PARENT_DIR' => $_ARRAYLANG['TXT_PARENT_DIR'], 'TXT_SORT' => $_ARRAYLANG['TXT_SORT'], 'TXT_MEMBERDIR_USER_DEFINED' => $_ARRAYLANG['TXT_MEMBERDIR_USER_DEFINED'], 'TXT_DISPLAY_MODE_BOTH' => $_ARRAYLANG['TXT_DISPLAY_MODE_BOTH'], 'TXT_DISPLAY_MODE_DIR_ONLY' => $_ARRAYLANG['TXT_DISPLAY_MODE_DIR_ONLY'], 'TXT_DISPLAY_MODE_ENTRIES_ONLY' => $_ARRAYLANG['TXT_DISPLAY_MODE_ENTRIES_ONLY'], 'TXT_DISPLAY_MODE' => $_ARRAYLANG['TXT_DISPLAY_MODE'], 'TXT_MEMBERDIR_LANGUAGE' => $_ARRAYLANG['TXT_MEMBERDIR_LANGUAGE']));
$this->_objTpl->setVariable(array('MODE_' . $displayMode . '_CHECKED' => 'checked="checked"', 'PARENT_DIRLIST' => $this->_getDirectoryMenu('name="parentdir" size="1" style="width:300px;"', $dirid), 'MEMBERDIR_ACTION' => $dirid ? '?cmd=MemberDir&act=save' . ($copy ? 'Copy' : 'Edited') . 'Dir&id=' . $dirid : '?cmd=MemberDir&act=saveNewDir', 'MEMBERDIR_DIR_NAME' => htmlentities($name, ENT_QUOTES, CONTREXX_CHARSET), 'MEMBERDIR_DESCRIPTION' => htmlentities($description, ENT_QUOTES, CONTREXX_CHARSET), 'MEMBERDIR_SELECTED_SORT' => $sort, 'MEMBERDIR_LANGUAGE_MENU' => $this->_getLanguageMenu('name="memberdirLangId" size="1" style="width:300px;"', $lang), 'MEMBERDIR_FIELD_PIC_1' => $pic1 ? 'checked="checked"' : '', 'MEMBERDIR_FIELD_PIC_2' => $pic2 ? 'checked="checked"' : ''));
if ($dirid) {
$query = 'SELECT `field`, `dirid`, `name`, `active` FROM `' . DBPREFIX . 'module_memberdir_name` WHERE `dirid` = ' . $dirid;
$objResult = $objDatabase->Execute($query);
if ($objResult !== false) {
while (!$objResult->EOF) {
$this->_objTpl->setVariable(array('MEMBERDIR_FIELD_ACTIVE_' . $objResult->fields['field'] => $objResult->fields['active'] == '1' ? 'checked="checked"' : '', 'MEMBERDIR_FIELD_NAME_' . $objResult->fields['field'] => htmlentities($objResult->fields['name'], ENT_QUOTES, CONTREXX_CHARSET)));
$objResult->MoveNext();
}
} else {
$this->statusMessage = $_ARRAYLANG['TXT_DATABASE_READ_ERROR'];
}
} else {
$arrFieldNames = explode(';', $_ARRAYLANG['TXT_FIELD_DEFAULT_NAMES']);
foreach ($arrFieldNames as $fieldId => $fieldName) {
$this->_objTpl->setVariable(array('MEMBERDIR_FIELD_NAME_' . ($fieldId + 1) => $fieldName, 'MEMBERDIR_FIELD_ACTIVE_' . ($fieldId + 1) => 'checked="checked"'));
}
}
}
示例9: errorHandler
/**
* Tries to fix database problems
*
* Also migrates text fields to the new structure.
* Note that no VAT classes are added here (yet), so neither the old
* nor the new table exists to begin with, the new structure will be
* created with no records.
* @return boolean False. Always.
* @throws Cx\Lib\Update_DatabaseException
*/
static function errorHandler()
{
// Vat
$table_name = DBPREFIX . 'module_shop_vat';
$table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'rate' => array('type' => 'DECIMAL(5,2)', 'unsigned' => true, 'notnull' => true, 'default' => '0.00', 'renamefrom' => 'percent'));
$table_index = array();
$default_lang_id = \FWLanguage::getDefaultLangId();
if (\Cx\Lib\UpdateUtil::table_exist($table_name, 'class')) {
if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'class')) {
// Migrate all Vat classes to the Text table first
\Text::deleteByKey('Shop', self::TEXT_CLASS);
$query = "\n SELECT `id`, `class`\n FROM `{$table_name}`";
$objResult = \Cx\Lib\UpdateUtil::sql($query);
while (!$objResult->EOF) {
$id = $objResult->fields['id'];
$class = $objResult->fields['class'];
if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_CLASS, $class)) {
throw new \Cx\Lib\Update_DatabaseException("Failed to migrate VAT class '{$class}'");
}
$objResult->MoveNext();
}
}
}
\Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
// Always
return false;
}
示例10: translatePage
/**
* Creates a translated page in this node
*
* Does not flush EntityManager.
*
* @param boolean $activate whether the new page should be activated
* @param int $targetLang target language id
* @returns \Cx\Core\ContentManager\Model\Entity\Page the copy
*/
public function translatePage($activate, $targetLang)
{
$type = \Cx\Core\ContentManager\Model\Entity\Page::TYPE_FALLBACK;
$fallback_language = \FWLanguage::getFallbackLanguageIdById($targetLang);
$defaultLang = \FWLanguage::getDefaultLangId();
// copy the corresponding language version (if there is one)
if ($fallback_language && $this->getPage($fallback_language)) {
$pageToTranslate = $this->getPage($fallback_language);
// find best page to copy if no corresponding language version is present
} else {
if ($this->getPage($defaultLang)) {
$pageToTranslate = $this->getPage($defaultLang);
} else {
$pages = $this->getPages();
$pageToTranslate = $pages[0];
}
if (!$fallback_language) {
$type = \Cx\Core\ContentManager\Model\Entity\Page::TYPE_CONTENT;
}
}
// copy page following redirects
$page = $pageToTranslate->copyToLang($targetLang, true, true, true, true, true, false, true);
$page->setActive($activate);
$page->setType($type);
$pageToTranslate->setupPath($targetLang);
return $page;
}
示例11: errorHandler
/**
* Tries to recreate the database table(s) for the class
*
* Should be called whenever there's a problem with the database table.
* @return boolean False. Always.
*/
static function errorHandler()
{
$table_name = DBPREFIX . 'core_country';
$table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'alpha2' => array('type' => 'CHAR(2)', 'notnull' => true, 'default' => ''), 'alpha3' => array('type' => 'CHAR(3)', 'notnull' => true, 'default' => ''), 'ord' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'renamefrom' => 'sort_order'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'renamefrom' => 'is_active'));
\Cx\Lib\UpdateUtil::table($table_name, $table_structure);
if (\Cx\Lib\UpdateUtil::table_empty($table_name)) {
\Text::deleteByKey('core', self::TEXT_NAME);
// Copy the Countries from the Shop module if possible
if (\Cx\Lib\UpdateUtil::table_exist(DBPREFIX . "module_shop_countries")) {
$query = "\n SELECT `countries_id`, `countries_name`,\n `countries_iso_code_2`, `countries_iso_code_3`,\n `activation_status`\n FROM " . DBPREFIX . "module_shop_countries";
$objResult = \Cx\Lib\UpdateUtil::sql($query);
if (!$objResult) {
throw new \Cx\Lib\Update_DatabaseException("Failed to to query Country names", $query);
}
$default_lang_id = \FWLanguage::getDefaultLangId();
while (!$objResult->EOF) {
$id = $objResult->fields['countries_id'];
$name = $objResult->fields['countries_name'];
$alpha2 = $objResult->fields['countries_iso_code_2'];
$alpha3 = $objResult->fields['countries_iso_code_3'];
$active = $objResult->fields['activation_status'];
$ord = 0;
if ($id == 14) {
// fixing missing name
$name = 'Österreich';
}
if (!self::store($alpha2, $alpha3, $default_lang_id, $name, $ord, $active, $id)) {
throw new \Cx\Lib\Update_DatabaseException("Failed to to migrate Country '{$name}'");
}
$objResult->MoveNext();
}
\Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_shop_countries');
}
}
// USE FOR NEW INSTALLATIONS ONLY!
// These records will lead to inconsistencies with Country references in
// other tables otherwise.
if (\Cx\Lib\UpdateUtil::table_empty($table_name)) {
// Add new Country records if available
if (file_exists(ASCMS_CORE_PATH . '/countries_iso_3166-2.php') && (include_once ASCMS_CORE_PATH . '/countries_iso_3166-2.php')) {
//DBG::log("Country::errorHandler(): Included ISO file");
$arrCountries = null;
$ord = 0;
foreach ($arrCountries as $country_id => $arrCountry) {
$name = $arrCountry[0];
$alpha2 = $arrCountry[1];
$alpha3 = $arrCountry[2];
// Not currently in use:
// $numeric = $arrCountry[3];
// $iso_full = $arrCountry[4];
// English (language ID 2) only!
if (!self::store($alpha2, $alpha3, 2, $name, ++$ord, true, $country_id)) {
throw new \Cx\Lib\Update_DatabaseException("Failed to to add Country '{$name}' from ISO file");
}
//DBG::log("Country::errorHandler(): Added Country ID $country_id: '$name'");
}
}
}
//DBG::activate(DBG_ADODB);
// Add more languages from the countries_languages.php file,
// if present
$arrCountries = array();
// $arrCountries is redefined in the file
if (file_exists(ASCMS_CORE_PATH . '/countries_languages.php') && (include_once ASCMS_CORE_PATH . '/countries_languages.php')) {
foreach ($arrCountries as $alpha2 => $arrLanguage) {
//DBG::log("errorHandler: Looking for Alpha-2 $alpha2");
$country_id = self::getIdByAlpha2($alpha2);
if (!$country_id) {
// TODO: Fail or not?
continue;
}
foreach ($arrLanguage as $lang_id => $name) {
if (!\Text::replace($country_id, $lang_id, 'core', self::TEXT_NAME, $name)) {
throw new \Cx\Lib\Update_DatabaseException("Failed to to update Country '{$name}' from languages file");
}
//DBG::log("Country::errorHandler(): Added Country ID $country_id: language ID $lang_id");
}
}
}
\Cx\Core\Setting\Controller\Setting::init('core', 'country');
\Cx\Core\Setting\Controller\Setting::add('numof_countries_per_page_backend', 30, 101);
// More to come...
// Always!
return false;
}
示例12: GetProfileURL
/**
* Return link to the profile of a user
*/
function GetProfileURL($code, $email, $type = self::USER_TYPE_NEWSLETTER)
{
global $_ARRAYLANG, $_CONFIG;
if ($type == self::USER_TYPE_CORE) {
// recipients that will receive the newsletter through the selection of their user group don't have a profile
return '';
}
$profileURI = '?section=Newsletter&cmd=profile&code=' . $code . '&mail=' . urlencode($email);
$uri = ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? NULL : ':' . intval($_SERVER['SERVER_PORT'])) . ASCMS_PATH_OFFSET . '/' . \FWLanguage::getLanguageParameter(\FWLanguage::getDefaultLangId(), 'lang') . '/' . CONTREXX_DIRECTORY_INDEX . $profileURI;
return '<a href="' . $uri . '">' . $_ARRAYLANG['TXT_EDIT_PROFILE'] . '</a>';
}
示例13: errorHandler
/**
* Handles any kind of database error
* @throws Cx\Lib\Update_DatabaseException
* @return boolean False. Always.
*/
static function errorHandler()
{
// ShopCategory
// Fix the Text and Settings table first
\Text::errorHandler();
ShopSettings::errorHandler();
$default_lang_id = \FWLanguage::getDefaultLangId();
$table_name = DBPREFIX . 'module_shop_categories';
$table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true, 'renamefrom' => 'catid'), 'parent_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'parentid'), 'ord' => array('type' => 'INT(5)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'catsorting'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'catstatus'), 'picture' => array('type' => 'VARCHAR(255)', 'default' => ''), 'flags' => array('type' => 'VARCHAR(255)', 'default' => ''));
$table_index = array('flags' => array('fields' => 'flags', 'type' => 'FULLTEXT'));
if (\Cx\Lib\UpdateUtil::table_exist($table_name)) {
if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'catname')) {
// Migrate all ShopCategory names to the Text table first
\Text::deleteByKey('Shop', self::TEXT_NAME);
\Text::deleteByKey('Shop', self::TEXT_DESCRIPTION);
$query = "\n SELECT `catid`, `catname`\n FROM `{$table_name}`";
$objResult = \Cx\Lib\UpdateUtil::sql($query);
if (!$objResult) {
throw new \Cx\Lib\Update_DatabaseException("Failed to query ShopCategory names");
}
while (!$objResult->EOF) {
$id = $objResult->fields['catid'];
$name = $objResult->fields['catname'];
if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) {
throw new \Cx\Lib\Update_DatabaseException("Failed to migrate ShopCategory name '{$name}'");
}
$objResult->MoveNext();
}
}
}
\Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index);
// Always
return false;
}
示例14: resolve
public function resolve()
{
// $this->resolveAlias() also sets $this->page
$aliaspage = $this->resolveAlias();
if ($aliaspage != null) {
$this->lang = $aliaspage->getTargetLangId();
$aliaspage = clone $aliaspage;
$aliaspage->setVirtual(true);
} else {
$this->lang = \Env::get('init')->getFallbackFrontendLangId();
//try to find the language in the url
$extractedLanguage = \FWLanguage::getLanguageIdByCode($this->url->getLangDir());
$activeLanguages = \FWLanguage::getActiveFrontendLanguages();
if (!$extractedLanguage) {
$this->redirectToCorrectLanguageDir();
}
if (!in_array($extractedLanguage, array_keys($activeLanguages))) {
$this->lang = \FWLanguage::getDefaultLangId();
$this->redirectToCorrectLanguageDir();
}
//only set langid according to url if the user has not explicitly requested a language change.
if (!isset($_REQUEST['setLang'])) {
$this->lang = $extractedLanguage;
//the user wants to change the language, but we're still inside the wrong language directory.
} else {
if ($this->lang != $extractedLanguage) {
$this->redirectToCorrectLanguageDir();
}
}
}
// used for LinkGenerator
define('FRONTEND_LANG_ID', $this->lang);
// used to load template file
\Env::get('init')->setFrontendLangId($this->lang);
global $section, $command, $history, $sessionObj, $url, $_CORELANG, $page, $pageId, $themesPages, $page_template, $isRegularPageRequest, $now, $start, $end, $plainSection;
$section = isset($_REQUEST['section']) ? $_REQUEST['section'] : '';
$command = isset($_REQUEST['cmd']) ? contrexx_addslashes($_REQUEST['cmd']) : '';
$history = isset($_REQUEST['history']) ? intval($_REQUEST['history']) : 0;
// Initialize page meta
$page = null;
$pageAccessId = 0;
$page_protected = $pageId = $themesPages = $page_template = null;
// If standalone is set, then we will not have to initialize/load any content page related stuff
$isRegularPageRequest = !isset($_REQUEST['standalone']) || $_REQUEST['standalone'] == 'false';
// Regular page request
if ($isRegularPageRequest) {
// TODO: history (empty($history) ? )
if (isset($_GET['pagePreview']) && $_GET['pagePreview'] == 1 && empty($sessionObj)) {
$sessionObj = \cmsSession::getInstance();
}
$this->init($url, $this->lang, \Env::get('em'), ASCMS_INSTANCE_OFFSET . \Env::get('virtualLanguageDirectory'), \FWLanguage::getFallbackLanguageArray());
try {
$this->resolvePage();
$page = $this->getPage();
// TODO: should this check (for type 'application') moved to \Cx\Core\ContentManager\Model\Entity\Page::getCmd()|getModule() ?
// only set $section and $command if the requested page is an application
$command = $this->getCmd();
$section = $this->getSection();
} catch (\Cx\Core\Routing\ResolverException $e) {
try {
$this->legacyResolve($url, $section, $command);
$page = $this->getPage();
$command = $this->getCmd();
$section = $this->getSection();
} catch (\Cx\Core\Routing\ResolverException $e) {
// legacy resolving also failed.
// provoke a 404
$page = null;
}
}
if (!$page || !$page->isActive()) {
//fallback for inexistant error page
if ($section == 'Error') {
// If the error module is not installed, show this
die($_CORELANG['TXT_THIS_MODULE_DOESNT_EXISTS']);
} else {
//page not found, redirect to error page.
\Cx\Core\Csrf\Controller\Csrf::header('Location: ' . \Cx\Core\Routing\Url::fromModuleAndCmd('Error'));
exit;
}
}
// TODO: question: what do we need this for? I think there is no need for this (had been added in r15026)
//legacy: re-populate cmd and section into $_GET
$_GET['cmd'] = $command;
$_GET['section'] = $section;
// END of TODO question
//check whether the page is active
$now = new \DateTime('now');
$start = $page->getStart();
$end = $page->getEnd();
$pageId = $page->getId();
//access: frontend access id for default requests
$pageAccessId = $page->getFrontendAccessId();
//revert the page if a history param has been given
if ($history) {
//access: backend access id for history requests
$pageAccessId = $page->getBackendAccessId();
$logRepo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\LogEntry');
try {
$logRepo->revert($page, $history);
//.........这里部分代码省略.........
示例15: getTypeByPage
/**
* Returns the type of the page as string.
*
* @param \Cx\Core\ContentManager\Model\Entity\Page $page
* @return string $type
*/
public function getTypeByPage($page)
{
global $_CORELANG;
switch ($page->getType()) {
case \Cx\Core\ContentManager\Model\Entity\Page::TYPE_REDIRECT:
$criteria = array('nodeIdShadowed' => $page->getTargetNodeId(), 'lang' => $page->getLang());
$targetPage = $this->findOneBy($criteria);
$targetTitle = $targetPage ? $targetPage->getTitle() : $page->getTarget();
$type = $_CORELANG['TXT_CORE_CM_TYPE_REDIRECT'] . ': ';
$type .= $targetTitle;
break;
case \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION:
$type = $_CORELANG['TXT_CORE_CM_TYPE_APPLICATION'] . ': ';
$type .= $page->getModule();
$type .= $page->getCmd() != '' ? ' | ' . $page->getCmd() : '';
break;
case \Cx\Core\ContentManager\Model\Entity\Page::TYPE_FALLBACK:
$fallbackLangId = \FWLanguage::getFallbackLanguageIdById($page->getLang());
if ($fallbackLangId == 0) {
$fallbackLangId = \FWLanguage::getDefaultLangId();
}
$type = $_CORELANG['TXT_CORE_CM_TYPE_FALLBACK'] . ' ';
$type .= \FWLanguage::getLanguageCodeById($fallbackLangId);
break;
default:
$type = $_CORELANG['TXT_CORE_CM_TYPE_CONTENT'];
}
return $type;
}