| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: template.php,v 1.1.2.7 2010/04/08 07:02:59 sociotech Exp $ 3 4 require_once ('theme-settings.php'); 5 6 7 /** 8 * Initialize theme settings 9 */ 10 global $theme_key; 11 if (db_is_active()) { 12 fusion_core_initialize_theme_settings($theme_key); 13 } 14 15 16 /** 17 * Maintenance page preprocessing 18 */ 19 function fusion_core_preprocess_maintenance_page(&$vars) { 20 if (db_is_active()) { 21 fusion_core_preprocess_page($vars); 22 } 23 } 24 25 26 /** 27 * Page preprocessing 28 */ 29 function fusion_core_preprocess_page(&$vars) { 30 global $language, $theme_key, $theme_info, $user; 31 32 // Remove sidebars if disabled e.g., for Panels 33 if (!$vars['show_blocks']) { 34 $vars['sidebar_first'] = ''; 35 $vars['sidebar_last'] = ''; 36 } 37 // Set grid info & row widths 38 $grid_name = substr(theme_get_setting('theme_grid'), 0, 7); 39 $grid_type = substr(theme_get_setting('theme_grid'), 7); 40 $grid_width = (int)substr($grid_name, 4, 2); 41 $vars['grid_width'] = $grid_name . $grid_width; 42 $sidebar_first_top_width = ($vars['sidebar_first_top']) ? theme_get_setting('sidebar_first_top_width') : 0; 43 $sidebar_first_width = ($vars['sidebar_first']) ? theme_get_setting('sidebar_first_width') : 0; 44 $sidebar_last_width = ($vars['sidebar_last']) ? theme_get_setting('sidebar_last_width') : 0; 45 $vars['sidebar_first_top_width'] = $grid_name . $sidebar_first_top_width; 46 $vars['sidebar_first_width'] = $grid_name . $sidebar_first_width; 47 $vars['main_group_width'] = $grid_name . ($grid_width - $sidebar_first_width); 48 // For nested elements in a fluid grid calculate % widths & add inline 49 if ($grid_type == 'fluid') { 50 $sidebar_last_width = round(($sidebar_last_width/($grid_width - $sidebar_first_width)) * 100, 2); 51 $vars['content_group_width'] = '" style="width:' . (100 - $sidebar_last_width) . '%'; 52 $vars['sidebar_last_width'] = '" style="width:' . $sidebar_last_width . '%'; 53 } 54 else { 55 $vars['content_group_width'] = $grid_name . ($grid_width - ($sidebar_first_width + $sidebar_last_width)); 56 $vars['sidebar_last_width'] = $grid_name . $sidebar_last_width; 57 } 58 59 // Add to array of helpful body classes 60 $body_classes = explode(' ', $vars['body_classes']); // Default classes 61 if (isset($vars['node'])) { 62 $body_classes[] = ($vars['node']) ? 'full-node' : ''; // Full node 63 $body_classes[] = (($vars['node']->type == 'forum') || (arg(0) == 'forum')) ? 'forum' : ''; // Forum page 64 } 65 else { 66 $body_classes[] = (arg(0) == 'forum') ? 'forum' : ''; // Forum page 67 } 68 if (module_exists('panels') && function_exists('panels_get_current_page_display')) { // Panels page 69 $body_classes[] = (panels_get_current_page_display()) ? 'panels' : ''; 70 } 71 $body_classes[] = 'layout-'. (($vars['sidebar_first']) ? 'first-main' : 'main') . (($vars['sidebar_last']) ? '-last' : ''); // Sidebars active 72 $body_classes[] = theme_get_setting('sidebar_layout'); // Sidebar layout 73 $body_classes[] = (theme_get_setting('theme_font') != 'none') ? theme_get_setting('theme_font') : ''; // Font family 74 $body_classes[] = theme_get_setting('theme_font_size'); // Font size 75 $body_classes[] = (user_access('administer blocks', $user) && theme_get_setting('grid_mask')) ? 'grid-mask-enabled' : ''; // Grid mask overlay 76 $body_classes[] = 'grid-type-' . $grid_type; // Fixed width or fluid 77 $body_classes[] = 'grid-width-' . sprintf("%02d", $grid_width); // Grid width in units 78 $body_classes[] = ($grid_type == 'fluid') ? theme_get_setting('fluid_grid_width') : ''; // Fluid grid width in % 79 $body_classes = array_filter($body_classes); // Remove empty elements 80 $vars['body_classes'] = implode(' ', $body_classes); // Create class list separated by spaces 81 $vars['body_id'] = 'pid-' . strtolower(preg_replace('/[^a-zA-Z0-9-]+/', '-', drupal_get_path_alias($_GET['q']))); // Add a unique page id 82 83 // Generate links tree & add Superfish class if dropdown enabled, else make standard primary links 84 $vars['primary_links_tree'] = ''; 85 if ($vars['primary_links']) { 86 if (theme_get_setting('primary_menu_dropdown') == 1) { 87 $vars['primary_links_tree'] = menu_tree(variable_get('menu_primary_links_source', 'primary-links')); 88 $vars['primary_links_tree'] = preg_replace('/<ul class="menu/i', '<ul class="menu sf-menu', $vars['primary_links_tree'], 1); 89 } 90 else { 91 $vars['primary_links_tree'] = theme('links', $vars['primary_links'], array('class' => 'menu')); 92 } 93 } 94 95 // Remove breadcrumbs if disabled 96 if (theme_get_setting('breadcrumb_display') == 0) { 97 $vars['breadcrumb'] = ''; 98 } 99 100 // Add grid, color, ie6, ie7, ie8 & local stylesheets, including inherited & rtl versions 101 $grid_style = '/css/' . theme_get_setting('theme_grid'); 102 $themes = fusion_core_theme_paths($theme_key); 103 $vars['setting_styles'] = $vars['ie6_styles'] = $vars['ie7_styles'] = $vars['ie8_styles'] = $vars['local_styles'] = ''; 104 foreach ($themes as $name => $path) { 105 $link = '<link type="text/css" rel="stylesheet" media="all" href="' . base_path() . $path; 106 $vars['setting_styles'] .= (file_exists($path . $grid_style . '.css')) ? $link . $grid_style . '.css" />' . "\n" : ''; 107 $vars['ie6_styles'] .= (file_exists($path . '/css/ie6-fixes.css')) ? $link . '/css/ie6-fixes.css" />' . "\n" : ''; 108 $vars['ie7_styles'] .= (file_exists($path . '/css/ie7-fixes.css')) ? $link . '/css/ie7-fixes.css" />' . "\n" : ''; 109 $vars['ie8_styles'] .= (file_exists($path . '/css/ie8-fixes.css')) ? $link . '/css/ie8-fixes.css" />' . "\n" : ''; 110 $vars['local_styles'] .= (file_exists($path . '/css/local.css')) ? $link . '/css/local.css" />' . "\n" : ''; 111 if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) { 112 $vars['setting_styles'] .= (file_exists($path . $grid_style . '-rtl.css')) ? $link . $grid_style . '-rtl.css" />' . "\n" : ''; 113 $vars['ie6_styles'] .= (file_exists($path . '/css/ie6-fixes-rtl.css')) ? $link . '/css/ie6-fixes-rtl.css" />' . "\n" : ''; 114 $vars['ie7_styles'] .= (file_exists($path . '/css/ie7-fixes-rtl.css')) ? $link . '/css/ie7-fixes-rtl.css" />' . "\n" : ''; 115 $vars['ie8_styles'] .= (file_exists($path . '/css/ie8-fixes-rtl.css')) ? $link . '/css/ie8-fixes-rtl.css" />' . "\n" : ''; 116 $vars['local_styles'] .= (file_exists($path . '/css/local-rtl.css')) ? $link . '/css/local-rtl.css" />' . "\n" : ''; 117 } 118 } 119 120 // Use grouped import setting to avoid 30 stylesheet limit in IE 121 if (theme_get_setting('fix_css_limit') && !variable_get('preprocess_css', FALSE)) { 122 $css = drupal_add_css(); 123 $style_count = substr_count($vars['setting_styles'] . $vars['ie6_styles'] . $vars['ie7_styles'] . $vars['ie8_styles'] . $vars['local_styles'], '<link'); 124 if (fusion_core_css_count($css) > (30 - $style_count)) { 125 $styles = ''; 126 $suffix = "\n".'</style>'."\n"; 127 foreach ($css as $media => $types) { 128 $prefix = '<style type="text/css" media="'. $media .'">'."\n"; 129 $imports = array(); 130 foreach ($types as $files) { 131 foreach ($files as $file => $preprocess) { 132 $imports[] = '@import "'. base_path() . $file .'";'; 133 if (count($imports) == 30) { 134 $styles .= $prefix . implode("\n", $imports) . $suffix; 135 $imports = array(); 136 } 137 } 138 } 139 $styles .= (count($imports) > 0) ? ($prefix . implode("\n", $imports) . $suffix) : ''; 140 } 141 $vars['styles'] = $styles; 142 } 143 } 144 } 145 146 147 /** 148 * Node preprocessing 149 */ 150 function fusion_core_preprocess_node(&$vars) { 151 // Build array of handy node classes 152 $node_classes = array(); 153 $node_classes[] = $vars['zebra']; // Node is odd or even 154 $node_classes[] = (!$vars['node']->status) ? 'node-unpublished' : ''; // Node is unpublished 155 $node_classes[] = ($vars['sticky']) ? 'sticky' : ''; // Node is sticky 156 $node_classes[] = (isset($vars['node']->teaser)) ? 'teaser' : 'full-node'; // Node is teaser or full-node 157 $node_classes[] = 'node-type-'. $vars['node']->type; // Node is type-x, e.g., node-type-page 158 $node_classes[] = (isset($vars['skinr'])) ? $vars['skinr'] : ''; // Add Skinr classes if present 159 $node_classes = array_filter($node_classes); // Remove empty elements 160 $vars['node_classes'] = implode(' ', $node_classes); // Implode class list with spaces 161 162 // Add node_top and node_bottom region content 163 $vars['node_top'] = theme('blocks', 'node_top'); 164 $vars['node_bottom'] = theme('blocks', 'node_bottom'); 165 166 // Render Ubercart fields into separate variables for node-product.tpl.php 167 if (module_exists('uc_product') && uc_product_is_product($vars) && $vars['template_files'][0] == 'node-product') { 168 $node = node_build_content(node_load($vars['nid'])); 169 $vars['fusion_uc_image'] = drupal_render($node->content['image']); 170 $vars['fusion_uc_body'] = drupal_render($node->content['body']); 171 $vars['fusion_uc_display_price'] = drupal_render($node->content['display_price']); 172 $vars['fusion_uc_add_to_cart'] = drupal_render($node->content['add_to_cart']); 173 $vars['fusion_uc_sell_price'] = drupal_render($node->content['sell_price']); 174 $vars['fusion_uc_cost'] = drupal_render($node->content['cost']); 175 $vars['fusion_uc_weight'] = (!empty($node->weight)) ? drupal_render($node->content['weight']) : ''; // Hide weight if empty 176 if ($vars['fusion_uc_weight'] == '') { 177 unset($node->content['weight']); 178 } 179 $dimensions = !empty($node->height) && !empty($node->width) && !empty($node->length); // Hide dimensions if empty 180 $vars['fusion_uc_dimensions'] = ($dimensions) ? drupal_render($node->content['dimensions']) : ''; 181 if ($vars['fusion_uc_dimensions'] == '') { 182 unset($node->content['dimensions']); 183 } 184 $list_price = !empty($node->list_price) && $node->list_price > 0; // Hide list price if empty or zero 185 $vars['fusion_uc_list_price'] = ($list_price) ? drupal_render($node->content['list_price']) : ''; 186 if ($vars['fusion_uc_list_price'] == '') { 187 unset($node->content['list_price']); 188 } 189 $vars['fusion_uc_additional'] = drupal_render($node->content); // Render remaining fields 190 } 191 } 192 193 194 /** 195 * Comment preprocessing 196 */ 197 function fusion_core_preprocess_comment(&$vars) { 198 global $user; 199 static $comment_odd = TRUE; // Comment is odd or even 200 201 // Build array of handy comment classes 202 $comment_classes = array(); 203 $comment_classes[] = $comment_odd ? 'odd' : 'even'; 204 $comment_odd = !$comment_odd; 205 $comment_classes[] = ($vars['comment']->status == COMMENT_NOT_PUBLISHED) ? 'comment-unpublished' : ''; // Comment is unpublished 206 $comment_classes[] = ($vars['comment']->new) ? 'comment-new' : ''; // Comment is new 207 $comment_classes[] = ($vars['comment']->uid == 0) ? 'comment-by-anon' : ''; // Comment is by anonymous user 208 $comment_classes[] = ($user->uid && $vars['comment']->uid == $user->uid) ? 'comment-mine' : ''; // Comment is by current user 209 $node = node_load($vars['comment']->nid); // Comment is by node author 210 $vars['author_comment'] = ($vars['comment']->uid == $node->uid) ? TRUE : FALSE; 211 $comment_classes[] = ($vars['author_comment']) ? 'comment-by-author' : ''; 212 $comment_classes = array_filter($comment_classes); // Remove empty elements 213 $vars['comment_classes'] = implode(' ', $comment_classes); // Create class list separated by spaces 214 215 // Date & author 216 $submitted_by = t('by ') .'<span class="comment-name">'. theme('username', $vars['comment']) .'</span>'; 217 $submitted_by .= t(' - ') .'<span class="comment-date">'. format_date($vars['comment']->timestamp, 'small') .'</span>'; // Format date as small, medium, or large 218 $vars['submitted'] = $submitted_by; 219 } 220 221 222 /** 223 * Comment wrapper preprocessing 224 * Defaults for comments display 225 */ 226 function fusion_core_preprocess_comment_wrapper(&$vars) { 227 $vars['display_mode'] = COMMENT_MODE_FLAT_EXPANDED; 228 $vars['display_order'] = COMMENT_ORDER_OLDEST_FIRST; 229 $vars['comment_controls_state'] = COMMENT_CONTROLS_HIDDEN; 230 } 231 232 233 /** 234 * Block preprocessing 235 */ 236 function fusion_core_preprocess_block(&$vars) { 237 global $theme_info, $user; 238 static $regions, $sidebar_first_top_width, $sidebar_first_width, $sidebar_last_width, $grid_name, $grid_width, $grid_fixed; 239 240 // Do not process blocks outside defined regions 241 if (!in_array($vars['block']->region, array_keys($theme_info->info['regions']))) { 242 return; 243 } 244 245 // Initialize block region grid info once per page 246 if (!isset($regions)) { 247 $grid_name = substr(theme_get_setting('theme_grid'), 0, 7); 248 $grid_width = (int)substr($grid_name, 4, 2); 249 $grid_fixed = (substr(theme_get_setting('theme_grid'), 7) != 'fluid') ? 1 : 0; 250 $sidebar_first_top_width = (block_list('sidebar_first_top')) ? theme_get_setting('sidebar_first_top_width') : 0; 251 $sidebar_first_width = (block_list('sidebar_first')) ? theme_get_setting('sidebar_first_width') : 0; 252 $sidebar_last_width = (block_list('sidebar_last')) ? theme_get_setting('sidebar_last_width') : 0; 253 $regions = fusion_core_set_regions($grid_width, $sidebar_first_width, $sidebar_first_top_width, $sidebar_last_width); 254 } 255 256 // Increment block count for current block's region, add first/last position class 257 $regions[$vars['block']->region]['count'] ++; 258 $region_count = $regions[$vars['block']->region]['count']; 259 $total_blocks = $regions[$vars['block']->region]['total']; 260 $vars['position'] = ($region_count == 1) ? 'first' : ''; 261 $vars['position'] .= ($region_count == $total_blocks) ? ' last' : ''; 262 263 // Set a default block width if not already set by Skinr 264 if (!isset($vars['skinr']) || (strpos($vars['skinr'], $grid_name) === false)) { 265 // Stack blocks vertically in sidebars by setting to full sidebar width 266 if ($vars['block']->region == 'sidebar_first_top') { 267 $width = ($grid_fixed) ? $sidebar_first_top_width : $grid_width; // Sidebar width or 100% (if fluid) 268 } 269 elseif ($vars['block']->region == 'sidebar_first') { 270 $width = ($grid_fixed) ? $sidebar_first_width : $grid_width; // Sidebar width or 100% (if fluid) 271 } 272 elseif ($vars['block']->region == 'sidebar_last') { 273 $width = ($grid_fixed) ? $sidebar_last_width : $grid_width; // Sidebar width or 100% (if fluid) 274 } 275 else { 276 // Default block width = region width divided by total blocks, adding any extra width to last block 277 $region_width = ($grid_fixed) ? $regions[$vars['block']->region]['width'] : $grid_width; // fluid grid regions = 100% 278 $width_adjust = (($region_count == $total_blocks) && ($region_width % $total_blocks)) ? $region_width % $total_blocks : 0; 279 $width = ($total_blocks) ? floor($region_width / $total_blocks) + $width_adjust : 0; 280 } 281 $vars['skinr'] = (isset($vars['skinr'])) ? $vars['skinr'] . ' ' . $grid_name . $width : $grid_name . $width; 282 } 283 284 if (isset($vars['skinr']) && (strpos($vars['skinr'], 'superfish') !== false) && 285 ($vars['block']->module == 'menu' || ($vars['block']->module == 'user' && $vars['block']->delta == 1))) { 286 $superfish = ' sf-menu'; 287 $superfish .= (strpos($vars['skinr'], 'superfish-vertical')) ? ' sf-vertical' : ''; 288 $vars['block']->content = preg_replace('/<ul class="menu/i', '<ul class="menu' . $superfish, $vars['block']->content, 1); 289 } 290 291 // Add block edit links for admins 292 if (user_access('administer blocks', $user) && theme_get_setting('block_config_link')) { 293 $vars['edit_links'] = '<div class="fusion-edit">'. implode(' ', fusion_core_edit_links($vars['block'])) .'</div>'; 294 } 295 } 296 297 298 /** 299 * Views preprocessing 300 * Add view type class (e.g., node, teaser, list, table) 301 */ 302 function fusion_core_preprocess_views_view(&$vars) { 303 $vars['css_name'] = $vars['css_name'] .' view-style-'. views_css_safe(strtolower($vars['view']->type)); 304 } 305 306 307 /** 308 * Search result preprocessing 309 */ 310 function fusion_core_preprocess_search_result(&$vars) { 311 static $search_zebra = 'even'; 312 313 $search_zebra = ($search_zebra == 'even') ? 'odd' : 'even'; 314 $vars['search_zebra'] = $search_zebra; 315 $result = $vars['result']; 316 $vars['url'] = check_url($result['link']); 317 $vars['title'] = check_plain($result['title']); 318 319 // Check for snippet existence. User search does not include snippets. 320 $vars['snippet'] = ''; 321 if (isset($result['snippet']) && theme_get_setting('search_snippet')) { 322 $vars['snippet'] = $result['snippet']; 323 } 324 325 $info = array(); 326 if (!empty($result['type']) && theme_get_setting('search_info_type')) { 327 $info['type'] = check_plain($result['type']); 328 } 329 if (!empty($result['user']) && theme_get_setting('search_info_user')) { 330 $info['user'] = $result['user']; 331 } 332 if (!empty($result['date']) && theme_get_setting('search_info_date')) { 333 $info['date'] = format_date($result['date'], 'small'); 334 } 335 if (isset($result['extra']) && is_array($result['extra'])) { 336 // $info = array_merge($info, $result['extra']); Drupal bug? [extra] array not keyed with 'comment' & 'upload' 337 if (!empty($result['extra'][0]) && theme_get_setting('search_info_comment')) { 338 $info['comment'] = $result['extra'][0]; 339 } 340 if (!empty($result['extra'][1]) && theme_get_setting('search_info_upload')) { 341 $info['upload'] = $result['extra'][1]; 342 } 343 } 344 345 // Provide separated and grouped meta information. 346 $vars['info_split'] = $info; 347 $vars['info'] = implode(' - ', $info); 348 349 // Provide alternate search result template. 350 $vars['template_files'][] = 'search-result-'. $vars['type']; 351 } 352 353 354 /** 355 * Username override 356 * Hides or shows username '(not verified)' text 357 */ 358 function fusion_core_username($object) { 359 if ((!$object->uid) && $object->name) { 360 $output = (!empty($object->homepage)) ? l($object->name, $object->homepage, array('attributes' => array('rel' => 'nofollow'))) : check_plain($object->name); 361 $output .= (theme_get_setting('user_notverified_display') == 1) ? t(' (not verified)') : ''; 362 } 363 else { 364 $output = theme_username($object); 365 } 366 return $output; 367 } 368 369 370 /** 371 * File element override 372 * Sets form file input max width 373 */ 374 function fusion_core_file($element) { 375 $element['#size'] = ($element['#size'] > 40) ? 40 : $element['#size']; 376 return theme_file($element); 377 } 378 379 380 /** 381 * Custom theme functions 382 */ 383 function fusion_core_theme() { 384 return array( 385 'grid_row' => array( 386 'arguments' => array('element' => NULL, 'name' => NULL, 'class' => NULL, 'width' => NULL), 387 ), 388 'grid_block' => array( 389 'arguments' => array('element' => NULL, 'name' => NULL), 390 ), 391 ); 392 } 393 394 395 /** 396 * Row & block theme functions 397 * Adds divs to elements in page.tpl.php 398 */ 399 function fusion_core_grid_row($element, $name, $class='', $width='') { 400 $output = ''; 401 if ($element) { 402 if ($class == 'full-width') { 403 $output .= '<div id="' . $name . '-wrapper" class="' . $name . '-wrapper full-width">' . "\n"; 404 $output .= '<div id="' . $name . '" class="' . $name . ' row ' . $width . '">' . "\n"; 405 } 406 else { 407 $output .= '<div id="' . $name . '" class="' . $name . ' row ' . $class . ' ' . $width . '">' . "\n"; 408 } 409 if($name == 'sidebar-first-top' ||$name == 'sidebar-first' ) { 410 $output .= '<div id="' . $name . '-inner" class="' . $name . '-inner inner">' . "\n"; 411 } 412 else { 413 $output .= '<div id="' . $name . '-inner" class="' . $name . '-inner inner clearfix">' . "\n"; 414 } 415 $output .= $element; 416 $output .= '</div><!-- /' . $name . '-inner -->' . "\n"; 417 $output .= '</div><!-- /' . $name . ' -->' . "\n"; 418 $output .= ($class == 'full-width') ? '</div><!-- /' . $name . '-wrapper -->' . "\n" : ''; 419 } 420 return $output; 421 } 422 423 424 function fusion_core_grid_block($element, $name) { 425 $output = ''; 426 if ($element) { 427 $output .= '<div id="' . $name . '" class="' . $name . ' block">' . "\n"; 428 $output .= '<div id="' . $name . '-inner" class="' . $name . '-inner inner clearfix">' . "\n"; 429 $output .= $element; 430 $output .= '</div><!-- /' . $name . '-inner -->' . "\n"; 431 $output .= '</div><!-- /' . $name . ' -->' . "\n"; 432 } 433 return $output; 434 } 435 436 437 /** 438 * Block region grid info function 439 * Defaults match grid_row widths set in preprocess_page() 440 */ 441 function fusion_core_set_regions($grid_width, $sidebar_first_width, $sidebar_last_width) { 442 $sidebar_total = $sidebar_first_width + $sidebar_last_width; 443 $regions = array( 444 'header_top' => array('width' => $grid_width, 'total' => count(block_list('header_top')), 'count' => 0), 445 'header' => array('width' => $grid_width, 'total' => count(block_list('header')), 'count' => 0), 446 'preface_top' => array('width' => $grid_width, 'total' => count(block_list('preface_top')), 'count' => 0), 447 'preface_bottom' => array('width' => $grid_width - $sidebar_first_width, 'total' => count(block_list('preface_bottom')), 'count' => 0), 448 'sidebar_first_top' => array('width' => $sidebar_first_top_width, 'total' => count(block_list('sidebar_first_top')), 'count' => 0), 449 'sidebar_first' => array('width' => $sidebar_first_width, 'total' => count(block_list('sidebar_first')), 'count' => 0), 450 'content_top' => array('width' => $grid_width - $sidebar_total, 'total' => count(block_list('content_top')), 'count' => 0), 451 'content' => array('width' => $grid_width - $sidebar_total, 'total' => count(block_list('content')), 'count' => 0), 452 'node_top' => array('width' => $grid_width - $sidebar_total, 'total' => count(block_list('node_top')), 'count' => 0), 453 'node_bottom' => array('width' => $grid_width - $sidebar_total, 'total' => count(block_list('node_bottom')), 'count' => 0), 454 'content_bottom' => array('width' => $grid_width - $sidebar_total, 'total' => count(block_list('content_bottom')), 'count' => 0), 455 'sidebar_last' => array('width' => $sidebar_last_width, 'total' => count(block_list('sidebar_last')), 'count' => 0), 456 'postscript_top' => array('width' => $grid_width - $sidebar_first_width, 'total' => count(block_list('postscript_top')), 'count' => 0), 457 'postscript_bottom' => array('width' => $grid_width, 'total' => count(block_list('postscript_bottom')), 'count' => 0), 458 'footer' => array('width' => $grid_width, 'total' => count(block_list('footer')), 'count' => 0) 459 ); 460 return $regions; 461 } 462 463 464 /** 465 * Block edit links function 466 * Create block edit links for admins 467 */ 468 function fusion_core_edit_links($block) { 469 $path = 'admin/build/block/configure/' . $block->module . '/' . $block->delta; 470 $return = drupal_get_destination(); 471 // Use 'edit' for custom blocks, 'configure' for others 472 if ($block->module == 'block') { 473 $text = t('edit block'); 474 $block_info = array('@region' => str_replace('_', ' ', $block->region)); 475 $attributes = array('title' => t('edit the content of this Custom block (in @region)', $block_info), 'class' => 'fusion-block-edit'); 476 } 477 else { 478 $text = t('configure block'); 479 $block_info = array('@type' => ucwords($block->module), '@region' => str_replace('_', ' ', $block->region)); 480 $attributes = array('title' => t('configure this @type block (in @region)', $block_info), 'class' => 'fusion-block-config'); 481 } 482 $edit_links[] = l($text, $path, array('attributes' => $attributes, 'query' => $return)); 483 // Add extra 'edit menu' for menu blocks 484 if (user_access('administer menu') && ($block->module == 'menu' || ($block->module == 'user' && $block->delta == 1))) { 485 $text = t('edit menu'); 486 $path = 'admin/build/menu-customize/' . (($block->module == 'user') ? 'navigation' : $block->delta); 487 $attributes = array('title' => t('edit the menu of this @type block (in @region)', $block_info), 'class' => 'fusion-edit-menu'); 488 $edit_links[] = l($text, $path, array('attributes' => $attributes, 'query' => $return)); 489 } 490 return $edit_links; 491 } 492 493 494 /** 495 * CSS count function 496 * Counts the total number of CSS files in $vars['css'] 497 */ 498 function fusion_core_css_count($array) { 499 $count = 0; 500 foreach ($array as $item) { 501 $count = (is_array($item)) ? $count + fusion_core_css_count($item) : $count + 1; 502 } 503 return $count; 504 } 505 506 507 /** 508 * Theme paths function 509 * Retrieves current theme path and its parent 510 * theme paths, in parent-to-child order. 511 */ 512 function fusion_core_theme_paths($theme) { 513 $all_parents = array(); 514 $themes = list_themes(); 515 $all_parents[$theme] = drupal_get_path('theme', $theme); 516 $base_theme = $themes[$theme]->info['base theme']; 517 while ($base_theme) { 518 $all_parents[$base_theme] = drupal_get_path('theme', $base_theme); 519 $base_theme = (isset($themes[$base_theme]->info['base theme'])) ? $themes[$base_theme]->info['base theme'] : ''; 520 } 521 return array_reverse($all_parents); 522 } 523 524 525 /** 526 * Theme settings link function 527 * Creates link with prefix and suffix text 528 * ($options info: http://api.drupal.org/api/function/l) 529 */ 530 function fusion_core_themesettings_link($prefix, $suffix, $text, $path, $options) { 531 return $prefix . (($text) ? l($text, $path, $options) : '') . $suffix; 532 } 533
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |