/**
  * 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);
     }
 }
Пример #3
0
 private function writeToHistoryArray($strSessionKey)
 {
     $strQueryString = getServer("QUERY_STRING");
     //Clean querystring of empty actions
     if (uniSubstr($strQueryString, -8) == "&action=") {
         $strQueryString = substr_replace($strQueryString, "", -8);
     }
     //Just do s.th., if not in the rights-mgmt
     if (uniStrpos($strQueryString, "module=right") !== false) {
         return;
     }
     $arrHistory = $this->objSession->getSession($strSessionKey);
     //And insert just, if different to last entry
     if ($strQueryString == $this->getHistoryEntry(0, $strSessionKey)) {
         return;
     }
     //If we reach up here, we can enter the current query
     if ($arrHistory !== false) {
         array_unshift($arrHistory, $strQueryString);
         while (count($arrHistory) > 10) {
             array_pop($arrHistory);
         }
     } else {
         $arrHistory = array($strQueryString);
     }
     //saving the new array to session
     $this->objSession->setSession($strSessionKey, $arrHistory);
 }
Пример #4
0
 /**
  * @param interface_admin|interface_portal $objViewInstance
  */
 private function runSingleFile($objViewInstance)
 {
     $objReflection = new ReflectionClass($objViewInstance);
     $arrMethods = $objReflection->getMethods();
     $objAnnotations = new class_reflection(get_class($objViewInstance));
     //collect the autotestable annotations located on class-level
     foreach ($objAnnotations->getAnnotationValuesFromClass("@autoTestable") as $strValue) {
         foreach (explode(",", $strValue) as $strOneMethod) {
             echo "found method " . get_class($objViewInstance) . "@" . $strOneMethod . " marked as class-based @autoTestable, preparing call\n";
             echo "   calling via action() method\n";
             $objViewInstance->action($strOneMethod);
         }
     }
     /** @var ReflectionMethod $objOneMethod */
     foreach ($arrMethods as $objOneMethod) {
         if ($objAnnotations->hasMethodAnnotation($objOneMethod->getName(), "@autoTestable")) {
             echo "found method " . get_class($objViewInstance) . "@" . $objOneMethod->getName() . " marked as @autoTestable, preparing call\n";
             if (uniSubstr($objOneMethod->getName(), 0, 6) == "action" && $objReflection->hasMethod("action")) {
                 echo "   calling via action() method\n";
                 $objViewInstance->action(uniSubstr($objOneMethod->getName(), 6));
             } else {
                 echo "   direct call";
                 $objOneMethod->invoke($objViewInstance);
             }
         }
     }
 }
