/** * 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; } }
/** * Converts a tree level to JSON * @param Cx\Core\ContentManager\Model\Entity\Node $root Root node of the current level * @param Array $logs List of all logs (used to get the username) * @return String JSON data */ private function tree_to_jstree_array($root, $flat = false, &$actions = null) { $fallback_langs = $this->fallbacks; $sorted_tree = array(); foreach ($root->getChildren() as $node) { $sorted_tree[$node->getLft()] = $node; } ksort($sorted_tree); // get open nodes $open_nodes = array(); if (isset($_COOKIE['jstree_open'])) { $tmp_open_nodes = explode(',', $_COOKIE['jstree_open']); foreach ($tmp_open_nodes as $node) { $node_id = substr($node, 6); $open_nodes[$node_id] = true; } } $output = array(); $tree = array(); $nodeLevels = array(); foreach ($sorted_tree as $node) { $data = array(); $metadata = array(); $children = array(); // if this node is expanded (toggled) $toggled = isset($open_nodes[$node->getId()]) && $open_nodes[$node->getId()]; if (!$flat || $toggled) { $children = $this->tree_to_jstree_array($node, $flat); } $last_resort = 0; $numberOfPages = 0; /** * I (<*****@*****.**> 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; }
/** * 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); }
/** * Sets the placeholders used for the event list view * * @param object $objTpl Template object * @param integer $type Event type * * @return null */ function showEventList($objTpl, $type = '') { global $objInit, $_ARRAYLANG, $_LANGID; parent::getFrontendLanguages(); //if($objInit->mode == 'backend') { $i = 0; foreach ($this->eventList as $key => $objEvent) { $objCategory = new \Cx\Modules\Calendar\Controller\CalendarCategory(intval($objEvent->catId)); $showIn = explode(",", $objEvent->showIn); $languages = ''; if (count(\FWLanguage::getActiveFrontendLanguages()) > 1) { $langState = array(); foreach ($this->arrFrontendLanguages as $langKey => $arrLang) { if (in_array($arrLang['id'], $showIn)) { $langState[$langKey] = 'active'; } } $languages = \Html::getLanguageIcons($langState, 'index.php?cmd=Calendar&act=modify_event&id=' . $objEvent->id . '&langId=%1$d' . ($type == 'confirm' ? "&confirm=1" : "")); if ($type == 'confirm' && $objTpl->blockExists('txt_languages_block_confirm_list')) { $objTpl->touchBlock('txt_languages_block_confirm_list'); } elseif ($objTpl->blockExists('txt_languages_block')) { $objTpl->touchBlock('txt_languages_block'); } } else { if ($type == 'confirm' && $objTpl->blockExists('txt_languages_block_confirm_list')) { $objTpl->hideBlock('txt_languages_block_confirm_list'); } elseif ($objTpl->blockExists('txt_languages_block')) { $objTpl->hideBlock('txt_languages_block'); } } list($priority, $priorityImg) = $this->getPriorityImage($objEvent); $plainDescription = contrexx_html2plaintext($objEvent->description); if (strlen($plainDescription) > 100) { $points = '...'; } else { $points = ''; } $parts = explode("\n", wordwrap($plainDescription, 100, "\n")); $attachNamePos = strrpos($objEvent->attach, '/'); $attachNamelength = strlen($objEvent->attach); $attachName = substr($objEvent->attach, $attachNamePos + 1, $attachNamelength); if ($objEvent->external) { $objHost = new \Cx\Modules\Calendar\Controller\CalendarHost($objEvent->hostId); if (substr($objHost->uri, -1) != '/') { $hostUri = $objHost->uri . '/'; } else { $hostUri = $objHost->uri; } if (substr($hostUri, 0, 7) != 'http://') { $hostUri = "http://" . $hostUri; } } $copyLink = ''; if ($objInit->mode == 'backend') { $editLink = 'index.php?cmd=' . $this->moduleName . '&act=modify_event&id=' . $objEvent->id . ($type == 'confirm' ? "&confirm=1" : ""); $copyLink = $editLink . "&copy=1"; } else { $editLink = CONTREXX_DIRECTORY_INDEX . '?section=' . $this->moduleName . '&cmd=edit&id=' . $objEvent->id; } $picThumb = file_exists(\Env::get('cx')->getWebsitePath() . "{$objEvent->pic}.thumb") ? "{$objEvent->pic}.thumb" : ($objEvent->pic != '' ? $objEvent->pic : ''); $placeLink = $objEvent->place_link != '' ? "<a href='" . $objEvent->place_link . "' target='_blank' >" . $objEvent->place_link . "</a>" : ""; $placeLinkSource = $objEvent->place_link; if ($this->arrSettings['placeData'] > 1 && $objEvent->locationType == 2) { $objEvent->loadPlaceFromMediadir($objEvent->place_mediadir_id, 'place'); list($placeLink, $placeLinkSource) = $objEvent->loadPlaceLinkFromMediadir($objEvent->place_mediadir_id, 'place'); } $hostLink = $objEvent->org_link != '' ? "<a href='" . $objEvent->org_link . "' target='_blank' >" . $objEvent->org_link . "</a>" : ""; $hostLinkSource = $objEvent->org_link; if ($this->arrSettings['placeDataHost'] > 1 && $objEvent->hostType == 2) { $objEvent->loadPlaceFromMediadir($objEvent->host_mediadir_id, 'host'); list($hostLink, $hostLinkSource) = $objEvent->loadPlaceLinkFromMediadir($objEvent->host_mediadir_id, 'host'); } $objTpl->setVariable(array($this->moduleLangVar . '_EVENT_ROW' => $i % 2 == 0 ? 'row1' : 'row2', $this->moduleLangVar . '_EVENT_LED' => $objEvent->status == 0 ? 'red' : 'green', $this->moduleLangVar . '_EVENT_STATUS' => $objEvent->status == 0 ? $_ARRAYLANG['TXT_CALENDAR_INACTIVE'] : $_ARRAYLANG['TXT_CALENDAR_ACTIVE'], $this->moduleLangVar . '_EVENT_ID' => $objEvent->id, $this->moduleLangVar . '_EVENT_TITLE' => $objEvent->title, $this->moduleLangVar . '_EVENT_PICTURE' => $objEvent->pic != '' ? '<img src="' . $objEvent->pic . '" alt="' . $objEvent->title . '" title="' . $objEvent->title . '" />' : '', $this->moduleLangVar . '_EVENT_PICTURE_SOURCE' => $objEvent->pic, $this->moduleLangVar . '_EVENT_THUMBNAIL' => $objEvent->pic != '' ? '<img src="' . $picThumb . '" alt="' . $objEvent->title . '" title="' . $objEvent->title . '" />' : '', $this->moduleLangVar . '_EVENT_PRIORITY' => $priority, $this->moduleLangVar . '_EVENT_PRIORITY_IMG' => $priorityImg, $this->moduleLangVar . '_EVENT_PLACE' => $objEvent->place, $this->moduleLangVar . '_EVENT_DESCRIPTION' => $objEvent->description, $this->moduleLangVar . '_EVENT_SHORT_DESCRIPTION' => $parts[0] . $points, $this->moduleLangVar . '_EVENT_LINK' => $objEvent->link ? "<a href='" . $objEvent->link . "' target='_blank' >" . $objEvent->link . "</a>" : "", $this->moduleLangVar . '_EVENT_LINK_SOURCE' => $objEvent->link, $this->moduleLangVar . '_EVENT_ATTACHMENT' => $objEvent->attach != '' ? '<a href="' . $hostUri . $objEvent->attach . '" target="_blank" >' . $attachName . '</a>' : '', $this->moduleLangVar . '_EVENT_ATTACHMENT_SOURCE' => $objEvent->attach, $this->moduleLangVar . '_EVENT_START' => date(parent::getDateFormat() . " H:i", $objEvent->startDate), $this->moduleLangVar . '_EVENT_END' => date(parent::getDateFormat() . " H:i", $objEvent->endDate), $this->moduleLangVar . '_EVENT_DATE' => date(parent::getDateFormat(), $objEvent->startDate), $this->moduleLangVar . '_EVENT_START_DATE' => date(parent::getDateFormat(), $objEvent->startDate), $this->moduleLangVar . '_EVENT_START_TIME' => date("H:i", $objEvent->startDate), $this->moduleLangVar . '_EVENT_END_DATE' => date(parent::getDateFormat(), $objEvent->endDate), $this->moduleLangVar . '_EVENT_END_TIME' => date("H:i", $objEvent->endDate), $this->moduleLangVar . '_EVENT_LANGUAGES' => $languages, $this->moduleLangVar . '_EVENT_CATEGORY' => $objCategory->name, $this->moduleLangVar . '_EVENT_DETAIL_LINK' => $objEvent->type == 0 ? self::_getDetailLink($objEvent) : $objEvent->arrData['redirect'][$_LANGID], $this->moduleLangVar . '_EVENT_EDIT_LINK' => $editLink, $this->moduleLangVar . '_EVENT_COPY_LINK' => $copyLink, $this->moduleLangVar . '_EVENT_DETAIL_TARGET' => $objEvent->type == 0 ? '_self' : '_blank', $this->moduleLangVar . '_EVENT_SERIES' => $objEvent->seriesStatus == 1 ? '<img src="' . ASCMS_MODULE_WEB_PATH . '/' . $this->moduleName . '/View/Media/Repeat.png" border="0"/>' : '<i>' . $_ARRAYLANG['TXT_CALENDAR_NO_SERIES'] . '</i>', $this->moduleLangVar . '_EVENT_FREE_PLACES' => $objEvent->freePlaces, $this->moduleLangVar . '_EVENT_ACCESS' => $_ARRAYLANG['TXT_CALENDAR_EVENT_ACCESS_' . $objEvent->access])); $hasPlaceMap = !empty($objEvent->place_map) && file_exists(\Env::get('cx')->getWebsitePath() . $objEvent->place_map); if ($hasPlaceMap) { $arrInfo = getimagesize(\Env::get('cx')->getWebsitePath() . $objEvent->place_map); $picWidth = $arrInfo[0] + 20; $picHeight = $arrInfo[1] + 20; } $map_thumb_name = file_exists(\Env::get('cx')->getWebsitePath() . $objEvent->place_map . ".thumb") ? $objEvent->place_map . ".thumb" : $objEvent->place_map; $objTpl->setVariable(array($this->moduleLangVar . '_EVENT_LOCATION_PLACE' => $objEvent->place, $this->moduleLangVar . '_EVENT_LOCATION_ADDRESS' => $objEvent->place_street, $this->moduleLangVar . '_EVENT_LOCATION_ZIP' => $objEvent->place_zip, $this->moduleLangVar . '_EVENT_LOCATION_CITY' => $objEvent->place_city, $this->moduleLangVar . '_EVENT_LOCATION_COUNTRY' => $objEvent->place_country, $this->moduleLangVar . '_EVENT_LOCATION_LINK' => $placeLink, $this->moduleLangVar . '_EVENT_LOCATION_LINK_SOURCE' => $placeLinkSource, $this->moduleLangVar . '_EVENT_LOCATION_MAP_LINK' => $hasPlaceMap ? '<a href="' . $objEvent->place_map . '" onClick="window.open(this.href,\'\',\'resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,width=' . $picWidth . ',height=' . $picHeight . ',status\'); return false">' . $_ARRAYLANG['TXT_CALENDAR_MAP'] . '</a>' : "", $this->moduleLangVar . '_EVENT_LOCATION_MAP_THUMBNAIL' => $hasPlaceMap ? '<a href="' . $objEvent->place_map . '" onClick="window.open(this.href,\'\',\'resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,width=' . $picWidth . ',height=' . $picHeight . ',status\'); return false"><img src="' . $map_thumb_name . '" border="0" alt="' . $objEvent->place_map . '" /></a>' : "", $this->moduleLangVar . '_EVENT_LOCATION_MAP_SOURCE' => $hasPlaceMap ? $objEvent->place_map : '', $this->moduleLangVar . '_EVENT_HOST' => $objEvent->org_name, $this->moduleLangVar . '_EVENT_HOST_ADDRESS' => $objEvent->org_street, $this->moduleLangVar . '_EVENT_HOST_ZIP' => $objEvent->org_zip, $this->moduleLangVar . '_EVENT_HOST_CITY' => $objEvent->org_city, $this->moduleLangVar . '_EVENT_HOST_COUNTRY' => $objEvent->org_country, $this->moduleLangVar . '_EVENT_HOST_LINK' => $hostLink, $this->moduleLangVar . '_EVENT_HOST_LINK_SOURCE' => $hostLinkSource, $this->moduleLangVar . '_EVENT_HOST_EMAIL' => $objEvent->org_email != '' ? "<a href='mailto:" . $objEvent->org_email . "' >" . $objEvent->org_email . "</a>" : "", $this->moduleLangVar . '_EVENT_HOST_EMAIL_SOURCE' => $objEvent->org_email)); if ($objInit->mode == 'backend') { $objTpl->setVariable(array($this->moduleLangVar . '_EVENT_COUNT_REG' => $objEvent->registrationCount, $this->moduleLangVar . '_EVENT_COUNT_DEREG' => $objEvent->cancellationCount, $this->moduleLangVar . '_EVENT_COUNT_WAITLIST' => $objEvent->waitlistCount)); } $i++; // show date block if ($objTpl->blockExists('calendarDateList')) { $showStartDateList = $objEvent->useCustomDateDisplay ? $objEvent->showStartDateList : $this->arrSettings['showStartDateList'] == 1; $showEndDateList = $objEvent->useCustomDateDisplay ? $objEvent->showEndDateList : $this->arrSettings['showEndDateList'] == 1; $showStartTimeList = $objEvent->all_day ? false : ($objEvent->useCustomDateDisplay ? $objEvent->showStartTimeList : $this->arrSettings['showStartTimeList'] == 1); $showEndTimeList = $objEvent->all_day ? false : ($objEvent->useCustomDateDisplay ? $objEvent->showEndTimeList : $this->arrSettings['showEndTimeList'] == 1); $showTimeTypeList = $objEvent->useCustomDateDisplay ? $objEvent->showTimeTypeList : 1; // get date for several days format > show starttime with startdate and endtime with enddate > only if several days event and all values (dates/times) are displayed if (date(parent::getDateFormat(), $objEvent->startDate) != date(parent::getDateFormat(), $objEvent->endDate) && ($showStartDateList && $showEndDateList && $showStartTimeList && $showEndTimeList)) { //part 1 $part = 1; $this->getMultiDateBlock($objEvent, $this->arrSettings['separatorDateTimeList'], $this->arrSettings['separatorSeveralDaysList'], $this->arrSettings['showClockList'] == 1, $part); $objTpl->setVariable(array($this->moduleLangVar . '_DATE_LIST' => $this->date, $this->moduleLangVar . '_SEP_DATE_TIME_LIST' => $this->sepDateTime, $this->moduleLangVar . '_TIME_LIST' => $this->time, 'TXT_' . $this->moduleLangVar . '_CLOCK_LIST' => $this->clock)); $objTpl->parse('calendarDateList'); //part 2 $part = 2; $this->getMultiDateBlock($objEvent, $this->arrSettings['separatorDateTimeList'], $this->arrSettings['separatorSeveralDaysList'], $this->arrSettings['showClockList'] == 1, $part); $objTpl->setVariable(array($this->moduleLangVar . '_DATE_LIST' => $this->date, $this->moduleLangVar . '_SEP_DATE_TIME_LIST' => $this->sepDateTime, $this->moduleLangVar . '_TIME_LIST' => $this->time, 'TXT_' . $this->moduleLangVar . '_CLOCK_LIST' => $this->clock)); $objTpl->parse('calendarDateList'); } else { // get date for single day format $this->getSingleDateBlock($objEvent, $showStartDateList, $showEndDateList, $this->arrSettings['separatorDateList'], $showTimeTypeList, $showStartTimeList, $showEndTimeList, $this->arrSettings['separatorDateTimeList'], $this->arrSettings['separatorTimeList'], $this->arrSettings['showClockList'] == 1); $objTpl->setVariable(array($this->moduleLangVar . '_DATE_LIST' => $this->date, $this->moduleLangVar . '_SEP_DATE_TIME_LIST' => $this->sepDateTime, $this->moduleLangVar . '_TIME_LIST' => $this->time, 'TXT_' . $this->moduleLangVar . '_CLOCK_LIST' => $this->clock)); $objTpl->parse('calendarDateList'); } } if ($type == 'confirm') { if ($objTpl->blockExists('eventConfirmList')) { $objTpl->parse('eventConfirmList'); } } else { if ($objTpl->blockExists('eventList')) { $objTpl->parse('eventList'); } if ($objTpl->blockExists('calendar_headlines_row')) { $objTpl->parse('calendar_headlines_row'); } } } if (count($this->eventList) == 0 && $type != 'confirm') { $objTpl->hideBlock('eventList'); $objTpl->setVariable(array('TXT_' . $this->moduleLangVar . '_NO_EVENTS' => $_ARRAYLANG['TXT_CALENDAR_EVENTS_NO'])); $objTpl->parse('emptyEventList'); } //} }
/** * add and modify language values * * @global array * @global ADONewConnection * @return boolean True on success, false on failure */ function modifyLanguage() { global $_ARRAYLANG, $_CONFIG, $objDatabase; $langRemovalStatus = isset($_POST['removeLangVersion']) ? contrexx_input2raw($_POST['removeLangVersion']) : false; if (!empty($_POST['submit']) and isset($_POST['addLanguage']) && $_POST['addLanguage'] == "true") { //----------------------------------------------- // Add new language with all variables //----------------------------------------------- if (!empty($_POST['newLangName']) and !empty($_POST['newLangShortname'])) { $newLangShortname = addslashes(strip_tags($_POST['newLangShortname'])); $newLangName = addslashes(strip_tags($_POST['newLangName'])); $newLangCharset = addslashes(strip_tags($_POST['newLangCharset'])); $objResult = $objDatabase->Execute("SELECT lang FROM " . DBPREFIX . "languages WHERE lang='" . $newLangShortname . "'"); if ($objResult !== false) { if ($objResult->RecordCount() >= 1) { $this->strErrMessage = $_ARRAYLANG['TXT_DATABASE_QUERY_ERROR']; return false; } else { $objDatabase->Execute("INSERT INTO " . DBPREFIX . "languages SET lang='" . $newLangShortname . "',\n name='" . $newLangName . "',\n charset='" . $newLangCharset . "',\n is_default='false'"); $newLanguageId = $objDatabase->Insert_ID(); if (!empty($newLanguageId)) { $objResult = $objDatabase->SelectLimit("SELECT id FROM " . DBPREFIX . "languages WHERE is_default='true'", 1); if ($objResult !== false && !$objResult->EOF) { $defaultLanguage = $objResult->fields['id']; $objResult = $objDatabase->Execute("SELECT varid,content,module FROM " . DBPREFIX . "language_variable_content WHERE 1 AND lang=" . $defaultLanguage); if ($objResult !== false) { while (!$objResult->EOF) { $arrayLanguageContent[$objResult->fields['varid']] = stripslashes($objResult->fields['content']); $arrayLanguageModule[$objResult->fields['varid']] = $objResult->fields['module']; $objResult->MoveNext(); } foreach ($arrayLanguageContent as $varid => $content) { $LanguageModule = $arrayLanguageModule[$varid]; $objDatabase->Execute("INSERT INTO " . DBPREFIX . "language_variable_content SET varid=" . $varid . ", content='" . addslashes($content) . "', module=" . $LanguageModule . ", lang=" . $newLanguageId . ", status=0"); } $this->strOkMessage = $_ARRAYLANG['TXT_NEW_LANGUAGE_ADDED_SUCCESSFUL']; return true; } } } else { $this->strErrMessage = $_ARRAYLANG['TXT_DATABASE_QUERY_ERROR']; return false; } } } } } elseif (!empty($_POST['submit']) and $_POST['modLanguage'] == "true") { $eventArgs = array('langRemovalStatus' => $langRemovalStatus); $frontendLangIds = array_keys(\FWLanguage::getActiveFrontendLanguages()); $postLangIds = array_keys($_POST['langActiveStatus']); foreach (array_keys(\FWLanguage::getLanguageArray()) as $langId) { $isLangInPost = in_array($langId, $postLangIds); $isLangInFrontend = in_array($langId, $frontendLangIds); if ($isLangInPost == $isLangInFrontend) { continue; } $eventArgs['langData'][] = array('langId' => $langId, 'status' => $isLangInPost && !$isLangInFrontend); } //Trigger the event 'languageStatusUpdate' //if the language is activated/deactivated for frontend if (!empty($eventArgs)) { $evm = \Cx\Core\Core\Controller\Cx::instanciate()->getEvents(); $evm->triggerEvent('languageStatusUpdate', array($eventArgs, new \Cx\Core\Model\RecursiveArrayAccess(array()))); } //----------------------------------------------- // Update languages //----------------------------------------------- foreach ($_POST['langName'] as $id => $name) { $active = 0; if (isset($_POST['langActiveStatus'][$id]) && $_POST['langActiveStatus'][$id] == 1) { $languageCode = \FWLanguage::getLanguageCodeById($id); $pageRepo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page'); $alias = $pageRepo->findBy(array('type' => \Cx\Core\ContentManager\Model\Entity\Page::TYPE_ALIAS, 'slug' => $languageCode), true); if (count($alias)) { if (is_array($alias)) { $alias = $alias[0]; } $id = $alias->getNode()->getId(); $config = \Env::get('config'); $link = 'http://' . $config['domainUrl'] . ASCMS_PATH_OFFSET . '/' . $alias->getSlug(); $lang = \Env::get('lang'); $this->strErrMessage = $lang['TXT_CORE_REMOVE_ALIAS_TO_ACTIVATE_LANGUAGE'] . ':<br /> <a href="index.php?cmd=Alias&act=modify&id=' . $id . '" target="_blank">' . $link . '</a>'; return false; } $active = 1; } $status = "false"; if ($_POST['langDefaultStatus'] == $id) { $status = "true"; } $adminstatus = 0; if (isset($_POST['langAdminStatus'][$id]) && $_POST['langAdminStatus'][$id] == 1) { $adminstatus = 1; } $fallBack = isset($_POST['fallBack'][$id]) && $_POST['fallBack'][$id] != "" ? intval($_POST['fallBack'][$id]) : 'NULL'; $objDatabase->Execute("UPDATE " . DBPREFIX . "languages SET \n name='" . $name . "',\n frontend=" . $active . ",\n is_default='" . $status . "',\n backend='" . $adminstatus . "',\n fallback=" . $fallBack . "\n WHERE id=" . $id); } $this->strOkMessage = $_ARRAYLANG['TXT_DATA_RECORD_UPDATED_SUCCESSFUL']; \FWLanguage::init(); return true; } return false; }
/** * @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(); }
/** * 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(); } } }
/** * 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']); }
/** * 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; }
/** * 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; }
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; }
/** * 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); }
/** * 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>'; }
/** * 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; }
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); } catch (\Gedmo\Exception\UnexpectedValueException $e) { } $logRepo->revert($page, $history); } /* //404 for inactive pages if(($start > $now && $start != null) || ($now > $end && $end != null)) { if ($section == 'Error') { // If the error module is not installed, show this die($_CORELANG['TXT_THIS_MODULE_DOESNT_EXISTS']); } \Cx\Core\Csrf\Controller\Csrf::header('Location: index.php?section=Error&id=404'); exit; }*/ \Env::get('init')->setCustomizedTheme($page->getSkin(), $page->getCustomContent(), $page->getUseSkinForAllChannels()); $themesPages = \Env::get('init')->getTemplates($page); //replace the {NODE_<ID>_<LANG>}- placeholders \LinkGenerator::parseTemplate($themesPages); //TODO: analyze those, take action. //$page_protected = $objResult->fields['protected']; $page_protected = $page->isFrontendProtected(); //$page_access_id = $objResult->fields['frontend_access_id']; $page_template = $themesPages['content']; // Authentification for protected pages // This is only done for regular page requests ($isRegularPageRequest == TRUE) $this->checkPageFrontendProtection($page, $history); //TODO: history } // TODO: refactor system to be able to remove this backward compatibility // Backwards compatibility for code pre Contrexx 3.0 (update) $_GET['cmd'] = $_POST['cmd'] = $_REQUEST['cmd'] = $command; $_GET['section'] = $_POST['section'] = $_REQUEST['section'] = $section; // the system should directly use $this->url->getParamArray() instead of using the super globals $qsArr = $this->url->getParamArray(); foreach ($qsArr as $qsParam => $qsArgument) { $_GET[$qsParam] = $_REQUEST[$qsParam] = $qsArgument; } // To clone any module, use an optional integer cmd suffix. // E.g.: "shop2", "gallery5", etc. // Mind that you *MUST* copy all necessary database tables, and fix any // references to your module (section and cmd parameters, database tables) // using the MODULE_INDEX constant in the right place both in your code // *AND* templates! // See the Shop module for an example. $arrMatch = array(); if (preg_match('/^(\\D+)(\\d+)$/', $section, $arrMatch)) { // The plain section/module name, used below $plainSection = $arrMatch[1]; } else { $plainSection = $section; } // The module index. // An empty or 1 (one) index represents the same (default) module, // values 2 (two) and larger represent distinct instances. $moduleIndex = empty($arrMatch[2]) || $arrMatch[2] == 1 ? '' : $arrMatch[2]; define('MODULE_INDEX', $moduleIndex); // Start page or default page for no section if ($section == 'Home') { if (!\Env::get('init')->hasCustomContent()) { $page_template = $themesPages['home']; } else { $page_template = $themesPages['content']; } } // this is the case for standalone and backend requests if (!$this->page) { return null; } $this->page = clone $this->page; $this->page->setVirtual(); // check for further URL parts to resolve if ($this->page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION && $this->page->getPath() != '/' . $this->url->getSuggestedTargetPath()) { // does this work for fallback(/aliases)? $additionalPath = substr('/' . $this->url->getSuggestedTargetPath(), strlen($this->page->getPath())); $componentController = $this->em->getRepository('Cx\\Core\\Core\\Model\\Entity\\SystemComponent')->findOneBy(array('name' => $this->page->getModule())); if ($componentController) { $parts = explode('/', substr($additionalPath, 1)); $componentController->resolve($parts, $this->page); } } return $this->page; }
/** * Show setttings general page * * @access private */ private function showSettingsGeneral() { global $_CORELANG, $_ARRAYLANG; \JS::activate('jquery'); $this->objTemplate->addBlockfile('CHECKOUT_SETTINGS_CONTENT', 'settings_content', 'module_checkout_settings_general.html'); if (isset($_POST['submit'])) { if (!empty($_POST['epayment_status'])) { //check if the Yellowpay configuration is filled out $arrYellowpay = $this->objSettingsYellowpay->get(); $yellowpayStatus = true; foreach ($arrYellowpay as $value) { $value = trim($value); if (empty($value)) { $yellowpayStatus = false; } } if ($yellowpayStatus) { if ($this->objSettingsGeneral->setEpaymentStatus($_POST['epayment_status'])) { $this->arrStatusMessages['ok'][] = $_ARRAYLANG['TXT_CHECKOUT_SETTINGS_CHANGES_SAVED_SUCCESSFULLY']; } else { $this->arrStatusMessages['alert'][] = $_ARRAYLANG['TXT_CHECKOUT_SETTINGS_CHANGES_COULD_NOT_BE_SAVED']; } } else { $this->arrStatusMessages['alert'][] = $_ARRAYLANG['TXT_CHECKOUT_SETTINGS_GENERAL_EPAYMENT_ACTIVATION_FAILED']; } } else { if ($this->objSettingsGeneral->setEpaymentStatus(0)) { $this->arrStatusMessages['ok'][] = $_ARRAYLANG['TXT_CHECKOUT_SETTINGS_CHANGES_SAVED_SUCCESSFULLY']; } else { $this->arrStatusMessages['alert'][] = $_ARRAYLANG['TXT_CHECKOUT_SETTINGS_CHANGES_COULD_NOT_BE_SAVED']; } } } $pages = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page')->getFromModuleCmdByLang('Checkout'); $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; } } } } $backendLinkURL = isset($pages[$langId]) ? 'index.php?cmd=ContentManager&page=' . $pages[$langId]->getId() . '&tab=content' : 'javascript:void(0);'; $frontendLinkURL = isset($pages[$langId]) ? '../' . \FWLanguage::getLanguageCodeById($langId) . $pages[$langId]->getPath() : 'javascript:void(0);'; $parameterPassingDescription = $_ARRAYLANG['TXT_CHECKOUT_SETTINGS_GENERAL_PARAMETER_PASSING_DESCRIPTION']; $parameterPassingDescription = str_replace('%1$s', '<img src="../modules/Checkout/View/Media/Images/parameter_passing/url.jpg" width="792" height="36" />', $parameterPassingDescription); $parameterPassingDescription = str_replace('%2$s', '<img src="../modules/Checkout/View/Media/Images/parameter_passing/form.jpg" width="612" height="345" />', $parameterPassingDescription); $this->objTemplate->setVariable(array('TXT_CHECKOUT_SETTINGS_GENERAL_STATUS' => $_ARRAYLANG['TXT_CHECKOUT_SETTINGS_GENERAL_STATUS'], 'TXT_CHECKOUT_SETTINGS_GENERAL_EPAYMENT_ACTIVATED' => $_ARRAYLANG['TXT_CHECKOUT_SETTINGS_GENERAL_EPAYMENT_ACTIVATED'], 'TXT_CHECKOUT_SETTINGS_GENERAL_EPAYMENT_ACTIVATED_INFO' => $_ARRAYLANG['TXT_CHECKOUT_SETTINGS_GENERAL_EPAYMENT_ACTIVATED_INFO'], 'CHECKOUT_EPAYMENT_STATUS_CHECKED' => $this->objSettingsGeneral->getEpaymentStatus() ? 'checked="checked"' : '', 'TXT_SAVE' => $_ARRAYLANG['TXT_SAVE'], 'TXT_CHECKOUT_SETTINGS_GENERAL_INFORMATION' => $_ARRAYLANG['TXT_CHECKOUT_SETTINGS_GENERAL_INFORMATION'], 'TXT_CHECKOUT_SETTINGS_GENERAL_MODULE_NAME_TITLE' => $_ARRAYLANG['TXT_CHECKOUT_SETTINGS_GENERAL_MODULE_NAME_TITLE'], 'TXT_CHECKOUT_MODULE_NAME' => $_ARRAYLANG['TXT_CHECKOUT_MODULE_NAME'], 'TXT_CHECKOUT_SETTINGS_GENERAL_MODULE_DESCRIPTION_TITLE' => $_ARRAYLANG['TXT_CHECKOUT_SETTINGS_GENERAL_MODULE_DESCRIPTION_TITLE'], 'TXT_CHECKOUT_SETTINGS_GENERAL_MODULE_DESCRIPTION' => $_ARRAYLANG['TXT_CHECKOUT_SETTINGS_GENERAL_MODULE_DESCRIPTION'], 'TXT_CORE_EDIT_PAGE_LAYOUT' => $_CORELANG['TXT_CORE_EDIT_PAGE_LAYOUT'], 'TXT_CORE_SHOW_FRONTEND_VIEW' => $_CORELANG['TXT_CORE_SHOW_FRONTEND_VIEW'], 'TXT_CHECKOUT_LINKS' => $_ARRAYLANG['TXT_CHECKOUT_LINKS'], 'CHECKOUT_BACKEND_LINK_URL' => $backendLinkURL, 'CHECKOUT_FRONTEND_LINK_URL' => $frontendLinkURL, 'TXT_CHECKOUT_SETTINGS_GENERAL_PARAMETER_PASSING_TITLE' => $_ARRAYLANG['TXT_CHECKOUT_SETTINGS_GENERAL_PARAMETER_PASSING_TITLE'], 'TXT_CHECKOUT_SETTINGS_GENERAL_PARAMETER_PASSING_DESCRIPTION' => $parameterPassingDescription)); $this->objTemplate->touchBlock('settings_content'); }
/** * Initialize the active frontend languages array * * Fetch the active frontend languages from the database and assign those * values into $this->arrFrontendLanguages * * @return null */ function getFrontendLanguages() { // return $arrLanguages; $this->arrFrontendLanguages = \FWLanguage::getActiveFrontendLanguages(); }
/** * Recheck the selected links status * * @return null */ public function recheckSelectedLinks() { global $_ARRAYLANG; //Get the post values $selectedIds = isset($_POST['selected']) ? $_POST['selected'] : ''; $links = $this->linkRepository->getSelectedLinks($selectedIds); if (!$links) { $links = array(); } $pageLinks = array(); foreach ($links as $link) { $refererPath = $link->getRefererPath(); $requestPath = $link->getRequestedPath(); $subLinks = array(); $recheckPage = false; // Get the Links in the referer // Recheck the refer once (on first request of refer) if (array_key_exists($refererPath, $pageLinks)) { $subLinks = $pageLinks[$refererPath]; } else { $pageLinks[$refererPath] = $subLinks = $this->getController('LinkCrawler')->getPageLinks($refererPath); $recheckPage = true; } if ($recheckPage) { $this->recheckPage($link, $subLinks); } // Check whether the request path exists in the referer page // if not exists remove the link if (!array_key_exists($requestPath, $subLinks)) { $this->em->remove($link); } else { $urlStatus = $this->getUrlStatus($link->getRequestedPath()); $link->setLinkStatusCode($urlStatus); $link->setFlagStatus($urlStatus == 200 ? 1 : 0); $link->setLinkRecheck(true); } } //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->flush(); \Message::ok($_ARRAYLANG['TXT_CORE_MODULE_LINKMANAGER_SUCCESS_MSG']); }
public function parseSettingsPage() { global $_ARRAYLANG, $objDatabase; \Cx\Core\Setting\Controller\Setting::init('FileSharing', 'config'); if (!\Cx\Core\Setting\Controller\Setting::getValue('permission', 'FileSharing')) { \Cx\Core\Setting\Controller\Setting::add('permission', 'off'); } if (isset($_POST['save_settings'])) { $this->saveSettings(); } $this->_objTpl->setVariable(array('FILESHARING_INFO' => $_ARRAYLANG["TXT_FILESHARING_SETTINGS_GENERAL_INFORMATION"], 'FILESHARING_MAIL_TEMPLATES' => $_ARRAYLANG["TXT_FILESHARING_MAIL_TEMPLATES"], 'TXT_FILESHARING_SECURITY' => $_ARRAYLANG["TXT_FILESHARING_SECURITY"], 'TXT_FILESHARING_SECURITY_INFO' => $_ARRAYLANG["TXT_FILESHARING_SECURITY_INFO"], 'TXT_FILESHARING_APPLICATION_NAME' => $_ARRAYLANG["TXT_FILESHARING_SETTINGS_GENERAL_MODULE_NAME_TITLE"], 'FILESHARING_APPLICATION_NAME' => $_ARRAYLANG["TXT_FILESHARING_MODULE"], 'TXT_FILESHARING_DESCRIPTION' => $_ARRAYLANG["TXT_FILESHARING_SETTINGS_GENERAL_MODULE_DESCRIPTION_TITLE"], 'FILESHARING_DESCRIPTION' => $_ARRAYLANG["TXT_FILESHARING_SETTINGS_GENERAL_MODULE_DESCRIPTION"], 'TXT_FILESHARING_MANUAL' => $_ARRAYLANG["TXT_FILESHARING_SETTINGS_GENERAL_MODULE_MANUAL_TITLE"], 'FILESHARING_MANUAL' => $_ARRAYLANG["TXT_FILESHARING_SETTINGS_GENERAL_MODULE_MANUAL"])); /** * parse mailtemplates */ $arrActiveSystemFrontendLanguages = \FWLanguage::getActiveFrontendLanguages(); foreach ($arrActiveSystemFrontendLanguages as $activeLang) { $objMailTemplate = $objDatabase->Execute("SELECT `subject`, `content` FROM " . DBPREFIX . "module_filesharing_mail_template WHERE `lang_id` = " . intval($activeLang["id"])); if ($objMailTemplate !== false) { $content = str_replace(array('{', '}'), array('[[', ']]'), $objMailTemplate->fields["content"]); $this->_objTpl->setVariable(array('FILESHARING_MAIL_SUBJECT' => htmlentities($objMailTemplate->fields["subject"], ENT_QUOTES, CONTREXX_CHARSET), 'FILESHARING_MAIL_CONTENT' => htmlentities($content, ENT_QUOTES, CONTREXX_CHARSET))); } $this->_objTpl->setVariable(array('TXT_MAIL_SUBJECT' => $_ARRAYLANG['TXT_MAIL_SUBJECT'], 'TXT_MAIL_CONTENT' => $_ARRAYLANG['TXT_MAIL_CONTENT'], 'LANG_NAME' => $activeLang["name"], 'LANG' => $activeLang["id"])); $this->_objTpl->parse('filesharing_email_template'); } /** * parse permissions */ $oldFilesharingPermission = \Cx\Core\Setting\Controller\Setting::getValue('permission', 'FileSharing'); $objFWUser = \FWUser::getFWUserObject(); if (!is_numeric($oldFilesharingPermission)) { // Get all groups $objGroup = $objFWUser->objGroup->getGroups(); } else { // Get access groups $objGroup = $objFWUser->objGroup->getGroups(array('dynamic' => $oldFilesharingPermission)); $arrAssociatedGroups = $objGroup->getLoadedGroupIds(); } $objGroup = $objFWUser->objGroup->getGroups(); while (!$objGroup->EOF) { $option = '<option value="' . $objGroup->getId() . '">' . htmlentities($objGroup->getName(), ENT_QUOTES, CONTREXX_CHARSET) . ' [' . $objGroup->getType() . ']</option>'; if (in_array($objGroup->getId(), $arrAssociatedGroups)) { $arrAssociatedGroupOptions[] = $option; } else { $arrNotAssociatedGroupOptions[] = $option; } $objGroup->next(); } if (!is_numeric($mediaManageSetting)) { // Get all groups $objGroup = $objFWUser->objGroup->getGroups(); } else { // Get access groups $objGroup = $objFWUser->objGroup->getGroups(array('dynamic' => $mediaManageSetting)); $arrAssociatedManageGroups = $objGroup->getLoadedGroupIds(); } $objGroup = $objFWUser->objGroup->getGroups(); while (!$objGroup->EOF) { $option = '<option value="' . $objGroup->getId() . '">' . htmlentities($objGroup->getName(), ENT_QUOTES, CONTREXX_CHARSET) . ' [' . $objGroup->getType() . ']</option>'; if (in_array($objGroup->getId(), $arrAssociatedManageGroups)) { $arrAssociatedGroupManageOptions[] = $option; } else { $arrNotAssociatedGroupManageOptions[] = $option; } $objGroup->next(); } $this->_objTpl->setVariable(array('FILESHARING_ALLOW_USER_UPLOAD_ON' => $oldFilesharingPermission == 'on' ? 'checked="checked"' : '', 'FILESHARING_ALLOW_USER_UPLOAD_OFF' => $oldFilesharingPermission == 'off' ? 'checked="checked"' : '', 'FILESHARING_ALLOW_USER_UPLOAD_GROUP' => is_numeric($oldFilesharingPermission) ? 'checked="checked"' : '', 'FILESHARING_ACCESS_DISPLAY' => is_numeric($oldFilesharingPermission) ? 'block' : 'none', 'FILESHARING_ACCESS_ASSOCIATED_GROUPS' => implode("\n", $arrAssociatedGroupOptions), 'FILESHARING_ACCESS_NOT_ASSOCIATED_GROUPS' => implode("\n", $arrNotAssociatedGroupOptions), 'FILESHARING_SECURITY' => $_ARRAYLANG["TXT_FILESHARING_SECURITY"])); $this->_objTpl->parse('filesharing_security'); }
/** * Finds a single entity by a set of criteria. * * @param array $criteria * @param boolean $inactive_langs * @return object * @override */ public function findOneBy(array $criteria, $inactive_langs = false, $useResultCache = true) { $activeLangs = \FWLanguage::getActiveFrontendLanguages(); $qb = $this->_em->createQueryBuilder(); $qb->select('p')->from('\\Cx\\Core\\ContentManager\\Model\\Entity\\Page', 'p')->setMaxResults(1); $i = 1; foreach ($criteria as $key => $value) { if ($i == 1) { $qb->where('p.' . $key . ' = ?' . $i)->setParameter($i, $value); } else { $qb->andWhere('p.' . $key . ' = ?' . $i)->setParameter($i, $value); } $i++; } try { $q = $qb->getQuery()->useResultCache($useResultCache); $page = $q->getSingleResult(); } catch (\Doctrine\ORM\NoResultException $e) { $page = null; } if (!$inactive_langs && $page) { if (!in_array($page->getLang(), array_keys($activeLangs))) { return null; } } return $page; }
protected function getLangArray() { $output = array(); // set selected frontend language as first language // jstree does display the tree of the first language $output[] = \FWLanguage::getLanguageCodeById(FRONTEND_LANG_ID); foreach (\FWLanguage::getActiveFrontendLanguages() as $lang) { if ($lang['id'] == FRONTEND_LANG_ID) { continue; } $output[] = \FWLanguage::getLanguageCodeById($lang['id']); } return $output; }
/** * Show modify block * * Show the block modification page * * @access private * @global array * @see blockLibrary::_getBlockContent(), blockLibrary::blockNamePrefix */ private function _showModifyBlock($copy = false) { global $_ARRAYLANG; \JS::activate('cx'); \JS::activate('ckeditor'); \JS::activate('jqueryui'); \JS::registerJS('lib/javascript/tag-it/js/tag-it.min.js'); \JS::registerCss('lib/javascript/tag-it/css/tag-it.css'); $mediaBrowserCkeditor = new MediaBrowser(); $mediaBrowserCkeditor->setCallback('ckeditor_image_button'); $mediaBrowserCkeditor->setOptions(array('id' => 'ckeditor_image_button', 'type' => 'button', 'style' => 'display:none')); $blockId = !empty($_REQUEST['blockId']) ? intval($_REQUEST['blockId']) : 0; $blockCat = 0; $blockName = ''; $blockStart = 0; $blockEnd = 0; $blockRandom = 0; $blockRandom2 = 0; $blockRandom3 = 0; $blockRandom4 = 0; $blockGlobal = 0; $blockDirect = 0; $blockCategory = 0; $blockWysiwygEditor = 1; $blockContent = array(); $blockAssociatedPageIds = array(); $blockLangActive = array(); $blockGlobalAssociatedPageIds = array(); $blockDirectAssociatedPageIds = array(); $blockCategoryAssociatedPageIds = array(); $this->_objTpl->loadTemplateFile('module_block_modify.html'); $this->_objTpl->setGlobalVariable(array('TXT_BLOCK_CONTENT' => $_ARRAYLANG['TXT_BLOCK_CONTENT'], 'TXT_BLOCK_NAME' => $_ARRAYLANG['TXT_BLOCK_NAME'], 'TXT_BLOCK_RANDOM' => $_ARRAYLANG['TXT_BLOCK_RANDOM'], 'TXT_BLOCK_GLOBAL' => $_ARRAYLANG['TXT_BLOCK_SHOW_IN_GLOBAL'], 'TXT_BLOCK_SAVE' => $_ARRAYLANG['TXT_BLOCK_SAVE'], 'TXT_BLOCK_DEACTIVATE' => $_ARRAYLANG['TXT_BLOCK_DEACTIVATE'], 'TXT_BLOCK_ACTIVATE' => $_ARRAYLANG['TXT_BLOCK_ACTIVATE'], 'TXT_DONT_SHOW_ON_PAGES' => $_ARRAYLANG['TXT_DONT_SHOW_ON_PAGES'], 'TXT_SHOW_ON_ALL_PAGES' => $_ARRAYLANG['TXT_SHOW_ON_ALL_PAGES'], 'TXT_SHOW_ON_SELECTED_PAGES' => $_ARRAYLANG['TXT_SHOW_ON_SELECTED_PAGES'], 'TXT_BLOCK_CATEGORY' => $_ARRAYLANG['TXT_BLOCK_CATEGORY'], 'TXT_BLOCK_NONE' => $_ARRAYLANG['TXT_BLOCK_NONE'], 'TXT_BLOCK_SHOW_FROM' => $_ARRAYLANG['TXT_BLOCK_SHOW_FROM'], 'TXT_BLOCK_SHOW_UNTIL' => $_ARRAYLANG['TXT_BLOCK_SHOW_UNTIL'], 'TXT_BLOCK_SHOW_TIMED' => $_ARRAYLANG['TXT_BLOCK_SHOW_TIMED'], 'TXT_BLOCK_SHOW_ALWAYS' => $_ARRAYLANG['TXT_BLOCK_SHOW_ALWAYS'], 'TXT_BLOCK_LANG_SHOW' => $_ARRAYLANG['TXT_BLOCK_SHOW_BLOCK_IN_THIS_LANGUAGE'], 'TXT_BLOCK_BASIC_DATA' => $_ARRAYLANG['TXT_BLOCK_BASIC_DATA'], 'TXT_BLOCK_ADDITIONAL_OPTIONS' => $_ARRAYLANG['TXT_BLOCK_ADDITIONAL_OPTIONS'], 'TXT_BLOCK_SELECTED_PAGES' => $_ARRAYLANG['TXT_BLOCK_SELECTED_PAGES'], 'TXT_BLOCK_AVAILABLE_PAGES' => $_ARRAYLANG['TXT_BLOCK_AVAILABLE_PAGES'], 'TXT_BLOCK_SELECT_ALL' => $_ARRAYLANG['TXT_BLOCK_SELECT_ALL'], 'TXT_BLOCK_UNSELECT_ALL' => $_ARRAYLANG['TXT_BLOCK_UNSELECT_ALL'], 'TXT_BLOCK_GLOBAL_PLACEHOLDERS' => $_ARRAYLANG['TXT_BLOCK_GLOBAL_PLACEHOLDERS'], 'TXT_BLOCK_GLOBAL_PLACEHOLDERS_INFO' => $_ARRAYLANG['TXT_BLOCK_GLOBAL_PLACEHOLDERS_INFO'], 'TXT_BLOCK_DIRECT_PLACEHOLDERS' => $_ARRAYLANG['TXT_BLOCK_DIRECT_PLACEHOLDERS'], 'TXT_BLOCK_DIRECT_PLACEHOLDERS_INFO' => $_ARRAYLANG['TXT_BLOCK_DIRECT_PLACEHOLDERS_INFO'], 'TXT_BLOCK_CATEGORY_PLACEHOLDERS' => $_ARRAYLANG['TXT_BLOCK_CATEGORY_PLACEHOLDERS'], 'TXT_BLOCK_CATEGORY_PLACEHOLDERS_INFO' => $_ARRAYLANG['TXT_BLOCK_CATEGORY_PLACEHOLDERS_INFO'], 'TXT_BLOCK_DISPLAY_TIME' => $_ARRAYLANG['TXT_BLOCK_DISPLAY_TIME'], 'TXT_BLOCK_FORM_DESC' => $_ARRAYLANG['TXT_BLOCK_CONTENT'], 'TXT_BLOCK_USE_WYSIWYG_EDITOR' => $_ARRAYLANG['TXT_BLOCK_USE_WYSIWYG_EDITOR'], 'TXT_BLOCK_TARGETING' => $_ARRAYLANG['TXT_BLOCK_TARGETING'], 'TXT_BLOCK_TARGETING_SHOW_PANE' => $_ARRAYLANG['TXT_BLOCK_TARGETING_SHOW_PANE'], 'TXT_BLOCK_TARGETING_ALL_USERS' => $_ARRAYLANG['TXT_BLOCK_TARGETING_ALL_USERS'], 'TXT_BLOCK_TARGETING_VISITOR_CONDITION_BELOW' => $_ARRAYLANG['TXT_BLOCK_TARGETING_VISITOR_CONDITION_BELOW'], 'TXT_BLOCK_TARGETING_INCLUDE' => $_ARRAYLANG['TXT_BLOCK_TARGETING_INCLUDE'], 'TXT_BLOCK_TARGETING_EXCLUDE' => $_ARRAYLANG['TXT_BLOCK_TARGETING_EXCLUDE'], 'TXT_BLOCK_TARGETING_TYPE_LOCATION' => $_ARRAYLANG['TXT_BLOCK_TARGETING_TYPE_LOCATION'], 'TXT_BLOCK_TARGETING_GEOIP_DISABLED_WARNING' => $_ARRAYLANG['TXT_BLOCK_TARGETING_GEOIP_DISABLED_WARNING'])); $targetingStatus = isset($_POST['targeting_status']) ? contrexx_input2int($_POST['targeting_status']) : 0; $targeting = array(); foreach ($this->availableTargeting as $targetingType) { $targetingArr = isset($_POST['targeting'][$targetingType]) ? $_POST['targeting'][$targetingType] : array(); if (empty($targetingArr)) { continue; } $targeting[$targetingType] = array('filter' => !empty($targetingArr['filter']) && in_array($targetingArr['filter'], array('include', 'exclude')) ? contrexx_input2raw($targetingArr['filter']) : 'include', 'value' => isset($targetingArr['value']) ? contrexx_input2raw($targetingArr['value']) : array()); } if (isset($_POST['block_save_block'])) { $blockCat = !empty($_POST['blockCat']) ? intval($_POST['blockCat']) : 0; $blockContent = isset($_POST['blockFormText_']) ? array_map('contrexx_input2raw', $_POST['blockFormText_']) : array(); $blockName = !empty($_POST['blockName']) ? contrexx_input2raw($_POST['blockName']) : $_ARRAYLANG['TXT_BLOCK_NO_NAME']; $blockStart = strtotime($_POST['inputStartDate']); $blockEnd = strtotime($_POST['inputEndDate']); $blockRandom = !empty($_POST['blockRandom']) ? intval($_POST['blockRandom']) : 0; $blockRandom2 = !empty($_POST['blockRandom2']) ? intval($_POST['blockRandom2']) : 0; $blockRandom3 = !empty($_POST['blockRandom3']) ? intval($_POST['blockRandom3']) : 0; $blockRandom4 = !empty($_POST['blockRandom4']) ? intval($_POST['blockRandom4']) : 0; $blockWysiwygEditor = isset($_POST['wysiwyg_editor']) ? 1 : 0; $blockLangActive = isset($_POST['blockFormLanguages']) ? array_map('intval', $_POST['blockFormLanguages']) : array(); // placeholder configurations // global block // 0 = not activated , 1 = on all pages , 2 = selected pages $blockGlobal = !empty($_POST['blockGlobal']) ? intval($_POST['blockGlobal']) : 0; // direct block and category block placeholders // 0 = on all pages , 1 = selected pages $blockDirect = !empty($_POST['blockDirect']) ? intval($_POST['blockDirect']) : 0; $blockCategory = !empty($_POST['blockCategory']) ? intval($_POST['blockCategory']) : 0; // block on page relations for each placeholder $blockGlobalAssociatedPageIds = isset($_POST['globalSelectedPagesList']) ? array_map('intval', explode(",", $_POST['globalSelectedPagesList'])) : array(); $blockDirectAssociatedPageIds = isset($_POST['directSelectedPagesList']) ? array_map('intval', explode(",", $_POST['directSelectedPagesList'])) : array(); $blockCategoryAssociatedPageIds = isset($_POST['categorySelectedPagesList']) ? array_map('intval', explode(",", $_POST['categorySelectedPagesList'])) : array(); if ($blockId) { if ($this->_updateBlock($blockId, $blockCat, $blockContent, $blockName, $blockStart, $blockEnd, $blockRandom, $blockRandom2, $blockRandom3, $blockRandom4, $blockWysiwygEditor, $blockLangActive)) { if ($this->storePlaceholderSettings($blockId, $blockGlobal, $blockDirect, $blockCategory, $blockGlobalAssociatedPageIds, $blockDirectAssociatedPageIds, $blockCategoryAssociatedPageIds)) { $this->storeTargetingSettings($blockId, $targetingStatus, $targeting); \Cx\Core\Csrf\Controller\Csrf::header('location: index.php?cmd=Block&modified=true&blockname=' . $blockName); exit; } } $this->_strErrMessage = $_ARRAYLANG['TXT_BLOCK_BLOCK_COULD_NOT_BE_UPDATED']; } else { if ($blockId = $this->_addBlock($blockCat, $blockContent, $blockName, $blockStart, $blockEnd, $blockRandom, $blockRandom2, $blockRandom3, $blockRandom4, $blockWysiwygEditor, $blockLangActive)) { if ($this->storePlaceholderSettings($blockId, $blockGlobal, $blockDirect, $blockCategory, $blockGlobalAssociatedPageIds, $blockDirectAssociatedPageIds, $blockCategoryAssociatedPageIds)) { $this->storeTargetingSettings($blockId, $targetingStatus, $targeting); \Cx\Core\Csrf\Controller\Csrf::header('location: index.php?cmd=Block&added=true&blockname=' . $blockName); exit; } } $this->_strErrMessage = $_ARRAYLANG['TXT_BLOCK_BLOCK_COULD_NOT_BE_ADDED']; } } elseif (($arrBlock = $this->_getBlock($blockId)) !== false) { $blockStart = $arrBlock['start']; $blockEnd = $arrBlock['end']; $blockCat = $arrBlock['cat']; $blockRandom = $arrBlock['random']; $blockRandom2 = $arrBlock['random2']; $blockRandom3 = $arrBlock['random3']; $blockRandom4 = $arrBlock['random4']; $blockWysiwygEditor = $arrBlock['wysiwyg_editor']; $blockContent = $arrBlock['content']; $blockLangActive = $arrBlock['lang_active']; $blockName = $arrBlock['name']; $blockGlobal = $arrBlock['global']; $blockDirect = $arrBlock['direct']; $blockCategory = $arrBlock['category']; $blockGlobalAssociatedPageIds = $this->_getAssociatedPageIds($blockId, 'global'); $blockDirectAssociatedPageIds = $this->_getAssociatedPageIds($blockId, 'direct'); $blockCategoryAssociatedPageIds = $this->_getAssociatedPageIds($blockId, 'category'); $targeting = $this->loadTargetingSettings($blockId); if (!empty($targeting)) { $targetingStatus = 1; } } $pageTitle = $blockId != 0 ? sprintf($copy ? $_ARRAYLANG['TXT_BLOCK_COPY_BLOCK'] : $_ARRAYLANG['TXT_BLOCK_MODIFY_BLOCK'], contrexx_raw2xhtml($blockName)) : $_ARRAYLANG['TXT_BLOCK_ADD_BLOCK']; $this->_pageTitle = $pageTitle; if ($copy) { $blockId = 0; } $this->_objTpl->setVariable(array('BLOCK_ID' => $blockId, 'BLOCK_MODIFY_TITLE' => $pageTitle, 'BLOCK_NAME' => contrexx_raw2xhtml($blockName), 'BLOCK_CATEGORIES_PARENT_DROPDOWN' => $this->_getCategoriesDropdown($blockCat), 'BLOCK_START' => !empty($blockStart) ? strftime('%Y-%m-%d %H:%M', $blockStart) : $blockStart, 'BLOCK_END' => !empty($blockEnd) ? strftime('%Y-%m-%d %H:%M', $blockEnd) : $blockEnd, 'BLOCK_WYSIWYG_EDITOR' => $blockWysiwygEditor == 1 ? 'checked="checked"' : '', 'BLOCK_RANDOM' => $blockRandom == '1' ? 'checked="checked"' : '', 'BLOCK_RANDOM_2' => $blockRandom2 == '1' ? 'checked="checked"' : '', 'BLOCK_RANDOM_3' => $blockRandom3 == '1' ? 'checked="checked"' : '', 'BLOCK_RANDOM_4' => $blockRandom4 == '1' ? 'checked="checked"' : '', 'BLOCK_GLOBAL_0' => $blockGlobal == '0' ? 'checked="checked"' : '', 'BLOCK_GLOBAL_1' => $blockGlobal == '1' ? 'checked="checked"' : '', 'BLOCK_GLOBAL_2' => $blockGlobal == '2' ? 'checked="checked"' : '', 'BLOCK_GLOBAL_SHOW_PAGE_SELECTOR' => $blockGlobal == '2' ? 'block' : 'none', 'BLOCK_DIRECT_0' => $blockDirect == '0' ? 'checked="checked"' : '', 'BLOCK_DIRECT_1' => $blockDirect == '1' ? 'checked="checked"' : '', 'BLOCK_DIRECT_SHOW_PAGE_SELECTOR' => $blockDirect == '1' ? 'block' : 'none', 'BLOCK_CATEGORY_0' => $blockCategory == '0' ? 'checked="checked"' : '', 'BLOCK_CATEGORY_1' => $blockCategory == '1' ? 'checked="checked"' : '', 'BLOCK_CATEGORY_SHOW_PAGE_SELECTOR' => $blockCategory == '1' ? 'block' : 'none', 'BLOCK_WYSIWYG_MEDIABROWSER' => $mediaBrowserCkeditor->getXHtml(), 'BLOCK_TARGETING_ALL_USERS' => $targetingStatus == 0 ? 'checked="checked"' : '', 'BLOCK_TARGETING_VISITOR_CONDITION_BELOW' => $targetingStatus == 1 ? 'checked="checked"' : '', 'BLOCK_TARGETING_COUNTRY_INCLUDE' => !empty($targeting['country']) && $targeting['country']['filter'] == 'include' ? 'selected="selected"' : '', 'BLOCK_TARGETING_COUNTRY_EXCLUDE' => !empty($targeting['country']) && $targeting['country']['filter'] == 'exclude' ? 'selected="selected"' : '')); if (!empty($targeting['country']) && !empty($targeting['country']['value'])) { foreach ($targeting['country']['value'] as $countryId) { $countryName = \Cx\Core\Country\Controller\Country::getNameById($countryId); if (empty($countryName)) { continue; } $this->_objTpl->setVariable(array('BLOCK_TARGET_COUNTRY_ID' => contrexx_raw2xhtml($countryId), 'BLOCK_TARGET_COUNTRY_NAME' => contrexx_raw2xhtml($countryName))); $this->_objTpl->parse('block_targeting_country'); } } $jsonData = new \Cx\Core\Json\JsonData(); $pageTitlesTree = $jsonData->data('node', 'getPageTitlesTree'); $pageTitlesTree = $pageTitlesTree['data']; $objJs = \ContrexxJavascript::getInstance(); $blockGlobalPageSelects = $this->getPageSelections($pageTitlesTree, $blockGlobalAssociatedPageIds); $blockDirectPageSelects = $this->getPageSelections($pageTitlesTree, $blockDirectAssociatedPageIds); $blockCategoryPageSelects = $this->getPageSelections($pageTitlesTree, $blockCategoryAssociatedPageIds); $objJs->setVariable('globalPagesUnselectedOptions', $jsonData->json($blockGlobalPageSelects[1]), 'block'); $objJs->setVariable('globalPagesSelectedOptions', $jsonData->json($blockGlobalPageSelects[0]), 'block'); $objJs->setVariable('directPagesUnselectedOptions', $jsonData->json($blockDirectPageSelects[1]), 'block'); $objJs->setVariable('directPagesSelectedOptions', $jsonData->json($blockDirectPageSelects[0]), 'block'); $objJs->setVariable('categoryPagesUnselectedOptions', $jsonData->json($blockCategoryPageSelects[1]), 'block'); $objJs->setVariable('categoryPagesSelectedOptions', $jsonData->json($blockCategoryPageSelects[0]), 'block'); $objJs->setVariable('ckeditorconfigpath', substr(\Env::get('ClassLoader')->getFilePath(ASCMS_CORE_PATH . '/Wysiwyg/ckeditor.config.js.php'), strlen(ASCMS_DOCUMENT_ROOT) + 1), 'block'); $arrActiveSystemFrontendLanguages = \FWLanguage::getActiveFrontendLanguages(); $this->parseLanguageOptionsByPlaceholder($arrActiveSystemFrontendLanguages, 'global'); $this->parseLanguageOptionsByPlaceholder($arrActiveSystemFrontendLanguages, 'direct'); $this->parseLanguageOptionsByPlaceholder($arrActiveSystemFrontendLanguages, 'category'); if (count($arrActiveSystemFrontendLanguages) > 0) { $intLanguageCounter = 0; $arrLanguages = array(0 => '', 1 => '', 2 => ''); $strJsTabToDiv = ''; foreach ($arrActiveSystemFrontendLanguages as $langId => $arrLanguage) { $boolLanguageIsActive = $blockId == 0 && $intLanguageCounter == 0 ? true : (isset($blockLangActive[$langId]) && $blockLangActive[$langId] == 1 ? true : false); $arrLanguages[$intLanguageCounter % 3] .= '<input id="languagebar_' . $langId . '" ' . ($boolLanguageIsActive ? 'checked="checked"' : '') . ' type="checkbox" name="blockFormLanguages[' . $langId . ']" value="1" onclick="switchBoxAndTab(this, \'lang_blockContent_' . $langId . '\');" /><label for="languagebar_' . $langId . '">' . contrexx_raw2xhtml($arrLanguage['name']) . ' [' . $arrLanguage['lang'] . ']</label><br />'; $strJsTabToDiv .= 'arrTabToDiv["lang_blockContent_' . $langId . '"] = "langTab_' . $langId . '";' . "\n"; ++$intLanguageCounter; } $this->_objTpl->setVariable(array('TXT_BLOCK_LANGUAGE' => $_ARRAYLANG['TXT_BLOCK_LANGUAGE'], 'EDIT_LANGUAGES_1' => $arrLanguages[0], 'EDIT_LANGUAGES_2' => $arrLanguages[1], 'EDIT_LANGUAGES_3' => $arrLanguages[2], 'EDIT_JS_TAB_TO_DIV' => $strJsTabToDiv)); } $arrLanguages = \FWLanguage::getLanguageArray(); $i = 0; $activeFlag = 0; foreach ($arrLanguages as $langId => $arrLanguage) { if ($arrLanguage['frontend'] != 1) { continue; } $tmpBlockContent = isset($blockContent[$langId]) ? $blockContent[$langId] : ''; $tmpBlockLangActive = isset($blockLangActive[$langId]) ? $blockLangActive[$langId] : 0; $tmpBlockContent = preg_replace('/\\{([A-Z0-9_-]+)\\}/', '[[\\1]]', $tmpBlockContent); if ($blockId != 0) { if (!$activeFlag && isset($blockLangActive[$langId])) { $activeClass = 'active'; $activeFlag = 1; } } elseif (!$activeFlag) { $activeClass = 'active'; $activeFlag = 1; } $this->_objTpl->setVariable(array('BLOCK_LANG_TAB_LANG_ID' => intval($langId), 'BLOCK_LANG_TAB_CLASS' => isset($activeClass) ? $activeClass : '', 'TXT_BLOCK_LANG_TAB_LANG_NAME' => contrexx_raw2xhtml($arrLanguage['name']), 'BLOCK_LANGTAB_DISPLAY' => $tmpBlockLangActive == 1 ? 'display:inline;' : ($blockId == 0 && $i == 0 ? 'display:inline;' : 'display:none;'))); $this->_objTpl->parse('block_language_tabs'); $this->_objTpl->setVariable(array('BLOCK_LANG_ID' => intval($langId), 'BLOCK_CONTENT_TEXT_HIDDEN' => contrexx_raw2xhtml($tmpBlockContent))); $this->_objTpl->parse('block_language_content'); $activeClass = ''; $i++; } if (!$this->getGeoIpComponent() || !$this->getGeoIpComponent()->getGeoIpServiceStatus()) { $this->_objTpl->touchBlock('warning_geoip_disabled'); } else { $this->_objTpl->hideBlock('warning_geoip_disabled'); } }
/** * 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; }
/** * @param int $id */ protected function modifyCategory($id = null) { global $objDatabase, $_ARRAYLANG; $manageCategoriesLink = 'index.php?cmd=News&act=newscat'; // cast input id to integer and check whether the id is zero or not $id = intval($id); if ($id == 0) { \Cx\Core\Csrf\Controller\Csrf::redirect($manageCategoriesLink); exit; } // check whether the category exists or not $objResult = $objDatabase->SelectLimit("SELECT `catid`, `parent_id` FROM `" . DBPREFIX . "module_news_categories` WHERE `catid` = " . $id); if ($objResult->RecordCount() == 0) { \Cx\Core\Csrf\Controller\Csrf::redirect($manageCategoriesLink); exit; } // load template $this->_objTpl->loadTemplateFile('module_news_category_modify.html', true, true); $this->pageTitle = $_ARRAYLANG['TXT_EDIT_CATEGORY']; // validate form inputs and save the changes if (isset($_POST['submit'])) { if (!isset($_POST['newsCatParentId']) || $_POST['newsCatParentId'] == $id) { } else { $catParentId = intval($_POST['newsCatParentId']); if ($catParentId == 0) { $catParentId = $this->nestedSetRootId; } if ($this->objNestedSet->getParent($id)->id != $catParentId) { // move the node under the parent node id $this->objNestedSet->moveTree($id, $catParentId, NESE_MOVE_BELOW); } } // write the new locale data to database $status = $this->storeCategoriesLocales($_POST['newsCatName']); if (!$status) { \Message::error($_ARRAYLANG['TXT_DATABASE_QUERY_ERROR']); } else { \Message::ok($_ARRAYLANG['TXT_DATA_RECORD_UPDATED_SUCCESSFUL']); } } // get language data from categories $categories = $this->getCategoriesLangData(); $categoryLangData = $categories[$id]; // get languages which are active $arrLanguages = \FWLanguage::getActiveFrontendLanguages(); // parse category name list for each activated frontend language foreach ($arrLanguages as $langId => $languageName) { $this->_objTpl->setVariable(array('NEWS_CAT_LANG_ID' => $langId, 'NEWS_CAT_NAME_VALUE' => contrexx_raw2xhtml($categoryLangData[$langId]), 'NEWS_CAT_LANG_NAME' => $languageName['name'])); $this->_objTpl->parse('category_name_list'); } // get parent category from this category $parentCategoryNode = $this->objNestedSet->getParent($id); // set global variables $this->_objTpl->setGlobalVariable(array('NEWS_CAT_ID' => $id, 'NEWS_CAT_NAME' => $categoryLangData[FRONTEND_LANG_ID])); // set variables $childrenNodes = $this->objNestedSet->getChildren($id, true); $childrenNodeIds = array(); foreach ($childrenNodes as $childrenNode) { $childrenNodeIds[] = $childrenNode['id']; } $this->_objTpl->setVariable(array('NEWS_CAT_CATEGORIES' => $this->getCategoryMenu($this->nestedSetRootId, array($parentCategoryNode->id), array_merge(array($id), $childrenNodeIds)))); // set language variables $this->_objTpl->setVariable(array('TXT_SAVE' => $_ARRAYLANG['TXT_SAVE'], 'TXT_NAME' => $_ARRAYLANG['TXT_NAME'], 'TXT_EDIT_CATEGORY' => $_ARRAYLANG['TXT_EDIT_CATEGORY'], 'TXT_NEWS_EXTENDED' => $_ARRAYLANG['TXT_NEWS_EXTENDED'], 'TXT_NEWS_PARENT_CATEGORY' => $_ARRAYLANG['TXT_NEWS_PARENT_CATEGORY'], 'TXT_NEWS_NEW_MAIN_CATEGORY' => $_ARRAYLANG['TXT_NEWS_NEW_MAIN_CATEGORY'])); }
function _editUser() { global $objDatabase, $_ARRAYLANG, $_CORELANG; $activeFrontendlang = \FWLanguage::getActiveFrontendLanguages(); $copy = isset($_REQUEST['copy']) && $_REQUEST['copy'] == 1; $recipientId = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; $recipientEmail = ''; $recipientUri = ''; $recipientSex = ''; $recipientSalutation = 0; $recipientTitle = ''; $recipientPosition = ''; $recipientIndustrySector = ''; $recipientPhoneMobile = ''; $recipientPhonePrivate = ''; $recipientFax = ''; $recipientNotes = ''; $recipientLastname = ''; $recipientFirstname = ''; $recipientCompany = ''; $recipientAddress = ''; $recipientZip = ''; $recipientCity = ''; $recipientCountry = ''; $recipientPhoneOffice = ''; $recipientBirthday = ''; $recipientLanguage = count($activeFrontendlang) == 1 ? key($activeFrontendlang) : ''; $recipientStatus = isset($_POST['newsletter_recipient_status']) ? 1 : (empty($_POST) ? 1 : 0); $arrAssociatedLists = array(); $recipientSendEmailId = isset($_POST['sendEmail']) ? intval($_POST['sendEmail']) : 0; $recipientSendMailDisplay = false; if (isset($_POST['newsletter_recipient_email'])) { $recipientEmail = $_POST['newsletter_recipient_email']; } if (isset($_POST['newsletter_recipient_uri'])) { $recipientUri = $_POST['newsletter_recipient_uri']; } if (isset($_POST['newsletter_recipient_sex'])) { $recipientSex = in_array($_POST['newsletter_recipient_sex'], array('f', 'm')) ? $_POST['newsletter_recipient_sex'] : ''; } if (isset($_POST['newsletter_recipient_salutation'])) { // TODO: use FWUSER $arrRecipientSalutation = $this->_getRecipientTitles(); $recipientSalutation = in_array($_POST['newsletter_recipient_salutation'], array_keys($arrRecipientSalutation)) ? intval($_POST['newsletter_recipient_salutation']) : 0; } if (isset($_POST['newsletter_recipient_lastname'])) { $recipientLastname = $_POST['newsletter_recipient_lastname']; } if (isset($_POST['newsletter_recipient_firstname'])) { $recipientFirstname = $_POST['newsletter_recipient_firstname']; } if (isset($_POST['newsletter_recipient_company'])) { $recipientCompany = $_POST['newsletter_recipient_company']; } if (isset($_POST['newsletter_recipient_address'])) { $recipientAddress = $_POST['newsletter_recipient_address']; } if (isset($_POST['newsletter_recipient_zip'])) { $recipientZip = $_POST['newsletter_recipient_zip']; } if (isset($_POST['newsletter_recipient_city'])) { $recipientCity = $_POST['newsletter_recipient_city']; } if (isset($_POST['newsletter_country_id'])) { $recipientCountry = $_POST['newsletter_country_id']; } if (isset($_POST['newsletter_recipient_phone_office'])) { $recipientPhoneOffice = $_POST['newsletter_recipient_phone_office']; } if (isset($_POST['newsletter_recipient_notes'])) { $recipientNotes = $_POST['newsletter_recipient_notes']; } if (isset($_POST['day']) && isset($_POST['month']) && isset($_POST['year'])) { $recipientBirthday = str_pad(intval($_POST['day']), 2, '0', STR_PAD_LEFT) . '-' . str_pad(intval($_POST['month']), 2, '0', STR_PAD_LEFT) . '-' . intval($_POST['year']); } if (isset($_POST['newsletter_recipient_title'])) { $recipientTitle = $_POST['newsletter_recipient_title']; } if (isset($_POST['newsletter_recipient_position'])) { $recipientPosition = $_POST['newsletter_recipient_position']; } if (isset($_POST['newsletter_recipient_industry_sector'])) { $recipientIndustrySector = $_POST['newsletter_recipient_industry_sector']; } if (isset($_POST['newsletter_recipient_phone_mobile'])) { $recipientPhoneMobile = $_POST['newsletter_recipient_phone_mobile']; } if (isset($_POST['newsletter_recipient_phone_private'])) { $recipientPhonePrivate = $_POST['newsletter_recipient_phone_private']; } if (isset($_POST['newsletter_recipient_fax'])) { $recipientFax = $_POST['newsletter_recipient_fax']; } if (isset($_POST['language'])) { $recipientLanguage = $_POST['language']; } if (isset($_POST['newsletter_recipient_associated_list'])) { foreach ($_POST['newsletter_recipient_associated_list'] as $listId => $status) { if (intval($status) == 1) { array_push($arrAssociatedLists, intval($listId)); } } } // Get interface settings $objInterface = $objDatabase->Execute('SELECT `setvalue` FROM `' . DBPREFIX . 'module_newsletter_settings` WHERE `setname` = "recipient_attribute_status"'); $recipientAttributeStatus = json_decode($objInterface->fields['setvalue'], true); if (isset($_POST['newsletter_recipient_save'])) { $objValidator = new \FWValidator(); if ($objValidator->isEmail($recipientEmail)) { if ($this->_validateRecipientAttributes($recipientAttributeStatus, $recipientUri, $recipientSex, $recipientSalutation, $recipientTitle, $recipientLastname, $recipientFirstname, $recipientPosition, $recipientCompany, $recipientIndustrySector, $recipientAddress, $recipientZip, $recipientCity, $recipientCountry, $recipientPhoneOffice, $recipientPhonePrivate, $recipientPhoneMobile, $recipientFax, $recipientBirthday)) { if ($this->_isUniqueRecipientEmail($recipientEmail, $recipientId, $copy)) { //reset the $recipientId on copy function $recipientId = $copy ? 0 : $recipientId; if ($recipientId > 0) { if ($this->_updateRecipient($recipientAttributeStatus, $recipientId, $recipientEmail, $recipientUri, $recipientSex, $recipientSalutation, $recipientTitle, $recipientLastname, $recipientFirstname, $recipientPosition, $recipientCompany, $recipientIndustrySector, $recipientAddress, $recipientZip, $recipientCity, $recipientCountry, $recipientPhoneOffice, $recipientPhonePrivate, $recipientPhoneMobile, $recipientFax, $recipientNotes, $recipientBirthday, $recipientStatus, $arrAssociatedLists, $recipientLanguage)) { self::$strOkMessage .= $_ARRAYLANG['TXT_NEWSLETTER_RECIPIENT_UPDATED_SUCCESSFULLY']; return $this->_userList(); } else { // fall back to old recipient id, if any error occurs on copy $recipientId = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; self::$strErrMessage .= $_ARRAYLANG['TXT_NEWSLETTER_ERROR_UPDATE_RECIPIENT']; } } else { if ($this->_addRecipient($recipientEmail, $recipientUri, $recipientSex, $recipientSalutation, $recipientTitle, $recipientLastname, $recipientFirstname, $recipientPosition, $recipientCompany, $recipientIndustrySector, $recipientAddress, $recipientZip, $recipientCity, $recipientCountry, $recipientPhoneOffice, $recipientPhonePrivate, $recipientPhoneMobile, $recipientFax, $recipientNotes, $recipientBirthday, $recipientStatus, $arrAssociatedLists, $recipientLanguage)) { if (!empty($recipientSendEmailId)) { $objRecipient = $objDatabase->SelectLimit("SELECT id FROM " . DBPREFIX . "module_newsletter_user WHERE email='" . contrexx_input2db($recipientEmail) . "'", 1); $recipientId = $objRecipient->fields['id']; $this->insertTmpEmail($recipientSendEmailId, $recipientEmail, self::USER_TYPE_NEWSLETTER); // setting TmpEntry=1 will set the newsletter status=1, this will force an imediate stop in the newsletter send procedere. if ($this->SendEmail($recipientId, $recipientSendEmailId, $recipientEmail, 1, self::USER_TYPE_NEWSLETTER) == false) { // fall back to old recipient id, if any error occurs on copy $recipientId = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; self::$strErrMessage .= $_ARRAYLANG['TXT_SENDING_MESSAGE_ERROR']; } else { $objRecipientCount = $objDatabase->execute('SELECT subject FROM ' . DBPREFIX . 'module_newsletter WHERE id=' . intval($recipientSendEmailId)); $newsTitle = $objRecipientCount->fields['subject']; // TODO: Unused // $objUpdateCount = $objDatabase->execute(' UPDATE ' . DBPREFIX . 'module_newsletter SET recipient_count = recipient_count+1 WHERE id=' . intval($recipientSendEmailId)); self::$strOkMessage .= sprintf($_ARRAYLANG['TXT_NEWSLETTER_RECIPIENT_MAIL_SEND_SUCCESSFULLY'] . '<br />', '<strong>' . $newsTitle . '</strong>'); } } self::$strOkMessage .= $_ARRAYLANG['TXT_NEWSLETTER_RECIPIENT_SAVED_SUCCESSFULLY']; return $this->_userList(); } else { // fall back to old recipient id, if any error occurs on copy $recipientId = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; self::$strErrMessage .= $_ARRAYLANG['TXT_NEWSLETTER_ERROR_SAVE_RECIPIENT']; } } } elseif (empty($recipientId)) { $objRecipient = $objDatabase->SelectLimit("SELECT id, language, status, notes FROM " . DBPREFIX . "module_newsletter_user WHERE email='" . contrexx_input2db($recipientEmail) . "'", 1); $recipientId = $objRecipient->fields['id']; $recipientLanguage = $objRecipient->fields['language']; $recipientStatus = $objRecipient->fields['status']; $recipientNotes = !empty($objRecipient->fields['notes']) ? $objRecipient->fields['notes'] . ' ' . $recipientNotes : $recipientNotes; $objList = $objDatabase->Execute("SELECT category FROM " . DBPREFIX . "module_newsletter_rel_user_cat WHERE user="******"SELECT id FROM " . DBPREFIX . "module_newsletter_user WHERE email='" . contrexx_input2db($recipientEmail) . "' AND id!=" . ($copy ? 0 : $recipientId), 1); self::$strErrMessage .= sprintf($_ARRAYLANG['TXT_NEWSLETTER_ERROR_EMAIL_ALREADY_EXISTS'], '<a href="index.php?cmd=Newsletter&act=users&tpl=edit&id=' . $objResult->fields['id'] . '" target="_blank">' . $_ARRAYLANG['TXT_NEWSLETTER_ERROR_EMAIL_ALREADY_EXISTS_CLICK_HERE'] . '</a>'); } } else { self::$strErrMessage .= $_ARRAYLANG['TXT_NEWSLETTER_MANDATORY_FIELD_ERROR']; } } else { self::$strErrMessage .= $_ARRAYLANG['TXT_NEWSLETTER_INVALIDE_EMAIL_ADDRESS']; } } elseif ($recipientId > 0) { $objRecipient = $objDatabase->SelectLimit("SELECT email, uri, sex, salutation, title, lastname, firstname, position, company, industry_sector, address, zip, city, country_id, phone_office, phone_private, phone_mobile, fax, notes, birthday, status, language FROM " . DBPREFIX . "module_newsletter_user WHERE id=" . $recipientId, 1); if ($objRecipient !== false && $objRecipient->RecordCount() == 1) { $recipientEmail = $objRecipient->fields['email']; $recipientUri = $objRecipient->fields['uri']; $recipientSex = $objRecipient->fields['sex']; $recipientSalutation = $objRecipient->fields['salutation']; $recipientTitle = $objRecipient->fields['title']; $recipientLastname = $objRecipient->fields['lastname']; $recipientFirstname = $objRecipient->fields['firstname']; $recipientPosition = $objRecipient->fields['position']; $recipientCompany = $objRecipient->fields['company']; $recipientIndustrySector = $objRecipient->fields['industry_sector']; $recipientAddress = $objRecipient->fields['address']; $recipientZip = $objRecipient->fields['zip']; $recipientCity = $objRecipient->fields['city']; $recipientCountry = $objRecipient->fields['country_id']; $recipientPhoneOffice = $objRecipient->fields['phone_office']; $recipientPhonePrivate = $objRecipient->fields['phone_private']; $recipientPhoneMobile = $objRecipient->fields['phone_mobile']; $recipientFax = $objRecipient->fields['fax']; $recipientBirthday = $objRecipient->fields['birthday']; $recipientLanguage = $objRecipient->fields['language']; $recipientStatus = $objRecipient->fields['status']; $recipientNotes = $objRecipient->fields['notes']; $objList = $objDatabase->Execute("SELECT category FROM " . DBPREFIX . "module_newsletter_rel_user_cat WHERE user="******"checked"' : '')); $this->_objTpl->parse('newsletter_mail_associated_list_' . $column); $listNr++; } if (count($activeFrontendlang) > 1) { foreach ($activeFrontendlang as $lang) { $selected = $lang['id'] == $recipientLanguage ? 'selected="selected"' : ''; $this->_objTpl->setVariable(array('NEWSLETTER_LANGUAGE_ID' => contrexx_raw2xhtml($lang['id']), 'NEWSLETTER_LANGUAGE_NAME' => contrexx_raw2xhtml($lang['name']), 'NEWSLETTER_LANGUAGES_SELECTED' => $selected)); $this->_objTpl->parse('languages'); } $languageOptionDisplay = true; } else { $this->_objTpl->hideBlock('languageOption'); } if (empty($recipientId) || $copy) { $objNewsletterMails = $objDatabase->Execute('SELECT id, subject FROM ' . DBPREFIX . 'module_newsletter ORDER BY status, id DESC'); while (!$objNewsletterMails->EOF) { $selected = $recipientSendEmailId == $objNewsletterMails->fields['id'] ? 'selected="selected"' : ''; $this->_objTpl->setVariable(array('NEWSLETTER_EMAIL_ID' => contrexx_raw2xhtml($objNewsletterMails->fields['id']), 'NEWSLETTER_EMAIL_NAME' => contrexx_raw2xhtml($objNewsletterMails->fields['subject']), 'NEWSLETTER_EMAIL_SELECTED' => $selected)); $this->_objTpl->parse('allMails'); $objNewsletterMails->MoveNext(); } $recipientSendMailDisplay = true; } else { $this->_objTpl->hideBlock('sendEmail'); } // Display settings recipient general attributes $sendMailRowClass = $languageOptionDisplay ? 'row2' : 'row1'; if ($languageOptionDisplay && $recipientSendMailDisplay) { $associatedListRowClass = 'row1'; } elseif ($languageOptionDisplay || $recipientSendMailDisplay) { $associatedListRowClass = 'row2'; } else { $associatedListRowClass = 'row1'; } $recipientNotesRowClass = $associatedListRowClass == 'row1' ? 'row2' : 'row1'; $this->_objTpl->setVariable(array('NEWSLETTER_SEND_EMAIL_ROWCLASS' => $sendMailRowClass, 'NEWSLETTER_ASSOCIATED_LISTS_ROWCLASS' => $associatedListRowClass, 'NEWSLETTER_NOTES_ROWCLASS' => $recipientNotesRowClass)); //display settings recipient profile detials $recipientAttributeDisplay = false; foreach ($recipientAttributeStatus as $value) { if ($value['active']) { $recipientAttributeDisplay = true; break; } } $profileRowCount = 0; $recipientAttributesArray = array('recipient_sex', 'recipient_salutation', 'recipient_title', 'recipient_firstname', 'recipient_lastname', 'recipient_position', 'recipient_company', 'recipient_industry', 'recipient_address', 'recipient_city', 'recipient_zip', 'recipient_country', 'recipient_phone', 'recipient_private', 'recipient_mobile', 'recipient_fax', 'recipient_birthday', 'recipient_website'); if ($recipientAttributeDisplay) { foreach ($recipientAttributesArray as $attribute) { if ($recipientAttributeStatus[$attribute]['active'] && $this->_objTpl->blockExists($attribute)) { $this->_objTpl->touchBlock($attribute); $this->_objTpl->setVariable(array('NEWSLETTER_' . strtoupper($attribute) . '_ROW_CLASS' => $profileRowCount % 2 == 0 ? 'row2' : 'row1', 'NEWSLETTER_' . strtoupper($attribute) . '_MANDATORY' => $recipientAttributeStatus[$attribute]['required'] ? '*' : '')); $profileRowCount++; } else { $this->_objTpl->hideBlock($attribute); } } } else { $this->_objTpl->hideBlock('recipientProfileAttributes'); } $filterParams = (!empty($_GET['newsletterListId']) ? '&newsletterListId=' . contrexx_input2raw($_GET['newsletterListId']) : '') . (!empty($_GET['filterkeyword']) ? '&filterkeyword=' . contrexx_input2raw($_GET['filterkeyword']) : '') . (!empty($_GET['filterattribute']) ? '&filterattribute=' . contrexx_input2raw($_GET['filterattribute']) : '') . (!empty($_GET['filterStatus']) ? '&filterStatus=' . contrexx_input2raw($_GET['filterStatus']) : ''); $this->_objTpl->setVariable(array('NEWSLETTER_RECIPIENT_ID' => $recipientId, 'NEWSLETTER_RECIPIENT_EMAIL' => htmlentities($recipientEmail, ENT_QUOTES, CONTREXX_CHARSET), 'TXT_NEWSLETTER_STATUS' => $_ARRAYLANG['TXT_NEWSLETTER_STATUS'], 'TXT_NEWSLETTER_LANGUAGE' => $_ARRAYLANG['TXT_NEWSLETTER_LANGUAGE'], 'TXT_NEWSLETTER_SEND_EMAIL' => $_ARRAYLANG['TXT_NEWSLETTER_SEND_EMAIL'], 'TXT_NEWSLETTER_ASSOCIATED_LISTS' => $_ARRAYLANG['TXT_NEWSLETTER_ASSOCIATED_LISTS'], 'TXT_NEWSLETTER_NOTES' => $_ARRAYLANG['TXT_NEWSLETTER_NOTES'], 'TXT_NEWSLETTER_PROFILE' => $_ARRAYLANG['TXT_NEWSLETTER_PROFILE'], 'TXT_NEWSLETTER_POSITION' => $_ARRAYLANG['TXT_NEWSLETTER_POSITION'], 'TXT_NEWSLETTER_INDUSTRY_SECTOR' => $_ARRAYLANG['TXT_NEWSLETTER_INDUSTRY_SECTOR'], 'TXT_NEWSLETTER_PHONE_MOBILE' => $_ARRAYLANG['TXT_NEWSLETTER_PHONE_MOBILE'], 'TXT_NEWSLETTER_PHONE_PRIVATE' => $_ARRAYLANG['TXT_NEWSLETTER_PHONE_PRIVATE'], 'TXT_NEWSLETTER_FAX' => $_ARRAYLANG['TXT_NEWSLETTER_FAX'], 'NEWSLETTER_RECIPIENT_STATUS' => $recipientStatus == '1' ? 'checked="checked"' : '', 'NEWSLETTER_RECIPIENT_NOTES' => htmlentities($recipientNotes, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_URI' => htmlentities($recipientUri, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_FEMALE' => $recipientSex == 'f' ? 'checked="checked"' : '', 'NEWSLETTER_RECIPIENT_MALE' => $recipientSex == 'm' ? 'checked="checked"' : '', 'NEWSLETTER_RECIPIENT_SALUTATION' => $this->_getRecipientTitleMenu($recipientSalutation, 'name="newsletter_recipient_salutation" style="width:296px" size="1"'), 'NEWSLETTER_RECIPIENT_TITLE' => htmlentities($recipientTitle, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_FIRSTNAME' => htmlentities($recipientFirstname, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_LASTNAME' => htmlentities($recipientLastname, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_POSITION' => htmlentities($recipientPosition, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_COMPANY' => htmlentities($recipientCompany, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_INDUSTRY_SECTOR' => htmlentities($recipientIndustrySector, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_ADDRESS' => htmlentities($recipientAddress, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_ZIP' => htmlentities($recipientZip, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_CITY' => htmlentities($recipientCity, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_COUNTRY' => $this->getCountryMenu($recipientCountry, $recipientAttributeStatus['recipient_country']['active'] && $recipientAttributeStatus['recipient_country']['required']), 'NEWSLETTER_RECIPIENT_PHONE' => htmlentities($recipientPhoneOffice, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_PHONE_MOBILE' => htmlentities($recipientPhoneMobile, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_PHONE_PRIVATE' => htmlentities($recipientPhonePrivate, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_FAX' => htmlentities($recipientFax, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_BIRTHDAY' => htmlentities($recipientBirthday, ENT_QUOTES, CONTREXX_CHARSET), 'NEWSLETTER_RECIPIENT_COPY' => $copy ? 1 : 0, 'TXT_NEWSLETTER_EMAIL_ADDRESS' => $_ARRAYLANG['TXT_NEWSLETTER_EMAIL_ADDRESS'], 'TXT_NEWSLETTER_WEBSITE' => $_ARRAYLANG['TXT_NEWSLETTER_WEBSITE'], 'TXT_NEWSLETTER_SALUTATION' => $_ARRAYLANG['TXT_NEWSLETTER_SALUTATION'], 'TXT_NEWSLETTER_TITLE' => $_ARRAYLANG['TXT_NEWSLETTER_TITLE'], 'TXT_NEWSLETTER_SEX' => $_ARRAYLANG['TXT_NEWSLETTER_SEX'], 'TXT_NEWSLETTER_FEMALE' => $_ARRAYLANG['TXT_NEWSLETTER_FEMALE'], 'TXT_NEWSLETTER_MALE' => $_ARRAYLANG['TXT_NEWSLETTER_MALE'], 'TXT_NEWSLETTER_LASTNAME' => $_ARRAYLANG['TXT_NEWSLETTER_LASTNAME'], 'TXT_NEWSLETTER_FIRSTNAME' => $_ARRAYLANG['TXT_NEWSLETTER_FIRSTNAME'], 'TXT_NEWSLETTER_COMPANY' => $_ARRAYLANG['TXT_NEWSLETTER_COMPANY'], 'TXT_NEWSLETTER_ADDRESS' => $_ARRAYLANG['TXT_NEWSLETTER_ADDRESS'], 'TXT_NEWSLETTER_ZIP' => $_ARRAYLANG['TXT_NEWSLETTER_ZIP'], 'TXT_NEWSLETTER_CITY' => $_ARRAYLANG['TXT_NEWSLETTER_CITY'], 'TXT_NEWSLETTER_COUNTRY' => $_ARRAYLANG['TXT_NEWSLETTER_COUNTRY'], 'TXT_NEWSLETTER_PHONE' => $_ARRAYLANG['TXT_NEWSLETTER_PHONE'], 'TXT_NEWSLETTER_BIRTHDAY' => $_ARRAYLANG['TXT_NEWSLETTER_BIRTHDAY'], 'TXT_NEWSLETTER_SAVE' => $_ARRAYLANG['TXT_NEWSLETTER_SAVE'], 'TXT_CANCEL' => $_CORELANG['TXT_CANCEL'], 'TXT_NEWSLETTER_DO_NOT_SEND_EMAIL' => $_ARRAYLANG['TXT_NEWSLETTER_DO_NOT_SEND_EMAIL'], 'TXT_NEWSLETTER_INFO_ABOUT_SEND_EMAIL' => $_ARRAYLANG['TXT_NEWSLETTER_INFO_ABOUT_SEND_EMAIL'], 'TXT_NEWSLETTER_RECIPIENT_DATE' => $_ARRAYLANG['TXT_NEWSLETTER_RECIPIENT_DATE'], 'TXT_NEWSLETTER_RECIPIENT_MONTH' => $_ARRAYLANG['TXT_NEWSLETTER_RECIPIENT_MONTH'], 'TXT_NEWSLETTER_RECIPIENT_YEAR' => $_ARRAYLANG['TXT_NEWSLETTER_RECIPIENT_YEAR'], 'NEWSLETTER_FILTER_PARAMS' => $filterParams)); $this->_objTpl->parse('module_newsletter_user_edit'); return true; }
/** * Shows an overview of all entries. * * @global array * @global array */ function showEntries() { global $_CORELANG, $_ARRAYLANG; $this->_strPageTitle = $_CORELANG['TXT_BLOG_ENTRY_MANAGE_TITLE']; $this->_objTpl->loadTemplateFile('module_blog_entries.html', true, true); $this->_objTpl->setVariable(array('TXT_ENTRIES_TITLE' => $_CORELANG['TXT_BLOG_ENTRY_MANAGE_TITLE'], 'TXT_ENTRIES_SUBTITLE_DATE' => $_ARRAYLANG['TXT_BLOG_ENTRY_MANAGE_DATE'], 'TXT_ENTRIES_SUBTITLE_SUBJECT' => $_ARRAYLANG['TXT_BLOG_ENTRY_ADD_SUBJECT'], 'TXT_ENTRIES_SUBTITLE_LANGUAGES' => $_ARRAYLANG['TXT_BLOG_CATEGORY_ADD_LANGUAGES'], 'TXT_ENTRIES_SUBTITLE_HITS' => $_ARRAYLANG['TXT_BLOG_ENTRY_MANAGE_HITS'], 'TXT_ENTRIES_SUBTITLE_COMMENTS' => $_ARRAYLANG['TXT_BLOG_ENTRY_MANAGE_COMMENTS'], 'TXT_ENTRIES_SUBTITLE_VOTES' => $_ARRAYLANG['TXT_BLOG_ENTRY_MANAGE_VOTE'], 'TXT_ENTRIES_SUBTITLE_USER' => $_CORELANG['TXT_USER'], 'TXT_ENTRIES_SUBTITLE_EDITED' => $_ARRAYLANG['TXT_BLOG_ENTRY_MANAGE_UPDATED'], 'TXT_ENTRIES_SUBTITLE_ACTIONS' => $_ARRAYLANG['TXT_BLOG_CATEGORY_MANAGE_ACTIONS'], 'TXT_ENTRIES_DELETE_ENTRY_JS' => $_ARRAYLANG['TXT_BLOG_ENTRY_DELETE_JS'], 'TXT_ENTRIES_MARKED' => $_ARRAYLANG['TXT_BLOG_CATEGORY_MANAGE_SUBMIT_MARKED'], 'TXT_ENTRIES_SELECT_ALL' => $_ARRAYLANG['TXT_BLOG_CATEGORY_MANAGE_SUBMIT_SELECT'], 'TXT_ENTRIES_DESELECT_ALL' => $_ARRAYLANG['TXT_BLOG_CATEGORY_MANAGE_SUBMIT_DESELECT'], 'TXT_ENTRIES_SUBMIT_SELECT' => $_ARRAYLANG['TXT_BLOG_CATEGORY_MANAGE_SUBMIT_ACTION'], 'TXT_ENTRIES_SUBMIT_DELETE' => $_ARRAYLANG['TXT_BLOG_CATEGORY_MANAGE_SUBMIT_DELETE'], 'TXT_ENTRIES_SUBMIT_DELETE_JS' => $_ARRAYLANG['TXT_BLOG_ENTRY_MANAGE_SUBMIT_DELETE_JS'])); $intSelectedCategory = isset($_GET['catId']) ? intval($_GET['catId']) : 0; $intPagingPosition = isset($_GET['pos']) ? intval($_GET['pos']) : 0; $objFWUser = \FWUser::getFWUserObject(); $this->_intCurrentUserId = $objFWUser->objUser->getId(); $arrEntries = $this->createEntryArray(0, $intPagingPosition, $this->getPagingLimit()); if (count($arrEntries) > 0) { $intRowClass = 1; foreach ($arrEntries as $intEntryId => $arrEntryValues) { if ($intSelectedCategory > 0) { //Filter for a specific category. If the category doesn't match: skip. if (!$this->categoryMatches($intSelectedCategory, $arrEntryValues['categories'][$this->_intLanguageId])) { continue; } } $this->_objTpl->setVariable(array('TXT_IMGALT_EDIT' => $_ARRAYLANG['TXT_BLOG_ENTRY_EDIT_TITLE'], 'TXT_IMGALT_DELETE' => $_ARRAYLANG['TXT_BLOG_ENTRY_DELETE_TITLE'])); //Check active languages $strActiveLanguages = ''; if (count(\FWLanguage::getActiveFrontendLanguages()) > 1) { $langState = array(); foreach ($arrEntryValues['translation'] as $intLangId => $arrEntryTranslations) { if ($arrEntryTranslations['is_active'] && key_exists($intLangId, $this->_arrLanguages)) { $langState[$intLangId] = 'active'; } } $strActiveLanguages = \Html::getLanguageIcons($langState, 'index.php?cmd=Blog&act=editEntry&id=' . $intEntryId . '&langId=%1$d'); $this->_objTpl->touchBlock('txt_languages_block'); } else { $this->_objTpl->hideBlock('txt_languages_block'); } $this->_objTpl->setVariable(array('ENTRY_ROWCLASS' => $intRowClass % 2 == 0 ? 'row1' : 'row2', 'ENTRY_ID' => $intEntryId, 'ENTRY_DATE' => $arrEntryValues['time_created'], 'ENTRY_EDITED' => $arrEntryValues['time_edited'], 'ENTRY_SUBJECT' => $arrEntryValues['subject'], 'ENTRY_LANGUAGES' => $strActiveLanguages, 'ENTRY_HITS' => $arrEntryValues['hits'], 'ENTRY_COMMENTS' => $arrEntryValues['comments'] . ' ' . $_ARRAYLANG['TXT_BLOG_ENTRY_MANAGE_COMMENTS'], 'ENTRY_VOTES' => 'Ø ' . $arrEntryValues['votes_avg'] . ' / ' . $arrEntryValues['votes'] . ' ' . $_ARRAYLANG['TXT_BLOG_ENTRY_MANAGE_VOTES'], 'ENTRY_USER' => $arrEntryValues['user_name'])); $this->_objTpl->parse('showEntries'); $intRowClass++; } //Show paging if needed if ($this->countEntries() > $this->getPagingLimit()) { $strPaging = getPaging($this->countEntries(), $intPagingPosition, '&cmd=Blog', '<strong>' . $_ARRAYLANG['TXT_BLOG_ENTRY_MANAGE_PAGING'] . '</strong>', true, $this->getPagingLimit()); $this->_objTpl->setVariable('ENTRIES_PAGING', $strPaging); } } else { $this->_objTpl->setVariable('TXT_ENTRIES_NO_ENTRIES_FOUND', $_ARRAYLANG['TXT_BLOG_ENTRY_MANAGE_NO_ENTRIES']); $this->_objTpl->parse('noEntries'); } }
/** * Insert new locales after submit news from frontend * @global ADONewConnection * @param Integer $newsId * @param String $title * @param String $text * @param String $teaser_text * @return Boolean */ private function storeLocalesOfSubmittedNewsMessage($newsId, $title, $text, $teaser_text) { global $objDatabase; if (empty($newsId)) { return false; } $status = true; $arrActiveFrontendLanguages = array_keys(\FWLanguage::getActiveFrontendLanguages()); foreach ($arrActiveFrontendLanguages as $langId) { $query = "INSERT INTO " . DBPREFIX . "module_news_locale (`lang_id`, `news_id`, `title`, `text`, `teaser_text`)\n VALUES (" . intval($langId) . ", " . intval($newsId) . ", '" . contrexx_raw2db($title) . "', '" . \Cx\Core\Wysiwyg\Wysiwyg::prepareBBCodeForDb($text, true) . "', '" . contrexx_raw2db($teaser_text) . "')"; if (!$objDatabase->Execute($query)) { $status = false; } } return $status; }
/** * @param Sigma $template */ public function preFinalize(Sigma $template) { if (count($this->mediaBrowserInstances) == 0) { return; } global $_ARRAYLANG; /** * @var $init \InitCMS */ $init = \Env::get('init'); $init->loadLanguageData('MediaBrowser'); foreach ($_ARRAYLANG as $key => $value) { if (preg_match("/TXT_FILEBROWSER_[A-Za-z0-9]+/", $key)) { \ContrexxJavascript::getInstance()->setVariable($key, $value, 'mediabrowser'); } } $thumbnailsTemplate = new Sigma(); $thumbnailsTemplate->loadTemplateFile($this->cx->getCoreModuleFolderName() . '/MediaBrowser/View/Template/Thumbnails.html'); $thumbnailsTemplate->setVariable('TXT_FILEBROWSER_THUMBNAIL_ORIGINAL_SIZE', sprintf($_ARRAYLANG['TXT_FILEBROWSER_THUMBNAIL_ORIGINAL_SIZE'])); foreach ($this->cx->getMediaSourceManager()->getThumbnailGenerator()->getThumbnails() as $thumbnail) { $thumbnailsTemplate->setVariable(array('THUMBNAIL_NAME' => sprintf($_ARRAYLANG['TXT_FILEBROWSER_THUMBNAIL_' . strtoupper($thumbnail['name']) . '_SIZE'], $thumbnail['size']), 'THUMBNAIL_ID' => $thumbnail['id'], 'THUMBNAIL_SIZE' => $thumbnail['size'])); $thumbnailsTemplate->parse('thumbnails'); } \ContrexxJavascript::getInstance()->setVariable('thumbnails_template', $thumbnailsTemplate->get(), 'mediabrowser'); \ContrexxJavascript::getInstance()->setVariable('chunk_size', min(floor((\FWSystem::getMaxUploadFileSize() - 1000000) / 1000000), 20) . 'mb', 'mediabrowser'); \ContrexxJavascript::getInstance()->setVariable('languages', \FWLanguage::getActiveFrontendLanguages(), 'mediabrowser'); \ContrexxJavascript::getInstance()->setVariable('language', \FWLanguage::getLanguageCodeById(\FWLanguage::getDefaultLangId()), 'mediabrowser'); \JS::activate('mediabrowser'); \JS::registerJS('core_modules/MediaBrowser/View/Script/MediaBrowser.js'); }
/** * get the available email template lang ids * * @param String $section mail template section name * @param String $key mail template key value * * @return array */ function getActiveEmailTemLangId($section = 'Crm', $key = '') { global $objDatabase; if (empty($section) || empty($key)) { return false; } $activeFrontLangId = \FWLanguage::getActiveFrontendLanguages(); $query = "SELECT DISTINCT ct.lang_id FROM `" . DBPREFIX . "core_text` as ct LEFT JOIN\n `" . DBPREFIX . "core_mail_template` as mt ON (ct.id=mt.text_id)\n WHERE mt.key = '" . $key . "' AND mt.section = '" . $section . "'"; $objResult = $objDatabase->Execute($query); if ($objResult && $objResult->RecordCount() > 0) { $activeLangArray = array(); $finalActiveLangArray = array(); while (!$objResult->EOF) { array_push($activeLangArray, (int) $objResult->fields['lang_id']); $objResult->MoveNext(); } foreach ($activeFrontLangId as $val) { if (in_array($val['id'], $activeLangArray)) { array_push($finalActiveLangArray, $val['id']); } } return $finalActiveLangArray; } return false; }
function _handleContentPage($formId = 0) { if (!$formId) { return; } $objDatabase = \Env::get('db'); $objFWUser = \FWUser::getFWUserObject(); $pageRepo = $this->em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page'); $pages = array(); foreach ($pageRepo->findBy(array('module' => 'Contact', 'cmd' => $formId)) as $page) { if ($page) { $pages[$page->getLang()] = $page; } } $frontendLangIds = array_keys(\FWLanguage::getActiveFrontendLanguages()); $selectedLangIds = array_keys($this->arrForms[$formId]['lang']); // filter out only those languages that are active in the frontent. // we do want to create/update only the content pages of those languages. $selectedLangIds = array_intersect($selectedLangIds, $frontendLangIds); // Maybe there will already be a fallback page if we activate a new language. // So we use the fallback page to prevent the creation of a new page. foreach ($selectedLangIds as $selectedLangId) { if (!isset($pages[$selectedLangId])) { $fallbackPage = $pageRepo->findOneByModuleCmdLang('Contact', $formId, $selectedLangId); if (!empty($fallbackPage)) { $pages[$selectedLangId] = $fallbackPage; } } } $presentLangIds = array_keys($pages); // define which languages of the content pages have to be updated // $updateLangIds = array_intersect($selectedLangIds, $presentLangIds); // define which languages of the content pages have to be created // $newLangIds = array_diff($selectedLangIds, $updateLangIds); // define which languages of the content pages have to be removed $deleteLangIds = array_diff($presentLangIds, $selectedLangIds); $langIdsOfAssociatedPagesOfPageNode = array(); foreach ($presentLangIds as $langId) { $langIdsOfAssociatedPagesOfPageNode[$pages[$langId]->getId()] = array_keys($pages[$langId]->getNode()->getPagesByLang()); } foreach ($selectedLangIds as $langId) { $page = null; $node = null; if (isset($pages[$langId])) { // Content page already exists, so we will update this very page $page = $pages[$langId]; \DBG::msg("Page in lang {$langId} exists -> Update()"); } else { // Content page of the frontend language $langId doesn't exist yet. // Therefore we will either have to create a new node or we will have to // find a node to which we can attach our new page. // We will prefer the latter. \DBG::msg("Page doesn't exist in lang {$langId} -> Create()"); // Check if there exists already a content page to who's node we could attach our new page if (count($pages)) { if ($langId != \FWLanguage::getDefaultLangId() && isset($pages[\FWLanguage::getDefaultLangId()]) && !in_array($langId, $langIdsOfAssociatedPagesOfPageNode[$pages[\FWLanguage::getDefaultLangId()]->getId()])) { // if that is the case, we will attach our new page to this node $node = $pages[\FWLanguage::getDefaultLangId()]->getNode(); \DBG::msg("Page does exists in the default language"); \DBG::msg("Attach page to node {$node->getId()} of the page of the lang " . \FWLanguage::getDefaultLangId()); } else { foreach ($pages as $langIdOfPage => $page) { // Skip the page of the default frontend language - we just checked this page's node before if ($langIdOfPage == \FWLanguage::getDefaultLangId()) { continue; } // Check if there exists a node of the pages in the other languages that don't // have an associated page in the language we're going to create a new page if (!in_array($langId, $langIdsOfAssociatedPagesOfPageNode[$pages[$langIdOfPage]->getId()])) { $node = $pages[$langIdOfPage]->getNode(); \DBG::msg("Attach page to node {$node->getId()} of the page of the lang {$langIdOfPage}"); break; } } } } if ($node === null) { \DBG::msg("No node found -> Create()"); $root = $this->em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Node')->getRoot(); // Create a new node $node = new \Cx\Core\ContentManager\Model\Entity\Node(); $node->setParent($root); $this->em->persist($node); } // Create a new Page $page = new \Cx\Core\ContentManager\Model\Entity\Page(); $page->setNode($node); // Set the following attributes only on new pages $page->setTitle($this->arrForms[$formId]['lang'][$langId]['name']); $page->setDisplay(false); $page->setActive(true); $page->setLang($langId); } $page->setType(\Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION); $page->setModule('Contact'); $page->setCmd($formId); $content = $page->getContent(); //if the content is missing the placeholder {APPLICATION_DATA}, append the placeholder to the page's content. if (!preg_match_all('/\\{APPLICATION_DATA\\}/xi', $content, $matches)) { $content .= '{APPLICATION_DATA}'; } $page->setContent($content); $page->setSourceMode(true); $this->em->persist($page); // Remember newly created pages. We will need this for the creating of other new pages above in this method. if (!isset($pages[$langId])) { $pages[$langId] = $page; $langIdsOfAssociatedPagesOfPageNode[$pages[$langId]->getId()] = array($langId); } } //$this->em->flush(); // Delete those content pages of those languages that had been deactivated foreach ($deleteLangIds as $langId) { $page = $pages[$langId]; $node = $page->getNode(); \DBG::msg("Delete page: {$langId}"); //DBG::dump(count($node->getPages())); $this->em->remove($page); //$this->em->persist($page); //$this->em->flush(); //DBG::dump(count($node->getPages())); // TODO: Delete empty nodes } $this->em->flush(); }