Exemplo n.º 1
0
 /**
  * (non-PHPdoc)
  * @see \oat\oatbox\action\Action::__invoke()
  */
 public function __invoke($params)
 {
     $merged = array_merge(common_ext_ExtensionsManager::singleton()->getInstalledExtensions(), $this->getMissingExtensions());
     $sorted = \helpers_ExtensionHelper::sortByDependencies($merged);
     $report = new common_report_Report(common_report_Report::TYPE_INFO, 'Running extension update');
     foreach ($sorted as $ext) {
         try {
             if (!common_ext_ExtensionsManager::singleton()->isInstalled($ext->getId())) {
                 $installer = new \tao_install_ExtensionInstaller($ext);
                 $installer->install();
                 $report->add(new common_report_Report(common_report_Report::TYPE_SUCCESS, 'Installed ' . $ext->getName()));
             } else {
                 $report->add($this->updateExtension($ext));
             }
         } catch (common_ext_MissingExtensionException $ex) {
             $report->add(new common_report_Report(common_report_Report::TYPE_ERROR, $ex->getMessage()));
             break;
         } catch (common_ext_OutdatedVersionException $ex) {
             $report->add(new common_report_Report(common_report_Report::TYPE_ERROR, $ex->getMessage()));
             break;
         } catch (Exception $e) {
             $this->logError('Exception during update of ' . $ext->getId() . ': ' . get_class($e) . ' "' . $e->getMessage() . '"');
             $report->setType(common_report_Report::TYPE_ERROR);
             $report->setTitle('Update failed');
             $report->add(new common_report_Report(common_report_Report::TYPE_ERROR, 'Exception during update of ' . $ext->getId() . '.'));
             break;
         }
     }
     $this->logInfo(helpers_Report::renderToCommandline($report, false));
     return $report;
 }
Exemplo n.º 2
0
 *
 */
