[geeklog-cvs] geeklog: Added a config option to define the default sort order ...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sun Nov 29 13:25:50 EST 2009


changeset 7498:6c5a648a4d05
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/6c5a648a4d05
user: Dirk Haun <dirk at haun-online.de>
date: Sun Nov 29 19:10:37 2009 +0100
description:
Added a config option to define the default sort order for the admin's list of Static Pages (feature request #0000812)

diffstat:

 plugins/staticpages/functions.inc               |  84 +++++++++++++++------------
 plugins/staticpages/install_defaults.php        |   5 +
 plugins/staticpages/language/english.php        |   2 +
 plugins/staticpages/language/english_utf-8.php  |   2 +
 plugins/staticpages/sql/mssql_updates.php       |   2 +
 plugins/staticpages/sql/mysql_updates.php       |   2 +
 public_html/admin/plugins/staticpages/index.php |  48 ++++++++++++---
 public_html/docs/english/staticpages.html       |  26 +++++---
 public_html/docs/history                        |   2 +
 9 files changed, 116 insertions(+), 57 deletions(-)

diffs (truncated from 355 to 300 lines):

diff -r 8bd93a61ca0e -r 6c5a648a4d05 plugins/staticpages/functions.inc
--- a/plugins/staticpages/functions.inc	Sun Nov 29 18:04:39 2009 +0100
+++ b/plugins/staticpages/functions.inc	Sun Nov 29 19:10:37 2009 +0100
@@ -1183,46 +1183,56 @@
 
 function plugin_getListField_staticpages($fieldname, $fieldvalue, $A, $icon_arr)
 {
-    global $_CONF, $LANG_ADMIN, $LANG_STATIC, $_TABLES;
+    global $_CONF, $_TABLES, $LANG_ADMIN, $LANG_STATIC;
 
-    switch($fieldname) {
-        case "edit":
-            $retval = COM_createLink($icon_arr['edit'],
-                "{$_CONF['site_admin_url']}/plugins/staticpages/index.php?mode=edit&sp_id={$A['sp_id']}");
-            break;
-        case "copy":
-            $retval = COM_createLink($icon_arr['copy'],
-                "{$_CONF['site_admin_url']}/plugins/staticpages/index.php?mode=clone&sp_id={$A['sp_id']}");
-            break;
-        case "sp_title":
-            $sp_title = stripslashes ($A['sp_title']);
-            $url = COM_buildUrl ($_CONF['site_url'] .
-                                 '/staticpages/index.php?page=' . $A['sp_id']);
-            $retval = COM_createLink($sp_title, $url, array('title'=>$LANG_STATIC['title_display']));
-            break;
-        case "sp_uid":
-            $retval = COM_getDisplayName ($A['sp_uid']);
-            break;
-        case "sp_centerblock":
-            if ($A['sp_centerblock']) {
-                switch ($A['sp_where']) {
-                    case '1': $where = $LANG_STATIC['centerblock_top']; break;
-                    case '2': $where = $LANG_STATIC['centerblock_feat']; break;
-                    case '3': $where = $LANG_STATIC['centerblock_bottom']; break;
-                    default:  $where = $LANG_STATIC['centerblock_entire']; break;
-                }
-                $retval = $where;
-            } else {
-                $retval = $LANG_STATIC['centerblock_no'];
+    switch ($fieldname) {
+    case 'edit':
+        $retval = COM_createLink($icon_arr['edit'],
+            "{$_CONF['site_admin_url']}/plugins/staticpages/index.php?mode=edit&sp_id={$A['sp_id']}");
+        break;
+
+    case 'copy':
+        $retval = COM_createLink($icon_arr['copy'],
+            "{$_CONF['site_admin_url']}/plugins/staticpages/index.php?mode=clone&sp_id={$A['sp_id']}");
+        break;
+
+    case 'sp_title':
+        $sp_title = stripslashes($A['sp_title']);
+        $url = COM_buildUrl($_CONF['site_url'] .
+                            '/staticpages/index.php?page=' . $A['sp_id']);
+        $retval = COM_createLink($sp_title, $url,
+                    array('title' => $LANG_STATIC['title_display']));
+        break;
+
+    case 'username':
+    case 'fullname':
+        $retval = COM_getDisplayName($A['sp_uid'], $A['username'],
+                                     $A['fullname']);
+        break;
+
+    case 'sp_centerblock':
+        if ($A['sp_centerblock']) {
+            switch ($A['sp_where']) {
+                case '1': $where = $LANG_STATIC['centerblock_top'];    break;
+                case '2': $where = $LANG_STATIC['centerblock_feat'];   break;
+                case '3': $where = $LANG_STATIC['centerblock_bottom']; break;
+                default:  $where = $LANG_STATIC['centerblock_entire']; break;
             }
-            break;
-        case "unixdate":
-            $retval = strftime ($_CONF['daytime'], $A['unixdate']);
-            break;
-        default:
-            $retval = $fieldvalue;
-            break;
+            $retval = $where;
+        } else {
+            $retval = $LANG_STATIC['centerblock_no'];
+        }
+        break;
+
+    case 'unixdate':
+        $retval = strftime($_CONF['daytime'], $A['unixdate']);
+        break;
+
+    default:
+        $retval = $fieldvalue;
+        break;
     }
+
     return $retval;
 }
 
diff -r 8bd93a61ca0e -r 6c5a648a4d05 plugins/staticpages/install_defaults.php
--- a/plugins/staticpages/install_defaults.php	Sun Nov 29 18:04:39 2009 +0100
+++ b/plugins/staticpages/install_defaults.php	Sun Nov 29 19:10:37 2009 +0100
@@ -65,6 +65,9 @@
 // (assuming you're using a theme that uses the {plg_menu_elements} variable)
 $_SP_DEFAULT['sort_menu_by'] = 'label'; // can be 'id', 'label', 'title', 'date'
 
+// Sort admin list by which field?
+$_SP_DEFAULT['sort_list_by'] = 'title'; // can be 'id', 'title', 'date', 'author'
+
 // When a user is deleted, ownership of static pages created by that user can
 // be transfered to a user in the Root group (= 0) or the pages can be
 // deleted (= 1).
@@ -159,6 +162,8 @@
                 0, 0, 2, 20, true, 'staticpages');
         $c->add('sort_menu_by', $_SP_DEFAULT['sort_menu_by'], 'select',
                 0, 0, 3, 30, true, 'staticpages');
+        $c->add('sort_list_by', $_SP_DEFAULT['sort_list_by'], 'select',
+                0, 0, 4, 35, true, 'staticpages');
         $c->add('delete_pages', $_SP_DEFAULT['delete_pages'], 'select',
                 0, 0, 0, 40, true, 'staticpages');
         $c->add('in_block', $_SP_DEFAULT['in_block'], 'select',
diff -r 8bd93a61ca0e -r 6c5a648a4d05 plugins/staticpages/language/english.php
--- a/plugins/staticpages/language/english.php	Sun Nov 29 18:04:39 2009 +0100
+++ b/plugins/staticpages/language/english.php	Sun Nov 29 19:10:37 2009 +0100
@@ -133,6 +133,7 @@
     'allow_php' => 'Allow PHP?',
     'sort_by' => 'Sort Centerblocks by',
     'sort_menu_by' => 'Sort Menu Entries by',
+    'sort_list_by' => 'Sort Admin List by',
     'delete_pages' => 'Delete Pages with Owner?',
     'in_block' => 'Wrap Pages in Block?',
     'show_hits' => 'Show Hits?',
@@ -171,6 +172,7 @@
     1 => array('True' => TRUE, 'False' => FALSE),
     2 => array('Date' => 'date', 'Page ID' => 'id', 'Title' => 'title'),
     3 => array('Date' => 'date', 'Page ID' => 'id', 'Title' => 'title', 'Label' => 'label'),
+    4 => array('Date' => 'date', 'Page ID' => 'id', 'Title' => 'title', 'Author' => 'author'),
     9 => array('Forward to page' => 'item', 'Display List' => 'list', 'Display Home' => 'home', 'Display Admin' => 'admin'),
     12 => array('No access' => 0, 'Read-Only' => 2, 'Read-Write' => 3),
     17 => array('Comments Enabled' => 0, 'Comments Disabled' => -1)
diff -r 8bd93a61ca0e -r 6c5a648a4d05 plugins/staticpages/language/english_utf-8.php
--- a/plugins/staticpages/language/english_utf-8.php	Sun Nov 29 18:04:39 2009 +0100
+++ b/plugins/staticpages/language/english_utf-8.php	Sun Nov 29 19:10:37 2009 +0100
@@ -133,6 +133,7 @@
     'allow_php' => 'Allow PHP?',
     'sort_by' => 'Sort Centerblocks by',
     'sort_menu_by' => 'Sort Menu Entries by',
+    'sort_list_by' => 'Sort Admin List by',
     'delete_pages' => 'Delete Pages with Owner?',
     'in_block' => 'Wrap Pages in Block?',
     'show_hits' => 'Show Hits?',
@@ -171,6 +172,7 @@
     1 => array('True' => TRUE, 'False' => FALSE),
     2 => array('Date' => 'date', 'Page ID' => 'id', 'Title' => 'title'),
     3 => array('Date' => 'date', 'Page ID' => 'id', 'Title' => 'title', 'Label' => 'label'),
+    4 => array('Date' => 'date', 'Page ID' => 'id', 'Title' => 'title', 'Author' => 'author'),
     9 => array('Forward to page' => 'item', 'Display List' => 'list', 'Display Home' => 'home', 'Display Admin' => 'admin'),
     12 => array('No access' => 0, 'Read-Only' => 2, 'Read-Write' => 3),
     17 => array('Comments Enabled' => 0, 'Comments Disabled' => -1)
diff -r 8bd93a61ca0e -r 6c5a648a4d05 plugins/staticpages/sql/mssql_updates.php
--- a/plugins/staticpages/sql/mssql_updates.php	Sun Nov 29 18:04:39 2009 +0100
+++ b/plugins/staticpages/sql/mssql_updates.php	Sun Nov 29 19:10:37 2009 +0100
@@ -111,6 +111,8 @@
 
     $c->add('comment_code', $_SP_DEFAULT['comment_code'], 'select',
             0, 0, 17, 125, true, 'staticpages');
+    $c->add('sort_list_by', $_SP_DEFAULT['sort_list_by'], 'select',
+            0, 0, 4, 35, true, 'staticpages');
 
     return true;
 }
diff -r 8bd93a61ca0e -r 6c5a648a4d05 plugins/staticpages/sql/mysql_updates.php
--- a/plugins/staticpages/sql/mysql_updates.php	Sun Nov 29 18:04:39 2009 +0100
+++ b/plugins/staticpages/sql/mysql_updates.php	Sun Nov 29 19:10:37 2009 +0100
@@ -112,6 +112,8 @@
 
     $c->add('comment_code', $_SP_DEFAULT['comment_code'], 'select',
             0, 0, 17, 125, true, 'staticpages');
+    $c->add('sort_list_by', $_SP_DEFAULT['sort_list_by'], 'select',
+            0, 0, 4, 35, true, 'staticpages');
 
     return true;
 }
