コード例 #1
0
function cli_main($argv)
{
    $argc = count($argv);
    if ($argc < 2) {
        die("Usage: zombie.php <app name> <template=template_name> <option=value> ...\n");
    }
    $app = $argv[1];
    $options = array();
    for ($i = 2; $i < $argc; ++$i) {
        $opt = explode("=", $argv[$i], 2);
        if (count($opt) == 2) {
            $options[$opt[0]] = $opt[1];
        } else {
            $options[$opt[0]] = true;
        }
    }
    $template = isset($options['template']) ? $options['template'] : 'basic';
    if (!file_exists("brainz/template/" . $template . "/template.php")) {
        die("unknown template: " . $template . "\n");
    }
    require __DIR__ . "/brainz/template/" . $template . "/template.php";
    $template_class = underscore_to_class($template . "_template");
    $template = new $template_class($template, $app, $options);
    $template->run();
}
コード例 #2
0
 function prepare()
 {
     $class = underscore_to_class($this->app);
     $options = array('template' => $this->template, 'app' => $this->app, 'create_app' => true, 'create_model' => true, 'views' => array('index'), 'slug' => $this->app, 'class' => $class, 'model_class' => $class . "Model");
     $this->options = array_merge($this->options, $options);
     $this->replace = array('SLUG' => $this->app, 'CLASS_NAME' => $class, 'MODEL_CLASS_NAME' => $class . "Model");
     $this->files = array();
     array_push($this->files, new TemplateFile($this->zombie_root . "/apps/" . $this->app . "/" . $this->app . ".php", $this->zombie_root . "/brainz/template/" . $this->template . "/app/app.php"));
 }
コード例 #3
0
ファイル: home.php プロジェクト: regality/Zombie-PHP-Website
 public function default_run($request)
 {
     $this->token = $this->get_csrf_token();
     $this->request = $request;
     $this->menu = new Menu();
     $this->console = new Console();
     if ($this->action == 'index') {
         $this->action = 'welcome';
     }
     $this->preload_action = isset($request['preload_action']) ? $request['preload_action'] : "index";
     if (class_exists($this->action)) {
         $preload_class = underscore_to_class($this->action);
         $this->preload = new $preload_class();
     } else {
         $this->view = '404';
     }
 }
コード例 #4
0
ファイル: app.php プロジェクト: regality/Zombie-PHP-Website
<?php

require "../brainz/config.php";
require_once "../brainz/util/util.php";
if (isset($_GET['app'])) {
    // sanitize the app name: only letters, numbers, underscores, and slashes
    $app = preg_replace('/[^0-9a-zA-Z_]/', '', $_GET['app']);
    // => app_dir/foo
    if (strpos($app, '/')) {
        $app_name = substr(strrchr($app, '/'), 1);
        // foo
    } else {
        $app_name = $app;
    }
    $app_file = $app_root . '/' . $app . '/' . $app_name . '.php';
    // => root/app/foo/foo.php
    //$app_class = str_replace(' ','', ucwords(str_replace('_', ' ', $app_name))); // app_name => AppName
    $app_class = underscore_to_class($app_name);
    if (!file_exists($app_file)) {
        die("file not found: {$app_file}");
    }
    include $app_file;
    if (class_exists($app_class)) {
        $app = new $app_class();
        $app->run();
    }
} else {
    echo "no app specified";
}
コード例 #5
0
ファイル: app.php プロジェクト: regality/Zombie-PHP-Website
 public function get_model($model)
 {
     require dirname(__FILE__) . "/../../model/{$model}.php";
     $class = underscore_to_class($model) . "Model";
     return new $class();
 }