OSDN Git Service

Cleanup. true/false => TRUE/FALSE. Added spaces.
[pukiwiki/pukiwiki.git] / plugin / aname.inc.php
index 9cd7a94..fb4aad7 100644 (file)
@@ -1,13 +1,34 @@
 <?php
-// $Id: aname.inc.php,v 1.5 2002/11/29 00:09:01 panda Exp $
+/////////////////////////////////////////////////
+// PukiWiki - Yet another WikiWikiWeb clone.
+//
+// $Id: aname.inc.php,v 1.16 2004/08/09 14:03:42 henoheno Exp $
+//
+
+function plugin_aname_inline()
+{
+       $args = func_get_args();
+       return call_user_func_array('plugin_aname_convert', $args);
+}
 
 function plugin_aname_convert()
 {
-  if (!func_num_args()) return "Aname no argument!!\n";
-  $aryargs = func_get_args();
-  if (eregi("^[A-Z][A-Z0-9\-_]*$", $aryargs[0]))
-    return "<a name=\"$aryargs[0]\" id=\"$aryargs[0]\"></a>";
-  else
-    return "Bad Aname!! -- ".$aryargs[0]."\n";
+       global $script, $vars;
+
+       if (func_num_args() < 1) return FALSE;
+
+       $args = func_get_args();
+       $id = array_shift($args);
+
+       if (! preg_match('/^[A-Za-z][\w\-]*$/', $id))
+               return FALSE;
+
+       $body = count($args) ? preg_replace('/<\/?a[^>]*>/', '', array_pop($args)) : '';
+
+       $class   = in_array('super', $args) ? 'anchor_super' : 'anchor';
+       $url     = in_array('full',  $args) ? "$script?" . rawurlencode($vars['page']) : '';
+       $attr_id = in_array('noid',  $args) ? '' : " id=\"$id\"";
+
+       return "<a class=\"$class\"$attr_id href=\"$url#$id\" title=\"$id\">$body</a>";
 }
-?>
\ No newline at end of file
+?>