public function validateValue() { $objDate = new class_date("0"); $arrParams = class_carrier::getAllParams(); if (array_key_exists($this->getStrEntryName(), $arrParams)) { $objDate->generateDateFromParams($this->getStrEntryName(), $arrParams); } else { $objDate = new class_date($this->getStrValue()); } return $this->getObjValidator()->validate($objDate); }
/** * Creates int-values of the passed date-values */ private function processDates() { if ($this->getParam("filter") == "true") { $this->objDateStart = new class_date(); $this->objDateStart->generateDateFromParams("start", $this->getAllParams()); $this->objDateEnd = new class_date(); $this->objDateEnd->generateDateFromParams("end", $this->getAllParams()); class_carrier::getInstance()->getObjSession()->setSession(self::$STR_SESSION_KEY_DATE_START, $this->objDateStart->getTimeInOldStyle()); class_carrier::getInstance()->getObjSession()->setSession(self::$STR_SESSION_KEY_DATE_END, $this->objDateEnd->getTimeInOldStyle()); if ($this->getParam("interval") != "") { $this->intInterval = (int) $this->getParam("interval"); } else { $this->intInterval = 2; } class_carrier::getInstance()->getObjSession()->setSession(self::$STR_SESSION_KEY_INTERVAL, $this->intInterval); } }
/** * Method used to validate posted form-values. * NOTE: To work with this method, the derived class needs to implement * a method "getRequiredFields()", returning an array of field to validate. * The array returned by getRequiredFields() has to fit the format * [fieldname] = type, whereas type can be one of * string, number, email, folder, systemid * The array saved in $this->$arrValidationErrors return by this method is empty in case of no validation Errors, * otherwise an array with the structure * [nonvalidField] = text from objText * is being created. * * @return bool * @deprecated */ public function validateForm() { $arrReturn = array(); $arrFieldsToCheck = $this->getRequiredFields(); foreach ($arrFieldsToCheck as $strFieldname => $strType) { //backwards compatibility if ($strType == "string") { $strType = "text"; } //backwards compatibility if ($strType == "number") { $strType = "numeric"; } $strValue = $this->getParam($strFieldname); if ($strType == "date") { $objDate = new class_date("0"); $objDate->generateDateFromParams($strFieldname, $this->getAllParams()); $strValue = $objDate; } $objValidator = $this->getValidatorInstance($strType); if (!$objValidator->validate($strValue)) { if ($this->getLang("required_" . $strFieldname) != "!required_" . $strFieldname . "!") { $arrReturn[$strFieldname] = $this->getLang("required_" . $strFieldname); } else { if ($this->getLang($strFieldname) != "!" . $strFieldname . "!") { $arrReturn[$strFieldname] = $this->getLang($strFieldname); } else { $arrReturn[$strFieldname] = $this->getLang("required_" . $strFieldname); } } } } $this->arrValidationErrors = array_merge($this->arrValidationErrors, $arrReturn); return count($this->arrValidationErrors) == 0; }
/** * Saves the passed Element to the database (edit or new modes) * * @throws class_exception * @return string "" in case of success */ protected function actionSaveElement() { $strReturn = ""; //There are two modes - edit and new //The element itself just knows the edit mode, so in case of new, we have to create a dummy element - before //passing control to the element if ($this->getParam("mode") == "new") { //Using the passed placeholder-param to load the element and get the table $strPlaceholder = $this->getParam("placeholder"); //Split up the placeholder $arrPlaceholder = explode("_", $strPlaceholder); $strPlaceholderName = $arrPlaceholder[0]; $strPlaceholderElement = $this->getParam("element"); //Now, load all infos about the requested element $objElement = class_module_pages_element::getElement($strPlaceholderElement); //Load the class to create an object $strElementClass = str_replace(".php", "", $objElement->getStrClassAdmin()); //and finally create the object /** @var class_element_admin $objElement */ $objElement = new $strElementClass(); //really continue? try to validate the passed data. if ($objElement->getAdminForm() !== null && !$objElement->getAdminForm()->validateForm()) { class_carrier::getInstance()->setParam("peClose", ""); $strReturn .= $this->actionNew(true); return $strReturn; } else { if (!$objElement->validateForm()) { class_carrier::getInstance()->setParam("peClose", ""); $strReturn .= $this->actionNew(true); return $strReturn; } } //So, lets do the magic - create the records $objPageElement = new class_module_pages_pageelement(); $objPageElement->setStrName($strPlaceholderName); $objPageElement->setStrPlaceholder($strPlaceholder); $objPageElement->setStrElement($strPlaceholderElement); $objPageElement->setStrLanguage($this->getParam("page_element_ph_language")); if (!$objPageElement->updateObjectToDb($this->getSystemid())) { throw new class_exception("Error saving new element-object to db", class_exception::$level_ERROR); } $strElementSystemId = $objPageElement->getSystemid(); $objLockmanager = new class_lockmanager($strElementSystemId); $objLockmanager->lockRecord(); //To have the element working as expected, set the systemid $this->setSystemid($strElementSystemId); } // ************************************* Edit the current Element ******************************* //check, if the element isn't locked $objCommons = new class_module_system_common($this->getSystemid()); $strPageSystemid = $objCommons->getPrevId(); $objLockmanager = new class_lockmanager($this->getSystemid()); if ($objLockmanager->isLockedByCurrentUser()) { //Load the data of the current element $objElementData = new class_module_pages_pageelement($this->getSystemid()); /** @var $objElement class_element_admin */ $objElement = $objElementData->getConcreteAdminInstance(); //really continue? try to validate the passed data. if ($objElement->getAdminForm() !== null && !$objElement->getAdminForm()->validateForm()) { class_carrier::getInstance()->setParam("peClose", ""); $strReturn .= $this->actionEdit(true); return $strReturn; } else { if (!$objElement->validateForm()) { class_carrier::getInstance()->setParam("peClose", ""); $strReturn .= $this->actionEdit(true); return $strReturn; } } //pass the data to the element, maybe the element wants to update some data $objElement->setArrParamData($this->getAllParams()); if ($objElement->getAdminForm() !== null) { $objElement->getAdminForm()->updateSourceObject(); } $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(); //And update the internal comment and language $objElementData->setStrTitle($this->getParam("page_element_ph_title")); $objElementData->setStrLanguage($this->getParam("page_element_ph_language")); //placeholder to update? if ($this->getParam("placeholder") != "") { $objElementData->setStrPlaceholder($this->getParam("placeholder")); } $objStartDate = new class_date("0"); $objEndDate = new class_date("0"); $objStartDate->generateDateFromParams("start", $this->getAllParams()); $objEndDate->generateDateFromParams("end", $this->getAllParams()); if ($objStartDate->getIntYear() == "0000") { $objElementData->setObjStartDate(null); } else { $objElementData->setObjStartDate($objStartDate); } if ($objEndDate->getIntYear() == "0000") { $objElementData->setObjEndDate(null); } else { $objElementData->setObjEndDate($objEndDate); } if (!$objElementData->updateObjectToDb()) { throw new class_exception("Error updating object to db", class_exception::$level_ERROR); } //allow the element to run actions after saving $objElement->doAfterSaveToDb(); //Loading the data of the corresponding site $objPage = new class_module_pages_page($strPageSystemid); $this->flushCompletePagesCache(); if ($this->getParam("peClose") == "1") { //generate the elements' output $objPortalElement = $objElementData->getConcretePortalInstance(); $strElementContent = $objPortalElement->getElementOutput(); $strContent = json_encode($strElementContent, JSON_FORCE_OBJECT); //JSON_HEX_QUOT|JSON_HEX_APOS $strReturn = <<<JS parent.KAJONA.admin.portaleditor.changeElementData('{$objElementData->getStrPlaceholder()}', '{$objElementData->getSystemid()}', {$strContent}); parent.KAJONA.admin.portaleditor.closeDialog(true); JS; class_carrier::getInstance()->setParam("peClose", null); return "<script type='text/javascript'>{$strReturn}</script>"; } $this->adminReload(class_link::getLinkAdminHref("pages_content", "list", "systemid=" . $objPage->getSystemid())); } else { $strReturn = $this->objToolkit->warningBox($this->getLang("ds_gesperrt")); } return $strReturn; }
/** * Shows a form or deltes a timeintervall from the logs * * @throws class_exception * @return string "" in case of success * @permissions edit * @autoTestable */ protected function actionLogbookFlush() { $strReturn = ""; if ($this->getParam("flush") == "") { $strReturn .= $this->objToolkit->formHeader(class_link::getLinkAdminHref($this->getArrModule("modul"), "logbookFlush", "flush=1")); $strReturn .= $this->objToolkit->formTextRow($this->getLang("logbook_hint_date")); $strReturn .= $this->objToolkit->formDateSingle("date", $this->getLang("commons_date"), new class_date()); $strReturn .= $this->objToolkit->formInputSubmit($this->getLang("commons_save")); $strReturn .= $this->objToolkit->formClose(); } elseif ($this->getParam("flush") == "1") { //Build the date $objDate = new class_date(); $objDate->generateDateFromParams("date", $this->getAllParams()); if (!class_module_mediamanager_logbook::deleteFromLogs($objDate->getTimeInOldStyle())) { throw new class_exception("Error deleting log-rows", class_exception::$level_ERROR); } $this->adminReload(class_link::getLinkAdminHref($this->getArrModule("modul"), "logbook")); } return $strReturn; }