Пример #5
0
 /**
  * This method returns all plugins registered for the current extension point searching at the predefined path.
  * By default, new instances of the classes are returned. If the implementing
  * class requires specific constructor arguments, pass them as the second argument and they will be
  * used during instantiation.
  *
  * @param array $arrConstructorArguments
  *
  * @static
  * @return interface_generic_plugin[]
  */
 public function getPlugins($arrConstructorArguments = array())
 {
     //load classes in passed-folders
     $strKey = md5($this->strSearchPath . $this->strPluginPoint);
     if (!array_key_exists($strKey, self::$arrPluginClasses)) {
         $strPluginPoint = $this->strPluginPoint;
         $arrClasses = class_resourceloader::getInstance()->getFolderContent($this->strSearchPath, array(".php"), false, function ($strOneFile) use($strPluginPoint) {
             $strOneFile = uniSubstr($strOneFile, 0, -4);
             if (uniStripos($strOneFile, "class_") === false || uniStrpos($strOneFile, "class_testbase") !== false) {
                 return false;
             }
             $objReflection = new ReflectionClass($strOneFile);
             if (!$objReflection->isAbstract() && $objReflection->implementsInterface("interface_generic_plugin")) {
                 $objMethod = $objReflection->getMethod("getExtensionName");
                 if ($objMethod->invoke(null) == $strPluginPoint) {
                     return true;
                 }
             }
             return false;
         }, function (&$strOneFile) {
             $strOneFile = uniSubstr($strOneFile, 0, -4);
         });
         self::$arrPluginClasses[$strKey] = $arrClasses;
     }
     $arrReturn = array();
     foreach (self::$arrPluginClasses[$strKey] as $strOneClass) {
         $objReflection = new ReflectionClass($strOneClass);
         if (count($arrConstructorArguments) > 0) {
             $arrReturn[] = $objReflection->newInstanceArgs($arrConstructorArguments);
         } else {
             $arrReturn[] = $objReflection->newInstance();
         }
     }
     return $arrReturn;
 }
 /**
  * Invokes the installer, if given.
  * The installer itself is capable of detecting whether an update or a plain installation is required.
  *
  * @throws class_exception
  * @return string
  */
 public function installOrUpdate()
 {
     $strReturn = "";
     if (uniStrpos($this->getObjMetadata()->getStrPath(), "core") === false) {
         throw new class_exception("Current module not located at /core*.", class_exception::$level_ERROR);
     }
     if (!$this->isInstallable()) {
         throw new class_exception("Current module isn't installable, not all requirements are given", class_exception::$level_ERROR);
     }
     //search for an existing installer
     $objFilesystem = new class_filesystem();
     $arrInstaller = $objFilesystem->getFilelist($this->objMetadata->getStrPath() . "/installer/", array(".php"));
     if ($arrInstaller === false) {
         $strReturn .= "Updating default template pack...\n";
         $this->updateDefaultTemplate();
         class_cache::flushCache();
         return $strReturn;
     }
     //proceed with elements
     foreach ($arrInstaller as $strOneInstaller) {
         //skip samplecontent files
         if (uniStrpos($strOneInstaller, "element") !== false) {
             class_logger::getInstance(class_logger::PACKAGEMANAGEMENT)->addLogRow("triggering updateOrInstall() on installer " . $strOneInstaller . ", all requirements given", class_logger::$levelInfo);
             //trigger update or install
             $strName = uniSubstr($strOneInstaller, 0, -4);
             /** @var $objInstaller interface_installer */
             $objInstaller = new $strName();
             $strReturn .= $objInstaller->installOrUpdate();
         }
     }
     $strReturn .= "Updating default template pack...\n";
     $this->updateDefaultTemplate();
     return $strReturn;
 }
Пример #7
0
 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();
 }
 /**
  * @return interface_messageprovider[]
  */
 public function getMessageproviders()
 {
     return class_resourceloader::getInstance()->getFolderContent("/system/messageproviders", array(".php"), false, function ($strOneFile) {
         if (uniStrpos($strOneFile, "interface") !== false) {
             return false;
         }
         return true;
     }, function (&$strOneFile) {
         $strOneFile = uniSubstr($strOneFile, 0, -4);
         $strOneFile = new $strOneFile();
     });
 }
