Esempio n. 1
0
    /**
     * setupを開始する
     */
    public static function start()
    {
        Repository::load_map(getcwd() . "/__repository__.xml");
        $req = new Request("_inc_session_=false");
        if (!$req->is_cli()) {
            exit;
        }
        if (!is_file(File::absolute(getcwd(), "__settings__.php"))) {
            $app_install = Command::stdin("install application");
            if (!empty($app_install)) {
                try {
                    self::download($app_install);
                } catch (RuntimeException $e) {
                    self::error_print("not foud application " . $app_install);
                    exit;
                }
            }
        }
        $settings_path = File::absolute(getcwd(), "__settings__.php");
        if (!is_file($settings_path)) {
            $ref = new ReflectionClass("Object");
            $jump_path = str_replace("\\", "/", dirname(dirname($ref->getFileName())));
            $pwd = str_replace("\\", "/", getcwd());
            $url = Command::stdin("application url", "http://localhost/" . basename(getcwd()));
            if (!empty($url) && substr($url, -1) != "/") {
                $url .= "/";
            }
            $work = Command::stdin("working directory", App::work());
            $mode = Command::stdin("application mode");
            App::config_path($pwd, $url, $work, $mode);
            $config = sprintf(Text::plain('
								<?php
								require_once("%s/jump.php");
								App::config_path(__FILE__,"%s","%s","%s");
							'), $jump_path, $url, $work, $mode);
            File::write($settings_path, $config . "\n");
        } else {
            $maxlen = 0;
            $cmd = $value = null;
            if ($req->is_vars()) {
                $keys = array_keys($req->vars());
                $cmd = array_shift($keys);
                $value = $req->in_vars($cmd);
            }
            self::search_cmd($req, $cmd, $value, $maxlen, __CLASS__);
            foreach (Lib::classes(true, true) as $path => $name) {
                self::search_cmd($req, $cmd, $value, $maxlen, $path);
            }
            self::info($maxlen);
        }
    }
Esempio n. 2
0
 /**
  * 初期定義
  *
  * @param string $path アプリケーションのルートパス
  * @param string $url アプリケーションのURL
  * @param string $work 一時ファイルを書き出すパス
  * @param string $mode モード
  */
 public static function config_path($path, $url = null, $work = null, $mode = null)
 {
     if (empty($path)) {
         $debug = debug_backtrace(false);
         $debug = array_pop($debug);
         $path = $debug['file'];
     }
     if (is_file($path)) {
         $path = dirname($path);
     }
     self::$path = preg_replace("/^(.+)\\/\$/", "\\1", str_replace("\\", "/", $path)) . "/";
     if (isset($work)) {
         if (is_file($work)) {
             $work = dirname($work);
         }
         self::$work = preg_replace("/^(.+)\\/\$/", "\\1", str_replace("\\", "/", $work)) . "/";
     } else {
         self::$work = self::$path . 'work/';
     }
     if (!empty($url)) {
         self::$url = preg_replace("/^(.+)\\/\$/", "\\1", $url) . "/";
         self::$surl = preg_replace("/^http:\\/\\/(.+)\$/", "https://\$1", self::$url);
     }
     if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         list($lang) = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
         list($lang) = explode('-', $lang);
         self::lang($lang);
         self::set_messages(self::$path);
     }
     self::$mode = empty($mode) ? 'noname' : $mode;
     if (is_file(App::path('__repository__.xml'))) {
         Repository::load_map(App::path('__repository__.xml'));
     }
     if (is_file(App::path('__common__.php'))) {
         require_once App::path('__common__.php');
     }
     if (is_file(App::path('__common_' . $mode) . '__.php')) {
         require_once App::path('__common_' . $mode . '__.php');
     }
 }