Commit a3dd3c4071e3d169f29757e803cddf11e14778a4
- Diff rendering mode:
- inline
- side by side
entry.class.php
(54 / 7)
|   | |||
| 12 | 12 | $this->$key = htmlspecialchars($value, ENT_NOQUOTES, 'utf-8', FALSE); | |
| 13 | 13 | } | |
| 14 | 14 | } | |
| 15 | |||
| 15 | |||
| 16 | /** | ||
| 17 | * Turn URLs into links. | ||
| 18 | */ | ||
| 19 | function linkify($text){ | ||
| 20 | return preg_replace('/((http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?)/i', '<a href="$1">$1</a>', $text); | ||
| 21 | } | ||
| 22 | |||
| 16 | 23 | function timeSince(){ | |
| 17 | 24 | $timeSince = time() - ($this->rec_updated); | |
| 18 | 25 | ||
| … | … | ||
| 102 | 102 | } | |
| 103 | 103 | ||
| 104 | 104 | class MicroBlog extends Entry{ | |
| 105 | #TODO: add link to post | ||
| 106 | #TODO: create hyperlinks within post | ||
| 105 | |||
| 106 | #TODO: add link to post ? | ||
| 107 | 107 | function getSingleTitle(){ | |
| 108 | return $this->getNeutralTitle(); | ||
| 108 | $title = $this->getNeutralTitle(); | ||
| 109 | |||
| 110 | // Replace URLs with links | ||
| 111 | $title = $this->linkify($title); | ||
| 112 | |||
| 113 | // Default to Twitter if multiple... | ||
| 114 | $domain = count($this->icons) > 1 ? Twitter::$static_domain : $this->domain; | ||
| 115 | $search_path = count($this->icons) > 1 ? Twitter::$static_search_path : $this->search_path; | ||
| 116 | |||
| 117 | // Link usernames | ||
| 118 | $title = preg_replace('/( |\.|^)@([\w_-]+)/i', '$1@<a href="http://'.$domain.'/$2">$2</a>', $title); | ||
| 119 | |||
| 120 | // Link hash tags | ||
| 121 | $title = preg_replace('/( |^)#([\w_-]+)/i', '$1#<a href="http://'.$search_path.'?q=%23$2">$2</a>', $title); | ||
| 122 | |||
| 123 | return $title; | ||
| 109 | 124 | } | |
| 110 | 125 | ||
| 111 | 126 | function getSingleDescription(){ | |
| … | … | ||
| 128 | 128 | } | |
| 129 | 129 | ||
| 130 | 130 | function equals($other){ | |
| 131 | return $other->getNeutralTitle() == $this->getNeutralTitle(); | ||
| 131 | $x = trim($this->getNeutralTitle()); | ||
| 132 | $y = trim($other->getNeutralTitle()); | ||
| 133 | |||
| 134 | $basic_match = $x == $y; | ||
| 135 | $ignore_last_char = ($x == substr_replace($y, '', -1) || $y == substr_replace($x, '', -1)); | ||
| 136 | $without_hash_tags = ($x == str_replace('#', '', $y) || $y == str_replace('#', '', $x)); // ping.fm sometimes strips them | ||
| 137 | |||
| 138 | return $basic_match || $ignore_last_char || $without_hash_tags; | ||
| 132 | 139 | } | |
| 133 | 140 | ||
| 134 | 141 | /** | |
| … | … | ||
| 143 | 143 | */ | |
| 144 | 144 | function getNeutralTitle(){ | |
| 145 | 145 | #TODO: un-hardcode | |
| 146 | // Strip out username from update | ||
| 146 | 147 | $usernames['twitter'] = 'balleyne: '; | |
| 147 | 148 | $usernames['facebook'] = 'Blaise '; | |
| 148 | 149 | $ustring = ''; | |
| … | … | ||
| 341 | 341 | #TODO: make this more interesting | |
| 342 | 342 | class StatusUpdates extends MicroBlog{ | |
| 343 | 343 | function getSingleTitle(){ | |
| 344 | return $this->title; | ||
| 344 | return $this->linkify($this->title); | ||
| 345 | 345 | } | |
| 346 | 346 | } | |
| 347 | 347 | ||
| … | … | ||
| 459 | 459 | ||
| 460 | 460 | class Identica extends MicroBlog{ | |
| 461 | 461 | var $img = 'http://identi.ca/favicon.ico'; | |
| 462 | var $domain = 'identi.ca'; | ||
| 463 | var $search_path = 'identi.ca/search/notice'; | ||
| 464 | public static $static_domain = 'identi.ca'; | ||
| 465 | public static $static_search_path = 'identi.ca/search/notice'; | ||
| 466 | |||
| 467 | function getSingleTitle(){ | ||
| 468 | $title = parent::getSingleTitle(); | ||
| 469 | |||
| 470 | // Link groups | ||
| 471 | $title = preg_replace('/( |^)!([\w_-]+)/i', '$1!<a href="http://'.$this->domain.'/group/$2">$2</a>', $title); | ||
| 472 | |||
| 473 | return $title; | ||
| 474 | } | ||
| 462 | 475 | } | |
| 463 | 476 | ||
| 464 | 477 | class IdenticaFavorites extends Favorites{ | |
| 465 | 478 | var $img = 'http://identi.ca/favicon.ico'; | |
| 466 | |||
| 479 | |||
| 467 | 480 | function getSingleDescription(){ | |
| 468 | 481 | return ''; | |
| 469 | 482 | } | |
| … | … | ||
| 499 | 499 | ||
| 500 | 500 | class Twitter extends MicroBlog{ | |
| 501 | 501 | var $img = 'http://www.twitter.com/favicon.ico'; | |
| 502 | var $domain = 'twitter.com'; | ||
| 503 | var $search_path = 'search.twitter.com/search'; | ||
| 504 | public static $static_domain = 'twitter.com'; | ||
| 505 | public static $static_search_path = 'search.twitter.com/search'; | ||
| 502 | 506 | } | |
| 503 | 507 | ||
| 504 | 508 | class TwitterFavorites extends Favorites{ |

