/**
  * Returns a list of all packages available.
  * By default a json-encoded array-like structure.
  *
  * @return string|json
  * @permissions view
  * @xml
  */
 protected function actionList()
 {
     $arrPackages = array();
     $intNrOfFiles = 0;
     $intStart = $this->ensureNumericValue($this->getParam("start"), null);
     $intEnd = $this->ensureNumericValue($this->getParam("end"), null);
     $strTypeFilter = $this->isValidCategoryFilter($this->getParam("type")) ? $this->getParam("type") : false;
     $strNameFilter = trim($this->getParam("title")) != "" ? trim($this->getParam("title")) : false;
     if ($this->isValidPagingParameter($intStart) && $this->isValidPagingParameter($intEnd)) {
         if ($intEnd >= $intStart) {
             $intNrOfFiles = $this->getAllPackagesCount(class_module_system_setting::getConfigValue("_packageserver_repo_id_"), $strTypeFilter, $strNameFilter);
             $arrDBFiles = $this->getAllPackages(class_module_system_setting::getConfigValue("_packageserver_repo_id_"), $strTypeFilter, $intStart, $intEnd, $strNameFilter);
             //error-handling: a new filter and a offset is passed. but maybe the passed offset is no longer valid for the new filter criteria
             if (count($arrDBFiles) == 0 && $intNrOfFiles > 0) {
                 $arrDBFiles = $this->getAllPackages(class_module_system_setting::getConfigValue("_packageserver_repo_id_"), $strTypeFilter, 0, $intNrOfFiles, $strNameFilter);
             }
             $objManager = new class_module_packagemanager_manager();
             foreach ($arrDBFiles as $objOneFile) {
                 try {
                     $objMetadata = $objManager->getPackageManagerForPath($objOneFile->getStrFilename());
                     $arrPackages[] = array("systemid" => $objOneFile->getSystemid(), "title" => $objMetadata->getObjMetadata()->getStrTitle(), "version" => $objMetadata->getObjMetadata()->getStrVersion(), "description" => $objMetadata->getObjMetadata()->getStrDescription(), "type" => $objMetadata->getObjMetadata()->getStrType());
                 } catch (class_exception $objEx) {
                 }
             }
             class_module_packageserver_log::generateDlLog($strNameFilter !== false ? $strNameFilter : "", isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : "::1", urldecode($this->getParam("domain")));
             class_response_object::getInstance()->setStrResponseType(class_http_responsetypes::STR_TYPE_JSON);
         }
     }
     $result = array();
     $result['numberOfTotalItems'] = $intNrOfFiles;
     $result['items'] = $arrPackages;
     $result['protocolVersion'] = self::PROTOCOL_VERSION;
     $strReturn = json_encode($result);
     return $strReturn;
 }
 /**
  * Triggers the initial steps to start the update of a single package.
  * @permissions edit
  * @return string
  */
 protected function actionInitPackageUpdate()
 {
     $strPackage = $this->getParam("package");
     $objManager = new class_module_packagemanager_manager();
     $objHandler = $objManager->getPackageManagerForPath($strPackage);
     return $objManager->updatePackage($objHandler);
 }
