[geeklog-hg] geeklog: Improved the Topic Admin panel. But, familiar with the ...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Fri Oct 26 10:07:27 EDT 2012


changeset 8869:f10113a27de8
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/f10113a27de8
user: dengen
date: Fri Oct 26 23:06:26 2012 +0900
description:
Improved the Topic Admin panel. But, familiar with the other admin panel.

diffstat:

 language/english.php                                    |    7 +-
 language/english_utf-8.php                              |    7 +-
 language/japanese_utf-8.php                             |    7 +-
 public_html/admin/topic.php                             |  162 +++++++++++++++-
 public_html/layout/denim/css_ltr/style.css              |    5 +
 public_html/layout/denim/css_rtl/style.css              |    5 +
 public_html/layout/modern_curve/css/admin/topic.css     |    5 +
 public_html/layout/professional/style.css               |    4 +
 public_html/layout/professional_css/css/admin/topic.css |    5 +
 system/lib-admin.php                                    |  109 ++++++++++
 10 files changed, 312 insertions(+), 4 deletions(-)

diffs (truncated from 435 to 300 lines):

diff -r e50672d515e9 -r f10113a27de8 language/english.php
--- a/language/english.php	Thu Oct 25 15:33:12 2012 -0400
+++ b/language/english.php	Fri Oct 26 23:06:26 2012 +0900
@@ -870,7 +870,8 @@
     6 => 'Deleting a topic deletes all stories, submissions and blocks associated with it (as long as they are only associated with that deleted topic).',
     7 => 'Please fill in the Topic ID and Topic Name fields',
     8 => 'Topic Manager',
-    9 => 'To modify or delete a topic, click on that topic.  To create a new topic, click on "Create New" above. You will find your access level for each topic in parenthesis. The asterisk(*) denotes the default topic.',
+//    9 => 'To modify or delete a topic, click on that topic.  To create a new topic, click on "Create New" above. You will find your access level for each topic in parenthesis. The asterisk(*) denotes the default topic.',
+    9 => 'To modify or delete a topic, click on that topic\'s edit icon below. To create a new topic, click on "Create New" above. The asterisk(*) denotes the default topic.',
     10 => 'Sort Order',
     11 => 'Stories/Page',
     12 => 'Access Denied',
@@ -911,6 +912,10 @@
     47 => 'An Archive Topic cannot have any child topics. Please remove any child topics before making a topic the Archive Topic.', 
     48 => 'Parent Topic Id not found.',
     49 => 'This Topic ID is already being used. Please choose another one.',
+    50 => 'Yes',
+    51 => 'No',
+    52 => 'Story',
+    53 => 'Image',
     'breadcrumb_separator' => '>', 
     'breadcrumb_root' => 'Home'
 );
diff -r e50672d515e9 -r f10113a27de8 language/english_utf-8.php
--- a/language/english_utf-8.php	Thu Oct 25 15:33:12 2012 -0400
+++ b/language/english_utf-8.php	Fri Oct 26 23:06:26 2012 +0900
@@ -870,7 +870,8 @@
     6 => 'Deleting a topic deletes all stories, submissions and blocks associated with it (as long as they are only associated with that deleted topic).',
     7 => 'Please fill in the Topic ID and Topic Name fields',
     8 => 'Topic Manager',
-    9 => 'To modify or delete a topic, click on that topic.  To create a new topic, click on "Create New" above. You will find your access level for each topic in parenthesis. The asterisk(*) denotes the default topic.',
+//    9 => 'To modify or delete a topic, click on that topic.  To create a new topic, click on "Create New" above. You will find your access level for each topic in parenthesis. The asterisk(*) denotes the default topic.',
+    9 => 'To modify or delete a topic, click on that topic\'s edit icon below. To create a new topic, click on "Create New" above. The asterisk(*) denotes the default topic.',
     10 => 'Sort Order',
     11 => 'Stories/Page',
     12 => 'Access Denied',
@@ -911,6 +912,10 @@
     47 => 'An Archive Topic cannot have any child topics. Please remove any child topics before making a topic the Archive Topic.', 
     48 => 'Parent Topic Id not found.',
     49 => 'This Topic ID is already being used. Please choose another one.',
+    50 => 'Yes',
+    51 => 'No',
+    52 => 'Story',
+    53 => 'Image',
     'breadcrumb_separator' => '>', 
     'breadcrumb_root' => 'Home'
 );
diff -r e50672d515e9 -r f10113a27de8 language/japanese_utf-8.php
--- a/language/japanese_utf-8.php	Thu Oct 25 15:33:12 2012 -0400
+++ b/language/japanese_utf-8.php	Fri Oct 26 23:06:26 2012 +0900
@@ -877,7 +877,8 @@
     6 => '話題を削除すると、その話題の記事・投稿・ブロックもすべて削除されます。',
     7 => '話題IDと話題名をå
¥åŠ›ã—てください',
     8 => '話題管理',
-    9 => '話題とは、記事カテゴリのことです。話題の編集・削除は各話題名を、新しい話題の作成は「新規作成」リンクをクリックしてください。カッコå†
はあなたのアクセスレベルです。アスタリスク(*)付きの話題は、記事投稿時のデフォルトです。',
+//    9 => '話題とは、記事カテゴリのことです。話題の編集・削除は各話題名を、新しい話題の作成は「新規作成」リンクをクリックしてください。カッコå†
はあなたのアクセスレベルです。アスタリスク(*)付きの話題は、記事投稿時のデフォルトです。',
+    9 => '話題とは、記事カテゴリのことです。話題の編集・削除は各話題名を、新しい話題の作成は「新規作成」リンクをクリックしてください。アスタリスク(*)付きの話題は、記事投稿時のデフォルトです。',
     10 => '順序',
     11 => '1ページあたりの記事数',
     12 => 'アクセスが拒否されました',
@@ -918,6 +919,10 @@
     47 => 'アーカイブの話題は子の話題を持てません。アーカイブ話題に設定する前に子の話題を解除してください。',
     48 => '親の話題IDが見つかりません。',
     49 => 'This Topic ID is already being used. Please choose another one.',
+    50 => 'Yes',
+    51 => 'No',
+    52 => '記事',
+    53 => '画像',
     'breadcrumb_separator' => '>',
     'breadcrumb_root' => 'Home'
 );
diff -r e50672d515e9 -r f10113a27de8 public_html/admin/topic.php
--- a/public_html/admin/topic.php	Thu Oct 25 15:33:12 2012 -0400
+++ b/public_html/admin/topic.php	Fri Oct 26 23:06:26 2012 +0900
@@ -634,6 +634,152 @@
     return $retval;
 }
 
