Example #1
0
 function showTabPluginsAction()
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->assign('path', $this->_TPL_PATH);
     // Auto synchronize when viewing Config->Extensions
     DevblocksPlatform::readPlugins();
     if (DEVELOPMENT_MODE) {
         DAO_Platform::cleanupPluginTables();
     }
     $plugins = DevblocksPlatform::getPluginRegistry();
     unset($plugins['devblocks.core']);
     unset($plugins['feg.core']);
     unset($plugins['feg.auditlog']);
     $tpl->assign('plugins', $plugins);
     $license = FegLicense::getInstance();
     $tpl->assign('license', $license);
     $tpl->display('file:' . $this->_TPL_PATH . 'setup/tabs/plugins/index.tpl');
 }
Example #2
0
 /**
  * Reads and caches manifests from the plugin directory.
  *
  * @static 
  * @return DevblocksPluginManifest[]
  */
 static function readPlugins()
 {
     $dir = DEVBLOCKS_PLUGIN_PATH;
     $plugins = array();
     if (is_dir($dir)) {
         if ($dh = opendir($dir)) {
             while (($file = readdir($dh)) !== false) {
                 if ($file == "." || $file == ".." || 0 == strcasecmp($file, "CVS")) {
                     continue;
                 }
                 $path = $dir . '/' . $file;
                 if (is_dir($path) && file_exists($path . '/plugin.xml')) {
                     $manifest = self::_readPluginManifest($file);
                     /* @var $manifest DevblocksPluginManifest */
                     if (null != $manifest) {
                         $plugins[] = $manifest;
                     }
                     /*
                      * [TODO] Somehow here we need to cache the classes from the plugin so
                      * we don't have to load up the file unless we need it.
                      * 
                      * The main place this happens is when some class from a plugin gets 
                      * persisted in the session.
                      */
                     //	                   $instance = $manifest->createInstance();
                     //	                   $instance->load($manifest);
                 }
             }
             closedir($dh);
         }
     }
     // [TODO] Instance the plugins in dependency order
     //		$plugin_instance = $manifest->createInstance();
     //		if(!$plugin_instance->install($manifest))
     //			return;
     DAO_Platform::cleanupPluginTables();
     DevblocksPlatform::clearCache();
     return $plugins;
     // [TODO] Move this to the DB
 }
Example #3
0
 private function _initPlugins()
 {
     // Load all the exported classes defined by plugin manifests
     $class_map = DAO_Platform::getClassLoaderMap();
     if (is_array($class_map) && !empty($class_map)) {
         foreach ($class_map as $path => $classes) {
             $this->registerClasses($path, $classes);
         }
     }
 }
Example #4
0
 static function update()
 {
     // Update the platform
     if (!DevblocksPlatform::update()) {
         throw new Exception("Couldn't update Devblocks.");
     }
     // Read in plugin information from the filesystem to the database
     DevblocksPlatform::readPlugins();
     // Clean up missing plugins
     DAO_Platform::cleanupPluginTables();
     // Registry
     $plugins = DevblocksPlatform::getPluginRegistry();
     // Update the application core (version by version)
     if (!isset($plugins['feg.core'])) {
         throw new Exception("Couldn't read application manifest.");
     }
     $plugin_patches = array();
     // Load patches
     foreach ($plugins as $p) {
         /* @var $p DevblocksPluginManifest */
         if ('devblocks.core' == $p->id) {
             continue;
         }
         // Don't patch disabled plugins
         if ($p->enabled) {
             $plugin_patches[$p->id] = $p->getPatches();
         }
     }
     $core_patches = $plugin_patches['feg.core'];
     unset($plugin_patches['feg.core']);
     /*
      * For each core release, patch plugins in dependency order
      */
     foreach ($core_patches as $patch) {
         /* @var $patch DevblocksPatch */
         if (!file_exists($patch->getFilename())) {
             throw new Exception("Missing application patch: " . $path);
         }
         $version = $patch->getVersion();
         if (!$patch->run()) {
             throw new Exception("Application patch failed to apply: " . $path);
         }
         // Patch this version and then patch plugins up to this version
         foreach ($plugin_patches as $plugin_id => $patches) {
             $pass = true;
             foreach ($patches as $k => $plugin_patch) {
                 // Recursive patch up to _version_
                 if ($pass && version_compare($plugin_patch->getVersion(), $version, "<=")) {
                     if ($plugin_patch->run()) {
                         unset($plugin_patches[$plugin_id][$k]);
                     } else {
                         $plugins[$plugin_id]->setEnabled(false);
                         $pass = false;
                     }
                 }
             }
         }
     }
     return TRUE;
 }
Example #5
0
 /**
  * @return boolean
  */
 public function hasRun()
 {
     // Compare PLUGIN_ID + REVISION in script history
     return DAO_Platform::hasPatchRun($this->plugin_id, $this->revision);
 }
Example #6
0
 /**
  * Reads and caches manifests from the features + plugins directories.
  *
  * @static 
  * @return DevblocksPluginManifest[]
  */
 static function readPlugins()
 {
     $scan_dirs = array('features', 'storage/plugins');
     $plugins = array();
     if (is_array($scan_dirs)) {
         foreach ($scan_dirs as $scan_dir) {
             $scan_path = APP_PATH . '/' . $scan_dir;
             if (is_dir($scan_path)) {
                 if ($dh = opendir($scan_path)) {
                     while (($file = readdir($dh)) !== false) {
                         if ($file == "." || $file == "..") {
                             continue;
                         }
                         $plugin_path = $scan_path . '/' . $file;
                         $rel_path = $scan_dir . '/' . $file;
                         if (is_dir($plugin_path) && file_exists($plugin_path . '/plugin.xml')) {
                             $manifest = self::_readPluginManifest($rel_path);
                             /* @var $manifest DevblocksPluginManifest */
                             if (null != $manifest) {
                                 $plugins[] = $manifest;
                             }
                         }
                     }
                     closedir($dh);
                 }
             }
         }
     }
     // [TODO] Instance the plugins in dependency order
     DAO_Platform::cleanupPluginTables();
     DevblocksPlatform::clearCache();
     return $plugins;
 }