[geeklog-hg] geeklog: Fixed SQL error in article directory with all topics se...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sat Mar 23 13:24:45 EDT 2013


changeset 9006:e5bd3cd9244a
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/e5bd3cd9244a
user: Tom <websitemaster at cogeco.net>
date: Sat Mar 23 13:18:23 2013 -0400
description:
Fixed SQL error in article directory with all topics selected. (bug #0001570)

diffstat:

 public_html/directory.php |  136 +++++++++++++++++++++++++--------------------
 1 files changed, 76 insertions(+), 60 deletions(-)

diffs (truncated from 369 to 300 lines):

diff -r 6830ccf81adb -r e5bd3cd9244a public_html/directory.php
--- a/public_html/directory.php	Sat Mar 23 12:22:56 2013 +0900
+++ b/public_html/directory.php	Sat Mar 23 13:18:23 2013 -0400
@@ -80,13 +80,13 @@
 /**
 * Display a topic selection drop-down menu
 *
-* @param    string  $topic          current topic
+* @param    string  $dir_topic          current topic
 * @param    int     $year           current year
 * @param    int     $month          current month
 * @param    boolean $standalone     true: don't display form inline
 *
 */
-function DIR_topicList ($topic = 'all', $year = 0, $month = 0, $standalone = false)
+function DIR_topicList ($dir_topic = 'all', $year = 0, $month = 0, $standalone = false)
 {
     global $_CONF, $LANG21;
 
@@ -99,7 +99,7 @@
     }
     $retval .= '><div>' . LB;
     $retval .= '<select name="topic" onchange="this.form.submit()">' . LB;
-    $retval .= TOPIC_getTopicListSelect($topic, 2, true);
+    $retval .= TOPIC_getTopicListSelect($dir_topic, 2, true);
     $retval .= '</select>' . LB;
     $retval .= '<input type="hidden" name="year" value="' . $year . '"' . XHTML . '>';
     $retval .= '<input type="hidden" name="month" value="' . $month . '"' . XHTML . '>';
@@ -111,14 +111,14 @@
 /**
 * Build link to a month's page
 *
-* @param    string  $topic  current topic
+* @param    string  $dir_topic  current topic
 * @param    int     $year   year to link to
 * @param    int     $month  month to link to
 * @param    int     $count  number of stories for that month (may be 0)
 * @return   string          month name + count, as link or plain text
 *
 */
-function DIR_monthLink ($topic, $year, $month, $count)
+function DIR_monthLink ($dir_topic, $year, $month, $count)
 {
     global $_CONF, $LANG_MONTH;
 
@@ -126,7 +126,7 @@
 
     if ($count > 0) {
         $month_url = COM_buildUrl ($_CONF['site_url'] . '/'
-            . THIS_SCRIPT . '?topic=' . urlencode ($topic) . '&year='
+            . THIS_SCRIPT . '?topic=' . urlencode ($dir_topic) . '&year='
             . $year . '&month=' . $month);
         $retval =  COM_createLink ($retval, $month_url);
     }
@@ -139,13 +139,13 @@
 /**
 * Display navigation bar
 *
-* @param    string  $topic  current topic
+* @param    string  $dir_topic  current topic
 * @param    int     $year   current year
 * @param    int     $month  current month (or 0 for year view pages)
 * @return   string          navigation bar with prev, next, and "up" links
 *
 */
-function DIR_navBar ($topic, $year, $month = 0)
+function DIR_navBar ($dir_topic, $year, $month = 0)
 {
     global $_CONF, $_TABLES, $LANG05, $LANG_DIR;
 
@@ -190,7 +190,7 @@
 
     if ($prevyear > 0) {
         $url = $_CONF['site_url'] . '/' . THIS_SCRIPT . '?topic='
-             . urlencode ($topic) . '&year=' . $prevyear;
+             . urlencode ($dir_topic) . '&year=' . $prevyear;
         if ($month > 0) {
             $url .= '&month=' . $prevmonth;
         }
@@ -202,8 +202,8 @@
     $retval .= ' | ';
 
     $url = $_CONF['site_url'] . '/' . THIS_SCRIPT;
-    if ($topic != 'all') {
-        $url = COM_buildUrl ($url . '?topic=' . urlencode ($topic));
+    if ($dir_topic != 'all') {
+        $url = COM_buildUrl ($url . '?topic=' . urlencode ($dir_topic));
     }
 
     $retval .= COM_createLink($LANG_DIR['nav_top'] , $url);
@@ -212,7 +212,7 @@
 
     if ($nextyear > 0) {
         $url = $_CONF['site_url'] . '/' . THIS_SCRIPT . '?topic='
-             . urlencode ($topic) . '&year=' . $nextyear;
+             . urlencode ($dir_topic) . '&year=' . $nextyear;
         if ($month > 0) {
             $url .= '&month=' . $nextmonth;
         }
@@ -229,14 +229,14 @@
 /**
 * Display month view
 *
-* @param    string  $topic  current topic
+* @param    string  $dir_topic  current topic
 * @param    int     $year   year to display
 * @param    int     $month  month to display
 * @param    boolean $main   true: display view on its own page
 * @return   string          list of articles for the given month
 *
 */
-function DIR_displayMonth ($topic, $year, $month, $main = false)
+function DIR_displayMonth ($dir_topic, $year, $month, $main = false)
 {
     global $_CONF, $_TABLES, $LANG_MONTH, $LANG_DIR;
 
@@ -244,7 +244,7 @@
 
     if ($main) {
         $retval .= '<div><h1 style="display:inline">' . $LANG_MONTH[$month]
-                . ' ' . $year . '</h1> ' . DIR_topicList ($topic, $year, $month)
+                . ' ' . $year . '</h1> ' . DIR_topicList ($dir_topic, $year, $month)
                 . '</div>' . LB;
     } else {
         $retval .= '<h1>' . $LANG_MONTH[$month] . ' ' . $year . '</h1>' . LB;
@@ -267,10 +267,10 @@
         WHERE (date >= '$start') AND (date <= '$end') AND (draft_flag = 0) AND (date <= NOW()) 
         AND ta.type = 'article' AND ta.id = sid ";
     
-    if ($topic != 'all') {
-        $sql['mysql'] .= " AND ta.tid = '$topic'";
+    if ($dir_topic != 'all') {
+        $sql['mysql'] .= " AND ta.tid = '$dir_topic'";
         $sql['mssql'] = $sql['mysql'];
-        $sql['pgsql'] .= " AND ta.tid = '$topic'";
+        $sql['pgsql'] .= " AND ta.tid = '$dir_topic'";
     }
     $sql['mysql'] .= COM_getTopicSql ('AND', 0, 'ta') . COM_getPermSql ('AND')
          . COM_getLangSQL ('sid', 'AND') . " GROUP BY sid ORDER BY date ASC";
@@ -323,13 +323,13 @@
 /**
 * Display year view
 *
-* @param    string  $topic  current topic
+* @param    string  $dir_topic  current topic
 * @param    int     $year   year to display
 * @param    boolean $main   true: display view on its own page
 * @return   string          list of months (+ number of stories) for given year
 *
 */
-function DIR_displayYear ($topic, $year, $main = false)
+function DIR_displayYear ($dir_topic, $year, $main = false)
 {
     global $_CONF, $_TABLES, $LANG_MONTH, $LANG_DIR;
 
@@ -337,7 +337,7 @@
 
     if ($main) {
         $retval .= '<div><h1 style="display:inline">' . $year . '</h1> '
-                . DIR_topicList ($topic, $year) . '</div>' . LB;
+                . DIR_topicList ($dir_topic, $year) . '</div>' . LB;
     } else {
         $retval .= '<h2>' . $year . '</h2>' . LB;
     }
@@ -364,10 +364,10 @@
         WHERE (date >= '$start') AND (date <= '$end') AND (draft_flag = 0) AND (date <= NOW()) 
         AND ta.type = 'article' AND ta.id = sid ";
     
-    if ($topic != 'all') {
-        $monthsql['mysql'] .= " AND ta.tid = '$topic'";
-        $monthsql['mssql'] .= " AND ta.tid = '$topic'";
-        $monthsql['pgsql'] .= " AND ta.tid = '$topic'";
+    if ($dir_topic != 'all') {
+        $monthsql['mysql'] .= " AND ta.tid = '$dir_topic'";
+        $monthsql['mssql'] .= " AND ta.tid = '$dir_topic'";
+        $monthsql['pgsql'] .= " AND ta.tid = '$dir_topic'";
     }
     $monthsql['mysql'] .= COM_getTopicSql ('AND', 0, 'ta') . COM_getPermSql ('AND')
               . COM_getLangSQL ('sid', 'AND');
@@ -391,12 +391,12 @@
             $M = DB_fetchArray ($mresult);
 
             for (; $lastm < $M['month']; $lastm++) {
-                $retval .= '<li>' . DIR_monthLink ($topic, $year, $lastm, 0)
+                $retval .= '<li>' . DIR_monthLink ($dir_topic, $year, $lastm, 0)
                         . '</li>';
             }
             $lastm = $M['month'] + 1;
 
-            $retval .= '<li>' . DIR_monthLink ($topic, $year, $M['month'],
+            $retval .= '<li>' . DIR_monthLink ($dir_topic, $year, $M['month'],
                                                $M['count']) . '</li>';
         }
 
@@ -408,7 +408,7 @@
 
         if ($lastm <= $fillm) {
             for (; $lastm <= $fillm; $lastm++) {
-                $retval .= '<li>' . DIR_monthLink ($topic, $year, $lastm, 0)
+                $retval .= '<li>' . DIR_monthLink ($dir_topic, $year, $lastm, 0)
                         . '</li>';
             }
         }
@@ -430,12 +430,12 @@
 * year for which a story has been posted. Can optionally display a list of
 * the stories for the current month at the top of the page.
 *
-* @param    string  $topic                  current topic
+* @param    string  $dir_topic                  current topic
 * @param    boolean $list_current_month     true = list stories f. current month
 * @return   string                          list of all the years in the db
 *
 */
-function DIR_displayAll ($topic, $list_current_month = false)
+function DIR_displayAll ($dir_topic, $list_current_month = false)
 {
     global $_TABLES, $LANG_DIR;
 
@@ -445,13 +445,13 @@
         $currentyear = date ('Y', time ());
         $currentmonth = date ('n', time ());
 
-        $retval .= DIR_displayMonth ($topic, $currentyear, $currentmonth);
+        $retval .= DIR_displayMonth ($dir_topic, $currentyear, $currentmonth);
 
         $retval .= '<hr' . XHTML . '>' . LB;
     }
 
     $retval .= '<div><h1 style="display:inline">' . $LANG_DIR['title']
-            . '</h1> ' . DIR_topicList ($topic) . '</div>' . LB;
+            . '</h1> ' . DIR_topicList ($dir_topic) . '</div>' . LB;
 
     $yearsql = array();
     $yearsql['mysql'] = "SELECT DISTINCT YEAR(date) AS year,date 
@@ -483,7 +483,7 @@
         for ($i = 0; $i < $numyears; $i++) {
             $Y = DB_fetchArray ($yresult);
     
-            $retval .= DIR_displayYear ($topic, $Y['year']);
+            $retval .= DIR_displayYear ($dir_topic, $Y['year']);
         }
     } else {
         $retval .= '<p>' . $LANG_DIR['no_articles'] . '</p>';
@@ -495,25 +495,25 @@
 /**
 * Return a canonical link
 *
-* @param    string  $topic  current topic or 'all'
+* @param    string  $dir_topic  current topic or 'all'
 * @param    int     $year   current year
 * @param    int     $month  current month
 * @return   string          <link rel="canonical"> tag
 *
 */
-function DIR_canonicalLink($topic, $year = 0, $month = 0)
+function DIR_canonicalLink($dir_topic, $year = 0, $month = 0)
 {
     global $_CONF;
 
     $script = $_CONF['site_url'] . '/' . THIS_SCRIPT;
 
-    $tp = '?topic=' . urlencode($topic);
+    $tp = '?topic=' . urlencode($dir_topic);
     $parts = '';
     if (($year != 0) && ($month != 0)) {
         $parts .= "&year=$year&month=$month";
     } elseif ($year != 0) {
         $parts .= "&year=$year";
-    } elseif ($topic == 'all') {
+    } elseif ($dir_topic == 'all') {
         $tp = '';
     }
     $url = COM_buildUrl($script . $tp . $parts);
@@ -525,20 +525,36 @@
 $display = '';
 
 if (isset ($_POST['topic']) && isset ($_POST['year']) && isset ($_POST['month'])) {
-    $topic = $_POST['topic'];
+    $dir_topic = $_POST['topic'];
     $year = $_POST['year'];
     $month = $_POST['month'];
 } else {
     COM_setArgNames (array ('topic', 'year', 'month'));
-    $topic = COM_getArgument ('topic');
+    $dir_topic = COM_getArgument ('topic');
     $year = COM_getArgument ('year');
     $month = COM_getArgument ('month');
 }
 
-$topic = COM_applyFilter ($topic);
-if (empty ($topic)) {
-    $topic = 'all';
+$dir_topic = COM_applyFilter ($dir_topic);
+if (empty ($dir_topic)) {
+    $dir_topic = 'all';
 }
+
+// Topic stuff already set in lib-common but need to double check if URL_Write is_a enabled
+//Set topic for rest of site
+if ($dir_topic == 'all') {



More information about the geeklog-cvs mailing list