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); } }
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); } }
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 static function handleException($exception) { sgCLI::error($exception->getMessage()); sgCLI::println($exception); }