Пример #9
0
 /**
  * Calls the scriptlets in order to process additional tags and in order to enrich the content.
  *
  * @param string $strContent the content to process
  * @param int $intContext context-selector used to find the matching scriptlets to apply. if not given, all contexts are applied - worst case!
  *
  * @return string
  * @see interface_scriptlet
  */
 public function processString($strContent, $intContext = null)
 {
     $arrScriptletFiles = class_resourceloader::getInstance()->getFolderContent("/system/scriptlets", array(".php"));
     foreach ($arrScriptletFiles as $strPath => $strOneScriptlet) {
         $strOneScriptlet = uniSubstr($strOneScriptlet, 0, -4);
         /** @var $objScriptlet interface_scriptlet */
         $objScriptlet = new $strOneScriptlet();
         if ($objScriptlet instanceof interface_scriptlet && ($intContext == null || $intContext & $objScriptlet->getProcessingContext())) {
             $strContent = $objScriptlet->processContent($strContent);
             class_logger::getInstance("scriptlets.log")->addLogRow("processing call to " . $strOneScriptlet . ", filter: " . $intContext, class_logger::$levelInfo);
         }
     }
     return $strContent;
 }
 /**
  * Looks up all widgets available in the filesystem.
  * ATTENTION: returns the class-name representation of a file, NOT the filename itself.
  *
  * @return string[]
  */
 public static function getListOfWidgetsAvailable()
 {
     return class_resourceloader::getInstance()->getFolderContent("/admin/widgets/", array(".php"), false, function ($strFilename) {
         if ($strFilename != "interface_adminwidget.php" && $strFilename != "class_adminwidget.php") {
             $strFilename = uniSubstr($strFilename, 0, -4);
             $objReflection = new ReflectionClass($strFilename);
             if (!$objReflection->isAbstract() && $objReflection->implementsInterface("interface_adminwidget")) {
                 return true;
             }
         }
         return false;
     }, function (&$strFilename) {
         $strFilename = uniSubstr($strFilename, 0, -4);
     });
 }
 public function getSystemParameter()
 {
     $strHeaderName = class_config::readPlainConfigsFromFilesystem("https_header");
     $strHeaderValue = strtolower(class_config::readPlainConfigsFromFilesystem("https_header_value"));
     $arrSystemParameter = array();
     $arrSystemParameter["SCHEME"] = isset($_SERVER[$strHeaderName]) && strtolower($_SERVER[$strHeaderName]) == $strHeaderValue ? "https" : "http";
     $arrSystemParameter["HOSTNAME"] = $_SERVER['SERVER_NAME'];
     $strRequestUri = $_SERVER['REQUEST_URI'];
     $path_parts = pathinfo($strRequestUri);
     $arrSystemParameter["URLPATHNAME"] = $path_parts['dirname'];
     if ($arrSystemParameter["URLPATHNAME"][0] == "/") {
         $arrSystemParameter["URLPATHNAME"] = uniSubstr($arrSystemParameter["URLPATHNAME"], 1);
     }
     return $arrSystemParameter;
 }
    /**
     * Processes the content.
     * Make sure to return the string again, otherwise the output will remain blank.
     *
     * @param string $strContent
     *
     * @return string
     */
    public function processContent($strContent)
    {
        $strHighlight = trim(class_carrier::getInstance()->getParam("highlight"));
        if ($strHighlight != "") {
            $strHighlight = strip_tags($strHighlight);
            $strJS = <<<JS
KAJONA.portal.loader.loadFile('/templates/default/js/jquery.highlight.js', function() { \$("body div[class='contentRight']").highlight("{$strHighlight}"); });
JS;
            $strJS = "<script type=\"text/javascript\">" . $strJS . "</script>\n";
            $intBodyClose = uniStripos($strContent, "</body>");
            if ($intBodyClose !== false) {
                $strContent = uniSubstr($strContent, 0, $intBodyClose) . $strJS . uniSubstr($strContent, $intBodyClose);
            }
        }
        return $strContent;
    }
