public function executeCoreInitProject($arguments, $options)
 {
     $targetDir = realpath($_SERVER['PWD']);
     $scriptDir = sgContext::getLibDir();
     if (file_exists($targetDir . '/superglue')) {
         sgCLI::error('A project already exists in this directory.');
         return false;
     }
     if (sgCLI::confirm("Are you sure you want to initialize a superglue project in\n{$targetDir}")) {
         sgCLI::println('Initializing project...', sgCLI::STYLE_HEADER);
         sgToolkit::mkdir($targetDir . '/config', 0755);
         sgToolkit::mkdir($targetDir . '/cache', 0777);
         sgToolkit::mkdir($targetDir . '/cache', 0777);
         sgToolkit::mkdir($targetDir . '/models', 0755);
         sgToolkit::mkdir($targetDir . '/controllers', 0755);
         sgToolkit::mkdir($targetDir . '/views', 0755);
         sgToolkit::mkdir($targetDir . '/plugins', 0755);
         sgToolkit::mkdir($targetDir . '/web', 0755);
         sgToolkit::copy($scriptDir . '/skeleton/web/htaccess-dist', $targetDir . '/web/.htaccess');
         sgToolkit::copy($scriptDir . '/skeleton/web/index.php-dist', $targetDir . '/web/index.php');
         sgToolkit::copy($scriptDir . '/skeleton/config/ProjectConfiguration.class.php-dist', $targetDir . '/config/ProjectConfiguration.class.php');
         sgToolkit::copy($scriptDir . '/skeleton/config/config.php-dist', $targetDir . '/config/config.php');
         sgToolkit::copy($scriptDir . '/skeleton/config/routing.php-dist', $targetDir . '/config/routing.php');
         sgToolkit::copy($scriptDir . '/skeleton/views/index.html', $targetDir . '/views/index.html');
         if (sgToolkit::checkFileLocation($scriptDir, $targetDir)) {
             sgToolkit::symlink($this->relPath($scriptDir, $targetDir) . '/superglue', $targetDir . '/superglue');
         } else {
             sgToolkit::mkdir($targetDir . '/lib', 0755);
             sgToolkit::symlink($scriptDir, $targetDir . '/lib/superglue');
             sgToolkit::symlink($scriptDir, $targetDir . '/superglue');
         }
         sgToolkit::chmod($targetDir . '/superglue', 0755);
         sgCLI::println('Done.', sgCLI::STYLE_INFO);
     }
 }
    public static function uninstall()
    {
        $message = <<<END
Are you you want to uninstall this plugin? Doing this will remove
all of your cms data in the project_root/data/flatcms directory!
END;
        sgCLI::confirm($message);
        sgToolkit::rmdir(sgConfiguration::get('settings.FlatCMSPlugin.data_dir'));
    }
 private function pluginOp($pluginName, $op, $actionString)
 {
     $plugins = sgConfiguration::getPlugins();
     if (isset($plugins[$pluginName])) {
         $plugin = $plugins[$pluginName];
         if (isset($plugin->configuration) && is_object($plugin->configuration) && method_exists($plugin->configuration, $op)) {
             $opString = sgCLI::formatText($op, array('options' => array('bright', 'underscore')), sgCLI::STYLE_CONFIRM, false);
             if (sgCLI::confirm("Are you sure you want to {$opString} the plugin \"{$plugin->name}\"?")) {
                 sgCLI::println(ucwords($actionString) . " Plugin \"{$plugin->name}\":", sgCLI::STYLE_HEADER);
                 sgConfiguration::executePluginHook($plugin, $op);
             }
         } else {
             sgClI::println("Nothing to {$op}.", sgCLI::STYLE_INFO);
         }
     } else {
         sgClI::println("{$pluginName} is not an enabled plugin.", sgCLI::STYLE_ERROR);
     }
 }
