public function views_plugin_display::init in Views (for Drupal 7) 7.3
Same name and namespace in other branches
- 6.3 plugins/views_plugin_display.inc \views_plugin_display::init()
- 6.2 plugins/views_plugin_display.inc \views_plugin_display::init()
1 call to views_plugin_display::init()
- views_plugin_display_feed::init in plugins/views_plugin_display_feed.inc
1 method overrides views_plugin_display::init()
- views_plugin_display_feed::init in plugins/views_plugin_display_feed.inc
File
- plugins/views_plugin_display.inc, line 51
- Definition of views_plugin_display.
Class
- views_plugin_display
- The default display plugin handler. Display plugins handle options and
basic mechanisms for different output methods.
Code
public function init(&$view, &$display, $options = NULL) {
$this->view =& $view;
$this->display =& $display;
$this->extender = array();
$extenders = views_get_enabled_display_extenders();
if (!empty($extenders) && class_exists('views_plugin_display_extender')) {
foreach ($extenders as $extender) {
$plugin = views_get_plugin('display_extender', $extender);
if ($plugin) {
$plugin
->init($this->view, $this);
$this->extender[$extender] = $plugin;
}
else {
vpr('Invalid display extender @extender', array(
'@extender' => $extender,
));
}
}
}
$changed = FALSE;
if (!isset($options) && isset($display->display_options)) {
$options = $display->display_options;
}
if ($this
->is_default_display() && isset($options['defaults'])) {
unset($options['defaults']);
}
static $unpack_options = array();
if (empty($view->editing)) {
$cid = 'unpack_options:' . md5(serialize(array(
$this->options,
$options,
)));
if (empty($unpack_options[$cid])) {
$cache = views_cache_get($cid, TRUE);
if (!empty($cache->data)) {
$this->options = $cache->data;
}
else {
$this
->unpack_options($this->options, $options);
views_cache_set($cid, $this->options, TRUE);
}
$unpack_options[$cid] = $this->options;
}
else {
$this->options = $unpack_options[$cid];
}
}
else {
$this
->unpack_options($this->options, $options);
}
$items_per_page = $this
->get_option('items_per_page');
$offset = $this
->get_option('offset');
$use_pager = $this
->get_option('use_pager');
$pager = $this
->get_option('pager');
if (!empty($items_per_page) && $items_per_page != 10 || !empty($offset) || !empty($use_pager) || !empty($view->api_version) && $view->api_version == 2) {
if ($use_pager) {
$type = 'full';
}
else {
$type = $items_per_page ? 'some' : 'none';
}
$pager = array(
'type' => $type,
'options' => array(
'offset' => intval($offset),
),
);
if ($items_per_page) {
$pager['options']['items_per_page'] = $items_per_page;
}
if ($id = $this
->get_option('pager_element')) {
$pager['options']['id'] = $id;
}
$this
->set_option('items_per_page', NULL);
$this
->set_option('offset', NULL);
$this
->set_option('use_pager', NULL);
$this
->set_option('pager', $pager);
$changed = TRUE;
}
foreach (array(
'header',
'footer',
'empty',
) as $area) {
$converted = FALSE;
if (isset($this->options[$area]) && !is_array($this->options[$area])) {
if (!empty($this->options[$area])) {
$content = $this
->get_option($area);
if (!empty($content) && !is_array($content)) {
$format = $this
->get_option($area . '_format');
$options = array(
'id' => 'area',
'table' => 'views',
'field' => 'area',
'label' => '',
'relationship' => 'none',
'group_type' => 'group',
'content' => $content,
'format' => !empty($format) ? $format : filter_default_format(),
);
if ($area != 'empty' && ($empty = $this
->get_option($area . '_empty'))) {
$options['empty'] = $empty;
}
$this
->set_option($area, array(
'text' => $options,
));
$converted = TRUE;
$changed = TRUE;
}
}
if (!$converted) {
$this
->set_option($area, array());
}
}
}
$distinct = $this
->get_option('distinct');
if (!empty($distinct)) {
$query_settings = $this
->get_option('query');
$query_settings['options']['distinct'] = $distinct;
$this
->set_option('query', $query_settings);
$this
->set_option('distinct', NULL);
$changed = TRUE;
}
$query_options = $this
->get_option('query');
if (isset($query_options['options']['field_language'])) {
$this
->set_option('field_language', $query_options['options']['field_language']);
unset($query_options['options']['field_language']);
$changed = TRUE;
}
if (isset($query_options['options']['field_language_add_to_query'])) {
$this
->set_option('field_language_add_to_query', $query_options['options']['field_language_add_to_query']);
unset($query_options['options']['field_language_add_to_query']);
$changed = TRUE;
}
$this
->set_option('query', $query_options);
$filter_groups = $this
->get_option('filter_groups');
if (isset($filter_groups['groups'][0])) {
$filter_groups['groups'] = views_array_key_plus($filter_groups['groups']);
$this
->set_option('filter_groups', $filter_groups);
$filters = $this
->get_option('filters');
foreach ($filters as &$filter) {
if (isset($filter['group'])) {
$filter['group']++;
}
else {
$filter['group'] = 1;
}
}
$this
->set_option('filters', $filters);
$changed = TRUE;
}
if (!$this
->is_default_display() && !$this->options['defaults']['filters'] && $this->options['defaults']['filter_groups']) {
$this->options['defaults']['filter_groups'] = FALSE;
$this->display->display_options['defaults']['filter_groups'] = $this->options['defaults']['filter_groups'];
$this->options['filter_groups'] = $this->view->display['default']->handler->options['filter_groups'];
$this->display->display_options['filter_groups'] = $this->options['filter_groups'];
$changed = TRUE;
}
if ($changed) {
$this->view->changed = TRUE;
}
}