/**
  * install an extension
  *
  * @access public
  * @author Jerome Bogaerts, <*****@*****.**>
  * @return void
  */
 public function install()
 {
     common_Logger::i('Installing extension ' . $this->extension->getId(), 'INSTALL');
     if ($this->extension->getId() == 'generis') {
         throw new common_ext_ForbiddenActionException('Tried to install generis using the ExtensionInstaller', $this->extension->getId());
     }
     if (common_ext_ExtensionsManager::singleton()->isInstalled($this->extension->getId())) {
         throw new common_ext_AlreadyInstalledException('Problem installing extension ' . $this->extension->getId() . ' : Already installed', $this->extension->getId());
     }
     // we purge the whole cache.
     $cache = common_cache_FileCache::singleton();
     $cache->purge();
     // check reuired extensions, throws exception if failed
     helpers_ExtensionHelper::checkRequiredExtensions($this->getExtension());
     $this->installLoadDefaultConfig();
     $this->installOntology();
     $this->installRegisterExt();
     common_Logger::d('Installing custom script for extension ' . $this->extension->getId());
     $this->installCustomScript();
     common_Logger::d('Done installing custom script for extension ' . $this->extension->getId());
     if ($this->getLocalData() == true) {
         common_Logger::d('Installing local data for extension ' . $this->extension->getId());
         $this->installLocalData();
         common_Logger::d('Done installing local data for extension ' . $this->extension->getId());
     }
     common_Logger::d('Extended install for extension ' . $this->extension->getId());
     // Method to be overriden by subclasses
     // to extend the installation mechanism.
     $this->extendedInstall();
     common_Logger::d('Done extended install for extension ' . $this->extension->getId());
     $eventManager = ServiceManager::getServiceManager()->get(EventManager::CONFIG_ID);
     $eventManager->trigger(new common_ext_event_ExtensionInstalled($this->extension));
 }
 /**
  * uninstall an extension
  *
  * @access public
  * @author Jerome Bogaerts, <*****@*****.**>
  * @return boolean
  */
 public function uninstall()
 {
     common_Logger::i('Uninstalling ' . $this->extension->getId(), 'UNINSTALL');
     // uninstall possible
     if (is_null($this->extension->getManifest()->getUninstallData())) {
         throw new common_Exception('Problem uninstalling extension ' . $this->extension->getId() . ' : Uninstall not supported');
     }
     // installed?
     if (!common_ext_ExtensionsManager::singleton()->isInstalled($this->extension->getId())) {
         throw new common_Exception('Problem uninstalling extension ' . $this->extension->getId() . ' : Not installed');
     }
     // check dependcies
     if (helpers_ExtensionHelper::isRequired($this->extension)) {
         throw new common_Exception('Problem uninstalling extension ' . $this->extension->getId() . ' : Still required');
     }
     common_Logger::d('uninstall script for ' . $this->extension->getId());
     $this->uninstallScripts();
     // hook
     $this->extendedUninstall();
     common_Logger::d('unregister extension ' . $this->extension->getId());
     $this->unregister();
     // we purge the whole cache.
     $cache = common_cache_FileCache::singleton();
     $cache->purge();
     common_Logger::i('Uninstalled ' . $this->extension->getId());
     return true;
 }
 /**
  * Index page
  */
 public function index()
 {
     $extensionManager = \common_ext_ExtensionsManager::singleton();
     $all = array();
     $installed = array();
     foreach ($extensionManager->getInstalledExtensions() as $ext) {
         $all[] = $ext;
         $installed[] = $ext->getId();
     }
     foreach ($extensionManager->getAvailableExtensions() as $ext) {
         $all[] = $ext;
     }
     $all = \helpers_ExtensionHelper::sortById($all);
     $this->setData('extensions', $all);
     $this->setData('installedIds', $installed);
     $this->setView('extensionManager/view.tpl');
 }
Exemple #4
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;
 protected function getMissingExtensions()
 {
     $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;
     }
     return $missingExt;
 }
Exemple #6
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);
}