Beispiel #4
0
 protected function parseParams($namespace, $task, $cliParams = array())
 {
     sgAutoloader::loadFile('Console_Getopt', dirname(__FILE__) . '/vendor/Console/Getopt.php');
     $arguments = array();
     $options = array();
     $taskDefinition = self::getTask($namespace, $task);
     if (isset($taskDefinition['options']) || isset($taskDefinition['arguments'])) {
         if (!isset($taskDefinition['arguments'])) {
             $taskDefinition['arguments'] = array();
         }
         if (!isset($taskDefinition['options']['short'])) {
             $taskDefinition['options']['short'] = null;
         }
         if (!isset($taskDefinition['options']['long'])) {
             $taskDefinition['options']['long'] = array();
         }
         try {
             $params = Console_Getopt::getopt($cliParams, $taskDefinition['options']['short'], $taskDefinition['options']['long']);
             if (!empty($taskDefinition['arguments']) && (!isset($params[1]) || count($taskDefinition['arguments']) !== count($params[1]))) {
                 throw new Exception('Missing required argument.');
             }
             $arguments = array();
             if (!empty($taskDefinition['arguments'])) {
                 $arguments = array_combine($taskDefinition['arguments'], $params[1]);
             }
             $options = array();
             foreach ($params[0] as $param) {
                 $options[$param[0]] = $param[1];
             }
         } catch (Exception $e) {
             $error = array();
             $error[] = $e->getMessage();
             if (isset($taskDefinition['usage'])) {
                 $error[] = 'Usage: ' . $taskDefinition['usage'];
             }
             sgCLI::error($error);
             return false;
         }
     }
     return array('arguments' => $arguments, 'options' => $options);
 }
    public static function install()
    {
        sgToolkit::touch(sgConfiguration::get('settings.ZendAuthPlugin.passwd_path'));
        $message = <<<END
    You must place the Zend Framework in your project. ZendAuthPlugin will 
    automatically look in project_root/lib/vendor for the Zend dir, or you 
    can specify the lib dir with the config ZendAuthPlugin => zend_lib_path. 
    This path should be the directory containing the Zend dir, without 
    including the Zend/ dir itself. Also remeber to exclude the Zend path from
    the autoloader by adding this line to your ProjectConfiguration before
    the sgAutoload::register() call is made: 
    
    sgAutoloader::setExclusions(array(realpath('path/to/Zend')));
    
    Finally, you must add users to the /data/ZendAuthPlugin.passwd file in the format:

    username:realm:md5(username:realm:password)

END;
        sgCLI::println($message, sgCLI::STYLE_COMMENT);
    }
 public function executeDoctrineCli($arguments = array(), $options = array())
 {
     try {
         DoctrinePluginConfiguration::init();
     } catch (Exception $e) {
         sgCLI::error($e->getMessage());
         return false;
     }
     // spl_autoload_register(array('Doctrine', 'modelsAutoload'));
     spl_autoload_register(array('Doctrine', 'extensionsAutoload'));
     $settings = sgConfiguration::get('settings.DoctrinePlugin');
     $settings['generate_models_options']['suffix'] = '.class.php';
     $config = array('data_fixtures_path' => DoctrinePluginConfiguration::getPath('fixtures'), 'models_path' => DoctrinePluginConfiguration::getPath('models'), 'migrations_path' => DoctrinePluginConfiguration::getPath('mogrations'), 'sql_path' => DoctrinePluginConfiguration::getPath('sql'), 'yaml_schema_path' => DoctrinePluginConfiguration::getPath('schema'), 'generate_models_options' => $settings['generate_models_options']);
     $cg = new Console_Getopt();
     $params = $cg->readPHPArgv();
     $params[0] .= ' ' . $params[1];
     unset($params[1]);
     $params = array_merge($params);
     $cli = new DoctrinePluginCli($config);
     $cli->run($params);
 }
 public static function touch($path, $time = null, $atime = null)
 {
     touch($path, $time, $atime);
     sgCLI::printAction('+file', $path);
 }
Beispiel #8
0
 public static function handleException($exception)
 {
     sgCLI::error($exception->getMessage());
     sgCLI::println($exception);
 }