diff -r 8bd93a61ca0e -r 6c5a648a4d05 public_html/admin/plugins/staticpages/index.php
--- a/public_html/admin/plugins/staticpages/index.php	Sun Nov 29 18:04:39 2009 +0100
+++ b/public_html/admin/plugins/staticpages/index.php	Sun Nov 29 19:10:37 2009 +0100
@@ -408,7 +408,7 @@
 */
 function liststaticpages()
 {
-    global $_CONF, $_TABLES, $_IMAGE_TYPE, $LANG_ADMIN, $LANG_STATIC;
+    global $_CONF, $_TABLES, $_IMAGE_TYPE, $LANG_ADMIN, $LANG_STATIC, $_SP_CONF;
 
     require_once $_CONF['path_system'] . 'lib-admin.php';
 
@@ -418,12 +418,37 @@
         array('text' => $LANG_ADMIN['edit'], 'field' => 'edit', 'sort' => false),
         array('text' => $LANG_ADMIN['copy'], 'field' => 'copy', 'sort' => false),
         array('text' => $LANG_STATIC['id'], 'field' => 'sp_id', 'sort' => true),
-        array('text' => $LANG_ADMIN['title'], 'field' => 'sp_title', 'sort' => true),
-        array('text' => $LANG_STATIC['writtenby'], 'field' => 'sp_uid', 'sort' => true),
-        array('text' => $LANG_STATIC['head_centerblock'], 'field' => 'sp_centerblock', 'sort' => true),
-        array('text' => $LANG_STATIC['date'], 'field' => 'unixdate', 'sort' => true)
+        array('text' => $LANG_ADMIN['title'], 'field' => 'sp_title', 'sort' => true)
     );
