diff options
-rw-r--r-- | EVENTS.txt | 19 | ||||
-rw-r--r-- | actions/emailsettings.php | 22 | ||||
-rw-r--r-- | actions/register.php | 23 | ||||
-rwxr-xr-x | classes/laconica.ini | 3 | ||||
-rw-r--r-- | db/carrier.sql | 61 | ||||
-rw-r--r-- | db/laconica.sql | 2 | ||||
-rw-r--r-- | db/sms_carrier.sql | 63 | ||||
-rw-r--r-- | index.php | 4 | ||||
-rw-r--r-- | lib/action.php | 46 | ||||
-rw-r--r-- | lib/util.php | 75 | ||||
-rw-r--r-- | lib/xmlstringer.php | 68 | ||||
-rw-r--r-- | theme/base/css/display.css | 3 |
12 files changed, 223 insertions, 166 deletions
diff --git a/EVENTS.txt b/EVENTS.txt index d9634325d..aed3dd9c5 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -39,3 +39,22 @@ StartShowSections: Start the list of sections in the sidebar EndShowSections: End the list of sections in the sidebar - $action: the current action + +StartShowHeader: Showing before the header container +- $action: the current action + +EndShowHeader: Showing after the header container +- $action: the current action + +StartShowFooter: Showing before the footer container +- $action: the current action + +EndShowFooter: Showing after the footer container +- $action: the current action + +StartShowContentBlock: Showing before the content container +- $action: the current action + +EndShowContentBlock: Showing after the content container +- $action: the current action + diff --git a/actions/emailsettings.php b/actions/emailsettings.php index 0a86aa66d..b84acb214 100644 --- a/actions/emailsettings.php +++ b/actions/emailsettings.php @@ -487,26 +487,4 @@ class EmailsettingsAction extends AccountSettingsAction return $other->id != $user->id; } } - - /** - * Handle old fashioned PEAR_Error msgs coming from DB_DataObject - * - * In this case email don't exist in the DB yet, so DB_DataObject - * throws an error. Overrided from Action. - * - * @param PEAR_Error - * - * @return nothing - */ - - function handleError($error) { - if ($error->getCode() == DB_DATAOBJECT_ERROR_NODATA) { - - // Do nothing. - - } else { - parent::handleError($error); - } - } - } diff --git a/actions/register.php b/actions/register.php index aafb54ebb..5d7a8ce69 100644 --- a/actions/register.php +++ b/actions/register.php @@ -223,31 +223,10 @@ class RegisterAction extends Action */ function nicknameExists($nickname) - { + { $user = User::staticGet('nickname', $nickname); return ($user !== false); } - - /** - * Handle old fashioned PEAR_Error msgs coming from DB_DataObject - * - * In this case nickname and email don't exist in the DB yet, - * so DB_DataObject throws an error. Overrided from Action. - * - * @param PEAR_Error - * - * @return nothing - */ - - function handleError($error) { - if ($error->getCode() == DB_DATAOBJECT_ERROR_NODATA) { - - // Do nothing. - - } else { - parent::handleError($error); - } - } /** * Does the given email address already exist? diff --git a/classes/laconica.ini b/classes/laconica.ini index 255122a97..19267f268 100755 --- a/classes/laconica.ini +++ b/classes/laconica.ini @@ -292,7 +292,8 @@ created = 142 modified = 384 [sms_carrier__keys] -id = N +id = K +name = U [subscription] subscriber = 129 diff --git a/db/carrier.sql b/db/carrier.sql deleted file mode 100644 index 932f7c8bb..000000000 --- a/db/carrier.sql +++ /dev/null @@ -1,61 +0,0 @@ -insert into sms_carrier - (name, email_pattern, created) -values - ('3 River Wireless', '%s@sms.3rivers.net', now()), - ('7-11 Speakout', '%s@cingularme.com', now()), - ('Airtel (Karnataka, India)', '%s@airtelkk.com', now()), - ('Alaska Communications Systems', '%s@msg.acsalaska.com', now()), - ('Alltel Wireless', '%s@message.alltel.com', now()), - ('AT&T Wireless', '%s@txt.att.net', now()), - ('Bell Mobility (Canada)', '%s@txt.bell.ca', now()), - ('Boost Mobile', '%s@myboostmobile.com', now()), - ('Cellular One (Dobson)', '%s@mobile.celloneusa.com', now()), - ('Cincinnati Bell Wireless', '%s@gocbw.com', now()), - ('Cingular (Postpaid)', '%s@cingularme.com', now()), - ('Centennial Wireless', '%s@cwemail.com', now()), - ('Cingular (GoPhone prepaid)', '%s@cingularme.com', now()), - ('Claro (Nicaragua)', '%s@ideasclaro-ca.com', now()), - ('Comcel', '%s@comcel.com.co', now()), - ('Cricket', '%s@sms.mycricket.com', now()), - ('CTI', '%s@sms.ctimovil.com.ar', now()), - ('Emtel (Mauritius)', '%s@emtelworld.net', now()), - ('Fido (Canada)', '%s@fido.ca', now()), - ('General Communications Inc.', '%s@msg.gci.net', now()), - ('Globalstar', '%s@msg.globalstarusa.com', now()), - ('Helio', '%s@myhelio.com', now()), - ('Illinois Valley Cellular', '%s@ivctext.com', now()), - ('i wireless', '%s.iws@iwspcs.net', now()), - ('Meteor (Ireland)', '%s@sms.mymeteor.ie', now()), - ('Mero Mobile (Nepal)', '%s@sms.spicenepal.com', now()), - ('MetroPCS', '%s@mymetropcs.com', now()), - ('Movicom', '%s@movimensaje.com.ar', now()), - ('Mobitel (Sri Lanka)', '%s@sms.mobitel.lk', now()), - ('Movistar (Colombia)', '%s@movistar.com.co', now()), - ('MTN (South Africa)', '%s@sms.co.za', now()), - ('MTS (Canada)', '%s@text.mtsmobility.com', now()), - ('Nextel (Argentina)', '%s@nextel.net.ar', now()), - ('Orange (Poland)', '%s@orange.pl', now()), - ('Orange (UK)', '%s@orange.net', now()), - ('Personal (Argentina)', '%s@personal-net.com.ar', now()), - ('Plus GSM (Poland)', '%s@text.plusgsm.pl', now()), - ('President''s Choice (Canada)', '%s@txt.bell.ca', now()), - ('Qwest', '%s@qwestmp.com', now()), - ('Rogers (Canada)', '%s@pcs.rogers.com', now()), - ('Sasktel (Canada)', '%s@sms.sasktel.com', now()), - ('Setar Mobile email (Aruba)', '%s@mas.aw', now()), - ('Solo Mobile', '%s@txt.bell.ca', now()), - ('Sprint (PCS)', '%s@messaging.sprintpcs.com', now()), - ('Sprint (Nextel)', '%s@page.nextel.com', now()), - ('Suncom', '%s@tms.suncom.com', now()), - ('T-Mobile', '%s@tmomail.net', now()), - ('T-Mobile (Austria)', '%s@sms.t-mobile.at', now()), - ('Telus Mobility (Canada)', '%s@msg.telus.com', now()), - ('Thumb Cellular', '%s@sms.thumbcellular.com', now()), - ('Tigo (Formerly Ola)', '%s@sms.tigo.com.co', now()), - ('Unicel', '%s@utext.com', now()), - ('US Cellular', '%s@email.uscc.net', now()), - ('Verizon', '%s@vtext.com', now()), - ('Virgin Mobile (Canada)', '%s@vmobile.ca', now()), - ('Virgin Mobile (USA)', '%s@vmobl.com', now()), - ('Vodafone NZ (txt ''R'' to 901 to enable first)', '%s@sms.vodafone.net.nz', now()), - ('YCC', '%s@sms.ycc.ru', now()); diff --git a/db/laconica.sql b/db/laconica.sql index 16f482134..15f03a978 100644 --- a/db/laconica.sql +++ b/db/laconica.sql @@ -31,7 +31,7 @@ create table avatar ( ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; create table sms_carrier ( - id integer auto_increment primary key comment 'primary key for SMS carrier', + id integer primary key comment 'primary key for SMS carrier', name varchar(64) unique key comment 'name of the carrier', email_pattern varchar(255) not null comment 'sprintf pattern for making an email address from a phone number', created datetime not null comment 'date this record was created', diff --git a/db/sms_carrier.sql b/db/sms_carrier.sql new file mode 100644 index 000000000..6879f2089 --- /dev/null +++ b/db/sms_carrier.sql @@ -0,0 +1,63 @@ +INSERT INTO sms_carrier + (id, name, email_pattern, created) +VALUES + (100056, '3 River Wireless', '%s@sms.3rivers.net', now()), + (100057, '7-11 Speakout', '%s@cingularme.com', now()), + (100058, 'Airtel (Karnataka, India)', '%s@airtelkk.com', now()), + (100059, 'Alaska Communications Systems', '%s@msg.acsalaska.com', now()), + (100060, 'Alltel Wireless', '%s@message.alltel.com', now()), + (100061, 'AT&T Wireless', '%s@txt.att.net', now()), + (100062, 'Bell Mobility (Canada)', '%s@txt.bell.ca', now()), + (100063, 'Boost Mobile', '%s@myboostmobile.com', now()), + (100064, 'Cellular One (Dobson)', '%s@mobile.celloneusa.com', now()), + (100065, 'Cingular (Postpaid)', '%s@cingularme.com', now()), + (100066, 'Centennial Wireless', '%s@cwemail.com', now()), + (100067, 'Cingular (GoPhone prepaid)', '%s@cingularme.com', now()), + (100068, 'Claro (Nicaragua)', '%s@ideasclaro-ca.com', now()), + (100069, 'Comcel', '%s@comcel.com.co', now()), + (100070, 'Cricket', '%s@sms.mycricket.com', now()), + (100071, 'CTI', '%s@sms.ctimovil.com.ar', now()), + (100072, 'Emtel (Mauritius)', '%s@emtelworld.net', now()), + (100073, 'Fido (Canada)', '%s@fido.ca', now()), + (100074, 'General Communications Inc.', '%s@msg.gci.net', now()), + (100075, 'Globalstar', '%s@msg.globalstarusa.com', now()), + (100076, 'Helio', '%s@myhelio.com', now()), + (100077, 'Illinois Valley Cellular', '%s@ivctext.com', now()), + (100078, 'i wireless', '%s.iws@iwspcs.net', now()), + (100079, 'Meteor (Ireland)', '%s@sms.mymeteor.ie', now()), + (100080, 'Mero Mobile (Nepal)', '%s@sms.spicenepal.com', now()), + (100081, 'MetroPCS', '%s@mymetropcs.com', now()), + (100082, 'Movicom', '%s@movimensaje.com.ar', now()), + (100083, 'Mobitel (Sri Lanka)', '%s@sms.mobitel.lk', now()), + (100084, 'Movistar (Colombia)', '%s@movistar.com.co', now()), + (100085, 'MTN (South Africa)', '%s@sms.co.za', now()), + (100086, 'MTS (Canada)', '%s@text.mtsmobility.com', now()), + (100087, 'Nextel (Argentina)', '%s@nextel.net.ar', now()), + (100088, 'Orange (Poland)', '%s@orange.pl', now()), + (100089, 'Personal (Argentina)', '%s@personal-net.com.ar', now()), + (100090, 'Plus GSM (Poland)', '%s@text.plusgsm.pl', now()), + (100091, 'President\'s Choice (Canada)', '%s@txt.bell.ca', now()), + (100092, 'Qwest', '%s@qwestmp.com', now()), + (100093, 'Rogers (Canada)', '%s@pcs.rogers.com', now()), + (100094, 'Sasktel (Canada)', '%s@sms.sasktel.com', now()), + (100095, 'Setar Mobile email (Aruba)', '%s@mas.aw', now()), + (100096, 'Solo Mobile', '%s@txt.bell.ca', now()), + (100097, 'Sprint (PCS)', '%s@messaging.sprintpcs.com', now()), + (100098, 'Sprint (Nextel)', '%s@page.nextel.com', now()), + (100099, 'Suncom', '%s@tms.suncom.com', now()), + (100100, 'T-Mobile', '%s@tmomail.net', now()), + (100101, 'T-Mobile (Austria)', '%s@sms.t-mobile.at', now()), + (100102, 'Telus Mobility (Canada)', '%s@msg.telus.com', now()), + (100103, 'Thumb Cellular', '%s@sms.thumbcellular.com', now()), + (100104, 'Tigo (Formerly Ola)', '%s@sms.tigo.com.co', now()), + (100105, 'Unicel', '%s@utext.com', now()), + (100106, 'US Cellular', '%s@email.uscc.net', now()), + (100107, 'Verizon', '%s@vtext.com', now()), + (100108, 'Virgin Mobile (Canada)', '%s@vmobile.ca', now()), + (100109, 'Virgin Mobile (USA)', '%s@vmobl.com', now()), + (100110, 'YCC', '%s@sms.ycc.ru', now()), + (100111, 'Orange (UK)', '%s@orange.net', now()), + (100112, 'Cincinnati Bell Wireless', '%s@gocbw.com', now()), + (100113, 'T-Mobile Germany', '%s@t-mobile-sms.de', now()), + (100114, 'Vodafone Germany', '%s@vodafone-sms.de', now()), + (100115, 'E-Plus', '%s@smsmail.eplus.de', now()); @@ -38,6 +38,10 @@ function getPath($req) function handleError($error) { + if ($error->getCode() == DB_DATAOBJECT_ERROR_NODATA) { + return; + } + common_log(LOG_ERR, "PEAR error: " . $error->getMessage()); $msg = sprintf(_('The database for %s isn\'t responding correctly, '. 'so the site won\'t work properly. '. diff --git a/lib/action.php b/lib/action.php index 926fe93fb..602118cdf 100644 --- a/lib/action.php +++ b/lib/action.php @@ -82,11 +82,6 @@ class Action extends HTMLOutputter // lawsuit */ function prepare($argarray) { - - // For PEAR_Errors comming from DB_DataObject - PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, - array($this, "handleError")); - $this->args =& common_copy_args($argarray); return true; } @@ -280,9 +275,15 @@ class Action extends HTMLOutputter // lawsuit { $this->elementStart('body', array('id' => $this->trimmed('action'))); $this->elementStart('div', array('id' => 'wrap')); - $this->showHeader(); + if (Event::handle('StartShowHeader', array($this))) { + $this->showHeader(); + Event::handle('EndShowHeader', array($this)); + } $this->showCore(); - $this->showFooter(); + if (Event::handle('StartShowFooter', array($this))) { + $this->showFooter(); + Event::handle('EndShowFooter', array($this)); + } $this->elementEnd('div'); $this->elementEnd('body'); } @@ -437,7 +438,10 @@ class Action extends HTMLOutputter // lawsuit { $this->elementStart('div', array('id' => 'core')); $this->showLocalNavBlock(); - $this->showContentBlock(); + if (Event::handle('StartShowContentBlock', array($this))) { + $this->showContentBlock(); + Event::handle('EndShowContentBlock', array($this)); + } $this->showAside(); $this->elementEnd('div'); } @@ -850,32 +854,6 @@ class Action extends HTMLOutputter // lawsuit } /** - * Handle old fashioned PEAR_Error msgs coming from DB_DataObject - * - * Logs the DB_DataObject error. Override to do something else. - * - * @param PEAR_Error - * - * @return nothing - */ - - function handleError($error) { - - common_log(LOG_ERR, "PEAR error: " . $error->getMessage()); - $msg = sprintf(_('The database for %s isn\'t responding correctly, '. - 'so the site won\'t work properly. '. - 'The site admins probably know about the problem, '. - 'but you can contact them at %s to make sure. '. - 'Otherwise, wait a few minutes and try again.'), - common_config('site', 'name'), - common_config('site', 'email')); - - $dac = new DBErrorAction($msg, 500); - $dac->showPage(); - exit(-1); - } - - /** * Returns the current URL * * @return string current URL diff --git a/lib/util.php b/lib/util.php index 7923fe28a..031fd0da0 100644 --- a/lib/util.php +++ b/lib/util.php @@ -394,20 +394,20 @@ function common_render_text($text) function common_replace_urls_callback($text, $callback) { // Start off with a regex - $regex = '# - (?: - (?: - (?:https?|ftps?|mms|rtsp|gopher|news|nntp|telnet|wais|file|prospero|webcal|xmpp|irc):// - | - (?:mailto|aim|tel): - ) - [^.\s]+\.[^\s]+ - | - (?:[^.\s/:]+\.)+ - (?:museum|travel|[a-z]{2,4}) - (?:[:/][^\s]*)? - ) - #ix'; + $regex = '#'. + '(?:'. + '(?:'. + '(?:https?|ftps?|mms|rtsp|gopher|news|nntp|telnet|wais|file|prospero|webcal|xmpp|irc)://'. + '|'. + '(?:mailto|aim|tel):'. + ')'. + '[^.\s]+\.[^\s]+'. + '|'. + '(?:[^.\s/:]+\.)+'. + '(?:museum|travel|[a-z]{2,4})'. + '(?:[:/][^\s]*)?'. + ')'. + '#ix'; preg_match_all($regex, $text, $matches); // Then clean up what the regex left behind @@ -472,16 +472,19 @@ function common_replace_urls_callback($text, $callback) { } function common_linkify($url) { + // It comes in special'd, so we unspecial it before passing to the stringifying + // functions + $url = htmlspecialchars_decode($url); $display = $url; - $url = (!preg_match('#^([a-z]+://|(mailto|aim|tel):)#i', $url)) ? 'http://'.$url:$url; + $url = (!preg_match('#^([a-z]+://|(mailto|aim|tel):)#i', $url)) ? 'http://'.$url : $url; + + $attrs = array('href' => $url, 'rel' => 'external'); if ($longurl = common_longurl($url)) { - $longurl = htmlentities($longurl, ENT_QUOTES, 'UTF-8'); - $title = "title=\"$longurl\""; + $attrs['title'] = $longurl; } - else $title = ''; - return "<a href=\"$url\" $title rel=\"external\">$display</a>"; + return XMLStringer::estring('a', $attrs, $display); } function common_longurl($short_url) @@ -582,7 +585,13 @@ function common_tag_link($tag) { $canonical = common_canonical_tag($tag); $url = common_local_url('tag', array('tag' => $canonical)); - return '<span class="tag"><a href="' . htmlspecialchars($url) . '" rel="tag">' . htmlspecialchars($tag) . '</a></span>'; + $xs = new XMLStringer(); + $xs->elementStart('span', 'tag'); + $xs->element('a', array('href' => $url, + 'rel' => 'tag'), + $tag); + $xs->elementEnd(); + return $xs->getString(); } function common_canonical_tag($tag) @@ -600,7 +609,14 @@ function common_at_link($sender_id, $nickname) $sender = Profile::staticGet($sender_id); $recipient = common_relative_profile($sender, common_canonical_nickname($nickname)); if ($recipient) { - return '<span class="vcard"><a href="'.htmlspecialchars($recipient->profileurl).'" class="url"><span class="fn nickname">'.$nickname.'</span></a></span>'; + $xs = new XMLStringer(false); + $xs->elementStart('span', 'vcard'); + $xs->elementStart('a', array('href' => $recipient->profileurl, + 'class' => 'url')); + $xs->element('span', 'fn nickname', $nickname); + $xs->elementEnd('a'); + $xs->elementEnd('span'); + return $xs->getString(); } else { return $nickname; } @@ -611,7 +627,14 @@ function common_group_link($sender_id, $nickname) $sender = Profile::staticGet($sender_id); $group = User_group::staticGet('nickname', common_canonical_nickname($nickname)); if ($group && $sender->isMember($group)) { - return '<span class="vcard"><a href="'.htmlspecialchars($group->permalink()).'" class="url"><span class="fn nickname">'.$nickname.'</span></a></span>'; + $xs = new XMLStringer(); + $xs->elementStart('span', 'vcard'); + $xs->elementStart('a', array('href' => $group->permalink(), + 'class' => 'url')); + $xs->element('span', 'fn nickname', $nickname); + $xs->elementEnd('a'); + $xs->elementEnd('span'); + return $xs->getString(); } else { return $nickname; } @@ -628,7 +651,13 @@ function common_at_hash_link($sender_id, $tag) $url = common_local_url('subscriptions', array('nickname' => $user->nickname, 'tag' => $tag)); - return '<span class="tag"><a href="'.htmlspecialchars($url).'" rel="tag">'.$tag.'</a></span>'; + $xs = new XMLStringer(); + $xs->elementStart('span', 'tag'); + $xs->element('a', array('href' => $url, + 'rel' => $tag), + $tag); + $xs->elementEnd('span'); + return $xs->getString(); } else { return $tag; } diff --git a/lib/xmlstringer.php b/lib/xmlstringer.php new file mode 100644 index 000000000..951b13b67 --- /dev/null +++ b/lib/xmlstringer.php @@ -0,0 +1,68 @@ +<?php +/** + * Laconica, the distributed open-source microblogging tool + * + * Generator for in-memory XML + * + * 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 Output + * @package Laconica + * @author Evan Prodromou <evan@controlyourself.ca> + * @copyright 2009 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +if (!defined('LACONICA')) { + exit(1); +} + +/** + * Create in-memory XML + * + * @category Output + * @package Laconica + * @author Evan Prodromou <evan@controlyourself.ca> + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + * @see Action + * @see HTMLOutputter + */ + +class XMLStringer extends XMLOutputter +{ + function __construct($indent=false) + { + $this->xw = new XMLWriter(); + $this->xw->openMemory(); + $this->xw->setIndent($indent); + } + + function getString() + { + return $this->xw->outputMemory(); + } + + // utility for quickly creating XML-strings + + static function estring($tag, $attrs=null, $content=null) + { + $xs = new XMLStringer(); + $xs->element($tag, $attrs, $content); + return $xs->getString(); + } +}
\ No newline at end of file diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 3b72d00ce..1ac63927d 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -22,7 +22,7 @@ line-height:1.65; position:relative; } h1,h2,h3,h4,h5,h6 { -text-transform:uppercase; +text-transform:capitalize; margin-bottom:7px; overflow:hidden; } @@ -43,7 +43,6 @@ font-weight:bold; legend { font-weight:bold; font-size:1.3em; -text-transform:uppercase; } input, textarea, select, option { padding:4px; |