Changeset 1331
- Timestamp:
- 03/19/11 22:45:58 (2 years ago)
- Location:
- Files:
-
- 2 added
- 8 modified
- 1 moved
-
cronjobs.xml (modified) (1 diff)
-
de.xml (modified) (1 diff)
-
en.xml (modified) (1 diff)
-
files/lib/data/twitter/TwitterMessageParser.class.php (added)
-
files/lib/data/twitter/TwitterSidebar.class.php (modified) (4 diffs)
-
files/lib/data/twitter/ViewableTwitterMessage.class.php (moved) (moved from twitter/files/lib/data/twitter/ViewableTwitter.class.php) (4 diffs)
-
files/lib/system/cronjob/TwitterUpdateJob.class.php (modified) (3 diffs)
-
package.xml (modified) (1 diff)
-
templates/twitter.tpl (modified) (2 diffs)
-
templates/twitterSidebar.tpl (modified) (1 diff)
-
update.sql (added)
Legend:
- Unmodified
- Added
- Removed
-
twitter/cronjobs.xml
r1298 r1331 6 6 <classPath>lib/system/cronjob/TwitterUpdateJob.class.php</classPath> 7 7 <description><![CDATA[Twitter Update]]></description> 8 <startminute> */30</startminute>8 <startminute>23</startminute> 9 9 <starthour>*</starthour> 10 10 <startdom>*</startdom> -
twitter/de.xml
r1305 r1331 16 16 <category name="wcf.twitter"> 17 17 <item name="wcf.twitter.title"><![CDATA[Twitter]]></item> 18 <item name="wcf.twitter.messages"><![CDATA[Tweets]]></item> 18 19 <item name="wcf.twitter.information"><![CDATA[Informationen]]></item> 19 20 <item name="wcf.twitter.systemUserMissing"><![CDATA[Der Twitter Benutzer, der im Admin angegeben ist, muss noch mit einem Benutzer authentifiziert werden.]]></item> -
twitter/en.xml
r1299 r1331 17 17 <item name="wcf.twitter.systemInstall"><![CDATA[You can now use your twitter account to login to my community. Therefore i am using the plugin from http://goo.gl/IcMuG, @easycoding]]></item> 18 18 <item name="wcf.twitter.title"><![CDATA[Twitter]]></item> 19 <item name="wcf.twitter.messages"><![CDATA[Tweets]]></item> 19 20 <item name="wcf.twitter.information"><![CDATA[Informationen]]></item> 20 21 <item name="wcf.twitter.systemUserMissing"><![CDATA[Der Twitter Username, as set in the admin panel, still has to be authenticated by a real user.]]></item> -
twitter/files/lib/data/twitter/TwitterSidebar.class.php
r1298 r1331 1 1 <?php 2 require_once(WCF_DIR.'lib/data/twitter/ViewableTwitterMessage.class.php'); 2 3 3 4 /** … … 16 17 */ 17 18 protected $account = null; 19 20 /** 21 * 22 * @var array<ViewableTwitterMessage> 23 */ 24 protected $tweets = array(); 18 25 19 26 /** … … 36 43 EventHandler::fireAction($this, 'init'); 37 44 38 45 $sql = "SELECT * 46 FROM wcf".WCF_N."_twitter_message message 47 INNER JOIN wcf".WCF_N."_twitter_account account 48 ON (message.accountID = account.accountID) 49 INNER JOIN wcf".WCF_N."_user_to_twitter ug 50 ON (account.accountID = ug.accountID) 51 INNER JOIN wcf".WCF_N."_user user_table 52 ON (user_table.userID = ug.userID) 53 LEFT JOIN wcf".WCF_N."_avatar avatar 54 ON (avatar.avatarID = user_table.avatarID)"; 55 $result = WCF::getDB()->sendQuery($sql, $itemsPerPage = 10); 56 while ($row = WCF::getDB()->fetchArray($result)) { 57 $this->tweets[] = new ViewableTwitterMessage(null, $row); 58 } 39 59 } 40 60 41 61 /** 42 62 * Assigns variables to the template engine. … … 48 68 // assign variables 49 69 WCF::getTPL()->assign(array( 70 'tweets' => $this->tweets 50 71 )); 51 72 } -
twitter/files/lib/data/twitter/ViewableTwitterMessage.class.php
r1290 r1331 11 11 * @package de.easy-coding.wcf.twitter 12 12 */ 13 class ViewableTwitter extends DatabaseObject { 13 class ViewableTwitterMessage extends DatabaseObject { 14 14 15 /** 15 16 * owner object … … 17 18 * @var TwitterOwner 18 19 */ 19 protected $ owner = null;20 protected $user = null; 20 21 21 22 /** 22 23 * Creates a new ViewableTwitter object. 23 24 * 24 * @param integer $ twitterID25 * @param integer $messageID 25 26 * @param array<mixed> $row 26 27 */ 27 public function __construct($twitterID, $row = null) { 28 if ($twitterID !== null) { 29 $sql = "SELECT avatar_table.*, 30 twitter.*, 31 user_table.username, 32 group_table.groupName 33 FROM wcf".WCF_N."_twitter twitter 34 LEFT JOIN wcf".WCF_N."_user user_table 35 ON (user_table.userID = twitter.userID) 36 LEFT JOIN wcf".WCF_N."_group group_table 37 ON (group_table.groupID = twitter.groupID) 38 LEFT JOIN wcf".WCF_N."_avatar avatar_table 39 ON (avatar_table.avatarID = user_table.avatarID) 40 WHERE twitter.twitterID = ".intval($twitterID)." 41 AND (".Twitter::getStateConditions().")"; 42 $row = WCF::getDB()->getFirstRow($sql); 43 } 28 public function __construct($messageID, $row = null) { 44 29 DatabaseObject::__construct($row); 30 } 31 32 /** 33 * @see DatabaseObject::handleData() 34 */ 35 protected function handleData($data) { 36 parent::handleData($data); 37 $this->user = new UserProfile(null, $data); 45 38 } 46 39 … … 54 47 } 55 48 49 public function getUser() { 50 return $this->user; 51 } 52 56 53 /** 57 54 * Returns the formatted message. … … 60 57 */ 61 58 public function getFormattedMessage() { 62 require_once(WCF_DIR.'lib/data/message/bbcode/MessageParser.class.php'); 63 MessageParser::getInstance()->setOutputType('text/html'); 64 require_once(WCF_DIR.'lib/data/message/bbcode/AttachmentBBCode.class.php'); 65 AttachmentBBCode::setMessageID($this->twitterID); 66 return MessageParser::getInstance()->parse($this->message, $this->enableSmilies, $this->enableHtml, $this->enableBBCodes, !$this->messagePreview); 59 require_once(WCF_DIR.'lib/data/twitter/TwitterMessageParser.class.php'); 60 return TwitterMessageParser::getInstance()->parse($this->message); 67 61 } 68 62 } -
twitter/files/lib/system/cronjob/TwitterUpdateJob.class.php
r1305 r1331 1 1 <?php 2 2 require_once(WCF_DIR.'lib/data/cronjobs/Cronjob.class.php'); 3 require_once(WCF_DIR.'lib/data/twitter/Twitte .class.php');3 require_once(WCF_DIR.'lib/data/twitter/Twitter.class.php'); 4 4 5 5 /** … … 16 16 */ 17 17 public function execute($data) { 18 $action = 'user_timeline';19 20 18 $sql = "SELECT *, 21 19 ta.screen_name = '".escapeString(TWITTER_USER)."' AS doSave 22 20 FROM wcf".WCF_N."_twitter_account ta 23 21 INNER JOIN wcf".WCF_N."_user_to_twitter utt ON utt.accountID = ta.accountID 24 LEFT JOIN wcf".WCF_N."_twitter_import ti ON ti.accountID = ta.accountID 25 WHERE (ISNULL(ti.action) OR (ti.action = '".escapeString($action)."'))"; 26 22 INNER JOIN wcf".WCF_N."_twitter_import ti ON ti.accountID = ta.accountID"; 27 23 $result = WCF::getDB()->sendQuery($sql); 28 24 while ($row = WCF::getDB()->fetchArray($result)) { 29 $this->load($row , $action);25 $this->load($row); 30 26 } 31 27 } … … 34 30 * 35 31 */ 36 public function load($me , $action) {32 public function load($me) { 37 33 $twitterObj = Twitter::getInstance(); 38 34 $twitterObj->setToken($me['userToken'], $me['userSecret']); 39 35 40 $opts = array( 41 'since_id' => $me['since_id'], 42 'trim_user' => 1, 43 ); 36 $opts = array(); 37 $opts['trim_user'] = 1; 38 39 if($me['since_id']) { 40 $opts['since_id'] = $me['since_id']; 41 } 44 42 45 $list = $twitterObj->get('/statuses/'.$action.'.json', $opts); 43 $list = $twitterObj->get('/statuses/'.$me['action'].'.json', $opts); 44 45 $maxid = 0; 46 foreach($list as $message) { 47 $maxid = max($maxid, $message->id); 48 49 $sql = 'INSERT IGNORE INTO 50 wcf'.WCF_N.'_twitter_message 51 (messageID, accountID, username, message, time) 52 VALUES ('.intval($message->id).', '.intval($me['accountID']).', 53 "'.escapeString($me['screen_name']).'", "'.escapeString($message->text).'", 54 '.intval(strtotime($message->created_at)).')'; 55 WCF::getDB()->sendQuery($sql); 56 } 46 57 47 foreach($list as $message) { 48 if($me['doSave']) { 49 // TODO: check column documentation 50 $sql = 'INSERT IGNORE INTO twitter_message 51 (messageID, accountID, username, message, time) 52 VALUES ('.intval($message->id).', '.intval($me['accountID']).', 53 "'.escapeString($me['screen_name']).'", "'.escapeString($message->text).'", 54 '.intval($message->time).')'; 55 WCF::getDB()->sendQuery($sql); 56 } 57 58 // TODO: check wether the list is sorted ascending or descending 59 // TODO: update useroption with current status 58 if($maxid) { 59 $sql = 'UPDATE wcf'.WCF_N.'_twitter_import 60 SET since_id = '.intval($maxid + 1).' 61 WHERE accountID = '.intval($me['accountID']).' 62 AND action = "'.escapeString($me['action']).'"'; 63 WCF::getDB()->sendQuery($sql); 60 64 } 61 65 } -
twitter/package.xml
r1321 r1331 42 42 <instructions type="update" fromversion="2.0.0"> 43 43 <files>files.tar</files> 44 <templates>templates.tar</templates> 45 <sql>update.sql</sql> 44 46 <eventlistener>eventlistener.xml</eventlistener> 45 47 <languages languagecode="de">de.xml</languages> 46 48 <languages languagecode="de-informal">de.xml</languages> 49 <languages languagecode="en">en.xml</languages> 47 50 <useroptions>useroptions.xml</useroptions> 48 51 </instructions> -
twitter/templates/twitter.tpl
r1298 r1331 95 95 </div> 96 96 </div> 97 {*98 97 <div class="container-3 column second twitterSidebar"> 99 98 <div class="columnInner"> … … 101 100 </div> 102 101 </div> 103 *}104 102 </div> 105 103 </div> -
twitter/templates/twitterSidebar.tpl
r1298 r1331 2 2 <div class="contentBox"> 3 3 <div class="border"> 4 <div class="containerHead"> 5 <h3>{lang}wcf.contest.sidebar.addcontest.title{/lang}</h3> 6 </div> 7 <div style="padding:10px"> 8 {lang}wcf.contest.sidebar.addcontest.description{/lang} 9 10 <div class="largeButtons" style="width:175px;margin-top:10px; margin-left:10px"> 11 <ul> 12 <li style="float:none"><a href="index.php?form=ContestAdd{@SID_ARG_2ND}"><img src="{icon}twitterM.png{/icon}" alt="" /> <span>{lang}wcf.contest.sidebar.addcontest.submit{/lang}</span></a></li> 13 </ul> 14 </div> 15 16 </div> 4 <div class="containerHead"> 5 <h3>{lang}wcf.twitter.messages{/lang}</h3> 6 </div> 7 <ul class="dataList"> 8 {foreach from=$tweets item=tweet} 9 <li class="{cycle values='container-1,container-2'}"> 10 <div class="containerIcon"> 11 {if $tweet->getUser()->getAvatar()} 12 {assign var=x value=$tweet->getUser()->getAvatar()->setMaxSize(24, 24)} 13 {@$tweet->getUser()->getAvatar()} 14 {else} 15 <img src="{@RELATIVE_WCF_DIR}images/avatars/avatar-default.png" alt="" style="width: 24px; height: 24px" /> 16 {/if} 17 </div> 18 <div class="containerContent"> 19 <h4>{@$tweet->getFormattedMessage()}</h4> 20 </div> 21 </li> 22 {/foreach} 23 </ul> 17 24 </div> 18 25 </div> 19 26 {if $additionalBoxes2|isset}{@$additionalBoxes2}{/if} 20 21 {if $todos|isset && $todos|count > 0}22 <div class="contentBox">23 <div class="border">24 <div class="containerHead">25 <h3>{lang}wcf.contest.todo{/lang}</h3>26 </div>27 28 <ul class="dataList">29 {foreach from=$todos item=todo}30 <li class="{cycle values='container-1,container-2'}">31 <div class="containerIcon">32 {if $todo->getOwner()->getAvatar()}33 {assign var=x value=$todo->getOwner()->getAvatar()->setMaxSize(24, 24)}34 {@$todo->getOwner()->getAvatar()}35 {else}36 <img src="{@RELATIVE_WCF_DIR}images/avatars/avatar-default.png" alt="" style="width: 24px; height: 24px" />37 {/if}38 </div>39 <div class="containerContent">40 <h4>{$todo->getMessage()}</h4>41 </div>42 </li>43 {/foreach}44 </ul>45 </div>46 </div>47 {/if}48 49 {if $additionalBoxes3|isset}{@$additionalBoxes3}{/if}
