當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Html::cleanCssIdentifier方法代碼示例

本文整理匯總了PHP中Drupal\Component\Utility\Html::cleanCssIdentifier方法的典型用法代碼示例。如果您正苦於以下問題:PHP Html::cleanCssIdentifier方法的具體用法?PHP Html::cleanCssIdentifier怎麽用?PHP Html::cleanCssIdentifier使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\Component\Utility\Html的用法示例。


在下文中一共展示了Html::cleanCssIdentifier方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: viewMultiple

 /**
  * {@inheritdoc}
  */
 public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL)
 {
     /** @var \Drupal\tour\TourInterface[] $entities */
     $build = array();
     foreach ($entities as $entity_id => $entity) {
         $tips = $entity->getTips();
         $count = count($tips);
         $list_items = array();
         foreach ($tips as $index => $tip) {
             if ($output = $tip->getOutput()) {
                 $attributes = array('class' => array('tip-module-' . Html::cleanCssIdentifier($entity->getModule()), 'tip-type-' . Html::cleanCssIdentifier($tip->getPluginId()), 'tip-' . Html::cleanCssIdentifier($tip->id())));
                 $list_items[] = array('output' => $output, 'counter' => array('#type' => 'container', '#attributes' => array('class' => array('tour-progress')), '#children' => t('@tour_item of @total', array('@tour_item' => $index + 1, '@total' => $count))), '#wrapper_attributes' => $tip->getAttributes() + $attributes);
             }
         }
         // If there is at least one tour item, build the tour.
         if ($list_items) {
             end($list_items);
             $key = key($list_items);
             $list_items[$key]['#wrapper_attributes']['data-text'] = t('End tour');
             $build[$entity_id] = array('#theme' => 'item_list', '#items' => $list_items, '#list_type' => 'ol', '#attributes' => array('id' => 'tour', 'class' => array('hidden')), '#cache' => ['tags' => $entity->getCacheTags()]);
         }
     }
     // If at least one tour was built, attach the tour library.
     if ($build) {
         $build['#attached']['library'][] = 'tour/tour';
     }
     return $build;
 }
開發者ID:HakS,項目名稱:drupal8_training,代碼行數:31,代碼來源:TourViewBuilder.php

示例2: view

 /**
  * {@inheritdoc}
  */
 public function view(FieldItemListInterface $items, $langcode = NULL)
 {
     $elements = parent::view($items, $langcode);
     $gallery_type = $this->getSetting('gallery_type');
     $elements['#attributes']['class'][] = 'mfp-field';
     $elements['#attributes']['class'][] = 'mfp-video-embed-' . Html::cleanCssIdentifier($gallery_type);
     return $elements;
 }
開發者ID:justincletus,項目名稱:webdrupalpro,代碼行數:11,代碼來源:VideoEmbedField.php

示例3: testCleanCssIdentifier

 /**
  * Tests the Html::cleanCssIdentifier() method.
  *
  * @param string $expected
  *   The expected result.
  * @param string $source
  *   The string being transformed to an ID.
  * @param array|null $filter
  *   (optional) An array of string replacements to use on the identifier. If
  *   NULL, no filter will be passed and a default will be used.
  *
  * @dataProvider providerTestCleanCssIdentifier
  *
  * @covers ::cleanCssIdentifier
  */
 public function testCleanCssIdentifier($expected, $source, $filter = NULL)
 {
     if ($filter !== NULL) {
         $this->assertSame($expected, Html::cleanCssIdentifier($source, $filter));
     } else {
         $this->assertSame($expected, Html::cleanCssIdentifier($source));
     }
 }
開發者ID:nstielau,項目名稱:drops-8,代碼行數:23,代碼來源:HtmlTest.php

示例4: alterForm

 /**
  * {@inheritdoc}
  */
 public function alterForm(array &$form, FormStateInterface $form_state, $form_id = NULL)
 {
     $plugin_id = Html::cleanCssIdentifier($this->provider->getPluginId());
     $setting = $this->getElement($form, $form_state);
     $setting->setProperty('options', $this->provider->getVersions());
     $setting->setProperty('ajax', ['callback' => [get_class($this), 'ajaxCallback'], 'wrapper' => 'cdn-provider-' . $plugin_id]);
     if (!$this->provider->hasError() && !$this->provider->isImported()) {
         $setting->setProperty('description', t('These versions are automatically populated by the @provider API upon cache clear and newer versions may appear over time. It is highly recommended the version that the site was built with stays at that version. Until a newer version has been properly tested for updatability by the site maintainer, you should not arbitrarily "update" just because there is a newer version. This can cause many inconsistencies and undesired effects with an existing site.', ['@provider' => $this->provider->getLabel()]));
     }
 }
