/** * Adds the portal-editor code to the current page-output - if all requirements are given * * @param class_module_pages_page $objPageData * @param bool $bitEditPermissionOnMasterPage * @param string $strPageContent * * @return string */ private function renderPortalEditorCode(class_module_pages_page $objPageData, $bitEditPermissionOnMasterPage, $strPageContent) { //add the portaleditor toolbar if (class_module_system_setting::getConfigValue("_pages_portaleditor_") == "false") { return $strPageContent; } if (!$this->objSession->isAdmin()) { return $strPageContent; } if (!$objPageData->rightEdit() && !$bitEditPermissionOnMasterPage) { return $strPageContent; } class_adminskin_helper::defineSkinWebpath(); //save back the current portal text language and set the admin-one $strPortalLanguage = class_carrier::getInstance()->getObjLang()->getStrTextLanguage(); class_carrier::getInstance()->getObjLang()->setStrTextLanguage($this->objSession->getAdminLanguage()); if ($this->objSession->getSession("pe_disable") != "true") { $strPeToolbar = ""; $arrPeContents = array(); $arrPeContents["pe_status_page_val"] = $objPageData->getStrName(); $arrPeContents["pe_status_status_val"] = $objPageData->getIntRecordStatus() == 1 ? "active" : "inactive"; $arrPeContents["pe_status_autor_val"] = $objPageData->getLastEditUser(); $arrPeContents["pe_status_time_val"] = timeToString($objPageData->getIntLmTime(), false); $arrPeContents["pe_dialog_close_warning"] = $this->getLang("pe_dialog_close_warning", "pages"); //Add an iconbar $arrPeContents["pe_iconbar"] = ""; $arrPeContents["pe_iconbar"] .= class_link::getLinkAdmin("pages_content", "list", "&systemid=" . $objPageData->getSystemid() . "&language=" . $strPortalLanguage, $this->getLang("pe_icon_edit"), $this->getLang("pe_icon_edit", "pages"), "icon_page"); $arrPeContents["pe_iconbar"] .= " "; $strEditUrl = class_link::getLinkAdminHref("pages", "editPage", "&systemid=" . $objPageData->getSystemid() . "&language=" . $strPortalLanguage . "&pe=1"); $arrPeContents["pe_iconbar"] .= "<a href=\"#\" onclick=\"KAJONA.admin.portaleditor.openDialog('" . $strEditUrl . "'); return false;\">" . class_adminskin_helper::getAdminImage("icon_edit", $this->getLang("pe_icon_page", "pages")) . "</a>"; $arrPeContents["pe_iconbar"] .= " "; $strEditUrl = class_link::getLinkAdminHref("pages", "newPage", "&systemid=" . $objPageData->getSystemid() . "&language=" . $strPortalLanguage . "&pe=1"); $arrPeContents["pe_iconbar"] .= "<a href=\"#\" onclick=\"KAJONA.admin.portaleditor.openDialog('" . $strEditUrl . "'); return false;\">" . class_adminskin_helper::getAdminImage("icon_new", $this->getLang("pe_icon_new", "pages")) . "</a>"; $arrPeContents["pe_disable"] = "<a href=\"#\" onclick=\"KAJONA.admin.portaleditor.switchEnabled(false); return false;\" title=\"\">" . class_adminskin_helper::getAdminImage("icon_enabled", $this->getLang("pe_disable", "pages")) . "</a>"; //Load portaleditor javascript (even if it's maybe already loaded in portal and init the ckeditor) $strTemplateInitID = $this->objTemplate->readTemplate("/elements.tpl", "wysiwyg_ckeditor_inits"); $strSkinInit = $this->objTemplate->fillTemplate(array(), $strTemplateInitID); $strConfigFile = "'config_kajona_standard.js'"; if (is_file(_realpath_ . "/project/admin/scripts/ckeditor/config_kajona_standard.js")) { $strConfigFile = "KAJONA_WEBPATH+'/project/admin/scripts/ckeditor/config_kajona_standard.js'"; } $strPeToolbar .= "<script type='text/javascript'>\n KAJONA.admin.lang.pe_rte_unsavedChanges = '" . $this->getLang("pe_rte_unsavedChanges", "pages") . "';\n\n if(\$) {\n KAJONA.portal.loader.loadFile([\n '/core/module_pages/admin/scripts/kajona_portaleditor.js',\n '/core/module_system/admin/scripts/jqueryui/jquery-ui.custom.min.js',\n '/core/module_system/admin/scripts/jqueryui/css/smoothness/jquery-ui.custom.css'\n ], function() {\n KAJONA.admin.portaleditor.RTE.config = {\n language : '" . (class_session::getInstance()->getAdminLanguage() != "" ? class_session::getInstance()->getAdminLanguage() : "en") . "',\n filebrowserBrowseUrl : '" . uniStrReplace("&", "&", class_link::getLinkAdminHref("folderview", "browserChooser", "&form_element=ckeditor")) . "',\n filebrowserImageBrowseUrl : '" . uniStrReplace("&", "&", class_link::getLinkAdminHref("mediamanager", "folderContentFolderviewMode", "systemid=" . class_module_system_setting::getConfigValue("_mediamanager_default_imagesrepoid_") . "&form_element=ckeditor&bit_link=1")) . "',\n customConfig : {$strConfigFile},\n " . $strSkinInit . "\n }\n \$(KAJONA.admin.portaleditor.initPortaleditor);\n });\n }\n else {\n KAJONA.portal.loader.loadFile([\n '/core/module_system/admin/scripts/jquery/jquery.min.js',\n '/core/module_system/admin/scripts/jqueryui/jquery-ui.custom.min.js',\n '/core/module_pages/admin/scripts/kajona_portaleditor.js',\n '/core/module_system/admin/scripts/jqueryui/css/smoothness/jquery-ui.custom.css'\n ], function() {\n KAJONA.admin.portaleditor.RTE.config = {\n language : '" . (class_session::getInstance()->getAdminLanguage() != "" ? class_session::getInstance()->getAdminLanguage() : "en") . "',\n filebrowserBrowseUrl : '" . uniStrReplace("&", "&", class_link::getLinkAdminHref("folderview", "browserChooser", "&form_element=ckeditor")) . "',\n filebrowserImageBrowseUrl : '" . uniStrReplace("&", "&", class_link::getLinkAdminHref("mediamanager", "folderContentFolderviewMode", "systemid=" . class_module_system_setting::getConfigValue("_mediamanager_default_imagesrepoid_") . "&form_element=ckeditor&bit_link=1")) . "',\n " . $strSkinInit . "\n }\n \$(KAJONA.admin.portaleditor.initPortaleditor);\n });\n }\n </script>"; //Load portaleditor styles $strPeToolbar .= $this->objToolkit->getPeBasicData(); $strPeToolbar .= $this->objToolkit->getPeToolbar($arrPeContents); $objScriptlets = new class_scriptlet_helper(); $strPeToolbar = $objScriptlets->processString($strPeToolbar, interface_scriptlet::BIT_CONTEXT_ADMIN); //The toolbar has to be added right after the body-tag - to generate correct html-code $strTemp = uniSubstr($strPageContent, uniStrpos($strPageContent, "<body")); //find closing bracket $intTemp = uniStrpos($strTemp, ">") + 1; //and insert the code $strPageContent = uniSubstr($strPageContent, 0, uniStrpos($strPageContent, "<body") + $intTemp) . $strPeToolbar . uniSubstr($strPageContent, uniStrpos($strPageContent, "<body") + $intTemp); } else { //Button to enable the toolbar & pe $strEnableButton = "<div id=\"peEnableButton\" style=\"z-index: 1000; position: fixed; top: 0px; right: 0px;\"><a href=\"#\" onclick=\"KAJONA.admin.portaleditor.switchEnabled(true); return false;\" title=\"\">" . getImageAdmin("icon_disabled", $this->getLang("pe_enable", "pages")) . "</a></div>"; //Load portaleditor javascript $strEnableButton .= "\n<script type=\"text/javascript\" src=\"" . _webpath_ . "/core/module_pages/admin/scripts/kajona_portaleditor.js?" . class_module_system_setting::getConfigValue("_system_browser_cachebuster_") . "\"></script>"; $strEnableButton .= $this->objToolkit->getPeBasicData(); //Load portaleditor styles //The toobar has to be added right after the body-tag - to generate correct html-code $strTemp = uniSubstr($strPageContent, uniStripos($strPageContent, "<body")); //find closing bracket $intTemp = uniStripos($strTemp, ">") + 1; //and insert the code $strPageContent = uniSubstr($strPageContent, 0, uniStrpos($strPageContent, "<body") + $intTemp) . $strEnableButton . uniSubstr($strPageContent, uniStrpos($strPageContent, "<body") + $intTemp); } //reset the portal texts language class_carrier::getInstance()->getObjLang()->setStrTextLanguage($strPortalLanguage); return $strPageContent; }