OSDN Git Service

- added pre/post filter
[ethna/ethna.git] / class / Ethna_Controller.php
index 6f5e076..03a5746 100644 (file)
@@ -26,7 +26,7 @@ class Ethna_Controller
        /**
         *      @var    string          ¥¢¥×¥ê¥±¡¼¥·¥ç¥óID
         */
-       var $appid = 'PHPSTRUTS';
+       var $appid = 'ETHNA';
 
        /**
         *      @var    string          ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ù¡¼¥¹¥Ç¥£¥ì¥¯¥È¥ê
@@ -49,9 +49,10 @@ class Ethna_Controller
        var $directory = array(
                'action'                => 'app/action',
                'etc'                   => 'etc',
+               'filter'                => 'app/filter',
                'locale'                => 'locale',
                'log'                   => 'log',
-               'plugins'               => array('plugins'),
+               'plugins'               => array(),
                'template'              => 'template',
                'template_c'    => 'tmp',
                'tmp'                   => 'tmp',
@@ -78,11 +79,18 @@ class Ethna_Controller
         */
        var $class = array(
                'config'                => 'Ethna_Config',
+               'db'                    => 'Ethna_DB',
                'logger'                => 'Ethna_Logger',
                'sql'                   => 'Ethna_AppSQL',
        );
 
        /**
+        *      @var    array           ¥Õ¥£¥ë¥¿ÀßÄê
+        */
+       var $filter = array(
+       );
+
+       /**
         *      @var    string          »ÈÍѸÀ¸ìÀßÄê
         */
        var $language;
@@ -155,42 +163,47 @@ class Ethna_Controller
        /**
         *      @var    object  Ethna_Backend   backend¥ª¥Ö¥¸¥§¥¯¥È
         */
-       var $backend;
+       var $backend = null;
 
        /**
         *      @var    object  Ethna_I18N              i18n¥ª¥Ö¥¸¥§¥¯¥È
         */
-       var $i18n;
+       var $i18n = null;
 
        /**
         *      @var    object  Ethna_ActionError       action error¥ª¥Ö¥¸¥§¥¯¥È
         */
-       var $action_error;
+       var $action_error = null;
 
        /**
         *      @var    object  Ethna_ActionForm        action form¥ª¥Ö¥¸¥§¥¯¥È
         */
-       var $action_form;
+       var $action_form = null;
 
        /**
         *      @var    object  Ethna_Session           ¥»¥Ã¥·¥ç¥ó¥ª¥Ö¥¸¥§¥¯¥È
         */
-       var $session;
+       var $session = null;
 
        /**
         *      @var    object  Ethna_Config            ÀßÄꥪ¥Ö¥¸¥§¥¯¥È
         */
-       var     $config;
+       var     $config = null;
 
        /**
         *      @var    object  Ethna_Logger            ¥í¥°¥ª¥Ö¥¸¥§¥¯¥È
         */
-       var     $logger;
+       var     $logger = null;
 
        /**
         *      @var    object  Ethna_AppSQL            SQL¥ª¥Ö¥¸¥§¥¯¥È
         */
-       var     $sql;
+       var     $sql = null;
+
+       /**
+        *      @var    array   ¥Õ¥£¥ë¥¿¡¼¥Á¥§¥¤¥ó(Ethna_Filter¥ª¥Ö¥¸¥§¥¯¥È¤ÎÇÛÎó)
+        */
+       var     $filter_chain = array();
 
        /**#@-*/
 
@@ -205,13 +218,27 @@ class Ethna_Controller
                $GLOBALS['controller'] =& $this;
                $this->base = BASE;
 
+               // ¥¨¥é¡¼¥Ï¥ó¥É¥é¤ÎÀßÄê
+               Ethna::setErrorCallback(array(&$this, 'handleError'));
+
+               // ¥Ç¥£¥ì¥¯¥È¥ê̾¤ÎÀßÄê(ÁêÂХѥ¹->ÀäÂХѥ¹)
                foreach ($this->directory as $key => $value) {
-                       if ($value[0] != '/') {
-                               $this->directory[$key] = $this->base . (empty($this->base) ? '' : '/') . $value;
+                       if ($key == 'plugins') {
+                               // Smarty¥×¥é¥°¥¤¥ó¥Ç¥£¥ì¥¯¥È¥ê¤ÏÇÛÎó¤Ç»ØÄꤹ¤ë
+                               $tmp = array(SMARTY_DIR . 'plugins');
+                               foreach (to_array($value) as $elt) {
+                                       if ($elt{0} != '/') {
+                                               $tmp[] = $this->base . (empty($this->base) ? '' : '/') . $elt;
+                                       }
+                               }
+                               $this->directory[$key] = $tmp;
+                       } else {
+                               if ($value{0} != '/') {
+                                       $this->directory[$key] = $this->base . (empty($this->base) ? '' : '/') . $value;
+                               }
                        }
                }
                $this->i18n =& new Ethna_I18N($this->getDirectory('locale'), $this->getAppId());
-               $this->action_form = null;
                list($this->language, $this->system_encoding, $this->client_encoding) = $this->_getDefaultLanguage();
                $this->client_type = $this->_getDefaultClientType();
 
@@ -235,6 +262,22 @@ class Ethna_Controller
        }
 
        /**
+        *      (¸½ºß¥¢¥¯¥Æ¥£¥Ö¤Ê)¥³¥ó¥È¥í¡¼¥é¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤òÊÖ¤¹
+        *
+        *      @access public
+        *      @return object  Ethna_Controller        ¥³¥ó¥È¥í¡¼¥é¤Î¥¤¥ó¥¹¥¿¥ó¥¹
+        *      @static
+        */
+       function &getInstance()
+       {
+               if (isset($GLOBALS['controller'])) {
+                       return $GLOBALS['controller'];
+               } else {
+                       return null;
+               }
+       }
+
+       /**
         *      ¥¢¥×¥ê¥±¡¼¥·¥ç¥óID¤òÊÖ¤¹
         *
         *      @access public
@@ -261,6 +304,23 @@ class Ethna_Controller
        }
 
        /**
+        *      DSN¤Î»ý³ÀܳÀßÄê¤òÊÖ¤¹
+        *
+        *      @access public
+        *      @param  string  $type   DB¼ïÊÌ
+        *      @return bool    true:persistent false:non-persistent(¤¢¤ë¤¤¤ÏÀßÄê̵¤·)
+        */
+       function getDSN_persistent($type = "")
+       {
+               $key = sprintf("dsn%s_persistent", $type == "" ? "" : "_$type");
+               $dsn_persistent = $this->config->get($key);
+               if (is_null($dsn_persistent)) {
+                       return false;
+               }
+               return $dsn_persistent;
+       }
+
+       /**
         *      ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ù¡¼¥¹URL¤òÊÖ¤¹
         *
         *      @access public
@@ -328,6 +388,21 @@ class Ethna_Controller
        }
 
        /**
+        *      ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥¯¥é¥¹ÀßÄê¤òÊÖ¤¹
+        *
+        *      @access public
+        *      @param  string  $key    ¥¯¥é¥¹¥¿¥¤¥×("config", "db", "logger", "sql")
+        *      @return string  $key¤ËÂбþ¤·¤¿¥¯¥é¥¹Ì¾(ÀßÄ꤬¤Ê¤¤¾ì¹ç¤Ïnull)
+        */
+       function getClass($key)
+       {
+               if (isset($this->class[$key]) == false) {
+                       return null;
+               }
+               return $this->class[$key];
+       }
+
+       /**
         *      ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ç¥£¥ì¥¯¥È¥êÀßÄê¤òÊÖ¤¹
         *
         *      @access public
@@ -578,6 +653,8 @@ class Ethna_Controller
                        $smarty->register_outputfilter($outputfilter);
                }
 
+               $this->_setDefaultTemplateEngine($smarty);
+
                return $smarty;
        }
 
@@ -593,7 +670,7 @@ class Ethna_Controller
        function main($class_name, $action_name = "", $fallback_action_name = "")
        {
                $c =& new $class_name;
-               $c->trigger($action_name, $fallback_action_name);
+               $c->trigger('www', $action_name, $fallback_action_name);
        }
 
        /**
@@ -608,7 +685,7 @@ class Ethna_Controller
        {
                $c =& new $class_name;
                $c->action[$action_name] = array();
-               $c->trigger($action_name);
+               $c->trigger('www', $action_name);
        }
 
        /**
@@ -622,7 +699,7 @@ class Ethna_Controller
        {
                $c =& new $class_name;
                $c->setClientType(CLIENT_TYPE_SOAP);
-               $c->trigger_SOAP();
+               $c->trigger('soap');
        }
 
        /**
@@ -636,22 +713,56 @@ class Ethna_Controller
        {
                $c =& new $class_name;
                $c->setClientType(CLIENT_TYPE_AMF);
-               $c->trigger_AMF();
+               $c->trigger('amf');
        }
 
        /**
         *      ¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Î½èÍý¤ò³«»Ï¤¹¤ë
         *
+        *      @access public
+        *      @param  strint  $type                                   ½èÍý¥¿¥¤¥×(WWW/SOAP/AMF)
+        *      @param  mixed   $default_action_name    »ØÄê¤Î¥¢¥¯¥·¥ç¥ó̾
+        *      @param  mixed   $fallback_action_name   ¥¢¥¯¥·¥ç¥ó̾¤¬·èÄê¤Ç¤­¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¼Â¹Ô¤µ¤ì¤ë¥¢¥¯¥·¥ç¥ó̾
+        *      @return mixed   0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
+        */
+       function trigger($type, $default_action_name = "", $fallback_action_name = "")
+       {
+               // ¥Õ¥£¥ë¥¿¡¼¤ÎÀ¸À®
+               $this->_createFilterChain();
+
+               // prefilter
+               for ($i = 0; $i < count($this->filter_chain); $i++) {
+                       $this->filter_chain[$i]->prefilter();
+               }
+
+               // trigger
+               if ($type == 'www') {
+                       $this->_trigger($default_action_name, $fallback_action_name);
+               } else if ($type == 'soap') {
+                       $this->_trigger_SOAP();
+               } else if ($type == 'amf') {
+                       $this->_trigger_AMF();
+               }
+
+               // postfilter
+               for ($i = count($this->filter_chain) - 1; $i >= 0; $i--) {
+                       $this->filter_chain[$i]->postfilter();
+               }
+       }
+
+       /**
+        *      ¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Î½èÍý¤ò¼Â¹Ô¤¹¤ë(WWW)
+        *
         *      °ú¿ô$default_action_name¤ËÇÛÎ󤬻ØÄꤵ¤ì¤¿¾ì¹ç¡¢¤½¤ÎÇÛÎó¤Ç»ØÄꤵ¤ì¤¿
         *      ¥¢¥¯¥·¥ç¥ó°Ê³°¤Ï¼õ¤±ÉÕ¤±¤Ê¤¤(¤½¤ì°Ê³°¤Î¥¢¥¯¥·¥ç¥ó¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢
         *      ÇÛÎó¤ÎÀèƬ¤Ç»ØÄꤵ¤ì¤¿¥¢¥¯¥·¥ç¥ó¤¬¼Â¹Ô¤µ¤ì¤ë)
         *
-        *      @access public
+        *      @access private
         *      @param  mixed   $default_action_name    »ØÄê¤Î¥¢¥¯¥·¥ç¥ó̾
         *      @param  mixed   $fallback_action_name   ¥¢¥¯¥·¥ç¥ó̾¤¬·èÄê¤Ç¤­¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¼Â¹Ô¤µ¤ì¤ë¥¢¥¯¥·¥ç¥ó̾
         *      @return mixed   0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
         */