開發者ID:r-daneelolivaw,項目名稱:chalk,代碼行數:13,代碼來源:CdnJsdelivrVersion.php

示例5: getCustomClass

 /**
  * Return the token-replaced row or column classes for the specified result.
  *
  * @param int $result_index
  *   The delta of the result item to get custom classes for.
  * @param string $type
  *   The type of custom grid class to return, either "row" or "col".
  *
  * @return string
  *   A space-delimited string of classes.
  */
 public function getCustomClass($result_index, $type)
 {
     $class = $this->options[$type . '_class_custom'];
     if ($this->usesFields() && $this->view->field) {
         $class = strip_tags($this->tokenizeValue($class, $result_index));
     }
     $classes = explode(' ', $class);
     foreach ($classes as &$class) {
         $class = Html::cleanCssIdentifier($class);
     }
     return implode(' ', $classes);
 }
開發者ID:nstielau,項目名稱:drops-8,代碼行數:23,代碼來源:Grid.php

示例6: testSingleValuedWidget

 /**
  * Tests upload and remove buttons for a single-valued File field.
  */
 function testSingleValuedWidget()
 {
     $node_storage = $this->container->get('entity.manager')->getStorage('node');
     $type_name = 'article';
     $field_name = strtolower($this->randomMachineName());
     $this->createFileField($field_name, 'node', $type_name);
     $test_file = $this->getTestFile('text');
     foreach (array('nojs', 'js') as $type) {
         // Create a new node with the uploaded file and ensure it got uploaded
         // successfully.
         // @todo This only tests a 'nojs' submission, because drupalPostAjaxForm()
         //   does not yet support file uploads.
         $nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
         $node_storage->resetCache(array($nid));
         $node = $node_storage->load($nid);
         $node_file = file_load($node->{$field_name}->target_id);
         $this->assertFileExists($node_file, 'New file saved to disk on node creation.');
         // Ensure the file can be downloaded.
         $this->drupalGet(file_create_url($node_file->getFileUri()));
         $this->assertResponse(200, 'Confirmed that the generated URL is correct by downloading the shipped file.');
         // Ensure the edit page has a remove button instead of an upload button.
         $this->drupalGet("node/{$nid}/edit");
         $this->assertNoFieldByXPath('//input[@type="submit"]', t('Upload'), 'Node with file does not display the "Upload" button.');
         $this->assertFieldByXpath('//input[@type="submit"]', t('Remove'), 'Node with file displays the "Remove" button.');
         // "Click" the remove button (emulating either a nojs or js submission).
         switch ($type) {
             case 'nojs':
                 $this->drupalPostForm(NULL, array(), t('Remove'));
                 break;
             case 'js':
                 $button = $this->xpath('//input[@type="submit" and @value="' . t('Remove') . '"]');
                 $this->drupalPostAjaxForm(NULL, array(), array((string) $button[0]['name'] => (string) $button[0]['value']));
                 break;
         }
         // Ensure the page now has an upload button instead of a remove button.
         $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), 'After clicking the "Remove" button, it is no longer displayed.');
         $this->assertFieldByXpath('//input[@type="submit"]', t('Upload'), 'After clicking the "Remove" button, the "Upload" button is displayed.');
         // Test label has correct 'for' attribute.
         $label = $this->xpath("//label[@for='edit-" . Html::cleanCssIdentifier($field_name) . "-0-upload']");
         $this->assertTrue(isset($label[0]), 'Label for upload found.');
         // Save the node and ensure it does not have the file.
         $this->drupalPostForm(NULL, array(), t('Save and keep published'));
         $node_storage->resetCache(array($nid));
         $node = $node_storage->load($nid);
         $this->assertTrue(empty($node->{$field_name}->target_id), 'File was successfully removed from the node.');
     }
 }
開發者ID:nstielau,項目名稱:drops-8,代碼行數:50,代碼來源:FileFieldWidgetTest.php

