Update translator documentation.

L10n and i18n updates.
Break long lines in README before or at 80 characters.
Superfluous whitespace removed.
This commit is contained in:
Siebrand Mazeland
2011-04-07 14:01:40 +02:00
parent f9f437f5da
commit 2640232c68
20 changed files with 182 additions and 155 deletions

View File

@@ -43,7 +43,6 @@ if (!defined('STATUSNET')) {
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
class EmailSummaryPlugin extends Plugin
{
/**
@@ -51,13 +50,11 @@ class EmailSummaryPlugin extends Plugin
*
* @return boolean hook value
*/
function onCheckSchema()
{
$schema = Schema::get();
// For storing user-submitted flags on profiles
$schema->ensureTable('email_summary_status',
array(new ColumnDef('user_id', 'integer', null,
false, 'PRI'),
@@ -80,9 +77,8 @@ class EmailSummaryPlugin extends Plugin
* @param string $cls Name of the class to be loaded
*
* @return boolean hook value; true means continue processing, false means stop.
*
*
*/
function onAutoload($cls)
{
$dir = dirname(__FILE__);
@@ -107,9 +103,7 @@ class EmailSummaryPlugin extends Plugin
* @param array &$versions array of version data
*
* @return boolean hook value; true means continue processing, false means stop.
*
*/
function onPluginVersion(&$versions)
{
$versions[] = array('name' => 'EmailSummary',
@@ -117,86 +111,84 @@ class EmailSummaryPlugin extends Plugin
'author' => 'Evan Prodromou',
'homepage' => 'http://status.net/wiki/Plugin:EmailSummary',
'rawdescription' =>
// TRANS: Plugin description.
_m('Send an email summary of the inbox to users.'));
return true;
}
/**
* Register our queue handlers
*
*
* @param QueueManager $qm Current queue manager
*
*
* @return boolean hook value
*/
function onEndInitializeQueueManager($qm)
{
$qm->connect('sitesum', 'SiteEmailSummaryHandler');
$qm->connect('usersum', 'UserEmailSummaryHandler');
return true;
}
/**
* Add a checkbox to turn off email summaries
*
*
* @param Action $action Action being executed (emailsettings)
*
*
* @return boolean hook value
*/
function onEndEmailFormData($action)
{
$user = common_current_user();
$action->elementStart('li');
$action->checkbox('emailsummary',
// TRANS: Checkbox label in e-mail preferences form.
_m('Send me a periodic summary of updates from my network.'),
_m('Send me a periodic summary of updates from my network'),
Email_summary_status::getSendSummary($user->id));
$action->elementEnd('li');
return true;
}
/**
* Add a checkbox to turn off email summaries
*
*
* @param Action $action Action being executed (emailsettings)
*
*
* @return boolean hook value
*/
function onEndEmailSaveForm($action)
{
$sendSummary = $action->boolean('emailsummary');
$user = common_current_user();
if (!empty($user)) {
$ess = Email_summary_status::staticGet('user_id', $user->id);
if (empty($ess)) {
$ess = new Email_summary_status();
$ess->user_id = $user->id;
$ess->send_summary = $sendSummary;
$ess->created = common_sql_now();
$ess->modified = common_sql_now();
$ess->insert();
} else {
$orig = clone($ess);
$ess->send_summary = $sendSummary;
$ess->modified = common_sql_now();
$ess->update($orig);
}
}
return true;
}
}

View File

@@ -35,7 +35,7 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
/**
* Data class for email summaries
*
*
* Email summary information for users
*
* @category Action
@@ -46,7 +46,6 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
*
* @see DB_DataObject
*/
class Email_summary_status extends Memcached_DataObject
{
public $__table = 'email_summary_status'; // table name
@@ -78,7 +77,6 @@ class Email_summary_status extends Memcached_DataObject
*
* @return array array of column definitions
*/
function table()
{
return array('user_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
@@ -93,7 +91,6 @@ class Email_summary_status extends Memcached_DataObject
*
* @return array list of key field names
*/
function keys()
{
return array_keys($this->keyTypes());
@@ -121,7 +118,6 @@ class Email_summary_status extends Memcached_DataObject
*
* @return array magic three-false array that stops auto-incrementing.
*/
function sequenceKey()
{
return array(false, false, false);
@@ -134,7 +130,6 @@ class Email_summary_status extends Memcached_DataObject
*
* @return int flag for whether to send this user a summary email
*/
static function getSendSummary($user_id)
{
$ess = Email_summary_status::staticGet('user_id', $user_id);
@@ -153,11 +148,10 @@ class Email_summary_status extends Memcached_DataObject
*
* @return Email_summary_status instance for this user, with count already incremented.
*/
static function getLastSummaryID($user_id)
{
$ess = Email_summary_status::staticGet('user_id', $user_id);
if (!empty($ess)) {
return $ess->last_summary_id;
} else {

View File

@@ -1,7 +1,7 @@
<?php
/*
* StatusNet - the distributed open-source microblogging tool
*
*
* Handler for queue items of type 'sitesum', sends email summaries
* to all users on the site.
*
@@ -31,7 +31,7 @@ if (!defined('STATUSNET')) {
}
/**
*
*
* Handler for queue items of type 'sitesum', sends email summaries
* to all users on the site.
*
@@ -42,7 +42,6 @@ if (!defined('STATUSNET')) {
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
class SiteEmailSummaryHandler extends QueueHandler
{
@@ -55,7 +54,6 @@ class SiteEmailSummaryHandler extends QueueHandler
*
* @return string
*/
function transport()
{
return 'sitesum';
@@ -63,21 +61,20 @@ class SiteEmailSummaryHandler extends QueueHandler
/**
* Handle the site
*
*
* @param mixed $object
* @return boolean true on success, false on failure
*/
function handle($object)
{
$qm = QueueManager::get();
try {
// Enqueue a summary for all users
$user = new User();
$user->find();
while ($user->fetch()) {
try {
$qm->enqueue($user->id, 'usersum');
@@ -89,8 +86,7 @@ class SiteEmailSummaryHandler extends QueueHandler
} catch (Exception $e) {
common_log(LOG_WARNING, $e->getMessage());
}
return true;
}
}

View File

@@ -1,7 +1,7 @@
<?php
/**
* StatusNet - the distributed open-source microblogging tool
*
*
* Handler for queue items of type 'usersum', sends an email summaries
* to a particular user.
*
@@ -41,13 +41,11 @@ if (!defined('STATUSNET')) {
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
class UserEmailSummaryHandler extends QueueHandler
{
// Maximum number of notices to include by default. This is probably too much.
const MAX_NOTICES = 200;
/**
* Return transport keyword which identifies items this queue handler
* services; must be defined for all subclasses.
@@ -57,7 +55,6 @@ class UserEmailSummaryHandler extends QueueHandler
*
* @return string
*/
function transport()
{
return 'sitesum';
@@ -65,47 +62,46 @@ class UserEmailSummaryHandler extends QueueHandler
/**
* Send a summary email to the user
*
*
* @param mixed $object
* @return boolean true on success, false on failure
*/
function handle($user_id)
{
// Skip if they've asked not to get summaries
$ess = Email_summary_status::staticGet('user_id', $user_id);
if (!empty($ess) && !$ess->send_summary) {
common_log(LOG_INFO, sprintf('Not sending email summary for user %s by request.', $user_id));
return true;
}
$since_id = null;
if (!empty($ess)) {
$since_id = $ess->last_summary_id;
}
$user = User::staticGet('id', $user_id);
if (empty($user)) {
common_log(LOG_INFO, sprintf('Not sending email summary for user %s; no such user.', $user_id));
return true;
}
if (empty($user->email)) {
common_log(LOG_INFO, sprintf('Not sending email summary for user %s; no email address.', $user_id));
return true;
}
$profile = $user->getProfile();
if (empty($profile)) {
common_log(LOG_WARNING, sprintf('Not sending email summary for user %s; no profile.', $user_id));
return true;
}
$notice = $user->ownFriendsTimeline(0, self::MAX_NOTICES, $since_id);
if (empty($notice) || $notice->N == 0) {
@@ -117,18 +113,20 @@ class UserEmailSummaryHandler extends QueueHandler
// figuring out a better way. -ESP
$new_top = null;
if ($notice instanceof ArrayWrapper) {
$new_top = $notice->_items[0]->id;
}
$out = new XMLStringer();
$out->elementStart('div', array('width' => '100%',
'style' => 'background-color: #ffffff; border: 4px solid #4c609a; padding: 10px;'));
$out->elementStart('div', array('style' => 'color: #ffffff; background-color: #4c609a; font-weight: bold; margin-bottom: 10px; padding: 4px;'));
$out->raw(sprintf(_m('Recent updates from %1s for %2s:'),
// TRANS: Text in e-mail summary.
// TRANS: %1$s is the StatusNet sitename, %2$s is the recipient's profile name.
$out->raw(sprintf(_m('Recent updates from %1$s for %2s:'),
common_config('site', 'name'),
$profile->getBestName()));
$out->elementEnd('div');
@@ -137,13 +135,12 @@ class UserEmailSummaryHandler extends QueueHandler
'style' => 'border: none; border-collapse: collapse;', 'cellpadding' => '6'));
while ($notice->fetch()) {
$profile = Profile::staticGet('id', $notice->profile_id);
if (empty($profile)) {
continue;
}
$avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
$out->elementStart('tr');
@@ -191,7 +188,7 @@ class UserEmailSummaryHandler extends QueueHandler
$out->elementEnd('td');
$out->elementEnd('tr');
}
$out->elementEnd('table');
$out->raw(sprintf(_m('<p><a href="%1s">change your email settings for %2s</a></p>'),
@@ -199,35 +196,32 @@ class UserEmailSummaryHandler extends QueueHandler
common_config('site', 'name')));
$out->elementEnd('div');
$body = $out->getString();
// FIXME: do something for people who don't like HTML email
mail_to_user($user, _m('Updates from your network'), $body,
array('Content-Type' => 'text/html; charset=UTF-8'));
if (empty($ess)) {
$ess = new Email_summary_status();
$ess->user_id = $user_id;
$ess->created = common_sql_now();
$ess->last_summary_id = $new_top;
$ess->modified = common_sql_now();
$ess->insert();
} else {
$orig = clone($ess);
$ess->last_summary_id = $new_top;
$ess->modified = common_sql_now();
$ess->update($orig);
}
return true;
}
}