[geeklog-cvs] Geeklog-1.x/public_html/links index.php,1.21,1.22

Oliver ospiess at qs1489.pair.com
Tue Aug 28 03:34:27 EDT 2007


Update of /usr/home/geeklog2/cvsroot/geeklog/Geeklog-1.x/public_html/links
In directory qs1489.pair.com:/tmp/cvs-serv65369

Modified Files:
	index.php 
Log Message:
install new links plugin with cateogory tree

Index: index.php
===================================================================
RCS file: /usr/home/geeklog2/cvsroot/geeklog/Geeklog-1.x/public_html/links/index.php,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** index.php	28 Apr 2007 18:55:47 -0000	1.21
--- index.php	28 Aug 2007 07:34:25 -0000	1.22
***************
*** 9,13 ****
  // | This is the main page for the Geeklog Links Plugin                        |
  // +---------------------------------------------------------------------------+
! // | Copyright (C) 2000-2007 by the following authors:                         |
  // |                                                                           |
  // | Authors: Tony Bibbs        - tony AT tonybibbs DOT com                    |
--- 9,13 ----
  // | This is the main page for the Geeklog Links Plugin                        |
  // +---------------------------------------------------------------------------+
! // | Copyright (C) 2000-2006 by the following authors:                         |
  // |                                                                           |
  // | Authors: Tony Bibbs        - tony AT tonybibbs DOT com                    |
***************
*** 35,41 ****
  // +---------------------------------------------------------------------------+
  //
! /**
!  * This is the links page
!  *
   * @package Links
   * @subpackage public_html
--- 35,41 ----
  // +---------------------------------------------------------------------------+
  //
! /** 
!  * This is the links page   
!  * 
   * @package Links
   * @subpackage public_html
***************
*** 44,48 ****
   * @since GL 1.4.0
   * @copyright Copyright © 2005-2006
!  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
   * @author Tony Bibbs <tony AT tonybibbs DOT com>
   * @author Mark Limburg <mlimburg AT users DOT sourceforge DOT net>
--- 44,48 ----
   * @since GL 1.4.0
   * @copyright Copyright © 2005-2006
!  * @license http://opensource.org/licenses/gpl-license.php GNU Public License 
   * @author Tony Bibbs <tony AT tonybibbs DOT com>
   * @author Mark Limburg <mlimburg AT users DOT sourceforge DOT net>
***************
*** 51,55 ****
   * @author Trinity Bays <trinity AT steubentech DOT com>
   * @author Dirk Haun <dirk AT haun-online DOT de>
!  *
   */
  // $Id$
--- 51,55 ----
   * @author Trinity Bays <trinity AT steubentech DOT com>
   * @author Dirk Haun <dirk AT haun-online DOT de>
!  * 
   */
  // $Id$
***************
*** 58,74 ****
  
  /**
! * create the links list depending on the category given
  *
- *  return       string      the links page
  */