//quick TZ fix
if (function_exists("date_default_timezone_set")) {
    date_default_timezone_set('UTC');
}
require_once dirname(__FILE__) . '/../includes/raw_start.php';
echo 'Look for missing required extensions' . PHP_EOL;
$missingId = \helpers_ExtensionHelper::getMissingExtensionIds(common_ext_ExtensionsManager::singleton()->getInstalledExtensions());
$missingExt = array();
foreach ($missingId as $extId) {
    $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById($extId);
    $missingExt[$extId] = $ext;
}
$merged = array_merge(common_ext_ExtensionsManager::singleton()->getInstalledExtensions(), $missingExt);
$sorted = \helpers_ExtensionHelper::sortByDependencies($merged);
foreach ($sorted as $ext) {
    if (!common_ext_ExtensionsManager::singleton()->isInstalled($ext->getId())) {
        echo 'Installing ' . $ext->getId() . PHP_EOL;
        $installer = new \tao_install_ExtensionInstaller($ext);
        $installer->install();
    } else {
        $installed = common_ext_ExtensionsManager::singleton()->getInstalledVersion($ext->getId());
        $current = $ext->getVersion();
        if ($installed !== $current) {
            echo $ext->getName() . ' requires update from ' . $installed . ' to ' . $current . PHP_EOL;
            $updaterClass = $ext->getManifest()->getUpdateHandler();
            if (!is_null($updaterClass)) {
                if (class_exists($updaterClass)) {
                    $updater = new $updaterClass($ext);
                    echo '  Running ' . $updaterClass . PHP_EOL;
Exemplo n.º 3
0
 /**
  * Get the structure content (from the structure.xml file) of each extension.
  * @return array
  */
 protected static function buildStructures()
 {
     $perspectives = array();
     $entrypoints = array();
     $toAdd = array();
     $sorted = \helpers_ExtensionHelper::sortByDependencies(\common_ext_ExtensionsManager::singleton()->getEnabledExtensions());
     foreach (array_keys($sorted) as $extId) {
         $file = self::getStructuresFilePath($extId);
         if (!is_null($file)) {
             $xmlStructures = new \SimpleXMLElement($file, null, true);
             $extStructures = $xmlStructures->xpath("/structures/structure");
             foreach ($extStructures as $xmlStructure) {
                 $perspective = Perspective::fromSimpleXMLElement($xmlStructure, $extId);
                 if (!isset($perspectives[$perspective->getId()])) {
                     $perspectives[$perspective->getId()] = $perspective;
                 } else {
                     foreach ($perspective->getChildren() as $section) {
                         $perspectives[$perspective->getId()]->addSection($section);
                     }
                 }
             }
             foreach ($xmlStructures->xpath("/structures/entrypoint") as $xmlStructure) {
                 $entryPoint = Entrypoint::fromSimpleXMLElement($xmlStructure);
                 foreach ($entryPoint->getReplacedIds() as $id) {
                     if (isset($entrypoints[$id])) {
                         unset($entrypoints[$id]);
                     }
                 }
                 $entrypoints[$entryPoint->getId()] = $entryPoint;
             }
             foreach ($xmlStructures->xpath("/structures/toolbar/toolbaraction") as $xmlStructure) {
                 $perspective = Perspective::fromLegacyToolbarAction($xmlStructure, $extId);
                 $perspectives[$perspective->getId()] = $perspective;
                 if (isset($xmlStructure['structure'])) {
                     $toAdd[$perspective->getId()] = (string) $xmlStructure['structure'];
                 }
             }
         }
     }
     foreach ($toAdd as $to => $from) {
         if (isset($perspectives[$from]) && isset($perspectives[$to])) {
             foreach ($perspectives[$from]->getChildren() as $section) {
                 $perspectives[$to]->addSection($section);
             }
         }
     }
     $sortCb = create_function('$a,$b', "return \$a->getLevel() - \$b->getLevel(); ");
     usort($perspectives, $sortCb);
     return array('perspectives' => $perspectives, 'entrypoints' => $entrypoints);
 }
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 * 
 * Copyright (c) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
 *               
 * 
 */
require_once dirname(__FILE__) . '/../includes/raw_start.php';
$inputFormat = array('min' => 1, 'parameters' => array(array('name' => 'verbose', 'type' => 'boolean', 'shortcut' => 'v', 'description' => 'Verbose mode'), array('name' => 'action', 'type' => 'string', 'shortcut' => 'a', 'description' => 'Action to undertake. Available actions are create, update, updateall, delete, deleteall, enable, disable, compile, compileall'), array('name' => 'language', 'type' => 'string', 'shortcut' => 'l', 'description' => 'A language identifier like en-US, be-NL, fr, ...'), array('name' => 'output', 'type' => 'string', 'shortcut' => 'o', 'description' => 'An output directory (PO and JS files)'), array('name' => 'input', 'type' => 'string', 'shortcut' => 'i', 'description' => 'An input directory (source code)'), array('name' => 'build', 'type' => 'boolean', 'shortcut' => 'b', 'description' => 'Sets if the language has to be built when created or not'), array('name' => 'force', 'type' => 'boolean', 'shortcut' => 'f', 'description' => 'Force to erase an existing language if you use the create action'), array('name' => 'extension', 'type' => 'string', 'shortcut' => 'e', 'description' => 'The TAO extension for which the script will apply'), array('name' => 'languageLabel', 'type' => 'string', 'shortcut' => 'll', 'description' => 'Language label to use when creating a new language'), array('name' => 'targetLanguage', 'type' => 'string', 'shortcut' => 'tl', 'description' => 'Target language code when you change the code of a locale'), array('name' => 'user', 'type' => 'string', 'shortcut' => 'u', 'description' => 'TAO user (TaoManager Role)'), array('name' => 'password', 'type' => 'string', 'shortcut' => 'p', 'description' => 'TAO password')));
//
$exts = common_ext_ExtensionsManager::singleton()->getInstalledExtensions();
foreach (common_ext_ExtensionsManager::singleton()->getAvailableExtensions() as $ext) {
    $exts[] = $ext;
}
$exts = helpers_ExtensionHelper::sortByDependencies($exts);
$extIds = array();
foreach ($exts as $ext) {
    if (file_exists($ext->getDir() . 'locales')) {
        $extIds[] = $ext->getId();
    } else {
        echo 'Skipping ' . $ext->getId() . PHP_EOL;
    }
}
foreach ($extIds as $extId) {
    $options = array('argv' => array("taoTranslate.php", "-e", $extId, "-a", "updateAll"));
    echo PHP_EOL . 'Updating and compiling ' . $extId . PHP_EOL;
    new tao_scripts_TaoTranslate($inputFormat, $options);
    $options = array('argv' => array("taoTranslate.php", "-e", $extId, "-a", "compileAll"));
    new tao_scripts_TaoTranslate($inputFormat, $options);
}