2 // vim: foldmethod=marker
6 * @author Masaki Fujimoto <fujimoto@php.net>
7 * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
12 // {{{ Ethna_Controller
16 * @author Masaki Fujimoto <fujimoto@php.net>
20 class Ethna_Controller
27 * @var string ¥¢¥×¥ê¥±¡¼¥·¥ç¥óID
29 var $appid = 'PHPSTRUTS';
32 * @var string ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ù¡¼¥¹¥Ç¥£¥ì¥¯¥È¥ê
37 * @var string ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ù¡¼¥¹URL
42 * @var string ¥¢¥×¥ê¥±¡¼¥·¥ç¥óDSN(Data Source Name)
47 * @var array ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ç¥£¥ì¥¯¥È¥ê
49 var $directory = array(
50 'action' => 'app/action',
55 'template' => 'template',
56 'template_c' => 'tmp',
62 * @var array DB¥¢¥¯¥»¥¹ÄêµÁ
69 * @var array ³ÈÄ¥»ÒÀßÄê
77 * @var array ¥¯¥é¥¹ÀßÄê
80 'config' => 'Ethna_Config',
81 'logger' => 'Ethna_Logger',
82 'sql' => 'Ethna_AppSQL',
86 * @var string »ÈÍѸÀ¸ìÀßÄê
91 * @var string ¥·¥¹¥Æ¥à¦¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°
96 * @var string ¥¯¥é¥¤¥¢¥ó¥È¦¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°
101 * @var string ¥¯¥é¥¤¥¢¥ó¥È¥¿¥¤¥×
106 * @var string ¸½ºß¼Â¹ÔÃæ¤Î¥¢¥¯¥·¥ç¥ó̾
111 * @var array forwardÄêµÁ
113 var $forward = array();
116 * @var array actionÄêµÁ
118 var $action = array();
121 * @var array soap actionÄêµÁ
123 var $soap_action = array();
126 * @var array ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Þ¥Í¡¼¥¸¥ãÄêµÁ
128 var $manager = array();
131 * @var array smarty modifierÄêµÁ
133 var $smarty_modifier_plugin = array();
136 * @var array smarty functionÄêµÁ
138 var $smarty_function_plugin = array();
141 * @var array smarty prefilterÄêµÁ
143 var $smarty_prefilter_plugin = array();
146 * @var array smarty postfilterÄêµÁ
148 var $smarty_postfilter_plugin = array();
151 * @var array smarty outputfilterÄêµÁ
153 var $smarty_outputfilter_plugin = array();
156 * @var object Ethna_Backend backend¥ª¥Ö¥¸¥§¥¯¥È
161 * @var object Ethna_I18N i18n¥ª¥Ö¥¸¥§¥¯¥È
166 * @var object Ethna_ActionError action error¥ª¥Ö¥¸¥§¥¯¥È
171 * @var object Ethna_ActionForm action form¥ª¥Ö¥¸¥§¥¯¥È
176 * @var object Ethna_Session ¥»¥Ã¥·¥ç¥ó¥ª¥Ö¥¸¥§¥¯¥È
181 * @var object Ethna_Config ÀßÄꥪ¥Ö¥¸¥§¥¯¥È
186 * @var object Ethna_Logger ¥í¥°¥ª¥Ö¥¸¥§¥¯¥È
191 * @var object Ethna_AppSQL SQL¥ª¥Ö¥¸¥§¥¯¥È
199 * Ethna_Controller¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿
203 function Ethna_Controller()
205 $GLOBALS['controller'] =& $this;
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;
217 $this->directory[$key] = $tmp;
219 if ($value{0} != '/') {
220 $this->directory[$key] = $this->base . (empty($this->base) ? '' : '/') . $value;
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();
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');
236 $logger_class = $this->class['logger'];
237 $this->logger =& new $logger_class($this);
238 $this->logger->begin();
240 // SQL¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®
241 $sql_class = $this->class['sql'];
242 $this->sql =& new $sql_class($this);
244 // Ethna¥Þ¥Í¡¼¥¸¥ãÀßÄê
245 $this->_activateEthnaManager();
249 * ¥¢¥×¥ê¥±¡¼¥·¥ç¥óID¤òÊÖ¤¹
252 * @return string ¥¢¥×¥ê¥±¡¼¥·¥ç¥óID
256 return ucfirst(strtolower($this->appid));
263 * @param string $type DB¼ïÊÌ
266 function getDSN($type = "")
268 if (isset($this->dsn[$type]) == false) {
271 return $this->dsn[$type];
275 * ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ù¡¼¥¹URL¤òÊÖ¤¹
278 * @return string ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ù¡¼¥¹URL
286 * ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ù¡¼¥¹¥Ç¥£¥ì¥¯¥È¥ê¤òÊÖ¤¹
289 * @return string ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ù¡¼¥¹¥Ç¥£¥ì¥¯¥È¥ê
291 function getBasedir()
297 * ¥¯¥é¥¤¥¢¥ó¥È¥¿¥¤¥×/¸À¸ì¤«¤é¥Æ¥ó¥×¥ì¡¼¥È¥Ç¥£¥ì¥¯¥È¥ê̾¤ò·èÄꤹ¤ë
300 * @return string ¥Æ¥ó¥×¥ì¡¼¥È¥Ç¥£¥ì¥¯¥È¥ê
302 function getTemplatedir()
304 $template = $this->getDirectory('template');
306 // ¸À¸ìÊ̥ǥ£¥ì¥¯¥È¥ê
307 if (file_exists($template . '/' . $this->language)) {
308 $template .= '/' . $this->language;
311 // ¥¯¥é¥¤¥¢¥ó¥ÈÊ̥ǥ£¥ì¥¯¥È¥ê(if we need)
312 if ($this->client_type == CLIENT_TYPE_MOBILE_AU && file_exists($template . '/au')) {
320 * ¥¢¥¯¥·¥ç¥ó¥Ç¥£¥ì¥¯¥È¥ê̾¤ò·èÄꤹ¤ë
323 * @return string ¥¢¥¯¥·¥ç¥ó¥Ç¥£¥ì¥¯¥È¥ê
325 function getActiondir()
327 return (empty($this->directory['action']) ? ($this->base . (empty($this->base) ? '' : '/')) : ($this->directory['action'] . "/"));
331 * ¥Ó¥å¡¼¥Ç¥£¥ì¥¯¥È¥ê̾¤ò·èÄꤹ¤ë
334 * @return string ¥¢¥¯¥·¥ç¥ó¥Ç¥£¥ì¥¯¥È¥ê
336 function getViewdir()
338 return (empty($this->directory['view']) ? ($this->base . (empty($this->base) ? '' : '/')) : ($this->directory['view'] . "/"));
342 * ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ç¥£¥ì¥¯¥È¥êÀßÄê¤òÊÖ¤¹
345 * @param string $key ¥Ç¥£¥ì¥¯¥È¥ê¥¿¥¤¥×("tmp", "template"...)
346 * @return string $key¤ËÂбþ¤·¤¿¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥Ç¥£¥ì¥¯¥È¥ê(ÀßÄ̵꤬¤¤¾ì¹ç¤Ïnull)
348 function getDirectory($key)
350 if (isset($this->directory[$key]) == false) {
353 return $this->directory[$key];
360 * @param string $key DB¥¿¥¤¥×("r", ...)
361 * @return string $key¤ËÂбþ¤¹¤ëDB¼ïÊÌÄêµÁ(ÀßÄ̵꤬¤¤¾ì¹ç¤Ïnull)
365 if (isset($this->db[$key]) == false) {
368 return $this->db[$key];
372 * ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó³ÈÄ¥»ÒÀßÄê¤òÊÖ¤¹
375 * @param string $key ³ÈÄ¥»Ò¥¿¥¤¥×("php", "tpl"...)
376 * @return string $key¤ËÂбþ¤·¤¿³ÈÄ¥»Ò(ÀßÄ̵꤬¤¤¾ì¹ç¤Ïnull)
378 function getExt($key)
380 if (isset($this->ext[$key]) == false) {
383 return $this->ext[$key];
387 * i18n¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¢¥¯¥»¥µ(R)
390 * @return object Ethna_I18N i18n¥ª¥Ö¥¸¥§¥¯¥È
398 * ÀßÄꥪ¥Ö¥¸¥§¥¯¥È¤Î¥¢¥¯¥»¥µ
401 * @return object Ethna_Config ÀßÄꥪ¥Ö¥¸¥§¥¯¥È
403 function &getConfig()
405 return $this->config;
409 * backend¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¢¥¯¥»¥µ
412 * @return object Ethna_Backend backend¥ª¥Ö¥¸¥§¥¯¥È
414 function &getBackend()
416 return $this->backend;
420 * action error¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¢¥¯¥»¥µ
423 * @return object Ethna_ActionError action error¥ª¥Ö¥¸¥§¥¯¥È
425 function &getActionError()
427 return $this->action_error;
431 * action form¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¢¥¯¥»¥µ
434 * @return object Ethna_ActionForm action form¥ª¥Ö¥¸¥§¥¯¥È
436 function &getActionForm()
438 return $this->action_form;
442 * ¥»¥Ã¥·¥ç¥ó¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¢¥¯¥»¥µ
445 * @return object Ethna_Session ¥»¥Ã¥·¥ç¥ó¥ª¥Ö¥¸¥§¥¯¥È
447 function &getSession()
449 return $this->session;
453 * ¥í¥°¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¢¥¯¥»¥µ
456 * @return object Ethna_Logger ¥í¥°¥ª¥Ö¥¸¥§¥¯¥È
458 function &getLogger()
460 return $this->logger;
464 * SQL¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¢¥¯¥»¥µ
467 * @return object Ethna_AppSQL SQL¥ª¥Ö¥¸¥§¥¯¥È
475 * ¥Þ¥Í¡¼¥¸¥ã°ìÍ÷¤òÊÖ¤¹
478 * @return array ¥Þ¥Í¡¼¥¸¥ã°ìÍ÷
480 function getManagerList()
482 return $this->manager;
486 * ¼Â¹ÔÃæ¤Î¥¢¥¯¥·¥ç¥ó̾¤òÊÖ¤¹
489 * @return string ¼Â¹ÔÃæ¤Î¥¢¥¯¥·¥ç¥ó̾
491 function getCurrentActionName()
493 return $this->action_name;
500 * @return array »ÈÍѸÀ¸ì,¥·¥¹¥Æ¥à¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°Ì¾,¥¯¥é¥¤¥¢¥ó¥È¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°Ì¾
502 function getLanguage()
504 return array($this->language, $this->system_encoding, $this->client_encoding);
508 * ¥¯¥é¥¤¥¢¥ó¥È¥¿¥¤¥×¤ò¼èÆÀ¤¹¤ë
511 * @return int ¥¯¥é¥¤¥¢¥ó¥È¥¿¥¤¥×ÄêµÁ(CLIENT_TYPE_WWW...)
513 function getClientType()
515 return $this->client_type;
519 * ¥¯¥é¥¤¥¢¥ó¥È¥¿¥¤¥×¤òÀßÄꤹ¤ë
522 * @param int $client_type ¥¯¥é¥¤¥¢¥ó¥È¥¿¥¤¥×ÄêµÁ(CLIENT_TYPE_WWW...)
524 function setClientType($client_type)
526 $this->client_type = $client_type;
530 * ¥Æ¥ó¥×¥ì¡¼¥È¥¨¥ó¥¸¥ó¼èÆÀ¤¹¤ë(¸½ºß¤Ïsmarty¤Î¤ßÂбþ)
533 * @return object Smarty ¥Æ¥ó¥×¥ì¡¼¥È¥¨¥ó¥¸¥ó¥ª¥Ö¥¸¥§¥¯¥È
534 * @todo ¥Ö¥í¥Ã¥¯´Ø¿ô¥×¥é¥°¥¤¥ó(etc)Âбþ
536 function &getTemplateEngine()
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);
544 $smarty->plugins_dir = $this->getDirectory('plugins');
545 var_dump($smarty->plugins_dir);
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');
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);
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');
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);
578 // user defined prefilters
579 foreach ($this->smarty_prefilter_plugin as $prefilter) {
580 $smarty->register_prefilter($prefilter);
583 // user defined postfilters
584 foreach ($this->smarty_postfilter_plugin as $postfilter) {
585 $smarty->register_postfilter($postfilter);
588 // user defined outputfilters
589 foreach ($this->smarty_outputfilter_plugin as $outputfilter) {
590 $smarty->register_outputfilter($outputfilter);
597 * ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¥¨¥ó¥È¥ê¥Ý¥¤¥ó¥È
600 * @param string $class_name ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥³¥ó¥È¥í¡¼¥é¤Î¥¯¥é¥¹Ì¾
601 * @param mixed $action_name »ØÄê¤Î¥¢¥¯¥·¥ç¥ó̾(¾Êά²Ä)
602 * @param mixed $fallback_action_name ¥¢¥¯¥·¥ç¥ó¤¬·èÄê¤Ç¤¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¼Â¹Ô¤µ¤ì¤ë¥¢¥¯¥·¥ç¥ó̾(¾Êά²Ä)
605 function main($class_name, $action_name = "", $fallback_action_name = "")
607 $c =& new $class_name;
608 $c->trigger($action_name, $fallback_action_name);
612 * ¥³¥Þ¥ó¥É¥é¥¤¥ó¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¥¨¥ó¥È¥ê¥Ý¥¤¥ó¥È
615 * @param string $class_name ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥³¥ó¥È¥í¡¼¥é¤Î¥¯¥é¥¹Ì¾
616 * @param string $action_name ¼Â¹Ô¤¹¤ë¥¢¥¯¥·¥ç¥ó̾
619 function main_CLI($class_name, $action_name)
621 $c =& new $class_name;
622 $c->action[$action_name] = array();
623 $c->trigger($action_name);
627 * SOAP¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¥¨¥ó¥È¥ê¥Ý¥¤¥ó¥È
630 * @param string $class_name ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥³¥ó¥È¥í¡¼¥é¤Î¥¯¥é¥¹Ì¾
633 function main_SOAP($class_name)
635 $c =& new $class_name;
636 $c->setClientType(CLIENT_TYPE_SOAP);
641 * AMF(Flash Remoting)¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¥¨¥ó¥È¥ê¥Ý¥¤¥ó¥È
644 * @param string $class_name ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¥³¥ó¥È¥í¡¼¥é¤Î¥¯¥é¥¹Ì¾
647 function main_AMF($class_name)
649 $c =& new $class_name;
650 $c->setClientType(CLIENT_TYPE_AMF);
655 * ¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Î½èÍý¤ò³«»Ï¤¹¤ë
657 * °ú¿ô$default_action_name¤ËÇÛÎ󤬻ØÄꤵ¤ì¤¿¾ì¹ç¡¢¤½¤ÎÇÛÎó¤Ç»ØÄꤵ¤ì¤¿
658 * ¥¢¥¯¥·¥ç¥ó°Ê³°¤Ï¼õ¤±ÉÕ¤±¤Ê¤¤(¤½¤ì°Ê³°¤Î¥¢¥¯¥·¥ç¥ó¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢
659 * ÇÛÎó¤ÎÀèƬ¤Ç»ØÄꤵ¤ì¤¿¥¢¥¯¥·¥ç¥ó¤¬¼Â¹Ô¤µ¤ì¤ë)
662 * @param mixed $default_action_name »ØÄê¤Î¥¢¥¯¥·¥ç¥ó̾
663 * @param mixed $fallback_action_name ¥¢¥¯¥·¥ç¥ó̾¤¬·èÄê¤Ç¤¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¼Â¹Ô¤µ¤ì¤ë¥¢¥¯¥·¥ç¥ó̾
664 * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼
666 function trigger($default_action_name = "", $fallback_action_name = "")
668 // ¥¢¥¯¥·¥ç¥ó̾¤Î¼èÆÀ
669 $action_name = $this->_getActionName($default_action_name, $fallback_action_name);
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);
678 if ($action_obj == null) {
679 return Ethna::raiseError(E_APP_UNDEFINED_ACTION, "undefined action [%s]", $action_name);
681 $action_name = $fallback_action_name;
684 $this->action_name = $action_name;
687 $this->_setLanguage($this->language, $this->system_encoding, $this->client_encoding);
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);
695 // ¥Ð¥Ã¥¯¥¨¥ó¥É½èÍý¼Â¹Ô
696 $backend =& new Ethna_Backend($this);
697 $this->backend =& $backend;
698 $forward_name = $backend->perform($action_name);
700 // ¥³¥ó¥È¥í¡¼¥é¤ÇÁ«°ÜÀè¤ò·èÄꤹ¤ë
701 $forward_name = $this->_sortForward($action_name, $forward_name);
703 if ($forward_name != null) {
704 $backend->preforward($forward_name);
706 if ($this->_forward($forward_name) != 0) {
715 * SOAP¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Î½èÍý¤ò³«»Ï¤¹¤ë
719 function trigger_SOAP()
721 // ¥¢¥¯¥·¥ç¥ó¥¹¥¯¥ê¥×¥È¤ò¥¤¥ó¥¯¥ë¡¼¥É
722 $this->_includeActionScript();
724 // SOAP¥¨¥ó¥È¥ê¥¯¥é¥¹
725 $gg =& new Ethna_SoapGatewayGenerator();
726 $script = $gg->generate();
729 // SOAP¥ê¥¯¥¨¥¹¥È½èÍý
730 $server =& new SoapServer(null, array('uri' => $this->config->get('url')));
731 $server->setClass($gg->getClassName());
736 * AMF(Flash Remoting)¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤Î½èÍý¤ò³«»Ï¤¹¤ë
740 function trigger_AMF()
742 include_once('ethna/contrib/amfphp/app/Gateway.php');
744 $this->action_error =& new Ethna_ActionError();
746 // Credential¥Ø¥Ã¥À¤Ç¥»¥Ã¥·¥ç¥ó¤ò½èÍý¤¹¤ë¤Î¤Ç¤³¤³¤Ç¤Ïnull¤ËÀßÄê
747 $this->session = null;
749 $this->_setLanguage($this->language, $this->system_encoding, $this->client_encoding);
751 // backend¥ª¥Ö¥¸¥§¥¯¥È
752 $backend =& new Ethna_Backend($this);
753 $this->backend =& $backend;
755 // ¥¢¥¯¥·¥ç¥ó¥¹¥¯¥ê¥×¥È¤ò¥¤¥ó¥¯¥ë¡¼¥É
756 $this->_includeActionScript();
758 // amfphp¤Ë½èÍý¤ò°Ñ¾ù
759 $gateway =& new Gateway();
760 $gateway->setBaseClassPath('');
765 * Ã×̿Ū¥¨¥é¡¼È¯À¸»þ¤Î²èÌ̤òɽ¼¨¤¹¤ë
767 * Ãí°Õ¡§¥á¥½¥Ã¥É¸Æ¤Ó½Ð¤·¸åÁ´¤Æ¤Î½èÍý¤ÏÃæÃǤµ¤ì¤ë(¤³¤Î¥á¥½¥Ã¥É¤Çexit()¤¹¤ë)
777 * »ØÄꤵ¤ì¤¿¥¢¥¯¥·¥ç¥ó¤Î¥Õ¥©¡¼¥à¥¯¥é¥¹Ì¾¤òÊÖ¤¹(¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀ¸À®¤Ï¹Ô¤ï¤Ê¤¤)
780 * @param string $action_name ¥¢¥¯¥·¥ç¥ó̾
781 * @return string ¥¢¥¯¥·¥ç¥ó¤Î¥Õ¥©¡¼¥à¥¯¥é¥¹Ì¾
783 function getActionFormName($action_name)
785 $action_obj =& $this->_getAction($action_name);
786 if (is_null($action_obj)) {
790 return $action_obj['form_name'];
794 * »ØÄꤵ¤ì¤¿¥¢¥¯¥·¥ç¥ó¤Î¥¯¥é¥¹Ì¾¤òÊÖ¤¹(¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀ¸À®¤Ï¹Ô¤ï¤Ê¤¤)
797 * @param string $action_name ¥¢¥¯¥·¥ç¥ó¤Î̾¾Î
798 * @return string ¥¢¥¯¥·¥ç¥ó¤Î¥¯¥é¥¹Ì¾
800 function getActionClassName($action_name)
802 $action_obj =& $this->_getAction($action_name);
803 if ($action_obj == null) {
807 return $action_obj['class_name'];
811 * »ØÄꤵ¤ì¤¿Á«°Ü̾¤ËÂбþ¤¹¤ë¥Ó¥å¡¼¥¯¥é¥¹Ì¾¤òÊÖ¤¹(¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀ¸À®¤Ï¹Ô¤ï¤Ê¤¤)
813 * ¥Ó¥å¡¼¥¯¥é¥¹¤ÏAction Class¤Ëpreforward()¥á¥½¥Ã¥É¤ò¼ÂÁõ¤·¤¿¤â¤Î(Èó¿ä¾©)¡¢
814 * ¤¢¤ë¤¤¤ÏViewClass¤ò·Ñ¾µ¤·¤¿¤â¤Î¤¤¤º¤ì¤«¤É¤Á¤é¤Ç¤â¤è¤¤(ViewClass¿ä¾©)
817 * @param string $forward_name Á«°ÜÀè¤Î̾¾Î
818 * @return string view class¤Î¥¯¥é¥¹Ì¾
820 function getViewClassName($forward_name)
822 if ($forward_name == null) {
826 if (isset($this->forward[$forward_name])) {
827 $forward_obj = $this->forward[$forward_name];
829 $forward_obj = array();
832 if (isset($forward_obj['preforward_name'])) {
833 $class_name = $forward_obj['preforward_name'];
834 if (class_exists($class_name)) {
841 // view¤Î¥¤¥ó¥¯¥ë¡¼¥É
842 $this->_includeViewScript($forward_obj, $forward_name);
844 if (is_null($class_name) == false && class_exists($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);
850 $class_name = $this->getDefaultViewClass($forward_name);
851 if (class_exists($class_name)) {
859 * ¥¢¥¯¥·¥ç¥ó¤ËÂбþ¤¹¤ë¥Õ¥©¡¼¥à¥¯¥é¥¹Ì¾¤¬¾Êά¤µ¤ì¤¿¾ì¹ç¤Î¥Ç¥Õ¥©¥ë¥È¥¯¥é¥¹Ì¾¤òÊÖ¤¹
861 * ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï[¥×¥í¥¸¥§¥¯¥ÈID]_Form_[¥¢¥¯¥·¥ç¥ó̾]¤È¤Ê¤ë¤Î¤Ç¹¥¤ß±þ¤¸¤Æ¥ª¡¼¥Ð¥é¥¤¥É¤¹¤ë
864 * @param string $action_name action̾
865 * @param bool $fallback ¥¯¥é¥¤¥¢¥ó¥È¼ïÊ̤ˤè¤ëfallback on/off
866 * @return string action form¥¯¥é¥¹Ì¾
868 function getDefaultFormClass($action_name, $fallback = true)
870 $postfix = preg_replace('/_(.)/e', "strtoupper('\$1')", ucfirst($action_name));
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)) {
883 $r = sprintf("%s_Form_%s", $this->getAppId(), $postfix);
885 $this->logger->log(LOG_DEBUG, "default action class [%s]", $r);
890 * ¥¢¥¯¥·¥ç¥ó¤ËÂбþ¤¹¤ë¥Õ¥©¡¼¥à¥Ñ¥¹Ì¾¤¬¾Êά¤µ¤ì¤¿¾ì¹ç¤Î¥Ç¥Õ¥©¥ë¥È¥Ñ¥¹Ì¾¤òÊÖ¤¹
892 * ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï_getDefaultActionPath()¤ÈƱ¤¸·ë²Ì¤òÊÖ¤¹(1¥Õ¥¡¥¤¥ë¤Ë
893 * ¥¢¥¯¥·¥ç¥ó¥¯¥é¥¹¤È¥Õ¥©¡¼¥à¥¯¥é¥¹¤¬µ½Ò¤µ¤ì¤ë)¤Î¤Ç¡¢¹¥¤ß¤Ë±þ¤¸¤Æ
897 * @param string $action_name action̾
898 * @param bool $fallback ¥¯¥é¥¤¥¢¥ó¥È¼ïÊ̤ˤè¤ëfallback on/off
899 * @return string form class¤¬ÄêµÁ¤µ¤ì¤ë¥¹¥¯¥ê¥×¥È¤Î¥Ñ¥¹Ì¾
901 function getDefaultFormPath($action_name, $fallback = true)
903 return $this->getDefaultActionPath($action_name, $fallback);
907 * ¥¢¥¯¥·¥ç¥ó¤ËÂбþ¤¹¤ë¥¢¥¯¥·¥ç¥ó¥¯¥é¥¹Ì¾¤¬¾Êά¤µ¤ì¤¿¾ì¹ç¤Î¥Ç¥Õ¥©¥ë¥È¥¯¥é¥¹Ì¾¤òÊÖ¤¹
909 * ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï[¥×¥í¥¸¥§¥¯¥ÈID]_Action_[¥¢¥¯¥·¥ç¥ó̾]¤È¤Ê¤ë¤Î¤Ç¹¥¤ß±þ¤¸¤Æ¥ª¡¼¥Ð¥é¥¤¥É¤¹¤ë
912 * @param string $action_name action̾
913 * @param bool $fallback ¥¯¥é¥¤¥¢¥ó¥È¼ïÊ̤ˤè¤ëfallback on/off
914 * @return string action class¥¯¥é¥¹Ì¾
916 function getDefaultActionClass($action_name, $fallback = true)
918 $postfix = preg_replace('/_(.)/e', "strtoupper('\$1')", ucfirst($action_name));
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)) {
931 $r = sprintf("%s_Action_%s", $this->getAppId(), $postfix);
933 $this->logger->log(LOG_DEBUG, "default action class [%s]", $r);
938 * ¥¢¥¯¥·¥ç¥ó¤ËÂбþ¤¹¤ë¥¢¥¯¥·¥ç¥ó¥Ñ¥¹Ì¾¤¬¾Êά¤µ¤ì¤¿¾ì¹ç¤Î¥Ç¥Õ¥©¥ë¥È¥Ñ¥¹Ì¾¤òÊÖ¤¹
940 * ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï"foo_bar" -> "/Foo/Bar.php"¤È¤Ê¤ë¤Î¤Ç¹¥¤ß±þ¤¸¤Æ¥ª¡¼¥Ð¡¼¥é¥¤¥É¤¹¤ë
943 * @param string $action_name action̾
944 * @param bool $fallback ¥¯¥é¥¤¥¢¥ó¥È¼ïÊ̤ˤè¤ëfallback on/off
945 * @return string action class¤¬ÄêµÁ¤µ¤ì¤ë¥¹¥¯¥ê¥×¥È¤Î¥Ñ¥¹Ì¾
947 function getDefaultActionPath($action_name, $fallback = true)
949 $default_path = preg_replace('/_(.)/e', "'/' . strtoupper('\$1')", ucfirst($action_name)) . '.php';
950 $action_dir = $this->getActiondir();
952 if ($this->getClientType() == CLIENT_TYPE_SOAP) {
954 } else if ($this->getClientType() == CLIENT_TYPE_MOBILE_AU) {
955 $r = 'MobileAU/' . $r;
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);
965 $this->logger->log(LOG_DEBUG, "default action path [%s]", $r);
970 * Á«°Ü̾¤ËÂбþ¤¹¤ë¥Ó¥å¡¼¥¯¥é¥¹Ì¾¤¬¾Êά¤µ¤ì¤¿¾ì¹ç¤Î¥Ç¥Õ¥©¥ë¥È¥¯¥é¥¹Ì¾¤òÊÖ¤¹
972 * ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï[¥×¥í¥¸¥§¥¯¥ÈID]_View_[Á«°Ü̾]¤È¤Ê¤ë¤Î¤Ç¹¥¤ß±þ¤¸¤Æ¥ª¡¼¥Ð¥é¥¤¥É¤¹¤ë
975 * @param string $forward_name forward̾
976 * @param bool $fallback ¥¯¥é¥¤¥¢¥ó¥È¼ïÊ̤ˤè¤ëfallback on/off
977 * @return string view class¥¯¥é¥¹Ì¾
979 function getDefaultViewClass($forward_name, $fallback = true)
981 $postfix = preg_replace('/_(.)/e', "strtoupper('\$1')", ucfirst($forward_name));
984 if ($this->getClientType() == CLIENT_TYPE_MOBILE_AU) {
985 $tmp = sprintf("%s_MobileAUView_%s", $this->getAppId(), $postfix);
986 if ($fallback == false || class_exists($tmp)) {
992 $r = sprintf("%s_View_%s", $this->getAppId(), $postfix);
994 $this->logger->log(LOG_DEBUG, "default action class [%s]", $r);
999 * Á«°Ü̾¤ËÂбþ¤¹¤ë¥Ó¥å¡¼¥Ñ¥¹Ì¾¤¬¾Êά¤µ¤ì¤¿¾ì¹ç¤Î¥Ç¥Õ¥©¥ë¥È¥Ñ¥¹Ì¾¤òÊÖ¤¹
1001 * ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï"foo_bar" -> "/Foo/Bar.php"¤È¤Ê¤ë¤Î¤Ç¹¥¤ß±þ¤¸¤Æ¥ª¡¼¥Ð¡¼¥é¥¤¥É¤¹¤ë
1004 * @param string $forward_name forward̾
1005 * @param bool $fallback ¥¯¥é¥¤¥¢¥ó¥È¼ïÊ̤ˤè¤ëfallback on/off
1006 * @return string view class¤¬ÄêµÁ¤µ¤ì¤ë¥¹¥¯¥ê¥×¥È¤Î¥Ñ¥¹Ì¾
1008 function getDefaultViewPath($forward_name, $fallback = true)
1010 $default_path = preg_replace('/_(.)/e', "'/' . strtoupper('\$1')", ucfirst($forward_name)) . '.php';
1011 $view_dir = $this->getViewdir();
1013 if ($this->getClientType() == CLIENT_TYPE_MOBILE_AU) {
1014 $r = 'MobileAU/' . $r;
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);
1024 $this->logger->log(LOG_DEBUG, "default action path [%s]", $r);
1029 * ¼Â¹Ô¤¹¤ë¥¢¥¯¥·¥ç¥ó̾¤òÊÖ¤¹
1032 * @param mixed $default_action_name »ØÄê¤Îaction̾
1033 * @return string ¼Â¹Ô¤¹¤ë¥¢¥¯¥·¥ç¥ó̾
1035 function _getActionName($default_action_name, $fallback_action_name)
1037 // ¥Õ¥©¡¼¥à¤«¤éÍ׵ᤵ¤ì¤¿action̾¤ò¼èÆÀ¤¹¤ë
1038 $form_action_name = $this->_getActionName_Form();
1039 $this->logger->log(LOG_DEBUG, 'form_action_name[%s]', $form_action_name);
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;
1047 $action_name = $form_action_name;
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;
1060 $this->logger->log(LOG_DEBUG, '<<< action_name[%s] >>>', $action_name);
1062 return $action_name;
1066 * ¥Õ¥©¡¼¥à¤Ë¤è¤êÍ׵ᤵ¤ì¤¿¥¢¥¯¥·¥ç¥ó̾¤òÊÖ¤¹
1068 * ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ÎÀ¼Á¤Ë±þ¤¸¤Æ¤³¤Î¥á¥½¥Ã¥É¤ò¥ª¡¼¥Ð¡¼¥é¥¤¥É¤·¤Æ²¼¤µ¤¤¡£
1069 * ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï"action_"¤Ç»Ï¤Þ¤ë¥Õ¥©¡¼¥àÃͤÎ"action_"¤ÎÉôʬ¤ò½ü¤¤¤¿¤â¤Î
1070 * ("action_sample"¤Ê¤é"sample")¤¬action̾¤È¤·¤Æ°·¤ï¤ì¤Þ¤¹
1073 * @return string ¥Õ¥©¡¼¥à¤Ë¤è¤êÍ׵ᤵ¤ì¤¿action¤Î̾¾Î
1075 function _getActionName_Form()
1077 if (isset($_SERVER['REQUEST_METHOD']) == false) {
1078 return $default_action_name;
1081 if (strcasecmp($_SERVER['REQUEST_METHOD'], 'post') == 0) {
1082 $http_vars =& $_POST;
1084 $http_vars =& $_GET;
1087 // ¥Õ¥©¡¼¥àÃͤ«¤é¥ê¥¯¥¨¥¹¥È¤µ¤ì¤¿¥¢¥¯¥·¥ç¥ó̾¤ò¼èÆÀ¤¹¤ë
1088 $action_name = $sub_action_name = null;
1089 foreach ($http_vars as $name => $value) {
1090 if ($value == "" || strncmp($name, 'action_', 7) != 0) {
1094 $tmp = substr($name, 7);
1097 if (preg_match('/_x$/', $name) || preg_match('/_y$/', $name)) {
1098 $tmp = substr($tmp, 0, strlen($tmp)-2);
1101 // value="dummy"¤È¤Ê¤Ã¤Æ¤¤¤ë¤â¤Î¤ÏÍ¥ÀèÅÙ¤ò²¼¤²¤ë
1102 if ($value == "dummy") {
1103 $sub_action_name = $tmp;
1105 $action_name = $tmp;
1108 if ($action_name == null) {
1109 $action_name = $sub_action_name;
1112 return $action_name;
1116 * ¥Õ¥©¡¼¥à¤Ë¤è¤êÍ׵ᤵ¤ì¤¿¥¢¥¯¥·¥ç¥ó̾¤ËÂбþ¤¹¤ëÄêµÁ¤òÊÖ¤¹
1119 * @param string $action_name ¥¢¥¯¥·¥ç¥ó̾
1120 * @return array ¥¢¥¯¥·¥ç¥óÄêµÁ
1122 function &_getAction($action_name)
1124 if ($this->client_type == CLIENT_TYPE_SOAP) {
1125 $action =& $this->soap_action;
1127 $action =& $this->action;
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']) {
1137 $this->logger->log(LOG_DEBUG, "action [%s] is not defined -> try default", $action_name);
1140 // ¥¢¥¯¥·¥ç¥ó¥¹¥¯¥ê¥×¥È¤Î¥¤¥ó¥¯¥ë¡¼¥É
1141 $this->_includeActionScript($action_obj, $action_name);
1144 if (isset($action_obj['class_name']) == false) {
1145 $action_obj['class_name'] = $this->getDefaultActionClass($action_name);
1148 if (isset($action_obj['form_name']) == false) {
1149 $action_obj['form_name'] = $this->getDefaultFormClass($action_name);
1151 // ÌÀ¼¨»ØÄꤵ¤ì¤¿¥Õ¥©¡¼¥à¥¯¥é¥¹¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï·Ù¹ð
1152 $this->logger->log(LOG_WARNING, 'stated form class is not defined [%s]', $action_obj['form_name']);
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']);
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';
1166 $action_obj['inspect'] = true;
1167 $action[$action_name] = $action_obj;
1168 return $action[$action_name];
1172 * ¥¢¥¯¥·¥ç¥ó̾¤È¥¢¥¯¥·¥ç¥ó¥¯¥é¥¹¤«¤é¤ÎÌá¤êÃͤ˴ð¤Å¤¤¤ÆÁ«°ÜÀè¤ò·èÄꤹ¤ë
1175 * @param string $action_name ¥¢¥¯¥·¥ç¥ó̾
1176 * @param string $retval ¥¢¥¯¥·¥ç¥ó¥¯¥é¥¹¤«¤é¤ÎÌá¤êÃÍ
1177 * @return string Á«°ÜÀè
1179 function _sortForward($action_name, $retval)
1185 * »ØÄꤵ¤ì¤¿Á«°Ü̾¤ËÂбþ¤¹¤ë²èÌ̤ò½ÐÎϤ¹¤ë
1188 * @param string $forward_name Á«°Ü̾
1189 * @return bool 0:Àµ¾ï½ªÎ» -1:¥¨¥é¡¼
1191 function _forward($forward_name)
1193 $forward_path = $this->_getForwardPath($forward_name);
1194 $smarty =& $this->getTemplateEngine();
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));
1206 $smarty->assign('script', basename($_SERVER['PHP_SELF']));
1207 $smarty->assign('request_uri', htmlspecialchars($_SERVER['REQUEST_URI']));
1209 // ¥Ç¥Õ¥©¥ë¥È¥Þ¥¯¥í¤ÎÀßÄê
1210 $this->_setDefaultMacro($smarty);
1212 $smarty->display($forward_path);
1218 * Á«°Ü̾¤«¤é¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë¤Î¥Ñ¥¹Ì¾¤ò¼èÆÀ¤¹¤ë
1221 * @param string $forward_name forward̾
1222 * @return string ¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë¤Î¥Ñ¥¹Ì¾
1224 function _getForwardPath($forward_name)
1226 $forward_obj = null;
1228 if (isset($this->forward[$forward_name]) == false) {
1230 $this->forward[$forward_name] = array();
1232 $forward_obj =& $this->forward[$forward_name];
1233 if (isset($forward_obj['forward_path']) == false) {
1235 $forward_obj['forward_path'] = $this->_getDefaultForwardPath($forward_name);
1238 return $forward_obj['forward_path'];
1242 * »ÈÍѸÀ¸ì¤òÀßÄꤹ¤ë
1244 * ¾Íè¤Ø¤Î³ÈÄ¥¤Î¤¿¤á¤Î¤ß¤Ë¸ºß¤·¤Æ¤¤¤Þ¤¹¡£¸½ºß¤ÏÆä˥ª¡¼¥Ð¡¼¥é¥¤¥É¤ÎɬÍפϤ¢¤ê¤Þ¤»¤ó¡£
1247 * @param string $language ¸À¸ìÄêµÁ(LANG_JA, LANG_EN...)
1248 * @param string $system_encoding ¥·¥¹¥Æ¥à¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°Ì¾
1249 * @param string $client_encoding ¥¯¥é¥¤¥¢¥ó¥È¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°
1251 function _setLanguage($language, $system_encoding = null, $client_encoding = null)
1253 $this->language = $language;
1254 $this->system_encoding = $system_encoding;
1255 $this->client_encoding = $client_encoding;
1257 $this->i18n->setLanguage($language, $system_encoding, $client_encoding);
1261 * ¥Ç¥Õ¥©¥ë¥È¾õÂ֤ǤλÈÍѸÀ¸ì¤ò¼èÆÀ¤¹¤ë
1264 * @return array »ÈÍѸÀ¸ì,¥·¥¹¥Æ¥à¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°Ì¾,¥¯¥é¥¤¥¢¥ó¥È¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°Ì¾
1266 function _getDefaultLanguage()
1268 return array(LANG_JA, null, null);
1272 * ¥Ç¥Õ¥©¥ë¥È¾õÂ֤ǤΥ¯¥é¥¤¥¢¥ó¥È¥¿¥¤¥×¤ò¼èÆÀ¤¹¤ë
1275 * @return int ¥¯¥é¥¤¥¢¥ó¥È¥¿¥¤¥×ÄêµÁ(CLIENT_TYPE_WWW...)
1277 function _getDefaultClientType()
1279 if (is_null($GLOBALS['_Ethna_client_type']) == false) {
1280 return $GLOBALS['_Ethna_client_type'];
1282 return CLIENT_TYPE_WWW;
1286 * ¥¢¥¯¥·¥ç¥ó¥¹¥¯¥ê¥×¥È¤ò¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë
1288 * ¤¿¤À¤·¡¢¥¤¥ó¥¯¥ë¡¼¥É¤·¤¿¥Õ¥¡¥¤¥ë¤Ë¥¯¥é¥¹¤¬Àµ¤·¤¯ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤«¤É¤¦¤«¤ÏÊݾڤ·¤Ê¤¤
1291 * @param array $action_obj ¥¢¥¯¥·¥ç¥óÄêµÁ
1292 * @param string $action_name ¥¢¥¯¥·¥ç¥ó̾
1294 function _includeActionScript($action_obj, $action_name)
1296 $class_path = $form_path = null;
1298 $action_dir = $this->getActiondir();
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']);
1305 include_once($action_dir . $action_obj['class_path']);
1306 $class_path = $action_obj['class_path'];
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);
1316 $this->logger->log(LOG_DEBUG, 'default action file not found [%s] -> try all files', $class_path);
1321 // Á´¥Õ¥¡¥¤¥ë¥¤¥ó¥¯¥ë¡¼¥É
1322 if (is_null($class_path)) {
1323 $this->_includeDirectory($this->getActiondir());
1327 // form_path°À¥Á¥§¥Ã¥¯
1328 if (isset($action_obj['form_path'])) {
1329 if ($action_obj['form_path'] == $class_path) {
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']);
1335 include_once($action_dir . $action_obj['form_path']);
1336 $form_path = $action_obj['form_path'];
1340 // ¥Ç¥Õ¥©¥ë¥È¥Á¥§¥Ã¥¯
1341 if (is_null($form_path)) {
1342 $form_path = $this->getDefaultFormPath($action_name);
1343 if ($form_path == $class_path) {
1346 if (file_exists($action_dir . $form_path)) {
1347 include_once($action_dir . $form_path);
1349 $this->logger->log(LOG_DEBUG, 'default form file not found [%s] -> maybe falling back to default form class', $form_path);
1355 * ¥Ó¥å¡¼¥¹¥¯¥ê¥×¥È¤ò¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë
1357 * ¤¿¤À¤·¡¢¥¤¥ó¥¯¥ë¡¼¥É¤·¤¿¥Õ¥¡¥¤¥ë¤Ë¥¯¥é¥¹¤¬Àµ¤·¤¯ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤«¤É¤¦¤«¤ÏÊݾڤ·¤Ê¤¤
1360 * @param array $forward_obj Á«°ÜÄêµÁ
1361 * @param string $forward_name Á«°Ü̾
1363 function _includeViewScript($forward_obj, $forward_name)
1365 $view_dir = $this->getViewdir();
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']);
1372 include_once($action_dir . $forward_obj['preforward_path']);
1377 // ¥Ç¥Õ¥©¥ë¥È¥Á¥§¥Ã¥¯
1378 $preforward_path = $this->getDefaultViewPath($forward_name);
1379 if (file_exists($view_dir . $preforward_path)) {
1380 include_once($view_dir . $preforward_path);
1383 $this->logger->log(LOG_DEBUG, 'default preforward file not found [%s]', $preforward_path);
1384 $preforward_path = null;
1389 * ¥Ç¥£¥ì¥¯¥È¥ê°Ê²¼¤ÎÁ´¤Æ¤Î¥¹¥¯¥ê¥×¥È¤ò¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë
1393 function _includeDirectory($dir)
1395 $ext = "." . $this->ext['php'];
1396 $ext_len = strlen($ext);
1398 if (is_dir($dir) == false) {
1402 $dh = opendir($dir);
1404 while (($file = readdir($dh)) !== false) {
1405 if ($file != '.' && $file != '..' && is_dir("$dir/$file")) {
1406 $this->_includeDirectory("$dir/$file");
1408 if (substr($file, -$ext_len, $ext_len) != $ext) {
1411 include_once("$dir/$file");
1418 * Á«°Ü»þ¤Î¥Ç¥Õ¥©¥ë¥È¥Þ¥¯¥í¤òÀßÄꤹ¤ë
1421 * @param object Smarty $smarty ¥Æ¥ó¥×¥ì¡¼¥È¥¨¥ó¥¸¥ó¥ª¥Ö¥¸¥§¥¯¥È
1423 function _setDefaultMacro(&$smarty)
1428 * Ethna¥Þ¥Í¡¼¥¸¥ã¤òÀßÄꤹ¤ë(ÉÔÍפʾì¹ç¤Ï¶õ¤Î¥á¥½¥Ã¥É¤È¤·¤Æ¥ª¡¼¥Ð¡¼¥é¥¤¥É¤·¤Æ¤â¤è¤¤)
1432 function _activateEthnaManager()
1434 $base = dirname(dirname(__FILE__));
1436 if ($this->config->get('debug') == false) {
1441 $this->action['__ethna_info__'] = array(
1442 'form_name' => 'Ethna_Form_Info',
1443 'class_name' => 'Ethna_Action_Info',
1445 $this->action['__ethna_info_do__'] = array(
1446 'form_name' => 'Ethna_Form_InfoDo',
1447 'class_name' => 'Ethna_Action_InfoDo',
1451 $forward_obj = array();
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;
1459 * Á«°Ü̾¤ËÂбþ¤¹¤ë¥Æ¥ó¥×¥ì¡¼¥È¥Ñ¥¹Ì¾¤¬¾Êά¤µ¤ì¤¿¾ì¹ç¤Î¥Ç¥Õ¥©¥ë¥È¥Ñ¥¹Ì¾¤òÊÖ¤¹
1461 * ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï"foo_bar"¤È¤¤¤¦forward̾¤¬"foo/bar" + ¥Æ¥ó¥×¥ì¡¼¥È³ÈÄ¥»Ò¤È¤Ê¤ë
1462 * ¤Î¤Ç¹¥¤ß±þ¤¸¤Æ¥ª¡¼¥Ð¥é¥¤¥É¤¹¤ë
1465 * @param string $forward_name forward̾
1466 * @return string forward¥Ñ¥¹Ì¾
1468 function _getDefaultForwardPath($forward_name)
1470 return str_replace('_', '/', $forward_name) . '.' . $this->ext['tpl'];
1474 * ÀßÄê¥Õ¥¡¥¤¥ë¤ÎDSNÄêµÁ¤«¤é»ÈÍѤ¹¤ë¥Ç¡¼¥¿¤òºÆ¹½ÃÛ¤¹¤ë(¥¹¥ì¡¼¥Ö¥¢¥¯¥»¥¹Ê¬´ôÅù)
1476 * DSN¤ÎÄêµÁÊýË¡(¥Ç¥Õ¥©¥ë¥È:ÀßÄê¥Õ¥¡¥¤¥ë)¤òÊѤ¨¤¿¤¤¾ì¹ç¤Ï¤³¤³¤ò¥ª¡¼¥Ð¡¼¥é¥¤¥É¤¹¤ë
1479 * @return array DSNÄêµÁ
1481 function _prepareDSN()
1485 foreach ($this->db as $key => $value) {
1486 $config_key = "dsn";
1488 $config_key .= "_$key";
1490 $dsn = $this->config->get($config_key);
1491 if (is_array($dsn)) {
1492 // ¼ïÊÌ1¤Ä¤Ë¤Ä¤Ê£¿ôDSN¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¥¢¥¯¥»¥¹Ê¬´ô
1493 $dsn = $this->_selectDSN($key, $dsn);
1501 * DSN¤Î¥¢¥¯¥»¥¹Ê¬´ô¤ò¹Ô¤¦
1503 * ¥¹¥ì¡¼¥Ö¥µ¡¼¥Ð¤Ø¤Î¿¶Ê¬¤±½èÍý(¥Ç¥Õ¥©¥ë¥È:¥é¥ó¥À¥à)¤òÊѹ¹¤·¤¿¤¤¾ì¹ç¤Ï¤³¤Î¥á¥½¥Ã¥É¤ò¥ª¡¼¥Ð¡¼¥é¥¤¥É¤¹¤ë
1506 * @param string $type DB¼ïÊÌ
1507 * @param array $dsn_list DSN°ìÍ÷
1508 * @return string ÁªÂò¤µ¤ì¤¿DSN
1510 function _selectDSN($type, $dsn_list)
1512 // ¥Ç¥Õ¥©¥ë¥È:¥é¥ó¥À¥à
1513 list($usec, $sec) = explode(' ', microtime());
1514 mt_srand($sec + ((float) $usec * 100000));
1515 $n = mt_rand(0, count($dsn_list)-1);
1517 return $dsn_list[$n];