OSDN Git Service

CANGE: i18n::formatted_datetime()を整備。mysqldate()関数を非推奨に。
[nucleus-jp/nucleus-next.git] / nucleus / libs / COMMENTACTIONS.php
index fd1671a..535a1e2 100644 (file)
@@ -102,11 +102,19 @@ class COMMENTACTIONS extends BaseActions {
         */
        function setCurrentComment(&$comment)
        {
-               global $manager;
+               global $currentcommentid, $currentcommentarray, $manager;
                
                if ( $comment['memberid'] != 0 )
                {
-                       $comment['authtext'] = $template['COMMENTS_AUTH'];
+                       if ( !array_key_exists('COMMENTS_AUTH', $this->template) )
+                       {
+                               $comment['authtext'] = '';
+                       }
+                       else
+                       {
+                               $comment['authtext'] = $this->template['COMMENTS_AUTH'];
+                       }
+                       
                        $mem =& $manager->getMember($comment['memberid']);
                        $comment['user'] = $mem->getDisplayName();
                        
@@ -131,7 +139,7 @@ class COMMENTACTIONS extends BaseActions {
                else
                {
                        // create smart links
-                       if ( !empty($comment['userid']) )
+                       if ( !array_key_exists('userid', $comment) || !empty($comment['userid']) )
                        {
                                if ( (i18n::strpos($comment['userid'], 'http://') === 0) || (i18n::strpos($comment['userid'], 'https://') === 0) )
                                {
@@ -153,7 +161,6 @@ class COMMENTACTIONS extends BaseActions {
                }
                
                $this->currentComment =& $comment;
-               global $currentcommentid, $currentcommentarray;
                $currentcommentid = $comment['commentid'];
                $currentcommentarray = $comment;
                return;
@@ -214,21 +221,36 @@ class COMMENTACTIONS extends BaseActions {
                else
                        echo $this->template['COMMENTS_MANY'];
        }
-
+       
        /**
         * COMMENTACTIONS::parse_date()
         * Parse templatevar date
         * 
         * @format      String  $format Date format according to PHP
-        * @return      String formatted datetime
+        * @return      void
         * 
         */
        function parse_date($format = '')
        {
+               if ( $format !== '' )
+               {
+                       /* pass */
+               }
+               else if ( !array_key_exists('FORMAT_DATE', $this->template) || $this->template['FORMAT_DATE'] === '' )
+               {
+                       $format = '%X';
+               }
+               else
+               {
+                       $format = $this->template['FORMAT_DATE'];
+               }
+               
                $offset = $this->commentsObj->itemActions->blog->getTimeOffset() * 3600;
-               echo i18n::formatted_datetime($format, $this->currentComment['timestamp'], $this->template['FORMAT_DATE'], $offset);
+               
+               echo i18n::formatted_datetime($format, $this->currentComment['timestamp'], $offset);
+               return;
        }
-
+       
        /**
         * Parse templatevar email
         */
@@ -320,17 +342,34 @@ class COMMENTACTIONS extends BaseActions {
                if ($tmp != $this->currentComment['body'])
                        $this->parser->parse($this->template['COMMENTS_CONTINUED']);
        }
-
+       
        /**
+        * COMMENTACTIONS::parse_time()
         * Parse templatevar time
+        * 
+        * @param       string  $format datetime format referring to strftime() in PHP's built-in function
+        * @return      void
+        * 
         */
-       function parse_time($format = '') {
-               echo i18n::strftime(
-                               ($format == '') ? $this->template['FORMAT_TIME'] : $format,
-                               $this->currentComment['timestamp']
-                       );
+       function parse_time($format = '')
+       {
+               if ( $format === '' )
+               {
+                       /* pass */
+               }
+               else if ( !array_key_exists('FORMAT_TIME', $this->template) || $this->template['FORMAT_TIME'] === '' )
+               {
+                       $format = '%x';
+               }
+               else
+               {
+                       $format = $this->template['FORMAT_TIME'];
+               }
+               
+               echo i18n::strftime($format, $this->currentComment['timestamp']);
+               return;
        }
-
+       
        /**
         * Parse templatevar timestamp
         */
@@ -723,4 +762,3 @@ class COMMENTACTIONS extends BaseActions {
        }
 
 }
-?>