示例7: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
     $row = parent::buildRow($entity);
     $status = $entity->status();
     $status_server = TRUE;
     $status_label = $status ? $this->t('Enabled') : $this->t('Disabled');
     if ($entity instanceof ServerInterface && $entity->status() && !$entity->isAvailable()) {
         $status = FALSE;
         $status_server = FALSE;
         $status_label = $this->t('Unavailable');
     }
     $status_icon = array('#theme' => 'image', '#uri' => $status ? 'core/misc/icons/73b355/check.svg' : 'core/misc/icons/e32700/error.svg', '#width' => 18, '#height' => 18, '#alt' => $status_label, '#title' => $status_label);
     $row = array('data' => array('type' => array('data' => $entity instanceof ServerInterface ? $this->t('Server') : $this->t('Index'), 'class' => array('search-api-type')), 'title' => array('data' => array('#type' => 'link', '#title' => $entity->label(), '#suffix' => '<div>' . $entity->get('description') . '</div>') + $entity->toUrl('canonical')->toRenderArray(), 'class' => array('search-api-title')), 'status' => array('data' => $status_icon, 'class' => array('checkbox')), 'operations' => $row['operations']), 'title' => $this->t('ID: @name', array('@name' => $entity->id())), 'class' => array(Html::cleanCssIdentifier($entity->getEntityTypeId() . '-' . $entity->id()), $status ? 'search-api-list-enabled' : 'search-api-list-disabled', $entity instanceof ServerInterface ? 'search-api-list-server' : 'search-api-list-index'));
     if (!$status_server) {
         $row['class'][] = 'color-error';
     }
     return $row;
 }
開發者ID:nB-MDSO,項目名稱:mdso-d8blog,代碼行數:22,代碼來源:IndexListBuilder.php

