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

Revision 1336, 1.5 kB (checked in by Torben Brodt, 2 years ago)

start with twitter 2.2.0, better modeling and event api

Line 
1<?php
2// wcf imports
3require_once(WCF_DIR.'lib/data/twitter/TwitterMessage.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 TwitterMessage {
15
16        /**
17         * owner object
18         *
19         * @var UserProfile
20         */
21        protected $user = null;
22       
23        /**
24         * @see DatabaseObject::handleData()
25         */
26        protected function handleData($data) {
27                parent::handleData($data);
28                $this->user = new UserProfile(null, $data);
29        }
30       
31        /**
32         * @return string
33         */
34        public function getLink() {
35                return 'http://twitter.com/'.$this->screen_name.'/statuses/'.$this->tweetID;
36        }
37
38        /**
39         * @return string
40         */
41        public function getThumbnail() {
42                $avatar = $this->user->getAvatar();
43                if($avatar) {
44                        $avatar->setMaxSize(24, 24);
45                        return $avatar->getURL();
46                } else {
47                        return $this->profile_image_url;
48                }
49        }
50       
51        /**
52         * Returns the title of this entry.
53         *
54         * @return      string
55         */
56        public function __toString() {
57                return "".$this->message;
58        }
59       
60        /**
61         * @return      UserProfile
62         */
63        public function getUser() {
64                return $this->user;
65        }
66       
67        /**
68         * Returns the formatted message.
69         *
70         * @return      string
71         */
72        public function getFormattedMessage() {
73                require_once(WCF_DIR.'lib/data/twitter/TwitterMessageParser.class.php');
74                return TwitterMessageParser::getInstance()->parse($this->message);
75        }
76}
77?>
Note: See TracBrowser for help on using the browser.