/[drupal]/contributions/modules/bookmark_us/bookmark_us.module
ViewVC logotype

Contents of /contributions/modules/bookmark_us/bookmark_us.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download) (as text)
Thu Nov 16 09:27:46 2006 UTC (3 years ago) by Gurpartap
Branch: MAIN
CVS Tags: DRUPAL-5--1-0, HEAD
Branch point for: DRUPAL-5
Changes since 1.4: +20 -16 lines
File MIME type: text/x-php
Ported for Drupal. 5.x
1 <?php
2 // $Id:
3 function bookmark_us_help($section) {
4 switch ($section) {
5 case 'admin/modules#description':
6 return t("Defines a configurable block allowing users to add site and pages as bookmarks to their browser.");
7 }
8 }
9
10 function bookmark_us_menu($may_cache) {
11 $items = array();
12
13 if ($may_cache) {
14
15 $items[] = array(
16 'path' => 'admin/settings/bookmark_us',
17 'title' => t('Bookmark Us'),
18 'description' => t('Bookmark Us configuration.'),
19 'callback' => 'drupal_get_form',
20 'callback arguments' => 'bookmark_us_settings',
21 'type' => MENU_LOCAL_TASK,);
22 }
23 return $items;
24 }
25
26 function bookmark_us_block($op = 'list', $delta = 0, $edit = array()) {
27 if ($op == 'list') {
28 $blocks[0] = array('info' => t('Bookmark Us'),
29 'weight' => 0, 'enabled' => 1, 'region' => 'left');
30 return $blocks;
31 }
32 else if ($op == 'view') {
33 switch($delta) {
34 case 0:
35 $block = array('subject' => t('Bookmark Us')), 'content' => bookmark_us_block_code());
36 break;
37 }
38 return $block;
39 }
40 }
41
42 function bookmark_us_settings() {
43 $form = array();
44
45 $form['bookmark_us_config'] = array(
46 '#type' => 'fieldset',
47 '#title' => 'Bookmark Us Block Settings',
48 );
49 $form['bookmark_us_config']['bookmark_us_site'] = array(
50 '#type' => 'textfield',
51 '#title' => t('Label for site bookmark link'),
52 '#size' => 20,
53 '#maxlength' => 255,
54 '#default_value' => variable_get('bookmark_us_site', t('Bookmark Website')),
55 );
56 $form['bookmark_us_config']['bookmark_us_page'] = array(
57 '#type' => 'textfield',
58 '#title' => t('Label for current page bookmark link'),
59 '#size' => 20,
60 '#maxlength' => 255,
61 '#default_value' => variable_get('bookmark_us_page', t('Bookmark Page'))
62 );
63 $form['bookmark_us_config']['bookmark_us_icons'] = array(
64 '#type' => 'checkbox',
65 '#title' => t('Enable icons'),
66 '#default_value' => variable_get('bookmark_us_icons', 1),
67 );
68
69 return system_settings_form($form);
70 }
71
72 function bookmark_us_block_code() {
73 $path = base_path() . drupal_get_path('module', 'bookmark_us');
74 global $base_url;
75 $bmarkus_stitle = variable_get('bookmark_us_site', t('Bookmark Website'));
76 $bmarkus_ptitle = variable_get('bookmark_us_page', t('Bookmark Page'));
77 $bmarkus_icons = variable_get('bookmark_us_icons', 1);
78 $sitename = variable_get('site_name', t('drupal'));
79 $slogan = variable_get('site_slogan', '');
80 $pagetitle = strip_tags(drupal_get_title());
81 $head_title = $pagetitle ? $pagetitle . ' | ' . $sitename : $sitename;
82
83 $output = '';
84 drupal_add_js($path . '/bookmark_us.js');
85 if($bmarkus_icons) $output .= '<img src="' . $path . '/bookmark_site.gif" alt="' . $bmarkus_stitle . '" align="absmiddle" />';
86 $output .= '&nbsp;';
87 $output .= '<script type="text/javascript"> displayLink("1","' . $base_url . '","' . $sitename . '","' . $bmarkus_stitle . '"); </script>';
88 $output .= '<br />';
89 if($bmarkus_icons) $output .= '<img src="' . $path . '/bookmark_page.gif" alt="' . $bmarkus_ptitle . '" align="absmiddle" />';
90 $output .= '&nbsp;';
91 $output .= '<script type="text/javascript"> displayLink("3","","' . $head_title . '","' . $bmarkus_ptitle . '"); </script>';
92
93 return $output;
94 }

  ViewVC Help
Powered by ViewVC 1.1.2