[pmwiki-users] small patch for empty attachlists

Mikael Nilsson mini at nada.kth.se
Mon Dec 11 12:45:48 CST 2006


in XHTML, <ul></ul> is not permitted, so empty (:attachlist:) will make
a page not compliant.

As I include (:attachlist:) in the GroupFooter, many of my pages won't
validate. Yes, I will use (:if !attachments:), but still....

A simple fix:

--- upload.php.orig     2006-12-11 19:41:02.737488225 +0100
+++ upload.php  2006-12-11 19:43:59.522055339 +0100
@@ -92,7 +92,7 @@
 
 Markup('attachlist', 'directives', 
   '/\\(:attachlist\\s*(.*?):\\)/ei',
-  "Keep('<ul>'.FmtUploadList('$pagename',PSS('$1')).'</ul>')");
+  "Keep(FmtUploadList('$pagename',PSS('$1')))");
 SDV($GUIButtons['attach'], array(220, 'Attach:', '', '$[file.ext]',
   '$GUIButtonDirUrlFmt/attach.gif"$[Attach file]"'));
 SDV($LinkFunctions['Attach:'], 'LinkUpload');
@@ -270,6 +270,8 @@
     $filelist[$file] = $file;
   }
   closedir($dirp);
+  if(!count($filelist))
+    return "";
   $out = array();
   natcasesort($filelist);
   $overwrite = '';
@@ -284,7 +286,7 @@
       number_format($stat['size']) . " bytes ... " . 
       strftime($TimeFmt, $stat['mtime']) . "</li>";
   }
-  return implode("\n",$out);
+  return implode("\n","<ul>".$out."</ul>");
 }
 
 # this adds (:if [!]attachments:) to the markup

-- 
Plus ça change, plus c'est la même chose





More information about the pmwiki-users mailing list