Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30916
Modified Files:
Tag: branch-smarty
serendipity_functions.inc.php NEWS
Log Message:
when searching for autodetected links, now not only accept text within <a> tags, but also <img> tags. Their alt-attribute will be used as description for the link title.
Index: NEWS
===================================================================
RCS file: /cvsroot/php-blog/serendipity/NEWS,v
retrieving revision 1.214.2.38
retrieving revision 1.214.2.39
diff -u -d -r1.214.2.38 -r1.214.2.39
--- NEWS 22 Oct 2004 17:33:51 -0000 1.214.2.38
+++ NEWS 26 Oct 2004 14:27:58 -0000 1.214.2.39
@@ -3,7 +3,10 @@
Version 0.8 ()
------------------------------------------------------------------------
- * Implement plugin install() and uninstall() methods that are called
+ * Routine for autodetecting links within an entry will now also
+ allow images to be used as description. (garvinhicking)
+
+ * Implement plugin install() and uninstall() methods that are called
on installation and removal of a plugin (tomsommer)
* Improve overall rewrite path syntax (tomsommer)
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.419.2.54
retrieving revision 1.419.2.55
diff -u -d -r1.419.2.54 -r1.419.2.55
--- serendipity_functions.inc.php 26 Oct 2004 13:33:47 -0000 1.419.2.54
+++ serendipity_functions.inc.php 26 Oct 2004 14:27:56 -0000 1.419.2.55
@@ -2064,7 +2064,7 @@
function serendipity_handle_references($id, $author, $title, $text) {
global $serendipity;
- if (!preg_match_all('@<a[^>]+?href\s*=\s*["\']?([^\'" >]+?)[ \'"][^>]*>([^<]*)</a>@i', $text, $matches)) {
+ if (!preg_match_all('@<a[^>]+?href\s*=\s*["\']?([^\'" >]+?)[ \'"][^>]*>(.+?)</a>@i', $text, $matches)) {
return;
}
@@ -2076,7 +2076,8 @@
// Add URL references
$locations = $matches[0];
- $names = $matches[1];
+ $names = $matches[1];
+
$tmpid = serendipity_db_escape_string($id);
$checked_locations = array();
@@ -2085,10 +2086,20 @@
$locations[$i] = 'http' . (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off' ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $locations[$i];
}
- if ( isset($checked_locations[$locations[$i]]) ) {
+ if (isset($checked_locations[$locations[$i]])) {
continue;
}
+ if (preg_match_all('@<img[^>]+?alt=["\']?([^\'">]+?)[\'"][^>]+?>@i', $names[$i], $img_alt)) {
+ if (is_array($img_alt) && is_array($img_alt[0])) {
+ foreach($img_alt[0] as $alt_idx => $alt_img) {
+ // Replace all <img>s within a link with their respective ALT tag, so that references
+ // can be stored with a title.
+ $names[$i] = str_replace($alt_img, $img_alt[1][$alt_idx], $names[$i]);
+ }
+ }
+ }
+
$query = "SELECT COUNT(id) FROM {$serendipity['dbPrefix']}references
WHERE entry_id = '". (int)$tmpid ."'
AND link = '" . serendipity_db_escape_string($locations[$i]) . "'";
@@ -2107,7 +2118,7 @@
for ($i = 0; $i < $j; ++$i) {
$query = "INSERT INTO {$serendipity['dbPrefix']}references (entry_id, name, link) VALUES(";
- $query .= "'$tmpid', '" . serendipity_db_escape_string($names[$i]) . "', '";
+ $query .= "'$tmpid', '" . serendipity_db_escape_string(strip_tags($names[$i])) . "', '";
$query .= serendipity_db_escape_string($locations[$i]) . "')";
serendipity_db_query($query);
|