diff --git includes/plugins.inc includes/plugins.inc index 4a80885..e66c60d 100644 --- includes/plugins.inc +++ includes/plugins.inc @@ -274,6 +274,19 @@ function views_views_plugins() { 'help topic' => 'cache-time', ), ), + 'breadcrumb' => array( + 'parent' => array( + 'no ui' => TRUE, + 'handler' => 'views_plugin_breadcrumb', + 'parent' => '', + ), + 'default' => array( + 'title' => t('Default'), + 'help' => t('Default breadcrumb system.'), + 'handler' => 'views_plugin_breadcrumb_default', + 'help topic' => 'breadcrumb-default', + ), + ), 'exposed_form' => array( 'parent' => array( 'no ui' => TRUE, @@ -449,11 +462,11 @@ function views_discover_plugins() { class views_plugin extends views_object { /** * The top object of a view. - * + * * @var view */ var $view = NULL; - + /** * The current used display plugin. * diff --git includes/view.inc includes/view.inc index 2b38dab..3f551a6 100644 --- includes/view.inc +++ includes/view.inc @@ -71,10 +71,7 @@ class view extends views_db_object { var $style_plugin; /** - * The current - - /** - * Constructor + * The current constructor */ function __construct() { parent::init(); @@ -1250,30 +1247,13 @@ class view extends views_db_object { * If true, use drupal_set_breadcrumb() to install the breadcrumb. */ function get_breadcrumb($set = FALSE) { - // Now that we've built the view, extract the breadcrumb. - $base = TRUE; - $breadcrumb = array(); + $breadcrumb_plugin = $this->display_handler->get_plugin('breadcrumb'); - if (!empty($this->build_info['breadcrumb'])) { - foreach ($this->build_info['breadcrumb'] as $path => $title) { - // Check to see if the frontpage is in the breadcrumb trail; if it - // is, we'll remove that from the actual breadcrumb later. - if ($path == variable_get('site_frontpage', 'node')) { - $base = FALSE; - $title = t('Home'); - } - if ($title) { - $breadcrumb[] = l($title, $path, array('html' => true)); - } - } - - if ($set) { - if ($base) { - $breadcrumb = array_merge(drupal_get_breadcrumb(), $breadcrumb); - } - drupal_set_breadcrumb($breadcrumb); - } + $breadcrumb = array(); + if ($breadcrumb_plugin) { + $breadcrumb = $breadcrumb_plugin->get_breadcrumb($set); } + return $breadcrumb; } diff --git plugins/views_plugin_breadcrumb.inc plugins/views_plugin_breadcrumb.inc new file mode 100644 index 0000000..7fcb005 --- /dev/null +++ plugins/views_plugin_breadcrumb.inc @@ -0,0 +1,30 @@ +view = &$view; + $this->display = &$display; + + $this->unpack_options($this->options, $options); + } + + /** + * Return a string to display as the clickable title for the + * access control. + */ + function summary_title() { + return t('Unknown'); + } + + function get_breadcrumb($set = FALSE) { } + +} diff --git plugins/views_plugin_breadcrumb_default.inc plugins/views_plugin_breadcrumb_default.inc new file mode 100644 index 0000000..438555c --- /dev/null +++ plugins/views_plugin_breadcrumb_default.inc @@ -0,0 +1,45 @@ +view->build_info['breadcrumb'])) { + foreach ($this->view->build_info['breadcrumb'] as $path => $title) { + // Check to see if the frontpage is in the breadcrumb trail; if it + // is, we'll remove that from the actual breadcrumb later. + if ($path == variable_get('site_frontpage', 'node')) { + $base = FALSE; + $title = t('Home'); + } + if ($title) { + $breadcrumb[] = l($title, $path, array('html' => TRUE)); + } + } + + if ($set) { + if ($base) { + $breadcrumb = array_merge(drupal_get_breadcrumb(), $breadcrumb); + } + drupal_set_breadcrumb($breadcrumb); + } + } + return $breadcrumb; + } +} diff --git plugins/views_plugin_display_page.inc plugins/views_plugin_display_page.inc index adac656..e5bf46a 100644 --- plugins/views_plugin_display_page.inc +++ plugins/views_plugin_display_page.inc @@ -40,7 +40,12 @@ class views_plugin_display_page extends views_plugin_display { 'name' => array('default' => 'navigation'), ), ); - + $options['breadcrumb'] = array( + 'contains' => array( + 'type' => array('default' => 'default', 'export' => 'export_plugin', 'unpack_translatable' => 'unpack_plugin'), + 'options' => array('default' => array(), 'export' => FALSE), + ), + ); return $options; } @@ -278,6 +283,24 @@ class views_plugin_display_page extends views_plugin_display { if ($menu['type'] == 'default tab') { $options['menu']['links']['tab_options'] = t('Change settings for the parent menu'); } + + $breadcrumb_plugin = $this->get_plugin('breadcrumb'); + if (!$breadcrumb_plugin) { + // use default breadcrumb plugin. + $breadcrumb_plugin = views_get_plugin('breadcrumb', 'default'); + } + + $breadcrumb_str = $breadcrumb_plugin->summary_title(); + + $options['breadcrumb'] = array( + 'category' => 'page', + 'title' => t('Breadcrumb'), + 'value' => $breadcrumb_str, + ); + + if (!empty($breadcrumb_plugin->definition['uses options'])) { + $options['breadcrumb']['links']['breadcrumb_options'] = t('Change settings for breadcrumb'); + } } /** @@ -295,9 +318,9 @@ class views_plugin_display_page extends views_plugin_display { '#type' => 'textfield', '#description' => t('This view will be displayed by visiting this path on your site. You may use "%" in your URL to represent values that will be used for arguments: For example, "node/%/feed".'), '#default_value' => $this->get_option('path'), - '#field_prefix' => '' . url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='), - '#field_suffix' => '', - '#attributes' => array('dir'=>'ltr'), + '#field_prefix' => '' . url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='), + '#field_suffix' => '', + '#attributes' => array('dir'=>'ltr'), ); break; case 'menu': @@ -458,6 +481,48 @@ class views_plugin_display_page extends views_plugin_display { '#dependency' => array('radio:tab_options[type]' => array('tab')), ); break; + case 'breadcrumb': + $form['#title'] .= t('Breadcrumb'); + $form['breadcrumb'] = array( + '#prefix' => '