/**
  * Creates a form
  *
  * @return string
  */
 private function tellafriendForm()
 {
     $arrTemplate = array();
     //any errors to print?
     if (count($this->arrError) > 0) {
         $strError = "";
         //Collect errors
         $strTemplateErrorID = $this->objTemplate->readTemplate("/element_tellafriend/" . $this->arrElementData["tellafriend_template"], "errorrow");
         foreach ($this->arrError as $strOneError) {
             $strError .= $this->fillTemplate(array("error" => $strOneError), $strTemplateErrorID);
         }
         //and the complete errorform
         $strTemplateErrorFormid = $this->objTemplate->readTemplate("/element_tellafriend/" . $this->arrElementData["tellafriend_template"], "errors");
         $arrTemplate["tellafriend_errors"] = $this->fillTemplate(array("liste_fehler" => $strError), $strTemplateErrorFormid);
     }
     $strTemplateID = $this->objTemplate->readTemplate("/element_tellafriend/" . $this->arrElementData["tellafriend_template"], "tellafriend_form");
     $arrTemplate["tellafriend_sender"] = htmlToString($this->getParam("tellafriend_sender"), true);
     $arrTemplate["tellafriend_sender_name"] = htmlToString($this->getParam("tellafriend_sender_name"), true);
     $arrTemplate["tellafriend_receiver"] = htmlToString($this->getParam("tellafriend_receiver"), true);
     $arrTemplate["tellafriend_receiver_name"] = htmlToString($this->getParam("tellafriend_receiver_name"), true);
     $arrTemplate["tellafriend_message"] = htmlToString($this->getParam("tellafriend_message"), true);
     $arrTemplate["tellafriend_action"] = "sendTellafriend";
     $arrTemplate["action"] = getLinkPortalHref($this->getPagename());
     return $this->fillTemplate($arrTemplate, $strTemplateID);
 }
 /**
  * Constructor
  *
  * @param mixed $arrElementData
  */
 public function __construct($arrElementData)
 {
     parent::__construct($arrElementData);
     if (isset($arrElementData["search_query_id"]) && $arrElementData["search_query_id"] != "") {
         $this->setAction("search");
     }
     $this->objSearchSearch = new class_module_search_search();
     if ($this->getParam("searchterm") != "") {
         $this->objSearchSearch->setStrQuery(htmlToString(urldecode($this->getParam("searchterm")), true));
     }
 }
 /**
  * Searches for a passed string
  *
  * @return string
  * @permissions view
  */
 protected function actionDoSearch()
 {
     $strReturn = "";
     $objSearch = new class_module_search_search();
     $objSearch->setStrPortalLangFilter($this->getStrPortalLanguage());
     if ($this->getParam("searchterm") != "") {
         $objSearch->setStrQuery(htmlToString(urldecode($this->getParam("searchterm")), true));
     }
     $arrResult = array();
     $objSearchCommons = new class_module_search_commons();
     if ($objSearch->getStrQuery() != "") {
         $arrResult = $objSearchCommons->doPortalSearch($objSearch);
     }
     $strReturn .= $this->createSearchXML($objSearch->getStrQuery(), $arrResult);
     return $strReturn;
 }
 /**
  * Renders the list of available packages or any other kind of gui-representation
  * of the packageprovider.
  *
  * Whenever the provider is capable of uploading new packages, the copy & and upload process
  * should be triggered by the admin-class again.
  * So make sure links or forms point to
  * module = packagemanager
  * action = uploadPackage
  * provider = class_name
  * The provider will be called using the processPackageUpload method.
  *
  * @throws class_exception
  * @return string
  */
 public function renderPackageList()
 {
     $objUser = new class_module_user_user(class_session::getInstance()->getUserID());
     $intStart = ($this->getPageNumber() - 1) * $objUser->getIntItemsPerPage();
     $intEnd = $intStart + $objUser->getIntItemsPerPage() - 1;
     $objToolkit = class_carrier::getInstance()->getObjToolkit("admin");
     $objLang = class_carrier::getInstance()->getObjLang();
     $objManager = new class_module_packagemanager_manager();
     $objRemoteloader = $this->getRemoteloader();
     $objRemoteloader->setStrQueryParams($this->buildQueryParams($intStart, $intEnd));
     $strResponse = "";
     try {
         $strResponse = $objRemoteloader->getRemoteContent();
     } catch (class_exception $objEx) {
         return $objLang->getLang("package_remote_errorloading", self::$STR_MODULE_NAME);
     }
     $arrResponse = json_decode($strResponse, true);
     if ($arrResponse === null) {
         throw new class_exception("Error loading the remote package list. Got: <br />" . htmlToString($strResponse, true), class_exception::$level_ERROR);
     }
     $objRemoteParser = class_module_packagemanager_remoteparser_factory::getRemoteParser($arrResponse, $this->getPageNumber(), $intStart, $intEnd, get_class($this), "&name=" . urlencode($this->getParam("name")) . "&type=" . $this->getParam("type"));
     $arrPackages = $objRemoteParser->getArrPackages();
     $strReturn = $this->createFilterCriteria();
     $strReturn .= $objToolkit->listHeader();
     if (!$this->containsItems($arrPackages)) {
         $strReturn .= $objToolkit->getTextRow($objLang->getLang("commons_list_empty", null));
     } else {
         $intI = 0;
         foreach ($arrPackages as $arrOnePackage) {
             //check if already installed locally
             if ($objManager->getPackage($arrOnePackage["title"]) !== null) {
                 $strAction = $objToolkit->listButton(getImageAdmin("icon_installDisabled", $objLang->getLang("package_noinstall_installed", self::$STR_MODULE_NAME)));
             } else {
                 $strAction = $objToolkit->listButton(getLinkAdmin(self::$STR_MODULE_NAME, "uploadPackage", "provider=" . get_class($this) . "&systemid=" . $arrOnePackage["systemid"], $objLang->getLang("package_install", self::$STR_MODULE_NAME), $objLang->getLang("package_install", self::$STR_MODULE_NAME), "icon_install"));
             }
             $strIcon = "icon_module";
             if ($arrOnePackage["type"] == "TEMPLATE") {
                 $strIcon = "icon_dot";
             }
             $arrOnePackage["version"] = $objLang->getLang("type_" . $arrOnePackage["type"], self::$STR_MODULE_NAME) . ", V " . $arrOnePackage["version"];
             $strReturn .= $objToolkit->genericAdminList($arrOnePackage["systemid"], $arrOnePackage["title"], getImageAdmin($strIcon), $strAction, $intI++, $arrOnePackage["version"], $arrOnePackage["description"]);
         }
     }
     $strReturn .= $objToolkit->listFooter();
     $strReturn .= $objRemoteParser->paginationFooter();
     return $strReturn;
 }
 /**
  * Searches for a passed string
  *
  * @return string
  * @permissions view
  * @xml
  */
 protected function actionSearchXml()
 {
     $strReturn = "";
     $strSearchterm = "";
     if ($this->getParam("search_query") != "") {
         $strSearchterm = htmlToString(urldecode($this->getParam("search_query")), false);
     }
     $objSearch = new class_module_search_search();
     $objSearch->setStrQuery($strSearchterm);
     $arrResult = array();
     $objSearchCommons = new class_module_search_commons();
     if ($strSearchterm != "") {
         $arrResult = $objSearchCommons->doAdminSearch($objSearch, 0, self::INT_MAX_NR_OF_RESULTS);
     }
     $objSearchFunc = function (class_search_result $objA, class_search_result $objB) {
         //first by module, second by score
         if ($objA->getObjObject() instanceof class_model && $objB->getObjObject() instanceof class_model) {
             $intCmp = strcmp($objA->getObjObject()->getArrModule("modul"), $objB->getObjObject()->getArrModule("modul"));
             if ($intCmp != 0) {
                 return $intCmp;
             } else {
                 return $objA->getIntScore() < $objB->getIntScore();
             }
         }
         //fallback: score only
         return $objA->getIntScore() < $objB->getIntScore();
     };
     uasort($arrResult, $objSearchFunc);
     if ($this->getParam("asJson") != "") {
         $strReturn .= $this->createSearchJson($strSearchterm, $arrResult);
     } else {
         $strReturn .= $this->createSearchXML($strSearchterm, $arrResult);
     }
     return $strReturn;
 }
 /**
  * Tries to log the user with the given credentials into the system.
  * To log in through the portal, the right "portal" has to be given!
  *
  * @return bool
  */
 private function doLogin()
 {
     $strUsername = htmlToString($this->getParam("portallogin_username"), true);
     $strPassword = htmlToString($this->getParam("portallogin_password"), true);
     if ($this->objSession->login($strUsername, $strPassword)) {
         if (!$this->objSession->isPortal()) {
             $this->objSession->logout();
             return false;
         } else {
             return true;
         }
     }
     return false;
 }
 /**
  * Validates the submitted data
  *
  * @return bool
  */
 private function validateData()
 {
     $bitReturn = true;
     //Check captachcode
     if ($this->getParam("gb_post_captcha") != $this->objSession->getCaptchaCode() || $this->getParam("gb_post_captcha") == "") {
         $bitReturn = false;
     }
     //Check mailaddress
     $objMailValidator = new class_email_validator();
     if (!$objMailValidator->validate($this->getParam("gb_post_email"))) {
         $this->arrErrors[] = $this->getLang("insert_error_email");
         $bitReturn = false;
     }
     if (uniStrlen($this->getParam("gb_post_name")) == 0) {
         $this->arrErrors[] = $this->getLang("insert_error_name");
         $bitReturn = false;
     }
     if (uniStrlen($this->getParam("gb_post_text")) == 0) {
         $this->arrErrors[] = $this->getLang("insert_error_post");
         $bitReturn = false;
     }
     //if there ain't any errors, update texts
     if ($bitReturn) {
         $this->setParam("gb_post_name", htmlToString($this->getParam("gb_post_name")));
         $this->setParam("gb_post_email", htmlToString($this->getParam("gb_post_email")));
         $this->setParam("gb_post_text", htmlToString($this->getParam("gb_post_text")));
     }
     return $bitReturn;
 }
 /**
  * Creates the code surrounding the element.
  * Creates the "entry" to the portal-editor
  *
  * @param string $strContent elements' output
  * @param string $strSystemid elements' systemid
  * @param array $arrConfig : pe_module, pe_action, [pe_action_new, pe_action_new_params]
  * @param string $strElement
  *
  * @return string
  * @static
  */
 public static function addPortalEditorCode($strContent, $strSystemid, $arrConfig, $strElement = "")
 {
     $strReturn = "";
     if (!validateSystemid($strSystemid)) {
         return $strContent;
     }
     $objInstance = class_objectfactory::getInstance()->getObject($strSystemid);
     if ($objInstance == null || class_module_system_setting::getConfigValue("_pages_portaleditor_") != "true") {
         return $strContent;
     }
     if (!class_carrier::getInstance()->getObjSession()->isAdmin() || !$objInstance->rightEdit($strSystemid) || class_carrier::getInstance()->getObjSession()->getSession("pe_disable") == "true") {
         return $strContent;
     }
     //switch the text-language temporary
     $strPortalLanguage = class_carrier::getInstance()->getObjLang()->getStrTextLanguage();
     class_carrier::getInstance()->getObjLang()->setStrTextLanguage(class_carrier::getInstance()->getObjSession()->getAdminLanguage());
     //fetch the language to set the correct admin-lang
     $objLanguages = new class_module_languages_language();
     $strAdminLangParam = "&language=" . $objLanguages->getPortalLanguage();
     $strModule = "pages_content";
     $strAction = "edit";
     //param-inits ---------------------------------------
     //Generate url to the admin-area
     if ($arrConfig["pe_module"] != "") {
         $strModule = $arrConfig["pe_module"];
     }
     //---------------------------------------------------
     //---------------------------------------------------
     //Link to create a new entry - only for modules, so not the page-content directly!
     $strNewLink = "";
     if ($strModule != "pages_content") {
         //Use Module-config to generate link
         if (isset($arrConfig["pe_action_new"]) && $arrConfig["pe_action_new"] != "") {
             $strNewUrl = class_link::getLinkAdminHref($strModule, $arrConfig["pe_action_new"], $arrConfig["pe_action_new_params"] . $strAdminLangParam . "&pe=1");
             $strNewLink = "<a href=\"#\" onclick=\"KAJONA.admin.portaleditor.openDialog('" . $strNewUrl . "'); return false;\">" . class_carrier::getInstance()->getObjLang()->getLang("pe_new_old", "pages") . "</a>";
         }
     }
     //---------------------------------------------------
     //Link to edit current element
     $strEditLink = "";
     //standard: pages_content.
     if ($strModule == "pages_content") {
         $arrConfig["pe_action_edit"] = $strAction;
         $arrConfig["pe_action_edit_params"] = "&systemid=" . $strSystemid;
     }
     //Use Module-config to generate link
     if (isset($arrConfig["pe_action_edit"]) && $arrConfig["pe_action_edit"] != "") {
         $strEditUrl = class_link::getLinkAdminHref($strModule, $arrConfig["pe_action_edit"], $arrConfig["pe_action_edit_params"] . $strAdminLangParam . "&pe=1");
         $strEditLink = "<a href=\"#\" onclick=\"KAJONA.admin.portaleditor.openDialog('" . $strEditUrl . "'); return false;\">" . class_carrier::getInstance()->getObjLang()->getLang("pe_edit", "pages") . "</a>";
     }
     //---------------------------------------------------
     //link to copy an element to the same or another placeholder
     $strCopyLink = "";
     //standard: pages_content.
     if ($strModule == "pages_content") {
         $arrConfig["pe_action_copy"] = "copyElement";
         $arrConfig["pe_action_copy_params"] = "&systemid=" . $strSystemid;
     }
     //Use Module-config to generate link
     if (isset($arrConfig["pe_action_copy"]) && $arrConfig["pe_action_copy"] != "") {
         $strCopyUrl = class_link::getLinkAdminHref($strModule, $arrConfig["pe_action_copy"], $arrConfig["pe_action_copy_params"] . $strAdminLangParam . "&pe=1");
         $strCopyLink = "<a href=\"#\" onclick=\"KAJONA.admin.portaleditor.openDialog('" . $strCopyUrl . "'); return false;\">" . class_carrier::getInstance()->getObjLang()->getLang("pe_copy", "pages") . "</a>";
     }
     //---------------------------------------------------
     //link to delete the current element
     $strDeleteLink = "";
     if ($objInstance->rightDelete()) {
         //standard: pages_content.
         if ($strModule == "pages_content") {
             $arrConfig["pe_action_delete"] = "deleteElementFinal";
             $arrConfig["pe_action_edit_params"] = "&systemid=" . $strSystemid;
             $strCallback = " function() { delDialog.hide(); KAJONA.admin.portaleditor.deleteElementData('{$strSystemid}'); return false; } ";
         } else {
             if (isset($arrConfig["pe_action_delete"]) && $arrConfig["pe_action_delete"] != "") {
                 $strDeleteUrl = class_link::getLinkAdminHref($strModule, $arrConfig["pe_action_delete"], $arrConfig["pe_action_edit_params"] . $strAdminLangParam . "&pe=1");
                 $strCallback = " function() { delDialog.hide(); KAJONA.admin.portaleditor.openDialog('{$strDeleteUrl}'); return false; } ";
             }
         }
         if (isset($arrConfig["pe_action_delete"]) && $arrConfig["pe_action_delete"] != "") {
             $strElementName = uniStrReplace(array('\''), array('\\\''), $objInstance->getStrDisplayName());
             $strQuestion = uniStrReplace("%%element_name%%", htmlToString($strElementName, true), class_carrier::getInstance()->getObjLang()->getLang("commons_delete_record_question", "system"));
             $strDeleteLink = class_link::getLinkAdminManual("href=\"#\" onclick=\"javascript:delDialog.setTitle('" . class_carrier::getInstance()->getObjLang()->getLang("dialog_deleteHeader", "system") . "'); delDialog.setContent('" . $strQuestion . "', '" . class_carrier::getInstance()->getObjLang()->getLang("dialog_deleteButton", "system") . "',  " . $strCallback . "); delDialog.init(); return false;\"", class_carrier::getInstance()->getObjLang()->getLang("commons_delete", "system"), class_carrier::getInstance()->getObjLang()->getLang("commons_delete", "system"));
         }
     }
     //---------------------------------------------------
     //link to drag n drop element
     //TODO: check if there are more than one elements in current placeholder before showing shift buttons
     $strMoveHandle = "";
     if ($strModule == "pages_content") {
         $strMoveHandle = "<i href=\"#\" class=\"moveHandle fa fa-arrows\" title=\"" . class_carrier::getInstance()->getObjLang()->getLang("pe_move", "pages") . "\" rel=\"tooltip\"></i>";
     }
     //---------------------------------------------------
     //link to set element inactive
     $strSetInactiveLink = "";
     //standard: pages_content.
     if ($strModule == "pages_content") {
         $arrConfig["pe_action_setStatus"] = "elementStatus";
         $arrConfig["pe_action_setStatus_params"] = "&systemid=" . $strSystemid;
     }
     //Use Module-config to generate link
     if (isset($arrConfig["pe_action_setStatus"]) && $arrConfig["pe_action_setStatus"] != "") {
         $strSetInactiveUrl = class_link::getLinkAdminHref($strModule, $arrConfig["pe_action_setStatus"], $arrConfig["pe_action_setStatus_params"] . $strAdminLangParam . "&pe=1");
         $strSetInactiveLink = "<a href=\"#\" onclick=\"KAJONA.admin.portaleditor.openDialog('" . $strSetInactiveUrl . "'); return false;\">" . class_carrier::getInstance()->getObjLang()->getLang("pe_setinactive", "pages") . "</a>";
     }
     //---------------------------------------------------
     // layout generation
     $strReturn .= class_carrier::getInstance()->getObjToolkit("portal")->getPeActionToolbar($strSystemid, array($strMoveHandle, $strNewLink, $strEditLink, $strCopyLink, $strDeleteLink, $strSetInactiveLink), $strContent, $strElement);
     //reset the portal texts language
     class_carrier::getInstance()->getObjLang()->setStrTextLanguage($strPortalLanguage);
     return $strReturn;
 }
 /**
  * Returns a simple <pre>-Element to display pre-formatted text such as logfiles
  *
  * @param array $arrLines
  * @param int $nrRows number of rows to display
  *
  * @return string
  */
 public function getPreformatted($arrLines, $nrRows = 0, $bitHighlightKeywords = true)
 {
     $strTemplateID = $this->objTemplate->readTemplate("/elements.tpl", "preformatted");
     $strRows = "";
     $intI = 0;
     foreach ($arrLines as $strOneLine) {
         if ($nrRows != 0 && $intI++ > $nrRows) {
             break;
         }
         $strOneLine = str_replace(array("<pre>", "</pre>", "\n"), array(" ", " ", "\r\n"), $strOneLine);
         $strOneLine = htmlToString($strOneLine, true);
         $strOneLine = uniStrReplace(array("INFO", "ERROR", "WARNING"), array("<span style=\"color: green\">INFO</span>", "<span style=\"color: red\">ERROR</span>", "<span style=\"color: orange\">WARNING</span>"), $strOneLine);
         $strRows .= $strOneLine;
     }
     return $this->objTemplate->fillTemplate(array("pretext" => $strRows), $strTemplateID);
 }