* i18n/L10n review.

* add onPluginVersion()
This commit is contained in:
Siebrand Mazeland 2010-10-02 22:25:32 +02:00
parent 08054e85fe
commit 0f4f6fdb01
7 changed files with 61 additions and 71 deletions

View File

@ -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 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/ * @link http://status.net/
*/ */
class UserFlagPlugin extends Plugin class UserFlagPlugin extends Plugin
{ {
const REVIEWFLAGS = 'UserFlagPlugin::reviewflags'; const REVIEWFLAGS = 'UserFlagPlugin::reviewflags';
@ -56,7 +55,6 @@ class UserFlagPlugin extends Plugin
* *
* @return boolean hook return * @return boolean hook return
*/ */
function onCheckSchema() function onCheckSchema()
{ {
$schema = Schema::get(); $schema = Schema::get();
@ -83,7 +81,6 @@ class UserFlagPlugin extends Plugin
* *
* @return boolean hook return * @return boolean hook return
*/ */
function onRouterInitialized($m) function onRouterInitialized($m)
{ {
$m->connect('main/flag/profile', array('action' => 'flagprofile')); $m->connect('main/flag/profile', array('action' => 'flagprofile'));
@ -99,7 +96,6 @@ class UserFlagPlugin extends Plugin
* *
* @return boolean hook return * @return boolean hook return
*/ */
function onAutoload($cls) function onAutoload($cls)
{ {
switch (strtolower($cls)) switch (strtolower($cls))
@ -130,7 +126,6 @@ class UserFlagPlugin extends Plugin
* *
* @return boolean hook result * @return boolean hook result
*/ */
function onEndProfilePageActionsElements(&$action, $profile) function onEndProfilePageActionsElements(&$action, $profile)
{ {
$user = common_current_user(); $user = common_current_user();
@ -140,6 +135,8 @@ class UserFlagPlugin extends Plugin
$action->elementStart('li', 'entity_flag'); $action->elementStart('li', 'entity_flag');
if (User_flag_profile::exists($profile->id, $user->id)) { if (User_flag_profile::exists($profile->id, $user->id)) {
// @todo FIXME: Add a title explaining what 'flagged' means?
// TRANS: Message added to a profile if it has been flagged for review.
$action->element('p', 'flagged', _('Flagged')); $action->element('p', 'flagged', _('Flagged'));
} else { } else {
$form = new FlagProfileForm($action, $profile, $form = new FlagProfileForm($action, $profile,
@ -161,7 +158,6 @@ class UserFlagPlugin extends Plugin
* *
* @return boolean hook result * @return boolean hook result
*/ */
function onEndProfileListItemActionElements($item) function onEndProfileListItemActionElements($item)
{ {
$user = common_current_user(); $user = common_current_user();
@ -189,7 +185,6 @@ class UserFlagPlugin extends Plugin
* *
* @return boolean hook result * @return boolean hook result
*/ */
function onEndShowScripts($action) function onEndShowScripts($action)
{ {
$action->inlineScript('if ($(".form_entity_flag").length > 0) { '. $action->inlineScript('if ($(".form_entity_flag").length > 0) { '.
@ -210,7 +205,6 @@ class UserFlagPlugin extends Plugin
* *
* @return boolean hook result * @return boolean hook result
*/ */
function onUserRightsCheck($user, $right, &$result) function onUserRightsCheck($user, $right, &$result)
{ {
switch ($right) { switch ($right) {
@ -233,7 +227,6 @@ class UserFlagPlugin extends Plugin
* *
* @return boolean hook result * @return boolean hook result
*/ */
function onEndBlockProfile($user, $profile) function onEndBlockProfile($user, $profile)
{ {
if ($this->flagOnBlock && !User_flag_profile::exists($profile->id, if ($this->flagOnBlock && !User_flag_profile::exists($profile->id,
@ -255,7 +248,6 @@ class UserFlagPlugin extends Plugin
* *
* @return boolean hook result * @return boolean hook result
*/ */
function onProfileDeleteRelated($profile, &$related) function onProfileDeleteRelated($profile, &$related)
{ {
$related[] = 'user_flag_profile'; $related[] = 'user_flag_profile';
@ -272,10 +264,33 @@ class UserFlagPlugin extends Plugin
* *
* @return boolean hook result * @return boolean hook result
*/ */
function onUserDeleteRelated($user, &$related) function onUserDeleteRelated($user, &$related)
{ {
$related[] = 'user_flag_profile'; $related[] = 'user_flag_profile';
return true; return true;
} }
/**
* Provide plugin version information.
*
* This data is used when showing the version page.
*
* @param array &$versions array of version data arrays; see EVENTS.txt
*
* @return boolean hook value
*/
function onPluginVersion(&$versions)
{
$url = 'http://status.net/wiki/Plugin:UserFlag';
$versions[] = array('name' => 'UserFlag',
'version' => STATUSNET_VERSION,
'author' => 'Evan Prodromou',
'homepage' => $url,
'rawdescription' =>
// TRANS: Plugin description.
_m('This plugin allows flagging of profiles for review and reviewing flagged profiles.'));
return true;
}
} }

View File

@ -44,7 +44,6 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/ * @link http://status.net/
*/ */
class User_flag_profile extends Memcached_DataObject class User_flag_profile extends Memcached_DataObject
{ {
###START_AUTOCODE ###START_AUTOCODE
@ -67,7 +66,6 @@ class User_flag_profile extends Memcached_DataObject
* *
* @return array array of column definitions * @return array array of column definitions
*/ */
function table() function table()
{ {
return array( return array(
@ -83,7 +81,6 @@ class User_flag_profile extends Memcached_DataObject
* *
* @return array key definitions * @return array key definitions
*/ */
function keys() function keys()
{ {
return array('profile_id' => 'K', 'user_id' => 'K'); return array('profile_id' => 'K', 'user_id' => 'K');
@ -94,7 +91,6 @@ class User_flag_profile extends Memcached_DataObject
* *
* @return array key definitions * @return array key definitions
*/ */
function keyTypes() function keyTypes()
{ {
return $this->keys(); return $this->keys();
@ -107,7 +103,6 @@ class User_flag_profile extends Memcached_DataObject
* *
* @return User_flag_profile found object or null * @return User_flag_profile found object or null
*/ */
function pkeyGet($kv) function pkeyGet($kv)
{ {
return Memcached_DataObject::pkeyGet('User_flag_profile', $kv); return Memcached_DataObject::pkeyGet('User_flag_profile', $kv);
@ -121,7 +116,6 @@ class User_flag_profile extends Memcached_DataObject
* *
* @return boolean true if exists, else false * @return boolean true if exists, else false
*/ */
static function exists($profile_id, $user_id) static function exists($profile_id, $user_id)
{ {
$ufp = User_flag_profile::pkeyGet(array('profile_id' => $profile_id, $ufp = User_flag_profile::pkeyGet(array('profile_id' => $profile_id,
@ -138,7 +132,6 @@ class User_flag_profile extends Memcached_DataObject
* *
* @return boolean success flag * @return boolean success flag
*/ */
static function create($user_id, $profile_id) static function create($user_id, $profile_id)
{ {
$ufp = new User_flag_profile(); $ufp = new User_flag_profile();
@ -148,7 +141,8 @@ class User_flag_profile extends Memcached_DataObject
$ufp->created = common_sql_now(); $ufp->created = common_sql_now();
if (!$ufp->insert()) { if (!$ufp->insert()) {
$msg = sprintf(_("Couldn't flag profile '%d' for review."), // TRANS: Server exception.
$msg = sprintf(_m('Couldn\'t flag profile "%d" for review.'),
$profile_id); $profile_id);
throw new ServerException($msg); throw new ServerException($msg);
} }

View File

@ -40,7 +40,6 @@ if (!defined('STATUSNET')) {
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/ * @link http://status.net/
*/ */
class AdminprofileflagAction extends Action class AdminprofileflagAction extends Action
{ {
var $page = null; var $page = null;
@ -53,7 +52,6 @@ class AdminprofileflagAction extends Action
* *
* @return boolean success flag * @return boolean success flag
*/ */
function prepare($args) function prepare($args)
{ {
parent::prepare($args); parent::prepare($args);
@ -109,7 +107,6 @@ class AdminprofileflagAction extends Action
* *
* @return void * @return void
*/ */
function handle($args) function handle($args)
{ {
parent::handle($args); parent::handle($args);
@ -122,10 +119,10 @@ class AdminprofileflagAction extends Action
* *
* @return string Title of the page * @return string Title of the page
*/ */
function title() function title()
{ {
return _('Flagged profiles'); // TRANS: Title for page with a list of profiles that were flagged for review.
return _m('Flagged profiles');
} }
/** /**
@ -133,7 +130,6 @@ class AdminprofileflagAction extends Action
* *
* @return void * @return void
*/ */
function showContent() function showContent()
{ {
$pl = new FlaggedProfileList($this->profiles, $this); $pl = new FlaggedProfileList($this->profiles, $this);
@ -149,7 +145,6 @@ class AdminprofileflagAction extends Action
* *
* @return Profile $profile Profile query results * @return Profile $profile Profile query results
*/ */
function getProfiles() function getProfiles()
{ {
$ufp = new User_flag_profile(); $ufp = new User_flag_profile();
@ -196,7 +191,6 @@ class AdminprofileflagAction extends Action
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/ * @link http://status.net/
*/ */
class FlaggedProfileList extends ProfileList class FlaggedProfileList extends ProfileList
{ {
/** /**
@ -206,7 +200,6 @@ class FlaggedProfileList extends ProfileList
* *
* @return ProfileListItem newly-created item * @return ProfileListItem newly-created item
*/ */
function newListItem($profile) function newListItem($profile)
{ {
return new FlaggedProfileListItem($this->profile, $this->action); return new FlaggedProfileListItem($this->profile, $this->action);
@ -222,7 +215,6 @@ class FlaggedProfileList extends ProfileList
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/ * @link http://status.net/
*/ */
class FlaggedProfileListItem extends ProfileListItem class FlaggedProfileListItem extends ProfileListItem
{ {
const MAX_FLAGGERS = 5; const MAX_FLAGGERS = 5;
@ -235,7 +227,6 @@ class FlaggedProfileListItem extends ProfileListItem
* *
* @return void * @return void
*/ */
function showActions() function showActions()
{ {
$this->user = common_current_user(); $this->user = common_current_user();
@ -247,7 +238,8 @@ class FlaggedProfileListItem extends ProfileListItem
$this->startActions(); $this->startActions();
if (Event::handle('StartProfileListItemActionElements', array($this))) { if (Event::handle('StartProfileListItemActionElements', array($this))) {
$this->out->elementStart('li', 'entity_moderation'); $this->out->elementStart('li', 'entity_moderation');
$this->out->element('p', null, _('Moderate')); // TRANS: Header for moderation menu with action buttons for flagged profiles (like 'sandbox', 'silence', ...).
$this->out->element('p', null, _m('Moderate'));
$this->out->elementStart('ul'); $this->out->elementStart('ul');
$this->showSandboxButton(); $this->showSandboxButton();
$this->showSilenceButton(); $this->showSilenceButton();
@ -265,7 +257,6 @@ class FlaggedProfileListItem extends ProfileListItem
* *
* @return void * @return void
*/ */
function showSandboxButton() function showSandboxButton()
{ {
if ($this->user->hasRight(Right::SANDBOXUSER)) { if ($this->user->hasRight(Right::SANDBOXUSER)) {
@ -286,7 +277,6 @@ class FlaggedProfileListItem extends ProfileListItem
* *
* @return void * @return void
*/ */
function showSilenceButton() function showSilenceButton()
{ {
if ($this->user->hasRight(Right::SILENCEUSER)) { if ($this->user->hasRight(Right::SILENCEUSER)) {
@ -307,7 +297,6 @@ class FlaggedProfileListItem extends ProfileListItem
* *
* @return void * @return void
*/ */
function showDeleteButton() function showDeleteButton()
{ {
@ -324,7 +313,6 @@ class FlaggedProfileListItem extends ProfileListItem
* *
* @return void * @return void
*/ */
function showClearButton() function showClearButton()
{ {
if ($this->user->hasRight(UserFlagPlugin::CLEARFLAGS)) { if ($this->user->hasRight(UserFlagPlugin::CLEARFLAGS)) {
@ -340,7 +328,6 @@ class FlaggedProfileListItem extends ProfileListItem
* *
* @return void * @return void
*/ */
function endProfile() function endProfile()
{ {
$this->showFlaggersList(); $this->showFlaggersList();
@ -352,7 +339,6 @@ class FlaggedProfileListItem extends ProfileListItem
* *
* @return void * @return void
*/ */
function showFlaggersList() function showFlaggersList()
{ {
$flaggers = array(); $flaggers = array();
@ -394,12 +380,16 @@ class FlaggedProfileListItem extends ProfileListItem
} }
if ($cnt > 0) { if ($cnt > 0) {
$text = _('Flagged by ');
$text .= implode(', ', $lnks);
if ($others > 0) { if ($others > 0) {
$text .= sprintf(_(' and %d others'), $others); $flagging_users = implode(', ', $lnks);
// TRANS: Message displayed on a profile if it has been flagged.
// TRANS: %1$s is a comma separated list of at most 5 user nicknames that flagged.
// TRANS: %2$d is a positive integer of additional flagging users. Also used for the plural.
$text .= sprintf(_m('Flagged by %1$s and %2$d other', 'Flagged by %1$s and %2$d others', $others), $flagging_users, $others);
} else {
// TRANS: Message displayed on a profile if it has been flagged.
// TRANS: %s is a comma separated list of at most 5 user nicknames that flagged.
$text .= sprintf(_m('Flagged by %s'), $flagging_users);
} }
$this->out->elementStart('p', array('class' => 'flaggers')); $this->out->elementStart('p', array('class' => 'flaggers'));

View File

@ -40,7 +40,6 @@ if (!defined('STATUSNET')) {
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/ * @link http://status.net/
*/ */
class ClearflagAction extends ProfileFormAction class ClearflagAction extends ProfileFormAction
{ {
/** /**
@ -75,7 +74,6 @@ class ClearflagAction extends ProfileFormAction
* *
* @return void * @return void
*/ */
function handle($args) function handle($args)
{ {
if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($_SERVER['REQUEST_METHOD'] == 'POST') {
@ -93,7 +91,6 @@ class ClearflagAction extends ProfileFormAction
* *
* @return void * @return void
*/ */
function handlePost() function handlePost()
{ {
$ufp = new User_flag_profile(); $ufp = new User_flag_profile();
@ -104,7 +101,8 @@ class ClearflagAction extends ProfileFormAction
'AND profile_id = ' . $this->profile->id); 'AND profile_id = ' . $this->profile->id);
if ($result == false) { if ($result == false) {
$msg = sprintf(_("Couldn't clear flags for profile '%s'."), // TRANS: Server exception given when flags could not be cleared.
$msg = sprintf(_m('Couldn\'t clear flags for profile "%s".'),
$this->profile->nickname); $this->profile->nickname);
throw new ServerException($msg); throw new ServerException($msg);
} }
@ -121,17 +119,18 @@ class ClearflagAction extends ProfileFormAction
* *
* @return void * @return void
*/ */
function ajaxResults() function ajaxResults()
{ {
header('Content-Type: text/xml;charset=utf-8'); header('Content-Type: text/xml;charset=utf-8');
$this->xw->startDocument('1.0', 'UTF-8'); $this->xw->startDocument('1.0', 'UTF-8');
$this->elementStart('html'); $this->elementStart('html');
$this->elementStart('head'); $this->elementStart('head');
$this->element('title', null, _('Flags cleared')); // TRANS: Title for AJAX form to indicated that flags were removed.
$this->element('title', null, _m('Flags cleared'));
$this->elementEnd('head'); $this->elementEnd('head');
$this->elementStart('body'); $this->elementStart('body');
$this->element('p', 'cleared', _('Cleared')); // TRANS: Body element for "flags cleared" form.
$this->element('p', 'cleared', _m('Cleared'));
$this->elementEnd('body'); $this->elementEnd('body');
$this->elementEnd('html'); $this->elementEnd('html');
} }

View File

@ -42,7 +42,6 @@ require_once INSTALLDIR.'/lib/form.php';
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/ * @link http://status.net/
*/ */
class ClearFlagForm extends ProfileActionForm class ClearFlagForm extends ProfileActionForm
{ {
/** /**
@ -51,7 +50,6 @@ class ClearFlagForm extends ProfileActionForm
* *
* @return string class of the form * @return string class of the form
*/ */
function formClass() function formClass()
{ {
return 'form_user_clearflag'; return 'form_user_clearflag';
@ -62,7 +60,6 @@ class ClearFlagForm extends ProfileActionForm
* *
* @return string Name of the action, lowercased. * @return string Name of the action, lowercased.
*/ */
function target() function target()
{ {
return 'clearflag'; return 'clearflag';
@ -73,10 +70,10 @@ class ClearFlagForm extends ProfileActionForm
* *
* @return string Title of the form, internationalized * @return string Title of the form, internationalized
*/ */
function title() function title()
{ {
return _('Clear'); // TRANS: Form title for action on a profile.
return _m('Clear');
} }
/** /**
@ -87,6 +84,7 @@ class ClearFlagForm extends ProfileActionForm
function description() function description()
{ {
return _('Clear all flags'); // Form description for clearing flags from a profile.
return _m('Clear all flags');
} }
} }

View File

@ -40,7 +40,6 @@ if (!defined('STATUSNET')) {
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/ * @link http://status.net/
*/ */
class FlagprofileAction extends ProfileFormAction class FlagprofileAction extends ProfileFormAction
{ {
/** /**
@ -50,7 +49,6 @@ class FlagprofileAction extends ProfileFormAction
* *
* @return boolean success flag * @return boolean success flag
*/ */
function prepare($args) function prepare($args)
{ {
if (!parent::prepare($args)) { if (!parent::prepare($args)) {
@ -64,7 +62,8 @@ class FlagprofileAction extends ProfileFormAction
if (User_flag_profile::exists($this->profile->id, if (User_flag_profile::exists($this->profile->id,
$user->id)) { $user->id)) {
$this->clientError(_('Flag already exists.')); // TRANS: Client error when setting flag that has already been set for a profile.
$this->clientError(_m('Flag already exists.'));
return false; return false;
} }
@ -81,7 +80,6 @@ class FlagprofileAction extends ProfileFormAction
* *
* @return void * @return void
*/ */
function handle($args) function handle($args)
{ {
if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($_SERVER['REQUEST_METHOD'] == 'POST') {
@ -97,7 +95,6 @@ class FlagprofileAction extends ProfileFormAction
* *
* @return void * @return void
*/ */
function handlePost() function handlePost()
{ {
$user = common_current_user(); $user = common_current_user();
@ -119,19 +116,19 @@ class FlagprofileAction extends ProfileFormAction
* *
* @return void * @return void
*/ */
function ajaxResults() function ajaxResults()
{ {
header('Content-Type: text/xml;charset=utf-8'); header('Content-Type: text/xml;charset=utf-8');
$this->xw->startDocument('1.0', 'UTF-8'); $this->xw->startDocument('1.0', 'UTF-8');
$this->elementStart('html'); $this->elementStart('html');
$this->elementStart('head'); $this->elementStart('head');
$this->element('title', null, _('Flagged for review')); // TRANS: AJAX form title for a flagged profile.
$this->element('title', null, _m('Flagged for review'));
$this->elementEnd('head'); $this->elementEnd('head');
$this->elementStart('body'); $this->elementStart('body');
$this->element('p', 'flagged', _('Flagged')); // TRANS: Body text for AJAX form when a profile has been flagged for review.
$this->element('p', 'flagged', _m('Flagged'));
$this->elementEnd('body'); $this->elementEnd('body');
$this->elementEnd('html'); $this->elementEnd('html');
} }
} }

View File

@ -44,7 +44,6 @@ require_once INSTALLDIR.'/lib/form.php';
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/ * @link http://status.net/
*/ */
class FlagProfileForm extends ProfileActionForm class FlagProfileForm extends ProfileActionForm
{ {
/** /**
@ -53,7 +52,6 @@ class FlagProfileForm extends ProfileActionForm
* *
* @return string class of the form * @return string class of the form
*/ */
function formClass() function formClass()
{ {
return 'form_entity_flag'; return 'form_entity_flag';
@ -64,7 +62,6 @@ class FlagProfileForm extends ProfileActionForm
* *
* @return string Name of the action, lowercased. * @return string Name of the action, lowercased.
*/ */
function target() function target()
{ {
return 'flagprofile'; return 'flagprofile';
@ -75,10 +72,10 @@ class FlagProfileForm extends ProfileActionForm
* *
* @return string Title of the form, internationalized * @return string Title of the form, internationalized
*/ */
function title() function title()
{ {
return _('Flag'); // TRANS: Form title for flagging a profile for review.
return _m('Flag');
} }
/** /**
@ -86,9 +83,9 @@ class FlagProfileForm extends ProfileActionForm
* *
* @return string description of the form, internationalized * @return string description of the form, internationalized
*/ */
function description() function description()
{ {
return _('Flag profile for review'); // TRANS: Form description.
return _m('Flag profile for review.');
} }
} }