OSDN Git Service

BugTrack2/383 Set Form authentication as default auth method type
[pukiwiki/pukiwiki.git] / plugin / rename.inc.php
index 4b096d1..857957a 100644 (file)
@@ -60,14 +60,14 @@ function plugin_rename_action()
        }
 }
 
-// ÊÑ¿ô¤ò¼èÆÀ¤¹¤ë
+// 変数を取得する
 function plugin_rename_getvar($key)
 {
        global $vars;
        return isset($vars[$key]) ? $vars[$key] : '';
 }
 
-// ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤òºî¤ë
+// エラーメッセージを作る
 function plugin_rename_err($err, $page = '')
 {
        global $_rename_messages;
@@ -86,7 +86,7 @@ function plugin_rename_err($err, $page = '')
        return $msg;
 }
 
-//Âè°ìÃʳ¬:¥Ú¡¼¥¸Ì¾¤Þ¤¿¤ÏÀµµ¬É½¸½¤ÎÆþÎÏ
+//第一段階:ページ名または正規表現の入力
 function plugin_rename_phase1($err = '', $page = '')
 {
        global $script, $_rename_messages;
@@ -128,7 +128,7 @@ EOD;
        return $ret;
 }
 
-//ÂèÆóÃʳ¬:¿·¤·¤¤Ì¾Á°¤ÎÆþÎÏ
+//第二段階:新しい名前の入力
 function plugin_rename_phase2($err = '')
 {
        global $script, $_rename_messages;
@@ -174,7 +174,7 @@ EOD;
        return $ret;
 }
 
-//¥Ú¡¼¥¸Ì¾¤È´ØÏ¢¤¹¤ë¥Ú¡¼¥¸¤òÎóµó¤·¡¢phase3¤Ø
+//ページ名と関連するページを列挙し、phase3へ
 function plugin_rename_refer()
 {
        $page  = plugin_rename_getvar('page');
@@ -190,7 +190,7 @@ function plugin_rename_refer()
        return plugin_rename_phase3($pages);
 }
 
-//Àµµ¬É½¸½¤Ç¥Ú¡¼¥¸¤òÃÖ´¹
+//正規表現でページを置換
 function plugin_rename_regex($arr_from, $arr_to)
 {
        $exists = array();
@@ -307,21 +307,20 @@ function plugin_rename_get_files($pages)
        $matches = array();
        foreach ($dirs as $path) {
                $dir = opendir($path);
-               if (! $dir) continue;
-
-               while ($file = readdir($dir)) {
+               if (! $dir) continue;   // TODO: !== FALSE or die()?
+               while (($file = readdir($dir)) !== FALSE) {
                        if ($file == '.' || $file == '..') continue;
-
-                       foreach ($pages as $from=>$to) {
+                       foreach ($pages as $from => $to) {
+                               // TODO: preg_quote()?
                                $pattern = '/^' . str_replace('/', '\/', $from) . '([._].+)$/';
-                               if (! preg_match($pattern, $file, $matches))
-                                       continue;
-
-                               $newfile = $to . $matches[1];
-                               $files[$from][$path . $file] = $path . $newfile;
+                               if (preg_match($pattern, $file, $matches)) {
+                                       $newfile = $to . $matches[1];
+                                       $files[$from][$path . $file] = $path . $newfile;
+                               }
                        }
                }
        }
+
        return $files;
 }
 
@@ -340,7 +339,7 @@ function plugin_rename_proceed($pages, $files, $exists)
                                unlink($new);
                        rename($old, $new);
 
-                       // link¥Ç¡¼¥¿¥Ù¡¼¥¹¤ò¹¹¿·¤¹¤ë BugTrack/327 arino
+                       // linkデータベースを更新する BugTrack/327 arino
                        links_update($old);
                        links_update($new);
                }
@@ -374,17 +373,17 @@ function plugin_rename_proceed($pages, $files, $exists)
                $postdata[] = '-' . decode($old) .
                        $_rename_messages['msg_arrow'] . decode($new) . "\n";
 
-       // ¹¹¿·¤Î¾×ÆͤϥÁ¥§¥Ã¥¯¤·¤Ê¤¤¡£
+       // 更新の衝突はチェックしない。
 
-       // ¥Õ¥¡¥¤¥ë¤Î½ñ¤­¹þ¤ß
+       // ファイルの書き込み
        page_write(PLUGIN_RENAME_LOGPAGE, join('', $postdata));
 
-       //¥ê¥À¥¤¥ì¥¯¥È
+       //リダイレクト
        $page = plugin_rename_getvar('page');
        if ($page == '') $page = PLUGIN_RENAME_LOGPAGE;
 
        pkwk_headers_sent();
-       header('Location: ' . get_script_uri() . '?' . rawurlencode($page));
+       header('Location: ' . get_script_uri() . '?' . pagename_urlencode($page));
        exit;
 }
 
@@ -424,4 +423,4 @@ function plugin_rename_getselecttag($page)
 EOD;
 
 }
-?>
+