/[drupal]/drupal/modules/block.module
ViewVC logotype

Contents of /drupal/modules/block.module

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


Revision 1.162.2.6 - (hide annotations) (download) (as text)
Tue Aug 22 19:32:56 2006 UTC (3 years, 3 months ago) by dries
Branch: DRUPAL-4-6
Changes since 1.162.2.5: +2 -2 lines
File MIME type: text/x-php
- Patch #58187 by Zack: documentation improvement.
1 dries 1.8 <?php
2 dries 1.162.2.6 // $Id: block.module,v 1.162.2.5 2005/07/20 11:41:57 dries Exp $
3 dries 1.132
4     /**
5     * @file
6     * Controls the boxes that are displayed around the main content.
7     */
8 dries 1.69
9 dries 1.112 /**
10     * Implementation of hook_help().
11     */
12     function block_help($section) {
13 dries 1.69 switch ($section) {
14 dries 1.82 case 'admin/help#block':
15 dries 1.140 return t('
16 unconed 1.129 <p>Blocks are the boxes visible in the sidebar(s) of your web site. These are usually generated automatically by modules (e.g. recent forum topics), but you can also create your own blocks.</p>
17 dries 1.140 <p>The sidebar each block appears in depends on both which theme you are using (some are left-only, some right, some both), and on the settings in block management.</p>
18     <p>The block management screen lets you specify the vertical sort-order of the blocks within a sidebar. You do this by assigning a weight to each block. Lighter blocks (smaller weight) "float up" towards the top of the sidebar. Heavier ones "sink down" towards the bottom of it.</p>
19     <p>A block\'s visibility depends on:</p>
20     <ul>
21     <li>Its enabled checkbox. Disabled blocks are never shown.</li>
22     <li>Its throttle checkbox. Throttled blocks are hidden during high server loads.</li>
23 dries 1.162.2.3 <li>Its path options. Blocks can be configured to only show/hide on certain pages.</li>
24 dries 1.140 <li>User settings. You can choose to let your users decide whether to show/hide certain blocks.</li>
25     <li>Its function. Dynamic blocks (such as those defined by modules) may be empty on certain pages and will not be shown.</li>
26     </ul>
27    
28     <h3>Administrator defined blocks</h3>
29     <p>An administrator defined block contains content supplied by you (as opposed to being generated automatically by a module). Each admin-defined block consists of a title, a description, and a body which can be as long as you wish. The Drupal engine will render the content of the block.</p>');
30 dries 1.116 case 'admin/modules#description':
31 dries 1.112 return t('Controls the boxes that are displayed around the main content.');
32 dries 1.116 case 'admin/block':
33 dries 1.140 return t("
34     <p>Blocks are the boxes in the left and right side bars of the web site. They are made available by modules or created manually.</p>
35 dries 1.159 <p>Only enabled blocks are shown. You can position the blocks by deciding which side of the page they will show up on (sidebar) and in which order they appear (weight).</p>
36 dries 1.162.2.2 <p>If you want certain blocks to disable themselves temporarily during high server loads, check the 'Throttle' box. You can configure the auto-throttle on the <a href=\"%throttle\">throttle configuration page</a> after having enabled the throttle module.</p>
37 dries 1.140 ", array('%throttle' => url('admin/settings/throttle')));
38 dries 1.116 case 'admin/block/add':
39 unconed 1.160 return t('<p>Here you can create a new block. Once you have created this block you must make it active and give it a place on the page using <a href="%overview">blocks</a>. The title is used when displaying the block. The description is used in the "block" column on the <a href="%overview">blocks</a> page.</p>', array('%overview' => url('admin/block')));
40 dries 1.69 }
41 dries 1.86 }
42    
43 dries 1.112 /**
44     * Implementation of hook_perm().
45     */
46 dries 1.13 function block_perm() {
47 dries 1.112 return array('administer blocks');
48 dries 1.15 }
49    
50 dries 1.111 /**
51 dries 1.116 * Implementation of hook_menu().
52 dries 1.111 */
53 dries 1.135 function block_menu($may_cache) {
54 dries 1.116 $items = array();
55 dries 1.135
56     if ($may_cache) {
57     $items[] = array('path' => 'admin/block', 'title' => t('blocks'),
58     'access' => user_access('administer blocks'),
59     'callback' => 'block_admin');
60     $items[] = array('path' => 'admin/block/list', 'title' => t('list'),
61     'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
62 dries 1.140 $items[] = array('path' => 'admin/block/configure', 'title' => t('configure block'),
63     'access' => user_access('administer blocks'),
64     'callback' => 'block_admin_configure',
65     'type' => MENU_CALLBACK);
66     $items[] = array('path' => 'admin/block/delete', 'title' => t('delete block'),
67 dries 1.135 'access' => user_access('administer blocks'),
68 dries 1.140 'callback' => 'block_box_delete',
69 dries 1.135 'type' => MENU_CALLBACK);
70 dries 1.143 $items[] = array('path' => 'admin/block/add', 'title' => t('add block'),
71 dries 1.135 'access' => user_access('administer blocks'),
72 dries 1.140 'callback' => 'block_box_add',
73 dries 1.135 'type' => MENU_LOCAL_TASK);
74     }
75    
76 dries 1.116 return $items;
77 dries 1.13 }
78    
79 dries 1.112 /**
80     * Implementation of hook_block().
81     *
82     * Generates the administrator-defined blocks for display.
83     */
84 dries 1.140 function block_block($op = 'list', $delta = 0, $edit = array()) {
85     switch ($op) {
86     case 'list':
87     $result = db_query('SELECT bid, title, info FROM {boxes} ORDER BY title');
88     while ($block = db_fetch_object($result)) {
89 unconed 1.161 $blocks[$block->bid]['info'] = $block->info ? check_plain($block->info) : check_plain($block->title);
90 dries 1.140 }
91     return $blocks;
92    
93     case 'configure':
94     $box = block_box_get($delta);
95     if (filter_access($box['format'])) {
96     return block_box_form($box);
97     }
98     break;
99    
100     case 'save':
101     block_box_save($edit, $delta);
102     break;
103    
104     case 'view':
105     $block = db_fetch_object(db_query('SELECT * FROM {boxes} WHERE bid = %d', $delta));
106 unconed 1.161 $data['subject'] = check_plain($block->title);
107 dries 1.140 $data['content'] = check_output($block->body, $block->format);
108     return $data;
109 kjartan 1.25 }
110     }
111    
112 dries 1.1 function block_admin_save($edit) {
113 dries 1.38 foreach ($edit as $module => $blocks) {
114     foreach ($blocks as $delta => $block) {
115 dries 1.140 db_query("UPDATE {blocks} SET region = %d, status = %d, weight = %d, throttle = %d WHERE module = '%s' AND delta = '%s'",
116     $block['region'], $block['status'], $block['weight'], $block['throttle'], $module, $delta);
117 dries 1.38 }
118 dries 1.1 }
119 dries 1.42
120 dries 1.140 return t('The block settings have been updated.');
121 dries 1.1 }
122    
123 dries 1.39 /**
124 dries 1.112 * Update the 'blocks' DB table with the blocks currently exported by modules.
125 dries 1.40 *
126 dries 1.95 * @param $order_by php <a
127     * href="http://www.php.net/manual/en/function.array-multisort.php">array_multisort()</a>
128     * style sort ordering, eg. "weight", SORT_ASC, SORT_STRING.
129 dries 1.87 *
130 dries 1.112 * @return
131     * Blocks currently exported by modules, sorted by $order_by.
132 dries 1.39 */
133 dries 1.112 function _block_rehash($order_by = array('weight')) {
134     $result = db_query('SELECT * FROM {blocks} ');
135 dries 1.38 while ($old_block = db_fetch_object($result)) {
136     $old_blocks[$old_block->module][$old_block->delta] = $old_block;
137     }
138    
139 dries 1.112 db_query('DELETE FROM {blocks} ');
140 dries 1.38
141     foreach (module_list() as $module) {
142 dries 1.112 $module_blocks = module_invoke($module, 'block', 'list');
143 dries 1.38 if ($module_blocks) {
144     foreach ($module_blocks as $delta => $block) {
145 dries 1.112 $block['module'] = $module;
146     $block['delta'] = $delta;
147 dries 1.38 if ($old_blocks[$module][$delta]) {
148 dries 1.112 $block['status'] = $old_blocks[$module][$delta]->status;
149     $block['weight'] = $old_blocks[$module][$delta]->weight;
150     $block['region'] = $old_blocks[$module][$delta]->region;
151 dries 1.140 $block['visibility'] = $old_blocks[$module][$delta]->visibility;
152     $block['pages'] = $old_blocks[$module][$delta]->pages;
153 dries 1.112 $block['custom'] = $old_blocks[$module][$delta]->custom;
154     $block['throttle'] = $old_blocks[$module][$delta]->throttle;
155 dries 1.149 $block['types'] = $old_blocks[$module][$delta]->types;
156 dries 1.38 }
157     else {
158 dries 1.112 $block['status'] = $block['weight'] = $block['region'] = $block['custom'] = 0;
159 dries 1.149 $block['pages'] = $block['types'] = '';
160 dries 1.38 }
161    
162     // reinsert blocks into table
163 dries 1.149 db_query("INSERT INTO {blocks} (module, delta, status, weight, region, visibility, pages, custom, throttle, types) VALUES ('%s', '%s', %d, %d, %d, %d, '%s', %d, %d, '%s')",
164     $block['module'], $block['delta'], $block['status'], $block['weight'], $block['region'], $block['visibility'], $block['pages'], $block['custom'], $block['throttle'], $block['types']);
165 dries 1.38
166     $blocks[] = $block;
167 dries 1.40
168 dries 1.39 // build array to sort on
169     $order[$order_by[0]][] = $block[$order_by[0]];
170 dries 1.38 }
171     }
172     }
173    
174 dries 1.39 // sort
175     array_multisort($order[$order_by[0]], $order_by[1] ? $order_by[1] : SORT_ASC, $order_by[2] ? $order_by[2] : SORT_REGULAR, $blocks);
176    
177 dries 1.38 return $blocks;
178     }
179 dries 1.5
180 dries 1.112 /**
181     * Prepare the main block administration form.
182     */
183 dries 1.38 function block_admin_display() {
184 dries 1.39 $blocks = _block_rehash();
185 dries 1.4
186 dries 1.159 $header = array(t('Block'), t('Enabled'), t('Weight'), t('Sidebar'));
187 dries 1.144 if (module_exist('throttle')) {
188     $header[] = t('Throttle');
189     }
190     $header[] = array('data' => t('Operations'), 'colspan' => 2);
191    
192 dries 1.157 $left = array();
193     $right = array();
194     $disabled = array();
195 dries 1.38 foreach ($blocks as $block) {
196 dries 1.140 if ($block['module'] == 'block') {
197 unconed 1.153 $delete = l(t('delete'), 'admin/block/delete/'. $block['delta']);
198 dries 1.48 }
199     else {
200 unconed 1.153 $delete = '';
201 kjartan 1.25 }
202 dries 1.46
203 dries 1.157 $row = array(array('data' => $block['info'], 'class' => 'block'),
204 unconed 1.154 form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][status', 1, $block['status']),
205     form_weight(NULL, $block['module'] .']['. $block['delta'] .'][weight', $block['weight']),
206     form_radios(NULL, $block['module'] .']['. $block['delta'] .'][region', $block['region'],
207     array(t('left'), t('right'))));
208 dries 1.144
209     if (module_exist('throttle')) {
210 unconed 1.154 $row[] = form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][throttle', 1, $block['throttle']);
211 dries 1.144 }
212 unconed 1.153 $row[] = l(t('configure'), 'admin/block/configure/'. $block['module'] .'/'. $block['delta']);
213     $row[] = $delete;
214 dries 1.157 if ($block['status']) {
215     if ($block['region'] == 0) {
216     $left[] = $row;
217     }
218 dries 1.162 if ($block['region'] == 1) {
219 dries 1.157 $right[] = $row;
220     }
221     }
222 dries 1.162 else if ($block['region'] <= 1) {
223 dries 1.157 $disabled[] = $row;
224     }
225 dries 1.1 }
226 dries 1.5
227 dries 1.157 $rows = array();
228     if (count($left)) {
229     $rows[] = array(array('data' => t('Left sidebar'), 'class' => 'region', 'colspan' => (module_exist('throttle') ? 7 : 6)));
230     $rows = array_merge($rows, $left);
231     }
232     if (count($right)) {
233 dries 1.158 $rows[] = array(array('data' => t('Right sidebar'), 'class' => 'region', 'colspan' => (module_exist('throttle') ? 7 : 6)));
234 dries 1.157 $rows = array_merge($rows, $right);
235     }
236     if (count($disabled)) {
237     $rows[] = array(array('data' => t('Disabled'), 'class' => 'region', 'colspan' => (module_exist('throttle') ? 7 : 6)));
238     $rows = array_merge($rows, $disabled);
239     }
240     $output = theme('table', $header, $rows, array('id' => 'blocks'));
241 dries 1.112 $output .= form_submit(t('Save blocks'));
242 dries 1.1
243 dries 1.116 return form($output, 'post', url('admin/block'));
244 dries 1.1 }
245    
246 kjartan 1.25 function block_box_get($bid) {
247 dries 1.112 return db_fetch_array(db_query('SELECT * FROM {boxes} WHERE bid = %d', $bid));
248     }
249    
250     /**
251 dries 1.140 * Menu callback; displays the block configuration form.
252 dries 1.112 */
253 dries 1.140 function block_admin_configure($module = NULL, $delta = 0) {
254 dries 1.112 $edit = $_POST['edit'];
255     $op = $_POST['op'];
256    
257 unconed 1.138 switch ($op) {
258     case t('Save block'):
259 dries 1.149 if ($edit['types']) {
260     $types = implode(',', $edit['types']);
261     }
262     else {
263     $types = '';
264     }
265     db_query("UPDATE {blocks} SET visibility = %d, pages = '%s', custom = %d, types = '%s' WHERE module = '%s' AND delta = '%s'", $edit['visibility'], $edit['pages'], $edit['custom'], $types, $module, $delta);
266 dries 1.140 module_invoke($module, 'block', 'save', $delta, $edit);
267 dries 1.162.2.1 drupal_set_message(t('The block configuration has been saved.'));
268 unconed 1.138 cache_clear_all();
269     drupal_goto('admin/block');
270    
271 dries 1.140 default:
272     // Always evaluates to TRUE, but a validation step may be added later.
273     if (!$edit) {
274 dries 1.149 $edit = db_fetch_array(db_query("SELECT pages, visibility, custom, types FROM {blocks} WHERE module = '%s' AND delta = '%s'", $module, $delta));
275 dries 1.140 }
276    
277     // Module-specific block configurations.
278     if ($settings = module_invoke($module, 'block', 'configure', $delta)) {
279     $form = form_group(t('Block-specific settings'), $settings);
280     }
281    
282 dries 1.149 foreach (node_list() as $type) {
283     $content_types[$type] = node_invoke($type, 'node_name');
284     }
285 dries 1.140 // Get the block subject for the page title.
286     $info = module_invoke($module, 'block', 'list');
287     drupal_set_title(t("'%name' block", array('%name' => $info[$delta]['info'])));
288    
289     // Standard block configurations.
290 dries 1.149 $group_1 = form_radios(t('Custom visibility settings'), 'custom', $edit['custom'], array(t('Users cannot control whether or not they see this block.'), t('Show this block by default, but let individual users hide it.'), t('Hide this block by default but let individual users show it.')), t('Allow individual users to customize the visibility of this block in their account settings.'));
291     $group_2 = form_radios(t('Show block on specific pages'), 'visibility', $edit['visibility'], array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')));
292 unconed 1.151 $group_2 .= form_textarea(t('Pages'), 'pages', $edit['pages'], 40, 5, t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are '<em>blog</em>' for the blog page and '<em>blog/*</em>' for every personal blog. '<em>&lt;front&gt;</em>' is the front page."));
293     $group_3 = form_checkboxes(t('Restrict block to specific content types'), 'types', explode(',', $edit['types']), $content_types, t('Selecting one or more content types will cause this block to only be shown on pages of the selected types. This feature works alone or in conjunction with page specific visibility settings. For example, you can specify that a block only appear on book pages in the \'FAQ\' path.'), NULL, FALSE);
294 dries 1.149
295 dries 1.152 $form .= form_group(t('User specific visibility settings'), $group_1);
296 dries 1.149 $form .= form_group(t('Page specific visibility settings'), $group_2);
297     $form .= form_group(t('Content specific visibility settings'), $group_3);
298 dries 1.140
299    
300     $form .= form_submit(t('Save block'));
301    
302     print theme('page', form($form));
303     }
304     }
305    
306     /**
307     * Menu callback; displays the block creation form.
308     */
309     function block_box_add() {
310     $edit = $_POST['edit'];
311     $op = $_POST['op'];
312    
313     switch ($op) {
314     case t('Save block'):
315     block_box_save($edit);
316     drupal_set_message(t('The new block has been added.'));
317     drupal_goto('admin/block');
318    
319     default:
320     $form = block_box_form();
321     $form .= form_submit(t('Save block'));
322     $output .= form($form);
323     }
324    
325     print theme('page', $output);
326     }
327    
328     /**
329     * Menu callback; confirm and delete custom blocks.
330     */
331     function block_box_delete($bid = 0) {
332     $op = $_POST['op'];
333     $box = block_box_get($bid);
334 unconed 1.156 $info = $box['info'] ? $box['info'] : $box['title'];
335 unconed 1.138
336 unconed 1.156 if ($_POST['edit']['confirm']) {
337     db_query('DELETE FROM {boxes} WHERE bid = %d', $bid);
338 unconed 1.161 drupal_set_message(t('The block %name has been deleted.', array('%name' => theme('placeholder', $info))));
339 unconed 1.156 cache_clear_all();
340     drupal_goto('admin/block');
341     }
342     else {
343     $output = theme('confirm',
344 unconed 1.161 t('Are you sure you want to delete the block %name?', array('%name' => theme('placeholder', $info))),
345 unconed 1.156 'admin/block',
346     NULL,
347     t('Delete'));
348 dries 1.112 }
349    
350     print theme('page', $output);
351 kjartan 1.25 }
352    
353     function block_box_form($edit = array()) {
354 dries 1.162.2.6 $output = form_textfield(t('Block title'), 'title', $edit['title'], 50, 64, t('The title of the block as shown to the user. Leave blank for no title.'));
355 unconed 1.138 $output .= filter_form('format', $edit['format']);
356     $output .= form_textarea(t('Block body'), 'body', $edit['body'], 70, 10, t('The content of the block as shown to the user.'));
357 unconed 1.155 $output .= form_textfield(t('Block description'), 'info', $edit['info'], 50, 64, t('A brief description of your block. Used on the <a href="%overview">block overview page</a>.', array('%overview' => url('admin/block'))));
358 kjartan 1.25
359 dries 1.140 return $output;
360 kjartan 1.25 }
361    
362 dries 1.140 function block_box_save($edit, $delta = NULL) {
363 unconed 1.129 if (!filter_access($edit['format'])) {
364     $edit['format'] = FILTER_FORMAT_DEFAULT;
365 dries 1.38 }
366    
367 dries 1.140 if (isset($delta)) {
368     db_query("UPDATE {boxes} SET title = '%s', body = '%s', info = '%s', format = %d WHERE bid = %d", $edit['title'], $edit['body'], $edit['info'], $edit['format'], $delta);
369 kjartan 1.25 }
370     else {
371 unconed 1.129 db_query("INSERT INTO {boxes} (title, body, info, format) VALUES ('%s', '%s', '%s', %d)", $edit['title'], $edit['body'], $edit['info'], $edit['format']);
372 kjartan 1.25 }
373     }
374    
375 dries 1.112 /**
376 dries 1.114 * Menu callback; displays the block overview page.
377 dries 1.112 */
378 dries 1.1 function block_admin() {
379 dries 1.112 $edit = $_POST['edit'];
380     $op = $_POST['op'];
381 dries 1.5
382 dries 1.112 if ($op == t('Save blocks')) {
383     drupal_set_message(block_admin_save($edit));
384     cache_clear_all();
385 unconed 1.136 drupal_goto($_GET['q']);
386 dries 1.105 }
387 dries 1.112 print theme('page', block_admin_display());
388 kjartan 1.25 }
389    
390 dries 1.112 /**
391     * Implementation of hook_user().
392     *
393     * Allow users to decide which custom blocks to display when they visit
394     * the site.
395     */
396 dries 1.120 function block_user($type, $edit, &$user, $category = NULL) {
397 kjartan 1.25 switch ($type) {
398 kjartan 1.113 case 'form':
399 dries 1.120 if ($category == 'account') {
400 dries 1.140 $result = db_query('SELECT * FROM {blocks} WHERE status = 1 AND custom != 0 ORDER BY weight, module, delta');
401 kjartan 1.25
402 dries 1.120 while ($block = db_fetch_object($result)) {
403     $data = module_invoke($block->module, 'block', 'list');
404     if ($data[$block->delta]['info']) {
405 dries 1.140 $form .= form_checkbox($data[$block->delta]['info'], 'block]['. $block->module .']['. $block->delta, 1, isset($user->block[$block->module][$block->delta]) ? $user->block[$block->module][$block->delta] : ($block->custom == 1));
406 dries 1.120 }
407 kjartan 1.30 }
408    
409 dries 1.120 if (isset($form)) {
410     return array(array('title' => t('Block configuration'), 'data' => $form, 'weight' => 2));
411     }
412 kjartan 1.25 }
413 dries 1.41
414     break;
415 dries 1.112 case 'validate':
416     if (!$edit['block']) {
417     $edit['block'] = array();
418 kjartan 1.36 }
419     return $edit;
420 dries 1.1 }
421     }
422 dries 1.20
423 dries 1.162 /**
424     * Return all blocks in the specied region for the current user. You may
425     * use this function to implement variable block regions. The default
426     * regions are 'left', 'right' and 'all', where 'all' means both left and
427     * right.
428     *
429     * @param $region
430     * This is a string which describes in a human readable form which region
431     * you need.
432     *
433     * @param $regions
434     * This is an optional array and contains map(s) from the string $region to
435     * the numerical region value(s) in the blocks table. See default value for
436     * examples.
437     *
438     * @return
439     * An array of block objects, indexed with <i>module</i>_<i>delta</i>.
440     * If you are displaying your blocks in one or two sidebars, you may check
441     * whether this array is empty to see how many columns are going to be
442     * displayed.
443     *
444     * @todo
445     * Add a proper primary key (bid) to the blocks table so we don't have
446     * to mess around with this <i>module</i>_<i>delta</i> construct.
447     * Currently, the blocks table has no primary key defined!
448     */
449     function block_list($region, $regions = array('left' => 0, 'right' => 1, 'all' => '0, 1')) {
450 dries 1.147 global $user;
451 dries 1.85 static $blocks = array();
452    
453     if (!isset($blocks[$region])) {
454     $blocks[$region] = array();
455 dries 1.162.2.4 $result = db_query("SELECT * FROM {blocks} WHERE status = 1 AND region IN (%s) ORDER BY weight, module", $regions[$region]);
456 dries 1.162 while ($block = db_fetch_array($result)) {
457 dries 1.140 // Use the user's block visibility setting, if necessary
458     if ($block['custom'] != 0) {
459     if ($user->uid && isset($user->block[$block['module']][$block['delta']])) {
460     $enabled = $user->block[$block['module']][$block['delta']];
461     }
462     else {
463     $enabled = ($block['custom'] == 1);
464     }
465     }
466     else {
467     $enabled = TRUE;
468 unconed 1.106 }
469 dries 1.89
470 unconed 1.126 // Match path if necessary
471 dries 1.140 if ($block['pages']) {
472 dries 1.147 $path = drupal_get_path_alias($_GET['q']);
473 dries 1.162.2.5 $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($block['pages'], '/')) .')$/';
474 dries 1.149 $page_match = !($block['visibility'] xor preg_match($regexp, $path));
475     }
476     else {
477     $page_match = TRUE;
478     }
479     // Match node type if necessary
480     $type_match = FALSE;
481     if ($block['types'] != '') {
482     if (arg(0) == 'node' && is_numeric(arg(1))) {
483     $node = node_load(array('nid' => arg(1)));
484     $types = explode(',', $block['types']);
485     //Match on any one selected type
486     foreach ($types as $type) {
487     if ($node->type == $type) {
488     $type_match = TRUE;
489     break;
490     }
491     }
492     }
493 unconed 1.126 }
494     else {
495 dries 1.149 $type_match = TRUE;
496 unconed 1.126 }
497    
498 dries 1.149 if ($enabled && $page_match && $type_match) {
499 dries 1.140 // Check the current throttle status and see if block should be displayed
500     // based on server load.
501 dries 1.141 if (!($block['throttle'] && (module_invoke('throttle', 'status') > 0))) {
502 unconed 1.133 $array = module_invoke($block['module'], 'block', 'view', $block['delta']);
503 dries 1.134 if (is_array($array)) {
504 unconed 1.133 $block = array_merge($block, $array);
505     }
506 dries 1.89 }
507 dries 1.93 if (isset($block['content']) && $block['content']) {
508 dries 1.85 $blocks[$region]["$block[module]_$block[delta]"] = (object) $block;
509     }
510     }
511     }
512     }
513     return $blocks[$region];
514     }
515    
516 dries 1.65 ?>

  ViewVC Help
Powered by ViewVC 1.1.2