コード例 #1
0
ファイル: dispatcher.php プロジェクト: 4bs4/marifa
 /**
  * Despachamos una petición.
  */
 public static function dispatch()
 {
     // Obtenemos los parametros.
     $params = Shell_Cli::parse_args($_SERVER['argv']);
     // Obtenemos el controlador.
     if (!isset($params[0]) || $params[0] == 'help') {
         // Usamos de ayuda.
         $controller = 'Shell_Controller_Ayuda';
     } else {
         // Armamos el nombre.
         $c_name = ucfirst(strtolower($params[0]));
         $c_name = preg_replace('/\\s/', '_', $c_name);
         if (!class_exists('Shell_Controller_' . $c_name)) {
             Shell_Cli::write_line(Shell_Cli::get_colored_string("Parámetros incorrectos, intente llamando a la ayuda con --help", 'red'));
             exit;
         } else {
             $controller = 'Shell_Controller_' . $c_name;
         }
     }
     $c = new $controller($params);
     $c->start();
 }
コード例 #2
0
ファイル: generador.php プロジェクト: 4bs4/marifa
 /**
  * Obtenemos el código PHP del archivo a parsear.
  * @param string $file Nombre del archivo.
  * @param string $class Clase a extender.
  * @param string $subpackage Subpaquete del bloque phpdoc.
  * @param string $alias Alias de la clase.
  * @return bool Resultado de la ejecución.
  */
 protected function make_template($file, $class, $subpackage, $alias)
 {
     $t = "<?php\n/**\n * {{FILE}} is part of Marifa.\n *\n * Marifa is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * Marifa is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with Marifa. If not, see <http://www.gnu.org/licenses/>.\n *\n * @license     http://www.gnu.org/licenses/gpl-3.0-standalone.html GNU Public License\n * @filesource\n * @package\t\tMarifa\\Base{{SUBPACKAGE1}}\n */\ndefined('APP_BASE') || die('No direct access allowed.');\n\n/**\n * Alias de {{BASE_CLASS_NAME}}\n *\n * @package    Marifa\\Marifa{{SUBPACKAGE2}}\n */\n{{DECLARACION}}";
     $t = str_replace('{{DECLARACION}}', $class, $t);
     $t = str_replace('{{BASE_CLASS_NAME}}', $alias, $t);
     $t = str_replace('{{SUBPACKAGE1}}', trim($subpackage) == '' ? '' : "\n * @subpackage  {$subpackage}", $t);
     $t = str_replace('{{SUBPACKAGE2}}', trim($subpackage) == '' ? '' : "\n * @subpackage {$subpackage}", $t);
     $t = str_replace('{{FILE}}', basename($file), $t);
     // Creamos el path.
     $base_dir = dirname($file);
     if (!file_exists($base_dir)) {
         mkdir($base_dir, 0777, TRUE);
     }
     if (!file_exists($file)) {
         if (!file_put_contents($file, $t)) {
             Shell_Cli::write_line(Shell_Cli::get_colored_string("ERROR: {$file}", 'red'));
             return FALSE;
         }
     }
     return TRUE;
 }
コード例 #3
0
ファイル: migration.php プロジェクト: 4bs4/marifa
 /**
  * Verificamos el estado de configuración de la base de datos.
  */
 protected static function check_db_status()
 {
     // Verificamos coneccion a la base de datos.
     try {
         $db = Database::get_instance();
     } catch (Database_Exception $e) {
         Shell_Cli::write_line(Shell_Cli::get_colored_string('Error ', 'red') . $e->getCode() . ': ' . $e->getMessage());
     }
     Shell_Cli::write_line('Conección DB: ' . Shell_Cli::get_colored_string('OK', 'green'));
     // Intentamos crear la tabla de migraciones.
     try {
         $db->insert('CREATE TABLE IF NOT EXISTS `migraciones` ( `numero` INTEGER NOT NULL, `fecha` DATETIME NOT NULL, PRIMARY KEY (`numero`) );');
     } catch (Database_Exception $e) {
         Shell_Cli::write_line(Shell_Cli::get_colored_string('Error ', 'red') . $e->getCode() . ': ' . $e->getMessage());
     }
 }