summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.15/sites/all/modules/page_title/views/plugins/page_title_plugin_display_page_with_page_title.inc
blob: de4d85b5352462f70599af561665cdca8fd157f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php

/**
 * @file
 * Custom Views display handler. Extends the Page display by adding our own page title option to it.
 */

class page_title_plugin_display_page_with_page_title extends views_plugin_display_page {
  function option_definition() {
    $options = parent::option_definition();
    $options['page_title_pattern'] = array('default' => '');
    return $options;
  }

  function options_summary(&$categories, &$options) {
    parent::options_summary($categories, $options);

    // Lookup the current title and strip any tags out.
    $title = strip_tags($this->get_option('page_title_pattern'));

    if (empty($title)) {
      $title = t('None');
    }
    elseif (drupal_strlen($title) > 16) {
      $title = drupal_substr($title, 0, 16) . '...';
    }

    $options['page_title_pattern'] = array(
      'category' => 'page',
      'title' => t('Page Title Pattern'),
      'value' => $title,
    );
  }

  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);

    if ($form_state['section'] == 'page_title_pattern') {
      $form['#title'] = t('The <em>Page Title Pattern</em> of this view');

      $form['page_title_pattern'] = array(
        '#title' => t('Page Title Pattern'),
        '#type' => 'textfield',
        '#description' => t('Optionally use this field to define a Page Title Pattern (not the Page Title). You may use the Tokens listed below'),
        '#default_value' => $this->get_option('page_title_pattern'),
      );

      // Add the token help to a collapsed fieldset at the end of the configuration page.
      $form['token_help'] = array(
        '#type' => 'fieldset',
        '#title' => t('Available Tokens List'),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
      );
      $form['token_help']['content'] = array(
        '#theme' => 'token_tree',
        '#token_types' => array(),
      );
    }
  }


  function options_submit(&$form, &$form_state) {
    parent::options_submit($form, $form_state);

    if ($form_state['section'] == 'page_title_pattern') {
      $this->set_option('page_title_pattern', $form_state['values']['page_title_pattern']);
    }
  }
}