OSDN Git Service

- like a singleton
authorfujimoto <fujimoto@2ef88817-412d-0410-a32c-8029a115e976>
Wed, 8 Dec 2004 12:32:38 +0000 (12:32 +0000)
committerfujimoto <fujimoto@2ef88817-412d-0410-a32c-8029a115e976>
Wed, 8 Dec 2004 12:32:38 +0000 (12:32 +0000)
class/Ethna_ActionError.php
class/Ethna_ActionForm.php
class/Ethna_Controller.php
class/Ethna_Error.php
class/Ethna_Logger.php
class/Ethna_SkeltonGenerator.php
class/Ethna_SmartyPlugin.php
class/Ethna_Util.php

index e26e8a6..6420363 100644 (file)
@@ -208,7 +208,7 @@ class Ethna_ActionError
        function &_getActionForm()
        {
                if (is_null($this->action_form)) {
-                       $controller =& getController();
+                       $controller =& Ethna_Controller::getInstance();
                        $this->action_form =& $controller->getActionForm();
                }
                return $this->action_form;
@@ -223,7 +223,7 @@ class Ethna_ActionError
        function _getLogger()
        {
                if (is_null($this->logger)) {
-                       $controller =& getController();
+                       $controller =& Ethna_Controller::getInstance();
                        $this->logger =& $controller->getLogger();
                }
                return $this->logger;
index 66d41b9..8c063f2 100644 (file)
@@ -438,7 +438,7 @@ class Ethna_ActionForm
                }
 
                // Ethna_Backend¤ÎÀßÄê
-               $c =& getController();
+               $c =& Ethna_Controller::getInstance();
                $this->backend =& $c->getBackend();
 
                return to_array($this->form_vars[$name]);
index 4bf09fd..c9c851b 100644 (file)
@@ -9,20 +9,6 @@
  *     @version        $Id$
  */
 
-// {{{ getController
-/**
- *     ¥³¥ó¥È¥í¡¼¥é¥ª¥Ö¥¸¥§¥¯¥È¤ò¼èÆÀ¤¹¤ë
- *
- *     @access public
- *     @return object  ¥³¥ó¥È¥í¡¼¥é¥ª¥Ö¥¸¥§¥¯¥È
- */
-function &getController()
-{
-       $controller =& $GLOBALS['controller'];
-       return $controller;
-}
-// }}}
-
 // {{{ Ethna_Controller
 /**
  *     ¥³¥ó¥È¥í¡¼¥é¥¯¥é¥¹
@@ -264,6 +250,22 @@ class Ethna_Controller
        }
 
        /**
+        *      (¸½ºß¥¢¥¯¥Æ¥£¥Ö¤Ê)¥³¥ó¥È¥í¡¼¥é¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤òÊÖ¤¹
+        *
+        *      @access public
+        *      @return object  Ethna_Controller        ¥³¥ó¥È¥í¡¼¥é¤Î¥¤¥ó¥¹¥¿¥ó¥¹
+        *      @static
+        */
+       function &getInstance()
+       {
+               if (isset($GLOBALS['controller'])) {
+                       return $GLOBALS['controller'];
+               } else {
+                       return null;
+               }
+       }
+
+       /**
         *      ¥¢¥×¥ê¥±¡¼¥·¥ç¥óID¤òÊÖ¤¹
         *
         *      @access public
index 8a9ef52..8e59504 100644 (file)
@@ -46,7 +46,7 @@ class Ethna_Error extends PEAR_Error
         */
        function Ethna_Error($message = null, $code = null, $mode = null, $options = null)
        {
-               $controller =& getController();
+               $controller =& Ethna_Controller::getInstance();
                $this->i18n =& $controller->getI18N();
 
                // $options°Ê¹ß¤Î°ú¿ô->$userinfo
index 1ce87f1..adf1e5e 100644 (file)
@@ -31,7 +31,7 @@ define('LOG_FUNCTION', 1 << 17);
  */
 function ethna_error_handler($errno, $errstr, $errfile, $errline)
 {
-       $c =& getController();
+       $c =& Ethna_Controller::getInstance();
 
        list($level, $name) = Ethna_Logger::errorLevelToLogLevel($errno);
        if ($errno == E_STRICT) {
index 344a0b4..ac83e7b 100644 (file)
@@ -115,7 +115,7 @@ class Ethna_SkeltonGenerator
         */
        function generateActionSkelton($action_name)
        {
-               $c =& getController();
+               $c =& Ethna_Controller::getInstance();
 
                $action_dir = $c->getActiondir();
                $action_class = $c->getDefaultActionClass($action_name, false);
@@ -147,7 +147,7 @@ class Ethna_SkeltonGenerator
         */
        function generateViewSkelton($forward_name)
        {
-               $c =& getController();
+               $c =& Ethna_Controller::getInstance();
 
                $view_dir = $c->getViewdir();
                $view_class = $c->getDefaultViewClass($forward_name, false);
@@ -207,7 +207,7 @@ class Ethna_SkeltonGenerator
         */
        function _generateFile($skel, $entity, $macro)
        {
-               $c =& getController();
+               $c =& Ethna_Controller::getInstance();
                if (is_object($c)) {
                        $base = $c->getBasedir();
                        if (file_exists("$base/skel/$skel") == false) {
index 6db47d0..eda660e 100644 (file)
@@ -258,7 +258,7 @@ function smarty_modifier_wordwrap_i18n($string, $width, $break = "\n", $indent =
  */
 function smarty_modifier_i18n($string)
 {
-       $c =& getController();
+       $c =& Ethna_Controller::getInstance();
 
        $i18n =& $c->getI18N();
 
@@ -337,7 +337,7 @@ function smarty_modifier_select($string, $value)
  */
 function smarty_modifier_form_value($string)
 {
-       $c =& getController();
+       $c =& Ethna_Controller::getInstance();
        $af =& $c->getActionForm();
 
        $elts = explode(".", $string);
@@ -364,7 +364,7 @@ function smarty_modifier_form_value($string)
  */
 function smarty_function_message($params, &$smarty)
 {
-       $c =& getController();
+       $c =& Ethna_Controller::getInstance();
 
        extract($params);
 
index 0e2bb0c..a481b97 100644 (file)
@@ -35,7 +35,7 @@ function to_array($v)
  */
 function is_error($name)
 {
-       $c =& getController();
+       $c =& Ethna_Controller::getInstance();
 
        $action_error =& $c->getActionError();
 
@@ -61,7 +61,7 @@ class Ethna_Util
         */
        function isDuplicatePost()
        {
-               $c =& getController();
+               $c =& Ethna_Controller::getInstance();
 
                // use raw post data
                if (isset($_POST['uniqid'])) {
@@ -97,7 +97,7 @@ class Ethna_Util
         */
        function clearDuplicatePost()
        {
-               $c =& getController();
+               $c =& Ethna_Controller::getInstance();
 
                // use raw post data
                if (isset($_POST['uniqid'])) {
@@ -482,7 +482,7 @@ class Ethna_Util
         */
        function purgeTmp($prefix, $timeout)
        {
-               $c =& getController();
+               $c =& Ethna_Controller::getInstance();
 
                $dh = opendir($c->getDirectory('tmp'));
                if ($dh) {