本文整理汇总了PHP中FWLanguage::getActiveFrontendLanguages方法的典型用法代码示例。如果您正苦于以下问题:PHP FWLanguage::getActiveFrontendLanguages方法的具体用法?PHP FWLanguage::getActiveFrontendLanguages怎么用?PHP FWLanguage::getActiveFrontendLanguages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FWLanguage
的用法示例。
在下文中一共展示了FWLanguage::getActiveFrontendLanguages方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*/
function __construct()
{
$this->em = \Env::get('em');
$this->db = \Env::get('db');
if ($this->em) {
$this->pageRepo = $this->em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
$this->nodeRepo = $this->em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Node');
$this->logRepo = $this->em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\LogEntry');
}
$this->messages = array();
$this->tz = new \DateTimeZone('Europe/Berlin');
$fallback_lang_codes = \FWLanguage::getFallbackLanguageArray();
$active_langs = \FWLanguage::getActiveFrontendLanguages();
// get all active languages and their fallbacks
foreach ($active_langs as $lang) {
$this->fallbacks[\FWLanguage::getLanguageCodeById($lang['id'])] = array_key_exists($lang['id'], $fallback_lang_codes) ? \FWLanguage::getLanguageCodeById($fallback_lang_codes[$lang['id']]) : null;
}
}
示例2: tree_to_jstree_array
//.........这里部分代码省略.........
}
$last_resort = 0;
$numberOfPages = 0;
/**
* I (<michael.ritter@comvation.com> cannot recall the reason why to
* get alias pages too but I think there was one (probably not a nice one)
* @todo Write unit tests for CM then try $node->getPages()
* if the above is done do the following too
* @todo Replace $numberOfPages by $pages = $node->getPages(), then just count them
*/
foreach ($node->getPages(false, true) as $page) {
// don't display aliases in cm's tree
if ($page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_ALIAS) {
continue 2;
}
$numberOfPages++;
$user = $page->getUpdatedBy();
$data[\FWLanguage::getLanguageCodeById($page->getLang())] = array('language' => \FWLanguage::getLanguageCodeById($page->getLang()), 'title' => $page->getTitle(), 'attr' => array('id' => $page->getId(), 'data-href' => json_encode(array('slug' => $page->getSlug(), 'path' => $page->getPath(), 'module' => $page->getModule() . ' ' . $page->getCmd(), 'lastupdate' => $page->getUpdatedAt()->format('d.m.Y H:i'), 'level' => $page->getNode()->getLvl(), 'user' => $user)), 'frontend_access_id' => $page->getFrontendAccessId(), 'backend_access_id' => $page->getBackendAccessId(), 'protected' => $page->isFrontendProtected(), 'locked' => $page->isBackendProtected()));
$editingStatus = $page->getEditingStatus();
if ($page->isActive()) {
if ($editingStatus == 'hasDraft') {
$publishingStatus = 'published draft';
} else {
if ($editingStatus == 'hasDraftWaiting') {
$publishingStatus = 'published draft waiting';
} else {
$publishingStatus = 'published';
}
}
} else {
if ($editingStatus == 'hasDraft') {
$publishingStatus = 'unpublished draft';
} else {
if ($editingStatus == 'hasDraftWaiting') {
$publishingStatus = 'unpublished draft waiting';
} else {
$publishingStatus = 'unpublished';
}
}
}
if ($page->isBackendProtected() && !\Permission::checkAccess($page->getBackendAccessId(), 'dynamic', true)) {
$publishingStatus .= ' locked';
}
$metadata[$page->getId()] = array('visibility' => $page->getStatus(), 'publishing' => $publishingStatus);
$last_resort = \FWLanguage::getLanguageCodeById($page->getLang());
}
if ($numberOfPages == 0) {
continue;
}
foreach ($fallback_langs as $lang => $fallback) {
// fallback can be false, array_key_exists does not like booleans
if (!$fallback) {
$fallback = null;
}
if (!array_key_exists($lang, $data) && array_key_exists($fallback, $data)) {
$data[$lang]['language'] = $lang;
$data[$lang]['title'] = $data[$fallback]['title'];
if ($data[$fallback]['attr']['id'] == 'broken') {
$data[$lang]['attr']['id'] = 'broken';
} else {
$data[$lang]['attr']['id'] = '0';
}
} else {
if (!array_key_exists($lang, $data)) {
$data[$lang]['language'] = $lang;
if (array_key_exists($last_resort, $data)) {
$data[$lang]['title'] = $data[$last_resort]['title'];
$data[$lang]['attr']['id'] = '0';
} else {
$data[$lang]['title'] = 'No Title';
$data[$lang]['attr']['id'] = 'broken';
}
}
}
$metadata[0] = array('visibility' => 'active', 'publishing' => 'unpublished');
$metadata['broken'] = array('visibility' => 'broken', 'publishing' => 'unpublished');
}
$state = array();
if (count($node->getChildren()) > 0) {
if ($toggled) {
$state = array('state' => 'open');
} else {
$state = array('state' => 'closed');
}
}
$nodeLevels[$node->getId()] = $node->getLvl();
if (isset($children['nodeLevels'])) {
$nodeLevels = $nodeLevels + $children['nodeLevels'];
}
$tree[] = array_merge(array('attr' => array('id' => 'node_' . $node->getId(), 'rel_id' => $node->getId()), 'data' => array_values($data), 'children' => isset($children['tree']) ? $children['tree'] : array(), 'metadata' => $metadata), $state);
}
$output['tree'] = $tree;
$output['nodeLevels'] = $nodeLevels;
$output['hasHome'] = array();
foreach (\FWLanguage::getActiveFrontendLanguages() as $lang) {
$page = $this->pageRepo->findOneBy(array('module' => 'Home', 'cmd' => '', 'lang' => $lang['id']));
$output['hasHome'][$lang['lang']] = $page ? $page->getId() : false;
}
return $output;
}
示例3: loadPlaceLinkFromMediadir
/**
* 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);
}
示例4: 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;
//.........这里部分代码省略.........
示例5: modifyLanguage
/**
* 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) {
//.........这里部分代码省略.........
示例6: validate
/**
* @prePersist
* @onFlush
*/
public function validate()
{
// Slug must be unique per language and level of a branch (of the node tree)
$slugs = array();
foreach ($this->getNode()->getParent()->getChildren() as $child) {
$page = $child->getPage($this->getLang());
if ($page && $page !== $this) {
$slugs[] = $page->getSlug();
}
}
while ($this->getSlug() == '' || in_array($this->getSlug(), $slugs)) {
$this->nextSlug();
}
// Alias slugs must not be equal to an existing file or folder
if ($this->getType() == self::TYPE_ALIAS) {
$invalidAliasNames = array('admin', 'cache', 'cadmin', 'config', 'core', 'core_modules', 'customizing', 'feed', 'images', 'installer', 'lang', 'lib', 'media', 'model', 'modules', 'themes', 'tmp', 'update', 'webcam', 'favicon.ico');
foreach (\FWLanguage::getActiveFrontendLanguages() as $id => $lang) {
$invalidAliasNames[] = $lang['lang'];
}
if (in_array($this->getSlug(), $invalidAliasNames)) {
$lang = \Env::get('lang');
throw new PageException('Cannot use name of existing files, folders or languages as alias.', $lang['TXT_CORE_CANNOT_USE_AS_ALIAS']);
}
}
//workaround, this method is regenerated each time
parent::validate();
}
示例7: languageOverview
/**
* Set the language list page
*
* @global array
* @global ADONewConnection
* @global \Cx\Core\Html\Sigma
* @return void
*/
function languageOverview()
{
global $_ARRAYLANG, $objDatabase;
// init vars
$i = 0;
\JS::activate('cx');
$cxjs = \ContrexxJavascript::getInstance();
$cxjs->setVariable('copyTitle', $_ARRAYLANG['TXT_LANGUAGE_COPY_TITLE'], 'language/lang');
$cxjs->setVariable('copyText', $_ARRAYLANG['TXT_LANGUAGE_COPY_TEXT'], 'language/lang');
$cxjs->setVariable('copySuccess', $_ARRAYLANG['TXT_LANGUAGE_COPY_SUCCESS'], 'language/lang');
$cxjs->setVariable('linkTitle', $_ARRAYLANG['TXT_LANGUAGE_LINK_TITLE'], 'language/lang');
$cxjs->setVariable('linkText', $_ARRAYLANG['TXT_LANGUAGE_LINK_TEXT'], 'language/lang');
$cxjs->setVariable('linkSuccess', $_ARRAYLANG['TXT_LANGUAGE_LINK_SUCCESS'], 'language/lang');
$cxjs->setVariable('warningTitle', $_ARRAYLANG['TXT_LANGUAGE_WARNING_TITLE'], 'language/lang');
$cxjs->setVariable('warningText', $_ARRAYLANG['TXT_LANGUAGE_WARNING_TEXT'], 'language/lang');
$cxjs->setVariable('waitTitle', $_ARRAYLANG['TXT_LANGUAGE_WAIT_TITLE'], 'language/lang');
$cxjs->setVariable('waitText', $_ARRAYLANG['TXT_LANGUAGE_WAIT_TEXT'], 'language/lang');
$cxjs->setVariable('yesOption', $_ARRAYLANG['TXT_YES'], 'language/lang');
$cxjs->setVariable('noOption', $_ARRAYLANG['TXT_NO'], 'language/lang');
$this->template->loadTemplateFile('language_langlist.html');
$this->pageTitle = $_ARRAYLANG['TXT_LANGUAGE_LIST'];
if (!$this->isInFullMode()) {
$this->hideVariables = true;
$this->template->hideBlock('extendedTitles');
$this->template->hideBlock('extendedHeaders');
} else {
$this->template->touchBlock('extendedTitles');
}
//begin language variables
$this->template->setVariable(array('TXT_ADD_NEW_LANGUAGE' => $_ARRAYLANG['TXT_ADD_NEW_LANGUAGE'], 'TXT_NAME' => $_ARRAYLANG['TXT_NAME'], 'TXT_SHORT_NAME' => $_ARRAYLANG['TXT_SHORT_NAME'], 'TXT_CHARSET' => $_ARRAYLANG['TXT_CHARSET'], 'TXT_ADD' => $_ARRAYLANG['TXT_ADD'], 'TXT_LANGUAGE_LIST' => $_ARRAYLANG['TXT_LANGUAGE_LIST'], 'TXT_ID' => $_ARRAYLANG['TXT_ID'], 'TXT_SHORT_FORM' => $_ARRAYLANG['TXT_SHORT_FORM'], 'TXT_STANDARD_LANGUAGE' => $_ARRAYLANG['TXT_STANDARD_LANGUAGE'], 'TXT_ACTION' => $_ARRAYLANG['TXT_ACTION'], 'TXT_ACCEPT_CHANGES' => $_ARRAYLANG['TXT_ACCEPT_CHANGES'], 'TXT_REMARK' => $_ARRAYLANG['TXT_REMARK'], 'TXT_ADD_DELETE_LANGUAGE_REMARK' => $_ARRAYLANG['TXT_ADD_DELETE_LANGUAGE_REMARK'], 'TXT_CONFIRM_DELETE_DATA' => $_ARRAYLANG['TXT_CONFIRM_DELETE_DATA'], 'TXT_ACTION_IS_IRREVERSIBLE' => $_ARRAYLANG['TXT_ACTION_IS_IRREVERSIBLE'], 'TXT_VALUE' => $_ARRAYLANG['TXT_VALUE'], 'TXT_MODULE' => $_ARRAYLANG['TXT_MODULE'], 'TXT_LANGUAGE' => $_ARRAYLANG['TXT_LANGUAGE'], 'TXT_STATUS' => $_ARRAYLANG['TXT_STATUS'], 'TXT_VIEW' => $_ARRAYLANG['TXT_VIEW'], 'TXT_CONTROLLED' => $_ARRAYLANG['TXT_CONTROLLED'], 'TXT_OPEN_ISSUE' => $_ARRAYLANG['TXT_OPEN_ISSUE'], 'TXT_SHORT_NAME' => $_ARRAYLANG['TXT_SHORT_NAME'], 'TXT_LANGUAGE_DEPENDANT_SYSTEM_VARIABLES' => $_ARRAYLANG['TXT_LANGUAGE_DEPENDANT_SYSTEM_VARIABLES'], 'TXT_ADMINISTRATION_PAGES' => $_ARRAYLANG['TXT_ADMINISTRATION_PAGES'], 'TXT_WEB_PAGES' => $_ARRAYLANG['TXT_WEB_PAGES'], 'TXT_SECTION' => $_ARRAYLANG['TXT_SECTION'], 'TXT_CORE_FALLBACK' => $_ARRAYLANG['TXT_CORE_FALLBACK']));
$this->template->setGlobalVariable(array('TXT_DEFAULT_LANGUAGE' => $_ARRAYLANG['TXT_STANDARD_LANGUAGE'], 'TXT_CORE_NONE' => $_ARRAYLANG['TXT_CORE_NONE'], 'CMD' => contrexx_input2xhtml($_GET['cmd']), 'TXT_LANGUAGE_ACTION_COPY' => $_ARRAYLANG['TXT_LANGUAGE_ACTION_COPY'], 'TXT_LANGUAGE_ACTION_LINK' => $_ARRAYLANG['TXT_LANGUAGE_ACTION_LINK']));
//end language variables
if ($this->hideVariables == true) {
$this->template->setGlobalVariable(array('LANGUAGE_ADMIN_STYLE' => 'display: none'));
} else {
$this->template->setGlobalVariable(array('LANGUAGE_ADMIN_STYLE' => 'display: block'));
}
$arrLanguages = \FWLanguage::getActiveFrontendLanguages();
$objResult = $objDatabase->Execute("SELECT * FROM " . DBPREFIX . "languages ORDER BY id");
if ($objResult !== false) {
while (!$objResult->EOF) {
$checked = "";
if ($objResult->fields['is_default'] == "true") {
$checked = "checked";
}
$status = "<input type='radio' name='langDefaultStatus' onchange='updateCurrent();' value='" . $objResult->fields['id'] . "' {$checked} />";
$checked = "";
if ($objResult->fields['frontend'] == 1) {
$checked = "checked";
}
$activeStatus = "<input type='checkbox' name='langActiveStatus[" . $objResult->fields['id'] . "]' onchange='updateCurrent();' value='1' {$checked} />";
$checked = "";
if ($objResult->fields['backend'] == 1) {
$checked = "checked";
}
$selectedLang = '';
switch ($objResult->fields['fallback']) {
case '':
$this->template->setVariable('NONE_SELECTED', 'selected="selected"');
break;
case '0':
$this->template->setVariable('LANGUAGE_DEFAULT_SELECTED', 'selected="selected"');
break;
default:
$selectedLang = $objResult->fields['fallback'];
}
// set fallback language drop down
foreach ($arrLanguages as $langId => $arrLanguage) {
$selected = $langId == $selectedLang ? 'selected="selected"' : '';
$this->template->setVariable(array('LANGUAGE_LANG_ID' => $langId, 'LANGUAGE_LANG_OPTION' => contrexx_raw2xhtml($arrLanguage['name']), 'LANGUAGE_OPTION_SELECTED' => $selected));
$this->template->parse('fallbackLanguages');
}
$adminStatus = "<input type='checkbox' name='langAdminStatus[" . $objResult->fields['id'] . "]' value='1' {$checked} />";
$this->template->setVariable(array('LANGUAGE_ROWCLASS' => 'row' . ($i++ % 2 + 1), 'LANGUAGE_LANG_ID' => $objResult->fields['id'], 'LANGUAGE_LANG_NAME' => $objResult->fields['name'], 'LANGUAGE_LANG_SHORTNAME' => $objResult->fields['lang'], 'LANGUAGE_LANG_CHARSET' => $objResult->fields['charset'], 'LANGUAGE_LANG_STATUS' => $status, 'LANGUAGE_ACTIVE_STATUS' => $activeStatus, 'LANGUAGE_ADMIN_STATUS' => $adminStatus));
if (!$this->isInFullMode()) {
$this->template->hideBlock('extendedOptions');
}
$this->template->parse('languageRow');
$objResult->MoveNext();
}
}
}
示例8: recheckSelectedLinks
/**
* Recheck the selected links status
*
* @global array $_ARRAYLANG
*
* @return null
*/
public function recheckSelectedLinks()
{
global $_ARRAYLANG;
$selectedIds = isset($_POST['selected']) ? $_POST['selected'] : '';
$links = $this->linkRepository->getSelectedLinks($selectedIds);
if (!$links) {
$links = array();
}
$request = new \HTTP_Request2();
$pageLinks = array();
foreach ($links as $link) {
if (!in_array($link->getEntryTitle(), $pageLinks)) {
$pageLinks[] = $link->getEntryTitle();
${$link->getEntryTitle()} = array();
try {
$request->setUrl($link->getRefererPath());
$request->setConfig(array('ssl_verify_peer' => false, 'ssl_verify_host' => false, 'follow_redirects' => true));
$response = $request->send();
$html = \str_get_html($response->getBody());
} catch (\Exception $e) {
$html = false;
}
if (!$html) {
continue;
} else {
//remove the navigation menu
$objNavigation = $html->find('ul#navigation, ul.navigation', 0);
$objNavigation->outertext = '';
$html = \str_get_html($html->outertext);
// Find all images
foreach ($html->find('img') as $element) {
if (preg_match('#\\.(jpg|jpeg|gif|png)$# i', $element->src)) {
$imgSrc = \Cx\Core_Modules\LinkManager\Controller\Url::checkPath($element->src, null);
if (!empty($imgSrc)) {
${$link->getEntryTitle()}[$imgSrc] = $_ARRAYLANG['TXT_CORE_MODULE_LINKMANAGER_NO_IMAGE'];
}
}
}
// Find all links
foreach ($html->find('a') as $element) {
$aHref = \Cx\Core_Modules\LinkManager\Controller\Url::checkPath($element->href, $link->getRefererPath());
if (!empty($aHref)) {
$linkText = $element->plaintext ? $element->plaintext : $_ARRAYLANG['TXT_CORE_MODULE_LINKMANAGER_NO_LINK'];
${$link->getEntryTitle()}[$aHref] = $linkText;
}
}
}
}
if (!array_key_exists($link->getRequestedPath(), ${$link->getEntryTitle()})) {
$linkInputValues = array('lang' => $link->getLang(), 'refererPath' => $link->getRefererPath(), 'leadPath' => $link->getLeadPath(), 'entryTitle' => $link->getEntryTitle(), 'detectedTime' => $link->getDetectedTime(), 'updatedBy' => 0);
$this->recheckPage(${$link->getEntryTitle()}, $linkInputValues, $request);
$this->em->remove($link);
} else {
try {
$request->setUrl($link->getRequestedPath());
$response = $request->send();
$urlStatus = $response->getStatus();
} catch (\Exception $e) {
$urlStatus = 0;
}
if ($urlStatus == '200') {
$this->em->remove($link);
} else {
$link->setLinkStatusCode($urlStatus);
$link->setLinkRecheck(true);
}
}
$this->em->persist($link);
$this->em->flush();
}
//update the broken links count in crawler table
foreach (\FWLanguage::getActiveFrontendLanguages() as $lang) {
$lastRunByLang = $this->crawlerRepository->getLastRunByLang($lang['id']);
$brokenLinkCnt = $this->linkRepository->brokenLinkCountByLang($lang['id']);
if ($lastRunByLang) {
$lastRunByLang->setTotalBrokenLinks($brokenLinkCnt);
$this->em->persist($lastRunByLang);
}
}
$this->em->flush();
\Message::ok($_ARRAYLANG['TXT_CORE_MODULE_LINKMANAGER_SUCCESS_MSG']);
}
示例9: activateLanguages
/**
* activate selected languages for the corresponding theme
*
* @return array result
*/
public function activateLanguages()
{
$themeTypes = array(\Cx\Core\View\Model\Entity\Theme::THEME_TYPE_WEB, \Cx\Core\View\Model\Entity\Theme::THEME_TYPE_MOBILE, \Cx\Core\View\Model\Entity\Theme::THEME_TYPE_PRINT, \Cx\Core\View\Model\Entity\Theme::THEME_TYPE_PDF, \Cx\Core\View\Model\Entity\Theme::THEME_TYPE_APP);
$themeId = isset($_POST['themeId']) ? $_POST['themeId'] : 0;
$themeType = isset($_POST['themeType']) && array_key_exists($_POST['themeType'], $themeTypes) ? intval($_POST['themeType']) : 0;
$selectThemeNotInLanguages = array();
$themeRepository = new \Cx\Core\View\Model\Repository\ThemeRepository();
if (!empty($themeId)) {
$theme = $themeRepository->findById($themeId);
$selectThemeNotInLanguages = array_diff_key(\FWLanguage::getActiveFrontendLanguages(), array_flip($theme->getLanguagesByType($themeTypes[$themeType])));
}
foreach ($selectThemeNotInLanguages as $selectThemeNotInLanguage) {
$result[] = array("lang_id" => $selectThemeNotInLanguage['id'], "lang_name" => $selectThemeNotInLanguage['name']);
}
return $result;
}
示例10: getPages
/**
* Get pages
*
* @return Doctrine\Common\Collections\Collection $pages
*/
public function getPages($inactive_langs = false, $aliases = false)
{
$repo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
foreach ($this->pages as $i => $page) {
if (!is_int($page)) {
continue;
}
$this->pages[$i] = $repo->find($page);
}
if ($inactive_langs) {
return $this->pages;
}
$activeLangs = \FWLanguage::getActiveFrontendLanguages();
$pages = array();
foreach ($this->pages as $page) {
if (in_array($page->getLang(), array_keys($activeLangs)) || $aliases && $page->getLang() == 0) {
$pages[] = $page;
}
}
return $pages;
}
示例11: installModules
function installModules()
{
global $objDatabase;
$em = \Env::get('em');
$nodeRepo = $em->getRepository('\\Cx\\Core\\ContentManager\\Model\\Entity\\Node');
//$i = 1;
if (empty($_POST['installModule']) || !is_array($_POST['installModule'])) {
return false;
}
//$currentTime = time();
$paridarray = array();
foreach (array_keys($_POST['installModule']) as $moduleId) {
$id = intval($moduleId);
$objResult = $objDatabase->Execute("\n SELECT name\n FROM " . DBPREFIX . "modules\n WHERE id={$id}\n ");
if ($objResult) {
if (!$objResult->EOF) {
$module_name = $objResult->fields['name'];
}
} else {
$this->errorHandling();
return false;
}
// get content from repo
$query = "SELECT *\n FROM " . DBPREFIX . "module_repository\n WHERE moduleid={$id}\n ORDER BY parid ASC";
$objResult = $objDatabase->Execute($query);
if ($objResult) {
while (!$objResult->EOF) {
// define parent node
$root = false;
if (isset($paridarray[$objResult->fields['parid']])) {
$parcat = $paridarray[$objResult->fields['parid']];
} else {
$root = true;
$parcat = $nodeRepo->getRoot();
}
$this->arrayInstalledModules[$module_name] = true;
$sourceMode = !empty($objResult->fields['expertmode']) && $objResult->fields['expertmode'] == 'y' ? true : false;
// create node
$newnode = new \Cx\Core\ContentManager\Model\Entity\Node();
$newnode->setParent($parcat);
// replace root node by parent!
$em->persist($newnode);
$em->flush();
$nodeRepo->moveDown($newnode, true);
// move to the end of this level
$paridarray[$objResult->fields['id']] = $newnode;
// add content to default lang
// add content to all langs without fallback
// link content to all langs with fallback
foreach (\FWLanguage::getActiveFrontendLanguages() as $lang) {
if ($lang['is_default'] === 'true' || $lang['fallback'] == null) {
$page = $this->createPage($newnode, $lang['id'], $objResult->fields['title'], \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION, $module_name, $objResult->fields['cmd'], !$root && $objResult->fields['displaystatus'], $sourceMode, $objResult->fields['content']);
} else {
$page = $this->createPage($newnode, $lang['id'], $objResult->fields['title'], \Cx\Core\ContentManager\Model\Entity\Page::TYPE_FALLBACK, $module_name, $objResult->fields['cmd'], !$root && $objResult->fields['displaystatus'], $sourceMode, '');
}
$em->persist($page);
}
$em->flush();
$objResult->MoveNext();
}
} else {
$this->errorHandling();
return false;
}
}
// end foreach
return true;
}
示例12: setLanguagePlaceholders
/**
* Sets the language placeholders in the provided template
* @param \Cx\Core\Routing\Url $pageUrl
* @param \Cx\Core\Html\Sigma $objTemplate
*/
public function setLanguagePlaceholders($page, $pageUrl, $objTemplate)
{
$activeLanguages = \FWLanguage::getActiveFrontendLanguages();
$node = $page->getNode();
$placeholders = array();
foreach ($activeLanguages as $langId => $langData) {
$url = clone $pageUrl;
$url->setLangDir($langData['lang']);
if (($targetPage = $node->getPage($langId)) && $targetPage->isActive()) {
$url->setPath(substr($targetPage->getPath(), 1));
$link = $url->__toString();
} else {
$link = $url->fromModuleAndCmd('Error', '', $langId);
}
$placeholders['LANG_CHANGE_' . strtoupper($langData['lang'])] = $link;
$placeholders['LANG_SELECTED_' . strtoupper($langData['lang'])] = '';
}
$placeholders['LANG_SELECTED_' . strtoupper($pageUrl->getLangDir())] = 'selected';
$objTemplate->setVariable($placeholders);
}
示例13: getLanguageIcons
/**
* Generates code for ContentManager style language state icons
*
* For $languageStates you may supply an array in one of these to forms:
*
* $languageStates = array(
* {language id} => 'active','inactive','inexistent',
* )
*
* $languageStates = array(
* {language id} => array(
* 'active' => {bool},
* 'page' => {page id or object},
* ),
* )
*
* The latter will be resolved to the first form. The two forms can be mixed.
*
* For $link, supply a hyperlink, that may contain %1$d and %2$s which will be
* replaced with the language ID and code.
*
* @param array $languageStates Language states to get icons for
* @param string $link Hyperlink for language icons
* @return string The HTML code for the elements
*/
public static function getLanguageIcons(&$languageStates, $link)
{
// resolve second to first form
foreach ($languageStates as $langId => $state) {
if (is_array($state)) {
if (is_object($state['page'])) {
$languageStates[$langId] = $state['active'] ? 'active' : 'inactive';
} else {
$em = \Env::get('cx')->getDb()->getEntityManager();
$pageRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
$page = $pageRepo->findOneById($state['page']);
if (!$page) {
$languageStates[$langId] = 'inexistent';
} else {
$languageStates[$langId] = $state['active'] ? 'active' : 'inactive';
}
}
}
}
// parse icons
$content = '<div class="language-icons">';
foreach (\FWLanguage::getActiveFrontendLanguages() as $language) {
if (isset($languageStates[$language['id']])) {
$state = $languageStates[$language['id']];
} else {
$state = 'inactive';
}
$parsedLink = sprintf($link, $language['id'], $language['lang']);
$content .= self::getLanguageIcon($language['id'], $state, $parsedLink, strtoupper($language['lang']));
}
return $content . '</div>';
}
示例14: loadPagesFromModuleRepository
/**
* Loads pages from module repository
* @param int $moduleId the module id
* @return boolean True on success, false if no pages found in repo
*/
protected function loadPagesFromModuleRepository($moduleId)
{
$cx = \Env::get('cx');
$em = $cx->getDb()->getEntityManager();
$id = $moduleId;
$nodeRepo = $em->getRepository('\\Cx\\Core\\ContentManager\\Model\\Entity\\Node');
$pageRepo = $em->getRepository('\\Cx\\Core\\ContentManager\\Model\\Entity\\Page');
$module_name = $this->componentName;
// get content from repo
$query = '
SELECT
`id`,
`moduleid`,
`content`,
`title`,
`cmd`,
`expertmode`,
`parid`,
`displaystatus`,
`username`,
`displayorder`
FROM
`' . DBPREFIX . 'module_repository`
WHERE
`moduleid` = ' . $id . '
ORDER BY
`parid` ASC
';
$objResult = $cx->getDb()->getAdoDb()->query($query);
if ($objResult->EOF) {
// no pages
return false;
}
$paridarray = array();
while (!$objResult->EOF) {
// define parent node
$root = false;
if (isset($paridarray[$objResult->fields['parid']])) {
$parcat = $paridarray[$objResult->fields['parid']];
} else {
$root = true;
$parcat = $nodeRepo->getRoot();
}
// create node
$newnode = new \Cx\Core\ContentManager\Model\Entity\Node();
$newnode->setParent($parcat);
// replace root node by parent!
$em->persist($newnode);
$em->flush();
$nodeRepo->moveDown($newnode, true);
// move to the end of this level
$paridarray[$objResult->fields['id']] = $newnode;
// add content to default lang
// add content to all langs without fallback
// link content to all langs with fallback
foreach (\FWLanguage::getActiveFrontendLanguages() as $lang) {
if ($lang['is_default'] === 'true' || $lang['fallback'] == null) {
$page = $pageRepo->createPage($newnode, $lang['id'], $objResult->fields['title'], \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION, $module_name, $objResult->fields['cmd'], !$root && $objResult->fields['displaystatus'], $objResult->fields['content']);
} else {
$page = $pageRepo->createPage($newnode, $lang['id'], $objResult->fields['title'], \Cx\Core\ContentManager\Model\Entity\Page::TYPE_FALLBACK, $module_name, $objResult->fields['cmd'], !$root && $objResult->fields['displaystatus'], '');
}
$em->persist($page);
}
$em->flush();
$objResult->MoveNext();
}
return true;
}
示例15: 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);
//.........这里部分代码省略.........