+
+/**
+* Displays a list of topics
+*
+* Lists all the topics and their icons.
+*
+* @param    string      $token  Security token to use in list
+* @return   string      HTML for the topic list
+*
+*/
+function draft_listTopics($token)
+{
+    global $_CONF, $_TABLES, $LANG27, $LANG_ACCESS, $LANG_ADMIN;
+
+    require_once $_CONF['path_system'] . 'lib-admin.php';
+
+    global $_SCRIPTS;
+    $_SCRIPTS->setJavaScriptFile('admin.topic', '/javascript/admin.topic.js');
+
+
+    $retval = '';
+
+    $retval .= COM_startBlock($LANG27[8], '',
+                              COM_getBlockTemplate ('_admin_block', 'header'));
+
+    $menu_arr = array(
+        array('url'  => $_CONF['site_admin_url'] . '/topic.php?mode=edit',
+              'text' => $LANG_ADMIN['create_new']),
+        array('url'  => $_CONF['site_admin_url'],
+              'text' => $LANG_ADMIN['admin_home'])
+    );
+
+    $retval .= ADMIN_createMenu($menu_arr, $LANG27[9],
+                              $_CONF['layout_url'] . "/images/icons/topic.png");
+
+    $header_arr[] = array('text' => $LANG_ADMIN['edit'],    'field' => 'edit',    'sort' => false);
+    $header_arr[] = array('text' => $LANG27[10],            'field' => 'sortnum', 'sort' => true);
+    $header_arr[] = array('text' => $LANG27[53],            'field' => 'image',   'sort' => false);
+    $header_arr[] = array('text' => $LANG27[3],             'field' => 'topic',   'sort' => false);
+    $header_arr[] = array('text' => $LANG27[2],             'field' => 'tid',     'sort' => true);
+    $header_arr[] = array('text' => $LANG27[52],            'field' => 'story',   'sort' => false);
+    $header_arr[] = array('text' => $LANG_ACCESS['access'], 'field' => 'access',  'sort' => false);
+    $header_arr[] = array('text' => $LANG27[33],            'field' => 'inherit', 'sort' => false);
+    $header_arr[] = array('text' => $LANG27[35],            'field' => 'hidden',  'sort' => false);
+
+    $defsort_arr = array('field' => 'sortnum', 'direction' => 'asc');
+
+    $text_arr    = array('has_extras' => true,
+                         'form_url'   => $_CONF['site_admin_url'] . '/topic.php'
+    );
+
+    $query_arr   = array('table'          => 'topics',
+                         'sql'            => "SELECT * FROM {$_TABLES['topics']} WHERE 1=1 ",
+                         'query_fields'   => array('topic'),
+                         'default_filter' => COM_getPermSql('AND')
+    );
+
+    $retval .= ADMIN_list('topics', 'ADMIN_getListField_topics', $header_arr,
+                           $text_arr, $query_arr, $defsort_arr, '', $token);
+
+    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
+
+    return $retval;
+}
+
+/**
+* Get topic child tree array
+*
+* @return   array  Topic array
+*
+*/
+function getTopicChildTreeArray($sel_id = TOPIC_ROOT, $tarray = array(), $orderby = "ASC")
+{
+    global $_CONF, $_TABLES;
+
+    $field = ($_CONF['sortmethod'] == 'sortnum') ? 'sortnum' : 'topic';
+    $sql = "SELECT * FROM {$_TABLES['topics']} "
+         . "WHERE parent_id = '$sel_id' ORDER BY $field $orderby";
+    $result = DB_query($sql);
+    if (DB_numRows($result) == 0) return $tarray;
+    while ($A = DB_fetchArray($result)) {
+        array_push($tarray, $A);
+        $tarray = getTopicChildTreeArray($A['tid'], $tarray, $orderby);
+    }
+
+    return $tarray;
+}
+
+/**
+* Re-order all topics in steps of 10
+*
+* @return   void
+*
+*/
+function reorderTopics()
+{
+    global $_TABLES;
+
+    $order = 0;
+    $A = getTopicChildTreeArray();
+    foreach ($A as $B) {
+        $order += 10;
+        if ($B['sortnum'] != $order) {
+            DB_query("UPDATE {$_TABLES['topics']} SET sortnum = '$order' WHERE tid = '{$B['tid']}'");
+        }
+    }
+}
+
+/**
+* Move topic UP and Down
+*
+* @param    string  $tid        Topic ID
+* @param    string  $where      Where to move the topic specified by $tid.
+*                               Valid values are "up" and "dn", which stand for
+*                               move 'Up' or 'Down' through the sort number.
+* @return   void
+*
+*/
+function moveTopics($tid, $where)
+{
+    global $_TABLES;
+
+    if (empty($tid) || empty($where)) return;
+
+    $sortnum   = DB_getItem($_TABLES['topics'], 'sortnum',   "tid = '$tid'");
+    $parent_id = DB_getItem($_TABLES['topics'], 'parent_id', "tid = '$tid'");
+
+    if (empty($sortnum) || empty($parent_id)) return;
+
+    if ($where == 'up') {
+        $A = getTopicChildTreeArray(TOPIC_ROOT, array(), 'DESC');
+        foreach ($A as $B) {
+            $order = $B['sortnum'] - 1;
+            if (($B['sortnum'] < $sortnum) && ($B['parent_id'] == $parent_id)) break;
+        }
+    } else {
+        $A = getTopicChildTreeArray(TOPIC_ROOT, array(), 'ASC');
+        foreach ($A as $B) {
+            $order = $B['sortnum'] + 1;
+            if (($B['sortnum'] > $sortnum) && ($B['parent_id'] == $parent_id)) break;
+        }
+    }
+
+    DB_query("UPDATE {$_TABLES['topics']} SET sortnum = $order WHERE tid = '$tid'");
+}
+
 /**
 * Delete a topic
 *
@@ -914,9 +1060,23 @@
     }
     $display .= edittopic($tid);
     $display = COM_createHTMLDocument($display, array('pagetitle' => $LANG27[1]));
+
+
+} elseif ($mode == 'change_sortnum' && SEC_checkToken()) {
+    $display .= COM_showMessageFromParameter();
+    moveTopics(COM_applyFilter($_GET['tid']), COM_applyFilter($_GET['where']));
+    reorderTopics();
+    $display .= draft_listTopics(SEC_createToken());
+    $display = COM_createHTMLDocument($display, array('pagetitle' => $LANG27[8]));
+
 } else { // 'cancel' or no mode at all
     $display .= COM_showMessageFromParameter();
-    $display .= listtopics();
+
+//    $display .= listtopics();
+
+    reorderTopics();
+    $display .= draft_listTopics(SEC_createToken());
+
     $display = COM_createHTMLDocument($display, array('pagetitle' => $LANG27[8]));
 }
 
diff -r e50672d515e9 -r f10113a27de8 public_html/layout/denim/css_ltr/style.css
--- a/public_html/layout/denim/css_ltr/style.css	Thu Oct 25 15:33:12 2012 -0400
+++ b/public_html/layout/denim/css_ltr/style.css	Fri Oct 26 23:06:26 2012 +0900
@@ -2407,6 +2407,11 @@
   color: #CCC;
 }
 
+.admin-topic-image {
+  margin: 0 5px 0 0;
+  vertical-align: middle;
+}
+
 /*--------------------------------------
   Group Editor
 --------------------------------------*/