示例8: form

 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form['#attached']['library'][] = 'facets/drupal.facets.admin_css';
     /** @var \Drupal\facets\FacetInterface $facet */
     $facet = $this->entity;
     $widget_options = [];
     foreach ($this->getWidgetPluginManager()->getDefinitions() as $widget_id => $definition) {
         $widget_options[$widget_id] = !empty($definition['label']) ? $definition['label'] : $widget_id;
     }
     $form['widget'] = ['#type' => 'radios', '#title' => $this->t('Widget'), '#description' => $this->t('The widget used for displaying this facet.'), '#options' => $widget_options, '#default_value' => $facet->getWidget(), '#required' => TRUE, '#ajax' => ['trigger_as' => ['name' => 'widget_configure'], 'callback' => '::buildAjaxWidgetConfigForm', 'wrapper' => 'facets-widget-config-form', 'method' => 'replace', 'effect' => 'fade']];
     $form['widget_configs'] = ['#type' => 'container', '#attributes' => ['id' => 'facets-widget-config-form'], '#tree' => TRUE];
     $form['widget_configure_button'] = ['#type' => 'submit', '#name' => 'widget_configure', '#value' => $this->t('Configure widget'), '#limit_validation_errors' => [['widget']], '#submit' => ['::submitAjaxWidgetConfigForm'], '#ajax' => ['callback' => '::buildAjaxWidgetConfigForm', 'wrapper' => 'facets-widget-config-form'], '#attributes' => ['class' => ['js-hide']]];
     $this->buildWidgetConfigForm($form, $form_state);
     // Retrieve lists of all processors, and the stages and weights they have.
     if (!$form_state->has('processors')) {
         $all_processors = $facet->getProcessors(FALSE);
         $sort_processors = function (ProcessorInterface $a, ProcessorInterface $b) {
             return strnatcasecmp((string) $a->getPluginDefinition()['label'], (string) $b->getPluginDefinition()['label']);
         };
         uasort($all_processors, $sort_processors);
     } else {
         $all_processors = $form_state->get('processors');
     }
     $enabled_processors = $facet->getProcessors(TRUE);
     $stages = $this->processorPluginManager->getProcessingStages();
     $processors_by_stage = array();
     foreach ($stages as $stage => $definition) {
         $processors_by_stage[$stage] = $facet->getProcessorsByStage($stage, FALSE);
     }
     $form['#tree'] = TRUE;
     $form['#attached']['library'][] = 'facets/drupal.facets.index-active-formatters';
     $form['#title'] = $this->t('Edit %label facet', array('%label' => $facet->label()));
     // Add the list of all other processors with checkboxes to enable/disable
     // them.
     $form['facet_settings'] = array('#type' => 'fieldset', '#title' => $this->t('Facet settings'), '#attributes' => array('class' => array('search-api-status-wrapper')));
     foreach ($all_processors as $processor_id => $processor) {
         if (!$processor instanceof WidgetOrderProcessorInterface && !$processor instanceof UrlProcessorInterface) {
             $clean_css_id = Html::cleanCssIdentifier($processor_id);
             $form['facet_settings'][$processor_id]['status'] = array('#type' => 'checkbox', '#title' => (string) $processor->getPluginDefinition()['label'], '#default_value' => $processor->isLocked() || !empty($enabled_processors[$processor_id]), '#description' => $processor->getDescription(), '#attributes' => array('class' => array('search-api-processor-status-' . $clean_css_id), 'data-id' => $clean_css_id), '#disabled' => $processor->isLocked(), '#access' => !$processor->isHidden());
             $processor_form_state = new SubFormState($form_state, ['facet_settings', $processor_id, 'settings']);
             $processor_form = $processor->buildConfigurationForm($form, $processor_form_state, $facet);
             if ($processor_form) {
                 $form['facet_settings'][$processor_id]['settings'] = array('#type' => 'details', '#title' => $this->t('%processor settings', ['%processor' => (string) $processor->getPluginDefinition()['label']]), '#open' => TRUE, '#attributes' => array('class' => array('facets-processor-settings-' . Html::cleanCssIdentifier($processor_id), 'facets-processor-settings-facet', 'facets-processor-settings')), '#states' => array('visible' => array(':input[name="facet_settings[' . $processor_id . '][status]"]' => array('checked' => TRUE))));
                 $form['facet_settings'][$processor_id]['settings'] += $processor_form;
             }
         }
     }
     // Add the list of widget sort processors with checkboxes to enable/disable
     // them.
     $form['facet_sorting'] = array('#type' => 'fieldset', '#title' => $this->t('Facet sorting'), '#attributes' => array('class' => array('search-api-status-wrapper')));
     foreach ($all_processors as $processor_id => $processor) {
         if ($processor instanceof WidgetOrderProcessorInterface) {
             $clean_css_id = Html::cleanCssIdentifier($processor_id);
             $form['facet_sorting'][$processor_id]['status'] = array('#type' => 'checkbox', '#title' => (string) $processor->getPluginDefinition()['label'], '#default_value' => $processor->isLocked() || !empty($enabled_processors[$processor_id]), '#description' => $processor->getDescription(), '#attributes' => array('class' => array('search-api-processor-status-' . $clean_css_id), 'data-id' => $clean_css_id), '#disabled' => $processor->isLocked(), '#access' => !$processor->isHidden());
             $processor_form_state = new SubFormState($form_state, array('facet_sorting', $processor_id, 'settings'));
             $processor_form = $processor->buildConfigurationForm($form, $processor_form_state, $facet);
             if ($processor_form) {
                 $form['facet_sorting'][$processor_id]['settings'] = array('#type' => 'container', '#open' => TRUE, '#attributes' => array('class' => array('facets-processor-settings-' . Html::cleanCssIdentifier($processor_id), 'facets-processor-settings-sorting', 'facets-processor-settings')), '#states' => array('visible' => array(':input[name="facet_sorting[' . $processor_id . '][status]"]' => array('checked' => TRUE))));
                 $form['facet_sorting'][$processor_id]['settings'] += $processor_form;
             }
         }
     }
     $form['facet_settings']['only_visible_when_facet_source_is_visible'] = ['#type' => 'checkbox', '#title' => $this->t('Hide facet when facet source is not rendered'), '#description' => $this->t('When checked, this facet will only be rendered when the facet source is rendered.  If you want to show facets on other pages too, you need to uncheck this setting.'), '#default_value' => $facet->getOnlyVisibleWhenFacetSourceIsVisible()];
     $form['facet_settings']['show_only_one_result'] = ['#type' => 'checkbox', '#title' => $this->t('Make sure only one result can be shown.'), '#description' => $this->t('When checked, this will make sure that only one result can be selected for this facet at one time.'), '#default_value' => $facet->getShowOnlyOneResult()];
     $form['facet_settings']['url_alias'] = ['#type' => 'machine_name', '#title' => $this->t('Url alias'), '#default_value' => $facet->getUrlAlias(), '#maxlength' => 50, '#required' => TRUE, '#machine_name' => ['exists' => [\Drupal::service('entity_type.manager')->getStorage('facets_facet'), 'load'], 'source' => ['name']]];
     $empty_behavior_config = $facet->getEmptyBehavior();
     $form['facet_settings']['empty_behavior'] = ['#type' => 'radios', '#title' => t('Empty facet behavior'), '#default_value' => $empty_behavior_config['behavior'] ?: 'none', '#options' => ['none' => t('Do not display facet'), 'text' => t('Display text')], '#description' => $this->t('The action to take when a facet has no items.'), '#required' => TRUE];
     $form['facet_settings']['empty_behavior_container'] = ['#type' => 'container', '#states' => array('visible' => array(':input[name="facet_settings[empty_behavior]"]' => array('value' => 'text')))];
     $form['facet_settings']['empty_behavior_container']['empty_behavior_text'] = ['#type' => 'text_format', '#title' => $this->t('Empty text'), '#format' => isset($empty_behavior_config['text_format']) ? $empty_behavior_config['text_format'] : 'plain_text', '#editor' => TRUE, '#default_value' => isset($empty_behavior_config['text_format']) ? $empty_behavior_config['text'] : ''];
     $form['facet_settings']['query_operator'] = ['#type' => 'radios', '#title' => $this->t('Operator'), '#options' => ['OR' => $this->t('OR'), 'AND' => $this->t('AND')], '#description' => $this->t('AND filters are exclusive and narrow the result set. OR filters are inclusive and widen the result set.'), '#default_value' => $facet->getQueryOperator()];
     $form['facet_settings']['exclude'] = ['#type' => 'checkbox', '#title' => $this->t('Exclude'), '#description' => $this->t('Make the search exclude selected facets, instead of restricting it to them.'), '#default_value' => $facet->getExclude()];
     $form['facet_settings']['weight'] = ['#type' => 'number', '#title' => $this->t('Weight'), '#default_value' => $facet->getWeight(), '#maxlength' => 4, '#required' => TRUE];
     $form['weights'] = array('#type' => 'details', '#title' => t('Advanced settings'), '#collapsible' => TRUE, '#collapsed' => TRUE);
     $form['weights']['order'] = ['#markup' => "<h3>" . t('Processor order') . "</h3>"];
     // Order enabled processors per stage, create all the containers for the
     // different stages.
     foreach ($stages as $stage => $description) {
         $form['weights'][$stage] = array('#type' => 'fieldset', '#title' => $description['label'], '#attributes' => array('class' => array('search-api-stage-wrapper', 'search-api-stage-wrapper-' . Html::cleanCssIdentifier($stage))));
         $form['weights'][$stage]['order'] = array('#type' => 'table');
         $form['weights'][$stage]['order']['#tabledrag'][] = array('action' => 'order', 'relationship' => 'sibling', 'group' => 'search-api-processor-weight-' . Html::cleanCssIdentifier($stage));
     }
     $processor_settings = $facet->getProcessorConfigs();
     // Fill in the containers previously created with the processors that are
     // enabled on the facet.
     foreach ($processors_by_stage as $stage => $processors) {
         /** @var \Drupal\facets\Processor\ProcessorInterface $processor */
         foreach ($processors as $processor_id => $processor) {
             $weight = isset($processor_settings[$processor_id]['weights'][$stage]) ? $processor_settings[$processor_id]['weights'][$stage] : $processor->getDefaultWeight($stage);
             if ($processor->isHidden()) {
                 $form['processors'][$processor_id]['weights'][$stage] = array('#type' => 'value', '#value' => $weight);
                 continue;
             }
             $form['weights'][$stage]['order'][$processor_id]['#attributes']['class'][] = 'draggable';
             $form['weights'][$stage]['order'][$processor_id]['#attributes']['class'][] = 'search-api-processor-weight--' . Html::cleanCssIdentifier($processor_id);
             $form['weights'][$stage]['order'][$processor_id]['#weight'] = $weight;
             $form['weights'][$stage]['order'][$processor_id]['label']['#plain_text'] = (string) $processor->getPluginDefinition()['label'];
             $form['weights'][$stage]['order'][$processor_id]['weight'] = array('#type' => 'weight', '#title' => $this->t('Weight for processor %title', array('%title' => (string) $processor->getPluginDefinition()['label'])), '#title_display' => 'invisible', '#default_value' => $weight, '#parents' => array('processors', $processor_id, 'weights', $stage), '#attributes' => array('class' => array('search-api-processor-weight-' . Html::cleanCssIdentifier($stage))));
//.........這裏部分代碼省略.........
開發者ID:nB-MDSO,項目名稱:mdso-d8blog,代碼行數:101,代碼來源:FacetForm.php

示例9: fieldAsReadOnly

 /**
  * Builds a read-only form element for a field.
  *
  * @param string $label
  *   The element label.
  * @param string $value
  *   The element value.
  *
  * @return array
  *   The form element.
  */
 protected function fieldAsReadOnly($label, $value)
 {
     return ['#type' => 'item', '#wrapper_attributes' => ['class' => [Html::cleanCssIdentifier(strtolower($label)), 'container-inline']], '#markup' => '<h4 class="label inline">' . $label . '</h4> ' . $value];
 }
開發者ID:alexburrows,項目名稱:cream-2.x,代碼行數:15,代碼來源:OrderForm.php

示例10: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     // Don't show the form when batch operations are in progress.
     if ($batch = batch_get() && isset($batch['current_set'])) {
         return array('#theme' => '');
     }
     // Make sure that we validate because this form might be submitted
     // multiple times per page.
     $form_state->setValidationEnforced();
     /** @var \Drupal\views\ViewExecutable $view */
     $view = $form_state->get('view');
     $display =& $form_state->get('display');
     $form_state->setUserInput($view->getExposedInput());
     // Let form plugins know this is for exposed widgets.
     $form_state->set('exposed', TRUE);
     // Check if the form was already created
     if ($cache = $this->exposedFormCache->getForm($view->storage->id(), $view->current_display)) {
         return $cache;
     }
     $form['#info'] = array();
     // Go through each handler and let it generate its exposed widget.
     foreach ($view->display_handler->handlers as $type => $value) {
         /** @var \Drupal\views\Plugin\views\ViewsHandlerInterface $handler */
         foreach ($view->{$type} as $id => $handler) {
             if ($handler->canExpose() && $handler->isExposed()) {
                 // Grouped exposed filters have their own forms.
                 // Instead of render the standard exposed form, a new Select or
                 // Radio form field is rendered with the available groups.
                 // When an user choose an option the selected value is split
                 // into the operator and value that the item represents.
                 if ($handler->isAGroup()) {
                     $handler->groupForm($form, $form_state);
                     $id = $handler->options['group_info']['identifier'];
                 } else {
                     $handler->buildExposedForm($form, $form_state);
                 }
                 if ($info = $handler->exposedInfo()) {
                     $form['#info']["{$type}-{$id}"] = $info;
                 }
             }
         }
     }
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#name' => '', '#type' => 'submit', '#value' => $this->t('Apply'), '#id' => Html::getUniqueId('edit-submit-' . $view->storage->id()));
     $form['#action'] = $view->hasUrl() ? $view->getUrl()->toString() : Url::fromRoute('<current>')->toString();
     $form['#theme'] = $view->buildThemeFunctions('views_exposed_form');
     $form['#id'] = Html::cleanCssIdentifier('views_exposed_form-' . SafeMarkup::checkPlain($view->storage->id()) . '-' . SafeMarkup::checkPlain($display['id']));
     /** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginBase $exposed_form_plugin */
     $exposed_form_plugin = $view->display_handler->getPlugin('exposed_form');
     $exposed_form_plugin->exposedFormAlter($form, $form_state);
     // Save the form.
     $this->exposedFormCache->setForm($view->storage->id(), $view->current_display, $form);
     return $form;
 }
開發者ID:nstielau,項目名稱:drops-8,代碼行數:57,代碼來源:ViewsExposedForm.php

示例11: elementWrapperClasses

 /**
  * {@inheritdoc}
  */
 public function elementWrapperClasses($row_index = NULL)
 {
     $classes = explode(' ', $this->options['element_wrapper_class']);
     foreach ($classes as &$class) {
         $class = $this->tokenizeValue($class, $row_index);
         $class = Html::cleanCssIdentifier($class);
     }
     return implode(' ', $classes);
 }
開發者ID:nstielau,項目名稱:drops-8,代碼行數:12,代碼來源:FieldPluginBase.php

示例12: array

       $form['slideshows']['slideshow_' . $i]['slideshow_options']['wrapper']['advanced_options']['settings_slideshow_' . $i . '_usecss'] = array('#type' => 'checkbox', '#title' => t('Use CSS'), '#default_value' => null !== theme_get_setting('settings.slideshow_' . $i . '_usecss') ? theme_get_setting('settings.slideshow_' . $i . '_usecss') : 1, '#description' => t('Slider will use CSS3 transitions if the browser supports them. Uncheck this if you have issues with slides flashing or flickering, or if you prefer to use JavaScript animation.'));
       // touch            : true,           // Boolean Allow touch swipe navigation of the slider on enabled devices
       $form['slideshows']['slideshow_' . $i]['slideshow_options']['wrapper']['advanced_options']['settings_slideshow_' . $i . '_touch'] = array('#type' => 'checkbox', '#title' => t('Touch swipe navigation'), '#default_value' => null !== theme_get_setting('settings.slideshow_' . $i . '_touch') ? theme_get_setting('settings.slideshow_' . $i . '_touch') : 1, '#description' => t('Allow touch swipe navigation of the slider on enabled devices.'));
       // video            : false,          // Boolean Will prevent use of CSS3 3D Transforms, avoiding graphical glitches
       $form['slideshows']['slideshow_' . $i]['slideshow_options']['wrapper']['advanced_options']['settings_slideshow_' . $i . '_video'] = array('#type' => 'checkbox', '#title' => t('Video'), '#default_value' => theme_get_setting('settings.slideshow_' . $i . '_video'), '#description' => t('Checking this setting will prevent use of CSS3 3D Transforms, avoiding graphical glitches when embedding video.'));
       // prevText : String Set the text for the "previous" directionNav item
       $form['slideshows']['slideshow_' . $i]['slideshow_options']['wrapper']['advanced_options']['settings_slideshow_' . $i . '_prevtext'] = array('#type' => 'textfield', '#title' => t('Previous text'), '#default_value' => null !== theme_get_setting('settings.slideshow_' . $i . '_prevtext') ? theme_get_setting('settings.slideshow_' . $i . '_prevtext') : t('Previous'), '#description' => t('Text for the "previous" direction nav item.'));
       //nextText : String Set the text for the "next" directionNav item
       $form['slideshows']['slideshow_' . $i]['slideshow_options']['wrapper']['advanced_options']['settings_slideshow_' . $i . '_nexttext'] = array('#type' => 'textfield', '#title' => t('Next text'), '#default_value' => null !== theme_get_setting('settings.slideshow_' . $i . '_nexttext') ? theme_get_setting('settings.slideshow_' . $i . '_nexttext') : t('Next'), '#description' => t('Text for the "next" direction nav item.'));
       // slideshow selector         : themename-slideshow-N i.e. $slideshow_class
       $form['slideshows']['slideshow_' . $i]['slideshow_options']['wrapper']['advanced_options']['settings_slideshow_' . $i . '_slideshow_class'] = array('#type' => 'textfield', '#title' => t('Slideshow selector'), '#default_value' => null !== theme_get_setting('settings.slideshow_' . $i . '_slideshow_class') ? theme_get_setting('settings.slideshow_' . $i . '_slideshow_class') : '.' . $slideshow_class, '#description' => t('Change this if you are using your own markup, e.g. a custom block with image fields.'));
       // slide selector         : ".slides > li", // Selector Must match a simple pattern. '{container} > {slide}'.
       $form['slideshows']['slideshow_' . $i]['slideshow_options']['wrapper']['advanced_options']['settings_slideshow_' . $i . '_selector'] = array('#type' => 'textfield', '#title' => t('Slide selector'), '#default_value' => null !== theme_get_setting('settings.slideshow_' . $i . '_selector') ? theme_get_setting('settings.slideshow_' . $i . '_selector') : '.slides > li', '#description' => t('Selector must match the pattern <code>{container} &#62; {slide}</code>. Modify with caution. The generated markup snippet will not reflect changes here, and you will need to account for changes both in markup and CSS. Changing this without editing the markup in your slideshow or CSS will break the slideshow.'));
       if (theme_get_setting('settings.slideshow_' . $i . '_slideshow_class') !== null) {
           $slideshow_class_setting = theme_get_setting('settings.slideshow_' . $i . '_slideshow_class');
           $this_slideshow_class = Html::cleanCssIdentifier($slideshow_class_setting);
       } else {
           $this_slideshow_class = $slideshow_class;
       }
       // Class and markup generator TODO: markup generator
       $form['slideshows']['slideshow_' . $i]['slideshow_options']['wrapper']['slideshow_markup'] = array('#type' => 'textarea', '#title' => t('Generated markup for this slideshow (with working examples)'), '#default_value' => '<div class="flexslider loading ' . ltrim($this_slideshow_class, '.') . '">
 <ul class="slides">
   <li>
     <img src="' . base_path() . $subtheme_path . '/images/slides/test-slide-1.png" alt="Test slide one" />
     <p class="flex-caption">Test slide one</p>
   </li>
   <li>
     <img src="' . base_path() . $subtheme_path . '/images/slides/test-slide-2.png" alt="Test slide two" />
     <p class="flex-caption">Test slide two</p>
   </li>
   <li>
開發者ID:neetumorwani,項目名稱:blogging,代碼行數:31,代碼來源:slideshows.php

示例13: getExpectedExposedFormId

 /**
  * Returns a views exposed form ID.
  *
  * @param \Drupal\views\ViewExecutable $view
  *   The view to create an ID for.
  *
  * @return string
  *   The form ID.
  */
 protected function getExpectedExposedFormId(ViewExecutable $view)
 {
     return Html::cleanCssIdentifier('views-exposed-form-' . $view->storage->id() . '-' . $view->current_display);
 }
開發者ID:eduardolcouto,項目名稱:drupal,代碼行數:13,代碼來源:ExposedFormTest.php

示例14: assertEntityStatusChange

 /**
  * Asserts enable/disable operations for a search server or index.
  *
  * @param \Drupal\search_api\ServerInterface|\Drupal\search_api\IndexInterface $entity
  *   A search server or index.
  */
 protected function assertEntityStatusChange($entity)
 {
     $this->drupalGet($this->overviewPageUrl);
     $row_class = Html::cleanCssIdentifier($entity->getEntityTypeId() . '-' . $entity->id());
     $this->assertFieldByXPath('//tr[contains(@class,"' . $row_class . '") and contains(@class, "search-api-list-enabled")]', NULL, 'The newly created entity is enabled by default.');
     // The first "Disable" link on the page belongs to our server, the second
     // one to our index.
     $this->clickLink('Disable', $entity instanceof ServerInterface ? 0 : 1);
     // Submit the confirmation form and test that the entity has been disabled.
     $this->drupalPostForm(NULL, array(), 'Disable');
     $this->assertFieldByXPath('//tr[contains(@class,"' . $row_class . '") and contains(@class, "search-api-list-disabled")]', NULL, 'The entity has been disabled.');
     // Now enable the entity and verify that the operation succeeded.
     $this->clickLink('Enable');
     $this->drupalGet($this->overviewPageUrl);
     $this->assertFieldByXPath('//tr[contains(@class,"' . $row_class . '") and contains(@class, "search-api-list-enabled")]', NULL, 'The entity has benn enabled.');
 }
開發者ID:alexku,項目名稱:travisintegrationtest,代碼行數:22,代碼來源:OverviewPageTest.php

示例15: buildRow

  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity) {
    /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
    $row = parent::buildRow($entity);

    $status_label = $entity->status() ? $this->t('Enabled') : $this->t('Disabled');
    $status_icon = array(
      '#theme' => 'image',
      '#uri' => $entity->status() ? 'core/misc/icons/73b355/check.svg' : 'core/misc/icons/ea2800/error.svg',
      '#width' => 18,
      '#height' => 18,
      '#alt' => $status_label,
      '#title' => $status_label,
    );

    return array(
      'data' => array(
        'type' => array(
          'data' => $entity instanceof ServerInterface ? $this->t('Server') : $this->t('Index'),
          'class' => array('search-api-type'),
        ),
        'title' => array(
          'data' => array(
              '#type' => 'link',
              '#title' => $entity->label(),
              '#suffix' => '<div>' . $entity->get('description') . '</div>',
            ) + $entity->urlInfo('canonical')->toRenderArray(),
          'class' => array('search-api-title'),
        ),
        'status' => array(
          'data' => $status_icon,
          'class' => array('checkbox'),
        ),
        'operations' => $row['operations'],
      ),
      'title' => $this->t('ID: @name', array('@name' => $entity->id())),
      'class' => array(
        Html::cleanCssIdentifier($entity->getEntityTypeId() . '-' . $entity->id()),
        $entity->status() ? 'search-api-list-enabled' : 'search-api-list-disabled',
        $entity instanceof ServerInterface ? 'search-api-list-server' : 'search-api-list-index',
      ),
    );
  }
開發者ID:jkyto,項目名稱:agolf,代碼行數:45,代碼來源:IndexListBuilder.php


注:本文中的Drupal\Component\Utility\Html::cleanCssIdentifier方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。