本文整理汇总了PHP中views_ui_standard_display_dropdown函数的典型用法代码示例。如果您正苦于以下问题:PHP views_ui_standard_display_dropdown函数的具体用法?PHP views_ui_standard_display_dropdown怎么用?PHP views_ui_standard_display_dropdown使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了views_ui_standard_display_dropdown函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$view = $form_state->get('view');
$display_id = $form_state->get('display_id');
$type = $form_state->get('type');
$types = ViewExecutable::getHandlerTypes();
$executable = $view->getExecutable();
if (!$executable->setDisplay($display_id)) {
$form['markup'] = array('#markup' => $this->t('Invalid display id @display', array('@display' => $display_id)));
return $form;
}
$display =& $executable->displayHandlers->get($display_id);
$form['#title'] = $this->t('Rearrange @type', array('@type' => $types[$type]['ltitle']));
$form['#section'] = $display_id . 'rearrange-item';
if ($display->defaultableSections($types[$type]['plural'])) {
$section = $types[$type]['plural'];
$form_state->set('section', $section);
views_ui_standard_display_dropdown($form, $form_state, $section);
}
$count = 0;
// Get relationship labels
$relationships = array();
foreach ($display->getHandlers('relationship') as $id => $handler) {
$relationships[$id] = $handler->adminLabel();
}
$form['fields'] = array('#type' => 'table', '#header' => array('', $this->t('Weight'), $this->t('Remove')), '#empty' => $this->t('No fields available.'), '#tabledrag' => array(array('action' => 'order', 'relationship' => 'sibling', 'group' => 'weight')), '#tree' => TRUE, '#prefix' => '<div class="scroll" data-drupal-views-scroll>', '#suffix' => '</div>');
foreach ($display->getOption($types[$type]['plural']) as $id => $field) {
$form['fields'][$id] = array();
$form['fields'][$id]['#attributes'] = array('class' => array('draggable'), 'id' => 'views-row-' . $id);
$handler = $display->getHandler($type, $id);
if ($handler) {
$name = $handler->adminLabel() . ' ' . $handler->adminSummary();
if (!empty($field['relationship']) && !empty($relationships[$field['relationship']])) {
$name = '(' . $relationships[$field['relationship']] . ') ' . $name;
}
$markup = $name;
} else {
$name = $id;
$markup = $this->t('Broken field @id', array('@id' => $id));
}
$form['fields'][$id]['name'] = array('#markup' => $markup);
$form['fields'][$id]['weight'] = array('#type' => 'textfield', '#default_value' => ++$count, '#attributes' => array('class' => array('weight')), '#title' => t('Weight for @title', array('@title' => $name)), '#title_display' => 'invisible');
$form['fields'][$id]['removed'] = array('#type' => 'checkbox', '#title' => t('Remove @title', array('@title' => $name)), '#title_display' => 'invisible', '#id' => 'views-removed-' . $id, '#attributes' => array('class' => array('views-remove-checkbox')), '#default_value' => 0, '#suffix' => \Drupal::l(String::format('<span>@text</span>', array('@text' => $this->t('Remove'))), Url::fromRoute('<none>', array(), array('attributes' => array('id' => 'views-remove-link-' . $id, 'class' => array('views-hidden', 'views-button-remove', 'views-remove-link'), 'alt' => $this->t('Remove this item'), 'title' => $this->t('Remove this item'))))));
}
$view->getStandardButtons($form, $form_state, 'views_ui_rearrange_form');
return $form;
}
示例2: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$view = $form_state->get('view');
$display_id = $form_state->get('display_id');
$type = $form_state->get('type');
$form = array('options' => array('#theme_wrappers' => array('container'), '#attributes' => array('class' => array('scroll'), 'data-drupal-views-scroll' => TRUE)));
$executable = $view->getExecutable();
$executable->setDisplay($display_id);
$display =& $executable->displayHandlers->get($display_id);
$types = ViewExecutable::getHandlerTypes();
$ltitle = $types[$type]['ltitle'];
$section = $types[$type]['plural'];
if (!empty($types[$type]['type'])) {
$type = $types[$type]['type'];
}
$form['#title'] = $this->t('Add @type', array('@type' => $ltitle));
$form['#section'] = $display_id . 'add-handler';
// Add the display override dropdown.
views_ui_standard_display_dropdown($form, $form_state, $section);
// Figure out all the base tables allowed based upon what the relationships provide.
$base_tables = $executable->getBaseTables();
$options = Views::viewsDataHelper()->fetchFields(array_keys($base_tables), $type, $display->useGroupBy(), $form_state->get('type'));
if (!empty($options)) {
$form['override']['controls'] = array('#theme_wrappers' => array('container'), '#id' => 'views-filterable-options-controls', '#attributes' => array('class' => array('container-inline')));
$form['override']['controls']['options_search'] = array('#type' => 'textfield', '#title' => $this->t('Search'));
$groups = array('all' => $this->t('- All -'));
$form['override']['controls']['group'] = array('#type' => 'select', '#title' => $this->t('Type'), '#options' => array());
$form['options']['name'] = array('#prefix' => '<div class="views-radio-box form-checkboxes views-filterable-options">', '#suffix' => '</div>', '#tree' => TRUE, '#default_value' => 'all');
// Group options first to simplify the usage of #states.
$grouped_options = array();
foreach ($options as $key => $option) {
$group = preg_replace('/[^a-z0-9]/', '-', strtolower($option['group']));
$groups[$group] = $option['group'];
$grouped_options[$group][$key] = $option;
if (!empty($option['aliases']) && is_array($option['aliases'])) {
foreach ($option['aliases'] as $id => $alias) {
if (empty($alias['base']) || !empty($base_tables[$alias['base']])) {
$copy = $option;
$copy['group'] = $alias['group'];
$copy['title'] = $alias['title'];
if (isset($alias['help'])) {
$copy['help'] = $alias['help'];
}
$group = preg_replace('/[^a-z0-9]/', '-', strtolower($copy['group']));
$groups[$group] = $copy['group'];
$grouped_options[$group][$key . '$' . $id] = $copy;
}
}
}
}
foreach ($grouped_options as $group => $group_options) {
foreach ($group_options as $key => $option) {
$form['options']['name'][$key] = array('#type' => 'checkbox', '#title' => $this->t('!group: !field', array('!group' => $option['group'], '!field' => $option['title'])), '#description' => $option['help'], '#return_value' => $key, '#prefix' => "<div class='filterable-option'>", '#suffix' => '</div>', '#states' => array('visible' => array(array(':input[name="override[controls][group]"]' => array('value' => 'all')), array(':input[name="override[controls][group]"]' => array('value' => $group)))));
}
}
$form['override']['controls']['group']['#options'] = $groups;
} else {
$form['options']['markup'] = array('#markup' => '<div class="form-item">' . $this->t('There are no @types available to add.', array('@types' => $ltitle)) . '</div>');
}
// Add a div to show the selected items
$form['selected'] = array('#type' => 'item', '#markup' => '<span class="views-ui-view-title">' . $this->t('Selected:') . '</span> ' . '<div class="views-selected-options"></div>', '#theme_wrappers' => array('form_element', 'views_ui_container'), '#attributes' => array('class' => array('container-inline', 'views-add-form-selected'), 'data-drupal-views-offset' => 'bottom'));
$view->getStandardButtons($form, $form_state, 'views_ui_add_handler_form', $this->t('Add and configure @types', array('@types' => $ltitle)));
// Remove the default submit function.
$form['actions']['submit']['#submit'] = array_filter($form['actions']['submit']['#submit'], function ($var) {
return !(is_array($var) && isset($var[1]) && $var[1] == 'standardSubmit');
});
$form['actions']['submit']['#submit'][] = array($view, 'submitItemAdd');
return $form;
}
示例3: buildOptionsForm
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state)
{
parent::buildOptionsForm($form, $form_state);
$section = $form_state->get('section');
if ($this->defaultableSections($section)) {
views_ui_standard_display_dropdown($form, $form_state, $section);
}
$form['#title'] = $this->display['display_title'] . ': ';
// Set the 'section' to highlight on the form.
// If it's the item we're looking at is pulling from the default display,
// reflect that. Don't use is_defaulted since we want it to show up even
// on the default display.
if (!empty($this->options['defaults'][$section])) {
$form['#section'] = 'default-' . $section;
} else {
$form['#section'] = $this->display['id'] . '-' . $section;
}
switch ($section) {
case 'display_id':
$form['#title'] .= $this->t('The machine name of this display');
$form['display_id'] = array('#type' => 'textfield', '#title' => $this->t('Machine name of the display'), '#default_value' => !empty($this->display['new_id']) ? $this->display['new_id'] : $this->display['id'], '#required' => TRUE, '#size' => 64);
break;
case 'display_title':
$form['#title'] .= $this->t('The name and the description of this display');
$form['display_title'] = array('#title' => $this->t('Administrative name'), '#type' => 'textfield', '#default_value' => $this->display['display_title']);
$form['display_description'] = array('#title' => $this->t('Administrative description'), '#type' => 'textfield', '#default_value' => $this->getOption('display_description'));
break;
case 'display_comment':
$form['#title'] .= $this->t('Administrative comment');
$form['display_comment'] = array('#type' => 'textarea', '#title' => $this->t('Administrative comment'), '#description' => $this->t('This description will only be seen within the administrative interface and can be used to document this display.'), '#default_value' => $this->getOption('display_comment'));
break;
case 'title':
$form['#title'] .= $this->t('The title of this view');
$form['title'] = array('#title' => $this->t('Title'), '#type' => 'textfield', '#description' => $this->t('This title will be displayed with the view, wherever titles are normally displayed; i.e, as the page title, block title, etc.'), '#default_value' => $this->getOption('title'), '#maxlength' => 255);
break;
case 'css_class':
$form['#title'] .= $this->t('CSS class');
$form['css_class'] = array('#type' => 'textfield', '#title' => $this->t('CSS class name(s)'), '#description' => $this->t('Separate multiple classes by spaces.'), '#default_value' => $this->getOption('css_class'));
break;
case 'use_ajax':
$form['#title'] .= $this->t('AJAX');
$form['use_ajax'] = array('#description' => $this->t('Options such as paging, table sorting, and exposed filters will not initiate a page refresh.'), '#type' => 'checkbox', '#title' => $this->t('Use AJAX'), '#default_value' => $this->getOption('use_ajax') ? 1 : 0);
break;
case 'hide_attachment_summary':
$form['#title'] .= $this->t('Hide attachments when displaying a contextual filter summary');
$form['hide_attachment_summary'] = array('#type' => 'checkbox', '#title' => $this->t('Hide attachments in summary'), '#default_value' => $this->getOption('hide_attachment_summary') ? 1 : 0);
break;
case 'show_admin_links':
$form['#title'] .= $this->t('Show contextual links on this view.');
$form['show_admin_links'] = array('#type' => 'checkbox', '#title' => $this->t('Show contextual links'), '#default_value' => $this->getOption('show_admin_links'));
break;
case 'use_more':
$form['#title'] .= $this->t('Add a more link to the bottom of the display.');
$form['use_more'] = array('#type' => 'checkbox', '#title' => $this->t('Create more link'), '#description' => $this->t("This will add a more link to the bottom of this view, which will link to the page view. If you have more than one page view, the link will point to the display specified in 'Link display' section under pager. You can override the URL at the link display setting."), '#default_value' => $this->getOption('use_more'));
$form['use_more_always'] = array('#type' => 'checkbox', '#title' => $this->t('Always display the more link'), '#description' => $this->t('Check this to display the more link even if there are no more items to display.'), '#default_value' => $this->getOption('use_more_always'), '#states' => array('visible' => array(':input[name="use_more"]' => array('checked' => TRUE))));
$form['use_more_text'] = array('#type' => 'textfield', '#title' => $this->t('More link text'), '#description' => $this->t('The text to display for the more link.'), '#default_value' => $this->getOption('use_more_text'), '#states' => array('visible' => array(':input[name="use_more"]' => array('checked' => TRUE))));
break;
case 'group_by':
$form['#title'] .= $this->t('Allow grouping and aggregation (calculation) of fields.');
$form['group_by'] = array('#type' => 'checkbox', '#title' => $this->t('Aggregate'), '#description' => $this->t('If enabled, some fields may become unavailable. All fields that are selected for grouping will be collapsed to one record per distinct value. Other fields which are selected for aggregation will have the function run on them. For example, you can group nodes on title and count the number of nids in order to get a list of duplicate titles.'), '#default_value' => $this->getOption('group_by'));
break;
case 'access':
$form['#title'] .= $this->t('Access restrictions');
$form['access'] = array('#prefix' => '<div class="clearfix">', '#suffix' => '</div>', '#tree' => TRUE);
$access = $this->getOption('access');
$form['access']['type'] = array('#title' => $this->t('Access'), '#title_display' => 'invisible', '#type' => 'radios', '#options' => Views::fetchPluginNames('access', $this->getType(), array($this->view->storage->get('base_table'))), '#default_value' => $access['type']);
$access_plugin = $this->getPlugin('access');
if ($access_plugin->usesOptions()) {
$form['markup'] = array('#prefix' => '<div class="js-form-item form-item description">', '#markup' => $this->t('You may also adjust the @settings for the currently selected access restriction.', array('@settings' => $this->optionLink($this->t('settings'), 'access_options'))), '#suffix' => '</div>');
}
break;
case 'access_options':
$plugin = $this->getPlugin('access');
$form['#title'] .= $this->t('Access options');
if ($plugin) {
$form['access_options'] = array('#tree' => TRUE);
$plugin->buildOptionsForm($form['access_options'], $form_state);
}
break;
case 'cache':
$form['#title'] .= $this->t('Caching');
$form['cache'] = array('#prefix' => '<div class="clearfix">', '#suffix' => '</div>', '#tree' => TRUE);
$cache = $this->getOption('cache');
$form['cache']['type'] = array('#title' => $this->t('Caching'), '#title_display' => 'invisible', '#type' => 'radios', '#options' => Views::fetchPluginNames('cache', $this->getType(), array($this->view->storage->get('base_table'))), '#default_value' => $cache['type']);
$cache_plugin = $this->getPlugin('cache');
if ($cache_plugin->usesOptions()) {
$form['markup'] = array('#prefix' => '<div class="js-form-item form-item description">', '#suffix' => '</div>', '#markup' => $this->t('You may also adjust the @settings for the currently selected cache mechanism.', array('@settings' => $this->optionLink($this->t('settings'), 'cache_options'))));
}
break;
case 'cache_options':
$plugin = $this->getPlugin('cache');
$form['#title'] .= $this->t('Caching options');
if ($plugin) {
$form['cache_options'] = array('#tree' => TRUE);
$plugin->buildOptionsForm($form['cache_options'], $form_state);
}
break;
//.........这里部分代码省略.........
示例4: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$view = $form_state->get('view');
$display_id = $form_state->get('display_id');
$type = 'filter';
$types = ViewExecutable::getHandlerTypes();
$executable = $view->getExecutable();
if (!$executable->setDisplay($display_id)) {
$form['markup'] = array('#markup' => $this->t('Invalid display id @display', array('@display' => $display_id)));
return $form;
}
$display = $executable->displayHandlers->get($display_id);
$form['#title'] = Html::escape($display->display['display_title']) . ': ';
$form['#title'] .= $this->t('Rearrange @type', array('@type' => $types[$type]['ltitle']));
$form['#section'] = $display_id . 'rearrange-item';
if ($display->defaultableSections($types[$type]['plural'])) {
$section = $types[$type]['plural'];
$form_state->set('section', $section);
views_ui_standard_display_dropdown($form, $form_state, $section);
}
if (!empty($view->form_cache)) {
$groups = $view->form_cache['groups'];
$handlers = $view->form_cache['handlers'];
} else {
$groups = $display->getOption('filter_groups');
$handlers = $display->getOption($types[$type]['plural']);
}
$count = 0;
// Get relationship labels
$relationships = array();
foreach ($display->getHandlers('relationship') as $id => $handler) {
$relationships[$id] = $handler->adminLabel();
}
$group_options = array();
/**
* Filter groups is an array that contains:
* array(
* 'operator' => 'and' || 'or',
* 'groups' => array(
* $group_id => 'and' || 'or',
* ),
* );
*/
$grouping = count(array_keys($groups['groups'])) > 1;
$form['filter_groups']['#tree'] = TRUE;
$form['filter_groups']['operator'] = array('#type' => 'select', '#options' => array('AND' => $this->t('And'), 'OR' => $this->t('Or')), '#default_value' => $groups['operator'], '#attributes' => array('class' => array('warning-on-change')), '#title' => $this->t('Operator to use on all groups'), '#description' => $this->t('Either "group 0 AND group 1 AND group 2" or "group 0 OR group 1 OR group 2", etc'), '#access' => $grouping);
$form['remove_groups']['#tree'] = TRUE;
foreach ($groups['groups'] as $id => $group) {
$form['filter_groups']['groups'][$id] = array('#title' => $this->t('Operator'), '#type' => 'select', '#options' => array('AND' => $this->t('And'), 'OR' => $this->t('Or')), '#default_value' => $group, '#attributes' => array('class' => array('warning-on-change')));
$form['remove_groups'][$id] = array();
// to prevent a notice
if ($id != 1) {
$form['remove_groups'][$id] = array('#type' => 'submit', '#value' => $this->t('Remove group @group', array('@group' => $id)), '#id' => "views-remove-group-{$id}", '#attributes' => array('class' => array('views-remove-group')), '#group' => $id);
}
$group_options[$id] = $id == 1 ? $this->t('Default group') : $this->t('Group @group', array('@group' => $id));
$form['#group_renders'][$id] = array();
}
$form['#group_options'] = $group_options;
$form['#groups'] = $groups;
// We don't use getHandlers() because we want items without handlers to
// appear and show up as 'broken' so that the user can see them.
$form['filters'] = array('#tree' => TRUE);
foreach ($handlers as $id => $field) {
// If the group does not exist, move the filters to the default group.
if (empty($field['group']) || empty($groups['groups'][$field['group']])) {
$field['group'] = 1;
}
$handler = $display->getHandler($type, $id);
if ($grouping && $handler && !$handler->canGroup()) {
$field['group'] = 'ungroupable';
}
// If not grouping and the handler is set ungroupable, move it back to
// the default group to prevent weird errors from having it be in its
// own group:
if (!$grouping && $field['group'] == 'ungroupable') {
$field['group'] = 1;
}
// Place this item into the proper group for rendering.
$form['#group_renders'][$field['group']][] = $id;
$form['filters'][$id]['weight'] = array('#title' => t('Weight for @id', array('@id' => $id)), '#title_display' => 'invisible', '#type' => 'textfield', '#default_value' => ++$count, '#size' => 8);
$form['filters'][$id]['group'] = array('#title' => t('Group for @id', array('@id' => $id)), '#title_display' => 'invisible', '#type' => 'select', '#options' => $group_options, '#default_value' => $field['group'], '#attributes' => array('class' => array('views-region-select', 'views-region-' . $id)), '#access' => $field['group'] !== 'ungroupable');
if ($handler) {
$name = $handler->adminLabel() . ' ' . $handler->adminSummary();
if (!empty($field['relationship']) && !empty($relationships[$field['relationship']])) {
$name = '(' . $relationships[$field['relationship']] . ') ' . $name;
}
$form['filters'][$id]['name'] = array('#markup' => $name);
} else {
$form['filters'][$id]['name'] = array('#markup' => $this->t('Broken field @id', array('@id' => $id)));
}
$form['filters'][$id]['removed'] = array('#title' => t('Remove @id', array('@id' => $id)), '#title_display' => 'invisible', '#type' => 'checkbox', '#id' => 'views-removed-' . $id, '#attributes' => array('class' => array('views-remove-checkbox')), '#default_value' => 0);
}
$view->getStandardButtons($form, $form_state, 'views_ui_rearrange_filter_form');
$form['actions']['add_group'] = array('#type' => 'submit', '#value' => $this->t('Create new filter group'), '#id' => 'views-add-group', '#group' => 'add', '#attributes' => array('class' => array('views-add-group')), '#ajax' => ['url' => NULL]);
return $form;
}
示例5: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, array &$form_state)
{
$view = $form_state['view'];
$display_id = $form_state['display_id'];
$type = $form_state['type'];
$id = $form_state['id'];
$form = array('options' => array('#tree' => TRUE, '#theme_wrappers' => array('container'), '#attributes' => array('class' => array('scroll'), 'data-drupal-views-scroll' => TRUE)));
$executable = $view->getExecutable();
$save_ui_cache = FALSE;
$executable->setDisplay($display_id);
$item = $executable->getHandler($display_id, $type, $id);
if ($item) {
$handler = $executable->display_handler->getHandler($type, $id);
if (empty($handler)) {
$form['markup'] = array('#markup' => $this->t("Error: handler for @table > @field doesn't exist!", array('@table' => $item['table'], '@field' => $item['field'])));
} else {
$types = ViewExecutable::getHandlerTypes();
// If this item can come from the default display, show a dropdown
// that lets the user choose which display the changes should apply to.
if ($executable->display_handler->defaultableSections($types[$type]['plural'])) {
$form_state['section'] = $types[$type]['plural'];
views_ui_standard_display_dropdown($form, $form_state, $form_state['section']);
}
// A whole bunch of code to figure out what relationships are valid for
// this item.
$relationships = $executable->display_handler->getOption('relationships');
$relationship_options = array();
foreach ($relationships as $relationship) {
// relationships can't link back to self. But also, due to ordering,
// relationships can only link to prior relationships.
if ($type == 'relationship' && $id == $relationship['id']) {
break;
}
$relationship_handler = Views::handlerManager('relationship')->getHandler($relationship);
// ignore invalid/broken relationships.
if (empty($relationship_handler)) {
continue;
}
// If this relationship is valid for this type, add it to the list.
$data = Views::viewsData()->get($relationship['table']);
if (isset($data[$relationship['field']]['relationship']['base']) && ($base = $data[$relationship['field']]['relationship']['base'])) {
$base_fields = Views::viewsDataHelper()->fetchFields($base, $form_state['type'], $executable->display_handler->useGroupBy());
if (isset($base_fields[$item['table'] . '.' . $item['field']])) {
$relationship_handler->init($executable, $executable->display_handler, $relationship);
$relationship_options[$relationship['id']] = $relationship_handler->adminLabel();
}
}
}
if (!empty($relationship_options)) {
// Make sure the existing relationship is even valid. If not, force
// it to none.
$base_fields = Views::viewsDataHelper()->fetchFields($view->get('base_table'), $form_state['type'], $executable->display_handler->useGroupBy());
if (isset($base_fields[$item['table'] . '.' . $item['field']])) {
$relationship_options = array_merge(array('none' => $this->t('Do not use a relationship')), $relationship_options);
}
$rel = empty($item['relationship']) ? 'none' : $item['relationship'];
if (empty($relationship_options[$rel])) {
// Pick the first relationship.
$rel = key($relationship_options);
// We want this relationship option to get saved even if the user
// skips submitting the form.
$executable->setHandlerOption($display_id, $type, $id, 'relationship', $rel);
$save_ui_cache = TRUE;
}
$form['options']['relationship'] = array('#type' => 'select', '#title' => $this->t('Relationship'), '#options' => $relationship_options, '#default_value' => $rel, '#weight' => -500);
} else {
$form['options']['relationship'] = array('#type' => 'value', '#value' => 'none');
}
$form['#title'] = $this->t('Configure @type: @item', array('@type' => $types[$type]['lstitle'], '@item' => $handler->adminLabel()));
if (!empty($handler->definition['help'])) {
$form['options']['form_description'] = array('#markup' => $handler->definition['help'], '#theme_wrappers' => array('container'), '#attributes' => array('class' => array('form-item description')), '#weight' => -1000);
}
$form['#section'] = $display_id . '-' . $type . '-' . $id;
// Get form from the handler.
$handler->buildOptionsForm($form['options'], $form_state);
$form_state['handler'] = $handler;
}
$name = NULL;
if (isset($form_state['update_name'])) {
$name = $form_state['update_name'];
}
$view->getStandardButtons($form, $form_state, 'views_ui_config_item_form', $name);
// Add a 'remove' button.
$form['actions']['remove'] = array('#type' => 'submit', '#value' => $this->t('Remove'), '#submit' => array(array($this, 'remove')), '#limit_validation_errors' => array(array('override')), '#ajax' => array('path' => current_path()));
}
if ($save_ui_cache) {
$view->cacheSet();
}
return $form;
}
示例6: buildOptionsForm
/**
* Provide the default form for setting options.
*/
public function buildOptionsForm(&$form, &$form_state)
{
parent::buildOptionsForm($form, $form_state);
if ($this->defaultableSections($form_state['section'])) {
views_ui_standard_display_dropdown($form, $form_state, $form_state['section']);
}
$form['#title'] = String::checkPlain($this->display['display_title']) . ': ';
// Set the 'section' to hilite on the form.
// If it's the item we're looking at is pulling from the default display,
// reflect that. Don't use is_defaulted since we want it to show up even
// on the default display.
if (!empty($this->options['defaults'][$form_state['section']])) {
$form['#section'] = 'default-' . $form_state['section'];
} else {
$form['#section'] = $this->display['id'] . '-' . $form_state['section'];
}
switch ($form_state['section']) {
case 'display_id':
$form['#title'] .= t('The machine name of this display');
$form['display_id'] = array('#type' => 'textfield', '#title' => t('Machine name of the display'), '#default_value' => !empty($this->display['new_id']) ? $this->display['new_id'] : $this->display['id'], '#required' => TRUE, '#size' => 64);
break;
case 'display_title':
$form['#title'] .= t('The name and the description of this display');
$form['display_title'] = array('#title' => t('Administrative name'), '#type' => 'textfield', '#default_value' => $this->display['display_title']);
$form['display_description'] = array('#title' => t('Administrative description'), '#type' => 'textfield', '#default_value' => $this->getOption('display_description'));
break;
case 'display_comment':
$form['#title'] .= t('Administrative comment');
$form['display_comment'] = array('#type' => 'textarea', '#title' => t('Administrative comment'), '#description' => t('This description will only be seen within the administrative interface and can be used to document this display.'), '#default_value' => $this->getOption('display_comment'));
break;
case 'title':
$form['#title'] .= t('The title of this view');
$form['title'] = array('#title' => t('Title'), '#type' => 'textfield', '#description' => t('This title will be displayed with the view, wherever titles are normally displayed; i.e, as the page title, block title, etc.'), '#default_value' => $this->getOption('title'), '#maxlength' => 255);
break;
case 'css_class':
$form['#title'] .= t('CSS class');
$form['css_class'] = array('#type' => 'textfield', '#title' => t('CSS class name(s)'), '#description' => t('Multiples classes should be separated by spaces.'), '#default_value' => $this->getOption('css_class'));
break;
case 'use_ajax':
$form['#title'] .= t('Use AJAX when available to load this view');
$form['use_ajax'] = array('#description' => t('When viewing a view, things like paging, table sorting, and exposed filters will not trigger a page refresh.'), '#type' => 'checkbox', '#title' => t('Use AJAX'), '#default_value' => $this->getOption('use_ajax') ? 1 : 0);
break;
case 'hide_attachment_summary':
$form['#title'] .= t('Hide attachments when displaying a contextual filter summary');
$form['hide_attachment_summary'] = array('#type' => 'checkbox', '#title' => t('Hide attachments in summary'), '#default_value' => $this->getOption('hide_attachment_summary') ? 1 : 0);
break;
case 'show_admin_links':
$form['#title'] .= t('Show contextual links on this view.');
$form['show_admin_links'] = array('#type' => 'checkbox', '#title' => t('Show contextual links'), '#default_value' => $this->getOption('show_admin_links'));
break;
case 'use_more':
$form['#title'] .= t('Add a more link to the bottom of the display.');
$form['use_more'] = array('#type' => 'checkbox', '#title' => t('Create more link'), '#description' => t("This will add a more link to the bottom of this view, which will link to the page view. If you have more than one page view, the link will point to the display specified in 'Link display' section under pager. You can override the url at the link display setting."), '#default_value' => $this->getOption('use_more'));
$form['use_more_always'] = array('#type' => 'checkbox', '#title' => t('Always display the more link'), '#description' => t('Check this to display the more link even if there are no more items to display.'), '#default_value' => $this->getOption('use_more_always'), '#states' => array('visible' => array(':input[name="use_more"]' => array('checked' => TRUE))));
$form['use_more_text'] = array('#type' => 'textfield', '#title' => t('More link text'), '#description' => t('The text to display for the more link.'), '#default_value' => $this->getOption('use_more_text'), '#states' => array('visible' => array(':input[name="use_more"]' => array('checked' => TRUE))));
break;
case 'group_by':
$form['#title'] .= t('Allow grouping and aggregation (calculation) of fields.');
$form['group_by'] = array('#type' => 'checkbox', '#title' => t('Aggregate'), '#description' => t('If enabled, some fields may become unavailable. All fields that are selected for grouping will be collapsed to one record per distinct value. Other fields which are selected for aggregation will have the function run on them. For example, you can group nodes on title and count the number of nids in order to get a list of duplicate titles.'), '#default_value' => $this->getOption('group_by'));
break;
case 'access':
$form['#title'] .= t('Access restrictions');
$form['access'] = array('#prefix' => '<div class="clearfix">', '#suffix' => '</div>', '#tree' => TRUE);
$access = $this->getOption('access');
$form['access']['type'] = array('#title' => t('Access'), '#title_display' => 'invisible', '#type' => 'radios', '#options' => Views::fetchPluginNames('access', $this->getType(), array($this->view->storage->get('base_table'))), '#default_value' => $access['type']);
$access_plugin = $this->getPlugin('access');
if ($access_plugin->usesOptions()) {
$form['markup'] = array('#prefix' => '<div class="form-item description">', '#markup' => t('You may also adjust the !settings for the currently selected access restriction.', array('!settings' => $this->optionLink(t('settings'), 'access_options'))), '#suffix' => '</div>');
}
break;
case 'access_options':
$plugin = $this->getPlugin('access');
$form['#title'] .= t('Access options');
if ($plugin) {
$form['access_options'] = array('#tree' => TRUE);
$plugin->buildOptionsForm($form['access_options'], $form_state);
}
break;
case 'cache':
$form['#title'] .= t('Caching');
$form['cache'] = array('#prefix' => '<div class="clearfix">', '#suffix' => '</div>', '#tree' => TRUE);
$cache = $this->getOption('cache');
$form['cache']['type'] = array('#title' => t('Caching'), '#title_display' => 'invisible', '#type' => 'radios', '#options' => Views::fetchPluginNames('cache', $this->getType(), array($this->view->storage->get('base_table'))), '#default_value' => $cache['type']);
$cache_plugin = $this->getPlugin('cache');
if ($cache_plugin->usesOptions()) {
$form['markup'] = array('#prefix' => '<div class="form-item description">', '#suffix' => '</div>', '#markup' => t('You may also adjust the !settings for the currently selected cache mechanism.', array('!settings' => $this->optionLink(t('settings'), 'cache_options'))));
}
break;
case 'cache_options':
$plugin = $this->getPlugin('cache');
$form['#title'] .= t('Caching options');
if ($plugin) {
$form['cache_options'] = array('#tree' => TRUE);
$plugin->buildOptionsForm($form['cache_options'], $form_state);
}
break;
case 'query':
//.........这里部分代码省略.........