[geeklog-cvs] geeklog-1.3/public_html article.php,1.50,1.51 index.php,1.62,1.63 lib-common.php,1.360,1.361 submit.php,1.72,1.73

dhaun at iowaoutdoors.org dhaun at iowaoutdoors.org
Mon Aug 16 06:44:48 EDT 2004


Update of /var/cvs/geeklog-1.3/public_html
In directory www:/tmp/cvs-serv16589/public_html

Modified Files:
	article.php index.php lib-common.php submit.php 
Log Message:
Moved story-related functions to new file system/lib-story.php


Index: submit.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/submit.php,v
retrieving revision 1.72
retrieving revision 1.73
diff -C2 -d -r1.72 -r1.73
*** submit.php	9 Aug 2004 18:36:29 -0000	1.72
--- submit.php	16 Aug 2004 10:44:44 -0000	1.73
***************
*** 35,39 ****
  // $Id$
  
! require_once('lib-common.php');
  
  // Uncomment the line below if you need to debug the HTTP variables being passed
--- 35,40 ----
  // $Id$
  
! require_once ('lib-common.php');
! require_once ($_CONF['path_system'] . 'lib-story.php');
  
  // Uncomment the line below if you need to debug the HTTP variables being passed
***************
*** 297,301 ****
  	$A += DB_fetchArray($res);
          $retval .= COM_startBlock($LANG12[32])
!             . COM_article($A,'n')
              . COM_endBlock();
      }
--- 298,302 ----
  	$A += DB_fetchArray($res);
          $retval .= COM_startBlock($LANG12[32])
!             . STORY_renderArticle ($A, 'n')
              . COM_endBlock();
      }
***************
*** 674,678 ****
                  $result = DB_query ("SELECT * FROM {$_TABLES['topics']} WHERE tid='{$A['tid']}'");
                  $T = DB_fetchArray ($result);
!                 $related = addslashes (COM_whatsRelated ($introtext, $A['uid'], $A['tid']));
                  DB_save ($_TABLES['stories'], 'sid,uid,tid,title,introtext,related,date,commentcode,postmode,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon', "{$A['sid']},{$A['uid']},'{$A['tid']}','{$A['title']}','{$A['introtext']}','{$related}',NOW(),{$_CONF['comment_code']},'{$A['postmode']}',{$A['uid']},{$T['group_id']},{$T['perm_owner']},{$T['perm_group']},{$T['perm_members']},{$T['perm_anon']}");
  
--- 675,679 ----
                  $result = DB_query ("SELECT * FROM {$_TABLES['topics']} WHERE tid='{$A['tid']}'");
                  $T = DB_fetchArray ($result);
!                 $related = addslashes (STORY_whatsRelated ($introtext, $A['uid'], $A['tid']));
                  DB_save ($_TABLES['stories'], 'sid,uid,tid,title,introtext,related,date,commentcode,postmode,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon', "{$A['sid']},{$A['uid']},'{$A['tid']}','{$A['title']}','{$A['introtext']}','{$related}',NOW(),{$_CONF['comment_code']},'{$A['postmode']}',{$A['uid']},{$T['group_id']},{$T['perm_owner']},{$T['perm_group']},{$T['perm_members']},{$T['perm_anon']}");
  

Index: article.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/article.php,v
retrieving revision 1.50
retrieving revision 1.51
diff -C2 -d -r1.50 -r1.51
*** article.php	13 Aug 2004 15:41:58 -0000	1.50
--- article.php	16 Aug 2004 10:44:44 -0000	1.51
***************
*** 45,49 ****
  * Geeklog common function library
  */
! require_once('lib-common.php');
  
  // Uncomment the line below if you need to debug the HTTP variables being passed
--- 45,50 ----
  * Geeklog common function library
  */
! require_once ('lib-common.php');
! require_once ($_CONF['path_system'] . 'lib-story.php');
  
  // Uncomment the line below if you need to debug the HTTP variables being passed
***************
*** 188,193 ****
                          . urlencode ($printUrl) . '">' . $LANG11[5] . '</a>';
              }
