コード例 #1
0
ファイル: Flow.php プロジェクト: tokushima/rhaco3
 public function __construct($app_url = null)
 {
     $entry_file = $this->entry_file();
     $branch_url = basename($entry_file);
     $rewrite = \org\rhaco\Conf::get('rewrite_entry');
     $this->app_url = \org\rhaco\Conf::get('app_url');
     $this->media_url = \org\rhaco\Conf::get('media_url');
     $path = function ($url) {
         if (!empty($url)) {
             $url = str_replace('\\', '/', $url);
             if (substr($url, -1) != '/') {
                 $url .= '/';
             }
         }
         return $url;
     };
     if (empty($this->app_url)) {
         $host = \org\rhaco\Request::host();
         if (!empty($host)) {
             $hasport = (bool) preg_match('/:\\d+/', $host);
             $this->app_url = $host . ($hasport ? '' : '/' . dirname(preg_replace("/.+\\/workspace\\/(.+)/", "\\1", $entry_file)));
             if (!isset($rewrite)) {
                 $rewrite = $hasport ? false : true;
             }
         } else {
             $this->app_url = 'http://localhost:8000/';
             $rewrite = false;
         }
     }
     if (substr($branch_url, 0, 1) == '/') {
         $branch_url = substr($branch_url, 1);
     }
     if ($rewrite === null || $rewrite === true) {
         $branch_url = basename($branch_url, '.php');
         if ($branch_url == 'index') {
             $branch_url = '';
         }
     }
     $this->app_url = str_replace('https://', 'http://', $path($this->app_url));
     $this->branch_url = $this->app_url . $path($branch_url);
     $this->media_url = $path(empty($this->media_url) ? $this->app_url . 'resources/media/' : $this->media_url);
     $this->template_path = $path(\org\rhaco\Conf::get('template_path', \org\rhaco\io\File::resource_path('templates')));
     $this->template = new \org\rhaco\Template();
 }