public function testAdminModules() { class_adminskin_helper::defineSkinWebpath(); class_carrier::getInstance()->getObjRights()->setBitTestMode(true); //load all admin-classes $arrFiles = class_resourceloader::getInstance()->getFolderContent("/admin", array(".php"), false, function ($strOneFile) { if (preg_match("/class_module_(.*)_admin.php/i", $strOneFile)) { $strClassname = uniSubstr($strOneFile, 0, -4); $objReflection = new ReflectionClass($strClassname); if (!$objReflection->isAbstract()) { return true; } } return false; }, function (&$strOneFile) { $strOneFile = uniSubstr($strOneFile, 0, -4); $strOneFile = new $strOneFile(); }); foreach ($arrFiles as $objAdminInstance) { $this->runSingleFile($objAdminInstance); } class_carrier::getInstance()->getObjRights()->setBitTestMode(false); }
/** * Processes an admin-request * * @param string $strModule * @param string $strAction * @param string $strLanguageParam * * @throws class_exception * @return string */ private function processAdminRequest($strModule, $strAction, $strLanguageParam) { $strReturn = ""; $bitLogin = false; //validate https status if (class_module_system_setting::getConfigValue("_admin_only_https_") == "true") { //check which headers to compare $strHeaderName = class_carrier::getInstance()->getObjConfig()->getConfig("https_header"); $strHeaderValue = strtolower(class_carrier::getInstance()->getObjConfig()->getConfig("https_header_value")); //header itself given? if (!issetServer($strHeaderName)) { //reload to https if (_xmlLoader_ === true) { class_response_object::getInstance()->setStrRedirectUrl(uniStrReplace("http:", "https:", _xmlpath_) . "?" . getServer("QUERY_STRING")); } else { class_response_object::getInstance()->setStrRedirectUrl(uniStrReplace("http:", "https:", _indexpath_) . "?" . getServer("QUERY_STRING")); } class_response_object::getInstance()->sendHeaders(); die("Reloading using https..."); } else { if ($strHeaderValue != "" && $strHeaderValue != strtolower(getServer($strHeaderName))) { //reload to https if (_xmlLoader_ === true) { class_response_object::getInstance()->setStrRedirectUrl(uniStrReplace("http:", "https:", _xmlpath_) . "?" . getServer("QUERY_STRING")); } else { class_response_object::getInstance()->setStrRedirectUrl(uniStrReplace("http:", "https:", _indexpath_) . "?" . getServer("QUERY_STRING")); } class_response_object::getInstance()->sendHeaders(); die("Reloading using https..."); } } } //process language-param $objLanguage = new class_module_languages_language(); $objLanguage->setStrAdminLanguageToWorkOn($strLanguageParam); //set the current backend skin. right here to do it only once. class_adminskin_helper::defineSkinWebpath(); //validate login-status / process login-request if ($strModule != "login" && $this->objSession->isLoggedin()) { if ($this->objSession->isAdmin()) { //try to load the module $objModuleRequested = class_module_system_module::getModuleByName($strModule); if ($objModuleRequested != null) { //see if there is data from a previous, failed request if (class_carrier::getInstance()->getObjSession()->getSession(class_module_login_admin::SESSION_LOAD_FROM_PARAMS) === "true") { foreach (class_carrier::getInstance()->getObjSession()->getSession(class_module_login_admin::SESSION_PARAMS) as $strOneKey => $strOneVal) { class_carrier::getInstance()->setParam($strOneKey, $strOneVal); } class_carrier::getInstance()->getObjSession()->sessionUnset(class_module_login_admin::SESSION_LOAD_FROM_PARAMS); class_carrier::getInstance()->getObjSession()->sessionUnset(class_module_login_admin::SESSION_PARAMS); } if (_xmlLoader_) { if ($objModuleRequested->getStrXmlNameAdmin() != "") { $strClassname = str_replace(".php", "", $objModuleRequested->getStrXmlNameAdmin()); $objConcreteModule = new $strClassname(); $strReturn = $objConcreteModule->action($strAction); } else { //xml-loader not defined, try to use the regular dispatcher $objConcreteModule = $objModuleRequested->getAdminInstanceOfConcreteModule(); $strReturn = $objConcreteModule->action($strAction); } } else { //fill the history array to track actions $objHistory = new class_history(); //Writing to the history if (class_carrier::getInstance()->getParam("folderview") == "") { $objHistory->setAdminHistory(); } $objConcreteModule = $objModuleRequested->getAdminInstanceOfConcreteModule(); if (class_carrier::getInstance()->getParam("blockAction") != "1") { $objConcreteModule->action(); $strReturn = $objConcreteModule->getModuleOutput(); } //React, if admin was opened by the portaleditor if (class_carrier::getInstance()->getParam("peClose") == "1") { if (getGet("peRefreshPage") != "") { $strReturn = "<html><head></head><body onload=\"parent.location = '" . urldecode(getGet("peRefreshPage")) . "';\"></body></html>"; } else { $strReturn = "<html><head></head><body onload=\"parent.location.reload();\"></body></html>"; } } } } else { throw new class_exception("Requested module " . $strModule . " not existing", class_exception::$level_FATALERROR); } } else { throw new class_exception("Sorry, but you don't have the needed permissions to access the admin-area", class_exception::$level_FATALERROR); } } else { $bitLogin = true; if ($strModule != "login") { $strAction = ""; } } if ($bitLogin) { if (_xmlLoader_) { $objLogin = new class_module_login_admin_xml(); $strReturn = $objLogin->action($strAction); } else { if (count(class_carrier::getInstance()->getObjDB()->getTables()) == 0 && file_exists(_realpath_ . "/installer.php")) { class_response_object::getInstance()->setStrRedirectUrl(_webpath_ . "/installer.php"); return ""; } $objLogin = new class_module_login_admin(); $objLogin->action($strAction); $strReturn = $objLogin->getModuleOutput(); } } return $strReturn; }
/** * 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; }