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

Contents of /contributions/modules/links/links.module

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


Revision 1.21 - (show annotations) (download) (as text)
Mon Jul 7 02:28:55 2008 UTC (16 months, 2 weeks ago) by syscrusher
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-BETA13, DRUPAL-6--1-0-BETA12, DRUPAL-6--1-0-BETA11, DRUPAL-6--1-0-BETA10, DRUPAL-6--1-0-BETA9, DRUPAL-6--1-0-BETA8, DRUPAL-6--1-0-BETA3, DRUPAL-6--1-0-BETA2, DRUPAL-6--1-0-BETA1, DRUPAL-6--1-0-BETA7, DRUPAL-6--1-0-BETA6, DRUPAL-6--1-0-BETA5, HEAD
Branch point for: DRUPAL-6--1
Changes since 1.20: +2 -3 lines
File MIME type: text/x-php
Significant further progress toward Drupal 6.2 compatibility for Links.
links.module and links_related.module are almost done. Still not production
code due to a cosmetic issue with the related links editing form.
1 <?php
2 /** @file
3 * $Id: links.module,v 1.20 2008/01/01 00:10:41 syscrusher Exp $
4 *
5 * links.module provides an application program interface (API) for managing
6 * internal and external links as part of a Drupal node. The module by itself
7 * does very little; mainly, it provides a user interface for controlling the
8 * way in which links are handled and how they behave within all nodes -- in
9 * other words, the global settings for the API library.
10 *
11 * Author: Scott Courtney (drupal.org user "syscrusher")
12 */
13
14 module_load_include('inc','links','links');
15 if (module_exists('views')) {
16 module_load_include('inc','links','links_views');
17 }
18
19 /**
20 * Returns an array of the permission names that apply to this module
21 */
22 function links_perm() {
23 return array('access links statistics');
24 }
25
26 /**
27 * Manages the global settings for the module
28 */
29 function links_settings_form() {
30 $form = array();
31
32 $form['description'] = array(
33 '#type' => 'markup',
34 '#value' => '<p>' . t('These settings control the behavior of the link-management services and provide defaults for modules which use those services. Some modules may offer module-specific settings that override these for that module only.'),
35 );
36
37 $form['display_settings'] = array(
38 '#type' => 'fieldset',
39 '#title' => t('Display settings'),
40 );
41
42 $form['display_settings']['links_link_display'] = array(
43 '#type' => 'radios',
44 '#title' => t("Visit link display mode"),
45 // CAUTION: The specific value constants (the integers) are significant here.
46 '#options' => array(0=>t("display as title"), 1=>t("display as url"), 2=>t("only display the 'visit linked page' text")),
47 '#default_value' => variable_get("links_link_display", 0),
48 '#description' => t("Users are able to visit links via the node links list. This setting toggles how the visit link is displayed, either containing the node title or the node target URL or just the words 'visit linked page'"),
49 );
50
51 $form['link_targets'] = array(
52 '#type' => 'fieldset',
53 '#title' => t('Link targets'),
54 '#tree' => 0,
55 '#description' => t('These settings allow you to apply the attribute <code>target="_blank"</code> to cause links to open in a new browser window or tab. Using this setting will cause your pages not to validate under the XHTML standard, but will work with most browsers. There is some debate over whether using the <code>target</code> attribute is good design practice; Links leaves this choice up to the system administrator.'),
56 );
57
58 $form['link_targets']['links_target'] = array(
59 '#type' => 'radios',
60 '#title' => t("Open links in new window"),
61 // CAUTION: The specific value constants (the integers) are significant here.
62 '#options' => array(0=>t("Never"), 1=>t("All links"), 2=>t("External links only")),
63 '#default_value' => variable_get("links_target", 0),
64 '#description' => t("Controls opening of new browser windows for links."),
65 );
66
67 $form['link_targets']['links_target_is_user_specific'] = array(
68 '#type' => 'radios',
69 '#title' => t("User setting for target"),
70 // CAUTION: The specific value constants (the integers) are significant here.
71 '#options' => array(0=>t("deny"), 1=>t("allow")),
72 '#default_value' => variable_get("links_target_is_user_specific", 0),
73 '#description' => t("Allow users to specify their own preference via the user settings page."),
74 );
75
76 $form['security_settings'] = array(
77 '#type' => 'fieldset',
78 '#title' => t('Security settings'),
79 );
80
81 $form['security_settings']['security_link'] = array(
82 '#type' => 'markup',
83 '#value' => t("You can set the permissions of who is allowed to view the count of how many people have followed each link in the !link.", array('!link'=>l(t('access control page'),'admin/user/access'))),
84 );
85
86 return system_settings_form($form);
87 }
88
89 function links_user($op, &$edit, &$user, $category='') {
90 $user_setting_allowed = links_prefs_is_user_specific('links_target');
91 if ($user_setting_allowed && $op == 'form' && $category == 'account') {
92 $form = array();
93 $form['links_settings'] = array(
94 '#type' => 'fieldset',
95 '#title' => t('Links behavior'),
96 '#collapsible' => true,
97 '#tree' => false,
98 );
99 $form['links_settings']['links_target'] = array(
100 '#type' => 'radios',
101 '#title' => t("Open links in new browser window"),
102 // CAUTION: The specific value constants (the integers) are significant here.
103 '#options' => array(0=>t("Never"), 1=>t("All links"), 2=>t("External links only")),
104 '#default_value' => links_prefs_get('links_target'),
105 '#description' => t("Create a new window (or tab, depending on your browser's settings) when you click on a link? This affects all URLs managed by the Links package."),
106 );
107 return $form;
108 }
109 return;
110 }
111
112 /**
113 * Implements hook_menu
114 */
115 function links_menu() {
116 $items = array();
117 $items['links/goto/%'] = array(
118 'title'=>'Outlink Redirection',
119 'page callback'=>'links_menu_goto',
120 'access callback'=>'user_access',
121 'access arguments'=>array('access content'),
122 'type' => MENU_CALLBACK
123 );
124 $items['admin/content/links'] = array(
125 'title' => 'link management',
126 'description' => 'Manage links for your site.',
127 'page callback' => 'system_admin_menu_block_page',
128 'access callback'=>'user_access',
129 'access arguments' => array('administer site configuration'),
130 'type' => MENU_NORMAL_ITEM,
131 );
132 $items['admin/settings/links'] = array(
133 'title' => 'Links package',
134 'description' => 'Configure the global display settings and default targets for links managed by the Links package.',
135 'page callback' => 'drupal_get_form',
136 'page arguments' => array('links_settings_form'),
137 'access callback'=>'user_access',
138 'access arguments' => array('administer site configuration'),
139 // 'type' => MENU_NORMAL_ITEM,
140 );
141 $items['admin/settings/links/package'] = array(
142 'title' => t('package settings'),
143 'page callback' => 'drupal_get_form',
144 'page arguments' => array('links_settings_form'),
145 'access callback'=>'user_access',
146 'access arguments' => array('administer site configuration'),
147 'type' => MENU_DEFAULT_LOCAL_TASK,
148 );
149 return $items;
150 }
151
152 // Menu callback functions
153
154 function links_menu_goto() {
155 $nid = arg(2);
156 $lid = arg(3);
157 $module = arg(4);
158 if (! links_goto_bynode($nid, $lid, $module)) {
159 drupal_set_message(t('Link data not found'),'error');
160 if ($nid) {
161 $output = l(t('Return'),'node/'.$nid);
162 } else {
163 $output = '';
164 }
165 print theme('page',$output);
166 }
167 }

  ViewVC Help
Powered by ViewVC 1.1.2