Пример #13
0
function walkFolderRecursive($strStartFolder)
{
    $objFilesystem = new class_filesystem();
    $arrFilesAndFolders = $objFilesystem->getCompleteList($strStartFolder, array(".php"), array(), array(".", "..", ".svn"));
    foreach ($arrFilesAndFolders["files"] as $arrOneFile) {
        $strFilename = $arrOneFile["filename"];
        //include the filecontent
        $strContent = file_get_contents($strStartFolder . "/" . $strFilename);
        if (uniSubstr($strContent, 0, 5) != "<?php") {
            echo "Whitespace at the beginning of file >> " . $strStartFolder . "/" . $strFilename . " is:>" . uniSubstr($strContent, 0, 1) . "< << \n";
        }
        if (uniSubstr($strContent, -2) != "?>") {
            echo "Whitespace at the end of file >> " . $strStartFolder . "/" . $strFilename . " << \n";
        }
    }
    foreach ($arrFilesAndFolders["folders"] as $strOneFolder) {
        walkFolderRecursive($strStartFolder . "/" . $strOneFolder);
    }
}
Пример #14
0
 public function testModuleModels()
 {
     echo "preparing object saves...\n";
     class_carrier::getInstance()->getObjRights()->setBitTestMode(true);
     $arrFiles = class_resourceloader::getInstance()->getFolderContent("/system", array(".php"), false, function ($strOneFile) {
         if (uniStripos($strOneFile, "class_module_") !== false) {
             $objClass = new ReflectionClass(uniSubstr($strOneFile, 0, -4));
             if (!$objClass->isAbstract() && $objClass->isSubclassOf("class_model")) {
                 $objAnnotations = new class_reflection(uniSubstr($strOneFile, 0, -4));
                 //block from autotesting?
                 if ($objAnnotations->hasClassAnnotation("@blockFromAutosave")) {
                     echo "skipping class " . uniSubstr($strOneFile, 0, -4) . " due to @blockFromAutosave annotation" . "\n";
                     return false;
                 }
                 return true;
             }
         }
         return false;
     }, function (&$strOneFile) {
         $strOneFile = uniSubstr($strOneFile, 0, -4);
         $strOneFile = new $strOneFile();
     });
     $arrSystemids = array();
     /** @var $objOneInstance class_model */
     foreach ($arrFiles as $objOneInstance) {
         echo "testing object of type " . get_class($objOneInstance) . "@" . $objOneInstance->getSystemid() . "\n";
         $this->assertTrue($objOneInstance->updateObjectToDb(), "saving object " . get_class($objOneInstance));
         $arrSystemids[$objOneInstance->getSystemid()] = get_class($objOneInstance);
         echo " ...saved object of type " . get_class($objOneInstance) . "@" . $objOneInstance->getSystemid() . "\n";
     }
     $objObjectfactory = class_objectfactory::getInstance();
     foreach ($arrSystemids as $strSystemid => $strClass) {
         echo "instantiating " . $strSystemid . "@" . $strClass . "\n";
         $objInstance = $objObjectfactory->getObject($strSystemid);
         $this->assertTrue($objInstance != null);
         $this->assertEquals(get_class($objInstance), $strClass);
         echo "deleting " . $strSystemid . "@" . $strClass . "\n";
         $objInstance->deleteObjectFromDatabase();
     }
     class_carrier::getInstance()->getObjRights()->setBitTestMode(false);
 }
 /**
  * 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;
 }
 /**
  * @see interface_admin_systemtask::getAdminForm()
  * @return string
  */
 public function getAdminForm()
 {
     $strReturn = "";
     //show dropdown to select db-dump
     $objFilesystem = new class_filesystem();
     $arrFiles = $objFilesystem->getFilelist(_projectpath_ . "/dbdumps/", array(".sql", ".gz"));
     $arrOptions = array();
     foreach ($arrFiles as $strOneFile) {
         $arrDetails = $objFilesystem->getFileDetails(_projectpath_ . "/dbdumps/" . $strOneFile);
         $strTimestamp = "";
         if (uniStrpos($strOneFile, "_") !== false) {
             $strTimestamp = uniSubstr($strOneFile, uniStrrpos($strOneFile, "_") + 1, uniStrpos($strOneFile, ".") - uniStrrpos($strOneFile, "_"));
         }
         if (uniStrlen($strTimestamp) > 9 && is_numeric($strTimestamp)) {
             $arrOptions[$strOneFile] = $strOneFile . " (" . bytesToString($arrDetails["filesize"]) . ")" . "<br />" . $this->getLang("systemtask_dbimport_datefilename") . " " . timeToString($strTimestamp) . "<br />" . $this->getLang("systemtask_dbimport_datefileinfo") . " " . timeToString($arrDetails['filechange']);
         } else {
             $arrOptions[$strOneFile] = $strOneFile . " (" . bytesToString($arrDetails["filesize"]) . ")" . "<br />" . $this->getLang("systemtask_dbimport_datefileinfo") . " " . timeToString($arrDetails['filechange']);
         }
     }
     $strReturn .= $this->objToolkit->formInputRadiogroup("dbImportFile", $arrOptions, $this->getLang("systemtask_dbimport_file"));
     return $strReturn;
 }
