diff options
author | Brenda Wallace <shiny@cpan.org> | 2009-10-30 09:41:04 +1300 |
---|---|---|
committer | Brenda Wallace <shiny@cpan.org> | 2009-10-30 09:41:04 +1300 |
commit | c0f8c0178a3cccead97fb0800a514b0ac9dbde64 (patch) | |
tree | 9d2f26feccaa85e73a7bc4985a1f899d9b89f730 | |
parent | 7f5fbee2e36889fae1d1c5043d76625e197e39ea (diff) | |
parent | 24c3a15124ab866bf7e9401f638156e102074608 (diff) |
Merge commit 'mainline/0.9.x' into 0.9.x
-rw-r--r-- | actions/bookmarklet.php | 75 | ||||
-rw-r--r-- | actions/othersettings.php | 2 | ||||
-rw-r--r-- | actions/showstream.php | 10 | ||||
-rw-r--r-- | classes/Notice.php | 17 | ||||
-rw-r--r-- | classes/Profile.php | 25 | ||||
-rw-r--r-- | doc-src/bookmarklet | 2 | ||||
-rw-r--r-- | js/util.js | 3 | ||||
-rw-r--r-- | lib/location.php | 36 | ||||
-rw-r--r-- | lib/noticelist.php | 39 | ||||
-rw-r--r-- | lib/router.php | 2 | ||||
-rw-r--r-- | plugins/Facebook/FacebookPlugin.php | 2 | ||||
-rw-r--r-- | plugins/GeonamesPlugin.php | 24 | ||||
-rw-r--r-- | plugins/OpenID/OpenIDPlugin.php | 2 | ||||
-rw-r--r-- | plugins/TemplatePlugin.php | 2 | ||||
-rw-r--r-- | plugins/TwitterBridge/README | 3 | ||||
-rw-r--r-- | plugins/TwitterBridge/TwitterBridgePlugin.php | 4 | ||||
-rw-r--r-- | theme/base/css/display.css | 10 |
17 files changed, 241 insertions, 17 deletions
diff --git a/actions/bookmarklet.php b/actions/bookmarklet.php new file mode 100644 index 000000000..0603a7456 --- /dev/null +++ b/actions/bookmarklet.php @@ -0,0 +1,75 @@ +<?php +/** + * StatusNet, the distributed open-source microblogging tool + * + * Handler for posting new notices + * + * PHP version 5 + * + * LICENCE: This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @category Bookmarklet + * @package StatusNet + * @author Sarven Capadisli <csarven@status.net> + * @copyright 2008-2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR . '/actions/newnotice.php'; + +/** + * Action for posting a notice + * + * @category Bookmarklet + * @package StatusNet + * @author Sarven Capadisli <csarven@status.net> + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class BookmarkletAction extends NewnoticeAction +{ + function showTitle() + { + $this->element('title', null, _('Post to ').common_config('site', 'name')); + } + + function showHeader() + { + $this->elementStart('div', array('id' => 'header')); + $this->elementStart('address'); + $this->element('a', array('class' => 'url', + 'href' => common_local_url('public')), + ''); + $this->elementEnd('address'); + if (common_logged_in()) { + $this->showNoticeForm(); + } + $this->elementEnd('div'); + } + + function showCore() + { + } + + function showFooter() + { + } +} + diff --git a/actions/othersettings.php b/actions/othersettings.php index 011b4fc83..d32a2d651 100644 --- a/actions/othersettings.php +++ b/actions/othersettings.php @@ -103,7 +103,7 @@ class OthersettingsAction extends AccountSettingsAction foreach($_shorteners as $name=>$value) { $services[$name]=$name; - if($value['info']['freeService']){ + if(!empty($value['info']['freeService'])){ // I18N $services[$name].=' (free service)'; } diff --git a/actions/showstream.php b/actions/showstream.php index b3a9b1f05..de7100b1d 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -348,6 +348,8 @@ class ShowstreamAction extends ProfileAction { if (Event::handle('StartProfilePageActionsSection', array(&$this, $this->profile))) { + $cur = common_current_user(); + $this->elementStart('div', 'entity_actions'); $this->element('h2', null, _('User actions')); $this->elementStart('ul'); @@ -379,21 +381,21 @@ class ShowstreamAction extends ProfileAction } $this->elementEnd('li'); - if ($cur->mutuallySubscribed($user)) { + if ($cur->mutuallySubscribed($this->user)) { // message $this->elementStart('li', 'entity_send-a-message'); - $this->element('a', array('href' => common_local_url('newmessage', array('to' => $user->id)), + $this->element('a', array('href' => common_local_url('newmessage', array('to' => $this->user->id)), 'title' => _('Send a direct message to this user')), _('Message')); $this->elementEnd('li'); // nudge - if ($user->email && $user->emailnotifynudge) { + if ($this->user->email && $this->user->emailnotifynudge) { $this->elementStart('li', 'entity_nudge'); - $nf = new NudgeForm($this, $user); + $nf = new NudgeForm($this, $this->user); $nf->show(); $this->elementEnd('li'); } diff --git a/classes/Notice.php b/classes/Notice.php index fdf5cd4c8..c08a66790 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1412,4 +1412,21 @@ class Notice extends Memcached_DataObject $contentlimit = self::maxContent(); return ($contentlimit > 0 && !empty($content) && (mb_strlen($content) > $contentlimit)); } + + function getLocation() + { + $location = null; + + if (!empty($this->location_id) && !empty($this->location_ns)) { + $location = Location::fromId($this->location_id, $this->location_ns); + } + + if (is_null($location)) { // no ID, or Location::fromId() failed + if (!empty($this->lat) && !empty($this->lon)) { + $location = Location::fromLatLon($this->lat, $this->lon); + } + } + + return $location; + } } diff --git a/classes/Profile.php b/classes/Profile.php index 53d07fb2f..7c1e9db33 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -562,4 +562,29 @@ class Profile extends Memcached_DataObject $block->blocked = $this->id; $block->delete(); } + + // XXX: identical to Notice::getLocation. + + function getLocation() + { + $location = null; + + if (!empty($this->location_id) && !empty($this->location_ns)) { + $location = Location::fromId($this->location_id, $this->location_ns); + } + + if (is_null($location)) { // no ID, or Location::fromId() failed + if (!empty($this->lat) && !empty($this->lon)) { + $location = Location::fromLatLon($this->lat, $this->lon); + } + } + + if (is_null($location)) { // still haven't found it! + if (!empty($this->location)) { + $location = Location::fromName($this->location); + } + } + + return $location; + } } diff --git a/doc-src/bookmarklet b/doc-src/bookmarklet index e5ded7702..6ce23bd0b 100644 --- a/doc-src/bookmarklet +++ b/doc-src/bookmarklet @@ -2,4 +2,4 @@ A bookmarklet is a small piece of javascript code used as a bookmark. This one w Drag-and-drop the following link to your bookmarks bar or right-click it and add it to your browser favorites to keep it handy. -<a href="javascript:var%20d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='http://%%site.server%%/%%site.path%%/index.php?action=newnotice',l=d.location,e=encodeURIComponent,g=f+'&status_textarea=%22'+((e(s))?e(s):e(document.title))+'%22 from '+l.href;function%20a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=800,height=570')){l.href=g;}}a();void(0);">Post to %%site.name%%</a> +<a href="javascript:(function(){var%20d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='http://%%site.server%%/%%site.path%%/index.php?action=bookmarklet',l=d.location,e=encodeURIComponent,g=f+'&status_textarea=%22'+((e(s))?e(s):e(document.title))+'%22%20%E2%80%94%20'+l.href;function%20a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=450,height=200')){l.href=g;}}a();})()">Post to %%site.name%%</a> diff --git a/js/util.js b/js/util.js index 0a943512f..b079388e4 100644 --- a/js/util.js +++ b/js/util.js @@ -241,6 +241,9 @@ $(document).ready(function(){ alert(result); } else { + if($('body')[0].id == 'bookmarklet') { + self.close(); + } if ($("#command_result", xml).length > 0) { var result = document._importNode($("p", xml).get(0), true); result = result.textContent || result.innerHTML; diff --git a/lib/location.php b/lib/location.php index 048554f0f..bbfc15a36 100644 --- a/lib/location.php +++ b/lib/location.php @@ -47,10 +47,11 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { class Location { - public $lat; - public $lon; - public $location_id; - public $location_ns; + public $lat; + public $lon; + public $location_id; + public $location_ns; + private $_url; var $names = array(); @@ -90,6 +91,10 @@ class Location static function fromId($id, $ns, $language=null) { + if (is_null($language)) { + $language = common_language(); + } + $location = null; // Let a third-party handle it @@ -157,4 +162,27 @@ class Location } } } + + /** + * Get an URL suitable for this location + * + * @return string URL for this location or NULL + */ + + function getURL() + { + // Keep one cached + + if (is_string($this->_url)) { + return $this->_url; + } + + $url = null; + + Event::handle('LocationUrl', array($this, &$url)); + + $this->_url = $url; + + return $url; + } } diff --git a/lib/noticelist.php b/lib/noticelist.php index 6c296f82a..8b3015cc3 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -199,6 +199,7 @@ class NoticeListItem extends Widget { $this->out->elementStart('div', 'entry-content'); $this->showNoticeLink(); + $this->showNoticeLocation(); $this->showNoticeSource(); $this->showContext(); $this->out->elementEnd('div'); @@ -370,6 +371,44 @@ class NoticeListItem extends Widget } /** + * show the notice location + * + * shows the notice location in the correct language. + * + * If an URL is available, makes a link. Otherwise, just a span. + * + * @return void + */ + + function showNoticeLocation() + { + $id = $this->notice->id; + + $location = $this->notice->getLocation(); + + if (empty($location)) { + return; + } + + $name = $location->getName(); + + if (empty($name)) { + // XXX: Could be a translation issue. Fall back to... something? + return; + } + + $url = $location->getUrl(); + + if (empty($url)) { + $this->out->element('span', array('class' => 'location'), $name); + } else { + $this->out->element('a', array('class' => 'location', + 'href' => $url), + $name); + } + } + + /** * Show the source of the notice * * Either the name (and link) of the API client that posted the notice, diff --git a/lib/router.php b/lib/router.php index dedf73c86..2fd255fe6 100644 --- a/lib/router.php +++ b/lib/router.php @@ -179,6 +179,8 @@ class Router array('action' => 'deletenotice'), array('notice' => '[0-9]+')); + $m->connect('bookmarklet/new', array('action' => 'bookmarklet')); + // conversation $m->connect('conversation/:id', diff --git a/plugins/Facebook/FacebookPlugin.php b/plugins/Facebook/FacebookPlugin.php index fc3adcfad..b68534b24 100644 --- a/plugins/Facebook/FacebookPlugin.php +++ b/plugins/Facebook/FacebookPlugin.php @@ -58,7 +58,7 @@ class FacebookPlugin extends Plugin * @return boolean hook return */ - function onRouterInitialized(&$m) + function onRouterInitialized($m) { // Facebook App stuff diff --git a/plugins/GeonamesPlugin.php b/plugins/GeonamesPlugin.php index 745cd4126..80ef44cc9 100644 --- a/plugins/GeonamesPlugin.php +++ b/plugins/GeonamesPlugin.php @@ -278,4 +278,28 @@ class GeonamesPlugin extends Plugin return true; } + + /** + * Human-readable name for a location + * + * Given a location, we try to retrieve a geonames.org URL. + * + * @param Location $location Location to get the url for + * @param string &$url Place to put the url + * + * @return boolean whether to continue + */ + + function onLocationUrl($location, &$url) + { + if ($location->location_ns != self::NAMESPACE) { + // It's not one of our IDs... keep processing + return true; + } + + $url = 'http://www.geonames.org/' . $location->location_id; + + // it's been filled, so don't process further. + return false; + } } diff --git a/plugins/OpenID/OpenIDPlugin.php b/plugins/OpenID/OpenIDPlugin.php index 560da71e7..81e3ed9c4 100644 --- a/plugins/OpenID/OpenIDPlugin.php +++ b/plugins/OpenID/OpenIDPlugin.php @@ -62,7 +62,7 @@ class OpenIDPlugin extends Plugin * @return boolean hook return */ - function onRouterInitialized(&$m) + function onRouterInitialized($m) { $m->connect('main/openid', array('action' => 'openidlogin')); $m->connect('settings/openid', array('action' => 'openidsettings')); diff --git a/plugins/TemplatePlugin.php b/plugins/TemplatePlugin.php index cfa051162..5f3ad81f5 100644 --- a/plugins/TemplatePlugin.php +++ b/plugins/TemplatePlugin.php @@ -32,7 +32,7 @@ class TemplatePlugin extends Plugin { // capture the RouterInitialized event // and connect a new API method // for updating the template - function onRouterInitialized( &$m ) { + function onRouterInitialized( $m ) { $m->connect( 'template/update', array( 'action' => 'template', )); diff --git a/plugins/TwitterBridge/README b/plugins/TwitterBridge/README index 09352188e..d3bcda598 100644 --- a/plugins/TwitterBridge/README +++ b/plugins/TwitterBridge/README @@ -11,8 +11,7 @@ Installation To enable the plugin, add the following to your config.php: - require_once(INSTALLDIR . '/plugins/TwitterBridge/TwitterBridgePlugin.php'); - $tb = new TwitterBridgePlugin(); + addPlugin("TwitterBridge"); OAuth is used to to access protected resources on Twitter (as opposed to HTTP Basic Auth)*. To use Twitter bridging you will need to register diff --git a/plugins/TwitterBridge/TwitterBridgePlugin.php b/plugins/TwitterBridge/TwitterBridgePlugin.php index e69567fc7..ad3c2e551 100644 --- a/plugins/TwitterBridge/TwitterBridgePlugin.php +++ b/plugins/TwitterBridge/TwitterBridgePlugin.php @@ -60,12 +60,12 @@ class TwitterBridgePlugin extends Plugin * * Hook for RouterInitialized event. * - * @param Net_URL_Mapper &$m path-to-action mapper + * @param Net_URL_Mapper $m path-to-action mapper * * @return boolean hook return */ - function onRouterInitialized(&$m) + function onRouterInitialized($m) { $m->connect('twitter/authorization', array('action' => 'twitterauthorization')); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index d9dca9815..c8aafe489 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -1295,3 +1295,13 @@ display:none; .guide { clear:both; } + +#bookmarklet address { +display:none; +} +#bookmarklet #form_notice { +width:auto; +} +#bookmarklet #wrap { +min-width:0; +} |