-       function trigger($default_action_name = "", $fallback_action_name = "")
+       function _trigger($default_action_name = "", $fallback_action_name = "")
        {
                // ¥¢¥¯¥·¥ç¥ó̾¤Î¼èÆÀ
                $action_name = $this->_getActionName($default_action_name, $fallback_action_name);
@@ -685,26 +796,31 @@ class Ethna_Controller
                $this->backend =& $backend;
                $forward_name = $backend->perform($action_name);
 
-               // ¥³¥ó¥È¥í¡¼¥é¤ÇÁ«°ÜÀè¤ò·èÄꤹ¤ë
+               // ¥³¥ó¥È¥í¡¼¥é¤ÇÁ«°ÜÀè¤ò·èÄꤹ¤ë(¥ª¥×¥·¥ç¥ó)
                $forward_name = $this->_sortForward($action_name, $forward_name);
 
                if ($forward_name != null) {
-                       $backend->preforward($forward_name);
-
-                       if ($this->_forward($forward_name) != 0) {
-                               return -1;
+                       $view_name = $this->getViewClassName($forward_name);
+                       $view_class =& new $view_name($this->backend, $forward_name, $this->_getForwardPath($forward_name));
+                       // ¸åÊý¸ß´¹½èÍý:(
+                       if (is_subclass_of($view_class, 'Ethna_ViewClass') == false) {
+                               $view_class->preforward();
+                               $view_class =& new Ethna_ViewClass($this->backend, $forward_name, $this->_getForwardPath($forward_name));
                        }
+                       $view_class->forward();
                }
 
                return 0;
        }
 
        /**
-        *  SOAP¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Î½èÍý¤ò³«»Ï¤¹¤ë
+        *  SOAP¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Î½èÍý¤ò¼Â¹Ô¤¹¤ë
+        *
+        *      (experimental)
         *
-        *  @access public
+        *  @access private
         */
-       function trigger_SOAP()
+       function _trigger_SOAP()
        {
                // ¥¢¥¯¥·¥ç¥ó¥¹¥¯¥ê¥×¥È¤ò¥¤¥ó¥¯¥ë¡¼¥É
                $this->_includeActionScript();
@@ -721,11 +837,13 @@ class Ethna_Controller
        }
 
        /**
-        *      AMF(Flash Remoting)¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Î½èÍý¤ò³«»Ï¤¹¤ë
+        *      AMF(Flash Remoting)¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Î½èÍý¤ò¼Â¹Ô¤¹¤ë
+        *
+        *      (experimental)
         *
         *      @access public
         */
-       function trigger_AMF()
+       function _trigger_AMF()
        {
                include_once('ethna/contrib/amfphp/app/Gateway.php');
 
@@ -750,15 +868,40 @@ class Ethna_Controller
        }
 
        /**
-        *      Ã×̿Ū¥¨¥é¡¼È¯À¸»þ¤Î²èÌ̤òɽ¼¨¤¹¤ë
+        *      ¥¨¥é¡¼¥Ï¥ó¥É¥é
+        *
+        *      ¥¨¥é¡¼È¯À¸»þ¤ÎÄɲýèÍý¤ò¹Ô¤¤¤¿¤¤¾ì¹ç¤Ï¤³¤Î¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹
+        *      (¥¢¥é¡¼¥È¥á¡¼¥ëÁ÷¿®Åù¡Ý¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¥í¥°½ÐÎÏ»þ¤Ë¥¢¥é¡¼¥È¥á¡¼¥ë
+        *      ¤¬Á÷¿®¤µ¤ì¤ë¤¬¡¢¥¨¥é¡¼È¯À¸»þ¤ËÊ̤˥¢¥é¡¼¥È¥á¡¼¥ë¤ò¤³¤³¤ÇÁ÷¿®
+        *      ¤µ¤»¤ë¤³¤È¤â²Äǽ)
         *
-        *      Ãí°Õ¡§¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·¸åÁ´¤Æ¤Î½èÍý¤ÏÃæÃǤµ¤ì¤ë(¤³¤Î¥á¥½¥Ã¥É¤Çexit()¤¹¤ë)
+        *      @access public
+        *      @param  object  Ethna_Error             ¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È
+        */
+       function handleError(&$error)
+       {
+               // ¥í¥°½ÐÎÏ
+               list ($log_level, $dummy) = $this->logger->errorLevelToLogLevel($error->getLevel());
+               $message = $error->getMessage();
+               $this->logger->log($log_level, sprintf("[APP(%d)] %s", $error->getCode(), $message));
+       }
+
+       /**
+        *      ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤ò¼èÆÀ¤¹¤ë
         *
         *      @access public
+        *      @param  int             $code           ¥¨¥é¡¼¥³¡¼¥É
+        *      @return string  ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
         */
-       function fatal()
+       function getErrorMessage($code)
        {
-               exit(0);
+               $message_list =& $GLOBALS['_Ethna_error_message_list'];
+               for ($i = count($message_list)-1; $i >= 0; $i--) {
+                       if (array_key_exists($code, $message_list[$i])) {
+                               return $message_list[$i][$code];
+                       }
+               }
+               return null;
        }
 
        /**
@@ -798,9 +941,6 @@ class Ethna_Controller
        /**
         *      »ØÄꤵ¤ì¤¿Á«°Ü̾¤ËÂбþ¤¹¤ë¥Ó¥å¡¼¥¯¥é¥¹Ì¾¤òÊÖ¤¹(¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀ¸À®¤Ï¹Ô¤ï¤Ê¤¤)
         *
-        *      ¥Ó¥å¡¼¥¯¥é¥¹¤ÏAction Class¤Ëpreforward()¥á¥½¥Ã¥É¤ò¼ÂÁõ¤·¤¿¤â¤Î(Èó¿ä¾©)¡¢
-        *      ¤¢¤ë¤¤¤ÏViewClass¤ò·Ñ¾µ¤·¤¿¤â¤Î¤¤¤º¤ì¤«¤É¤Á¤é¤Ç¤â¤è¤¤(ViewClass¿ä¾©)
-        *
         *      @access public
         *      @param  string  $forward_name   Á«°ÜÀè¤Î̾¾Î
         *      @return string  view class¤Î¥¯¥é¥¹Ì¾
@@ -817,8 +957,8 @@ class Ethna_Controller
                        $forward_obj = array();
                }
 
-               if (isset($forward_obj['preforward_name'])) {
-                       $class_name = $forward_obj['preforward_name'];
+               if (isset($forward_obj['view_name'])) {
+                       $class_name = $forward_obj['view_name'];
                        if (class_exists($class_name)) {
                                return $class_name;
                        }
@@ -832,14 +972,15 @@ class Ethna_Controller
                if (is_null($class_name) == false && class_exists($class_name)) {
                        return $class_name;
                } else if (is_null($class_name) == false) {
-                       $this->logger->log(LOG_WARNING, 'stated preforward class is not defined [%s] -> try default', $class_name);
+                       $this->logger->log(LOG_WARNING, 'stated view class is not defined [%s] -> try default', $class_name);
                }
 
                $class_name = $this->getDefaultViewClass($forward_name);
                if (class_exists($class_name)) {
                        return $class_name;
                } else {
-                       return null;
+                       $this->logger->log(LOG_DEBUG, 'view class is not defined for [%s] -> use default [%s]', $forward_name, 'Ethna_ViewClass');
+                       return 'Ethna_ViewClass';
                }
        }
 
@@ -934,7 +1075,7 @@ class Ethna_Controller
         */
        function getDefaultActionPath($action_name, $fallback = true)
        {
-               $default_path = preg_replace('/_(.)/e', "'/' . strtoupper('\$1')", ucfirst($action_name)) . '.php';
+               $default_path = preg_replace('/_(.)/e', "'/' . strtoupper('\$1')", ucfirst($action_name)) . '.' . $this->getExt('php');
                $action_dir = $this->getActiondir();
 
                if ($this->getClientType() == CLIENT_TYPE_SOAP) {
@@ -979,7 +1120,7 @@ class Ethna_Controller
                if ($r == null) {
                        $r = sprintf("%s_View_%s", $this->getAppId(), $postfix);
                }
-               $this->logger->log(LOG_DEBUG, "default action class [%s]", $r);
+               $this->logger->log(LOG_DEBUG, "default view class [%s]", $r);
                return $r;
        }
 
@@ -995,7 +1136,7 @@ class Ethna_Controller
         */
        function getDefaultViewPath($forward_name, $fallback = true)
        {
-               $default_path = preg_replace('/_(.)/e', "'/' . strtoupper('\$1')", ucfirst($forward_name)) . '.php';
+               $default_path = preg_replace('/_(.)/e', "'/' . strtoupper('\$1')", ucfirst($forward_name)) . '.' . $this->getExt('php');
                $view_dir = $this->getViewdir();
 
                if ($this->getClientType() == CLIENT_TYPE_MOBILE_AU) {
@@ -1009,7 +1150,7 @@ class Ethna_Controller
                        $r = $default_path;
                }
 
-               $this->logger->log(LOG_DEBUG, "default action path [%s]", $r);
+               $this->logger->log(LOG_DEBUG, "default view path [%s]", $r);
                return $r;
        }
 
@@ -1024,6 +1165,7 @@ class Ethna_Controller
        {
                // ¥Õ¥©¡¼¥à¤«¤éÍ׵ᤵ¤ì¤¿action̾¤ò¼èÆÀ¤¹¤ë
                $form_action_name = $this->_getActionName_Form();
+               $form_action_name = preg_replace('/[^a-z0-9\-_]+/i', '', $form_action_name);
                $this->logger->log(LOG_DEBUG, 'form_action_name[%s]', $form_action_name);
 
                // ¥Õ¥©¡¼¥à¤«¤é¤Î»ØÄ̵꤬¤¤¾ì¹ç¤Ï¥¨¥ó¥È¥ê¥Ý¥¤¥ó¥È¤Ë»ØÄꤵ¤ì¤¿¥Ç¥Õ¥©¥ë¥ÈÃͤòÍøÍѤ¹¤ë
@@ -1037,9 +1179,12 @@ class Ethna_Controller
 
                // ¥¨¥ó¥È¥ê¥Ý¥¤¥ó¥È¤ËÇÛÎ󤬻ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï»ØÄê°Ê³°¤Îaction̾¤ÏµñÈݤ¹¤ë
                if (is_array($default_action_name)) {
-                       if (in_array($action_name, $default_action_name) == false) {
+                       if ($this->_isAcceptableActionName($action_name, $default_action_name) == false) {
                                // »ØÄê°Ê³°¤Îaction̾¤Ç¹ç¤Ã¤¿¾ì¹ç¤Ï$fallback_action_name(or ¥Ç¥Õ¥©¥ë¥È)
                                $tmp = $fallback_action_name != "" ? $fallback_action_name : $default_action_name[0];
+                               if ($tmp{strlen($tmp)-1} == '*') {
+                                       $tmp = substr($tmp, 0, -1);
+                               }
                                $this->logger->log(LOG_DEBUG, '-> fallback_action_name[%s]', $tmp);
                                $action_name = $tmp;
                        }
@@ -1170,39 +1315,6 @@ class Ethna_Controller
        }
 
        /**
-        *      »ØÄꤵ¤ì¤¿Á«°Ü̾¤ËÂбþ¤¹¤ë²èÌ̤ò½ÐÎϤ¹¤ë
-        *
-        *      @access private
-        *      @param  string  $forward_name   Á«°Ü̾
-        *      @return bool    0:Àµ¾ï½ªÎ» -1:¥¨¥é¡¼
-        */
-       function _forward($forward_name)
-       {
-               $forward_path = $this->_getForwardPath($forward_name);
-               $smarty =& $this->getTemplateEngine();
-
-               $form_array =& $this->action_form->getArray();
-               $app_array =& $this->action_form->getAppArray();
-               $app_ne_array =& $this->action_form->getAppNEArray();
-               $smarty->assign_by_ref('form', $form_array);
-               $smarty->assign_by_ref('app', $app_array);
-               $smarty->assign_by_ref('app_ne', $app_ne_array);
-               $smarty->assign_by_ref('errors', Ethna_Util::escapeHtml($this->action_error->getMessageList()));
-               if (isset($_SESSION)) {
-                       $smarty->assign_by_ref('session', Ethna_Util::escapeHtml($_SESSION));
-               }
-               $smarty->assign('script', basename($_SERVER['PHP_SELF']));
-               $smarty->assign('request_uri', htmlspecialchars($_SERVER['REQUEST_URI']));
-
-               // ¥Ç¥Õ¥©¥ë¥È¥Þ¥¯¥í¤ÎÀßÄê
-               $this->_setDefaultMacro($smarty);
-
-               $smarty->display($forward_path);
-
-               return 0;
-       }
-
-       /**
         *      Á«°Ü̾¤«¤é¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë¤Î¥Ñ¥¹Ì¾¤ò¼èÆÀ¤¹¤ë
         *
         *      @access private
@@ -1352,24 +1464,24 @@ class Ethna_Controller
        {
                $view_dir = $this->getViewdir();
 
-               // preforward_path°À­¥Á¥§¥Ã¥¯
-               if (isset($action_obj['preforward_path'])) {
-                       if (file_exists($view_dir . $forward_obj['preforward_path']) == false) {
-                               $this->logger->log(LOG_WARNING, 'preforward_path file not found [%s] -> try default', $forward_obj['preforward_path']);
+               // view_path°À­¥Á¥§¥Ã¥¯
+               if (isset($action_obj['view_path'])) {
+                       if (file_exists($view_dir . $forward_obj['view_path']) == false) {
+                               $this->logger->log(LOG_WARNING, 'view_path file not found [%s] -> try default', $forward_obj['view_path']);
                        } else {
-                               include_once($action_dir . $forward_obj['preforward_path']);
+                               include_once($action_dir . $forward_obj['view_path']);
                                return;
                        }
                }
 
                // ¥Ç¥Õ¥©¥ë¥È¥Á¥§¥Ã¥¯
-               $preforward_path = $this->getDefaultViewPath($forward_name);
-               if (file_exists($view_dir . $preforward_path)) {
-                       include_once($view_dir . $preforward_path);
+               $view_path = $this->getDefaultViewPath($forward_name);
+               if (file_exists($view_dir . $view_path)) {
+                       include_once($view_dir . $view_path);
                        return;
                } else {
-                       $this->logger->log(LOG_DEBUG, 'default preforward file not found [%s]', $preforward_path);
-                       $preforward_path = null;
+                       $this->logger->log(LOG_DEBUG, 'default view file not found [%s]', $view_path);
+                       $view_path = null;
                }
        }
 
@@ -1403,12 +1515,12 @@ class Ethna_Controller
        }
 
        /**
-        *      Á«°Ü»þ¤Î¥Ç¥Õ¥©¥ë¥È¥Þ¥¯¥í¤òÀßÄꤹ¤ë
+        *  ¥Æ¥ó¥×¥ì¡¼¥È¥¨¥ó¥¸¥ó¤Î¥Ç¥Õ¥©¥ë¥È¾õÂÖ¤òÀßÄꤹ¤ë
         *
-        *      @access protected
-        *      @param  object  Smarty  $smarty ¥Æ¥ó¥×¥ì¡¼¥È¥¨¥ó¥¸¥ó¥ª¥Ö¥¸¥§¥¯¥È
+        *  @access protected
+        *  @param  object  Smarty  $smarty ¥Æ¥ó¥×¥ì¡¼¥È¥¨¥ó¥¸¥ó¥ª¥Ö¥¸¥§¥¯¥È
         */
-       function _setDefaultMacro(&$smarty)
+       function _setDefaultTemplateEngine(&$smarty)
        {
        }
 
@@ -1439,7 +1551,7 @@ class Ethna_Controller
                $forward_obj = array();
 
                $forward_obj['forward_path'] = sprintf("%s/tpl/info.tpl", $base);
-               $forward_obj['preforward_name'] = 'Ethna_Action_Info';
+               $forward_obj['view_name'] = 'Ethna_Action_Info';
                $this->forward['__ethna_info__'] = $forward_obj;
        }
 
@@ -1504,6 +1616,47 @@ class Ethna_Controller
                
                return $dsn_list[$n];
        }
+
+       /**
+        *      ¥¢¥¯¥·¥ç¥ó̾¤¬¼Â¹Ôµö²Ä¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤«¤É¤¦¤«¤òÊÖ¤¹
+        *
+        *      @access private
+        *      @param  string  $action_name                    ¥ê¥¯¥¨¥¹¥È¤µ¤ì¤¿¥¢¥¯¥·¥ç¥ó̾
+        *      @param  array   $default_action_name    µö²Ä¤µ¤ì¤Æ¤¤¤ë¥¢¥¯¥·¥ç¥ó̾
+        *      @return bool    true:µö²Ä false:ÉÔµö²Ä
+        */
+       function _isAcceptableActionName($action_name, $default_action_name)
+       {
+               foreach (to_array($default_action_name) as $name) {
+                       if ($action_name == $name) {
+                               return true;
+                       } else if ($name{strlen($name)-1} == '*') {
+                               if (strncmp($action_name, substr($name, 0, -1), strlen($name)-1) == 0) {
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }
+
+       /**
+        *      ¥Õ¥£¥ë¥¿¡¼¥Á¥§¥¤¥ó¤òÀ¸À®¤¹¤ë
+        *
+        *      @access private
+        */
+       function _createFilterChain()
+       {
+               $this->filter_chain = array();
+               foreach ($this->filter as $filter) {
+                       $file = sprintf("%s/%s.%s", $this->getDirectory('filter'), $filter, $this->getExt('php'));
+                       if (file_exists($file)) {
+                               include_once($file);
+                       }
+                       if (class_exists($filter)) {
+                               $this->filter_chain[] =& new $filter($this);
+                       }
+               }
+       }
 }
 // }}}
 ?>