* @author: Robert Bienert * @version: 1.5 * @date: 2009-01-14 */ define('COMMENTFEED_VERSION', '1.5'); /* This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ class CommentFeed extends JlogPlugin { /* XXX Von der Funktion her zurueck zu den Wurzeln, aber ich * weiss jetzt auch warum newComment nicht funktioniert: Ich * habe in diesem Hook keinen Zugriff auf die noch nicht * vorhandene mysql_insert_id. Also bleibt es bei onUpdate, auch * wenn das vom Aufwand her vielleicht "overkill" sein mag. */ function hook_onUpdate($form) { global $l; // Sprachtabelle global $bbcode; // BBCode-Parser // nur zwei Abkuerzungen fuer Datenbank-Tabellen: $pm = JLOG_DB_COMMENTS; $pn = JLOG_DB_CONTENT; /* Jlog speichert datetime-Typen, wir brauchen fuer * date() am Besten Timestamps. Ausserdem entfernt MySQL * den Tabellennamen, weshalb wir zwischen comments.date * und content.date unterscheiden muessen. */ # XXX Aktuell wird die Anzahl der eingestellten # Subcurrent-Eintraege als Limit genommen, evtl. # andere/eigene Konfiguration waehlen? # XXX Weiterer fuer Konfiguration: Beruecksichtigung von # Pingbacks? $q = new Query("SELECT $pm.name, " . "UNIX_TIMESTAMP($pm.date) AS com_date, " . "$pm.content, $pm.id, $pn.url, " . "UNIX_TIMESTAMP($pn.date) AS con_date, " . "$pn.topic " . "FROM $pm, $pn " . "WHERE $pm.reference = $pn.id AND " . "($pm.type = '' OR $pm.type = 'pingback') " . "ORDER BY $pm.date DESC LIMIT 0," . JLOG_SUB_CURRENT); $item = NULL; // Es gibt nichts zu tun # FIXME keine Fehlermeldung if ($q->error()) return $form; /* Seit Version 1.1 ist Jlog in UTF-8 und die Konstante * JLOG_VERSION ist nicht mehr definiert. */ $enc = 'ISO-8859-1'; if (defined('JLOG_INSTALLED_VERSION')) { $enc = 'utf-8'; if (! defined('JLOG_VERSION')) define('JLOG_VERSION', JLOG_INSTALLED_VERSION); } // Zusammenbau des Feeds $feed = '\n" . '' . '' . 'Kommentare zu '.htmlspecialchars(JLOG_WEBSITE).'' . ''.htmlspecialchars(JLOG_PATH).'' . ''.htmlspecialchars(JLOG_DESCRIPTION).'' . ''.$l['language'].'' . ''.date('r').'' . 'http://blogs.law.harvard.edu/tech/rss' . '<a href="http://jeenaparadies.net/webdesign/jlog/">Jlog v'.JLOG_VERSION.'</a> with <a href="http://jeenaparadies.net/projects/jlog/wiki/plugins/comment-feed">CommentsFeed v'.COMMENTFEED_VERSION.'</a>' . ''.htmlspecialchars(JLOG_PUBLISHER).' '.htmlspecialchars(JLOG_EMAIL).'' . '©'.date('Y').' by '.htmlspecialchars(JLOG_PUBLISHER)."\n"; while (($item = $q->fetch())) { $author = htmlspecialchars($item['name']); $url = blog($item['con_date'], $item['url']) . "#c{$item['id']}"; $feed .= '' . "$author zu ".htmlspecialchars($item['topic']).'' . "$url" . "$author" . ''.date('r', $item['com_date']).'' . "$url" . ''.htmlspecialchars($bbcode->parse($item['content'])).'' . "\n"; } $feed .= "\n"; $feedPath = JLOG_BASEPATH.'personal'.DIRECTORY_SEPARATOR. 'rss-comments.xml'; // Speichern der beiden Feeds $mask = umask(0); # FIXME Schnittstelle fuer error handling waere praktisch if (($fh = @fopen($feedPath, 'wb'))) { @fwrite($fh, $feed); @fclose($fh); } // Bug behoben: zlib sollte vorhanden sein if (function_exists('gzopen') && ($fh = @gzopen($feedPath.'.gz', 'wb'))) { @gzwrite($fh, $feed, strlen($feed)); @gzclose($fh); } umask($mask); return $form; } } ?>