Пример #18
0
 public function testReports()
 {
     if (!defined("_skinwebpath_")) {
         define("_skinwebpath_", "1");
     }
     echo "processing reports...\n";
     $arrReportsInFs = class_resourceloader::getInstance()->getFolderContent("/admin/statsreports", array(".php"), false, function ($strOneFile) {
         if (uniStripos($strOneFile, "class_stats_report") === false) {
             return false;
         }
         return true;
     }, function (&$strOneFile) {
         $strOneFile = uniSubstr($strOneFile, 0, -4);
         $strOneFile = new $strOneFile(class_carrier::getInstance()->getObjDB(), class_carrier::getInstance()->getObjToolkit("admin"), class_carrier::getInstance()->getObjLang());
     });
     $arrReports = array();
     foreach ($arrReportsInFs as $objReport) {
         if ($objReport instanceof interface_admin_statsreports) {
             $arrReports[$objReport->getTitle()] = $objReport;
         }
         $objStartDate = new class_date();
         $objStartDate->setPreviousDay();
         $objEndDate = new class_date();
         $objEndDate->setNextDay();
         $intStartDate = mktime(0, 0, 0, $objStartDate->getIntMonth(), $objStartDate->getIntDay(), $objStartDate->getIntYear());
         $intEndDate = mktime(0, 0, 0, $objEndDate->getIntMonth(), $objEndDate->getIntDay(), $objEndDate->getIntYear());
         $objReport->setEndDate($intEndDate);
         $objReport->setStartDate($intStartDate);
         $objReport->setInterval(2);
     }
     /** @var interface_admin_statsreports $objReport */
     foreach ($arrReports as $objReport) {
         ob_start();
         echo "processing report " . $objReport->getTitle() . "\n";
         $objReport->getReport();
         $objReport->getReportGraph();
     }
 }
 /**
  * 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 "";
 }
Пример #20
0
/**
 * Unicode-safe string trimmer
 *
 * @param string $strString string to wrap
 * @param int $intLength
 * @param string $strAdd string to add after wrapped string
 *
 * @return string
 */
function uniStrTrim($strString, $intLength, $strAdd = "…")
{
    if ($intLength > 0 && uniStrlen($strString) > $intLength) {
        return trim(uniSubstr($strString, 0, $intLength)) . $strAdd;
    } else {
        return $strString;
    }
}
Пример #21
0
 /**
  * If multiple new actions are given, all buttons are merged into a new, single button.
  * The button itself is rendering the different buttons using a new dropdown-menu.
  * @param array $arrActions
  * @return string
  */
 private function mergeNewEntryActions($arrActions)
 {
     if (!is_array($arrActions)) {
         return $arrActions;
     }
     if (is_array($arrActions) && count($arrActions) == 0) {
         return "";
     }
     if (is_array($arrActions) && count($arrActions) == 1) {
         return $arrActions[0];
     }
     //create a menu and merge all buttons
     $arrActionMenuEntries = array();
     foreach ($arrActions as $strOneAction) {
         $strOneAction = trim($strOneAction);
         //search for a title attribute
         $arrMatches = array();
         if (preg_match('/<a.*?title=(["\'])(.*?)\\1.*$/i', $strOneAction, $arrMatches)) {
             if (uniSubstr($strOneAction, -11) == "</a></span>") {
                 $strOneAction = uniSubstr($strOneAction, 0, -11) . $arrMatches[2] . "</a></span>";
             } else {
                 $strOneAction .= $arrMatches[2];
             }
         }
         $arrActionMenuEntries[] = array("fullentry" => $strOneAction);
     }
     return $this->objToolkit->listButton("<span class='dropdown pull-right'><a href='#' data-toggle='dropdown' role='button'>" . class_adminskin_helper::getAdminImage("icon_new_multi") . "</a>" . $this->objToolkit->registerMenu(generateSystemid(), $arrActionMenuEntries) . "</span>");
 }
