t('Path'), 'weight' => -10, 'single' => TRUE, 'content_types' => 'panels_admin_content_types_path', 'render callback' => 'panels_content_path', 'editor render callback' => 'panels_admin_content_path', 'add callback' => 'panels_admin_edit_path', 'edit callback' => 'panels_admin_edit_path', 'title callback' => 'panels_admin_title_path', 'no override title' => TRUE, ); return $items; } /** * Output function for the 'custom' content type. Outputs a custom * based on the module and delta supplied in the configuration. */ function panels_content_path($conf) { $block = new stdClass(); $block->module = 'path'; $block->subject = filter_xss_admin($conf['title']); // cribbed from menu_execute_active_handler() $menu = menu_get_menu(); // Determine the menu item containing the callback. $path = $conf['path']; while ($path && !isset($menu['callbacks'][$path])) { $path = substr($path, 0, strrpos($path, '/')); } if ($path === '' || !isset($menu['callbacks'][$path])) { return; } if (!function_exists($menu['callbacks'][$path]['callback'])) { return; } if (!_menu_item_is_accessible(menu_get_active_item())) { return; } // We found one, and are allowed to execute it. $arguments = isset($menu['callbacks'][$path]['callback arguments']) ? $menu['callbacks'][$path]['callback arguments'] : array(); $arg = substr($conf['path'], strlen($path) + 1); if (strlen($arg)) { $arguments = array_merge($arguments, explode('/', $arg)); } $block->content = call_user_func_array($menu['callbacks'][$path]['callback'], $arguments); return $block; } /** * Render callback for when the custom content is in the editor so that people * can have a preview on the spot. * * @param panels_display $display * @param stdClass $pane * @return stdClass $block */ function panels_admin_content_path($display, $pane) { $block = new stdClass(); $block->title = filter_xss_admin($pane->configuration['title']); return $block; } /** * Return all content types available. */ function panels_admin_content_types_path() { return array( 'path' => array( 'title' => t('Path content'), 'icon' => 'icon_block_path.png', 'path' => panels_get_path('content_types/path'), 'description' => t('BLAH BLAH.'), 'category' => array(t('Custom'), -10), ), ); } /** * Returns an edit form for the custom type. */ function panels_admin_edit_path($id, $parents, $conf = NULL) { if (!is_array($conf)) { $conf = array('title' => '', 'path' => ''); } $form['title'] = array( '#type' => 'textfield', '#default_value' => $conf['title'], '#title' => t('Title'), ); $form['path'] = array( '#title' => t('Path'), '#type' => 'textfield', '#default_value' => $conf['path'], '#description' => 'Enter a Drupal path, including arguments. Do not start or end with /.', ); return $form; } /** * Returns the administrative title for a type. */ function panels_admin_title_path($conf) { $output = t('Path'); if ($conf['title']) { $output .= " (" . filter_xss_admin($conf['title']) . ")"; } return $output; }