OSDN Git Service

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