$bestname = $profile->getBestName();
$sitename = common_config('site', 'name');
$personal = $this->trimmed('personal');
+ $language = $this->trimmed('language');
$addresses = explode("\n", $this->trimmed('addresses'));
foreach ($addresses as $email) {
} catch (NoSuchUserException $e) {
// If email was not known, let's send an invite!
$this->sent[] = $email;
- $this->sendInvitation($email, $user, $personal);
+ $this->sendInvitation($email, $user, $personal, $language);
}
}
}
}
- function sendInvitation($email, $user, $personal)
+ function sendInvitation($email, $user, $personal, $language)
{
$profile = $user->getProfile();
$bestname = $profile->getBestName();
$title = (empty($personal)) ? 'invite' : 'invitepersonal';
// @todo FIXME: i18n issue.
- $inviteTemplate = DocFile::forTitle($title, DocFile::mailPaths());
+ $inviteTemplate = DocFile::forTitle($title, DocFile::mailPaths(), $language);
$body = $inviteTemplate->toHTML(array('inviter' => $bestname,
'inviterurl' => $profile->profileurl,
$this->filename = $filename;
}
- static function forTitle($title, $paths)
+ static function forTitle($title, array $paths, $language=null)
{
- if (!is_array($paths)) {
- $paths = array($paths);
- }
-
$filename = null;
if (Event::handle('StartDocFileForTitle', array($title, &$paths, &$filename))) {
}
if (!empty($lang) || !empty($def)) {
- $filename = self::negotiateLanguage($lang, $def);
+ $filename = self::negotiateLanguage($lang, $def, $language);
break;
}
}
}
}
- function toHTML($args=null)
+ function toHTML(array $args=array())
{
- if (is_null($args)) {
- $args = array();
- }
-
if (empty($this->contents)) {
$this->contents = file_get_contents($this->filename);
}
INSTALLDIR.'/doc-src/');
$site = StatusNet::currentSite();
-
+
if (!empty($site)) {
array_unshift($paths, INSTALLDIR.'/local/doc-src/'.$site.'/');
}
INSTALLDIR.'/mail-src/');
$site = StatusNet::currentSite();
-
+
if (!empty($site)) {
array_unshift($paths, INSTALLDIR.'/local/mail-src/'.$site.'/');
}
return $paths;
}
- static function negotiateLanguage($filenames, $defaultFilename=null)
+ private static function negotiateLanguage(array $filenames, $defaultFilename=null, $language = null)
{
- // XXX: do this better
-
+ // Default is current language
$langcode = common_language();
+ // Is a language set?
+ if (!empty($language)) {
+ // And is it valid?
+ if (common_valid_language($language)) {
+ // Use this as language (e.g. from form)
+ $langcode = strval($language);
+ }
+ }
+
foreach ($filenames as $filename) {
if (preg_match('/\.'.$langcode.'$/', $filename)) {
return $filename;
function formData()
{
$this->out->elementStart('ul', 'form_data');
+
$this->out->elementStart('li');
$this->out->textarea(
'addresses',
_('Addresses of friends to invite (one per line).')
);
$this->out->elementEnd('li');
+
$this->out->elementStart('li');
$this->out->textarea(
// TRANS: Field label for a personal message to send to invitees.
_('Optionally add a personal message to the invitation.')
);
$this->out->elementEnd('li');
+
+ $language = common_language();
+
+ $this->out->elementStart('li');
+ $this->out->dropdown('language', _('Language'),
+ // TRANS: Tooltip for dropdown list label in form for profile settings.
+ get_nice_language_list(), _('Preferred language.'),
+ false, $language);
+ $this->out->elementEnd('li');
+
$this->out->elementEnd('ul');
}
$dir = dirname(__FILE__);
// @todo FIXME: i18n issue.
- $docFile = DocFile::forTitle($title, $dir.'/doc-src/');
+ $docFile = DocFile::forTitle($title, array($dir . '/doc-src/'));
if (!empty($docFile)) {
$output = $docFile->toHTML();
mail_send($recipients, $headers, $body);
}
- function onEndDocFileForTitle($title, $paths, &$filename)
+ function onEndDocFileForTitle($title, array $paths, &$filename)
{
if ($title == 'confirmemailreg' && empty($filename)) {
$filename = dirname(__FILE__).'/mail-src/'.$title;
return true;
}
- function onEndDocFileForTitle($title, $paths, &$filename)
+ function onEndDocFileForTitle($title, array $paths, &$filename)
{
if (empty($filename)) {
$filename = dirname(__FILE__) . '/mail-src/' . $title;
* Send a real live email reminder
*
* @todo This would probably be better as two or more sep functions
+ * @todo Add language support?
*
* @param string $type type of reminder
* @param mixed $object Confirm_address or Invitation object