/**
  * Render the option field in the backend.
  *
  * @param Sigma $template
  */
 public function renderOptionField($template)
 {
     global $_ARRAYLANG;
     $subTemplate = new Sigma();
     $subTemplate->loadTemplateFile($this->cx->getCodeBaseCoreModulePath() . '/TemplateEditor/View/Template/Backend/ImagesSeriesOption.html');
     $subTemplate->setGlobalVariable($_ARRAYLANG);
     foreach ($this->urls as $id => $url) {
         $subTemplate->setVariable('TEMPLATEEDITOR_OPTION_VALUE', $url);
         $subTemplate->setVariable('TEMPLATEEDITOR_OPTION_ID', $id);
         $subTemplate->parse('images');
     }
     $mediaBrowser = new MediaBrowser();
     $mediaBrowserId = $this->name . '_mediabrowser';
     $mediaBrowser->setOptions(array('id' => $mediaBrowserId));
     $mediaBrowser->setOptions(array('views' => 'uploader,filebrowser', 'startview' => 'filebrowser'));
     $mediaBrowser->setCallback('callback_' . $this->name);
     $subTemplate->setVariable('MEDIABROWSER_BUTTON', $mediaBrowser->getXHtml($_ARRAYLANG['TXT_CORE_MODULE_TEMPLATEEDITOR_ADD_PICTURE']));
     $subTemplate->setVariable('MEDIABROWSER_ID', $mediaBrowserId);
     $subTemplate->setVariable('TEMPLATEEDITOR_OPTION_NAME', $this->name);
     $subTemplate->setVariable('TEMPLATEEDITOR_OPTION_HUMAN_NAME', $this->humanName);
     //Get last key
     end($this->urls);
     $key = key($this->urls);
     $key = $key != null ? $key : '0';
     $subTemplate->setVariable('TEMPLATEEDITOR_LASTID', $key);
     $template->setVariable('TEMPLATEEDITOR_OPTION', $subTemplate->get());
     $template->setVariable('TEMPLATEEDITOR_OPTION_TYPE', 'img series');
     $template->parse('option');
 }
 /**
  * Render the option field in the backend.
  *
  * @param Sigma $template
  */
 public function renderOptionField($template)
 {
     global $_ARRAYLANG;
     $subTemplate = new Sigma();
     $subTemplate->loadTemplateFile($this->cx->getCodeBaseCoreModulePath() . '/TemplateEditor/View/Template/Backend/ImageOption.html');
     $subTemplate->setGlobalVariable($_ARRAYLANG);
     $subTemplate->setVariable('TEMPLATEEDITOR_OPTION_VALUE', $this->url);
     $subTemplate->setVariable('TEMPLATEEDITOR_OPTION_NAME', $this->name);
     $subTemplate->setVariable('TEMPLATEEDITOR_OPTION_HUMAN_NAME', $this->humanName);
     $mediaBrowser = new MediaBrowser();
     $mediaBrowser->setOptions(array('views' => 'uploader,filebrowser', 'startView' => 'filebrowser'));
     $mediaBrowser->setCallback('callback_' . $this->name);
     $subTemplate->setVariable('MEDIABROWSER_BUTTON', $mediaBrowser->getXHtml($_ARRAYLANG['TXT_CORE_MODULE_TEMPLATEEDITOR_CHOOSE_PICTURE']));
     $template->setVariable('TEMPLATEEDITOR_OPTION', $subTemplate->get());
     $template->setVariable('TEMPLATEEDITOR_OPTION_TYPE', 'img');
     $template->parse('option');
 }
 /**
  * Use this to parse your backend page
  *
  * You will get the template located in /View/Template/{CMD}.html
  * You can access Cx class using $this->cx
  * To show messages, use \Message class
  *
  * @param \Cx\Core\Html\Sigma $template Template for current CMD
  * @param array               $cmd      CMD separated by slashes
  */
 public function parsePage(\Cx\Core\Html\Sigma $template, array $cmd)
 {
     $uploader = new Uploader();
     $uploader->setFinishedCallback('\\Cx\\Core_Modules\\Uploader\\Model\\DefaultUploadCallback');
     $uploader->setCallback('gallery.uploader');
     $template->setVariable('UPLOADER_CODE', $uploader->getXHtml('Open Uploader 1'));
     $uploader2 = new Uploader();
     $uploader2->setFinishedCallback('\\Cx\\Core_Modules\\Uploader\\Model\\DefaultUploadCallback');
     $uploader2->setCallback('gallery.uploader2');
     $uploader2->setType(Uploader::UPLOADER_TYPE_INLINE);
     $template->setVariable('UPLOADER_CODE2', $uploader2->getXHtml('Open Uploader 2'));
     $mediaBrowser = new MediaBrowser();
     $mediaBrowser->setCallback('gallery.fancyCallback');
     $template->setVariable('MEDIABROWSER_CODE1', $mediaBrowser->getXHtml('MediaBrowser'));
     $template->setVariable('MEDIABROWSER_CODE1_RAW', htmlspecialchars($mediaBrowser->getXHtml('MediaBrowser')));
     $template->setVariable('MEDIABROWSER_FOLDER_WIDGET', new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($this->cx->getWebsiteImagesContentPath()));
     $template->setVariable('MEDIABROWSER_FOLDER_WIDGET_VIEW_MODE', new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($this->cx->getWebsiteImagesContentPath(), true));
 }
 /**
  * Get the html source code for the wysiwyg editor
  *
  * @return string
  */
 public function getSourceCode()
 {
     $mediaBrowserCkeditor = new MediaBrowser();
     $mediaBrowserCkeditor->setOptions(array('type' => 'button', 'style' => 'display:none'));
     $mediaBrowserCkeditor->setCallback('ckeditor_image_callback');
     $mediaBrowserCkeditor->setOptions(array('id' => 'ckeditor_image_button'));
     \JS::activate('ckeditor');
     \JS::activate('jquery');
     $configPath = ASCMS_PATH_OFFSET . substr(\Env::get('ClassLoader')->getFilePath(ASCMS_CORE_PATH . '/Wysiwyg/ckeditor.config.js.php'), strlen(ASCMS_DOCUMENT_ROOT));
     $options = array("customConfig: CKEDITOR.getUrl('" . $configPath . "?langId=" . $this->langId . "')", "width: '" . $this->types[$this->type]['width'] . "'", "height: '" . $this->types[$this->type]['height'] . "'", "toolbar: '" . $this->types[$this->type]['toolbar'] . "'", "fullPage: " . $this->types[$this->type]['fullPage']);
     $extraPlugins = array_merge($this->extraPlugins, $this->types[$this->type]['extraPlugins']);
     if (!empty($extraPlugins)) {
         $options[] = "extraPlugins: '" . implode(',', $extraPlugins) . "'";
     }
     $onReady = "CKEDITOR.replace('" . $this->name . "', { %s });";
     \JS::registerCode('
         $J(function(){
             ' . sprintf($onReady, implode(",\r\n", $options)) . '
         });
     ');
     return $mediaBrowserCkeditor->getXHtml('mediabrowser') . '<textarea name="' . $this->name . '" style="width: 100%; height: ' . $this->types[$this->type]['height'] . 'px">' . $this->value . '</textarea>';
 }
 protected function actRenderCM()
 {
     global $_ARRAYLANG, $_CORELANG, $_CONFIG;
     \JS::activate('jqueryui');
     \JS::activate('cx');
     \JS::activate('ckeditor');
     \JS::activate('cx-form');
     \JS::activate('jstree');
     \JS::registerJS('lib/javascript/lock.js');
     \JS::registerJS('lib/javascript/jquery/jquery.history.max.js');
     // this can be used to debug the tree, just add &tree=verify or &tree=fix
     $tree = null;
     if (isset($_GET['tree'])) {
         $tree = contrexx_input2raw($_GET['tree']);
     }
     if ($tree == 'verify') {
         echo '<pre>';
         print_r($this->nodeRepository->verify());
         echo '</pre>';
     } else {
         if ($tree == 'fix') {
             // this should print "bool(true)"
             var_dump($this->nodeRepository->recover());
         }
     }
     $objCx = \ContrexxJavascript::getInstance();
     $themeRepo = new \Cx\Core\View\Model\Repository\ThemeRepository();
     $defaultTheme = $themeRepo->getDefaultTheme();
     $objCx->setVariable('themeId', $defaultTheme->getId(), 'contentmanager/theme');
     foreach ($themeRepo->findAll() as $theme) {
         if ($theme == $defaultTheme) {
             $objCx->setVariable('themeName', $theme->getFoldername(), 'contentmanager/theme');
         }
     }
     $this->template->addBlockfile('ADMIN_CONTENT', 'content_manager', 'Skeleton.html');
     // user has no permission to create new page, hide navigation item in admin navigation
     if (!\Permission::checkAccess(127, 'static', true)) {
         $this->template->hideBlock('content_manager_create_new_page_navigation_item');
     }
     $this->template->touchBlock('content_manager');
     $this->template->addBlockfile('CONTENT_MANAGER_MEAT', 'content_manager_meat', 'Page.html');
     $this->template->touchBlock('content_manager_meat');
     if (\Permission::checkAccess(78, 'static', true)) {
         \JS::registerCode("var publishAllowed = true;");
     } else {
         \JS::registerCode("var publishAllowed = false;");
     }
     if (\Permission::checkAccess(78, 'static', true) && \Permission::checkAccess(115, 'static', true)) {
         \JS::registerCode("var aliasManagementAllowed = true;");
         $alias_permission = "block";
         $alias_denial = "none !important";
     } else {
         \JS::registerCode("var aliasManagementAllowed = false;");
         $alias_permission = "none !important";
         $alias_denial = "block";
     }
     $mediaBrowser = new MediaBrowser();
     $mediaBrowser->setCallback('target_page_callback');
     $mediaBrowser->setOptions(array('type' => 'button', 'data-cx-mb-views' => 'sitestructure', 'id' => 'page_target_browse'));
     $mediaBrowserCkeditor = new MediaBrowser();
     $mediaBrowserCkeditor->setCallback('ckeditor_image_callback');
     $mediaBrowserCkeditor->setOptions(array('id' => 'ckeditor_image_button', 'type' => 'button', 'style' => 'display:none'));
     $this->template->setVariable(array('MEDIABROWSER_BUTTON' => $mediaBrowser->getXHtml($_ARRAYLANG['TXT_CORE_CM_BROWSE']), 'MEDIABROWSER_BUTTON_CKEDITOR' => $mediaBrowserCkeditor->getXHtml($_ARRAYLANG['TXT_CORE_CM_BROWSE'])));
     $this->template->setVariable(array('ALIAS_PERMISSION' => $alias_permission, 'ALIAS_DENIAL' => $alias_denial, 'CONTREXX_BASE_URL' => ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET . '/', 'CONTREXX_LANG' => \FWLanguage::getLanguageCodeById(BACKEND_LANG_ID)));
     global $_CORELANG;
     $this->template->setVariable($_CORELANG);
     $objCx->setVariable('TXT_CORE_CM_VIEW', $_CORELANG['TXT_CORE_CM_VIEW'], 'contentmanager/lang');
     $objCx->setVariable('TXT_CORE_CM_ACTIONS', $_CORELANG['TXT_CORE_CM_ACTIONS'], 'contentmanager/lang');
     $objCx->setVariable('TXT_CORE_CM_VALIDATION_FAIL', $_CORELANG['TXT_CORE_CM_VALIDATION_FAIL'], 'contentmanager/lang');
     $objCx->setVariable('TXT_CORE_CM_HOME_FAIL', $_CORELANG['TXT_CORE_CM_HOME_FAIL'], 'contentmanager/lang');
     $arrLangVars = array('actions' => array('new' => 'TXT_CORE_CM_ACTION_NEW', 'copy' => 'TXT_CORE_CM_ACTION_COPY', 'activate' => 'TXT_CORE_CM_ACTION_PUBLISH', 'deactivate' => 'TXT_CORE_CM_ACTION_UNPUBLISH', 'publish' => 'TXT_CORE_CM_ACTION_PUBLISH_DRAFT', 'show' => 'TXT_CORE_CM_ACTION_SHOW', 'hide' => 'TXT_CORE_CM_ACTION_HIDE', 'delete' => 'TXT_CORE_CM_ACTION_DELETE', 'recursiveQuestion' => 'TXT_CORE_CM_RECURSIVE_QUESTION'), 'tooltip' => array('TXT_CORE_CM_LAST_MODIFIED' => 'TXT_CORE_CM_LAST_MODIFIED', 'TXT_CORE_CM_PUBLISHING_INFO_STATUSES' => 'TXT_CORE_CM_PUBLISHING_INFO_STATUSES', 'TXT_CORE_CM_PUBLISHING_INFO_ACTION_ACTIVATE' => 'TXT_CORE_CM_PUBLISHING_INFO_ACTION_ACTIVATE', 'TXT_CORE_CM_PUBLISHING_INFO_ACTION_DEACTIVATE' => 'TXT_CORE_CM_PUBLISHING_INFO_ACTION_DEACTIVATE', 'TXT_CORE_CM_PUBLISHING_DRAFT' => 'TXT_CORE_CM_PUBLISHING_DRAFT', 'TXT_CORE_CM_PUBLISHING_DRAFT_WAITING' => 'TXT_CORE_CM_PUBLISHING_DRAFT_WAITING', 'TXT_CORE_CM_PUBLISHING_LOCKED' => 'TXT_CORE_CM_PUBLISHING_LOCKED', 'TXT_CORE_CM_PUBLISHING_PUBLISHED' => 'TXT_CORE_CM_PUBLISHING_PUBLISHED', 'TXT_CORE_CM_PUBLISHING_UNPUBLISHED' => 'TXT_CORE_CM_PUBLISHING_UNPUBLISHED', 'TXT_CORE_CM_PAGE_INFO_STATUSES' => 'TXT_CORE_CM_PAGE_INFO_STATUSES', 'TXT_CORE_CM_PUBLISHING_INFO_TYPES' => 'TXT_CORE_CM_PUBLISHING_INFO_TYPES', 'TXT_CORE_CM_PAGE_INFO_ACTION_SHOW' => 'TXT_CORE_CM_PAGE_INFO_ACTION_SHOW', 'TXT_CORE_CM_PAGE_INFO_ACTION_HIDE' => 'TXT_CORE_CM_PAGE_INFO_ACTION_HIDE', 'TXT_CORE_CM_PAGE_STATUS_BROKEN' => 'TXT_CORE_CM_PAGE_STATUS_BROKEN', 'TXT_CORE_CM_PAGE_STATUS_VISIBLE' => 'TXT_CORE_CM_PAGE_STATUS_VISIBLE', 'TXT_CORE_CM_PAGE_STATUS_INVISIBLE' => 'TXT_CORE_CM_PAGE_STATUS_INVISIBLE', 'TXT_CORE_CM_PAGE_STATUS_PROTECTED' => 'TXT_CORE_CM_PAGE_STATUS_PROTECTED', 'TXT_CORE_CM_PAGE_TYPE_HOME' => 'TXT_CORE_CM_PAGE_TYPE_HOME', 'TXT_CORE_CM_PAGE_TYPE_CONTENT_SITE' => 'TXT_CORE_CM_PAGE_TYPE_CONTENT_SITE', 'TXT_CORE_CM_PAGE_TYPE_APPLICATION' => 'TXT_CORE_CM_PAGE_TYPE_APPLICATION', 'TXT_CORE_CM_PAGE_TYPE_REDIRECTION' => 'TXT_CORE_CM_PAGE_TYPE_REDIRECTION', 'TXT_CORE_CM_PAGE_TYPE_SYMLINK' => 'TXT_CORE_CM_PAGE_TYPE_SYMLINK', 'TXT_CORE_CM_PAGE_TYPE_FALLBACK' => 'TXT_CORE_CM_PAGE_TYPE_FALLBACK', 'TXT_CORE_CM_PAGE_MOVE_INFO' => 'TXT_CORE_CM_PAGE_MOVE_INFO', 'TXT_CORE_CM_TRANSLATION_INFO' => 'TXT_CORE_CM_TRANSLATION_INFO', 'TXT_CORE_CM_PREVIEW_INFO' => 'TXT_CORE_CM_PREVIEW_INFO'));
     foreach ($arrLangVars as $subscope => $arrLang) {
         foreach ($arrLang as $name => $value) {
             $objCx->setVariable($name, $_CORELANG[$value], 'contentmanager/lang/' . $subscope);
         }
     }
     // Mediabrowser
     $mediaBrowser = new \Cx\Core_Modules\MediaBrowser\Model\Entity\MediaBrowser();
     $mediaBrowser->setOptions(array('type' => 'button'));
     $mediaBrowser->setCallback('setWebPageUrlCallback');
     $mediaBrowser->setOptions(array('data-cx-mb-startview' => 'sitestructure', 'id' => 'page_target_browse'));
     $this->template->setVariable(array('CM_MEDIABROWSER_BUTTON' => $mediaBrowser->getXHtml($_ARRAYLANG['TXT_CORE_CM_BROWSE'])));
     $toggleTitles = !empty($_SESSION['contentManager']['toggleStatuses']['toggleTitles']) ? $_SESSION['contentManager']['toggleStatuses']['toggleTitles'] : 'block';
     $toggleType = !empty($_SESSION['contentManager']['toggleStatuses']['toggleType']) ? $_SESSION['contentManager']['toggleStatuses']['toggleType'] : 'block';
     $toggleNavigation = !empty($_SESSION['contentManager']['toggleStatuses']['toggleNavigation']) ? $_SESSION['contentManager']['toggleStatuses']['toggleNavigation'] : 'block';
     $toggleBlocks = !empty($_SESSION['contentManager']['toggleStatuses']['toggleBlocks']) ? $_SESSION['contentManager']['toggleStatuses']['toggleBlocks'] : 'block';
     $toggleThemes = !empty($_SESSION['contentManager']['toggleStatuses']['toggleThemes']) ? $_SESSION['contentManager']['toggleStatuses']['toggleThemes'] : 'block';
     $toggleApplication = !empty($_SESSION['contentManager']['toggleStatuses']['toggleApplication']) ? $_SESSION['contentManager']['toggleStatuses']['toggleApplication'] : 'block';
     $toggleSidebar = !empty($_SESSION['contentManager']['toggleStatuses']['sidebar']) ? $_SESSION['contentManager']['toggleStatuses']['sidebar'] : 'block';
     $objCx->setVariable('toggleTitles', $toggleTitles, 'contentmanager/toggle');
     $objCx->setVariable('toggleType', $toggleType, 'contentmanager/toggle');
     $objCx->setVariable('toggleNavigation', $toggleNavigation, 'contentmanager/toggle');
     $objCx->setVariable('toggleBlocks', $toggleBlocks, 'contentmanager/toggle');
     $objCx->setVariable('toggleThemes', $toggleThemes, 'contentmanager/toggle');
     $objCx->setVariable('toggleApplication', $toggleApplication, 'contentmanager/toggle');
     $objCx->setVariable('sidebar', $toggleSidebar, 'contentmanager/toggle');
     // get initial tree data
     $objJsonData = new \Cx\Core\Json\JsonData();
     $treeData = $objJsonData->jsondata('node', 'getTree', array('get' => $_GET), false);
     $objCx->setVariable('tree-data', $treeData, 'contentmanager/tree');
     if (!empty($_GET['act']) && $_GET['act'] == 'new') {
         $this->template->setVariable(array('TITLES_DISPLAY_STYLE' => 'display: block;', 'TITLES_TOGGLE_CLASS' => 'open', 'TYPE_DISPLAY_STYLE' => 'display: block;', 'TYPE_TOGGLE_CLASS' => 'open', 'NAVIGATION_DISPLAY_STYLE' => 'display: block;', 'NAVIGATION_TOGGLE_CLASS' => 'open', 'BLOCKS_DISPLAY_STYLE' => 'display: block;', 'BLOCKS_TOGGLE_CLASS' => 'open', 'THEMES_DISPLAY_STYLE' => 'display: block;', 'THEMES_TOGGLE_CLASS' => 'open', 'APPLICATION_DISPLAY_STYLE' => 'display: block;', 'APPLICATION_TOGGLE_CLASS' => 'open', 'MULTIPLE_ACTIONS_STRIKE_STYLE' => 'display: none;'));
     } else {
         $this->template->setVariable(array('TITLES_DISPLAY_STYLE' => $toggleTitles == 'none' ? 'display: none;' : 'display: block;', 'TITLES_TOGGLE_CLASS' => $toggleTitles == 'none' ? 'closed' : 'open', 'TYPE_DISPLAY_STYLE' => $toggleType == 'none' ? 'display: none;' : 'display: block;', 'TYPE_TOGGLE_CLASS' => $toggleType == 'none' ? 'closed' : 'open', 'NAVIGATION_DISPLAY_STYLE' => $toggleNavigation == 'none' ? 'display: none;' : 'display: block;', 'NAVIGATION_TOGGLE_CLASS' => $toggleNavigation == 'none' ? 'closed' : 'open', 'BLOCKS_DISPLAY_STYLE' => $toggleBlocks == 'none' ? 'display: none;' : 'display: block;', 'BLOCKS_TOGGLE_CLASS' => $toggleBlocks == 'none' ? 'closed' : 'open', 'THEMES_DISPLAY_STYLE' => $toggleThemes == 'none' ? 'display: none;' : 'display: block;', 'THEMES_TOGGLE_CLASS' => $toggleThemes == 'none' ? 'closed' : 'open', 'APPLICATION_DISPLAY_STYLE' => $toggleApplication == 'none' ? 'display: none;' : 'display: block;', 'APPLICATION_TOGGLE_CLASS' => $toggleApplication == 'none' ? 'closed' : 'open'));
     }
     $modules = $this->db->Execute("SELECT * FROM " . DBPREFIX . "modules WHERE `status` = 'y' ORDER BY `name`");
     while (!$modules->EOF) {
         $this->template->setVariable('MODULE_KEY', $modules->fields['name']);
         //            $this->template->setVariable('MODULE_TITLE', $_CORELANG[$modules->fields['description_variable']]);
         $this->template->setVariable('MODULE_TITLE', ucwords($modules->fields['name']));
         $this->template->parse('module_option');
         $modules->MoveNext();
     }
     $newPageFirstLevel = isset($_GET['act']) && $_GET['act'] == 'new';
     if (\Permission::checkAccess(36, 'static', true)) {
         $this->template->touchBlock('page_permissions_tab');
         $this->template->touchBlock('page_permissions');
     } else {
         $this->template->hideBlock('page_permissions_tab');
         $this->template->hideBlock('page_permissions');
     }
     //show the caching options only if the caching system is actually active
     if ($_CONFIG['cacheEnabled'] == 'on') {
         $this->template->touchBlock('show_caching_option');
     } else {
         $this->template->hideBlock('show_caching_option');
     }
     if (\Permission::checkAccess(78, 'static', true)) {
         $this->template->hideBlock('release_button');
     } else {
         $this->template->hideBlock('publish_button');
         $this->template->hideBlock('refuse_button');
     }
     // show no access page if the user wants to create new page in first level but he does not have enough permissions
     if ($newPageFirstLevel) {
         \Permission::checkAccess(127, 'static');
     }
     $editViewCssClass = '';
     if ($newPageFirstLevel) {
         $editViewCssClass = 'edit_view';
         $this->template->hideBlock('refuse_button');
     }
     $cxjs = \ContrexxJavascript::getInstance();
     $cxjs->setVariable('confirmDeleteQuestion', $_ARRAYLANG['TXT_CORE_CM_CONFIRM_DELETE'], 'contentmanager/lang');
     $cxjs->setVariable('cleanAccessData', $objJsonData->jsondata('page', 'getAccessData', array(), false), 'contentmanager');
     $cxjs->setVariable('contentTemplates', $this->getCustomContentTemplates(), 'contentmanager');
     $cxjs->setVariable('defaultTemplates', $this->getDefaultTemplates(), 'contentmanager/themes');
     $cxjs->setVariable('templateFolders', $this->getTemplateFolders(), 'contentmanager/themes');
     $cxjs->setVariable('availableBlocks', $objJsonData->jsondata('Block', 'getBlocks', array(), false), 'contentmanager');
     // TODO: move including of add'l JS dependencies to cx obj from /cadmin/index.html
     $getLangOptions = $this->getLangOptions();
     $statusPageLayout = '';
     $languageDisplay = '';
     if ((!empty($_GET['act']) && $_GET['act'] == 'new' || !empty($_GET['page'])) && $getLangOptions == "") {
         $statusPageLayout = 'margin0';
         $languageDisplay = 'display:none';
     }
     $this->template->setVariable('ADMIN_LIST_MARGIN', $statusPageLayout);
     $this->template->setVariable('LANGUAGE_DISPLAY', $languageDisplay);
     // TODO: move including of add'l JS dependencies to cx obj from /cadmin/index.html
     $this->template->setVariable('SKIN_OPTIONS', $this->getSkinOptions());
     $this->template->setVariable('LANGSWITCH_OPTIONS', $this->getLangOptions());
     $this->template->setVariable('LANGUAGE_ARRAY', json_encode($this->getLangArray()));
     $this->template->setVariable('FALLBACK_ARRAY', json_encode($this->getFallbackArray()));
     $this->template->setVariable('LANGUAGE_LABELS', json_encode($this->getLangLabels()));
     $this->template->setVariable('EDIT_VIEW_CSS_CLASS', $editViewCssClass);
     $this->template->touchBlock('content_manager_language_selection');
     $editmodeTemplate = new \Cx\Core\Html\Sigma(ASCMS_CORE_PATH . '/ContentManager/View/Template/Backend');
     $editmodeTemplate->loadTemplateFile('content_editmode.html');
     $editmodeTemplate->setVariable(array('TXT_EDITMODE_TEXT' => $_CORELANG['TXT_FRONTEND_EDITING_SELECTION_TEXT'], 'TXT_EDITMODE_CODE' => $_CORELANG['TXT_FRONTEND_EDITING_SELECTION_MODE_PAGE'], 'TXT_EDITMODE_CONTENT' => $_CORELANG['TXT_FRONTEND_EDITING_SELECTION_MODE_CONTENT']));
     $cxjs->setVariable(array('editmodetitle' => $_CORELANG['TXT_FRONTEND_EDITING_SELECTION_TITLE'], 'editmodecontent' => $editmodeTemplate->get(), 'ckeditorconfigpath' => substr(\Env::get('ClassLoader')->getFilePath(ASCMS_CORE_PATH . '/Wysiwyg/ckeditor.config.js.php'), strlen(ASCMS_DOCUMENT_ROOT) + 1), 'regExpUriProtocol' => \FWValidator::REGEX_URI_PROTO, 'contrexxBaseUrl' => ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET . '/', 'contrexxPathOffset' => ASCMS_PATH_OFFSET), 'contentmanager');
 }
 /**
  * Display the MediaBrowser button
  *
  * @global array $_ARRAYLANG
  *
  * @param string $name callback function name
  * @param string $type mediabrowser type
  *
  * @return string
  */
 protected function showMediaBrowserButton($name, $type = 'filebrowser')
 {
     if (empty($name)) {
         return;
     }
     global $_ARRAYLANG;
     $mediaBrowser = new \Cx\Core_Modules\MediaBrowser\Model\Entity\MediaBrowser();
     $mediaBrowser->setOptions(array('type' => 'button', 'data-cx-mb-views' => $type));
     $mediaBrowser->setCallback('cx.cm.setSelected' . ucfirst($name));
     return $mediaBrowser->getXHtml($_ARRAYLANG['TXT_CORE_CM_BROWSE']);
 }
 /**
  * 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');
     }
 }
 /**
  * Use this to parse your backend page
  *
  * You will get the template located in /View/Template/{CMD}.html
  * You can access Cx class using $this->cx
  * To show messages, use \Message class
  *
  * @param \Cx\Core\Html\Sigma $template Template for current CMD
  * @param array               $cmd      CMD separated by slashes
  */
 public function parsePage(\Cx\Core\Html\Sigma $template, array $cmd)
 {
     $uploader = new Uploader();
     $uploader->setFinishedCallback('\\Cx\\Core_Modules\\Uploader\\Model\\DefaultUploadCallback');
     $uploader->setCallback('gallery.uploader');
     $template->setVariable('UPLOADER_CODE', $uploader->getXHtml('Open Uploader 1'));
     $uploader2 = new Uploader();
     $uploader2->setUploadLimit(1);
     $uploader2->setFinishedCallback('\\Cx\\Core_Modules\\Uploader\\Model\\DefaultUploadCallback');
     $uploader2->setCallback('gallery.uploader2');
     $uploader2->setType(Uploader::UPLOADER_TYPE_INLINE);
     $template->setVariable('UPLOADER_CODE2', $uploader2->getXHtml('Open Uploader 2'));
     $configurations = array(array(), array('startview' => 'sitestructure', 'views' => 'sitestructure'), array('views' => 'uploader'), array('views' => 'sitestructure'), array('views' => 'filebrowser'), array('startmediatype' => 'gallery'), array('mediatypes' => 'gallery, files'), array('multipleselect' => true), array('data-cx-Mb-Cb-Js-modalopened' => 'testfunction'));
     foreach ($configurations as $configuration) {
         $mediaBrowser = new MediaBrowser();
         $mediaBrowser->setOptions($configuration);
         $mediaBrowser->setCallback('gallery.fancyCallback');
         $template->setVariable('MEDIABROWSER_CODE', $mediaBrowser->getXHtml('MediaBrowser'));
         $template->setVariable('MEDIABROWSER_OPTIONS', var_export($configuration, true));
         $template->setVariable('MEDIABROWSER_CODE_RAW', htmlspecialchars($mediaBrowser->getXHtml('MediaBrowser')));
         $template->parse('mediabrowser_demo');
     }
     $template->setVariable('MEDIABROWSER_FOLDER_WIDGET', new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($this->cx->getWebsiteImagesContentPath()));
     $template->setVariable('MEDIABROWSER_FOLDER_WIDGET_VIEW_MODE', new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($this->cx->getWebsiteImagesContentPath(), true));
 }