[geeklog-cvs] geeklog: Fixed handling of empty id in autotags

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Mon Apr 13 03:18:17 EDT 2009


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/2be2c5fff798
changeset: 6933:2be2c5fff798
user:      Dirk Haun <dirk at haun-online.de>
date:      Mon Apr 13 08:47:58 2009 +0200
description:
Fixed handling of empty id in autotags

diffstat:

4 files changed, 55 insertions(+), 45 deletions(-)
plugins/calendar/functions.inc    |   20 +++++++++++---------
plugins/links/functions.inc       |   36 +++++++++++++++++++-----------------
plugins/staticpages/functions.inc |   34 +++++++++++++++++++---------------
system/lib-plugins.php            |   10 ++++++----

diffs (147 lines):

diff -r 462ba3404c2d -r 2be2c5fff798 plugins/calendar/functions.inc
--- a/plugins/calendar/functions.inc	Sun Apr 12 23:42:22 2009 +0200
+++ b/plugins/calendar/functions.inc	Mon Apr 13 08:47:58 2009 +0200
@@ -1104,16 +1104,18 @@
     if ($op == 'tagname' ) {
         return 'event';
     } else if ($op == 'parse') {
-        $eid = COM_applyFilter ($autotag['parm1']);
-        $url = $_CONF['site_url'] . '/calendar/event.php?eid=' . $eid;
-        if (empty ($autotag['parm2'])) {
-            $linktext = stripslashes (DB_getItem ($_TABLES['events'],
-                                      'title', "eid = '$eid'"));
-        } else {
-            $linktext = $autotag['parm2'];
+        $eid = COM_applyFilter($autotag['parm1']);
+        if (! empty($eid)) {
+            $url = $_CONF['site_url'] . '/calendar/event.php?eid=' . $eid;
+            if (empty ($autotag['parm2'])) {
+                $linktext = stripslashes (DB_getItem ($_TABLES['events'],
+                                          'title', "eid = '$eid'"));
+            } else {
+                $linktext = $autotag['parm2'];
+            }
+            $link = COM_createLink($linktext, $url);
+            $content = str_replace ($autotag['tagstr'], $link, $content);
         }
-        $link = COM_createLink($linktext, $url);
-        $content = str_replace ($autotag['tagstr'], $link, $content);
 
         return $content;
     }
diff -r 462ba3404c2d -r 2be2c5fff798 plugins/links/functions.inc
--- a/plugins/links/functions.inc	Sun Apr 12 23:42:22 2009 +0200
+++ b/plugins/links/functions.inc	Mon Apr 13 08:47:58 2009 +0200
@@ -181,25 +181,27 @@
         return 'link';
     } else if ($op == 'parse') {
         $lid = COM_applyFilter($autotag['parm1']);
-        $url = COM_buildUrl($_CONF['site_url']
+        if (! empty($lid)) {
+            $url = COM_buildUrl($_CONF['site_url']
                             . '/links/portal.php?what=link&item=' . $lid);
-        if (empty($autotag['parm2'])) {
-            $result = DB_query("SELECT url, title FROM {$_TABLES['links']} WHERE lid = '$lid'");
-            list($siteurl, $linktext) = DB_fetchArray($result);
-        } else {
-            $linktext = $autotag['parm2'];
-            $siteurl = DB_getItem($_TABLES['links'], 'url', "lid = '$lid'");
+            if (empty($autotag['parm2'])) {
+                $result = DB_query("SELECT url, title FROM {$_TABLES['links']} WHERE lid = '$lid'");
+                list($siteurl, $linktext) = DB_fetchArray($result);
+            } else {
+                $linktext = $autotag['parm2'];
+                $siteurl = DB_getItem($_TABLES['links'], 'url', "lid = '$lid'");
+            }
+            $class = 'ext-link';
+            if ((!empty($LANG_DIRECTION)) && ($LANG_DIRECTION == 'rtl')) {
+                $class .= '-rtl';
+            }
+            $attr = array(
+                        'title' => $siteurl,
+                        'class' => $class
+                         );
+            $link = COM_createLink($linktext, $url, $attr);
+            $content = str_replace($autotag['tagstr'], $link, $content);
         }
-        $class = 'ext-link';
-        if ((!empty($LANG_DIRECTION)) && ($LANG_DIRECTION == 'rtl')) {
-            $class .= '-rtl';
-        }
-        $attr = array(
-                    'title' => $siteurl,
-                    'class' => $class
-                     );
-        $link = COM_createLink($linktext, $url, $attr);
-        $content = str_replace($autotag['tagstr'], $link, $content);
 
         return $content;
     }
diff -r 462ba3404c2d -r 2be2c5fff798 plugins/staticpages/functions.inc
--- a/plugins/staticpages/functions.inc	Sun Apr 12 23:42:22 2009 +0200
+++ b/plugins/staticpages/functions.inc	Mon Apr 13 08:47:58 2009 +0200
@@ -943,25 +943,29 @@
     } else if ($op == 'parse') {
         if ($autotag['tag'] == 'staticpage' ) {
             $sp_id = COM_applyFilter($autotag['parm1']);
-            $url = COM_buildUrl($_CONF['site_url']
+            if (! empty($sp_is)) {
+                $url = COM_buildUrl($_CONF['site_url']
                                 . '/staticpages/index.php?page=' . $sp_id);
-            if (empty($autotag['parm2'])) {
-                $linktext = stripslashes(DB_getItem ($_TABLES['staticpage'],
-                                         'sp_title', "sp_id = '$sp_id'"));
-            } else {
-                $linktext = $autotag['parm2'];
+                if (empty($autotag['parm2'])) {
+                    $linktext = stripslashes(DB_getItem($_TABLES['staticpage'],
+                                             'sp_title', "sp_id = '$sp_id'"));
+                } else {
+                    $linktext = $autotag['parm2'];
+                }
+                $link = COM_createLink($linktext, $url);
+                $content = str_replace($autotag['tagstr'], $link, $content);
             }
-            $link = COM_createLink($linktext, $url);
-            $content = str_replace($autotag['tagstr'], $link, $content);
         } else if ($autotag['tag'] == 'staticpage_content') {
             $sp_id = COM_applyFilter($autotag['parm1']);
-            if (isset($recursive[$sp_id])) {
-                $content = '';
-            } else {
-                $recursive[$sp_id] = true;
-                $sp_content = SP_returnStaticpage($sp_id, 'autotag');
-                $content = str_replace($autotag['tagstr'], $sp_content,
-                                       $content);
+            if (! empty($sp_id)) {
+                if (isset($recursive[$sp_id])) {
+                    $content = '';
+                } else {
+                    $recursive[$sp_id] = true;
+                    $sp_content = SP_returnStaticpage($sp_id, 'autotag');
+                    $content = str_replace($autotag['tagstr'], $sp_content,
+                                           $content);
+                }
             }
         }
 
diff -r 462ba3404c2d -r 2be2c5fff798 system/lib-plugins.php
--- a/system/lib-plugins.php	Sun Apr 12 23:42:22 2009 +0200
+++ b/system/lib-plugins.php	Mon Apr 13 08:47:58 2009 +0200
@@ -1618,10 +1618,12 @@
                 $linktext = $autotag['parm2'];
                 if ($autotag['tag'] == 'story') {
                     $autotag['parm1'] = COM_applyFilter ($autotag['parm1']);
-                    $url = COM_buildUrl ($_CONF['site_url']
-                         . '/article.php?story=' . $autotag['parm1']);
-                    if (empty ($linktext)) {
-                        $linktext = stripslashes (DB_getItem ($_TABLES['stories'], 'title', "sid = '{$autotag['parm1']}'"));
+                    if (! empty($autotag['parm1'])) {
+                        $url = COM_buildUrl ($_CONF['site_url']
+                             . '/article.php?story=' . $autotag['parm1']);
+                        if (empty ($linktext)) {
+                            $linktext = stripslashes (DB_getItem ($_TABLES['stories'], 'title', "sid = '{$autotag['parm1']}'"));
+                        }
                     }
                 }
 



More information about the geeklog-cvs mailing list