| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: blog_user.inc,v 1.1.2.2 2009/10/13 18:12:20 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_user_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 'title' => t('User blog'), 17 'admin title' => t('User blog'), 18 'admin description' => t('When enabled, this overrides the default Drupal behavior for displaying user blogs at <em>blog/%user</em>. If no variant is selected, the default Drupal user blog will be used.'), 19 'admin path' => 'blog/%user', 20 21 // Callback to add items to the page managertask administration form: 22 'task admin' => 'page_manager_blog_user_task_admin', 23 24 'hook menu alter' => 'page_manager_blog_user_menu_alter', 25 26 // This is task uses 'context' handlers and must implement these to give the 27 // handler data it needs. 28 'handler type' => 'context', // handler type -- misnamed 29 'get arguments' => 'page_manager_blog_user_get_arguments', 30 'get context placeholders' => 'page_manager_blog_user_get_contexts', 31 32 // Allow this to be enabled or disabled: 33 'disabled' => variable_get('page_manager_blog_user_disabled', TRUE), 34 'enable callback' => 'page_manager_blog_user_enable', 35 ); 36 } 37 38 /** 39 * Callback defined by page_manager_blog_user_page_manager_tasks(). 40 * 41 * Alter the user view input so that user view comes to us rather than the 42 * normal user view process. 43 */ 44 function page_manager_blog_user_menu_alter(&$items, $task) { 45 if (variable_get('page_manager_blog_user_disabled', TRUE)) { 46 return; 47 } 48 49 // Override the user view handler for our purpose. 50 if ($items['blog/%user_uid_optional']['page callback'] == 'blog_page_user' || variable_get('page_manager_override_anyway', FALSE)) { 51 $items['blog/%user_uid_optional']['page callback'] = 'page_manager_blog_user'; 52 $items['blog/%user_uid_optional']['file path'] = $task['path']; 53 $items['blog/%user_uid_optional']['file'] = $task['file']; 54 } 55 else { 56 // automatically disable this task if it cannot be enabled. 57 variable_set('page_manager_blog_user_disabled', TRUE); 58 if (!empty($GLOBALS['page_manager_enabling_blog_user'])) { 59 drupal_set_message(t('Page manager module is unable to enable blog/%user because some other module already has overridden with %callback.', array('%callback' => $items['blog/%user']['page callback'])), 'error'); 60 } 61 } 62 } 63 64 /** 65 * Entry point for our overridden user view. 66 * 67 * This function asks its assigned handlers who, if anyone, would like 68 * to run with it. If no one does, it passes through to Drupal core's 69 * user view, which is user_page_view(). 70 */ 71 function page_manager_blog_user($account) { 72 // Load my task plugin: 73 $task = page_manager_get_task('blog_user'); 74 75 // Load the account into a context. 76 ctools_include('context'); 77 ctools_include('context-task-handler'); 78 $contexts = ctools_context_handler_get_task_contexts($task, '', array($account)); 79 80 $output = ctools_context_handler_render($task, '', $contexts, array($account->uid)); 81 if ($output !== FALSE) { 82 return $output; 83 } 84 85 module_load_include('inc', 'blog', 'blog.pages'); 86 $function = 'blog_page_user'; 87 foreach (module_implements('page_manager_override') as $module) { 88 $call = $module . '_page_manager_override'; 89 if (($rc = $call('blog_user')) && function_exists($rc)) { 90 $function = $rc; 91 break; 92 } 93 } 94 95 // Otherwise, fall back. 96 return $function($account); 97 } 98 99 /** 100 * Callback to get arguments provided by this task handler. 101 * 102 * Since this is the node view and there is no UI on the arguments, we 103 * create dummy arguments that contain the needed data. 104 */ 105 function page_manager_blog_user_get_arguments($task, $subtask_id) { 106 return array( 107 array( 108 'keyword' => 'user', 109 'identifier' => t('User being viewed'), 110 'id' => 1, 111 'name' => 'uid', 112 'settings' => array(), 113 ), 114 ); 115 } 116 117 /** 118 * Callback to get context placeholders provided by this handler. 119 */ 120 function page_manager_blog_user_get_contexts($task, $subtask_id) { 121 return ctools_context_get_placeholders_from_argument(page_manager_blog_user_get_arguments($task, $subtask_id)); 122 } 123 124 /** 125 * Callback to enable/disable the page from the UI. 126 */ 127 function page_manager_blog_user_enable($cache, $status) { 128 variable_set('page_manager_blog_user_disabled', $status); 129 130 // Set a global flag so that the menu routine knows it needs 131 // to set a message if enabling cannot be done. 132 if (!$status) { 133 $GLOBALS['page_manager_enabling_blog_user'] = TRUE; 134 } 135 }
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 |