Fixing bug 4244: length of rss title changed to TEXT in db and truncated to 64+ ... in block content. Also fixed BAD BUG where the function name for rss_client block upgrade was misnamed - this would have meant that db no upgrades ran for this block

This commit is contained in:
mjollnir_
2005-11-13 22:50:45 +00:00
parent 860cea3526
commit 79598cf025
5 changed files with 30 additions and 9 deletions
+13 -3
View File
@@ -23,7 +23,7 @@ define('BLOCK_RSS_SECONDARY_CACHE_ENABLED', true);
function init() {
$this->title = get_string('feedstitle', 'block_rss_client');
$this->version = 2004112000;
$this->version = 2005111400;
}
function preferred_width() {
@@ -194,9 +194,9 @@ define('BLOCK_RSS_SECONDARY_CACHE_ENABLED', true);
}
if (empty($rss_record->preferredtitle)) {
$feedtitle = stripslashes_safe(rss_unhtmlentities($rss->channel['title']));
$feedtitle = $this->format_title(stripslashes_safe(rss_unhtmlentities($rss->channel['title'])));
} else {
$feedtitle = stripslashes_safe($rss_record->preferredtitle);
$feedtitle = $this->format_title(stripslashes_safe($rss_record->preferredtitle));
}
// print_object($rss);
if (isset($this->config) &&
@@ -269,5 +269,15 @@ define('BLOCK_RSS_SECONDARY_CACHE_ENABLED', true);
$this->instance_config_save($this->config);
return $returnstring;
}
// just strips the title down and adds ... for excessively long titles.
function format_title($title,$max=64) {
if (strlen($title) <= $max) {
return $title;
}
else {
return substr($title,0,$max-3).'...';
}
}
}
?>
+7 -1
View File
@@ -1,6 +1,6 @@
<?php //$Id$
function block_rss_client_upgrade($oldversion) {
function rss_client_upgrade($oldversion) {
/// This function does anything necessary to upgrade
/// older versions to match current functionality
@@ -10,6 +10,12 @@ function block_rss_client_upgrade($oldversion) {
# Do something ...
}
if ($oldversion < 2005111400) {
// title and description should be TEXT as we don't have control over their length.
table_column('block_rss_client','title','title','text');
table_column('block_rss_client','description','description','text');
}
return true;
}
+2 -2
View File
@@ -14,9 +14,9 @@
CREATE TABLE prefix_block_rss_client (
`id` int(11) NOT NULL auto_increment,
`userid` int(11) NOT NULL default '0',
`title` varchar(64) NOT NULL default '',
`title` text NOT NULL default '',
`preferredtitle` varchar(64) NOT NULL default '',
`description` varchar(128) NOT NULL default '',
`description` text NOT NULL default '',
`url` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM COMMENT='Remote news feed information. Contains the news feed id, the userid of the user who added the feed, the title of the feed itself and a description of the feed contents along with the url used to access the remote feed. Preferredtitle is a field for future use - intended to allow for custom titles rather than those found in the feed.';
+6 -1
View File
@@ -1,11 +1,16 @@
<?php //$Id$
function block_rss_client_upgrade($oldversion) {
function rss_client_upgrade($oldversion) {
/// This function does anything necessary to upgrade
/// older versions to match current functionality
global $CFG;
if ($oldversion < 2005111400) {
// title and description should be TEXT as we don't have control over their length.
table_column('block_rss_client','title','title','text');
table_column('block_rss_client','description','description','text');
}
return true;
}
+2 -2
View File
@@ -12,8 +12,8 @@
CREATE TABLE prefix_block_rss_client (
id SERIAL PRIMARY KEY,
userid INTEGER NOT NULL default '0',
title varchar(64) NOT NULL default '',
title text NOT NULL default '',
preferredtitle varchar(64) NOT NULL default '',
description varchar(128) NOT NULL default '',
description text NOT NULL default '',
url varchar(255) NOT NULL default ''
);