]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Bookmark/importdelicious.php
Merge branch 'testing' of gitorious.org:statusnet/mainline into testing
[quix0rs-gnu-social.git] / plugins / Bookmark / importdelicious.php
index b98b215717c1b286685af92baab4908c84f0644d..85a63e847063645f87abf69c4157e335d6b9e35a 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2010, StatusNet, Inc.
  *
  * Import del.icio.us bookmarks backups
- * 
+ *
  * PHP version 5
  *
  * This program is free software: you can redistribute it and/or modify
@@ -44,7 +44,6 @@ if (!defined('STATUSNET')) {
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  * @link      http://status.net/
  */
-
 class ImportdeliciousAction extends Action
 {
     protected $success = false;
@@ -55,10 +54,10 @@ class ImportdeliciousAction extends Action
      *
      * @return string page title
      */
-
     function title()
     {
-        return _("Import del.icio.us bookmarks");
+        // TRANS: Title for page to import del.icio.us bookmark backups on.
+        return _m("Import del.icio.us bookmarks");
     }
 
     /**
@@ -68,7 +67,6 @@ class ImportdeliciousAction extends Action
      *
      * @return boolean true
      */
-
     function prepare($argarray)
     {
         parent::prepare($argarray);
@@ -76,13 +74,15 @@ class ImportdeliciousAction extends Action
         $cur = common_current_user();
 
         if (empty($cur)) {
-            throw new ClientException(_('Only logged-in users can '.
+            // TRANS: Client exception thrown when trying to import bookmarks without being logged in.
+            throw new ClientException(_m('Only logged-in users can '.
                                         'import del.icio.us backups.'),
                                       403);
         }
 
         if (!$cur->hasRight(BookmarkPlugin::IMPORTDELICIOUS)) {
-            throw new ClientException(_('You may not restore your account.'), 403);
+            // TRANS: Client exception thrown when trying to import bookmarks without having the rights to do so.
+            throw new ClientException(_m('You may not restore your account.'), 403);
         }
 
         return true;
@@ -95,7 +95,6 @@ class ImportdeliciousAction extends Action
      *
      * @return void
      */
-
     function handle($argarray=null)
     {
         parent::handle($argarray);
@@ -110,18 +109,18 @@ class ImportdeliciousAction extends Action
 
     /**
      * Queue a file for importation
-     * 
+     *
      * Uses the DeliciousBackupImporter class; may take a long time!
      *
      * @return void
      */
-
     function importDelicious()
     {
         $this->checkSessionToken();
 
         if (!isset($_FILES[ImportDeliciousForm::FILEINPUT]['error'])) {
-            throw new ClientException(_('No uploaded file.'));
+            // TRANS: Client exception thrown when trying to import bookmarks and upload fails.
+            throw new ClientException(_m('No uploaded file.'));
         }
 
         switch ($_FILES[ImportDeliciousForm::FILEINPUT]['error']) {
@@ -129,42 +128,43 @@ class ImportdeliciousAction extends Action
             break;
         case UPLOAD_ERR_INI_SIZE:
             // TRANS: Client exception thrown when an uploaded file is too large.
-            throw new ClientException(_('The uploaded file exceeds the ' .
+            throw new ClientException(_m('The uploaded file exceeds the ' .
                 'upload_max_filesize directive in php.ini.'));
             return;
         case UPLOAD_ERR_FORM_SIZE:
             throw new ClientException(
-                // TRANS: Client exception.
-                _('The uploaded file exceeds the MAX_FILE_SIZE directive' .
+            // TRANS: Client exception thrown when an uploaded file is too large.
+                _m('The uploaded file exceeds the MAX_FILE_SIZE directive' .
                 ' that was specified in the HTML form.'));
             return;
         case UPLOAD_ERR_PARTIAL:
             @unlink($_FILES[ImportDeliciousForm::FILEINPUT]['tmp_name']);
-            // TRANS: Client exception.
-            throw new ClientException(_('The uploaded file was only' .
+            // TRANS: Client exception thrown when a file was only partially uploaded.
+            throw new ClientException(_m('The uploaded file was only' .
                 ' partially uploaded.'));
             return;
         case UPLOAD_ERR_NO_FILE:
             // No file; probably just a non-AJAX submission.
-            throw new ClientException(_('No uploaded file.'));
+            // TRANS: Client exception thrown when a file upload has failed.
+            throw new ClientException(_m('No uploaded file.'));
             return;
         case UPLOAD_ERR_NO_TMP_DIR:
-            // TRANS: Client exception thrown when a temporary folder is not present
-            throw new ClientException(_('Missing a temporary folder.'));
+            // TRANS: Client exception thrown when a temporary folder is not present.
+            throw new ClientException(_m('Missing a temporary folder.'));
             return;
         case UPLOAD_ERR_CANT_WRITE:
-            // TRANS: Client exception thrown when writing to disk is not possible
-            throw new ClientException(_('Failed to write file to disk.'));
+            // TRANS: Client exception thrown when writing to disk is not possible.
+            throw new ClientException(_m('Failed to write file to disk.'));
             return;
         case UPLOAD_ERR_EXTENSION:
-            // TRANS: Client exception thrown when a file upload has been stopped
-            throw new ClientException(_('File upload stopped by extension.'));
+            // TRANS: Client exception thrown when a file upload has been stopped.
+            throw new ClientException(_m('File upload stopped by extension.'));
             return;
         default:
             common_log(LOG_ERR, __METHOD__ . ": Unknown upload error " .
                 $_FILES[ImportDeliciousForm::FILEINPUT]['error']);
-            // TRANS: Client exception thrown when a file upload operation has failed
-            throw new ClientException(_('System error uploading file.'));
+            // TRANS: Client exception thrown when a file upload operation has failed.
+            throw new ClientException(_m('System error uploading file.'));
             return;
         }
 
@@ -172,18 +172,24 @@ class ImportdeliciousAction extends Action
 
         try {
             if (!file_exists($filename)) {
-                throw new ServerException("No such file '$filename'.");
+                // TRANS: Server exception thrown when a file upload cannot be found.
+                // TRANS: %s is the file that could not be found.
+                throw new ServerException(sprintf(_m('No such file "%s".'),$filename));
             }
-        
+
             if (!is_file($filename)) {
-                throw new ServerException("Not a regular file: '$filename'.");
+                // TRANS: Server exception thrown when a file upload is incorrect.
+                // TRANS: %s is the irregular file.
+                throw new ServerException(sprintf(_m('Not a regular file: "%s".'),$filename));
             }
-        
+
             if (!is_readable($filename)) {
-                throw new ServerException("File '$filename' not readable.");
+                // TRANS: Server exception thrown when a file upload is not readable.
+                // TRANS: %s is the file that could not be read.
+                throw new ServerException(sprintf(_m('File "%s" not readable.'),$filename));
             }
-        
-            common_debug(sprintf(_("Getting backup from file '%s'."), $filename));
+
+            common_debug(sprintf("Getting backup from file '%s'.", $filename));
 
             $html = file_get_contents($filename);
 
@@ -214,15 +220,16 @@ class ImportdeliciousAction extends Action
      *
      * @return void
      */
-
     function showContent()
     {
         if ($this->success) {
             $this->element('p', null,
-                           _('Bookmarks have been imported. Your bookmarks should now appear in search and your profile page.'));
+                           // TRANS: Success message after importing bookmarks.
+                           _m('Bookmarks have been imported. Your bookmarks should now appear in search and your profile page.'));
         } else if ($this->inprogress) {
             $this->element('p', null,
-                           _('Bookmarks are being imported. Please wait a few minutes for results.'));
+                           // TRANS: Busy message for importing bookmarks.
+                           _m('Bookmarks are being imported. Please wait a few minutes for results.'));
         } else {
             $form = new ImportDeliciousForm($this);
             $form->show();
@@ -238,7 +245,6 @@ class ImportdeliciousAction extends Action
      *
      * @return boolean is read only action?
      */
-
     function isReadOnly($args)
     {
         return !$this->isPost();
@@ -255,21 +261,19 @@ class ImportdeliciousAction extends Action
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  * @link      http://status.net/
  */
-
 class ImportDeliciousForm extends Form
 {
     const FILEINPUT = 'deliciousbackupfile';
 
     /**
      * Constructor
-     * 
+     *
      * Set the encoding type, since this is a file upload.
      *
      * @param HTMLOutputter $out output channel
      *
      * @return ImportDeliciousForm this
      */
-
     function __construct($out=null)
     {
         parent::__construct($out);
@@ -281,7 +285,6 @@ class ImportDeliciousForm extends Form
      *
      * @return string the form's class
      */
-
     function formClass()
     {
         return 'form_import_delicious';
@@ -292,7 +295,6 @@ class ImportDeliciousForm extends Form
      *
      * @return string the form's action URL
      */
-
     function action()
     {
         return common_local_url('importdelicious');
@@ -300,19 +302,19 @@ class ImportDeliciousForm extends Form
 
     /**
      * Output form data
-     * 
+     *
      * Really, just instructions for doing a backup.
      *
      * @return void
      */
-
     function formData()
     {
         $this->out->elementStart('p', 'instructions');
 
-        $this->out->raw(_('You can upload a backed-up '.
+        // TRANS: Form instructions for importing bookmarks.
+        $this->out->raw(_m('You can upload a backed-up '.
                           'delicious.com bookmarks file.'));
-        
+
         $this->out->elementEnd('p');
 
         $this->out->elementStart('ul', 'form_data');
@@ -328,7 +330,7 @@ class ImportDeliciousForm extends Form
 
     /**
      * Buttons for the form
-     * 
+     *
      * In this case, a single submit button
      *
      * @return void
@@ -337,9 +339,11 @@ class ImportDeliciousForm extends Form
     function formActions()
     {
         $this->out->submit('submit',
+                           // TRANS: Button text on form to import bookmarks.
                            _m('BUTTON', 'Upload'),
                            'submit',
                            null,
-                           _('Upload the file'));
+                           // TRANS: Button title on form to import bookmarks.
+                           _m('Upload the file.'));
     }
 }