أعجوبة

البرمجيات الحُرة والمفتوحة المصدر

أدوات المستخدم

أدوات الموقع


pri:discussion_feeds

اختلافات

عرض الاختلافات بين النسخة المختارة و النسخة الحالية من الصفحة.

رابط إلى هذه المقارنة

جانبي المراجعة السابقةالمراجعة السابقة
المراجعة التالية
المراجعة السابقة
pri:discussion_feeds [2009/06/12 23:51] alsadipri:discussion_feeds [2015/04/23 03:21] (حالي) – تحرير خارجي 127.0.0.1
سطر 1: سطر 1:
 +====== discussion feeds ======
 +
 +  * http://www.dokuwiki.org/development
 +  * http://dev.splitbrain.org/reference/dokuwiki/nav.html?index.html
 +
 +تقليد الوظيفة _getThreads() الموجودة في admin.php داخل discussion plugin
 +
 +<code php>
 +    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;
 +    }
 +</code>
 +
 +يعني نعمل commentsfeed.php تحتوي على دالة ترتب ملفات .comments في ns حسب filemtime ثم تأخذ أحدث كذا واحدة (فلنقل 10) ثم تعمل unserialize  التي تعيد hash نسميه data من مفاتحه 'comments' وهي مصفوفة ب comment id هذا
 +<code php>
 +$comment=$data['comments'][$cid]
 +</code>
 +يمكن معرفة التاريخ والاسم هكذا
 +<code php>
 +        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'];
 +        }
 +</code>
 +
 +بعد معرفة تاريخ التعليقات نأخذ آخر كذا تعليق ثم نولد ال 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 (تحرير خارجي)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki