/**
  * Contructor
  *
  * @param $objElementData
  */
 public function __construct($objElementData)
 {
     parent::__construct($objElementData);
     if ($this->getParam("action") == "saveGuestbook") {
         $this->setStrCacheAddon(generateSystemid());
     }
 }
 /**
  * Redefined in order to register cache busters
  *
  * @param class_module_pages_pageelement $objElementData
  */
 public function __construct($objElementData)
 {
     parent::__construct($objElementData);
     //we support ratings, so add cache-busters
     if (class_module_system_module::getModuleByName("rating") !== null) {
         $this->setStrCacheAddon(getCookie(class_module_rating_rate::RATING_COOKIE));
     }
 }
 /**
  * Adds the code to load the portaleditor
  *
  * @param string $strReturn
  *
  * @return string
  */
 private function addPortaleditorCode($strReturn)
 {
     $objNavigation = new class_module_navigation_tree($this->arrElementData["navigation_id"]);
     //Add pe code
     $arrPeConfig = array("pe_module" => "navigation", "pe_action_edit" => "list", "pe_action_edit_params" => "&systemid=" . $this->arrElementData["navigation_id"], "pe_action_new" => "", "pe_action_new_params" => "", "pe_action_delete" => "", "pe_action_delete_params" => "");
     $arrPeConfigAutoNavigation = array("pe_module" => "pages", "pe_action_edit" => "list", "pe_action_edit_params" => "&systemid=" . $objNavigation->getStrFolderId(), "pe_action_new" => "", "pe_action_new_params" => "", "pe_action_delete" => "", "pe_action_delete_params" => "");
     //only add the code, if not auto-generated
     if (!validateSystemid($objNavigation->getStrFolderId())) {
         $strReturn = class_element_portal::addPortalEditorCode($strReturn, $this->arrElementData["navigation_id"], $arrPeConfig);
     } else {
         $strReturn = class_element_portal::addPortalEditorCode($strReturn, $this->arrElementData["navigation_id"], $arrPeConfigAutoNavigation);
     }
     return $strReturn;
 }
 /**
  * Returns a list of comments.
  *
  * @return string
  * @permissions view
  */
 protected function actionList()
 {
     $strReturn = "";
     $strPosts = "";
     $strForm = "";
     $strNewButton = "";
     //pageid or systemid to filter?
     $strSystemidfilter = "";
     $strPagefilter = $this->strPagefilter;
     if ($this->getSystemid() != "") {
         $strSystemidfilter = $this->getSystemid();
     }
     if ($strPagefilter === null && class_module_pages_page::getPageByName($this->getPagename()) !== null) {
         $strPagefilter = class_module_pages_page::getPageByName($this->getPagename())->getSystemid();
     }
     $intNrOfPosts = isset($this->arrElementData["int1"]) ? $this->arrElementData["int1"] : 0;
     //Load all posts
     $objArraySectionIterator = new class_array_section_iterator(class_module_postacomment_post::getNumberOfPostsAvailable(true, $strPagefilter, $strSystemidfilter, $this->getStrPortalLanguage()));
     $objArraySectionIterator->setIntElementsPerPage($intNrOfPosts);
     $objArraySectionIterator->setPageNumber((int) ($this->getParam("pvPAC") != "" ? $this->getParam("pvPAC") : 1));
     $objArraySectionIterator->setArraySection(class_module_postacomment_post::loadPostList(true, $strPagefilter, $strSystemidfilter, $this->getStrPortalLanguage(), $objArraySectionIterator->calculateStartPos(), $objArraySectionIterator->calculateEndPos()));
     //params to add?
     $strAdd = "";
     if ($this->getParam("action") != "") {
         $strAdd .= "&action=" . $this->getParam("action");
     }
     if ($this->getParam("systemid") != "") {
         $strAdd .= "&systemid=" . $this->getParam("systemid");
     }
     if ($this->getParam("pv") != "") {
         $strAdd .= "&pv=" . $this->getParam("pv");
     }
     $arrComments = $this->objToolkit->simplePager($objArraySectionIterator, $this->getLang("commons_next"), $this->getLang("commons_back"), "", $this->getPagename(), $strAdd, "pvPAC");
     $strTemplateID = $this->objTemplate->readTemplate("/module_postacomment/" . $this->arrElementData["char1"], "postacomment_post");
     if (!$objArraySectionIterator->valid()) {
         $strPosts .= $this->getLang("postacomment_empty");
     }
     //Check rights
     /** @var class_module_postacomment_post $objOnePost */
     foreach ($objArraySectionIterator as $objOnePost) {
         if ($objOnePost->rightView()) {
             $strOnePost = "";
             $arrOnePost = array();
             $arrOnePost["postacomment_post_name"] = $objOnePost->getStrUsername();
             $arrOnePost["postacomment_post_subject"] = $objOnePost->getStrTitle();
             $arrOnePost["postacomment_post_message"] = $objOnePost->getStrComment();
             $arrOnePost["postacomment_post_systemid"] = $objOnePost->getSystemid();
             $arrOnePost["postacomment_post_date"] = timeToString($objOnePost->getIntDate(), true);
             //ratings available?
             if ($objOnePost->getFloatRating() !== null) {
                 /** @var $objRating class_module_rating_portal */
                 $objRating = class_module_system_module::getModuleByName("rating")->getPortalInstanceOfConcreteModule();
                 $arrOnePost["postacomment_post_rating"] = $objRating->buildRatingBar($objOnePost->getFloatRating(), $objOnePost->getIntRatingHits(), $objOnePost->getSystemid(), $objOnePost->isRateableByUser(), $objOnePost->rightRight2());
             }
             $strOnePost .= $this->objTemplate->fillTemplate($arrOnePost, $strTemplateID, false);
             //Add pe code
             $arrPeConfig = array("pe_module" => "postacomment", "pe_action_edit" => "edit", "pe_action_edit_params" => "&systemid=" . $objOnePost->getSystemid(), "pe_action_new" => "", "pe_action_new_params" => "", "pe_action_delete" => "delete", "pe_action_delete_params" => "&systemid=" . $objOnePost->getSystemid());
             $strPosts .= class_element_portal::addPortalEditorCode($strOnePost, $objOnePost->getSystemid(), $arrPeConfig);
         }
     }
     //Create form
     if ($this->getObjModule()->rightRight1()) {
         $strTemplateID = $this->objTemplate->readTemplate("/module_postacomment/" . $this->arrElementData["char1"], "postacomment_form");
         $arrForm = array();
         if ($this->getParam("comment_name") == "" && $this->objSession->isLoggedin()) {
             $this->setParam("comment_name", $this->objSession->getUsername());
         }
         $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->arrElementData["char1"];
         $arrForm["comment_systemid"] = $this->getSystemid();
         $arrForm["comment_page"] = $this->getPagename();
         $arrForm["validation_errors"] = $this->strErrors;
         foreach ($arrForm as $strKey => $strValue) {
             if (uniStrpos($strKey, "comment_") !== false) {
                 $arrForm[$strKey] = htmlspecialchars($strValue, ENT_QUOTES, "UTF-8", false);
             }
         }
         $strForm .= $this->objTemplate->fillTemplate($arrForm, $strTemplateID, false);
         //button to show the form
         $strTemplateNewButtonID = $this->objTemplate->readTemplate("/module_postacomment/" . $this->arrElementData["char1"], "postacomment_new_button");
         $strNewButton = $this->objTemplate->fillTemplate(array("comment_systemid" => $this->getSystemid()), $strTemplateNewButtonID, false);
     }
     //add sourrounding list template
     $strTemplateID = $this->objTemplate->readTemplate("/module_postacomment/" . $this->arrElementData["char1"], "postacomment_list");
     //link to the post-form & pageview links
     $arrTemplate = array();
     $arrTemplate["postacomment_forward"] = $arrComments["strForward"];
     $arrTemplate["postacomment_pages"] = $arrComments["strPages"];
     $arrTemplate["postacomment_back"] = $arrComments["strBack"];
     $arrTemplate["postacomment_form"] = $strForm;
     $arrTemplate["postacomment_new_button"] = $strNewButton;
     $arrTemplate["postacomment_systemid"] = $this->getSystemid();
     $arrTemplate["postacomment_list"] = $strPosts;
     $strReturn .= $this->fillTemplate($arrTemplate, $strTemplateID);
     return $strReturn;
 }
 /**
  * Prints a file as a detailed-view
  * and generates forward / backward links + a strip of prev / next files
  *
  * @param bool $bitRegisterAdditionalTitle
  * @return string
  */
 protected function actionFileDetails($bitRegisterAdditionalTitle = true)
 {
     if (!$this->checkIfRequestedIdIsInElementsTree()) {
         return $this->actionList();
     }
     $bitIsImage = false;
     //Load record
     $objFile = new class_module_mediamanager_file($this->getSystemid());
     //common fields
     $arrDetailsTemplate = array();
     $arrDetailsTemplate["file_name"] = $objFile->getStrName();
     $arrDetailsTemplate["file_description"] = $objFile->getStrDescription();
     $arrDetailsTemplate["file_subtitle"] = $objFile->getStrSubtitle();
     $arrDetailsTemplate["file_filename"] = $objFile->getStrFilename();
     $arrDetailsTemplate["file_size"] = bytesToString($objFile->getIntFileSize());
     $arrDetailsTemplate["file_hits"] = $objFile->getIntHits();
     $arrDetailsTemplate["file_systemid"] = $objFile->getSystemid();
     $arrDetailsTemplate["file_elementid"] = $this->arrElementData["content_id"];
     $arrDetailsTemplate["file_lmtime"] = timeToString(filemtime(_realpath_ . $objFile->getStrFilename()));
     if (validateSystemid($objFile->getOwnerId())) {
         $objUser = new class_module_user_user($objFile->getOwnerId());
         $arrDetailsTemplate["file_owner"] = $objUser->getStrUsername();
     }
     if ($objFile->rightRight2()) {
         $arrDetailsTemplate["file_link_href"] = _webpath_ . "/download.php?systemid=" . $objFile->getSystemid();
         $arrDetailsTemplate["file_link"] = "<a href=\"" . _webpath_ . "/download.php?systemid=" . $objFile->getSystemid() . "\">" . $this->getLang("download_link") . "</a>";
     }
     //if its an image, provide additional information
     $strSuffix = uniStrtolower(uniSubstr($objFile->getStrFilename(), uniStrrpos($objFile->getStrFilename(), ".")));
     if (in_array($strSuffix, $this->arrImageTypes) && isset($this->arrElementData["gallery_maxh_d"]) && isset($this->arrElementData["gallery_maxw_d"])) {
         $bitIsImage = true;
         $arrDetailsTemplate["image_src"] = $this->getImageUrl($objFile->getStrFilename(), $this->arrElementData["gallery_maxh_d"], $this->arrElementData["gallery_maxw_d"], $this->arrElementData["gallery_text"], $this->arrElementData["gallery_overlay"], $objFile->getSystemid(), $this->arrElementData["content_id"]);
     }
     $arrStripIds = $this->getNextPrevIds();
     $arrDetailsTemplate["backlink"] = $arrStripIds["backward_1"] != "" ? class_link::getLinkPortal($this->getPagename(), "", "", $this->getLang("commons_back"), "fileDetails", "", $arrStripIds["backward_1"]) : "";
     $arrDetailsTemplate["forwardlink"] = $arrStripIds["forward_1"] != "" ? class_link::getLinkPortal($this->getPagename(), "", "", $this->getLang("commons_next"), "fileDetails", "", $arrStripIds["forward_1"]) : "";
     //next /prev 3 files
     for ($intI = 1; $intI <= 3; $intI++) {
         if ($arrStripIds["forward_" . $intI] != "") {
             $objCurFile = new class_module_mediamanager_file($arrStripIds["forward_" . $intI]);
             $arrDetailsTemplate["forwardlink_" . $intI] = $this->renderFileStripEntry($objCurFile);
         }
         if ($arrStripIds["backward_" . $intI] != "") {
             $objCurFile = new class_module_mediamanager_file($arrStripIds["backward_" . $intI]);
             $arrDetailsTemplate["backlink_" . $intI] = $this->renderFileStripEntry($objCurFile);
         }
     }
     //current file
     $arrDetailsTemplate["filestrip_current"] = $this->renderFileStripEntry($objFile);
     $arrDetailsTemplate["overview"] = getLinkPortal($this->getPagename(), "", "", $this->getLang("overview"), "mediaFolder", "", $objFile->getPrevId());
     $arrDetailsTemplate["pathnavigation"] = $this->generatePathnavi(true);
     //ratings available?
     if ($objFile->getFloatRating() !== null) {
         /** @var $objRating class_module_rating_portal */
         $objRating = class_module_system_module::getModuleByName("rating")->getPortalInstanceOfConcreteModule();
         $arrDetailsTemplate["file_rating"] = $objRating->buildRatingBar($objFile->getFloatRating(), $objFile->getIntRatingHits(), $objFile->getSystemid(), $objFile->isRateableByUser(), $objFile->rightRight3());
     }
     $strTemplateID = $this->objTemplate->readTemplate("/module_mediamanager/" . $this->arrElementData["repo_template"], "filedetail");
     $strReturn = $this->fillTemplate($arrDetailsTemplate, $strTemplateID);
     //Add pe code
     $arrPeConfig = array("pe_module" => "mediamanager", "pe_action_edit" => "editFile", "pe_action_edit_params" => "&systemid=" . $objFile->getSystemid());
     $strReturn = class_element_portal::addPortalEditorCode($strReturn, $objFile->getSystemid(), $arrPeConfig);
     //set the name of the current image to the page title via class_pages
     if ($bitRegisterAdditionalTitle) {
         class_module_pages_portal::registerAdditionalTitle($objFile->getStrName());
     }
     //Update view counter
     if ($bitIsImage) {
         $objFile->increaseHits();
     }
     return $this->addPortaleditorCode($strReturn);
 }
 /**
  * Creates the detailed-view of news
  *
  * @return string
  */
 protected function actionNewsDetail()
 {
     $strReturn = "";
     /** @var $objNews class_module_news_news */
     $objNews = class_objectfactory::getInstance()->getObject($this->getSystemid());
     if ($objNews != null && $objNews instanceof class_module_news_news && $objNews->rightView() && $objNews->getIntRecordStatus() == "1") {
         //see if we should generate a redirect instead
         if ($objNews->getIntRedirectEnabled() == "1" && $objNews->getStrRedirectPage() != "") {
             $this->portalReload(class_link::getLinkPortalHref($objNews->getStrRedirectPage()));
             return "<script type='text/javascript'>window.location.replace('" . class_link::getLinkPortalHref($objNews->getStrRedirectPage()) . "');</script>";
         }
         //Load record
         $objMapper = new class_template_mapper($objNews);
         $objMapper->addPlaceholder("news_back_link", "<a href=\"javascript:history.back();\">" . $this->getLang("news_zurueck") . "</a>");
         $objMapper->addPlaceholder("news_start_date", dateToString($objNews->getObjStartDate(), false));
         $objMapper->addPlaceholder("news_id", $objNews->getSystemid());
         $objMapper->addPlaceholder("news_title", $objNews->getStrTitle());
         $objMapper->addPlaceholder("news_intro", $objNews->getStrIntro());
         $objMapper->addPlaceholder("news_text", $objNews->getStrText());
         //postacomment
         $arrPAC = $this->loadPostacomments($objNews->getSystemid(), $objNews->getStrImage() != "" ? "news_detail_image" : "news_detail");
         if ($arrPAC != null) {
             $objMapper->addPlaceholder("news_nrofcomments", $arrPAC["nrOfComments"]);
             $objMapper->addPlaceholder("news_commentlist", $arrPAC["commentList"]);
         }
         //ratings
         if ($objNews->getFloatRating() !== null) {
             /** @var $objRating class_module_rating_portal */
             $objRating = class_module_system_module::getModuleByName("rating")->getPortalInstanceOfConcreteModule();
             $objMapper->addPlaceholder("news_rating", $objRating->buildRatingBar($objNews->getFloatRating(), $objNews->getIntRatingHits(), $objNews->getSystemid(), $objNews->isRateableByUser(), $objNews->rightRight3()));
         }
         //categories
         $objMapper->addPlaceholder("news_categories", $this->renderCategoryTitles($objNews));
         //load template section with or without image?
         if ($objNews->getStrImage() != "") {
             $objMapper->addPlaceholder("news_image", urlencode($objNews->getStrImage()));
             $strReturn .= $objMapper->writeToTemplate("/module_news/" . $this->arrElementData["news_template"], "news_detail_image");
         } else {
             $strReturn .= $objMapper->writeToTemplate("/module_news/" . $this->arrElementData["news_template"], "news_detail");
         }
         //Add pe code
         $arrPeConfig = array("pe_module" => "news", "pe_action_edit" => "editNews", "pe_action_edit_params" => "&systemid=" . $this->getSystemid());
         $strReturn = class_element_portal::addPortalEditorCode($strReturn, $objNews->getSystemid(), $arrPeConfig);
         //and count the hit
         $objNews->increaseHits();
         //set the name of the current news to the page-title via class_pages
         class_module_pages_portal::registerAdditionalTitle($objNews->getStrTitle());
     } else {
         $strReturn = $this->getLang("commons_error_permissions");
     }
     return $strReturn;
 }
 /**
  * Handles the loading of a page, more in a functional than in an oop style
  *
  * @throws class_exception
  * @return string the generated page
  * @permissions view
  */
 protected function actionGeneratePage()
 {
     //Determine the pagename
     $objPageData = $this->getPageData();
     //react on portaleditor commands
     //pe to display, or pe to disable?
     if ($this->getParam("pe") == "false") {
         $this->objSession->setSession("pe_disable", "true");
     }
     if ($this->getParam("pe") == "true") {
         $this->objSession->setSession("pe_disable", "false");
     }
     //if using the pe, the cache shouldn't be used, otherwise strange things might happen.
     //the system could frighten your cat or eat up all your cheese with marshmallows...
     //get the current state of the portal editor
     $bitPeRequested = false;
     if (class_module_system_setting::getConfigValue("_pages_portaleditor_") == "true" && $this->objSession->getSession("pe_disable") != "true" && $this->objSession->isAdmin() && $objPageData->rightEdit()) {
         $bitPeRequested = true;
     }
     //If we reached up till here, we can begin loading the elements to fill
     if ($bitPeRequested) {
         $arrElementsOnPage = class_module_pages_pageelement::getElementsOnPage($objPageData->getSystemid(), false, $this->getStrPortalLanguage());
     } else {
         $arrElementsOnPage = class_module_pages_pageelement::getElementsOnPage($objPageData->getSystemid(), true, $this->getStrPortalLanguage());
     }
     //If there's a master-page, load elements on that, too
     $objMasterData = class_module_pages_page::getPageByName("master");
     $bitEditPermissionOnMasterPage = false;
     if ($objMasterData != null) {
         if ($bitPeRequested) {
             $arrElementsOnMaster = class_module_pages_pageelement::getElementsOnPage($objMasterData->getSystemid(), false, $this->getStrPortalLanguage());
         } else {
             $arrElementsOnMaster = class_module_pages_pageelement::getElementsOnPage($objMasterData->getSystemid(), true, $this->getStrPortalLanguage());
         }
         //and merge them
         $arrElementsOnPage = array_merge($arrElementsOnPage, $arrElementsOnMaster);
         if ($objMasterData->rightEdit()) {
             $bitEditPermissionOnMasterPage = true;
         }
     }
     //Load the template from the filesystem to get the placeholders
     $strTemplateID = $this->objTemplate->readTemplate("/module_pages/" . $objPageData->getStrTemplate(), "", false, true);
     //bit include the masters-elements!!
     $arrRawPlaceholders = array_merge($this->objTemplate->getElements($strTemplateID, 0), $this->objTemplate->getElements($strTemplateID, 1));
     $arrPlaceholders = array();
     //and retransform
     foreach ($arrRawPlaceholders as $arrOneRawPlaceholder) {
         $arrPlaceholders[] = $arrOneRawPlaceholder["placeholder"];
     }
     //Initialize the caches internal cache :)
     class_cache::fillInternalCache("class_element_portal", $this->getPagename(), null, $this->getStrPortalLanguage());
     //try to load the additional title from cache
     $strAdditionalTitleFromCache = "";
     $intMaxCacheDuration = 0;
     $objCachedTitle = class_cache::getCachedEntry(__CLASS__, $this->getPagename(), $this->generateHash2Sum(), $this->getStrPortalLanguage());
     if ($objCachedTitle != null) {
         $strAdditionalTitleFromCache = $objCachedTitle->getStrContent();
         self::$strAdditionalTitle = $strAdditionalTitleFromCache;
     }
     //copy for the portaleditor
     $arrPlaceholdersFilled = array();
     //Iterate over all elements and pass control to them
     //Get back the filled element
     //Build the array to fill the template
     $arrTemplate = array();
     /** @var class_module_pages_pageelement $objOneElementOnPage */
     foreach ($arrElementsOnPage as $objOneElementOnPage) {
         //element really available on the template?
         if (!in_array($objOneElementOnPage->getStrPlaceholder(), $arrPlaceholders)) {
             //next one, plz
             continue;
         } else {
             //create a protocol of placeholders filled
             //remove from pe-additional-array, pe code is injected by element directly
             $arrPlaceholdersFilled[] = array("placeholder" => $objOneElementOnPage->getStrPlaceholder(), "name" => $objOneElementOnPage->getStrName(), "element" => $objOneElementOnPage->getStrElement(), "repeatable" => $objOneElementOnPage->getIntRepeat());
         }
         //Build the class-name for the object
         /** @var  class_element_portal $objElement  */
         $objElement = $objOneElementOnPage->getConcretePortalInstance();
         //let the element do the work and earn the output
         if (!isset($arrTemplate[$objOneElementOnPage->getStrPlaceholder()])) {
             $arrTemplate[$objOneElementOnPage->getStrPlaceholder()] = "";
         }
         //cache-handling. load element from cache.
         //if the element is re-generated, save it back to cache.
         if (class_module_system_setting::getConfigValue("_pages_cacheenabled_") == "true" && $this->getParam("preview") != "1" && $objPageData->getStrName() != class_module_system_setting::getConfigValue("_pages_errorpage_")) {
             $strElementOutput = "";
             //if the portaleditor is disabled, do the regular cache lookups in storage. otherwise regenerate again and again :)
             if ($bitPeRequested) {
                 $strElementOutput = $objElement->getElementOutput();
             } else {
                 //pe not to be taken into account --> full support of caching
                 $strElementOutput = $objElement->getElementOutputFromCache();
                 if ($objOneElementOnPage->getIntCachetime() > $intMaxCacheDuration) {
                     $intMaxCacheDuration = $objOneElementOnPage->getIntCachetime();
                 }
                 if ($strElementOutput === false) {
                     $strElementOutput = $objElement->getElementOutput();
                     $objElement->saveElementToCache($strElementOutput);
                 }
             }
         } else {
             $strElementOutput = $objElement->getElementOutput();
         }
         //if element is disabled & the pe is requested, wrap the content
         if ($bitPeRequested && $objOneElementOnPage->getIntRecordStatus() == 0) {
             $arrPeElement = array();
             $arrPeElement["title"] = $this->getLang("pe_inactiveElement", "pages") . " (" . $objOneElementOnPage->getStrElement() . ")";
             $strElementOutput = $this->objToolkit->getPeInactiveElement($arrPeElement);
             $strElementOutput = class_element_portal::addPortalEditorSetActiveCode($strElementOutput, $objElement->getSystemid(), array());
         }
         $arrTemplate[$objOneElementOnPage->getStrPlaceholder()] .= $strElementOutput;
     }
     //pe-code to add new elements on unfilled placeholders --> only if pe is visible?
     if ($bitPeRequested) {
         //loop placeholders on template in order to remove already filled ones not being repeatable
         $arrRawPlaceholdersForPe = $arrRawPlaceholders;
         foreach ($arrPlaceholdersFilled as $arrOnePlaceholder) {
             foreach ($arrRawPlaceholdersForPe as &$arrOneRawPlaceholder) {
                 if ($arrOneRawPlaceholder["placeholder"] == $arrOnePlaceholder["placeholder"]) {
                     foreach ($arrOneRawPlaceholder["elementlist"] as $intElementKey => $arrOneRawElement) {
                         if ($arrOnePlaceholder["element"] == $arrOneRawElement["element"]) {
                             if (uniSubstr($arrOneRawElement["name"], 0, 5) == "master") {
                                 $arrOneRawPlaceholder["elementlist"][$intElementKey] = null;
                             } else {
                                 if ($arrOnePlaceholder["repeatable"] == "0") {
                                     $arrOneRawPlaceholder["elementlist"][$intElementKey] = null;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         //array is now set up. loop again to create new-buttons
         $arrPePlaceholdersDone = array();
         $arrPeNewButtons = array();
         foreach ($arrRawPlaceholdersForPe as $arrOneRawPlaceholderForPe) {
             $strPeNewPlaceholder = $arrOneRawPlaceholderForPe["placeholder"];
             foreach ($arrOneRawPlaceholderForPe["elementlist"] as $arrOnePeNewElement) {
                 if ($arrOnePeNewElement == null) {
                     continue;
                 }
                 //check if the linked element exists
                 $objPeNewElement = class_module_pages_element::getElement($arrOnePeNewElement["element"]);
                 if ($objPeNewElement == null) {
                     continue;
                 }
                 //placeholder processed before?
                 $strArrayKey = $strPeNewPlaceholder . $objPeNewElement->getStrName();
                 if (in_array($strArrayKey, $arrPePlaceholdersDone)) {
                     continue;
                 } else {
                     $arrPePlaceholdersDone[] = $strArrayKey;
                 }
                 //create and register the button to add a new element
                 if (!isset($arrPeNewButtons[$strPeNewPlaceholder])) {
                     $arrPeNewButtons[$strPeNewPlaceholder] = "";
                 }
                 if (uniStripos($strArrayKey, "master") !== false) {
                     $strLink = "";
                     if ($objMasterData !== null) {
                         $strLink = class_element_portal::getPortaleditorNewCode($objMasterData->getSystemid(), $strPeNewPlaceholder, $objPeNewElement);
                     }
                 } else {
                     $strLink = class_element_portal::getPortaleditorNewCode($objPageData->getSystemid(), $strPeNewPlaceholder, $objPeNewElement);
                 }
                 $arrPeNewButtons[$strPeNewPlaceholder] .= $strLink;
             }
         }
         //loop pe-new code in order to add the wrappers and assign the code to the matching placeholder
         foreach ($arrPeNewButtons as $strPlaceholderName => $strNewButtons) {
             if (!isset($arrTemplate[$strPlaceholderName])) {
                 $arrTemplate[$strPlaceholderName] = "";
             }
             if ($strNewButtons != "") {
                 $strNewButtons = class_element_portal::getPortaleditorNewWrapperCode($strPlaceholderName, $strNewButtons);
             }
             $arrTemplate[$strPlaceholderName] .= $strNewButtons;
         }
         // add placeholder wrapping
         foreach ($arrTemplate as $strPlaceholder => $strContent) {
             $arrTemplate[$strPlaceholder] = class_carrier::getInstance()->getObjToolkit("portal")->getPePlaceholderWrapper($strPlaceholder, $strContent);
         }
     }
     //check if the additional title has to be saved to the cache
     if (self::$strAdditionalTitle != "" && self::$strAdditionalTitle != $strAdditionalTitleFromCache) {
         $objCacheEntry = class_cache::getCachedEntry(__CLASS__, $this->getPagename(), $this->generateHash2Sum(), $this->getStrPortalLanguage(), true);
         $objCacheEntry->setStrContent(self::$strAdditionalTitle);
         $objCacheEntry->setIntLeasetime(time() + $intMaxCacheDuration);
         $objCacheEntry->updateObjectToDb();
     }
     $arrTemplate["description"] = $objPageData->getStrDesc();
     $arrTemplate["keywords"] = $objPageData->getStrKeywords();
     $arrTemplate["title"] = $objPageData->getStrBrowsername();
     $arrTemplate["additionalTitle"] = self::$strAdditionalTitle;
     $arrTemplate["canonicalUrl"] = class_link::getLinkPortalHref($objPageData->getStrName(), "", $this->getParam("action"), "", $this->getParam("systemid"));
     //Include the $arrGlobal Elements
     $arrGlobal = array();
     $strPath = class_resourceloader::getInstance()->getPathForFile("/portal/global_includes.php");
     if ($strPath !== false) {
         include _realpath_ . $strPath;
     }
     $arrTemplate = array_merge($arrTemplate, $arrGlobal);
     //fill the template. the template was read before
     $strPageContent = $this->fillTemplate($arrTemplate, $strTemplateID);
     $strPageContent = $this->renderPortalEditorCode($objPageData, $bitEditPermissionOnMasterPage, $strPageContent);
     //insert the copyright headers. Due to our licence, you are NOT allowed to remove those lines.
     $strHeader = "<!--\n";
     $strHeader .= "Website powered by Kajona Open Source Content Management Framework\n";
     $strHeader .= "For more information about Kajona see http://www.kajona.de\n";
     $strHeader .= "-->\n";
     $intBodyPos = uniStripos($strPageContent, "</head>");
     $intPosXml = uniStripos($strPageContent, "<?xml");
     if ($intBodyPos !== false) {
         $intBodyPos += 0;
         $strPageContent = uniSubstr($strPageContent, 0, $intBodyPos) . $strHeader . uniSubstr($strPageContent, $intBodyPos);
     } else {
         if ($intPosXml !== false) {
             $intBodyPos = uniStripos($strPageContent, "?>");
             $intBodyPos += 2;
             $strPageContent = uniSubstr($strPageContent, 0, $intBodyPos) . $strHeader . uniSubstr($strPageContent, $intBodyPos);
         } else {
             $strPageContent = $strHeader . $strPageContent;
         }
     }
     return $strPageContent;
 }
 /**
  * Returns a list of faqs.
  * The category is choosen from the element-data
  *
  * @return string
  */
 protected function actionList()
 {
     $strReturn = "";
     //load categories
     $arrCategories = array();
     if ($this->arrElementData["faqs_category"] == "0") {
         $arrCategories = class_module_faqs_category::getObjectList();
     } else {
         $arrCategories[] = new class_module_faqs_category($this->arrElementData["faqs_category"]);
     }
     //if no cat was created by now, use a dummy cat
     if (count($arrCategories) == 0) {
         $arrCategories[] = 1;
     }
     //load every category
     $strCats = "";
     foreach ($arrCategories as $objCategory) {
         //Load faqs
         if (!is_object($objCategory) && $objCategory == 1) {
             $arrFaqs = class_module_faqs_faq::loadListFaqsPortal(1);
             $objCategory = new class_module_faqs_category();
         } else {
             if ($objCategory->getIntRecordStatus() == 0) {
                 continue;
             }
             $arrFaqs = class_module_faqs_faq::loadListFaqsPortal($objCategory->getSystemid());
         }
         $strFaqs = "";
         //Check rights
         foreach ($arrFaqs as $objOneFaq) {
             if ($objOneFaq->rightView()) {
                 $objMapper = new class_template_mapper($objOneFaq);
                 //legacy support
                 $objMapper->addPlaceholder("faq_question", $objOneFaq->getStrQuestion());
                 $objMapper->addPlaceholder("faq_answer", $objOneFaq->getStrAnswer());
                 $objMapper->addPlaceholder("faq_systemid", $objOneFaq->getSystemid());
                 //ratings available?
                 if ($objOneFaq->getFloatRating() !== null && class_module_system_module::getModuleByName("rating") != null) {
                     /** @var $objRating class_module_rating_portal */
                     $objRating = class_module_system_module::getModuleByName("rating")->getPortalInstanceOfConcreteModule();
                     $objMapper->addPlaceholder("faq_rating", $objRating->buildRatingBar($objOneFaq->getFloatRating(), $objOneFaq->getIntRatingHits(), $objOneFaq->getSystemid(), $objOneFaq->isRateableByUser(), $objOneFaq->rightRight1()));
                 }
                 $strOneFaq = $objMapper->writeToTemplate("/module_faqs/" . $this->arrElementData["faqs_template"], "faq_faq", false);
                 //Add pe code
                 $arrPeConfig = array("pe_module" => "faqs", "pe_action_edit" => "editFaq", "pe_action_edit_params" => "&systemid=" . $objOneFaq->getSystemid(), "pe_action_new" => "newFaq", "pe_action_new_params" => "", "pe_action_delete" => "deleteFaq", "pe_action_delete_params" => "&systemid=" . $objOneFaq->getSystemid());
                 $strFaqs .= class_element_portal::addPortalEditorCode($strOneFaq, $objOneFaq->getSystemid(), $arrPeConfig);
             }
         }
         //wrap category around
         $objMapper = new class_template_mapper($objCategory);
         //legacy support
         $objMapper->addPlaceholder("faq_cat_title", $objCategory->getStrTitle());
         $objMapper->addPlaceholder("faq_faqs", $strFaqs);
         $objMapper->addPlaceholder("faq_cat_systemid", $objCategory->getSystemid());
         $strCats .= $objMapper->writeToTemplate("/module_faqs/" . $this->arrElementData["faqs_template"], "faq_category");
     }
     //wrap list container around
     //wrap category around
     $strListTemplateID = $this->objTemplate->readTemplate("/module_faqs/" . $this->arrElementData["faqs_template"], "faqs_list");
     $arrTemplate = array();
     $arrTemplate["faq_categories"] = $strCats;
     $strReturn .= $this->objTemplate->fillTemplate($arrTemplate, $strListTemplateID);
     return $strReturn;
 }
 /**
  * @param class_module_pages_pageelement|mixed $objElementData
  */
 public function __construct($objElementData)
 {
     parent::__construct($objElementData);
     $this->setStrCacheAddon(getPost("searchterm") . getGet("searchterm"));
 }