diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/action.php | 49 | ||||
-rw-r--r-- | lib/command.php | 12 | ||||
-rw-r--r-- | lib/feedlist.php | 1 | ||||
-rw-r--r-- | lib/groupeditform.php | 15 | ||||
-rw-r--r-- | lib/imagefile.php | 13 | ||||
-rw-r--r-- | lib/mailhandler.php | 5 | ||||
-rw-r--r-- | lib/ping.php | 75 | ||||
-rw-r--r-- | lib/searchaction.php | 6 | ||||
-rw-r--r-- | lib/themeuploader.php | 7 | ||||
-rw-r--r-- | lib/uapplugin.php | 27 | ||||
-rw-r--r-- | lib/unblockform.php | 6 |
11 files changed, 143 insertions, 73 deletions
diff --git a/lib/action.php b/lib/action.php index 01bb0f7e9..766cfca26 100644 --- a/lib/action.php +++ b/lib/action.php @@ -283,6 +283,7 @@ class Action extends HTMLOutputter // lawsuit if (Event::handle('StartShowStatusNetScripts', array($this)) && Event::handle('StartShowLaconicaScripts', array($this))) { $this->script('util.js'); + $this->showScriptMessages(); // Frame-busting code to avoid clickjacking attacks. $this->inlineScript('if (window.top !== window.self) { window.top.location.href = window.self.location.href; }'); Event::handle('EndShowStatusNetScripts', array($this)); @@ -293,6 +294,54 @@ class Action extends HTMLOutputter // lawsuit } /** + * Exports a map of localized text strings to JavaScript code. + * + * Plugins can add to what's exported by hooking the StartScriptMessages or EndScriptMessages + * events and appending to the array. Try to avoid adding strings that won't be used, as + * they'll be added to HTML output. + */ + function showScriptMessages() + { + $messages = array(); + if (Event::handle('StartScriptMessages', array($this, &$messages))) { + // Common messages needed for timeline views etc... + + // TRANS: Localized tooltip for '...' expansion button on overlong remote messages. + $messages['showmore_tooltip'] = _m('TOOLTIP', 'Show more'); + + $messages = array_merge($messages, $this->getScriptMessages()); + } + Event::handle('EndScriptMessages', array($this, &$messages)); + if ($messages) { + $this->inlineScript('SN.messages=' . json_encode($messages)); + } + return $messages; + } + + /** + * If the action will need localizable text strings, export them here like so: + * + * return array('pool_deepend' => _('Deep end'), + * 'pool_shallow' => _('Shallow end')); + * + * The exported map will be available via SN.msg() to JS code: + * + * $('#pool').html('<div class="deepend"></div><div class="shallow"></div>'); + * $('#pool .deepend').text(SN.msg('pool_deepend')); + * $('#pool .shallow').text(SN.msg('pool_shallow')); + * + * Exports a map of localized text strings to JavaScript code. + * + * Plugins can add to what's exported on any action by hooking the StartScriptMessages or + * EndScriptMessages events and appending to the array. Try to avoid adding strings that won't + * be used, as they'll be added to HTML output. + */ + function getScriptMessages() + { + return array(); + } + + /** * Show OpenSearch headers * * @return nothing diff --git a/lib/command.php b/lib/command.php index efe917fb1..bd8a4ebfe 100644 --- a/lib/command.php +++ b/lib/command.php @@ -483,9 +483,11 @@ class MessageCommand extends Command if (Message::contentTooLong($this->text)) { // XXX: i18n. Needs plural support. - // TRANS: Message given if content is too long. + // TRANS: Message given if content is too long. %1$sd is used for plural. // TRANS: %1$d is the maximum number of characters, %2$d is the number of submitted characters. - $channel->error($this->user, sprintf(_('Message too long - maximum is %1$d characters, you sent %2$d.'), + $channel->error($this->user, sprintf(_m('Message too long - maximum is %1$d character, you sent %2$d.', + 'Message too long - maximum is %1$d characters, you sent %2$d.', + Message::maxContent()), Message::maxContent(), mb_strlen($this->text))); return; } @@ -584,9 +586,11 @@ class ReplyCommand extends Command if (Notice::contentTooLong($this->text)) { // XXX: i18n. Needs plural support. - // TRANS: Message given if content of a notice for a reply is too long. + // TRANS: Message given if content of a notice for a reply is too long. %1$d is used for plural. // TRANS: %1$d is the maximum number of characters, %2$d is the number of submitted characters. - $channel->error($this->user, sprintf(_('Notice too long - maximum is %1$d characters, you sent %2$d.'), + $channel->error($this->user, sprintf(_m('Notice too long - maximum is %1$d character, you sent %2$d.', + 'Notice too long - maximum is %1$d characters, you sent %2$d.', + Notice::maxContent()), Notice::maxContent(), mb_strlen($this->text))); return; } diff --git a/lib/feedlist.php b/lib/feedlist.php index 076576028..bbe66b2e7 100644 --- a/lib/feedlist.php +++ b/lib/feedlist.php @@ -62,6 +62,7 @@ class FeedList extends Widget if (!empty($feeds)) { $this->out->elementStart('div', array('id' => 'export_data', 'class' => 'section')); + // TRANS: Header for feed links (h2). $this->out->element('h2', null, _('Feeds')); $this->out->elementStart('ul', array('class' => 'xoxo')); diff --git a/lib/groupeditform.php b/lib/groupeditform.php index 433f6a138..cc25f0688 100644 --- a/lib/groupeditform.php +++ b/lib/groupeditform.php @@ -160,14 +160,17 @@ class GroupEditForm extends Form $this->out->elementStart('li'); $this->out->input('homepage', _('Homepage'), ($this->out->arg('homepage')) ? $this->out->arg('homepage') : $homepage, - _('URL of the homepage or blog of the group or topic')); + _('URL of the homepage or blog of the group or topic.')); $this->out->elementEnd('li'); $this->out->elementStart('li'); $desclimit = User_group::maxDescription(); if ($desclimit == 0) { $descinstr = _('Describe the group or topic'); } else { - $descinstr = sprintf(_('Describe the group or topic in %d characters'), $desclimit); + $descinstr = sprintf(_m('Describe the group or topic in %d character or less', + 'Describe the group or topic in %d characters or less', + $desclimit), + $desclimit); } $this->out->textarea('description', _('Description'), ($this->out->arg('description')) ? $this->out->arg('description') : $description, @@ -176,7 +179,7 @@ class GroupEditForm extends Form $this->out->elementStart('li'); $this->out->input('location', _('Location'), ($this->out->arg('location')) ? $this->out->arg('location') : $location, - _('Location for the group, if any, like "City, State (or Region), Country"')); + _('Location for the group, if any, like "City, State (or Region), Country".')); $this->out->elementEnd('li'); if (common_config('group', 'maxaliases') > 0) { $aliases = (empty($this->group)) ? array() : $this->group->getAliases(); @@ -184,7 +187,9 @@ class GroupEditForm extends Form $this->out->input('aliases', _('Aliases'), ($this->out->arg('aliases')) ? $this->out->arg('aliases') : (!empty($aliases)) ? implode(' ', $aliases) : '', - sprintf(_('Extra nicknames for the group, comma- or space- separated, max %d'), + sprintf(_m('Extra nicknames for the group, separated with commas or spaces. Maximum %d alias allowed.', + 'Extra nicknames for the group, separated with commas or spaces. Maximum %d aliases allowed.', + common_config('group', 'maxaliases')), common_config('group', 'maxaliases')));; $this->out->elementEnd('li'); } @@ -199,6 +204,6 @@ class GroupEditForm extends Form function formActions() { - $this->out->submit('submit', _('Save')); + $this->out->submit('submit', _m('BUTTON','Save')); } } diff --git a/lib/imagefile.php b/lib/imagefile.php index e47287741..b70fd248e 100644 --- a/lib/imagefile.php +++ b/lib/imagefile.php @@ -85,6 +85,8 @@ class ImageFile break; case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: + // TRANS: Exception thrown when too large a file is uploaded. + // TRANS: %s is the maximum file size, for example "500b", "10kB" or "2MB". throw new Exception(sprintf(_('That file is too big. The maximum file size is %s.'), ImageFile::maxFileSize())); return; @@ -241,11 +243,16 @@ class ImageFile $value = ImageFile::maxFileSizeInt(); if ($value > 1024 * 1024) { - return ($value/(1024*1024)) . _('MB'); + $value = $value/(1024*1024); + // TRANS: Number of megabytes. %d is the number. + return sprintf(_m('%dMB','%dMB',$value),$value); } else if ($value > 1024) { - return ($value/(1024)) . _('kB'); + $value = $value/1024; + // TRANS: Number of kilobytes. %d is the number. + return sprintf(_m('%dkB','%dkB',$value),$value); } else { - return $value; + // TRANS: Number of bytes. %d is the number. + return sprintf(_m('%dB','%dB',$value),$value); } } diff --git a/lib/mailhandler.php b/lib/mailhandler.php index e9ba41839..69eb26bdd 100644 --- a/lib/mailhandler.php +++ b/lib/mailhandler.php @@ -57,8 +57,9 @@ class MailHandler $msg = $this->cleanup_msg($msg); $msg = common_shorten_links($msg); if (Notice::contentTooLong($msg)) { - $this->error($from, sprintf(_('That\'s too long. '. - 'Max notice size is %d chars.'), + $this->error($from, sprintf(_('That\'s too long. Maximum notice size is %d character.', + 'That\'s too long. Maximum notice size is %d characters.', + Notice::maxContent()), Notice::maxContent())); } diff --git a/lib/ping.php b/lib/ping.php index abf1c4048..e1c7c748e 100644 --- a/lib/ping.php +++ b/lib/ping.php @@ -20,13 +20,12 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } function ping_broadcast_notice($notice) { + if ($notice->is_local != Notice::LOCAL_PUBLIC && $notice->is_local != Notice::LOCAL_NONPUBLIC) { + return true; + } - if ($notice->is_local != Notice::LOCAL_PUBLIC && $notice->is_local != Notice::LOCAL_NONPUBLIC) { - return true; - } - - # Array of servers, URL => type - $notify = common_config('ping', 'notify'); + # Array of servers, URL => type + $notify = common_config('ping', 'notify'); try { $profile = $notice->getProfile(); } catch (Exception $e) { @@ -35,21 +34,21 @@ function ping_broadcast_notice($notice) { common_log(LOG_ERR, "Exception getting notice profile: " . $e->getMessage()); return true; } - $tags = ping_notice_tags($notice); + $tags = ping_notice_tags($notice); - foreach ($notify as $notify_url => $type) { - switch ($type) { - case 'xmlrpc': - case 'extended': - $req = xmlrpc_encode_request('weblogUpdates.ping', - array($profile->nickname, # site name - common_local_url('showstream', - array('nickname' => $profile->nickname)), - common_local_url('shownotice', - array('notice' => $notice->id)), - common_local_url('userrss', - array('nickname' => $profile->nickname)), - $tags)); + foreach ($notify as $notify_url => $type) { + switch ($type) { + case 'xmlrpc': + case 'extended': + $req = xmlrpc_encode_request('weblogUpdates.ping', + array($profile->nickname, # site name + common_local_url('showstream', + array('nickname' => $profile->nickname)), + common_local_url('shownotice', + array('notice' => $notice->id)), + common_local_url('userrss', + array('nickname' => $profile->nickname)), + $tags)); $request = HTTPClient::start(); $request->setConfig('connect_timeout', common_config('ping', 'timeout')); @@ -79,9 +78,8 @@ function ping_broadcast_notice($notice) { "Ping success for $notify_url $notice->id"); } break; - - case 'get': - case 'post': + case 'get': + case 'post': $args = array('name' => $profile->nickname, 'url' => common_local_url('showstream', array('nickname' => $profile->nickname)), @@ -108,26 +106,25 @@ function ping_broadcast_notice($notice) { "'$result->body'"); } break; - - default: - common_log(LOG_WARNING, 'Unknown notify type for ' . $notify_url . ': ' . $type); + default: + common_log(LOG_WARNING, 'Unknown notify type for ' . $notify_url . ': ' . $type); } - } + } return true; } function ping_notice_tags($notice) { - $tag = new Notice_tag(); - $tag->notice_id = $notice->id; - $tags = array(); - if ($tag->find()) { - while ($tag->fetch()) { - $tags[] = $tag->tag; - } - $tag->free(); - unset($tag); - return implode('|', $tags); - } - return NULL; + $tag = new Notice_tag(); + $tag->notice_id = $notice->id; + $tags = array(); + if ($tag->find()) { + while ($tag->fetch()) { + $tags[] = $tag->tag; + } + $tag->free(); + unset($tag); + return implode('|', $tags); + } + return NULL; } diff --git a/lib/searchaction.php b/lib/searchaction.php index 14c3ed016..6d7f46cd6 100644 --- a/lib/searchaction.php +++ b/lib/searchaction.php @@ -70,7 +70,6 @@ class SearchAction extends Action * @return void * @see SearchGroupNav */ - function showLocalNav() { $nav = new SearchGroupNav($this, $this->trimmed('q')); @@ -127,6 +126,7 @@ class SearchAction extends 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); + // TRANS: Button text for searching site. $this->submit('search', _m('BUTTON','Search')); $this->elementEnd('li'); $this->elementEnd('ul'); @@ -138,7 +138,7 @@ class SearchAction extends Action } function searchSuggestions($q) { - // @todo FIXME: This formatting does not make this string get picked up by gettext. + // @todo FIXME: i18n issue: 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. @@ -150,7 +150,7 @@ 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. + // @todo FIXME: i18n issue: 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 diff --git a/lib/themeuploader.php b/lib/themeuploader.php index 5a48e884e..b7b14d7b9 100644 --- a/lib/themeuploader.php +++ b/lib/themeuploader.php @@ -163,9 +163,10 @@ class ThemeUploader $estSize = $blockSize * max(1, intval(ceil($size / $blockSize))); $totalSize += $estSize; if ($totalSize > $sizeLimit) { - $msg = sprintf(_("Uploaded theme is too large; " . - "must be less than %d bytes uncompressed."), - $sizeLimit); + $msg = sprintf(_m('Uploaded theme is too large; must be less than %d byte uncompressed.', + 'Uploaded theme is too large; must be less than %d bytes uncompressed.', + $sizeLimit), + $sizeLimit); throw new ClientException($msg); } diff --git a/lib/uapplugin.php b/lib/uapplugin.php index ef35bafbf..26d6a72d8 100644 --- a/lib/uapplugin.php +++ b/lib/uapplugin.php @@ -51,7 +51,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 UAPPlugin extends Plugin { public $mediumRectangle = null; @@ -66,7 +65,6 @@ abstract class UAPPlugin extends Plugin * * @return boolean hook flag */ - function onEndShowStatusNetStyles($action) { // XXX: allow override by theme @@ -81,7 +79,6 @@ abstract class UAPPlugin extends Plugin * * @return boolean hook flag */ - function onStartShowAside($action) { if (!is_null($this->mediumRectangle)) { @@ -95,6 +92,24 @@ abstract class UAPPlugin extends Plugin $action->elementEnd('div'); } + // XXX: Hack to force ads to show on single-notice pages + + if (!is_null($this->rectangle) && + $action->trimmed('action') == 'shownotice') { + + $action->elementStart('div', array('id' => 'aside_primary', + 'class' => 'aside')); + + if (Event::handle('StartShowSections', array($action))) { + $action->showSections(); + Event::handle('EndShowSections', array($action)); + } + + $action->elementEnd('div'); + + return false; + } + return true; } @@ -126,7 +141,6 @@ abstract class UAPPlugin extends Plugin * * @return boolean hook flag */ - function onStartShowSections($action) { if (!is_null($this->rectangle)) { @@ -147,7 +161,6 @@ abstract class UAPPlugin extends Plugin * * @return boolean hook flag */ - function onEndShowAside($action) { if (!is_null($this->wideSkyscraper)) { @@ -169,7 +182,6 @@ abstract class UAPPlugin extends Plugin * * @return void */ - abstract protected function showMediumRectangle($action); /** @@ -179,7 +191,6 @@ abstract class UAPPlugin extends Plugin * * @return void */ - abstract protected function showRectangle($action); /** @@ -189,7 +200,6 @@ abstract class UAPPlugin extends Plugin * * @return void */ - abstract protected function showWideSkyscraper($action); /** @@ -199,6 +209,5 @@ abstract class UAPPlugin extends Plugin * * @return void */ - abstract protected function showLeaderboard($action); } diff --git a/lib/unblockform.php b/lib/unblockform.php index b89d7ff78..8daad3c92 100644 --- a/lib/unblockform.php +++ b/lib/unblockform.php @@ -44,7 +44,6 @@ if (!defined('STATUSNET')) { * * @see BlockForm */ - class UnblockForm extends ProfileActionForm { /** @@ -52,7 +51,6 @@ class UnblockForm extends ProfileActionForm * * @return string Name of the action, lowercased. */ - function target() { return 'unblock'; @@ -63,11 +61,10 @@ class UnblockForm extends ProfileActionForm * * @return string Title of the form, internationalized */ - function title() { // TRANS: Title for the form to unblock a user. - return _('Unblock'); + return _m('TITLE','Unblock'); } /** @@ -75,7 +72,6 @@ class UnblockForm extends ProfileActionForm * * @return string description of the form, internationalized */ - function description() { // TRANS: Description of the form to unblock a user. |