Commit c041fc4c authored by mfer's avatar mfer

update to 2.x version of bloginfo module. adds input filters and moves...

update to 2.x version of bloginfo module.  adds input filters and moves theming of block content to theme_bloginfo_block
parent 600a49f9
; $Id$
name = Bloginfo
description = Blog title and description.
dependencies = blog
version = "5.x-0.x-dev"
\ No newline at end of file
dependencies = blog
\ No newline at end of file
......@@ -39,4 +39,17 @@ function bloginfo_uninstall() {
db_query('DROP TABLE {bloginfo}');
}
function bloginfo_update_1(){
$items = array();
switch ($GLOBALS['db_type']) {
case 'pgsql':
db_add_column($items, 'bloginfo', 'format', 'int', array('not null' => TRUE, 'default' => 0));
break;
case 'mysql':
case 'mysqli':
$items[] = update_sql("ALTER TABLE {bloginfo} ADD COLUMN format int NOT NULL default '0'");
break;
}
return $items;
}
?>
\ No newline at end of file
......@@ -45,27 +45,34 @@ function bloginfo_block($op = 'list', $delta = 0) {
if (((arg(0) == 'blog' && is_numeric(arg(1))) || $node->type == 'blog')) {
if (arg(0) == 'blog') $authorid = arg(1);
else if ($node->type == 'blog') $authorid = $node->uid;
$results = db_query("SELECT title, description FROM {bloginfo} WHERE uid = %d", $authorid);
$results = db_query("SELECT title, description, format FROM {bloginfo} WHERE uid = %d", $authorid);
if (mysql_num_rows($results) == 1){
$bloginfo = db_fetch_object($results);
$block['subject'] = check_plain($bloginfo->title);
$block['content'] = check_plain($bloginfo->description);
$block['content'] = theme_bloginfo_block($bloginfo->description, $bloginfo->format);
return $block;
}
}
}
}
/**
* Theme Function: Theme bloginfo block content
*/
function theme_bloginfo_block($description, $format) {
return check_markup($description, $format, FALSE);
}
/**
* Helper function: create the form on the user settings page
*/
function bloginfo_form_bloginfo($edit, $account, $category) {
if ($category == 'account' && is_numeric(arg(1)) && (user_access('edit own bloginfo') || user_access('administer bloginfo'))) {
$result = db_query('SELECT title, description FROM {bloginfo} WHERE uid = %d', arg(1));
$result = db_query('SELECT title, description, format FROM {bloginfo} WHERE uid = %d', arg(1));
while ($bloginfo = db_fetch_object($result)) {
$mybloginfo['title'] = $bloginfo->title;
$mybloginfo['description'] = $bloginfo->description;
$mybloginfo['title'] = $bloginfo->title;
$mybloginfo['description'] = $bloginfo->description;
$mybloginfo['format'] = $bloginfo->format;
}
$fields['bloginfo_settings'] = array(
'#type' => 'fieldset',
......@@ -81,7 +88,8 @@ function bloginfo_form_bloginfo($edit, $account, $category) {
'#type' => 'textarea',
'#title' => t('Blog Description'),
'#default_value' => $mybloginfo['description'],
'#description' => t('Your blog description will display on your blog and blog posts.'));
'#description' => t('Your blog description will display on your blog and blog posts.'));
$fields['bloginfo_settings']['desc_format'] = filter_form($mybloginfo['format']);
return $fields;
}//end if
}//end function bloginfo_form_bloginfo()
......@@ -95,12 +103,12 @@ function bloginfo_save_bloginfo(&$edit, &$user, $category) {
//This is to update where info already exists in the database
if (db_num_rows($results) == 1){
db_query("Update {bloginfo} SET title = \"%s\", description = \"%s\" WHERE uid = %d", $edit['Title'], $edit['Description'], arg(1));
db_query("Update {bloginfo} SET title = \"%s\", description = \"%s\", format = %d WHERE uid = %d", $edit['Title'], $edit['Description'], $edit['format'], arg(1));
}
//This adds it to the database for the first time
else {
db_query("INSERT INTO {bloginfo} (uid, title, description) VALUES (%d, \"%s\", \"%s\")", arg(1), $edit['Title'], $edit['Description']);
db_query("INSERT INTO {bloginfo} (uid, title, description, format) VALUES (%d, \"%s\", \"%s\", %d)", arg(1), $edit['Title'], $edit['Description'], $edit['format']);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment