| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: blog.inc,v 1.1.2.2 2010/01/29 21:21:31 merlinofchaos Exp $ 3 4 /** 5 * Specialized implementation of hook_page_manager_task_tasks(). See api-task.html for 6 * more information. 7 */ 8 function page_manager_blog_page_manager_tasks() { 9 if (!module_exists('blog')) { 10 return; 11 } 12 13 return array( 14 // This is a 'page' task and will fall under the page admin UI 15 'task type' => 'page', 16 17 'title' => t('All blogs'), 18 'admin title' => t('All blogs'), 19 'admin description' => t('When enabled, this overrides the default Drupal behavior for the all blogs at <em>/blog</em>. If no variant is selected, the default Drupal most recent blog posts will be shown.'), 20 'admin path' => 'blog', 21 22 // Menu hooks so that we can alter the node/%node menu entry to point to us. 23 'hook menu alter' => 'page_manager_blog_menu_alter', 24 25 // This is task uses 'context' handlers and must implement these to give the 26 // handler data it needs. 27 'handler type' => 'context', 28 29 // Allow this to be enabled or disabled: 30 'disabled' => variable_get('page_manager_blog_disabled', TRUE), 31 'enable callback' => 'page_manager_blog_enable', 32 ); 33 } 34 35 /** 36 * Callback defined by page_manager_blog_page_manager_tasks(). 37 * 38 * Alter the node edit input so that node edit comes to us rather than the 39 * normal node edit process. 40 */ 41 function page_manager_blog_menu_alter(&$items, $task) { 42 if (variable_get('page_manager_blog_disabled', TRUE)) { 43 return; 44 } 45 46 $callback = $items['blog']['page callback']; 47 // Override the node edit handler for our purpose. 48 if ($callback == 'blog_page_last' || variable_get('page_manager_override_anyway', FALSE)) { 49 $items['blog']['page callback'] = 'page_manager_blog'; 50 $items['blog']['file path'] = $task['path']; 51 $items['blog']['file'] = $task['file']; 52 } 53 else { 54 variable_set('page_manager_blog_disabled', TRUE); 55 if (!empty($GLOBALS['page_manager_enabling_blog'])) { 56 drupal_set_message(t('Page manager module is unable to enable blog because some other module already has overridden with %callback.', array('%callback' => $callback)), 'warning'); 57 } 58 return; 59 } 60 61 } 62 63 /** 64 * Entry point for our overridden node edit. 65 * 66 * This function asks its assigned handlers who, if anyone, would like 67 * to run with it. If no one does, it passes through to Drupal core's 68 * node edit, which is node_page_edit(). 69 */ 70 function page_manager_blog() { 71 // Load my task plugin 72 $task = page_manager_get_task('blog'); 73 74 ctools_include('context'); 75 ctools_include('context-task-handler'); 76 $output = ctools_context_handler_render($task, '', array(), array()); 77 if ($output !== FALSE) { 78 return $output; 79 } 80 81 module_load_include('inc', 'blog', 'blog.pages'); 82 $function = 'blog_page_last'; 83 foreach (module_implements('page_manager_override') as $module) { 84 $call = $module . '_page_manager_override'; 85 if (($rc = $call('blog')) && function_exists($rc)) { 86 $function = $rc; 87 break; 88 } 89 } 90 91 // Otherwise, fall back. 92 return $function(); 93 } 94 95 /** 96 * Callback to enable/disable the page from the UI. 97 */ 98 function page_manager_blog_enable($cache, $status) { 99 variable_set('page_manager_blog_disabled', $status); 100 // Set a global flag so that the menu routine knows it needs 101 // to set a message if enabling cannot be done. 102 if (!$status) { 103 $GLOBALS['page_manager_enabling_blog'] = TRUE; 104 } 105 }
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 |