!             $related = COM_whatsRelated ($A['introtext'] . ' ' . $A['bodytext'],
!                                          $A['uid'], $A['tid']);
              if (!empty ($related)) {
                  $related = COM_startBlock ($LANG11[1], '',
--- 189,194 ----
                          . urlencode ($printUrl) . '">' . $LANG11[5] . '</a>';
              }
!             $related = STORY_whatsRelated ($A['introtext'] . ' '
!                                     . $A['bodytext'], $A['uid'], $A['tid']);
              if (!empty ($related)) {
                  $related = COM_startBlock ($LANG11[1], '',
***************
*** 215,219 ****
              // }
  
!             $story_template->set_var('formatted_article', COM_article($A, 'n'));
              // Display the comments, if there are any ..
              if ($A['commentcode'] >= 0) {
--- 216,221 ----
              // }
  
!             $story_template->set_var ('formatted_article',
!                                       STORY_renderArticle ($A, 'n'));
              // Display the comments, if there are any ..
              if ($A['commentcode'] >= 0) {

Index: lib-common.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/lib-common.php,v
retrieving revision 1.360
retrieving revision 1.361
diff -C2 -d -r1.360 -r1.361
*** lib-common.php	15 Aug 2004 12:06:06 -0000	1.360
--- lib-common.php	16 Aug 2004 10:44:44 -0000	1.361
***************
*** 371,648 ****
  
  // +---------------------------------------------------------------------------+
- // | STORY FUNCTIONS                                                           |
- // +---------------------------------------------------------------------------+
- 
- /**
- * Returns the array (created from db record) passed to it as formated HTML
- *
- * Formats the given article data into HTML.  Called by index.php, article.php,
- * and admin/story.php (when previewing)
- *
- * @param    array       $A      Data to display as an article (associative array from record from gl_stories
- * @param    string      $index  whether or not this is the index page if 'n' then compact display for index page else display full article
- * @return   string      Article as formated HTML
- *
- */
- 
- function COM_article( $A, $index='', $storytpl='storytext.thtml' )
- {
-     global $_TABLES, $mode, $_CONF, $_USER, $LANG01, $LANG05, $LANG11, $_THEME_URL;
- 
-     $curtime = COM_getUserDateTimeFormat( $A['day'] );
-     $A['day'] = $curtime[0];
- 
-     // If plain text then replace newlines with <br> tags
-     if( $A['postmode'] == 'plaintext' )
-     {
-         $A['introtext'] = nl2br( COM_makeClickableLinks( $A['introtext'] ));
-         $A['bodytext'] = nl2br( COM_makeClickableLinks( $A['bodytext'] ));
-     }
- 
-     $A['introtext'] = str_replace( '{', '{', $A['introtext'] );
-     $A['introtext'] = str_replace( '}', '}', $A['introtext'] );
-     $A['bodytext'] = str_replace( '{', '{', $A['bodytext'] );
-     $A['bodytext'] = str_replace( '}', '}', $A['bodytext'] );
- 
-     $article = new Template( $_CONF['path_layout'] );
-     $article->set_file( array(
-             'article'          => $storytpl,
-             'bodytext'         => 'storybodytext.thtml',
-             'featuredarticle'  => 'featuredstorytext.thtml',
-             'featuredbodytext'=>'featuredstorybodytext.thtml',
-             'archivearticle'=>'archivestorytext.thtml',
-             'archivebodytext'=>'archivestorybodytext.thtml'
-             ));
- 
-     $article->set_var( 'layout_url', $_CONF['layout_url'] );
-     $article->set_var( 'site_url', $_CONF['site_url'] );
-     $article->set_var( 'story_date', $A['day'] );
-     $article->set_var( 'lang_views', $LANG01[106] );
-     $article->set_var( 'story_hits', $A['hits'] );
-     $article->set_var( 'story_id', $A['sid'] );
- 
-     if( $_CONF['contributedbyline'] == 1 )
-     {
-         $article->set_var( 'lang_contributed_by', $LANG01[1] );
-         $article->set_var( 'contributedby_uid', $A['uid'] );
-         $username = $A['username'];
-         $article->set_var( 'contributedby_user', $username );
- 
-         $fullname = $A['fullname'];
-         if( empty( $fullname ))
-         {
-             $article->set_var( 'contributedby_fullname', $username );
-         }
-         else
-         {
-             $article->set_var( 'contributedby_fullname', $fullname );
-         }
- 
-         if( $A['uid'] > 1 )
-         {
-             $article->set_var( 'start_contributedby_anchortag',
-                     '<a class="storybyline" href="' . $_CONF['site_url']
-                     . '/users.php?mode=profile&uid=' . $A['uid'] . '">' );
-             $article->set_var( 'end_contributedby_anchortag', '</a>' );
-             $article->set_var( 'contributedby_url', $_CONF['site_url']
-                     . '/users.php?mode=profile&uid=' . $A['uid'] );
- 
-             $photo = $A['photo'];
-             if( !empty( $photo ))
-             {
-                 if( empty( $fullname ))
-                 {
-                     $altname = $username;
-                 }
-                 else
-                 {
-                     $altname = $fullname;
-                 }
-                 $article->set_var( 'contributedby_photo', '<img src="'
-                         . $_CONF['site_url'] . '/images/userphotos/' . $photo
-                         . '" alt="' . $altname . '">' );
-             }
-         }
-     }
- 
-     if( $_USER['noicons'] != 1 AND $A['show_topic_icon'] == 1 )
-     {
-         $topicname = htmlspecialchars( stripslashes( $A['topic'] ));
-         $topicurl = $_CONF['site_url'] . '/index.php?topic=' . $A['tid'];
-         if( !empty( $A['imageurl'] ))
-         {
-             if( isset( $_THEME_URL ))
-             {
-                 $imagebase = $_THEME_URL;
-             }
-             else
-             {
-                 $imagebase = $_CONF['site_url'];
-             }
-             $topicimage = '<img align="' . $_CONF['article_image_align']
-                     . '" src="' . $imagebase . $A['imageurl'] . '" alt="'
-                     . $topicname . '" title="' . $topicname . '" border="0">';
-             $article->set_var( 'story_anchortag_and_image', '<a href="'
-                     . $topicurl . '">' . $topicimage . '</a>' );
-             $article->set_var( 'story_topic_image', $topicimage );
-         }
-         $article->set_var( 'story_topic_id', $A['tid'] );
-         $article->set_var( 'story_topic_name', $topicname );
-         $article->set_var( 'story_topic_url', $topicurl );
-     }
- 
-     $A['title'] = str_replace( '$', '$', $A['title'] );
-     $A['introtext'] = str_replace( '$', '$', $A['introtext'] );
-     $A['bodytext'] = str_replace( '$', '$', $A['bodytext'] );
- 
-     $recent_post_anchortag = '';
-     $articleUrl = COM_buildUrl( $_CONF['site_url'] . '/article.php?story='
-                                 . $A['sid'] );
-     $introtext = stripslashes( $A['introtext'] );
-     if( $index == 'n' )
-     {
-         $article->set_var( 'story_title', stripslashes( $A['title'] ));
-         if( empty( $A['bodytext'] ))
-         {
-             $article->set_var( 'story_introtext', $introtext );
-         }
-         else
-         {
-             $article->set_var( 'story_introtext', $introtext . '<br><br>'
-                                . stripslashes( $A['bodytext'] ));
-         }
-     }
-     else
-     {
-         $article->set_var( 'story_title', stripslashes( $A['title'] ));
-         $article->set_var( 'story_introtext', $introtext );
- 
-         if( !empty( $A['bodytext'] ))
-         {
-             $article->set_var( 'lang_readmore', $LANG01[2] );
-             $article->set_var( 'lang_readmore_words', $LANG01[62] );
-             $numwords = sizeof( explode( ' ', $A['bodytext'] ));
-             $article->set_var( 'readmore_words', $numwords );
- 
-             $article->set_var( 'readmore_link', '<a href="' . $articleUrl . '">'
-                     . $LANG01[2] . '</a> (' . $numwords . ' ' . $LANG01[62]
-                     . ') ' );
-             $article->set_var( 'start_readmore_anchortag', '<a href="'
-                     . $articleUrl . '">' );
-             $article->set_var( 'end_readmore_anchortag', '</a>' );
-         }
- 
-         if( $A['commentcode'] >= 0 )
-         {
-             if( $A['comments'] > 0 )
-             {
-                 $commentsUrl = COM_buildUrl( $_CONF['site_url']
-                         . '/article.php?story=' . $A['sid'] . '#comments' );
-                 $article->set_var( 'comments_url', $commentsUrl );
-                 $article->set_var( 'comments_text', $A['comments'] . ' '
-                         . $LANG01[3] );
-                 $article->set_var( 'comments_count', $A['comments'] );
-                 $article->set_var( 'lang_comments', $LANG01[3] );
- 
-                 $result = DB_query( "SELECT UNIX_TIMESTAMP(date) AS day,username FROM {$_TABLES['comments']},{$_TABLES['users']} WHERE {$_TABLES['users']}.uid = {$_TABLES['comments']}.uid AND sid = '{$A['sid']}' ORDER BY date desc LIMIT 1" );
-                 $C = DB_fetchArray( $result );
- 
-                 $recent_post_anchortag = '<span class="storybyline">'
-                         . $LANG01[27] . ': '
-                         . strftime( $_CONF['daytime'], $C['day'] ) . ' '
-                         . $LANG01[104] . ' ' . $C['username'] . '</span>';
-                 $article->set_var( 'start_comments_anchortag', '<a href="'
-                         . $commentsUrl . '">' );
-                 $article->set_var( 'end_comments_anchortag', '</a>' );
-             }
-             else
-             {
-                 $recent_post_anchortag = ' <a href="' . $_CONF['site_url']
-                         . '/comment.php?sid=' . $A['sid']
-                         . '&pid=0&type=article">' . $LANG01[60] . '</a>';
-             }
-             $article->set_var( 'post_comment_link',' <a href="'
-                     . $_CONF['site_url'] . '/comment.php?sid=' . $A['sid']
-                     . '&pid=0&type=article">' . $LANG01[60] . '</a>' );
-         }
- 
-         if( $_CONF['hideemailicon'] == 1 )
-         {
-             $article->set_var( 'email_icon', '' );
-         }
-         else
-         {
-             $article->set_var( 'email_icon', '<a href="' . $_CONF['site_url']
-                 . '/profiles.php?sid=' . $A['sid'] . '&what=emailstory">'
-                 . '<img src="' . $_CONF['layout_url']
-                 . '/images/mail.gif" alt="' . $LANG01[64]
-                 . '" title="' . $LANG11[2] . '" border="0"></a>' );
-         }
-         $printUrl = COM_buildUrl( $_CONF['site_url'] . '/article.php?story='
-                                   . $A['sid'] . '&mode=print' );
-         if( $_CONF['hideprintericon'] == 1 )
-         {
-             $article->set_var( 'print_icon', '' );
-         }
-         else
-         {
-             $article->set_var( 'print_icon', '<a href="' . $printUrl . '">'
-                 . '<img border="0" src="' . $_CONF['layout_url']
-                 . '/images/print.gif" alt="' . $LANG01[65] . '" title="'
-                 . $LANG11[3] . '"></a>' );
-         }
-         if( $_CONF['pdf_enabled'] == 1 )
-         {
-             $article->set_var( 'pdf_icon',
-                 sprintf( '<a href="%s/pdfgenerator.php?pageType=2&pageData=%s"><img border="0" src="%s/images/pdf.gif" alt="%s" title="%s"></a>',
-                     $_CONF['site_url'], urlencode( $printUrl ),
-                     $_CONF['layout_url'], $LANG01[111], $LANG11[5] ));
-         }
-         else
-         {
-             $article->set_var( 'pdf_icon', '' );
-         }
-     }
-     $article->set_var( 'article_url', $articleUrl );
-     $article->set_var( 'recent_post_anchortag', $recent_post_anchortag );
- 
-     if( SEC_hasAccess( $A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon'] ) == 3 AND SEC_hasrights( 'story.edit' ))
-     {
-         $article->set_var( 'edit_link', '<a href="' . $_CONF['site_admin_url']
-                 . '/story.php?mode=edit&sid=' . $A['sid'] . '">'
-                 . $LANG01[4] . '</a>' );
-         $article->set_var( 'edit_url', $_CONF['site_admin_url']
-                 . '/story.php?mode=edit&sid=' . $A['sid'] );
-         $article->set_var( 'lang_edit_text',  $LANG01[4] );
-         $article->set_var( 'edit_icon', '<a href="' . $_CONF['site_admin_url']
-                 . '/story.php?mode=edit&sid=' . $A['sid'] . '"><img src="'
-                 . $_CONF['layout_url'] . '/images/edit.gif" alt="' . $LANG01[4]
-                 . '" title="' . $LANG01[4] . '" border="0"></a>' );
-         $article->set_var( 'edit_image',  '<img src="' . $_CONF['layout_url']
-                 . '/images/edit.gif" alt="' . $LANG01[4] . '" title="'
-                 . $LANG01[4] . '" border="0">' );
-     }
- 
-     if( $A['featured'] == 1 )
-     {
-         $article->set_var( 'lang_todays_featured_article', $LANG05[4] );
-         $article->parse( 'story_bodyhtml', 'featuredbodytext', true );
-         $article->parse( 'finalstory', 'featuredarticle' );
-     }
-     elseif ($A['statuscode'] == 10)
-     {
-         $article->parse( 'story_bodyhtml', 'archivestorybodytext', true );
-         $article->parse( 'finalstory', 'archivearticle' );
-     }
-     else
-     {
-         $article->parse( 'story_bodyhtml', 'bodytext', true );
-         $article->parse( 'finalstory', 'article' );
-     }
- 
-     return $article->finish( $article->get_var( 'finalstory' ));
- }
- 
- // +---------------------------------------------------------------------------+
  // | HTML WIDGETS                                                              |
  // +---------------------------------------------------------------------------+
--- 371,374 ----
***************
*** 5489,5570 ****
  
  /**
- * Extract links from an HTML-formatted text.
- *
- * Collects all the links in a story and returns them in an array.
- *
- * @param        string      $fulltext   the text to search for links
- * @param        int         $maxlength  max. length of text in a link (can be 0)
- * @return       array       an array of strings of form <a href="...">link</a>
- */
- 
- function COM_extractLinks( $fulltext, $maxlength = 26 )
- {
-     $rel = array();
- 
-     /* Only match anchor tags that contain 'href="<something>"'
-      */
-     preg_match_all( "/<a[^>]*href=[\"']([^\"']*)[\"'][^>]*>(.*?)<\/a>/i", $fulltext, $matches );
-     for ( $i=0; $i< count( $matches[0] ); $i++ )
-     {
-         $matches[2][$i] = strip_tags( $matches[2][$i] );
-         if ( !strlen( trim( $matches[2][$i] ) ) ) {
-             $matches[2][$i] = strip_tags( $matches[1][$i] );
-         }
- 
-         // if link is too long, shorten it and add ... at the end
-         if ( ( $maxlength > 0 ) && ( strlen( $matches[2][$i] ) > $maxlength ) )
-         {
-             $matches[2][$i] = substr( $matches[2][$i], 0, $maxlength - 3 ) . '...';
-         }
- 
-         $rel[] = '<a href="' . $matches[1][$i] . '">' . $matches[2][$i] . '</a>';
-     }
- 
-     return( $rel );
- }
- 
- /**
- * Create "What's Related" links for a story
- *
- * Creates an HTML-formatted list of links to be used for the What's Related
- * block next to a story (in article view).
- *
- * @param        string      $fulltext   the story text
- * @param        int         $uid        user id of the author
- * @param        int         $tid        topic id
- * @return       string      HTML-formatted list of links
- */
- 
- function COM_whatsRelated( $fulltext, $uid, $tid )
- {
-     global $_CONF, $_TABLES, $LANG24;
- 
-     // collect any links from the story text
-     $rel = COM_extractLinks( $fulltext );
- 
-     if( !empty( $_USER['username'] ) || (( $_CONF['loginrequired'] == 0 ) &&
-            ( $_CONF['searchloginrequired'] == 0 ))) {
-         // add a link to "search by author"
-         if( $_CONF['contributedbyline'] == 1 )
-         {
-             $author = DB_getItem( $_TABLES['users'], 'username', "uid = $uid" );
-             $rel[] = "<a href=\"{$_CONF['site_url']}/search.php?mode=search&type=stories&author=$uid\">{$LANG24[37]} $author</a>";
-         }
- 
-         // add a link to "search by topic"
-         $topic = DB_getItem( $_TABLES['topics'], 'topic', "tid = '$tid'" );
-         $rel[] = "<a href=\"{$_CONF['site_url']}/search.php?mode=search&type=stories&topic=$tid\">{$LANG24[38]} $topic</a>";
-     }
- 
-     $related = '';
-     if( sizeof( $rel ) > 0 )
-     {
-         $related = COM_checkWords( COM_makeList( $rel, 'list-whats-related' ));
-     }
- 
-     return( $related );
- }
- 
- /**
  * Return SQL expression to check for permissions.
  *
--- 5215,5218 ----

Index: index.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/index.php,v
retrieving revision 1.62
retrieving revision 1.63
diff -C2 -d -r1.62 -r1.63
*** index.php	15 Aug 2004 19:57:49 -0000	1.62
--- index.php	16 Aug 2004 10:44:44 -0000	1.63
***************
*** 35,39 ****
  // $Id$
  
! require_once('lib-common.php');
  
  $newstories = false;
--- 35,40 ----
  // $Id$
  
! require_once ('lib-common.php');
! require_once ($_CONF['path_system'] . 'lib-story.php');
  
  $newstories = false;
***************
*** 190,194 ****
  
      // display first article
!     $display .= COM_article($A,'y');
  
      // get plugin center blocks after featured article
--- 191,195 ----
  
      // display first article
!     $display .= STORY_renderArticle ($A, 'y');
  
      // get plugin center blocks after featured article
***************
*** 199,203 ****
      // get reamaining stories
      while ( $A = DB_fetchArray($result) ) {
!         $display .= COM_article($A,'y');
      }
  
--- 200,204 ----
      // get reamaining stories
      while ( $A = DB_fetchArray($result) ) {
!         $display .= STORY_renderArticle ($A, 'y');
      }
  




More information about the geeklog-cvs mailing list