예제 #3
0
 public function main()
 {
     echo "\n\n";
     echo "Kajona Build Project Helper\n";
     echo " Params:\n";
     echo "   projectPath: " . $this->strProjectPath . "\n";
     echo "   configFile: " . $this->strConfigFile . "\n";
     echo "   onlySetup: " . ($this->bitOnlyProjectsetup ? "true" : "false") . "\n";
     echo "\n\n";
     $arrCores = array();
     foreach (scandir(__DIR__ . "/" . $this->strProjectPath) as $strRootFolder) {
         if (strpos($strRootFolder, "core") === false) {
             continue;
         }
         $arrCores[] = $strRootFolder;
     }
     //trigger the setup script, try to get the matching one
     foreach (array_reverse($arrCores) as $strOneCore) {
         if (file_exists(__DIR__ . "/" . $this->strProjectPath . "/" . $strOneCore . "/setupproject.php")) {
             require __DIR__ . "/" . $this->strProjectPath . "/" . $strOneCore . "/setupproject.php";
             break;
         }
     }
     echo "calling cleanCore script: php -f '" . __DIR__ . "/cleanCore.php' '" . $this->strProjectPath . "'\n";
     $arrReturn = array();
     exec("php -f \"" . __DIR__ . "/cleanCore.php\" \"" . $this->strProjectPath . "\"", $arrReturn);
     echo implode("\n", $arrReturn) . "\n";
     if ($this->bitOnlyProjectsetup) {
         return;
     }
     //include config
     echo "include config.php -> " . __DIR__ . "/config.php\n";
     require __DIR__ . "/" . $this->strConfigFile;
     echo "creating modified config.php...\n";
     echo "using db-driver " . DB_DRIVER . "...\n";
     $strConfigfile = file_get_contents(__DIR__ . "/" . $this->strProjectPath . "/core/module_system/system/config/config.php");
     $strConfigfile = str_replace(array("%%defaulthost%%", "%%defaultusername%%", "%%defaultpassword%%", "%%defaultdbname%%", "%%defaultprefix%%", "%%defaultdriver%%", "%%defaultport%%"), array(DB_HOST, DB_USER, DB_PASS, DB_DB, "autotest_", DB_DRIVER, ""), $strConfigfile);
     $strSearch = "/\\[\\'debuglevel\\'\\]\\s* = 0/";
     $strReplace = "['debuglevel'] = 1";
     $strConfigfile = preg_replace($strSearch, $strReplace, $strConfigfile);
     $strSearch = "/\\[\\'debuglogging\\'\\]\\s* = 1/";
     $strReplace = "['debuglogging'] = 3";
     $strConfigfile = preg_replace($strSearch, $strReplace, $strConfigfile);
     file_put_contents(__DIR__ . "/" . $this->strProjectPath . "/project/system/config/config.php", $strConfigfile);
     echo "starting up system-kernel...\n";
     include __DIR__ . "/" . $this->strProjectPath . "/core/module_system/bootstrap.php";
     $objCarrier = class_carrier::getInstance();
     echo "dropping old tables...\n";
     $objDB = $objCarrier->getObjDB();
     $arrTables = $objDB->getTables();
     foreach ($arrTables as $strOneTable) {
         echo " ... drop table " . $strOneTable . "\n";
         $objDB->_pQuery("DROP TABLE " . $strOneTable, array());
     }
     class_carrier::getInstance()->flushCache(class_carrier::INT_CACHE_TYPE_DBQUERIES | class_carrier::INT_CACHE_TYPE_DBTABLES | class_carrier::INT_CACHE_TYPE_MODULES | class_carrier::INT_CACHE_TYPE_OBJECTFACTORY | class_carrier::INT_CACHE_TYPE_ORMCACHE);
     echo "\n\n";
     echo "Blocking browscap update\n";
     touch(__DIR__ . "/" . $this->strProjectPath . "/project/temp/cache.lock");
     echo "\n\n\n";
     echo "Searching for packages to be installed...";
     $objManager = new class_module_packagemanager_manager();
     $arrPackageMetadata = $objManager->getAvailablePackages();
     $arrPackagesToInstall = array();
     foreach ($arrPackageMetadata as $objOneMetadata) {
         if (!in_array($objOneMetadata->getStrTitle(), array("samplecontent"))) {
             $arrPackagesToInstall[] = $objOneMetadata;
         }
     }
     echo "nr of packages found to install: " . count($arrPackagesToInstall) . "\n";
     echo "\n\n";
     $intMaxLoops = 0;
     echo "starting installations...\n";
     while (count($arrPackagesToInstall) > 0 && ++$intMaxLoops < 100) {
         /** @var class_module_packagemanager_metadata $objOneMetadata */
         foreach ($arrPackagesToInstall as $intKey => $objOneMetadata) {
             echo "---------------------------------------------------------------\n";
             if (!$objOneMetadata->getBitProvidesInstaller()) {
                 echo "skipping " . $objOneMetadata->getStrTitle() . ", no installer provided...\n\n";
                 unset($arrPackagesToInstall[$intKey]);
                 continue;
             }
             echo "Installing " . $objOneMetadata->getStrTitle() . "...\n\n";
             $objHandler = $objManager->getPackageManagerForPath($objOneMetadata->getStrPath());
             if (!$objHandler->isInstallable()) {
                 echo "skipping " . $objOneMetadata->getStrTitle() . " due to unresolved requirements\n";
                 continue;
             }
             echo $objHandler->installOrUpdate();
             unset($arrPackagesToInstall[$intKey]);
             echo "\n\n";
         }
     }
     echo "Installing samplecontent...\n\n";
     try {
         $objHandler = $objManager->getPackageManagerForPath(class_resourceloader::getInstance()->getCorePathForModule("module_samplecontent") . "/module_samplecontent");
     } catch (class_exception $objEx) {
         $objHandler = null;
     }
     if ($objHandler !== null) {
         echo $objHandler->installOrUpdate();
     }
 }
 /**
  * Creates a small print-view of the current package, rendering all relevant key-value-pairs
  * @permissions view
  * @return string
  */
 protected function actionShowInfo()
 {
     $strReturn = "";
     $this->setArrModuleEntry("template", "/folderview.tpl");
     /** @var $objPackage class_module_mediamanager_file */
     $objPackage = class_objectfactory::getInstance()->getObject($this->getSystemid());
     if ($objPackage instanceof class_module_mediamanager_file && $objPackage->rightView()) {
         $objManager = new class_module_packagemanager_manager();
         $objHandler = $objManager->getPackageManagerForPath($objPackage->getStrFilename());
         /** @var class_module_packagemanager_admin $objAdmin */
         $objAdmin = class_module_system_module::getModuleByName("packagemanager")->getAdminInstanceOfConcreteModule();
         $strReturn .= $objAdmin->renderPackageDetails($objHandler);
     }
     return $strReturn;
 }
 /**
  * Scans all packages available and tries to load the latest version available.
  * All packages found are returned in a list like
  * array(packagename => version)
  * In addition, the update-available messages are triggered internally.
  *
  * @return array
  */
 public function scanForUpdates()
 {
     $objManager = new class_module_packagemanager_manager();
     $arrVersions = $objManager->getArrLatestVersion();
     foreach ($arrVersions as $strOneModule => $strOneVersion) {
         $objMetadata = $objManager->getPackage($strOneModule);
         if ($objMetadata != null) {
             $objManager->updateAvailable($objManager->getPackageManagerForPath($objMetadata->getStrPath()), $strOneVersion);
         }
     }
     return $arrVersions;
 }
 public function testUpdateOrInstall()
 {
     $objManager = new class_module_packagemanager_manager();
     $objHandler = $objManager->getPackageManagerForPath(class_resourceloader::getInstance()->getCorePathForModule("module_packagemanager") . "/module_packagemanager");
     $this->assertTrue(!$objHandler->isInstallable());
 }
예제 #7
0
 public function processAutoInstall()
 {
     $strReturn = "";
     $strReturn .= "Searching for packages to be installed...\n";
     $objManager = new class_module_packagemanager_manager();
     $arrPackageMetadata = $objManager->getAvailablePackages();
     $arrPackagesToInstall = array();
     foreach ($arrPackageMetadata as $objOneMetadata) {
         if (!in_array($objOneMetadata->getStrTitle(), array("samplecontent"))) {
             $arrPackagesToInstall[] = $objOneMetadata;
         }
     }
     $strReturn .= "Number of packages found: " . count($arrPackagesToInstall) . "\n";
     $strReturn .= "\n\n";
     $intMaxLoops = 0;
     $strReturn .= "starting installations...\n";
     while (count($arrPackagesToInstall) > 0 && ++$intMaxLoops < 100) {
         foreach ($arrPackagesToInstall as $intKey => $objOneMetadata) {
             $strReturn .= "------------------------------\n";
             if (!$objOneMetadata->getBitProvidesInstaller()) {
                 $strReturn .= "skipping " . $objOneMetadata->getStrTitle() . ", no installer provided...\n";
                 unset($arrPackagesToInstall[$intKey]);
                 continue;
             }
             $strReturn .= "Installing " . $objOneMetadata->getStrTitle() . "...\n";
             $objHandler = $objManager->getPackageManagerForPath($objOneMetadata->getStrPath());
             if (!$objHandler->isInstallable()) {
                 $strReturn .= "skipping " . $objOneMetadata->getStrTitle() . " due to unresolved requirements\n";
                 continue;
             }
             $strReturn .= $objHandler->installOrUpdate();
             unset($arrPackagesToInstall[$intKey]);
             $strReturn .= "\n";
         }
     }
     $strReturn .= "Installing samplecontent...\n";
     try {
         $objHandler = $objManager->getPackageManagerForPath(class_resourceloader::getInstance()->getCorePathForModule("module_samplecontent") . "/module_samplecontent");
     } catch (class_exception $objEx) {
         $objHandler = null;
     }
     if ($objHandler != null && $objHandler->isInstallable()) {
         $strReturn .= $objHandler->installOrUpdate();
     }
     return $strReturn;
 }