updated contrib modules
This commit is contained in:
@@ -12,10 +12,12 @@
|
||||
*/
|
||||
class views_ui extends ctools_export_ui {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function init($plugin) {
|
||||
// We modify the plugin info here so that we take the defaults and
|
||||
// twiddle, rather than completely override them.
|
||||
|
||||
// We modify the plugin info here so that we take the defaults and twiddle,
|
||||
// rather than completely override them.
|
||||
// Reset the edit path to match what we're really using.
|
||||
$plugin['menu']['items']['edit']['path'] = 'view/%ctools_export_ui/edit';
|
||||
$plugin['menu']['items']['clone']['path'] = 'view/%ctools_export_ui/clone';
|
||||
@@ -44,12 +46,13 @@ class views_ui extends ctools_export_ui {
|
||||
return parent::init($plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function hook_menu(&$items) {
|
||||
// We are using our own 'edit' still, rather than having edit on this
|
||||
// object (maybe in the future) so unset the edit callbacks:
|
||||
|
||||
// Store this so we can put them back as sometimes they're needed
|
||||
// again laster:
|
||||
// object (maybe in the future) so unset the edit callbacks. Store this so
|
||||
// we can put them back as sometimes they're needed again laster.
|
||||
$stored_items = $this->plugin['menu']['items'];
|
||||
// We leave these to make sure the operations still exist in the plugin so
|
||||
// that the path finder.
|
||||
@@ -63,10 +66,16 @@ class views_ui extends ctools_export_ui {
|
||||
$this->plugin['menu']['items'] = $stored_items;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function load_item($item_name) {
|
||||
return views_ui_cache_load($item_name);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function list_form(&$form, &$form_state) {
|
||||
$row_class = 'container-inline';
|
||||
if (!variable_get('views_ui_show_listing_filters', FALSE)) {
|
||||
@@ -77,8 +86,8 @@ class views_ui extends ctools_export_ui {
|
||||
|
||||
parent::list_form($form, $form_state);
|
||||
|
||||
// ctools only has two rows. We want four.
|
||||
// That's why we create our own structure.
|
||||
// CTools only has two rows. We want four. That's why we create our own
|
||||
// structure.
|
||||
$form['bottom row']['submit']['#attributes']['class'][] = 'js-hide';
|
||||
$form['first row'] = array(
|
||||
'#prefix' => '<div class="' . $row_class . ' ctools-export-ui-row ctools-export-ui-first-row clearfix">',
|
||||
@@ -164,6 +173,9 @@ class views_ui extends ctools_export_ui {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function list_filter($form_state, $view) {
|
||||
// Don't filter by tags if all is set up.
|
||||
if ($form_state['values']['tag'] != 'all') {
|
||||
@@ -183,6 +195,9 @@ class views_ui extends ctools_export_ui {
|
||||
return parent::list_filter($form_state, $view);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function list_sort_options() {
|
||||
return array(
|
||||
'disabled' => t('Enabled, name'),
|
||||
@@ -193,7 +208,9 @@ class views_ui extends ctools_export_ui {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function list_build_row($view, &$form_state, $operations) {
|
||||
if (!empty($view->human_name)) {
|
||||
$title = $view->human_name;
|
||||
@@ -212,45 +229,79 @@ class views_ui extends ctools_export_ui {
|
||||
|
||||
$info = theme('views_ui_view_info', array('view' => $view, 'base' => $base));
|
||||
|
||||
// Reorder the operations so that enable is the default action for a templatic views
|
||||
// Reorder the operations so that enable is the default action for a
|
||||
// templatic views.
|
||||
if (!empty($operations['enable'])) {
|
||||
$operations = array('enable' => $operations['enable']) + $operations;
|
||||
}
|
||||
|
||||
// Set up sorting
|
||||
// Set up sorting.
|
||||
switch ($form_state['values']['order']) {
|
||||
case 'disabled':
|
||||
$this->sorts[$view->name] = strtolower(empty($view->disabled) . $title);
|
||||
break;
|
||||
|
||||
case 'name':
|
||||
$this->sorts[$view->name] = strtolower($title);
|
||||
break;
|
||||
|
||||
case 'path':
|
||||
$this->sorts[$view->name] = strtolower($paths);
|
||||
break;
|
||||
|
||||
case 'tag':
|
||||
$this->sorts[$view->name] = strtolower($view->tag);
|
||||
break;
|
||||
|
||||
case 'storage':
|
||||
$this->sorts[$view->name] = strtolower($view->type . $title);
|
||||
break;
|
||||
}
|
||||
|
||||
$ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline'))));
|
||||
$theme_args = array(
|
||||
'links' => $operations,
|
||||
'attributes' => array(
|
||||
'class' => array(
|
||||
'links',
|
||||
'inline',
|
||||
),
|
||||
),
|
||||
);
|
||||
$ops = theme('links__ctools_dropbutton', $theme_args);
|
||||
|
||||
$this->rows[$view->name] = array(
|
||||
'data' => array(
|
||||
array('data' => $info, 'class' => array('views-ui-name')),
|
||||
array('data' => check_plain($view->description), 'class' => array('views-ui-description')),
|
||||
array('data' => check_plain($view->tag), 'class' => array('views-ui-tag')),
|
||||
array('data' => $paths, 'class' => array('views-ui-path')),
|
||||
array('data' => $ops, 'class' => array('views-ui-operations')),
|
||||
array(
|
||||
'data' => $info,
|
||||
'class' => array('views-ui-name'),
|
||||
),
|
||||
array(
|
||||
'data' => check_plain($view->description),
|
||||
'class' => array('views-ui-description'),
|
||||
),
|
||||
array(
|
||||
'data' => check_plain($view->tag),
|
||||
'class' => array('views-ui-tag'),
|
||||
),
|
||||
array(
|
||||
'data' => $paths,
|
||||
'class' => array('views-ui-path'),
|
||||
),
|
||||
array(
|
||||
'data' => $ops,
|
||||
'class' => array('views-ui-operations'),
|
||||
),
|
||||
),
|
||||
'title' => t('Machine name: ') . check_plain($view->name),
|
||||
'class' => array(!empty($view->disabled) ? 'ctools-export-ui-disabled' : 'ctools-export-ui-enabled'),
|
||||
'class' => array(
|
||||
!empty($view->disabled) ? 'ctools-export-ui-disabled' : 'ctools-export-ui-enabled',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function list_render(&$form_state) {
|
||||
views_include('admin');
|
||||
views_ui_add_admin_css();
|
||||
@@ -263,7 +314,7 @@ class views_ui extends ctools_export_ui {
|
||||
$this->active = $form_state['values']['order'];
|
||||
$this->order = $form_state['values']['sort'];
|
||||
|
||||
$query = tablesort_get_query_parameters();
|
||||
$query = tablesort_get_query_parameters();
|
||||
|
||||
$header = array(
|
||||
$this->tablesort_link(t('View name'), 'name', 'views-ui-name'),
|
||||
@@ -282,6 +333,9 @@ class views_ui extends ctools_export_ui {
|
||||
return theme('table', $table);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function tablesort_link($label, $field, $class) {
|
||||
$title = t('sort by @s', array('@s' => $label));
|
||||
$initial = 'asc';
|
||||
@@ -306,7 +360,12 @@ class views_ui extends ctools_export_ui {
|
||||
return array('data' => $link, 'class' => $class);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function clone_page($js, $input, $item, $step = NULL) {
|
||||
$args = func_get_args();
|
||||
|
||||
drupal_set_title($this->get_page_title('clone', $item));
|
||||
|
||||
$name = $item->{$this->plugin['export']['key']};
|
||||
@@ -323,7 +382,7 @@ class views_ui extends ctools_export_ui {
|
||||
'no_redirect' => TRUE,
|
||||
'step' => $step,
|
||||
// Store these in case additional args are needed.
|
||||
'function args' => func_get_args(),
|
||||
'function args' => $args,
|
||||
);
|
||||
|
||||
$output = drupal_build_form('views_ui_clone_form', $form_state);
|
||||
@@ -339,6 +398,9 @@ class views_ui extends ctools_export_ui {
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function add_template_page($js, $input, $name, $step = NULL) {
|
||||
$templates = views_get_all_templates();
|
||||
|
||||
@@ -348,9 +410,8 @@ class views_ui extends ctools_export_ui {
|
||||
|
||||
$template = $templates[$name];
|
||||
|
||||
// The template description probably describes the template, not the
|
||||
// view that will be created from it, but users aren't that likely to
|
||||
// touch it.
|
||||
// The template description probably describes the template, not the view
|
||||
// that will be created from it, but users aren't that likely to touch it.
|
||||
if (!empty($template->description)) {
|
||||
unset($template->description);
|
||||
}
|
||||
@@ -363,6 +424,9 @@ class views_ui extends ctools_export_ui {
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function set_item_state($state, $js, $input, $item) {
|
||||
ctools_export_set_object_status($item, $state);
|
||||
menu_rebuild();
|
||||
@@ -375,23 +439,27 @@ class views_ui extends ctools_export_ui {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function list_page($js, $input) {
|
||||
// Remove filters values from session if filters are hidden.
|
||||
if (!variable_get('views_ui_show_listing_filters', FALSE) && isset($_SESSION['ctools_export_ui'][$this->plugin['name']])) {
|
||||
unset($_SESSION['ctools_export_ui'][$this->plugin['name']]);
|
||||
}
|
||||
|
||||
// wrap output in a div for CSS
|
||||
// Wrap output in a div for CSS.
|
||||
$output = parent::list_page($js, $input);
|
||||
if (is_string($output)) {
|
||||
$output = '<div id="views-ui-list-page">' . $output . '</div>';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Form callback to edit an exportable item using the wizard
|
||||
* Form callback to edit an exportable item using the wizard.
|
||||
*
|
||||
* This simply loads the object defined in the plugin and hands it off.
|
||||
*/
|
||||
|
@@ -17,59 +17,63 @@
|
||||
* The base plugin to handle access control.
|
||||
*/
|
||||
class views_plugin_access extends views_plugin {
|
||||
|
||||
/**
|
||||
* Initialize the plugin.
|
||||
*
|
||||
* @param $view
|
||||
* @param view $view
|
||||
* The view object.
|
||||
* @param $display
|
||||
* @param object $display
|
||||
* The display handler.
|
||||
*/
|
||||
function init(&$view, &$display) {
|
||||
public function init(&$view, &$display) {
|
||||
$this->view = &$view;
|
||||
$this->display = &$display;
|
||||
|
||||
if (is_object($display->handler)) {
|
||||
$options = $display->handler->get_option('access');
|
||||
// Overlay incoming options on top of defaults
|
||||
// Overlay incoming options on top of defaults.
|
||||
$this->unpack_options($this->options, $options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the options when this is a new access
|
||||
* control plugin
|
||||
* Retrieve the options when this is a new access control plugin.
|
||||
*/
|
||||
function option_definition() { return array(); }
|
||||
public function option_definition() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the default form for setting options.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) { }
|
||||
public function options_form(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the default form form for validating options
|
||||
* Provide the default form form for validating options.
|
||||
*/
|
||||
function options_validate(&$form, &$form_state) { }
|
||||
public function options_validate(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the default form form for submitting options
|
||||
* Provide the default form form for submitting options.
|
||||
*/
|
||||
function options_submit(&$form, &$form_state) { }
|
||||
public function options_submit(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string to display as the clickable title for the
|
||||
* access control.
|
||||
* Return a string to display as the clickable title for the access control.
|
||||
*/
|
||||
function summary_title() {
|
||||
public function summary_title() {
|
||||
return t('Unknown');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the current user has access or not.
|
||||
*/
|
||||
function access($account) {
|
||||
// default to no access control.
|
||||
public function access($account) {
|
||||
// Default to no access control.
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -80,15 +84,16 @@ class views_plugin_access extends views_plugin {
|
||||
* performance hits during menu item access testing, which happens
|
||||
* a lot.
|
||||
*
|
||||
* @return an array; the first item should be the function to call,
|
||||
* and the second item should be an array of arguments. The first
|
||||
* item may also be TRUE (bool only) which will indicate no
|
||||
* access control.)
|
||||
* @return array
|
||||
* The first item should be the function to call, and the second item should
|
||||
* be an array of arguments. The first item may also be TRUE (bool only)
|
||||
* which will indicate no access control.
|
||||
*/
|
||||
function get_access_callback() {
|
||||
// default to no access control.
|
||||
public function get_access_callback() {
|
||||
// Default to no access control.
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_plugin_access_none.
|
||||
* Contains .
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -11,7 +11,12 @@
|
||||
* @ingroup views_access_plugins
|
||||
*/
|
||||
class views_plugin_access_none extends views_plugin_access {
|
||||
function summary_title() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function summary_title() {
|
||||
return t('Unrestricted');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -11,15 +11,25 @@
|
||||
* @ingroup views_access_plugins
|
||||
*/
|
||||
class views_plugin_access_perm extends views_plugin_access {
|
||||
function access($account) {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function access($account) {
|
||||
return views_check_perm($this->options['perm'], $account);
|
||||
}
|
||||
|
||||
function get_access_callback() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_access_callback() {
|
||||
return array('views_check_perm', array($this->options['perm']));
|
||||
}
|
||||
|
||||
function summary_title() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function summary_title() {
|
||||
$permissions = module_invoke_all('permission');
|
||||
if (isset($permissions[$this->options['perm']])) {
|
||||
return $permissions[$this->options['perm']]['title'];
|
||||
@@ -29,19 +39,25 @@ class views_plugin_access_perm extends views_plugin_access {
|
||||
}
|
||||
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['perm'] = array('default' => 'access content');
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$perms = array();
|
||||
$module_info = system_get_info('module');
|
||||
|
||||
// Get list of permissions
|
||||
// Get list of permissions.
|
||||
foreach (module_implements('permission') as $module) {
|
||||
$permissions = module_invoke($module, 'permission');
|
||||
foreach ($permissions as $name => $perm) {
|
||||
@@ -59,4 +75,5 @@ class views_plugin_access_perm extends views_plugin_access {
|
||||
'#description' => t('Only users with the selected permission flag will be able to access this display. Note that users with "access all views" can see any view, regardless of other permissions.'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -11,15 +11,25 @@
|
||||
* @ingroup views_access_plugins
|
||||
*/
|
||||
class views_plugin_access_role extends views_plugin_access {
|
||||
function access($account) {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function access($account) {
|
||||
return views_check_roles(array_filter($this->options['role']), $account);
|
||||
}
|
||||
|
||||
function get_access_callback() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_access_callback() {
|
||||
return array('views_check_roles', array(array_filter($this->options['role'])));
|
||||
}
|
||||
|
||||
function summary_title() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function summary_title() {
|
||||
$count = count($this->options['role']);
|
||||
if ($count < 1) {
|
||||
return t('No role(s) selected');
|
||||
@@ -34,15 +44,20 @@ class views_plugin_access_role extends views_plugin_access {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['role'] = array('default' => array());
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['role'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
@@ -53,14 +68,21 @@ class views_plugin_access_role extends views_plugin_access {
|
||||
);
|
||||
}
|
||||
|
||||
function options_validate(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_validate(&$form, &$form_state) {
|
||||
if (!array_filter($form_state['values']['access_options']['role'])) {
|
||||
form_error($form['role'], t('You must select at least one role if type is "by role"'));
|
||||
}
|
||||
}
|
||||
|
||||
function options_submit(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_submit(&$form, &$form_state) {
|
||||
// I hate checkboxes.
|
||||
$form_state['values']['access_options']['role'] = array_filter($form_state['values']['access_options']['role']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -17,18 +17,20 @@
|
||||
* The fixed argument default handler; also used as the base.
|
||||
*/
|
||||
class views_plugin_argument_default extends views_plugin {
|
||||
|
||||
/**
|
||||
* Return the default argument.
|
||||
*
|
||||
* This needs to be overridden by every default argument handler to properly do what is needed.
|
||||
* This needs to be overridden by every default argument handler to properly
|
||||
* do what is needed.
|
||||
*/
|
||||
function get_argument() { }
|
||||
public function get_argument() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize this plugin with the view and the argument
|
||||
* it is linked to.
|
||||
* Initialize this plugin with the view and the argument it is linked to.
|
||||
*/
|
||||
function init(&$view, &$argument, $options) {
|
||||
public function init(&$view, &$argument, $options) {
|
||||
$this->view = &$view;
|
||||
$this->argument = &$argument;
|
||||
|
||||
@@ -37,31 +39,36 @@ class views_plugin_argument_default extends views_plugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the options when this is a new access
|
||||
* control plugin
|
||||
* Retrieve the options when this is a new access control plugin.
|
||||
*/
|
||||
function option_definition() { return array(); }
|
||||
public function option_definition() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the default form for setting options.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) { }
|
||||
public function options_form(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the default form form for validating options
|
||||
* Provide the default form form for validating options.
|
||||
*/
|
||||
function options_validate(&$form, &$form_state) { }
|
||||
public function options_validate(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the default form form for submitting options
|
||||
* Provide the default form form for submitting options.
|
||||
*/
|
||||
function options_submit(&$form, &$form_state, &$options = array()) { }
|
||||
public function options_submit(&$form, &$form_state, &$options = array()) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the administrator has the privileges to use this
|
||||
* plugin
|
||||
* Determine if the administrator has the privileges to use this plugin.
|
||||
*/
|
||||
function access() { return TRUE; }
|
||||
public function access() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* If we don't have access to the form but are showing it anyway, ensure that
|
||||
@@ -70,7 +77,7 @@ class views_plugin_argument_default extends views_plugin {
|
||||
* This is only called by child objects if specified in the options_form(),
|
||||
* so it will not always be used.
|
||||
*/
|
||||
function check_access(&$form, $option_name) {
|
||||
public function check_access(&$form, $option_name) {
|
||||
if (!$this->access()) {
|
||||
$form[$option_name]['#disabled'] = TRUE;
|
||||
$form[$option_name]['#value'] = $form[$this->option_name]['#default_value'];
|
||||
@@ -86,7 +93,9 @@ class views_plugin_argument_default extends views_plugin {
|
||||
* move arguments from the old style to the new style. See
|
||||
* views_plugin_argument_default_fixed for a good example of this method.
|
||||
*/
|
||||
function convert_options(&$options) { }
|
||||
public function convert_options(&$options) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the fixed argument default plugin.
|
||||
* Definition of views_plugin_argument_default_fixed.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -11,14 +11,21 @@
|
||||
* @ingroup views_argument_default_plugins
|
||||
*/
|
||||
class views_plugin_argument_default_fixed extends views_plugin_argument_default {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['argument'] = array('default' => '');
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['argument'] = array(
|
||||
'#type' => 'textfield',
|
||||
@@ -30,15 +37,19 @@ class views_plugin_argument_default_fixed extends views_plugin_argument_default
|
||||
/**
|
||||
* Return the default argument.
|
||||
*/
|
||||
function get_argument() {
|
||||
public function get_argument() {
|
||||
return $this->options['argument'];
|
||||
}
|
||||
|
||||
function convert_options(&$options) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function convert_options(&$options) {
|
||||
if (!isset($options['argument']) && isset($this->argument->options['default_argument_fixed'])) {
|
||||
$options['argument'] = $this->argument->options['default_argument_fixed'];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the php code argument default plugin.
|
||||
* Definition of views_plugin_argument_default_php.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -11,14 +11,21 @@
|
||||
* @ingroup views_argument_default_plugins
|
||||
*/
|
||||
class views_plugin_argument_default_php extends views_plugin_argument_default {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['code'] = array('default' => '');
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['code'] = array(
|
||||
'#type' => 'textarea',
|
||||
@@ -27,11 +34,14 @@ class views_plugin_argument_default_php extends views_plugin_argument_default {
|
||||
'#description' => t('Enter PHP code that returns a value to use for this filter. Do not use <?php ?>. You must return only a single value for just this filter. Some variables are available: the view object will be "$view". The argument handler will be "$argument", for example you may change the title used for substitutions for this argument by setting "argument->validated_title"".'),
|
||||
);
|
||||
|
||||
// Only do this if using one simple standard form gadget
|
||||
// Only do this if using one simple standard form gadget.
|
||||
$this->check_access($form, 'code');
|
||||
}
|
||||
|
||||
function convert_options(&$options) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function convert_options(&$options) {
|
||||
if (!isset($options['code']) && isset($this->argument->options['default_argument_php'])) {
|
||||
$options['code'] = $this->argument->options['default_argument_php'];
|
||||
}
|
||||
@@ -41,11 +51,14 @@ class views_plugin_argument_default_php extends views_plugin_argument_default {
|
||||
* Only let users with PHP block visibility permissions set/modify this
|
||||
* default plugin.
|
||||
*/
|
||||
function access() {
|
||||
public function access() {
|
||||
return user_access('use PHP for settings');
|
||||
}
|
||||
|
||||
function get_argument() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_argument() {
|
||||
// set up variables to make it easier to reference during the argument.
|
||||
$view = &$this->view;
|
||||
$argument = &$this->argument;
|
||||
@@ -54,4 +67,5 @@ class views_plugin_argument_default_php extends views_plugin_argument_default {
|
||||
ob_end_clean();
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the raw value argument default plugin.
|
||||
* Definition of views_plugin_argument_default_raw.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -11,7 +11,11 @@
|
||||
* @ingroup views_argument_default_plugins
|
||||
*/
|
||||
class views_plugin_argument_default_raw extends views_plugin_argument_default {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['index'] = array('default' => '');
|
||||
$options['use_alias'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
@@ -19,7 +23,10 @@ class views_plugin_argument_default_raw extends views_plugin_argument_default {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
// Using range(1, 10) will create an array keyed 0-9, which allows arg() to
|
||||
// properly function since it is also zero-based.
|
||||
@@ -38,7 +45,10 @@ class views_plugin_argument_default_raw extends views_plugin_argument_default {
|
||||
);
|
||||
}
|
||||
|
||||
function get_argument() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_argument() {
|
||||
$path = NULL;
|
||||
if ($this->options['use_alias']) {
|
||||
$path = drupal_get_path_alias();
|
||||
@@ -47,4 +57,5 @@ class views_plugin_argument_default_raw extends views_plugin_argument_default {
|
||||
return $arg;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the base argument validator plugin.
|
||||
* Definition of views_plugin_argument_validate.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -19,10 +19,9 @@
|
||||
class views_plugin_argument_validate extends views_plugin {
|
||||
|
||||
/**
|
||||
* Initialize this plugin with the view and the argument
|
||||
* it is linked to.
|
||||
* Initialize this plugin with the view and the argument it is linked to.
|
||||
*/
|
||||
function init(&$view, &$argument, $options) {
|
||||
public function init(&$view, &$argument, $options) {
|
||||
$this->view = &$view;
|
||||
$this->argument = &$argument;
|
||||
|
||||
@@ -31,25 +30,29 @@ class views_plugin_argument_validate extends views_plugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the options when this is a new access
|
||||
* control plugin
|
||||
* Retrieve the options when this is a new access control plugin.
|
||||
*/
|
||||
function option_definition() { return array(); }
|
||||
public function option_definition() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the default form for setting options.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) { }
|
||||
public function options_form(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the default form form for validating options
|
||||
* Provide the default form form for validating options.
|
||||
*/
|
||||
function options_validate(&$form, &$form_state) { }
|
||||
public function options_validate(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the default form form for submitting options
|
||||
*/
|
||||
function options_submit(&$form, &$form_state, &$options = array()) { }
|
||||
public function options_submit(&$form, &$form_state, &$options = array()) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert options from the older style.
|
||||
@@ -59,12 +62,15 @@ class views_plugin_argument_validate extends views_plugin {
|
||||
* move arguments from the old style to the new style. See
|
||||
* views_plugin_argument_default_fixed for a good example of this method.
|
||||
*/
|
||||
function convert_options(&$options) { }
|
||||
public function convert_options(&$options) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the administrator has the privileges to use this plugin
|
||||
* Determine if the administrator has the privileges to use this plugin.
|
||||
*/
|
||||
function access() { return TRUE; }
|
||||
public function access() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* If we don't have access to the form but are showing it anyway, ensure that
|
||||
@@ -73,7 +79,7 @@ class views_plugin_argument_validate extends views_plugin {
|
||||
* This is only called by child objects if specified in the options_form(),
|
||||
* so it will not always be used.
|
||||
*/
|
||||
function check_access(&$form, $option_name) {
|
||||
public function check_access(&$form, $option_name) {
|
||||
if (!$this->access()) {
|
||||
$form[$option_name]['#disabled'] = TRUE;
|
||||
$form[$option_name]['#value'] = $form[$this->option_name]['#default_value'];
|
||||
@@ -81,7 +87,12 @@ class views_plugin_argument_validate extends views_plugin {
|
||||
}
|
||||
}
|
||||
|
||||
function validate_argument($arg) { return TRUE; }
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validate_argument($arg) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the summary arguments for displaying.
|
||||
@@ -91,7 +102,9 @@ class views_plugin_argument_validate extends views_plugin {
|
||||
* for a faster query. But there are use cases where you want to use
|
||||
* the old value again, for example the summary.
|
||||
*/
|
||||
function process_summary_arguments(&$args) { }
|
||||
public function process_summary_arguments(&$args) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the numeric argument validator plugin.
|
||||
* Definition of views_plugin_argument_validate_numeric.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -11,7 +11,12 @@
|
||||
* @ingroup views_argument_validate_plugins
|
||||
*/
|
||||
class views_plugin_argument_validate_numeric extends views_plugin_argument_validate {
|
||||
function validate_argument($argument) {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validate_argument($argument) {
|
||||
return is_numeric($argument);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the php code argument validator plugin.
|
||||
* Definition of views_plugin_argument_validate_php.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -11,14 +11,21 @@
|
||||
* @ingroup views_argument_validate_plugins
|
||||
*/
|
||||
class views_plugin_argument_validate_php extends views_plugin_argument_validate {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['code'] = array('default' => '');
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['code'] = array(
|
||||
'#type' => 'textarea',
|
||||
@@ -34,17 +41,23 @@ class views_plugin_argument_validate_php extends views_plugin_argument_validate
|
||||
* Only let users with PHP block visibility permissions set/modify this
|
||||
* validate plugin.
|
||||
*/
|
||||
function access() {
|
||||
public function access() {
|
||||
return user_access('use PHP for settings');
|
||||
}
|
||||
|
||||
function convert_options(&$options) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function convert_options(&$options) {
|
||||
if (!isset($options['code']) && isset($this->argument->options['validate_argument_php'])) {
|
||||
$options['code'] = $this->argument->options['validate_argument_php'];
|
||||
}
|
||||
}
|
||||
|
||||
function validate_argument($argument) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validate_argument($argument) {
|
||||
// set up variables to make it easier to reference during the argument.
|
||||
$view = &$this->view;
|
||||
$handler = &$this->argument;
|
||||
@@ -54,4 +67,5 @@ class views_plugin_argument_validate_php extends views_plugin_argument_validate
|
||||
ob_end_clean();
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -17,31 +17,32 @@
|
||||
* The base plugin to handle caching.
|
||||
*/
|
||||
class views_plugin_cache extends views_plugin {
|
||||
|
||||
/**
|
||||
* Contains all data that should be written/read from cache.
|
||||
*/
|
||||
var $storage = array();
|
||||
public $storage = array();
|
||||
|
||||
/**
|
||||
* What table to store data in.
|
||||
*/
|
||||
var $table = 'cache_views_data';
|
||||
public $table = 'cache_views_data';
|
||||
|
||||
/**
|
||||
* Initialize the plugin.
|
||||
*
|
||||
* @param $view
|
||||
* @param view $view
|
||||
* The view object.
|
||||
* @param $display
|
||||
* @param object $display
|
||||
* The display handler.
|
||||
*/
|
||||
function init(&$view, &$display) {
|
||||
public function init(&$view, &$display) {
|
||||
$this->view = &$view;
|
||||
$this->display = &$display;
|
||||
|
||||
if (is_object($display->handler)) {
|
||||
$options = $display->handler->get_option('cache');
|
||||
// Overlay incoming options on top of defaults
|
||||
// Overlay incoming options on top of defaults.
|
||||
$this->unpack_options($this->options, $options);
|
||||
}
|
||||
}
|
||||
@@ -50,7 +51,7 @@ class views_plugin_cache extends views_plugin {
|
||||
* Return a string to display as the clickable title for the
|
||||
* access control.
|
||||
*/
|
||||
function summary_title() {
|
||||
public function summary_title() {
|
||||
return t('Unknown');
|
||||
}
|
||||
|
||||
@@ -59,35 +60,37 @@ class views_plugin_cache extends views_plugin {
|
||||
*
|
||||
* Plugins must override this to implement expiration.
|
||||
*
|
||||
* @param $type
|
||||
* @param string $type
|
||||
* The cache type, either 'query', 'result' or 'output'.
|
||||
*/
|
||||
function cache_expire($type) { }
|
||||
|
||||
/**
|
||||
* Determine expiration time in the cache table of the cache type
|
||||
* or CACHE_PERMANENT if item shouldn't be removed automatically from cache.
|
||||
*
|
||||
* Plugins must override this to implement expiration in the cache table.
|
||||
*
|
||||
* @param $type
|
||||
* The cache type, either 'query', 'result' or 'output'.
|
||||
*/
|
||||
function cache_set_expire($type) {
|
||||
return CACHE_PERMANENT;
|
||||
public function cache_expire($type) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine expiration time in the cache table of the cache type.
|
||||
*
|
||||
* Or CACHE_PERMANENT if item shouldn't be removed automatically from cache.
|
||||
*
|
||||
* Plugins must override this to implement expiration in the cache table.
|
||||
*
|
||||
* @param string $type
|
||||
* The cache type, either 'query', 'result' or 'output'.
|
||||
*/
|
||||
public function cache_set_expire($type) {
|
||||
return CACHE_PERMANENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save data to the cache.
|
||||
*
|
||||
* A plugin should override this to provide specialized caching behavior.
|
||||
*/
|
||||
function cache_set($type) {
|
||||
public function cache_set($type) {
|
||||
switch ($type) {
|
||||
case 'query':
|
||||
// Not supported currently, but this is certainly where we'd put it.
|
||||
break;
|
||||
|
||||
case 'results':
|
||||
$data = array(
|
||||
'result' => $this->view->result,
|
||||
@@ -96,6 +99,7 @@ class views_plugin_cache extends views_plugin {
|
||||
);
|
||||
cache_set($this->get_results_key(), $data, $this->table, $this->cache_set_expire($type));
|
||||
break;
|
||||
|
||||
case 'output':
|
||||
$this->gather_headers();
|
||||
$this->storage['output'] = $this->view->display_handler->output;
|
||||
@@ -104,18 +108,18 @@ class views_plugin_cache extends views_plugin {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve data from the cache.
|
||||
*
|
||||
* A plugin should override this to provide specialized caching behavior.
|
||||
*/
|
||||
function cache_get($type) {
|
||||
public function cache_get($type) {
|
||||
$cutoff = $this->cache_expire($type);
|
||||
switch ($type) {
|
||||
case 'query':
|
||||
// Not supported currently, but this is certainly where we'd put it.
|
||||
return FALSE;
|
||||
|
||||
case 'results':
|
||||
// Values to set: $view->result, $view->total_rows, $view->execute_time,
|
||||
// $view->current_page.
|
||||
@@ -129,6 +133,7 @@ class views_plugin_cache extends views_plugin {
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case 'output':
|
||||
if ($cache = cache_get($this->get_output_key(), $this->table)) {
|
||||
if (!$cutoff || $cache->created > $cutoff) {
|
||||
@@ -145,18 +150,18 @@ class views_plugin_cache extends views_plugin {
|
||||
/**
|
||||
* Clear out cached data for a view.
|
||||
*
|
||||
* We're just going to nuke anything related to the view, regardless of display,
|
||||
* to be sure that we catch everything. Maybe that's a bad idea.
|
||||
* We're just going to nuke anything related to the view, regardless of
|
||||
* display, to be sure that we catch everything. Maybe that's a bad idea.
|
||||
*/
|
||||
function cache_flush() {
|
||||
public function cache_flush() {
|
||||
cache_clear_all($this->view->name . ':', $this->table, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Post process any rendered data.
|
||||
*
|
||||
* This can be valuable to be able to cache a view and still have some level of
|
||||
* dynamic output. In an ideal world, the actual output will include HTML
|
||||
* This can be valuable to be able to cache a view and still have some level
|
||||
* of dynamic output. In an ideal world, the actual output will include HTML
|
||||
* comment based tokens, and then the post process can replace those tokens.
|
||||
*
|
||||
* Example usage. If it is known that the view is a node view and that the
|
||||
@@ -172,16 +177,17 @@ class views_plugin_cache extends views_plugin {
|
||||
* All of the cached result data will be available in $view->result, as well,
|
||||
* so all ids used in the query should be discoverable.
|
||||
*/
|
||||
function post_render(&$output) { }
|
||||
public function post_render(&$output) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Start caching javascript, css and other out of band info.
|
||||
* Start caching JavaScript, css and other out of band info.
|
||||
*
|
||||
* This takes a snapshot of the current system state so that we don't
|
||||
* duplicate it. Later on, when gather_headers() is run, this information
|
||||
* will be removed so that we don't hold onto it.
|
||||
*/
|
||||
function cache_start() {
|
||||
public function cache_start() {
|
||||
$this->storage['head'] = drupal_add_html_head();
|
||||
$this->storage['css'] = drupal_add_css();
|
||||
$this->storage['js'] = drupal_add_js();
|
||||
@@ -189,10 +195,10 @@ class views_plugin_cache extends views_plugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gather out of band data, compare it to what we started with and store the difference.
|
||||
* Gather out of band data, compare it to the start data and store the diff.
|
||||
*/
|
||||
function gather_headers() {
|
||||
// Simple replacement for head
|
||||
public function gather_headers() {
|
||||
// Simple replacement for head.
|
||||
if (isset($this->storage['head'])) {
|
||||
$this->storage['head'] = str_replace($this->storage['head'], '', drupal_add_html_head());
|
||||
}
|
||||
@@ -203,15 +209,15 @@ class views_plugin_cache extends views_plugin {
|
||||
// Check if the advanced mapping function of D 7.23 is available.
|
||||
$array_mapping_func = function_exists('drupal_array_diff_assoc_recursive') ? 'drupal_array_diff_assoc_recursive' : 'array_diff_assoc';
|
||||
|
||||
// Slightly less simple for CSS:
|
||||
// Slightly less simple for CSS.
|
||||
$css = drupal_add_css();
|
||||
$css_start = isset($this->storage['css']) ? $this->storage['css'] : array();
|
||||
$this->storage['css'] = $this->assetDiff($css, $css_start, $array_mapping_func);
|
||||
|
||||
// Get javascript after/before views renders.
|
||||
// Get JavaScript after/before views renders.
|
||||
$js = drupal_add_js();
|
||||
$js_start = isset($this->storage['js']) ? $this->storage['js'] : array();
|
||||
// If there are any differences between the old and the new javascript then
|
||||
// If there are any differences between the old and the new JavaScript then
|
||||
// store them to be added later.
|
||||
$this->storage['js'] = $this->assetDiff($js, $js_start, $array_mapping_func);
|
||||
|
||||
@@ -259,7 +265,7 @@ class views_plugin_cache extends views_plugin {
|
||||
/**
|
||||
* Restore out of band data saved to cache. Copied from Panels.
|
||||
*/
|
||||
function restore_headers() {
|
||||
public function restore_headers() {
|
||||
if (!empty($this->storage['head'])) {
|
||||
drupal_add_html_head($this->storage['head']);
|
||||
}
|
||||
@@ -287,7 +293,10 @@ class views_plugin_cache extends views_plugin {
|
||||
}
|
||||
}
|
||||
|
||||
function get_results_key() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function get_results_key() {
|
||||
if (!isset($this->_results_key)) {
|
||||
$key_data = array();
|
||||
foreach (array('exposed_info', 'page', 'sort', 'order', 'items_per_page', 'offset') as $key) {
|
||||
@@ -302,7 +311,10 @@ class views_plugin_cache extends views_plugin {
|
||||
return $this->_results_key;
|
||||
}
|
||||
|
||||
function get_output_key() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function get_output_key() {
|
||||
if (!isset($this->_output_key)) {
|
||||
$key_data = array(
|
||||
'result' => $this->view->result,
|
||||
@@ -323,24 +335,33 @@ class views_plugin_cache extends views_plugin {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_cache_key($key_data = array()) {
|
||||
public function get_cache_key($key_data = array()) {
|
||||
global $user;
|
||||
|
||||
$key_data += array(
|
||||
'roles' => array_keys($user->roles),
|
||||
'super-user' => $user->uid == 1, // special caching for super user.
|
||||
'super-user' => $user->uid == 1,
|
||||
// special caching for super user.
|
||||
'language' => $GLOBALS['language']->language,
|
||||
'language_content' => $GLOBALS['language_content']->language,
|
||||
'base_url' => $GLOBALS['base_url'],
|
||||
);
|
||||
|
||||
if (empty($key_data['build_info'])) {
|
||||
$build_info = $this->view->build_info;
|
||||
foreach (array('query','count_query') as $index) {
|
||||
foreach (array('query', 'count_query') as $index) {
|
||||
// If the default query back-end is used generate SQL query strings from
|
||||
// the query objects.
|
||||
if ($build_info[$index] instanceof SelectQueryInterface) {
|
||||
$query = clone $build_info[$index];
|
||||
$query->preExecute();
|
||||
$query = $build_info[$index];
|
||||
|
||||
// If the query was not yet prepared, work on a clone and run
|
||||
// preExecute().
|
||||
if (!$query->isPrepared()) {
|
||||
$query = clone $build_info[$index];
|
||||
$query->preExecute();
|
||||
}
|
||||
|
||||
$key_data['build_info'][$index] = array(
|
||||
'sql' => (string) $query,
|
||||
'arguments' => $query->getArguments(),
|
||||
@@ -348,9 +369,9 @@ class views_plugin_cache extends views_plugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
$key = md5(serialize($key_data));
|
||||
return $key;
|
||||
return md5(serialize($key_data));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -11,15 +11,32 @@
|
||||
* @ingroup views_cache_plugins
|
||||
*/
|
||||
class views_plugin_cache_none extends views_plugin_cache {
|
||||
function cache_start() { /* do nothing */ }
|
||||
|
||||
function summary_title() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function cache_start() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function summary_title() {
|
||||
return t('None');
|
||||
}
|
||||
|
||||
function cache_get($type) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function cache_get($type) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function cache_set($type) { }
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function cache_set($type) {
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -11,7 +11,11 @@
|
||||
* @ingroup views_cache_plugins
|
||||
*/
|
||||
class views_plugin_cache_time extends views_plugin_cache {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['results_lifespan'] = array('default' => 3600);
|
||||
$options['results_lifespan_custom'] = array('default' => 0);
|
||||
@@ -21,7 +25,10 @@ class views_plugin_cache_time extends views_plugin_cache {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$options = array(60, 300, 1800, 3600, 21600, 518400);
|
||||
$options = drupal_map_assoc($options, 'format_interval');
|
||||
@@ -67,27 +74,39 @@ class views_plugin_cache_time extends views_plugin_cache {
|
||||
);
|
||||
}
|
||||
|
||||
function options_validate(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_validate(&$form, &$form_state) {
|
||||
$custom_fields = array('output_lifespan', 'results_lifespan');
|
||||
foreach ($custom_fields as $field) {
|
||||
if ($form_state['values']['cache_options'][$field] == 'custom' && !is_numeric($form_state['values']['cache_options'][$field . '_custom'])) {
|
||||
form_error($form[$field .'_custom'], t('Custom time values must be numeric.'));
|
||||
form_error($form[$field . '_custom'], t('Custom time values must be numeric.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function summary_title() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function summary_title() {
|
||||
$results_lifespan = $this->get_lifespan('results');
|
||||
$output_lifespan = $this->get_lifespan('output');
|
||||
return format_interval($results_lifespan, 1) . '/' . format_interval($output_lifespan, 1);
|
||||
}
|
||||
|
||||
function get_lifespan($type) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_lifespan($type) {
|
||||
$lifespan = $this->options[$type . '_lifespan'] == 'custom' ? $this->options[$type . '_lifespan_custom'] : $this->options[$type . '_lifespan'];
|
||||
return $lifespan;
|
||||
}
|
||||
|
||||
function cache_expire($type) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function cache_expire($type) {
|
||||
$lifespan = $this->get_lifespan($type);
|
||||
if ($lifespan) {
|
||||
$cutoff = REQUEST_TIME - $lifespan;
|
||||
@@ -98,7 +117,10 @@ class views_plugin_cache_time extends views_plugin_cache {
|
||||
}
|
||||
}
|
||||
|
||||
function cache_set_expire($type) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function cache_set_expire($type) {
|
||||
$lifespan = $this->get_lifespan($type);
|
||||
if ($lifespan) {
|
||||
return time() + $lifespan;
|
||||
@@ -108,14 +130,20 @@ class views_plugin_cache_time extends views_plugin_cache {
|
||||
}
|
||||
}
|
||||
|
||||
function cache_set($type) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function cache_set($type) {
|
||||
$lifespan = $this->get_lifespan($type);
|
||||
if ($lifespan >= 0) {
|
||||
parent::cache_set($type);
|
||||
}
|
||||
}
|
||||
|
||||
function cache_get($type) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function cache_get($type) {
|
||||
$lifespan = $this->get_lifespan($type);
|
||||
if ($lifespan >= 0) {
|
||||
return parent::cache_get($type);
|
||||
@@ -124,4 +152,5 @@ class views_plugin_cache_time extends views_plugin_cache {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the attachment display plugin.
|
||||
* Definition of views_plugin_display_attachment.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -15,9 +15,15 @@
|
||||
* @ingroup views_display_plugins
|
||||
*/
|
||||
class views_plugin_display_attachment extends views_plugin_display {
|
||||
function option_definition () {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition () {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['show_title'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
$options['show_title_empty'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
$options['displays'] = array('default' => array());
|
||||
$options['attachment_position'] = array('default' => 'before');
|
||||
$options['inherit_arguments'] = array('default' => TRUE, 'bool' => TRUE);
|
||||
@@ -28,11 +34,17 @@ class views_plugin_display_attachment extends views_plugin_display {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function execute() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function execute() {
|
||||
return $this->view->render($this->display->id);
|
||||
}
|
||||
|
||||
function attachment_positions($position = NULL) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attachment_positions($position = NULL) {
|
||||
$positions = array(
|
||||
'before' => t('Before'),
|
||||
'after' => t('After'),
|
||||
@@ -51,8 +63,8 @@ class views_plugin_display_attachment extends views_plugin_display {
|
||||
*
|
||||
* This output is returned as an array.
|
||||
*/
|
||||
function options_summary(&$categories, &$options) {
|
||||
// It is very important to call the parent function here:
|
||||
public function options_summary(&$categories, &$options) {
|
||||
// It is very important to call the parent function here.
|
||||
parent::options_summary($categories, $options);
|
||||
|
||||
$categories['attachment'] = array(
|
||||
@@ -78,6 +90,18 @@ class views_plugin_display_attachment extends views_plugin_display {
|
||||
$attach_to = t('Not defined');
|
||||
}
|
||||
|
||||
$options['show_title'] = array(
|
||||
'category' => 'title',
|
||||
'title' => t('Show title'),
|
||||
'value' => $this->get_option('show_title') ? t('Yes') : t('No'),
|
||||
);
|
||||
|
||||
$options['show_title_empty'] = array(
|
||||
'category' => 'title',
|
||||
'title' => t('Show title even if view has no results'),
|
||||
'value' => $this->get_option('show_title_empty') ? t('Yes') : t('No'),
|
||||
);
|
||||
|
||||
$options['displays'] = array(
|
||||
'category' => 'attachment',
|
||||
'title' => t('Attach to'),
|
||||
@@ -119,11 +143,29 @@ class views_plugin_display_attachment extends views_plugin_display {
|
||||
/**
|
||||
* Provide the default form for setting options.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
// It is very important to call the parent function here:
|
||||
public function options_form(&$form, &$form_state) {
|
||||
// It is very important to call the parent function here.
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
switch ($form_state['section']) {
|
||||
case 'show_title':
|
||||
$form['#title'] .= t('Title');
|
||||
$form['show_title'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Show title'),
|
||||
'#description' => t('Do you want to show the title of the attachment?'),
|
||||
'#default_value' => $this->get_option('show_title'),
|
||||
);
|
||||
break;
|
||||
case 'show_title_empty':
|
||||
$form['#title'] .= t('Title');
|
||||
$form['show_title_empty'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Show title for empty view'),
|
||||
'#description' => t('Do you want to show the title of the attachment even if the view has no results?'),
|
||||
'#default_value' => $this->get_option('show_title_empty'),
|
||||
);
|
||||
break;
|
||||
case 'inherit_arguments':
|
||||
$form['#title'] .= t('Inherit contextual filters');
|
||||
$form['inherit_arguments'] = array(
|
||||
@@ -133,6 +175,7 @@ class views_plugin_display_attachment extends views_plugin_display {
|
||||
'#default_value' => $this->get_option('inherit_arguments'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'inherit_exposed_filters':
|
||||
$form['#title'] .= t('Inherit exposed filters');
|
||||
$form['inherit_exposed_filters'] = array(
|
||||
@@ -142,6 +185,7 @@ class views_plugin_display_attachment extends views_plugin_display {
|
||||
'#default_value' => $this->get_option('inherit_exposed_filters'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'inherit_pager':
|
||||
$form['#title'] .= t('Inherit pager');
|
||||
$form['inherit_pager'] = array(
|
||||
@@ -151,6 +195,7 @@ class views_plugin_display_attachment extends views_plugin_display {
|
||||
'#default_value' => $this->get_option('inherit_pager'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'render_pager':
|
||||
$form['#title'] .= t('Render pager');
|
||||
$form['render_pager'] = array(
|
||||
@@ -160,6 +205,7 @@ class views_plugin_display_attachment extends views_plugin_display {
|
||||
'#default_value' => $this->get_option('render_pager'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'attachment_position':
|
||||
$form['#title'] .= t('Position');
|
||||
$form['attachment_position'] = array(
|
||||
@@ -169,6 +215,7 @@ class views_plugin_display_attachment extends views_plugin_display {
|
||||
'#default_value' => $this->get_option('attachment_position'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'displays':
|
||||
$form['#title'] .= t('Attach to');
|
||||
$displays = array();
|
||||
@@ -191,10 +238,12 @@ class views_plugin_display_attachment extends views_plugin_display {
|
||||
* Perform any necessary changes to the form values prior to storage.
|
||||
* There is no need for this function to actually store the data.
|
||||
*/
|
||||
function options_submit(&$form, &$form_state) {
|
||||
// It is very important to call the parent function here:
|
||||
public function options_submit(&$form, &$form_state) {
|
||||
// It is very important to call the parent function here.
|
||||
parent::options_submit($form, $form_state);
|
||||
switch ($form_state['section']) {
|
||||
case 'show_title':
|
||||
case 'show_title_empty':
|
||||
case 'inherit_arguments':
|
||||
case 'inherit_pager':
|
||||
case 'render_pager':
|
||||
@@ -209,7 +258,7 @@ class views_plugin_display_attachment extends views_plugin_display {
|
||||
/**
|
||||
* Attach to another view.
|
||||
*/
|
||||
function attach_to($display_id) {
|
||||
public function attach_to($display_id) {
|
||||
$displays = $this->get_option('displays');
|
||||
|
||||
if (empty($displays[$display_id])) {
|
||||
@@ -220,14 +269,14 @@ class views_plugin_display_attachment extends views_plugin_display {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get a fresh view because our current one has a lot of stuff on it because it's
|
||||
// already been executed.
|
||||
// Get a fresh view because our current one has a lot of stuff on it
|
||||
// because it's already been executed.
|
||||
$view = $this->view->clone_view();
|
||||
$view->original_args = $view->args;
|
||||
|
||||
$args = $this->get_option('inherit_arguments') ? $this->view->args : array();
|
||||
$view->set_arguments($args);
|
||||
$exposed_input = $this->get_option('inherit_exposed_filters') ? $this->view->exposed_input : array();
|
||||
$exposed_input = $this->get_option('inherit_exposed_filters') && isset($this->view->exposed_input) ? $this->view->exposed_input : array();
|
||||
$view->set_exposed_input($exposed_input);
|
||||
$view->set_display($this->display->id);
|
||||
if ($this->get_option('inherit_pager')) {
|
||||
@@ -235,15 +284,30 @@ class views_plugin_display_attachment extends views_plugin_display {
|
||||
$view->display_handler->set_option('pager', $this->view->display[$display_id]->handler->get_option('pager'));
|
||||
}
|
||||
|
||||
$attachment = $view->execute_display($this->display->id, $args);
|
||||
$attachment_output = $view->execute_display($this->display->id, $args);
|
||||
|
||||
$attachment = '';
|
||||
if ($view->display_handler->get_option('show_title') && $view->display_handler->get_option('title')) {
|
||||
if ($view->display_handler->get_option('show_title_empty') || !empty($view->result)) {
|
||||
$attachment .= theme('html_tag', array(
|
||||
'element' => array(
|
||||
'#tag' => 'h2',
|
||||
'#value' => $view->display_handler->get_option('title'),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
$attachment .= $attachment_output;
|
||||
|
||||
switch ($this->get_option('attachment_position')) {
|
||||
case 'before':
|
||||
$this->view->attachment_before .= $attachment;
|
||||
break;
|
||||
|
||||
case 'after':
|
||||
$this->view->attachment_after .= $attachment;
|
||||
break;
|
||||
|
||||
case 'both':
|
||||
$this->view->attachment_before .= $attachment;
|
||||
$this->view->attachment_after .= $attachment;
|
||||
@@ -254,11 +318,10 @@ class views_plugin_display_attachment extends views_plugin_display {
|
||||
}
|
||||
|
||||
/**
|
||||
* Attachment displays only use exposed widgets if
|
||||
* they are set to inherit the exposed filter settings
|
||||
* of their parent display.
|
||||
* Attachment displays only use exposed widgets if they are set to inherit
|
||||
* the exposed filter settings of their parent display.
|
||||
*/
|
||||
function uses_exposed() {
|
||||
public function uses_exposed() {
|
||||
if (!empty($this->options['inherit_exposed_filters']) && parent::uses_exposed()) {
|
||||
return TRUE;
|
||||
}
|
||||
@@ -266,19 +329,26 @@ class views_plugin_display_attachment extends views_plugin_display {
|
||||
}
|
||||
|
||||
/**
|
||||
* If an attachment is set to inherit the exposed filter
|
||||
* settings from its parent display, then don't render and
|
||||
* display a second set of exposed filter widgets.
|
||||
* If an attachment is set to inherit the exposed filter settings from its
|
||||
* parent display, then don't render and display a second set of exposed
|
||||
* filter widgets.
|
||||
*/
|
||||
function displays_exposed() {
|
||||
public function displays_exposed() {
|
||||
return $this->options['inherit_exposed_filters'] ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
function use_pager() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function use_pager() {
|
||||
return !empty($this->use_pager);
|
||||
}
|
||||
|
||||
function render_pager() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render_pager() {
|
||||
return !empty($this->use_pager) && $this->get_option('render_pager');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the block display plugin.
|
||||
* Definition of views_plugin_display_block.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -11,7 +11,11 @@
|
||||
* @ingroup views_display_plugins
|
||||
*/
|
||||
class views_plugin_display_block extends views_plugin_display {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['block_description'] = array('default' => '', 'translatable' => TRUE);
|
||||
@@ -25,7 +29,7 @@ class views_plugin_display_block extends views_plugin_display {
|
||||
* but extended block handlers might be able to do interesting
|
||||
* stuff with it.
|
||||
*/
|
||||
function execute_hook_block_list($delta = 0, $edit = array()) {
|
||||
public function execute_hook_block_list($delta = 0, $edit = array()) {
|
||||
$delta = $this->view->name . '-' . $this->display->id;
|
||||
$desc = $this->get_option('block_description');
|
||||
|
||||
@@ -40,7 +44,7 @@ class views_plugin_display_block extends views_plugin_display {
|
||||
return array(
|
||||
$delta => array(
|
||||
'info' => $desc,
|
||||
'cache' => $this->get_cache_type()
|
||||
'cache' => $this->get_cache_type(),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -48,7 +52,7 @@ class views_plugin_display_block extends views_plugin_display {
|
||||
/**
|
||||
* The display block handler returns the structure necessary for a block.
|
||||
*/
|
||||
function execute() {
|
||||
public function execute() {
|
||||
// Prior to this being called, the $view should already be set to this
|
||||
// display, and arguments should be set on the view.
|
||||
$info['content'] = $this->view->render();
|
||||
@@ -64,8 +68,8 @@ class views_plugin_display_block extends views_plugin_display {
|
||||
*
|
||||
* This output is returned as an array.
|
||||
*/
|
||||
function options_summary(&$categories, &$options) {
|
||||
// It is very important to call the parent function here:
|
||||
public function options_summary(&$categories, &$options) {
|
||||
// It is very important to call the parent function here.
|
||||
parent::options_summary($categories, $options);
|
||||
|
||||
$categories['block'] = array(
|
||||
@@ -98,7 +102,7 @@ class views_plugin_display_block extends views_plugin_display {
|
||||
/**
|
||||
* Provide a list of core's block caching modes.
|
||||
*/
|
||||
function block_caching_modes() {
|
||||
public function block_caching_modes() {
|
||||
return array(
|
||||
DRUPAL_NO_CACHE => t('Do not cache'),
|
||||
DRUPAL_CACHE_GLOBAL => t('Cache once for everything (global)'),
|
||||
@@ -114,7 +118,7 @@ class views_plugin_display_block extends views_plugin_display {
|
||||
* Provide a single method to figure caching type, keeping a sensible default
|
||||
* for when it's unset.
|
||||
*/
|
||||
function get_cache_type() {
|
||||
public function get_cache_type() {
|
||||
$cache_type = $this->get_option('block_caching');
|
||||
if (empty($cache_type)) {
|
||||
$cache_type = DRUPAL_NO_CACHE;
|
||||
@@ -125,8 +129,8 @@ class views_plugin_display_block extends views_plugin_display {
|
||||
/**
|
||||
* Provide the default form for setting options.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
// It is very important to call the parent function here:
|
||||
public function options_form(&$form, &$form_state) {
|
||||
// It is very important to call the parent function here.
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
switch ($form_state['section']) {
|
||||
@@ -138,6 +142,7 @@ class views_plugin_display_block extends views_plugin_display {
|
||||
'#default_value' => $this->get_option('block_description'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'block_caching':
|
||||
$form['#title'] .= t('Block caching type');
|
||||
|
||||
@@ -148,6 +153,7 @@ class views_plugin_display_block extends views_plugin_display {
|
||||
'#default_value' => $this->get_cache_type(),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'exposed_form_options':
|
||||
$this->view->init_handlers();
|
||||
if (!$this->uses_exposed() && parent::uses_exposed()) {
|
||||
@@ -156,6 +162,7 @@ class views_plugin_display_block extends views_plugin_display {
|
||||
'#markup' => '<div class="messages warning">' . t('Exposed filters in block displays require "Use AJAX" to be set to work correctly.') . '</div>',
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,19 +170,21 @@ class views_plugin_display_block extends views_plugin_display {
|
||||
* Perform any necessary changes to the form values prior to storage.
|
||||
* There is no need for this function to actually store the data.
|
||||
*/
|
||||
function options_submit(&$form, &$form_state) {
|
||||
// It is very important to call the parent function here:
|
||||
public function options_submit(&$form, &$form_state) {
|
||||
// It is very important to call the parent function here.
|
||||
parent::options_submit($form, $form_state);
|
||||
switch ($form_state['section']) {
|
||||
case 'display_id':
|
||||
$this->update_block_bid($form_state['view']->name, $this->display->id, $this->display->new_id);
|
||||
break;
|
||||
|
||||
case 'block_description':
|
||||
$this->set_option('block_description', $form_state['values']['block_description']);
|
||||
break;
|
||||
|
||||
case 'block_caching':
|
||||
$this->set_option('block_caching', $form_state['values']['block_caching']);
|
||||
$this->save_block_cache($form_state['view']->name . '-'. $form_state['display_id'], $form_state['values']['block_caching']);
|
||||
$this->save_block_cache($form_state['view']->name . '-' . $form_state['display_id'], $form_state['values']['block_caching']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -183,17 +192,17 @@ class views_plugin_display_block extends views_plugin_display {
|
||||
/**
|
||||
* Block views use exposed widgets only if AJAX is set.
|
||||
*/
|
||||
function uses_exposed() {
|
||||
if ($this->use_ajax()) {
|
||||
return parent::uses_exposed();
|
||||
}
|
||||
return FALSE;
|
||||
public function uses_exposed() {
|
||||
if ($this->use_ajax()) {
|
||||
return parent::uses_exposed();
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the block delta when you change the machine readable name of the display.
|
||||
* Update the block delta when the machine name of the display changes.
|
||||
*/
|
||||
function update_block_bid($name, $old_delta, $delta) {
|
||||
public function update_block_bid($name, $old_delta, $delta) {
|
||||
$old_hashes = $hashes = variable_get('views_block_hashes', array());
|
||||
|
||||
$old_delta = $name . '-' . $old_delta;
|
||||
@@ -224,21 +233,22 @@ class views_plugin_display_block extends views_plugin_display {
|
||||
|
||||
/**
|
||||
* Save the block cache setting in the blocks table if this block already
|
||||
* exists in the blocks table. Dirty fix until http://drupal.org/node/235673 gets in.
|
||||
* exists in the blocks table. Dirty fix until http://drupal.org/node/235673
|
||||
* gets in.
|
||||
*/
|
||||
function save_block_cache($delta, $cache_setting) {
|
||||
public function save_block_cache($delta, $cache_setting) {
|
||||
if (strlen($delta) >= 32) {
|
||||
$delta = md5($delta);
|
||||
}
|
||||
if (db_table_exists('block') && $bid = db_query("SELECT bid FROM {block} WHERE module = 'views' AND delta = :delta", array(
|
||||
':delta' => $delta))->fetchField()) {
|
||||
if (db_table_exists('block') && $bid = db_query("SELECT bid FROM {block} WHERE module = 'views' AND delta = :delta", array(':delta' => $delta))->fetchField()) {
|
||||
db_update('block')
|
||||
->fields(array(
|
||||
'cache' => $cache_setting,
|
||||
'cache' => $cache_setting,
|
||||
))
|
||||
->condition('module','views')
|
||||
->condition('module', 'views')
|
||||
->condition('delta', $delta)
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the default display plugin.
|
||||
* Definition of views_plugin_display_default.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -11,11 +11,14 @@
|
||||
* @ingroup views_display_plugins
|
||||
*/
|
||||
class views_plugin_display_default extends views_plugin_display {
|
||||
|
||||
/**
|
||||
* Determine if this display is the 'default' display which contains
|
||||
* fallback settings
|
||||
* fallback settings.
|
||||
*/
|
||||
function is_default_display() { return TRUE; }
|
||||
public function is_default_display() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default execute handler fully renders the view.
|
||||
@@ -26,32 +29,34 @@ class views_plugin_display_default extends views_plugin_display {
|
||||
* @endcode
|
||||
*
|
||||
* For more complex usages, a view can be partially built:
|
||||
*
|
||||
* @code
|
||||
* $view->set_arguments($args);
|
||||
* $view->build('default'); // Build the query
|
||||
* $view->build('default'); // Build the query.
|
||||
* $view->pre_execute(); // Pre-execute the query.
|
||||
* $view->execute(); // Run the query
|
||||
* $output = $view->render(); // Render the view
|
||||
* $view->execute(); // Run the query.
|
||||
* $output = $view->render(); // Render the view.
|
||||
* @endcode
|
||||
*
|
||||
* If short circuited at any point, look in $view->build_info for
|
||||
* information about the query. After execute, look in $view->result
|
||||
* for the array of objects returned from db_query.
|
||||
* If short circuited at any point, look in $view->build_info for information
|
||||
* about the query. After execute, look in $view->result for the array of
|
||||
* objects returned from db_query.
|
||||
*
|
||||
* You can also do:
|
||||
*
|
||||
* @code
|
||||
* $view->set_arguments($args);
|
||||
* $output = $view->render('default'); // Render the view
|
||||
* $output = $view->render('default'); // Render the view.
|
||||
* @endcode
|
||||
*
|
||||
* This illustrates that render is smart enough to call build and execute
|
||||
* if these items have not already been accomplished.
|
||||
* This illustrates that render is smart enough to call build and execute if
|
||||
* these items have not already been accomplished.
|
||||
*
|
||||
* Note that execute also must accomplish other tasks, such
|
||||
* as setting page titles, breadcrumbs, and generating exposed filter
|
||||
* data if necessary.
|
||||
* Note that execute also must accomplish other tasks, such as setting page
|
||||
* titles, breadcrumbs, and generating exposed filter data if necessary.
|
||||
*/
|
||||
function execute() {
|
||||
public function execute() {
|
||||
return $this->view->render($this->display->id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the embed display plugin.
|
||||
* Definition of views_plugin_display_embed.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@@ -11,52 +11,64 @@
|
||||
* @ingroup views_display_plugins
|
||||
*/
|
||||
class views_plugin_display_extender extends views_plugin {
|
||||
function init(&$view, &$display) {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init(&$view, &$display) {
|
||||
$this->view = $view;
|
||||
$this->display = $display;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a form to edit options for this plugin.
|
||||
*/
|
||||
public function options_definition_alter(&$options) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a form to edit options for this plugin.
|
||||
*/
|
||||
function options_definition_alter(&$options) { }
|
||||
|
||||
/**
|
||||
* Provide a form to edit options for this plugin.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) { }
|
||||
public function options_form(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the options form.
|
||||
*/
|
||||
function options_validate(&$form, &$form_state) { }
|
||||
public function options_validate(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle any special handling on the validate form.
|
||||
*/
|
||||
function options_submit(&$form, &$form_state) { }
|
||||
public function options_submit(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up any variables on the view prior to execution.
|
||||
*/
|
||||
function pre_execute() { }
|
||||
public function pre_execute() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject anything into the query that the display_extender handler needs.
|
||||
*/
|
||||
function query() { }
|
||||
public function query() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the default summary for options in the views UI.
|
||||
*
|
||||
* This output is returned as an array.
|
||||
*/
|
||||
function options_summary(&$categories, &$options) { }
|
||||
public function options_summary(&$categories, &$options) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Static member function to list which sections are defaultable
|
||||
* and what items each section contains.
|
||||
*/
|
||||
function defaultable_sections(&$sections, $section = NULL) { }
|
||||
public function defaultable_sections(&$sections, $section = NULL) {
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the feed display plugin.
|
||||
* Definition of views_plugin_display_feed.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -13,7 +13,11 @@
|
||||
* @ingroup views_display_plugins
|
||||
*/
|
||||
class views_plugin_display_feed extends views_plugin_display_page {
|
||||
function init(&$view, &$display, $options = NULL) {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init(&$view, &$display, $options = NULL) {
|
||||
parent::init($view, $display, $options);
|
||||
|
||||
// Set the default row style. Ideally this would be part of the option
|
||||
@@ -26,23 +30,40 @@ class views_plugin_display_feed extends views_plugin_display_page {
|
||||
}
|
||||
}
|
||||
|
||||
function uses_breadcrumb() { return FALSE; }
|
||||
function get_style_type() { return 'feed'; }
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function uses_breadcrumb() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_style_type() {
|
||||
return 'feed';
|
||||
}
|
||||
|
||||
/**
|
||||
* Feeds do not go through the normal page theming mechanism. Instead, they
|
||||
* go through their own little theme function and then return NULL so that
|
||||
* Drupal believes that the page has already rendered itself...which it has.
|
||||
*/
|
||||
function execute() {
|
||||
public function execute() {
|
||||
$output = $this->view->render();
|
||||
if (!empty($this->view->build_info['denied'])) {
|
||||
return MENU_ACCESS_DENIED;
|
||||
}
|
||||
if (empty($output)) {
|
||||
return MENU_NOT_FOUND;
|
||||
}
|
||||
print $output;
|
||||
}
|
||||
|
||||
function preview() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function preview() {
|
||||
if (!empty($this->view->live_preview)) {
|
||||
return '<pre>' . check_plain($this->view->render()) . '</pre>';
|
||||
}
|
||||
@@ -53,11 +74,14 @@ class views_plugin_display_feed extends views_plugin_display_page {
|
||||
* Instead of going through the standard views_view.tpl.php, delegate this
|
||||
* to the style handler.
|
||||
*/
|
||||
function render() {
|
||||
public function render() {
|
||||
return $this->view->style_plugin->render($this->view->result);
|
||||
}
|
||||
|
||||
function defaultable_sections($section = NULL) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultable_sections($section = NULL) {
|
||||
if (in_array($section, array('style_options', 'style_plugin', 'row_options', 'row_plugin',))) {
|
||||
return FALSE;
|
||||
}
|
||||
@@ -74,12 +98,15 @@ class views_plugin_display_feed extends views_plugin_display_page {
|
||||
return $sections;
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['displays'] = array('default' => array());
|
||||
|
||||
// Overrides for standard stuff:
|
||||
// Overrides for standard stuff.
|
||||
$options['style_plugin']['default'] = 'rss';
|
||||
$options['style_options']['default'] = array('description' => '');
|
||||
$options['sitename_title']['default'] = FALSE;
|
||||
@@ -92,8 +119,11 @@ class views_plugin_display_feed extends views_plugin_display_page {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_summary(&$categories, &$options) {
|
||||
// It is very important to call the parent function here:
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_summary(&$categories, &$options) {
|
||||
// It is very important to call the parent function here.
|
||||
parent::options_summary($categories, $options);
|
||||
|
||||
// Since we're childing off the 'page' type, we'll still *call* our
|
||||
@@ -138,7 +168,7 @@ class views_plugin_display_feed extends views_plugin_display_page {
|
||||
/**
|
||||
* Provide the default form for setting options.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
// It is very important to call the parent function here.
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
@@ -155,6 +185,7 @@ class views_plugin_display_feed extends views_plugin_display_page {
|
||||
$form['title'] = $title;
|
||||
$form['title']['#dependency'] = array('edit-sitename-title' => array(FALSE));
|
||||
break;
|
||||
|
||||
case 'displays':
|
||||
$form['#title'] .= t('Attach to');
|
||||
$displays = array();
|
||||
@@ -170,8 +201,10 @@ class views_plugin_display_feed extends views_plugin_display_page {
|
||||
'#default_value' => $this->get_option('displays'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'path':
|
||||
$form['path']['#description'] = t('This view will be displayed by visiting this path on your site. It is recommended that the path be something like "path/%/%/feed" or "path/%/%/rss.xml", putting one % in the path for each contextual filter you have defined in the view.');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,13 +212,14 @@ class views_plugin_display_feed extends views_plugin_display_page {
|
||||
* Perform any necessary changes to the form values prior to storage.
|
||||
* There is no need for this function to actually store the data.
|
||||
*/
|
||||
function options_submit(&$form, &$form_state) {
|
||||
// It is very important to call the parent function here:
|
||||
public function options_submit(&$form, &$form_state) {
|
||||
// It is very important to call the parent function here.
|
||||
parent::options_submit($form, $form_state);
|
||||
switch ($form_state['section']) {
|
||||
case 'title':
|
||||
$this->set_option('sitename_title', $form_state['values']['sitename_title']);
|
||||
break;
|
||||
|
||||
case 'displays':
|
||||
$this->set_option($form_state['section'], $form_state['values'][$form_state['section']]);
|
||||
break;
|
||||
@@ -195,7 +229,7 @@ class views_plugin_display_feed extends views_plugin_display_page {
|
||||
/**
|
||||
* Attach to another view.
|
||||
*/
|
||||
function attach_to($display_id) {
|
||||
public function attach_to($display_id) {
|
||||
$displays = $this->get_option('displays');
|
||||
if (empty($displays[$display_id])) {
|
||||
return;
|
||||
@@ -216,7 +250,11 @@ class views_plugin_display_feed extends views_plugin_display_page {
|
||||
}
|
||||
}
|
||||
|
||||
function uses_link_display() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function uses_link_display() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the page display plugin.
|
||||
* Definition of views_plugin_display_page.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -11,13 +11,25 @@
|
||||
* @ingroup views_display_plugins
|
||||
*/
|
||||
class views_plugin_display_page extends views_plugin_display {
|
||||
|
||||
/**
|
||||
* The page display has a path.
|
||||
*/
|
||||
function has_path() { return TRUE; }
|
||||
function uses_breadcrumb() { return TRUE; }
|
||||
public function has_path() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function uses_breadcrumb() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['path'] = array('default' => '');
|
||||
@@ -50,7 +62,7 @@ class views_plugin_display_page extends views_plugin_display {
|
||||
/**
|
||||
* Add this display's path information to Drupal's menu system.
|
||||
*/
|
||||
function execute_hook_menu($callbacks) {
|
||||
public function execute_hook_menu($callbacks) {
|
||||
$items = array();
|
||||
// Replace % with the link to our standard views argument loader
|
||||
// views_arg_load -- which lives in views.module
|
||||
@@ -79,7 +91,8 @@ class views_plugin_display_page extends views_plugin_display {
|
||||
$access_plugin = views_get_plugin('access', 'none');
|
||||
}
|
||||
|
||||
// Get access callback might return an array of the callback + the dynamic arguments.
|
||||
// Get access callback might return an array of the callback + the dynamic
|
||||
// arguments.
|
||||
$access_plugin_callback = $access_plugin->get_access_callback();
|
||||
|
||||
if (is_array($access_plugin_callback)) {
|
||||
@@ -140,17 +153,23 @@ class views_plugin_display_page extends views_plugin_display {
|
||||
default:
|
||||
$items[$path]['type'] = MENU_CALLBACK;
|
||||
break;
|
||||
|
||||
case 'normal':
|
||||
$items[$path]['type'] = MENU_NORMAL_ITEM;
|
||||
// Insert item into the proper menu
|
||||
$items[$path]['menu_name'] = $menu['name'];
|
||||
break;
|
||||
|
||||
case 'tab':
|
||||
$items[$path]['type'] = MENU_LOCAL_TASK;
|
||||
break;
|
||||
|
||||
case 'default tab':
|
||||
$items[$path]['type'] = MENU_DEFAULT_LOCAL_TASK;
|
||||
break;
|
||||
case 'local action':
|
||||
$items[$path]['type'] = MENU_LOCAL_ACTION;
|
||||
break;
|
||||
}
|
||||
|
||||
// Add context for contextual links.
|
||||
@@ -169,7 +188,7 @@ class views_plugin_display_page extends views_plugin_display {
|
||||
$bit = array_pop($bits);
|
||||
|
||||
// we can't do this if they tried to make the last path bit variable.
|
||||
// @todo: We can validate this.
|
||||
// @todo We can validate this.
|
||||
if ($bit != '%views_arg' && !empty($bits)) {
|
||||
$default_path = implode('/', $bits);
|
||||
$items[$default_path] = array(
|
||||
@@ -192,6 +211,7 @@ class views_plugin_display_page extends views_plugin_display {
|
||||
case 'normal':
|
||||
$items[$default_path]['type'] = MENU_NORMAL_ITEM;
|
||||
break;
|
||||
|
||||
case 'tab':
|
||||
$items[$default_path]['type'] = MENU_LOCAL_TASK;
|
||||
break;
|
||||
@@ -212,7 +232,7 @@ class views_plugin_display_page extends views_plugin_display {
|
||||
* a drupal_set_title for the page, and does a views_set_page_view
|
||||
* on the view.
|
||||
*/
|
||||
function execute() {
|
||||
public function execute() {
|
||||
// Let the world know that this is the page view we're using.
|
||||
views_set_page_view($this->view);
|
||||
|
||||
@@ -250,8 +270,8 @@ class views_plugin_display_page extends views_plugin_display {
|
||||
*
|
||||
* This output is returned as an array.
|
||||
*/
|
||||
function options_summary(&$categories, &$options) {
|
||||
// It is very important to call the parent function here:
|
||||
public function options_summary(&$categories, &$options) {
|
||||
// It is very important to call the parent function here.
|
||||
parent::options_summary($categories, $options);
|
||||
|
||||
$categories['page'] = array(
|
||||
@@ -280,18 +300,22 @@ class views_plugin_display_page extends views_plugin_display {
|
||||
if (!is_array($menu)) {
|
||||
$menu = array('type' => 'none');
|
||||
}
|
||||
switch($menu['type']) {
|
||||
switch ($menu['type']) {
|
||||
case 'none':
|
||||
default:
|
||||
$menu_str = t('No menu');
|
||||
break;
|
||||
|
||||
case 'normal':
|
||||
$menu_str = t('Normal: @title', array('@title' => $menu['title']));
|
||||
break;
|
||||
|
||||
case 'tab':
|
||||
case 'default tab':
|
||||
$menu_str = t('Tab: @title', array('@title' => $menu['title']));
|
||||
break;
|
||||
case 'local action':
|
||||
$menu_str = t('Local action: @title', array('@title' => $menu['title']));
|
||||
}
|
||||
|
||||
$options['menu'] = array(
|
||||
@@ -300,7 +324,8 @@ class views_plugin_display_page extends views_plugin_display {
|
||||
'value' => views_ui_truncate($menu_str, 24),
|
||||
);
|
||||
|
||||
// This adds a 'Settings' link to the style_options setting if the style has options.
|
||||
// This adds a 'Settings' link to the style_options setting if the style
|
||||
// has options.
|
||||
if ($menu['type'] == 'default tab') {
|
||||
$options['menu']['setting'] = t('Parent menu item');
|
||||
$options['menu']['links']['tab_options'] = t('Change settings for the parent menu');
|
||||
@@ -310,8 +335,8 @@ class views_plugin_display_page extends views_plugin_display {
|
||||
/**
|
||||
* Provide the default form for setting options.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
// It is very important to call the parent function here:
|
||||
public function options_form(&$form, &$form_state) {
|
||||
// It is very important to call the parent function here.
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
switch ($form_state['section']) {
|
||||
@@ -322,11 +347,13 @@ 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 contextual filters: For example, "node/%/feed".'),
|
||||
'#default_value' => $this->get_option('path'),
|
||||
'#field_prefix' => '<span dir="ltr">' . url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
|
||||
'#field_suffix' => '</span>‎',
|
||||
'#attributes' => array('dir'=>'ltr'),
|
||||
'#field_prefix' => '<span dir="ltr">' . url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
|
||||
'#field_suffix' => '</span>‎',
|
||||
'#attributes' => array('dir'=>'ltr'),
|
||||
'#maxlength' => 255,
|
||||
);
|
||||
break;
|
||||
|
||||
case 'menu':
|
||||
$form['#title'] .= t('Menu item entry');
|
||||
$form['#help_topic'] = 'menu';
|
||||
@@ -339,6 +366,7 @@ class views_plugin_display_page extends views_plugin_display {
|
||||
if (empty($menu)) {
|
||||
$menu = array('type' => 'none', 'title' => '', 'weight' => 0);
|
||||
}
|
||||
$menu_type_dependencies = array('normal', 'tab', 'default tab', 'local action');
|
||||
$form['menu']['type'] = array(
|
||||
'#prefix' => '<div class="views-left-30">',
|
||||
'#suffix' => '</div>',
|
||||
@@ -348,7 +376,8 @@ class views_plugin_display_page extends views_plugin_display {
|
||||
'none' => t('No menu entry'),
|
||||
'normal' => t('Normal menu entry'),
|
||||
'tab' => t('Menu tab'),
|
||||
'default tab' => t('Default menu tab')
|
||||
'default tab' => t('Default menu tab'),
|
||||
'local action' => t('Local action'),
|
||||
),
|
||||
'#default_value' => $menu['type'],
|
||||
);
|
||||
@@ -358,14 +387,14 @@ class views_plugin_display_page extends views_plugin_display {
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => $menu['title'],
|
||||
'#description' => t('If set to normal or tab, enter the text to use for the menu item.'),
|
||||
'#dependency' => array('radio:menu[type]' => array('normal', 'tab', 'default tab')),
|
||||
'#dependency' => array('radio:menu[type]' => $menu_type_dependencies),
|
||||
);
|
||||
$form['menu']['description'] = array(
|
||||
'#title' => t('Description'),
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => $menu['description'],
|
||||
'#description' => t("If set to normal or tab, enter the text to use for the menu item's description."),
|
||||
'#dependency' => array('radio:menu[type]' => array('normal', 'tab', 'default tab')),
|
||||
'#dependency' => array('radio:menu[type]' => $menu_type_dependencies),
|
||||
);
|
||||
|
||||
// Only display the menu selector if menu module is enabled.
|
||||
@@ -393,7 +422,7 @@ class views_plugin_display_page extends views_plugin_display {
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => isset($menu['weight']) ? $menu['weight'] : 0,
|
||||
'#description' => t('The lower the weight the higher/further left it will appear.'),
|
||||
'#dependency' => array('radio:menu[type]' => array('normal', 'tab', 'default tab')),
|
||||
'#dependency' => array('radio:menu[type]' => $menu_type_dependencies),
|
||||
);
|
||||
$form['menu']['context'] = array(
|
||||
'#title' => t('Context'),
|
||||
@@ -415,6 +444,7 @@ class views_plugin_display_page extends views_plugin_display {
|
||||
'#dependency_count' => 2,
|
||||
);
|
||||
break;
|
||||
|
||||
case 'tab_options':
|
||||
$form['#title'] .= t('Default tab options');
|
||||
$tab_options = $this->get_option('tab_options');
|
||||
@@ -480,15 +510,18 @@ class views_plugin_display_page extends views_plugin_display {
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => $tab_options['weight'],
|
||||
'#size' => 5,
|
||||
'#description' => t('If the parent menu item is a tab, enter the weight of the tab. The lower the number, the more to the left it will be.'),
|
||||
'#dependency' => array('radio:tab_options[type]' => array('tab')),
|
||||
'#description' => t('Enter the weight of the item. The lower the number, the more to the left it will be.'),
|
||||
'#dependency' => array('radio:tab_options[type]' => array('normal', 'tab')),
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function options_validate(&$form, &$form_state) {
|
||||
// It is very important to call the parent function here:
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_validate(&$form, &$form_state) {
|
||||
// It is very important to call the parent function here.
|
||||
parent::options_validate($form, $form_state);
|
||||
switch ($form_state['section']) {
|
||||
case 'path':
|
||||
@@ -500,9 +533,10 @@ class views_plugin_display_page extends views_plugin_display {
|
||||
form_error($form['path'], t('"%" may not be used for the first segment of a path.'));
|
||||
}
|
||||
|
||||
// automatically remove '/' and trailing whitespace from path.
|
||||
// Automatically remove '/' and trailing whitespace from path.
|
||||
$form_state['values']['path'] = trim($form_state['values']['path'], '/ ');
|
||||
break;
|
||||
|
||||
case 'menu':
|
||||
$path = $this->get_option('path');
|
||||
if ($form_state['values']['menu']['type'] == 'normal' && strpos($path, '%') !== FALSE) {
|
||||
@@ -524,27 +558,35 @@ class views_plugin_display_page extends views_plugin_display {
|
||||
}
|
||||
}
|
||||
|
||||
function options_submit(&$form, &$form_state) {
|
||||
// It is very important to call the parent function here:
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_submit(&$form, &$form_state) {
|
||||
// It is very important to call the parent function here.
|
||||
parent::options_submit($form, $form_state);
|
||||
switch ($form_state['section']) {
|
||||
case 'path':
|
||||
$this->set_option('path', $form_state['values']['path']);
|
||||
break;
|
||||
|
||||
case 'menu':
|
||||
$this->set_option('menu', $form_state['values']['menu']);
|
||||
// send ajax form to options page if we use it.
|
||||
// Send ajax form to options page if we use it.
|
||||
if ($form_state['values']['menu']['type'] == 'default tab') {
|
||||
views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('tab_options'));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'tab_options':
|
||||
$this->set_option('tab_options', $form_state['values']['tab_options']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function validate() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validate() {
|
||||
$errors = parent::validate();
|
||||
|
||||
$menu = $this->get_option('menu');
|
||||
@@ -562,7 +604,10 @@ class views_plugin_display_page extends views_plugin_display {
|
||||
return $errors;
|
||||
}
|
||||
|
||||
function get_argument_text() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_argument_text() {
|
||||
return array(
|
||||
'filter value not present' => t('When the filter value is <em>NOT</em> in the URL'),
|
||||
'filter value present' => t('When the filter value <em>IS</em> in the URL or a default is provided'),
|
||||
@@ -570,10 +615,14 @@ class views_plugin_display_page extends views_plugin_display {
|
||||
);
|
||||
}
|
||||
|
||||
function get_pager_text() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_pager_text() {
|
||||
return array(
|
||||
'items per page title' => t('Items per page'),
|
||||
'items per page description' => t('The number of items to display per page. Enter 0 for no limit.')
|
||||
'items per page description' => t('The number of items to display per page. Enter 0 for no limit.'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -23,19 +23,24 @@ class views_plugin_exposed_form extends views_plugin {
|
||||
/**
|
||||
* Initialize the plugin.
|
||||
*
|
||||
* @param $view
|
||||
* @param object $view
|
||||
* The view object.
|
||||
* @param $display
|
||||
* @param object $display
|
||||
* The display handler.
|
||||
* @param array $options
|
||||
* Any additional options that are being added.
|
||||
*/
|
||||
function init(&$view, &$display, $options = array()) {
|
||||
public function init(&$view, &$display, $options = array()) {
|
||||
$this->view = &$view;
|
||||
$this->display = &$display;
|
||||
|
||||
$this->unpack_options($this->options, $options);
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['submit_button'] = array('default' => 'Apply', 'translatable' => TRUE);
|
||||
$options['reset_button'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
@@ -49,7 +54,10 @@ class views_plugin_exposed_form extends views_plugin {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['submit_button'] = array(
|
||||
'#type' => 'textfield',
|
||||
@@ -120,7 +128,7 @@ class views_plugin_exposed_form extends views_plugin {
|
||||
$form['autosubmit_hide'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Hide submit button'),
|
||||
'#description' => t('Hide submit button if javascript is enabled.'),
|
||||
'#description' => t('Hide submit button if JavaScript is enabled.'),
|
||||
'#default_value' => $this->options['autosubmit_hide'],
|
||||
'#dependency' => array(
|
||||
'edit-exposed-form-options-autosubmit' => array(1),
|
||||
@@ -135,7 +143,7 @@ class views_plugin_exposed_form extends views_plugin {
|
||||
* also assign data to the appropriate handlers for use in building the
|
||||
* query.
|
||||
*/
|
||||
function render_exposed_form($block = FALSE) {
|
||||
public function render_exposed_form($block = FALSE) {
|
||||
// Deal with any exposed filters we may have, before building.
|
||||
$form_state = array(
|
||||
'view' => &$this->view,
|
||||
@@ -169,7 +177,10 @@ class views_plugin_exposed_form extends views_plugin {
|
||||
}
|
||||
}
|
||||
|
||||
function query() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$view = $this->view;
|
||||
$exposed_data = isset($view->exposed_data) ? $view->exposed_data : array();
|
||||
$sort_by = isset($exposed_data['sort_by']) ? $exposed_data['sort_by'] : NULL;
|
||||
@@ -182,7 +193,7 @@ class views_plugin_exposed_form extends views_plugin {
|
||||
if (!$sort->is_exposed()) {
|
||||
$sort->query();
|
||||
}
|
||||
else if ($key == $sort_by) {
|
||||
elseif ($key == $sort_by) {
|
||||
if (isset($exposed_data['sort_order']) && in_array($exposed_data['sort_order'], array('ASC', 'DESC'))) {
|
||||
$sort->options['order'] = $exposed_data['sort_order'];
|
||||
}
|
||||
@@ -194,15 +205,34 @@ class views_plugin_exposed_form extends views_plugin {
|
||||
}
|
||||
}
|
||||
|
||||
function pre_render($values) { }
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function pre_render($values) {
|
||||
}
|
||||
|
||||
function post_render(&$output) { }
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function post_render(&$output) {
|
||||
}
|
||||
|
||||
function pre_execute() { }
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function pre_execute() {
|
||||
}
|
||||
|
||||
function post_execute() { }
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function post_execute() {
|
||||
}
|
||||
|
||||
function exposed_form_alter(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function exposed_form_alter(&$form, &$form_state) {
|
||||
if (!empty($this->options['reset_button'])) {
|
||||
$form['reset'] = array(
|
||||
'#value' => $this->options['reset_button_label'],
|
||||
@@ -231,7 +261,8 @@ class views_plugin_exposed_form extends views_plugin {
|
||||
);
|
||||
if (isset($form_state['input']['sort_by']) && isset($this->view->sort[$form_state['input']['sort_by']])) {
|
||||
$default_sort_order = $this->view->sort[$form_state['input']['sort_by']]->options['order'];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$first_sort = reset($this->view->sort);
|
||||
$default_sort_order = $first_sort->options['order'];
|
||||
}
|
||||
@@ -275,7 +306,10 @@ class views_plugin_exposed_form extends views_plugin {
|
||||
}
|
||||
}
|
||||
|
||||
function exposed_form_validate(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function exposed_form_validate(&$form, &$form_state) {
|
||||
if (isset($form_state['pager_plugin'])) {
|
||||
$form_state['pager_plugin']->exposed_form_validate($form, $form_state);
|
||||
}
|
||||
@@ -284,15 +318,14 @@ class views_plugin_exposed_form extends views_plugin {
|
||||
/**
|
||||
* This function is executed when exposed form is submited.
|
||||
*
|
||||
* @param $form
|
||||
* @param array $form
|
||||
* Nested array of form elements that comprise the form.
|
||||
* @param $form_state
|
||||
* @param array $form_state
|
||||
* A keyed array containing the current state of the form.
|
||||
* @param $exclude
|
||||
* Nested array of keys to exclude of insert into
|
||||
* $view->exposed_raw_input
|
||||
* @param array $exclude
|
||||
* Nested array of keys to exclude of insert into $view->exposed_raw_input.
|
||||
*/
|
||||
function exposed_form_submit(&$form, &$form_state, &$exclude) {
|
||||
public function exposed_form_submit(&$form, &$form_state, &$exclude) {
|
||||
if (!empty($form_state['values']['op']) && $form_state['values']['op'] == $this->options['reset_button_label']) {
|
||||
$this->reset_form($form, $form_state);
|
||||
}
|
||||
@@ -302,7 +335,10 @@ class views_plugin_exposed_form extends views_plugin {
|
||||
}
|
||||
}
|
||||
|
||||
function reset_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function reset_form(&$form, &$form_state) {
|
||||
// _SESSION is not defined for users who are not logged in.
|
||||
|
||||
// If filters are not overridden, store the 'remember' settings on the
|
||||
@@ -327,6 +363,7 @@ class views_plugin_exposed_form extends views_plugin {
|
||||
$form_state['redirect'] = current_path();
|
||||
$form_state['values'] = array();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -10,4 +10,6 @@
|
||||
*
|
||||
* @ingroup views_exposed_form_plugins
|
||||
*/
|
||||
class views_plugin_exposed_form_basic extends views_plugin_exposed_form { }
|
||||
class views_plugin_exposed_form_basic extends views_plugin_exposed_form {
|
||||
// Nothing to see here.
|
||||
}
|
||||
|
@@ -12,7 +12,10 @@
|
||||
*/
|
||||
class views_plugin_exposed_form_input_required extends views_plugin_exposed_form {
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['text_input_required'] = array('default' => 'Select any filter and click on Apply to see results', 'translatable' => TRUE);
|
||||
@@ -20,7 +23,10 @@ class views_plugin_exposed_form_input_required extends views_plugin_exposed_form
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$form['text_input_required'] = array(
|
||||
@@ -33,13 +39,19 @@ class views_plugin_exposed_form_input_required extends views_plugin_exposed_form
|
||||
);
|
||||
}
|
||||
|
||||
function options_submit(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_submit(&$form, &$form_state) {
|
||||
$form_state['values']['exposed_form_options']['text_input_required_format'] = $form_state['values']['exposed_form_options']['text_input_required']['format'];
|
||||
$form_state['values']['exposed_form_options']['text_input_required'] = $form_state['values']['exposed_form_options']['text_input_required']['value'];
|
||||
parent::options_submit($form, $form_state);
|
||||
}
|
||||
|
||||
function exposed_filter_applied() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function exposed_filter_applied() {
|
||||
static $cache = NULL;
|
||||
if (!isset($cache)) {
|
||||
$view = $this->view;
|
||||
@@ -60,7 +72,10 @@ class views_plugin_exposed_form_input_required extends views_plugin_exposed_form
|
||||
return $cache;
|
||||
}
|
||||
|
||||
function pre_render($values) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function pre_render($values) {
|
||||
if (!$this->exposed_filter_applied()) {
|
||||
$options = array(
|
||||
'id' => 'area',
|
||||
@@ -82,7 +97,10 @@ class views_plugin_exposed_form_input_required extends views_plugin_exposed_form
|
||||
}
|
||||
}
|
||||
|
||||
function query() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
if (!$this->exposed_filter_applied()) {
|
||||
// We return with no query; this will force the empty text.
|
||||
$this->view->built = TRUE;
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the base class for views localization plugins.
|
||||
* Definition of views_plugin_localization.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -17,22 +17,29 @@
|
||||
* The base plugin to handle localization of Views strings.
|
||||
*/
|
||||
class views_plugin_localization extends views_plugin {
|
||||
// Store for exported strings
|
||||
var $export_strings = array();
|
||||
var $translate = TRUE;
|
||||
|
||||
/**
|
||||
* Store for exported strings.
|
||||
*/
|
||||
public $export_strings = array();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public $translate = TRUE;
|
||||
|
||||
/**
|
||||
* Initialize the plugin.
|
||||
*
|
||||
* @param $view
|
||||
* @param view $view
|
||||
* The view object.
|
||||
*/
|
||||
function init(&$view) {
|
||||
public function init(&$view) {
|
||||
$this->view = &$view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate a string / text with format
|
||||
* Translate a string / text with format.
|
||||
*
|
||||
* The $source parameter is an array with the following elements:
|
||||
* - value, source string
|
||||
@@ -40,14 +47,15 @@ class views_plugin_localization extends views_plugin {
|
||||
* - keys. An array of keys to identify the string. Generally constructed from
|
||||
* view name, display_id, and a property, e.g., 'header'.
|
||||
*
|
||||
* @param $source
|
||||
* @param string $source
|
||||
* Full data for the string to be translated.
|
||||
*
|
||||
* @return string
|
||||
* Translated string / text
|
||||
* Translated string / text.
|
||||
*/
|
||||
function translate($source) {
|
||||
// Allow other modules to make changes to the string before and after translation
|
||||
public function translate($source) {
|
||||
// Allow other modules to make changes to the string before and after
|
||||
// translation.
|
||||
$source['pre_process'] = $this->invoke_translation_process($source, 'pre');
|
||||
$source['translation'] = $this->translate_string($source['value'], $source['keys'], $source['format']);
|
||||
$source['post_process'] = $this->invoke_translation_process($source, 'post');
|
||||
@@ -57,64 +65,67 @@ class views_plugin_localization extends views_plugin {
|
||||
/**
|
||||
* Translate a string.
|
||||
*
|
||||
* @param $string
|
||||
* @param string $string
|
||||
* The string to be translated.
|
||||
* @param $keys
|
||||
* @param array $keys
|
||||
* An array of keys to identify the string. Generally constructed from
|
||||
* view name, display_id, and a property, e.g., 'header'.
|
||||
* @param $format
|
||||
* view name, display_id, and a property, e.g. 'header'.
|
||||
* @param string $format
|
||||
* The input format of the string. This is optional.
|
||||
*/
|
||||
function translate_string($string, $keys = array(), $format = '') {}
|
||||
public function translate_string($string, $keys = array(), $format = '') {}
|
||||
|
||||
/**
|
||||
* Save string source for translation.
|
||||
*
|
||||
* @param $source
|
||||
* @param string $source
|
||||
* Full data for the string to be translated.
|
||||
*/
|
||||
function save($source) {
|
||||
// Allow other modules to make changes to the string before saving
|
||||
public function save($source) {
|
||||
// Allow other modules to make changes to the string before saving.
|
||||
$source['pre_process'] = $this->invoke_translation_process($source, 'pre');
|
||||
$this->save_string($source['value'], $source['keys'], isset($source['format']) ? $source['format'] : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a string for translation
|
||||
* Save a string for translation.
|
||||
*
|
||||
* @param $string
|
||||
* @param string $string
|
||||
* The string to be translated.
|
||||
* @param $keys
|
||||
* @param array $keys
|
||||
* An array of keys to identify the string. Generally constructed from
|
||||
* view name, display_id, and a property, e.g., 'header'.
|
||||
* @param $format
|
||||
* @param string $format
|
||||
* The input format of the string. This is optional.
|
||||
*/
|
||||
function save_string($string, $keys = array(), $format = '') {}
|
||||
public function save_string($string, $keys = array(), $format = '') {}
|
||||
|
||||
/**
|
||||
* Delete a string.
|
||||
*
|
||||
* @param $source
|
||||
* @param string $source
|
||||
* Full data for the string to be translated.
|
||||
*/
|
||||
function delete($source) { }
|
||||
public function delete($source) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect strings to be exported to code.
|
||||
*
|
||||
* @param $source
|
||||
* @param string $source
|
||||
* Full data for the string to be translated.
|
||||
*/
|
||||
function export($source) { }
|
||||
public function export($source) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Render any collected exported strings to code.
|
||||
*
|
||||
* @param $indent
|
||||
* @param string $indent
|
||||
* An optional indentation for prettifying nested code.
|
||||
*/
|
||||
function export_render($indent = ' ') { }
|
||||
public function export_render($indent = ' ') {
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke hook_translation_pre_process() or hook_translation_post_process().
|
||||
@@ -122,7 +133,7 @@ class views_plugin_localization extends views_plugin {
|
||||
* Like node_invoke_nodeapi(), this function is needed to enable both passing
|
||||
* by reference and fetching return values.
|
||||
*/
|
||||
function invoke_translation_process(&$value, $op) {
|
||||
public function invoke_translation_process(&$value, $op) {
|
||||
$return = array();
|
||||
$hook = 'translation_' . $op . '_process';
|
||||
foreach (module_implements($hook) as $module) {
|
||||
@@ -135,7 +146,10 @@ class views_plugin_localization extends views_plugin {
|
||||
return $return;
|
||||
}
|
||||
|
||||
function process_locale_strings($op) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function process_locale_strings($op) {
|
||||
$this->view->init_display();
|
||||
|
||||
foreach ($this->view->display as $display_id => $display) {
|
||||
@@ -154,9 +168,11 @@ class views_plugin_localization extends views_plugin {
|
||||
case 'save':
|
||||
$this->save($data);
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
$this->delete($data);
|
||||
break;
|
||||
|
||||
case 'export':
|
||||
$this->export($data);
|
||||
break;
|
||||
@@ -164,6 +180,7 @@ class views_plugin_localization extends views_plugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the Drupal core localization plugin.
|
||||
* Definition of views_plugin_localization_core.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -15,35 +15,35 @@ class views_plugin_localization_core extends views_plugin_localization {
|
||||
/**
|
||||
* Translate a string.
|
||||
*
|
||||
* @param $string
|
||||
* @param string $string
|
||||
* The string to be translated.
|
||||
* @param $keys
|
||||
* @param array $keys
|
||||
* An array of keys to identify the string. Generally constructed from
|
||||
* view name, display_id, and a property, e.g., 'header'.
|
||||
* @param $format
|
||||
* @param string $format
|
||||
* The input format of the string. This is optional.
|
||||
*/
|
||||
function translate_string($string, $keys = array(), $format = '') {
|
||||
public function translate_string($string, $keys = array(), $format = '') {
|
||||
return t($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a string for translation.
|
||||
*
|
||||
* @param $string
|
||||
* @param string $string
|
||||
* The string to be translated.
|
||||
* @param $keys
|
||||
* @param array $keys
|
||||
* An array of keys to identify the string. Generally constructed from
|
||||
* view name, display_id, and a property, e.g., 'header'.
|
||||
* @param $format
|
||||
* @param string $format
|
||||
* The input format of the string. This is optional.
|
||||
*/
|
||||
function save_string($string, $keys = array(), $format = '') {
|
||||
public function save_string($string, $keys = array(), $format = '') {
|
||||
global $language;
|
||||
|
||||
// If the current language is 'en', we need to reset the language
|
||||
// in order to trigger an update.
|
||||
// TODO: add test for number of languages.
|
||||
// @todo add test for number of languages.
|
||||
if ($language->language == 'en') {
|
||||
$changed = TRUE;
|
||||
$languages = language_list();
|
||||
@@ -67,22 +67,23 @@ class views_plugin_localization_core extends views_plugin_localization {
|
||||
*
|
||||
* Deletion is not supported.
|
||||
*
|
||||
* @param $source
|
||||
* @param mixed $source
|
||||
* Full data for the string to be translated.
|
||||
*/
|
||||
function delete($source) {
|
||||
public function delete($source) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect strings to be exported to code.
|
||||
*
|
||||
* String identifiers are not supported so strings are anonymously in an array.
|
||||
* String identifiers are not supported so strings are anonymously in an
|
||||
* array.
|
||||
*
|
||||
* @param $source
|
||||
* @param array $source
|
||||
* Full data for the string to be translated.
|
||||
*/
|
||||
function export($source) {
|
||||
public function export($source) {
|
||||
if (!empty($source['value'])) {
|
||||
$this->export_strings[] = $source['value'];
|
||||
}
|
||||
@@ -91,10 +92,10 @@ class views_plugin_localization_core extends views_plugin_localization {
|
||||
/**
|
||||
* Render any collected exported strings to code.
|
||||
*
|
||||
* @param $indent
|
||||
* @param string $indent
|
||||
* An optional indentation for prettifying nested code.
|
||||
*/
|
||||
function export_render($indent = ' ') {
|
||||
public function export_render($indent = ' ') {
|
||||
$output = '';
|
||||
if (!empty($this->export_strings)) {
|
||||
$this->export_strings = array_unique($this->export_strings);
|
||||
@@ -106,4 +107,5 @@ class views_plugin_localization_core extends views_plugin_localization {
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the 'none' localization plugin.
|
||||
* Definition of views_plugin_localization_none.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -11,26 +11,31 @@
|
||||
* @ingroup views_localization_plugins
|
||||
*/
|
||||
class views_plugin_localization_none extends views_plugin_localization {
|
||||
var $translate = FALSE;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public $translate = FALSE;
|
||||
|
||||
/**
|
||||
* Translate a string; simply return the string.
|
||||
*/
|
||||
function translate($source) {
|
||||
public function translate($source) {
|
||||
return $source['value'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a string for translation; not supported.
|
||||
*/
|
||||
function save($source) {
|
||||
public function save($source) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a string; not supported.
|
||||
*/
|
||||
function delete($source) {
|
||||
public function delete($source) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -17,18 +17,26 @@
|
||||
* The base plugin to handle pager.
|
||||
*/
|
||||
class views_plugin_pager extends views_plugin {
|
||||
var $current_page = NULL;
|
||||
var $total_items = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public $current_page = NULL;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public $total_items = 0;
|
||||
|
||||
/**
|
||||
* Initialize the plugin.
|
||||
*
|
||||
* @param $view
|
||||
* @param view $view
|
||||
* The view object.
|
||||
* @param $display
|
||||
* @param object $display
|
||||
* The display handler.
|
||||
*/
|
||||
function init(&$view, &$display, $options = array()) {
|
||||
public function init(&$view, &$display, $options = array()) {
|
||||
$this->view = &$view;
|
||||
$this->display = &$display;
|
||||
|
||||
@@ -41,8 +49,8 @@ class views_plugin_pager extends views_plugin {
|
||||
* All but the leanest pagers should probably return a value here, so
|
||||
* most pagers will not need to override this method.
|
||||
*/
|
||||
function get_items_per_page() {
|
||||
return isset($this->options['items_per_page']) ? $this->options['items_per_page'] : 0;
|
||||
public function get_items_per_page() {
|
||||
return isset($this->options['items_per_page']) ? (int) $this->options['items_per_page'] : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,8 +58,8 @@ class views_plugin_pager extends views_plugin {
|
||||
*
|
||||
* This is mostly used for things that will override the value.
|
||||
*/
|
||||
function set_items_per_page($items) {
|
||||
$this->options['items_per_page'] = $items;
|
||||
public function set_items_per_page($items) {
|
||||
$this->options['items_per_page'] = (int) $items;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,15 +68,15 @@ class views_plugin_pager extends views_plugin {
|
||||
* Even pagers that don't actually page can skip items at the beginning,
|
||||
* so few pagers will need to override this method.
|
||||
*/
|
||||
function get_offset() {
|
||||
return isset($this->options['offset']) ? $this->options['offset'] : 0;
|
||||
public function get_offset() {
|
||||
return isset($this->options['offset']) ? (int) $this->options['offset'] : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the page offset, or how many items to skip.
|
||||
*/
|
||||
function set_offset($offset) {
|
||||
$this->options['offset'] = $offset;
|
||||
public function set_offset($offset) {
|
||||
$this->options['offset'] = (int) $offset;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,18 +84,18 @@ class views_plugin_pager extends views_plugin {
|
||||
*
|
||||
* If NULL, we do not know what the current page is.
|
||||
*/
|
||||
function get_current_page() {
|
||||
public function get_current_page() {
|
||||
return $this->current_page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current page.
|
||||
*
|
||||
* @param $number
|
||||
* @param int $number
|
||||
* If provided, the page number will be set to this. If NOT provided,
|
||||
* the page number will be set from the global page array.
|
||||
*/
|
||||
function set_current_page($number = NULL) {
|
||||
public function set_current_page($number = NULL) {
|
||||
if (!is_numeric($number) || $number < 0) {
|
||||
$number = 0;
|
||||
}
|
||||
@@ -99,32 +107,34 @@ class views_plugin_pager extends views_plugin {
|
||||
*
|
||||
* If NULL, we do not yet know what the total number of items are.
|
||||
*/
|
||||
function get_total_items() {
|
||||
public function get_total_items() {
|
||||
return $this->total_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pager id, if it exists
|
||||
* Get the pager id, if it exists.
|
||||
*/
|
||||
function get_pager_id() {
|
||||
public function get_pager_id() {
|
||||
return !empty($this->options['id']) ? $this->options['id'] : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the default form form for validating options
|
||||
* Provide the default form form for validating options.
|
||||
*/
|
||||
function options_validate(&$form, &$form_state) { }
|
||||
public function options_validate(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the default form form for submitting options
|
||||
* Provide the default form form for submitting options.
|
||||
*/
|
||||
function options_submit(&$form, &$form_state) { }
|
||||
public function options_submit(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string to display as the clickable title for the
|
||||
* pager plugin.
|
||||
*/
|
||||
function summary_title() {
|
||||
public function summary_title() {
|
||||
return t('Unknown');
|
||||
}
|
||||
|
||||
@@ -133,7 +143,7 @@ class views_plugin_pager extends views_plugin {
|
||||
*
|
||||
* Only a couple of very specific pagers will set this to false.
|
||||
*/
|
||||
function use_pager() {
|
||||
public function use_pager() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -142,7 +152,7 @@ class views_plugin_pager extends views_plugin {
|
||||
*
|
||||
* If a pager needs a count query, a simple query
|
||||
*/
|
||||
function use_count_query() {
|
||||
public function use_count_query() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -150,7 +160,7 @@ class views_plugin_pager extends views_plugin {
|
||||
* Execute the count query, which will be done just prior to the query
|
||||
* itself being executed.
|
||||
*/
|
||||
function execute_count_query(&$count_query) {
|
||||
public function execute_count_query(&$count_query) {
|
||||
$this->total_items = $count_query->execute()->fetchField();
|
||||
if (!empty($this->options['offset'])) {
|
||||
$this->total_items -= $this->options['offset'];
|
||||
@@ -164,8 +174,7 @@ class views_plugin_pager extends views_plugin {
|
||||
* If there are pagers that need global values set, this method can
|
||||
* be used to set them. It will be called when the count query is run.
|
||||
*/
|
||||
function update_page_info() {
|
||||
|
||||
public function update_page_info() {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,22 +182,26 @@ class views_plugin_pager extends views_plugin {
|
||||
*
|
||||
* This is called during the build phase and can directly modify the query.
|
||||
*/
|
||||
function query() { }
|
||||
public function query() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform any needed actions just prior to the query executing.
|
||||
*/
|
||||
function pre_execute(&$query) { }
|
||||
public function pre_execute(&$query) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform any needed actions just after the query executing.
|
||||
*/
|
||||
function post_execute(&$result) { }
|
||||
public function post_execute(&$result) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform any needed actions just before rendering.
|
||||
*/
|
||||
function pre_render(&$result) { }
|
||||
public function pre_render(&$result) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the pager.
|
||||
@@ -196,39 +209,62 @@ class views_plugin_pager extends views_plugin {
|
||||
* Called during the view render process, this will render the
|
||||
* pager.
|
||||
*
|
||||
* @param $input
|
||||
* @param array $input
|
||||
* Any extra GET parameters that should be retained, such as exposed
|
||||
* input.
|
||||
*/
|
||||
function render($input) { }
|
||||
public function render($input) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if there are more records available.
|
||||
*
|
||||
* This is primarily used to control the display of a more link.
|
||||
*/
|
||||
function has_more_records() {
|
||||
public function has_more_records() {
|
||||
return $this->get_items_per_page()
|
||||
&& $this->total_items > (intval($this->current_page) + 1) * $this->get_items_per_page();
|
||||
}
|
||||
|
||||
function exposed_form_alter(&$form, &$form_state) { }
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function exposed_form_alter(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
function exposed_form_validate(&$form, &$form_state) { }
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function exposed_form_validate(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
function exposed_form_submit(&$form, &$form_state, &$exclude) { }
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function exposed_form_submit(&$form, &$form_state, &$exclude) {
|
||||
}
|
||||
|
||||
function uses_exposed() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function uses_exposed() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function items_per_page_exposed() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function items_per_page_exposed() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function offset_exposed() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function offset_exposed() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -11,14 +11,21 @@
|
||||
* @ingroup views_pager_plugins
|
||||
*/
|
||||
class views_plugin_pager_full extends views_plugin_pager {
|
||||
function summary_title() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function summary_title() {
|
||||
if (!empty($this->options['offset'])) {
|
||||
return format_plural($this->options['items_per_page'], '@count item, skip @skip', 'Paged, @count items, skip @skip', array('@count' => $this->options['items_per_page'], '@skip' => $this->options['offset']));
|
||||
}
|
||||
return format_plural($this->options['items_per_page'], '@count item', 'Paged, @count items', array('@count' => $this->options['items_per_page']));
|
||||
return format_plural($this->options['items_per_page'], '@count item', 'Paged, @count items', array('@count' => $this->options['items_per_page']));
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['items_per_page'] = array('default' => 10);
|
||||
$options['offset'] = array('default' => 0);
|
||||
@@ -52,7 +59,7 @@ class views_plugin_pager_full extends views_plugin_pager {
|
||||
/**
|
||||
* Provide the default form for setting options.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$pager_text = $this->display->handler->get_pager_text();
|
||||
$form['items_per_page'] = array(
|
||||
@@ -90,7 +97,7 @@ class views_plugin_pager_full extends views_plugin_pager {
|
||||
'#default_value' => $this->options['quantity'],
|
||||
);
|
||||
|
||||
$form['tags'] = array (
|
||||
$form['tags'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#collapsible' => FALSE,
|
||||
'#collapsed' => FALSE,
|
||||
@@ -128,7 +135,7 @@ class views_plugin_pager_full extends views_plugin_pager {
|
||||
'#default_value' => $this->options['tags']['last'],
|
||||
);
|
||||
|
||||
$form['expose'] = array (
|
||||
$form['expose'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#collapsible' => FALSE,
|
||||
'#collapsed' => FALSE,
|
||||
@@ -152,7 +159,7 @@ class views_plugin_pager_full extends views_plugin_pager {
|
||||
'#description' => t('Label to use in the exposed items per page form element.'),
|
||||
'#default_value' => $this->options['expose']['items_per_page_label'],
|
||||
'#dependency' => array(
|
||||
'edit-pager-options-expose-items-per-page' => array(1)
|
||||
'edit-pager-options-expose-items-per-page' => array(1),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -163,11 +170,10 @@ class views_plugin_pager_full extends views_plugin_pager {
|
||||
'#description' => t('Set between which values the user can choose when determining the items per page. Separated by comma.'),
|
||||
'#default_value' => $this->options['expose']['items_per_page_options'],
|
||||
'#dependency' => array(
|
||||
'edit-pager-options-expose-items-per-page' => array(1)
|
||||
'edit-pager-options-expose-items-per-page' => array(1),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
$form['expose']['items_per_page_options_all'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Include all items option'),
|
||||
@@ -199,19 +205,22 @@ class views_plugin_pager_full extends views_plugin_pager {
|
||||
'#description' => t('Label to use in the exposed offset form element.'),
|
||||
'#default_value' => $this->options['expose']['offset_label'],
|
||||
'#dependency' => array(
|
||||
'edit-pager-options-expose-offset' => array(1)
|
||||
'edit-pager-options-expose-offset' => array(1),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function options_validate(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_validate(&$form, &$form_state) {
|
||||
// Only accept integer values.
|
||||
$error = FALSE;
|
||||
$exposed_options = $form_state['values']['pager_options']['expose']['items_per_page_options'];
|
||||
if (strpos($exposed_options, '.') !== FALSE) {
|
||||
$error = TRUE;
|
||||
}
|
||||
$options = explode(',',$exposed_options);
|
||||
$options = explode(',', $exposed_options);
|
||||
if (!$error && is_array($options)) {
|
||||
foreach ($options as $option) {
|
||||
if (!is_numeric($option) || intval($option) == 0) {
|
||||
@@ -237,10 +246,13 @@ class views_plugin_pager_full extends views_plugin_pager {
|
||||
}
|
||||
}
|
||||
|
||||
function query() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
if ($this->items_per_page_exposed()) {
|
||||
if (!empty($_GET['items_per_page']) && $_GET['items_per_page'] > 0) {
|
||||
$this->options['items_per_page'] = $_GET['items_per_page'];
|
||||
$this->options['items_per_page'] = (int) $_GET['items_per_page'];
|
||||
}
|
||||
elseif (!empty($_GET['items_per_page']) && $_GET['items_per_page'] == 'All' && $this->options['expose']['items_per_page_options_all']) {
|
||||
$this->options['items_per_page'] = 0;
|
||||
@@ -248,16 +260,15 @@ class views_plugin_pager_full extends views_plugin_pager {
|
||||
}
|
||||
if ($this->offset_exposed()) {
|
||||
if (isset($_GET['offset']) && $_GET['offset'] >= 0) {
|
||||
$this->options['offset'] = $_GET['offset'];
|
||||
$this->options['offset'] = (int) $_GET['offset'];
|
||||
}
|
||||
}
|
||||
|
||||
$limit = $this->options['items_per_page'];
|
||||
$offset = $this->current_page * $this->options['items_per_page'] + $this->options['offset'];
|
||||
$limit = $this->get_items_per_page();
|
||||
$offset = $this->current_page * $limit + $this->get_offset();
|
||||
if (!empty($this->options['total_pages'])) {
|
||||
if ($this->current_page >= $this->options['total_pages']) {
|
||||
$limit = $this->options['items_per_page'];
|
||||
$offset = $this->options['total_pages'] * $this->options['items_per_page'];
|
||||
$offset = $this->options['total_pages'] * $limit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,7 +276,10 @@ class views_plugin_pager_full extends views_plugin_pager {
|
||||
$this->view->query->set_offset($offset);
|
||||
}
|
||||
|
||||
function render($input) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render($input) {
|
||||
$pager_theme = views_theme_functions('pager', $this->view, $this->display);
|
||||
// The 0, 1, 3, 4 index are correct. See theme_pager documentation.
|
||||
$tags = array(
|
||||
@@ -286,11 +300,11 @@ class views_plugin_pager_full extends views_plugin_pager {
|
||||
/**
|
||||
* Set the current page.
|
||||
*
|
||||
* @param $number
|
||||
* @param int $number
|
||||
* If provided, the page number will be set to this. If NOT provided,
|
||||
* the page number will be set from the global page array.
|
||||
*/
|
||||
function set_current_page($number = NULL) {
|
||||
public function set_current_page($number = NULL) {
|
||||
if (isset($number)) {
|
||||
$this->current_page = $number;
|
||||
return;
|
||||
@@ -320,7 +334,10 @@ class views_plugin_pager_full extends views_plugin_pager {
|
||||
}
|
||||
}
|
||||
|
||||
function get_pager_total() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_pager_total() {
|
||||
if ($items_per_page = intval($this->get_items_per_page())) {
|
||||
return ceil($this->total_items / $items_per_page);
|
||||
}
|
||||
@@ -336,7 +353,7 @@ class views_plugin_pager_full extends views_plugin_pager {
|
||||
* items available and to update the current page if the requested
|
||||
* page is out of range.
|
||||
*/
|
||||
function update_page_info() {
|
||||
public function update_page_info() {
|
||||
if (!empty($this->options['total_pages'])) {
|
||||
if (($this->options['total_pages'] * $this->options['items_per_page']) < $this->total_items) {
|
||||
$this->total_items = $this->options['total_pages'] * $this->options['items_per_page'];
|
||||
@@ -356,34 +373,47 @@ class views_plugin_pager_full extends views_plugin_pager {
|
||||
// Calculate and set the count of available pages.
|
||||
$pager_total[$pager_id] = $this->get_pager_total();
|
||||
|
||||
// See if the requested page was within range:
|
||||
// See if the requested page was within range.
|
||||
if ($this->current_page < 0) {
|
||||
$this->current_page = 0;
|
||||
}
|
||||
else if ($this->current_page >= $pager_total[$pager_id]) {
|
||||
// Pages are numbered from 0 so if there are 10 pages, the last page is 9.
|
||||
elseif ($this->current_page >= $pager_total[$pager_id]) {
|
||||
// Pages are numbered from 0 so if there are 10 pages, the last page is
|
||||
// 9.
|
||||
$this->current_page = $pager_total[$pager_id] - 1;
|
||||
}
|
||||
|
||||
// Put this number in to guarantee that we do not generate notices when the pager
|
||||
// goes to look for it later.
|
||||
// Put this number in to guarantee that we do not generate notices when
|
||||
// the pager goes to look for it later.
|
||||
$pager_page_array[$pager_id] = $this->current_page;
|
||||
}
|
||||
}
|
||||
|
||||
function uses_exposed() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function uses_exposed() {
|
||||
return $this->items_per_page_exposed() || $this->offset_exposed();
|
||||
}
|
||||
|
||||
function items_per_page_exposed() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function items_per_page_exposed() {
|
||||
return !empty($this->options['expose']['items_per_page']);
|
||||
}
|
||||
|
||||
function offset_exposed() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function offset_exposed() {
|
||||
return !empty($this->options['expose']['offset']);
|
||||
}
|
||||
|
||||
function exposed_form_alter(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function exposed_form_alter(&$form, &$form_state) {
|
||||
if ($this->items_per_page_exposed()) {
|
||||
$options = explode(',', $this->options['expose']['items_per_page_options']);
|
||||
$sanitized_options = array();
|
||||
@@ -414,11 +444,15 @@ class views_plugin_pager_full extends views_plugin_pager {
|
||||
}
|
||||
}
|
||||
|
||||
function exposed_form_validate(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function exposed_form_validate(&$form, &$form_state) {
|
||||
if (!empty($form_state['values']['offset']) && trim($form_state['values']['offset'])) {
|
||||
if (!is_numeric($form_state['values']['offset']) || $form_state['values']['offset'] < 0) {
|
||||
form_set_error('offset', t('Offset must be an number greater or equal than 0.'));
|
||||
form_set_error('offset', t('Offset must be a number greater than or equal to 0.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -11,21 +11,24 @@
|
||||
* @ingroup views_pager_plugins
|
||||
*/
|
||||
class views_plugin_pager_mini extends views_plugin_pager_full {
|
||||
function summary_title() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function summary_title() {
|
||||
if (!empty($this->options['offset'])) {
|
||||
return format_plural($this->options['items_per_page'], 'Mini pager, @count item, skip @skip', 'Mini pager, @count items, skip @skip', array('@count' => $this->options['items_per_page'], '@skip' => $this->options['offset']));
|
||||
}
|
||||
return format_plural($this->options['items_per_page'], 'Mini pager, @count item', 'Mini pager, @count items', array('@count' => $this->options['items_per_page']));
|
||||
return format_plural($this->options['items_per_page'], 'Mini pager, @count item', 'Mini pager, @count items', array('@count' => $this->options['items_per_page']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides views_plugin_pager_full::option_definition().
|
||||
*
|
||||
* Overrides the full pager options form by deleting unused settings.
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function option_definition() {
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
// Overrides the full pager options form by deleting unused settings.
|
||||
unset($options['quantity']);
|
||||
unset($options['tags']['first']);
|
||||
unset($options['tags']['last']);
|
||||
@@ -36,25 +39,25 @@ class views_plugin_pager_mini extends views_plugin_pager_full {
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides views_plugin_pager_full::options_form().
|
||||
*
|
||||
* Overrides the full pager options form by deleting unused settings.
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
// Overrides the full pager options form by deleting unused settings.
|
||||
unset($form['quantity']);
|
||||
unset($form['tags']['first']);
|
||||
unset($form['tags']['last']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides views_plugin_pager_full::render().
|
||||
*
|
||||
* Overrides the full pager renderer by changing the theme function
|
||||
* and leaving out variables that are not used in the mini pager.
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function render($input) {
|
||||
public function render($input) {
|
||||
// Overrides the full pager renderer by changing the theme function and
|
||||
// leaving out variables that are not used in the mini pager.
|
||||
$pager_theme = views_theme_functions('views_mini_pager', $this->view, $this->display);
|
||||
|
||||
// The 1, 3 index are correct.
|
||||
// @see theme_pager().
|
||||
$tags = array(
|
||||
@@ -67,4 +70,5 @@ class views_plugin_pager_mini extends views_plugin_pager_full {
|
||||
'parameters' => $input,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -12,21 +12,30 @@
|
||||
*/
|
||||
class views_plugin_pager_none extends views_plugin_pager {
|
||||
|
||||
function init(&$view, &$display, $options = array()) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init(&$view, &$display, $options = array()) {
|
||||
parent::init($view, $display, $options);
|
||||
|
||||
// If the pager is set to none, then it should show all items.
|
||||
$this->set_items_per_page(0);
|
||||
}
|
||||
|
||||
function summary_title() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function summary_title() {
|
||||
if (!empty($this->options['offset'])) {
|
||||
return t('All items, skip @skip', array('@skip' => $this->options['offset']));
|
||||
}
|
||||
return t('All items');
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['offset'] = array('default' => 0);
|
||||
|
||||
@@ -36,7 +45,7 @@ class views_plugin_pager_none extends views_plugin_pager {
|
||||
/**
|
||||
* Provide the default form for setting options.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['offset'] = array(
|
||||
'#type' => 'textfield',
|
||||
@@ -46,30 +55,50 @@ class views_plugin_pager_none extends views_plugin_pager {
|
||||
);
|
||||
}
|
||||
|
||||
function use_pager() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function use_pager() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function use_count_query() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function use_count_query() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function get_items_per_page() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_items_per_page() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function execute_count_query(&$count_query) {
|
||||
// If we are displaying all items, never count. But we can update the count in post_execute.
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function execute_count_query(&$count_query) {
|
||||
// If we are displaying all items, never count. But we can update the count
|
||||
// in post_execute.
|
||||
}
|
||||
|
||||
function post_execute(&$result) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function post_execute(&$result) {
|
||||
$this->total_items = count($result);
|
||||
}
|
||||
|
||||
function query() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
// The only query modifications we might do are offsets.
|
||||
if (!empty($this->options['offset'])) {
|
||||
$this->view->query->set_offset($this->options['offset']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -11,14 +11,21 @@
|
||||
* @ingroup views_pager_plugins
|
||||
*/
|
||||
class views_plugin_pager_some extends views_plugin_pager {
|
||||
function summary_title() {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function summary_title() {
|
||||
if (!empty($this->options['offset'])) {
|
||||
return format_plural($this->options['items_per_page'], '@count item, skip @skip', '@count items, skip @skip', array('@count' => $this->options['items_per_page'], '@skip' => $this->options['offset']));
|
||||
}
|
||||
return format_plural($this->options['items_per_page'], '@count item', '@count items', array('@count' => $this->options['items_per_page']));
|
||||
return format_plural($this->options['items_per_page'], '@count item', '@count items', array('@count' => $this->options['items_per_page']));
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['items_per_page'] = array('default' => 10);
|
||||
$options['offset'] = array('default' => 0);
|
||||
@@ -29,7 +36,7 @@ class views_plugin_pager_some extends views_plugin_pager {
|
||||
/**
|
||||
* Provide the default form for setting options.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$pager_text = $this->display->handler->get_pager_text();
|
||||
$form['items_per_page'] = array(
|
||||
@@ -47,16 +54,26 @@ class views_plugin_pager_some extends views_plugin_pager {
|
||||
);
|
||||
}
|
||||
|
||||
function use_pager() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function use_pager() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function use_count_query() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function use_count_query() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function query() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$this->view->query->set_limit($this->options['items_per_page']);
|
||||
$this->view->query->set_offset($this->options['offset']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Defines the base query class, which is the underlying layer in a View.
|
||||
* Definition of views_plugin_query.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -14,20 +14,21 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Object used to create a SELECT query.
|
||||
* The base query class, which is the underlying layer in a View.
|
||||
*/
|
||||
class views_plugin_query extends views_plugin {
|
||||
|
||||
/**
|
||||
* A pager plugin that should be provided by the display.
|
||||
*
|
||||
* @var views_plugin_pager
|
||||
*/
|
||||
var $pager = NULL;
|
||||
public $pager = NULL;
|
||||
|
||||
/**
|
||||
* Constructor; Create the basic query object and fill with default values.
|
||||
*/
|
||||
function init($base_table, $base_field, $options) {
|
||||
public function init($base_table, $base_field, $options) {
|
||||
$this->base_table = $base_table;
|
||||
$this->base_field = $base_field;
|
||||
$this->unpack_options($this->options, $options);
|
||||
@@ -37,13 +38,14 @@ class views_plugin_query extends views_plugin {
|
||||
* Generate a query and a countquery from all of the information supplied
|
||||
* to the object.
|
||||
*
|
||||
* @param $get_count
|
||||
* Provide a countquery if this is true, otherwise provide a normal query.
|
||||
* @param bool $get_count
|
||||
* Provide a countquery if this is TRUE, otherwise provide a normal query.
|
||||
*
|
||||
* @return SelectQuery
|
||||
* A SelectQuery object.
|
||||
*/
|
||||
function query($get_count = FALSE) { }
|
||||
public function query($get_count = FALSE) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Let modules modify the query just prior to finalizing it.
|
||||
@@ -51,7 +53,8 @@ class views_plugin_query extends views_plugin {
|
||||
* @param view $view
|
||||
* The view which is executed.
|
||||
*/
|
||||
function alter(&$view) { }
|
||||
public function alter(&$view) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the necessary info to execute the query.
|
||||
@@ -59,7 +62,8 @@ class views_plugin_query extends views_plugin {
|
||||
* @param view $view
|
||||
* The view which is executed.
|
||||
*/
|
||||
function build(&$view) { }
|
||||
public function build(&$view) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the query and fills the associated view object with according
|
||||
@@ -74,7 +78,8 @@ class views_plugin_query extends views_plugin {
|
||||
* @param view $view
|
||||
* The view which is executed.
|
||||
*/
|
||||
function execute(&$view) { }
|
||||
public function execute(&$view) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a signature to the query, if such a thing is feasible.
|
||||
@@ -85,48 +90,61 @@ class views_plugin_query extends views_plugin {
|
||||
* @param view $view
|
||||
* The view which is executed.
|
||||
*/
|
||||
function add_signature(&$view) { }
|
||||
public function add_signature(&$view) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get aggregation info for group by queries.
|
||||
*
|
||||
* If NULL, aggregation is not allowed.
|
||||
*/
|
||||
function get_aggregation_info() { }
|
||||
public function get_aggregation_info() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add settings for the ui.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
}
|
||||
|
||||
function options_validate(&$form, &$form_state) { }
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_validate(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
function options_submit(&$form, &$form_state) { }
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_submit(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
function summary_title() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function summary_title() {
|
||||
return t('Settings');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a LIMIT on the query, specifying a maximum number of results.
|
||||
*/
|
||||
function set_limit($limit) {
|
||||
public function set_limit($limit) {
|
||||
$this->limit = $limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an OFFSET on the query, specifying a number of results to skip
|
||||
*/
|
||||
function set_offset($offset) {
|
||||
public function set_offset($offset) {
|
||||
$this->offset = $offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the pager, if necessary.
|
||||
*/
|
||||
function render_pager($exposed_input) {
|
||||
public function render_pager($exposed_input) {
|
||||
if (!empty($this->pager) && $this->pager->use_pager()) {
|
||||
return $this->pager->render($exposed_input);
|
||||
}
|
||||
@@ -137,18 +155,18 @@ class views_plugin_query extends views_plugin {
|
||||
/**
|
||||
* Create a new grouping for the WHERE or HAVING clause.
|
||||
*
|
||||
* @param $type
|
||||
* @param string $type
|
||||
* Either 'AND' or 'OR'. All items within this group will be added
|
||||
* to the WHERE clause with this logical operator.
|
||||
* @param $group
|
||||
* @param string $group
|
||||
* An ID to use for this group. If unspecified, an ID will be generated.
|
||||
* @param $where
|
||||
* @param string $where
|
||||
* 'where' or 'having'.
|
||||
*
|
||||
* @return $group
|
||||
* @return string
|
||||
* The group ID generated.
|
||||
*/
|
||||
function set_where_group($type = 'AND', $group = NULL, $where = 'where') {
|
||||
public function set_where_group($type = 'AND', $group = NULL, $where = 'where') {
|
||||
// Set an alias.
|
||||
$groups = &$this->$where;
|
||||
|
||||
@@ -168,19 +186,20 @@ class views_plugin_query extends views_plugin {
|
||||
/**
|
||||
* Control how all WHERE and HAVING groups are put together.
|
||||
*
|
||||
* @param $type
|
||||
* Either 'AND' or 'OR'
|
||||
* @param string $type
|
||||
* Either 'AND' or 'OR'.
|
||||
*/
|
||||
function set_group_operator($type = 'AND') {
|
||||
public function set_group_operator($type = 'AND') {
|
||||
$this->group_operator = strtoupper($type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the according entity objects for the given query results.
|
||||
*/
|
||||
function get_result_entities($results, $relationship = NULL) {
|
||||
public function get_result_entities($results, $relationship = NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the base row style plugin.
|
||||
* Definition of views_plugin_row.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -17,14 +17,15 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default plugin to view a single row of a table. This is really just a wrapper around
|
||||
* a theme function.
|
||||
* Default plugin to view a single row of a table. This is really just a wrapper
|
||||
* around a theme function.
|
||||
*/
|
||||
class views_plugin_row extends views_plugin {
|
||||
|
||||
/**
|
||||
* Initialize the row plugin.
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function init(&$view, &$display, $options = NULL) {
|
||||
public function init(&$view, &$display, $options = NULL) {
|
||||
$this->view = &$view;
|
||||
$this->display = &$display;
|
||||
|
||||
@@ -32,12 +33,17 @@ class views_plugin_row extends views_plugin {
|
||||
$this->unpack_options($this->options, isset($options) ? $options : $display->handler->get_option('row_options'));
|
||||
}
|
||||
|
||||
function uses_fields() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function uses_fields() {
|
||||
return !empty($this->definition['uses fields']);
|
||||
}
|
||||
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
if (isset($this->base_table)) {
|
||||
$options['relationship'] = array('default' => 'none');
|
||||
@@ -49,7 +55,7 @@ class views_plugin_row extends views_plugin {
|
||||
/**
|
||||
* Provide a form for setting options.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
if (isset($this->base_table)) {
|
||||
$view = &$form_state['view'];
|
||||
@@ -98,15 +104,20 @@ class views_plugin_row extends views_plugin {
|
||||
/**
|
||||
* Validate the options form.
|
||||
*/
|
||||
function options_validate(&$form, &$form_state) { }
|
||||
public function options_validate(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform any necessary changes to the form values prior to storage.
|
||||
* There is no need for this function to actually store the data.
|
||||
*/
|
||||
function options_submit(&$form, &$form_state) { }
|
||||
public function options_submit(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
function query() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
if (isset($this->base_table)) {
|
||||
if (isset($this->options['relationship']) && isset($this->view->relationship[$this->options['relationship']])) {
|
||||
$relationship = $this->view->relationship[$this->options['relationship']];
|
||||
@@ -121,10 +132,11 @@ class views_plugin_row extends views_plugin {
|
||||
/**
|
||||
* Allow the style to do stuff before each row is rendered.
|
||||
*
|
||||
* @param $result
|
||||
* @param array $result
|
||||
* The full array of results from the query.
|
||||
*/
|
||||
function pre_render($result) { }
|
||||
public function pre_render($result) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a row object. This usually passes through to a theme template
|
||||
@@ -136,7 +148,7 @@ class views_plugin_row extends views_plugin {
|
||||
* @return string
|
||||
* The rendered output of a single row, used by the style plugin.
|
||||
*/
|
||||
function render($row) {
|
||||
public function render($row) {
|
||||
return theme($this->theme_functions(),
|
||||
array(
|
||||
'view' => $this->view,
|
||||
@@ -145,6 +157,7 @@ class views_plugin_row extends views_plugin {
|
||||
'field_alias' => isset($this->field_alias) ? $this->field_alias : '',
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2,11 +2,11 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the base row style plugin.
|
||||
* Definition of views_plugin_row_fields.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The basic 'fields' row plugin
|
||||
* The basic 'fields' row plugin.
|
||||
*
|
||||
* This displays fields one after another, giving options for inline
|
||||
* or not.
|
||||
@@ -14,7 +14,11 @@
|
||||
* @ingroup views_row_plugins
|
||||
*/
|
||||
class views_plugin_row_fields extends views_plugin_row {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['inline'] = array('default' => array());
|
||||
@@ -27,7 +31,7 @@ class views_plugin_row_fields extends views_plugin_row {
|
||||
/**
|
||||
* Provide a form for setting options.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$options = $this->display->handler->get_field_labels();
|
||||
|
||||
@@ -80,7 +84,8 @@ class views_plugin_row_fields extends views_plugin_row {
|
||||
* Perform any necessary changes to the form values prior to storage.
|
||||
* There is no need for this function to actually store the data.
|
||||
*/
|
||||
function options_submit(&$form, &$form_state) {
|
||||
public function options_submit(&$form, &$form_state) {
|
||||
$form_state['values']['row_options']['inline'] = array_filter($form_state['values']['row_options']['inline']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,14 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains an implementation of RSS items based on fields on a row plugin.
|
||||
* Definition of views_plugin_row_rss_fields.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Renders an RSS item based on fields.
|
||||
*/
|
||||
class views_plugin_row_rss_fields extends views_plugin_row {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['title_field'] = array('default' => '');
|
||||
$options['link_field'] = array('default' => '');
|
||||
@@ -20,7 +25,10 @@ class views_plugin_row_rss_fields extends views_plugin_row {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$initial_labels = array('' => t('- None -'));
|
||||
@@ -89,7 +97,10 @@ class views_plugin_row_rss_fields extends views_plugin_row {
|
||||
);
|
||||
}
|
||||
|
||||
function validate() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function validate() {
|
||||
$errors = parent::validate();
|
||||
$required_options = array('title_field', 'link_field', 'description_field', 'creator_field', 'date_field');
|
||||
foreach ($required_options as $required_option) {
|
||||
@@ -105,7 +116,10 @@ class views_plugin_row_rss_fields extends views_plugin_row {
|
||||
return $errors;
|
||||
}
|
||||
|
||||
function render($row) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render($row) {
|
||||
static $row_index;
|
||||
if (!isset($row_index)) {
|
||||
$row_index = 0;
|
||||
@@ -165,12 +179,12 @@ class views_plugin_row_rss_fields extends views_plugin_row {
|
||||
/**
|
||||
* Retrieves a views field value from the style plugin.
|
||||
*
|
||||
* @param $index
|
||||
* The index count of the row as expected by views_plugin_style::get_field().
|
||||
* @param $field_id
|
||||
* @param int $index
|
||||
* The index of the row as expected by views_plugin_style::get_field().
|
||||
* @param string $field_id
|
||||
* The ID assigned to the required field in the display.
|
||||
*/
|
||||
function get_field($index, $field_id) {
|
||||
public function get_field($index, $field_id) {
|
||||
if (empty($this->view->style_plugin) || !is_object($this->view->style_plugin) || empty($field_id)) {
|
||||
return '';
|
||||
}
|
||||
|
@@ -8,13 +8,13 @@
|
||||
/**
|
||||
* @defgroup views_style_plugins Views style plugins
|
||||
* @{
|
||||
* Style plugins control how a view is rendered. For example, they
|
||||
* can choose to display a collection of fields, node_view() output,
|
||||
* table output, or any kind of crazy output they want.
|
||||
* Style plugins control how a view is rendered. For example, they can choose to
|
||||
* display a collection of fields, node_view() output, table output, or any kind
|
||||
* of crazy output they want.
|
||||
*
|
||||
* Many style plugins can have an optional 'row' plugin, that displays
|
||||
* a single record. Not all style plugins can utilize this, so it is
|
||||
* up to the plugin to set this up and call through to the row plugin.
|
||||
* Many style plugins can have an optional 'row' plugin, that displays a single
|
||||
* record. Not all style plugins can utilize this, so it is up to the plugin to
|
||||
* set this up and call through to the row plugin.
|
||||
*
|
||||
* @see hook_views_plugins()
|
||||
*/
|
||||
@@ -23,29 +23,29 @@
|
||||
* Base class to define a style plugin handler.
|
||||
*/
|
||||
class views_plugin_style extends views_plugin {
|
||||
|
||||
/**
|
||||
* Store all available tokens row rows.
|
||||
*/
|
||||
var $row_tokens = array();
|
||||
public $row_tokens = array();
|
||||
|
||||
/**
|
||||
* Contains the row plugin, if it's initialized
|
||||
* and the style itself supports it.
|
||||
* The row plugin, if it's initialized and the style itself supports it.
|
||||
*
|
||||
* @var views_plugin_row
|
||||
*/
|
||||
var $row_plugin;
|
||||
public $row_plugin;
|
||||
|
||||
/**
|
||||
* Initialize a style plugin.
|
||||
*
|
||||
* @param $view
|
||||
* @param $display
|
||||
* @param $options
|
||||
* @param view $view
|
||||
* @param object $display
|
||||
* @param array $options
|
||||
* The style options might come externally as the style can be sourced
|
||||
* from at least two locations. If it's not included, look on the display.
|
||||
*/
|
||||
function init(&$view, &$display, $options = NULL) {
|
||||
public function init(&$view, &$display, $options = NULL) {
|
||||
$this->view = &$view;
|
||||
$this->display = &$display;
|
||||
|
||||
@@ -65,7 +65,10 @@ class views_plugin_style extends views_plugin {
|
||||
);
|
||||
}
|
||||
|
||||
function destroy() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function destroy() {
|
||||
parent::destroy();
|
||||
|
||||
if (isset($this->row_plugin)) {
|
||||
@@ -76,14 +79,14 @@ class views_plugin_style extends views_plugin {
|
||||
/**
|
||||
* Return TRUE if this style also uses a row plugin.
|
||||
*/
|
||||
function uses_row_plugin() {
|
||||
public function uses_row_plugin() {
|
||||
return !empty($this->definition['uses row plugin']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return TRUE if this style also uses a row plugin.
|
||||
*/
|
||||
function uses_row_class() {
|
||||
public function uses_row_class() {
|
||||
return !empty($this->definition['uses row class']);
|
||||
}
|
||||
|
||||
@@ -92,7 +95,7 @@ class views_plugin_style extends views_plugin {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function uses_fields() {
|
||||
public function uses_fields() {
|
||||
// If we use a row plugin, ask the row plugin. Chances are, we don't
|
||||
// care, it does.
|
||||
$row_uses_fields = FALSE;
|
||||
@@ -108,7 +111,7 @@ class views_plugin_style extends views_plugin {
|
||||
*
|
||||
* Used to ensure we don't fetch tokens when not needed for performance.
|
||||
*/
|
||||
function uses_tokens() {
|
||||
public function uses_tokens() {
|
||||
if ($this->uses_row_class()) {
|
||||
$class = $this->options['row_class'];
|
||||
if (strpos($class, '[') !== FALSE || strpos($class, '!') !== FALSE || strpos($class, '%') !== FALSE) {
|
||||
@@ -120,7 +123,7 @@ class views_plugin_style extends views_plugin {
|
||||
/**
|
||||
* Return the token replaced row class for the specified row.
|
||||
*/
|
||||
function get_row_class($row_index) {
|
||||
public function get_row_class($row_index) {
|
||||
if ($this->uses_row_class()) {
|
||||
$class = $this->options['row_class'];
|
||||
|
||||
@@ -129,7 +132,7 @@ class views_plugin_style extends views_plugin {
|
||||
|
||||
// Explode the value by whitespace, this allows the function to handle
|
||||
// a single class name and multiple class names that are then tokenized.
|
||||
foreach(explode(' ', $class) as $token_class) {
|
||||
foreach (explode(' ', $class) as $token_class) {
|
||||
$classes = array_merge($classes, explode(' ', strip_tags($this->tokenize_value($token_class, $row_index))));
|
||||
}
|
||||
}
|
||||
@@ -148,7 +151,7 @@ class views_plugin_style extends views_plugin {
|
||||
/**
|
||||
* Take a value and apply token replacement logic to it.
|
||||
*/
|
||||
function tokenize_value($value, $row_index) {
|
||||
public function tokenize_value($value, $row_index) {
|
||||
if (strpos($value, '[') !== FALSE || strpos($value, '!') !== FALSE || strpos($value, '%') !== FALSE) {
|
||||
$fake_item = array(
|
||||
'alter_text' => TRUE,
|
||||
@@ -170,13 +173,16 @@ class views_plugin_style extends views_plugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the output of the style plugin be rendered even if it's a empty view.
|
||||
* Should the output of the style plugin be rendered even if it's empty.
|
||||
*/
|
||||
function even_empty() {
|
||||
public function even_empty() {
|
||||
return !empty($this->definition['even empty']);
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['grouping'] = array('default' => array());
|
||||
if ($this->uses_row_class()) {
|
||||
@@ -189,19 +195,23 @@ class views_plugin_style extends views_plugin {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
// Only fields-based views can handle grouping. Style plugins can also exclude
|
||||
// themselves from being groupable by setting their "use grouping" definition
|
||||
// key to FALSE.
|
||||
// @TODO: Document "uses grouping" in docs.php when docs.php is written.
|
||||
// Only fields-based views can handle grouping. Style plugins can also
|
||||
// exclude themselves from being groupable by setting their "use grouping"
|
||||
// definition key to FALSE.
|
||||
// @todo Document "uses grouping" in docs.php when docs.php is written.
|
||||
if ($this->uses_fields() && $this->definition['uses grouping']) {
|
||||
$options = array('' => t('- None -'));
|
||||
$field_labels = $this->display->handler->get_field_labels(TRUE);
|
||||
$options += $field_labels;
|
||||
// If there are no fields, we can't group on them.
|
||||
if (count($options) > 1) {
|
||||
// This is for backward compatibility, when there was just a single select form.
|
||||
// This is for backward compatibility, when there was just a single
|
||||
// select form.
|
||||
if (is_string($this->options['grouping'])) {
|
||||
$grouping = $this->options['grouping'];
|
||||
$this->options['grouping'] = array();
|
||||
@@ -282,7 +292,10 @@ class views_plugin_style extends views_plugin {
|
||||
}
|
||||
}
|
||||
|
||||
function options_validate(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_validate(&$form, &$form_state) {
|
||||
// Don't run validation on style plugins without the grouping setting.
|
||||
if (isset($form_state['values']['style_options']['grouping'])) {
|
||||
// Don't save grouping if no field is specified.
|
||||
@@ -299,21 +312,24 @@ class views_plugin_style extends views_plugin {
|
||||
* interfere with the sorts. If so it should build; if it returns
|
||||
* any non-TRUE value, normal sorting will NOT be added to the query.
|
||||
*/
|
||||
function build_sort() { return TRUE; }
|
||||
public function build_sort() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the view builder to let the style build a second set of
|
||||
* sorts that will come after any other sorts in the view.
|
||||
*/
|
||||
function build_sort_post() { }
|
||||
public function build_sort_post() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow the style to do stuff before each row is rendered.
|
||||
*
|
||||
* @param $result
|
||||
* @param array $result
|
||||
* The full array of results from the query.
|
||||
*/
|
||||
function pre_render($result) {
|
||||
public function pre_render($result) {
|
||||
if (!empty($this->row_plugin)) {
|
||||
$this->row_plugin->pre_render($result);
|
||||
}
|
||||
@@ -322,7 +338,7 @@ class views_plugin_style extends views_plugin {
|
||||
/**
|
||||
* Render the display in this style.
|
||||
*/
|
||||
function render() {
|
||||
public function render() {
|
||||
if ($this->uses_row_plugin() && empty($this->row_plugin)) {
|
||||
debug('views_plugin_style_default: Missing row plugin');
|
||||
return;
|
||||
@@ -344,18 +360,19 @@ class views_plugin_style extends views_plugin {
|
||||
* Plugins may override this method if they wish some other way of handling
|
||||
* grouping.
|
||||
*
|
||||
* @param $sets
|
||||
* @param array $sets
|
||||
* Array containing the grouping sets to render.
|
||||
* @param $level
|
||||
* @param int $level
|
||||
* Integer indicating the hierarchical level of the grouping.
|
||||
*
|
||||
* @return string
|
||||
* Rendered output of given grouping sets.
|
||||
*/
|
||||
function render_grouping_sets($sets, $level = 0) {
|
||||
public function render_grouping_sets($sets, $level = 0) {
|
||||
$output = '';
|
||||
foreach ($sets as $set) {
|
||||
$row = reset($set['rows']);
|
||||
$level = isset($set['level']) ? $set['level'] : 0;
|
||||
// Render as a grouping set.
|
||||
if (is_array($row) && isset($row['group'])) {
|
||||
$output .= theme(views_theme_functions('views_view_grouping', $this->view, $this->display),
|
||||
@@ -393,18 +410,19 @@ class views_plugin_style extends views_plugin {
|
||||
/**
|
||||
* Group records as needed for rendering.
|
||||
*
|
||||
* @param $records
|
||||
* @param array $records
|
||||
* An array of records from the view to group.
|
||||
* @param $groupings
|
||||
* @param array $groupings
|
||||
* An array of grouping instructions on which fields to group. If empty, the
|
||||
* result set will be given a single group with an empty string as a label.
|
||||
* @param $group_rendered
|
||||
* @param bool $group_rendered
|
||||
* Boolean value whether to use the rendered or the raw field value for
|
||||
* grouping. If set to NULL the return is structured as before
|
||||
* Views 7.x-3.0-rc2. After Views 7.x-3.0 this boolean is only used if
|
||||
* $groupings is an old-style string or if the rendered option is missing
|
||||
* for a grouping instruction.
|
||||
* @return
|
||||
*
|
||||
* @return array
|
||||
* The grouped record set.
|
||||
* A nested set structure is generated if multiple grouping fields are used.
|
||||
*
|
||||
@@ -429,9 +447,9 @@ class views_plugin_style extends views_plugin {
|
||||
* )
|
||||
* @endcode
|
||||
*/
|
||||
function render_grouping($records, $groupings = array(), $group_rendered = NULL) {
|
||||
// This is for backward compatibility, when $groupings was a string containing
|
||||
// the ID of a single field.
|
||||
public function render_grouping($records, $groupings = array(), $group_rendered = NULL) {
|
||||
// This is for backward compatibility, when $groupings was a string
|
||||
// containing the ID of a single field.
|
||||
if (is_string($groupings)) {
|
||||
$rendered = $group_rendered === NULL ? TRUE : $group_rendered;
|
||||
$groupings = array(array('field' => $groupings, 'rendered' => $rendered));
|
||||
@@ -446,7 +464,7 @@ class views_plugin_style extends views_plugin {
|
||||
// hierarchically positioned set where the current row belongs to.
|
||||
// While iterating, parent groups, that do not exist yet, are added.
|
||||
$set = &$sets;
|
||||
foreach ($groupings as $info) {
|
||||
foreach ($groupings as $level => $info) {
|
||||
$field = $info['field'];
|
||||
$rendered = isset($info['rendered']) ? $info['rendered'] : $group_rendered;
|
||||
$rendered_strip = isset($info['rendered_strip']) ? $info['rendered_strip'] : FALSE;
|
||||
@@ -479,13 +497,16 @@ class views_plugin_style extends views_plugin {
|
||||
// Create the group if it does not exist yet.
|
||||
if (empty($set[$grouping])) {
|
||||
$set[$grouping]['group'] = $group_content;
|
||||
$set[$grouping]['level'] = $level;
|
||||
$set[$grouping]['rows'] = array();
|
||||
}
|
||||
|
||||
// Move the set reference into the row set of the group we just determined.
|
||||
// Move the set reference into the row set of the group we just
|
||||
// determined.
|
||||
$set = &$set[$grouping]['rows'];
|
||||
}
|
||||
// Add the row to the hierarchically positioned row set we just determined.
|
||||
// Add the row to the hierarchically positioned row set we just
|
||||
// determined.
|
||||
$set[$index] = $row;
|
||||
}
|
||||
}
|
||||
@@ -499,7 +520,7 @@ class views_plugin_style extends views_plugin {
|
||||
|
||||
// If this parameter isn't explicitly set modify the output to be fully
|
||||
// backward compatible to code before Views 7.x-3.0-rc2.
|
||||
// @TODO Remove this as soon as possible e.g. October 2020
|
||||
// @todo Remove this as soon as possible e.g. October 2020
|
||||
if ($group_rendered === NULL) {
|
||||
$old_style_sets = array();
|
||||
foreach ($sets as $group) {
|
||||
@@ -514,10 +535,10 @@ class views_plugin_style extends views_plugin {
|
||||
/**
|
||||
* Render all of the fields for a given style and store them on the object.
|
||||
*
|
||||
* @param $result
|
||||
* @param array $result
|
||||
* The result array from $view->result
|
||||
*/
|
||||
function render_fields($result) {
|
||||
public function render_fields($result) {
|
||||
if (!$this->uses_fields()) {
|
||||
return;
|
||||
}
|
||||
@@ -548,12 +569,12 @@ class views_plugin_style extends views_plugin {
|
||||
/**
|
||||
* Get a rendered field.
|
||||
*
|
||||
* @param $index
|
||||
* @param int $index
|
||||
* The index count of the row.
|
||||
* @param $field
|
||||
* @param string $field
|
||||
* The id of the field.
|
||||
*/
|
||||
function get_field($index, $field) {
|
||||
public function get_field($index, $field) {
|
||||
if (!isset($this->rendered_fields)) {
|
||||
$this->render_fields($this->view->result);
|
||||
}
|
||||
@@ -566,19 +587,22 @@ class views_plugin_style extends views_plugin {
|
||||
/**
|
||||
* Get the raw field value.
|
||||
*
|
||||
* @param $index
|
||||
* @param int $index
|
||||
* The index count of the row.
|
||||
* @param $field
|
||||
* @param string $field
|
||||
* The id of the field.
|
||||
*/
|
||||
function get_field_value($index, $field) {
|
||||
public function get_field_value($index, $field) {
|
||||
$this->view->row_index = $index;
|
||||
$value = $this->view->field[$field]->get_value($this->view->result[$index]);
|
||||
unset($this->view->row_index);
|
||||
return $value;
|
||||
}
|
||||
|
||||
function validate() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validate() {
|
||||
$errors = parent::validate();
|
||||
|
||||
if ($this->uses_row_plugin()) {
|
||||
@@ -596,12 +620,16 @@ class views_plugin_style extends views_plugin {
|
||||
return $errors;
|
||||
}
|
||||
|
||||
function query() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
parent::query();
|
||||
if (isset($this->row_plugin)) {
|
||||
$this->row_plugin->query();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the default style plugin.
|
||||
* Definition of views_plugin_style_default.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -12,14 +12,19 @@
|
||||
* @ingroup views_style_plugins
|
||||
*/
|
||||
class views_plugin_style_default extends views_plugin_style {
|
||||
|
||||
/**
|
||||
* Set default options
|
||||
* Set default options.
|
||||
*/
|
||||
function options(&$options) {
|
||||
public function options(&$options) {
|
||||
parent::options($options);
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the grid style plugin.
|
||||
* Definition of views_plugin_style_grid.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -11,10 +11,11 @@
|
||||
* @ingroup views_style_plugins
|
||||
*/
|
||||
class views_plugin_style_grid extends views_plugin_style {
|
||||
|
||||
/**
|
||||
* Set default options
|
||||
* Set default options.
|
||||
*/
|
||||
function option_definition() {
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['columns'] = array('default' => '4');
|
||||
@@ -29,7 +30,7 @@ class views_plugin_style_grid extends views_plugin_style {
|
||||
/**
|
||||
* Render the given style.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['columns'] = array(
|
||||
'#type' => 'textfield',
|
||||
@@ -67,4 +68,5 @@ class views_plugin_style_grid extends views_plugin_style {
|
||||
'#default_value' => $this->options['summary'],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the table style plugin.
|
||||
* Definition of views_plugin_style_jump_menu.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -11,7 +11,11 @@
|
||||
* @ingroup views_style_plugins
|
||||
*/
|
||||
class views_plugin_style_jump_menu extends views_plugin_style {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['hide'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
@@ -28,7 +32,7 @@ class views_plugin_style_jump_menu extends views_plugin_style {
|
||||
/**
|
||||
* Render the given style.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$handlers = $this->display->handler->get_handlers('field');
|
||||
if (empty($handlers)) {
|
||||
@@ -61,7 +65,7 @@ class views_plugin_style_jump_menu extends views_plugin_style {
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Hide the "Go" button'),
|
||||
'#default_value' => !empty($this->options['hide']),
|
||||
'#description' => t('If hidden, this button will only be hidden for users with javascript and the page will automatically jump when the select is changed.'),
|
||||
'#description' => t('If hidden, this button will only be hidden for users with JavaScript and the page will automatically jump when the select is changed.'),
|
||||
);
|
||||
|
||||
$form['text'] = array(
|
||||
@@ -103,7 +107,7 @@ class views_plugin_style_jump_menu extends views_plugin_style {
|
||||
*
|
||||
* This is overridden so that we can render our grouping specially.
|
||||
*/
|
||||
function render() {
|
||||
public function render() {
|
||||
$sets = $this->render_grouping($this->view->result, $this->options['grouping']);
|
||||
|
||||
// Turn this all into an $options array for the jump menu.
|
||||
@@ -122,8 +126,8 @@ class views_plugin_style_jump_menu extends views_plugin_style {
|
||||
$path = drupal_substr($path, drupal_strlen($base_path));
|
||||
}
|
||||
|
||||
// use drupal_parse_url() to preserve query and fragment in case the user
|
||||
// wants to do fun tricks.
|
||||
// Use drupal_parse_url() to preserve query and fragment in case the
|
||||
// user wants to do fun tricks.
|
||||
$url_options = drupal_parse_url($path);
|
||||
|
||||
$path = url($url_options['path'], $url_options);
|
||||
@@ -144,8 +148,8 @@ class views_plugin_style_jump_menu extends views_plugin_style {
|
||||
$default_value = '';
|
||||
if ($this->options['default_value']) {
|
||||
$lookup_options = array();
|
||||
// We need to check if the path is absolute
|
||||
// or else language is not taken in account.
|
||||
// We need to check if the path is absolute or else language is not taken
|
||||
// in account.
|
||||
if (!empty($this->view->display[$this->view->current_display]->display_options['fields'][$this->options['path']]['absolute'])) {
|
||||
$lookup_options['absolute'] = TRUE;
|
||||
}
|
||||
@@ -169,8 +173,12 @@ class views_plugin_style_jump_menu extends views_plugin_style {
|
||||
return $form;
|
||||
}
|
||||
|
||||
function render_set($title, $records) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function render_set($title, $records) {
|
||||
$options = array();
|
||||
$fields = $this->rendered_fields;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the list style plugin.
|
||||
* Definition of views_plugin_style_list.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -11,10 +11,11 @@
|
||||
* @ingroup views_style_plugins
|
||||
*/
|
||||
class views_plugin_style_list extends views_plugin_style {
|
||||
|
||||
/**
|
||||
* Set default options
|
||||
* Set default options.
|
||||
*/
|
||||
function option_definition() {
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['type'] = array('default' => 'ul');
|
||||
@@ -27,7 +28,7 @@ class views_plugin_style_list extends views_plugin_style {
|
||||
/**
|
||||
* Render the given style.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['type'] = array(
|
||||
'#type' => 'radios',
|
||||
@@ -50,4 +51,5 @@ class views_plugin_style_list extends views_plugin_style {
|
||||
'#default_value' => $this->options['class'],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -27,9 +27,9 @@ abstract class views_plugin_style_mapping extends views_plugin_style {
|
||||
abstract protected function define_mapping();
|
||||
|
||||
/**
|
||||
* Overrides views_plugin_style::option_definition().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function option_definition() {
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
// Parse the mapping and add a default for each.
|
||||
@@ -50,9 +50,9 @@ abstract class views_plugin_style_mapping extends views_plugin_style {
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides views_plugin_style::options_form().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
// Get the mapping.
|
||||
@@ -110,11 +110,10 @@ abstract class views_plugin_style_mapping extends views_plugin_style {
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides views_plugin_style::render().
|
||||
*
|
||||
* Provides the mapping definition as an available variable.
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function render() {
|
||||
public function render() {
|
||||
// Provides the mapping definition as an available variable.
|
||||
return theme($this->theme_functions(), array(
|
||||
'view' => $this->view,
|
||||
'options' => $this->options,
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the RSS style plugin.
|
||||
* Definition of views_plugin_style_rss.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -11,7 +11,11 @@
|
||||
* @ingroup views_style_plugins
|
||||
*/
|
||||
class views_plugin_style_rss extends views_plugin_style {
|
||||
function attach_to($display_id, $path, $title) {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function attach_to($display_id, $path, $title) {
|
||||
$display = $this->view->display[$display_id]->handler;
|
||||
$url_options = array();
|
||||
$input = $this->view->get_exposed_input();
|
||||
@@ -36,12 +40,15 @@ class views_plugin_style_rss extends views_plugin_style {
|
||||
'rel' => 'alternate',
|
||||
'type' => 'application/rss+xml',
|
||||
'title' => $title,
|
||||
'href' => $url
|
||||
'href' => $url,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['description'] = array('default' => '', 'translatable' => TRUE);
|
||||
@@ -49,7 +56,10 @@ class views_plugin_style_rss extends views_plugin_style {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$form['description'] = array(
|
||||
@@ -67,7 +77,7 @@ class views_plugin_style_rss extends views_plugin_style {
|
||||
* @return
|
||||
* An array that can be passed to format_xml_elements().
|
||||
*/
|
||||
function get_channel_elements() {
|
||||
public function get_channel_elements() {
|
||||
return array();
|
||||
}
|
||||
|
||||
@@ -80,7 +90,7 @@ class views_plugin_style_rss extends views_plugin_style {
|
||||
* @return
|
||||
* An array that can be passed to format_xml_elements().
|
||||
*/
|
||||
function get_channel_elements_atom_link() {
|
||||
public function get_channel_elements_atom_link() {
|
||||
$url_options = array('absolute' => TRUE);
|
||||
$input = $this->view->get_exposed_input();
|
||||
if ($input) {
|
||||
@@ -107,7 +117,7 @@ class views_plugin_style_rss extends views_plugin_style {
|
||||
* @return string
|
||||
* The string containing the description with the tokens replaced.
|
||||
*/
|
||||
function get_description() {
|
||||
public function get_description() {
|
||||
$description = $this->options['description'];
|
||||
|
||||
// Allow substitutions from the first row.
|
||||
@@ -116,7 +126,10 @@ class views_plugin_style_rss extends views_plugin_style {
|
||||
return $description;
|
||||
}
|
||||
|
||||
function render() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render() {
|
||||
if (empty($this->row_plugin)) {
|
||||
vpr('views_plugin_style_default: Missing row plugin');
|
||||
return;
|
||||
@@ -148,9 +161,10 @@ class views_plugin_style_rss extends views_plugin_style {
|
||||
array(
|
||||
'view' => $this->view,
|
||||
'options' => $this->options,
|
||||
'rows' => $rows
|
||||
'rows' => $rows,
|
||||
));
|
||||
unset($this->view->row_index);
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the default summary style plugin, which displays items in an HTML list.
|
||||
* Definition of views_plugin_style_summary.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -11,7 +11,11 @@
|
||||
* @ingroup views_style_plugins
|
||||
*/
|
||||
class views_plugin_style_summary extends views_plugin_style {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['base_path'] = array('default' => '');
|
||||
@@ -22,13 +26,19 @@ class views_plugin_style_summary extends views_plugin_style {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function query() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
if (!empty($this->options['override'])) {
|
||||
$this->view->set_items_per_page(intval($this->options['items_per_page']));
|
||||
}
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
$form['base_path'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Base path'),
|
||||
@@ -55,22 +65,26 @@ class views_plugin_style_summary extends views_plugin_style {
|
||||
'#title' => t('Items to display'),
|
||||
'#default_value' => $this->options['items_per_page'],
|
||||
'#dependency' => array(
|
||||
'edit-options-summary-options-' . str_replace('_', '-', $this->definition['name']) . '-override' => array(1)
|
||||
'edit-options-summary-options-' . str_replace('_', '-', $this->definition['name']) . '-override' => array(1),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function render() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render() {
|
||||
$rows = array();
|
||||
foreach ($this->view->result as $row) {
|
||||
// @todo: Include separator as an option.
|
||||
// @todo Include separator as an option.
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
return theme($this->theme_functions(), array(
|
||||
'view' => $this->view,
|
||||
'options' => $this->options,
|
||||
'rows' => $rows
|
||||
'rows' => $rows,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the default summary style plugin, which displays items in an HTML list.
|
||||
* Definition of views_plugin_style_summary_jump_menu.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -11,7 +11,11 @@
|
||||
* @ingroup views_style_plugins
|
||||
*/
|
||||
class views_plugin_style_summary_jump_menu extends views_plugin_style {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['base_path'] = array('default' => '');
|
||||
@@ -26,7 +30,10 @@ class views_plugin_style_summary_jump_menu extends views_plugin_style {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function query() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
// Copy the offset option.
|
||||
$pager = array(
|
||||
'type' => 'none',
|
||||
@@ -35,7 +42,10 @@ class views_plugin_style_summary_jump_menu extends views_plugin_style {
|
||||
$this->display->handler->set_option('pager', $pager);
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
$form['base_path'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Base path'),
|
||||
@@ -56,7 +66,7 @@ class views_plugin_style_summary_jump_menu extends views_plugin_style {
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Hide the "Go" button'),
|
||||
'#default_value' => !empty($this->options['hide']),
|
||||
'#description' => t('If hidden, this button will only be hidden for users with javascript and the page will automatically jump when the select is changed.'),
|
||||
'#description' => t('If hidden, this button will only be hidden for users with JavaScript and the page will automatically jump when the select is changed.'),
|
||||
);
|
||||
|
||||
$form['text'] = array(
|
||||
@@ -93,7 +103,10 @@ class views_plugin_style_summary_jump_menu extends views_plugin_style {
|
||||
);
|
||||
}
|
||||
|
||||
function render() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render() {
|
||||
$argument = $this->view->argument[$this->view->build_info['summary_level']];
|
||||
|
||||
$url_options = array();
|
||||
@@ -143,4 +156,5 @@ class views_plugin_style_summary_jump_menu extends views_plugin_style {
|
||||
$form = drupal_get_form('ctools_jump_menu', $options, $settings);
|
||||
return drupal_render($form);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the unformatted summary style plugin.
|
||||
* Definition of views_plugin_style_summary_unformatted.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -11,14 +11,21 @@
|
||||
* @ingroup views_style_plugins
|
||||
*/
|
||||
class views_plugin_style_summary_unformatted extends views_plugin_style_summary {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['inline'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
$options['separator'] = array('default' => '');
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['inline'] = array(
|
||||
'#type' => 'checkbox',
|
||||
@@ -31,4 +38,5 @@ class views_plugin_style_summary_unformatted extends views_plugin_style_summary
|
||||
'#default_value' => $this->options['separator'],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the table style plugin.
|
||||
* Definition of views_plugin_style_table.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -24,10 +24,14 @@ class views_plugin_style_table extends views_plugin_style {
|
||||
*/
|
||||
public $order;
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['columns'] = array('default' => array());
|
||||
$options['class'] = array('default' => array());
|
||||
$options['default'] = array('default' => '');
|
||||
$options['info'] = array('default' => array());
|
||||
$options['override'] = array('default' => TRUE, 'bool' => TRUE);
|
||||
@@ -45,7 +49,7 @@ class views_plugin_style_table extends views_plugin_style {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function build_sort() {
|
||||
public function build_sort() {
|
||||
if (!isset($_GET['order']) && ($this->options['default'] == -1 || empty($this->view->field[$this->options['default']]))) {
|
||||
return TRUE;
|
||||
}
|
||||
@@ -62,7 +66,7 @@ class views_plugin_style_table extends views_plugin_style {
|
||||
/**
|
||||
* Add our actual sort criteria
|
||||
*/
|
||||
function build_sort_post() {
|
||||
public function build_sort_post() {
|
||||
if (!isset($_GET['order'])) {
|
||||
// check for a 'default' clicksort. If there isn't one, exit gracefully.
|
||||
if (empty($this->options['default'])) {
|
||||
@@ -111,10 +115,10 @@ class views_plugin_style_table extends views_plugin_style {
|
||||
* - Any fields not currently represented must be added.
|
||||
* - Columns must be re-ordered to match the fields.
|
||||
*
|
||||
* @param $columns
|
||||
* @param array $columns
|
||||
* An array of all fields; the key is the id of the field and the
|
||||
* value is the id of the column the field should be in.
|
||||
* @param $fields
|
||||
* @param array $fields
|
||||
* The fields to use for the columns. If not provided, they will
|
||||
* be requested from the current display. The running render should
|
||||
* send the fields through, as they may be different than what the
|
||||
@@ -123,7 +127,7 @@ class views_plugin_style_table extends views_plugin_style {
|
||||
* @return array
|
||||
* An array of all the sanitized columns.
|
||||
*/
|
||||
function sanitize_columns($columns, $fields = NULL) {
|
||||
public function sanitize_columns($columns, $fields = NULL) {
|
||||
$sanitized = array();
|
||||
if ($fields === NULL) {
|
||||
$fields = $this->display->handler->get_option('fields');
|
||||
@@ -157,7 +161,7 @@ class views_plugin_style_table extends views_plugin_style {
|
||||
/**
|
||||
* Render the given style.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$handlers = $this->display->handler->get_handlers('field');
|
||||
if (empty($handlers)) {
|
||||
@@ -175,7 +179,7 @@ class views_plugin_style_table extends views_plugin_style {
|
||||
|
||||
$form['sticky'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Enable Drupal style "sticky" table headers (Javascript)'),
|
||||
'#title' => t('Enable Drupal style "sticky" table headers (JavaScript)'),
|
||||
'#default_value' => !empty($this->options['sticky']),
|
||||
'#description' => t('(Sticky header effects will not be active for preview below, only on live output.)'),
|
||||
);
|
||||
@@ -195,6 +199,14 @@ class views_plugin_style_table extends views_plugin_style {
|
||||
'#default_value' => $this->options['summary'],
|
||||
'#maxlength' => 255,
|
||||
);
|
||||
|
||||
$form['class'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('CSS classes'),
|
||||
'#description' => t('Add CSS classes to the table; multiple classes may be separated by spaces.'),
|
||||
'#default_value' => $this->options['class'],
|
||||
'#maxlength' => 255,
|
||||
);
|
||||
|
||||
// Note: views UI registers this theme handler on our behalf. Your module
|
||||
// will have to register your theme handlers if you do stuff like this.
|
||||
@@ -202,7 +214,7 @@ class views_plugin_style_table extends views_plugin_style {
|
||||
|
||||
$columns = $this->sanitize_columns($this->options['columns']);
|
||||
|
||||
// Create an array of allowed columns from the data we know:
|
||||
// Create an array of allowed columns from the data we know.
|
||||
$field_names = $this->display->handler->get_field_labels();
|
||||
|
||||
if (isset($this->options['default'])) {
|
||||
@@ -293,7 +305,7 @@ class views_plugin_style_table extends views_plugin_style {
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Show the empty text in the table'),
|
||||
'#default_value' => $this->options['empty_table'],
|
||||
'#description' => t('Per default the table is hidden for an empty view. With this option it is posible to show an empty table with the text in it.'),
|
||||
'#description' => t('Per default the table is hidden for an empty view. With this option it is possible to show an empty table with the text in it.'),
|
||||
);
|
||||
|
||||
$form['description_markup'] = array(
|
||||
@@ -301,7 +313,10 @@ class views_plugin_style_table extends views_plugin_style {
|
||||
);
|
||||
}
|
||||
|
||||
function even_empty() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function even_empty() {
|
||||
return parent::even_empty() || !empty($this->options['empty_table']);
|
||||
}
|
||||
}
|
||||
|
@@ -14,8 +14,7 @@ $plugin = array(
|
||||
'class' => 'ViewsUiFileManagedViewsWizard',
|
||||
),
|
||||
'title' => t('Files'),
|
||||
'filters' => array(
|
||||
),
|
||||
'filters' => array(),
|
||||
'path_field' => array(
|
||||
'id' => 'uri',
|
||||
'table' => 'file_managed',
|
||||
|
@@ -10,7 +10,7 @@ $plugin = array(
|
||||
'base_table' => 'node',
|
||||
'created_column' => 'created',
|
||||
'available_sorts' => array(
|
||||
'title:DESC' => t('Title')
|
||||
'title:DESC' => t('Title'),
|
||||
),
|
||||
'form_wizard_class' => array(
|
||||
'file' => 'views_ui_node_views_wizard.class.php',
|
||||
|
@@ -17,7 +17,8 @@ $plugin = array(
|
||||
'filters' => array(
|
||||
'status' => array(
|
||||
'value' => '1',
|
||||
'table' => 'node', // @todo - unclear if this should be node or node_revision
|
||||
'table' => 'node',
|
||||
// @todo - unclear if this should be node or node_revision
|
||||
'field' => 'status',
|
||||
),
|
||||
),
|
||||
|
@@ -14,8 +14,7 @@ if (module_exists('taxonomy')) {
|
||||
'class' => 'ViewsUiTaxonomyTermViewsWizard',
|
||||
),
|
||||
'title' => t('Taxonomy terms'),
|
||||
'filters' => array(
|
||||
),
|
||||
'filters' => array(),
|
||||
'path_field' => array(
|
||||
'id' => 'tid',
|
||||
'table' => 'taxonomy_term_data',
|
||||
|
@@ -9,6 +9,10 @@
|
||||
* Defines a common interface for Views Wizard plugins.
|
||||
*/
|
||||
interface ViewsWizardInterface {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
function __construct($plugin);
|
||||
|
||||
/**
|
||||
@@ -31,6 +35,7 @@ interface ViewsWizardInterface {
|
||||
* @throws ViewsWizardException in the event of a problem.
|
||||
*/
|
||||
function create_view($form, &$form_state);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,6 +48,7 @@ class ViewsWizardException extends Exception {
|
||||
* A very generic Views Wizard class - can be constructed for any base table.
|
||||
*/
|
||||
class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
|
||||
|
||||
protected $base_table;
|
||||
protected $entity_type;
|
||||
protected $entity_info = array();
|
||||
@@ -87,7 +93,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
|
||||
|
||||
$form['displays']['page'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend'),),
|
||||
'#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend')),
|
||||
'#tree' => TRUE,
|
||||
);
|
||||
$form['displays']['page']['create'] = array(
|
||||
@@ -102,7 +108,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
|
||||
// can be hidden en masse when the "Create a page" checkbox is unchecked.
|
||||
$form['displays']['page']['options'] = array(
|
||||
'#type' => 'container',
|
||||
'#attributes' => array('class' => array('options-set'),),
|
||||
'#attributes' => array('class' => array('options-set')),
|
||||
'#dependency' => array(
|
||||
'edit-page-create' => array(1),
|
||||
),
|
||||
@@ -224,7 +230,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
|
||||
|
||||
$form['displays']['block'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend'),),
|
||||
'#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend')),
|
||||
'#tree' => TRUE,
|
||||
);
|
||||
$form['displays']['block']['create'] = array(
|
||||
@@ -238,7 +244,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
|
||||
// can be hidden en masse when the "Create a block" checkbox is unchecked.
|
||||
$form['displays']['block']['options'] = array(
|
||||
'#type' => 'container',
|
||||
'#attributes' => array('class' => array('options-set'),),
|
||||
'#attributes' => array('class' => array('options-set')),
|
||||
'#dependency' => array(
|
||||
'edit-block-create' => array(1),
|
||||
),
|
||||
@@ -334,7 +340,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the part of the form that allows the user to select the view's filters.
|
||||
* Build the part of the form that allows the user to select the filters.
|
||||
*
|
||||
* By default, this adds "of type" and "tagged with" filters (when they are
|
||||
* available).
|
||||
@@ -344,7 +350,8 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
|
||||
$fields = views_fetch_fields($this->base_table, 'filter');
|
||||
|
||||
$entity_info = $this->entity_info;
|
||||
// If the current base table support bundles and has more than one (like user).
|
||||
// If the current base table support bundles and has more than one (like
|
||||
// user).
|
||||
if (isset($entity_info['bundle keys']) && isset($entity_info['bundles'])) {
|
||||
// Get all bundles and their human readable names.
|
||||
$options = array('all' => t('All'));
|
||||
@@ -431,7 +438,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the part of the form that allows the user to select the view's sort order.
|
||||
* Build the part of the form that allows the user to select the sort order.
|
||||
*
|
||||
* By default, this adds a "sorted by [date]" filter (when it is available).
|
||||
*/
|
||||
@@ -492,7 +499,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
|
||||
* arrays of options for that display.
|
||||
*/
|
||||
protected function build_display_options($form, $form_state) {
|
||||
// Display: Master
|
||||
// Display: Master.
|
||||
$display_options['default'] = $this->default_display_options($form, $form_state);
|
||||
$display_options['default'] += array(
|
||||
'filters' => array(),
|
||||
@@ -501,17 +508,17 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
|
||||
$display_options['default']['filters'] += $this->default_display_filters($form, $form_state);
|
||||
$display_options['default']['sorts'] += $this->default_display_sorts($form, $form_state);
|
||||
|
||||
// Display: Page
|
||||
// Display: Page.
|
||||
if (!empty($form_state['values']['page']['create'])) {
|
||||
$display_options['page'] = $this->page_display_options($form, $form_state);
|
||||
|
||||
// Display: Feed (attached to the page)
|
||||
// Display: Feed (attached to the page).
|
||||
if (!empty($form_state['values']['page']['feed'])) {
|
||||
$display_options['feed'] = $this->page_feed_display_options($form, $form_state);
|
||||
}
|
||||
}
|
||||
|
||||
// Display: Block
|
||||
// Display: Block.
|
||||
if (!empty($form_state['values']['block']['create'])) {
|
||||
$display_options['block'] = $this->block_display_options($form, $form_state);
|
||||
}
|
||||
@@ -573,13 +580,13 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
|
||||
* Add the array of display options to the view, with appropriate overrides.
|
||||
*/
|
||||
protected function add_displays($view, $display_options, $form, $form_state) {
|
||||
// Display: Master
|
||||
// Display: Master.
|
||||
$default_display = $view->new_display('default', 'Master', 'default');
|
||||
foreach ($display_options['default'] as $option => $value) {
|
||||
$default_display->set_option($option, $value);
|
||||
}
|
||||
|
||||
// Display: Page
|
||||
// Display: Page.
|
||||
if (isset($display_options['page'])) {
|
||||
$display = $view->new_display('page', 'Page', 'page');
|
||||
// The page display is usually the main one (from the user's point of
|
||||
@@ -587,14 +594,14 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
|
||||
// so that new displays which are added later automatically inherit them.
|
||||
$this->set_default_options($display_options['page'], $display, $default_display);
|
||||
|
||||
// Display: Feed (attached to the page)
|
||||
// Display: Feed (attached to the page).
|
||||
if (isset($display_options['feed'])) {
|
||||
$display = $view->new_display('feed', 'Feed', 'feed');
|
||||
$this->set_override_options($display_options['feed'], $display, $default_display);
|
||||
}
|
||||
}
|
||||
|
||||
// Display: Block
|
||||
// Display: Block.
|
||||
if (isset($display_options['block'])) {
|
||||
$display = $view->new_display('block', 'Block', 'block');
|
||||
// When there is no page, the block display options should become the
|
||||
@@ -622,9 +629,10 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
|
||||
$display_options['style_plugin'] = 'default';
|
||||
$display_options['row_plugin'] = 'fields';
|
||||
|
||||
// Add a least one field so the view validates and the user has already a preview.
|
||||
// Therefore the basefield could provide 'defaults][field]' in it's base settings.
|
||||
// If there is nothing like this choose the first field with a field handler.
|
||||
// Add a least one field so the view validates and the user has already a
|
||||
// preview. Therefore the basefield could provide 'defaults][field]' in
|
||||
// it's base settings. If there is nothing like this choose the first field
|
||||
// with a field handler.
|
||||
$data = views_fetch_data($this->base_table);
|
||||
if (isset($data['table']['base']['defaults']['field'])) {
|
||||
$field = $data['table']['base']['defaults']['field'];
|
||||
@@ -682,8 +690,9 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
|
||||
}
|
||||
}
|
||||
$table_data = views_fetch_data($table);
|
||||
// Check whether the bundle key filter handler is or an child of it views_handler_filter_in_operator
|
||||
// If it's not just use a single value instead of an array.
|
||||
// Check whether the bundle key filter handler is or an child of it
|
||||
// views_handler_filter_in_operator. If it's not just use a single value
|
||||
// instead of an array.
|
||||
$handler = $table_data[$bundle_key]['filter']['handler'];
|
||||
if ($handler == 'views_handler_filter_in_operator' || is_subclass_of($handler, 'views_handler_filter_in_operator')) {
|
||||
$value = drupal_map_assoc(array($form_state['values']['show']['type']));
|
||||
@@ -700,7 +709,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
|
||||
);
|
||||
}
|
||||
|
||||
// @todo: Figure out why this isn't part of node_views_wizard.
|
||||
// @todo Figure out why this isn't part of node_views_wizard.
|
||||
if (!empty($form_state['values']['show']['tagged_with']['tids'])) {
|
||||
$filters['tid'] = array(
|
||||
'id' => 'tid',
|
||||
@@ -741,7 +750,8 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
|
||||
protected function default_display_sorts_user($form, $form_state) {
|
||||
$sorts = array();
|
||||
|
||||
// Don't add a sort if there is no form value or the user selected none as sort.
|
||||
// Don't add a sort if there is no form value or the user selected none as
|
||||
// sort.
|
||||
if (!empty($form_state['values']['show']['sort']) && $form_state['values']['show']['sort'] != 'none') {
|
||||
list($column, $sort) = explode(':', $form_state['values']['show']['sort']);
|
||||
// Column either be a column-name or the table-columnn-ame.
|
||||
@@ -826,14 +836,14 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
|
||||
* so that new displays which the user adds later will be similar to this
|
||||
* one.
|
||||
*
|
||||
* @param $options
|
||||
* @param array $options
|
||||
* An array whose keys are the name of each option and whose values are the
|
||||
* desired values to set.
|
||||
* @param $display
|
||||
* @param object $display
|
||||
* The display which the options will be applied to. The default display
|
||||
* will actually be assigned the options (and this display will inherit
|
||||
* them) when possible.
|
||||
* @param $default_display
|
||||
* @param object$default_display
|
||||
* The default display, which will store the options when possible.
|
||||
*/
|
||||
protected function set_default_options($options, $display, $default_display) {
|
||||
@@ -862,13 +872,13 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
|
||||
* the views wizard, then the view will wind up with the title stored as the
|
||||
* default (with the page and block both inheriting from it).
|
||||
*
|
||||
* @param $options
|
||||
* @param array $options
|
||||
* An array whose keys are the name of each option and whose values are the
|
||||
* desired values.
|
||||
* @param $display
|
||||
* @param object $display
|
||||
* The display which the options will apply to. It will get the options by
|
||||
* inheritance from the default display when possible.
|
||||
* @param $default_display
|
||||
* @param object $default_display
|
||||
* The default display, from which the options will be inherited when
|
||||
* possible.
|
||||
*/
|
||||
@@ -918,12 +928,12 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface {
|
||||
*
|
||||
* @throws ViewsWizardException if the values have not been validated.
|
||||
*/
|
||||
function create_view($form, &$form_state) {
|
||||
$view = $this->retrieve_validated_view($form, $form_state);
|
||||
if (empty($view)) {
|
||||
throw new ViewsWizardException(t('Attempted to create_view with values that have not been validated'));
|
||||
}
|
||||
return $view;
|
||||
}
|
||||
function create_view($form, &$form_state) {
|
||||
$view = $this->retrieve_validated_view($form, $form_state);
|
||||
if (empty($view)) {
|
||||
throw new ViewsWizardException(t('Attempted to create_view with values that have not been validated'));
|
||||
}
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -105,4 +105,5 @@ class ViewsUiCommentViewsWizard extends ViewsUiBaseViewsWizard {
|
||||
|
||||
return $display_options;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@
|
||||
* Tests creating managed files views with the wizard.
|
||||
*/
|
||||
class ViewsUiFileManagedViewsWizard extends ViewsUiBaseViewsWizard {
|
||||
|
||||
protected function default_display_options($form, $form_state) {
|
||||
$display_options = parent::default_display_options($form, $form_state);
|
||||
|
||||
@@ -37,4 +38,5 @@ class ViewsUiFileManagedViewsWizard extends ViewsUiBaseViewsWizard {
|
||||
|
||||
return $display_options;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -65,4 +65,5 @@ class ViewsUiNodeRevisionViewsWizard extends ViewsUiNodeViewsWizard {
|
||||
|
||||
return $display_options;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -118,20 +118,24 @@ class ViewsUiNodeViewsWizard extends ViewsUiBaseViewsWizard {
|
||||
$display_options['row_options']['links'] = !empty($row_options['links']);
|
||||
$display_options['row_options']['comments'] = !empty($row_options['comments']);
|
||||
break;
|
||||
|
||||
case 'teasers':
|
||||
$display_options['row_plugin'] = 'node';
|
||||
$display_options['row_options']['build_mode'] = 'teaser';
|
||||
$display_options['row_options']['links'] = !empty($row_options['links']);
|
||||
$display_options['row_options']['comments'] = !empty($row_options['comments']);
|
||||
break;
|
||||
|
||||
case 'titles_linked':
|
||||
$display_options['row_plugin'] = 'fields';
|
||||
$display_options['field']['title']['link_to_node'] = 1;
|
||||
break;
|
||||
|
||||
case 'titles':
|
||||
$display_options['row_plugin'] = 'fields';
|
||||
$display_options['field']['title']['link_to_node'] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -39,4 +39,5 @@ class ViewsUiTaxonomyTermViewsWizard extends ViewsUiBaseViewsWizard {
|
||||
|
||||
return $display_options;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@
|
||||
* Tests creating user views with the wizard.
|
||||
*/
|
||||
class ViewsUiUsersViewsWizard extends ViewsUiBaseViewsWizard {
|
||||
|
||||
protected function default_display_options($form, $form_state) {
|
||||
$display_options = parent::default_display_options($form, $form_state);
|
||||
|
||||
@@ -39,4 +40,5 @@ class ViewsUiUsersViewsWizard extends ViewsUiBaseViewsWizard {
|
||||
|
||||
return $display_options;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user