[geeklog-cvs] geeklog-1.3/sql/updates mysql_1.3.9_to_1.3.10.php,1.13,1.14

dhaun at iowaoutdoors.org dhaun at iowaoutdoors.org
Sun Aug 22 13:53:24 EDT 2004


Update of /var/cvs/geeklog-1.3/sql/updates
In directory www:/tmp/cvs-serv22007/sql/updates

Modified Files:
	mysql_1.3.9_to_1.3.10.php 
Log Message:
Changes so that the links for the What's Related block are stored in the database again, instead of having to parse the story every time it is rendered.


Index: mysql_1.3.9_to_1.3.10.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/sql/updates/mysql_1.3.9_to_1.3.10.php,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** mysql_1.3.9_to_1.3.10.php	4 Aug 2004 18:45:57 -0000	1.13
--- mysql_1.3.9_to_1.3.10.php	22 Aug 2004 17:53:22 -0000	1.14
***************
*** 89,92 ****
--- 89,123 ----
  }
  
+ 
+ // Note: this is the exact same function as STORY_extractLinks
+ function UPDATE_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] . '">'
+                . str_replace ("/(\015\012)|(\015)|(\012)/", '', $matches[2][$i])
+                . '</a>';
+     }
+ 
+     return( $rel );
+ }
+ 
+ 
  // modify the comments table to speed things up
  $_SQL[] = "ALTER TABLE {$_TABLES['comments']} ADD lft mediumint(10) unsigned NOT NULL default '0' AFTER pid";




More information about the geeklog-cvs mailing list