예제 #1
0
파일: Cli.class.php 프로젝트: davbfr/cf
 public static function clean()
 {
     self::enableHelp();
     self::pinfo("Clean the application cache");
     Plugins::dispatchAll("clean");
 }
예제 #2
0
파일: cf.php 프로젝트: davbfr/cf
    die("ROOT_DIR not defined." . PHP_EOL);
}
Options::set("CF_DIR", dirname(__FILE__), "Path to the framework");
Options::set("CF_PLUGINS_DIR", CF_DIR);
Options::set("PLUGINS_DIR", ROOT_DIR . DIRECTORY_SEPARATOR . "plugins");
Options::set("ROOT_DIR", dirname(CF_DIR));
Options::set("CONFIG_DIR", ROOT_DIR . DIRECTORY_SEPARATOR . "config");
Options::set("CORE_PLUGIN", "Core");
Options::set("FORCE_HTTPS", false);
Options::set("USE_STS", false);
Options::set("DEFAULT_TIMEZONE", "Europe/Paris");
Options::set("DEBUG", false);
Options::set("IS_CLI", defined("STDIN") && substr(php_sapi_name(), 0, 3) == "cli");
Options::set("IS_PHAR", substr(__FILE__, 0, 7) == "phar://");
if (!IS_CLI && FORCE_HTTPS && $_SERVER["HTTPS"] != "on") {
    if (USE_STS) {
        header('Strict-Transport-Security: max-age=500');
    } else {
        header('Status-Code: 301');
        header("Location: https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
        Output::finish(301);
    }
}
date_default_timezone_set(DEFAULT_TIMEZONE);
if (function_exists('mb_internal_encoding')) {
    mb_internal_encoding('UTF-8');
}
Plugins::registerAutoload();
Plugins::add(CORE_PLUGIN, Plugins::CORE);
Plugins::addApp();
예제 #3
0
파일: Core.plugin.php 프로젝트: davbfr/cf
 public static function bootstrap()
 {
     ErrorHandler::Init(__NAMESPACE__ . "\\ErrorHandler");
     self::loadConfig();
     if (array_key_exists("PATH_INFO", $_SERVER) && $_SERVER["PATH_INFO"]) {
         Rest::handle();
     }
     $conf = Config::getInstance();
     $tpt = new TemplateRes(array("title" => $conf->get("title", "CF " . CF_VERSION), "description" => $conf->get("description", null), "favicon" => $conf->get("favicon", null)));
     foreach (Plugins::dispatchAll("index", $tpt) as $index) {
         if ($index !== null) {
             $tpt->output($index);
         }
     }
     return $tpt;
 }
예제 #4
0
파일: Crud.class.php 프로젝트: davbfr/cf
 public static function create()
 {
     $create_tpt = Cli::addSwitch("t", "Create templates");
     $models = Cli::getInputs("models", "Model names to create");
     Cli::enableHelp();
     $config = Config::getInstance();
     $rest = Plugins::get(Plugins::APP_NAME)->getDir() . DIRECTORY_SEPARATOR . self::REQUEST_DIR;
     System::ensureDir($rest);
     $ctrl = WWW_DIR . "/app/crud";
     System::ensureDir($ctrl);
     foreach ($models as $model) {
         $className = ucfirst($model) . "Rest";
         $modelClass = ucfirst($model) . "Model";
         Cli::pinfo(" * " . $className);
         $filename = $rest . "/" . $className . ".class.php";
         $tpt = new Template(array("className" => $className, "model" => $model, "umodel" => ucfirst($model), "modelClass" => $modelClass));
         if (!file_exists($filename)) {
             $f = fopen($filename, "w");
             fwrite($f, $tpt->parse("crud-rest-skel.php"));
             fclose($f);
         }
         $filename = $ctrl . "/" . $className . ".js";
         if (!file_exists($filename)) {
             $f = fopen($filename, "w");
             fwrite($f, $tpt->parse("crud-app-skel.php"));
             fclose($f);
         }
         if ($create_tpt) {
             $templates = Plugins::get(Plugins::APP_NAME)->getDir() . DIRECTORY_SEPARATOR . Template::TEMPLATES_DIR;
             System::ensureDir($templates);
             $afields = $config->get("model." . $model);
             $fields = array();
             foreach ($afields as $name => $prop) {
                 $fields[$name] = new ModelField($model, $name, $prop);
             }
             $options = self::defaultOptions();
             $tpt = new Template(array_merge($options, array("model" => $fields)));
             $filename = $templates . "/" . $model . "-crud-list.php";
             if (!file_exists($filename)) {
                 $f = fopen($filename, "w");
                 fwrite($f, $tpt->parse($options["list_partial"]));
                 fclose($f);
             }
             $filename = $templates . "/" . $model . "-crud-detail.php";
             if (!file_exists($filename)) {
                 $f = fopen($filename, "w");
                 fwrite($f, $tpt->parse($options["detail_partial"]));
                 fclose($f);
             }
         }
     }
 }
예제 #5
0
 public static function runtests()
 {
     Cli::pinfo("Running tests");
     ErrorHandler::unregister();
     // Create Suite
     foreach (Plugins::get_plugins() as $name) {
         $result = new PHPUnit_Framework_TestResult();
         $listner = new self($name);
         $result->addListener($listner);
         $plugin = Plugins::get($name);
         $dir = $plugin->getDir() . DIRECTORY_SEPARATOR . self::TESTS_DIR;
         if (is_dir($dir)) {
             foreach (glob($dir . DIRECTORY_SEPARATOR . "*.test.php") as $file) {
                 require_once $file;
                 $testclassname = __NAMESPACE__ . "\\" . substr(basename($file), 0, -9) . "Test";
                 $suite = new PHPUnit_Framework_TestSuite(new ReflectionClass($testclassname));
                 $suite->run($result);
             }
         }
         if ($listner->dot) {
             Cli::pcolorln(Cli::ansiinfo, "]");
         }
     }
 }