OSDN Git Service

Cleanup, shrink: Rename var, etc
authorhenoheno <henoheno>
Wed, 11 Aug 2004 12:12:57 +0000 (21:12 +0900)
committerhenoheno <henoheno>
Wed, 11 Aug 2004 12:12:57 +0000 (21:12 +0900)
plugin/calendar_viewer.inc.php

index 12ed257..fe8bcb4 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  * PukiWiki calendar_viewer¥×¥é¥°¥¤¥ó
- * $Id: calendar_viewer.inc.php,v 1.22 2004/08/10 13:44:52 henoheno Exp $
+ * $Id: calendar_viewer.inc.php,v 1.23 2004/08/11 12:12:57 henoheno Exp $
  * calendarrecent¥×¥é¥°¥¤¥ó¤ò¸µ¤ËºîÀ®
  */
 
@@ -43,7 +43,7 @@
 
 function plugin_calendar_viewer_convert()
 {
-       global $WikiName, $BracketName, $vars, $get, $post, $hr, $script;
+       global $vars, $get, $post, $hr, $script;
        global $_err_calendar_viewer_param, $_err_calendar_viewer_param2;
        global $_msg_calendar_viewer_right, $_msg_calendar_viewer_left;
        global $_msg_calendar_viewer_restrict;
@@ -52,47 +52,48 @@ function plugin_calendar_viewer_convert()
        if (func_num_args() < 2)
                return '#calendar_viewer(): ' . $_err_calendar_viewer_param . '<br />';
 
-       $func_vars_array = func_get_args();
+       $func_args = func_get_args();
 
        // ¥Ç¥Õ¥©¥ë¥ÈÃÍ
-       $pagename = $func_vars_array[0];        // ´ð½à¤È¤Ê¤ë¥Ú¡¼¥¸Ì¾
+       $pagename = $func_args[0];      // ´ð½à¤È¤Ê¤ë¥Ú¡¼¥¸Ì¾
        $limit_page = 7;        // É½¼¨¤¹¤ë·ï¿ôÀ©¸Â
        $date_YM    = '';       // °ìÍ÷ɽ¼¨¤¹¤ëǯ·î
        $mode       = 'past';   // Æ°ºî¥â¡¼¥É
        $date_sep   = '-';      // ÆüÉդΥ»¥Ñ¥ì¡¼¥¿ calendar2¤Ê¤é '-', calendar¤Ê¤é ''
 
-       if (isset($func_vars_array[3])) {
-               $date_sep = $func_vars_array[3];
+       if (isset($func_args[3])) {
+               $date_sep = $func_args[3];
        }
-       if (preg_match('/[0-9]{4}' . $date_sep . '[0-9]{2}/', $func_vars_array[1])) {
+
+       if (preg_match('/[0-9]{4}' . $date_sep . '[0-9]{2}/', $func_args[1])) {
                // »ØÄêǯ·î¤Î°ìÍ÷ɽ¼¨
-               $page_YM     = $func_vars_array[1];
-               $limit_base  = 0;
+               $page_YM     = $func_args[1];
                $limit_page  = 31;      // ¼êÈ´¤­¡£31Æüʬ¤ò¥ê¥ß¥Ã¥È¤È¤¹¤ë¡£
-       } else if (preg_match('/this/si', $func_vars_array[1])) {
+               $limit_base  = 0;
+       } else if (preg_match('/this/si', $func_args[1])) {
                // º£·î¤Î°ìÍ÷ɽ¼¨
                $page_YM     = get_date('Y' . $date_sep . 'm');
-               $limit_base  = 0;
                $limit_page  = 31;
-       } else if (preg_match('/^[0-9]+$/', $func_vars_array[1])) {
+               $limit_base  = 0;
+       } else if (preg_match('/^[0-9]+$/', $func_args[1])) {
                // nÆüʬɽ¼¨
                $page_YM     = '';
-               $limit_page  = $func_vars_array[1];
+               $limit_page  = $func_args[1];
                $limit_base  = 0;
-               $limit_pitch = $func_vars_array[1];
-       } else if (preg_match('/([0-9]+)\*([0-9]+)/', $func_vars_array[1], $reg_array)) {
+               $limit_pitch = $func_args[1];
+       } else if (preg_match('/([0-9]+)\*([0-9]+)/', $func_args[1], $reg_array)) {
                $page_YM     = '';
-               $limit_base  = $reg_array[1];
                $limit_page  = $reg_array[1] + $reg_array[2];
+               $limit_base  = $reg_array[1];
                $limit_pitch = $reg_array[2];
        } else {
                return '#calendar_viewer(): ' . $_err_calendar_viewer_param2 . '<br />';
        }
 
-       if (isset($func_vars_array[2]) &&
-           preg_match('/^(past|view|future)$/si', $func_vars_array[2])) {
+       if (isset($func_args[2]) &&
+           preg_match('/^(past|view|future)$/si', $func_args[2])) {
                // ¥â¡¼¥É»ØÄê
-               $mode = $func_vars_array[2];
+               $mode = $func_args[2];
        }
 
 
@@ -222,42 +223,44 @@ function plugin_calendar_viewer_convert()
        } else {
                // n·ïɽ¼¨»þ
                if ($limit_base >= count($pagelist)) {
-                       $right_YM = '';
+                       $right_YM = ''; // É½¼¨¤·¤Ê¤¤
                } else {
                        $right_base = $limit_base + $limit_pitch;
                        $right_YM   = $right_base . '*' . $limit_pitch;
                        $right_text = sprintf($_msg_calendar_viewer_right, $limit_pitch);
                }
                $left_base  = $limit_base - $limit_pitch;
-               if ($left_base >= 0) {
+               if ($left_base < 0) {
+                       $left_YM = ''; // É½¼¨¤·¤Ê¤¤
+               } else {
                        $left_YM   = $left_base . '*' . $limit_pitch;
                        $left_text = sprintf($_msg_calendar_viewer_left, $limit_pitch);
 
-               } else {
-                       $left_YM = '';
                }
 
        }
-       // ¥ê¥ó¥¯ºîÀ®
-       $s_date_sep = htmlspecialchars($date_sep);
-       if ($left_YM != '') {
-               $left_link = "<a href=\"$script?plugin=calendar_viewer&amp;file=$enc_pagename&amp;date=$left_YM&amp;date_sep=$s_date_sep&amp;mode=$mode\">$left_text</a>";
-       } else {
-               $left_link = '';
-       }
-       if ($right_YM != '') {
-               $right_link = "<a href=\"$script?plugin=calendar_viewer&amp;file=$enc_pagename&amp;date=$right_YM&amp;date_sep=$s_date_sep&amp;mode=$mode\">$right_text</a>";
-       } else {
-               $right_link = '';
-       }
-
-       // past mode¤Ï<<¿· µì>> Â¾¤Ï<<µì ¿·>>
-       $return_body .= '<table width ="100%"><tr><td align="left">';
-       $return_body .= $left_link;
-       $return_body .= '</td><td align="right">';
-       $return_body .= $right_link;
-       $return_body .= '</td></tr></table>';
 
+       // ¥Ê¥Ó¥²¡¼¥ÈÍѤΥê¥ó¥¯¤òËöÈø¤ËÄɲÃ
+       if ($left_YM != '' || $right_YM != '') {
+               $s_date_sep = htmlspecialchars($date_sep);
+               $left_link = $right_link = '';
+               $link = "$script?plugin=calendar_viewer&amp;mode=$mode&amp;" .
+                       "file=$enc_pagename&amp;date_sep=$s_date_sep&amp;";
+               if ($left_YM != '') {
+                       $left_link = '<a href="' . $link .
+                               "date=$left_YM\">$left_text</a>";
+               }
+               if ($right_YM != '') {
+                       $right_link = '<a href="' . $link .
+                               "date=$right_YM\">$right_text</a>";
+               }
+               // past mode¤Ï<<¿· µì>> Â¾¤Ï<<µì ¿·>>
+               $return_body .=
+                       '<table width ="100%"><tr>' .
+                       '<td align="left">'  . $left_link  . '</td>' .
+                       '<td align="right">' . $right_link . '</td>' .
+                       '</tr></table>';
+       }
 
        $get['page'] = $post['page'] = $vars['page'] = $tmppage;
 
@@ -266,7 +269,7 @@ function plugin_calendar_viewer_convert()
 
 function plugin_calendar_viewer_action()
 {
-       global $WikiName, $BracketName, $vars, $get, $post, $hr, $script;
+       global $vars, $get, $post, $hr, $script;
 
        $date_sep = '-';