Пример #22
0
 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;
 }
 /**
  * Triggers the installation of a package
  * @permissions edit
  * @return string
  */
 protected function actionInstallPackage()
 {
     $this->setArrModuleEntry("template", "/folderview.tpl");
     $strReturn = "";
     $strLog = "";
     $strFile = $this->getParam("package");
     $objManager = new class_module_packagemanager_manager();
     if ($objManager->validatePackage($strFile)) {
         if (uniSubstr($strFile, -4) == ".zip") {
             $objHandler = $objManager->extractPackage($strFile);
             $objFilesystem = new class_filesystem();
             $objFilesystem->fileDelete($strFile);
             $objHandler->move2Filesystem();
             class_classloader::getInstance()->flushCache();
             class_reflection::flushCache();
             class_resourceloader::getInstance()->flushCache();
             //reload the module-ids
             bootstrapIncludeModuleIds();
             //reload the current request in order to flush the class-loader
             $this->adminReload(class_link::getLinkAdminHref("packagemanager", "installPackage", "&package=" . $objHandler->getStrTargetPath()));
             return;
         } else {
             $objHandler = $objManager->getPackageManagerForPath($strFile);
         }
         if ($objHandler->getObjMetadata()->getBitProvidesInstaller()) {
             $strLog .= $objHandler->installOrUpdate();
         }
         $strLog .= "Updating default template pack...\n";
         $objHandler->updateDefaultTemplate();
         $strOnSubmit = 'window.parent.parent.location.reload();';
         if ($strLog !== "") {
             $strReturn .= $this->objToolkit->formHeadline($this->getLang("package_install_success"));
             $strReturn .= $this->objToolkit->getPreformatted(array($strLog));
             $strReturn .= $this->objToolkit->formHeader(class_link::getLinkAdminHref($this->getArrModule("modul"), "list"), "", "", "javascript:" . $strOnSubmit);
             $strReturn .= $this->objToolkit->formInputSubmit($this->getLang("commons_ok"));
             $strReturn .= $this->objToolkit->formClose();
         } else {
             // break out of dialog and remove iframes by reloading main window
             $strReturn .= '<script>' . $strOnSubmit . '</script>';
         }
     }
     return $strReturn;
 }
Пример #24
0
 /**
  * Returns a textual description of the current element, based
  * on the lang key element_description.
  *
  * @return string
  * @since 3.2.1
  */
 public function getElementDescription()
 {
     $strName = uniSubstr(get_class($this), uniStrlen("class_"), -6);
     $strDesc = $this->getLang($strName . "_description");
     if ($strDesc == "!" . $strName . "_description!") {
         $strDesc = "";
     }
     return $strDesc;
 }
 /**
  * Internal helper, loads all files available including a traversal
  * of the nested folders.
  *
  * @param $strParentId
  * @param int|bool $strCategoryFilter
  * @param int $intStart
  * @param int $intEnd
  * @param bool $strNameFilter
  *
  * @return class_module_mediamanager_file[]
  */
 private function getAllPackages($strParentId, $strCategoryFilter = false, $intStart = null, $intEnd = null, $strNameFilter = false)
 {
     $arrReturn = array();
     if (validateSystemid($strParentId)) {
         $arrSubfiles = class_module_mediamanager_file::loadFilesDB($strParentId, false, true, null, null, true);
         foreach ($arrSubfiles as $objOneFile) {
             if ($objOneFile->getIntType() == class_module_mediamanager_file::$INT_TYPE_FILE) {
                 //filename based check if the file should be included
                 if ($strNameFilter !== false) {
                     if (uniStrpos($strNameFilter, ",") !== false) {
                         if (in_array($objOneFile->getStrName(), explode(",", $strNameFilter))) {
                             $arrReturn[] = $objOneFile;
                         }
                     } else {
                         if (uniSubstr($objOneFile->getStrName(), 0, uniStrlen($strNameFilter)) == $strNameFilter) {
                             $arrReturn[] = $objOneFile;
                         }
                     }
                 } else {
                     $arrReturn[] = $objOneFile;
                 }
             } else {
                 $arrReturn = array_merge($arrReturn, $this->getAllPackages($objOneFile->getSystemid()));
             }
         }
         if ($intStart !== null && $intEnd !== null && $intStart > 0 && $intEnd > $intStart) {
             if ($intEnd > count($arrReturn)) {
                 $intEnd = count($arrReturn);
             }
             $arrTemp = array();
             for ($intI = $intStart; $intI <= $intEnd; $intI++) {
                 $arrTemp[] = $arrReturn[$intI];
             }
             $arrReturn = $arrTemp;
         }
         //sort them by filename
         usort($arrReturn, function (class_module_mediamanager_file $objA, class_module_mediamanager_file $objB) {
             return strcmp($objA->getStrName(), $objB->getStrName());
         });
     } else {
         $arrReturn = class_module_mediamanager_file::getFlatPackageList($strCategoryFilter, true, $intStart, $intEnd, $strNameFilter);
     }
     return $arrReturn;
 }
