pri:discussion_feeds
discussion feeds
تقليد الوظيفة _getThreads() الموجودة في admin.php داخل discussion plugin
function _getThreads() { global $conf; require_once(DOKU_INC.'inc/search.php'); // returns the list of pages in the given namespace and it's subspaces $items = array(); search($items, $conf['datadir'], 'search_allpages', ''); // add pages with comments to result $result = array(); foreach ($items as $item) { $id = $item['id']; // some checks $file = metaFN($id, '.comments'); if (!@file_exists($file)) continue; // skip if no comments file $date = filemtime($file); $result[] = array( 'id' => $id, 'file' => $file, 'date' => $date, ); } // finally sort by time of last comment usort($result, array('admin_plugin_discussion', '_threadCmp')); return $result; } function _getComments(&$thread) { $id = $thread['id']; if (!$thread['file']) $thread['file'] = metaFN($id, '.comments'); if (!@file_exists($thread['file'])) return false; // no discussion thread at all $data = unserialize(io_readFile($thread['file'], false)); $thread['status'] = $data['status']; $thread['number'] = $data['number']; if (!$data['status']) return false; // comments are turned off if (!$data['comments']) return false; // no comments $result = array(); foreach ($data['comments'] as $cid => $comment) { $this->_addComment($cid, $data, $result); } if (empty($result)) return false; else return $result; }
يعني نعمل commentsfeed.php تحتوي على دالة ترتب ملفات .comments في ns حسب filemtime ثم تأخذ أحدث كذا واحدة (فلنقل 10) ثم تعمل unserialize التي تعيد hash نسميه data من مفاتحه 'comments' وهي مصفوفة ب comment id هذا
$comment=$data['comments'][$cid]
يمكن معرفة التاريخ والاسم هكذا
if (is_array($comment['user'])) { // new format $name = $comment['user']['name']; $mail = $comment['user']['mail']; } else { // old format $name = $comment['name']; $mail = $comment['mail']; } if (is_array($comment['date'])) { // new format $created = $comment['date']['created']; } else { // old format $created = $comment['date']; }
بعد معرفة تاريخ التعليقات نأخذ آخر كذا تعليق ثم نولد ال rss ونخزن ملف .commentsfeed كي يتم تزويده إن كان أحدث من ملف .comments وإلا يولد بالطريقة أعلاه
الخطوة الاولى
معرفة الصفحات
- هل تصلح getRecent من changelog.php ؟ غالبا لا
http://dev.splitbrain.org/reference/dokuwiki/inc/changelog.php.source.html#l131
- استخدام search من search.php
search($data,$conf['datadir'],'search_list','',$ns);
http://dev.splitbrain.org/reference/dokuwiki/inc/search.php.source.html#l12
pri/discussion_feeds.txt · آخر تعديل: 2015/04/23 03:21 بواسطة 127.0.0.1