root/twitter/files/lib/data/twitter/ViewableTwitterMessage.class.php @ 1333

Revision 1333, 1.7 kB (checked in by Torben Brodt, 2 years ago)

more updates for twitter 2.1, allow to display mentions, see demo page

Line 
1<?php
2// wcf imports
3require_once(WCF_DIR.'lib/data/DatabaseObject.class.php');
4require_once(WCF_DIR.'lib/data/user/UserProfile.class.php');
5
6/**
7 * Represents a viewable twitter entry.
8 *
9 * @author      Torben Brodt
10 * @copyright   2010 easy-coding.de
11 * @license     GNU General Public License <http://opensource.org/licenses/gpl-3.0.html>
12 * @package     de.easy-coding.wcf.twitter
13 */
14class ViewableTwitterMessage extends DatabaseObject {
15
16        /**
17         * owner object
18         *
19         * @var TwitterOwner
20         */
21        protected $user = null;
22
23        /**
24         * Creates a new ViewableTwitter object.
25         *
26         * @param       integer         $messageID
27         * @param       array<mixed>    $row
28         */
29        public function __construct($messageID, $row = null) {
30                DatabaseObject::__construct($row);
31        }
32       
33        /**
34         * @see DatabaseObject::handleData()
35         */
36        protected function handleData($data) {
37                parent::handleData($data);
38                $this->user = new UserProfile(null, $data);
39        }
40       
41        /**
42         * @return string
43         */
44        public function getLink() {
45                return 'http://twitter.com/'.$this->screen_name.'/statuses/'.$this->tweetID;
46        }
47
48        /**
49         * @return string
50         */
51        public function getThumbnail() {
52                $avatar = $this->user->getAvatar();
53                if($avatar) {
54                        $avatar->setMaxSize(24, 24);
55                        return $avatar->getURL();
56                } else {
57                        return $this->profile_image_url;
58                }
59        }
60       
61        /**
62         * Returns the title of this entry.
63         *
64         * @return      string
65         */
66        public function __toString() {
67                return "".$this->title;
68        }
69       
70        public function getUser() {
71                return $this->user;
72        }
73       
74        /**
75         * Returns the formatted message.
76         *
77         * @return      string
78         */
79        public function getFormattedMessage() {
80                require_once(WCF_DIR.'lib/data/twitter/TwitterMessageParser.class.php');
81                return TwitterMessageParser::getInstance()->parse($this->message);
82        }
83}
84?>
Note: See TracBrowser for help on using the browser.