/**
  * Sets the index view of the modules to the response
  * @param zibo\admin\form\ModuleInstallForm $form
  * @return zibo\admin\view\modules\ModulesView
  */
 private function setIndexView(ModuleInstallForm $form = null)
 {
     if (!$form) {
         $form = new ModuleInstallForm($this->request->getBasePath() . '/install');
     }
     $translator = $this->getTranslator();
     $modules = $this->installer->getModules();
     $table = new ModulesTable($this->request->getBasePath(), $modules);
     $view = new ModulesView($form, $table);
     $view->setPageTitle($translator->translate(self::TRANSLATION_TITLE));
     $sidebar = $view->getSidebar();
     $sidebar->setInformation($translator->translate(self::TRANSLATION_DESCRIPTION));
     if (class_exists(self::CLASS_REPOSITORY_CLIENT)) {
         $url = $this->request->getBaseUrl() . '/' . ClientModule::ROUTE;
         $sidebar->addAction($url, self::TRANSLATION_REPOSITORY_CLIENT, true);
     }
     $this->response->setView($view);
 }
 /**
  * Decorates a table cell by setting an anchor to the cell based on the cell's value
  * @param zibo\library\html\table\Cell $cell Cell to decorate
  * @param zibo\library\html\table\Row $row Row which will contain the cell
  * @param int $rowNumber Number of the row in the table
  * @param array $remainingValues Array containing the values of the remaining rows of the table
  * @return null
  */
 public function decorate(Cell $cell, Row $row, $rowNumber, array $remainingValues)
 {
     $module = $cell->getValue();
     if (!$module instanceof Module) {
         $cell->setValue('');
         return;
     }
     $namespace = $module->getNamespace();
     $name = $module->getName();
     $version = $module->getVersion();
     $ziboVersion = $module->getZiboVersion();
     if (version_compare(Zibo::VERSION, $ziboVersion) === -1) {
         $label = $this->translator->translate(self::TRANSLATION_DEPENDENCY_ZIBO, array('version' => $ziboVersion));
         $label = '<span class="newerZiboRequired">' . $label . '</span>';
         $cell->setValue($label);
         return;
     }
     $urlParams = $namespace . '/' . $name . '/' . $version;
     if (!$this->installer->hasModule($namespace, $name)) {
         $label = $this->translator->translate(self::TRANSLATION_INSTALL, array('version' => $version));
         $anchor = new Anchor($label, $this->installAction . $urlParams);
         $anchor = $anchor->getHtml();
         $cell->setValue($anchor);
         return;
     }
     $installedModule = $this->installer->getModule($namespace, $name);
     $installedVersion = $installedModule->getVersion();
     $versionCompare = version_compare($installedVersion, $version);
     if ($versionCompare === 0) {
         $value = '<span class="installed">' . $this->translator->translate(self::TRANSLATION_INSTALLED) . '</span>';
     } elseif ($versionCompare === -1) {
         $label = $this->translator->translate(self::TRANSLATION_UPGRADE, array('version' => $version));
         $anchor = new Anchor($label, $this->upgradeAction . $urlParams);
         $value = $anchor->getHtml();
     } else {
         $value = '<span class="installedNewer">' . $this->translator->translate(self::TRANSLATION_INSTALLED_NEWER) . '</span>';
     }
     $value .= '<div class="info">' . $this->translator->translate(self::TRANSLATION_VERSION_CURRENT, array('version' => $installedVersion)) . '</div>';
     $cell->setValue($value);
 }
示例#3
0
 /**
  * Installs the provided module on the filesystem
  * @param string $moduleFileContent Decoded Base64 of the contents of the module phar file
  * @param string $namespace The namespace of the module
  * @param string $name The name of the module
  * @return null
  * @throws Exception when an error occured
  */
 private function installModuleLocally($moduleFileContent, $namespace, $name)
 {
     if ($moduleFileContent === '') {
         throw new ZiboException('No sources for the module ' . $namespace . '.' . $name . ' recieved from the repository');
     }
     $downloadDirectory = new File('application/data');
     $downloadDirectory->create();
     $moduleFile = new File($downloadDirectory, $namespace . '.' . $name . '.phar');
     $moduleFile->write($moduleFileContent);
     $exception = null;
     try {
         $this->installer->installModule($moduleFile);
     } catch (Exception $e) {
         $exception = $e;
     }
     if ($moduleFile->exists()) {
         $moduleFile->delete();
     }
     if ($exception) {
         throw $exception;
     }
 }