public function install()
 {
     $strReturn = "Installing " . $this->objMetadata->getStrTitle() . "...\n";
     $objManager = new class_orm_schemamanager();
     $strReturn .= "Installing table mediamanager_repo...\n";
     $objManager->createTable("class_module_mediamanager_repo");
     $strReturn .= "Installing table mediamanager_file...\n";
     $objManager->createTable("class_module_mediamanager_file");
     $strReturn .= "Installing table mediamanager_dllog...\n";
     $arrFields = array();
     $arrFields["downloads_log_id"] = array("char20", false);
     $arrFields["downloads_log_date"] = array("int", true);
     $arrFields["downloads_log_file"] = array("char254", true);
     $arrFields["downloads_log_user"] = array("char20", true);
     $arrFields["downloads_log_ip"] = array("char20", true);
     if (!$this->objDB->createTable("mediamanager_dllog", $arrFields, array("downloads_log_id"))) {
         $strReturn .= "An error occurred! ...\n";
     }
     //register the module
     $this->registerModule("mediamanager", _mediamanager_module_id_, "class_module_mediamanager_portal.php", "class_module_mediamanager_admin.php", $this->objMetadata->getStrVersion(), true, "", "class_module_mediamanager_admin_xml.php");
     //The folderview
     $this->registerModule("folderview", _mediamanager_folderview_modul_id_, "", "class_module_folderview_admin.php", $this->objMetadata->getStrVersion(), false);
     $this->registerConstant("_mediamanager_default_imagesrepoid_", "", class_module_system_setting::$int_TYPE_STRING, _mediamanager_module_id_);
     $this->registerConstant("_mediamanager_default_filesrepoid_", "", class_module_system_setting::$int_TYPE_STRING, _mediamanager_module_id_);
     $strReturn .= "Trying to copy the *.root files to top-level...\n";
     if (!file_exists(_realpath_ . "/download.php")) {
         if (!copy(class_resourceloader::getInstance()->getCorePathForModule("module_mediamanager", true) . "/module_mediamanager/download.php.root", _realpath_ . "/download.php")) {
             $strReturn .= "<b>Copying the download.php.root to top level failed!!!</b>";
         }
     }
     return $strReturn;
 }
 /**
  * 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);
     }
 }
 /**
  * Loads the file-system path for a single skin
  * @static
  * @param string $strSkin
  * @return string
  */
 public static function getPathForSkin($strSkin)
 {
     if (self::$strSkinPath == null) {
         self::$strSkinPath = class_resourceloader::getInstance()->getPathForFolder("/admin/skins/" . $strSkin);
     }
     return self::$strSkinPath;
 }
    public function testMergedConfigReader()
    {
        $strSimpleConfigFile = <<<TXT
<?php
        \$config["testkey1"] = "testval1";
        \$config["testkey2"] = "testval2";

TXT;
        $strMergingConfigFile = <<<TXT
<?php
        \$config["testkey2"] = "otherval";

TXT;
        file_put_contents(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/system/config/test2.php", $strSimpleConfigFile);
        file_put_contents(_realpath_ . _projectpath_ . "/system/config/test2.php", $strMergingConfigFile);
        $this->assertFileExists(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/system/config/test2.php");
        $this->assertFileExists(_realpath_ . _projectpath_ . "/system/config/test2.php");
        $objConfig = class_config::getInstance("test2.php");
        $this->assertEquals("testval1", $objConfig->getConfig("testkey1"));
        $this->assertEquals("otherval", $objConfig->getConfig("testkey2"));
        $objFilesystem = new class_filesystem();
        $objFilesystem->fileDelete(class_resourceloader::getInstance()->getCorePathForModule("module_system") . "/module_system/system/config/test2.php");
        $objFilesystem->fileDelete(_projectpath_ . "/system/config/test2.php");
        $this->assertFileNotExists(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/system/config/test2.php");
        $this->assertFileNotExists(_realpath_ . _projectpath_ . "/system/config/test2.php");
    }
Beispiel #5
0
 public function debugHelper()
 {
     echo "<pre>";
     echo "<b>Kajona V4 Debug Subsystem</b>\n\n";
     if (getGet("debugfile") != "") {
         echo "Loading path for " . getGet("debugfile") . "\n";
         $strPath = array_search(getGet("debugfile"), class_resourceloader::getInstance()->getFolderContent("/debug", array(".php")));
         if ($strPath !== false) {
             echo "Passing request to " . $strPath . "\n\n";
             include _realpath_ . $strPath;
         }
     } else {
         echo "Searching for debug-scripts available...\n";
         $arrFiles = class_resourceloader::getInstance()->getFolderContent("/debug", array(".php"));
         echo "<ul>";
         foreach ($arrFiles as $strPath => $strOneFile) {
             echo "<li><a href='?debugfile=" . $strOneFile . "' >" . $strOneFile . "</a> <br />" . $strPath . "</li>";
         }
         echo "</ul>";
     }
     $arrTimestampEnde = gettimeofday();
     $intTimeUsed = ($arrTimestampEnde['sec'] * 1000000 + $arrTimestampEnde['usec'] - ($this->arrTimestampStart['sec'] * 1000000 + $this->arrTimestampStart['usec'])) / 1000000;
     echo "\n\n<b>PHP-Time:</b>                              " . number_format($intTimeUsed, 6) . " sec \n";
     echo "<b>Queries db/cachesize/cached/fired:</b>     " . class_carrier::getInstance()->getObjDB()->getNumber() . "/" . class_carrier::getInstance()->getObjDB()->getCacheSize() . "/" . class_carrier::getInstance()->getObjDB()->getNumberCache() . "/" . (class_carrier::getInstance()->getObjDB()->getNumber() - class_carrier::getInstance()->getObjDB()->getNumberCache()) . "\n";
     echo "<b>Templates cached:</b>                      " . class_carrier::getInstance()->getObjTemplate()->getNumberCacheSize() . " \n";
     echo "<b>Memory/Max Memory:</b>                     " . bytesToString(memory_get_usage()) . "/" . bytesToString(memory_get_peak_usage()) . " \n";
     echo "<b>Classes Loaded:</b>                        " . class_classloader::getInstance()->getIntNumberOfClassesLoaded() . " \n";
     echo "<b>Cache requests/hits/saves/cachesize:</b>   " . class_cache::getIntRequests() . "/" . class_cache::getIntHits() . "/" . class_cache::getIntSaves() . "/" . class_cache::getIntCachesize() . " \n";
     echo "</pre>";
 }
 /**
  * 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;
 }
Beispiel #7
0
 /**
  * Reads a template from the filesystem
  *
  * @param string $strName
  * @param string $strSection
  * @param bool $bitForce Force the passed template name, not adding the current area
  * @param bool $bitThrowErrors If set true, the method throws exceptions in case of errors
  *
  * @return string The identifier for further actions
  * @throws class_exception
  */
 public function readTemplate($strName, $strSection = "", $bitForce = false, $bitThrowErrors = false)
 {
     //avoid directory traversals
     $strName = removeDirectoryTraversals($strName);
     if (!$bitForce) {
         try {
             $strName = class_resourceloader::getInstance()->getTemplate($strName);
         } catch (class_exception $objEx) {
             //try to resolve the file in the current skin
             $strName = class_resourceloader::getInstance()->getTemplate($strName, true);
         }
     }
     $bitKnownTemplate = false;
     //Is this template already in the cache?
     $strCacheTemplate = md5($strName);
     $strCacheSection = md5($strName . $strSection);
     if (isset($this->arrCacheTemplateSections[$strCacheSection])) {
         return $strCacheSection;
     }
     $this->bitSaveToCacheRequired = true;
     if (isset($this->arrCacheTemplates[$strCacheTemplate])) {
         $bitKnownTemplate = true;
     }
     if (!$bitKnownTemplate) {
         //We have to read the whole template from the filesystem
         if (uniSubstr($strName, -4) == ".tpl" && is_file(_realpath_ . "/" . $strName)) {
             $strTemplate = file_get_contents(_realpath_ . "/" . $strName);
             //Saving to the cache
             $this->arrCacheTemplates[$strCacheTemplate] = $strTemplate;
         } else {
             $strTemplate = "Template " . $strName . " not found!";
             if ($bitThrowErrors) {
                 throw new class_exception("Template " . $strName . " not found!", class_exception::$level_FATALERROR);
             }
         }
     } else {
         $strTemplate = $this->arrCacheTemplates[$strCacheTemplate];
     }
     //Now we have to extract the section
     if ($strSection != "") {
         //find opening tag
         $intStart = uniStrpos($strTemplate, "<" . $strSection . ">");
         //find closing tag
         $intEnd = uniStrpos($strTemplate, "</" . $strSection . ">");
         $intEnd = $intEnd - $intStart;
         if ($intStart !== false && $intEnd !== false) {
             //delete substring before and after
             $strTemplate = uniSubstr($strTemplate, $intStart, $intEnd);
             $strTemplate = str_replace("<" . $strSection . ">", "", $strTemplate);
             $strTemplate = str_replace("</" . $strSection . ">", "", $strTemplate);
         } else {
             $strTemplate = "";
         }
     }
     //Saving the section to the cache
     $this->arrCacheTemplateSections[$strCacheSection] = $strTemplate;
     return $strCacheSection;
 }
 public function getAdminForm()
 {
     $objForm = parent::getAdminForm();
     $arrClassesDD = array();
     foreach (class_resourceloader::getInstance()->getFolderContent("/portal/forms", array(".php")) as $strClass) {
         $arrClassesDD[$strClass] = $strClass;
     }
     $objForm->getField("class")->setArrKeyValues($arrClassesDD);
     return $objForm;
 }
 private function getJsFiles()
 {
     $arrFiles = array();
     $arrFiles = array_merge($arrFiles, class_resourceloader::getInstance()->getFolderContent("/admin/scripts", array(".js")));
     $arrFiles = array_merge($arrFiles, class_resourceloader::getInstance()->getFolderContent("/system/scripts", array(".js")));
     $arrFiles = array_merge($arrFiles, class_resourceloader::getInstance()->getFolderContent("/portal/scripts", array(".js")));
     return $arrFiles;
     //        $objFilesystem = new class_filesystem();
     //        return $objFilesystem->getFilelist("/", array(".js"), true);
 }
 /**
  * @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();
     });
 }
 /**
  * Loads the navigation-class and passes control
  *
  * @throws class_exception
  * @return string
  */
 public function loadData()
 {
     $strPath = class_resourceloader::getInstance()->getPathForFile("/portal/forms/" . $this->arrElementData["formular_class"]);
     if ($strPath === false) {
         throw new class_exception("failed to load form-class " . $this->arrElementData["formular_class"], class_exception::$level_ERROR);
     }
     require_once _realpath_ . $strPath;
     $strClassname = uniStrReplace(".php", "", $this->arrElementData["formular_class"]);
     $objForm = new $strClassname($this->arrElementData);
     $strReturn = $objForm->action();
     return $strReturn;
 }
Beispiel #12
0
 /**
  * @param resource &$objResource
  *
  * @return bool
  */
 public function render(&$objResource)
 {
     $strFontPath = class_resourceloader::getInstance()->getPathForFile("/system/fonts/" . $this->strFont);
     if ($strFontPath !== false && is_file(_realpath_ . $strFontPath)) {
         $intColor = $this->allocateColor($objResource, $this->arrColor);
         $strText = html_entity_decode($this->strText, ENT_COMPAT, "UTF-8");
         imagealphablending($objResource, true);
         imagefttext($objResource, $this->floatSize, $this->floatAngle, $this->intX, $this->intY, $intColor, _realpath_ . $strFontPath, $strText);
         imagealphablending($objResource, false);
         return true;
     }
     return false;
 }
 /**
  * Loads the feed and displays it
  *
  * @return string the prepared html-output
  */
 public function loadData()
 {
     require_once class_resourceloader::getInstance()->getCorePathForModule("element_markdown", true) . "/element_markdown/system/parsedown/vendor/autoload.php";
     $arrUrl = parse_url($this->arrElementData["char2"]);
     $objLoader = new class_remoteloader();
     $objLoader->setStrProtocolHeader($arrUrl["scheme"] . "://");
     $objLoader->setStrHost($arrUrl["host"]);
     $objLoader->setStrQueryParams($arrUrl["path"]);
     $objLoader->setIntPort(null);
     $strFile = $objLoader->getRemoteContent();
     $objMarkdown = new Parsedown();
     $strParsed = $objMarkdown->text($strFile);
     return $this->objTemplate->fillTemplate(array("markdown_content" => $strParsed, "markdown_url" => $this->arrElementData["char2"]), $this->objTemplate->readTemplate("/element_markdown/" . $this->arrElementData["char1"], "markdown"), true);
 }
 public function testResourceloader()
 {
     $arrContent = class_resourceloader::getInstance()->getFolderContent("/admin", array(".php"), false);
     $this->assertTrue(in_array("class_admin_controller.php", $arrContent));
     $this->assertTrue(in_array("class_admin_batchaction.php", $arrContent));
     $this->assertTrue(!in_array("class_systemtask_base.php", $arrContent));
     $this->assertTrue(!in_array("formentries", $arrContent));
     $arrContent = class_resourceloader::getInstance()->getFolderContent("/admin", array(), true);
     $this->assertTrue(in_array("class_admin_controller.php", $arrContent));
     $this->assertTrue(in_array("formentries", $arrContent));
     $this->assertTrue(in_array("class_admin_batchaction.php", $arrContent));
     $this->assertTrue(!in_array("class_systemtask_base.php", $arrContent));
     $this->assertTrue(!in_array("class_formentry_base.php", $arrContent));
 }
 /**
  * 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);
     });
 }
 protected function renderAdditionalActions(class_model $objListEntry)
 {
     if ($objListEntry instanceof class_module_tags_tag) {
         $arrButtons = array();
         $arrButtons[] = $this->objToolkit->listButton(class_link::getLinkAdmin($this->getArrModule("modul"), "showAssignedRecords", "&systemid=" . $objListEntry->getSystemid(), $this->getLang("action_show_assigned_records"), $this->getLang("action_show_assigned_records"), "icon_folderActionOpen"));
         if ($objListEntry->rightRight1()) {
             $strJs = "<script type='text/javascript'>KAJONA.admin.loader.loadFile('" . class_resourceloader::getInstance()->getCorePathForModule("module_tags") . "/module_tags/admin/scripts/tags.js', function() {\n                    KAJONA.admin.tags.createFavoriteEnabledIcon = '" . addslashes(class_adminskin_helper::getAdminImage("icon_favorite", $this->getLang("tag_favorite_remove"))) . "';\n                    KAJONA.admin.tags.createFavoriteDisabledIcon = '" . addslashes(class_adminskin_helper::getAdminImage("icon_favoriteDisabled", $this->getLang("tag_favorite_add"))) . "';\n                });</script>";
             $strImage = class_module_tags_favorite::getAllFavoritesForUserAndTag($this->objSession->getUserID(), $objListEntry->getSystemid()) != null ? class_adminskin_helper::getAdminImage("icon_favorite", $this->getLang("tag_favorite_remove")) : class_adminskin_helper::getAdminImage("icon_favoriteDisabled", $this->getLang("tag_favorite_add"));
             $arrButtons[] = $strJs . $this->objToolkit->listButton("<a href=\"#\" onclick=\"KAJONA.admin.tags.createFavorite('" . $objListEntry->getSystemid() . "', this); return false;\">" . $strImage . "</a>");
         }
         return $arrButtons;
     } else {
         return array();
     }
 }
 /**
  * Creates a graph-instance either based on the current config or
  * based on the passed param
  *
  * @param string $strType
  *
  * @throws class_exception
  * @return interface_graph
  */
 public static function getGraphInstance($strType = "")
 {
     if ($strType == "") {
         if (class_module_system_setting::getConfigValue("_system_graph_type_") != "") {
             $strType = class_module_system_setting::getConfigValue("_system_graph_type_");
         } else {
             $strType = "jqplot";
         }
     }
     $strClassname = "class_graph_" . $strType;
     $strPath = class_resourceloader::getInstance()->getPathForFile("/system/" . $strClassname . ".php");
     if ($strPath !== false) {
         $objReflection = new ReflectionClass($strClassname);
         if (!$objReflection->isAbstract() && $objReflection->implementsInterface("interface_graph")) {
             return $objReflection->newInstance();
         }
     }
     throw new class_exception("Requested charts-plugin " . $strType . " not existing", class_exception::$level_FATALERROR);
 }
Beispiel #19
0
 public function testZipFileread()
 {
     $objFileSystem = new class_filesystem();
     echo "\ttesting class_zip file-reading...\n";
     $objZip = new class_zip();
     echo "\topening " . _realpath_ . "/test.zip\n";
     $this->assertTrue($objZip->openArchiveForWriting("/files/cache/test.zip"), __FILE__ . " openArchive");
     $this->assertTrue($objZip->addFile(class_resourceloader::getInstance()->getCorePathForModule("module_system") . "/module_system/metadata.xml"), __FILE__ . " addFile");
     $this->assertTrue($objZip->closeArchive(), __FILE__ . " closeArchive");
     $this->assertFileExists(_realpath_ . "/files/cache/test.zip", __FILE__ . " checkFileExists");
     echo "\treading files\n";
     $strContent = $objZip->getFileFromArchive("/files/cache/test.zip", class_resourceloader::getInstance()->getCorePathForModule("module_system") . "/module_system/metadata.xml");
     $this->assertTrue(uniStrpos($strContent, "xsi:noNamespaceSchemaLocation=\"https://apidocs.kajona.de/xsd/package.xsd\"") !== false);
     echo "\tremoving testfile\n";
     $this->assertTrue($objFileSystem->fileDelete("/files/cache/test.zip"), __FILE__ . " deleteFile");
     $this->assertFileNotExists(_realpath_ . "/files/cache/test.zip", __FILE__ . " checkFileNotExists");
     $objFileSystem->folderDeleteRecursive("/files/cache/zipextract");
     $this->assertFileNotExists(_realpath_ . "/files/cache/zipextract", __FILE__ . " checkFileNotExists");
 }
 public function install()
 {
     $strReturn = "Installing " . $this->objMetadata->getStrTitle() . "...\n";
     //Register the module
     $strReturn .= "\nRegistering module\n";
     $this->registerModule($this->objMetadata->getStrTitle(), _samplecontent_modul_id_, "", "", $this->objMetadata->getStrVersion(), false);
     //search for installers available
     $arrInstaller = class_resourceloader::getInstance()->getFolderContent("/installer", array(".php"), false, function ($strFile) {
         return strpos($strFile, "installer_sc_") !== false;
     });
     asort($arrInstaller);
     $strReturn .= "Loading installers...\n";
     foreach ($arrInstaller as $strOneInstaller) {
         $strReturn .= "\n\nInstaller found: " . $strOneInstaller . "\n";
         include_once _realpath_ . array_search($strOneInstaller, $arrInstaller);
         //Creating an object....
         $strClass = "class_" . str_replace(".php", "", $strOneInstaller);
         /** @var $objInstaller interface_sc_installer|class_installer_base */
         $objInstaller = new $strClass();
         if ($objInstaller instanceof interface_sc_installer) {
             $strModule = $objInstaller->getCorrespondingModule();
             $strReturn .= "Module " . $strModule . "...\n";
             $objModule = class_module_system_module::getModuleByName($strModule);
             if ($objModule == null) {
                 $strReturn .= "\t... not installed!\n";
             } else {
                 $strReturn .= "\t... installed.\n";
                 $objInstaller->setObjDb($this->objDB);
                 $objInstaller->setStrContentlanguage($this->strContentLanguage);
                 $strReturn .= $objInstaller->install();
             }
         }
         $this->objDB->flushQueryCache();
     }
     if (!file_exists(_realpath_ . "/favicon.ico")) {
         if (!copy(class_resourceloader::getInstance()->getCorePathForModule("module_samplecontent", true) . "/module_samplecontent/favicon.ico.root", _realpath_ . "/favicon.ico")) {
             $strReturn .= "<b>Copying the favicon.ico.root to top level failed!!!</b>";
         }
     }
     return $strReturn;
 }
 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;
 }
Beispiel #23
0
function debug_parse_foldercontent($strSourceFolder, &$arrEntries)
{
    $arrContent = class_resourceloader::getInstance()->getFolderContent($strSourceFolder, array(), true);
    foreach ($arrContent as $strPath => $strOneEntry) {
        if ($strOneEntry == "." || $strOneEntry == "..") {
            continue;
        }
        if (is_file(_realpath_ . $strPath) && substr($strOneEntry, 0, 5) == "lang_") {
            $arrTemp = explode("_", substr($strOneEntry, 0, -4));
            //regular lang file found, parse contents
            $lang = array();
            include _realpath_ . $strPath;
            foreach ($lang as $strKey => $strValue) {
                $strModul = $arrTemp[1];
                $objTemp = debug_get_langhelper($arrEntries, $strModul, $strKey);
                if ($arrTemp[2] == "de") {
                    $objTemp->strDe = $strValue;
                }
                if ($arrTemp[2] == "en") {
                    $objTemp->strEn = $strValue;
                }
                if ($arrTemp[2] == "pt") {
                    $objTemp->strPt = $strValue;
                }
                if ($arrTemp[2] == "bg") {
                    $objTemp->strBg = $strValue;
                }
                if ($arrTemp[2] == "ru") {
                    $objTemp->strRu = $strValue;
                }
                if ($arrTemp[2] == "sv") {
                    $objTemp->strSv = $strValue;
                }
            }
        }
        if (is_dir(_realpath_ . $strPath) && $strOneEntry != ".svn") {
            debug_parse_foldercontent($strSourceFolder . "/" . $strOneEntry, $arrEntries);
        }
    }
}
 public function testPortalModules()
 {
     class_carrier::getInstance()->getObjRights()->setBitTestMode(true);
     //load all admin-classes
     $arrFiles = class_resourceloader::getInstance()->getFolderContent("/portal", array(".php"), false, function ($strOneFile) {
         if (preg_match("/class_module_(.*)_portal.php/i", $strOneFile)) {
             $strClassname = uniSubstr($strOneFile, 0, -4);
             $objReflection = new ReflectionClass($strClassname);
             if (!$objReflection->isAbstract()) {
                 return true;
             }
         }
         return false;
     }, function (&$strOneFile) {
         $strOneFile = uniSubstr($strOneFile, 0, -4);
         $strOneFile = new $strOneFile(array());
     });
     foreach ($arrFiles as $objPortalInstance) {
         $this->runSingleFile($objPortalInstance);
     }
     class_carrier::getInstance()->getObjRights()->setBitTestMode(false);
 }
Beispiel #25
0
 /**
  * Resolves, reads and merges the config-files
  *
  * @param string $strConfigFile
  * @return void
  */
 private function readConfigFile($strConfigFile)
 {
     $config = array();
     $debug = array();
     //Include the config-File
     $strPath = class_resourceloader::getInstance()->getPathForFile("/system/config/" . $strConfigFile, false);
     if ($strPath !== false) {
         @(include _realpath_ . $strPath);
     } else {
         if (!@(include class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/system/config/" . $strConfigFile)) {
             die("Error reading config-file from core folder: " . $strConfigFile);
         }
     }
     //overwrite with settings from project
     if (is_file(_realpath_ . "/project/system/config/" . $strConfigFile)) {
         if (!@(include _realpath_ . "/project/system/config/" . $strConfigFile)) {
             die("Error reading config-file from project folder: " . $strConfigFile);
         }
     }
     $this->arrConfig = $config;
     $this->arrDebug = $debug;
 }
 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();
     }
 }
Beispiel #27
0
 /**
  * Loading texts from textfiles
  *
  * @param string $strModule
  *
  * @return void
  */
 private function loadText($strModule)
 {
     $bitFileMatched = false;
     //load files
     $arrFiles = class_resourceloader::getInstance()->getLanguageFiles("module_" . $strModule);
     if (is_array($arrFiles)) {
         foreach ($arrFiles as $strPath => $strFilename) {
             /** @noinspection PhpUnusedLocalVariableInspection */
             $lang = array();
             $strTemp = str_replace(".php", "", $strFilename);
             $arrName = explode("_", $strTemp);
             if ($arrName[0] == "lang" && $arrName[count($arrName) - 1] == $this->strLanguage && $this->strLanguage != "") {
                 $bitFileMatched = true;
                 $this->loadAndMergeTextfile($strModule, $strPath, $this->strLanguage, $this->arrTexts);
             }
         }
         if ($bitFileMatched) {
             return;
         }
         //if we reach up here, no matching file was found. search for fallback file (fallback language)
         foreach ($arrFiles as $strPath => $strFilename) {
             $strTemp = str_replace(".php", "", $strFilename);
             $arrName = explode("_", $strTemp);
             if ($arrName[0] == "lang" && $arrName[count($arrName) - 1] == $this->strFallbackLanguage) {
                 $this->loadAndMergeTextfile($strModule, $strPath, $this->strFallbackLanguage, $this->arrTexts);
             }
         }
     }
 }
 /**
  * @permissions edit
  * @return string
  */
 protected function actionCopyPack()
 {
     $objForm = $this->getPackAdminForm();
     $strPackName = $this->getParam("pack_name");
     $strPackName = createFilename($strPackName, true);
     if ($strPackName != "" && is_dir(_realpath_ . _templatepath_ . "/" . $strPackName)) {
         $objForm->addValidationError("name", $this->getLang("pack_folder_existing"));
     }
     if (!$objForm->validateForm()) {
         return $this->actionNew($objForm);
     }
     $objFilesystem = new class_filesystem();
     $objFilesystem->folderCreate(_templatepath_ . "/" . $strPackName);
     $objFilesystem->folderCreate(_templatepath_ . "/" . $strPackName . "/tpl");
     $objFilesystem->folderCreate(_templatepath_ . "/" . $strPackName . "/css");
     $objFilesystem->folderCreate(_templatepath_ . "/" . $strPackName . "/js");
     $arrModules = $this->getParam("pack_modules");
     foreach ($arrModules as $strName => $strValue) {
         if ($strValue != "") {
             $objFilesystem->folderCopyRecursive(class_resourceloader::getInstance()->getCorePathForModule($strName) . "/" . $strName . "/templates/default", _templatepath_ . "/" . $strPackName);
         }
     }
     class_resourceloader::getInstance()->flushCache();
     class_classloader::getInstance()->flushCache();
     class_reflection::flushCache();
     $this->adminReload(class_link::getLinkAdminHref($this->getArrModule("modul"), "listTemplates"));
     return "";
 }
 protected function tearDown()
 {
     unlink(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/system/class_module_genericeventdispatcher_test.php");
     class_resourceloader::getInstance()->flushCache();
     class_classloader::getInstance()->flushCache();
     parent::tearDown();
 }
 /**
  * Loads the validator identified by the passed name.
  *
  * @param string $strName
  * @return interface_validator
  * @throws class_exception
  * @deprecated
  */
 private function getValidatorInstance($strName)
 {
     $strClassname = "class_" . $strName . "_validator";
     if (class_resourceloader::getInstance()->getPathForFile("/system/validators/" . $strClassname . ".php")) {
         return new $strClassname();
     } else {
         throw new class_exception("failed to load validator of type " . $strClassname, class_exception::$level_ERROR);
     }
 }