OSDN Git Service

- fixup DB class
[ethna/ethna.git] / class / Ethna_Controller.php
1 <?php
2 // vim: foldmethod=marker
3 /**
4  *      Ethna_Controller.php
5  *
6  *      @author         Masaki Fujimoto <fujimoto@php.net>
7  *      @license        http://www.opensource.org/licenses/bsd-license.php The BSD License
8  *      @package        Ethna
9  *      @version        $Id$
10  */
11
12 // {{{ getController
13 /**
14  *      ¥³¥ó¥È¥í¡¼¥é¥ª¥Ö¥¸¥§¥¯¥È¤ò¼èÆÀ¤¹¤ë
15  *
16  *      @access public
17  *      @return object  ¥³¥ó¥È¥í¡¼¥é¥ª¥Ö¥¸¥§¥¯¥È
18  */
19 function &getController()
20 {
21         $controller =& $GLOBALS['controller'];
22         return $controller;
23 }
24 // }}}
25
26 // {{{ Ethna_Controller
27 /**
28  *      ¥³¥ó¥È¥í¡¼¥é¥¯¥é¥¹
29  *
30  *      @author         Masaki Fujimoto <fujimoto@php.net>
31  *      @access         public
32  *      @package        Ethna
33  */
34 class Ethna_Controller
35 {
36         /**#@+
37          *      @access private
38          */
39
40         /**
41          *      @var    string          ¥¢¥×¥ê¥±¡¼¥·¥ç¥óID
42          */
43         var $appid = 'PHPSTRUTS';
44
45         /**
46          *      @var    string          ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ù¡¼¥¹¥Ç¥£¥ì¥¯¥È¥ê
47          */
48         var $base = '';
49
50         /**
51          *      @var    string          ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ù¡¼¥¹URL
52          */
53         var     $url = '';
54
55         /**
56          *      @var    string          ¥¢¥×¥ê¥±¡¼¥·¥ç¥óDSN(Data Source Name)
57          */
58         var $dsn;
59
60         /**
61          *      @var    array           ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ç¥£¥ì¥¯¥È¥ê
62          */
63         var $directory = array(
64                 'action'                => 'app/action',
65                 'etc'                   => 'etc',
66                 'locale'                => 'locale',
67                 'log'                   => 'log',
68                 'plugins'               => array(),
69                 'template'              => 'template',
70                 'template_c'    => 'tmp',
71                 'tmp'                   => 'tmp',
72                 'view'                  => 'app/view',
73         );
74
75         /**
76          *      @var    array           DB¥¢¥¯¥»¥¹ÄêµÁ
77          */
78         var     $db = array(
79                 ''                              => DB_TYPE_RW,
80         );
81
82         /**
83          *      @var    array           ³ÈÄ¥»ÒÀßÄê
84          */
85         var $ext = array(
86                 'php'                   => 'php',
87                 'tpl'                   => 'tpl',
88         );
89
90         /**
91          *      @var    array           ¥¯¥é¥¹ÀßÄê
92          */
93         var $class = array(
94                 'config'                => 'Ethna_Config',
95                 'db'                    => 'Ethna_DB',
96                 'logger'                => 'Ethna_Logger',
97                 'sql'                   => 'Ethna_AppSQL',
98         );
99
100         /**
101          *      @var    string          »ÈÍѸÀ¸ìÀßÄê
102          */
103         var $language;
104
105         /**
106          *      @var    string          ¥·¥¹¥Æ¥à¦¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°
107          */
108         var     $system_encoding;
109
110         /**
111          *      @var    string          ¥¯¥é¥¤¥¢¥ó¥È¦¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°
112          */
113         var     $client_encoding;
114
115         /**
116          *      @var    string          ¥¯¥é¥¤¥¢¥ó¥È¥¿¥¤¥×
117          */
118         var $client_type;
119
120         /**
121          *      @var    string  ¸½ºß¼Â¹ÔÃæ¤Î¥¢¥¯¥·¥ç¥ó̾
122          */
123         var     $action_name;
124
125         /**
126          *      @var    array   forwardÄêµÁ
127          */
128         var $forward = array();
129
130         /**
131          *      @var    array   actionÄêµÁ
132          */
133         var $action = array();
134
135         /**
136          *      @var    array   soap actionÄêµÁ
137          */
138         var $soap_action = array();
139
140         /**
141          *      @var    array   ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Þ¥Í¡¼¥¸¥ãÄêµÁ
142          */
143         var     $manager = array();
144
145         /**
146          *      @var    array   smarty modifierÄêµÁ
147          */
148         var $smarty_modifier_plugin = array();
149
150         /**
151          *      @var    array   smarty functionÄêµÁ
152          */
153         var $smarty_function_plugin = array();
154
155         /**
156          *      @var    array   smarty prefilterÄêµÁ
157          */
158         var $smarty_prefilter_plugin = array();
159
160         /**
161          *      @var    array   smarty postfilterÄêµÁ
162          */
163         var $smarty_postfilter_plugin = array();
164
165         /**
166          *      @var    array   smarty outputfilterÄêµÁ
167          */
168         var $smarty_outputfilter_plugin = array();
169
170         /**
171          *      @var    object  Ethna_Backend   backend¥ª¥Ö¥¸¥§¥¯¥È
172          */
173         var $backend = null;
174
175         /**
176          *      @var    object  Ethna_I18N              i18n¥ª¥Ö¥¸¥§¥¯¥È
177          */
178         var $i18n = null;
179
180         /**
181          *      @var    object  Ethna_ActionError       action error¥ª¥Ö¥¸¥§¥¯¥È
182          */
183         var $action_error = null;
184
185         /**
186          *      @var    object  Ethna_ActionForm        action form¥ª¥Ö¥¸¥§¥¯¥È
187          */
188         var $action_form = null;
189
190         /**
191          *      @var    object  Ethna_Session           ¥»¥Ã¥·¥ç¥ó¥ª¥Ö¥¸¥§¥¯¥È
192          */
193         var $session = null;
194
195         /**
196          *      @var    object  Ethna_Config            ÀßÄꥪ¥Ö¥¸¥§¥¯¥È
197          */
198         var     $config = null;
199
200         /**
201          *      @var    object  Ethna_Logger            ¥í¥°¥ª¥Ö¥¸¥§¥¯¥È
202          */
203         var     $logger = null;
204
205         /**
206          *      @var    object  Ethna_AppSQL            SQL¥ª¥Ö¥¸¥§¥¯¥È
207          */
208         var     $sql = null;
209
210         /**#@-*/
211
212
213         /**
214          *      Ethna_Controller¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
215          *
216          *      @access         public
217          */
218         function Ethna_Controller()
219         {
220                 $GLOBALS['controller'] =& $this;
221                 $this->base = BASE;
222
223                 // ¥¨¥é¡¼¥Ï¥ó¥É¥é¤ÎÀßÄê
224                 Ethna::setErrorCallback(array(&$this, 'handleError'));
225
226                 // ¥Ç¥£¥ì¥¯¥È¥ê̾¤ÎÀßÄê(ÁêÂХѥ¹->ÀäÂХѥ¹)
227                 foreach ($this->directory as $key => $value) {
228                         if ($key == 'plugins') {
229                                 // Smarty¥×¥é¥°¥¤¥ó¥Ç¥£¥ì¥¯¥È¥ê¤ÏÇÛÎó¤Ç»ØÄꤹ¤ë
230                                 $tmp = array(SMARTY_DIR . 'plugins');
231                                 foreach (to_array($value) as $elt) {
232                                         if ($elt{0} != '/') {
233                                                 $tmp[] = $this->base . (empty($this->base) ? '' : '/') . $elt;
234                                         }
235                                 }
236                                 $this->directory[$key] = $tmp;
237                         } else {
238                                 if ($value{0} != '/') {
239                                         $this->directory[$key] = $this->base . (empty($this->base) ? '' : '/') . $value;
240                                 }
241                         }
242                 }
243                 $this->i18n =& new Ethna_I18N($this->getDirectory('locale'), $this->getAppId());
244                 list($this->language, $this->system_encoding, $this->client_encoding) = $this->_getDefaultLanguage();
245                 $this->client_type = $this->_getDefaultClientType();
246
247                 // ÀßÄê¥Õ¥¡¥¤¥ëÆɤ߹þ¤ß
248                 $config_class = $this->class['config'];
249                 $this->config =& new $config_class($this);
250                 $this->dsn = $this->_prepareDSN();
251                 $this->url = $this->config->get('url');
252
253                 // ¥í¥°½ÐÎϳ«»Ï
254                 $logger_class = $this->class['logger'];
255                 $this->logger =& new $logger_class($this);
256                 $this->logger->begin();
257
258                 // SQL¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®
259                 $sql_class = $this->class['sql'];
260                 $this->sql =& new $sql_class($this);
261
262                 // Ethna¥Þ¥Í¡¼¥¸¥ãÀßÄê
263                 $this->_activateEthnaManager();
264         }
265
266         /**
267          *      ¥¢¥×¥ê¥±¡¼¥·¥ç¥óID¤òÊÖ¤¹
268          *
269          *      @access public
270          *      @return string  ¥¢¥×¥ê¥±¡¼¥·¥ç¥óID
271          */
272         function getAppId()
273         {
274                 return ucfirst(strtolower($this->appid));
275         }
276
277         /**
278          *      DSN¤òÊÖ¤¹
279          *
280          *      @access public
281          *      @param  string  $type   DB¼ïÊÌ
282          *      @return string  DSN
283          */
284         function getDSN($type = "")
285         {
286                 if (isset($this->dsn[$type]) == false) {
287                         return null;
288                 }
289                 return $this->dsn[$type];
290         }
291
292         /**
293          *      DSN¤Î»ý³ÀܳÀßÄê¤òÊÖ¤¹
294          *
295          *      @access public
296          *      @param  string  $type   DB¼ïÊÌ
297          *      @return bool    true:persistent false:non-persistent(¤¢¤ë¤¤¤ÏÀßÄê̵¤·)
298          */
299         function getDSN_persistent($type = "")
300         {
301                 $key = sprintf("dsn%s_persistent", $type == "" ? "" : "_$type");
302                 $dsn_persistent = $this->config->get($key);
303                 if (is_null($dsn_persistent)) {
304                         return false;
305                 }
306                 return $dsn_persistent;
307         }
308
309         /**
310          *      ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ù¡¼¥¹URL¤òÊÖ¤¹
311          *
312          *      @access public
313          *      @return string  ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ù¡¼¥¹URL
314          */
315         function getURL()
316         {
317                 return $this->url;
318         }
319
320         /**
321          *      ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ù¡¼¥¹¥Ç¥£¥ì¥¯¥È¥ê¤òÊÖ¤¹
322          *
323          *      @access public
324          *      @return string  ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ù¡¼¥¹¥Ç¥£¥ì¥¯¥È¥ê
325          */
326         function getBasedir()
327         {
328                 return $this->base;
329         }
330
331         /**
332          *      ¥¯¥é¥¤¥¢¥ó¥È¥¿¥¤¥×/¸À¸ì¤«¤é¥Æ¥ó¥×¥ì¡¼¥È¥Ç¥£¥ì¥¯¥È¥ê̾¤ò·èÄꤹ¤ë
333          *
334          *      @access public
335          *      @return string  ¥Æ¥ó¥×¥ì¡¼¥È¥Ç¥£¥ì¥¯¥È¥ê
336          */
337         function getTemplatedir()
338         {
339                 $template = $this->getDirectory('template');
340
341                 // ¸À¸ìÊ̥ǥ£¥ì¥¯¥È¥ê
342                 if (file_exists($template . '/' . $this->language)) {
343                         $template .= '/' . $this->language;
344                 }
345
346                 // ¥¯¥é¥¤¥¢¥ó¥ÈÊ̥ǥ£¥ì¥¯¥È¥ê(if we need)
347                 if ($this->client_type == CLIENT_TYPE_MOBILE_AU && file_exists($template . '/au')) {
348                         $template .= '/au';
349                 }
350
351                 return $template;
352         }
353
354         /**
355          *      ¥¢¥¯¥·¥ç¥ó¥Ç¥£¥ì¥¯¥È¥ê̾¤ò·èÄꤹ¤ë
356          *
357          *      @access public
358          *      @return string  ¥¢¥¯¥·¥ç¥ó¥Ç¥£¥ì¥¯¥È¥ê
359          */
360         function getActiondir()
361         {
362                 return (empty($this->directory['action']) ? ($this->base . (empty($this->base) ? '' : '/')) : ($this->directory['action'] . "/"));
363         }
364
365         /**
366          *      ¥Ó¥å¡¼¥Ç¥£¥ì¥¯¥È¥ê̾¤ò·èÄꤹ¤ë
367          *
368          *      @access public
369          *      @return string  ¥¢¥¯¥·¥ç¥ó¥Ç¥£¥ì¥¯¥È¥ê
370          */
371         function getViewdir()
372         {
373                 return (empty($this->directory['view']) ? ($this->base . (empty($this->base) ? '' : '/')) : ($this->directory['view'] . "/"));
374         }
375
376         /**
377          *      ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥¯¥é¥¹ÀßÄê¤òÊÖ¤¹
378          *
379          *      @access public
380          *      @param  string  $key    ¥¯¥é¥¹¥¿¥¤¥×("config", "db", "logger", "sql")
381          *      @return string  $key¤ËÂбþ¤·¤¿¥¯¥é¥¹Ì¾(ÀßÄ꤬¤Ê¤¤¾ì¹ç¤Ïnull)
382          */
383         function getClass($key)
384         {
385                 if (isset($this->class[$key]) == false) {
386                         return null;
387                 }
388                 return $this->class[$key];
389         }
390
391         /**
392          *      ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ç¥£¥ì¥¯¥È¥êÀßÄê¤òÊÖ¤¹
393          *
394          *      @access public
395          *      @param  string  $key    ¥Ç¥£¥ì¥¯¥È¥ê¥¿¥¤¥×("tmp", "template"...)
396          *      @return string  $key¤ËÂбþ¤·¤¿¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ç¥£¥ì¥¯¥È¥ê(ÀßÄ̵꤬¤¤¾ì¹ç¤Ïnull)
397          */
398         function getDirectory($key)
399         {
400                 if (isset($this->directory[$key]) == false) {
401                         return null;
402                 }
403                 return $this->directory[$key];
404         }
405
406         /**
407          *      DBÀßÄê¤òÊÖ¤¹
408          *
409          *      @access public
410          *      @param  string  $key    DB¥¿¥¤¥×("r", ...)
411          *      @return string  $key¤ËÂбþ¤¹¤ëDB¼ïÊÌÄêµÁ(ÀßÄ̵꤬¤¤¾ì¹ç¤Ïnull)
412          */
413         function getDB($key)
414         {
415                 if (isset($this->db[$key]) == false) {
416                         return null;
417                 }
418                 return $this->db[$key];
419         }
420
421         /**
422          *      ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó³ÈÄ¥»ÒÀßÄê¤òÊÖ¤¹
423          *
424          *      @access public
425          *      @param  string  $key    ³ÈÄ¥»Ò¥¿¥¤¥×("php", "tpl"...)
426          *      @return string  $key¤ËÂбþ¤·¤¿³ÈÄ¥»Ò(ÀßÄ̵꤬¤¤¾ì¹ç¤Ïnull)
427          */
428         function getExt($key)
429         {
430                 if (isset($this->ext[$key]) == false) {
431                         return null;
432                 }
433                 return $this->ext[$key];
434         }
435
436         /**
437          *      i18n¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¢¥¯¥»¥µ(R)
438          *
439          *      @access public
440          *      @return object  Ethna_I18N      i18n¥ª¥Ö¥¸¥§¥¯¥È
441          */
442         function &getI18N()
443         {
444                 return $this->i18n;
445         }
446
447         /**
448          *      ÀßÄꥪ¥Ö¥¸¥§¥¯¥È¤Î¥¢¥¯¥»¥µ
449          *
450          *      @access public
451          *      @return object  Ethna_Config    ÀßÄꥪ¥Ö¥¸¥§¥¯¥È
452          */
453         function &getConfig()
454         {
455                 return $this->config;
456         }
457
458         /**
459          *      backend¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¢¥¯¥»¥µ
460          *
461          *      @access public
462          *      @return object  Ethna_Backend   backend¥ª¥Ö¥¸¥§¥¯¥È
463          */
464         function &getBackend()
465         {
466                 return $this->backend;
467         }
468
469         /**
470          *      action error¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¢¥¯¥»¥µ
471          *
472          *      @access public
473          *      @return object  Ethna_ActionError       action error¥ª¥Ö¥¸¥§¥¯¥È
474          */
475         function &getActionError()
476         {
477                 return $this->action_error;
478         }
479
480         /**
481          *      action form¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¢¥¯¥»¥µ
482          *
483          *      @access public
484          *      @return object  Ethna_ActionForm        action form¥ª¥Ö¥¸¥§¥¯¥È
485          */
486         function &getActionForm()
487         {
488                 return $this->action_form;
489         }
490
491         /**
492          *      ¥»¥Ã¥·¥ç¥ó¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¢¥¯¥»¥µ
493          *
494          *      @access public
495          *      @return object  Ethna_Session           ¥»¥Ã¥·¥ç¥ó¥ª¥Ö¥¸¥§¥¯¥È
496          */
497         function &getSession()
498         {
499                 return $this->session;
500         }
501
502         /**
503          *      ¥í¥°¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¢¥¯¥»¥µ
504          *
505          *      @access public
506          *      @return object  Ethna_Logger            ¥í¥°¥ª¥Ö¥¸¥§¥¯¥È
507          */
508         function &getLogger()
509         {
510                 return $this->logger;
511         }
512
513         /**
514          *      SQL¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¢¥¯¥»¥µ
515          *
516          *      @access public
517          *      @return object  Ethna_AppSQL    SQL¥ª¥Ö¥¸¥§¥¯¥È
518          */
519         function &getSQL()
520         {
521                 return $this->sql;
522         }
523
524         /**
525          *      ¥Þ¥Í¡¼¥¸¥ã°ìÍ÷¤òÊÖ¤¹
526          *
527          *      @access public
528          *      @return array   ¥Þ¥Í¡¼¥¸¥ã°ìÍ÷
529          */
530         function getManagerList()
531         {
532                 return $this->manager;
533         }
534
535         /**
536          *      ¼Â¹ÔÃæ¤Î¥¢¥¯¥·¥ç¥ó̾¤òÊÖ¤¹
537          *
538          *      @access public
539          *      @return string  ¼Â¹ÔÃæ¤Î¥¢¥¯¥·¥ç¥ó̾
540          */
541         function getCurrentActionName()
542         {
543                 return $this->action_name;
544         }
545
546         /**
547          *      »ÈÍѸÀ¸ì¤ò¼èÆÀ¤¹¤ë
548          *
549          *      @access public
550          *      @return array   »ÈÍѸÀ¸ì,¥·¥¹¥Æ¥à¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°Ì¾,¥¯¥é¥¤¥¢¥ó¥È¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°Ì¾
551          */
552         function getLanguage()
553         {
554                 return array($this->language, $this->system_encoding, $this->client_encoding);
555         }
556
557         /**
558          *      ¥¯¥é¥¤¥¢¥ó¥È¥¿¥¤¥×¤ò¼èÆÀ¤¹¤ë
559          *
560          *      @access public
561          *      @return int             ¥¯¥é¥¤¥¢¥ó¥È¥¿¥¤¥×ÄêµÁ(CLIENT_TYPE_WWW...)
562          */
563         function getClientType()
564         {
565                 return $this->client_type;
566         }
567
568         /**
569          *      ¥¯¥é¥¤¥¢¥ó¥È¥¿¥¤¥×¤òÀßÄꤹ¤ë
570          *
571          *      @access public
572          *      @param  int             $client_type    ¥¯¥é¥¤¥¢¥ó¥È¥¿¥¤¥×ÄêµÁ(CLIENT_TYPE_WWW...)
573          */
574         function setClientType($client_type)
575         {
576                 $this->client_type = $client_type;
577         }
578
579         /**
580          *      ¥Æ¥ó¥×¥ì¡¼¥È¥¨¥ó¥¸¥ó¼èÆÀ¤¹¤ë(¸½ºß¤Ïsmarty¤Î¤ßÂбþ)
581          *
582          *      @access public
583          *      @return object  Smarty  ¥Æ¥ó¥×¥ì¡¼¥È¥¨¥ó¥¸¥ó¥ª¥Ö¥¸¥§¥¯¥È
584          *      @todo   ¥Ö¥í¥Ã¥¯´Ø¿ô¥×¥é¥°¥¤¥ó(etc)Âбþ
585          */
586         function &getTemplateEngine()
587         {
588                 $smarty =& new Smarty();
589                 $smarty->template_dir = $this->getTemplatedir();
590                 $smarty->compile_dir = $this->getDirectory('template_c') . '/tpl_' . md5($smarty->template_dir);
591                 if (@is_dir($smarty->compile_dir) == false) {
592                         mkdir($smarty->compile_dir, 0755);
593                 }
594                 $smarty->plugins_dir = $this->getDirectory('plugins');
595
596                 // default modifiers
597                 $smarty->register_modifier('number_format', 'smarty_modifier_number_format');
598                 $smarty->register_modifier('strftime', 'smarty_modifier_strftime');
599                 $smarty->register_modifier('count', 'smarty_modifier_count');
600                 $smarty->register_modifier('join', 'smarty_modifier_join');
601                 $smarty->register_modifier('filter', 'smarty_modifier_filter');
602                 $smarty->register_modifier('unique', 'smarty_modifier_unique');
603                 $smarty->register_modifier('wordwrap_i18n', 'smarty_modifier_wordwrap_i18n');
604                 $smarty->register_modifier('i18n', 'smarty_modifier_i18n');
605                 $smarty->register_modifier('checkbox', 'smarty_modifier_checkbox');
606                 $smarty->register_modifier('select', 'smarty_modifier_select');
607                 $smarty->register_modifier('form_value', 'smarty_modifier_form_value');
608
609                 // user defined modifiers
610                 foreach ($this->smarty_modifier_plugin as $modifier) {
611                         $name = str_replace('smarty_modifier_', '', $modifier);
612                         $smarty->register_modifier($name, $modifier);
613                 }
614
615                 // default functions
616                 $smarty->register_function('message', 'smarty_function_message');
617                 $smarty->register_function('uniqid', 'smarty_function_uniqid');
618                 $smarty->register_function('select', 'smarty_function_select');
619                 $smarty->register_function('checkbox_list', 'smarty_function_checkbox_list');
620
621                 // user defined functions
622                 foreach ($this->smarty_function_plugin as $function) {
623                         $name = str_replace('smarty_function_', '', $function);
624                         $smarty->register_function($name, $function);
625                 }
626
627                 // user defined prefilters
628                 foreach ($this->smarty_prefilter_plugin as $prefilter) {
629                         $smarty->register_prefilter($prefilter);
630                 }
631
632                 // user defined postfilters
633                 foreach ($this->smarty_postfilter_plugin as $postfilter) {
634                         $smarty->register_postfilter($postfilter);
635                 }
636
637                 // user defined outputfilters
638                 foreach ($this->smarty_outputfilter_plugin as $outputfilter) {
639                         $smarty->register_outputfilter($outputfilter);
640                 }
641
642                 return $smarty;
643         }
644
645         /**
646          *      ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¥¨¥ó¥È¥ê¥Ý¥¤¥ó¥È
647          *
648          *      @access public
649          *      @param  string  $class_name             ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥³¥ó¥È¥í¡¼¥é¤Î¥¯¥é¥¹Ì¾
650          *      @param  mixed   $action_name    »ØÄê¤Î¥¢¥¯¥·¥ç¥ó̾(¾Êά²Ä)
651          *      @param  mixed   $fallback_action_name   ¥¢¥¯¥·¥ç¥ó¤¬·èÄê¤Ç¤­¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¼Â¹Ô¤µ¤ì¤ë¥¢¥¯¥·¥ç¥ó̾(¾Êά²Ä)
652          *      @static
653          */
654         function main($class_name, $action_name = "", $fallback_action_name = "")
655         {
656                 $c =& new $class_name;
657                 $c->trigger($action_name, $fallback_action_name);
658         }
659
660         /**
661          *      ¥³¥Þ¥ó¥É¥é¥¤¥ó¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¥¨¥ó¥È¥ê¥Ý¥¤¥ó¥È
662          *
663          *      @access public
664          *      @param  string  $class_name             ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥³¥ó¥È¥í¡¼¥é¤Î¥¯¥é¥¹Ì¾
665          *      @param  string  $action_name    ¼Â¹Ô¤¹¤ë¥¢¥¯¥·¥ç¥ó̾
666          *      @static
667          */
668         function main_CLI($class_name, $action_name)
669         {
670                 $c =& new $class_name;
671                 $c->action[$action_name] = array();
672                 $c->trigger($action_name);
673         }
674
675         /**
676          *      SOAP¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¥¨¥ó¥È¥ê¥Ý¥¤¥ó¥È
677          *
678          *      @access public
679          *      @param  string  $class_name     ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥³¥ó¥È¥í¡¼¥é¤Î¥¯¥é¥¹Ì¾
680          *      @static
681          */
682         function main_SOAP($class_name)
683         {
684                 $c =& new $class_name;
685                 $c->setClientType(CLIENT_TYPE_SOAP);
686                 $c->trigger_SOAP();
687         }
688
689         /**
690          *      AMF(Flash Remoting)¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¥¨¥ó¥È¥ê¥Ý¥¤¥ó¥È
691          *
692          *      @access public
693          *      @param  string  $class_name     ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥³¥ó¥È¥í¡¼¥é¤Î¥¯¥é¥¹Ì¾
694          *      @static
695          */
696         function main_AMF($class_name)
697         {
698                 $c =& new $class_name;
699                 $c->setClientType(CLIENT_TYPE_AMF);
700                 $c->trigger_AMF();
701         }
702
703         /**
704          *      ¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Î½èÍý¤ò³«»Ï¤¹¤ë
705          *
706          *      °ú¿ô$default_action_name¤ËÇÛÎ󤬻ØÄꤵ¤ì¤¿¾ì¹ç¡¢¤½¤ÎÇÛÎó¤Ç»ØÄꤵ¤ì¤¿
707          *      ¥¢¥¯¥·¥ç¥ó°Ê³°¤Ï¼õ¤±ÉÕ¤±¤Ê¤¤(¤½¤ì°Ê³°¤Î¥¢¥¯¥·¥ç¥ó¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢
708          *      ÇÛÎó¤ÎÀèƬ¤Ç»ØÄꤵ¤ì¤¿¥¢¥¯¥·¥ç¥ó¤¬¼Â¹Ô¤µ¤ì¤ë)
709          *
710          *      @access public
711          *      @param  mixed   $default_action_name    »ØÄê¤Î¥¢¥¯¥·¥ç¥ó̾
712          *      @param  mixed   $fallback_action_name   ¥¢¥¯¥·¥ç¥ó̾¤¬·èÄê¤Ç¤­¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¼Â¹Ô¤µ¤ì¤ë¥¢¥¯¥·¥ç¥ó̾
713          *      @return mixed   0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
714          */
715         function trigger($default_action_name = "", $fallback_action_name = "")
716         {
717                 // ¥¢¥¯¥·¥ç¥ó̾¤Î¼èÆÀ
718                 $action_name = $this->_getActionName($default_action_name, $fallback_action_name);
719
720                 // ¥¢¥¯¥·¥ç¥óÄêµÁ¤Î¼èÆÀ
721                 $action_obj =& $this->_getAction($action_name);
722                 if (is_null($action_obj)) {
723                         if ($fallback_action_name != "") {
724                                 $this->logger->log(LOG_DEBUG, 'undefined action [%s] -> try fallback action [%s]', $action_name, $fallback_action_name);
725                                 $action_obj =& $this->_getAction($fallback_action_name);
726                         }
727                         if ($action_obj == null) {
728                                 return Ethna::raiseError(E_APP_UNDEFINED_ACTION, "undefined action [%s]", $action_name);
729                         } else {
730                                 $action_name = $fallback_action_name;
731                         }
732                 }
733                 $this->action_name = $action_name;
734
735                 // ¸À¸ìÀßÄê
736                 $this->_setLanguage($this->language, $this->system_encoding, $this->client_encoding);
737
738                 // ¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®
739                 $this->action_error =& new Ethna_ActionError();
740                 $form_name = $this->getActionFormName($action_name);
741                 $this->action_form =& new $form_name($this);
742                 $this->session =& new Ethna_Session($this->getAppId(), $this->getDirectory('tmp'), $this->logger);
743
744                 // ¥Ð¥Ã¥¯¥¨¥ó¥É½èÍý¼Â¹Ô
745                 $backend =& new Ethna_Backend($this);
746                 $this->backend =& $backend;
747                 $forward_name = $backend->perform($action_name);
748
749                 // ¥³¥ó¥È¥í¡¼¥é¤ÇÁ«°ÜÀè¤ò·èÄꤹ¤ë
750                 $forward_name = $this->_sortForward($action_name, $forward_name);
751
752                 if ($forward_name != null) {
753                         $backend->preforward($forward_name);
754
755                         if ($this->_forward($forward_name) != 0) {
756                                 return -1;
757                         }
758                 }
759
760                 return 0;
761         }
762
763         /**
764          *  SOAP¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Î½èÍý¤ò³«»Ï¤¹¤ë
765          *
766          *  @access public
767          */
768         function trigger_SOAP()
769         {
770                 // ¥¢¥¯¥·¥ç¥ó¥¹¥¯¥ê¥×¥È¤ò¥¤¥ó¥¯¥ë¡¼¥É
771                 $this->_includeActionScript();
772
773                 // SOAP¥¨¥ó¥È¥ê¥¯¥é¥¹
774                 $gg =& new Ethna_SoapGatewayGenerator();
775                 $script = $gg->generate();
776                 eval($script);
777
778                 // SOAP¥ê¥¯¥¨¥¹¥È½èÍý
779                 $server =& new SoapServer(null, array('uri' => $this->config->get('url')));
780                 $server->setClass($gg->getClassName());
781                 $server->handle();
782         }
783
784         /**
785          *      AMF(Flash Remoting)¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Î½èÍý¤ò³«»Ï¤¹¤ë
786          *
787          *      @access public
788          */
789         function trigger_AMF()
790         {
791                 include_once('ethna/contrib/amfphp/app/Gateway.php');
792
793                 $this->action_error =& new Ethna_ActionError();
794
795                 // Credential¥Ø¥Ã¥À¤Ç¥»¥Ã¥·¥ç¥ó¤ò½èÍý¤¹¤ë¤Î¤Ç¤³¤³¤Ç¤Ïnull¤ËÀßÄê
796                 $this->session = null;
797
798                 $this->_setLanguage($this->language, $this->system_encoding, $this->client_encoding);
799
800                 // backend¥ª¥Ö¥¸¥§¥¯¥È
801                 $backend =& new Ethna_Backend($this);
802                 $this->backend =& $backend;
803
804                 // ¥¢¥¯¥·¥ç¥ó¥¹¥¯¥ê¥×¥È¤ò¥¤¥ó¥¯¥ë¡¼¥É
805                 $this->_includeActionScript();
806
807                 // amfphp¤Ë½èÍý¤ò°Ñ¾ù
808                 $gateway =& new Gateway();
809                 $gateway->setBaseClassPath('');
810                 $gateway->service();
811         }
812
813         /**
814          *      ¥¨¥é¡¼¥Ï¥ó¥É¥é
815          *
816          *      ¥¨¥é¡¼È¯À¸»þ¤ÎÄɲýèÍý¤ò¹Ô¤¤¤¿¤¤¾ì¹ç¤Ï¤³¤Î¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹
817          *      (¥¢¥é¡¼¥È¥á¡¼¥ëÁ÷¿®Åù¡Ý¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¥í¥°½ÐÎÏ»þ¤Ë¥¢¥é¡¼¥È¥á¡¼¥ë
818          *      ¤¬Á÷¿®¤µ¤ì¤ë¤¬¡¢¥¨¥é¡¼È¯À¸»þ¤ËÊ̤˥¢¥é¡¼¥È¥á¡¼¥ë¤ò¤³¤³¤ÇÁ÷¿®
819          *      ¤µ¤»¤ë¤³¤È¤â²Äǽ)
820          *
821          *      @access public
822          *      @param  object  Ethna_Error             ¥¨¥é¡¼¥ª¥Ö¥¸¥§¥¯¥È
823          */
824         function handleError(&$error)
825         {
826                 // ¥í¥°½ÐÎÏ
827                 list ($log_level, $dummy) = $this->logger->errorLevelToLogLevel($error->getLevel());
828                 $message = $error->getMessage();
829                 $this->logger->log($log_level, sprintf("[APP(%d)] %s", $error->getCode(), $message));
830         }
831
832         /**
833          *      ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤ò¼èÆÀ¤¹¤ë
834          *
835          *      @access public
836          *      @param  int             $code           ¥¨¥é¡¼¥³¡¼¥É
837          *      @return string  ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
838          */
839         function getErrorMessage($code)
840         {
841                 $message_list =& $GLOBALS['_Ethna_error_message_list'];
842                 for ($i = count($message_list)-1; $i >= 0; $i--) {
843                         if (array_key_exists($code, $message_list[$i])) {
844                                 return $message_list[$i][$code];
845                         }
846                 }
847                 return null;
848         }
849
850         /**
851          *      »ØÄꤵ¤ì¤¿¥¢¥¯¥·¥ç¥ó¤Î¥Õ¥©¡¼¥à¥¯¥é¥¹Ì¾¤òÊÖ¤¹(¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀ¸À®¤Ï¹Ô¤ï¤Ê¤¤)
852          *
853          *      @access public
854          *      @param  string  $action_name    ¥¢¥¯¥·¥ç¥ó̾
855          *      @return string  ¥¢¥¯¥·¥ç¥ó¤Î¥Õ¥©¡¼¥à¥¯¥é¥¹Ì¾
856          */
857         function getActionFormName($action_name)
858         {
859                 $action_obj =& $this->_getAction($action_name);
860                 if (is_null($action_obj)) {
861                         return null;
862                 }
863
864                 return $action_obj['form_name'];
865         }
866
867         /**
868          *      »ØÄꤵ¤ì¤¿¥¢¥¯¥·¥ç¥ó¤Î¥¯¥é¥¹Ì¾¤òÊÖ¤¹(¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀ¸À®¤Ï¹Ô¤ï¤Ê¤¤)
869          *
870          *      @access public
871          *      @param  string  $action_name    ¥¢¥¯¥·¥ç¥ó¤Î̾¾Î
872          *      @return string  ¥¢¥¯¥·¥ç¥ó¤Î¥¯¥é¥¹Ì¾
873          */
874         function getActionClassName($action_name)
875         {
876                 $action_obj =& $this->_getAction($action_name);
877                 if ($action_obj == null) {
878                         return null;
879                 }
880
881                 return $action_obj['class_name'];
882         }
883
884         /**
885          *      »ØÄꤵ¤ì¤¿Á«°Ü̾¤ËÂбþ¤¹¤ë¥Ó¥å¡¼¥¯¥é¥¹Ì¾¤òÊÖ¤¹(¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀ¸À®¤Ï¹Ô¤ï¤Ê¤¤)
886          *
887          *      ¥Ó¥å¡¼¥¯¥é¥¹¤ÏAction Class¤Ëpreforward()¥á¥½¥Ã¥É¤ò¼ÂÁõ¤·¤¿¤â¤Î(Èó¿ä¾©)¡¢
888          *      ¤¢¤ë¤¤¤ÏViewClass¤ò·Ñ¾µ¤·¤¿¤â¤Î¤¤¤º¤ì¤«¤É¤Á¤é¤Ç¤â¤è¤¤(ViewClass¿ä¾©)
889          *
890          *      @access public
891          *      @param  string  $forward_name   Á«°ÜÀè¤Î̾¾Î
892          *      @return string  view class¤Î¥¯¥é¥¹Ì¾
893          */
894         function getViewClassName($forward_name)
895         {
896                 if ($forward_name == null) {
897                         return null;
898                 }
899
900                 if (isset($this->forward[$forward_name])) {
901                         $forward_obj = $this->forward[$forward_name];
902                 } else {
903                         $forward_obj = array();
904                 }
905
906                 if (isset($forward_obj['preforward_name'])) {
907                         $class_name = $forward_obj['preforward_name'];
908                         if (class_exists($class_name)) {
909                                 return $class_name;
910                         }
911                 } else {
912                         $class_name = null;
913                 }
914
915                 // view¤Î¥¤¥ó¥¯¥ë¡¼¥É
916                 $this->_includeViewScript($forward_obj, $forward_name);
917
918                 if (is_null($class_name) == false && class_exists($class_name)) {
919                         return $class_name;
920                 } else if (is_null($class_name) == false) {
921                         $this->logger->log(LOG_WARNING, 'stated preforward class is not defined [%s] -> try default', $class_name);
922                 }
923
924                 $class_name = $this->getDefaultViewClass($forward_name);
925                 if (class_exists($class_name)) {
926                         return $class_name;
927                 } else {
928                         return null;
929                 }
930         }
931
932         /**
933          *      ¥¢¥¯¥·¥ç¥ó¤ËÂбþ¤¹¤ë¥Õ¥©¡¼¥à¥¯¥é¥¹Ì¾¤¬¾Êά¤µ¤ì¤¿¾ì¹ç¤Î¥Ç¥Õ¥©¥ë¥È¥¯¥é¥¹Ì¾¤òÊÖ¤¹
934          *
935          *      ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï[¥×¥í¥¸¥§¥¯¥ÈID]_Form_[¥¢¥¯¥·¥ç¥ó̾]¤È¤Ê¤ë¤Î¤Ç¹¥¤ß±þ¤¸¤Æ¥ª¡¼¥Ð¥é¥¤¥É¤¹¤ë
936          *
937          *      @access public
938          *      @param  string  $action_name    action̾
939          *      @param  bool    $fallback               ¥¯¥é¥¤¥¢¥ó¥È¼ïÊ̤ˤè¤ëfallback on/off
940          *      @return string  action form¥¯¥é¥¹Ì¾
941          */
942         function getDefaultFormClass($action_name, $fallback = true)
943         {
944                 $postfix = preg_replace('/_(.)/e', "strtoupper('\$1')", ucfirst($action_name));
945
946                 $r = null;
947                 if ($this->getClientType() == CLIENT_TYPE_SOAP) {
948                         $r = sprintf("%s_SOAPForm_%s", $this->getAppId(), $postfix);
949                 } else if ($this->getClientType() == CLIENT_TYPE_MOBILE_AU) {
950                         $tmp = sprintf("%s_MobileAUForm_%s", $this->getAppId(), $postfix);
951                         if ($fallback == false || class_exists($tmp)) {
952                                 $r = $tmp;
953                         }
954                 }
955
956                 if ($r == null) {
957                         $r = sprintf("%s_Form_%s", $this->getAppId(), $postfix);
958                 }
959                 $this->logger->log(LOG_DEBUG, "default action class [%s]", $r);
960                 return $r;
961         }
962
963         /**
964          *      ¥¢¥¯¥·¥ç¥ó¤ËÂбþ¤¹¤ë¥Õ¥©¡¼¥à¥Ñ¥¹Ì¾¤¬¾Êά¤µ¤ì¤¿¾ì¹ç¤Î¥Ç¥Õ¥©¥ë¥È¥Ñ¥¹Ì¾¤òÊÖ¤¹
965          *
966          *      ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï_getDefaultActionPath()¤ÈƱ¤¸·ë²Ì¤òÊÖ¤¹(1¥Õ¥¡¥¤¥ë¤Ë
967          *      ¥¢¥¯¥·¥ç¥ó¥¯¥é¥¹¤È¥Õ¥©¡¼¥à¥¯¥é¥¹¤¬µ­½Ò¤µ¤ì¤ë)¤Î¤Ç¡¢¹¥¤ß¤Ë±þ¤¸¤Æ
968          *      ¥ª¡¼¥Ð¡¼¥é¥¤¥É¤¹¤ë
969          *
970          *      @access public
971          *      @param  string  $action_name    action̾
972          *      @param  bool    $fallback               ¥¯¥é¥¤¥¢¥ó¥È¼ïÊ̤ˤè¤ëfallback on/off
973          *      @return string  form class¤¬ÄêµÁ¤µ¤ì¤ë¥¹¥¯¥ê¥×¥È¤Î¥Ñ¥¹Ì¾
974          */
975         function getDefaultFormPath($action_name, $fallback = true)
976         {
977                 return $this->getDefaultActionPath($action_name, $fallback);
978         }
979
980         /**
981          *      ¥¢¥¯¥·¥ç¥ó¤ËÂбþ¤¹¤ë¥¢¥¯¥·¥ç¥ó¥¯¥é¥¹Ì¾¤¬¾Êά¤µ¤ì¤¿¾ì¹ç¤Î¥Ç¥Õ¥©¥ë¥È¥¯¥é¥¹Ì¾¤òÊÖ¤¹
982          *
983          *      ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï[¥×¥í¥¸¥§¥¯¥ÈID]_Action_[¥¢¥¯¥·¥ç¥ó̾]¤È¤Ê¤ë¤Î¤Ç¹¥¤ß±þ¤¸¤Æ¥ª¡¼¥Ð¥é¥¤¥É¤¹¤ë
984          *
985          *      @access public
986          *      @param  string  $action_name    action̾
987          *      @param  bool    $fallback               ¥¯¥é¥¤¥¢¥ó¥È¼ïÊ̤ˤè¤ëfallback on/off
988          *      @return string  action class¥¯¥é¥¹Ì¾
989          */
990         function getDefaultActionClass($action_name, $fallback = true)
991         {
992                 $postfix = preg_replace('/_(.)/e', "strtoupper('\$1')", ucfirst($action_name));
993
994                 $r = null;
995                 if ($this->getClientType() == CLIENT_TYPE_SOAP) {
996                         $r = sprintf("%s_SOAPAction_%s", $this->getAppId(), $postfix);
997                 } else if ($this->getClientType() == CLIENT_TYPE_MOBILE_AU) {
998                         $tmp = sprintf("%s_MobileAUAction_%s", $this->getAppId(), $postfix);
999                         if ($fallback == false || class_exists($tmp)) {
1000                                 $r = $tmp;
1001                         }
1002                 }
1003
1004                 if ($r == null) {
1005                         $r = sprintf("%s_Action_%s", $this->getAppId(), $postfix);
1006                 }
1007                 $this->logger->log(LOG_DEBUG, "default action class [%s]", $r);
1008                 return $r;
1009         }
1010
1011         /**
1012          *      ¥¢¥¯¥·¥ç¥ó¤ËÂбþ¤¹¤ë¥¢¥¯¥·¥ç¥ó¥Ñ¥¹Ì¾¤¬¾Êά¤µ¤ì¤¿¾ì¹ç¤Î¥Ç¥Õ¥©¥ë¥È¥Ñ¥¹Ì¾¤òÊÖ¤¹
1013          *
1014          *      ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï"foo_bar" -> "/Foo/Bar.php"¤È¤Ê¤ë¤Î¤Ç¹¥¤ß±þ¤¸¤Æ¥ª¡¼¥Ð¡¼¥é¥¤¥É¤¹¤ë
1015          *
1016          *      @access public
1017          *      @param  string  $action_name    action̾
1018          *      @param  bool    $fallback               ¥¯¥é¥¤¥¢¥ó¥È¼ïÊ̤ˤè¤ëfallback on/off
1019          *      @return string  action class¤¬ÄêµÁ¤µ¤ì¤ë¥¹¥¯¥ê¥×¥È¤Î¥Ñ¥¹Ì¾
1020          */
1021         function getDefaultActionPath($action_name, $fallback = true)
1022         {
1023                 $default_path = preg_replace('/_(.)/e', "'/' . strtoupper('\$1')", ucfirst($action_name)) . '.php';
1024                 $action_dir = $this->getActiondir();
1025
1026                 if ($this->getClientType() == CLIENT_TYPE_SOAP) {
1027                         $r = 'SOAP/' . $r;
1028                 } else if ($this->getClientType() == CLIENT_TYPE_MOBILE_AU) {
1029                         $r = 'MobileAU/' . $r;
1030                 } else {
1031                         $r = $default_path;
1032                 }
1033
1034                 if ($fallback && file_exists($action_dir . $r) == false && $r != $default_path) {
1035                         $this->logger->log(LOG_DEBUG, 'client_type specific file not found [%s] -> try defualt', $r);
1036                         $r = $default_path;
1037                 }
1038
1039                 $this->logger->log(LOG_DEBUG, "default action path [%s]", $r);
1040                 return $r;
1041         }
1042
1043         /**
1044          *      Á«°Ü̾¤ËÂбþ¤¹¤ë¥Ó¥å¡¼¥¯¥é¥¹Ì¾¤¬¾Êά¤µ¤ì¤¿¾ì¹ç¤Î¥Ç¥Õ¥©¥ë¥È¥¯¥é¥¹Ì¾¤òÊÖ¤¹
1045          *
1046          *      ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï[¥×¥í¥¸¥§¥¯¥ÈID]_View_[Á«°Ü̾]¤È¤Ê¤ë¤Î¤Ç¹¥¤ß±þ¤¸¤Æ¥ª¡¼¥Ð¥é¥¤¥É¤¹¤ë
1047          *
1048          *      @access public
1049          *      @param  string  $forward_name   forward̾
1050          *      @param  bool    $fallback               ¥¯¥é¥¤¥¢¥ó¥È¼ïÊ̤ˤè¤ëfallback on/off
1051          *      @return string  view class¥¯¥é¥¹Ì¾
1052          */
1053         function getDefaultViewClass($forward_name, $fallback = true)
1054         {
1055                 $postfix = preg_replace('/_(.)/e', "strtoupper('\$1')", ucfirst($forward_name));
1056
1057                 $r = null;
1058                 if ($this->getClientType() == CLIENT_TYPE_MOBILE_AU) {
1059                         $tmp = sprintf("%s_MobileAUView_%s", $this->getAppId(), $postfix);
1060                         if ($fallback == false || class_exists($tmp)) {
1061                                 $r = $tmp;
1062                         }
1063                 }
1064
1065                 if ($r == null) {
1066                         $r = sprintf("%s_View_%s", $this->getAppId(), $postfix);
1067                 }
1068                 $this->logger->log(LOG_DEBUG, "default action class [%s]", $r);
1069                 return $r;
1070         }
1071
1072         /**
1073          *      Á«°Ü̾¤ËÂбþ¤¹¤ë¥Ó¥å¡¼¥Ñ¥¹Ì¾¤¬¾Êά¤µ¤ì¤¿¾ì¹ç¤Î¥Ç¥Õ¥©¥ë¥È¥Ñ¥¹Ì¾¤òÊÖ¤¹
1074          *
1075          *      ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï"foo_bar" -> "/Foo/Bar.php"¤È¤Ê¤ë¤Î¤Ç¹¥¤ß±þ¤¸¤Æ¥ª¡¼¥Ð¡¼¥é¥¤¥É¤¹¤ë
1076          *
1077          *      @access public
1078          *      @param  string  $forward_name   forward̾
1079          *      @param  bool    $fallback               ¥¯¥é¥¤¥¢¥ó¥È¼ïÊ̤ˤè¤ëfallback on/off
1080          *      @return string  view class¤¬ÄêµÁ¤µ¤ì¤ë¥¹¥¯¥ê¥×¥È¤Î¥Ñ¥¹Ì¾
1081          */
1082         function getDefaultViewPath($forward_name, $fallback = true)
1083         {
1084                 $default_path = preg_replace('/_(.)/e', "'/' . strtoupper('\$1')", ucfirst($forward_name)) . '.php';
1085                 $view_dir = $this->getViewdir();
1086
1087                 if ($this->getClientType() == CLIENT_TYPE_MOBILE_AU) {
1088                         $r = 'MobileAU/' . $r;
1089                 } else {
1090                         $r = $default_path;
1091                 }
1092
1093                 if ($fallback && file_exists($view_dir . $r) == false && $r != $default_path) {
1094                         $this->logger->log(LOG_DEBUG, 'client_type specific file not found [%s] -> try defualt', $r);
1095                         $r = $default_path;
1096                 }
1097
1098                 $this->logger->log(LOG_DEBUG, "default action path [%s]", $r);
1099                 return $r;
1100         }
1101
1102         /**
1103          *      ¼Â¹Ô¤¹¤ë¥¢¥¯¥·¥ç¥ó̾¤òÊÖ¤¹
1104          *
1105          *      @access private
1106          *      @param  mixed   $default_action_name    »ØÄê¤Îaction̾
1107          *      @return string  ¼Â¹Ô¤¹¤ë¥¢¥¯¥·¥ç¥ó̾
1108          */
1109         function _getActionName($default_action_name, $fallback_action_name)
1110         {
1111                 // ¥Õ¥©¡¼¥à¤«¤éÍ׵ᤵ¤ì¤¿action̾¤ò¼èÆÀ¤¹¤ë
1112                 $form_action_name = $this->_getActionName_Form();
1113                 $this->logger->log(LOG_DEBUG, 'form_action_name[%s]', $form_action_name);
1114
1115                 // ¥Õ¥©¡¼¥à¤«¤é¤Î»ØÄ̵꤬¤¤¾ì¹ç¤Ï¥¨¥ó¥È¥ê¥Ý¥¤¥ó¥È¤Ë»ØÄꤵ¤ì¤¿¥Ç¥Õ¥©¥ë¥ÈÃͤòÍøÍѤ¹¤ë
1116                 if ($form_action_name == "" && count($default_action_name) > 0) {
1117                         $tmp = is_array($default_action_name) ? $default_action_name[0] : $default_action_name;
1118                         $this->logger->log(LOG_DEBUG, '-> default_action_name[%s]', $tmp);
1119                         $action_name = $tmp;
1120                 } else {
1121                         $action_name = $form_action_name;
1122                 }
1123
1124                 // ¥¨¥ó¥È¥ê¥Ý¥¤¥ó¥È¤ËÇÛÎ󤬻ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï»ØÄê°Ê³°¤Îaction̾¤ÏµñÈݤ¹¤ë
1125                 if (is_array($default_action_name)) {
1126                         if (in_array($action_name, $default_action_name) == false) {
1127                                 // »ØÄê°Ê³°¤Îaction̾¤Ç¹ç¤Ã¤¿¾ì¹ç¤Ï$fallback_action_name(or ¥Ç¥Õ¥©¥ë¥È)
1128                                 $tmp = $fallback_action_name != "" ? $fallback_action_name : $default_action_name[0];
1129                                 $this->logger->log(LOG_DEBUG, '-> fallback_action_name[%s]', $tmp);
1130                                 $action_name = $tmp;
1131                         }
1132                 }
1133
1134                 $this->logger->log(LOG_DEBUG, '<<< action_name[%s] >>>', $action_name);
1135
1136                 return $action_name;
1137         }
1138
1139         /**
1140          *      ¥Õ¥©¡¼¥à¤Ë¤è¤êÍ׵ᤵ¤ì¤¿¥¢¥¯¥·¥ç¥ó̾¤òÊÖ¤¹
1141          *
1142          *      ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ÎÀ­¼Á¤Ë±þ¤¸¤Æ¤³¤Î¥á¥½¥Ã¥É¤ò¥ª¡¼¥Ð¡¼¥é¥¤¥É¤·¤Æ²¼¤µ¤¤¡£
1143          *      ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï"action_"¤Ç»Ï¤Þ¤ë¥Õ¥©¡¼¥àÃͤÎ"action_"¤ÎÉôʬ¤ò½ü¤¤¤¿¤â¤Î
1144          *      ("action_sample"¤Ê¤é"sample")¤¬action̾¤È¤·¤Æ°·¤ï¤ì¤Þ¤¹
1145          *
1146          *      @access protected
1147          *      @return string  ¥Õ¥©¡¼¥à¤Ë¤è¤êÍ׵ᤵ¤ì¤¿action¤Î̾¾Î
1148          */
1149         function _getActionName_Form()
1150         {
1151                 if (isset($_SERVER['REQUEST_METHOD']) == false) {
1152                         return $default_action_name;
1153                 }
1154
1155                 if (strcasecmp($_SERVER['REQUEST_METHOD'], 'post') == 0) {
1156                         $http_vars =& $_POST;
1157                 } else {
1158                         $http_vars =& $_GET;
1159                 }
1160
1161                 // ¥Õ¥©¡¼¥àÃͤ«¤é¥ê¥¯¥¨¥¹¥È¤µ¤ì¤¿¥¢¥¯¥·¥ç¥ó̾¤ò¼èÆÀ¤¹¤ë
1162                 $action_name = $sub_action_name = null;
1163                 foreach ($http_vars as $name => $value) {
1164                         if ($value == "" || strncmp($name, 'action_', 7) != 0) {
1165                                 continue;
1166                         }
1167
1168                         $tmp = substr($name, 7);
1169
1170                         // type="image"Âбþ
1171                         if (preg_match('/_x$/', $name) || preg_match('/_y$/', $name)) {
1172                                 $tmp = substr($tmp, 0, strlen($tmp)-2);
1173                         }
1174
1175                         // value="dummy"¤È¤Ê¤Ã¤Æ¤¤¤ë¤â¤Î¤ÏÍ¥ÀèÅÙ¤ò²¼¤²¤ë
1176                         if ($value == "dummy") {
1177                                 $sub_action_name = $tmp;
1178                         } else {
1179                                 $action_name = $tmp;
1180                         }
1181                 }
1182                 if ($action_name == null) {
1183                         $action_name = $sub_action_name;
1184                 }
1185
1186                 return $action_name;
1187         }
1188
1189         /**
1190          *      ¥Õ¥©¡¼¥à¤Ë¤è¤êÍ׵ᤵ¤ì¤¿¥¢¥¯¥·¥ç¥ó̾¤ËÂбþ¤¹¤ëÄêµÁ¤òÊÖ¤¹
1191          *
1192          *      @access private
1193          *      @param  string  $action_name    ¥¢¥¯¥·¥ç¥ó̾
1194          *      @return array   ¥¢¥¯¥·¥ç¥óÄêµÁ
1195          */
1196         function &_getAction($action_name)
1197         {
1198                 if ($this->client_type == CLIENT_TYPE_SOAP) {
1199                         $action =& $this->soap_action;
1200                 } else {
1201                         $action =& $this->action;
1202                 }
1203
1204                 $action_obj = array();
1205                 if (isset($action[$action_name])) {
1206                         $action_obj = $action[$action_name];
1207                         if (isset($action_obj['inspect']) && $action_obj['inspect']) {
1208                                 return $action_obj;
1209                         }
1210                 } else {
1211                         $this->logger->log(LOG_DEBUG, "action [%s] is not defined -> try default", $action_name);
1212                 }
1213
1214                 // ¥¢¥¯¥·¥ç¥ó¥¹¥¯¥ê¥×¥È¤Î¥¤¥ó¥¯¥ë¡¼¥É
1215                 $this->_includeActionScript($action_obj, $action_name);
1216
1217                 // ¾ÊάÃͤÎÊäÀµ
1218                 if (isset($action_obj['class_name']) == false) {
1219                         $action_obj['class_name'] = $this->getDefaultActionClass($action_name);
1220                 }
1221
1222                 if (isset($action_obj['form_name']) == false) {
1223                         $action_obj['form_name'] = $this->getDefaultFormClass($action_name);
1224                 } else {
1225                         // ÌÀ¼¨»ØÄꤵ¤ì¤¿¥Õ¥©¡¼¥à¥¯¥é¥¹¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï·Ù¹ð
1226                         $this->logger->log(LOG_WARNING, 'stated form class is not defined [%s]', $action_obj['form_name']);
1227                 }
1228
1229                 // É¬Í×¾ò·ï¤Î³Îǧ
1230                 if (class_exists($action_obj['class_name']) == false) {
1231                         $this->logger->log(LOG_WARNING, 'action class is not defined [%s]', $action_obj['class_name']);
1232                         return null;
1233                 }
1234                 if (class_exists($action_obj['form_name']) == false) {
1235                         // ¥Õ¥©¡¼¥à¥¯¥é¥¹¤Ï̤ÄêµÁ¤Ç¤âÎɤ¤
1236                         $this->logger->log(LOG_DEBUG, 'form class is not defined [%s] -> falling back to default [%s]', $action_obj['form_name'], 'Ethna_ActionForm');
1237                         $action_obj['form_name'] = 'Ethna_ActionForm';
1238                 }
1239
1240                 $action_obj['inspect'] = true;
1241                 $action[$action_name] = $action_obj;
1242                 return $action[$action_name];
1243         }
1244
1245         /**
1246          *      ¥¢¥¯¥·¥ç¥ó̾¤È¥¢¥¯¥·¥ç¥ó¥¯¥é¥¹¤«¤é¤ÎÌá¤êÃͤ˴ð¤Å¤¤¤ÆÁ«°ÜÀè¤ò·èÄꤹ¤ë
1247          *
1248          *      @access protected
1249          *      @param  string  $action_name    ¥¢¥¯¥·¥ç¥ó̾
1250          *      @param  string  $retval                 ¥¢¥¯¥·¥ç¥ó¥¯¥é¥¹¤«¤é¤ÎÌá¤êÃÍ
1251          *      @return string  Á«°ÜÀè
1252          */
1253         function _sortForward($action_name, $retval)
1254         {
1255                 return $retval;
1256         }
1257
1258         /**
1259          *      »ØÄꤵ¤ì¤¿Á«°Ü̾¤ËÂбþ¤¹¤ë²èÌ̤ò½ÐÎϤ¹¤ë
1260          *
1261          *      @access private
1262          *      @param  string  $forward_name   Á«°Ü̾
1263          *      @return bool    0:Àµ¾ï½ªÎ» -1:¥¨¥é¡¼
1264          */
1265         function _forward($forward_name)
1266         {
1267                 $forward_path = $this->_getForwardPath($forward_name);
1268                 $smarty =& $this->getTemplateEngine();
1269
1270                 $form_array =& $this->action_form->getArray();
1271                 $app_array =& $this->action_form->getAppArray();
1272                 $app_ne_array =& $this->action_form->getAppNEArray();
1273                 $smarty->assign_by_ref('form', $form_array);
1274                 $smarty->assign_by_ref('app', $app_array);
1275                 $smarty->assign_by_ref('app_ne', $app_ne_array);
1276                 $smarty->assign_by_ref('errors', Ethna_Util::escapeHtml($this->action_error->getMessageList()));
1277                 if (isset($_SESSION)) {
1278                         $smarty->assign_by_ref('session', Ethna_Util::escapeHtml($_SESSION));
1279                 }
1280                 $smarty->assign('script', basename($_SERVER['PHP_SELF']));
1281                 $smarty->assign('request_uri', htmlspecialchars($_SERVER['REQUEST_URI']));
1282
1283                 // ¥Ç¥Õ¥©¥ë¥È¥Þ¥¯¥í¤ÎÀßÄê
1284                 $this->_setDefaultMacro($smarty);
1285
1286                 $smarty->display($forward_path);
1287
1288                 return 0;
1289         }
1290
1291         /**
1292          *      Á«°Ü̾¤«¤é¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë¤Î¥Ñ¥¹Ì¾¤ò¼èÆÀ¤¹¤ë
1293          *
1294          *      @access private
1295          *      @param  string  $forward_name   forward̾
1296          *      @return string  ¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë¤Î¥Ñ¥¹Ì¾
1297          */
1298         function _getForwardPath($forward_name)
1299         {
1300                 $forward_obj = null;
1301
1302                 if (isset($this->forward[$forward_name]) == false) {
1303                         // try default
1304                         $this->forward[$forward_name] = array();
1305                 }
1306                 $forward_obj =& $this->forward[$forward_name];
1307                 if (isset($forward_obj['forward_path']) == false) {
1308                         // ¾ÊάÃÍÊäÀµ
1309                         $forward_obj['forward_path'] = $this->_getDefaultForwardPath($forward_name);
1310                 }
1311
1312                 return $forward_obj['forward_path'];
1313         }
1314
1315         /**
1316          *      »ÈÍѸÀ¸ì¤òÀßÄꤹ¤ë
1317          *
1318          *      ¾­Íè¤Ø¤Î³ÈÄ¥¤Î¤¿¤á¤Î¤ß¤Ë¸ºß¤·¤Æ¤¤¤Þ¤¹¡£¸½ºß¤ÏÆä˥ª¡¼¥Ð¡¼¥é¥¤¥É¤ÎɬÍפϤ¢¤ê¤Þ¤»¤ó¡£
1319          *
1320          *      @access protected
1321          *      @param  string  $language                       ¸À¸ìÄêµÁ(LANG_JA, LANG_EN...)
1322          *      @param  string  $system_encoding        ¥·¥¹¥Æ¥à¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°Ì¾
1323          *      @param  string  $client_encoding        ¥¯¥é¥¤¥¢¥ó¥È¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°
1324          */
1325         function _setLanguage($language, $system_encoding = null, $client_encoding = null)
1326         {
1327                 $this->language = $language;
1328                 $this->system_encoding = $system_encoding;
1329                 $this->client_encoding = $client_encoding;
1330
1331                 $this->i18n->setLanguage($language, $system_encoding, $client_encoding);
1332         }
1333
1334         /**
1335          *      ¥Ç¥Õ¥©¥ë¥È¾õÂ֤ǤλÈÍѸÀ¸ì¤ò¼èÆÀ¤¹¤ë
1336          *
1337          *      @access protected
1338          *      @return array   »ÈÍѸÀ¸ì,¥·¥¹¥Æ¥à¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°Ì¾,¥¯¥é¥¤¥¢¥ó¥È¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°Ì¾
1339          */
1340         function _getDefaultLanguage()
1341         {
1342                 return array(LANG_JA, null, null);
1343         }
1344
1345         /**
1346          *      ¥Ç¥Õ¥©¥ë¥È¾õÂ֤ǤΥ¯¥é¥¤¥¢¥ó¥È¥¿¥¤¥×¤ò¼èÆÀ¤¹¤ë
1347          *
1348          *      @access protected
1349          *      @return int             ¥¯¥é¥¤¥¢¥ó¥È¥¿¥¤¥×ÄêµÁ(CLIENT_TYPE_WWW...)
1350          */
1351         function _getDefaultClientType()
1352         {
1353                 if (is_null($GLOBALS['_Ethna_client_type']) == false) {
1354                         return $GLOBALS['_Ethna_client_type'];
1355                 }
1356                 return CLIENT_TYPE_WWW;
1357         }
1358
1359         /**
1360          *      ¥¢¥¯¥·¥ç¥ó¥¹¥¯¥ê¥×¥È¤ò¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë
1361          *
1362          *      ¤¿¤À¤·¡¢¥¤¥ó¥¯¥ë¡¼¥É¤·¤¿¥Õ¥¡¥¤¥ë¤Ë¥¯¥é¥¹¤¬Àµ¤·¤¯ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤«¤É¤¦¤«¤ÏÊݾڤ·¤Ê¤¤
1363          *
1364          *      @access private
1365          *      @param  array   $action_obj             ¥¢¥¯¥·¥ç¥óÄêµÁ
1366          *      @param  string  $action_name    ¥¢¥¯¥·¥ç¥ó̾
1367          */
1368         function _includeActionScript($action_obj, $action_name)
1369         {
1370                 $class_path = $form_path = null;
1371
1372                 $action_dir = $this->getActiondir();
1373
1374                 // class_path°À­¥Á¥§¥Ã¥¯
1375                 if (isset($action_obj['class_path'])) {
1376                         if (file_exists($action_dir . $action_obj['class_path']) == false) {
1377                                 $this->logger->log(LOG_WARNING, 'class_path file not found [%s] -> try default', $action_obj['class_path']);
1378                         } else {
1379                                 include_once($action_dir . $action_obj['class_path']);
1380                                 $class_path = $action_obj['class_path'];
1381                         }
1382                 }
1383
1384                 // ¥Ç¥Õ¥©¥ë¥È¥Á¥§¥Ã¥¯
1385                 if (is_null($class_path)) {
1386                         $class_path = $this->getDefaultActionPath($action_name);
1387                         if (file_exists($action_dir . $class_path)) {
1388                                 include_once($action_dir . $class_path);
1389                         } else {
1390                                 $this->logger->log(LOG_DEBUG, 'default action file not found [%s] -> try all files', $class_path);
1391                                 $class_path = null;
1392                         }
1393                 }
1394                 
1395                 // Á´¥Õ¥¡¥¤¥ë¥¤¥ó¥¯¥ë¡¼¥É
1396                 if (is_null($class_path)) {
1397                         $this->_includeDirectory($this->getActiondir());
1398                         return;
1399                 }
1400
1401                 // form_path°À­¥Á¥§¥Ã¥¯
1402                 if (isset($action_obj['form_path'])) {
1403                         if ($action_obj['form_path'] == $class_path) {
1404                                 return;
1405                         }
1406                         if (file_exists($action_dir . $action_obj['form_path']) == false) {
1407                                 $this->logger->log(LOG_WARNING, 'form_path file not found [%s] -> try default', $action_obj['form_path']);
1408                         } else {
1409                                 include_once($action_dir . $action_obj['form_path']);
1410                                 $form_path = $action_obj['form_path'];
1411                         }
1412                 }
1413
1414                 // ¥Ç¥Õ¥©¥ë¥È¥Á¥§¥Ã¥¯
1415                 if (is_null($form_path)) {
1416                         $form_path = $this->getDefaultFormPath($action_name);
1417                         if ($form_path == $class_path) {
1418                                 return;
1419                         }
1420                         if (file_exists($action_dir . $form_path)) {
1421                                 include_once($action_dir . $form_path);
1422                         } else {
1423                                 $this->logger->log(LOG_DEBUG, 'default form file not found [%s] -> maybe falling back to default form class', $form_path);
1424                         }
1425                 }
1426         }
1427
1428         /**
1429          *      ¥Ó¥å¡¼¥¹¥¯¥ê¥×¥È¤ò¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë
1430          *
1431          *      ¤¿¤À¤·¡¢¥¤¥ó¥¯¥ë¡¼¥É¤·¤¿¥Õ¥¡¥¤¥ë¤Ë¥¯¥é¥¹¤¬Àµ¤·¤¯ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤«¤É¤¦¤«¤ÏÊݾڤ·¤Ê¤¤
1432          *
1433          *      @access private
1434          *      @param  array   $forward_obj    Á«°ÜÄêµÁ
1435          *      @param  string  $forward_name   Á«°Ü̾
1436          */
1437         function _includeViewScript($forward_obj, $forward_name)
1438         {
1439                 $view_dir = $this->getViewdir();
1440
1441                 // preforward_path°À­¥Á¥§¥Ã¥¯
1442                 if (isset($action_obj['preforward_path'])) {
1443                         if (file_exists($view_dir . $forward_obj['preforward_path']) == false) {
1444                                 $this->logger->log(LOG_WARNING, 'preforward_path file not found [%s] -> try default', $forward_obj['preforward_path']);
1445                         } else {
1446                                 include_once($action_dir . $forward_obj['preforward_path']);
1447                                 return;
1448                         }
1449                 }
1450
1451                 // ¥Ç¥Õ¥©¥ë¥È¥Á¥§¥Ã¥¯
1452                 $preforward_path = $this->getDefaultViewPath($forward_name);
1453                 if (file_exists($view_dir . $preforward_path)) {
1454                         include_once($view_dir . $preforward_path);
1455                         return;
1456                 } else {
1457                         $this->logger->log(LOG_DEBUG, 'default preforward file not found [%s]', $preforward_path);
1458                         $preforward_path = null;
1459                 }
1460         }
1461
1462         /**
1463          *      ¥Ç¥£¥ì¥¯¥È¥ê°Ê²¼¤ÎÁ´¤Æ¤Î¥¹¥¯¥ê¥×¥È¤ò¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë
1464          *
1465          *      @access private
1466          */
1467         function _includeDirectory($dir)
1468         {
1469                 $ext = "." . $this->ext['php'];
1470                 $ext_len = strlen($ext);
1471
1472                 if (is_dir($dir) == false) {
1473                         return;
1474                 }
1475
1476                 $dh = opendir($dir);
1477                 if ($dh) {
1478                         while (($file = readdir($dh)) !== false) {
1479                                 if ($file != '.' && $file != '..' && is_dir("$dir/$file")) {
1480                                         $this->_includeDirectory("$dir/$file");
1481                                 }
1482                                 if (substr($file, -$ext_len, $ext_len) != $ext) {
1483                                         continue;
1484                                 }
1485                                 include_once("$dir/$file");
1486                         }
1487                 }
1488                 closedir($dh);
1489         }
1490
1491         /**
1492          *      Á«°Ü»þ¤Î¥Ç¥Õ¥©¥ë¥È¥Þ¥¯¥í¤òÀßÄꤹ¤ë
1493          *
1494          *      @access protected
1495          *      @param  object  Smarty  $smarty ¥Æ¥ó¥×¥ì¡¼¥È¥¨¥ó¥¸¥ó¥ª¥Ö¥¸¥§¥¯¥È
1496          */
1497         function _setDefaultMacro(&$smarty)
1498         {
1499         }
1500
1501         /**
1502          *      Ethna¥Þ¥Í¡¼¥¸¥ã¤òÀßÄꤹ¤ë(ÉÔÍפʾì¹ç¤Ï¶õ¤Î¥á¥½¥Ã¥É¤È¤·¤Æ¥ª¡¼¥Ð¡¼¥é¥¤¥É¤·¤Æ¤â¤è¤¤)
1503          *
1504          *      @access protected
1505          */
1506         function _activateEthnaManager()
1507         {
1508                 $base = dirname(dirname(__FILE__));
1509
1510                 if ($this->config->get('debug') == false) {
1511                         return;
1512                 }
1513
1514                 // actionÀßÄê
1515                 $this->action['__ethna_info__'] = array(
1516                         'form_name' =>  'Ethna_Form_Info',
1517                         'class_name' => 'Ethna_Action_Info',
1518                 );
1519                 $this->action['__ethna_info_do__'] = array(
1520                         'form_name' =>  'Ethna_Form_InfoDo',
1521                         'class_name' => 'Ethna_Action_InfoDo',
1522                 );
1523
1524                 // forwardÀßÄê
1525                 $forward_obj = array();
1526
1527                 $forward_obj['forward_path'] = sprintf("%s/tpl/info.tpl", $base);
1528                 $forward_obj['preforward_name'] = 'Ethna_Action_Info';
1529                 $this->forward['__ethna_info__'] = $forward_obj;
1530         }
1531
1532         /**
1533          *      Á«°Ü̾¤ËÂбþ¤¹¤ë¥Æ¥ó¥×¥ì¡¼¥È¥Ñ¥¹Ì¾¤¬¾Êά¤µ¤ì¤¿¾ì¹ç¤Î¥Ç¥Õ¥©¥ë¥È¥Ñ¥¹Ì¾¤òÊÖ¤¹
1534          *
1535          *      ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï"foo_bar"¤È¤¤¤¦forward̾¤¬"foo/bar" + ¥Æ¥ó¥×¥ì¡¼¥È³ÈÄ¥»Ò¤È¤Ê¤ë
1536          *      ¤Î¤Ç¹¥¤ß±þ¤¸¤Æ¥ª¡¼¥Ð¥é¥¤¥É¤¹¤ë
1537          *
1538          *      @access protected
1539          *      @param  string  $forward_name   forward̾
1540          *      @return string  forward¥Ñ¥¹Ì¾
1541          */
1542         function _getDefaultForwardPath($forward_name)
1543         {
1544                 return str_replace('_', '/', $forward_name) . '.' . $this->ext['tpl'];
1545         }
1546
1547         /**
1548          *      ÀßÄê¥Õ¥¡¥¤¥ë¤ÎDSNÄêµÁ¤«¤é»ÈÍѤ¹¤ë¥Ç¡¼¥¿¤òºÆ¹½ÃÛ¤¹¤ë(¥¹¥ì¡¼¥Ö¥¢¥¯¥»¥¹Ê¬´ôÅù)
1549          *
1550          *      DSN¤ÎÄêµÁÊýË¡(¥Ç¥Õ¥©¥ë¥È:ÀßÄê¥Õ¥¡¥¤¥ë)¤òÊѤ¨¤¿¤¤¾ì¹ç¤Ï¤³¤³¤ò¥ª¡¼¥Ð¡¼¥é¥¤¥É¤¹¤ë
1551          *
1552          *      @access protected
1553          *      @return array   DSNÄêµÁ
1554          */
1555         function _prepareDSN()
1556         {
1557                 $r = array();
1558
1559                 foreach ($this->db as $key => $value) {
1560                         $config_key = "dsn";
1561                         if ($key != "") {
1562                                 $config_key .= "_$key";
1563                         }
1564                         $dsn = $this->config->get($config_key);
1565                         if (is_array($dsn)) {
1566                                 // ¼ïÊÌ1¤Ä¤Ë¤Ä¤­Ê£¿ôDSN¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¥¢¥¯¥»¥¹Ê¬´ô
1567                                 $dsn = $this->_selectDSN($key, $dsn);
1568                         }
1569                         $r[$key] = $dsn;
1570                 }
1571                 return $r;
1572         }
1573
1574         /**
1575          *      DSN¤Î¥¢¥¯¥»¥¹Ê¬´ô¤ò¹Ô¤¦
1576          *      
1577          *      ¥¹¥ì¡¼¥Ö¥µ¡¼¥Ð¤Ø¤Î¿¶Ê¬¤±½èÍý(¥Ç¥Õ¥©¥ë¥È:¥é¥ó¥À¥à)¤òÊѹ¹¤·¤¿¤¤¾ì¹ç¤Ï¤³¤Î¥á¥½¥Ã¥É¤ò¥ª¡¼¥Ð¡¼¥é¥¤¥É¤¹¤ë
1578          *
1579          *      @access protected
1580          *      @param  string  $type           DB¼ïÊÌ
1581          *      @param  array   $dsn_list       DSN°ìÍ÷
1582          *      @return string  ÁªÂò¤µ¤ì¤¿DSN
1583          */
1584         function _selectDSN($type, $dsn_list)
1585         {
1586                 // ¥Ç¥Õ¥©¥ë¥È:¥é¥ó¥À¥à
1587                 list($usec, $sec) = explode(' ', microtime());
1588                 mt_srand($sec + ((float) $usec * 100000));
1589                 $n = mt_rand(0, count($dsn_list)-1);
1590                 
1591                 return $dsn_list[$n];
1592         }
1593 }
1594 // }}}
1595 ?>