Пример #26
0
 /**
  * Creates a raw Link for the portal (just the href)
  *
  * @param string $strPageI
  * @param string $strPageE
  * @param string $strAction
  * @param string $strParams
  * @param string $strSystemid
  * @param string $strLanguage
  * @param string $strSeoAddon Only used if using mod_rewrite
  * @return string
  */
 public static function getLinkPortalHref($strPageI, $strPageE = "", $strAction = "", $strParams = "", $strSystemid = "", $strLanguage = "", $strSeoAddon = "")
 {
     $strReturn = "";
     $bitInternal = true;
     //return "#" if neither an internal nor an external page is set
     if ($strPageI == "" && $strPageE == "") {
         return "#";
     }
     //Internal links are more important than external links!
     if ($strPageI == "" && $strPageE != "") {
         $bitInternal = false;
     }
     //create an array out of the params
     if ($strSystemid != "") {
         $strParams .= "&systemid=" . $strSystemid;
         $strSystemid = "";
     }
     $arrParams = self::parseParamsString($strParams, $strSystemid);
     // any anchors set to the page?
     $strAnchor = "";
     if (uniStrpos($strPageI, "#") !== false) {
         //get anchor, remove anchor from link
         $strAnchor = urlencode(uniSubstr($strPageI, uniStrpos($strPageI, "#") + 1));
         $strPageI = uniSubstr($strPageI, 0, uniStrpos($strPageI, "#"));
     }
     //urlencoding
     $strPageI = urlencode($strPageI);
     $strAction = urlencode($strAction);
     //more than one language installed?
     if ($strLanguage == "" && self::getIntNumberOfPortalLanguages() > 1) {
         $strLanguage = self::getStrPortalLanguage();
     } else {
         if ($strLanguage != "" && self::getIntNumberOfPortalLanguages() <= 1) {
             $strLanguage = "";
         }
     }
     $strHref = "";
     if ($bitInternal) {
         //check, if we could use mod_rewrite
         $bitRegularLink = true;
         if (class_module_system_setting::getConfigValue("_system_mod_rewrite_") == "true") {
             $strAddKeys = "";
             //used later to add seo-relevant keywords
             $objPage = class_module_pages_page::getPageByName($strPageI);
             if ($objPage !== null) {
                 if ($strLanguage != "") {
                     $objPage->setStrLanguage($strLanguage);
                     $objPage->initObject();
                 }
                 $strAddKeys = $objPage->getStrSeostring() . ($strSeoAddon != "" && $objPage->getStrSeostring() != "" ? "-" : "") . urlSafeString($strSeoAddon);
                 if (uniStrlen($strAddKeys) > 0 && uniStrlen($strAddKeys) <= 2) {
                     $strAddKeys .= "__";
                 }
                 //trim string
                 $strAddKeys = uniStrTrim($strAddKeys, 100, "");
                 if ($strLanguage != "") {
                     $strHref .= $strLanguage . "/";
                 }
                 $strPath = $objPage->getStrPath();
                 if ($strPath == "") {
                     $objPage->updatePath();
                     $strPath = $objPage->getStrPath();
                     $objPage->updateObjectToDb();
                 }
                 if ($strPath != "") {
                     $strHref .= $strPath . "/";
                 }
             }
             //ok, here we go. schema for rewrite_links: pagename.addKeywords.action.systemid.language.html
             //but: special case: just pagename & language
             if ($strAction == "" && $strSystemid == "" && $strAddKeys == "") {
                 $strHref .= $strPageI . ".html";
             } elseif ($strAction == "" && $strSystemid == "") {
                 $strHref .= $strPageI . ($strAddKeys == "" ? "" : "." . $strAddKeys) . ".html";
             } elseif ($strAction != "" && $strSystemid == "") {
                 $strHref .= $strPageI . "." . $strAddKeys . "." . $strAction . ".html";
             } else {
                 $strHref .= $strPageI . "." . $strAddKeys . "." . $strAction . "." . $strSystemid . ".html";
             }
             //params?
             if (count($arrParams) > 0) {
                 $strHref .= "?" . implode("&amp;", $arrParams);
             }
             // add anchor if given
             if ($strAnchor != "") {
                 $strHref .= "#" . $strAnchor;
             }
             //plus the domain as a prefix
             $strHref = "_webpath_" . "/" . $strHref;
             $bitRegularLink = false;
         }
         if ($bitRegularLink) {
             $strHref = "_indexpath_" . "?" . ($strPageI != "" ? "page=" . $strPageI : "") . "" . ($strSystemid != "" ? "&amp;systemid=" . $strSystemid : "") . ($strAction != "" ? "&amp;action=" . $strAction : "") . ($strLanguage != "" ? "&amp;language=" . $strLanguage : "") . (count($arrParams) > 0 ? "&amp;" . implode("&amp;", $arrParams) : "") . ($strAnchor != "" ? "#" . $strAnchor : "") . "";
         }
     } else {
         $strHref = $strPageE;
     }
     $strReturn .= $strHref;
     return $strReturn;
 }
