/**
  *  Ethna 本体付属のプラグインのソースを include する
  *
  *  @access public
  *  @param  string  $type   プラグインの種類
  *  @param  string  $name   プラグインの名前
  *  @static
  */
 function includeEthnaPlugin($type, $name)
 {
     Ethna_Plugin::includePlugin($type, $name, 'Ethna');
 }
示例#2
0
 /**
  *  Ethna_Controllerクラスのコンストラクタ
  *
  *  @access     public
  */
 public function __construct($gateway = GATEWAY_WWW)
 {
     $this->setupEventDispatcher();
     $this->registerSubscriber();
     $GLOBALS['_Ethna_controller'] = $this;
     if ($this->base === "") {
         // EthnaコマンドなどでBASEが定義されていない場合がある
         if (defined('BASE')) {
             $this->base = BASE;
         }
     }
     $this->gateway = $gateway;
     // クラス設定の未定義値を補完
     foreach ($this->class_default as $key => $val) {
         if (isset($this->class[$key]) == false) {
             $this->class[$key] = $val;
         }
     }
     // ディレクトリ設定の未定義値を補完
     foreach ($this->directory_default as $key => $val) {
         if (isset($this->directory[$key]) == false) {
             $this->directory[$key] = $val;
         }
     }
     // クラスファクトリオブジェクトの生成
     $class_factory = $this->class['class'];
     $this->class_factory = new $class_factory($this, $this->class);
     // ログ管理オブジェクトの用意
     $this->logger = $this->getLogger();
     // エラーハンドラの設定
     Ethna::setErrorCallback(array($this, 'handleError'));
     // ディレクトリ名の設定(相対パス->絶対パス)
     foreach ($this->directory as $key => $value) {
         if ($key == 'plugins') {
             // Smartyプラグインディレクトリは配列で指定する
             $tmp = array();
             foreach (to_array($value) as $elt) {
                 if (Ethna_Util::isAbsolute($elt) == false) {
                     $tmp[] = $this->base . (empty($this->base) ? '' : '/') . $elt;
                 }
             }
             $this->directory[$key] = $tmp;
         } else {
             if (Ethna_Util::isAbsolute($value) == false) {
                 $this->directory[$key] = $this->base . (empty($this->base) ? '' : '/') . $value;
             }
         }
     }
     // 遷移先設定をマージ
     // 但し、キーは完全に維持する
     $this->forward = $this->forward + $this->forward_default;
     // 初期設定
     // フレームワークとしての内部エンコーディングはクライアント
     // エンコーディング(=ブラウザからのエンコーディング)
     //
     // @see Ethna_Controller#_getDefaultLanguage
     list($this->locale, $this->system_encoding, $this->client_encoding) = $this->_getDefaultLanguage();
     if (extension_loaded('mbstring')) {
         mb_internal_encoding($this->client_encoding);
         mb_regex_encoding($this->client_encoding);
     }
     $this->config = $this->getConfig();
     $this->dsn = $this->_prepareDSN();
     $this->url = $this->config->get('url');
     if (empty($this->url) && PHP_SAPI != 'cli') {
         $this->url = Ethna_Util::getUrlFromRequestUri();
         $this->config->set('url', $this->url);
     }
     // プラグインオブジェクトの用意
     $this->plugin = $this->getPlugin();
     $this->plugin->setLogger($this->logger);
     // include Ethna_Plugin_Abstract for all plugins
     $this->plugin->includePlugin('Abstract');
     // ログ出力開始
     $this->logger->begin();
 }