/[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.7 - (hide annotations) (download) (as text)
Wed Oct 18 20:14:08 2006 UTC (3 years, 1 month ago) by killes
Branch: DRUPAL-4-6
CVS Tags: DRUPAL-4-6-11, DRUPAL-4-6-10
Changes since 1.162.2.6: +2 -1 lines
File MIME type: text/x-php
remove trailing spaces
1 dries 1.8 <?php
2 killes 1.162.2.7 // $Id: block.module,v 1.162.2.6 2006/08/22 19:32:56 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 killes 1.162.2.7 unset($edit['token']);
114 dries 1.38 foreach ($edit as $module => $blocks) {
115     foreach ($blocks as $delta => $block) {
116 dries 1.140 db_query("UPDATE {blocks} SET region = %d, status = %d, weight = %d, throttle = %d WHERE module = '%s' AND delta = '%s'",
117     $block['region'], $block['status'], $block['weight'], $block['throttle'], $module, $delta);
118 dries 1.38 }
119 dries 1.1 }
120 dries 1.42
121 dries 1.140 return t('The block settings have been updated.');
122 dries 1.1 }
123    
124 dries 1.39 /**
125 dries 1.112 * Update the 'blocks' DB table with the blocks currently exported by modules.
126 dries 1.40 *
127 dries 1.95 * @param $order_by php <a
128     * href="http://www.php.net/manual/en/function.array-multisort.php">array_multisort()</a>
129     * style sort ordering, eg. "weight", SORT_ASC, SORT_STRING.
130 dries 1.87 *
131 dries 1.112 * @return
132     * Blocks currently exported by modules, sorted by $order_by.
133 dries 1.39 */
134 dries 1.112 function _block_rehash($order_by = array('weight')) {
135     $result = db_query('SELECT * FROM {blocks} ');
136 dries 1.38 while ($old_block = db_fetch_object($result)) {
137     $old_blocks[$old_block->module][$old_block->delta] = $old_block;
138     }
139    
140 dries 1.112 db_query('DELETE FROM {blocks} ');
141 dries 1.38
142     foreach (module_list() as $module) {
143 dries 1.112 $module_blocks = module_invoke($module, 'block', 'list');
144 dries 1.38 if ($module_blocks) {
145     foreach ($module_blocks as $delta => $block) {
146 dries 1.112 $block['module'] = $module;
147     $block['delta'] = $delta;
148 dries 1.38 if ($old_blocks[$module][$delta]) {
149 dries 1.112 $block['status'] = $old_blocks[$module][$delta]->status;
150     $block['weight'] = $old_blocks[$module][$delta]->weight;
151     $block['region'] = $old_blocks[$module][$delta]->region;
152 dries 1.140 $block['visibility'] = $old_blocks[$module][$delta]->visibility;
153     $block['pages'] = $old_blocks[$module][$delta]->pages;
154 dries 1.112 $block['custom'] = $old_blocks[$module][$delta]->custom;
155     $block['throttle'] = $old_blocks[$module][$delta]->throttle;
156 dries 1.149 $block['types'] = $old_blocks[$module][$delta]->types;
157 dries 1.38 }
158     else {
159 dries 1.112 $block['status'] = $block['weight'] = $block['region'] = $block['custom'] = 0;
160 dries 1.149 $block['pages'] = $block['types'] = '';
161 dries 1.38 }
162    
163     // reinsert blocks into table
164 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')",
165     $block['module'], $block['delta'], $block['status'], $block['weight'], $block['region'], $block['visibility'], $block['pages'], $block['custom'], $block['throttle'], $block['types']);
166 dries 1.38
167     $blocks[] = $block;
168 dries 1.40
169 dries 1.39 // build array to sort on
170     $order[$order_by[0]][] = $block[$order_by[0]];
171 dries 1.38 }
172     }
173     }
174    
175 dries 1.39 // sort
176     array_multisort($order[$order_by[0]], $order_by[1] ? $order_by[1] : SORT_ASC, $order_by[2] ? $order_by[2] : SORT_REGULAR, $blocks);
177    
178 dries 1.38 return $blocks;
179     }
180 dries 1.5
181 dries 1.112 /**
182     * Prepare the main block administration form.
183     */
184 dries 1.38 function block_admin_display() {
185 dries 1.39 $blocks = _block_rehash();
186 dries 1.4
187 dries 1.159 $header = array(t('Block'), t('Enabled'), t('Weight'), t('Sidebar'));
188 dries 1.144 if (module_exist('throttle')) {
189     $header[] = t('Throttle');
190     }
191     $header[] = array('data' => t('Operations'), 'colspan' => 2);
192    
193 dries 1.157 $left = array();
194     $right = array();
195     $disabled = array();
196 dries 1.38 foreach ($blocks as $block) {
197 dries 1.140 if ($block['module'] == 'block') {
198 unconed 1.153 $delete = l(t('delete'), 'admin/block/delete/'. $block['delta']);
199 dries 1.48 }
200     else {
201 unconed 1.153 $delete = '';
202 kjartan 1.25 }
203 dries 1.46
204 dries 1.157 $row = array(array('data' => $block['info'], 'class' => 'block'),
205 unconed 1.154 form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][status', 1, $block['status']),
206     form_weight(NULL, $block['module'] .']['. $block['delta'] .'][weight', $block['weight']),
207     form_radios(NULL, $block['module'] .']['. $block['delta'] .'][region', $block['region'],
208     array(t('left'), t('right'))));
209 dries 1.144
210     if (module_exist('throttle')) {
211 unconed 1.154 $row[] = form_checkbox(NULL, $block['module'] .']['. $block['delta'] .'][throttle', 1, $block['throttle']);
212 dries 1.144 }
213 unconed 1.153 $row[] = l(t('configure'), 'admin/block/configure/'. $block['module'] .'/'. $block['delta']);
214     $row[] = $delete;
215 dries 1.157 if ($block['status']) {
216     if ($block['region'] == 0) {
217     $left[] = $row;
218     }
219 dries 1.162 if ($block['region'] == 1) {
220 dries 1.157 $right[] = $row;
221     }
222     }
223 dries 1.162 else if ($block['region'] <= 1) {
224 dries 1.157 $disabled[] = $row;
225     }
226 dries 1.1 }
227 dries 1.5
228 dries 1.157 $rows = array();
229     if (count($left)) {
230     $rows[] = array(array('data' => t('Left sidebar'), 'class' => 'region', 'colspan' => (module_exist('throttle') ? 7 : 6)));
231     $rows = array_merge($rows, $left);
232     }
233     if (count($right)) {
234 dries 1.158 $rows[] = array(array('data' => t('Right sidebar'), 'class' => 'region', 'colspan' => (module_exist('throttle') ? 7 : 6)));
235 dries 1.157 $rows = array_merge($rows, $right);
236     }
237     if (count($disabled)) {
238     $rows[] = array(array('data' => t('Disabled'), 'class' => 'region', 'colspan' => (module_exist('throttle') ? 7 : 6)));
239     $rows = array_merge($rows, $disabled);
240     }
241     $output = theme('table', $header, $rows, array('id' => 'blocks'));
242 dries 1.112 $output .= form_submit(t('Save blocks'));
243 dries 1.1
244 dries 1.116 return form($output, 'post', url('admin/block'));
245 dries 1.1 }
246    
247 kjartan 1.25 function block_box_get($bid) {
248 dries 1.112 return db_fetch_array(db_query('SELECT * FROM {boxes} WHERE bid = %d', $bid));
249     }
250    
251     /**
252 dries 1.140 * Menu callback; displays the block configuration form.
253 dries 1.112 */
254 dries 1.140 function block_admin_configure($module = NULL, $delta = 0) {
255 dries 1.112 $edit = $_POST['edit'];
256     $op = $_POST['op'];
257    
258 unconed 1.138 switch ($op) {
259     case t('Save block'):
260 dries 1.149 if ($edit['types']) {
261     $types = implode(',', $edit['types']);
262     }
263     else {
264     $types = '';
265     }
266     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);
267 dries 1.140 module_invoke($module, 'block', 'save', $delta, $edit);
268 dries 1.162.2.1 drupal_set_message(t('The block configuration has been saved.'));
269 unconed 1.138 cache_clear_all();
270     drupal_goto('admin/block');
271    
272 dries 1.140 default:
273     // Always evaluates to TRUE, but a validation step may be added later.
274     if (!$edit) {
275 dries 1.149 $edit = db_fetch_array(db_query("SELECT pages, visibility, custom, types FROM {blocks} WHERE module = '%s' AND delta = '%s'", $module, $delta));
276 dries 1.140 }
277    
278     // Module-specific block configurations.
279     if ($settings = module_invoke($module, 'block', 'configure', $delta)) {
280     $form = form_group(t('Block-specific settings'), $settings);
281     }
282    
283 dries 1.149 foreach (node_list() as $type) {
284     $content_types[$type] = node_invoke($type, 'node_name');
285     }
286 dries 1.140 // Get the block subject for the page title.
287     $info = module_invoke($module, 'block', 'list');
288     drupal_set_title(t("'%name' block", array('%name' => $info[$delta]['info'])));
289    
290     // Standard block configurations.
291 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.'));
292     $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.')));
293 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."));
294     $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);
295 dries 1.149
296 dries 1.152 $form .= form_group(t('User specific visibility settings'), $group_1);
297 dries 1.149 $form .= form_group(t('Page specific visibility settings'), $group_2);
298     $form .= form_group(t('Content specific visibility settings'), $group_3);
299 dries 1.140
300    
301     $form .= form_submit(t('Save block'));
302    
303     print theme('page', form($form));
304     }
305     }
306    
307     /**
308     * Menu callback; displays the block creation form.
309     */
310     function block_box_add() {
311     $edit = $_POST['edit'];
312     $op = $_POST['op'];
313    
314     switch ($op) {
315     case t('Save block'):
316     block_box_save($edit);
317     drupal_set_message(t('The new block has been added.'));
318     drupal_goto('admin/block');
319    
320     default:
321     $form = block_box_form();
322     $form .= form_submit(t('Save block'));
323     $output .= form($form);
324     }
325    
326     print theme('page', $output);
327     }
328    
329     /**
330     * Menu callback; confirm and delete custom blocks.
331     */
332     function block_box_delete($bid = 0) {
333     $op = $_POST['op'];
334     $box = block_box_get($bid);
335 unconed 1.156 $info = $box['info'] ? $box['info'] : $box['title'];
336 unconed 1.138
337 unconed 1.156 if ($_POST['edit']['confirm']) {
338     db_query('DELETE FROM {boxes} WHERE bid = %d', $bid);
339 unconed 1.161 drupal_set_message(t('The block %name has been deleted.', array('%name' => theme('placeholder', $info))));
340 unconed 1.156 cache_clear_all();
341     drupal_goto('admin/block');
342     }
343     else {
344     $output = theme('confirm',
345 unconed 1.161 t('Are you sure you want to delete the block %name?', array('%name' => theme('placeholder', $info))),
346 unconed 1.156 'admin/block',
347     NULL,
348     t('Delete'));
349 dries 1.112 }
350    
351     print theme('page', $output);
352 kjartan 1.25 }
353    
354     function block_box_form($edit = array()) {
355 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.'));
356 unconed 1.138 $output .= filter_form('format', $edit['format']);
357     $output .= form_textarea(t('Block body'), 'body', $edit['body'], 70, 10, t('The content of the block as shown to the user.'));
358 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'))));
359 kjartan 1.25
360 dries 1.140 return $output;
361 kjartan 1.25 }
362    
363 dries 1.140 function block_box_save($edit, $delta = NULL) {
364 unconed 1.129 if (!filter_access($edit['format'])) {
365     $edit['format'] = FILTER_FORMAT_DEFAULT;
366 dries 1.38 }
367    
368 dries 1.140 if (isset($delta)) {
369     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);
370 kjartan 1.25 }
371     else {
372 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']);
373 kjartan 1.25 }
374     }
375    
376 dries 1.112 /**
377 dries 1.114 * Menu callback; displays the block overview page.
378 dries 1.112 */
379 dries 1.1 function block_admin() {
380 dries 1.112 $edit = $_POST['edit'];
381     $op = $_POST['op'];
382 dries 1.5
383 dries 1.112 if ($op == t('Save blocks')) {
384     drupal_set_message(block_admin_save($edit));
385     cache_clear_all();
386 unconed 1.136 drupal_goto($_GET['q']);
387 dries 1.105 }
388 dries 1.112 print theme('page', block_admin_display());
389 kjartan 1.25 }
390    
391 dries 1.112 /**
392     * Implementation of hook_user().
393     *
394     * Allow users to decide which custom blocks to display when they visit
395     * the site.
396     */
397 dries 1.120 function block_user($type, $edit, &$user, $category = NULL) {
398 kjartan 1.25 switch ($type) {
399 kjartan 1.113 case 'form':
400 dries 1.120 if ($category == 'account') {
401 dries 1.140 $result = db_query('SELECT * FROM {blocks} WHERE status = 1 AND custom != 0 ORDER BY weight, module, delta');
402 kjartan 1.25
403 dries 1.120 while ($block = db_fetch_object($result)) {
404     $data = module_invoke($block->module, 'block', 'list');
405     if ($data[$block->delta]['info']) {
406 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));
407 dries 1.120 }
408 kjartan 1.30 }
409    
410 dries 1.120 if (isset($form)) {
411     return array(array('title' => t('Block configuration'), 'data' => $form, 'weight' => 2));
412     }
413 kjartan 1.25 }
414 dries 1.41
415     break;
416 dries 1.112 case 'validate':
417     if (!$edit['block']) {
418     $edit['block'] = array();
419 kjartan 1.36 }
420     return $edit;
421 dries 1.1 }
422     }
423 dries 1.20
424 dries 1.162 /**
425     * Return all blocks in the specied region for the current user. You may
426     * use this function to implement variable block regions. The default
427     * regions are 'left', 'right' and 'all', where 'all' means both left and
428     * right.
429     *
430     * @param $region
431     * This is a string which describes in a human readable form which region
432     * you need.
433     *
434     * @param $regions
435     * This is an optional array and contains map(s) from the string $region to
436     * the numerical region value(s) in the blocks table. See default value for
437     * examples.
438     *
439     * @return
440     * An array of block objects, indexed with <i>module</i>_<i>delta</i>.
441     * If you are displaying your blocks in one or two sidebars, you may check
442     * whether this array is empty to see how many columns are going to be
443     * displayed.
444     *
445     * @todo
446     * Add a proper primary key (bid) to the blocks table so we don't have
447     * to mess around with this <i>module</i>_<i>delta</i> construct.
448     * Currently, the blocks table has no primary key defined!
449     */
450     function block_list($region, $regions = array('left' => 0, 'right' => 1, 'all' => '0, 1')) {
451 dries 1.147 global $user;
452 dries 1.85 static $blocks = array();
453    
454     if (!isset($blocks[$region])) {
455     $blocks[$region] = array();
456 dries 1.162.2.4 $result = db_query("SELECT * FROM {blocks} WHERE status = 1 AND region IN (%s) ORDER BY weight, module", $regions[$region]);
457 dries 1.162 while ($block = db_fetch_array($result)) {
458 dries 1.140 // Use the user's block visibility setting, if necessary
459     if ($block['custom'] != 0) {
460     if ($user->uid && isset($user->block[$block['module']][$block['delta']])) {
461     $enabled = $user->block[$block['module']][$block['delta']];
462     }
463     else {
464     $enabled = ($block['custom'] == 1);
465     }
466     }
467     else {
468     $enabled = TRUE;
469 unconed 1.106 }
470 dries 1.89
471 unconed 1.126 // Match path if necessary
472 dries 1.140 if ($block['pages']) {
473 dries 1.147 $path = drupal_get_path_alias($_GET['q']);
474 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'], '/')) .')$/';
475 dries 1.149 $page_match = !($block['visibility'] xor preg_match($regexp, $path));
476     }
477     else {
478     $page_match = TRUE;
479     }
480     // Match node type if necessary
481     $type_match = FALSE;
482     if ($block['types'] != '') {
483     if (arg(0) == 'node' && is_numeric(arg(1))) {
484     $node = node_load(array('nid' => arg(1)));
485     $types = explode(',', $block['types']);
486     //Match on any one selected type
487     foreach ($types as $type) {
488     if ($node->type == $type) {
489     $type_match = TRUE;
490     break;
491     }
492     }
493     }
494 unconed 1.126 }
495     else {
496 dries 1.149 $type_match = TRUE;
497 unconed 1.126 }
498    
499 dries 1.149 if ($enabled && $page_match && $type_match) {
500 dries 1.140 // Check the current throttle status and see if block should be displayed
501     // based on server load.
502 dries 1.141 if (!($block['throttle'] && (module_invoke('throttle', 'status') > 0))) {
503 unconed 1.133 $array = module_invoke($block['module'], 'block', 'view', $block['delta']);
504 dries 1.134 if (is_array($array)) {
505 unconed 1.133 $block = array_merge($block, $array);
506     }
507 dries 1.89 }
508 dries 1.93 if (isset($block['content']) && $block['content']) {
509 dries 1.85 $blocks[$region]["$block[module]_$block[delta]"] = (object) $block;
510     }
511     }
512     }
513     }
514     return $blocks[$region];
515     }
516    
517 dries 1.65 ?>

  ViewVC Help
Powered by ViewVC 1.1.2