-    $defsort_arr = array('field' => 'sp_title', 'direction' => 'asc');
+    if ($_CONF['show_fullname'] == 1) {
+        $header_arr[] = array('text' => $LANG_STATIC['writtenby'], 'field' => 'fullname', 'sort' => true);
+    } else {
+        $header_arr[] = array('text' => $LANG_STATIC['writtenby'], 'field' => 'username', 'sort' => true);
+    }
+    $header_arr[] = array('text' => $LANG_STATIC['head_centerblock'], 'field' => 'sp_centerblock', 'sort' => true);
+    $header_arr[] = array('text' => $LANG_STATIC['date'], 'field' => 'unixdate', 'sort' => true);
+
+    switch ($_SP_CONF['sort_list_by']) {
+    case 'author':
+        if ($_CONF['show_fullname'] == 1) {
+            $defsort_arr = array('field' => 'fullname', 'direction' => 'asc');
+        } else {
+            $defsort_arr = array('field' => 'username', 'direction' => 'asc');
+        }
+        break;
+
+    case 'date':
+        $defsort_arr = array('field' => 'unixdate', 'direction' => 'desc');
+        break;
+
+    case 'id':
+        $defsort_arr = array('field' => 'sp_id', 'direction' => 'asc');
+        break;
+
+    case 'title':
+        $defsort_arr = array('field' => 'sp_title', 'direction' => 'asc');
+        break;
+    }
 
     $menu_arr = array (
         array('url' => $_CONF['site_admin_url'] . '/plugins/staticpages/index.php?mode=edit',
@@ -435,7 +460,8 @@
     $retval .= COM_startBlock($LANG_STATIC['staticpagelist'], '',
                               COM_getBlockTemplate('_admin_block', 'header'));
 
-    $retval .= ADMIN_createMenu($menu_arr, $LANG_STATIC['instructions'], plugin_geticon_staticpages());
+    $retval .= ADMIN_createMenu($menu_arr, $LANG_STATIC['instructions'],
+                                plugin_geticon_staticpages());
 
     $text_arr = array(
         'has_extras' => true,
@@ -444,10 +470,12 @@
 
     $query_arr = array(
         'table' => 'staticpage',
-        'sql' => "SELECT *,UNIX_TIMESTAMP(sp_date) AS unixdate "
-                ."FROM {$_TABLES['staticpage']} WHERE 1=1 ",
+        'sql' => "SELECT *,UNIX_TIMESTAMP(sp_date) AS unixdate, {$_TABLES['users']}.username, {$_TABLES['users']}.fullname "
+                ."FROM {$_TABLES['staticpage']} "
+                ."LEFT JOIN {$_TABLES['users']} ON {$_TABLES['staticpage']}.sp_uid = {$_TABLES['users']}.uid "
+                ."WHERE 1=1 ",
         'query_fields' => array('sp_title', 'sp_id'),
-        'default_filter' => COM_getPermSQL ('AND', 0, 3)
+        'default_filter' => COM_getPermSQL('AND', 0, 3)
     );
 
     $retval .= ADMIN_list('static_pages', 'plugin_getListField_staticpages',
diff -r 8bd93a61ca0e -r 6c5a648a4d05 public_html/docs/english/staticpages.html
--- a/public_html/docs/english/staticpages.html	Sun Nov 29 18:04:39 2009 +0100
+++ b/public_html/docs/english/staticpages.html	Sun Nov 29 19:10:37 2009 +0100
@@ -173,6 +173,12 @@
     page label, page ID, page title, and date of last change.</td>
 </tr>
 <tr class="r2">
+  <td><a name="desc_sort_list_by">sort_list_by</a></td>
+  <td>'title'</td>
+  <td>Defines the default sort order for the admin's list of static pages.
+    Allows sorting by author, page ID, page title, and date of last change.</td>
+</tr>
+<tr>
   <td><a name="desc_delete_pages">delete_pages</a></td>
   <td>false</td>
   <td>Specify what should happen to a static page when its owner (i.e. the user
@@ -180,35 +186,35 @@
     will assign it to a user in the "Root" group (usually the user with the
     lowest user ID).</td>
 </tr>
-<tr>
+<tr class="r2">
   <td><a name="desc_in_block">in_block</a></td>
   <td>true</td>
   <td>Whether to display the content of static pages inside a block template or
     not. This is the default setting and can be overridden per page.</td>
 </tr>
-<tr class="r2">
+<tr>
   <td><a name="desc_show_hits">show_hits</a></td>
   <td>true</td>
   <td>Whether to show the number of hits for a static page.</td>
-<tr>
-<tr>
+</tr>
+<tr class="r2">
   <td><a name="desc_show_date">show_date</a></td>
   <td>true</td>



More information about the geeklog-cvs mailing list