public function buildForm(array $form, FormStateInterface $form_state)
 {
     global $base_path;
     $addtoany_settings = $this->config('addtoany.settings');
     $button_img = '<img src="' . $base_path . drupal_get_path('module', 'addtoany') . '/images/%s" width="%d" height="%d"%s />';
     $button_options = array('default' => sprintf($button_img, 'a2a_32_32.svg', 32, 32, ' class="addtoany-round-icon"'), 'custom' => t('Custom button'), 'none' => t('None'));
     $attributes_for_code = array('autocapitalize' => array('off'), 'autocomplete' => array('off'), 'autocorrect' => array('off'), 'spellcheck' => array('false'));
     // Attach CSS and JS
     $form['#attached']['library'][] = 'addtoany/addtoany.admin';
     $form['addtoany_button_settings'] = array('#type' => 'details', '#title' => t('Buttons'), '#open' => TRUE);
     $form['addtoany_button_settings']['addtoany_buttons_size'] = array('#type' => 'number', '#title' => t('Icon size'), '#field_suffix' => ' ' . t('pixels'), '#default_value' => $addtoany_settings->get('buttons_size'), '#size' => 10, '#maxlength' => 3, '#min' => 8, '#max' => 999, '#required' => TRUE);
     $form['addtoany_button_settings']['addtoany_service_button_settings'] = array('#type' => 'details', '#title' => t('Service Buttons'), '#collapsible' => TRUE, '#collapsed' => TRUE);
     $form['addtoany_button_settings']['addtoany_service_button_settings']['addtoany_additional_html'] = array('#type' => 'textarea', '#title' => t('Service Buttons HTML code'), '#default_value' => $addtoany_settings->get('additional_html'), '#description' => t('You can add HTML code to display customized <a href="https://www.addtoany.com/buttons/customize/standalone_services" target="_blank">standalone service buttons</a> next to each universal share button. For example: <br /> <code>&lt;a class=&quot;a2a_button_facebook&quot;&gt;&lt;/a&gt;<br />&lt;a class=&quot;a2a_button_twitter&quot;&gt;&lt;/a&gt;<br />&lt;a class=&quot;a2a_button_pinterest&quot;&gt;&lt;/a&gt;</code>
   '), '#attributes' => $attributes_for_code);
     $form['addtoany_button_settings']['universal_button'] = array('#type' => 'details', '#title' => t('Universal Button'), '#collapsible' => TRUE, '#collapsed' => TRUE);
     $form['addtoany_button_settings']['universal_button']['addtoany_universal_button'] = array('#type' => 'radios', '#title' => t('Button'), '#default_value' => $addtoany_settings->get('universal_button'), '#attributes' => array('class' => array('addtoany-universal-button-option')), '#options' => $button_options);
     $form['addtoany_button_settings']['universal_button']['addtoany_custom_universal_button'] = array('#type' => 'textfield', '#title' => t('Custom button URL'), '#default_value' => $addtoany_settings->get('custom_universal_button'), '#description' => t('URL of the button image. Example: http://example.com/share.png'), '#states' => array('visible' => array(':input[name="addtoany_universal_button"]' => array('value' => 'custom'))));
     $form['addtoany_button_settings']['universal_button']['addtoany_universal_button_placement'] = array('#type' => 'radios', '#title' => t('Button placement'), '#default_value' => $addtoany_settings->get('universal_button_placement'), '#options' => array('after' => t('After the service buttons'), 'before' => t('Before the service buttons')), '#states' => array('invisible' => array(':input[name="addtoany_universal_button"]' => array('value' => 'none'))));
     $form['addtoany_placement_settings'] = array('#type' => 'details', '#title' => t('Placement'), '#collapsible' => TRUE, '#collapsed' => TRUE);
     $form['addtoany_placement_settings']['addtoany_nodetypes'] = array('#type' => 'checkboxes', '#title' => t('Node types'), '#description' => t('Display buttons for these node types.'), '#default_value' => !empty($addtoany_settings->get('nodetypes')) ? $addtoany_settings->get('nodetypes') : array(), '#options' => node_type_get_names());
     $form['addtoany_placement_settings']['addtoany_display_in_teasers'] = array('#type' => 'checkbox', '#title' => t('Display for node teasers'), '#default_value' => $addtoany_settings->get('display_in_teasers'), '#description' => t('Display buttons for node teasers in selected sections.'), '#states' => array('disabled' => array(':input[name="addtoany_display_in_nodecont"]' => array('checked' => FALSE))));
     $form['addtoany_placement_settings']['addtoany_display_in_nodecont'] = array('#type' => 'checkbox', '#title' => t('Display in content section'), '#default_value' => $addtoany_settings->get('display_in_nodecont'), '#description' => t('Display buttons in the content section of node pages.'));
     $form['addtoany_placement_settings']['addtoany_display_weight'] = array('#type' => 'weight', '#title' => t('Content weight'), '#default_value' => $addtoany_settings->get('display_weight'), '#delta' => 50, '#description' => t('Optional weight value for reordering AddToAny within the content section.'), '#states' => array('visible' => array(':input[name="addtoany_display_in_nodecont"]' => array('checked' => TRUE))));
     $form['addtoany_additional_settings'] = array('#type' => 'details', '#title' => t('Additional options'), '#collapsible' => TRUE, '#collapsed' => TRUE);
     $form['addtoany_additional_settings']['addtoany_additional_js'] = array('#type' => 'textarea', '#title' => t('Additional JavaScript'), '#default_value' => $addtoany_settings->get('additional_js'), '#description' => t('You can add special JavaScript code for AddToAny. See <a href="https://www.addtoany.com/buttons/customize/drupal" target="_blank">AddToAny documentation</a>.'), '#attributes' => $attributes_for_code);
     $form['addtoany_additional_settings']['addtoany_additional_css'] = array('#type' => 'textarea', '#title' => t('Additional CSS'), '#default_value' => $addtoany_settings->get('additional_css'), '#description' => t('You can add special CSS code for AddToAny. See <a href="https://www.addtoany.com/buttons/customize/drupal" target="_blank">AddToAny documentation</a>.'), '#attributes' => $attributes_for_code);
     $form['addtoany_additional_settings']['addtoany_no_3p'] = array('#type' => 'checkbox', '#title' => t('Disable 3rd party cookies'), '#default_value' => $addtoany_settings->get('no_3p'), '#description' => t('Disabling may affect analytics and limit some functionality.'));
     return parent::buildForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $fblikebutton_node_options = node_type_get_names();
     $config = $this->config('fblikebutton.settings');
     $form['fblikebutton_dynamic_visibility'] = array('#type' => 'details', '#title' => $this->t('Visibility settings'), '#open' => TRUE);
     $form['fblikebutton_dynamic_visibility']['fblikebutton_node_types'] = array('#type' => 'checkboxes', '#title' => $this->t('Display the Like button on these content types:'), '#options' => $fblikebutton_node_options, '#default_value' => $config->get('node_types'), '#description' => $this->t('Each of these content types will have the "like" button automatically added to them.'));
     /** 
      * @TODO: Uncomment this when the module is also able to add the button to 
      * the links area
      * 
     $form['fblikebutton_dynamic_visibility']['fblikebutton_full_node_display'] = array(
       '#type' => 'radios',
       '#title' => $this->t('Where do you want to show the Like button (full node view)?'),
       '#options' => array(
         $this->t('Content area'),
         $this->t('Links area')
       ),
       '#default_value' => $config->get('full_node_display'),
       '#description' => $this->t('If <em>Content area</em> is selected, the button will appear in the same area as the node content. When you select <em>Links area</em> the Like button will be visible in the links area, usually at the bottom of the node (When you select this last option you may want to adjust the Appearance settings). You can also configure Static Like Button Blocks in'. \Drupal::l($this->t('block page'), Url::fromRoute('block.admin_display')) . '.'),
     );
     */
     $form['fblikebutton_dynamic_visibility']['fblikebutton_teaser_display'] = array('#type' => 'radios', '#title' => $this->t('Where do you want to show the Like button on teasers?'), '#options' => array($this->t('Don\'t show on teasers'), $this->t('Content area')), '#default_value' => $config->get('teaser_display'), '#description' => $this->t('If you want to show the like button on teasers you can select the display area.'));
     $form['fblikebutton_dynamic_appearance'] = array('#type' => 'details', '#title' => $this->t('Appearance settings'), '#open' => TRUE);
     $form['fblikebutton_dynamic_appearance']['fblikebutton_layout'] = array('#type' => 'select', '#title' => $this->t('Layout style'), '#options' => array('standard' => $this->t('Standard'), 'box_count' => $this->t('Box Count'), 'button_count' => $this->t('Button Count'), 'button' => $this->t('Button')), '#default_value' => $config->get('layout'), '#description' => $this->t('Determines the size and amount of social context next to the button.'));
     // The actial values passed in from the options will be converted to a boolean
     // in the validation function, so it doesn't really matter what we use.
     $form['fblikebutton_dynamic_appearance']['fblikebutton_show_faces'] = array('#type' => 'select', '#title' => $this->t('Show faces in the box?'), '#options' => array(t('Do not show faces'), $this->t('Show faces')), '#default_value' => $config->get('show_faces', TRUE), '#description' => $this->t('Show profile pictures below the button. Only works if <em>Layout style</em> (found above) is set to <em>Standard</em> (otherwise, value is ignored).'));
     $form['fblikebutton_dynamic_appearance']['fblikebutton_action'] = array('#type' => 'select', '#title' => $this->t('Verb to display'), '#options' => array('like' => $this->t('Like'), 'recommend' => $this->t('Recommend')), '#default_value' => $config->get('action'), '#description' => $this->t('The verbiage to display inside the button itself.'));
     $form['fblikebutton_dynamic_appearance']['fblikebutton_font'] = array('#type' => 'select', '#title' => $this->t('Font'), '#options' => array('arial' => 'Arial', 'lucida+grande' => 'Lucida Grande', 'segoe+ui' => 'Segoe UI', 'tahoma' => 'Tahoma', 'trebuchet+ms' => 'Trebuchet MS', 'verdana' => 'Verdana'), '#default_value' => $config->get('font', 'arial'), '#description' => $this->t('The font with which to display the text of the button.'));
     $form['fblikebutton_dynamic_appearance']['fblikebutton_color_scheme'] = array('#type' => 'select', '#title' => $this->t('Color scheme'), '#options' => array('light' => $this->t('Light'), 'dark' => $this->t('Dark')), '#default_value' => $config->get('color_scheme'), '#description' => $this->t('The color scheme of the box environtment.'));
     $form['fblikebutton_dynamic_appearance']['fblikebutton_weight'] = array('#type' => 'number', '#title' => $this->t('Weight'), '#default_value' => $config->get('weight'), '#description' => $this->t('The weight determines where, at the content block, the like button will appear. The larger the weight, the lower it will appear on the node. For example, if you want the button to appear more toward the top of the node, choose <em>-40</em> as opposed to <em>-39, -38, 0, 1,</em> or <em>50,</em> etc. To position the Like button in its own block, go to the ' . \Drupal::l($this->t('block page'), Url::fromRoute('block.admin_display')) . '.'));
     $form['fblikebutton_dynamic_appearance']['fblikebutton_language'] = array('#type' => 'textfield', '#title' => $this->t('Language'), '#default_value' => $config->get('language'), '#description' => $this->t('Specific language to use. Default is English. Examples:<br />French (France): <em>fr_FR</em><br />French (Canada): <em>fr_CA</em><br />More information can be found at http://developers.facebook.com/docs/internationalization/ and a full XML list can be found at http://www.facebook.com/translations/FacebookLocales.xml'));
     return parent::buildForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::buildForm($form, $form_state);
     $rate = $this->entity;
     $form['label'] = array('#type' => 'textfield', '#title' => $this->t('Label'), '#description' => $this->t('This name will appear to the customer when this tax is applied to an order.'), '#default_value' => $rate->label(), '#required' => TRUE);
     $form['id'] = array('#type' => 'machine_name', '#title' => $this->t('Machine name'), '#default_value' => $rate->id(), '#machine_name' => array('exists' => array($this, 'exists'), 'replace_pattern' => '([^a-z0-9_]+)|(^custom$)', 'error' => 'The machine-readable name must be unique, and can only contain lowercase letters, numbers, and underscores. Additionally, it can not be the reserved word "custom".'));
     $form['rate'] = array('#type' => 'textfield', '#title' => $this->t('Rate'), '#description' => $this->t('The tax rate as a percent or decimal. Examples: 6%, .06'), '#size' => 15, '#default_value' => (double) $rate->getRate() * 100.0 . '%', '#required' => TRUE);
     $form['jurisdiction'] = array('#type' => 'textfield', '#title' => $this->t('Jurisdiction'), '#description' => $this->t('Administrative label for the taxing authority, used to prepare reports of collected taxes.'), '#default_value' => $rate->getJurisdiction(), '#required' => FALSE);
     $form['shippable'] = array('#type' => 'radios', '#title' => $this->t('Taxed products'), '#options' => array(0 => $this->t('Apply tax to any product regardless of its shippability.'), 1 => $this->t('Apply tax to shippable products only.')), '#default_value' => (int) $rate->isForShippable());
     // TODO: Remove the need for a special case for product kit module.
     $options = array();
     foreach (node_type_get_names() as $type => $name) {
         if ($type != 'product_kit' && uc_product_is_product($type)) {
             $options[$type] = $name;
         }
     }
     $options['blank-line'] = $this->t('"Blank line" product');
     $form['product_types'] = array('#type' => 'checkboxes', '#title' => $this->t('Taxed product types'), '#description' => $this->t('Apply taxes to the specified product types/classes.'), '#default_value' => $rate->getProductTypes(), '#options' => $options);
     $options = array();
     foreach (_uc_line_item_list() as $id => $line_item) {
         if (!in_array($id, ['subtotal', 'tax_subtotal', 'total', 'tax_display'])) {
             $options[$id] = $line_item['title'];
         }
     }
     $form['line_item_types'] = array('#type' => 'checkboxes', '#title' => $this->t('Taxed line items'), '#description' => $this->t('Adds the checked line item types to the total before applying this tax.'), '#default_value' => $rate->getLineItemTypes(), '#options' => $options);
     $form['weight'] = array('#type' => 'weight', '#title' => $this->t('Weight'), '#description' => $this->t('Taxes are sorted by weight and then applied to the order sequentially. This value is important when taxes need to include other tax line items.'), '#default_value' => $rate->getWeight());
     $form['display_include'] = array('#type' => 'checkbox', '#title' => $this->t('Include this tax when displaying product prices.'), '#default_value' => $rate->isIncludedInPrice());
     $form['inclusion_text'] = array('#type' => 'textfield', '#title' => $this->t('Tax inclusion text'), '#description' => $this->t('This text will be displayed near the price to indicate that it includes tax.'), '#default_value' => $rate->getInclusionText());
     return $form;
 }
Example #4
0
 /**
  * Returns an array of ds switch view mode permissions.
  *
  * @return array
  */
 public function permissions()
 {
     $permissions = [];
     foreach (node_type_get_names() as $key => $name) {
         $permissions['ds switch ' . $key] = array('title' => $this->t('Switch view modes on :type', array(':type' => $name)));
     }
     return $permissions;
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $types = node_type_get_names();
     $config = $this->config('book.settings');
     $form['book_allowed_types'] = array('#type' => 'checkboxes', '#title' => $this->t('Content types allowed in book outlines'), '#default_value' => $config->get('allowed_types'), '#options' => $types, '#description' => $this->t('Users with the %outline-perm permission can add all content types.', array('%outline-perm' => $this->t('Administer book outlines'))), '#required' => TRUE);
     $form['book_child_type'] = array('#type' => 'radios', '#title' => $this->t('Content type for the <em>Add child page</em> link'), '#default_value' => $config->get('child_type'), '#options' => $types, '#required' => TRUE);
     $form['array_filter'] = array('#type' => 'value', '#value' => TRUE);
     return parent::buildForm($form, $form_state);
 }
 /**
  * Ensures that node type functions (node_type_get_*) work correctly.
  *
  * Load available node types and validate the returned data.
  */
 function testNodeTypeGetFunctions()
 {
     $node_types = node_type_get_types();
     $node_names = node_type_get_names();
     $this->assertTrue(isset($node_types['article']), 'Node type article is available.');
     $this->assertTrue(isset($node_types['page']), 'Node type basic page is available.');
     $this->assertEqual($node_types['article']->name, $node_names['article'], 'Correct node type base has been returned.');
     $article = entity_load('node_type', 'article');
     $this->assertEqual($node_types['article'], $article, 'Correct node type has been returned.');
     $this->assertEqual($node_types['article']->name, $article->label(), 'Correct node type name has been returned.');
 }
 /**
  * {@inheritdoc}
  */
 public static function settingsForm($field, $instance)
 {
     $form = parent::settingsForm($field, $instance);
     $issue_node_types_options = array();
     $node_type_names = node_type_get_names();
     foreach ($node_type_names as $machine_name => $label) {
         if (project_issue_node_type_is_issue($machine_name)) {
             $issue_node_types[$machine_name] = $label;
         }
     }
     $form['target_bundles']['#options'] = $issue_node_types;
     return $form;
 }
Example #8
0
 /**
  * {@inheritdoc}
  */
 public function searchFormAlter(array &$form, FormStateInterface $form_state)
 {
     $parameters = $this->getParameters();
     $keys = $this->getKeywords();
     $used_advanced = !empty($parameters[self::ADVANCED_FORM]);
     if ($used_advanced) {
         $f = isset($parameters['f']) ? (array) $parameters['f'] : array();
         $defaults = $this->parseAdvancedDefaults($f, $keys);
     } else {
         $defaults = array('keys' => $keys);
     }
     $form['basic']['keys']['#default_value'] = $defaults['keys'];
     // Add advanced search keyword-related boxes.
     $form['advanced'] = array('#type' => 'details', '#title' => t('Advanced search'), '#attributes' => array('class' => array('search-advanced')), '#access' => $this->account && $this->account->hasPermission('use advanced search'), '#open' => $used_advanced);
     $form['advanced']['keywords-fieldset'] = array('#type' => 'fieldset', '#title' => t('Keywords'));
     $form['advanced']['keywords'] = array('#prefix' => '<div class="criterion">', '#suffix' => '</div>');
     $form['advanced']['keywords-fieldset']['keywords']['or'] = array('#type' => 'textfield', '#title' => t('Containing any of the words'), '#size' => 30, '#maxlength' => 255, '#default_value' => isset($defaults['or']) ? $defaults['or'] : '');
     $form['advanced']['keywords-fieldset']['keywords']['phrase'] = array('#type' => 'textfield', '#title' => t('Containing the phrase'), '#size' => 30, '#maxlength' => 255, '#default_value' => isset($defaults['phrase']) ? $defaults['phrase'] : '');
     $form['advanced']['keywords-fieldset']['keywords']['negative'] = array('#type' => 'textfield', '#title' => t('Containing none of the words'), '#size' => 30, '#maxlength' => 255, '#default_value' => isset($defaults['negative']) ? $defaults['negative'] : '');
     $form['advanced']['submit'] = array('#type' => 'submit', '#value' => t('Advanced search'), '#prefix' => '<div class="action">', '#suffix' => '</div>', '#weight' => 100);
     if (\Drupal::config("facets.facet_source.core_node_search__{$this->searchPageId}")->get('third_party_settings.core_search_facets.advanced_filters')) {
         // Add node types.
         $types = array_map(array('\\Drupal\\Component\\Utility\\Html', 'escape'), node_type_get_names());
         $form['advanced']['types-fieldset'] = array('#type' => 'fieldset', '#title' => t('Types'));
         $form['advanced']['types-fieldset']['type'] = array('#type' => 'checkboxes', '#title' => t('Only of the type(s)'), '#prefix' => '<div class="criterion">', '#suffix' => '</div>', '#options' => $types, '#default_value' => isset($defaults['type']) ? $defaults['type'] : array());
         $form['advanced']['submit'] = array('#type' => 'submit', '#value' => t('Advanced search'), '#prefix' => '<div class="action">', '#suffix' => '</div>', '#weight' => 100);
         // Add languages.
         $language_options = array();
         $language_list = $this->languageManager->getLanguages(LanguageInterface::STATE_ALL);
         foreach ($language_list as $langcode => $language) {
             // Make locked languages appear special in the list.
             $language_options[$langcode] = $language->isLocked() ? t('- @name -', array('@name' => $language->getName())) : $language->getName();
         }
         if (count($language_options) > 1) {
             $form['advanced']['lang-fieldset'] = array('#type' => 'fieldset', '#title' => t('Languages'));
             $form['advanced']['lang-fieldset']['language'] = array('#type' => 'checkboxes', '#title' => t('Languages'), '#prefix' => '<div class="criterion">', '#suffix' => '</div>', '#options' => $language_options, '#default_value' => isset($defaults['language']) ? $defaults['language'] : array());
         }
     }
 }
 function edit_form(&$form, &$form_state)
 {
     parent::edit_form($form, $form_state);
     $form['tag'] = array('#type' => 'textarea', '#title' => t('Tag'), '#default_value' => $form_state['item']->tag);
     $form['placement'] = array('#type' => 'select', '#title' => t('Placement'), '#default_value' => $form_state['item']->settings['placement'], '#options' => _springboard_tag_placement_options());
     $form['weight'] = array('#type' => 'weight', '#title' => t('Weight'), '#default_value' => $form_state['item']->weight, '#delta' => 10, '#description' => t('Optional. Set a heavier value to have a tag rendered below others in the document.'));
     // Visibility options.
     $form['visibility'] = array('#type' => 'container', '#tree' => TRUE);
     // Fundraiser visibility options.
     $form['visibility']['fundraiser'] = array('#type' => 'fieldset', '#title' => t('Fundraiser Visibility'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#access' => module_exists('fundraiser'));
     $form['visibility']['fundraiser']['confirmation'] = array('#type' => 'checkbox', '#title' => t('Show only on donation form confirmation pages'), '#default_value' => $form_state['item']->settings['visibility']['fundraiser']['confirmation']);
     // Fundraiser visibility options.
     $form['visibility']['user'] = array('#type' => 'fieldset', '#title' => t('User Visibility'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#access' => module_exists('fundraiser'));
     $role_options = array_map('check_plain', user_roles());
     $form['visibility']['user']['roles'] = array('#type' => 'checkboxes', '#title' => t('Exclude tag for specific user roles'), '#default_value' => $form_state['item']->settings['visibility']['user']['roles'], '#options' => $role_options, '#description' => t('Exclude this tag for the selected role(s). If you select no roles, the tag will be visible to all users.'));
     // Per-path visibility.
     $form['visibility']['path'] = array('#type' => 'fieldset', '#title' => t('Path Visibility'), '#collapsible' => TRUE, '#collapsed' => TRUE);
     $form['visibility']['path']['page_specific'] = array('#type' => 'radios', '#title' => t('Include tag on specific pages'), '#options' => array(BLOCK_VISIBILITY_NOTLISTED => t('All pages except those listed'), BLOCK_VISIBILITY_LISTED => t('Only the listed pages')), '#default_value' => $form_state['item']->settings['visibility']['path']['page_specific']);
     $form['visibility']['path']['pages'] = array('#type' => 'textarea', '#title' => 'Pages', '#default_value' => $form_state['item']->settings['visibility']['path']['pages'], '#description' => t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard."));
     // Per-node type visibility.
     $form['visibility']['node'] = array('#type' => 'fieldset', '#title' => t('Content Visibility'), '#collapsible' => TRUE, '#collapsed' => TRUE);
     $form['visibility']['node']['type'] = array('#type' => 'checkboxes', '#title' => t('Show tag for specific content types'), '#default_value' => $form_state['item']->settings['visibility']['node']['type'], '#options' => node_type_get_names(), '#description' => t('Show this tag only on nodes of the given type(s). If you select no types, there will be no type-specific limitation.'));
 }
 public function hook_page_alter(&$page)
 {
     // Add an extra "Panelizer" action on the content types admin page.
     if ($_GET['q'] == 'admin/structure/types') {
         // This only works with some themes.
         if (!empty($page['content']['system_main']['node_table'])) {
             // Shortcut.
             $table =& $page['content']['system_main']['node_table'];
             // Operations column should always be the last column in header.
             // Increase its colspan by one to include possible panelizer link.
             $operationsCol = end($table['#header']);
             if (!empty($operationsCol['colspan'])) {
                 $operationsColKey = key($table['#header']);
                 $table['#header'][$operationsColKey]['colspan']++;
             }
             // Since we can't tell what row a type is for, but we know that they
             // were generated in this order, go through the original types list.
             $types = node_type_get_types();
             $names = node_type_get_names();
             $row_index = 0;
             foreach ($names as $bundle => $name) {
                 $type = $types[$bundle];
                 if (node_hook($type->type, 'form')) {
                     $type_url_str = str_replace('_', '-', $type->type);
                     if ($this->is_panelized($bundle) && panelizer_administer_entity_bundle($this, $bundle)) {
                         $table['#rows'][$row_index][] = array('data' => l(t('panelizer'), 'admin/structure/types/manage/' . $type_url_str . '/panelizer'));
                     } else {
                         $table['#rows'][$row_index][] = array('data' => '');
                     }
                     // Update row index for next pass.
                     $row_index++;
                 }
             }
         }
     }
 }
 /**
  * Overrides \Drupal\block\BlockBase::blockForm().
  */
 public function blockForm($form, FormStateInterface $form_state)
 {
     // Labels & default text.
     $form['search_box'] = array('#type' => 'details', '#title' => t('Search box'), '#open' => TRUE);
     $form['search_box']['label_visibility'] = array('#type' => 'checkbox', '#title' => t('Display label'), '#default_value' => $this->configuration['search_box']['label_visibility']);
     $form['search_box']['label'] = array('#type' => 'textfield', '#title' => t('Label'), '#default_value' => $this->configuration['search_box']['label'], '#description' => t('Enter the label text for the search box. The default value is "Search this site".'), '#states' => array('visible' => array(':input[name="settings[search_box][label_visibility]"]' => array('checked' => TRUE))));
     $form['search_box']['placeholder'] = array('#type' => 'textfield', '#title' => t('Placeholder text'), '#default_value' => $this->configuration['search_box']['placeholder'], '#description' => t('This will change the default text inside the search form. This is the <a href="http://www.w3schools.com/tags/att_input_placeholder.asp" target="_blank">placeholder</a> attribute for the TextField. Leave blank for no text. This field is blank by default.'));
     $form['search_box']['title'] = array('#type' => 'textfield', '#title' => t('Hint text'), '#default_value' => $this->configuration['search_box']['title'], '#description' => t('Enter the text that will be displayed when hovering the input field (HTML <em>title</em> attritube).'));
     $form['search_box']['size'] = array('#type' => 'textfield', '#title' => t('Size'), '#size' => 3, '#default_value' => $this->configuration['search_box']['size'], '#description' => t('The default value is "!default".', array('!default' => 15)));
     $form['search_box']['max_length'] = array('#type' => 'textfield', '#title' => t('Maximum length'), '#size' => 3, '#default_value' => $this->configuration['search_box']['max_length'], '#description' => t('The default value is "!default".', array('!default' => 128)), '#required' => TRUE);
     // Submit button.
     $form['submit'] = array('#type' => 'details', '#title' => t('Submit button'), '#open' => TRUE);
     $form['submit']['text'] = array('#type' => 'textfield', '#title' => t('Text'), '#default_value' => $this->configuration['submit']['text'], '#description' => t('Enter the text for the submit button. Leave blank to hide it. The default value is "Search".'));
     if ($this->moduleHandler->moduleExists('file')) {
         $form['submit']['image_path'] = array('#type' => 'textfield', '#title' => t('Image path'), '#description' => t('The path to the file you would like to use as submit button instead of the default text button.'), '#default_value' => $this->configuration['submit']['image_path']);
         $friendly_path = NULL;
         $default_image = 'search.png';
         if (\Drupal::service('file_system')->uriScheme($this->configuration['submit']['image_path']) == 'public') {
             $friendly_path = file_uri_target($this->configuration['submit']['image_path']);
         }
         if ($this->configuration['submit']['image_path'] && isset($friendly_path)) {
             $local_file = strtr($this->configuration['submit']['image_path'], array('public:/' => PublicStream::basePath()));
         } else {
             $local_file = \Drupal::theme()->getActiveTheme()->getPath() . '/' . $default_image;
         }
         $form['submit']['image_path']['#description'] = t('Examples: <code>@implicit-public-file</code> (for a file in the public filesystem), <code>@explicit-file</code>, or <code>@local-file</code>.', array('@implicit-public-file' => isset($friendly_path) ? $friendly_path : $default_image, '@explicit-file' => \Drupal::service('file_system')->uriScheme($this->configuration['submit']['image_path']) !== FALSE ? $this->configuration['submit']['image_path'] : 'public://' . $default_image, '@local-file' => $local_file));
         $form['submit']['image'] = array('#type' => 'file', '#title' => t('Image'), '#description' => t("If you don't have direct file access to the server, use this field to upload your image."));
     }
     // Content.
     $form['content'] = array('#type' => 'details', '#title' => t('Content'), '#description' => t("Select the search types to present as search options in the search block. If none is selected, no selector will be displayed. <strong>Note</strong>: if there's only one type checked, the selector won't be displayed BUT only this type will be searched."), '#open' => count(array_filter($this->configuration['content']['types'])) + count(array_filter($this->configuration['content']['excluded'])));
     $search_pages = entity_load_multiple('search_page');
     $pages_options = array();
     foreach ($search_pages as $page) {
         if ($page->getPlugin()->getPluginId() == 'node_search') {
             $pages_options[$page->id()] = $page->label();
         }
     }
     if (count($pages_options)) {
         $form['content']['page'] = array('#type' => 'select', '#title' => t('Search page'), '#description' => t('Select which page to use when searching content with this block. Pages are defined <a href="!link">here</a>.', array('!link' => Url::fromRoute('entity.search_page.collection', array(), array('fragment' => 'edit-search-pages'))->toString())), '#default_value' => $this->configuration['content']['page'], '#options' => $pages_options);
     }
     $form['content']['types'] = array('#type' => 'checkboxes', '#title' => t('Content types'), '#default_value' => $this->configuration['content']['types'], '#options' => node_type_get_names());
     $other_pages_options = array();
     foreach ($search_pages as $page) {
         if ($page->getPlugin()->getPluginId() != 'node_search') {
             $other_pages_options[$page->id()] = $page->label();
         }
     }
     if (count($other_pages_options)) {
         $form['content']['other'] = array('#type' => 'checkboxes', '#title' => t('Other search pages'), '#default_value' => $this->configuration['content']['other'], '#options' => $other_pages_options);
     }
     $form['content']['selector']['type'] = array('#type' => 'select', '#title' => t('Selector type'), '#options' => array('select' => t('Drop-down list'), 'selectmultiple' => t('Drop-down list with multiple choices'), 'radios' => t('Radio buttons'), 'checkboxes' => t('Checkboxes')), '#description' => t('Choose which selector type to use. Note: content types and other searches cannot be combined in a single search.'), '#default_value' => $this->configuration['content']['selector']['type']);
     $form['content']['selector']['label_visibility'] = array('#type' => 'checkbox', '#title' => t('Display label'), '#default_value' => $this->configuration['content']['selector']['label_visibility']);
     $form['content']['selector']['label'] = array('#type' => 'textfield', '#title' => t('Label text'), '#default_value' => $this->configuration['content']['selector']['label'], '#description' => t('Enter the label text for the selector. The default value is "Search for".'), '#states' => array('visible' => array(':input[name="settings[content][selector][label_visibility]"]' => array('checked' => TRUE))));
     $form['content']['any'] = array('#type' => 'details', '#title' => t('- Any -'));
     $form['content']['any']['text'] = array('#type' => 'textfield', '#title' => t('- Any content type - text'), '#default_value' => $this->configuration['content']['any']['text'], '#required' => TRUE, '#description' => t('Enter the text for "any content type" choice. The default value is "- Any -".'));
     $form['content']['any']['restricts'] = array('#type' => 'checkbox', '#title' => t('Choosing - Any - restricts the search to the selected content types.'), '#default_value' => $this->configuration['content']['any']['restricts'], '#description' => t('If not checked, choosing - Any - will search in all content types.'));
     $form['content']['any']['force'] = array('#type' => 'checkbox', '#title' => t('Force - Any - to be displayed.'), '#default_value' => $this->configuration['content']['any']['force'], '#description' => t('When only one content type is selected, the default behaviour is to hide the selector. If you need the - Any - option to be displayed, check this.'));
     $form['content']['excluded'] = array('#type' => 'checkboxes', '#title' => t('Content exclusion'), '#description' => t("Select the content types you don't want to be displayed as results."), '#default_value' => $this->configuration['content']['excluded'], '#options' => node_type_get_names());
     // Taxonomy.
     $vocabularies = entity_load_multiple('taxonomy_vocabulary');
     if (count($vocabularies)) {
         $open = FALSE;
         foreach ($vocabularies as $voc) {
             $vocId = $voc->id();
             if ($this->configuration['taxonomy'][$vocId]['type'] != 'disabled') {
                 $open = TRUE;
                 break;
             }
         }
         $form['taxonomy'] = array('#type' => 'details', '#title' => t('Taxonomy'), '#description' => t('Select the vocabularies to present as search options in the search block. If none is selected, no selector will be displayed.'), '#open' => $open);
         // Get vocabularies forms.
         foreach ($vocabularies as $voc) {
             $vocId = $voc->id();
             $form['taxonomy'][$vocId] = array('#type' => 'details', '#title' => $voc->label(), '#open' => $this->configuration['taxonomy'][$vocId]['type'] != 'disabled');
             $form['taxonomy'][$vocId]['type'] = array('#type' => 'select', '#title' => t('Selector type'), '#options' => array('disabled' => t('Disabled'), 'select' => t('Drop-down list'), 'selectmultiple' => t('Drop-down list with multiple choices'), 'radios' => t('Radio buttons'), 'checkboxes' => t('Checkboxes')), '#description' => t('Choose which selector type to use.'), '#default_value' => $this->configuration['taxonomy'][$vocId]['type']);
             $form['taxonomy'][$vocId]['depth'] = array('#type' => 'textfield', '#title' => t('Depth'), '#size' => 2, '#default_value' => $this->configuration['taxonomy'][$vocId]['depth'], '#description' => t('Define the maximum depth of terms being displayed. The default value is "0" which disables the limit.'));
             $form['taxonomy'][$vocId]['label_visibility'] = array('#type' => 'checkbox', '#title' => t('Display label'), '#default_value' => $this->configuration['taxonomy'][$vocId]['label_visibility']);
             $form['taxonomy'][$vocId]['label'] = array('#type' => 'textfield', '#title' => t('Label text'), '#default_value' => $this->configuration['taxonomy'][$vocId]['label'], '#description' => t('Enter the label text for the selector. The default value is "!default".', array('!default' => $voc->label())), '#states' => array('visible' => array(':input[name="settings[taxonomy][' . $vocId . '][label_visibility]"]' => array('checked' => TRUE))));
             $form['taxonomy'][$vocId]['all_text'] = array('#type' => 'textfield', '#title' => t('-Any- text'), '#default_value' => $this->configuration['taxonomy'][$vocId]['all_text'], '#required' => TRUE, '#description' => t('Enter the text for "any term" choice. The default value is "- Any -".'));
         }
     }
     // Criteria.
     $form['criteria'] = array('#type' => 'details', '#title' => t('Advanced search criteria'), '#open' => $this->configuration['criteria']['or']['display'] || $this->configuration['criteria']['phrase']['display'] || $this->configuration['criteria']['negative']['display']);
     $form['criteria']['or'] = array('#type' => 'details', '#title' => t('Or'), '#open' => $this->configuration['criteria']['or']['display']);
     $form['criteria']['or']['display'] = array('#type' => 'checkbox', '#title' => t('Display'), '#default_value' => $this->configuration['criteria']['or']['display']);
     $form['criteria']['or']['label'] = array('#type' => 'textfield', '#title' => t('Label'), '#default_value' => $this->configuration['criteria']['or']['label'], '#description' => t('Enter the label text for this field. The default value is "Containing any of the words".'), '#states' => array('visible' => array(':input[name="settings[criteria][or][display]"]' => array('checked' => TRUE))));
     $form['criteria']['phrase'] = array('#type' => 'details', '#title' => t('Phrase'), '#open' => $this->configuration['criteria']['phrase']['display']);
     $form['criteria']['phrase']['display'] = array('#type' => 'checkbox', '#title' => t('Display'), '#default_value' => $this->configuration['criteria']['phrase']['display']);
     $form['criteria']['phrase']['label'] = array('#type' => 'textfield', '#title' => t('Label'), '#default_value' => $this->configuration['criteria']['phrase']['label'], '#description' => t('Enter the label text for this field. The default value is "Containing the phrase".'), '#states' => array('visible' => array(':input[name="settings[criteria][phrase][display]"]' => array('checked' => TRUE))));
     $form['criteria']['negative'] = array('#type' => 'details', '#title' => t('Negative'), '#open' => $this->configuration['criteria']['negative']['display']);
     $form['criteria']['negative']['display'] = array('#type' => 'checkbox', '#title' => t('Display'), '#default_value' => $this->configuration['criteria']['negative']['display']);
     $form['criteria']['negative']['label'] = array('#type' => 'textfield', '#title' => t('Label'), '#default_value' => $this->configuration['criteria']['negative']['label'], '#description' => t('Enter the label text for this field. The default value is "Containing none of the words".'), '#states' => array('visible' => array(':input[name="settings[criteria][negative][display]"]' => array('checked' => TRUE))));
     // Search API support.
     if ($this->moduleHandler->moduleExists('search_api_page')) {
         $search_api_pages = search_api_page_load_multiple();
         $options[0] = t('None');
         foreach ($search_api_pages as $page) {
             $options[$page->id()] = $page->label();
         }
         $form['searchapi'] = array('#type' => 'details', '#title' => t('Search API'), '#collapsible' => TRUE, '#collapsed' => TRUE);
         $form['searchapi']['page'] = array('#type' => 'select', '#title' => t('Search API Page to use'), '#options' => $options, '#default_value' => $this->configuration['searchapi']['page']);
     }
     // Languages.
     $form['languages'] = array('#type' => 'details', '#title' => t('Languages'), '#description' => t("Select the languages to present as search options in the search block. If none is selected, no selector will be displayed. <strong>Note</strong>: if there's only one language checked, the selector won't be displayed BUT only this language will be searched."), '#open' => count(array_filter($this->configuration['languages']['languages'])));
     $languages = \Drupal::languageManager()->getLanguages();
     $languages_options = array('current' => t('- Current language -'));
     foreach ($languages as $id => $language) {
         $languages_options[$id] = $language->getName();
     }
     $languages_options[Language::LANGCODE_NOT_SPECIFIED] = t('- Not specified -');
     $languages_options[Language::LANGCODE_NOT_APPLICABLE] = t('- Not applicable -');
     $form['languages']['languages'] = array('#type' => 'checkboxes', '#title' => t('Languages'), '#description' => t('Note: if <em>- Current language -</em> is selected, this current language won\'t be displayed twice.'), '#default_value' => $this->configuration['languages']['languages'], '#options' => $languages_options);
     $form['languages']['selector']['type'] = array('#type' => 'select', '#title' => t('Selector type'), '#options' => array('select' => t('Drop-down list'), 'selectmultiple' => t('Drop-down list with multiple choices'), 'radios' => t('Radio buttons'), 'checkboxes' => t('Checkboxes')), '#description' => t('Choose which selector type to use.'), '#default_value' => $this->configuration['languages']['selector']['type']);
     $form['languages']['selector']['label_visibility'] = array('#type' => 'checkbox', '#title' => t('Display label'), '#default_value' => $this->configuration['languages']['selector']['label_visibility']);
     $form['languages']['selector']['label'] = array('#type' => 'textfield', '#title' => t('Label text'), '#default_value' => $this->configuration['languages']['selector']['label'], '#description' => t('Enter the label text for the selector. The default value is "Languages".'), '#states' => array('visible' => array(':input[name="settings[languages][selector][label_visibility]"]' => array('checked' => TRUE))));
     $form['languages']['any'] = array('#type' => 'details', '#title' => t('- Any -'));
     $form['languages']['any']['text'] = array('#type' => 'textfield', '#title' => t('- Any language - text'), '#default_value' => $this->configuration['languages']['any']['text'], '#required' => TRUE, '#description' => t('Enter the text for "any language" choice. The default value is "- Any -".'));
     $form['languages']['any']['restricts'] = array('#type' => 'checkbox', '#title' => t('Choosing - Any - restricts the search to the selected languages.'), '#default_value' => $this->configuration['languages']['any']['restricts'], '#description' => t('If not checked, choosing - Any - will search in all languages.'));
     $form['languages']['any']['force'] = array('#type' => 'checkbox', '#title' => t('Force - Any - to be displayed.'), '#default_value' => $this->configuration['languages']['any']['force'], '#description' => t('When only one language is selected, the default behaviour is to hide the selector. If you need the - Any - option to be displayed, check this.'));
     // Custom Paths.
     $form['paths'] = array('#type' => 'details', '#title' => t('Custom search paths'), '#open' => $this->configuration['paths']['list'] != '');
     $form['paths']['selector']['type'] = array('#type' => 'select', '#title' => t('Selector type'), '#options' => array('select' => t('Drop-down list'), 'radios' => t('Radio buttons')), '#description' => t('Choose which selector type to use.'), '#default_value' => $this->configuration['paths']['selector']['type']);
     $form['paths']['selector']['label_visibility'] = array('#type' => 'checkbox', '#title' => t('Display label'), '#default_value' => $this->configuration['paths']['selector']['label_visibility']);
     $form['paths']['selector']['label'] = array('#type' => 'textfield', '#title' => t('Label text'), '#default_value' => $this->configuration['paths']['selector']['label'], '#description' => t('Enter the label text for the selector. The default value is "Customize your search".'), '#states' => array('visible' => array(':input[name="settings[paths][selector][label_visibility]"]' => array('checked' => TRUE))));
     $form['paths']['list'] = array('#type' => 'textarea', '#title' => t('Paths'), '#default_value' => $this->configuration['paths']['list'], '#rows' => 3, '#description' => t('If you want to use custom search paths, enter them here in the form <em>path</em>|<em>label</em>, one per line (if only one path is specified, the selector will be hidden). The [key] token will be replaced by what is entered in the search box, the [types] token will be replaced by the selected content types machine name(s) and the [terms] token will be replaced by the selected taxonomy term id(s). Ie: mysearch/[key]|My custom search label. The [current_path] token can also be used to use the current URL path of the page being viewed.'));
     $form['paths']['separator'] = array('#type' => 'textfield', '#title' => t('Arguments separator'), '#description' => t('Enter a separator that will be used when multiple content types or taxonomy terms are selected and [types] and/or [terms] tokens are used.'), '#default_value' => $this->configuration['paths']['separator'], '#size' => 2);
     // Ordering.
     $form['#attached']['library'][] = 'core/drupal.tableheader';
     $form['#attached']['library'][] = 'custom_search/custom_search.ordering';
     $form['order'] = array('#type' => 'details', '#title' => t('Elements layout'), '#description' => t('Order the form elements as you want them to be displayed. If you put elements in the Popup region, they will only appear when the search field is clicked.'), '#open' => TRUE);
     $form['order']['table'] = array('#type' => 'table', '#header' => array(t('Element'), t('Region'), t('Weight')), '#attributes' => array('id' => 'elements'));
     $elements = array('search_box' => array('label' => t('Search box'), 'config' => $this->configuration['search_box']), 'submit' => array('label' => t('Submit button'), 'config' => $this->configuration['submit']), 'content' => array('label' => t('Content types'), 'config' => $this->configuration['content']), 'or' => array('label' => t('Criteria: Containing any of the words'), 'config' => $this->configuration['criteria']['or']), 'phrase' => array('label' => t('Criteria: Containing the phrase'), 'config' => $this->configuration['criteria']['phrase']), 'negative' => array('label' => t('Criteria: Containing none of the words'), 'config' => $this->configuration['criteria']['negative']), 'languages' => array('label' => t('Languages'), 'config' => $this->configuration['languages']), 'paths' => array('label' => t('Custom Path'), 'config' => $this->configuration['paths']));
     if (count($vocabularies)) {
         foreach ($vocabularies as $voc) {
             $vocId = $voc->id();
             $elements['voc-' . $vocId] = array('label' => t('Taxonomy: !name', array('!name' => $voc->label())), 'config' => $this->configuration['taxonomy'][$vocId]);
         }
     }
     uasort($elements, array($this, 'weightsSort'));
     $regions = array('block' => t('Block'), 'popup' => t('Popup'));
     foreach ($elements as $id => $element) {
         $element_config = $element['config'];
         $regionsElements[$element_config['region']][$id] = $element;
     }
     foreach ($regions as $region => $title) {
         $form['order']['table']['#tabledrag'][] = array('action' => 'match', 'relationship' => 'sibling', 'group' => 'order-region', 'subgroup' => 'order-region-' . $region, 'hidden' => FALSE);
         $form['order']['table']['#tabledrag'][] = array('action' => 'order', 'relationship' => 'sibling', 'group' => 'order-weight', 'subgroup' => 'order-weight-' . $region);
         $form['order']['table'][$region] = array('#attributes' => array('class' => array('region-title', 'region-title-' . $region), 'no_striping' => TRUE));
         $form['order']['table'][$region]['title'] = array('#markup' => $title, '#wrapper_attributes' => array('colspan' => 5));
         $form['order']['table'][$region . '-message'] = array('#attributes' => array('class' => array('region-message', 'region-' . $region . '-message', empty($regionsElements[$region]) ? 'region-empty' : 'region-populated')));
         $form['order']['table'][$region . '-message']['message'] = array('#markup' => '<em>' . t('No elements in this region') . '</em>', '#wrapper_attributes' => array('colspan' => 5));
         if (isset($regionsElements[$region])) {
             foreach ($regionsElements[$region] as $id => $element) {
                 $element_config = $element['config'];
                 $form['order']['table'][$id]['#attributes']['class'][] = 'draggable';
                 $form['order']['table'][$id]['#weight'] = $element_config['weight'];
                 $form['order']['table'][$id]['element'] = array('#markup' => $element['label']);
                 $form['order']['table'][$id]['region'] = array('#type' => 'select', '#title' => t('Region for @title', array('@title' => $element['label'])), '#title_display' => 'invisible', '#options' => array('block' => t('Block'), 'popup' => t('Popup')), '#default_value' => $region, '#attributes' => array('class' => array('order-region', 'order-region-' . $region)));
                 $form['order']['table'][$id]['weight'] = array('#type' => 'weight', '#title' => t('Weight for @title', array('@title' => $element['label'])), '#title_display' => 'invisible', '#default_value' => $element_config['weight'], '#attributes' => array('class' => array('order-weight', 'order-weight-' . $element_config['region'])));
             }
         }
     }
     return $form;
 }
Example #12
0
/**
 * Inform the Field API about one or more fieldable types.
 *
 * Inform the Field API about one or more fieldable types, (object
 * types to which fields can be attached).
 *
 * @return
 *   An array whose keys are fieldable object type names and
 *   whose values identify properties of those types that the Field
 *   system needs to know about:
 *
 *   name: The human-readable name of the type.
 *   id key: The object property that contains the primary id for the
 *     object. Every object passed to the Field API must
 *     have this property and its value must be numeric.
 *   revision key: The object property that contains the revision id
 *     for the object, or NULL if the object type is not
 *     versioned. The Field API assumes that all revision ids are
 *     unique across all instances of a type; this means, for example,
 *     that every object's revision ids cannot be 0, 1, 2, ...
 *   bundle key: The object property that contains the bundle name for
 *     the object (bundle name is what nodes call "content type").
 *     The bundle name defines which fields are connected to the object.
 *   cacheable: A boolean indicating whether Field API should cache
 *     loaded fields for each object, reducing the cost of
 *     field_attach_load().
 *   bundles: An array of all existing bundle names for this object
 *     type. TODO: Define format. TODO: I'm unclear why we need
 *     this.
 */
function hook_fieldable_info()
{
    $return = array('node' => array('name' => t('Node'), 'id key' => 'nid', 'revision key' => 'vid', 'bundle key' => 'type', 'cacheable' => FALSE, 'bundles' => node_type_get_names()));
    return $return;
}
 /**
  * {@inheritdoc}
  */
 public function validateDrushParams($args)
 {
     $add_language = drush_get_option('languages');
     if (!empty($add_language)) {
         $add_language = explode(',', str_replace(' ', '', $add_language));
         // Intersect with the enabled languages to make sure the language args
         // passed are actually enabled.
         $values['values']['add_language'] = array_intersect($add_language, array_keys(locale_language_list()));
     }
     $values['kill'] = drush_get_option('kill');
     $values['title_length'] = 6;
     $values['num'] = array_shift($args);
     $values['max_comments'] = array_shift($args);
     $all_types = array_keys(node_type_get_names());
     $default_types = array_intersect(array('page', 'article'), $all_types);
     $selected_types = _convert_csv_to_array(drush_get_option('types', $default_types));
     if (empty($selected_types)) {
         return drush_set_error('DEVEL_GENERATE_NO_CONTENT_TYPES', dt('No content types available'));
     }
     $values['node_types'] = array_combine($selected_types, $selected_types);
     $node_types = array_filter($values['node_types']);
     if (!empty($values['kill']) && empty($node_types)) {
         return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Please provide content type (--types) in which you want to delete the content.'));
     }
     return $values;
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $config = $form_state->get('config');
     $filters = array();
     // Keywords.
     $keys = trim($form_state->getValue('keys'));
     // Filter Types.
     $types = $form_state->hasValue('types') ? $form_state->getValue('types') : array();
     if (!is_array($types)) {
         $types = array($types);
     }
     // Check if we're using another search (ie. Users).
     $first_type = current($types);
     if (substr($first_type, 0, 2) == 'o-') {
         $search_page_id = substr($first_type, 2);
         $search_pages = entity_load_multiple('search_page', array($search_page_id));
         if (!empty($search_pages)) {
             $route = 'search.view_' . $search_page_id;
         }
     } else {
         // Build route.
         $route = 'search.view_' . $config['content']['page'];
         // Types filters.
         $types = array_map(function ($val) {
             return $this->filterKeys($val);
         }, array_filter($types));
         $excluded = array_map(function ($val) {
             return $this->filterKeys($val);
         }, array_filter($config['content']['excluded']));
         if (count($types)) {
             if (in_array('all', $types)) {
                 // If - Any - is set to restrict the search, grab the content types.
                 if ($config['content']['any']['restricts']) {
                     $types = array_keys(array_filter($config['content']['types']));
                 }
                 // If exclusion has to be made, specify all the other types
                 if (!empty($excluded)) {
                     $types = array_keys(node_type_get_names());
                 }
                 $types = array_diff($types, $excluded);
                 if (!in_array('all', $types)) {
                     foreach ($types as $type) {
                         $filters[] = 'type:' . $type;
                     }
                 }
             } else {
                 $types = array_diff($types, $excluded);
                 foreach ($types as $type) {
                     $filters[] = 'type:' . $type;
                 }
             }
         } elseif (!empty($excluded)) {
             $types = array_diff(array_keys(node_type_get_names()), $excluded);
             foreach ($types as $type) {
                 $filters[] = 'type:' . $type;
             }
         }
         // Taxonomy filters.
         if ($this->moduleHandler->moduleExists('taxonomy')) {
             $terms = array();
             $vocabularies = entity_load_multiple('taxonomy_vocabulary');
             foreach ($vocabularies as $voc) {
                 $vid = $voc->id();
                 if ($form_state->hasValue('vocabulary_' . $vid)) {
                     $vterms = $form_state->getValue('vocabulary_' . $vid);
                     if (!is_array($vterms)) {
                         $vterms = array($vterms);
                     }
                     $terms = array_merge($terms, $vterms);
                 }
             }
             // Uses array_values() to filter here to get numerical index,
             // so we can splice the array later if needed (see line below the array_map()).
             $terms = array_map(function ($val) {
                 return $this->filterKeys($val);
             }, array_values(array_filter($terms)));
             // If one or more -Any- is selected, delete them.
             while (($index = array_search('all', $terms)) !== FALSE) {
                 array_splice($terms, $index, 1);
             }
             if (count($terms)) {
                 foreach ($terms as $term) {
                     $filters[] = 'term:' . $term;
                 }
             }
         }
         // Criteria filters.
         if ($form_state->hasValue('criteria_or') && trim($form_state->getValue('criteria_or')) != '') {
             $keys .= ' ' . str_replace(' ', ' OR ', trim($form_state->getValue('criteria_or')));
         }
         if ($form_state->hasValue('criteria_negative') && trim($form_state->getValue('criteria_negative')) != '') {
             $keys .= ' -' . str_replace(' ', ' -', trim($form_state->getValue('criteria_negative')));
         }
         if ($form_state->hasValue('criteria_phrase') && trim($form_state->getValue('criteria_phrase')) != '') {
             $keys .= ' "' . trim($form_state->getValue('criteria_phrase')) . '"';
         }
         // Language filters.
         $languages = $form_state->hasValue('languages') ? $form_state->getValue('languages') : array();
         if (!is_array($languages)) {
             $languages = array($languages);
         }
         $languages = array_map(function ($val) {
             return $this->filterKeys($val);
         }, array_filter($languages));
         if (count($languages)) {
             // If - Any - is selected and - Any - is set to restrict the search, grab the languages.
             if (in_array('all', $languages) && $config['languages']['any']['restricts']) {
                 $languages = array_keys(array_filter($config['languages']['languages']));
             }
             // If it's not - Any -, search for that language.
             if (!in_array('all', $languages)) {
                 foreach ($languages as $language) {
                     if ($language == 'current') {
                         $filters[] = 'language:' . \Drupal::languageManager()->getCurrentLanguage()->getId();
                     } else {
                         $filters[] = 'language:' . $language;
                     }
                 }
             }
         }
     }
     // Build a custom path if needed.
     if ($form_state->hasValue('paths') && $form_state->getValue('paths') != '') {
         $route = $form_state->getValue('paths');
         $route = str_replace('[current_path]', \Drupal::service('path.current')->getPath(), $route);
         $route = str_replace('[key]', $keys, $route);
         if (strpos($route, '[types]') !== FALSE) {
             $route = str_replace('[types]', isset($types) && count($types) ? implode($config['paths']['separator'], $types) : '', $route);
         }
         if (strpos($route, '[terms]') !== FALSE) {
             $route = str_replace('[terms]', isset($terms) && count($terms) ? implode($config['paths']['separator'], $terms) : '', $route);
         }
         // Check for a query string.
         $query = array();
         $route_query_position = strpos($route, '?');
         if ($route_query_position !== FALSE) {
             $query_tmp = substr($route, 1 + $route_query_position);
             $query_tmp = str_replace('&amp;', '&', $query_tmp);
             $query_tmp = explode('&', $query_tmp);
             foreach ($query_tmp as $param) {
                 $param_exploded = explode('=', $param);
                 $query[$param_exploded[0]] = $param_exploded[1];
             }
             $route = substr($route, 0, $route_query_position);
         }
         // If not an external URL, add the base url scheme.
         if (substr($route, 0, 4) != 'http') {
             $route = 'base://' . $route;
         }
         // Generate the final url
         $url = Url::fromUri($route, array('query' => $query));
         $form_state->setRedirectUrl($url);
     } else {
         $query['keys'] = $keys;
         if (count($filters)) {
             $query['f'] = $filters;
         }
         $form_state->setRedirect($route, array(), array('query' => $query));
     }
 }
Example #15
0
 /**
  * Adds availability reference field to a content type.
  *
  * @When /^I add the "(?<field_name>[^"]*)" availability reference field referencing to "(?<unit_types>[^"]*)" units in "(?<content_type>[^"]*)" content$/
  */
 public function iAddTheAvailabilityReferenceFieldReferencingToUnitsInPageContent($field_name, $unit_types, $content_type)
 {
     // Create the content type.
     // Make sure a testimonial content type doesn't already exist.
     if (!in_array($content_type, node_type_get_names())) {
         $type = array('type' => $content_type, 'name' => $content_type, 'base' => 'node_content', 'custom' => 1, 'modified' => 1, 'locked' => 0);
         $type = node_type_set_defaults($type);
         node_type_save($type);
         node_add_body_field($type);
         $this->content_types[] = $content_type;
     }
     // Create field ('rooms_booking_unit_options') if not exist.
     if (field_read_field($field_name) === FALSE) {
         $field = array('field_name' => $field_name, 'type' => 'rooms_availability_reference', 'cardinality' => -1, 'settings' => array('referenceable_unit_types' => drupal_map_assoc(explode(',', $unit_types))));
         field_create_field($field);
         $this->fields[] = $field_name;
     }
     if (field_read_instance('node', $field_name, $content_type) === FALSE) {
         // Create the instance on the bundle.
         $instance = array('field_name' => $field_name, 'entity_type' => 'node', 'label' => 'Availability reference', 'bundle' => $content_type, 'required' => FALSE, 'widget' => array('type' => 'rooms_availability_reference_autocomplete'));
         field_create_instance($instance);
     }
 }
Example #16
0
 /**
  * {@inheritdoc}
  */
 public function searchFormAlter(array &$form, FormStateInterface $form_state)
 {
     // Add advanced search keyword-related boxes.
     $form['advanced'] = array('#type' => 'details', '#title' => t('Advanced search'), '#attributes' => array('class' => array('search-advanced')), '#access' => $this->account && $this->account->hasPermission('use advanced search'));
     $form['advanced']['keywords-fieldset'] = array('#type' => 'fieldset', '#title' => t('Keywords'));
     $form['advanced']['keywords'] = array('#prefix' => '<div class="criterion">', '#suffix' => '</div>');
     $form['advanced']['keywords-fieldset']['keywords']['or'] = array('#type' => 'textfield', '#title' => t('Containing any of the words'), '#size' => 30, '#maxlength' => 255);
     $form['advanced']['keywords-fieldset']['keywords']['phrase'] = array('#type' => 'textfield', '#title' => t('Containing the phrase'), '#size' => 30, '#maxlength' => 255);
     $form['advanced']['keywords-fieldset']['keywords']['negative'] = array('#type' => 'textfield', '#title' => t('Containing none of the words'), '#size' => 30, '#maxlength' => 255);
     // Add node types.
     $types = array_map(array('\\Drupal\\Component\\Utility\\String', 'checkPlain'), node_type_get_names());
     $form['advanced']['types-fieldset'] = array('#type' => 'fieldset', '#title' => t('Types'));
     $form['advanced']['types-fieldset']['type'] = array('#type' => 'checkboxes', '#title' => t('Only of the type(s)'), '#prefix' => '<div class="criterion">', '#suffix' => '</div>', '#options' => $types);
     $form['advanced']['submit'] = array('#type' => 'submit', '#value' => t('Advanced search'), '#prefix' => '<div class="action">', '#suffix' => '</div>', '#weight' => 100);
     // Add languages.
     $language_options = array();
     $language_list = $this->languageManager->getLanguages(LanguageInterface::STATE_ALL);
     foreach ($language_list as $langcode => $language) {
         // Make locked languages appear special in the list.
         $language_options[$langcode] = $language->isLocked() ? t('- @name -', array('@name' => $language->getName())) : $language->getName();
     }
     if (count($language_options) > 1) {
         $form['advanced']['lang-fieldset'] = array('#type' => 'fieldset', '#title' => t('Languages'));
         $form['advanced']['lang-fieldset']['language'] = array('#type' => 'checkboxes', '#title' => t('Languages'), '#prefix' => '<div class="criterion">', '#suffix' => '</div>', '#options' => $language_options);
     }
 }
<?php

$data = variable_get('contents_on_chart_data');
$nodeTypes = node_type_get_names();
$typesArray = array();
$chartArray = array();
foreach ($nodeTypes as $key => $value) {
    $typesArray[$key] = array();
}
foreach ($typesArray as $nodeTypeKey => $nodeTypeValue) {
    foreach ($data['nodeData'] as $key => $value) {
        if ($value['type'] == $nodeTypeKey) {
            $typesArray[$nodeTypeKey][] = $value;
        }
    }
}
foreach ($typesArray as $key => $value) {
    $chartArray['totalNodes'][$key] = count($value);
}
$chartType = isset($_GET['chartType']) ? $_GET['chartType'] : $data['chartType'];
print '<ul class="content_on_charts">';
foreach ($extra['tabs'] as $links) {
    print '<li>' . $links . '</li>';
}
print '<ul>';
?>
<form class="form-inline" role="form" id="<?php 
print $form['#id'];
?>
">
  <div class="form-group">
Example #18
0
 /**
  * Create a stripe base on node type.
  *
  * @param \Drupal\calendar\CalendarEvent $event
  *   The event result object.
  */
 function nodeTypeStripe(&$event)
 {
     $colors = isset($this->options['colors']['calendar_colors_type']) ? $this->options['colors']['calendar_colors_type'] : [];
     if (empty($colors)) {
         return;
     }
     $type_names = node_type_get_names();
     $bundle = $event->getBundle();
     $label = '';
     $stripeHex = '';
     if (array_key_exists($bundle, $type_names) || $colors[$bundle] == CALENDAR_EMPTY_STRIPE) {
         $label = $type_names[$bundle];
     }
     if (array_key_exists($bundle, $colors)) {
         $stripeHex = $colors[$bundle];
     }
     $event->addStripeLabel($label);
     $event->addStripeHex($stripeHex);
 }
Example #19
0
/**
 * Implements hook_form_FORM_ID_alter().
 * Improve the accessibility of the advanced search form by wrapping everything in fieldsets.
 * Borrowed from Responsive HTML5 Boilerplate.
 * @link http://drupal.org/project/html5_boilerplate
 */
function zentropy_form_search_form_alter(&$form)
{
    if (isset($form['module']) && $form['module']['#value'] === 'node' && user_access('use advanced search')) {
        // Keywords
        $form['advanced'] = array('#type' => 'fieldset', '#title' => t('Advanced search'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#attributes' => array('class' => array('search-advanced')));
        $form['advanced']['keywords-fieldset'] = array('#type' => 'fieldset', '#title' => t('Keywords'), '#collapsible' => FALSE);
        $form['advanced']['keywords-fieldset']['keywords'] = array('#prefix' => '<div class="criterion">', '#suffix' => '</div>');
        $form['advanced']['keywords-fieldset']['keywords']['or'] = array('#type' => 'textfield', '#title' => t('Containing any of the words'), '#size' => 30, '#maxlength' => 255);
        $form['advanced']['keywords-fieldset']['keywords']['phrase'] = array('#type' => 'textfield', '#title' => t('Containing the phrase'), '#size' => 30, '#maxlength' => 255);
        $form['advanced']['keywords-fieldset']['keywords']['negative'] = array('#type' => 'textfield', '#title' => t('Containing none of the words'), '#size' => 30, '#maxlength' => 255);
        // Node types.
        $types = array_map('check_plain', node_type_get_names());
        $form['advanced']['types-fieldset'] = array('#type' => 'fieldset', '#title' => t('Types'), '#collapsible' => FALSE);
        $form['advanced']['types-fieldset']['type'] = array('#type' => 'checkboxes', '#prefix' => '<div class="criterion">', '#suffix' => '</div>', '#options' => $types);
        $form['advanced']['submit'] = array('#type' => 'submit', '#value' => t('Advanced search'), '#prefix' => '<div class="action advanced-search-submit">', '#suffix' => '</div>', '#weight' => 99);
        // Languages.
        $language_options = array();
        foreach (language_list('language') as $key => $entity) {
            $language_options[$key] = $entity->name;
        }
        if (count($language_options) > 1) {
            $form['advanced']['lang-fieldset'] = array('#type' => 'fieldset', '#title' => t('Languages'), '#collapsible' => FALSE, '#collapsed' => FALSE);
            $form['advanced']['lang-fieldset']['language'] = array('#type' => 'checkboxes', '#prefix' => '<div class="criterion">', '#suffix' => '</div>', '#options' => $language_options);
        }
        $form['#validate'][] = 'node_search_validate';
    }
}
Example #20
0
/**
 * Inform the base system and the Field API about one or more entity types.
 *
 * Inform the system about one or more entity types (i.e., object types that
 * can be loaded via entity_load() and, optionally, to which fields can be
 * attached).
 *
 * @see entity_load()
 * @see hook_entity_info_alter()
 *
 * @return
 *   An array whose keys are entity type names and whose values identify
 *   properties of those types that the  system needs to know about:
 *
 *   name: The human-readable name of the type.
 *   controller class: The name of the class that is used to load the objects.
 *     The class has to implement the DrupalEntityController interface. Leave
 *     blank to use the DefaultDrupalEntityController implementation.
 *   base table: (used by DefaultDrupalEntityController) The name of the entity
 *     type's base table.
 *   static cache: (used by DefaultDrupalEntityController) FALSE to disable
 *     static caching of entities during a page request. Defaults to TRUE.
 *   load hook: The name of the hook which should be invoked by
 *   DrupalDefaultEntityController:attachLoad(), for example 'node_load'.
 *   fieldable: Set to TRUE if you want your entity type to be fieldable.
 *   - object keys: An array describing how the Field API can extract the
 *     information it needs from the objects of the type.
 *     - id: The name of the property that contains the primary id of the
 *       object. Every object passed to the Field API must have this property
 *       and its value must be numeric.
 *     - revision: The name of the property that contains the revision id of
 *       the object. The Field API assumes that all revision ids are unique
 *       across all objects of a type.
 *       This element can be omitted if the objects of this type are not
 *       versionable.
 *     - bundle: The name of the property that contains the bundle name for the
 *       object. The bundle name defines which set of fields are attached to
 *       the object (e.g. what nodes call "content type").
 *       This element can be omitted if this type has no bundles (all objects
 *       have the same fields).
 *   - bundle keys: An array describing how the Field API can extract the
 *     information it needs from the bundle objects for this type (e.g
 *     $vocabulary objects for terms; not applicable for nodes).
 *     This element can be omitted if this type's bundles do not exist as
 *     standalone objects.
 *     - bundle: The name of the property that contains the name of the bundle
 *       object.
 *   - cacheable: A boolean indicating whether Field API should cache
 *     loaded fields for each object, reducing the cost of
 *     field_attach_load().
 *   - bundles: An array describing all bundles for this object type.
 *     Keys are bundles machine names, as found in the objects' 'bundle'
 *     property (defined in the 'object keys' entry above).
 *     - label: The human-readable name of the bundle.
 *     - admin: An array of information that allow Field UI pages (currently
 *       implemented in a contributed module) to attach themselves to the
 *       existing administration pages for the bundle.
 *       - path: the path of the bundle's main administration page, as defined
 *         in hook_menu(). If the path includes a placeholder for the bundle,
 *         the 'bundle argument', 'bundle helper' and 'real path' keys below
 *         are required.
 *       - bundle argument: The position of the placeholder in 'path', if any.
 *       - real path: The actual path (no placeholder) of the bundle's main
 *         administration page. This will be used to generate links.
 *       - access callback: As in hook_menu(). 'user_access' will be assumed if
 *         no value is provided.
 *       - access arguments: As in hook_menu().
 */
function hook_entity_info()
{
    $return = array('node' => array('name' => t('Node'), 'controller class' => 'NodeController', 'base table' => 'node', 'id key' => 'nid', 'revision key' => 'vid', 'fieldable' => TRUE, 'bundle key' => 'type', 'bundles' => node_type_get_names()));
    return $return;
}
Example #21
0
/**
 * Inform the base system and the Field API about one or more entity types.
 *
 * Inform the system about one or more entity types (i.e., object types that
 * can be loaded via entity_load() and, optionally, to which fields can be
 * attached).
 *
 * @return
 *   An array whose keys are entity type names and whose values identify
 *   properties of those types that the system needs to know about:
 *   - label: The human-readable name of the type.
 *   - controller class: The name of the class that is used to load the objects.
 *     The class has to implement the DrupalEntityControllerInterface interface.
 *     Leave blank to use the DrupalDefaultEntityController implementation.
 *   - base table: (used by DrupalDefaultEntityController) The name of the
 *     entity type's base table.
 *   - revision table: The name of the entity type's revision table (if any).
 *   - static cache: (used by DrupalDefaultEntityController) FALSE to disable
 *     static caching of entities during a page request. Defaults to TRUE.
 *   - field cache: (used by Field API loading and saving of field data) FALSE
 *     to disable Field API's persistent cache of field data. Only recommended
 *     if a higher level persistent cache is available for the entity type.
 *     Defaults to TRUE.
 *   - load hook: The name of the hook which should be invoked by
 *     DrupalDefaultEntityController:attachLoad(), for example 'node_load'.
 *   - uri callback: The name of an implementation of
 *     callback_entity_info_uri().
 *   - label callback: (optional) The name of an implementation of
 *     callback_entity_info_label(), which returns the label of the entity. The
 *     entity label is the main string associated with an entity; for example,
 *     the title of a node or the subject of a comment. If there is an entity
 *     object property that defines the label, then using the 'label' element of
 *     the 'entity keys' return value component suffices to provide this
 *     information (see below). Alternatively, specifying this callback allows
 *     more complex logic to determine the label of an entity. See also the
 *     entity_label() function, which implements this logic.
 *   - language callback: (optional) The name of an implementation of
 *     callback_entity_info_language(). In most situations, when needing to
 *     determine this value, inspecting a property named after the 'language'
 *     element of the 'entity keys' should be enough. The language callback is
 *     meant to be used primarily for temporary alterations of the property
 *     value: entity-defining modules are encouraged to always define a
 *     language property, instead of using the callback as main entity language
 *     source. In fact not having a language property defined is likely to
 *     prevent an entity from being queried by language. Moreover, given that
 *     entity_language() is not necessarily used everywhere it would be
 *     appropriate, modules implementing the language callback should be aware
 *     that this might not be always called.
 *   - fieldable: Set to TRUE if you want your entity type to accept fields
 *     being attached to it.
 *   - translation: An associative array of modules registered as field
 *     translation handlers. Array keys are the module names, array values
 *     can be any data structure the module uses to provide field translation.
 *     Any empty value disallows the module to appear as a translation handler.
 *   - entity keys: (optional) An array describing how the Field API can extract
 *     the information it needs from the objects of the type. Elements:
 *     - id: The name of the property that contains the primary id of the
 *       entity. Every entity object passed to the Field API must have this
 *       property and its value must be numeric.
 *     - revision: The name of the property that contains the revision id of
 *       the entity. The Field API assumes that all revision ids are unique
 *       across all entities of a type. This entry can be omitted if the
 *       entities of this type are not versionable. Defaults to an empty string.
 *     - bundle: The name of the property that contains the bundle name for the
 *       entity. The bundle name defines which set of fields are attached to
 *       the entity (e.g. what nodes call "content type"). This entry can be
 *       omitted if this entity type exposes a single bundle (all entities have
 *       the same collection of fields). The name of this single bundle will be
 *       the same as the entity type. Defaults to an empty string.
 *     - label: The name of the property that contains the entity label. For
 *       example, if the entity's label is located in $entity->subject, then
 *       'subject' should be specified here. If complex logic is required to
 *       build the label, a 'label callback' should be defined instead (see
 *       the 'label callback' section above for details).
 *     - language: The name of the property, typically 'language', that contains
 *       the language code representing the language the entity has been created
 *       in. This value may be changed when editing the entity and represents
 *       the language its textual components are supposed to have. If no
 *       language property is available, the 'language callback' may be used
 *       instead. This entry can be omitted if the entities of this type are not
 *       language-aware.
 *   - bundle keys: An array describing how the Field API can extract the
 *     information it needs from the bundle objects for this type. This entry
 *     is required if the 'path' provided in the 'bundles'/'admin' section
 *     identifies the bundle using a named menu placeholder whose loader
 *     callback returns an object (e.g., $vocabulary for taxonomy terms, or
 *     $node_type for nodes). If the path does not include the bundle, or the
 *     bundle is just a string rather than an automatically loaded object, then
 *     this can be omitted. Elements:
 *     - bundle: The name of the property of the bundle object that contains
 *       the name of the bundle object.
 *   - bundles: An array describing all bundles for this object type. Keys are
 *     bundles machine names, as found in the objects' 'bundle' property
 *     (defined in the 'entity keys' entry above). This entry can be omitted if
 *     this entity type exposes a single bundle (all entities have the same
 *     collection of fields). The name of this single bundle will be the same as
 *     the entity type. Elements:
 *     - label: The human-readable name of the bundle.
 *     - uri callback: Same as the 'uri callback' key documented above for the
 *       entity type, but for the bundle only. When determining the URI of an
 *       entity, if a 'uri callback' is defined for both the entity type and
 *       the bundle, the one for the bundle is used.
 *     - admin: An array of information that allows Field UI pages to attach
 *       themselves to the existing administration pages for the bundle.
 *       Elements:
 *       - path: the path of the bundle's main administration page, as defined
 *         in hook_menu(). If the path includes a placeholder for the bundle,
 *         the 'bundle argument' and 'real path' keys below are required.
 *       - bundle argument: The position of the bundle placeholder in 'path', if
 *         any.
 *       - real path: The actual path (no placeholder) of the bundle's main
 *         administration page. This will be used to generate links.
 *       - access callback: As in hook_menu(). 'user_access' will be assumed if
 *         no value is provided.
 *       - access arguments: As in hook_menu().
 *   - view modes: An array describing the view modes for the entity type. View
 *     modes let entities be displayed differently depending on the context.
 *     For instance, a node can be displayed differently on its own page
 *     ('full' mode), on the home page or taxonomy listings ('teaser' mode), or
 *     in an RSS feed ('rss' mode). Modules taking part in the display of the
 *     entity (notably the Field API) can adjust their behavior depending on
 *     the requested view mode. An additional 'default' view mode is available
 *     for all entity types. This view mode is not intended for actual entity
 *     display, but holds default display settings. For each available view
 *     mode, administrators can configure whether it should use its own set of
 *     field display settings, or just replicate the settings of the 'default'
 *     view mode, thus reducing the amount of display configurations to keep
 *     track of. Keys of the array are view mode names. Each view mode is
 *     described by an array with the following key/value pairs:
 *     - label: The human-readable name of the view mode
 *     - custom settings: A boolean specifying whether the view mode should by
 *       default use its own custom field display settings. If FALSE, entities
 *       displayed in this view mode will reuse the 'default' display settings
 *       by default (e.g. right after the module exposing the view mode is
 *       enabled), but administrators can later use the Field UI to apply custom
 *       display settings specific to the view mode.
 *
 * @see entity_load()
 * @see hook_entity_info_alter()
 */
function hook_entity_info()
{
    $return = array('node' => array('label' => t('Node'), 'controller class' => 'NodeController', 'base table' => 'node', 'revision table' => 'node_revision', 'uri callback' => 'node_uri', 'fieldable' => TRUE, 'translation' => array('locale' => TRUE), 'entity keys' => array('id' => 'nid', 'revision' => 'vid', 'bundle' => 'type', 'language' => 'language'), 'bundle keys' => array('bundle' => 'type'), 'bundles' => array(), 'view modes' => array('full' => array('label' => t('Full content'), 'custom settings' => FALSE), 'teaser' => array('label' => t('Teaser'), 'custom settings' => TRUE), 'rss' => array('label' => t('RSS'), 'custom settings' => FALSE))));
    // Search integration is provided by node.module, so search-related
    // view modes for nodes are defined here and not in search.module.
    if (module_exists('search')) {
        $return['node']['view modes'] += array('search_index' => array('label' => t('Search index'), 'custom settings' => FALSE), 'search_result' => array('label' => t('Search result highlighting input'), 'custom settings' => FALSE));
    }
    // Bundles must provide a human readable name so we can create help and error
    // messages, and the path to attach Field admin pages to.
    foreach (node_type_get_names() as $type => $name) {
        $return['node']['bundles'][$type] = array('label' => $name, 'admin' => array('path' => 'admin/structure/types/manage/%node_type', 'real path' => 'admin/structure/types/manage/' . str_replace('_', '-', $type), 'bundle argument' => 4, 'access arguments' => array('administer content types')));
    }
    return $return;
}
Example #22
0
 /**
  * Overrides Drupal\configuration\Config\Configuration::getAllIdentifiers().
  */
 public static function getAllIdentifiers($component)
 {
     return node_type_get_names();
 }
 public function hook_page_alter(&$page)
 {
     if ($_GET['q'] == 'admin/structure/types' && !empty($page['content']['system_main']['node_table'])) {
         // shortcut
         $table =& $page['content']['system_main']['node_table'];
         // Modify the header.
         $table['#header'][1]['colspan'] = 5;
         // Since we can't tell what row a type is for, but we know that they
         // were generated in this order, go through the original types
         // list:
         $types = node_type_get_types();
         $names = node_type_get_names();
         $row_index = 0;
         foreach ($names as $bundle => $name) {
             $type = $types[$bundle];
             if (node_hook($type->type, 'form')) {
                 $type_url_str = str_replace('_', '-', $type->type);
                 if ($this->is_panelized($bundle) && panelizer_administer_entity_bundle($this, $bundle)) {
                     $table['#rows'][$row_index][] = array('data' => l(t('panelizer'), 'admin/structure/types/manage/' . $type_url_str . '/panelizer'));
                 } else {
                     $table['#rows'][$row_index][] = array('data' => '');
                 }
                 // Update row index for next pass:
                 $row_index++;
             }
         }
     }
 }
 /**
  * Overrides \Drupal\block\BlockBase::blockForm().
  */
 public function blockForm($form, FormStateInterface $form_state)
 {
     $form['formblock_node_type'] = array('#title' => $this->t('Node type'), '#description' => $this->t('Select the node type whose form will be shown in the block.'), '#type' => 'select', '#required' => TRUE, '#options' => node_type_get_names(), '#default_value' => $this->configuration['type']);
     $form['formblock_show_help'] = array('#type' => 'checkbox', '#title' => $this->t('Show submission guidelines'), '#default_value' => $this->configuration['show_help'], '#description' => $this->t('Enable this option to show the submission guidelines in the block above the form.'));
     return $form;
 }