root/trackback/files/lib/system/event/listener/ThreadPageTrackbackListener.class.php @ 150

Revision 150, 1.6 kB (checked in by d0nut, 5 years ago)
  • added documentation
  • added time to incoming trackbacks
  • shortended rdf-description to 255 chars
  • encoded incoming trackback-data to html entities (XSS secure)
  • added icon for active trackbacks
  • Property svn:executable set to *
Line 
1<?php
2// WCF includes
3require_once(WCF_DIR.'lib/system/event/EventListener.class.php');
4
5// Utils
6require_once(WBB_DIR.'lib/util/TrackbackUtil.class.php');
7
8/**
9 * Loads the trackback data for the Threadpage
10 *
11 * @author      Torben Brodt
12 * @package     de.easy-coding.wbb.trackback
13 * @license     GNU General Public License <http://opensource.org/licenses/gpl-3.0.html>
14 */
15class ThreadPageTrackbackListener implements EventListener {
16
17        /**
18         * @see EventListener::execute()
19         * @param ThreadPage $eventObj
20         */
21        public function execute($eventObj, $className, $eventName) {
22                $postTrackbacks = array();
23                $check = array_filter($eventObj->postList->posts, create_function('$a', 'return $a->hasTrackback;'));
24
25                if(count($check) > 0) {
26                        // foreign trackbacks
27                        $sql = "SELECT          postID,
28                                                title,
29                                                excerpt,
30                                                url,
31                                                blog_name,
32                                                UNIX_TIMESTAMP(time) AS time
33                                FROM            wbb".WBB_N."_trackback
34                                WHERE           postID IN (".$eventObj->postList->postIDs."); ";
35
36                        $rows = WBBCore::getDB()->sendQuery($sql);
37                        while ($row = WBBCore::getDB()->fetchArray($rows)) {
38                                $postTrackbacks[$row['postID']][] = $row;
39                        }
40                       
41                        // fetch data
42                        $row = TrackbackUtil::getPost($eventObj->postList->postIDs);   
43                       
44                        // assign trackback data
45                        WBBCore::getTPL()->assign(array(
46                                'postTrackbacks'=>$postTrackbacks,
47                                'hasTrackbacks'=>array_flip(array_map(create_function('$a', 'return $a->getID();'), $check))
48                        ));
49                       
50                        // append head data for rdf information
51                        WBBCore::getTPL()->append(
52                                'specialStyles', 
53                                TrackbackUtil::getRDF($row['url'], $row['firstPostID'], $row['topic'], $row['firstPostPreview'], $row['username'], $row['time'])
54                        );
55                }
56        }
57}
58?>
Note: See TracBrowser for help on using the browser.