diff options
author | Zach Copley <zach@status.net> | 2009-11-19 12:47:11 -0800 |
---|---|---|
committer | Zach Copley <zach@status.net> | 2009-11-19 12:47:11 -0800 |
commit | a151ab7b996be99e5f01a4793dbad453a5ac5bd6 (patch) | |
tree | b999a1ce638cffeddca0756ba8c8bef1e3b1bb2d /lib | |
parent | ad56ebbb97c2ea544afb1f5b00235eb3395ade5a (diff) | |
parent | 93f6981b71c5fe4445352ca83a01a964fca9f078 (diff) |
Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 0.9.x
* '0.9.x' of gitorious.org:statusnet/mainline:
Localisation updates for !StatusNet from !translatewiki.net
Use the browser's geolocation API to set the location on the notice form
Add geometa library, and include it.
Add location form elements to the noticeform, and save their values on submission
Use the $user object nickname, as login name doesnt have to == nickname anymore with plugins such as ldap/etc
Revert "Re added NICKNAME_FMT constant to router.php."
Diffstat (limited to 'lib')
-rw-r--r-- | lib/action.php | 1 | ||||
-rw-r--r-- | lib/noticeform.php | 19 | ||||
-rw-r--r-- | lib/router.php | 54 |
3 files changed, 46 insertions, 28 deletions
diff --git a/lib/action.php b/lib/action.php index 9c7060bba..8ad391755 100644 --- a/lib/action.php +++ b/lib/action.php @@ -259,6 +259,7 @@ class Action extends HTMLOutputter // lawsuit Event::handle('StartShowLaconicaScripts', array($this))) { $this->script('js/xbImportNode.js'); $this->script('js/util.js'); + $this->script('js/geometa.js'); // Frame-busting code to avoid clickjacking attacks. $this->element('script', array('type' => 'text/javascript'), 'if (window.top !== window.self) { window.top.location.href = window.self.location.href; }'); diff --git a/lib/noticeform.php b/lib/noticeform.php index 1be011c18..ec8624597 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -76,6 +76,15 @@ class NoticeForm extends Form var $inreplyto = null; /** + * Pre-filled location content of the form + */ + + var $lat; + var $lon; + var $location_id; + var $location_ns; + + /** * Constructor * * @param HTMLOutputter $out output channel @@ -83,13 +92,17 @@ class NoticeForm extends Form * @param string $content content to pre-fill */ - function __construct($out=null, $action=null, $content=null, $user=null, $inreplyto=null) + function __construct($out=null, $action=null, $content=null, $user=null, $inreplyto=null, $lat=null, $lon=null, $location_id=null, $location_ns=null) { parent::__construct($out); $this->action = $action; $this->content = $content; $this->inreplyto = $inreplyto; + $this->lat = $lat; + $this->lon = $lon; + $this->location_id = $location_id; + $this->location_ns = $location_ns; if ($user) { $this->user = $user; @@ -188,6 +201,10 @@ class NoticeForm extends Form $this->out->hidden('notice_return-to', $this->action, 'returnto'); } $this->out->hidden('notice_in-reply-to', $this->inreplyto, 'inreplyto'); + $this->out->hidden('notice_data-lat', empty($this->lat) ? null : $this->lat, 'lat'); + $this->out->hidden('notice_data-lon', empty($this->lon) ? null : $this->lon, 'lon'); + $this->out->hidden('notice_data-location_id', empty($this->location_id) ? null : $this->location_id, 'location_id'); + $this->out->hidden('notice_data-location_ns', empty($this->location_ns) ? null : $this->location_ns, 'location_ns'); Event::handle('StartShowNoticeFormData', array($this)); } diff --git a/lib/router.php b/lib/router.php index ceb32aaa7..afe36f712 100644 --- a/lib/router.php +++ b/lib/router.php @@ -125,7 +125,7 @@ class Router // exceptional $m->connect('main/remote', array('action' => 'remotesubscribe')); - $m->connect('main/remote?nickname=:nickname', array('action' => 'remotesubscribe'), array('nickname' => '['.NICKNAME_FMT.']+')); + $m->connect('main/remote?nickname=:nickname', array('action' => 'remotesubscribe'), array('nickname' => '[A-Za-z0-9_-]+')); foreach (Router::$bare as $action) { $m->connect('index.php?action=' . $action, array('action' => $action)); @@ -169,10 +169,10 @@ class Router $m->connect('notice/new', array('action' => 'newnotice')); $m->connect('notice/new?replyto=:replyto', array('action' => 'newnotice'), - array('replyto' => '['.NICKNAME_FMT.']+')); + array('replyto' => '[A-Za-z0-9_-]+')); $m->connect('notice/new?replyto=:replyto&inreplyto=:inreplyto', array('action' => 'newnotice'), - array('replyto' => '['.NICKNAME_FMT.']+'), + array('replyto' => '[A-Za-z0-9_-]+'), array('inreplyto' => '[0-9]+')); $m->connect('notice/:notice/file', @@ -196,7 +196,7 @@ class Router array('id' => '[0-9]+')); $m->connect('message/new', array('action' => 'newmessage')); - $m->connect('message/new?to=:to', array('action' => 'newmessage'), array('to' => '['.NICKNAME_FMT.']+')); + $m->connect('message/new?to=:to', array('action' => 'newmessage'), array('to' => '[A-Za-z0-9_-]+')); $m->connect('message/:message', array('action' => 'showmessage'), array('message' => '[0-9]+')); @@ -280,7 +280,7 @@ class Router $m->connect('api/statuses/friends_timeline/:id.:format', array('action' => 'ApiTimelineFriends', - 'id' => '['.NICKNAME_FMT.']+', + 'id' => '[a-zA-Z0-9]+', 'format' => '(xml|json|rss|atom)')); $m->connect('api/statuses/home_timeline.:format', array('action' => 'ApiTimelineFriends', @@ -288,7 +288,7 @@ class Router $m->connect('api/statuses/home_timeline/:id.:format', array('action' => 'ApiTimelineFriends', - 'id' => '['.NICKNAME_FMT.']+', + 'id' => '[a-zA-Z0-9]+', 'format' => '(xml|json|rss|atom)')); $m->connect('api/statuses/user_timeline.:format', @@ -297,7 +297,7 @@ class Router $m->connect('api/statuses/user_timeline/:id.:format', array('action' => 'ApiTimelineUser', - 'id' => '['.NICKNAME_FMT.']+', + 'id' => '[a-zA-Z0-9]+', 'format' => '(xml|json|rss|atom)')); $m->connect('api/statuses/mentions.:format', @@ -306,7 +306,7 @@ class Router $m->connect('api/statuses/mentions/:id.:format', array('action' => 'ApiTimelineMentions', - 'id' => '['.NICKNAME_FMT.']+', + 'id' => '[a-zA-Z0-9]+', 'format' => '(xml|json|rss|atom)')); $m->connect('api/statuses/replies.:format', @@ -315,7 +315,7 @@ class Router $m->connect('api/statuses/replies/:id.:format', array('action' => 'ApiTimelineMentions', - 'id' => '['.NICKNAME_FMT.']+', + 'id' => '[a-zA-Z0-9]+', 'format' => '(xml|json|rss|atom)')); $m->connect('api/statuses/friends.:format', @@ -324,7 +324,7 @@ class Router $m->connect('api/statuses/friends/:id.:format', array('action' => 'ApiUserFriends', - 'id' => '['.NICKNAME_FMT.']+', + 'id' => '[a-zA-Z0-9]+', 'format' => '(xml|json)')); $m->connect('api/statuses/followers.:format', @@ -333,7 +333,7 @@ class Router $m->connect('api/statuses/followers/:id.:format', array('action' => 'ApiUserFollowers', - 'id' => '['.NICKNAME_FMT.']+', + 'id' => '[a-zA-Z0-9]+', 'format' => '(xml|json)')); $m->connect('api/statuses/show.:format', @@ -362,7 +362,7 @@ class Router $m->connect('api/users/show/:id.:format', array('action' => 'ApiUserShow', - 'id' => '['.NICKNAME_FMT.']+', + 'id' => '[a-zA-Z0-9]+', 'format' => '(xml|json)')); // direct messages @@ -400,12 +400,12 @@ class Router $m->connect('api/friendships/create/:id.:format', array('action' => 'ApiFriendshipsCreate', - 'id' => '['.NICKNAME_FMT.']+', + 'id' => '[a-zA-Z0-9]+', 'format' => '(xml|json)')); $m->connect('api/friendships/destroy/:id.:format', array('action' => 'ApiFriendshipsDestroy', - 'id' => '['.NICKNAME_FMT.']+', + 'id' => '[a-zA-Z0-9]+', 'format' => '(xml|json)')); // Social graph @@ -462,28 +462,28 @@ class Router $m->connect('api/favorites/:id.:format', array('action' => 'ApiTimelineFavorites', - 'id' => '['.NICKNAME_FMT.']+', + 'id' => '[a-zA-Z0-9]+', 'format' => '(xmljson|rss|atom)')); $m->connect('api/favorites/create/:id.:format', array('action' => 'ApiFavoriteCreate', - 'id' => '['.NICKNAME_FMT.']+', + 'id' => '[a-zA-Z0-9]+', 'format' => '(xml|json)')); $m->connect('api/favorites/destroy/:id.:format', array('action' => 'ApiFavoriteDestroy', - 'id' => '['.NICKNAME_FMT.']+', + 'id' => '[a-zA-Z0-9]+', 'format' => '(xml|json)')); // blocks $m->connect('api/blocks/create/:id.:format', array('action' => 'ApiBlockCreate', - 'id' => '['.NICKNAME_FMT.']+', + 'id' => '[a-zA-Z0-9]+', 'format' => '(xml|json)')); $m->connect('api/blocks/destroy/:id.:format', array('action' => 'ApiBlockDestroy', - 'id' => '['.NICKNAME_FMT.']+', + 'id' => '[a-zA-Z0-9]+', 'format' => '(xml|json)')); // help @@ -604,14 +604,14 @@ class Router 'replies', 'inbox', 'outbox', 'microsummary') as $a) { $m->connect(':nickname/'.$a, array('action' => $a), - array('nickname' => '['.NICKNAME_FMT.']{1,64}')); + array('nickname' => '[a-zA-Z0-9]{1,64}')); } foreach (array('subscriptions', 'subscribers') as $a) { $m->connect(':nickname/'.$a.'/:tag', array('action' => $a), array('tag' => '[a-zA-Z0-9]+', - 'nickname' => '['.NICKNAME_FMT.']{1,64}')); + 'nickname' => '[a-zA-Z0-9]{1,64}')); } foreach (array('rss', 'groups') as $a) { @@ -623,31 +623,31 @@ class Router foreach (array('all', 'replies', 'favorites') as $a) { $m->connect(':nickname/'.$a.'/rss', array('action' => $a.'rss'), - array('nickname' => '['.NICKNAME_FMT.']{1,64}')); + array('nickname' => '[a-zA-Z0-9]{1,64}')); } $m->connect(':nickname/favorites', array('action' => 'showfavorites'), - array('nickname' => '['.NICKNAME_FMT.']{1,64}')); + array('nickname' => '[a-zA-Z0-9]{1,64}')); $m->connect(':nickname/avatar/:size', array('action' => 'avatarbynickname'), array('size' => '(original|96|48|24)', - 'nickname' => '['.NICKNAME_FMT.']{1,64}')); + 'nickname' => '[a-zA-Z0-9]{1,64}')); $m->connect(':nickname/tag/:tag/rss', array('action' => 'userrss'), - array('nickname' => '['.NICKNAME_FMT.']{1,64}'), + array('nickname' => '[a-zA-Z0-9]{1,64}'), array('tag' => '[a-zA-Z0-9]+')); $m->connect(':nickname/tag/:tag', array('action' => 'showstream'), - array('nickname' => '['.NICKNAME_FMT.']{1,64}'), + array('nickname' => '[a-zA-Z0-9]{1,64}'), array('tag' => '[a-zA-Z0-9]+')); $m->connect(':nickname', array('action' => 'showstream'), - array('nickname' => '['.NICKNAME_FMT.']{1,64}')); + array('nickname' => '[a-zA-Z0-9]{1,64}')); Event::handle('RouterInitialized', array($m)); } |