abc_myplugin-0.1.txt // Plugin name is optional. If unset, it will be extracted from the current // file name. Uncomment and edit this line to override: # $plugin['name'] = 'abc_plugin'; $plugin['author'] = 'J. Bruce Fields'; $plugin['author_uri'] = 'http://www.umich.edu/~bfields'; $plugin['version'] = '0.3'; $plugin['description'] = 'recent comments list tailored for arborupdate.com'; // Plugin types: // 0 = regular plugin; loaded on the public web side only // 1 = admin plugin; loaded on both the public and admin side // 2 = library; loaded only when include_plugin() or require_plugin() is called $plugin['type'] = 0; @include_once('zem_tpl.php'); if (0) { ?> # --- BEGIN PLUGIN HELP --- h1. Textile-formatted help goes here # --- END PLUGIN HELP --- '', 'break' => br, 'wraptag' => '', 'articles' => 10, 'comments' => 3, 'maxname' => 16, 'numbers' => '', 'class' => __FUNCTION__, 'labeltag' => '' ),$atts)); $q = "SELECT DISTINCT a.title title, a.status status, a.id parentid," . " MAX(c.posted) lastcomment, COUNT(*) ncomments" . " FROM ".PFX."textpattern a inner join " .PFX."txp_discuss c ON c.parentid=a.id" ." WHERE c.visible = 1" ." GROUP BY c.parentid" ." ORDER BY lastcomment DESC LIMIT 0 , $articles"; $rs = safe_query($q); if (!$rs) return ''; while ($a = nextRow($rs)) { extract($a); if ($status < 4) break; // The number of comments might change between the // query above and this one, so there's a small chance // that comments could be misnumbered. $q = "SELECT name, discussid, message FROM " .PFX."txp_discuss" ." WHERE parentid = $parentid and visible = 1" ." ORDER by posted DESC LIMIT 0 , $comments"; $rt = safe_query($q); if (!$rt) break; if (!$numbers) $title .= " ($ncomments)"; $out[] = "".href(escape_title($title), permlinkurl_id($parentid)).""; while ($b = nextRow($rt)) { extract($b); if (strlen($name) > 3+$maxname) { $name = substr($name, 0, $maxname); $name .= "..."; } $pos = strcspn($message, "\n\r"); $message = substr($message, 0, $pos); $message = strip_tags($message); if (strlen($message) > 80) { $message = substr($message, 0, 80); $message .= "..."; } $message = escape_title($message); if ($numbers) $name = "$ncomments. $name"; $out[] = tag($name, "a", ' href="'. permlinkurl_id($parentid) ."#c$discussid" ."\" title=\"$message\""); $ncomments--; // Could happen with the rare race: if ($ncomments == 0) break; } } if (!empty($out)) return doLabel($label, $labeltag).doWrap($out, $wraptag, $break, $class); return ''; } # --- END PLUGIN CODE --- ?>