[geeklog-cvs] geeklog-1.3/public_html article.php,1.30,1.31

dhaun at geeklog.net dhaun at geeklog.net
Mon Jan 20 14:10:46 EST 2003


Update of /usr/cvs/geeklog/geeklog-1.3/public_html
In directory internal.geeklog.net:/tmp/cvs-serv26589

Modified Files:
	article.php 
Log Message:
What's Related block is now created dynamically,
removed some redundant code.


Index: article.php
===================================================================
RCS file: /usr/cvs/geeklog/geeklog-1.3/public_html/article.php,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** article.php	16 Jan 2003 22:52:40 -0000	1.30
--- article.php	20 Jan 2003 19:10:44 -0000	1.31
***************
*** 50,54 ****
  // the data being passed in a POST operation
  
! // debug($HTTP_POST_VARS);
  
  // MAIN
--- 50,54 ----
  // the data being passed in a POST operation
  
! // echo COM_debug($HTTP_POST_VARS);
  
  // MAIN
***************
*** 72,86 ****
      if ($reply == $LANG01[25]) {
          echo COM_refresh($_CONF['site_url'] . "/comment.php?sid=$story&pid=$pid&type=$type");
!     } else if (($mode == "print") && ($_CONF['hideprintericon'] == 0)) {
!         $result = DB_query("SELECT *,unix_timestamp(date) AS day FROM {$_TABLES['stories']} WHERE sid = '$story'");
!         $A = DB_fetchArray($result);
!         $access = SEC_hasAccess($A['owner_id'],$A['group_id'],$A['perm_owner'],$A['perm_group'],$A['perm_members'],$A['perm_anon']);
!         if (SEC_hasAccess($A['owner_id'],$A['group_id'],$A['perm_owner'],$A['perm_group'],$A['perm_members'],$A['perm_anon']) == 0 OR (!SEC_hasTopicAccess($A['tid']))) {   
!             $display .= COM_siteHeader('menu')
!                 .COM_startBlock($LANG_ACCESS[accessdenied])
!                 .$LANG_ACCESS[storydenialmsg]
!                 .COM_endBlock()
!                 .COM_siteFooter();
!         } else {
              $story_template = new Template($_CONF['path_layout'] . 'article');
              $story_template->set_file('article','printable.thtml');
--- 72,89 ----
      if ($reply == $LANG01[25]) {
          echo COM_refresh($_CONF['site_url'] . "/comment.php?sid=$story&pid=$pid&type=$type");
!     } else {
!         $result = DB_query ("SELECT sid,uid,tid,title,introtext,bodytext,hits,comments,featured,show_topic_icon,commentcode,postmode,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon,unix_timestamp(date) AS day FROM {$_TABLES['stories']} WHERE sid = '$story'");
!         $A = DB_fetchArray ($result);
! 
!         $access = SEC_hasAccess ($A['owner_id'], $A['group_id'],
!                 $A['perm_owner'], $A['perm_group'], $A['perm_members'],
!                 $A['perm_anon']);
!         if (($access == 0) OR !SEC_hasTopicAccess ($A['tid'])) {
!             $display .= COM_siteHeader ('menu')
!                      . COM_startBlock ($LANG_ACCESS['accessdenied'])
!                      . $LANG_ACCESS['storydenialmsg']
!                      . COM_endBlock ()
!                      . COM_siteFooter ();
!         } elseif (($mode == "print") && ($_CONF['hideprintericon'] == 0)) {
              $story_template = new Template($_CONF['path_layout'] . 'article');
              $story_template->set_file('article','printable.thtml');
***************
*** 103,197 ****
              $story_template->parse('output','article');
              $display = $story_template->finish($story_template->get_var('output')); 
!         }
!     } else {
!         // Set page title
! 
!         $result = DB_query("SELECT *,unix_timestamp(date) AS day FROM {$_TABLES["stories"]} WHERE sid = '$story'");
!         $A = DB_fetchArray($result);
!         $_CONF['pagetitle'] = stripslashes(str_replace('$','$',$A['title']));
!         $display .= COM_siteHeader('menu');
! 
!         // Make sure user has access to this article
!         $access = SEC_hasAccess($A['owner_id'],$A['group_id'],$A['perm_owner'],$A['perm_group'],$A['perm_members'],$A['perm_anon']);
!         if (SEC_hasAccess($A['owner_id'],$A['group_id'],$A['perm_owner'],$A['perm_group'],$A['perm_members'],$A['perm_anon']) == 0 OR (!SEC_hasTopicAccess($A['tid']))) {
!             // Bail, they don't have access
!             $display .= COM_startBlock($LANG_ACCESS[accessdenied])
!                 .$LANG_ACCESS[storydenialmsg]
!                 .COM_endBlock()
!                 .COM_siteFooter();
!             echo $display;
!             exit;
!         }
! 
!         // They have access...go ahead and show the article
  
!         DB_change($_TABLES['stories'],'hits',DB_getItem($_TABLES['stories'],'hits',"sid = '$story'") + 1,'sid',$story);
!         $sql = "SELECT *,unix_timestamp(date) AS day FROM {$_TABLES['stories']} WHERE sid = '$story' ";
!         $result = DB_query($sql);
!         $A = DB_fetchArray($result);
  
! 		if($query)
! 		{
! 			$mywords = explode(" ",$query);
!             foreach ($mywords as $searchword)
!             {
!                     $A['introtext'] = preg_replace ("/($searchword)/i", "<span class=highlight>\\1</span>", $A['introtext']);
!                     $A['bodytext'] = preg_replace ("/($searchword)/i", "<span class=highlight>\\1</span>", $A['bodytext']);
              }
  
! 		}
! 
! 
!         // Display whats related any polls configured for this page
  
!         $story_template = new Template($_CONF['path_layout'] . 'article');
!         $story_template->set_file('article','article.thtml');
  
!         $story_template->set_var('site_url', $_CONF['site_url']);
!         $story_template->set_var('layout_url', $_CONF['layout_url']);
!         $story_options = array ();
!         if ($_CONF['hideemailicon'] == 0) {
!             $story_options[] = '<a href="' . $_CONF['site_url'] .
!                     '/profiles.php?sid=' . $story . '&what=emailstory">' .
!                     $LANG11[2] . '</a>';
!         }
!         if ($_CONF['hideprintericon'] == 0) {
!             $story_options[] = '<a href="' . $_CONF['site_url']
!                     .  '/article.php?story=' . $story .  '&mode=print">'
                      . $LANG11[3] . '</a>';
!         }
!         $related = $A['related'];
!         if (!empty ($related)) {
!             $related = COM_startBlock ($LANG11[1], '',
!                 COM_getBlockTemplate ('whats_related_block', 'header'))
!                 . $A['related']
!                 . COM_endBlock (COM_getBlockTemplate ('whats_related_block',
!                     'footer'));
!         }
!         if (count ($story_options) > 0) {
!             $optionsblock = COM_startBlock ($LANG11[4], '',
!                     COM_getBlockTemplate ('story_options_block', 'header'))
!                 . COM_makeList ($story_options)
!                 . COM_endBlock(COM_getBlockTemplate('story_options_block','footer'));
!         } else {
!             $optionsblock = '';
!         }
!         $story_template->set_var ('whats_related', $related);
!         $story_template->set_var ('story_options', $optionsblock);
!         $story_template->set_var ('whats_related_story_options',
!             $related . $optionsblock);
  
!         // if (DB_count($_TABLES['pollquestions'],'qid',$story) > 0) {
!         //  $display .= COM_showPoll(80,$story);
!         // }
!         
!         $story_template->set_var('formatted_article', COM_article($A,'n'));
!         // Display the comments, if there are any ..
!         if ($A['commentcode'] >= 0) {
!                 $story_template->set_var('commentbar', COM_userComments($story,$A['title'],'article',$order,$mode));
          }
-         $story_template->parse('output', 'article');
-         $display .= $story_template->finish($story_template->get_var('output'));
-         $display .= COM_siteFooter();
      }
  } else {
--- 106,182 ----
              $story_template->parse('output','article');
              $display = $story_template->finish($story_template->get_var('output')); 
!         } else {
!             // Set page title
!             $_CONF['pagetitle'] = stripslashes (str_replace ('$', '$',
!                                                 $A['title']));
!             $display .= COM_siteHeader ('menu');
  
!             DB_change ($_TABLES['stories'], 'hits', DB_getItem ($_TABLES['stories'], 'hits', "sid = '$story'") + 1, 'sid', $story);
  
!             if ($query) {
!                 $mywords = explode(" ",$query);
!                 foreach ($mywords as $searchword) {
!                     $A['introtext'] = preg_replace ("/($searchword)/i",
!                         "<span class=\"highlight\">\\1</span>", $A['introtext']);
!                     $A['bodytext'] = preg_replace ("/($searchword)/i",
!                         "<span class=\"highlight\">\\1</span>", $A['bodytext']);
!                 }
              }
  
!             // Display whats related any polls configured for this page
  
!             $story_template = new Template($_CONF['path_layout'] . 'article');
!             $story_template->set_file('article','article.thtml');
  
!             $story_template->set_var('site_url', $_CONF['site_url']);
!             $story_template->set_var('layout_url', $_CONF['layout_url']);
!             $story_options = array ();
!             if ($_CONF['hideemailicon'] == 0) {
!                 $story_options[] = '<a href="' . $_CONF['site_url']
!                     . '/profiles.php?sid=' . $story . '&what=emailstory">'
!                     . $LANG11[2] . '</a>';
!             }
!             if ($_CONF['hideprintericon'] == 0) {
!                 $story_options[] = '<a href="' . $_CONF['site_url']
!                     . '/article.php?story=' . $story .  '&mode=print">'
                      . $LANG11[3] . '</a>';
!             }
!             $related = COM_whatsRelated ($A['introtext'] . ' ' . $A['bodytext'],
!                                          $A['uid'], $A['tid']);
!             if (!empty ($related)) {
!                 $related = COM_startBlock ($LANG11[1], '',
!                     COM_getBlockTemplate ('whats_related_block', 'header'))
!                     . $related
!                     . COM_endBlock (COM_getBlockTemplate ('whats_related_block',
!                         'footer'));
!             }
!             if (count ($story_options) > 0) {
!                 $optionsblock = COM_startBlock ($LANG11[4], '',
!                         COM_getBlockTemplate ('story_options_block', 'header'))
!                     . COM_makeList ($story_options)
!                     . COM_endBlock (COM_getBlockTemplate ('story_options_block',
!                         'footer'));
!             } else {
!                 $optionsblock = '';
!             }
!             $story_template->set_var ('whats_related', $related);
!             $story_template->set_var ('story_options', $optionsblock);
!             $story_template->set_var ('whats_related_story_options',
!                     $related . $optionsblock);
  
!             // if (DB_count($_TABLES['pollquestions'],'qid',$story) > 0) {
!             //     $display .= COM_showPoll(80,$story);
!             // }
! 
!             $story_template->set_var('formatted_article', COM_article($A, 'n'));
!             // Display the comments, if there are any ..
!             if ($A['commentcode'] >= 0) {
!                 $story_template->set_var ('commentbar',
!                         COM_userComments ($story, $A['title'], 'article',
!                                           $order, $mode));
!             }
!             $display .= $story_template->finish ($story_template->parse ('output', 'article'));
!             $display .= COM_siteFooter ();
          }
      }
  } else {
***************
*** 200,202 ****
  echo $display;
  
! ?>
\ No newline at end of file
--- 185,187 ----
  echo $display;
  
! ?>





More information about the geeklog-cvs mailing list