/** * Overwritten in order to load key-value pairs declared by annotations */ protected function updateValue() { parent::updateValue(); if ($this->getObjSourceObject() != null && $this->getStrSourceProperty() != "") { $objReflection = new class_reflection($this->getObjSourceObject()); //try to find the matching source property $arrProperties = $objReflection->getPropertiesWithAnnotation(self::STR_DDVALUES_ANNOTATION); $strSourceProperty = null; foreach ($arrProperties as $strPropertyName => $strValue) { if (uniSubstr(uniStrtolower($strPropertyName), uniStrlen($this->getStrSourceProperty()) * -1) == $this->getStrSourceProperty()) { $strSourceProperty = $strPropertyName; } } if ($strSourceProperty == null) { return; } $strDDValues = $objReflection->getAnnotationValueForProperty($strSourceProperty, self::STR_DDVALUES_ANNOTATION); if ($strDDValues !== null && $strDDValues != "") { $arrDDValues = array(); foreach (explode(",", $strDDValues) as $strOneKeyVal) { $strOneKeyVal = uniSubstr(trim($strOneKeyVal), 1, -1); $arrOneKeyValue = explode("=>", $strOneKeyVal); $strKey = trim($arrOneKeyValue[0]) == "" ? " " : trim($arrOneKeyValue[0]); if (count($arrOneKeyValue) == 2) { $strValue = class_carrier::getInstance()->getObjLang()->getLang(trim($arrOneKeyValue[1]), $this->getObjSourceObject()->getArrModule("modul")); if ($strValue == "!" . trim($arrOneKeyValue[1]) . "!") { $strValue = $arrOneKeyValue[1]; } $arrDDValues[$strKey] = $strValue; } } $this->setArrKeyValues($arrDDValues); } } }
/** * Overwritten in order to load key-value pairs declared by annotations */ protected function updateValue() { parent::updateValue(); if ($this->getObjSourceObject() != null && $this->getStrSourceProperty() != "") { $objReflection = new class_reflection($this->getObjSourceObject()); //try to find the matching source property $arrProperties = $objReflection->getPropertiesWithAnnotation(self::STR_TEMPLATEDIR_ANNOTATION); $strSourceProperty = null; foreach ($arrProperties as $strPropertyName => $strValue) { if (uniSubstr(uniStrtolower($strPropertyName), uniStrlen($this->getStrSourceProperty()) * -1) == $this->getStrSourceProperty()) { $strSourceProperty = $strPropertyName; } } if ($strSourceProperty == null) { return; } $strTemplateDir = $objReflection->getAnnotationValueForProperty($strSourceProperty, self::STR_TEMPLATEDIR_ANNOTATION); //load templates $arrTemplates = class_resourceloader::getInstance()->getTemplatesInFolder($strTemplateDir); $arrTemplatesDD = array(); if (count($arrTemplates) > 0) { foreach ($arrTemplates as $strTemplate) { $arrTemplatesDD[$strTemplate] = $strTemplate; } } $this->setArrKeyValues($arrTemplatesDD); } }
public function setValueToObject() { $objReflection = new class_reflection($this->getObjSourceObject()); $strSetter = $objReflection->getSetter($this->getStrSourceProperty()); if ($strSetter !== null && uniStrtolower(uniSubstr($strSetter, 0, 6)) == "setobj" && !$this->getStrValue() instanceof class_date && $this->getStrValue() > 0) { $this->setStrValue(new class_date($this->getStrValue())); } return parent::setValueToObject(); }
/** * Creates a new instance of the current field. * * @param $strFormName * @param $strSourceProperty * @param class_model $objSourceObject */ public function __construct($strFormName, $strSourceProperty, $objSourceObject = null) { $this->strSourceProperty = $strSourceProperty; $this->objSourceObject = $objSourceObject; $this->strFormName = $strFormName; if ($strFormName != "") { $strFormName .= "_"; } $this->strEntryName = uniStrtolower($strFormName . $strSourceProperty); if ($objSourceObject != null) { $this->updateLabel(); } $this->updateValue(); }
/** * The real "download" or "upload" should be handled right here. * All packages have to be downloaded to /project/temp in order to be processed afterwards. * * @return string the filename of the package downloaded */ public function processPackageUpload() { //fetch the upload, validate a few settings and copy the package to /project/temp $arrSource = class_carrier::getInstance()->getParam("provider_local_file"); $strTarget = "/project/temp/" . generateSystemid() . ".zip"; $objFilesystem = new class_filesystem(); //Check file for correct filters $strSuffix = uniStrtolower(uniSubstr($arrSource["name"], uniStrrpos($arrSource["name"], "."))); if (in_array($strSuffix, array(".zip"))) { if ($objFilesystem->copyUpload($strTarget, $arrSource["tmp_name"])) { class_logger::getInstance(class_logger::PACKAGEMANAGEMENT)->addLogRow("uploaded package " . $arrSource["name"] . " to " . $strTarget, class_logger::$levelInfo); class_resourceloader::getInstance()->flushCache(); class_classloader::getInstance()->flushCache(); class_reflection::flushCache(); return $strTarget; } } class_logger::getInstance(class_logger::PACKAGEMANAGEMENT)->addLogRow("error in uploaded package " . $arrSource["name"] . " either wrong format or not writeable target folder", class_logger::$levelInfo); @unlink($arrSource["tmp_name"]); return null; }
private function getSourceDir() { if ($this->getObjSourceObject() != null && $this->getStrSourceProperty() != "") { $objReflection = new class_reflection($this->getObjSourceObject()); //try to find the matching source property $arrProperties = $objReflection->getPropertiesWithAnnotation(self::STR_SOURCEDIR_ANNOTATION); $strSourceProperty = null; foreach ($arrProperties as $strPropertyName => $strValue) { if (uniSubstr(uniStrtolower($strPropertyName), uniStrlen($this->getStrSourceProperty()) * -1) == $this->getStrSourceProperty()) { $strSourceProperty = $strPropertyName; } } if ($strSourceProperty != null) { $strDir = $objReflection->getAnnotationValueForProperty($strSourceProperty, self::STR_SOURCEDIR_ANNOTATION); if ($strDir !== null && $strDir != "") { return $strDir; } } } return null; }
/** * Returns a textual representation of the formentries' value. * May contain html, but should be stripped down to text-only. * * @return string */ public function getValueAsText() { //load all matching and possible values based on the prefix if ($this->getObjSourceObject() == null || $this->getStrSourceProperty() == "") { return $this->getStrValue() . " Error: No target object mapped or missing @fieldValuePrefix annotation!"; } $objReflection = new class_reflection($this->getObjSourceObject()); //try to find the matching source property $arrProperties = $objReflection->getPropertiesWithAnnotation(self::STR_VALUE_ANNOTATION); $strSourceProperty = null; foreach ($arrProperties as $strPropertyName => $strValue) { if (uniSubstr(uniStrtolower($strPropertyName), uniStrlen($this->getStrSourceProperty()) * -1) == $this->getStrSourceProperty()) { $strSourceProperty = $strPropertyName; } } if ($strSourceProperty == null) { return $this->getStrValue(); } $strPrefix = trim($objReflection->getAnnotationValueForProperty($strSourceProperty, self::STR_VALUE_ANNOTATION)); if ($this->getStrValue() !== null && $this->getStrValue() !== "") { return $this->getObjSourceObject()->getLang($strPrefix . $this->getStrValue()); } return ""; }
/** * 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); }
/** * Adds a new field to the current form. * Therefore, the current source-object is inspected regarding the passed propertyname. * So it is essential to provide the matching getters and setters in order to have all * set up dynamically. * * @param string $strPropertyName * @return class_formentry_base|interface_formentry * @throws class_exception */ public function addDynamicField($strPropertyName) { //try to get the matching getter $objReflection = new class_reflection($this->objSourceobject); $strGetter = $objReflection->getGetter($strPropertyName); if ($strGetter === null) { throw new class_exception("unable to find getter for property " . $strPropertyName . "@" . get_class($this->objSourceobject), class_exception::$level_ERROR); } //load detailed properties $strType = $objReflection->getAnnotationValueForProperty($strPropertyName, self::STR_TYPE_ANNOTATION); $strValidator = $objReflection->getAnnotationValueForProperty($strPropertyName, self::STR_VALIDATOR_ANNOTATION); $strMandatory = $objReflection->getAnnotationValueForProperty($strPropertyName, self::STR_MANDATORY_ANNOTATION); $strLabel = $objReflection->getAnnotationValueForProperty($strPropertyName, self::STR_LABEL_ANNOTATION); $strHidden = $objReflection->getAnnotationValueForProperty($strPropertyName, self::STR_HIDDEN_ANNOTATION); $strReadonly = $objReflection->getAnnotationValueForProperty($strPropertyName, self::STR_READONLY_ANNOTATION); if ($strType === null) { $strType = "text"; } $strStart = uniSubstr($strPropertyName, 0, 3); if (in_array($strStart, array("int", "bit", "str", "arr", "obj"))) { $strPropertyName = uniStrtolower(uniSubstr($strPropertyName, 3)); } $strStart = uniSubstr($strPropertyName, 0, 4); if (in_array($strStart, array("long"))) { $strPropertyName = uniStrtolower(uniSubstr($strPropertyName, 4)); } $strStart = uniSubstr($strPropertyName, 0, 5); if (in_array($strStart, array("float"))) { $strPropertyName = uniStrtolower(uniSubstr($strPropertyName, 5)); } $objField = $this->getFormEntryInstance($strType, $strPropertyName); if ($strLabel !== null) { $objField->updateLabel($strLabel); } $bitMandatory = false; if ($strMandatory !== null && $strMandatory !== "false") { $bitMandatory = true; } $objField->setBitMandatory($bitMandatory); $bitReadonly = false; if ($strReadonly !== null && $strReadonly !== "false") { $bitReadonly = true; } $objField->setBitReadonly($bitReadonly); if ($strValidator !== null) { $objField->setObjValidator($this->getValidatorInstance($strValidator)); } $this->addField($objField, $strPropertyName); if ($strHidden !== null) { $this->addFieldToHiddenGroup($objField); } return $objField; }
/** * Will be kept for legacy compatibility * * @param bool $bitJsonResponse * * @return string */ private function doUpload($bitJsonResponse = false) { $strReturn = ""; //prepare the folder to be used as a target-folder for the upload $objFilemanagerRepo = new class_module_mediamanager_repo($this->arrElementData["char2"]); $objDownloadfolder = null; //add a special subfolder? $strPath = $objFilemanagerRepo->getStrPath(); if ($this->getParam("portaluploadDlfolder") != "") { /** @var $objDownloadfolder class_module_mediamanager_file */ $objDownloadfolder = class_objectfactory::getInstance()->getObject($this->getParam("portaluploadDlfolder")); //check if the folder is within the current repo /** @var $objTemp class_module_mediamanager_file */ $objTemp = $objDownloadfolder; while (validateSystemid($objTemp->getSystemid()) && ($objTemp instanceof class_module_mediamanager_file || $objTemp instanceof class_module_mediamanager_repo)) { if ($objTemp->getSystemid() == $this->arrElementData["char2"]) { $strPath = $objDownloadfolder->getStrFilename(); break; } $objTemp = class_objectfactory::getInstance()->getObject($objTemp->getPrevId()); } } //upload the file... if ($objFilemanagerRepo->rightRight1()) { //Handle the fileupload $arrSource = $this->getParam("portaluploadFile"); $strTarget = $strPath . "/" . createFilename($arrSource["name"]); $objFilesystem = new class_filesystem(); if ($objFilesystem->isWritable($strPath)) { //Check file for correct filters $arrAllowed = explode(",", $objFilemanagerRepo->getStrUploadFilter()); $strSuffix = uniStrtolower(uniSubstr($arrSource["name"], uniStrrpos($arrSource["name"], "."))); if ($objFilemanagerRepo->getStrUploadFilter() == "" || in_array($strSuffix, $arrAllowed)) { if ($objFilesystem->copyUpload($strTarget, $arrSource["tmp_name"])) { //upload was successfull. try to sync the downloads-archive. if ($objDownloadfolder != null && $objDownloadfolder instanceof class_module_mediamanager_file) { class_module_mediamanager_file::syncRecursive($objDownloadfolder->getSystemid(), $objDownloadfolder->getStrFilename()); } else { $objFilemanagerRepo->syncRepo(); } $this->flushCompletePagesCache(); if ($bitJsonResponse) { return true; } //reload the site to display the new file if (validateSystemid($this->getParam("portaluploadDlfolder"))) { $this->portalReload(class_link::getLinkPortalHref($this->getPagename(), "", "mediaFolder", "uploadSuccess=1", $this->getParam("portaluploadDlfolder"))); } else { $this->portalReload(class_link::getLinkPortalHref($this->getPagename(), "", "", $this->getAction(), "uploadSuccess=1", $this->getSystemid())); } } else { $strReturn .= $this->uploadForm($this->getLang("portaluploadCopyUploadError")); } } else { @unlink($arrSource["tmp_name"]); $strReturn .= $this->uploadForm($this->getLang("portaluploadFilterError")); } } else { $strReturn .= $this->uploadForm($this->getLang("portaluploadNotWritableError")); } } else { $strReturn .= $this->getLang("commons_error_permissions"); } return $strReturn; }
/** * Adds an image to the current page. * * @param string $strImage * @param int $intX * @param int $intY * @param int $intWidth * @param int $intHeight * * @return void */ public function addImage($strImage, $intX, $intY, $intWidth = 0, $intHeight = 0) { $strFilename = uniStrtolower(basename($strImage)); if (uniStrpos($strFilename, ".svg") !== false) { $this->objPdf->ImageSVG(_realpath_ . $strImage, $intX, $intY, $intWidth, $intHeight); } else { $this->objPdf->Image(_realpath_ . $strImage, $intX, $intY, $intWidth, $intHeight); } }
/** * Looks up the MIME-Type fot the passed filename * * @param string $strFilename * * @return array[type, suffix, icon] */ public function mimeType($strFilename) { $arrMime = array(); $arrMime["doc"] = array("application/msword", "doc", "icon_word"); $arrMime["xls"] = array("application/msexcel", "xls", "icon_excel"); $arrMime["bin"] = array("application/octet-stream", "bin", "icon_binary"); $arrMime["dms"] = array("application/octet-stream", "dms", "icon_binary"); $arrMime["lha"] = array("application/octet-stream", "lha", "icon_binary"); $arrMime["lzh"] = array("application/octet-stream", "lzh", "icon_binary"); $arrMime["exe"] = array("application/octet-stream", "exe", "icon_binary"); $arrMime["class"] = array("application/octet-stream", "class", "icon_binary"); $arrMime["so"] = array("application/octet-stream", "so", "icon_binary"); $arrMime["dll"] = array("application/octet-stream", "dll", "icon_binary"); $arrMime["dmg"] = array("application/octet-stream", "dmg", "icon_binary"); $arrMime["oda"] = array("application/oda", "oda", "icon_binary"); $arrMime["ogg"] = array("application/ogg", "ogg", "icon_binary"); $arrMime["pdf"] = array("application/pdf", "pdf", "icon_binary"); $arrMime["ai"] = array("application/postscript", "ai", "icon_binary"); $arrMime["eps"] = array("application/postscript", "eps", "icon_binary"); $arrMime["ps"] = array("application/postscript", "ps", "icon_binary"); $arrMime["rdf"] = array("application/rdf+xml", "rdf", "icon_binary"); $arrMime["vxml"] = array("application/voicexml+xml", "vxml", "icon_binary"); $arrMime["vcd"] = array("application/x-cdlink", "vcd", "icon_binary"); $arrMime["dcr"] = array("application/x-director", "dcr", "icon_binary"); $arrMime["dir"] = array("application/x-director", "dir", "icon_binary"); $arrMime["dxr"] = array("application/x-director", "dxr", "icon_binary"); $arrMime["dvi"] = array("application/x-dvi", "dvi", "icon_binary"); $arrMime["js"] = array("application/x-javascript", "js", "icon_binary"); $arrMime["latex"] = array("application/x-latex", "latex", "icon_binary"); $arrMime["swf"] = array("application/x-shockwave-flash", "swf", "icon_binary"); $arrMime["sit"] = array("application/x-stuffit", "sit", "icon_binary"); $arrMime["tar"] = array("application/x-tar", "tar", "icon_binary"); $arrMime["tcl"] = array("application/x-tcl", "tcl", "icon_binary"); $arrMime["tex"] = array("application/x-tex", "tex", "icon_binary"); $arrMime["texinfo"] = array("application/x-texinfo", "texinfo", "icon_binary"); $arrMime["texi"] = array("application/x-texinfo", "texi", "icon_binary"); $arrMime["xhtml"] = array("application/xhtml+xml", "xhtml", "icon_binary"); $arrMime["xht"] = array("application/xhtml+xml", "xht", "icon_binary"); $arrMime["xslt"] = array("application/xslt+xml", "xslt", "icon_binary"); $arrMime["xml"] = array("application/xml", "xml", "icon_binary"); $arrMime["xsl"] = array("application/xml", "xsl", "icon_binary"); $arrMime["dtd"] = array("application/xml-dtd", "dtd", "icon_binary"); $arrMime["zip"] = array("application/zip", "zip", "icon_binary"); $arrMime["mid"] = array("audio/midi", "mid", "icon_sound"); $arrMime["midi"] = array("audio/midi", "midi", "icon_sound"); $arrMime["kar"] = array("audio/midi", "kar", "icon_sound"); $arrMime["mpga"] = array("audio/mpeg", "mpga", "icon_sound"); $arrMime["mp2"] = array("audio/mpeg", "mp2", "icon_sound"); $arrMime["mp3"] = array("audio/mpeg", "mp3", "icon_sound"); $arrMime["aif"] = array("audio/x-aiff", "aif", "icon_sound"); $arrMime["aiff"] = array("audio/x-aiff", "aiff", "icon_sound"); $arrMime["aifc"] = array("audio/x-aiff", "aifc", "icon_sound"); $arrMime["m3u"] = array("audio/x-mpegurl", "m3u", "icon_sound"); $arrMime["ram"] = array("audio/x-pn-realaudio", "ram", "icon_sound"); $arrMime["ra"] = array("audio/x-pn-realaudio", "ra", "icon_sound"); $arrMime["rm"] = array("application/vnd.rn-realmedia", "rm", "icon_sound"); $arrMime["wav"] = array("audio/x-wav", "wav", "icon_sound"); $arrMime["bmp"] = array("image/bmp", "bmp", "icon_image"); $arrMime["cgm"] = array("image/cgm", "cgm", "icon_image"); $arrMime["gif"] = array("image/gif", "gif", "icon_image"); $arrMime["ief"] = array("image/ief", "ief", "icon_image"); $arrMime["jpeg"] = array("image/jpeg", "jpeg", "icon_image"); $arrMime["jpg"] = array("image/jpeg", "jpg", "icon_image"); $arrMime["jpe"] = array("image/jpeg", "jpe", "icon_image"); $arrMime["png"] = array("image/png", "png", "icon_image"); $arrMime["svg"] = array("image/svg+xml", "svg", "icon_image"); $arrMime["tiff"] = array("image/tiff", "tiff", "icon_image"); $arrMime["tif"] = array("image/tiff", "tif", "icon_image"); $arrMime["djvu"] = array("image/vnd.djvu", "djvu", "icon_image"); $arrMime["djv"] = array("image/vnd.djvu", "djv", "icon_image"); $arrMime["wbmp"] = array("image/vnd.wap.wbmp", "wbmp", "icon_image"); $arrMime["pnm"] = array("image/x-portable-anymap", "pnm", "icon_image"); $arrMime["pbm"] = array("image/x-portable-bitmap", "pbm", "icon_image"); $arrMime["pgm"] = array("image/x-portable-graymap", "pgm", "icon_image"); $arrMime["ppm"] = array("image/x-portable-pixmap", "ppm", "icon_image"); $arrMime["rgb"] = array("image/x-rgb", "rgb", "icon_image"); $arrMime["xbm"] = array("image/x-xbitmap", "xbm", "icon_image"); $arrMime["xpm"] = array("image/x-xpixmap", "xpm", "icon_image"); $arrMime["xwd"] = array("image/x-xwindowdump", "xwd", "icon_image"); $arrMime["ics"] = array("text/calendar", "ics", "icon_text"); $arrMime["ifb"] = array("text/calendar", "ifb", "icon_text"); $arrMime["css"] = array("text/css", "css", "icon_text"); $arrMime["html"] = array("text/html", "html", "icon_text"); $arrMime["htm"] = array("text/html", "htm", "icon_text"); $arrMime["asc"] = array("text/plain", "asc", "icon_text"); $arrMime["txt"] = array("text/plain", "txt", "icon_text"); $arrMime["php"] = array("text/php", "php", "icon_text"); $arrMime["rtx"] = array("text/richtext", "rtx", "icon_text"); $arrMime["rtf"] = array("text/rtf", "rtf", "icon_text"); $arrMime["sgml"] = array("text/sgml", "sgml", "icon_text"); $arrMime["sgm"] = array("text/sgml", "sgm", "icon_text"); $arrMime["tsv"] = array("text/tab-separated-values", "tsv", "icon_text"); $arrMime["wml"] = array("text/vnd.wap.wml", "wml", "icon_text"); $arrMime["wmls"] = array("text/vnd.wap.wmlscript", "wmls", "icon_text"); $arrMime["etx"] = array("text/x-setext", "etx", "icon_text"); $arrMime["mpeg"] = array("video/mpeg", "mpeg", "icon_movie"); $arrMime["mpg"] = array("video/mpeg", "mpg", "icon_movie"); $arrMime["mpe"] = array("video/mpeg", "mpe", "icon_movie"); $arrMime["qt"] = array("video/quicktime", "qt", "icon_movie"); $arrMime["mov"] = array("video/quicktime", "mov", "icon_movie"); $arrMime["mxu"] = array("video/vnd.mpegurl", "mxu", "icon_movie"); $arrMime["m4u"] = array("video/vnd.mpegurl", "m4u", "icon_movie"); $arrMime["avi"] = array("video/x-msvideo", "avi", "icon_movie"); $arrMime["movie"] = array("video/x-sgi-movie", "movie", "icon_movie"); $arrMime["default"] = array("application/octet-stream", "", "icon_binary"); //Determing the type $strType = ""; if (uniStrpos($strFilename, ".") !== false) { $strType = uniSubstr($strFilename, uniStrrpos($strFilename, ".") + 1); } else { $strType = $strFilename; } $strType = uniStrtolower($strType); //Known Type? if (isset($arrMime[$strType])) { $arrReturn = $arrMime[$strType]; } else { $arrReturn = $arrMime["default"]; $arrReturn[1] = $strType; } return $arrReturn; }
/** * Tries to save the passed file. * Therefore, the following post-params should be given: * action = fileUpload * folder = the folder to store the file within * systemid = the filemanagers' repo-id * inputElement = name of the inputElement * * @return string * @permissions right1 */ protected function actionFileupload() { $strReturn = ""; /** @var class_module_mediamanager_repo|class_module_mediamanager_file $objFile */ $objFile = class_objectfactory::getInstance()->getObject($this->getSystemid()); /** * @var class_module_mediamanager_repo */ $objRepo = null; if ($objFile instanceof class_module_mediamanager_file) { $strFolder = $objFile->getStrFilename(); if (!$objFile->rightEdit() || $objFile->getIntType() != class_module_mediamanager_file::$INT_TYPE_FOLDER) { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_UNAUTHORIZED); $strReturn .= "<message><error>" . xmlSafeString($this->getLang("commons_error_permissions")) . "</error></message>"; return $strReturn; } $objRepo = class_objectfactory::getInstance()->getObject($objFile->getPrevId()); while (!$objRepo instanceof class_module_mediamanager_repo) { $objRepo = class_objectfactory::getInstance()->getObject($objRepo->getPrevId()); } } elseif ($objFile instanceof class_module_mediamanager_repo) { $objRepo = $objFile; $strFolder = $objFile->getStrPath(); if (!$objFile->rightEdit()) { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_UNAUTHORIZED); $strReturn .= "<message><error>" . xmlSafeString($this->getLang("commons_error_permissions")) . "</error></message>"; return $strReturn; } } else { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_UNAUTHORIZED); $strReturn .= "<message><error>" . xmlSafeString($this->getLang("commons_error_permissions")) . "</error></message>"; return $strReturn; } //Handle the fileupload $arrSource = $this->getParam($this->getParam("inputElement")); $bitJsonResponse = $this->getParam("jsonResponse") != ""; $bitPostData = false; if (is_array($arrSource)) { $strFilename = $arrSource["name"]; } else { $bitPostData = getPostRawData() != ""; $strFilename = $arrSource; } $strTarget = $strFolder . "/" . createFilename($strFilename); $objFilesystem = new class_filesystem(); if (!file_exists(_realpath_ . "/" . $strFolder)) { $objFilesystem->folderCreate($strFolder, true); } if ($objFilesystem->isWritable($strFolder)) { //Check file for correct filters $arrAllowed = explode(",", $objRepo->getStrUploadFilter()); $strSuffix = uniStrtolower(uniSubstr($strFilename, uniStrrpos($strFilename, "."))); if ($objRepo->getStrUploadFilter() == "" || in_array($strSuffix, $arrAllowed)) { if ($bitPostData) { $objFilesystem = new class_filesystem(); $objFilesystem->openFilePointer($strTarget); $bitCopySuccess = $objFilesystem->writeToFile(getPostRawData()); $objFilesystem->closeFilePointer(); } else { $bitCopySuccess = $objFilesystem->copyUpload($strTarget, $arrSource["tmp_name"]); } if ($bitCopySuccess) { if ($bitJsonResponse) { $strReturn = json_encode(array('success' => true)); } else { $strReturn .= "<message>" . $this->getLang("xmlupload_success") . "</message>"; } class_logger::getInstance()->addLogRow("uploaded file " . $strTarget, class_logger::$levelInfo); $objRepo->syncRepo(); } else { if ($bitJsonResponse) { $strReturn .= json_encode(array('error' => $this->getLang("xmlupload_error_copyUpload"))); } else { $strReturn .= "<message><error>" . $this->getLang("xmlupload_error_copyUpload") . "</error></message>"; } } } else { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_BADREQUEST); if ($bitJsonResponse) { $strReturn .= json_encode(array('error' => $this->getLang("xmlupload_error_filter"))); } else { $strReturn .= "<message><error>" . $this->getLang("xmlupload_error_filter") . "</error></message>"; } } } else { class_response_object::getInstance()->setStrStatusCode(class_http_statuscodes::SC_INTERNAL_SERVER_ERROR); if ($bitJsonResponse) { $strReturn .= json_encode(array('error' => $this->getLang("xmlupload_error_notWritable"))); } else { $strReturn .= "<message><error>" . xmlSafeString($this->getLang("xmlupload_error_notWritable")) . "</error></message>"; } } if ($bitJsonResponse) { //disabled for ie. otherwise the upload won't work due to the headers. class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_HTML); //class_response_object::getInstance()->setStResponseType(class_http_responsetypes::STR_TYPE_JSON); } @unlink($arrSource["tmp_name"]); return $strReturn; }
/** * Calls the single search-functions, sorts the results an creates the output * * @return string * @permissions view */ protected function actionSearch() { $strReturn = ""; //Read the config $arrTemplate = array(); $arrTemplate["hitlist"] = ""; $strReturn .= $this->actionList(); $objSearchCommons = new class_module_search_commons(); $this->objSearchSearch->setBitPortalObjectFilter(true); $this->objSearchSearch->setStrPortalLangFilter($this->getStrPortalLanguage()); /** @var $arrHitsSorted class_search_result[] */ $arrHitsSorted = $objSearchCommons->doPortalSearch($this->objSearchSearch); //Resize Array to wanted size $arrHitsFilter = $this->objToolkit->pager($this->arrElementData["search_amount"], $this->getParam("pv") != "" ? (int) $this->getParam("pv") : 1, $this->getLang("commons_next"), $this->getLang("commons_back"), "search", $this->arrElementData["search_page"] != "" ? $this->arrElementData["search_page"] : $this->getPagename(), $arrHitsSorted, "&searchterm=" . urlencode(html_entity_decode($this->objSearchSearch->getStrQuery(), ENT_COMPAT, "UTF-8"))); $strRowTemplateID = $this->objTemplate->readTemplate("/module_search/" . $this->arrElementData["search_template"], "search_hitlist_hit"); /** @var $objHit class_search_result */ foreach ($arrHitsFilter["arrData"] as $objHit) { if ($objHit->getStrPagename() == "master") { continue; } $objPage = class_module_pages_page::getPageByName($objHit->getStrPagename()); if ($objPage === null || !$objPage->rightView() || $objPage->getIntRecordStatus() != 1) { continue; } $arrRow = array(); if ($objHit->getStrPagelink() == "") { $arrRow["page_link"] = getLinkPortal($objHit->getStrPagename(), "", "_self", $objHit->getStrPagename(), "", "&highlight=" . urlencode(html_entity_decode($this->objSearchSearch->getStrQuery(), ENT_QUOTES, "UTF-8")) . "#" . uniStrtolower(urlencode(html_entity_decode($this->objSearchSearch->getStrQuery(), ENT_QUOTES, "UTF-8")))); } else { $arrRow["page_link"] = $objHit->getStrPagelink(); } $arrRow["page_description"] = uniStrTrim($objHit->getStrDescription(), 200); $arrTemplate["hitlist"] .= $this->objTemplate->fillTemplate($arrRow, $strRowTemplateID, false); } //Collect global data $arrTemplate["search_term"] = $this->objSearchSearch->getStrQuery(); $arrTemplate["search_nrresults"] = count($arrHitsSorted); $arrTemplate["link_forward"] = $arrHitsFilter["strForward"]; $arrTemplate["link_back"] = $arrHitsFilter["strBack"]; $arrTemplate["link_overview"] = $arrHitsFilter["strPages"]; $strTemplateID = $this->objTemplate->readTemplate("/module_search/" . $this->arrElementData["search_template"], "search_hitlist"); return $strReturn . $this->fillTemplate($arrTemplate, $strTemplateID); }
/** * Queries the packagemanager for the resolved target path, so the folder to package will be located at * after installation (or is already located at since it's already installed. * * @return mixed */ public function getStrTargetPath() { $strTarget = $this->objMetadata->getStrTarget(); if ($strTarget == "") { $strTarget = uniStrtolower(createFilename($this->objMetadata->getStrTitle(), true)); } return "/templates/" . $strTarget; }
/** * Returns detailed info about a file * * @param string $strFile * * @return mixed */ public function getFileDetails($strFile) { $arrReturn = array(); if (strpos($strFile, _realpath_) === false) { $strFile = _realpath_ . $strFile; } if (is_file($strFile)) { //Filename $arrReturn["filename"] = basename($strFile); //Type $intTemp = uniStrrpos($strFile, "."); if ($intTemp !== false) { $arrReturn["filetype"] = uniSubstr($strFile, $intTemp); } else { $arrReturn["filetype"] = $strFile; } $arrReturn["filetype"] = uniStrtolower($arrReturn["filetype"]); //Size $arrReturn["filesize"] = filesize($strFile); //creatipn $arrReturn["filecreation"] = filemtime($strFile); //change $arrReturn["filechange"] = filectime($strFile); //access $arrReturn["fileaccess"] = fileatime($strFile); //path $arrReturn["filepath"] = $strFile; } return $arrReturn; }
/** * Loads the feed and displays it * * @return string the prepared html-output */ public function loadData() { $strReturn = ""; $strFeed = ""; try { $objRemoteloader = new class_remoteloader(); if (uniStrtolower(uniSubstr($this->arrElementData["char2"], 0, 8)) == "https://") { $objRemoteloader->setStrProtocolHeader("https://"); } $this->arrElementData["char2"] = uniStrReplace("&", "&", $this->arrElementData["char2"]); $objRemoteloader->setStrHost(uniStrReplace(array("http://", "https://"), "", $this->arrElementData["char2"])); $objRemoteloader->setIntPort(0); $strFeed = $objRemoteloader->getRemoteContent(); } catch (class_exception $objExeption) { $strFeed = ""; } $strFeedTemplateID = $this->objTemplate->readTemplate("/element_rssfeed/" . $this->arrElementData["char1"], "rssfeed_feed"); $strPostTemplateID = $this->objTemplate->readTemplate("/element_rssfeed/" . $this->arrElementData["char1"], "rssfeed_post"); $strContent = ""; $arrTemplate = array(); if (uniStrlen($strFeed) == 0) { $strContent = $this->getLang("rssfeed_errorloading"); } else { $objXmlparser = new class_xml_parser(); $objXmlparser->loadString($strFeed); $arrFeed = $objXmlparser->xmlToArray(); if (count($arrFeed) >= 1) { //rss feed if (isset($arrFeed["rss"])) { $arrTemplate["feed_title"] = $arrFeed["rss"][0]["channel"][0]["title"][0]["value"]; $arrTemplate["feed_link"] = $arrFeed["rss"][0]["channel"][0]["link"][0]["value"]; $arrTemplate["feed_description"] = $arrFeed["rss"][0]["channel"][0]["description"][0]["value"]; $intCounter = 0; if (isset($arrFeed["rss"][0]["channel"][0]["item"]) && is_array($arrFeed["rss"][0]["channel"][0]["item"])) { foreach ($arrFeed["rss"][0]["channel"][0]["item"] as $arrOneItem) { $strDate = isset($arrOneItem["pubDate"][0]["value"]) ? $arrOneItem["pubDate"][0]["value"] : ""; if ($strDate != "") { $intDate = strtotime($strDate); if ($intDate > 0) { $strDate = timeToString($intDate); } } $arrMessage = array(); $arrMessage["post_date"] = $strDate; $arrMessage["post_title"] = isset($arrOneItem["title"][0]["value"]) ? $arrOneItem["title"][0]["value"] : ""; $arrMessage["post_description"] = isset($arrOneItem["description"][0]["value"]) ? $arrOneItem["description"][0]["value"] : ""; $arrMessage["post_link"] = isset($arrOneItem["link"][0]["value"]) ? $arrOneItem["link"][0]["value"] : ""; $strContent .= $this->fillTemplate($arrMessage, $strPostTemplateID); if (++$intCounter >= $this->arrElementData["int1"]) { break; } } } else { $strContent = $this->getLang("rssfeed_noentry"); } } //atom feed if (isset($arrFeed["feed"]) && isset($arrFeed["feed"][0]["entry"])) { $arrTemplate["feed_title"] = $arrFeed["feed"][0]["title"][0]["value"]; $arrTemplate["feed_link"] = $arrFeed["feed"][0]["link"][0]["attributes"]["href"]; $arrTemplate["feed_description"] = $arrFeed["feed"][0]["subtitle"][0]["value"]; $intCounter = 0; if (isset($arrFeed["feed"][0]["entry"]) && is_array($arrFeed["feed"][0]["entry"])) { foreach ($arrFeed["feed"][0]["entry"] as $arrOneItem) { $strDate = isset($arrOneItem["updated"][0]["value"]) ? $arrOneItem["updated"][0]["value"] : ""; if ($strDate != "") { $intDate = strtotime($strDate); if ($intDate > 0) { $strDate = timeToString($intDate); } } $arrMessage = array(); $arrMessage["post_date"] = $strDate; $arrMessage["post_title"] = isset($arrOneItem["title"][0]["value"]) ? $arrOneItem["title"][0]["value"] : ""; $arrMessage["post_description"] = isset($arrOneItem["summary"][0]["value"]) ? $arrOneItem["summary"][0]["value"] : ""; $arrMessage["post_link"] = isset($arrOneItem["link"][0]["attributes"]["href"]) ? $arrOneItem["link"][0]["attributes"]["href"] : ""; $strContent .= $this->fillTemplate($arrMessage, $strPostTemplateID); if (++$intCounter >= $this->arrElementData["int1"]) { break; } } } else { $strContent = $this->getLang("rssfeed_noentry"); } } } else { $strContent = $this->getLang("rssfeed_errorparsing"); } } $arrTemplate["feed_content"] = $strContent; $strReturn .= $this->fillTemplate($arrTemplate, $strFeedTemplateID); return $strReturn; }
/** * Saves an image to the filesystem * * @param string $strTarget * @param bool $bitCache * @param int $intJpegQuality * * @return bool */ public function saveImage($strTarget = "", $bitCache = false, $intJpegQuality = 90) { $bitReturn = false; if ($this->bitNeedToSave) { if (!is_numeric($intJpegQuality) || $intJpegQuality < 0) { $intJpegQuality = 90; } if ($strTarget != "") { $strTarget = removeDirectoryTraversals($strTarget); } if ($bitCache) { $this->generateCachename(); $strTarget = $this->strCachepath . $this->strCachename; } //get file type if ($strTarget != "") { $strType = uniSubstr($strTarget, uniStrrpos($strTarget, ".")); } else { $strType = $this->strType; } if ($strTarget == "") { $strTarget = "/" . $this->strCachepath . $this->generateCachename(0, 0, $intJpegQuality); } switch (uniStrtolower($strType)) { case ".jpg": $bitReturn = imagejpeg($this->objImage, _realpath_ . $strTarget, $intJpegQuality); break; case ".png": $bitReturn = imagepng($this->objImage, _realpath_ . $strTarget); break; case ".gif": $bitReturn = imagegif($this->objImage, _realpath_ . $strTarget); break; } } else { $bitReturn = true; } if (!$bitReturn) { class_logger::getInstance()->addLogRow("error saving file to " . $strTarget, class_logger::$levelWarning); } return $bitReturn; }
/** * @see interface_admin_systemtask::getSubmitParams() * @return string */ public function getSubmitParams() { $arrFile = $this->getParam("pageimport_file"); $strError = ""; $objFilesystem = new class_filesystem(); $strTarget = "/import_" . generateSystemid() . ".xml"; $strSuffix = uniStrtolower(uniSubstr($arrFile["name"], uniStrrpos($arrFile["name"], "."))); if ($strSuffix == ".xml") { if ($objFilesystem->copyUpload($strTarget, $arrFile["tmp_name"])) { class_logger::getInstance()->addLogRow("uploaded file " . $strTarget, class_logger::$levelInfo); } else { $strError = "upload"; } } else { $strError = "suffix"; } return "&pageimport_file=" . $strTarget . "&pageimport_error=" . $strError . "&pageimport_replace=" . $this->getParam("pageimport_replace"); }
/** * Returns the file extension for a file (including the dot). * * @param string $strPath * * @return string */ function getFileExtension($strPath) { return uniStrtolower(uniSubstr($strPath, uniStrrpos($strPath, "."))); }
/** * Called whenever a update-request was fired. * Use this method to synchronize the current object with the database. * Use only updates, inserts are not required to be implemented. * Provides a default implementation based on the current objects column mappings. * Override this method whenever you want to perform additional actions or escaping. * * @throws class_exception * @return bool */ public function updateStateToDb() { if (!validateSystemid($this->getObjObject()->getSystemid()) || !$this->hasTargetTable()) { return true; } //fetch properties with annotations $objReflection = new class_reflection($this->getObjObject()); $arrTargetTables = $objReflection->getAnnotationValuesFromClass(class_orm_base::STR_ANNOTATION_TARGETTABLE); if (count($arrTargetTables) == 0) { //no table mapping found - skip return true; } $bitReturn = true; foreach ($arrTargetTables as $strOneTable) { $arrTableDef = explode(".", $strOneTable); //scan all properties $arrColValues = array(); $arrEscapes = array(); //get the mapped properties $arrProperties = $objReflection->getPropertiesWithAnnotation(class_orm_base::STR_ANNOTATION_TABLECOLUMN); foreach ($arrProperties as $strPropertyName => $strColumn) { //check if there are table annotation available $arrColumnDef = explode(".", $strColumn); //if the column doesn't declare a target table whereas the class defines more then one - skip it. if (count($arrColumnDef) == 1 && count($arrTargetTables) > 1) { throw new class_orm_exception("property " . $strPropertyName . " declares no target table, class " . get_class($this->getObjObject()) . " declares more than one target table.", class_exception::$level_FATALERROR); } //skip if property targets another table if (count($arrColumnDef) == 2 && $arrColumnDef[0] != $arrTableDef[0]) { continue; } if (count($arrColumnDef) == 2) { $strColumn = $arrColumnDef[1]; } //all prerequisites match, start creating query $strGetter = $objReflection->getGetter($strPropertyName); if ($strGetter !== null) { //explicit casts required? could be relevant, depending on the target column type / database system $mixedValue = call_user_func(array($this->getObjObject(), $strGetter)); if ($mixedValue !== null && (uniStrtolower(uniSubstr($strGetter, 0, 6)) == "getint" || uniStrtolower(uniSubstr($strGetter, 0, 6)) == "getbit")) { //different casts on 32bit / 64bit if ($mixedValue > PHP_INT_MAX) { $mixedValue = (double) $mixedValue; } else { $mixedValue = (int) $mixedValue; } } $arrColValues[$strColumn] = $mixedValue; $arrEscapes[] = !$objReflection->hasPropertyAnnotation($strPropertyName, class_orm_base::STR_ANNOTATION_BLOCKESCAPING); } } //update table if (count($arrColValues) > 0) { $bitReturn = $bitReturn && $this->updateSingleTable($arrColValues, $arrEscapes, $arrTableDef[0], $arrTableDef[1]); } } //see, if we should process object lists, too if ($bitReturn) { $bitReturn = $this->updateAssignments(); } if ($this->getObjObject() instanceof interface_versionable) { $objChanges = new class_module_system_changelog(); $objChanges->createLogEntry($this->getObjObject(), class_module_system_changelog::$STR_ACTION_EDIT); } return $bitReturn; }
public function stringToPlaceholder($strText) { $strReturn = ""; $strLastChar = ""; for ($i = 0; $i < uniStrlen($strText); $i++) { $strChar = uniSubstr($strText, $i, 1); $strCharLower = uniStrtolower($strChar); if ($i > 0 && $strChar != $strCharLower && $strLastChar != "_") { $strReturn .= "_" . $strCharLower; } else { $strReturn .= $strCharLower; } $strLastChar = $strChar; } return $strReturn; }
/** * Returns the list of top-queries * * @return mixed */ public function getTopQueries() { //Load all records in the passed interval $arrBlocked = explode(",", class_module_system_setting::getConfigValue("_stats_exclusionlist_")); $arrParams = array($this->intDateStart, $this->intDateEnd); $strExclude = ""; foreach ($arrBlocked as $strBlocked) { if ($strBlocked != "") { $strExclude .= " AND stats_referer NOT LIKE ? \n"; $arrParams[] = "%" . str_replace("%", "\\%", $strBlocked) . "%"; } } $strQuery = "SELECT stats_referer\n\t\t\t\t\t\tFROM " . _dbprefix_ . "stats_data\n\t\t\t\t\t\tWHERE stats_date > ?\n\t\t\t\t\t\t AND stats_date <= ?\n\t\t\t\t\t\t AND stats_referer != ''\n\t\t\t\t\t\t AND stats_referer IS NOT NULL\n\t\t\t\t\t\t " . $strExclude . "\n\t\t\t\t\t\tORDER BY stats_date desc"; $arrRecords = $this->objDB->getPArray($strQuery, $arrParams); $arrHits = array(); //Suchpatterns: q=, query= $arrQuerypatterns = array("q=", "query="); foreach ($arrRecords as $arrOneRecord) { foreach ($arrQuerypatterns as $strOnePattern) { if (uniStrpos($arrOneRecord["stats_referer"], $strOnePattern) !== false) { $strQueryterm = uniSubstr($arrOneRecord["stats_referer"], uniStrpos($arrOneRecord["stats_referer"], $strOnePattern) + uniStrlen($strOnePattern)); $strQueryterm = uniSubstr($strQueryterm, 0, uniStrpos($strQueryterm, "&")); $strQueryterm = uniStrtolower(trim(urldecode($strQueryterm))); if ($strQueryterm != "") { if (isset($arrHits[$strQueryterm])) { $arrHits[$strQueryterm]++; } else { $arrHits[$strQueryterm] = 1; } } break; } } } arsort($arrHits); return $arrHits; }
/** * Make it lower, baby... * @return void */ private function lowerize() { $this->setText(uniStrtolower($this->getText())); }
/** * Parses the xml-document and sets the internal properties. * * @param string $strXmlDocument * @return void */ private function parseXMLDocument($strXmlDocument) { $objXml = new class_xml_parser(); $objXml->loadString($strXmlDocument); $arrXml = $objXml->xmlToArray(); $this->setStrTitle($arrXml["package"]["0"]["title"]["0"]["value"]); $this->setStrDescription($arrXml["package"]["0"]["description"]["0"]["value"]); $this->setStrVersion($arrXml["package"]["0"]["version"]["0"]["value"]); $this->setStrAuthor($arrXml["package"]["0"]["author"]["0"]["value"]); if (isset($arrXml["package"]["0"]["target"]["0"]["value"])) { $this->setStrTarget($arrXml["package"]["0"]["target"]["0"]["value"]); } $this->setStrType($arrXml["package"]["0"]["type"]["0"]["value"]); $this->setBitProvidesInstaller($arrXml["package"]["0"]["providesInstaller"]["0"]["value"] == "TRUE"); if (is_array($arrXml["package"]["0"]["requiredModules"])) { foreach ($arrXml["package"]["0"]["requiredModules"] as $arrModules) { if (!is_array($arrModules)) { continue; } foreach ($arrModules as $arrTempModule) { if (!is_array($arrTempModule)) { continue; } foreach ($arrTempModule as $arrOneModule) { if (isset($arrOneModule["attributes"]["name"])) { $strModule = $arrOneModule["attributes"]["name"]; $strVersion = $arrOneModule["attributes"]["version"]; $this->arrRequiredModules[$strModule] = $strVersion; } } } } } if (isset($arrXml["package"]["0"]["screenshots"]) && is_array($arrXml["package"]["0"]["screenshots"])) { foreach ($arrXml["package"]["0"]["screenshots"] as $arrScreenshots) { if (!is_array($arrScreenshots)) { continue; } foreach ($arrScreenshots as $arrTempImage) { if (!is_array($arrTempImage)) { continue; } foreach ($arrTempImage as $arrOneImage) { if (isset($arrOneImage["attributes"]["path"])) { $strImage = $arrOneImage["attributes"]["path"]; if (in_array(uniStrtolower(uniSubstr($strImage, -4)), array(".jpg", ".jpeg", ".gif", ".png"))) { $this->arrScreenshots[] = $strImage; } } } } } } }
/** * @param string $strName * @return void */ public function setStrName($strName) { //make a valid pagename $strName = uniStrtolower(urlSafeString($strName)); $this->strName = $strName; }
/** * Queries the packagemanager for the resolved target path, so the folder to package will be located at * after installation (or is already located at since it's already installed. * * @return mixed */ public function getStrTargetPath() { $strTarget = $this->objMetadata->getStrTarget(); if ($strTarget == "") { $strTarget = uniStrtolower($this->objMetadata->getStrType() . "_" . createFilename($this->objMetadata->getStrTitle(), true)); } $arrModules = array_flip(class_resourceloader::getInstance()->getArrModules()); if (isset($arrModules[$strTarget])) { return "/" . $arrModules[$strTarget]; } return "/core/" . $strTarget; }
/** * @return string */ public function getStrPageI() { return uniStrtolower($this->strPageI); }
/** * Returns ALL tables in the database currently connected to * * @return mixed */ public function getTables() { $arrTemp = $this->getPArray("SELECT table_name AS name FROM ALL_TABLES", array()); foreach ($arrTemp as $intKey => $strValue) { $arrTemp[$intKey]["name"] = uniStrtolower($strValue["name"]); } return $arrTemp; }
private function getValueForAnnotations(&$strPrefix, &$arrDepends) { $objReflection = new class_reflection($this->getObjSourceObject()); //try to find the matching source property $arrProperties = $objReflection->getPropertiesWithAnnotation(self::STR_VALUE_ANNOTATION); $strSourceProperty = null; foreach ($arrProperties as $strPropertyName => $strValue) { if (uniSubstr(uniStrtolower($strPropertyName), uniStrlen($this->getStrSourceProperty()) * -1) == $this->getStrSourceProperty()) { $strSourceProperty = $strPropertyName; } } if ($strSourceProperty == null) { return; } $strPrefix = trim($objReflection->getAnnotationValueForProperty($strSourceProperty, self::STR_VALUE_ANNOTATION)); $strDependant = trim($objReflection->getAnnotationValueForProperty($strSourceProperty, self::STR_DEPENDS_ANNOTATION)); $arrDepends = explode(" ", $strDependant); array_walk($arrDepends, function (&$strValue) { $strValue = trim($strValue); }); }