4 * Specialized implementation of hook_page_manager_task_tasks(). See api-task.html for
7 function page_manager_blog_page_manager_tasks() {
8 if (!module_exists('blog')) {
13 // This is a 'page' task and will fall under the page admin UI
14 'task type' => 'page',
16 'title' => t('All blogs'),
17 'admin title' => t('All blogs'),
18 '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.'),
19 'admin path' => 'blog',
21 // Menu hooks so that we can alter the node/%node menu entry to point to us.
22 'hook menu alter' => 'page_manager_blog_menu_alter',
24 // This is task uses 'context' handlers and must implement these to give the
25 // handler data it needs.
26 'handler type' => 'context',
28 // Allow this to be enabled or disabled:
29 'disabled' => variable_get('page_manager_blog_disabled', TRUE),
30 'enable callback' => 'page_manager_blog_enable',
31 'access callback' => 'page_manager_blog_access_check',
36 * Callback defined by page_manager_blog_page_manager_tasks().
38 * Alter the node edit input so that node edit comes to us rather than the
39 * normal node edit process.
41 function page_manager_blog_menu_alter(&$items, $task) {
42 if (variable_get('page_manager_blog_disabled', TRUE)) {
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'];
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');
64 * Entry point for our overridden node edit.
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().
70 function page_manager_blog() {
71 // Load my task plugin
72 $task = page_manager_get_task('blog');
74 ctools_include('context');
75 ctools_include('context-task-handler');
76 $output = ctools_context_handler_render($task, '', array(), array());
77 if ($output !== FALSE) {
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)) {
91 // Otherwise, fall back.
96 * Callback to enable/disable the page from the UI.
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.
103 $GLOBALS['page_manager_enabling_blog'] = TRUE;
108 * Callback to determine if a page is accessible.
115 * The contexts loaded for the task.
117 * TRUE if the current user can access the page.
119 function page_manager_blog_access_check($task, $subtask_id, $contexts) {
120 return user_access('access content');