From 38f8d3d11b10d20b3802b1769568ca987ad4cd95 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Fri, 20 Nov 2009 17:33:22 -0500 Subject: Revert "Use the geo microformat as documented at http://microformats.org/wiki/geo" This reverts commit 67add6429136dd6c2f5a924fb6bfef3ae099b495. --- lib/noticelist.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/noticelist.php b/lib/noticelist.php index dd97b85bd..5877827ff 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -392,6 +392,11 @@ class NoticeListItem extends Widget $name = $location->getName(); + if (empty($name)) { + // XXX: Could be a translation issue. Fall back to... something? + return; + } + $lat = $this->notice->lat; $lon = $this->notice->lon; $latlon = (!empty($lat) && !empty($lon)) ? $lat.';'.$lon : ''; @@ -400,17 +405,16 @@ class NoticeListItem extends Widget $this->out->elementStart('span', array('class' => 'location')); $this->out->text(_('at')); - - $this->out->elementStart('a', array('class' => 'geo', 'href' => $url)); - $this->out->elementStart('abbr', array('class' => 'latitude', 'title' => $lat, 'style' => empty($name)?null:'display: none')); - $this->out->text($lat); //TODO translate to a prettier format, like "S 37.2 deg" instead of "-37.2" - $this->out->elementEnd('abbr'); - $this->out->elementStart('abbr', array('class' => 'longitude', 'title' => $lon, 'style' => empty($name)?null:'display: none')); - $this->out->text($lon); - $this->out->elementEnd('abbr'); - $this->out->text($name); - $this->out->elementEnd('a'); - + if (empty($url)) { + $this->out->element('span', array('class' => 'geo', + 'title' => $latlon), + $name); + } else { + $this->out->element('a', array('class' => 'geo', + 'title' => $latlon, + 'href' => $url), + $name); + } $this->out->elementEnd('span'); } -- cgit v1.2.3-54-g00ecf From 83ba93e945e5b933a73139f9e5db710444c99893 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Fri, 20 Nov 2009 17:40:38 -0500 Subject: Change the format of the lat/lon output on a notice in HTML --- lib/noticelist.php | 9 ++++----- plugins/Mapstraction/usermap.js | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/noticelist.php b/lib/noticelist.php index 5877827ff..167ba994b 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -392,15 +392,14 @@ class NoticeListItem extends Widget $name = $location->getName(); - if (empty($name)) { - // XXX: Could be a translation issue. Fall back to... something? - return; - } - $lat = $this->notice->lat; $lon = $this->notice->lon; $latlon = (!empty($lat) && !empty($lon)) ? $lat.';'.$lon : ''; + if (empty($name)) { + $name = $lat . ' ' . $lon; //TODO tranform to N/S deg/min/sec format + } + $url = $location->getUrl(); $this->out->elementStart('span', array('class' => 'location')); diff --git a/plugins/Mapstraction/usermap.js b/plugins/Mapstraction/usermap.js index 19ec54c39..e667dd579 100644 --- a/plugins/Mapstraction/usermap.js +++ b/plugins/Mapstraction/usermap.js @@ -1,7 +1,7 @@ $(document).ready(function() { - notices = []; + var notices = []; $(".notice").each(function(){ - notice = getNoticeFromElement($(this)); + var notice = getNoticeFromElement($(this)); if(notice['geo']) notices.push(notice); }); @@ -10,8 +10,8 @@ $(document).ready(function() { showMapstraction($("#map_canvas"), notices); } - $('a.geo').click(function(){ - noticeElement = $(this).closest(".notice"); + $('.geo').click(function(){ + var noticeElement = $(this).closest(".notice"); notice = getNoticeFromElement(noticeElement); $.fn.jOverlay.options = { @@ -23,7 +23,7 @@ $(document).ready(function() { autoHide : true, css : {'max-width':'542px', 'top':'5%', 'left':'32.5%'} }; - html="
"; + var html="
"; html+=""; html+=$("
").append($(this).clone()).html(); $().jOverlay({ "html": html }); @@ -47,11 +47,12 @@ function getMicroformatValue(element) function getNoticeFromElement(noticeElement) { - notice = {}; - if(noticeElement.find(".latitude").length){ + var notice = {}; + if(noticeElement.find(".geo").length){ + var latlon = noticeElement.find(".geo").attr('title').split(";"); notice['geo']={'coordinates': [ - parseFloat(getMicroformatValue(noticeElement.find(".latitude"))), - parseFloat(getMicroformatValue(noticeElement.find(".longitude")))] }; + parseFloat(latlon[0]), + parseFloat(latlon[1])] }; } notice['user']={ 'profile_image_url': noticeElement.find("img.avatar").attr('src'), -- cgit v1.2.3-54-g00ecf From f32fb65c6d11df9847a384a1d723111beebbc665 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Fri, 20 Nov 2009 18:20:23 -0500 Subject: Display lat/lon in DMS format --- lib/noticelist.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/noticelist.php b/lib/noticelist.php index 167ba994b..43aa2ca1b 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -397,7 +397,7 @@ class NoticeListItem extends Widget $latlon = (!empty($lat) && !empty($lon)) ? $lat.';'.$lon : ''; if (empty($name)) { - $name = $lat . ' ' . $lon; //TODO tranform to N/S deg/min/sec format + $name = $this->decimalDegreesToDMS(abs($lat)) . ($lat>0?'N ':'S ') . $this->decimalDegreesToDMS(abs($lon)) . ($lon>0?'E':'W'); } $url = $location->getUrl(); @@ -417,6 +417,21 @@ class NoticeListItem extends Widget $this->out->elementEnd('span'); } + function decimalDegreesToDMS($dec) + { + + $vars = explode(".",$dec); + $deg = $vars[0]; + $tempma = "0.".$vars[1]; + + $tempma = $tempma * 3600; + $min = floor($tempma / 60); + $sec = $tempma - ($min*60); + + return $deg . '°' . $min . "'" . $sec . "\""; + return array("deg"=>$deg,"min"=>$min,"sec"=>$sec); + } + /** * Show the source of the notice * -- cgit v1.2.3-54-g00ecf From 330ddd1d9bb75a571072116f8324983e4ec9cfa2 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 20 Nov 2009 16:34:01 -0800 Subject: Disable XHTML Content-Type negotiation... You've foiled our plans for the last time! XHTML mode breaks a lot of JS and has been causing trouble for Safari and Chrome, especially with the fancier new UI-side plugins like realtime and maps. --- lib/htmloutputter.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index c2ec83c28..d267526c8 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -34,9 +34,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { require_once INSTALLDIR.'/lib/xmloutputter.php'; -define('PAGE_TYPE_PREFS', - 'text/html,application/xhtml+xml,'. - 'application/xml;q=0.3,text/xml;q=0.2'); +// Can include XHTML options but these are too fragile in practice. +define('PAGE_TYPE_PREFS', 'text/html'); /** * Low-level generator for HTML -- cgit v1.2.3-54-g00ecf From ca7f701f1744d71c5935452e55cdc38a0d6394a3 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Sat, 21 Nov 2009 15:59:54 +0100 Subject: i18n for "Keyword(s)" --- lib/searchaction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/searchaction.php b/lib/searchaction.php index 130b28ff5..32e07b4bd 100644 --- a/lib/searchaction.php +++ b/lib/searchaction.php @@ -123,7 +123,7 @@ class SearchAction extends Action if (!common_config('site', 'fancy')) { $this->hidden('action', $this->trimmed('action')); } - $this->input('q', 'Keyword(s)', $q); + $this->input('q', _('Keyword(s)'), $q); $this->submit('search', 'Search'); $this->elementEnd('li'); $this->elementEnd('ul'); -- cgit v1.2.3-54-g00ecf From df6796763d344bfa403264be9a6dc911aff9fed9 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Sat, 21 Nov 2009 16:04:20 +0100 Subject: i18n for "Search" button text --- lib/searchaction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/searchaction.php b/lib/searchaction.php index 32e07b4bd..bb71a2ba1 100644 --- a/lib/searchaction.php +++ b/lib/searchaction.php @@ -124,7 +124,7 @@ class SearchAction extends Action $this->hidden('action', $this->trimmed('action')); } $this->input('q', _('Keyword(s)'), $q); - $this->submit('search', 'Search'); + $this->submit('search', _('Search')); $this->elementEnd('li'); $this->elementEnd('ul'); $this->elementEnd('fieldset'); -- cgit v1.2.3-54-g00ecf From bdc0d2dc78c6b0275cc12b1013b54834b35e901c Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Sat, 21 Nov 2009 22:34:54 -0500 Subject: Use sprintf and gettext to output the DMS version of the location. More translator-friendly. --- lib/noticelist.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/noticelist.php b/lib/noticelist.php index 43aa2ca1b..21cec528f 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -397,7 +397,12 @@ class NoticeListItem extends Widget $latlon = (!empty($lat) && !empty($lon)) ? $lat.';'.$lon : ''; if (empty($name)) { - $name = $this->decimalDegreesToDMS(abs($lat)) . ($lat>0?'N ':'S ') . $this->decimalDegreesToDMS(abs($lon)) . ($lon>0?'E':'W'); + $latdms = $this->decimalDegreesToDMS(abs($lat)); + $londms = $this->decimalDegreesToDMS(abs($lon)); + $name = sprintf( + _('%1$u°%2$u\'%3$u"%4$s %5$u°%6$u\'%7$u"%8$s'), + $latdms['deg'],$latdms['min'], $latdms['sec'],($lat>0?_('N'):_('S')), + $londms['deg'],$londms['min'], $londms['sec'],($lon>0?_('E'):_('W'))); } $url = $location->getUrl(); @@ -428,7 +433,6 @@ class NoticeListItem extends Widget $min = floor($tempma / 60); $sec = $tempma - ($min*60); - return $deg . '°' . $min . "'" . $sec . "\""; return array("deg"=>$deg,"min"=>$min,"sec"=>$sec); } -- cgit v1.2.3-54-g00ecf From 4bd17a7f59b45919dd40dcabb0413b63f67817c1 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 23 Nov 2009 06:42:02 -0800 Subject: Ticket 2007: make search tabs grammar forms consistent (People, Notices, Groups) --- lib/searchgroupnav.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/searchgroupnav.php b/lib/searchgroupnav.php index 677365ea9..e843dc096 100644 --- a/lib/searchgroupnav.php +++ b/lib/searchgroupnav.php @@ -79,9 +79,9 @@ class SearchGroupNav extends Widget } $this->out->menuItem(common_local_url('peoplesearch', $args), _('People'), _('Find people on this site'), $action_name == 'peoplesearch', 'nav_search_people'); - $this->out->menuItem(common_local_url('noticesearch', $args), _('Notice'), + $this->out->menuItem(common_local_url('noticesearch', $args), _('Notices'), _('Find content of notices'), $action_name == 'noticesearch', 'nav_search_notice'); - $this->out->menuItem(common_local_url('groupsearch', $args), _('Group'), + $this->out->menuItem(common_local_url('groupsearch', $args), _('Groups'), _('Find groups on this site'), $action_name == 'groupsearch', 'nav_search_group'); $this->action->elementEnd('ul'); } -- cgit v1.2.3-54-g00ecf From 2da531d7d65044f3093eafd72b73a08e1cf67fd5 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 24 Nov 2009 09:38:16 -0800 Subject: Break TableDef, ColumnDef classes to separate files so autoloader can find them. With $config['db']['schemacheck'] set to 'script' in live deployment, Schema class wasn't being preloaded for us; the uses of TableDef by plugins for DataObject configuration would then fail because the class wasn't loaded. Broken to separate files, the autoloader can find all classes in either case. PHP Fatal error: Class 'TableDef' not found in /var/www/statusnet/plugins/OpenID/User_openid.php on line 43, referer: http://identi.ca/brionv/all --- lib/columndef.php | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/schema.php | 168 ----------------------------------------------------- lib/tabledef.php | 63 ++++++++++++++++++++ 3 files changed, 232 insertions(+), 168 deletions(-) create mode 100644 lib/columndef.php create mode 100644 lib/tabledef.php (limited to 'lib') diff --git a/lib/columndef.php b/lib/columndef.php new file mode 100644 index 000000000..1bae6b33b --- /dev/null +++ b/lib/columndef.php @@ -0,0 +1,169 @@ +. + * + * @category Database + * @package StatusNet + * @author Evan Prodromou + * @copyright 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')) { + exit(1); +} + +/** + * A class encapsulating the structure of a column in a table. + * + * @category Database + * @package StatusNet + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class ColumnDef +{ + /** name of the column. */ + public $name; + /** type of column, e.g. 'int', 'varchar' */ + public $type; + /** size of the column. */ + public $size; + /** boolean flag; can it be null? */ + public $nullable; + /** + * type of key: null = no key; 'PRI' => primary; + * 'UNI' => unique key; 'MUL' => multiple values. + */ + public $key; + /** default value if any. */ + public $default; + /** 'extra' stuff. Returned by MySQL, largely + * unused. */ + public $extra; + /** auto increment this field if no value is specific for it during an insert **/ + public $auto_increment; + + /** + * Constructor. + * + * @param string $name name of the column + * @param string $type type of the column + * @param int $size size of the column + * @param boolean $nullable can this be null? + * @param string $key type of key + * @param value $default default value + * @param value $extra unused + */ + + function __construct($name=null, $type=null, $size=null, + $nullable=true, $key=null, $default=null, + $extra=null, $auto_increment=false) + { + $this->name = strtolower($name); + $this->type = strtolower($type); + $this->size = $size+0; + $this->nullable = $nullable; + $this->key = $key; + $this->default = $default; + $this->extra = $extra; + $this->auto_increment = $auto_increment; + } + + /** + * Compares this columndef with another to see + * if they're functionally equivalent. + * + * @param ColumnDef $other column to compare + * + * @return boolean true if equivalent, otherwise false. + */ + + function equals($other) + { + return ($this->name == $other->name && + $this->_typeMatch($other) && + $this->_defaultMatch($other) && + $this->_nullMatch($other) && + $this->key == $other->key && + $this->auto_increment == $other->auto_increment); + } + + /** + * Does the type of this column match the + * type of the other column? + * + * Checks the type and size of a column. Tries + * to ignore differences between synonymous + * data types, like 'integer' and 'int'. + * + * @param ColumnDef $other other column to check + * + * @return boolean true if they're about equivalent + */ + + private function _typeMatch($other) + { + switch ($this->type) { + case 'integer': + case 'int': + return ($other->type == 'integer' || + $other->type == 'int'); + break; + default: + return ($this->type == $other->type && + $this->size == $other->size); + } + } + + /** + * Does the default behaviour of this column match + * the other? + * + * @param ColumnDef $other other column to check + * + * @return boolean true if defaults are effectively the same. + */ + + private function _defaultMatch($other) + { + return ((is_null($this->default) && is_null($other->default)) || + ($this->default == $other->default)); + } + + /** + * Does the null behaviour of this column match + * the other? + * + * @param ColumnDef $other other column to check + * + * @return boolean true if these columns 'null' the same. + */ + + private function _nullMatch($other) + { + return ((!is_null($this->default) && !is_null($other->default) && + $this->default == $other->default) || + ($this->nullable == $other->nullable)); + } +} diff --git a/lib/schema.php b/lib/schema.php index 560884d9f..11e2b6f60 100644 --- a/lib/schema.php +++ b/lib/schema.php @@ -547,171 +547,3 @@ class Schema return $sql; } } - -/** - * A class encapsulating the structure of a table. - * - * @category Database - * @package StatusNet - * @author Evan Prodromou - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ - */ - -class TableDef -{ - /** name of the table */ - public $name; - /** array of ColumnDef objects for the columns. */ - public $columns; - - /** - * Constructor. - * - * @param string $name name of the table - * @param array $columns columns in the table - */ - - function __construct($name=null,$columns=null) - { - $this->name = $name; - $this->columns = $columns; - } -} - -/** - * A class encapsulating the structure of a column in a table. - * - * @category Database - * @package StatusNet - * @author Evan Prodromou - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ - */ - -class ColumnDef -{ - /** name of the column. */ - public $name; - /** type of column, e.g. 'int', 'varchar' */ - public $type; - /** size of the column. */ - public $size; - /** boolean flag; can it be null? */ - public $nullable; - /** - * type of key: null = no key; 'PRI' => primary; - * 'UNI' => unique key; 'MUL' => multiple values. - */ - public $key; - /** default value if any. */ - public $default; - /** 'extra' stuff. Returned by MySQL, largely - * unused. */ - public $extra; - /** auto increment this field if no value is specific for it during an insert **/ - public $auto_increment; - - /** - * Constructor. - * - * @param string $name name of the column - * @param string $type type of the column - * @param int $size size of the column - * @param boolean $nullable can this be null? - * @param string $key type of key - * @param value $default default value - * @param value $extra unused - */ - - function __construct($name=null, $type=null, $size=null, - $nullable=true, $key=null, $default=null, - $extra=null, $auto_increment=false) - { - $this->name = strtolower($name); - $this->type = strtolower($type); - $this->size = $size+0; - $this->nullable = $nullable; - $this->key = $key; - $this->default = $default; - $this->extra = $extra; - $this->auto_increment = $auto_increment; - } - - /** - * Compares this columndef with another to see - * if they're functionally equivalent. - * - * @param ColumnDef $other column to compare - * - * @return boolean true if equivalent, otherwise false. - */ - - function equals($other) - { - return ($this->name == $other->name && - $this->_typeMatch($other) && - $this->_defaultMatch($other) && - $this->_nullMatch($other) && - $this->key == $other->key && - $this->auto_increment == $other->auto_increment); - } - - /** - * Does the type of this column match the - * type of the other column? - * - * Checks the type and size of a column. Tries - * to ignore differences between synonymous - * data types, like 'integer' and 'int'. - * - * @param ColumnDef $other other column to check - * - * @return boolean true if they're about equivalent - */ - - private function _typeMatch($other) - { - switch ($this->type) { - case 'integer': - case 'int': - return ($other->type == 'integer' || - $other->type == 'int'); - break; - default: - return ($this->type == $other->type && - $this->size == $other->size); - } - } - - /** - * Does the default behaviour of this column match - * the other? - * - * @param ColumnDef $other other column to check - * - * @return boolean true if defaults are effectively the same. - */ - - private function _defaultMatch($other) - { - return ((is_null($this->default) && is_null($other->default)) || - ($this->default == $other->default)); - } - - /** - * Does the null behaviour of this column match - * the other? - * - * @param ColumnDef $other other column to check - * - * @return boolean true if these columns 'null' the same. - */ - - private function _nullMatch($other) - { - return ((!is_null($this->default) && !is_null($other->default) && - $this->default == $other->default) || - ($this->nullable == $other->nullable)); - } -} diff --git a/lib/tabledef.php b/lib/tabledef.php new file mode 100644 index 000000000..3aace123b --- /dev/null +++ b/lib/tabledef.php @@ -0,0 +1,63 @@ +. + * + * @category Database + * @package StatusNet + * @author Evan Prodromou + * @copyright 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')) { + exit(1); +} + +/** + * A class encapsulating the structure of a table. + * + * @category Database + * @package StatusNet + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class TableDef +{ + /** name of the table */ + public $name; + /** array of ColumnDef objects for the columns. */ + public $columns; + + /** + * Constructor. + * + * @param string $name name of the table + * @param array $columns columns in the table + */ + + function __construct($name=null,$columns=null) + { + $this->name = $name; + $this->columns = $columns; + } +} -- cgit v1.2.3-54-g00ecf