| 1 |
<?php
|
| 2 |
|
| 3 |
function phptemplate_block_list($region) {
|
| 4 |
// This is the list function from the block module. We have to comment
|
| 5 |
// out the throttle test, which for some reason breaks node previews.
|
| 6 |
// As a result, if blocks are throttled, we may get the wrong layout.
|
| 7 |
global $user, $theme_key;
|
| 8 |
|
| 9 |
static $blocks = array();
|
| 10 |
|
| 11 |
if (!count($blocks)) {
|
| 12 |
$result = db_query("SELECT * FROM {blocks} WHERE theme = '%s' AND status = 1 ORDER BY region, weight, module", $theme_key);
|
| 13 |
while ($block = db_fetch_object($result)) {
|
| 14 |
if (!isset($blocks[$block->region])) {
|
| 15 |
$blocks[$block->region] = array();
|
| 16 |
}
|
| 17 |
// Use the user's block visibility setting, if necessary
|
| 18 |
if ($block->custom != 0) {
|
| 19 |
if ($user->uid && isset($user->block[$block->module][$block->delta])) {
|
| 20 |
$enabled = $user->block[$block->module][$block->delta];
|
| 21 |
}
|
| 22 |
else {
|
| 23 |
$enabled = ($block->custom == 1);
|
| 24 |
}
|
| 25 |
}
|
| 26 |
else {
|
| 27 |
$enabled = TRUE;
|
| 28 |
}
|
| 29 |
|
| 30 |
// Match path if necessary
|
| 31 |
if ($block->pages) {
|
| 32 |
if ($block->visibility < 2) {
|
| 33 |
$path = drupal_get_path_alias($_GET['q']);
|
| 34 |
$regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($block->pages, '/')) .')$/';
|
| 35 |
$page_match = !($block->visibility xor preg_match($regexp, $path));
|
| 36 |
}
|
| 37 |
else {
|
| 38 |
$page_match = drupal_eval($block->pages);
|
| 39 |
}
|
| 40 |
}
|
| 41 |
else {
|
| 42 |
$page_match = TRUE;
|
| 43 |
}
|
| 44 |
|
| 45 |
if ($enabled && $page_match) {
|
| 46 |
// Check the current throttle status and see if block should be displayed
|
| 47 |
// based on server load.
|
| 48 |
// if (!($block->throttle && (module_invoke('throttle', 'status') > 0))) {
|
| 49 |
// $array = module_invoke($block->module, 'block', 'view', $block->delta);
|
| 50 |
// if (isset($array) && is_array($array)) {
|
| 51 |
// foreach ($array as $k => $v) {
|
| 52 |
// $block->$k = $v;
|
| 53 |
// }
|
| 54 |
// }
|
| 55 |
// }
|
| 56 |
if (isset($block->content) && $block->content) {
|
| 57 |
$blocks[$block->region]["{$block->module}_{$block->delta}"] = $block;
|
| 58 |
}
|
| 59 |
}
|
| 60 |
}
|
| 61 |
}
|
| 62 |
// Create an empty array if there were no entries
|
| 63 |
if (!isset($blocks[$region])) {
|
| 64 |
// $blocks[$region] = array();
|
| 65 |
return 0;
|
| 66 |
}
|
| 67 |
|
| 68 |
return 1;//$blocks[$region];
|
| 69 |
}
|
| 70 |
|
| 71 |
function _phptemplate_variables($hook, $vars) {
|
| 72 |
// Detect whether left and right sidebars are used, and
|
| 73 |
// set layoutcode accordingly
|
| 74 |
$vars['layoutcode'] = '3'; // default - right
|
| 75 |
if ($left=phptemplate_block_list("left")) {
|
| 76 |
$vars['layoutcode'] = '2'; } // left
|
| 77 |
if ($left && phptemplate_block_list("right")) {
|
| 78 |
$vars['layoutcode'] = '1'; } //both
|
| 79 |
return $vars;
|
| 80 |
}
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
function phptemplate_menu_tree($pid=1) {
|
| 85 |
// Code adapted from the nice_menus module
|
| 86 |
// generates nested <ul> <li> lists
|
| 87 |
$menu = menu_get_menu($pid);
|
| 88 |
$output = '';
|
| 89 |
if ($menu['visible'][$pid]['children']) {
|
| 90 |
foreach ($menu['visible'][$pid]['children'] as $mid) {
|
| 91 |
if (count($menu['visible'][$mid]['children']) > 0) {
|
| 92 |
$output.= "<li>".menu_item_link($mid);
|
| 93 |
if (menu_in_active_trail($mid)) { // only output children if they should be seen
|
| 94 |
$output.= "<ul>";
|
| 95 |
$tmp = phptemplate_menu_tree($mid);
|
| 96 |
$output.= $tmp;
|
| 97 |
$output.= "</ul>";
|
| 98 |
}
|
| 99 |
$output.= "</li>";
|
| 100 |
}
|
| 101 |
else {
|
| 102 |
$output.= "<li>".menu_item_link($mid)."</li>";
|
| 103 |
}
|
| 104 |
}
|
| 105 |
}
|
| 106 |
return $output;
|
| 107 |
}
|