diff options
author | Evan Prodromou <evan@status.net> | 2010-10-05 14:09:17 -0400 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2010-10-05 14:09:17 -0400 |
commit | 8aa9c271dffe6ec6766b94486c0635c9db588db7 (patch) | |
tree | f6cb465062767bdf5642121e61d143bdd2e4dcfe /lib | |
parent | 829a017a5d0104f495cd0b645ecb1f3cdeda25ac (diff) | |
parent | 5c4723919fa757b3e14a59350415cfe53e0900d1 (diff) |
Merge remote branch 'gitorious/1.0.x' into 1.0.x
Diffstat (limited to 'lib')
54 files changed, 566 insertions, 391 deletions
diff --git a/lib/accountsettingsaction.php b/lib/accountsettingsaction.php index 819f749f7..2c519e4ab 100644 --- a/lib/accountsettingsaction.php +++ b/lib/accountsettingsaction.php @@ -44,7 +44,6 @@ require_once INSTALLDIR.'/lib/settingsaction.php'; * * @see Widget */ - class AccountSettingsAction extends SettingsAction { /** @@ -54,7 +53,6 @@ class AccountSettingsAction extends SettingsAction * * @return void */ - function showLocalNav() { $menu = new AccountSettingsNav($this); @@ -73,7 +71,6 @@ class AccountSettingsAction extends SettingsAction * * @see HTMLOutputter */ - class AccountSettingsNav extends Widget { var $action = null; @@ -83,7 +80,6 @@ class AccountSettingsNav extends Widget * * @param Action $action current action, used for output */ - function __construct($action=null) { parent::__construct($action); @@ -95,7 +91,6 @@ class AccountSettingsNav extends Widget * * @return void */ - function show() { $action_name = $this->action->trimmed('action'); diff --git a/lib/action.php b/lib/action.php index e50397514..ddc058d41 100644 --- a/lib/action.php +++ b/lib/action.php @@ -314,7 +314,6 @@ class Action extends HTMLOutputter // lawsuit * * @return nothing */ - function showFeeds() { $feeds = $this->getFeeds(); @@ -710,19 +709,18 @@ class Action extends HTMLOutputter // lawsuit * * @return nothing */ - function showAside() { $this->elementStart('div', array('id' => 'aside_primary', 'class' => 'aside')); - if (Event::handle('StartShowExportData', array($this))) { - $this->showExportData(); - Event::handle('EndShowExportData', array($this)); - } if (Event::handle('StartShowSections', array($this))) { $this->showSections(); Event::handle('EndShowSections', array($this)); } + if (Event::handle('StartShowExportData', array($this))) { + $this->showExportData(); + Event::handle('EndShowExportData', array($this)); + } $this->elementEnd('div'); } @@ -731,7 +729,6 @@ class Action extends HTMLOutputter // lawsuit * * @return void */ - function showExportData() { $feeds = $this->getFeeds(); @@ -807,6 +804,7 @@ class Action extends HTMLOutputter // lawsuit // TRANS: Secondary navigation menu option leading to contact information on the StatusNet site. _('Contact')); $this->menuItem(common_local_url('doc', array('title' => 'badge')), + // TRANS: Secondary navigation menu option. _('Badge')); Event::handle('EndSecondaryNav', array($this)); } @@ -840,6 +838,9 @@ class Action extends HTMLOutputter // lawsuit $this->elementStart('dd', null); if (common_config('site', 'broughtby')) { // TRANS: First sentence of the StatusNet site license. Used if 'broughtby' is set. + // TRANS: Text between [] is a link description, text between () is the link itself. + // TRANS: Make sure there is no whitespace between "]" and "(". + // TRANS: "%%site.broughtby%%" is the value of the variable site.broughtby $instr = _('**%%site.name%%** is a microblogging service brought to you by [%%site.broughtby%%](%%site.broughtbyurl%%).'); } else { // TRANS: First sentence of the StatusNet site license. Used if 'broughtby' is not set. @@ -847,6 +848,9 @@ class Action extends HTMLOutputter // lawsuit } $instr .= ' '; // TRANS: Second sentence of the StatusNet site license. Mentions the StatusNet source code license. + // TRANS: Make sure there is no whitespace between "]" and "(". + // TRANS: Text between [] is a link description, text between () is the link itself. + // TRANS: %s is the version of StatusNet that is being used. $instr .= sprintf(_('It runs the [StatusNet](http://status.net/) microblogging software, version %s, available under the [GNU Affero General Public License](http://www.fsf.org/licensing/licenses/agpl-3.0.html).'), STATUSNET_VERSION); $output = common_markup_to_html($instr); $this->raw($output); @@ -893,7 +897,8 @@ class Action extends HTMLOutputter // lawsuit 'width' => '80', 'height' => '15')); $this->text(' '); - // TRANS: license message in footer. %1$s is the site name, %2$s is a link to the license URL, with a licence name set in configuration. + // TRANS: license message in footer. + // TRANS: %1$s is the site name, %2$s is a link to the license URL, with a licence name set in configuration. $notice = _('All %1$s content and data are available under the %2$s license.'); $link = "<a class=\"license\" rel=\"external license\" href=\"" . htmlspecialchars(common_config('license', 'url')) . @@ -947,7 +952,6 @@ class Action extends HTMLOutputter // lawsuit * * @return boolean is read only action? */ - function isReadOnly($args) { return false; @@ -1011,17 +1015,22 @@ class Action extends HTMLOutputter // lawsuit } } + $checked = false; if ($etag) { $if_none_match = (array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER)) ? $_SERVER['HTTP_IF_NONE_MATCH'] : null; - if ($if_none_match && $this->_hasEtag($etag, $if_none_match)) { - header('HTTP/1.1 304 Not Modified'); - // Better way to do this? - exit(0); + if ($if_none_match) { + // If this check fails, ignore the if-modified-since below. + $checked = true; + if ($this->_hasEtag($etag, $if_none_match)) { + header('HTTP/1.1 304 Not Modified'); + // Better way to do this? + exit(0); + } } } - if ($lm && array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) { + if (!$checked && $lm && array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) { $if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE']; $ims = strtotime($if_modified_since); if ($lm <= $ims) { @@ -1041,7 +1050,6 @@ class Action extends HTMLOutputter // lawsuit * * @return boolean is read only action? */ - function isCacheable() { return true; @@ -1055,7 +1063,6 @@ class Action extends HTMLOutputter // lawsuit * * @return boolean */ - function _hasEtag($etag, $if_none_match) { $etags = explode(',', $if_none_match); @@ -1095,7 +1102,6 @@ class Action extends HTMLOutputter // lawsuit * * @return integer integer value */ - function int($key, $defValue=null, $maxValue=null, $minValue=null) { $arg = strtolower($this->trimmed($key)); @@ -1123,7 +1129,6 @@ class Action extends HTMLOutputter // lawsuit * * @return nothing */ - function serverError($msg, $code=500) { $action = $this->trimmed('action'); @@ -1139,7 +1144,6 @@ class Action extends HTMLOutputter // lawsuit * * @return nothing */ - function clientError($msg, $code=400) { $action = $this->trimmed('action'); @@ -1152,7 +1156,6 @@ class Action extends HTMLOutputter // lawsuit * * @return string current URL */ - function selfUrl() { list($action, $args) = $this->returnToArgs(); @@ -1164,7 +1167,6 @@ class Action extends HTMLOutputter // lawsuit * * @return array two elements: action, other args */ - function returnToArgs() { $action = $this->trimmed('action'); @@ -1271,7 +1273,6 @@ class Action extends HTMLOutputter // lawsuit * * @return array Feed object to show in head and links */ - function getFeeds() { return null; @@ -1282,7 +1283,6 @@ class Action extends HTMLOutputter // lawsuit * * @return Design a design object to use */ - function getDesign() { return Design::siteDesign(); @@ -1296,7 +1296,6 @@ class Action extends HTMLOutputter // lawsuit * * @return void */ - // XXX: Finding this type of check with the same message about 50 times. // Possible to refactor? function checkSessionToken() @@ -1304,6 +1303,7 @@ class Action extends HTMLOutputter // lawsuit // CSRF protection $token = $this->trimmed('token'); if (empty($token) || $token != common_session_token()) { + // TRANS: Client error text when there is a problem with the session token. $this->clientError(_('There was a problem with your session token.')); } } diff --git a/lib/activity.php b/lib/activity.php index 8e2da99bb..e974ca991 100644 --- a/lib/activity.php +++ b/lib/activity.php @@ -48,7 +48,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 * @link http://status.net/ */ - class Activity { const SPEC = 'http://activitystrea.ms/spec/1.0/'; @@ -108,7 +107,6 @@ class Activity * @param DOMElement $entry Atom entry to poke at * @param DOMElement $feed Atom feed, for context */ - function __construct($entry = null, $feed = null) { if (is_null($entry)) { @@ -133,6 +131,7 @@ class Activity $entry->localName == 'item') { $this->_fromRssItem($entry, $feed); } else { + // Low level exception. No need for i18n. throw new Exception("Unknown DOM element: {$entry->namespaceURI} {$entry->localName}"); } } @@ -313,13 +312,12 @@ class Activity * * @return DOMElement Atom entry */ - function toAtomEntry() { return null; } - function asString($namespace=false) + function asString($namespace=false, $author=true) { $xs = new XMLStringer(true); @@ -338,7 +336,7 @@ class Activity $xs->element('id', null, $this->id); $xs->element('title', null, $this->title); - $xs->element('published', null, common_date_iso8601($this->time)); + $xs->element('published', null, self::iso8601Date($this->time)); $xs->element('content', array('type' => 'html'), $this->content); if (!empty($this->summary)) { @@ -353,13 +351,15 @@ class Activity // XXX: add context - $xs->elementStart('author'); - $xs->element('uri', array(), $this->actor->id); - if ($this->actor->title) { - $xs->element('name', array(), $this->actor->title); + if ($author) { + $xs->elementStart('author'); + $xs->element('uri', array(), $this->actor->id); + if ($this->actor->title) { + $xs->element('name', array(), $this->actor->title); + } + $xs->elementEnd('author'); + $xs->raw($this->actor->asString('activity:actor')); } - $xs->elementEnd('author'); - $xs->raw($this->actor->asString('activity:actor')); $xs->element('activity:verb', null, $this->verb); @@ -386,5 +386,12 @@ class Activity { return ActivityUtils::child($element, $tag, $namespace); } -} + static function iso8601Date($tm) + { + $dateStr = date('d F Y H:i:s', $tm); + $d = new DateTime($dateStr, new DateTimeZone('UTC')); + $d->setTimezone(new DateTimeZone(common_timezone())); + return $d->format('c'); + } +} diff --git a/lib/activitycontext.php b/lib/activitycontext.php index 09a457924..ff3bc9411 100644 --- a/lib/activitycontext.php +++ b/lib/activitycontext.php @@ -54,8 +54,12 @@ class ActivityContext const MENTIONED = 'mentioned'; const CONVERSATION = 'ostatus:conversation'; - function __construct($element) + function __construct($element = null) { + if (empty($element)) { + return; + } + $replyToEl = ActivityUtils::child($element, self::INREPLYTO, self::THR); if (!empty($replyToEl)) { @@ -73,7 +77,6 @@ class ActivityContext $attention = array(); for ($i = 0; $i < $links->length; $i++) { - $link = $links->item($i); $linkRel = $link->getAttribute(ActivityUtils::REL); diff --git a/lib/activityobject.php b/lib/activityobject.php index 677a48197..e89c8db4e 100644 --- a/lib/activityobject.php +++ b/lib/activityobject.php @@ -49,7 +49,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 * @link http://status.net/ */ - class ActivityObject { const ARTICLE = 'http://activitystrea.ms/schema/1.0/article'; @@ -116,7 +115,6 @@ class ActivityObject * * @param DOMElement $element DOM thing to turn into an Activity thing */ - function __construct($element = null) { if (empty($element)) { @@ -168,7 +166,6 @@ class ActivityObject ActivityObject::MEDIA_DESCRIPTION, Activity::MEDIA ); - } } @@ -204,7 +201,7 @@ class ActivityObject $title = ActivityUtils::childHtmlContent($element, self::TITLE); - $this->title = html_entity_decode(strip_tags($title)); + $this->title = html_entity_decode(strip_tags($title), ENT_QUOTES, 'UTF-8'); $this->source = $this->_getSource($element); @@ -217,8 +214,7 @@ class ActivityObject } } - // @fixme rationalize with Activity::_fromRssItem() - + // @todo FIXME: rationalize with Activity::_fromRssItem() private function _fromRssItem($item) { $this->title = ActivityUtils::childContent($item, ActivityObject::TITLE, Activity::RSS); @@ -418,7 +414,6 @@ class ActivityObject ); foreach ($sizes as $size) { - $alink = null; $avatar = $profile->getAvatar($size); @@ -430,6 +425,17 @@ class ActivityObject $alink->height = $size; $alink->width = $size; $alink->url = Avatar::defaultImage($size); + + if ($size == AVATAR_PROFILE_SIZE) { + // Hack for Twitter import: we don't have a 96x96 image, + // but we do have a 73x73 image. For now, fake it with that. + $avatar = $profile->getAvatar(73); + if ($avatar) { + $alink = AvatarLink::fromAvatar($avatar); + $alink->height= $size; + $alink->width = $size; + } + } } $object->avatarLinks[] = $alink; diff --git a/lib/activityutils.php b/lib/activityutils.php index dd38d4e14..c462514c4 100644 --- a/lib/activityutils.php +++ b/lib/activityutils.php @@ -46,7 +46,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 * @link http://status.net/ */ - class ActivityUtils { const ATOM = 'http://www.w3.org/2005/Atom'; @@ -66,7 +65,6 @@ class ActivityUtils * * @return string related link, if any */ - static function getPermalink($element) { return self::getLink($element, 'alternate', 'text/html'); @@ -79,19 +77,16 @@ class ActivityUtils * * @return string related link, if any */ - static function getLink(DOMNode $element, $rel, $type=null) { $els = $element->childNodes; foreach ($els as $link) { - if (!($link instanceof DOMElement)) { continue; } if ($link->localName == self::LINK && $link->namespaceURI == self::ATOM) { - $linkRel = $link->getAttribute(self::REL); $linkType = $link->getAttribute(self::TYPE); @@ -112,7 +107,6 @@ class ActivityUtils foreach ($els as $link) { if ($link->localName == self::LINK && $link->namespaceURI == self::ATOM) { - $linkRel = $link->getAttribute(self::REL); $linkType = $link->getAttribute(self::TYPE); @@ -135,7 +129,6 @@ class ActivityUtils * * @return DOMElement found element or null */ - static function child(DOMNode $element, $tag, $namespace=self::ATOM) { $els = $element->childNodes; @@ -160,7 +153,6 @@ class ActivityUtils * * @return string content of the child */ - static function childContent(DOMNode $element, $tag, $namespace=self::ATOM) { $el = self::child($element, $tag, $namespace); @@ -194,7 +186,6 @@ class ActivityUtils * @todo handle embedded XML mime types * @todo handle base64-encoded non-XML and non-text mime types */ - static function getContent($element) { return self::childHtmlContent($element, self::CONTENT, self::ATOM); @@ -205,6 +196,7 @@ class ActivityUtils $src = $el->getAttribute(self::SRC); if (!empty($src)) { + // TRANS: Client exception thrown when there is no source attribute. throw new ClientException(_("Can't handle remote content yet.")); } @@ -241,10 +233,12 @@ class ActivityUtils return trim($text); } else if (in_array($type, array('text/xml', 'application/xml')) || preg_match('#(+|/)xml$#', $type)) { + // TRANS: Client exception thrown when there embedded XML content is found that cannot be processed yet. throw new ClientException(_("Can't handle embedded XML content yet.")); } else if (strncasecmp($type, 'text/', 5)) { return $el->textContent; } else { + // TRANS: Client exception thrown when base64 encoded content is found that cannot be processed yet. throw new ClientException(_("Can't handle embedded Base64 content yet.")); } } diff --git a/lib/activityverb.php b/lib/activityverb.php index 76f2b84e9..264351308 100644 --- a/lib/activityverb.php +++ b/lib/activityverb.php @@ -42,7 +42,6 @@ if (!defined('STATUSNET')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 * @link http://status.net/ */ - class ActivityVerb { const POST = 'http://activitystrea.ms/schema/1.0/post'; diff --git a/lib/adminform.php b/lib/adminform.php index 3934f6351..1ecb02435 100644 --- a/lib/adminform.php +++ b/lib/adminform.php @@ -45,7 +45,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { * * @see Form */ - class AdminForm extends Form { /** @@ -59,7 +58,6 @@ class AdminForm extends Form * * @return void */ - function input($setting, $title, $instructions, $section='site') { $this->out->input($setting, $title, $this->value($setting, $section), $instructions); @@ -73,7 +71,6 @@ class AdminForm extends Form * * @return string param value if posted, or current config value */ - function value($setting, $main='site') { $value = $this->out->trimmed($setting); @@ -82,5 +79,4 @@ class AdminForm extends Form } return $value; } - } diff --git a/lib/adminpanelaction.php b/lib/adminpanelaction.php index 9e0b2d041..8dd16e9d0 100644 --- a/lib/adminpanelaction.php +++ b/lib/adminpanelaction.php @@ -44,7 +44,6 @@ if (!defined('STATUSNET')) { * * @todo Find some commonalities with SettingsAction and combine */ - class AdminPanelAction extends Action { var $success = true; @@ -61,7 +60,6 @@ class AdminPanelAction extends Action * * @return boolean success flag */ - function prepare($args) { parent::prepare($args); @@ -124,7 +122,6 @@ class AdminPanelAction extends Action * * @return void */ - function handle($args) { if ($_SERVER['REQUEST_METHOD'] == 'POST') { @@ -155,7 +152,6 @@ class AdminPanelAction extends Action * @return void * @see AdminPanelNav */ - function showLocalNav() { $nav = new AdminPanelNav($this); @@ -169,7 +165,6 @@ class AdminPanelAction extends Action * * @return void. */ - function showContent() { $this->showForm(); @@ -199,7 +194,6 @@ class AdminPanelAction extends Action * * @return void */ - function showPageNotice() { if ($this->msg) { @@ -222,7 +216,6 @@ class AdminPanelAction extends Action * * @return void */ - function showForm() { // TRANS: Client error message. @@ -239,7 +232,6 @@ class AdminPanelAction extends Action * * @return void */ - function getInstructions() { return ''; @@ -252,7 +244,6 @@ class AdminPanelAction extends Action * * @return void */ - function saveSettings() { // TRANS: Client error message @@ -267,7 +258,6 @@ class AdminPanelAction extends Action * * @return mixed $result false if something didn't work */ - function deleteSetting($section, $setting) { $config = new Config(); @@ -314,7 +304,6 @@ class AdminPanelAction extends Action * * @see Widget */ - class AdminPanelNav extends Widget { var $action = null; @@ -324,7 +313,6 @@ class AdminPanelNav extends Widget * * @param Action $action current action, used for output */ - function __construct($action=null) { parent::__construct($action); @@ -336,7 +324,6 @@ class AdminPanelNav extends Widget * * @return void */ - function show() { $action_name = $this->action->trimmed('action'); @@ -409,6 +396,14 @@ class AdminPanelNav extends Widget $menu_title, $action_name == 'snapshotadminpanel', 'nav_snapshot_admin_panel'); } + if (AdminPanelAction::canAdmin('license')) { + // TRANS: Menu item title/tooltip + $menu_title = _('Set site license'); + // TRANS: Menu item for site administration + $this->out->menuItem(common_local_url('licenseadminpanel'), _('License'), + $menu_title, $action_name == 'licenseadminpanel', 'nav_license_admin_panel'); + } + if (AdminPanelAction::canAdmin('plugins')) { // TRANS: Menu item title/tooltip $menu_title = _('Plugins configuration'); @@ -421,5 +416,4 @@ class AdminPanelNav extends Widget } $this->action->elementEnd('ul'); } - } diff --git a/lib/apiaction.php b/lib/apiaction.php index b4252db95..d8249055a 100644 --- a/lib/apiaction.php +++ b/lib/apiaction.php @@ -114,7 +114,6 @@ class ApiValidationException extends Exception { } * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class ApiAction extends Action { const READ_ONLY = 1; @@ -141,7 +140,6 @@ class ApiAction extends Action * * @return boolean false if user doesn't exist */ - function prepare($args) { StatusNet::setApi(true); // reduce exception reports to aid in debugging @@ -174,7 +172,6 @@ class ApiAction extends Action * * @return void */ - function handle($args) { header('Access-Control-Allow-Origin: *'); @@ -467,7 +464,6 @@ class ApiAction extends Action $entry = array(); if (Event::handle('StartRssEntryArray', array($notice, &$entry))) { - $profile = $notice->getProfile(); // We trim() to avoid extraneous whitespace in the output @@ -557,7 +553,6 @@ class ApiAction extends Action $notifications = false; if ($source->isSubscribed($target)) { - $sub = Subscription::pkeyGet(array('subscriber' => $source->id, 'subscribed' => $target->id)); @@ -743,7 +738,6 @@ class ApiAction extends Action function showXmlTimeline($notice) { - $this->initDocument('xml'); $this->elementStart('statuses', array('type' => 'array', 'xmlns:statusnet' => 'http://status.net/schema/api/1/')); @@ -768,7 +762,6 @@ class ApiAction extends Action function showRssTimeline($notice, $title, $link, $subtitle, $suplink = null, $logo = null, $self = null) { - $this->initDocument('rss'); $this->element('title', null, $title); @@ -824,7 +817,6 @@ class ApiAction extends Action function showAtomTimeline($notice, $title, $id, $link, $subtitle=null, $suplink=null, $selfuri=null, $logo=null) { - $this->initDocument('atom'); $this->element('title', null, $title); @@ -864,12 +856,10 @@ class ApiAction extends Action } $this->endDocument('atom'); - } function showRssGroups($group, $title, $link, $subtitle) { - $this->initDocument('rss'); $this->element('title', null, $title); @@ -1017,7 +1007,6 @@ class ApiAction extends Action function showAtomGroups($group, $title, $id, $link, $subtitle=null, $selfuri=null) { - $this->initDocument('atom'); $this->element('title', null, common_xml_safe_str($title)); @@ -1048,7 +1037,6 @@ class ApiAction extends Action function showJsonTimeline($notice) { - $this->initDocument('json'); $statuses = array(); @@ -1074,7 +1062,6 @@ class ApiAction extends Action function showJsonGroups($group) { - $this->initDocument('json'); $groups = array(); @@ -1120,7 +1107,6 @@ class ApiAction extends Action function showTwitterXmlUsers($user) { - $this->initDocument('xml'); $this->elementStart('users', array('type' => 'array', 'xmlns:statusnet' => 'http://status.net/schema/api/1/')); @@ -1143,7 +1129,6 @@ class ApiAction extends Action function showJsonUsers($user) { - $this->initDocument('json'); $users = array(); @@ -1228,7 +1213,6 @@ class ApiAction extends Action $this->endXML(); break; case 'json': - // Check for JSONP callback if (isset($this->callback)) { print ')'; @@ -1374,7 +1358,6 @@ class ApiAction extends Action function getTargetUser($id) { if (empty($id)) { - // Twitter supports these other ways of passing the user ID if (is_numeric($this->arg('id'))) { return User::staticGet($this->arg('id')); @@ -1485,7 +1468,6 @@ class ApiAction extends Action */ function arg($key, $def=null) { - // XXX: Do even more input validation/scrubbing? if (array_key_exists($key, $this->args)) { @@ -1552,5 +1534,4 @@ class ApiAction extends Action return $uri; } - } diff --git a/lib/apiauth.php b/lib/apiauth.php index cf7a2692c..8b0a3da17 100644 --- a/lib/apiauth.php +++ b/lib/apiauth.php @@ -68,7 +68,6 @@ require_once INSTALLDIR . '/lib/apioauth.php'; * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class ApiAuthAction extends ApiAction { var $auth_user_nickname = null; @@ -83,7 +82,6 @@ class ApiAuthAction extends ApiAction * @return boolean success flag * */ - function prepare($args) { parent::prepare($args); @@ -126,7 +124,6 @@ class ApiAuthAction extends ApiAction * * @return mixed the OAuthRequest or false */ - function getOAuthRequest() { ApiOauthAction::cleanRequest(); @@ -154,7 +151,6 @@ class ApiAuthAction extends ApiAction * * @return nothing */ - function checkOAuthRequest($request) { $datastore = new ApiStatusNetOAuthDataStore(); @@ -164,7 +160,6 @@ class ApiAuthAction extends ApiAction $server->add_signature_method($hmac_method); try { - $server->verify_request($request); $consumer = $request->get_parameter('oauth_consumer_key'); @@ -176,7 +171,8 @@ class ApiAuthAction extends ApiAction common_log(LOG_WARNING, 'Couldn\'t find the OAuth app for consumer key: ' . $consumer); - throw new OAuthException('No application for that consumer key.'); + // TRANS: OAuth exception thrown when no application is found for a given consumer key. + throw new OAuthException(_('No application for that consumer key.')); } // set the source attr @@ -186,19 +182,15 @@ class ApiAuthAction extends ApiAction $appUser = Oauth_application_user::staticGet('token', $access_token); if (!empty($appUser)) { - // If access_type == 0 we have either a request token // or a bad / revoked access token if ($appUser->access_type != 0) { - // Set the access level for the api call - $this->access = ($appUser->access_type & Oauth_application::$writeAccess) ? self::READ_WRITE : self::READ_ONLY; // Set the auth user - if (Event::handle('StartSetApiUser', array(&$user))) { $this->auth_user = User::staticGet('id', $appUser->profile_id); Event::handle('EndSetApiUser', array($user)); @@ -216,13 +208,13 @@ class ApiAuthAction extends ApiAction 'read-write' : 'read-only' )); } else { - throw new OAuthException('Bad access token.'); + // TRANS: OAuth exception given when an incorrect access token was given for a user. + throw new OAuthException(_('Bad access token.')); } } else { - // Also should not happen - - throw new OAuthException('No user for that token.'); + // TRANS: OAuth exception given when no user was found for a given token (no token was found). + throw new OAuthException(_('No user for that token.')); } } catch (OAuthException $e) { @@ -237,7 +229,6 @@ class ApiAuthAction extends ApiAction * * @return boolean true */ - function requiresAuth() { return true; @@ -249,7 +240,6 @@ class ApiAuthAction extends ApiAction * * @return boolean true or false */ - function checkBasicAuthUser($required = true) { $this->basicAuthProcessHeader(); @@ -264,8 +254,8 @@ class ApiAuthAction extends ApiAction header('WWW-Authenticate: Basic realm="' . $realm . '"'); // show error if the user clicks 'cancel' - - $this->clientError("Could not authenticate you.", 401, $this->format); + // TRANS: Client error thrown when authentication fails becaus a user clicked "Cancel". + $this->clientError(_("Could not authenticate you."), 401, $this->format); exit; } else { @@ -283,13 +273,11 @@ class ApiAuthAction extends ApiAction } // By default, basic auth users have rw access - $this->access = self::READ_WRITE; if (empty($this->auth_user) && ($required || isset($_SERVER['PHP_AUTH_USER']))) { // basic authentication failed - list($proxy, $ip) = common_client_ip(); $msg = sprintf( 'Failed API auth attempt, nickname = %1$s, ' . @@ -298,7 +286,8 @@ class ApiAuthAction extends ApiAction $proxy, $ip); common_log(LOG_WARNING, $msg); - $this->clientError("Could not authenticate you.", 401, $this->format); + // TRANS: Client error thrown when authentication fails. + $this->clientError(_("Could not authenticate you."), 401, $this->format); exit; } } @@ -310,7 +299,6 @@ class ApiAuthAction extends ApiAction * * @return void */ - function basicAuthProcessHeader() { $authHeaders = array('AUTHORIZATION', @@ -332,7 +320,6 @@ class ApiAuthAction extends ApiAction // Decode the HTTP_AUTHORIZATION header on php-cgi server self // on fcgid server the header name is AUTHORIZATION - $auth_hash = base64_decode(substr($authorization_header, 6)); list($this->auth_user_nickname, $this->auth_user_password) = explode(':', $auth_hash); diff --git a/lib/apibareauth.php b/lib/apibareauth.php index da7af1261..043181b07 100644 --- a/lib/apibareauth.php +++ b/lib/apibareauth.php @@ -30,7 +30,7 @@ * @author Evan Prodromou <evan@status.net> * @author mEDI <medi@milaro.net> * @author Sarven Capadisli <csarven@status.net> - * @author Zach Copley <zach@status.net> + * @author Zach Copley <zach@status.net> * @copyright 2009 StatusNet, Inc. * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 @@ -60,10 +60,8 @@ require_once INSTALLDIR.'/lib/apiauth.php'; * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class ApiBareAuthAction extends ApiAuthAction { - /** * Take arguments for running * @@ -72,7 +70,6 @@ class ApiBareAuthAction extends ApiAuthAction * @return boolean success flag * */ - function prepare($args) { parent::prepare($args); @@ -84,18 +81,15 @@ class ApiBareAuthAction extends ApiAuthAction * * @return boolean true or false */ - function requiresAuth() { // If the site is "private", all API methods except statusnet/config // need authentication - if (common_config('site', 'private')) { return true; } // check whether a user has been specified somehow - $id = $this->arg('id'); $user_id = $this->arg('user_id'); $screen_name = $this->arg('screen_name'); @@ -106,5 +100,4 @@ class ApiBareAuthAction extends ApiAuthAction return false; } - } diff --git a/lib/apioauth.php b/lib/apioauth.php index 4cb8a6775..1c87e4232 100644 --- a/lib/apioauth.php +++ b/lib/apioauth.php @@ -44,7 +44,6 @@ require_once INSTALLDIR . '/lib/apioauthstore.php'; * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class ApiOauthAction extends Action { /** @@ -52,7 +51,6 @@ class ApiOauthAction extends Action * * @return boolean false */ - function isReadOnly($args) { return false; @@ -73,7 +71,6 @@ class ApiOauthAction extends Action * * @return void */ - function handle($args) { parent::handle($args); @@ -83,7 +80,6 @@ class ApiOauthAction extends Action static function cleanRequest() { // kill evil effects of magical slashing - if (get_magic_quotes_gpc() == 1) { $_POST = array_map('stripslashes', $_POST); $_GET = array_map('stripslashes', $_GET); @@ -93,7 +89,6 @@ class ApiOauthAction extends Action // XXX: should we strip anything else? Or alternatively // only allow a known list of params? - unset($_GET['p']); unset($_POST['p']); } @@ -118,5 +113,4 @@ class ApiOauthAction extends Action return ($url . '&' . $k . '=' . $v); } } - } diff --git a/lib/apioauthstore.php b/lib/apioauthstore.php index 1bb11cbca..eca93866f 100644 --- a/lib/apioauthstore.php +++ b/lib/apioauthstore.php @@ -23,7 +23,6 @@ require_once INSTALLDIR . '/lib/oauthstore.php'; class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore { - function lookup_consumer($consumer_key) { $con = Consumer::staticGet('consumer_key', $consumer_key); @@ -39,7 +38,6 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore function getAppByRequestToken($token_key) { // Look up the full req tokenx - $req_token = $this->lookup_token(null, 'request', $token_key); @@ -50,7 +48,6 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore } // Look up the full Token - $token = new Token(); $token->tok = $req_token->key; $result = $token->find(true); @@ -150,10 +147,8 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore } // Okay, good - return new OAuthToken($at->tok, $at->secret); } - } else { return null; } @@ -172,19 +167,20 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore * * @return void */ - public function revoke_token($token_key, $type = 0) { $rt = new Token(); $rt->tok = $token_key; $rt->type = $type; $rt->state = 0; + if (!$rt->find(true)) { - throw new Exception('Tried to revoke unknown token'); + // TRANS: Exception thrown when an attempt is made to revoke an unknown token. + throw new Exception(_('Tried to revoke unknown token.')); } + if (!$rt->delete()) { - throw new Exception('Failed to delete revoked token'); + // TRANS: Exception thrown when an attempt is made to remove a revoked token. + throw new Exception(_('Failed to delete revoked token.')); } } - } - diff --git a/lib/apiprivateauth.php b/lib/apiprivateauth.php index 5e78c65a1..df401c382 100644 --- a/lib/apiprivateauth.php +++ b/lib/apiprivateauth.php @@ -29,7 +29,7 @@ * @author Evan Prodromou <evan@status.net> * @author mEDI <medi@milaro.net> * @author Sarven Capadisli <csarven@status.net> - * @author Zach Copley <zach@status.net> + * @author Zach Copley <zach@status.net> * @copyright 2009 StatusNet, Inc. * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 @@ -58,26 +58,21 @@ require_once INSTALLDIR.'/lib/apiauth.php'; * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class ApiPrivateAuthAction extends ApiAuthAction { - /** * Does this API resource require authentication? * * @return boolean true or false */ - function requiresAuth() { // If the site is "private", all API methods except statusnet/config // need authentication - if (common_config('site', 'private')) { return true; } return false; } - } diff --git a/lib/applicationeditform.php b/lib/applicationeditform.php index 81c8fb018..f53c31feb 100644 --- a/lib/applicationeditform.php +++ b/lib/applicationeditform.php @@ -43,13 +43,11 @@ require_once INSTALLDIR . '/lib/form.php'; * @link http://status.net/ * */ - class ApplicationEditForm extends Form { /** * group for user to join */ - var $application = null; /** @@ -58,7 +56,6 @@ class ApplicationEditForm extends Form * @param Action $out output channel * @param User_group $group group to join */ - function __construct($out=null, $application=null) { parent::__construct($out); @@ -71,7 +68,6 @@ class ApplicationEditForm extends Form * * @return string ID of the form */ - function id() { if ($this->application) { @@ -89,7 +85,6 @@ class ApplicationEditForm extends Form * * @return string the method to use for submitting */ - function method() { $this->enctype = 'multipart/form-data'; @@ -101,7 +96,6 @@ class ApplicationEditForm extends Form * * @return string of the form class */ - function formClass() { return 'form_settings'; @@ -112,7 +106,6 @@ class ApplicationEditForm extends Form * * @return string URL of the action */ - function action() { $cur = common_current_user(); @@ -130,7 +123,6 @@ class ApplicationEditForm extends Form * * @return void */ - function formLegend() { // TRANS: Form legend. @@ -142,7 +134,6 @@ class ApplicationEditForm extends Form * * @return void */ - function formData() { if ($this->application) { @@ -206,7 +197,8 @@ class ApplicationEditForm extends Form $maxDesc = Oauth_application::maxDesc(); if ($maxDesc > 0) { // TRANS: Form input field instructions. - $descInstr = sprintf(_('Describe your application in %d characters'), + // TRANS: %d is the number of available characters for the description. + $descInstr = sprintf(ngettext('Describe your application in %d character','Describe your application in %d characters',$maxDesc), $maxDesc); } else { // TRANS: Form input field instructions. @@ -265,8 +257,9 @@ class ApplicationEditForm extends Form // Default to Browser - if ($this->application->type == Oauth_application::$browser - || empty($this->application->type)) { + if (empty($this->application) + || empty($this->application->type) + || $this->application->type == Oauth_application::$browser) { $attrs['checked'] = 'checked'; } @@ -283,7 +276,7 @@ class ApplicationEditForm extends Form 'class' => 'radio', 'value' => Oauth_application::$desktop); - if ($this->application->type == Oauth_application::$desktop) { + if (!empty($this->application) && $this->application->type == Oauth_application::$desktop) { $attrs['checked'] = 'checked'; } @@ -307,8 +300,9 @@ class ApplicationEditForm extends Form // default to read-only access - if ($this->application->access_type & Oauth_application::$readAccess - || empty($this->application->access_type)) { + if (empty($this->application) + || empty($this->application->access_type) + || $this->application->access_type & Oauth_application::$readAccess) { $attrs['checked'] = 'checked'; } @@ -325,7 +319,8 @@ class ApplicationEditForm extends Form 'class' => 'radio', 'value' => 'rw'); - if ($this->application->access_type & Oauth_application::$readAccess + if (!empty($this->application) + && $this->application->access_type & Oauth_application::$readAccess && $this->application->access_type & Oauth_application::$writeAccess ) { $attrs['checked'] = 'checked'; @@ -350,16 +345,15 @@ class ApplicationEditForm extends Form * * @return void */ - function formActions() { - // TRANS: Button label + // TRANS: Button label in the "Edit application" form. $this->out->submit('cancel', _m('BUTTON','Cancel'), 'submit form_action-primary', - // TRANS: Submit button title + // TRANS: Submit button title. 'cancel', _('Cancel')); - // TRANS: Button label + // TRANS: Button label in the "Edit application" form. $this->out->submit('save', _m('BUTTON','Save'), 'submit form_action-secondary', - // TRANS: Submit button title + // TRANS: Submit button title. 'save', _('Save')); } } diff --git a/lib/applicationlist.php b/lib/applicationlist.php index 904f8981d..8b6e3a8ad 100644 --- a/lib/applicationlist.php +++ b/lib/applicationlist.php @@ -1,5 +1,4 @@ <?php - /** * StatusNet, the distributed open-source microblogging tool * @@ -45,7 +44,6 @@ define('APPS_PER_PAGE', 20); * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class ApplicationList extends Widget { /** Current application, application query */ @@ -140,7 +138,7 @@ class ApplicationList extends Widget $access = ($this->application->access_type & Oauth_application::$writeAccess) ? $readWriteText : $readOnlyText; $modifiedDate = common_date_string($appUser->modified); - // TRANS: Used in application list. %1$s is a modified date, %2$s is access type (read-write or read-only) + // TRANS: Used in application list. %1$s is a modified date, %2$s is access type ("read-write" or "read-only") $txt = sprintf(_('Approved %1$s - "%2$s" access.'),$modifiedDate,$access); $this->out->raw($txt); @@ -164,10 +162,8 @@ class ApplicationList extends Widget } /* Override this in subclasses. */ - function showOwnerControls() { return; } - } diff --git a/lib/atom10feed.php b/lib/atom10feed.php index a46d49f35..3ae9dc81b 100644 --- a/lib/atom10feed.php +++ b/lib/atom10feed.php @@ -109,7 +109,7 @@ class Atom10Feed extends XMLStringer $xs->element('name', null, $name); } else { throw new Atom10FeedException( - 'author element must contain a name element.' + _('author element must contain a name element.') ); } @@ -323,5 +323,4 @@ class Atom10Feed extends XMLStringer array_push($this->links, $attrs); } - } diff --git a/lib/atomusernoticefeed.php b/lib/atomusernoticefeed.php index 785db4915..ec368f5ca 100644 --- a/lib/atomusernoticefeed.php +++ b/lib/atomusernoticefeed.php @@ -44,7 +44,7 @@ if (!defined('STATUSNET')) */ class AtomUserNoticeFeed extends AtomNoticeFeed { - private $user; + protected $user; /** * Constructor @@ -55,7 +55,6 @@ class AtomUserNoticeFeed extends AtomNoticeFeed * * @return void */ - function __construct($user, $cur = null, $indent = true) { parent::__construct($cur, $indent); $this->user = $user; @@ -90,7 +89,7 @@ class AtomUserNoticeFeed extends AtomNoticeFeed array('nickname' => $user->nickname) ) ); - + $self = common_local_url('ApiTimelineUser', array('id' => $user->id, 'format' => 'atom')); diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php index 59cab9532..f6b09fb49 100644 --- a/lib/attachmentlist.php +++ b/lib/attachmentlist.php @@ -49,7 +49,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { * @see NoticeListItem * @see ProfileNoticeList */ - class AttachmentList extends Widget { /** the current stream of notices being displayed. */ @@ -61,7 +60,6 @@ class AttachmentList extends Widget * * @param Notice $notice stream of notices from DB_DataObject */ - function __construct($notice, $out=null) { parent::__construct($out); @@ -76,7 +74,6 @@ class AttachmentList extends Widget * * @return int count of notices listed. */ - function show() { $atts = new File; @@ -111,7 +108,6 @@ class AttachmentList extends Widget * * @return NoticeListItem a list item for displaying the notice */ - function newListItem($attachment) { return new AttachmentListItem($attachment, $this->out); @@ -135,7 +131,6 @@ class AttachmentList extends Widget * @see NoticeList * @see ProfileNoticeListItem */ - class AttachmentListItem extends Widget { /** The attachment this item will show. */ @@ -151,7 +146,6 @@ class AttachmentListItem extends Widget * * @param Notice $notice The notice we'll display */ - function __construct($attachment, $out=null) { parent::__construct($out); @@ -185,7 +179,6 @@ class AttachmentListItem extends Widget * * @return void */ - function show() { $this->showStart(); @@ -221,7 +214,6 @@ class AttachmentListItem extends Widget * * @return void */ - function showStart() { // XXX: RDFa @@ -236,7 +228,6 @@ class AttachmentListItem extends Widget * * @return void */ - function showEnd() { $this->out->elementEnd('li'); @@ -257,7 +248,7 @@ class Attachment extends AttachmentListItem $this->out->elementEnd('div'); if (!empty($this->oembed->author_name) || !empty($this->oembed->provider)) { - $this->out->elementStart('div', array('id' => 'oembed_info', + $this->out->elementStart('div', array('id' => 'oembed_info', 'class' => 'entry-content')); if (!empty($this->oembed->author_name)) { $this->out->elementStart('dl', 'vcard author'); @@ -438,4 +429,3 @@ class Attachment extends AttachmentListItem $this->out->raw('<script>window.location = ' . json_encode($this->attachment->url) . ';</script>'); } } - diff --git a/lib/attachmentnoticesection.php b/lib/attachmentnoticesection.php index 578c171ff..25e64adf9 100644 --- a/lib/attachmentnoticesection.php +++ b/lib/attachmentnoticesection.php @@ -42,7 +42,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class AttachmentNoticeSection extends NoticeSection { function showContent() { @@ -59,11 +58,12 @@ class AttachmentNoticeSection extends NoticeSection $notice->orderBy('created desc'); $notice->selectAdd('post_id as id'); $notice->find(); - return $notice; + return $notice; } function title() { + // TRANS: Title. return _('Notices where this attachment appears'); } @@ -72,4 +72,3 @@ class AttachmentNoticeSection extends NoticeSection return 'popular_notices'; } } - diff --git a/lib/attachmenttagcloudsection.php b/lib/attachmenttagcloudsection.php index e2f85ae02..2c8fc5ee1 100644 --- a/lib/attachmenttagcloudsection.php +++ b/lib/attachmenttagcloudsection.php @@ -40,11 +40,11 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class AttachmentTagCloudSection extends TagCloudSection { function title() { + // TRANS: Title. return _('Tags for this attachment'); } @@ -80,4 +80,3 @@ class AttachmentTagCloudSection extends TagCloudSection return $notice_tag; } } - diff --git a/lib/authenticationplugin.php b/lib/authenticationplugin.php index dbdf20629..5e878c155 100644 --- a/lib/authenticationplugin.php +++ b/lib/authenticationplugin.php @@ -40,12 +40,11 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - abstract class AuthenticationPlugin extends Plugin { //is this plugin authoritative for authentication? public $authoritative = false; - + //should accounts be automatically created after a successful login attempt? public $autoregistration = false; @@ -218,12 +217,14 @@ abstract class AuthenticationPlugin extends Plugin //stop handling of other handlers, because what was requested was done return false; }else{ - throw new Exception(_('Password changing failed')); + // TRANS: Exception thrown when a password change fails. + throw new Exception(_('Password changing failed.')); } }else{ if($this->authoritative){ //since we're authoritative, no other plugin could do this - throw new Exception(_('Password changing failed')); + // TRANS: Exception thrown when a password change fails. + throw new Exception(_('Password changing failed.')); }else{ //let another handler try return null; @@ -233,7 +234,8 @@ abstract class AuthenticationPlugin extends Plugin }else{ if($this->authoritative){ //since we're authoritative, no other plugin could do this - throw new Exception(_('Password changing is not allowed')); + // TRANS: Exception thrown when a password change attempt fails because it is not allowed. + throw new Exception(_('Password changing is not allowed.')); } } } @@ -267,4 +269,3 @@ abstract class AuthenticationPlugin extends Plugin return true; } } - diff --git a/lib/authorizationplugin.php b/lib/authorizationplugin.php index d71f77243..dda604add 100644 --- a/lib/authorizationplugin.php +++ b/lib/authorizationplugin.php @@ -40,7 +40,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - abstract class AuthorizationPlugin extends Plugin { //is this plugin authoritative for authorization? @@ -103,4 +102,3 @@ abstract class AuthorizationPlugin extends Plugin } } } - diff --git a/lib/blockform.php b/lib/blockform.php index b6652b1f6..1af5e8cfd 100644 --- a/lib/blockform.php +++ b/lib/blockform.php @@ -44,7 +44,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { * * @see UnblockForm */ - class BlockForm extends ProfileActionForm { /** @@ -63,9 +62,9 @@ class BlockForm extends ProfileActionForm * * @return string Title of the form, internationalized */ - function title() { + // TRANS: Title for the form to block a user. return _('Block'); } @@ -74,9 +73,9 @@ class BlockForm extends ProfileActionForm * * @return string description of the form, internationalized */ - function description() { + // TRANS: Description of the form to block a user. return _('Block this user'); } } diff --git a/lib/cache.php b/lib/cache.php index 17cc5f047..3d78c79ad 100644 --- a/lib/cache.php +++ b/lib/cache.php @@ -41,7 +41,6 @@ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ - class Cache { var $_items = array(); @@ -56,7 +55,6 @@ class Cache * * @return Cache cache object */ - static function instance() { if (is_null(self::$_inst)) { @@ -77,7 +75,6 @@ class Cache * * @return string full key */ - static function key($extra) { $base_key = common_config('cache', 'base'); @@ -98,7 +95,6 @@ class Cache * * @return string keyized string */ - static function keyize($str) { $str = strtolower($str); @@ -115,7 +111,6 @@ class Cache * * @return string retrieved value or null if unfound */ - function get($key) { $value = false; @@ -140,7 +135,6 @@ class Cache * * @return boolean success flag */ - function set($key, $value, $flag=null, $expiry=null) { $success = false; @@ -192,7 +186,6 @@ class Cache * * @return boolean success flag */ - function delete($key) { $success = false; @@ -214,7 +207,6 @@ class Cache * * @return boolean success flag */ - function reconnect() { $success = false; diff --git a/lib/channel.php b/lib/channel.php index 5b38a4b6a..ae9b2d214 100644 --- a/lib/channel.php +++ b/lib/channel.php @@ -19,6 +19,9 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } +/** + * @todo Needs documentation. + */ class Channel { function on($user) @@ -97,6 +100,7 @@ class WebChannel extends Channel # depending on what command was run $this->out->startHTML(); $this->out->elementStart('head'); + // TRANS: Title for command results. $this->out->element('title', null, _('Command results')); $this->out->elementEnd('head'); $this->out->elementStart('body'); @@ -117,6 +121,7 @@ class AjaxWebChannel extends WebChannel { $this->out->startHTML('text/xml;charset=utf-8'); $this->out->elementStart('head'); + // TRANS: Title for command results. $this->out->element('title', null, _('Command results')); $this->out->elementEnd('head'); $this->out->elementStart('body'); @@ -129,7 +134,8 @@ class AjaxWebChannel extends WebChannel { $this->out->startHTML('text/xml;charset=utf-8'); $this->out->elementStart('head'); - $this->out->element('title', null, _('Ajax Error')); + // TRANS: Title for command results. + $this->out->element('title', null, _('AJAX error')); $this->out->elementEnd('head'); $this->out->elementStart('body'); $this->out->element('p', array('id' => 'error'), $text); @@ -140,7 +146,6 @@ class AjaxWebChannel extends WebChannel class MailChannel extends Channel { - var $addr = null; function source() @@ -165,10 +170,10 @@ class MailChannel extends Channel function output($user, $text) { - $headers['From'] = $user->incomingemail; $headers['To'] = $this->addr; + // TRANS: E-mail subject when a command has completed. $headers['Subject'] = _('Command complete'); return mail_send(array($this->addr), $headers, $text); @@ -176,10 +181,10 @@ class MailChannel extends Channel function error($user, $text) { - $headers['From'] = $user->incomingemail; $headers['To'] = $this->addr; + // TRANS: E-mail subject when a command has failed. $headers['Subject'] = _('Command failed'); return mail_send(array($this->addr), $headers, $text); diff --git a/lib/clienterroraction.php b/lib/clienterroraction.php index 1b98a1064..08bced5bd 100644 --- a/lib/clienterroraction.php +++ b/lib/clienterroraction.php @@ -1,5 +1,4 @@ <?php - /** * Client error action. * diff --git a/lib/clientexception.php b/lib/clientexception.php index 01c013a01..a74cab4a5 100644 --- a/lib/clientexception.php +++ b/lib/clientexception.php @@ -42,7 +42,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class ClientException extends Exception { public function __construct($message = null, $code = 400) { diff --git a/lib/columndef.php b/lib/columndef.php index ac2fcd23e..b21b30e0d 100644 --- a/lib/columndef.php +++ b/lib/columndef.php @@ -40,7 +40,6 @@ if (!defined('STATUSNET')) { * @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. */ @@ -76,7 +75,6 @@ class ColumnDef * @param value $extra unused * @param boolean $auto_increment */ - function __construct($name=null, $type=null, $size=null, $nullable=true, $key=null, $default=null, $extra=null, $auto_increment=false) @@ -99,7 +97,6 @@ class ColumnDef * * @return boolean true if equivalent, otherwise false. */ - function equals($other) { return ($this->name == $other->name && @@ -122,7 +119,6 @@ class ColumnDef * * @return boolean true if they're about equivalent */ - private function _typeMatch($other) { switch ($this->type) { @@ -145,7 +141,6 @@ class ColumnDef * * @return boolean true if defaults are effectively the same. */ - private function _defaultMatch($other) { return ((is_null($this->default) && is_null($other->default)) || @@ -160,7 +155,6 @@ class ColumnDef * * @return boolean true if these columns 'null' the same. */ - private function _nullMatch($other) { return ((!is_null($this->default) && !is_null($other->default) && diff --git a/lib/command.php b/lib/command.php index 90a321ad3..efe917fb1 100644 --- a/lib/command.php +++ b/lib/command.php @@ -23,7 +23,6 @@ require_once(INSTALLDIR.'/lib/channel.php'); class Command { - var $user = null; function __construct($user=null) @@ -49,7 +48,6 @@ class Command } } - /** * Override this with the meat! * @@ -313,7 +311,6 @@ class FavCommand extends Command // TRANS: Text shown when a notice has been marked as favourite successfully. $channel->output($this->user, _('Notice marked as fave.')); } - } class JoinCommand extends Command @@ -361,8 +358,8 @@ class JoinCommand extends Command $cur->nickname, $group->nickname)); } - } + class DropCommand extends Command { var $other = null; @@ -409,7 +406,6 @@ class DropCommand extends Command $cur->nickname, $group->nickname)); } - } class WhoisCommand extends Command @@ -471,6 +467,7 @@ class MessageCommand extends Command throw $e; } // TRANS: Command exception text shown when trying to send a direct message to a remote user (a user not registered at the current server). + // TRANS: %s is a remote profile. throw new CommandException(sprintf(_('%s is a remote profile; you can only send direct messages to users on the same server.'), $this->other)); } @@ -611,7 +608,6 @@ class ReplyCommand extends Command class GetCommand extends Command { - var $other = null; function __construct($user, $other) @@ -638,7 +634,6 @@ class GetCommand extends Command class SubCommand extends Command { - var $other = null; function __construct($user, $other) @@ -678,7 +673,6 @@ class SubCommand extends Command class UnsubCommand extends Command { - var $other = null; function __construct($user, $other) @@ -712,6 +706,7 @@ class UnsubCommand extends Command class OffCommand extends Command { var $other = null; + function __construct($user, $other=null) { parent::__construct($user); @@ -831,7 +826,7 @@ class SubscriptionsCommand extends Command $out=_('You are not subscribed to anyone.'); }else{ // TRANS: Text shown after requesting other users a user is subscribed to. - // TRANS: This message support plural forms. This message is followed by a + // TRANS: This message supports plural forms. This message is followed by a // TRANS: hard coded space and a comma separated list of subscribed users. $out = ngettext('You are subscribed to this person:', 'You are subscribed to these people:', @@ -858,7 +853,7 @@ class SubscribersCommand extends Command $out=_('No one is subscribed to you.'); }else{ // TRANS: Text shown after requesting other users that are subscribed to a user (followers). - // TRANS: This message support plural forms. This message is followed by a + // TRANS: This message supports plural forms. This message is followed by a // TRANS: hard coded space and a comma separated list of subscribing users. $out = ngettext('This person is subscribed to you:', 'These people are subscribed to you:', @@ -885,7 +880,7 @@ class GroupsCommand extends Command $out=_('You are not a member of any groups.'); }else{ // TRANS: Text shown after requesting groups a user is subscribed to. - // TRANS: This message support plural forms. This message is followed by a + // TRANS: This message supports plural forms. This message is followed by a // TRANS: hard coded space and a comma separated list of subscribed groups. $out = ngettext('You are a member of this group:', 'You are a member of these groups:', @@ -900,8 +895,8 @@ class HelpCommand extends Command { function handle($channel) { - // TRANS: Help text for commands. $channel->output($this->user, + // TRANS: Help text for commands. Do not translate the command names themselves; they are fixed strings. _("Commands:\n". "on - turn on notifications\n". "off - turn off notifications\n". diff --git a/lib/commandinterpreter.php b/lib/commandinterpreter.php index fbc6174bb..c288c2e5f 100644 --- a/lib/commandinterpreter.php +++ b/lib/commandinterpreter.php @@ -272,7 +272,7 @@ class CommandInterpreter return false; } } - + /** * Split arguments without triggering a PHP notice warning */ @@ -285,4 +285,3 @@ class CommandInterpreter return $pieces; } } - diff --git a/lib/common.php b/lib/common.php index 0a0f5c631..2a11ab722 100644 --- a/lib/common.php +++ b/lib/common.php @@ -150,11 +150,17 @@ try { } catch (NoConfigException $e) { // XXX: Throw a conniption if database not installed // XXX: Find a way to use htmlwriter for this instead of handcoded markup + // TRANS: Error message displayed when no configuration file was found for a StatusNet installation. echo '<p>'. _('No configuration file found. ') .'</p>'; - echo '<p>'. _('I looked for configuration files in the following places: ') .'<br/> '; - echo implode($e->configFiles, '<br/>'); + // TRANS: Error message displayed when no configuration file was found for a StatusNet installation. + // TRANS: Is followed by a list of directories (separated by HTML breaks). + echo '<p>'. _('I looked for configuration files in the following places: ') .'<br /> '; + echo implode($e->configFiles, '<br />'); + // TRANS: Error message displayed when no configuration file was found for a StatusNet installation. echo '<p>'. _('You may wish to run the installer to fix this.') .'</p>'; + // @todo FIXME Link should be in a para? + // TRANS: Error message displayed when no configuration file was found for a StatusNet installation. + // TRANS: The text is link text that leads to the installer page. echo '<a href="install.php">'. _('Go to the installer.') .'</a>'; exit; } - diff --git a/lib/connectsettingsaction.php b/lib/connectsettingsaction.php index 5d62fc56b..c2e759f0f 100644 --- a/lib/connectsettingsaction.php +++ b/lib/connectsettingsaction.php @@ -44,7 +44,6 @@ require_once INSTALLDIR.'/lib/settingsaction.php'; * * @see Widget */ - class ConnectSettingsAction extends SettingsAction { /** @@ -54,7 +53,6 @@ class ConnectSettingsAction extends SettingsAction * * @return void */ - function showLocalNav() { $menu = new ConnectSettingsNav($this); @@ -73,7 +71,6 @@ class ConnectSettingsAction extends SettingsAction * * @see HTMLOutputter */ - class ConnectSettingsNav extends Widget { var $action = null; @@ -83,7 +80,6 @@ class ConnectSettingsNav extends Widget * * @param Action $action current action, used for output */ - function __construct($action=null) { parent::__construct($action); @@ -95,7 +91,6 @@ class ConnectSettingsNav extends Widget * * @return void */ - function show() { $action_name = $this->action->trimmed('action'); @@ -109,17 +104,23 @@ class ConnectSettingsNav extends Widget Event::handle('GetImTransports', array(&$transports)); if ($transports) { $menu['imsettings'] = - array(_('IM'), + // TRANS: Menu item for Instant Messaging settings. + array(_m('MENU','IM'), + // TRANS: Tooltip for Instant Messaging menu item. _('Updates by instant messenger (IM)')); } if (common_config('sms', 'enabled')) { $menu['smssettings'] = - array(_('SMS'), + // TRANS: Menu item for Short Message Service settings. + array(_m('MENU','SMS'), + // TRANS: Tooltip for Short Message Service menu item. _('Updates by SMS')); } - + $menu['oauthconnectionssettings'] = array( - _('Connections'), + // TRANS: Menu item for OAth connection settings. + _m('MENU','Connections'), + // TRANS: Tooltip for connected applications (Connections through OAth) menu item. _('Authorized connected applications') ); @@ -135,6 +136,4 @@ class ConnectSettingsNav extends Widget $this->action->elementEnd('ul'); } - } - diff --git a/lib/currentuserdesignaction.php b/lib/currentuserdesignaction.php index c2f38cd00..490f87d13 100644 --- a/lib/currentuserdesignaction.php +++ b/lib/currentuserdesignaction.php @@ -44,7 +44,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { * @link http://status.net/ * */ - class CurrentUserDesignAction extends Action { /** @@ -54,7 +53,6 @@ class CurrentUserDesignAction extends Action * * @return Design a design object to use */ - function getDesign() { $cur = common_current_user(); diff --git a/lib/dbqueuemanager.php b/lib/dbqueuemanager.php index 3dda9fd1a..51553b899 100644 --- a/lib/dbqueuemanager.php +++ b/lib/dbqueuemanager.php @@ -100,7 +100,7 @@ class DBQueueManager extends QueueManager } } else { $this->_log(LOG_INFO, "[$queue] Got empty/deleted item, discarding"); - $this->_fail($qi); + $this->_done($qi); } return true; } diff --git a/lib/default.php b/lib/default.php index 76e4e44cf..79b54fc3b 100644 --- a/lib/default.php +++ b/lib/default.php @@ -299,10 +299,11 @@ $default = 'RSSCloud' => null, 'ClientSideShorten' => null, 'OpenID' => null), + 'locale_path' => false, // Set to a path to use *instead of* each plugin's own locale subdirectories ), 'pluginlist' => array(), 'admin' => - array('panels' => array('design', 'site', 'user', 'paths', 'access', 'sessions', 'sitenotice', 'plugins')), + array('panels' => array('design', 'site', 'user', 'paths', 'access', 'sessions', 'sitenotice', 'license', 'plugins')), 'singleuser' => array('enabled' => false, 'nickname' => null), diff --git a/lib/disfavorform.php b/lib/disfavorform.php index 5b135b38a..6023766d7 100644 --- a/lib/disfavorform.php +++ b/lib/disfavorform.php @@ -123,9 +123,13 @@ class DisfavorForm extends Form function formData() { - $this->out->hidden('notice-n'.$this->notice->id, - $this->notice->id, - 'notice'); + if (Event::handle('StartDisFavorNoticeForm', array($this, $this->notice))) { + $this->out->hidden('notice-n'.$this->notice->id, + $this->notice->id, + 'notice'); + Event::handle('EndDisFavorNoticeForm', array($this, $this->notice)); + } + } /** diff --git a/lib/distribqueuehandler.php b/lib/distribqueuehandler.php index 8f4b72d5c..a7519c1d5 100644 --- a/lib/distribqueuehandler.php +++ b/lib/distribqueuehandler.php @@ -78,13 +78,19 @@ class DistribQueueHandler } try { + Event::handle('EndNoticeDistribute', array($notice)); + } catch (Exception $e) { + $this->logit($notice, $e); + } + + try { Event::handle('EndNoticeSave', array($notice)); - // Enqueue for other handlers } catch (Exception $e) { $this->logit($notice, $e); } try { + // Enqueue for other handlers common_enqueue_notice($notice); } catch (Exception $e) { $this->logit($notice, $e); diff --git a/lib/favorform.php b/lib/favorform.php index 625df7c8b..4e2891ffd 100644 --- a/lib/favorform.php +++ b/lib/favorform.php @@ -123,9 +123,12 @@ class FavorForm extends Form function formData() { - $this->out->hidden('notice-n'.$this->notice->id, - $this->notice->id, - 'notice'); + if (Event::handle('StartFavorNoticeForm', array($this, $this->notice))) { + $this->out->hidden('notice-n'.$this->notice->id, + $this->notice->id, + 'notice'); + Event::handle('EndFavorNoticeForm', array($this, $this->notice)); + } } /** diff --git a/lib/feedlist.php b/lib/feedlist.php index 9ae83f5e8..4aacf0b3d 100644 --- a/lib/feedlist.php +++ b/lib/feedlist.php @@ -59,42 +59,50 @@ class FeedList extends Widget function show($feeds) { - $this->out->elementStart('div', array('id' => 'export_data', - 'class' => 'section')); - $this->out->element('h2', null, _('Export data')); - $this->out->elementStart('ul', array('class' => 'xoxo')); + if (Event::handle('StartShowFeedLinkList', array($this->action, &$feeds))) { + if (!empty($feeds)) { + $this->out->elementStart('div', array('id' => 'export_data', + 'class' => 'section')); + $this->out->element('h2', null, _('Feeds')); + $this->out->elementStart('ul', array('class' => 'xoxo')); - foreach ($feeds as $feed) { - $this->feedItem($feed); - } + foreach ($feeds as $feed) { + $this->feedItem($feed); + } - $this->out->elementEnd('ul'); - $this->out->elementEnd('div'); + $this->out->elementEnd('ul'); + $this->out->elementEnd('div'); + } + Event::handle('EndShowFeedLinkList', array($this->action, &$feeds)); + } } function feedItem($feed) { - $classname = null; + if (Event::handle('StartShowFeedLink', array($this->action, &$feed))) { + $classname = null; - switch ($feed->type) { - case Feed::RSS1: - case Feed::RSS2: - $classname = 'rss'; - break; - case Feed::ATOM: - $classname = 'atom'; - break; - case Feed::FOAF: - $classname = 'foaf'; - break; - } + switch ($feed->type) { + case Feed::RSS1: + case Feed::RSS2: + $classname = 'rss'; + break; + case Feed::ATOM: + $classname = 'atom'; + break; + case Feed::FOAF: + $classname = 'foaf'; + break; + } - $this->out->elementStart('li'); - $this->out->element('a', array('href' => $feed->url, - 'class' => $classname, - 'type' => $feed->mimeType(), - 'title' => $feed->title), - $feed->typeName()); - $this->out->elementEnd('li'); + $this->out->elementStart('li'); + $this->out->element('a', array('href' => $feed->url, + 'class' => $classname, + 'type' => $feed->mimeType(), + 'title' => $feed->title), + $feed->typeName()); + $this->out->elementEnd('li'); + Event::handle('EndShowFeedLink', array($this->action, $feed)); + } } } diff --git a/lib/groupnav.php b/lib/groupnav.php index 131b38fa2..ee988d0a9 100644 --- a/lib/groupnav.php +++ b/lib/groupnav.php @@ -82,14 +82,20 @@ class GroupNav extends Widget if (Event::handle('StartGroupGroupNav', array($this))) { $this->out->menuItem(common_local_url('showgroup', array('nickname' => $nickname)), - _('Group'), - sprintf(_('%s group'), $nickname), + // TRANS: Menu item in the group navigation page. + _m('MENU','Group'), + // TRANS: Tooltip for menu item in the group navigation page. + // TRANS: %s is the nickname of the group. + sprintf(_m('TOOLTIP','%s group'), $nickname), $action_name == 'showgroup', 'nav_group_group'); $this->out->menuItem(common_local_url('groupmembers', array('nickname' => $nickname)), - _('Members'), - sprintf(_('%s group members'), $nickname), + // TRANS: Menu item in the group navigation page. + _m('MENU','Members'), + // TRANS: Tooltip for menu item in the group navigation page. + // TRANS: %s is the nickname of the group. + sprintf(_m('TOOLTIP','%s group members'), $nickname), $action_name == 'groupmembers', 'nav_group_members'); @@ -98,26 +104,38 @@ class GroupNav extends Widget if ($cur && $cur->isAdmin($this->group)) { $this->out->menuItem(common_local_url('blockedfromgroup', array('nickname' => $nickname)), - _('Blocked'), - sprintf(_('%s blocked users'), $nickname), + // TRANS: Menu item in the group navigation page. Only shown for group administrators. + _m('MENU','Blocked'), + // TRANS: Tooltip for menu item in the group navigation page. Only shown for group administrators. + // TRANS: %s is the nickname of the group. + sprintf(_m('TOOLTIP','%s blocked users'), $nickname), $action_name == 'blockedfromgroup', 'nav_group_blocked'); $this->out->menuItem(common_local_url('editgroup', array('nickname' => $nickname)), - _('Admin'), - sprintf(_('Edit %s group properties'), $nickname), + // TRANS: Menu item in the group navigation page. Only shown for group administrators. + _m('MENU','Admin'), + // TRANS: Tooltip for menu item in the group navigation page. Only shown for group administrators. + // TRANS: %s is the nickname of the group. + sprintf(_m('TOOLTIP','Edit %s group properties'), $nickname), $action_name == 'editgroup', 'nav_group_admin'); $this->out->menuItem(common_local_url('grouplogo', array('nickname' => $nickname)), - _('Logo'), - sprintf(_('Add or edit %s logo'), $nickname), + // TRANS: Menu item in the group navigation page. Only shown for group administrators. + _m('MENU','Logo'), + // TRANS: Tooltip for menu item in the group navigation page. Only shown for group administrators. + // TRANS: %s is the nickname of the group. + sprintf(_m('TOOLTIP','Add or edit %s logo'), $nickname), $action_name == 'grouplogo', 'nav_group_logo'); $this->out->menuItem(common_local_url('groupdesignsettings', array('nickname' => $nickname)), - _('Design'), - sprintf(_('Add or edit %s design'), $nickname), + // TRANS: Menu item in the group navigation page. Only shown for group administrators. + _m('MENU','Design'), + // TRANS: Tooltip for menu item in the group navigation page. Only shown for group administrators. + // TRANS: %s is the nickname of the group. + sprintf(_m('TOOLTIP','Add or edit %s design'), $nickname), $action_name == 'groupdesignsettings', 'nav_group_design'); } diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index 7eccd6cc0..9780dc424 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -325,6 +325,7 @@ class HTMLOutputter extends XMLOutputter * @param string $label text of the button * @param string $cls class of the button, default 'submit' * @param string $name name, if different than ID + * @param string $title title text for the submit button * * @return void * diff --git a/lib/language.php b/lib/language.php index 12b56be9a..86896cff9 100644 --- a/lib/language.php +++ b/lib/language.php @@ -322,6 +322,7 @@ function get_all_languages() { 'gl' => array('q' => 0.8, 'lang' => 'gl', 'name' => 'Galician', 'direction' => 'ltr'), 'he' => array('q' => 0.5, 'lang' => 'he', 'name' => 'Hebrew', 'direction' => 'rtl'), 'hsb' => array('q' => 0.8, 'lang' => 'hsb', 'name' => 'Upper Sorbian', 'direction' => 'ltr'), + 'hu' => array('q' => 0.8, 'lang' => 'hu', 'name' => 'Hungarian', 'direction' => 'ltr'), 'ia' => array('q' => 0.8, 'lang' => 'ia', 'name' => 'Interlingua', 'direction' => 'ltr'), 'is' => array('q' => 0.1, 'lang' => 'is', 'name' => 'Icelandic', 'direction' => 'ltr'), 'it' => array('q' => 1, 'lang' => 'it', 'name' => 'Italian', 'direction' => 'ltr'), diff --git a/lib/mediafile.php b/lib/mediafile.php index c96c78ab5..23338cc0e 100644 --- a/lib/mediafile.php +++ b/lib/mediafile.php @@ -95,6 +95,7 @@ class MediaFile if (!$file_id) { common_log_db_error($file, "INSERT", __FILE__); + // TRANS: Client exception thrown when a database error was thrown during a file upload operation. throw new ClientException(_('There was a database error while saving your file. Please try again.')); } @@ -120,6 +121,7 @@ class MediaFile if (!$result) { common_log_db_error($file_redir, "INSERT", __FILE__); + // TRANS: Client exception thrown when a database error was thrown during a file upload operation. throw new ClientException(_('There was a database error while saving your file. Please try again.')); } } @@ -139,16 +141,19 @@ class MediaFile case UPLOAD_ERR_OK: // success, jump out break; case UPLOAD_ERR_INI_SIZE: + // TRANS: Client exception thrown when an uploaded file is larger than set in php.ini. throw new ClientException(_('The uploaded file exceeds the ' . 'upload_max_filesize directive in php.ini.')); return; case UPLOAD_ERR_FORM_SIZE: throw new ClientException( + // TRANS: Client exception. _('The uploaded file exceeds the MAX_FILE_SIZE directive' . ' that was specified in the HTML form.')); return; case UPLOAD_ERR_PARTIAL: @unlink($_FILES[$param]['tmp_name']); + // TRANS: Client exception. throw new ClientException(_('The uploaded file was only' . ' partially uploaded.')); return; @@ -156,17 +161,21 @@ class MediaFile // No file; probably just a non-AJAX submission. return; case UPLOAD_ERR_NO_TMP_DIR: + // TRANS: Client exception thrown when a temporary folder is not present to store a file upload. throw new ClientException(_('Missing a temporary folder.')); return; case UPLOAD_ERR_CANT_WRITE: + // TRANS: Client exception thrown when writing to disk is not possible during a file upload operation. throw new ClientException(_('Failed to write file to disk.')); return; case UPLOAD_ERR_EXTENSION: + // TRANS: Client exception thrown when a file upload operation has been stopped by an extension. throw new ClientException(_('File upload stopped by extension.')); return; default: common_log(LOG_ERR, __METHOD__ . ": Unknown upload error " . $_FILES[$param]['error']); + // TRANS: Client exception thrown when a file upload operation has failed with an unknown reason. throw new ClientException(_('System error uploading file.')); return; } @@ -176,6 +185,7 @@ class MediaFile // Should never actually get here @unlink($_FILES[$param]['tmp_name']); + // TRANS: Client exception thrown when a file upload operation would cause a user to exceed a set quota. throw new ClientException(_('File exceeds user\'s quota.')); return; } @@ -194,11 +204,15 @@ class MediaFile $result = move_uploaded_file($_FILES[$param]['tmp_name'], $filepath); if (!$result) { + // TRANS: Client exception thrown when a file upload operation fails because the file could + // TRANS: not be moved from the temporary folder to the permanent file location. throw new ClientException(_('File could not be moved to destination directory.')); return; } } else { + // TRANS: Client exception thrown when a file upload operation has been stopped because the MIME + // TRANS: type of the uploaded file could not be determined. throw new ClientException(_('Could not determine file\'s MIME type.')); return; } @@ -214,6 +228,7 @@ class MediaFile // Should never actually get here + // TRANS: Client exception thrown when a file upload operation would cause a user to exceed a set quota. throw new ClientException(_('File exceeds user\'s quota.')); return; } @@ -231,10 +246,14 @@ class MediaFile $result = copy($stream['uri'], $filepath) && chmod($filepath, 0664); if (!$result) { + // TRANS: Client exception thrown when a file upload operation fails because the file could + // TRANS: not be moved from the temporary folder to the permanent file location. throw new ClientException(_('File could not be moved to destination directory.' . $stream['uri'] . ' ' . $filepath)); } } else { + // TRANS: Client exception thrown when a file upload operation has been stopped because the MIME + // TRANS: type of the uploaded file could not be determined. throw new ClientException(_('Could not determine file\'s MIME type.')); return; } @@ -315,12 +334,17 @@ class MediaFile } $media = MIME_Type::getMedia($filetype); if ('application' !== $media) { - $hint = sprintf(_(' Try using another %s format.'), $media); + // TRANS: Client exception thrown trying to upload a forbidden MIME type. + // TRANS: %1$s is the file type that was denied, %2$s is the application part of + // TRANS: the MIME type that was denied. + $hint = sprintf(_('"%1$s" is not a supported file type on this server. ' . + 'Try using another %2$s format.'), $filetype, $media); } else { - $hint = ''; + // TRANS: Client exception thrown trying to upload a forbidden MIME type. + // TRANS: %s is the file type that was denied. + $hint = sprintf(_('"%s" is not a supported file type on this server.'), $filetype); } - throw new ClientException(sprintf( - _('%s is not a supported file type on this server.'), $filetype) . $hint); + throw new ClientException($hint); } static function respectsQuota($user, $filesize) diff --git a/lib/noticelist.php b/lib/noticelist.php index 529d6a3f9..df1533980 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -226,24 +226,31 @@ class NoticeListItem extends Widget function showNoticeInfo() { $this->out->elementStart('div', 'entry-content'); - $this->showNoticeLink(); - $this->showNoticeSource(); - $this->showNoticeLocation(); - $this->showContext(); - $this->showRepeat(); + if (Event::handle('StartShowNoticeInfo', array($this))) { + $this->showNoticeLink(); + $this->showNoticeSource(); + $this->showNoticeLocation(); + $this->showContext(); + $this->showRepeat(); + Event::handle('EndShowNoticeInfo', array($this)); + } + $this->out->elementEnd('div'); } function showNoticeOptions() { - $user = common_current_user(); - if ($user) { - $this->out->elementStart('div', 'notice-options'); - $this->showFaveForm(); - $this->showReplyLink(); - $this->showRepeatForm(); - $this->showDeleteLink(); - $this->out->elementEnd('div'); + if (Event::handle('StartShowNoticeOptions', array($this))) { + $user = common_current_user(); + if ($user) { + $this->out->elementStart('div', 'notice-options'); + $this->showFaveForm(); + $this->showReplyLink(); + $this->showRepeatForm(); + $this->showDeleteLink(); + $this->out->elementEnd('div'); + } + Event::handle('EndShowNoticeOptions', array($this)); } } @@ -270,15 +277,18 @@ class NoticeListItem extends Widget function showFaveForm() { - $user = common_current_user(); - if ($user) { - if ($user->hasFave($this->notice)) { - $disfavor = new DisfavorForm($this->out, $this->notice); - $disfavor->show(); - } else { - $favor = new FavorForm($this->out, $this->notice); - $favor->show(); + if (Event::handle('StartShowFaveForm', array($this))) { + $user = common_current_user(); + if ($user) { + if ($user->hasFave($this->notice)) { + $disfavor = new DisfavorForm($this->out, $this->notice); + $disfavor->show(); + } else { + $favor = new FavorForm($this->out, $this->notice); + $favor->show(); + } } + Event::handle('EndShowFaveForm', array($this)); } } diff --git a/lib/oauthstore.php b/lib/oauthstore.php index a6a6de750..f3ee629fd 100644 --- a/lib/oauthstore.php +++ b/lib/oauthstore.php @@ -280,7 +280,7 @@ class StatusNetOAuthDataStore extends OAuthDataStore $profile->created = DB_DataObject_Cast::dateTime(); # current time $id = $profile->insert(); if (!$id) { - throw new Exception(_('Error inserting new profile')); + throw new Exception(_('Error inserting new profile.')); } $remote->id = $id; } @@ -288,7 +288,7 @@ class StatusNetOAuthDataStore extends OAuthDataStore $avatar_url = $omb_profile->getAvatarURL(); if ($avatar_url) { if (!$this->add_avatar($profile, $avatar_url)) { - throw new Exception(_('Error inserting avatar')); + throw new Exception(_('Error inserting avatar.')); } } else { $avatar = $profile->getOriginalAvatar(); @@ -303,12 +303,12 @@ class StatusNetOAuthDataStore extends OAuthDataStore if ($exists) { if (!$remote->update($orig_remote)) { - throw new Exception(_('Error updating remote profile')); + throw new Exception(_('Error updating remote profile.')); } } else { $remote->created = DB_DataObject_Cast::dateTime(); # current time if (!$remote->insert()) { - throw new Exception(_('Error inserting remote profile')); + throw new Exception(_('Error inserting remote profile.')); } } } @@ -342,7 +342,8 @@ class StatusNetOAuthDataStore extends OAuthDataStore **/ public function saveNotice(&$omb_notice) { if (Notice::staticGet('uri', $omb_notice->getIdentifierURI())) { - throw new Exception(_('Duplicate notice')); + // TRANS: Exception thrown when a notice is denied because it has been sent before. + throw new Exception(_('Duplicate notice.')); } $author_uri = $omb_notice->getAuthor()->getIdentifierURI(); common_log(LOG_DEBUG, $author_uri, __FILE__); diff --git a/lib/plugin.php b/lib/plugin.php index f63bdf309..3f84afa27 100644 --- a/lib/plugin.php +++ b/lib/plugin.php @@ -88,7 +88,12 @@ class Plugin $class = get_class($this); if (substr($class, -6) == 'Plugin') { $name = substr($class, 0, -6); - $path = INSTALLDIR . "/plugins/$name/locale"; + $path = common_config('plugins', 'locale_path'); + if (!$path) { + // @fixme this will fail for things installed in local/plugins + // ... but then so will web links so far. + $path = INSTALLDIR . "/plugins/$name/locale"; + } if (file_exists($path) && is_dir($path)) { bindtextdomain($name, $path); bind_textdomain_codeset($name, 'UTF-8'); @@ -112,9 +117,9 @@ class Plugin $name = mb_substr($cls, 0, -6); $versions[] = array('name' => $name, + // TRANS: Displayed as version information for a plugin if no version information was found. 'version' => _('Unknown')); return true; } } - diff --git a/lib/router.php b/lib/router.php index 30f6c8cdc..86f4fa02a 100644 --- a/lib/router.php +++ b/lib/router.php @@ -490,19 +490,19 @@ class Router // Social graph $m->connect('api/friends/ids/:id.:format', - array('action' => 'apiuserfriends', + array('action' => 'ApiUserFriends', 'ids_only' => true)); $m->connect('api/followers/ids/:id.:format', - array('action' => 'apiuserfollowers', + array('action' => 'ApiUserFollowers', 'ids_only' => true)); $m->connect('api/friends/ids.:format', - array('action' => 'apiuserfriends', + array('action' => 'ApiUserFriends', 'ids_only' => true)); $m->connect('api/followers/ids.:format', - array('action' => 'apiuserfollowers', + array('action' => 'ApiUserFollowers', 'ids_only' => true)); // account @@ -680,13 +680,13 @@ class Router $m->connect('api/trends.json', array('action' => 'ApiTrends')); $m->connect('api/oauth/request_token', - array('action' => 'apioauthrequesttoken')); + array('action' => 'ApiOauthRequestToken')); $m->connect('api/oauth/access_token', - array('action' => 'apioauthaccesstoken')); + array('action' => 'ApiOauthAccessToken')); $m->connect('api/oauth/authorize', - array('action' => 'apioauthauthorize')); + array('action' => 'ApiOauthAuthorize')); // Admin @@ -698,6 +698,7 @@ class Router $m->connect('admin/sessions', array('action' => 'sessionsadminpanel')); $m->connect('admin/sitenotice', array('action' => 'sitenoticeadminpanel')); $m->connect('admin/snapshot', array('action' => 'snapshotadminpanel')); + $m->connect('admin/license', array('action' => 'licenseadminpanel')); $m->connect('admin/plugins', array('action' => 'pluginsadminpanel')); $m->connect('admin/plugins/enable/:plugin', array('action' => 'pluginenable'), diff --git a/lib/searchaction.php b/lib/searchaction.php index bb71a2ba1..14c3ed016 100644 --- a/lib/searchaction.php +++ b/lib/searchaction.php @@ -117,14 +117,17 @@ class SearchAction extends Action 'class' => 'form_settings', 'action' => common_local_url($this->trimmed('action')))); $this->elementStart('fieldset'); + // TRANS: Fieldset legend for the search form. $this->element('legend', null, _('Search site')); $this->elementStart('ul', 'form_data'); $this->elementStart('li'); if (!common_config('site', 'fancy')) { $this->hidden('action', $this->trimmed('action')); } + // TRANS: Used as a field label for the field where one or more keywords + // TRANS: for searching can be entered. $this->input('q', _('Keyword(s)'), $q); - $this->submit('search', _('Search')); + $this->submit('search', _m('BUTTON','Search')); $this->elementEnd('li'); $this->elementEnd('ul'); $this->elementEnd('fieldset'); @@ -135,6 +138,8 @@ class SearchAction extends Action } function searchSuggestions($q) { + // @todo FIXME: This formatting does not make this string get picked up by gettext. + // TRANS: Standard search suggestions shown when a search does not give any results. $message = _(<<<E_O_T * Make sure all words are spelled correctly. * Try different keywords. @@ -145,6 +150,8 @@ E_O_T ); if (!common_config('site', 'private')) { $qe = urlencode($q); + // @todo FIXME: This formatting does not make this string get picked up by gettext. + // TRANS: Standard search suggestions shown when a search does not give any results. $message .= sprintf(_(<<<E_O_T You can also try your search on other engines: @@ -159,6 +166,7 @@ E_O_T ), $qe, $qe, $qe, $qe, $qe); } $this->elementStart('dl', array('id' => 'help_search', 'class' => 'help')); + // TRANS: Definition list item with instructions on how to get (better) search results. $this->element('dt', null, _('Search help')); $this->elementStart('dd', 'instructions'); $this->raw(common_markup_to_html($message)); @@ -166,4 +174,3 @@ E_O_T $this->elementEnd('div'); } } - diff --git a/lib/unblockform.php b/lib/unblockform.php index 2a444f7cd..b89d7ff78 100644 --- a/lib/unblockform.php +++ b/lib/unblockform.php @@ -66,6 +66,7 @@ class UnblockForm extends ProfileActionForm function title() { + // TRANS: Title for the form to unblock a user. return _('Unblock'); } @@ -77,6 +78,7 @@ class UnblockForm extends ProfileActionForm function description() { + // TRANS: Description of the form to unblock a user. return _('Unblock this user'); } } diff --git a/lib/useractivitystream.php b/lib/useractivitystream.php new file mode 100644 index 000000000..0fc315e26 --- /dev/null +++ b/lib/useractivitystream.php @@ -0,0 +1,151 @@ +<?php +/* + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2010 StatusNet, Inc. + * + * 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/>. + */ + +/** + * Class for activity streams + * + * Includes faves, notices, and subscriptions. + * + * We extend atomusernoticefeed since it does some nice setup for us. + * + */ + +class UserActivityStream extends AtomUserNoticeFeed +{ + function __construct($user, $indent = true) + { + parent::__construct($user, null, $indent); + + $subscriptions = $this->getSubscriptions(); + $subscribers = $this->getSubscribers(); + $groups = $this->getGroups(); + $faves = $this->getFaves(); + $notices = $this->getNotices(); + + $objs = array_merge($subscriptions, $subscribers, $groups, $faves, $notices); + + // Sort by create date + + usort($objs, 'UserActivityStream::compareObject'); + + foreach ($objs as $obj) { + $act = $obj->asActivity(); + // Only show the author sub-element if it's different from default user + $str = $act->asString(false, ($act->actor->id != $this->user->uri)); + $this->addEntryRaw($str); + } + } + + function compareObject($a, $b) + { + $ac = strtotime((empty($a->created)) ? $a->modified : $a->created); + $bc = strtotime((empty($b->created)) ? $b->modified : $b->created); + + return (($ac == $bc) ? 0 : (($ac < $bc) ? 1 : -1)); + } + + function getSubscriptions() + { + $subs = array(); + + $sub = new Subscription(); + + $sub->subscriber = $this->user->id; + + if ($sub->find()) { + while ($sub->fetch()) { + if ($sub->subscribed != $this->user->id) { + $subs[] = clone($sub); + } + } + } + + return $subs; + } + + function getSubscribers() + { + $subs = array(); + + $sub = new Subscription(); + + $sub->subscribed = $this->user->id; + + if ($sub->find()) { + while ($sub->fetch()) { + if ($sub->subscriber != $this->user->id) { + $subs[] = clone($sub); + } + } + } + + return $subs; + } + + function getFaves() + { + $faves = array(); + + $fave = new Fave(); + + $fave->user_id = $this->user->id; + + if ($fave->find()) { + while ($fave->fetch()) { + $faves[] = clone($fave); + } + } + + return $faves; + } + + function getNotices() + { + $notices = array(); + + $notice = new Notice(); + + $notice->profile_id = $this->user->id; + + if ($notice->find()) { + while ($notice->fetch()) { + $notices[] = clone($notice); + } + } + + return $notices; + } + + function getGroups() + { + $groups = array(); + + $gm = new Group_member(); + + $gm->profile_id = $this->user->id; + + if ($gm->find()) { + while ($gm->fetch()) { + $groups[] = clone($gm); + } + } + + return $groups; + } +} diff --git a/lib/util.php b/lib/util.php index 20c9144d4..b20ed8225 100644 --- a/lib/util.php +++ b/lib/util.php @@ -19,15 +19,18 @@ /* XXX: break up into separate modules (HTTP, user, files) */ -// Show a server error - +/** + * Show a server error. + */ function common_server_error($msg, $code=500) { $err = new ServerErrorAction($msg, $code); $err->showPage(); } -// Show a user error +/** + * Show a user error. + */ function common_user_error($msg, $code=400) { $err = new ClientErrorAction($msg, $code); @@ -203,8 +206,10 @@ function common_language() // Finally, if none of the above worked, use the site's default... return common_config('site', 'language'); } -// salted, hashed passwords are stored in the DB +/** + * Salted, hashed passwords are stored in the DB. + */ function common_munge_password($password, $id) { if (is_object($id) || is_object($password)) { @@ -215,8 +220,9 @@ function common_munge_password($password, $id) return md5($password . $id); } -// check if a username exists and has matching password - +/** + * Check if a username exists and has matching password. + */ function common_check_user($nickname, $password) { // empty nickname always unacceptable @@ -243,7 +249,9 @@ function common_check_user($nickname, $password) return $authenticatedUser; } -// is the current user logged in? +/** + * Is the current user logged in? + */ function common_logged_in() { return (!is_null(common_current_user())); @@ -289,12 +297,10 @@ function common_ensure_session() // 3) null to clear // Initialize to false; set to null if none found - $_cur = false; function common_set_user($user) { - global $_cur; if (is_null($user) && common_have_session()) { @@ -380,7 +386,6 @@ function common_rememberme($user=null) function common_remembered_user() { - $user = null; $packed = isset($_COOKIE[REMEMBERME]) ? $_COOKIE[REMEMBERME] : null; @@ -442,14 +447,17 @@ function common_remembered_user() return $user; } -// must be called with a valid user! - +/** + * must be called with a valid user! + */ function common_forgetme() { common_set_cookie(REMEMBERME, '', 0); } -// who is the current user? +/** + * Who is the current user? + */ function common_current_user() { global $_cur; @@ -485,10 +493,11 @@ function common_current_user() return $_cur; } -// Logins that are 'remembered' aren't 'real' -- they're subject to -// cookie-stealing. So, we don't let them do certain things. New reg, -// OpenID, and password logins _are_ real. - +/** + * Logins that are 'remembered' aren't 'real' -- they're subject to + * cookie-stealing. So, we don't let them do certain things. New reg, + * OpenID, and password logins _are_ real. + */ function common_real_login($real=true) { common_ensure_session(); @@ -500,6 +509,29 @@ function common_is_real_login() return common_logged_in() && $_SESSION['real_login']; } +/** + * Get a hash portion for HTTP caching Etags and such including + * info on the current user's session. If login/logout state changes, + * or we've changed accounts, or we've renamed the current user, + * we'll get a new hash value. + * + * This should not be considered secure information. + * + * @param User $user (optional; uses common_current_user() if left out) + * @return string + */ +function common_user_cache_hash($user=false) +{ + if ($user === false) { + $user = common_current_user(); + } + if ($user) { + return crc32($user->id . ':' . $user->nickname); + } else { + return '0'; + } +} + // get canonical version of nickname for comparison function common_canonical_nickname($nickname) { @@ -591,9 +623,7 @@ function common_find_mentions($text, $notice) } if (Event::handle('StartFindMentions', array($sender, $text, &$mentions))) { - // Get the context of the original notice, if any - $originalAuthor = null; $originalNotice = null; $originalMentions = array(); @@ -629,7 +659,6 @@ function common_find_mentions($text, $notice) $matches = array_merge($tmatches[1], $atmatches[1]); foreach ($matches as $match) { - $nickname = common_canonical_nickname($match[0]); // Try to get a profile for this nickname. @@ -637,19 +666,15 @@ function common_find_mentions($text, $notice) // sender context. if (!empty($originalAuthor) && $originalAuthor->nickname == $nickname) { - $mentioned = $originalAuthor; - } else if (!empty($originalMentions) && array_key_exists($nickname, $originalMentions)) { - $mentioned = $originalMentions[$nickname]; } else { $mentioned = common_relative_profile($sender, $nickname); } if (!empty($mentioned)) { - $user = User::staticGet('id', $mentioned->id); if ($user) { @@ -1130,30 +1155,30 @@ function common_date_string($dt) // TRANS: Used in notices to indicate when the notice was made compared to now. return _('about a minute ago'); } else if ($diff < 3300) { - // XXX: should support plural. + $minutes = round($diff/60); // TRANS: Used in notices to indicate when the notice was made compared to now. - return sprintf(_('about %d minutes ago'), round($diff/60)); + return sprintf( ngettext('about one minute ago', 'about %d minutes ago', $minutes), $minutes); } else if ($diff < 5400) { // TRANS: Used in notices to indicate when the notice was made compared to now. return _('about an hour ago'); } else if ($diff < 22 * 3600) { - // XXX: should support plural. + $hours = round($diff/3600); // TRANS: Used in notices to indicate when the notice was made compared to now. - return sprintf(_('about %d hours ago'), round($diff/3600)); + return sprintf( ngettext('about one hour ago', 'about %d hours ago', $hours), $hours); } else if ($diff < 37 * 3600) { // TRANS: Used in notices to indicate when the notice was made compared to now. return _('about a day ago'); } else if ($diff < 24 * 24 * 3600) { - // XXX: should support plural. + $days = round($diff/(24*3600)); // TRANS: Used in notices to indicate when the notice was made compared to now. - return sprintf(_('about %d days ago'), round($diff/(24*3600))); + return sprintf( ngettext('about one day ago', 'about %d days ago', $days), $days); } else if ($diff < 46 * 24 * 3600) { // TRANS: Used in notices to indicate when the notice was made compared to now. return _('about a month ago'); } else if ($diff < 330 * 24 * 3600) { - // XXX: should support plural. + $months = round($diff/(30*24*3600)); // TRANS: Used in notices to indicate when the notice was made compared to now. - return sprintf(_('about %d months ago'), round($diff/(30*24*3600))); + return sprintf( ngettext('about one month ago', 'about %d months ago',$months), $months); } else if ($diff < 480 * 24 * 3600) { // TRANS: Used in notices to indicate when the notice was made compared to now. return _('about a year ago'); @@ -1305,8 +1330,9 @@ function common_profile_url($nickname) null, null, false); } -// Should make up a reasonable root URL - +/** + * Should make up a reasonable root URL + */ function common_root_url($ssl=false) { $url = common_path('', $ssl, false); @@ -1317,9 +1343,10 @@ function common_root_url($ssl=false) return $url; } -// returns $bytes bytes of random data as a hexadecimal string -// "good" here is a goal and not a guarantee - +/** + * returns $bytes bytes of random data as a hexadecimal string + * "good" here is a goal and not a guarantee + */ function common_good_rand($bytes) { // XXX: use random.org...? @@ -1465,7 +1492,12 @@ function common_log_db_error(&$object, $verb, $filename=null) { $objstr = common_log_objstring($object); $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError'); - common_log(LOG_ERR, $last_error->message . '(' . $verb . ' on ' . $objstr . ')', $filename); + if (is_object($last_error)) { + $msg = $last_error->message; + } else { + $msg = 'Unknown error (' . var_export($last_error, true) . ')'; + } + common_log(LOG_ERR, $msg . '(' . $verb . ' on ' . $objstr . ')', $filename); } function common_log_objstring(&$object) @@ -1823,7 +1855,6 @@ function common_compatible_license($from, $to) */ function common_database_tablename($tablename) { - if(common_config('db','quote_identifiers')) { $tablename = '"'. $tablename .'"'; } diff --git a/lib/xrd.php b/lib/xrd.php index 145cd64cb..c8cffed9c 100644 --- a/lib/xrd.php +++ b/lib/xrd.php @@ -27,7 +27,6 @@ * @link http://status.net/ */ - class XRD { const XML_NS = 'http://www.w3.org/2000/xmlns/'; @@ -61,11 +60,13 @@ class XRD error_reporting($old); if (!$ok) { - throw new Exception("Invalid XML."); + // TRANS: Exception. + throw new Exception(_m('Invalid XML.')); } $xrd_element = $dom->getElementsByTagName('XRD')->item(0); if (!$xrd_element) { - throw new Exception("Invalid XML, missing XRD root."); + // TRANS: Exception. + throw new Exception(_m('Invalid XML, missing XRD root.')); } // Check for host-meta host |