function views_plugin_display::init in Views (for Drupal 7) 6.3
Same name and namespace in other branches
- 6.2 plugins/views_plugin_display.inc \views_plugin_display::init()
- 7.3 plugins/views_plugin_display.inc \views_plugin_display::init()
File
- plugins/views_plugin_display.inc, line 41
- Contains the base display plugin.
Class
- views_plugin_display
- The default display plugin handler. Display plugins handle options and
basic mechanisms for different output methods.
Code
function init(&$view, &$display, $options = NULL) {
$this->view =& $view;
$this->display =& $display;
if (!isset($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);
}
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 : variable_get('filter_default_format', 1),
);
if ($area != 'empty' && ($empty = $this
->get_option($area . '_empty'))) {
$options['empty'] = $empty;
}
$this
->set_option($area, array(
'text' => $options,
));
$converted = 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);
}
$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) {
$filter['group']++;
}
$this
->set_option('filters', $filters);
}
}