Пример #27
0
 /**
  * Inserts a line-break to long legend-values
  *
  * @param $strLegend
  * @return string
  */
 private function stripLegend($strLegend)
 {
     $intStart = $this->intLegendBreakCount;
     while (uniStrlen($strLegend) > $intStart) {
         $strLegend = uniSubstr($strLegend, 0, $intStart) . "\n" . uniSubstr($strLegend, $intStart);
         $intStart += $this->intLegendBreakCount;
     }
     return $strLegend;
 }
 /**
  * Returns a list of objects implementing the changelog-provider-interface
  * @return interface_changelog_provider[]
  */
 public static function getAdditionalProviders()
 {
     if (self::$arrCachedProviders != null) {
         return self::$arrCachedProviders;
     }
     $arrReturn = class_resourceloader::getInstance()->getFolderContent("/system", array(".php"), false, function ($strOneFile) {
         if (uniStrpos($strOneFile, "class_changelog_provider") === false) {
             return false;
         }
         $objReflection = new ReflectionClass(uniSubstr($strOneFile, 0, -4));
         if ($objReflection->implementsInterface("interface_changelog_provider")) {
             return true;
         }
         return false;
     }, function (&$strOneFile) {
         $objReflection = new ReflectionClass(uniSubstr($strOneFile, 0, -4));
         $strOneFile = $objReflection->newInstance();
     });
     self::$arrCachedProviders = $arrReturn;
     return $arrReturn;
 }
Пример #29
0
 /**
  * Loads a single file from the passed archive.
  * If not found, false is returned instead.
  *
  * @param string $strSourceArchive
  * @param string $strFilename
  *
  * @return mixed|bool
  */
 public function getFileFromArchive($strSourceArchive, $strFilename)
 {
     if ($strFilename[0] == "/") {
         $strFilename = uniSubstr($strFilename, 1);
     }
     $this->objArchive->open(_realpath_ . $strSourceArchive);
     $strReturn = $this->objArchive->getFromName($strFilename);
     $this->objArchive->close();
     return $strReturn;
 }
 /**
  * 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;
 }