]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Directory/actions/userdirectory.php
Merge commit 'refs/merge-requests/29' of https://gitorious.org/social/mainline into...
[quix0rs-gnu-social.git] / plugins / Directory / actions / userdirectory.php
index 005fb787d35a6ed096f7b9c5a8bd3ccf89b34e23..24bdd5c9fa848e7eddadc6d16bea206d81806ff6 100644 (file)
@@ -87,24 +87,27 @@ class UserdirectoryAction extends Action
      */
     function title()
     {
-        // @fixme: This looks kinda gross
+        // @todo fixme: This looks kinda gross
 
         if ($this->filter == 'all') {
             if ($this->page != 1) {
-                return(sprintf(_m('All users, page %d'), $this->page));
+                // TRANS: Page title for user directory. %d is a page number.
+                return(sprintf(_m('User Directory, page %d'), $this->page));
             }
-            return _m('All users');
-        }
-
-        if ($this->page == 1) {
+            // TRANS: Page title for user directory.
+            return _m('User directory');
+        } else if ($this->page == 1) {
             return sprintf(
-                _m('Users with nicknames beginning with %s'),
-                $this->filter
+                // TRANS: Page title for user directory. %s is the applied filter.
+                _m('User directory - %s'),
+                strtoupper($this->filter)
             );
         } else {
             return sprintf(
-                _m('Users with nicknames starting with %s, page %d'),
-                $this->filter,
+                // TRANS: Page title for user directory.
+                // TRANS: %1$s is the applied filter, %2$d is a page number.
+                _m('User directory - %1$s, page %2$d'),
+                strtoupper($this->filter),
                 $this->page
             );
         }
@@ -117,7 +120,11 @@ class UserdirectoryAction extends Action
      */
     function getInstructions()
     {
-        return _('User directory');
+        // TRANS: %%site.name%% is the name of the StatusNet site.
+        return _m('Search for people on %%site.name%% by their name, '
+            . 'location, or interests. Separate the terms by spaces; '
+            . ' they must be 3 characters or more.'
+        );
     }
 
     /**
@@ -125,7 +132,7 @@ class UserdirectoryAction extends Action
      *
      * @return boolean true
      */
-    function isReadOnly($args)
+    function isReadOnly(array $args=array())
     {
         return true;
     }
@@ -137,7 +144,7 @@ class UserdirectoryAction extends Action
      *
      * @return boolean success flag
      */
-    function prepare($args)
+    function prepare(array $args=array())
     {
         parent::prepare($args);
 
@@ -161,7 +168,7 @@ class UserdirectoryAction extends Action
      *
      * @return void
      */
-    function handle($args)
+    function handle(array $args=array())
     {
         parent::handle($args);
         $this->showPage();
@@ -184,18 +191,6 @@ class UserdirectoryAction extends Action
         $this->elementEnd('div');
     }
 
-    /**
-     * Local navigation
-     *
-     * This page is part of the public group, so show that.
-     *
-     * @return void
-     */
-    function showLocalNav()
-    {
-        $nav = new PublicGroupNav($this);
-        $nav->show();
-    }
 
     /**
      * Content area
@@ -208,9 +203,9 @@ class UserdirectoryAction extends Action
     {
         $this->showForm();
 
-        $this->elementStart('div', array('id' => 'user_directory'));
+        $this->elementStart('div', array('id' => 'profile_directory'));
 
-        $alphaNav = new AlphaNav($this, true, array('All'));
+        $alphaNav = new AlphaNav($this, false, false, array('0-9', 'All'));
         $alphaNav->show();
 
         $profile = null;
@@ -235,9 +230,16 @@ class UserdirectoryAction extends Action
         $args = array();
         if (isset($this->q)) {
             $args['q'] = $this->q;
-        } else {
+        } elseif (isset($this->filter) && $this->filter != 'all') {
             $args['filter'] = $this->filter;
         }
+        
+        if (isset($this->sort)) {
+            $args['sort'] = $this->sort;
+        }        
+        if (!empty($this->reverse)) {
+            $args['reverse'] = $this->reverse;
+        }
 
         $this->pagination(
             $this->page > 1,
@@ -265,12 +267,15 @@ class UserdirectoryAction extends Action
 
         $this->elementStart('fieldset');
 
-        $this->element('legend', null, _('Search site'));
+        // TRANS: Fieldset legend.
+        $this->element('legend', null, _m('Search site'));
         $this->elementStart('ul', 'form_data');
         $this->elementStart('li');
 
-        $this->input('q', _('Keyword(s)'), $this->q);
+        // TRANS: Field label for user directory filter.
+        $this->input('q', _m('Keyword(s)'), $this->q);
 
+        // TRANS: Button text.
         $this->submit('search', _m('BUTTON','Search'));
         $this->elementEnd('li');
         $this->elementEnd('ul');
@@ -317,7 +322,16 @@ class UserdirectoryAction extends Action
             $sort   = $this->getSortKey();
             $sql    = 'SELECT profile.* FROM profile, user WHERE profile.id = user.id';
 
-            if ($this->filter != 'all') {
+            switch($this->filter)
+            {
+            case 'all':
+                // NOOP
+                break;
+            case '0-9':
+                $sql .=
+                    '  AND LEFT(profile.nickname, 1) BETWEEN \'0\' AND \'9\'';
+                break;
+            default:
                 $sql .= sprintf(
                     ' AND LEFT(LOWER(profile.nickname), 1) = \'%s\'',
                     $this->filter
@@ -362,11 +376,29 @@ class UserdirectoryAction extends Action
      */
     function showEmptyListMessage()
     {
-        $message = sprintf(_m('No users starting with **%s**'), $this->filter);
-
-        $this->elementStart('div', 'guide');
-        $this->raw(common_markup_to_html($message));
-        $this->elementEnd('div');
+        if (!empty($this->filter) && ($this->filter != 'all')) {
+            $this->element(
+                'p',
+                'error',
+                sprintf(
+                    // TRANS: Empty list message for user directory.
+                    _m('No users starting with %s'),
+                    $this->filter
+                )
+            );
+        } else {
+            // TRANS: Empty list message for user directory.
+            $this->element('p', 'error', _m('No results.'));
+            // TRANS: Standard search suggestions shown when a search does not give any results.
+            $message = _m("* Make sure all words are spelled correctly.
+* Try different keywords.
+* Try more general keywords.
+* Try fewer keywords.");
+            $message .= "\n";
+
+            $this->elementStart('div', 'help instructions');
+            $this->raw(common_markup_to_html($message));
+            $this->elementEnd('div');
+        }
     }
-
 }