OSDN Git Service

Correct about $exists. Add 'rtrim' function at '.ref' file reading.
authorteanan <teanan>
Thu, 16 Jun 2005 18:26:52 +0000 (03:26 +0900)
committerteanan <teanan>
Thu, 16 Jun 2005 18:26:52 +0000 (03:26 +0900)
Cleanup.

plugin/yetlist.inc.php

index 97dc10d..f7d3056 100644 (file)
@@ -1,13 +1,13 @@
 <?php
 // PukiWiki - Yet another WikiWikiWeb clone
-// $Id: yetlist.inc.php,v 1.21 2005/01/29 02:59:37 henoheno Exp $
+// $Id: yetlist.inc.php,v 1.22 2005/06/16 18:26:52 teanan Exp $
 //
 // Yet list plugin - Show a dangling link list (not yet created)
 
 function plugin_yetlist_action()
 {
        global $script;
-       global $_title_yetlist,$_err_notexist;
+       global $_title_yetlist, $_err_notexist;
 
        $retval = array(
                'msg' => $_title_yetlist,
@@ -16,38 +16,33 @@ function plugin_yetlist_action()
 
        $refer = array();
        $exists = get_existpages();
-       $pages = array_diff(get_existpages(CACHE_DIR,'.ref'),get_existpages());
-       foreach ($pages as $page)
-       {
-               foreach (file(CACHE_DIR.encode($page).'.ref') as $line)
-               {
-                       list($_page) = explode("\t",$line);
+       $pages = array_diff(get_existpages(CACHE_DIR, '.ref'), $exists);
+       foreach ($pages as $page) {
+               foreach (file(CACHE_DIR . encode($page) . '.ref') as $line) {
+                       list($_page) = explode("\t", rtrim($line));
                        $refer[$page][] = $_page;
                }
        }
 
-       if (count($refer) == 0)
-       {
+       if (empty($refer)) {
                $retval['body'] = $_err_notexist;
                return $retval;
        }
 
-       ksort($refer,SORT_STRING);
+       ksort($refer, SORT_STRING);
 
-       foreach($refer as $page=>$refs)
-       {
+       foreach ($refer as $page=>$refs) {
                $r_page = rawurlencode($page);
                $s_page = htmlspecialchars($page);
 
                $link_refs = array();
-               foreach(array_unique($refs) as $_refer)
-               {
+               foreach (array_unique($refs) as $_refer) {
                        $r_refer = rawurlencode($_refer);
                        $s_refer = htmlspecialchars($_refer);
 
                        $link_refs[] = "<a href=\"$script?$r_refer\">$s_refer</a>";
                }
-               $link_ref = join(' ',$link_refs);
+               $link_ref = join(' ', $link_refs);
 
                if (PKWK_READONLY) {
                        $href = $s_page;
@@ -60,9 +55,8 @@ function plugin_yetlist_action()
                $retval['body'] .= '<li>' . $href . ' <em>(' . $link_ref . ')</em></li>' . "\n";
        }
 
-       if ($retval['body'] != '')
-       {
-               $retval['body'] = "<ul>\n".$retval['body']."</ul>\n";
+       if ($retval['body'] != '') {
+               $retval['body'] = "<ul>\n" . $retval['body'] . "</ul>\n";
        }
 
        return $retval;