/**
  * @inheritDoc
  */
 public function generateFieldsFromObject()
 {
     parent::generateFieldsFromObject();
     $objNews = $this->getObjSourceobject();
     if ($objNews->getSystemid() != class_module_system_module::getModuleByName("news")->getSystemid()) {
         //search the languages maintained
         $objLanguageManager = class_module_languages_languageset::getLanguagesetForSystemid($objNews->getSystemid());
         if ($objLanguageManager != null) {
             $arrMaintained = $objLanguageManager->getArrLanguageSet();
             $arrDD = array();
             foreach ($arrMaintained as $strLanguageId => $strSystemid) {
                 $objLanguage = new class_module_languages_language($strLanguageId);
                 $arrDD[$strSystemid] = $this->getLang("lang_" . $objLanguage->getStrName(), "languages");
             }
             class_module_languages_admin::enableLanguageSwitch();
             class_module_languages_admin::setArrLanguageSwitchEntries($arrDD);
             class_module_languages_admin::setStrOnChangeHandler("window.location='" . class_link::getLinkAdminHref("news", "editNews") . (class_module_system_setting::getConfigValue("_system_mod_rewrite_") == "true" ? "?" : "&") . "systemid='+this.value+'&pe=" . class_carrier::getInstance()->getParam("pe") . "';");
             class_module_languages_admin::setStrActiveKey($objNews->getSystemid());
         }
     }
     $arrCats = class_module_news_category::getObjectList();
     if (count($arrCats) > 0) {
         $arrKeyValues = array();
         /** @var class_module_news_category $objOneCat */
         foreach ($arrCats as $objOneCat) {
             $arrKeyValues[$objOneCat->getSystemid()] = $objOneCat->getStrDisplayName();
         }
         $this->getField("cats")->setStrLabel($this->getLang("commons_categories"))->setArrKeyValues($arrKeyValues);
     }
     if (class_module_system_setting::getConfigValue("_news_news_datetime_") == "true") {
         $this->addField(new class_formentry_datetime($this->getStrFormname(), "objDateStart", $objNews), "datestart")->setBitMandatory(true)->setStrLabel($this->getLang("form_news_datestart"));
         $this->addField(new class_formentry_datetime($this->getStrFormname(), "objDateEnd", $objNews), "dateend")->setStrLabel($this->getLang("form_news_dateend"));
         $this->addField(new class_formentry_datetime($this->getStrFormname(), "objDateSpecial", $objNews), "datespecial")->setStrLabel($this->getLang("form_news_datespecial"));
     }
 }
 /**
  * Returns a list of available placeholders & elements on this page
  *
  * @return string
  * @permissions edit
  */
 protected function actionList()
 {
     $strReturn = "";
     class_module_languages_admin::enableLanguageSwitch();
     $objPage = new class_module_pages_page($this->getSystemid());
     //get infos about the page
     $arrToolbarEntries = array();
     $arrToolbarEntries[0] = "<a href=\"" . class_link::getLinkAdminHref("pages", "editPage", "&systemid=" . $this->getSystemid()) . "\">" . class_adminskin_helper::getAdminImage("icon_edit") . $this->getLang("contentToolbar_pageproperties") . "</a>";
     $arrToolbarEntries[1] = "<a href=\"" . class_link::getLinkAdminHref("pages_content", "list", "&systemid=" . $this->getSystemid()) . "\">" . class_adminskin_helper::getAdminImage("icon_page") . $this->getLang("contentToolbar_content") . "</a>";
     $arrToolbarEntries[2] = "<a href=\"" . class_link::getLinkPortalHref($objPage->getStrName(), "", "", "&preview=1", "", $this->getLanguageToWorkOn()) . "\" target=\"_blank\">" . class_adminskin_helper::getAdminImage("icon_lens") . $this->getLang("contentToolbar_preview") . "</a>";
     if ($objPage->getIntType() != class_module_pages_page::$INT_TYPE_ALIAS) {
         $strReturn .= $this->objToolkit->getContentToolbar($arrToolbarEntries, 1);
     }
     $arrInfoRows = array(array($this->getLang("template"), $objPage->getStrTemplate()), array($this->getLang("lastuserTitle"), $objPage->getLastEditUser()), array($this->getLang("lasteditTitle"), timeToString($objPage->getIntLmTime())));
     $strReturn .= $this->objToolkit->dataTable(null, $arrInfoRows);
     $strReturn .= $this->objToolkit->divider();
     //try to load template, otherwise abort
     $strTemplateID = null;
     try {
         $strTemplateID = $this->objTemplate->readTemplate("/module_pages/" . $objPage->getStrTemplate(), "", false, true);
     } catch (class_exception $objException) {
         $strReturn .= $this->getLang("templateNotLoaded") . "<br />";
     }
     //Load elements on template, master-page special case!
     if ($objPage->getStrName() == "master") {
         $arrElementsOnTemplate = $this->objTemplate->getElements($strTemplateID, 1);
     } else {
         $arrElementsOnTemplate = $this->objTemplate->getElements($strTemplateID, 0);
     }
     //Language-dependant loading of elements, if installed
     $arrElementsOnPage = class_module_pages_pageelement::getElementsOnPage($this->getSystemid(), false, $this->getLanguageToWorkOn());
     //save a copy of the array to be able to check against all values later on
     $arrElementsOnPageCopy = $arrElementsOnPage;
     //Loading all Elements installed on the system ("RAW"-Elements)
     $arrElementsInSystem = class_module_pages_element::getObjectList();
     //So, loop through the placeholders and check, if there's any element already belonging to this one
     $intI = 0;
     if (is_array($arrElementsOnTemplate) && count($arrElementsOnTemplate) > 0) {
         //Iterate over every single placeholder provided by the template
         foreach ($arrElementsOnTemplate as $arrOneElementOnTemplate) {
             $strOutputAtPlaceholder = "";
             //Do we have one or more elements already in db at this placeholder?
             $bitHit = false;
             //Iterate over every single element-type provided by the placeholder
             foreach ($arrElementsOnPage as $intArrElementsOnPageKey => $objOneElementOnPage) {
                 //Check, if its the same placeholder
                 $bitSamePlaceholder = false;
                 if ($arrOneElementOnTemplate["placeholder"] == $objOneElementOnPage->getStrPlaceholder()) {
                     $bitSamePlaceholder = true;
                 }
                 if ($bitSamePlaceholder) {
                     $bitHit = true;
                     //try to unlock the record
                     $objOneElementOnPage->getLockManager()->unlockRecord();
                     $strActions = $this->getActionIcons($objOneElementOnPage);
                     //Put all Output together
                     $strOutputAtPlaceholder .= $this->objToolkit->simpleAdminList($objOneElementOnPage, $strActions, $intI++);
                     //remove the element from the array
                     unset($arrElementsOnPage[$intArrElementsOnPageKey]);
                 }
             }
             //Check, if one of the elements in the placeholder is allowed to be used multiple times
             foreach ($arrOneElementOnTemplate["elementlist"] as $arrSingleElementOnTemplateplaceholder) {
                 /** @var class_module_pages_element $objOneElementInSystem  */
                 foreach ($arrElementsInSystem as $objOneElementInSystem) {
                     if ($objOneElementInSystem->getStrName() == $arrSingleElementOnTemplateplaceholder["element"]) {
                         if ($objOneElementInSystem->getIntRepeat() == 1 || $bitHit === false) {
                             //So, the Row for a new element: element is repeatable or not yet created
                             $strActions = $this->objToolkit->listButton(class_link::getLinkAdmin("pages_content", "new", "&placeholder=" . $arrOneElementOnTemplate["placeholder"] . "&element=" . $arrSingleElementOnTemplateplaceholder["element"] . "&systemid=" . $this->getSystemid(), "", $this->getLang("element_anlegen"), "icon_new"));
                             $strOutputAtPlaceholder .= $this->objToolkit->genericAdminList("", $objOneElementInSystem->getStrDisplayName(), "", $strActions, $intI++);
                         } else {
                             //element not repeatable.
                             //Is there already one element installed? if not, then it IS allowed to create a new one
                             $bitOneInstalled = false;
                             foreach ($arrElementsOnPageCopy as $objOneElementToCheck) {
                                 if ($arrOneElementOnTemplate["placeholder"] == $objOneElementToCheck->getStrPlaceholder() && $arrSingleElementOnTemplateplaceholder["element"] == $objOneElementToCheck->getStrElement()) {
                                     $bitOneInstalled = true;
                                 }
                             }
                             if (!$bitOneInstalled) {
                                 //So, the Row for a new element
                                 $strActions = $this->objToolkit->listButton(class_link::getLinkAdmin("pages_content", "new", "&placeholder=" . $arrOneElementOnTemplate["placeholder"] . "&element=" . $arrSingleElementOnTemplateplaceholder["element"] . "&systemid=" . $this->getSystemid(), "", $this->getLang("element_anlegen"), "icon_new"));
                                 $strOutputAtPlaceholder .= $this->objToolkit->genericAdminList("", $objOneElementInSystem->getStrDisplayName(), "", $strActions, $intI++);
                             }
                         }
                     }
                 }
             }
             if ((int) uniStrlen($strOutputAtPlaceholder) > 0) {
                 $arrSinglePlaceholder = explode("_", $arrOneElementOnTemplate["placeholder"]);
                 if (count($arrSinglePlaceholder) == 2) {
                     $strOutputAtPlaceholder .= $this->objToolkit->formHeadline($arrSinglePlaceholder[0]);
                 }
                 $strListId = generateSystemid();
                 $strReturn .= $this->objToolkit->dragableListHeader($strListId, true);
                 $strReturn .= $strOutputAtPlaceholder;
                 $strReturn .= $this->objToolkit->dragableListFooter($strListId);
             }
         }
     } else {
         $strReturn .= $this->getLang("element_liste_leer");
     }
     //if there are any page-elements remaining, print a warning and print the elements row
     if (count($arrElementsOnPage) > 0) {
         $strReturn .= $this->objToolkit->divider();
         $strReturn .= $this->objToolkit->warningBox($this->getLang("warning_elementsremaining"));
         $strReturn .= $this->objToolkit->listHeader();
         //minimized actions now, plz. this ain't being a real element anymore!
         foreach ($arrElementsOnPage as $objOneElement) {
             $strActions = "";
             $strActions .= $this->objToolkit->listDeleteButton($objOneElement->getStrDisplayName(), $this->getLang("element_loeschen_frage"), class_link::getLinkAdminHref("pages_content", "deleteElementFinal", "&systemid=" . $objOneElement->getSystemid() . ($this->getParam("pe") == "" ? "" : "&peClose=" . $this->getParam("pe"))));
             //Put all Output together
             $strReturn .= $this->objToolkit->genericAdminList("", $objOneElement->getStrDisplayName() . $this->getLang("placeholder") . $objOneElement->getStrPlaceholder(), "", $strActions, $intI++);
         }
         $strReturn .= $this->objToolkit->listFooter();
     }
     $strReturn .= $this->objToolkit->getTableOfContents("h2");
     return $strReturn;
 }
 /**
  * Set the currently active key for the language switch
  *
  * @static
  *
  * @param $strActiveKey
  */
 public static function setStrActiveKey($strActiveKey)
 {
     self::$strActiveKey = $strActiveKey;
 }
 /**
  * Shows the form to create a new Site
  *
  * @param string $strMode
  * @param bool $bitAlias
  * @param class_admin_formgenerator|null $objForm
  *
  * @return string The form
  * @autoTestable
  * @permissions edit
  */
 protected function actionNewPage($strMode = "new", $bitAlias = false, class_admin_formgenerator $objForm = null)
 {
     $strReturn = "";
     $objPage = new class_module_pages_page();
     if ($strMode == "edit") {
         $objPage = new class_module_pages_page($this->getSystemid());
         if (!$objPage->rightEdit($this->getSystemid())) {
             return $this->getLang("commons_error_permissions");
         }
     } else {
         if ($strMode == "new") {
             $objPage->setSystemid($this->getSystemid());
         }
     }
     $arrToolbarEntries = array();
     if (!$bitAlias) {
         if ($strMode == "edit") {
             $arrToolbarEntries[] = "<a href=\"" . class_link::getLinkAdminHref("pages", "editPage", "&systemid=" . $this->getSystemid()) . "\">" . class_adminskin_helper::getAdminImage("icon_edit") . $this->getLang("contentToolbar_pageproperties") . "</a>";
             $arrToolbarEntries[] = "<a href=\"" . class_link::getLinkAdminHref("pages_content", "list", "&systemid=" . $this->getSystemid()) . "\" >" . class_adminskin_helper::getAdminImage("icon_page") . $this->getLang("contentToolbar_content") . "</a>";
             $arrToolbarEntries[] = "<a href=\"" . class_link::getLinkPortalHref($objPage->getStrName(), "", "", "&preview=1", "", $this->getLanguageToWorkOn()) . "\" target=\"_blank\">" . class_adminskin_helper::getAdminImage("icon_lens") . $this->getLang("contentToolbar_preview") . "</a>";
         }
         if ($this->getParam("pe") != 1) {
             $strReturn .= $this->objToolkit->getContentToolbar($arrToolbarEntries, 0) . "<br />";
         }
     }
     class_module_languages_admin::enableLanguageSwitch();
     if ($objForm == null) {
         $objForm = $this->getPageForm($bitAlias, $objPage, $strMode);
     }
     if ($bitAlias) {
         $strReturn .= $objForm->renderForm(class_link::getLinkAdminHref($this->getArrModule("modul"), "saveAlias"));
     } else {
         $strReturn .= $objForm->renderForm(class_link::getLinkAdminHref($this->getArrModule("modul"), "savePage"));
     }
     return $strReturn;
 }