/**
  * 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;
 }
 /**
  * @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 "";
 }
Esempio n. 3
0
 /**
  * @dataProvider additionProvider
  */
 public function testGetAnnotationValuesFromClassParameter($a)
 {
     $objReflection = new class_reflection(new C());
     $this->assertTrue($objReflection->hasClassAnnotation("@classTest"));
     $this->assertTrue($objReflection->hasClassAnnotation("@classParamTest1"));
     $this->assertTrue($objReflection->hasClassAnnotation("@classParamTest2"));
     $this->assertTrue($objReflection->hasClassAnnotation("@classParamTest3"));
     $this->assertTrue($objReflection->hasClassAnnotation("@classParamTest4"));
     $this->assertTrue($objReflection->hasClassAnnotation("@fieldDDValues"));
     $arrClassAnnotations = $objReflection->getAnnotationValuesFromClass("@classTest");
     $this->assertEquals(5, count($arrClassAnnotations));
     $this->assertTrue(in_array("val1", $arrClassAnnotations));
     $this->assertTrue(in_array("val2", $arrClassAnnotations));
     $this->assertTrue(in_array("val3", $arrClassAnnotations));
     $this->assertTrue(in_array("val4", $arrClassAnnotations));
     $this->assertTrue(in_array("val5", $arrClassAnnotations));
     //Values
     $arrValues = $objReflection->getAnnotationValuesFromClass("@classParamTest1");
     $this->assertCount(1, $arrValues);
     $this->assertEquals("val1", $arrValues[0]);
     class_reflection::flushCache();
     $arrValues = $objReflection->getAnnotationValuesFromClass("@classParamTest2");
     $this->assertCount(2, $arrValues);
     $this->assertEquals("", $arrValues[0]);
     $this->assertEquals("", $arrValues[1]);
     class_reflection::flushCache();
     $arrValues = $objReflection->getAnnotationValuesFromClass("@classParamTest3");
     $this->assertCount(1, $arrValues);
     $this->assertEquals("val3", $arrValues[0]);
     class_reflection::flushCache();
     $arrValues = $objReflection->getAnnotationValuesFromClass("@classParamTest4");
     $this->assertCount(1, $arrValues);
     $this->assertEquals("", $arrValues[0]);
     class_reflection::flushCache();
     //Params
     $arrParams = $objReflection->getAnnotationValuesFromClass("@classParamTest1", class_reflection_enum::PARAMS());
     $this->assertCount(1, $arrParams);
     $this->assertCount(0, $arrParams[0]);
     class_reflection::flushCache();
     $arrParamsAll = $objReflection->getAnnotationValuesFromClass("@classParamTest2", class_reflection_enum::PARAMS());
     $this->assertCount(2, $arrParamsAll);
     //param from tow classes
     //Class C
     $arrParams = $arrParamsAll[0];
     $this->assertCount(5, $arrParams);
     $this->assertArrayHasKey("param1", $arrParams);
     $this->assertArrayHasKey("param2", $arrParams);
     $this->assertArrayHasKey("param3", $arrParams);
     $this->assertArrayHasKey("param4", $arrParams);
     $this->assertArrayHasKey("param5", $arrParams);
     $this->assertEquals(0, $arrParams["param1"]);
     $this->assertEquals("abc", $arrParams["param2"]);
     $this->assertTrue(is_array($arrParams["param3"]));
     $this->assertEquals("0", $arrParams["param3"][0]);
     $this->assertEquals("123", $arrParams["param3"][1]);
     $this->assertEquals("456", $arrParams["param3"][2]);
     $this->assertEquals(999, $arrParams["param4"]);
     $this->assertEquals("hans im glück", $arrParams["param5"]);
     //Class B
     $arrParams = $arrParamsAll[1];
     $this->assertCount(2, $arrParams);
     $this->assertArrayHasKey("param1", $arrParams);
     $this->assertArrayHasKey("param2", $arrParams);
     $this->assertEquals(54, $arrParams["param1"]);
     $this->assertEquals(12334, $arrParams["param2"]);
     //Class C
     $arrParams = $objReflection->getAnnotationValuesFromClass("@classParamTest3", class_reflection_enum::PARAMS());
     $arrParams = $arrParams[0];
     $this->assertCount(3, $arrParams);
     $this->assertArrayHasKey("param1", $arrParams);
     $this->assertArrayHasKey("param2", $arrParams);
     $this->assertArrayHasKey("param3", $arrParams);
     $this->assertEquals(0, $arrParams["param1"]);
     $this->assertEquals("abc", $arrParams["param2"]);
     $this->assertTrue(is_array($arrParams["param3"]));
     $this->assertEquals("0", $arrParams["param3"][0]);
     $this->assertEquals("123", $arrParams["param3"][1]);
     $this->assertEquals("456", $arrParams["param3"][2]);
     //Class C
     $arrParams = $objReflection->getAnnotationValuesFromClass("@classParamTest4", class_reflection_enum::PARAMS());
     $arrParams = $arrParams[0];
     $this->assertCount(0, $arrParams);
 }
 private function update_43_431()
 {
     $strReturn = "Updating 4.3 to 4.3.1...\n";
     $strReturn .= "This update removes the flot chart module and replaces it with the jqplot chart module...\n\n";
     //1. install module jqplot
     $strReturn .= "Installing module jqplot if not exist...\n";
     $objManager = new class_module_packagemanager_manager();
     $objExistingJqPlotPackage = $objManager->getPackage("jqplot");
     //if jqplot is not installed, install it
     if ($objExistingJqPlotPackage === null) {
         $objContentProvider = new class_module_packagemanager_contentprovider_kajona();
         $arrPackageMetaData = $objContentProvider->searchPackage("jqplot");
         //if a package was found
         if ($arrPackageMetaData !== null && count($arrPackageMetaData) == 1) {
             //upload the package to projects/temp
             class_carrier::getInstance()->setParam("systemid", $arrPackageMetaData[0]["systemid"]);
             $strFile = $objContentProvider->processPackageUpload();
             if ($objManager->validatePackage($strFile)) {
                 if (uniSubstr($strFile, -4) == ".zip") {
                     //now extract the zip file and......
                     $objHandler = $objManager->extractPackage($strFile);
                     $objFilesystem = new class_filesystem();
                     $objFilesystem->fileDelete($strFile);
                     //move the created folder to /core
                     $objHandler->move2Filesystem();
                 }
             } else {
                 $strReturn .= "Package file is not valid...\n";
                 $strReturn .= "Update to version 4.3.1 cancelled...\n";
                 return $strReturn;
             }
         } else {
             $strReturn = "Module jqplot was not found via the packagemanager...\n";
             $strReturn .= "Update to version 4.3.1 cancelled...\n";
             return $strReturn;
         }
     }
     //2. uninstall module flot
     $strReturn .= "Removing module flotchart if exists...\n";
     $objFlotPackage = $objManager->getPackage("flotchart");
     if ($objFlotPackage !== null) {
         //uninstall flot
         $class_filesystem = new class_filesystem();
         $class_filesystem->folderDeleteRecursive($objFlotPackage->getStrPath());
     }
     //3. set jqplot as standard chart library
     $strReturn .= "Set jqplot as standard chart library if flot was selected standard chart library...\n";
     $objSetting = class_module_system_setting::getConfigByName("_system_graph_type_");
     if ($objSetting->getStrValue() == "flot") {
         $objSetting->setStrValue("jqplot");
         $objSetting->updateObjectToDb();
     }
     //4. update version to 4.3.1
     $strReturn .= "Updating module-versions...\n";
     $this->updateModuleVersion("", "4.3.1");
     //5. reload classloader etc.
     class_resourceloader::getInstance()->flushCache();
     class_classloader::getInstance()->flushCache();
     class_reflection::flushCache();
     return $strReturn;
 }
 /**
  * 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()
 {
     $strFilename = generateSystemid() . ".zip";
     //stream the original package
     $objRemoteloader = $this->getRemoteloader();
     $objRemoteloader->setBitCacheEnabled(false);
     $objRemoteloader->setStrQueryParams($this->STR_DOWNLOAD_URL . "?systemid=" . $this->getParam("systemid"));
     $strResponse = $objRemoteloader->getRemoteContent();
     file_put_contents(_realpath_ . _projectpath_ . "/temp/" . $strFilename, $strResponse);
     class_resourceloader::getInstance()->flushCache();
     class_classloader::getInstance()->flushCache();
     class_reflection::flushCache();
     return _projectpath_ . "/temp/" . $strFilename;
 }