! function links_list($message)
  {
!     global $_CONF, $_TABLES, $_LI_CONF, $LANG_LINKS_ADMIN, $LANG_LINKS,
!            $LANG_LINKS_STATS;
  
!     $category = '';
!     $display = '';
!     if (isset ($_GET['category'])) {
!         $category = strip_tags (COM_stripslashes ($_GET['category']));
      }
      $page = 0;
--- 58,121 ----
  
  /**
! * Prepare a link item for rendering
! *
! * @param    array   $A          link details
! * @param    ref     $template   reference of the links template
  *
  */
! function prepare_link_item ($A, &$template)
  {
!     global $_CONF, $LANG_ADMIN, $_IMAGE_TYPE;
  
!     $url = COM_buildUrl ($_CONF['site_url']
!                  . '/links/portal.php?what=link&item=' . $A['lid']);
!     $template->set_var ('link_url', $url);
!     $template->set_var ('link_actual_url', $A['url']);
!     $template->set_var ('link_name', stripslashes ($A['title']));
!     $template->set_var ('link_hits', COM_numberFormat ($A['hits']));
!     $template->set_var ('link_description',
!                         nl2br (stripslashes ($A['description'])));
! 
!     if ((SEC_hasAccess ($A['owner_id'], $A['group_id'], $A['perm_owner'],
!             $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3) &&
!             SEC_hasRights ('links.edit')) {
!         $editurl = $_CONF['site_admin_url']
!                  . '/plugins/links/index.php?mode=edit&lid=' . $A['lid'];
!         $template->set_var ('link_edit', '<a href="' . $editurl . '">'
!                  . $LANG_ADMIN['edit'] . '</a>');
!         $template->set_var ('edit_icon', '<a href="' . $editurl . '"><img src="'
!                  . $_CONF['layout_url'] . '/images/edit.' . $_IMAGE_TYPE
!                  . '" alt="' . $LANG_ADMIN['edit'] . '" title="'
!                  . $LANG_ADMIN['edit'] . '" border="0"></a>');
!     } else {
!         $template->set_var ('link_edit', '');
!         $template->set_var ('edit_icon', '');
!     }
! }
! 
! 
! // MAIN
! 
! $display = '';
! $root = 'site';
! 
! if (empty ($_USER['username']) &&
!     (($_CONF['loginrequired'] == 1) || ($_LI_CONF['linksloginrequired'] == 1))) {
!     $display .= COM_siteHeader ('menu', $LANG_LINKS[114]);
!     $display .= COM_startBlock ($LANG_LOGIN[1], '',
!                                 COM_getBlockTemplate ('_msg_block', 'header'));
!     $login = new Template ($_CONF['path_layout'] . 'submit');
!     $login->set_file (array ('login' => 'submitloginrequired.thtml'));
!     $login->set_var ('login_message', $LANG_LOGIN[2]);
!     $login->set_var ('site_url', $_CONF['site_url']);
!     $login->set_var ('lang_login', $LANG_LOGIN[3]);
!     $login->set_var ('lang_newuser', $LANG_LOGIN[4]);
!     $login->parse ('output', 'login');
!     $display .= $login->finish ($login->get_var ('output'));
!     $display .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
! } else {
!     $cid = '';
!     if (isset ($_REQUEST['cid'])) {
!         $cid = strip_tags (COM_stripslashes ($_REQUEST['cid']));
      }
      $page = 0;
***************
*** 80,84 ****
      }
  
!     if (empty ($category)) {
          if ($page > 1) {
              $page_title = sprintf ($LANG_LINKS[114] . ' (%d)', $page);
--- 127,133 ----
      }
  
!     if (empty ($cid)) {
!         // No category so set to root
!         $cid = $root;
          if ($page > 1) {
              $page_title = sprintf ($LANG_LINKS[114] . ' (%d)', $page);
***************
*** 88,106 ****
      } else {
          if ($page > 1) {
!             $page_title = sprintf ($LANG_LINKS[114] . ': %s (%d)', $category,
!                                                                    $page);
          } else {
!             $page_title = sprintf ($LANG_LINKS[114] . ': %s', $category);
          }
      }
-     $display .= COM_siteHeader ('menu', $page_title);
  
!     if (is_array($message) && !empty($message[0])) {
!         $display .= COM_startBlock ($message[0], '',
!                 COM_getBlockTemplate ('_msg_block', 'header'));
!         $display .= $message[1];
!         $display .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
      }
  
      $linklist = new Template ($_CONF['path'] . 'plugins/links/templates/');
      $linklist->set_file (array ('linklist' => 'links.thtml',
--- 137,164 ----
      } else {
          if ($page > 1) {
!             $page_title = sprintf ($LANG_LINKS[114] . ': %s (%d)', $cid, $page);
          } else {
!             $page_title = sprintf ($LANG_LINKS[114] . ': %s', $cid);
          }
      }
  
!     // Check has access to this category
!     if ($cid <> $root) {
!         $result = DB_query("SELECT owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['linkcategories']} WHERE cid='{$cid}'");
!         $A = DB_fetchArray($result);
!         if (SEC_hasAccess ($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) < 2) {
!             $display .= COM_siteHeader ('menu', $page_title);
!             $display .= COM_showMessage (5, 'links');
!             $display .= COM_siteFooter ();
!             echo $display;
!             exit;
!         }
      }
  
+ 
+ 
+     $display .= COM_siteHeader ('menu', $page_title);
+ 
+ 
      $linklist = new Template ($_CONF['path'] . 'plugins/links/templates/');
      $linklist->set_file (array ('linklist' => 'links.thtml',
***************
*** 115,139 ****
      $linklist->set_var ('layout_url',$_CONF['layout_url']);
  
      if ($_LI_CONF['linkcols'] > 0) {
!         $result = DB_query ("SELECT DISTINCT category FROM {$_TABLES['links']}" . COM_getPermSQL () . " ORDER BY category");
          $nrows  = DB_numRows ($result);
          if ($nrows > 0) {
!             $linklist->set_var ('lang_categories', $LANG_LINKS_ADMIN[14]);
              for ($i = 1; $i <= $nrows; $i++) {
                  $C = DB_fetchArray ($result);
!                 $cat = addslashes ($C['category']);
!                 $result1 = DB_query ("SELECT COUNT(*) AS count FROM {$_TABLES['links']} WHERE category = '{$cat}'" . COM_getPermSQL ('AND'));
                  $D = DB_fetchArray ($result1);
!                 if (empty ($C['category'])) {
!                     $linklist->set_var ('category_name', $LANG_LINKS_ADMIN[7]);
                  } else {
!                     $linklist->set_var ('category_name', $C['category']);
                  }
                  $linklist->set_var ('category_link', $_CONF['site_url'] .
!                     '/links/index.php?category=' . urlencode ($C['category']));
!                 $linklist->set_var ('category_count',
!                                     COM_numberFormat ($D['count']));
                  $linklist->set_var ('width', floor (100 / $_LI_CONF['linkcols']));
!                 if (!empty ($category) && ($category == $C['category'])) {
                      $linklist->parse ('category_col', 'actcol', true);
                  } else {
--- 173,235 ----
      $linklist->set_var ('layout_url',$_CONF['layout_url']);
  
+     // Create breadcrumb trail
+     $linklist->set_var('breadcrumbs', links_breadcrumbs ($root,$cid));
+ 
+     // Set dropdown for category jump
+     $linklist->set_var ('lang_go', $LANG_LINKS[117]);
+     $linklist->set_var('link_dropdown', links_select_box(2));
+ 
      if ($_LI_CONF['linkcols'] > 0) {
! 
!         // Show categories
!         $sql = "SELECT cid,pid,category,description FROM {$_TABLES['linkcategories']} WHERE pid='{$cid}'";
!         // check if we are using the multilanguage hack
!         if ($_LI_CONF['enable_multilingual_links']) {
!             $sql .= COM_getLangSQL('cid','AND');
!         }
!         $sql .= COM_getPermSQL('AND') . " ORDER BY category";
!         $result = DB_query($sql);
          $nrows  = DB_numRows ($result);
          if ($nrows > 0) {
!             $linklist->set_var ('lang_categories', $LANG_LINKS[118]);
              for ($i = 1; $i <= $nrows; $i++) {
                  $C = DB_fetchArray ($result);
! 
!                 // Get number of child links user can see in this category
!                 $result1 = DB_query ("SELECT COUNT(*) AS count FROM {$_TABLES['links']} WHERE cid='{$C['cid']}'" . COM_getPermSQL ('AND'));
                  $D = DB_fetchArray ($result1);
! 
!                 // Get number of child categories user can see in this category
!                 $result2 = DB_query ("SELECT COUNT(*) AS count FROM {$_TABLES['linkcategories']} WHERE pid='{$C['cid']}'" . COM_getPermSQL ('AND'));
!                 $E = DB_fetchArray($result2);
! 
!                 // Format numbers for display
!                 $display_count = '';
!                 // don't show zeroes
!                 if ($E['count']>0) {
!                     $display_count = COM_numberFormat ($E['count']);
!                 }
!                 if (($E['count']>0) && ($D['count']>0)) {
!                     $display_count .= ', ';
!                 }
!                 if ($D['count']>0) {
!                     $display_count .= COM_numberFormat ($D['count']);
!                 }
!                 // add brackets if child items exist
!                 if ($display_count<>'') {
!                     $display_count = '('.$display_count.')';
!                 }
! 
!                 $linklist->set_var ('category_name', $C['category']);
!                 if ($_LI_CONF['show_category_descriptions']) {
!                     $linklist->set_var ('category_description', $C['description']);
                  } else {
!                     $linklist->set_var ('category_description', '');
                  }
                  $linklist->set_var ('category_link', $_CONF['site_url'] .
!                     '/links/index.php?cid=' . urlencode ($C['cid']));
!                 $linklist->set_var ('category_count', $display_count);
                  $linklist->set_var ('width', floor (100 / $_LI_CONF['linkcols']));
!                 if (!empty ($cid) && ($cid == $C['cid'])) {
                      $linklist->parse ('category_col', 'actcol', true);
                  } else {
***************
*** 157,169 ****
  
      $linklist->set_var ('site_url', $_CONF['site_url']);
      $linklist->set_var ('lang_addalink', $LANG_LINKS[116]);
  
!     $sql = 'SELECT lid,category,url,description,title,hits,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon';
      $from_where = " FROM {$_TABLES['links']}";
      if ($_LI_CONF['linkcols'] > 0) {
!         if (!empty ($category)) {
!             $from_where .= " WHERE category = '" . addslashes ($category) . "'";
          } else {
!             $from_where .= " WHERE category = ''";
          }
          $from_where .= COM_getPermSQL ('AND');
--- 253,267 ----
  
      $linklist->set_var ('site_url', $_CONF['site_url']);
+     $linklist->set_var ('cid', $cid);
      $linklist->set_var ('lang_addalink', $LANG_LINKS[116]);
  
!     // Build SQL for links
!     $sql = 'SELECT lid,cid,url,description,title,hits,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon';
      $from_where = " FROM {$_TABLES['links']}";
      if ($_LI_CONF['linkcols'] > 0) {
!         if (!empty ($cid)) {
!             $from_where .= " WHERE cid='" . addslashes ($cid) . "'";
          } else {
!             $from_where .= " WHERE cid=''";
          }
          $from_where .= COM_getPermSQL ('AND');
***************
*** 171,175 ****
          $from_where .= COM_getPermSQL ();
      }
!     $order = ' ORDER BY category ASC,title';
      $limit = '';
      if ($_LI_CONF['linksperpage'] > 0) {
--- 269,273 ----
          $from_where .= COM_getPermSQL ();
      }
!     $order = ' ORDER BY cid ASC,title';
      $limit = '';
      if ($_LI_CONF['linksperpage'] > 0) {
***************
*** 183,194 ****
      $result = DB_query ($sql . $from_where . $order . $limit);
      $nrows = DB_numRows ($result);
      if ($nrows == 0) {
!         if (empty ($category) && ($page <= 1) && $_LI_CONF['show_top10']) {
              $result = DB_query ("SELECT lid,url,title,description,hits,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['links']} WHERE (hits > 0)" . COM_getPermSQL ('AND') . " ORDER BY hits DESC LIMIT 10");
              $nrows  = DB_numRows ($result);
              if ($nrows > 0) {
                  $linklist->set_var ('link_details', '');
!                 $linklist->set_var ('link_category',
!                                     $LANG_LINKS_STATS['stats_headline']);
                  for ($i = 0; $i < $nrows; $i++) {
                      $A = DB_fetchArray ($result);
--- 281,293 ----
      $result = DB_query ($sql . $from_where . $order . $limit);
      $nrows = DB_numRows ($result);
+ 
+     // No links
      if ($nrows == 0) {
!         if (($page <= 1) && $_LI_CONF['show_top10']) {
              $result = DB_query ("SELECT lid,url,title,description,hits,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['links']} WHERE (hits > 0)" . COM_getPermSQL ('AND') . " ORDER BY hits DESC LIMIT 10");
              $nrows  = DB_numRows ($result);
              if ($nrows > 0) {
                  $linklist->set_var ('link_details', '');
!                 $linklist->set_var ('link_category', $LANG_LINKS_STATS['stats_headline']);
                  for ($i = 0; $i < $nrows; $i++) {
                      $A = DB_fetchArray ($result);
***************
*** 200,217 ****
          }
          $linklist->set_var ('page_navigation', '');
      } else {
!         $currentcategory = '';
          for ($i = 0; $i < $nrows; $i++) {
              $A = DB_fetchArray ($result);
-             if (strcasecmp ($A['category'], $currentcategory) != 0) {
-                 // print the category and link
-                 if ($i > 0) {
-                     $linklist->parse ('category_links', 'catlinks', true);
-                     $linklist->set_var ('link_details', '');
-                 }
-                 $currentcategory = $A['category'];
-                 $linklist->set_var ('link_category', $currentcategory);
-             }
- 
              prepare_link_item ($A, $linklist);
              $linklist->parse ('link_details', 'link', true);
--- 299,311 ----
          }
          $linklist->set_var ('page_navigation', '');
+     // Have links, so build the page
      } else {
!         // Get current category name
!         $currentcategory=DB_GetItem($_TABLES['linkcategories'], "category","cid='{$cid}'");
!         $linklist->set_var ('link_category', $currentcategory);
!         $linklist->set_var ('link_details', '');
! 
          for ($i = 0; $i < $nrows; $i++) {
              $A = DB_fetchArray ($result);
              prepare_link_item ($A, $linklist);
              $linklist->parse ('link_details', 'link', true);
***************
*** 219,222 ****
--- 313,317 ----
          $linklist->parse ('category_links', 'catlinks', true);
  
+         // Google paging
          $result = DB_query ('SELECT COUNT(*) AS count ' . $from_where);
          list($numlinks) = DB_fetchArray ($result);
***************
*** 244,351 ****
      $linklist->parse ('output', 'linklist');
      $display .= $linklist->finish ($linklist->get_var ('output'));
-     return $display;
  }
  
- 
- /**
- * Prepare a link item for rendering
- *
- * @param    array   $A          link details
- * @param    ref     $template   reference of the links template
- *
- */
- function prepare_link_item ($A, &$template)
- {
-     global $_CONF, $_USER, $LANG_ADMIN, $LANG_LINKS, $_IMAGE_TYPE;
- 
-     $url = COM_buildUrl ($_CONF['site_url']
-                  . '/links/portal.php?what=link&item=' . $A['lid']);
-     $template->set_var ('link_url', $url);
-     $template->set_var ('link_actual_url', $A['url']);
-     $template->set_var ('link_name', stripslashes ($A['title']));
-     $template->set_var ('link_hits', COM_numberFormat ($A['hits']));
-     $template->set_var ('link_description',
-                         nl2br (stripslashes ($A['description'])));
-     $content = stripslashes ($A['title']);
-     $attr = array(
-         'title' => stripslashes ($A['title']),
-         'class' => 'ext-link');
-     $html = COM_createLink($content, $url, $attr);
-     $template->set_var ('link_html', $html);
-     if (isset ($_USER['uid']) && ($_USER['uid'] > 1)) {
-         $reporturl = $_CONF['site_url']
-                  . '/links/index.php?mode=report&lid=' . $A['lid'];
-         $template->set_var ('link_broken',
-                 COM_createLink($LANG_LINKS[117], $reporturl,
-                                array('class' => 'pluginSmallText',
-                                      'rel'   => 'nofollow'))
-         );
-     } else {
-         $template->set_var ('link_broken', '');
-     }
- 
-     if ((SEC_hasAccess ($A['owner_id'], $A['group_id'], $A['perm_owner'],
-             $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3) &&
-             SEC_hasRights ('links.edit')) {
-         $editurl = $_CONF['site_admin_url']
-                  . '/plugins/links/index.php?mode=edit&lid=' . $A['lid'];
-         $template->set_var ('link_edit', COM_createLink($LANG_ADMIN['edit'],$editurl));
-         $edit_icon = "<img src=\"{$_CONF['layout_url']}/images/edit.$_IMAGE_TYPE\" "
-             . "alt=\"{$LANG_ADMIN['edit']}\" title=\"{$LANG_ADMIN['edit']}\">";
-         $template->set_var ('edit_icon', COM_createLink($edit_icon, $editurl));
-     } else {
-         $template->set_var ('link_edit', '');
-         $template->set_var ('edit_icon', '');
-     }
- }
- 
- 
- // MAIN
- 
- $display = '';
- $mode = '';
- if (isset ($_REQUEST['mode'])) {
-     $mode = $_REQUEST['mode'];
- }
- 
- $message = array();
- if (($mode == 'report') && (isset($_USER['uid']) && ($_USER['uid'] > 1))) {
-     if (isset ($_GET['lid'])) {
-         $lid = COM_applyFilter($_GET['lid']);
-     }
-     if (!empty($lid)) {
-         $lidsl = addslashes($lid);
-         $result = DB_query("SELECT url, title FROM {$_TABLES['links']} WHERE lid = '$lidsl'");
-         list($url, $title) = DB_fetchArray($result);
- 
-         $editurl = $_CONF['site_admin_url']
-                  . '/plugins/links/index.php?mode=edit&lid=' . $lid;
-         $msg = $LANG_LINKS[119] . LB . LB . "$title, <$url>". LB . LB
-              .  $LANG_LINKS[120] . LB . '<' . $editurl . '>' . LB . LB
-              .  $LANG_LINKS[121] . $_USER['username'] . ', IP: '
-              . $_SERVER['REMOTE_ADDR'];
-         COM_mail($_CONF['site_mail'], $LANG_LINKS[118], $msg);
-         $message = array($LANG_LINKS[123], $LANG_LINKS[122]);
-     }
- }
- 
- if (empty ($_USER['username']) &&
-     (($_CONF['loginrequired'] == 1) || ($_LI_CONF['linksloginrequired'] == 1))) {
-     $display .= COM_siteHeader ('menu', $LANG_LINKS[114]);
-     $display .= COM_startBlock ($LANG_LOGIN[1], '',
-                                 COM_getBlockTemplate ('_msg_block', 'header'));
-     $login = new Template ($_CONF['path_layout'] . 'submit');
-     $login->set_file (array ('login' => 'submitloginrequired.thtml'));
-     $login->set_var ('login_message', $LANG_LOGIN[2]);
-     $login->set_var ('site_url', $_CONF['site_url']);
-     $login->set_var ('lang_login', $LANG_LOGIN[3]);
-     $login->set_var ('lang_newuser', $LANG_LOGIN[4]);
-     $login->parse ('output', 'login');
-     $display .= $login->finish ($login->get_var ('output'));
-     $display .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
- } else {
-     $display .= links_list($message);
- 
- }
  
  $display .= COM_siteFooter ();
--- 339,344 ----




More information about the geeklog-cvs mailing list