Exemplo n.º 1
0
 public function longHelp($params)
 {
     if (count($params) == 0) {
         $this->line('Invoques a plugin subcommand');
         $this->line('Usage:');
         $this->line('plugin [PLUGIN_NAME] [COMMAND_NAME] [[COMMAND_PARAMETERS]]');
         $this->line('');
         $this->line('You can get a description of the plugin and list the available subcommands using:');
         $this->line('help plugin [PLUGIN_NAME]');
         $this->line('You can also get help from subcommands if provided using:');
         $this->line('help plugin [PLUGIN_NAME] [COMMAND_NAME]');
         $this->line('============');
         $this->line('Here is a list of available plugins:');
         $dir = dirname(realpath(__FILE__));
         $pluginsPath = realpath($dir . '/../plugins/');
         foreach (FileUtils::getFolders($pluginsPath) as $adir) {
             if (ereg('^\\.', basename($adir))) {
                 continue;
             }
             $this->line(basename($adir));
         }
     } elseif (count($params) == 1) {
         $plugin = $params[0];
         $pluginPath = 'M/plugins/' . $plugin . '/';
         if (!FileUtils::file_exists_incpath($pluginPath . 'commands/help.php')) {
             if (!FileUtils::file_exists_incpath('M/plugins/' . $plugin)) {
                 throw new Exception($plugin . ' plugin does not exist');
             } else {
                 $this->line('no description for ' . $plugin . ' plugin');
             }
         } else {
             require_once 'M/plugins/' . $plugin . '/commands/help.php';
             $className = $plugin . '_Command_help';
             $h = new $className();
             $h->execute();
         }
         $this->line('============');
         $this->line('Here is a list of available commands for this plugin:');
         $dir = dirname(realpath(__FILE__));
         $commandsPath = realpath($dir . '/../../' . $pluginPath . 'commands/');
         foreach (FileUtils::getAllFiles($commandsPath) as $file) {
             $commandname = basename($file, '.php');
             if ($commandname == 'help') {
                 continue;
             }
             $className = $plugin . '_Command_' . $commandname;
             require_once $file;
             $newcommand = new $className();
             $this->line('');
             $this->line($commandname);
             $newcommand->shortHelp();
         }
     } else {
         $plugin = array_shift($params);
         $command = array_shift($params);
         $this->getPluginCommand($plugin, $command, $params)->longHelp();
     }
 }
Exemplo n.º 2
0
 protected function _regenerateAssets()
 {
     $this->header('Regenerating assets');
     $version_file = APP_ROOT . 'app/ASSETSVERSION';
     $assetsversion = (int) file_get_contents($version_file);
     $assetsversion++;
     file_put_contents($version_file, $assetsversion);
     $assetsfolder = APP_ROOT . 'public/assets/';
     $jsfolder = $assetsfolder . 'js/';
     foreach (FileUtils::getFolders($jsfolder) as $folder) {
         if (preg_match('`^\\.`', $folder)) {
             continue;
         }
         $this->line('Regenerating ' . $folder . ' javascript asset');
         $out = '';
         foreach (FileUtils::getAllFiles($jsfolder . $folder) as $file) {
             $out .= file_get_contents($file) . "\n";
         }
         if (MODE == 'production') {
             $out = JSmin::minify($out);
         }
         $version = self::getOption('assetsurlrewriting') ? '' : $assetsversion;
         file_put_contents(APP_ROOT . 'public/cache/' . $folder . $version . '.js', $out);
     }
     // css
     $cssfolder = $assetsfolder . 'css/';
     foreach (FileUtils::getFolders($cssfolder) as $folder) {
         if (preg_match('`^\\.`', $folder)) {
             continue;
         }
         $this->line('Regenerating ' . $folder . ' CSS asset');
         $out = '';
         foreach (FileUtils::getAllFiles($cssfolder . $folder) as $file) {
             $out .= file_get_contents($file) . "\n";
         }
         if (MODE == 'production') {
             $out = CSSmin::minify($out);
         }
         $version = self::getOption('assetsurlrewriting') ? '' : $assetsversion;
         file_put_contents(APP_ROOT . 'public/cache/' . $folder . $version . '.css', $out);
     }
 }