-<?
-// $Id: yetlist.inc.php,v 1.5 2002/07/29 01:47:24 masui Exp $
+<?php
+/////////////////////////////////////////////////
+// PukiWiki - Yet another WikiWikiWeb clone.
+//
+// $Id: yetlist.inc.php,v 1.19 2004/07/31 03:09:20 henoheno Exp $
+//
function plugin_yetlist_action()
{
- global $script,$InterWikiName,$WikiName,$BracketName,$defaultpage;
-
- if ($dir = @opendir(DATA_DIR))
+ global $script;
+ global $_title_yetlist,$_err_notexist;
+
+ $retval = array(
+ 'msg' => $_title_yetlist,
+ 'body' => ''
+ );
+
+ $refer = array();
+ $exists = get_existpages();
+ $pages = array_diff(get_existpages(CACHE_DIR,'.ref'),get_existpages());
+ foreach ($pages as $page)
{
- while($file = readdir($dir))
+ foreach (file(CACHE_DIR.encode($page).'.ref') as $line)
{
- if($file == ".." || $file == ".") continue;
- $cnt++;
- $page = decode(trim(preg_replace("/\.txt$/"," ",$file)));
- $data[$page] = file(DATA_DIR.$file);
+ list($_page) = explode("\t",$line);
+ $refer[$page][] = $_page;
}
- closedir($dir);
}
- $ret["body"] = "<ul>\n";
-
- foreach($data as $name => $lines)
+ if (count($refer) == 0)
{
- $lines = preg_replace("/^\s(.*)$/","",$lines);
-
- $line = join("\n",$lines);
-
- preg_replace("/
- (
- (\[\[([^\]]+)\:(https?|ftp|news)(:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)\]\])
- |
- (\[(https?|ftp|news)(:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)\s([^\]]+)\])
- |
- (https?|ftp|news)(:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)
- |
- ([[:alnum:]\-_.]+@[[:alnum:]\-_]+\.[[:alnum:]\-_\.]+)
- |
- (\[\[([^\]]+)\:([[:alnum:]\-_.]+@[[:alnum:]\-_]+\.[[:alnum:]\-_\.]+)\]\])
- |
- ($InterWikiName)
- |
- ($BracketName)
- |
- ($WikiName)
- )/ex","check_link('$1',\$name,\$_gwbn)",$line);
+ $retval['body'] = $_err_notexist;
+ return $retval;
}
-
- foreach($_gwbn as $wbn => $refs_arr)
- {
- foreach (array_unique($refs_arr) as $name)
- {
+ ksort($refer,SORT_STRING);
- if(preg_match("/^[^>]+>([^\]]+)/",$wbn,$match))
- {
- $wbn = $match[1];
- //ÊĤ¸¥Ö¥é¥±¥Ã¥È¤ÎÊä½¼¡£/^\[\[/¤Ç¤âɬÍ×½½Ê¬¤À¤¬Ç°¤Î¤¿¤á
- if(preg_match("/^\[\[[^\]]+$/",$wbn))
- $wbn = "$wbn]]";
- if(!preg_match("/($WikiName)|($BracketName)/",$wbn))
- $wbn = "[[$wbn]]";
- }
-
- $keep = $wbn;
-
- if(preg_match("/^\[\[\.\/([^\]]*)\]\]/",$wbn,$match))
- {
- if(!$match[1])
- $wbn = $name;
- else
- $wbn = "[[".strip_bracket($name)."/$match[1]]]";
- }
- else if(preg_match("/^\[\[\..\/([^\]]+)\]\]/",$wbn,$match))
- {
- for($i=0;$i<substr_count($keep,"../");$i++)
- $wbn = preg_replace("/(.+)\/([^\/]+)$/","$1",strip_bracket($name));
+ foreach($refer as $page=>$refs)
+ {
+ $r_page = rawurlencode($page);
+ $s_page = htmlspecialchars($page);
- if(!preg_match("/^($BracketName)|($WikiName)$/",$wbn))
- $wbn = "[[$wbn]]";
-
- if($wbn==$name)
- $wbn = "[[$match[1]]]";
- else
- $wbn = "[[".strip_bracket($wbn)."/$match[1]]]";
- }
- else if($wbn == "[[../]]")
+ $link_refs = array();
+ foreach(array_unique($refs) as $_refer)
{
- $wbn = preg_replace("/(.+)\/([^\/]+)$/","$1",strip_bracket($name));
-
- if(!preg_match("/^($BracketName)|($WikiName)$/",$wbn))
- $wbn = "[[$wbn]]";
- if($wbn==$name)
- $wbn = $defaultpage;
- }
+ $r_refer = rawurlencode($_refer);
+ $s_refer = htmlspecialchars($_refer);
- if(!is_page($wbn))
- {
- $refer[$wbn][] = $name;
- }
-
- $wbn = $keep; //¤Ò¡¼ ^^;)
+ $link_refs[] = "<a href=\"$script?$r_refer\">$s_refer</a>";
}
+ $link_ref = join(' ',$link_refs);
+ // »²¾È¸µ¥Ú¡¼¥¸¤¬Ê£¿ô¤¢¤Ã¤¿¾ì¹ç¡¢refer¤ÏºÇ¸å¤Î¥Ú¡¼¥¸¤ò»Ø¤¹(¤¤¤¤¤Î¤«¤Ê)
+ $retval['body'] .= "<li><a href=\"$script?cmd=edit&page=$r_page&refer=$r_refer\">$s_page</a> <em>($link_ref)</em></li>\n";
}
- ksort($refer);
- foreach($refer as $wbn => $refs_arr)
+ if ($retval['body'] != '')
{
- $url = rawurlencode($wbn);
- $name = strip_bracket($wbn);
-
- $link_ref = "";
- foreach(array_unique($refs_arr) as $refs)
- {
- $ref = strip_bracket($refs);
- $refurl = rawurlencode($refs);
-
- $link_ref .= " <a href=\"$script?$refurl\">$ref</a>";
- }
- $link_ref = trim($link_ref);
-
- $ret["body"] .= "<li><a href=\"$script?cmd=edit&page=$url&refer=$refurl\">$name</a> <em>($link_ref)</em></li>\n";
+ $retval['body'] = "<ul>\n".$retval['body']."</ul>\n";
}
-
- $ret["body"] .= "</ul>\n";
-
- $ret["msg"] = "List of pages,are not made yet";
-
- return $ret;
-}
-
-function check_link($name,$refer,&$_gwbn)
-{
- global $BracketName,$WikiName,$InterWikiName;
-
- if(preg_match("/^\[\[([^\]]+)\:((https?|ftp|news)([^\]]+))\]\]$/",$name))
- {
- return;
- }
- else if(preg_match("/^\[((https?|ftp|news)([^\]\s]+))\s([^\]]+)\]$/",$name))
- {
- return;
- }
- else if(preg_match("/^(https?|ftp|news).*?(\.gif|\.png|\.jpeg|\.jpg)?$/",$name))
- {
- return;
- }
- else if(preg_match("/^\[\[([^\]]+)\:([[:alnum:]\-_.]+@[[:alnum:]\-_]+\.[[:alnum:]\-_\.]+)\]\]/",$name))
- {
- return;
- }
- else if(preg_match("/^([[:alnum:]\-_]+@[[:alnum:]\-_]+\.[[:alnum:]\-_\.]+)/",$name))
- {
- return;
- }
- else if(preg_match("/^($InterWikiName)$/",$name))
- {
- return;
- }
- else if(preg_match("/^($BracketName)|($WikiName)$/",$name))
- {
- $_gwbn[$name][] = $refer;
- return;
- }
- return;
+ return $retval;
}
?>