/** * Triggers the processing of the current request * @return void */ public function processRequest() { $strModule = class_carrier::getInstance()->getParam("module"); if ($strModule == "") { $strModule = _admin_ ? "dashboard" : "pages"; } $strAction = class_carrier::getInstance()->getParam("action"); $strLanguageParam = class_carrier::getInstance()->getParam("language"); $this->objResponse = class_response_object::getInstance(); $this->objResponse->setStrResponseType(class_http_responsetypes::STR_TYPE_HTML); $this->objResponse->setStrStatusCode(class_http_statuscodes::SC_OK); $objDispatcher = new class_request_dispatcher($this->objResponse); $objDispatcher->processRequest(_admin_, $strModule, $strAction, $strLanguageParam); }
/** * Handles the incomming request. Catches all exceptions so that we return * an clean json response with an fitting status code if an error occured * * @xml */ protected function actionDispatch() { class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON); try { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_OK); $strRequestMethod = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET'; $strRequestMethod = strtolower($strRequestMethod); if (in_array($strRequestMethod, array('get', 'post', 'put', 'delete'))) { $arrResponse = $this->action($strRequestMethod); } else { throw new class_invalid_request_exception('Invalid request method', class_exception::$level_ERROR); } } catch (class_invalid_request_exception $e) { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_BADREQUEST); $e->processException(); $arrResponse = array('success' => false, 'message' => $e->getMessage()); } catch (class_exception $e) { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_INTERNAL_SERVER_ERROR); $e->processException(); $arrResponse = array('success' => false, 'message' => $e->getMessage()); } catch (Exception $e) { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_INTERNAL_SERVER_ERROR); $arrResponse = array('success' => false, 'message' => 'An unknown error occured'); } return json_encode($arrResponse, JSON_PRETTY_PRINT); }
/** * @return class_response_object */ public static function getInstance() { if (self::$objInstance == null) { self::$objInstance = new class_response_object(); } return self::$objInstance; }
/** * Returns a list of all packages available. * By default a json-encoded array-like structure. * * @return string|json * @permissions view * @xml */ protected function actionList() { $arrPackages = array(); $intNrOfFiles = 0; $intStart = $this->ensureNumericValue($this->getParam("start"), null); $intEnd = $this->ensureNumericValue($this->getParam("end"), null); $strTypeFilter = $this->isValidCategoryFilter($this->getParam("type")) ? $this->getParam("type") : false; $strNameFilter = trim($this->getParam("title")) != "" ? trim($this->getParam("title")) : false; if ($this->isValidPagingParameter($intStart) && $this->isValidPagingParameter($intEnd)) { if ($intEnd >= $intStart) { $intNrOfFiles = $this->getAllPackagesCount(class_module_system_setting::getConfigValue("_packageserver_repo_id_"), $strTypeFilter, $strNameFilter); $arrDBFiles = $this->getAllPackages(class_module_system_setting::getConfigValue("_packageserver_repo_id_"), $strTypeFilter, $intStart, $intEnd, $strNameFilter); //error-handling: a new filter and a offset is passed. but maybe the passed offset is no longer valid for the new filter criteria if (count($arrDBFiles) == 0 && $intNrOfFiles > 0) { $arrDBFiles = $this->getAllPackages(class_module_system_setting::getConfigValue("_packageserver_repo_id_"), $strTypeFilter, 0, $intNrOfFiles, $strNameFilter); } $objManager = new class_module_packagemanager_manager(); foreach ($arrDBFiles as $objOneFile) { try { $objMetadata = $objManager->getPackageManagerForPath($objOneFile->getStrFilename()); $arrPackages[] = array("systemid" => $objOneFile->getSystemid(), "title" => $objMetadata->getObjMetadata()->getStrTitle(), "version" => $objMetadata->getObjMetadata()->getStrVersion(), "description" => $objMetadata->getObjMetadata()->getStrDescription(), "type" => $objMetadata->getObjMetadata()->getStrType()); } catch (class_exception $objEx) { } } class_module_packageserver_log::generateDlLog($strNameFilter !== false ? $strNameFilter : "", isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : "::1", urldecode($this->getParam("domain"))); class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON); } } $result = array(); $result['numberOfTotalItems'] = $intNrOfFiles; $result['items'] = $arrPackages; $result['protocolVersion'] = self::PROTOCOL_VERSION; $strReturn = json_encode($result); return $strReturn; }
/** * Triggers the workflow engine * * @xml * @return string */ protected function actionTrigger() { class_carrier::getInstance()->getObjSession()->setBitBlockDbUpdate(true); if ($this->getParam("authkey") == class_module_system_setting::getConfigValue("_workflows_trigger_authkey_")) { $objWorkflowController = new class_workflows_controller(); $objWorkflowController->scheduleWorkflows(); $objWorkflowController->runWorkflows(); return "<message>Execution successful</message>"; } class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_UNAUTHORIZED); return "<message><error>Not authorized</error></message>"; }
/** * Logs the current user into the system * * @return string */ protected function actionLogin() { if ($this->objSession->login($this->getParam("username"), $this->getParam("password"))) { //user allowed to access admin? if (!$this->objSession->isAdmin()) { //no, reset session $this->objSession->logout(); } return "<message><success>" . xmlSafeString($this->getLang("login_xml_succeess", "system")) . "</success></message>"; } else { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_UNAUTHORIZED); return "<message><error>" . xmlSafeString($this->getLang("login_xml_error", "system")) . "</error></message>"; } }
/** * Internal upload handler to handle xml uploads. * Used as a backend by the jquery upload plugin. * Terminates the request. * @return string */ private function doAjaxUpload() { class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON); $strUpload = $this->doUpload(true); if ($strUpload === true) { $strUpload = $this->getLang("portaluploadSuccess"); } else { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_FORBIDDEN); } $this->flushCompletePagesCache(); class_response_object::getInstance()->sendHeaders(); echo json_encode($strUpload); die; }
/** * Starts the processing of the requests, fetches params and passes control to the request dispatcher * @return void */ public function processRequest() { $strModule = class_carrier::getInstance()->getParam("module"); $strAction = class_carrier::getInstance()->getParam("action"); $strLanguageParam = class_carrier::getInstance()->getParam("language"); $this->objResponse = class_response_object::getInstance(); $this->objResponse->setStrResponseType(class_http_responsetypes::STR_TYPE_XML); $this->objResponse->setStrStatusCode(class_http_statuscodes::SC_OK); $objDispatcher = new class_request_dispatcher($this->objResponse); $objDispatcher->processRequest(_admin_, $strModule, $strAction, $strLanguageParam); if ($this->objResponse->getStrContent() == "") { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_BADREQUEST); $this->objResponse->setStrContent("<error>An error occurred, malformed request</error>"); } if ($this->objResponse->getStrResponseType() == class_http_responsetypes::STR_TYPE_XML && self::$bitRenderXmlHeader) { $this->objResponse->setStrContent("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" . $this->objResponse->getStrContent()); } }
/** * Renderes the content of a single widget. * * @return string * @permissions view */ protected function actionGetWidgetContent() { //load the aspect and close the session afterwards class_module_system_aspect::getCurrentAspect(); $objWidgetModel = new class_module_dashboard_widget($this->getSystemid()); if ($objWidgetModel->rightView()) { $objConcreteWidget = $objWidgetModel->getConcreteAdminwidget(); if (!$objConcreteWidget->getBitBlockSessionClose()) { class_carrier::getInstance()->getObjSession()->sessionClose(); } //disable the internal changelog class_module_system_changelog::$bitChangelogEnabled = false; class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON); $strReturn = json_encode($objConcreteWidget->generateWidgetOutput()); } else { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_UNAUTHORIZED); $strReturn = "<message><error>" . xmlSafeString($this->getLang("commons_error_permissions")) . "</error></message>"; } return $strReturn; }
/** * Tries to save the passed cropping. * The following params are needed: * action = saveCropping * folder = the files' location * file = the file to crop * systemid = the repo-id * intX * intY * intWidth * intHeight * @return string * @permissions edit */ protected function actionSaveCropping() { $strReturn = ""; $strFile = $this->getParam("file"); $objImage = new class_image2(); $objImage->setUseCache(false); $objImage->load($strFile); $objImage->addOperation(new class_image_crop($this->getParam("intX"), $this->getParam("intY"), $this->getParam("intWidth"), $this->getParam("intHeight"))); if ($objImage->save($strFile)) { class_logger::getInstance()->addLogRow("cropped file " . $strFile, class_logger::$levelInfo); $strReturn .= "<message>" . xmlSafeString($this->getLang("xml_cropping_success")) . "</message>"; } else { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_UNAUTHORIZED); $strReturn .= "<message><error>" . xmlSafeString($this->getLang("commons_error_permissions")) . "</error></message>"; } return $strReturn; }
/** * Use this method to reload a specific url. * <b>Use ONLY this method and DO NOT use header("Location: ...");</b> * * @param string $strUrlToLoad * * @return void */ public function adminReload($strUrlToLoad) { //filling constants $strUrlToLoad = str_replace("_webpath_", _webpath_, $strUrlToLoad); $strUrlToLoad = str_replace("_indexpath_", _indexpath_, $strUrlToLoad); //No redirect, if close-Command for admin-area should be sent if ($this->getParam("peClose") == "") { class_response_object::getInstance()->setStrRedirectUrl($strUrlToLoad); } }
/** * saves a post in the database and returns the post as html. * In case of missing fields, the form is returned again * * @return string * @permissons right1 */ protected function actionSavePost() { $strXMLContent = ""; //validate needed fields if (!$this->validateForm()) { //Create form to reenter values $strTemplateID = $this->objTemplate->readTemplate("/module_postacomment/" . $this->getParam("comment_template"), "postacomment_form"); $arrForm = array(); $arrForm["formaction"] = class_link::getLinkPortalHref($this->getPagename(), "", "postComment", "", $this->getSystemid()); $arrForm["comment_name"] = $this->getParam("comment_name"); $arrForm["comment_subject"] = $this->getParam("comment_subject"); $arrForm["comment_message"] = $this->getParam("comment_message"); $arrForm["comment_template"] = $this->getParam("comment_template"); $arrForm["comment_systemid"] = $this->getParam("comment_systemid"); $arrForm["comment_page"] = $this->getParam("comment_page"); $arrForm["validation_errors"] = $this->strErrors; foreach ($arrForm as $strKey => $strValue) { if (uniStrpos($strKey, "comment_") !== false) { $arrForm[$strKey] = htmlspecialchars($strValue, ENT_QUOTES, "UTF-8", false); } } //texts $arrForm["postacomment_write_new"] = $this->getLang("postacomment_write_new"); $arrForm["form_name_label"] = $this->getLang("form_name_label"); $arrForm["form_subject_label"] = $this->getLang("form_subject_label"); $arrForm["form_message_label"] = $this->getLang("form_message_label"); $arrForm["form_captcha_label"] = $this->getLang("commons_captcha"); $arrForm["form_captcha_reload_label"] = $this->getLang("commons_captcha_reload"); $arrForm["form_submit_label"] = $this->getLang("form_submit_label"); $strXMLContent .= $this->fillTemplate($arrForm, $strTemplateID); } else { //save the post to the db //pageid or systemid to filter? $strSystemidfilter = $this->getParam("comment_systemid"); if (class_module_pages_page::getPageByName($this->getParam("comment_page")) !== null) { $strPagefilter = class_module_pages_page::getPageByName($this->getParam("comment_page"))->getSystemid(); } else { $strPagefilter = ""; } $objPost = new class_module_postacomment_post(); $objPost->setStrUsername($this->getParam("comment_name")); $objPost->setStrTitle($this->getParam("comment_subject")); $objPost->setStrComment($this->getParam("comment_message")); $objPost->setStrAssignedPage($strPagefilter); $objPost->setStrAssignedSystemid($strSystemidfilter); $objPost->setStrAssignedLanguage($this->getStrPortalLanguage()); $objPost->updateObjectToDb(); $this->flushPageFromPagesCache($this->getPagename()); $strMailtext = $this->getLang("new_comment_mail") . "\r\n\r\n" . $objPost->getStrComment() . "\r\n"; $strMailtext .= class_link::getLinkAdminHref("postacomment", "edit", "&systemid=" . $objPost->getSystemid(), false); $objMessageHandler = new class_module_messaging_messagehandler(); $arrGroups = array(); $allGroups = class_module_user_group::getObjectList(); foreach ($allGroups as $objOneGroup) { if (class_rights::getInstance()->checkPermissionForGroup($objOneGroup->getSystemid(), class_rights::$STR_RIGHT_EDIT, $this->getObjModule()->getSystemid())) { $arrGroups[] = $objOneGroup; } } $objMessageHandler->sendMessage($strMailtext, $arrGroups, new class_messageprovider_postacomment()); //reinit post -> encoded entities $objPost->initObject(); //load the post as a new post to add it at top of the list $arrOnePost = array(); $arrOnePost["postacomment_post_name"] = $objPost->getStrUsername(); $arrOnePost["postacomment_post_subject"] = $objPost->getStrTitle(); $arrOnePost["postacomment_post_message"] = $objPost->getStrComment(); $arrOnePost["postacomment_post_systemid"] = $objPost->getSystemid(); $arrOnePost["postacomment_post_date"] = timeToString($objPost->getIntDate(), true); $strTemplateID = $this->objTemplate->readTemplate("/module_postacomment/" . $this->getParam("comment_template"), "postacomment_post"); $strXMLContent .= $this->objTemplate->fillTemplate($arrOnePost, $strTemplateID); } class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON); return $strXMLContent; }
/** * Sets the prev-id of a record. * expects the param prevId * * @return string * @permissions edit */ protected function actionSetPrevid() { $strReturn = ""; $objRecord = class_objectfactory::getInstance()->getObject($this->getSystemid()); $strNewPrevId = $this->getParam("prevId"); //check permissions if ($objRecord != null && $objRecord->rightEdit() && validateSystemid($strNewPrevId)) { if ($objRecord->getStrPrevId() != $strNewPrevId) { $objRecord->updateObjectToDb($strNewPrevId); } $strReturn .= "<message>" . $objRecord->getStrDisplayName() . " - " . $this->getLang("setPrevIdOk") . "</message>"; $this->flushCompletePagesCache(); } else { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_UNAUTHORIZED); $strReturn .= "<message><error>" . xmlSafeString($this->getLang("commons_error_permissions")) . "</error></message>"; } return $strReturn; }
/** * Saves the rights passed by form * * @throws class_exception * @return string "" in case of success * @permissions right * @xml */ protected function actionSaveRights() { class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON); $arrRequest = json_decode($this->getParam("json")); //Collecting & sorting the passed values $strSystemid = $this->getSystemid(); $objRights = class_carrier::getInstance()->getObjRights(); if ($this->getParam("systemid") == "0") { $objTarget = new class_module_system_common("0"); $objTarget->setStrSystemid("0"); $strSystemid = "0"; } else { $objTarget = class_objectfactory::getInstance()->getObject($this->getSystemid()); } //Special case: The root-record. if (!$objTarget->rightRight()) { return $this->objToolkit->warningBox($this->getLang("commons_error_permissions"), "alert-danger"); } //Inheritance? if ($arrRequest->bitInherited) { $intInherit = 1; } else { $intInherit = 0; } //Modified RootRecord? Here Inheritance is NOT allowed! if ($strSystemid == "0") { $intInherit = 0; } $strAdminsGroupId = class_module_system_setting::getConfigValue("_admins_group_id_"); $strView = $strAdminsGroupId; $strEdit = $strAdminsGroupId; $strDelete = $strAdminsGroupId; $strRight = $strAdminsGroupId; $strRight1 = $strAdminsGroupId; $strRight2 = $strAdminsGroupId; $strRight3 = $strAdminsGroupId; $strRight4 = $strAdminsGroupId; $strRight5 = $strAdminsGroupId; $strChangelog = $strAdminsGroupId; foreach ($arrRequest->arrConfigs as $strOneCfg) { $arrRow = explode(",", $strOneCfg); if ($arrRow[1] == $strAdminsGroupId) { continue; } switch ($arrRow[0]) { case "1": $strView .= "," . $arrRow[1]; break; case "2": $strEdit .= "," . $arrRow[1]; break; case "3": $strDelete .= "," . $arrRow[1]; break; case "4": $strRight .= "," . $arrRow[1]; break; case "5": $strRight1 .= "," . $arrRow[1]; break; case "6": $strRight2 .= "," . $arrRow[1]; break; case "7": $strRight3 .= "," . $arrRow[1]; break; case "8": $strRight4 .= "," . $arrRow[1]; break; case "9": $strRight5 .= "," . $arrRow[1]; break; case "10": $strChangelog .= "," . $arrRow[1]; break; } } $arrReturn = array("inherit" => $intInherit, "view" => $strView, "edit" => $strEdit, "delete" => $strDelete, "right" => $strRight, "right1" => $strRight1, "right2" => $strRight2, "right3" => $strRight3, "right4" => $strRight4, "right5" => $strRight5, "changelog" => $strChangelog); //Pass to right-class if ($objRights->setRights($arrReturn, $strSystemid)) { $strReturn = $this->objToolkit->warningBox($this->getLang("permissions_success"), "alert-success"); } else { $strReturn = $this->objToolkit->warningBox($this->getLang("fehler_setzen"), "alert-danger"); } return json_encode(array("message" => $strReturn)); }
/** * Determines the page-data to load. * This includes the evaluation of the current page-data and the fallback to another language or even the error-page * * @throws class_exception * @return class_module_pages_page */ private function getPageData() { $strPagename = $this->getPagename(); //Load the data of the page $objPageData = class_module_pages_page::getPageByName($strPagename); //check, if the page is enabled and if the rights are given, or if we want to load a preview of a page $bitErrorpage = false; if ($objPageData == null || ($objPageData->getIntRecordStatus() != 1 || !$objPageData->rightView())) { $bitErrorpage = true; } //but: if count != 0 && preview && rights: if ($bitErrorpage && $objPageData != null && $this->getParam("preview") == "1" && $objPageData->rightEdit()) { $bitErrorpage = false; } //check, if the template could be loaded try { if (!$bitErrorpage) { $this->objTemplate->readTemplate("/module_pages/" . $objPageData->getStrTemplate(), "", false, true); } } catch (class_exception $objException) { $bitErrorpage = true; } if ($bitErrorpage) { //Unfortunately, we have to load the errorpage //try to send the correct header //page not found if ($objPageData == null || $objPageData->getIntRecordStatus() != 1) { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_NOT_FOUND); } //user is not allowed to view the page if ($objPageData != null && !$objPageData->rightView()) { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_FORBIDDEN); } //check, if the page may be loaded using the default-language $strPreviousLang = $this->getStrPortalLanguage(); $objDefaultLang = class_module_languages_language::getDefaultLanguage(); if ($this->getStrPortalLanguage() != $objDefaultLang->getStrName()) { class_logger::getInstance()->addLogRow("Requested page " . $strPagename . " not existing in language " . $this->getStrPortalLanguage() . ", switch to fallback lang", class_logger::$levelWarning); $objDefaultLang->setStrPortalLanguage($objDefaultLang->getStrName()); $objPageData = class_module_pages_page::getPageByName($strPagename); $bitErrorpage = false; try { if ($objPageData != null) { $this->objTemplate->readTemplate("/module_pages/" . $objPageData->getStrTemplate(), "", false, true); } else { $bitErrorpage = true; } } catch (class_exception $objException) { $bitErrorpage = true; } if ($bitErrorpage) { $strPagename = class_module_system_setting::getConfigValue("_pages_errorpage_"); $this->setParam("page", class_module_system_setting::getConfigValue("_pages_errorpage_")); //revert to the old language - fallback didn't work $objDefaultLang->setStrPortalLanguage($strPreviousLang); } } else { $strPagename = class_module_system_setting::getConfigValue("_pages_errorpage_"); $this->setParam("page", class_module_system_setting::getConfigValue("_pages_errorpage_")); } $objPageData = class_module_pages_page::getPageByName($strPagename); //check, if the page is enabled and if the rights are given, too if ($objPageData == null || ($objPageData->getIntRecordStatus() != 1 || !$objPageData->rightView())) { //Whoops. Nothing to output here throw new class_exception("Requested Page " . $strPagename . " not existing, no errorpage created or set!", class_exception::$level_FATALERROR); } } return $objPageData; }
/** * Sends the requested file to the browser * @return string */ public function actionDownload() { //Load filedetails if (validateSystemid($this->getSystemid())) { /** @var $objFile class_module_mediamanager_file */ $objFile = class_objectfactory::getInstance()->getObject($this->getSystemid()); //Succeeded? if ($objFile instanceof class_module_mediamanager_file && $objFile->getIntRecordStatus() == "1" && $objFile->getIntType() == class_module_mediamanager_file::$INT_TYPE_FILE) { //Check rights if ($objFile->rightRight2()) { //Log the download class_module_mediamanager_logbook::generateDlLog($objFile); //Send the data to the browser $strBrowser = getServer("HTTP_USER_AGENT"); //Check the current browsertype if (uniStrpos($strBrowser, "IE") !== false) { //Internet Explorer class_response_object::getInstance()->addHeader("Content-type: application/x-ms-download"); class_response_object::getInstance()->addHeader("Content-type: x-type/subtype\n"); class_response_object::getInstance()->addHeader("Content-type: application/force-download"); class_response_object::getInstance()->addHeader("Content-Disposition: attachment; filename=" . preg_replace('/\\./', '%2e', saveUrlEncode(trim(basename($objFile->getStrFilename()))), substr_count(basename($objFile->getStrFilename()), '.') - 1)); } else { //Good: another browser vendor class_response_object::getInstance()->addHeader("Content-Type: application/octet-stream"); class_response_object::getInstance()->addHeader("Content-Disposition: attachment; filename=" . saveUrlEncode(trim(basename($objFile->getStrFilename())))); } //Common headers class_response_object::getInstance()->addHeader("Expires: Mon, 01 Jan 1995 00:00:00 GMT"); class_response_object::getInstance()->addHeader("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); class_response_object::getInstance()->addHeader("Pragma: no-cache"); class_response_object::getInstance()->addHeader("Content-description: JustThum-Generated Data\n"); class_response_object::getInstance()->addHeader("Content-Length: " . filesize(_realpath_ . $objFile->getStrFilename())); //End Session $this->objSession->sessionClose(); class_response_object::getInstance()->sendHeaders(); //Loop the file $ptrFile = @fopen(_realpath_ . $objFile->getStrFilename(), 'rb'); fpassthru($ptrFile); @fclose($ptrFile); ob_flush(); flush(); return ""; } else { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_FORBIDDEN); } } else { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_NOT_FOUND); } } else { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_NOT_FOUND); } //if we reach up here, something gone wrong :/ class_response_object::getInstance()->setStrRedirectUrl(str_replace(array("_indexpath_", "&"), array(_indexpath_, "&"), class_link::getLinkPortalHref(class_module_system_setting::getConfigValue("_pages_errorpage_")))); class_response_object::getInstance()->sendHeaders(); class_response_object::getInstance()->sendContent(); return ""; }
/** * Checks if an update is available for a list of packages. * Renders the matching icon and tooltip or the link to update a package. * * @xml * @permissions view,edit * @return string */ protected function actionGetUpdateIcons() { $strPackages = $this->getParam("packages"); $arrPackagesToCheck = explode(",", $strPackages); $objManager = new class_module_packagemanager_manager(); //close session to avoid blocking $this->objSession->sessionClose(); $arrLatestVersion = $objManager->scanForUpdates(); $arrReturn = array(); foreach ($arrPackagesToCheck as $strOnePackage) { $objMetadata = $objManager->getPackage($strOnePackage); if ($objMetadata == null || !isset($arrLatestVersion[$strOnePackage])) { $arrReturn[$strOnePackage] = class_adminskin_helper::getAdminImage("icon_updateError", $this->getLang("package_noversion")); continue; } $objHandler = $objManager->getPackageManagerForPath($objMetadata->getStrPath()); $bitUpdateAvailable = $objManager->updateAvailable($objHandler, $arrLatestVersion[$strOnePackage]); if ($bitUpdateAvailable === null) { $arrReturn[$strOnePackage] = class_adminskin_helper::getAdminImage("icon_updateError", $this->getLang("package_noversion")); } else { //compare the version to trigger additional actions $strLatestVersion = $arrLatestVersion[$strOnePackage]; if ($bitUpdateAvailable) { $arrReturn[$strOnePackage] = class_link::getLinkAdminDialog($this->getArrModule("modul"), "initPackageUpdate", "&package=" . $objHandler->getObjMetadata()->getStrPath(), $this->getLang("package_updatefound") . " " . $strLatestVersion, $this->getLang("package_updatefound") . " " . $strLatestVersion, "icon_update", $objHandler->getObjMetadata()->getStrTitle()); } else { $arrReturn[$strOnePackage] = class_adminskin_helper::getAdminImage("icon_updateDisabled", $this->getLang("package_noupdate") . " " . $strLatestVersion); } } } class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON); return json_encode($arrReturn); }
/** * Returns all eventes in json-format. * Expects the params start & end. * @xml * @return string * @permissions view */ protected function actionGetJsonEvents() { $arrPrintableEvents = array(); $objStartDate = null; $objEndDate = null; if ($this->getParam("start") != "" && $this->getParam("end") != "") { $objStartDate = new class_date($this->getParam("start")); $objEndDate = new class_date($this->getParam("end")); } $arrEvents = class_module_eventmanager_event::getAllEvents(false, false, $objStartDate, $objEndDate, true); foreach ($arrEvents as $objOneEvent) { if ($objOneEvent->rightView()) { $arrSingleEvent = array(); $arrSingleEvent["id"] = $objOneEvent->getSystemid(); $arrSingleEvent["title"] = $objOneEvent->getStrTitle(); $arrSingleEvent["start"] = $objOneEvent->getObjStartDate()->getTimeInOldStyle(); $arrSingleEvent["end"] = $objOneEvent->getObjEndDate() != null ? $objOneEvent->getObjEndDate()->getTimeInOldStyle() : ""; $arrSingleEvent["url"] = uniStrReplace("&", "&", class_link::getLinkPortalHref($this->getParam("page"), "", "eventDetails", "", $objOneEvent->getSystemid(), "", $objOneEvent->getStrTitle())); $arrPrintableEvents[] = $arrSingleEvent; } } class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON); return json_encode($arrPrintableEvents); }
private function loadPostLoginSite() { //any url to redirect? if ($this->objSession->getSession(self::SESSION_REFERER) != "" && $this->objSession->getSession(self::SESSION_REFERER) != "admin=1") { class_response_object::getInstance()->setStrRedirectUrl(_indexpath_ . "?" . $this->objSession->getSession(self::SESSION_REFERER)); $this->objSession->sessionUnset(self::SESSION_REFERER); $this->objSession->setSession(self::SESSION_LOAD_FROM_PARAMS, "true"); } else { //route to the default module $strModule = "dashboard"; if (class_session::getInstance()->isLoggedin()) { $objUser = new class_module_user_user(class_session::getInstance()->getUserID()); if ($objUser->getStrAdminModule() != "") { $strModule = $objUser->getStrAdminModule(); } } class_response_object::getInstance()->setStrRedirectUrl(class_link::getLinkAdminHref($strModule)); } }
/** * Generates debugging-infos, but only in non-xml mode * * @param string $strReturn * * @return string */ private function getDebugInfo($strReturn) { $strDebug = ""; if (_timedebug_ || _dbnumber_ || _templatenr_ || _memory_) { //Maybe we need the time used to generate this page if (_timedebug_ === true) { $arrTimestampEnde = gettimeofday(); $intTimeUsed = ($arrTimestampEnde['sec'] * 1000000 + $arrTimestampEnde['usec'] - ($this->arrTimestampStart['sec'] * 1000000 + $this->arrTimestampStart['usec'])) / 1000000; $strDebug .= "<b>PHP-Time:</b> " . number_format($intTimeUsed, 6) . " sec "; } //Hows about the queries? if (_dbnumber_ === true) { $strDebug .= "<b>Queries db/cachesize/cached/fired:</b> " . class_carrier::getInstance()->getObjDB()->getNumber() . "/" . class_carrier::getInstance()->getObjDB()->getCacheSize() . "/" . class_carrier::getInstance()->getObjDB()->getNumberCache() . "/" . (class_carrier::getInstance()->getObjDB()->getNumber() - class_carrier::getInstance()->getObjDB()->getNumberCache()) . " "; } //anything to say about the templates? if (_templatenr_ === true) { $strDebug .= "<b>Templates cached:</b> " . class_carrier::getInstance()->getObjTemplate()->getNumberCacheSize() . " "; } //memory if (_memory_ === true) { $strDebug .= "<b>Memory/Max Memory:</b> " . bytesToString(memory_get_usage()) . "/" . bytesToString(memory_get_peak_usage()) . " "; $strDebug .= "<b>Classes Loaded:</b> " . class_classloader::getInstance()->getIntNumberOfClassesLoaded() . " "; } //and check the cache-stats if (_cache_ === true) { $strDebug .= "<b>Cache requests/hits/saves/cachesize:</b> " . class_cache::getIntRequests() . "/" . class_cache::getIntHits() . "/" . class_cache::getIntSaves() . "/" . class_cache::getIntCachesize() . " "; } if (_xmlLoader_ === true) { class_response_object::getInstance()->addHeader("Kajona Debug: " . $strDebug); } else { $strDebug = "<pre style='z-index: 2000000; position: fixed; background-color: white; width: 100%; top: 0px; font-size: 10px; padding: 0; margin: 0;'>Kajona Debug: " . $strDebug . "</pre>"; $intBodyPos = uniStrpos($strReturn, "</body>"); if ($intBodyPos !== false) { $strReturn = uniSubstr($strReturn, 0, $intBodyPos) . $strDebug . uniSubstr($strReturn, $intBodyPos); } else { $strReturn = $strDebug . $strReturn; } } } return $strReturn; }
/** * Creates a list of the recent messages for the current user. * The structure is returned in an json-format. * * @permissions view * @xml * @autoTestable * * @return string */ protected function actionGetRecentMessages() { class_carrier::getInstance()->getObjSession()->setBitBlockDbUpdate(true); class_session::getInstance()->sessionClose(); class_module_system_changelog::$bitChangelogEnabled = false; class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON); $intMaxAmount = $this->getParam("limit") != "" ? $this->getParam("limit") : 5; $arrMessages = class_module_messaging_message::getObjectList($this->objSession->getUserID(), 0, $intMaxAmount - 1); $arrReturn = array(); foreach ($arrMessages as $objOneMessage) { $arrReturn[] = array("systemid" => $objOneMessage->getSystemid(), "title" => $objOneMessage->getStrDisplayName(), "unread" => $objOneMessage->getBitRead(), "details" => class_link::getLinkAdminHref($objOneMessage->getArrModule("modul"), "edit", "&systemid=" . $objOneMessage->getSystemid(), false)); } $arrReturn = array("messages" => $arrReturn, "messageCount" => class_module_messaging_message::getNumberOfMessagesForUser($this->objSession->getUserID(), true)); return json_encode($arrReturn); }
/** * Generates the list of favorite tags for the current user. * Returned structure is json based. * * @return string * @permissions view */ protected function actionGetFavoriteTags() { class_session::getInstance()->sessionClose(); class_carrier::getInstance()->getObjSession()->setBitBlockDbUpdate(true); class_module_system_changelog::$bitChangelogEnabled = false; $arrReturn = array(); $arrFavorites = class_module_tags_favorite::getAllFavoritesForUser(class_carrier::getInstance()->getObjSession()->getUserID(), 0, 10); foreach ($arrFavorites as $objOneFavorite) { $arrReturn[] = array("name" => $objOneFavorite->getStrDisplayName(), "onclick" => "location.href='" . getLinkAdminHref("tags", "showAssignedRecords", "&systemid=" . $objOneFavorite->getMappedTagSystemid(), false) . "'", "url" => getLinkAdminHref("tags", "showAssignedRecords", "&systemid=" . $objOneFavorite->getMappedTagSystemid(), false)); } class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON); return json_encode($arrReturn); }
/** * @param string $strSearchterm * @param class_search_result[] $arrResults * * @return string */ private function createSearchJson($strSearchterm, $arrResults) { $arrItems = array(); foreach ($arrResults as $objOneResult) { $arrItem = array(); //create a correct link if ($objOneResult->getObjObject() == null || !$objOneResult->getObjObject()->rightView()) { continue; } $strIcon = ""; if ($objOneResult->getObjObject() instanceof interface_admin_listable) { $strIcon = $objOneResult->getObjObject()->getStrIcon(); if (is_array($strIcon)) { $strIcon = $strIcon[0]; } } $strLink = $objOneResult->getStrPagelink(); if ($strLink == "") { $strLink = class_link::getLinkAdminHref($objOneResult->getObjObject()->getArrModule("modul"), "edit", "&systemid=" . $objOneResult->getStrSystemid()); } $arrItem["module"] = class_carrier::getInstance()->getObjLang()->getLang("modul_titel", $objOneResult->getObjObject()->getArrModule("modul")); $arrItem["systemid"] = $objOneResult->getStrSystemid(); $arrItem["icon"] = class_adminskin_helper::getAdminImage($strIcon, "", true); $arrItem["score"] = $objOneResult->getStrSystemid(); $arrItem["description"] = uniStrTrim($objOneResult->getObjObject()->getStrDisplayName(), 200); $arrItem["link"] = html_entity_decode($strLink); $arrItems[] = $arrItem; } $objResult = $arrItems; class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON); return json_encode($objResult); }
/** * @xml * @permissions edit * @return string */ protected function actionUpdateObjectProperty() { $strReturn = ""; //get the object to update /** @var $objObject class_module_pages_element */ $objObject = class_objectfactory::getInstance()->getObject($this->getSystemid()); if ($objObject->rightEdit()) { //differ between two modes - page-elements or regular objects if ($objObject instanceof class_module_pages_pageelement) { $strPageSystemid = $objObject->getPrevId(); $objLockmanager = new class_lockmanager($objObject->getSystemid()); if (!$objLockmanager->isLocked()) { $objLockmanager->lockRecord(); } if ($objLockmanager->isLockedByCurrentUser()) { //and finally create the object /** @var class_module_pages_pageelement $objElement */ $strElementClass = str_replace(".php", "", $objObject->getStrClassAdmin()); //and finally create the object /** @var $objElement class_element_admin */ $objElement = new $strElementClass(); $objElement->setSystemid($this->getSystemid()); $arrElementData = $objElement->loadElementData(); //see if we could set the param to the element if ($this->getParam("property") != "") { $strProperty = null; //try to fetch the matching setter $objReflection = new class_reflection($objElement); //try to fetch the property based on the orm annotations $strTargetTable = $objReflection->getAnnotationValuesFromClass(class_orm_base::STR_ANNOTATION_TARGETTABLE); if (count($strTargetTable) > 0) { $strTargetTable = $strTargetTable[0]; } $arrTable = explode(".", $strTargetTable); if (count($arrTable) == 2) { $strTargetTable = $arrTable[0]; } $arrOrmProperty = $objReflection->getPropertiesWithAnnotation(class_orm_base::STR_ANNOTATION_TABLECOLUMN); foreach ($arrOrmProperty as $strCurProperty => $strValue) { if ($strValue == $strTargetTable . "." . $this->getParam("property")) { $strProperty = $strCurProperty; } } if ($strProperty == null) { $strProperty = $this->getParam("property"); } $strSetter = $objReflection->getSetter($strProperty); if ($strSetter != null) { call_user_func(array($objElement, $strSetter), $this->getParam("value")); } else { $arrElementData[$this->getParam("property")] = $this->getParam("value"); $objElement->setArrParamData($arrElementData); } } //pass the data to the element, maybe the element wants to update some data $objElement->doBeforeSaveToDb(); //check, if we could save the data, so the element needn't to //woah, we are soooo great $objElement->updateForeignElement(); //Edit Date of page & unlock $objPage = class_objectfactory::getInstance()->getObject($strPageSystemid); $objPage->updateObjectToDb(); $objLockmanager->unlockRecord(); //allow the element to run actions after saving $objElement->doAfterSaveToDb(); //Loading the data of the corresp site $this->flushCompletePagesCache(); $strReturn = "<message><success>element update succeeded</success></message>"; } } else { //any other object - try to find the matching property and write the value if ($this->getParam("property") == "") { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_BADREQUEST); return "<message><error>missing property param</error></message>"; } $objReflection = new class_reflection($objObject); $strSetter = $objReflection->getSetter($this->getParam("property")); if ($strSetter == null) { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_BADREQUEST); return "<message><error>setter not found</error></message>"; } call_user_func(array($objObject, $strSetter), $this->getParam("value")); $objObject->updateObjectToDb(); $this->flushCompletePagesCache(); $strReturn = "<message><success>object update succeeded</success></message>"; } } else { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_UNAUTHORIZED); $strReturn = "<message><error>" . $this->getLang("ds_gesperrt") . "." . $this->getLang("commons_error_permissions") . "</error></message>"; } return $strReturn; }
/** * Generates a captcha image to defend bots. * To generate a captcha image, use "kajonaCaptcha" as image-param * when calling image.php * Up to now, the size-params are ignored during the creation of a * captcha image * * @return void */ public function generateCaptchaImage() { if ($this->intMaxWidth == 0 || $this->intMaxWidth > 500) { $intWidth = 200; } else { $intWidth = $this->intMaxWidth; } if ($this->intMaxHeight == 0 || $this->intMaxHeight > 500) { $intHeight = 50; } else { $intHeight = $this->intMaxHeight; } $intMinfontSize = 15; $intMaxFontSize = 22; $intWidthPerChar = 30; $strCharsPossible = "abcdefghijklmnpqrstuvwxyz123456789"; $intHorizontalOffset = 10; $intVerticalOffset = 10; $intForegroundOffset = 2; $strCharactersPlaced = ""; //init the random-function srand((double) microtime() * 1000000); //v2 version $objImage2 = new class_image2(); $objImage2->create($intWidth, $intHeight); $objImage2->addOperation(new class_image_rectangle(0, 0, $intWidth, $intHeight, "#FFFFFF")); //draw vertical lines $intStart = 5; while ($intStart < $intWidth - 5) { $objImage2->addOperation(new class_image_line($intStart, 0, $intStart, $intWidth, $this->generateGreyLikeColor())); $intStart += rand(10, 17); } //draw horizontal lines $intStart = 5; while ($intStart < $intHeight - 5) { $objImage2->addOperation(new class_image_line(0, $intStart, $intWidth, $intStart, $this->generateGreyLikeColor())); $intStart += rand(10, 17); } //draw floating horizontal lines for ($intI = 0; $intI <= 3; $intI++) { $intXPrev = 0; $intYPrev = rand(0, $intHeight); while ($intXPrev <= $intWidth) { $intNewX = rand($intXPrev, $intXPrev + 50); $intNewY = rand(0, $intHeight); $objImage2->addOperation(new class_image_line($intXPrev, $intYPrev, $intNewX, $intNewY, $this->generateGreyLikeColor())); $intXPrev = $intNewX; $intYPrev = $intNewY; } } //calculate number of characters on the image $intNumberOfChars = floor($intWidth / $intWidthPerChar); //place characters in the image for ($intI = 0; $intI < $intNumberOfChars; $intI++) { //character to place $strCurrentChar = $strCharsPossible[rand(0, uniStrlen($strCharsPossible) - 1)]; $strCharactersPlaced .= $strCurrentChar; //color to use $intCol1 = rand(0, 200); $intCol2 = rand(0, 200); $intCol3 = rand(0, 200); //fontsize $intSize = rand($intMinfontSize, $intMaxFontSize); //calculate x and y pos $intX = $intHorizontalOffset + $intI * $intWidthPerChar; $intY = $intHeight - rand($intVerticalOffset, $intHeight - $intMaxFontSize); //the angle $intAngle = rand(-30, 30); //place the background character $objImage2->addOperation(new class_image_text($strCurrentChar, $intX, $intY, $intSize, "rgb(" . $intCol1 . "," . $intCol2 . "," . $intCol3 . ")", "dejavusans.ttf", $intAngle)); //place the foreground charater $objImage2->addOperation(new class_image_text($strCurrentChar, $intX + $intForegroundOffset, $intY + $intForegroundOffset, $intSize, "rgb(" . ($intCol1 + 50) . "," . ($intCol2 + 50) . "," . ($intCol3 + 50) . ")", "dejavusans.ttf", $intAngle)); } //register placed string to session class_carrier::getInstance()->getObjSession()->setCaptchaCode($strCharactersPlaced); //and send it to the browser //force no-cache headers class_response_object::getInstance()->addHeader("Expires: Thu, 19 Nov 1981 08:52:00 GMT", true); class_response_object::getInstance()->addHeader("Cache-Control: no-store, no-cache, must-revalidate, private", true); class_response_object::getInstance()->addHeader("Pragma: no-cache", true); $objImage2->setUseCache(false); $objImage2->sendToBrowser(class_image2::FORMAT_JPG); }
/** * Writes the current array of data to the given csv-file or directly to the browser. * Make sure to have set all needed values before, otherwise * an exception is thrown * * @return bool * * @param bool $bitStreamToBrowser * @param bool $bitExcludeHeaders skip the header-row in the output, generated based on the mapping * * @throws class_exception */ public function writeArrayToFile($bitStreamToBrowser = false, $bitExcludeHeaders = false) { //all needed values set before? if ($this->arrData != null && $this->arrMapping != null && $this->strFilename != null) { //create file-content. use a file-pointer to avoid max-mem-errors $objFilesystem = new class_filesystem(); //open file if ($bitStreamToBrowser) { class_response_object::getInstance()->addHeader('Pragma: private'); class_response_object::getInstance()->addHeader('Cache-control: private, must-revalidate'); class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_CSV); class_response_object::getInstance()->addHeader("Content-Disposition: attachment; filename=" . saveUrlEncode(trim(basename($this->strFilename)))); class_response_object::getInstance()->sendHeaders(); } else { $objFilesystem->openFilePointer($this->strFilename); } //the first row should contain the row-names if (!$bitExcludeHeaders) { $strRow = ""; foreach ($this->arrMapping as $strTagetCol) { //add enclosers? if ($this->strTextEncloser != null) { $strTagetCol = $this->strTextEncloser . $strTagetCol . $this->strTextEncloser; } $strRow .= $strTagetCol . $this->strDelimiter; } //remove last delimiter, eol $strRow = uniSubstr($strRow, 0, uniStrlen($this->strDelimiter) * -1); //add a linebreak $strRow .= "\n"; //write header to file if ($bitStreamToBrowser) { echo $strRow; } else { $objFilesystem->writeToFile($strRow); } } //iterate over the data array to write it to the file foreach ($this->arrData as $arrOneRow) { $strRow = ""; foreach ($this->arrMapping as $strSourceCol => $strTargetCol) { if (isset($arrOneRow[$strSourceCol])) { $strEntry = $arrOneRow[$strSourceCol]; //escape the delimiter maybe occuring in the text $strEntry = uniStrReplace($this->strDelimiter, "\\" . $this->strDelimiter, $strEntry); //add enclosers? if ($this->strTextEncloser != null) { $strEntry = $this->strTextEncloser . $strEntry . $this->strTextEncloser; } } else { $strEntry = ""; } $strRow .= $strEntry . $this->strDelimiter; } //remove last delimiter, eol $strRow = uniSubstr($strRow, 0, uniStrlen($this->strDelimiter) * -1); //add linebreak $strRow .= "\n"; //and write to file if ($bitStreamToBrowser) { echo $strRow; } else { $objFilesystem->writeToFile($strRow); } } //and close the filepointer... if (!$bitStreamToBrowser) { $objFilesystem->closeFilePointer(); } if ($bitStreamToBrowser) { flush(); die; } return true; } else { throw new class_exception("can't proceed, needed values missing", class_exception::$level_ERROR); } }
/** * Checks, if the browser sent the same checksum as provided. If so, * a http 304 is sent to the browser * * @param string $strChecksum * * @return bool */ function checkConditionalGetHeaders($strChecksum) { if (issetServer("HTTP_IF_NONE_MATCH")) { if (getServer("HTTP_IF_NONE_MATCH") == $strChecksum) { //strike. no further actions needed. class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_NOT_MODIFIED); class_response_object::getInstance()->addHeader("ETag: " . $strChecksum); class_response_object::getInstance()->addHeader("Cache-Control: max-age=86400, must-revalidate"); return true; } } return false; }
/** * Returns a list of users and/or groups matching the passed query. * * @return string * @xml */ protected function actionGetUserByFilter() { $strFilter = $this->getParam("filter"); $strCheckId = $this->getParam("checkid"); $arrCheckIds = json_decode($strCheckId); $arrUsers = array(); $objSource = new class_module_user_sourcefactory(); if ($this->getParam("user") == "true") { $arrUsers = $objSource->getUserlistByUserquery($strFilter); } if ($this->getParam("group") == "true") { $arrUsers = array_merge($arrUsers, $objSource->getGrouplistByQuery($strFilter)); } usort($arrUsers, function ($objA, $objB) { if ($objA instanceof class_module_user_user) { $strA = $objA->getStrUsername(); } else { $strA = $objA->getStrName(); } if ($objB instanceof class_module_user_user) { $strB = $objB->getStrUsername(); } else { $strB = $objB->getStrName(); } return strcmp(strtolower($strA), strtolower($strB)); }); $arrReturn = array(); foreach ($arrUsers as $objOneElement) { if ($this->getParam("block") == "current" && $objOneElement->getSystemid() == $this->objSession->getUserID()) { continue; } $bitUserHasRightView = true; if (!empty($arrCheckIds) && is_array($arrCheckIds) && $objOneElement instanceof class_module_user_user) { foreach ($arrCheckIds as $strCheckId) { if (!$this->hasUserViewPermissions($strCheckId, $objOneElement)) { $bitUserHasRightView = false; break; } } } if ($bitUserHasRightView) { $arrEntry = array(); if ($objOneElement instanceof class_module_user_user) { $arrEntry["title"] = $objOneElement->getStrUsername() . " (" . $objOneElement->getStrName() . ", " . $objOneElement->getStrForename() . " )"; $arrEntry["label"] = $objOneElement->getStrUsername() . " (" . $objOneElement->getStrName() . ", " . $objOneElement->getStrForename() . " )"; $arrEntry["value"] = $objOneElement->getStrUsername() . " (" . $objOneElement->getStrName() . ", " . $objOneElement->getStrForename() . " )"; $arrEntry["systemid"] = $objOneElement->getSystemid(); $arrEntry["icon"] = class_adminskin_helper::getAdminImage("icon_user"); } else { if ($objOneElement instanceof class_module_user_group) { $arrEntry["title"] = $objOneElement->getStrName(); $arrEntry["value"] = $objOneElement->getStrName(); $arrEntry["label"] = $objOneElement->getStrName(); $arrEntry["systemid"] = $objOneElement->getSystemid(); $arrEntry["icon"] = class_adminskin_helper::getAdminImage("icon_group"); } } $arrReturn[] = $arrEntry; } } class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON); return json_encode($arrReturn); }
/** * Fetches all child-nodes of the passed node. * Used by the tree-view in module-navigation admin view. * * @return string * @since 3.3.0 * @xml * @permissions view */ protected function actionGetChildNodes() { $arrNavigations = class_module_navigation_point::getNaviLayer($this->getSystemid()); $arrReturn = array(); if (count($arrNavigations) > 0) { /** @var class_module_navigation_point $objSinglePoint */ foreach ($arrNavigations as $objSinglePoint) { if ($objSinglePoint->rightView()) { $arrReturn[] = array("data" => array("title" => class_adminskin_helper::getAdminImage($objSinglePoint->getStrIcon()) . " " . $objSinglePoint->getStrDisplayName()), "state" => count(class_module_navigation_point::getNaviLayer($objSinglePoint->getSystemid())) == 0 ? "" : "closed", "attr" => array("id" => $objSinglePoint->getSystemid(), "systemid" => $objSinglePoint->getSystemid(), "link" => class_link::getLinkAdminHref("navigation", "list", "&systemid=" . $objSinglePoint->getSystemid(), false))); } } } $objCurNode = class_objectfactory::getInstance()->getObject($this->getSystemid()); if ($objCurNode instanceof class_module_navigation_tree) { $arrReturn = array("data" => array("title" => class_adminskin_helper::getAdminImage($objCurNode->getStrIcon()) . " " . $objCurNode->getStrDisplayName()), "state" => "", "attr" => array("id" => $objCurNode->getSystemid(), "systemid" => $objCurNode->getSystemid(), "link" => ""), "children" => $arrReturn); } class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON); return json_encode($arrReturn); }
/** * Create the image and send it directly to the browser. * * Calling this method will actually start the image processing, * if no cached image is available. * * @param null $strFormat * @return bool */ public function sendToBrowser($strFormat = null) { if ($strFormat == null && $this->strOriginalPath != null) { $strFormat = self::getFormatFromFilename($this->strOriginalPath); } $strResponseType = null; switch ($strFormat) { case self::FORMAT_PNG: $strResponseType = class_http_responsetypes::STR_TYPE_JPEG; break; case self::FORMAT_JPG: $strResponseType = class_http_responsetypes::STR_TYPE_PNG; break; case self::FORMAT_GIF: $strResponseType = class_http_responsetypes::STR_TYPE_GIF; break; default: return false; } class_response_object::getInstance()->setStrResponseType($strResponseType); class_response_object::getInstance()->sendHeaders(); if (!$this->isCached($strFormat)) { if ($this->processImage($strFormat)) { return $this->outputImage($strFormat); } else { return false; } } else { $strCacheFile = $this->getCachePath($strFormat); $ptrFile = fopen(_realpath_ . $strCacheFile, 'rb'); fpassthru($ptrFile); return fclose($ptrFile); } }