\n";
//
// sidebar_panel(): updated by AAM on 27.11.2004
// Support for drupal search box and customizable colors
//
function sidebar_panel() {
global $base_url;
$site_name = variable_get("site_name", "drupal");
$result = db_query_range("SELECT nid, type FROM {node} WHERE promote = '1' AND status = '1' ORDER BY created DESC", 0, variable_get("sidebar_items", "5"));
$output = "\n";
$output .= "\n
\n";
$output .= drupal_get_html_head();
$output .= "\n";
$output .= "\n";
$output .= "".$site_name."\n";
$output .= "\n";
$output .= "\n\n";
$output .= "The latest from ".$site_name."
\n";
$output .= "". t("Last updated: %date", array("%date" => date("F j, Y, g:i a T")));
$output .= " (". t("refresh") .")
\n\n";
if (variable_get("sidebar_searchbox", "1") == "1") {
$output .= "
\n";
}
while ($node = db_fetch_object($result)) {
$item = node_load(array("nid" => $node->nid, "type" => $node->type));
$output .= "". l($item->title, "node/$item->nid", array("title" => t("Read this article."), "target" => t("_content"))) ."\n";
$all = comment_num_all($item->nid);
$new = comment_num_new($item->nid);
$output .= "
(". l(format_plural($all, "1 comment", "%count comments") . ($new ? ", $new ". t("new") : ""), "node/$item->nid#comment", array("title" => t("View this posting and all of its comments."), "target" => t("_content"))) .")";
$output .= "\n";
if (variable_get("sidebar_teasers", "1") == "1") {
$output .= "" . check_output($item->teaser) . "\n";
}
}
$output .= "\n\n\n";
$output .= "\n\n\n";
print $output;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// sidebar_menu()
// New as described in "converting 4.4 modules to 4.5" tutorial: updated by AAM on 31.10.2004
// Added admin/settings/sidebar as dscribed in "converting 4.7 modules to 5.0" tutorial: updated by AAM on 05.02.2007
//
function sidebar_menu($may_cache) {
global $user;
$items = array();
if ($may_cache) {
$items[] = array('path' => 'sidebar', 'title' => t('Sidebar'),
'callback' => 'sidebar_page',
'access' => user_access('access content'),
'type' => MENU_SUGGESTED_ITEM);
$items[] = array(
'path' => 'admin/settings/sidebar',
'title' => t('Sidebar'),
'description' => t('Administer sidebar settings.'),
'callback' => 'drupal_get_form',
'callback arguments' => array('sidebar_admin_settings'),
'access' => user_access('administer site configuration'),
'type' => MENU_NORMAL_ITEM, // optional
);
}
return $items;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// function sidebar_link()
// function not needed anymore: updated by AAM on 31.10.2004
//
//function sidebar_link($type) {
// New as described in "converting 4.3 modules to 4.4" tutorial
// New as described in "converting 4.4 modules to 4.5" tutorial
// if ($type == "system") {
// $links[] = menu("sidebar", t("sidebar"), "sidebar_page", 0, MENU_HIDE);
// }
// if ($type == "page"
// && (eregi("Mozilla/5.0 \(", $_SERVER['HTTP_USER_AGENT'])
// || eregi("Opera", $_SERVER['HTTP_USER_AGENT']))) {
// $links[] = l(t("mozilla sidebar"), "sidebar");
// $links[] = menu("sidebar", t("sidebar"), "sidebar");
// }
// if ($type == "admin" && user_access("administer sidebar")) {
// $links[] = l(t("mozilla sidebar"), "admin/sidebar");
// $links[] = menu("sidebar", t("sidebar"), "admin/sidebar");
// $links[] = menu("sidebar", t("sidebar_help"), "admin/sidebar/help");
// }
// return $links ? $links : array();
//}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// sidebar_admin_settings():
// New name for this function and return system_settings_form($form): updated by AAM on 05.02.2007
// Support for search box and customizable colors: updated by AAM on 31.10.2004
//
function sidebar_admin_settings() {
if ( !user_access("administer sidebar") ) {
return message_access();
}
// $form = form_textfield("Items in sidebar", "sidebar_items", variable_get("sidebar_items","10"), 2, 2, "How many items to display in the sidebar.");
$form['sidebar_items'] = array(
'#type' => 'textfield',
'#title' => t('Items in Sidebar'),
'#default_value' => variable_get('sidebar_items', 10 ),
'#description' => t('How many items to display in the sidebar'),
'#maxlength' => '2',
'#size' => '2'
);
// $form .= form_select("Display teasers in sidebar", "sidebar_teasers", variable_get("sidebar_teasers", 0), array("Disabled", "Enabled"), "Display teasers in the sidebar panel?");
$form['sidebar_teasers'] = array(
'#type' => 'select',
'#title' => t('Display teasers in sidebar'),
'#default_value' => variable_get('sidebar_teasers', '0'),
'#description' => t('Whether to display teasers in the sidebar panel or not'),
'#options' => array('0' => 'Disabled', '1' => 'Enabled')
);
// $form .= form_select("Display searchbox in sidebar", "sidebar_searchbox", variable_get("sidebar_searchbox", 1), array("Disabled", "Enabled"), "Display searchbox in the sidebar panel?");
$form['sidebar_searchbox'] = array(
'#type' => 'select',
'#title' => t('Display serchbox in sidebar'),
'#default_value' => variable_get('sidebar_searchbox', '1'),
'#desciption' => t('Whether to display searchbox in the sidebar panel or not'),
'#options' => array('0' => 'Disabled', '1' => 'Enabled')
);
// $form .= form_textfield("Background color", "sidebar_bgcolor", variable_get("sidebar_bgcolor","#ffffff"), 7, 7, "Which background color should have the sidebar?");
$form['sidebar_bgcolor'] = array(
'#type' => 'textfield',
'#title' => t('Background color'),
'#default_value' => variable_get('sidebar_bgcolor', '#FFFFFF'),
'#desciption' => t('Which background color should have the sidebar panel'),
'#maxlendth' => '7',
'#size' => '7'
);
// $form .= form_textfield("Foreground color", "sidebar_color", variable_get("sidebar_color","#000000"), 7, 7, "Which foreground color should have the sidebar?");
$form['sidebar_color'] = array(
'#type' => 'textfield',
'#title' => t('Foreground color'),
'#default_value' => variable_get('sidebar_color', '#000000'),
'#desciption' => t('Which foreground color should have the sidebar panel'),
'#maxlendth' => '7',
'#size' => '7'
);
// $form .= form_textfield("Link color", "sidebar_lnkcolor", variable_get("sidebar_lnkcolor","#003388"), 7, 7, "Which color should have the links in the sidebar?");
$form['sidebar_linkcolor'] = array(
'#type' => 'textfield',
'#title' => t('Link color'),
'#default_value' => variable_get('sidebar_linkcolor', '#003388'),
'#desciption' => t('Which color should have the links on the sidebar panel'),
'#maxlendth' => '7',
'#size' => '7'
);
// $form .= form_textfield("Visited link color", "sidebar_vlnkcolor", variable_get("sidebar_vlnkcolor","#226699"), 7, 7, "Which color should have visited links in the sidebar?");
$form['sidebar_vlinkcolor'] = array(
'#type' => 'textfield',
'#title' => t('Visited link color'),
'#default_value' => variable_get('sidebar_vlinkcolor', '#226699'),
'#desciption' => t('Which color should have already visited links on the sidebar panel'),
'#maxlendth' => '7',
'#size' => '7'
);
// $form .= form_textfield("Active link color", "sidebar_alnkcolor", variable_get("sidebar_alnkcolor","#000000"), 7, 7, "Which color should have the active link in the sidebar?");
$form['sidebar_alinkcolor'] = array(
'#type' => 'textfield',
'#title' => t('Active link color'),
'#default_value' => variable_get('sidebar_alinkcolor', '#000000'),
'#desciption' => t('Which color should have active links on the sidebar panel'),
'#maxlendth' => '7',
'#size' => '7'
);
// $form .= "To test the sidebar panel right now, klick here
";
// $form .= "To add the sidebar panel right now, klick here
";
return system_settings_form($form);
}
function sidebar_save($edit = array()) {
foreach ($edit as $name=>$value) variable_set($name, $value);
$output = t("The sidebar options have been saved.") ."
";
return $output;
}
function sidebar_admin() {
global $edit, $op;
if (user_access("administer sidebar")) {
switch ($op) {
case "help":
print sidebar_help();
break;
case "Submit":
print sidebar_save($edit);
default:
print sidebar_settings();
}
}
else {
print message_access();
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// sidebar_addit(): updated by AAM on 01.12.2004
// All browser switches are removed from code due to cache issues/problems
//
// if ( eregi("Mozilla/5.0", $_SERVER['HTTP_USER_AGENT']) ) { ...
//
function sidebar_addit() {
global $theme, $base_url;
$site_name = variable_get("site_name", "drupal");
$output = "Sidebar for Mozilla Firefox, SeaMonkey, Netscape, Opera and Internet Explorer
";
$output .= "". t("The %site sidebar panel allows you to easily search and check the newest content posted to %site right from the sidebar in your favourite browser.", array("%site" => $site_name)) ."
";
$output .= "\n";
print theme("page", $output, t("Sidebar Panel"));
}
function sidebar_page() {
global $op;
switch (arg(1)) {
case "panel":
sidebar_panel();
break;
default:
sidebar_addit();
}
}
?>