]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Facebook/FBConnectAuth.php
Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 1.0.x
[quix0rs-gnu-social.git] / plugins / Facebook / FBConnectAuth.php
index 165477419a2efe0f3c0d770ee316a21285b24893..f06dffaaabbd789a71b6f4ee535fc48ffba0cd85 100644 (file)
@@ -48,8 +48,8 @@ class FBConnectauthAction extends Action
             common_log(LOG_WARNING, 'Facebook Connect Plugin - ' .
                        "Failed auth attempt, proxy = $proxy, ip = $ip.");
 
-            $this->clientError(_('You must be logged into Facebook to ' .
-                                 'use Facebook Connect.'));
+            $this->clientError(_m('You must be logged into Facebook to ' .
+                                  'use Facebook Connect.'));
         }
 
         return true;
@@ -60,22 +60,19 @@ class FBConnectauthAction extends Action
         parent::handle($args);
 
         if (common_is_real_login()) {
-
             // User is already logged in.  Does she already have a linked Facebook acct?
             $flink = Foreign_link::getByForeignID($this->fbuid, FACEBOOK_CONNECT_SERVICE);
 
             if (!empty($flink)) {
-
                 // User already has a linked Facebook account and shouldn't be here
                 common_debug('Facebook Connect Plugin - ' .
                              'There is already a local user (' . $flink->user_id .
                              ') linked with this Facebook (' . $this->fbuid . ').');
 
-                // We do not want these cookies
+                // We don't want these cookies
                 getFacebook()->clear_cookie_state();
 
-                $this->clientError(_('There is already a local user linked with this Facebook.'));
-
+                $this->clientError(_m('There is already a local user linked with this Facebook account.'));
             } else {
 
                 // User came from the Facebook connect settings tab, and
@@ -87,12 +84,12 @@ class FBConnectauthAction extends Action
 
             $token = $this->trimmed('token');
             if (!$token || $token != common_session_token()) {
-                $this->showForm(_('There was a problem with your session token. Try again, please.'));
+                $this->showForm(_m('There was a problem with your session token. Try again, please.'));
                 return;
             }
             if ($this->arg('create')) {
                 if (!$this->boolean('license')) {
-                    $this->showForm(_('You can\'t register if you don\'t agree to the license.'),
+                    $this->showForm(_m('You can\'t register if you don\'t agree to the license.'),
                                     $this->trimmed('newname'));
                     return;
                 }
@@ -102,7 +99,7 @@ class FBConnectauthAction extends Action
             } else {
                 common_debug('Facebook Connect Plugin - ' .
                              print_r($this->args, true));
-                $this->showForm(_('Something weird happened.'),
+                $this->showForm(_m('An unknown error has occured.'),
                                 $this->trimmed('newname'));
             }
         } else {
@@ -116,13 +113,15 @@ class FBConnectauthAction extends Action
             $this->element('div', array('class' => 'error'), $this->error);
         } else {
             $this->element('div', 'instructions',
-                           sprintf(_('This is the first time you\'ve logged into %s so we must connect your Facebook to a local account. You can either create a new account, or connect with your existing account, if you have one.'), common_config('site', 'name')));
+                           // TRANS: %s is the site name.
+                           sprintf(_m('This is the first time you\'ve logged into %s so we must connect your Facebook to a local account. You can either create a new account, or connect with your existing account, if you have one.'), common_config('site', 'name')));
         }
     }
 
     function title()
     {
-        return _('Facebook Account Setup');
+        // TRANS: Page title.
+        return _m('Facebook Account Setup');
     }
 
     function showForm($error=null, $username=null)
@@ -138,6 +137,11 @@ class FBConnectauthAction extends Action
         parent::showPage();
     }
 
+    /**
+     * @fixme much of this duplicates core code, which is very fragile.
+     * Should probably be replaced with an extensible mini version of
+     * the core registration form.
+     */
     function showContent()
     {
         if (!empty($this->message_text)) {
@@ -150,7 +154,8 @@ class FBConnectauthAction extends Action
                                           'class' => 'form_settings',
                                           'action' => common_local_url('FBConnectAuth')));
         $this->elementStart('fieldset', array('id' => 'settings_facebook_connect_options'));
-        $this->element('legend', null, _('Connection options'));
+        // TRANS: Legend.
+        $this->element('legend', null, _m('Connection options'));
         $this->elementStart('ul', 'form_data');
         $this->elementStart('li');
         $this->element('input', array('type' => 'checkbox',
@@ -159,10 +164,16 @@ class FBConnectauthAction extends Action
                                       'name' => 'license',
                                       'value' => 'true'));
         $this->elementStart('label', array('class' => 'checkbox', 'for' => 'license'));
-        $this->text(_('My text and files are available under '));
-        $this->element('a', array('href' => common_config('license', 'url')),
-                       common_config('license', 'title'));
-        $this->text(_(' except this private data: password, email address, IM address, phone number.'));
+        // TRANS: %s is the name of the license used by the user for their status updates.
+        $message = _m('My text and files are available under %s ' .
+                     'except this private data: password, ' .
+                     'email address, IM address, and phone number.');
+        $link = '<a href="' .
+                htmlspecialchars(common_config('license', 'url')) .
+                '">' .
+                htmlspecialchars(common_config('license', 'title')) .
+                '</a>';
+        $this->raw(sprintf(htmlspecialchars($message), $link));
         $this->elementEnd('label');
         $this->elementEnd('li');
         $this->elementEnd('ul');
@@ -170,33 +181,39 @@ class FBConnectauthAction extends Action
         $this->elementStart('fieldset');
         $this->hidden('token', common_session_token());
         $this->element('legend', null,
-                       _('Create new account'));
+                       // TRANS: Legend.
+                       _m('Create new account'));
         $this->element('p', null,
-                       _('Create a new user with this nickname.'));
+                       _m('Create a new user with this nickname.'));
         $this->elementStart('ul', 'form_data');
         $this->elementStart('li');
-        $this->input('newname', _('New nickname'),
+        // TRANS: Field label.
+        $this->input('newname', _m('New nickname'),
                      ($this->username) ? $this->username : '',
-                     _('1-64 lowercase letters or numbers, no punctuation or spaces'));
+                     _m('1-64 lowercase letters or numbers, no punctuation or spaces'));
         $this->elementEnd('li');
         $this->elementEnd('ul');
-        $this->submit('create', _('Create'));
+        // TRANS: Submit button.
+        $this->submit('create', _m('BUTTON','Create'));
         $this->elementEnd('fieldset');
 
         $this->elementStart('fieldset');
+        // TRANS: Legend.
         $this->element('legend', null,
-                       _('Connect existing account'));
+                       _m('Connect existing account'));
         $this->element('p', null,
-                       _('If you already have an account, login with your username and password to connect it to your Facebook.'));
+                       _m('If you already have an account, login with your username and password to connect it to your Facebook.'));
         $this->elementStart('ul', 'form_data');
         $this->elementStart('li');
-        $this->input('nickname', _('Existing nickname'));
+        // TRANS: Field label.
+        $this->input('nickname', _m('Existing nickname'));
         $this->elementEnd('li');
         $this->elementStart('li');
-        $this->password('password', _('Password'));
+        $this->password('password', _m('Password'));
         $this->elementEnd('li');
         $this->elementEnd('ul');
-        $this->submit('connect', _('Connect'));
+        // TRANS: Submit button.
+        $this->submit('connect', _m('BUTTON','Connect'));
         $this->elementEnd('fieldset');
 
         $this->elementEnd('fieldset');
@@ -212,7 +229,8 @@ class FBConnectauthAction extends Action
     function createNewUser()
     {
         if (common_config('site', 'closed')) {
-            $this->clientError(_('Registration not allowed.'));
+            // TRANS: Client error trying to register with registrations not allowed.
+            $this->clientError(_m('Registration not allowed.'));
             return;
         }
 
@@ -221,14 +239,16 @@ class FBConnectauthAction extends Action
         if (common_config('site', 'inviteonly')) {
             $code = $_SESSION['invitecode'];
             if (empty($code)) {
-                $this->clientError(_('Registration not allowed.'));
+                // TRANS: Client error trying to register with registrations 'invite only'.
+                $this->clientError(_m('Registration not allowed.'));
                 return;
             }
 
             $invite = Invitation::staticGet($code);
 
             if (empty($invite)) {
-                $this->clientError(_('Not a valid invitation code.'));
+                // TRANS: Client error trying to register with an invalid invitation code.
+                $this->clientError(_m('Not a valid invitation code.'));
                 return;
             }
         }
@@ -238,17 +258,17 @@ class FBConnectauthAction extends Action
         if (!Validate::string($nickname, array('min_length' => 1,
                                                'max_length' => 64,
                                                'format' => NICKNAME_FMT))) {
-            $this->showForm(_('Nickname must have only lowercase letters and numbers and no spaces.'));
+            $this->showForm(_m('Nickname must have only lowercase letters and numbers and no spaces.'));
             return;
         }
 
         if (!User::allowed_nickname($nickname)) {
-            $this->showForm(_('Nickname not allowed.'));
+            $this->showForm(_m('Nickname not allowed.'));
             return;
         }
 
         if (User::staticGet('nickname', $nickname)) {
-            $this->showForm(_('Nickname already in use. Try another one.'));
+            $this->showForm(_m('Nickname already in use. Try another one.'));
             return;
         }
 
@@ -266,7 +286,7 @@ class FBConnectauthAction extends Action
         $result = $this->flinkUser($user->id, $this->fbuid);
 
         if (!$result) {
-            $this->serverError(_('Error connecting user to Facebook.'));
+            $this->serverError(_m('Error connecting user to Facebook.'));
             return;
         }
 
@@ -286,7 +306,7 @@ class FBConnectauthAction extends Action
         $password = $this->trimmed('password');
 
         if (!common_check_user($nickname, $password)) {
-            $this->showForm(_('Invalid username or password.'));
+            $this->showForm(_m('Invalid username or password.'));
             return;
         }
 
@@ -300,7 +320,7 @@ class FBConnectauthAction extends Action
         $result = $this->flinkUser($user->id, $this->fbuid);
 
         if (!$result) {
-            $this->serverError(_('Error connecting user to Facebook.'));
+            $this->serverError(_m('Error connecting user to Facebook.'));
             return;
         }
 
@@ -320,7 +340,7 @@ class FBConnectauthAction extends Action
         $result = $this->flinkUser($user->id, $this->fbuid);
 
         if (empty($result)) {
-            $this->serverError(_('Error connecting user to Facebook.'));
+            $this->serverError(_m('Error connecting user to Facebook.'));
             return;
         }
 
@@ -364,7 +384,7 @@ class FBConnectauthAction extends Action
     {
         $url = common_get_returnto();
         if ($url) {
-            // We do not have to return to it again
+            // We don't have to return to it again
             common_set_returnto(null);
         } else {
             $url = common_local_url('all',
@@ -412,8 +432,9 @@ class FBConnectauthAction extends Action
         return null;
     }
 
-     // Given a string, try to make it work as a nickname
-
+     /**
+      * Given a string, try to make it work as a nickname
+      */
      function nicknamize($str)
      {
          $str = preg_replace('/\W/', '', $str);
@@ -457,5 +478,4 @@ class FBConnectauthAction extends Action
             return null;
         }
     }
-
 }