diff -r e50672d515e9 -r f10113a27de8 public_html/layout/denim/css_rtl/style.css
--- a/public_html/layout/denim/css_rtl/style.css	Thu Oct 25 15:33:12 2012 -0400
+++ b/public_html/layout/denim/css_rtl/style.css	Fri Oct 26 23:06:26 2012 +0900
@@ -2407,6 +2407,11 @@
   color: #CCC;
 }
 
+.admin-topic-image {
+  margin: 0 5px 0 0;
+  vertical-align: middle;
+}
+
 /*--------------------------------------
   Group Editor
 --------------------------------------*/
diff -r e50672d515e9 -r f10113a27de8 public_html/layout/modern_curve/css/admin/topic.css
--- a/public_html/layout/modern_curve/css/admin/topic.css	Thu Oct 25 15:33:12 2012 -0400
+++ b/public_html/layout/modern_curve/css/admin/topic.css	Fri Oct 26 23:06:26 2012 +0900
@@ -60,3 +60,8 @@
   padding: 0.5em 0 0 0;
   border-top: 1px solid #CCCCCC;
 }
+
+.admin-topic-image {
+  margin: 0 5px 0 0;
+  vertical-align: middle;
+}
diff -r e50672d515e9 -r f10113a27de8 public_html/layout/professional/style.css
--- a/public_html/layout/professional/style.css	Thu Oct 25 15:33:12 2012 -0400
+++ b/public_html/layout/professional/style.css	Fri Oct 26 23:06:26 2012 +0900
@@ -1287,3 +1287,7 @@
 .size9  { width: 540px; }



More information about the geeklog-cvs mailing list