示例#1
0
 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     $menus = menu_ui_get_menus();
     foreach ($menus as $menu => $title) {
         $this->derivatives[$menu] = $base_plugin_definition;
         $this->derivatives[$menu]['admin_label'] = $title;
     }
     return $this->derivatives;
 }
 /**
  * Implements \Drupal\Core\Form\FormInterface::buildForm().
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('coffee.configuration');
     $menus = menu_ui_get_menus();
     if (!empty($menus)) {
         // Settings for coffee.
         $form['coffee_menus'] = array('#type' => 'checkboxes', '#title' => t('Menus to include'), '#description' => t('Select the menus that should be used by Coffee to search.'), '#options' => $menus, '#required' => TRUE, '#default_value' => (array) $config->get('coffee_menus'));
     }
     return parent::buildForm($form, $form_state);
 }
示例#3
0
 /**
  * Implements \Drupal\Core\Form\FormInterface::buildForm().
  */
 public function buildForm(array $form, array &$form_state)
 {
     $config = $this->config('menu_ui.settings');
     $form['intro'] = array('#type' => 'item', '#markup' => t('The Menu UI module allows on-the-fly creation of menu links in the content authoring forms. To configure these settings for a particular content type, visit the <a href="@content-types">Content types</a> page, click the <em>edit</em> link for the content type, and go to the <em>Menu settings</em> section.', array('@content-types' => url('admin/structure/types'))));
     $menu_options = menu_ui_get_menus();
     $main = $config->get('main_links');
     $form['menu_main_links_source'] = array('#type' => 'select', '#title' => t('Source for the Main links'), '#default_value' => $main, '#empty_option' => t('No Main links'), '#options' => $menu_options, '#tree' => FALSE, '#description' => t('Select what should be displayed as the Main links (typically at the top of the page).'));
     $form['menu_secondary_links_source'] = array('#type' => 'select', '#title' => t('Source for the Secondary links'), '#default_value' => $config->get('secondary_links'), '#empty_option' => t('No Secondary links'), '#options' => $menu_options, '#tree' => FALSE, '#description' => t('Select the source for the Secondary links. An advanced option allows you to use the same source for both Main links (currently %main) and Secondary links: if your source menu has two levels of hierarchy, the top level menu links will appear in the Main links, and the children of the active link will appear in the Secondary links.', array('%main' => $main ? $menu_options[$main] : t('none'))));
     return parent::buildForm($form, $form_state);
 }
示例#4
0
 /**
  * Gets all the available menus and menu items as a JavaScript array.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The request of the page.
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  *   The available menu and menu items.
  */
 public function getParentOptions(Request $request)
 {
     $available_menus = array();
     if ($menus = $request->request->get('menus')) {
         foreach ($menus as $menu) {
             $available_menus[$menu] = $menu;
         }
     }
     $options = _menu_ui_get_options(menu_ui_get_menus(), $available_menus, array('mlid' => 0));
     return new JsonResponse($options);
 }
 /**
  * {@inheritdoc}
  */
 public function getPerMenuPermissions(AccountInterface $account)
 {
     $perms_menu =& drupal_static(__FUNCTION__, array());
     if (!$perms_menu) {
         $menus = menu_ui_get_menus();
         foreach ($menus as $name => $title) {
             $permission = 'administer ' . $name . ' menu items';
             if ($account->hasPermission($permission)) {
                 $perms_menu[$permission] = $permission;
             }
         }
         \Drupal::moduleHandler()->alter('menu_admin_per_menu_get_permissions', $perms_menu, $account);
     }
     return $perms_menu;
 }
 /**
  * This is page callback. Listing mega menus.
  */
 public function listMegaMenus()
 {
     // Get menus.
     $menus = menu_ui_get_menus();
     // Prepare data for each row.
     $rows = array();
     foreach ($menus as $name => $title) {
         $row = array('menu-name' => $name, 'menu-title' => $title);
         $dropbuttons = array('#type' => 'operations', '#links' => array('config' => array('url' => new Url('tb_megamenu.admin.configure', array('menu_name' => $name)), 'title' => 'Config'), 'edit' => array('url' => new Url('entity.menu.edit_form', array('menu' => $name)), 'title' => 'Edit links')));
         $row['menu-operations'] = array('data' => $dropbuttons);
         $rows[] = $row;
     }
     // Prepare label for headers.
     $header = array('menu-name' => t('Menu Name'), 'menu-title' => t('Menu Title'), 'menu-operations' => t('Operations'));
     return array('#theme' => 'table', '#header' => $header, '#rows' => $rows, '#empty' => t('No MegaMenu block available. <a href="@link">Add Menu</a>.', array('@link' => \Drupal::url('entity.menu.add_form'))), '#attributes' => array('id' => 'tb_megamenu'));
 }
示例#7
0
/**
 * Implements hook_form_FORM_ID_alter().
 */
function bluez8_form_system_theme_settings_alter(&$form, &$form_state)
{
    $form['bluez_settings'] = array('#type' => 'fieldset', '#title' => t('Bluez Theme Settings'), '#collapsible' => FALSE, '#collapsed' => FALSE);
    $form['bluez_settings']['breadcrumbs'] = array('#type' => 'checkbox', '#title' => t('Show breadcrumbs in a page'), '#default_value' => theme_get_setting('breadcrumbs', 'bluez8'), '#description' => t("Check this option to show breadcrumbs in page. Uncheck to hide."));
    $form['bluez_settings']['slideshow'] = array('#type' => 'fieldset', '#title' => t('Front Page Slideshow'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['bluez_settings']['slideshow']['slideshow_display'] = array('#type' => 'checkbox', '#title' => t('Show slideshow'), '#default_value' => theme_get_setting('slideshow_display', 'bluez8'), '#description' => t("Check this option to show Slideshow in front page. Uncheck to hide."));
    $form['bluez_settings']['slideshow']['slide'] = array('#markup' => t('You can change the description of each slide in the following Slide Settings.'));
    $form['bluez_settings']['slideshow']['slide1'] = array('#type' => 'fieldset', '#title' => t('Slide 1'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['bluez_settings']['slideshow']['slide1']['slide1_title'] = array('#type' => 'textfield', '#title' => t('Slide Title'), '#default_value' => theme_get_setting('slide1_title', 'bluez8'));
    $form['bluez_settings']['slideshow']['slide1']['slide1_desc'] = array('#type' => 'textfield', '#title' => t('Slide Description'), '#default_value' => theme_get_setting('slide1_desc', 'bluez8'));
    $form['bluez_settings']['slideshow']['slide2'] = array('#type' => 'fieldset', '#title' => t('Slide 2'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['bluez_settings']['slideshow']['slide2']['slide2_title'] = array('#type' => 'textfield', '#title' => t('Slide Title'), '#default_value' => theme_get_setting('slide2_title', 'bluez8'));
    $form['bluez_settings']['slideshow']['slide2']['slide2_desc'] = array('#type' => 'textfield', '#title' => t('Slide Description'), '#default_value' => theme_get_setting('slide2_desc', 'bluez8'));
    $form['bluez_settings']['slideshow']['slide3'] = array('#type' => 'fieldset', '#title' => t('Slide 3'), '#collapsible' => TRUE, '#collapsed' => TRUE);
    $form['bluez_settings']['slideshow']['slide3']['slide3_title'] = array('#type' => 'textfield', '#title' => t('Slide Title'), '#default_value' => theme_get_setting('slide3_title', 'bluez8'));
    $form['bluez_settings']['slideshow']['slide3']['slide3_desc'] = array('#type' => 'textfield', '#title' => t('Slide Description'), '#default_value' => theme_get_setting('slide3_desc', 'bluez8'));
    $form['bluez_settings']['slideshow']['slideimage'] = array('#markup' => t('To change the Slide Images, Replace the slide-image-1.jpg, slide-image-2.jpg and slide-image-3.jpg in the images folder of the bluez theme folder.'));
    $form['bluez_settings']['social'] = array('#type' => 'fieldset', '#title' => t('Social Icon'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['bluez_settings']['social']['display'] = array('#type' => 'checkbox', '#title' => t('Show Social Icon'), '#default_value' => theme_get_setting('display', 'bluez8'), '#description' => t("Check this option to show Social Icon. Uncheck to hide."));
    $form['bluez_settings']['social']['twitter'] = array('#type' => 'textfield', '#title' => t('Twitter URL'), '#default_value' => theme_get_setting('twitter', 'bluez8'), '#description' => t("Enter your Twitter Profile URL. example:: http://www.xyz.com"));
    $form['bluez_settings']['social']['facebook'] = array('#type' => 'textfield', '#title' => t('Facebook URL'), '#default_value' => theme_get_setting('facebook', 'bluez8'), '#description' => t("Enter your Facebook Profile URL. example:: http://www.xyz.com"));
    $form['bluez_settings']['social']['linkedin'] = array('#type' => 'textfield', '#title' => t('LinkedIn URL'), '#default_value' => theme_get_setting('linkedin', 'bluez8'), '#description' => t("Enter your LinkedIn Profile URL. example:: http://www.xyz.com"));
    $form['bluez_settings']['Welcome'] = array('#type' => 'fieldset', '#title' => t('Welcome Text'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['bluez_settings']['Welcome']['welcome_title'] = array('#type' => 'textfield', '#title' => t('Add Title'), '#default_value' => theme_get_setting('welcome_title', 'bluez8'), '#description' => t("Enter Title for Welcome text at frontpage."));
    $form['bluez_settings']['Welcome']['welcome_text'] = array('#type' => 'textarea', '#title' => t('Add Description'), '#default_value' => theme_get_setting('welcome_text', 'bluez8'), '#description' => t("Enter Description for Welcome text at frontpage."));
    $form['bluez_settings']['Columns'] = array('#type' => 'fieldset', '#title' => t('Columns'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['bluez_settings']['Columns']['columns_markup'] = array('#markup' => t('Default Promoted Area Images are placed at <b>bluez/images/promoted</b>, User will able to change these images path or image name from column\'s description settings.</br><code>Example : &lt;img src="sites/all/themes/bluez/images/promoted/col1.jpg"&gt;</code></br><b>Image Dimensions :</b></br>For 1 Column = Max Width will be 960px</br>For 2 Column = Max Width will be 467px</br>For 3 Column = Max Width will be 306px</br></br>To keep image on top of the conent use below pattern,<code>&lt;div class="image_wrapper"&gt;&lt;img src="sites/all/themes/bluez/images/promoted/col1.jpg"&gt;&lt;/div&gt;"</code>If IMG is not inside the DIV mentioned above, image and content will be inline.'));
    $form['bluez_settings']['Columns']['colonetitle'] = array('#type' => 'textfield', '#title' => t('First Column Title'), '#default_value' => theme_get_setting('colonetitle', 'bluez8'), '#description' => t("Enter Title for First Column."));
    $form['bluez_settings']['Columns']['colone'] = array('#type' => 'textarea', '#title' => t('First Column Description'), '#default_value' => theme_get_setting('colone', 'bluez8'), '#description' => t("Enter Description for First Column."));
    $form['bluez_settings']['Columns']['coltwotitle'] = array('#type' => 'textfield', '#title' => t('Second Column Title'), '#default_value' => theme_get_setting('coltwotitle', 'bluez8'), '#description' => t("Enter Title for Second Column."));
    $form['bluez_settings']['Columns']['coltwo'] = array('#type' => 'textarea', '#title' => t('Second Column Description'), '#default_value' => theme_get_setting('coltwo', 'bluez8'), '#description' => t("Enter Description for Second Column."));
    $form['bluez_settings']['Columns']['colthreetitle'] = array('#type' => 'textfield', '#title' => t('Third Column Title'), '#default_value' => theme_get_setting('colthreetitle', 'bluez8'), '#description' => t("Enter Title for Third Column."));
    $form['bluez_settings']['Columns']['colthree'] = array('#type' => 'textarea', '#title' => t('Third Column Description'), '#default_value' => theme_get_setting('colthree', 'bluez8'), '#description' => t("Enter Description for Third Column."));
    $form['bluez_settings']['footer'] = array('#type' => 'fieldset', '#title' => t('Footer'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['bluez_settings']['footer']['footer_copyright'] = array('#type' => 'checkbox', '#title' => t('Show copyright text in footer'), '#default_value' => theme_get_setting('footer_copyright', 'bluez8'), '#description' => t("Check this option to show copyright text in footer. Uncheck to hide."));
    $form['bluez_settings']['footer']['footer_developed'] = array('#type' => 'checkbox', '#title' => t('Show theme developed by in footer'), '#default_value' => theme_get_setting('footer_developed', 'bluez8'), '#description' => t("Check this option to show design & developed by text in footer. Uncheck to hide."));
    $form['bluez_settings']['footer']['footer_developedby'] = array('#type' => 'textfield', '#title' => t('Add name developed by in footer'), '#default_value' => theme_get_setting('footer_developedby', 'bluez8'), '#description' => t("Add name developed by in footer"));
    $form['bluez_settings']['footer']['footer_developedby_url'] = array('#type' => 'textfield', '#title' => t('Add link to developed by in footer'), '#default_value' => theme_get_setting('footer_developedby_url', 'bluez8'), '#description' => t("Add url developed by in footer. example:: http://www.xyz.com"));
    $form['bluez_settings']['menu'] = array('#type' => 'fieldset', '#title' => t('Menu'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['bluez_settings']['menu']['menu_name'] = array('#type' => 'select', '#title' => t('Menu list'), '#options' => menu_ui_get_menus(), '#default_value' => theme_get_setting('menu_name', 'bluez8'), '#description' => t('select the menu to display'));
}
/**
 * Implements hook_form_FORM_ID_alter().
 *
 * @param $form
 *   The form.
 * @param $form_state
 *   The form state.
 */
function corkedscrewer_form_system_theme_settings_alter(&$form, &$form_state)
{
    $form['mtt_settings'] = array('#type' => 'fieldset', '#title' => t('Corked Screwer Theme Settings'), '#collapsible' => FALSE, '#collapsed' => FALSE);
    $form['mtt_settings']['highlighted'] = array('#type' => 'fieldset', '#title' => t('Featured Content'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['mtt_settings']['highlighted']['highlighted_display'] = array('#type' => 'checkbox', '#title' => t('Show featured content'), '#description' => t('Use the checkbox to enable or disable featured content.'), '#default_value' => theme_get_setting('highlighted_display', 'corkedscrewer'));
    $form['mtt_settings']['breadcrumb'] = array('#type' => 'fieldset', '#title' => t('Breadcrumb'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['mtt_settings']['breadcrumb']['breadcrumb_display'] = array('#type' => 'checkbox', '#title' => t('Show breadcrumb'), '#description' => t('Use the checkbox to enable or disable breadcrumb.'), '#default_value' => theme_get_setting('breadcrumb_display', 'corkedscrewer'));
    $form['mtt_settings']['breadcrumb']['breadcrumb_separator'] = array('#type' => 'textfield', '#title' => t('Breadcrumb separator'), '#default_value' => theme_get_setting('breadcrumb_separator', 'corkedscrewer'), '#size' => 5, '#maxlength' => 10);
    $form['mtt_settings']['slideshow'] = array('#type' => 'fieldset', '#title' => t('Front Page Slideshow'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['mtt_settings']['slideshow']['slideshow_display'] = array('#type' => 'checkbox', '#title' => t('Show slideshow'), '#default_value' => theme_get_setting('slideshow_display', 'corkedscrewer'));
    $form['mtt_settings']['slideshow']['slideshow_js'] = array('#type' => 'checkbox', '#title' => t('Include slideshow javascript code'), '#default_value' => theme_get_setting('slideshow_js', 'corkedscrewer'));
    $form['mtt_settings']['slideshow']['slideshow_effect'] = array('#type' => 'select', '#title' => t('Effects'), '#description' => t('From the drop-down menu, select the slideshow effect you prefer.'), '#default_value' => theme_get_setting('slideshow_effect', 'corkedscrewer'), '#options' => array('blindX' => t('blindX'), 'blindY' => t('blindY'), 'blindZ' => t('blindZ'), 'cover' => t('cover'), 'curtainX' => t('curtainX'), 'curtainY' => t('curtainY'), 'fade' => t('fade'), 'fadeZoom' => t('fadeZoom'), 'growX' => t('growX'), 'growY' => t('growY'), 'scrollUp' => t('scrollUp'), 'scrollDown' => t('scrollDown'), 'scrollLeft' => t('scrollLeft'), 'scrollRight' => t('scrollRight'), 'scrollHorz' => t('scrollHorz'), 'scrollVert' => t('scrollVert'), 'shuffle' => t('shuffle'), 'slideX' => t('slideX'), 'slideY' => t('slideY'), 'toss' => t('toss'), 'turnUp' => t('turnUp'), 'turnDown' => t('turnDown'), 'turnLeft' => t('turnLeft'), 'turnRight' => t('turnRight'), 'uncover' => t('uncover'), 'wipe' => t('wipe'), 'zoom' => t('zoom')));
    $form['mtt_settings']['slideshow']['slideshow_effect_time'] = array('#type' => 'textfield', '#title' => t('Effect duration (sec)'), '#default_value' => theme_get_setting('slideshow_effect_time', 'corkedscrewer'));
    $form['mtt_settings']['slideshow']['slideshow_randomize'] = array('#type' => 'checkbox', '#title' => t('Randomize slideshow order'), '#default_value' => theme_get_setting('slideshow_randomize', 'corkedscrewer'));
    $form['mtt_settings']['slideshow']['slideshow_wrap'] = array('#type' => 'checkbox', '#title' => t('Prevent slideshow from wrapping'), '#default_value' => theme_get_setting('slideshow_wrap', 'corkedscrewer'));
    $form['mtt_settings']['slideshow']['slideshow_pause'] = array('#type' => 'checkbox', '#title' => t('Pause slideshow on hover'), '#default_value' => theme_get_setting('slideshow_pause', 'corkedscrewer'));
    $form['mtt_settings']['menu'] = array('#type' => 'fieldset', '#title' => t('Menu section'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['mtt_settings']['menu']['menu_name'] = array('#type' => 'select', '#title' => t('Menu list'), '#options' => menu_ui_get_menus(), '#default_value' => theme_get_setting('menu_name', 'corkedscrewer'), '#description' => t('select the menu to display'));
    $form['mtt_settings']['support']['responsive'] = array('#type' => 'fieldset', '#title' => t('Responsive'), '#collapsible' => TRUE, '#collapsed' => FALSE);
    $form['mtt_settings']['support']['responsive']['responsive_meta'] = array('#type' => 'checkbox', '#title' => t('Add meta tags to support responsive design on mobile devices.'), '#default_value' => theme_get_setting('responsive_meta', 'corkedscrewer'));
    $form['mtt_settings']['support']['responsive']['responsive_respond'] = array('#type' => 'checkbox', '#title' => t('Add Respond.js JavaScript to add basic CSS3 media query support to IE 6-8.'), '#default_value' => theme_get_setting('responsive_respond', 'corkedscrewer'), '#description' => t('IE 6-8 require a JavaScript polyfill solution to add basic support of CSS3 media queries. Note that you should enable <strong>Aggregate and compress CSS files</strong> through <em>/admin/config/development/performance</em>.'));
}
示例#9
0
 /**
  * Deletes custom generated menus
  */
 protected function deleteMenus()
 {
     if (\Drupal::moduleHandler()->moduleExists('menu_ui')) {
         foreach (menu_ui_get_menus(FALSE) as $menu => $menu_title) {
             if (strpos($menu, 'devel-') === 0) {
                 Menu::load($menu)->delete();
             }
         }
     }
     // Delete menu links generated by devel.
     $result = db_select('menu_links', 'm')->fields('m', array('mlid'))->condition('m.menu_name', 'devel', '<>')->condition('m.options', '%' . db_like('s:5:"devel";b:1') . '%', 'LIKE')->execute();
     foreach ($result as $link) {
         menu_link_delete($link->mlid);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $style_options = Views::fetchPluginNames('style', 'normal', array($this->base_table));
     $feed_row_options = Views::fetchPluginNames('row', 'feed', array($this->base_table));
     $path_prefix = $this->url('<none>', [], ['absolute' => TRUE]);
     // Add filters and sorts which apply to the view as a whole.
     $this->buildFilters($form, $form_state);
     $this->buildSorts($form, $form_state);
     $form['displays']['page'] = array('#type' => 'fieldset', '#title' => $this->t('Page settings'), '#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend')), '#tree' => TRUE);
     $form['displays']['page']['create'] = array('#title' => $this->t('Create a page'), '#type' => 'checkbox', '#attributes' => array('class' => array('strong')), '#default_value' => FALSE, '#id' => 'edit-page-create');
     // All options for the page display are included in this container so they
     // can be hidden as a group when the "Create a page" checkbox is unchecked.
     $form['displays']['page']['options'] = array('#type' => 'container', '#attributes' => array('class' => array('options-set')), '#states' => array('visible' => array(':input[name="page[create]"]' => array('checked' => TRUE))), '#prefix' => '<div><div id="edit-page-wrapper">', '#suffix' => '</div></div>', '#parents' => array('page'));
     $form['displays']['page']['options']['title'] = array('#title' => $this->t('Page title'), '#type' => 'textfield', '#maxlength' => 255);
     $form['displays']['page']['options']['path'] = array('#title' => $this->t('Path'), '#type' => 'textfield', '#field_prefix' => $path_prefix, '#maxlength' => 254);
     $form['displays']['page']['options']['style'] = array('#type' => 'fieldset', '#title' => $this->t('Page display settings'), '#attributes' => array('class' => array('container-inline', 'fieldset-no-legend')));
     // Create the dropdown for choosing the display format.
     $form['displays']['page']['options']['style']['style_plugin'] = array('#title' => $this->t('Display format'), '#type' => 'select', '#options' => $style_options);
     $style_form =& $form['displays']['page']['options']['style'];
     $style_form['style_plugin']['#default_value'] = static::getSelected($form_state, array('page', 'style', 'style_plugin'), 'default', $style_form['style_plugin']);
     // Changing this dropdown updates $form['displays']['page']['options'] via
     // AJAX.
     views_ui_add_ajax_trigger($style_form, 'style_plugin', array('displays', 'page', 'options'));
     $this->buildFormStyle($form, $form_state, 'page');
     $form['displays']['page']['options']['items_per_page'] = array('#title' => $this->t('Items to display'), '#type' => 'number', '#default_value' => 10, '#min' => 0);
     $form['displays']['page']['options']['pager'] = array('#title' => $this->t('Use a pager'), '#type' => 'checkbox', '#default_value' => TRUE);
     $form['displays']['page']['options']['link'] = array('#title' => $this->t('Create a menu link'), '#type' => 'checkbox', '#id' => 'edit-page-link');
     $form['displays']['page']['options']['link_properties'] = array('#type' => 'container', '#states' => array('visible' => array(':input[name="page[link]"]' => array('checked' => TRUE))), '#prefix' => '<div id="edit-page-link-properties-wrapper">', '#suffix' => '</div>');
     if (\Drupal::moduleHandler()->moduleExists('menu_ui')) {
         $menu_options = menu_ui_get_menus();
     } else {
         // These are not yet translated.
         $menu_options = menu_list_system_menus();
         foreach ($menu_options as $name => $title) {
             $menu_options[$name] = $this->t($title);
         }
     }
     $form['displays']['page']['options']['link_properties']['menu_name'] = array('#title' => $this->t('Menu'), '#type' => 'select', '#options' => $menu_options);
     $form['displays']['page']['options']['link_properties']['title'] = array('#title' => $this->t('Link text'), '#type' => 'textfield');
     // Only offer a feed if we have at least one available feed row style.
     if ($feed_row_options) {
         $form['displays']['page']['options']['feed'] = array('#title' => $this->t('Include an RSS feed'), '#type' => 'checkbox', '#id' => 'edit-page-feed');
         $form['displays']['page']['options']['feed_properties'] = array('#type' => 'container', '#states' => array('visible' => array(':input[name="page[feed]"]' => array('checked' => TRUE))), '#prefix' => '<div id="edit-page-feed-properties-wrapper">', '#suffix' => '</div>');
         $form['displays']['page']['options']['feed_properties']['path'] = array('#title' => $this->t('Feed path'), '#type' => 'textfield', '#field_prefix' => $path_prefix, '#maxlength' => 254);
         // This will almost never be visible.
         $form['displays']['page']['options']['feed_properties']['row_plugin'] = array('#title' => $this->t('Feed row style'), '#type' => 'select', '#options' => $feed_row_options, '#default_value' => key($feed_row_options), '#access' => count($feed_row_options) > 1, '#states' => array('visible' => array(':input[name="page[feed]"]' => array('checked' => TRUE))), '#prefix' => '<div id="edit-page-feed-properties-row-plugin-wrapper">', '#suffix' => '</div>');
     }
     // Only offer the block settings if the module is enabled.
     if (\Drupal::moduleHandler()->moduleExists('block')) {
         $form['displays']['block'] = array('#type' => 'fieldset', '#title' => $this->t('Block settings'), '#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend')), '#tree' => TRUE);
         $form['displays']['block']['create'] = array('#title' => $this->t('Create a block'), '#type' => 'checkbox', '#attributes' => array('class' => array('strong')), '#id' => 'edit-block-create');
         // All options for the block display are included in this container so
         // they can be hidden as a group when the "Create a block" checkbox is
         // unchecked.
         $form['displays']['block']['options'] = array('#type' => 'container', '#attributes' => array('class' => array('options-set')), '#states' => array('visible' => array(':input[name="block[create]"]' => array('checked' => TRUE))), '#prefix' => '<div id="edit-block-wrapper">', '#suffix' => '</div>', '#parents' => array('block'));
         $form['displays']['block']['options']['title'] = array('#title' => $this->t('Block title'), '#type' => 'textfield', '#maxlength' => 255);
         $form['displays']['block']['options']['style'] = array('#type' => 'fieldset', '#title' => $this->t('Block display settings'), '#attributes' => array('class' => array('container-inline', 'fieldset-no-legend')));
         // Create the dropdown for choosing the display format.
         $form['displays']['block']['options']['style']['style_plugin'] = array('#title' => $this->t('Display format'), '#type' => 'select', '#options' => $style_options);
         $style_form =& $form['displays']['block']['options']['style'];
         $style_form['style_plugin']['#default_value'] = static::getSelected($form_state, array('block', 'style', 'style_plugin'), 'default', $style_form['style_plugin']);
         // Changing this dropdown updates $form['displays']['block']['options']
         // via AJAX.
         views_ui_add_ajax_trigger($style_form, 'style_plugin', array('displays', 'block', 'options'));
         $this->buildFormStyle($form, $form_state, 'block');
         $form['displays']['block']['options']['items_per_page'] = array('#title' => $this->t('Items per block'), '#type' => 'number', '#default_value' => 5, '#min' => 0);
         $form['displays']['block']['options']['pager'] = array('#title' => $this->t('Use a pager'), '#type' => 'checkbox', '#default_value' => FALSE);
     }
     // Only offer the REST export settings if the module is enabled.
     if (\Drupal::moduleHandler()->moduleExists('rest')) {
         $form['displays']['rest_export'] = array('#type' => 'fieldset', '#title' => $this->t('REST export settings'), '#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend')), '#tree' => TRUE);
         $form['displays']['rest_export']['create'] = array('#title' => $this->t('Provide a REST export'), '#type' => 'checkbox', '#attributes' => array('class' => array('strong')), '#id' => 'edit-rest-export-create');
         // All options for the REST export display are included in this container
         // so they can be hidden as a group when the "Provide a REST export"
         // checkbox is unchecked.
         $form['displays']['rest_export']['options'] = array('#type' => 'container', '#attributes' => array('class' => array('options-set')), '#states' => array('visible' => array(':input[name="rest_export[create]"]' => array('checked' => TRUE))), '#prefix' => '<div id="edit-rest-export-wrapper">', '#suffix' => '</div>', '#parents' => array('rest_export'));
         $form['displays']['rest_export']['options']['path'] = array('#title' => $this->t('REST export path'), '#type' => 'textfield', '#field_prefix' => $path_prefix, '#maxlength' => 254);
     }
     return $form;
 }
示例#11
0
 /**
  * Overrides EntityForm::form().
  */
 public function form(array $form, array &$form_state)
 {
     $menu_link = $this->entity;
     // Since menu_link_load() no longer returns a translated and access checked
     // item, do it here instead.
     _menu_link_translate($menu_link);
     $form['link_title'] = array('#type' => 'textfield', '#title' => t('Menu link title'), '#default_value' => $menu_link->link_title, '#description' => t('The text to be used for this link in the menu.'), '#required' => TRUE);
     foreach (array('link_path', 'mlid', 'module', 'has_children', 'options') as $key) {
         $form[$key] = array('#type' => 'value', '#value' => $menu_link->{$key});
     }
     // Any item created or edited via this interface is considered "customized".
     $form['customized'] = array('#type' => 'value', '#value' => 1);
     // We are not using url() when constructing this path because it would add
     // $base_path.
     $path = $menu_link->link_path;
     if (isset($menu_link->options['query'])) {
         $path .= '?' . $this->urlGenerator->httpBuildQuery($menu_link->options['query']);
     }
     if (isset($menu_link->options['fragment'])) {
         $path .= '#' . $menu_link->options['fragment'];
     }
     if ($menu_link->module == 'menu_ui') {
         $form['link_path'] = array('#type' => 'textfield', '#title' => t('Path'), '#maxlength' => 255, '#default_value' => $path, '#description' => t('The path for this menu link. This can be an internal Drupal path such as %add-node or an external URL such as %drupal. Enter %front to link to the front page.', array('%front' => '<front>', '%add-node' => 'node/add', '%drupal' => 'http://drupal.org')), '#required' => TRUE);
     } else {
         $form['_path'] = array('#type' => 'item', '#title' => t('Path'), '#description' => l($menu_link->link_title, $menu_link->href, $menu_link->options));
     }
     $form['description'] = array('#type' => 'textarea', '#title' => t('Description'), '#default_value' => isset($menu_link->options['attributes']['title']) ? $menu_link->options['attributes']['title'] : '', '#rows' => 1, '#description' => t('Shown when hovering over the menu link.'));
     $form['enabled'] = array('#type' => 'checkbox', '#title' => t('Enabled'), '#default_value' => !$menu_link->hidden, '#description' => t('Menu links that are not enabled will not be listed in any menu.'));
     $form['expanded'] = array('#type' => 'checkbox', '#title' => t('Show as expanded'), '#default_value' => $menu_link->expanded, '#description' => t('If selected and this menu link has children, the menu will always appear expanded.'));
     // Generate a list of possible parents (not including this link or descendants).
     $options = menu_ui_parent_options(menu_ui_get_menus(), $menu_link);
     $default = $menu_link->menu_name . ':' . $menu_link->plid;
     if (!isset($options[$default])) {
         $default = 'tools:0';
     }
     $form['parent'] = array('#type' => 'select', '#title' => t('Parent link'), '#default_value' => $default, '#options' => $options, '#description' => t('The maximum depth for a link and all its children is fixed at !maxdepth. Some menu links may not be available as parents if selecting them would exceed this limit.', array('!maxdepth' => MENU_MAX_DEPTH)), '#attributes' => array('class' => array('menu-title-select')));
     // Get number of items in menu so the weight selector is sized appropriately.
     $delta = $this->menuLinkStorage->countMenuLinks($menu_link->menu_name);
     $form['weight'] = array('#type' => 'weight', '#title' => t('Weight'), '#delta' => max($delta, 50), '#default_value' => $menu_link->weight, '#description' => t('Optional. In the menu, the heavier links will sink and the lighter links will be positioned nearer the top.'));
     // Language module allows to configure the menu link language independently
     // of the menu language. It also allows to optionally show the language
     // selector on the menu link form so that the language of each menu link can
     // be configured individually.
     if ($this->moduleHandler->moduleExists('language')) {
         $language_configuration = language_get_default_configuration('menu_link', $menu_link->bundle());
         $default_langcode = $menu_link->isNew() ? $language_configuration['langcode'] : $menu_link->langcode;
         $language_show = $language_configuration['language_show'];
     } else {
         $default_langcode = $menu_link->isNew() ? entity_load('menu', $menu_link->menu_name)->language()->getId() : $menu_link->langcode;
         $language_show = FALSE;
     }
     $form['langcode'] = array('#type' => 'language_select', '#title' => t('Language'), '#languages' => LanguageInterface::STATE_ALL, '#default_value' => $default_langcode, '#access' => $language_show);
     return parent::form($form, $form_state, $menu_link);
 }
示例#12
0
 /**
  * Deletes custom generated menus.
  */
 protected function deleteMenus()
 {
     if ($this->moduleHandler->moduleExists('menu_ui')) {
         $menu_ids = array();
         foreach (menu_ui_get_menus(FALSE) as $menu => $menu_title) {
             if (strpos($menu, 'devel-') === 0) {
                 $menu_ids[] = $menu;
             }
         }
         if ($menu_ids) {
             $menus = $this->menuStorage->loadMultiple($menu_ids);
             $this->menuStorage->delete($menus);
         }
     }
     // Delete menu links generated by devel.
     $link_ids = $this->menuLinkContentStorage->getQuery()->condition('menu_name', 'devel', '<>')->condition('link__options', '%' . db_like('s:5:"devel";b:1') . '%', 'LIKE')->execute();
     if ($link_ids) {
         $links = $this->menuLinkContentStorage->loadMultiple($link_ids);
         $this->menuLinkContentStorage->delete($links);
     }
 }
 /**
  * Deletes custom generated menus
  */
 protected function deleteMenus()
 {
     if (\Drupal::moduleHandler()->moduleExists('menu_ui')) {
         foreach (menu_ui_get_menus(FALSE) as $menu => $menu_title) {
             if (strpos($menu, 'devel-') === 0) {
                 Menu::load($menu)->delete();
             }
         }
     }
     // Delete menu links generated by devel.
     $result = db_select('menu_link_content_data', 'm')->fields('m', array('id'))->condition('m.menu_name', 'devel', '<>')->condition('m.link__options', '%' . db_like('s:5:"devel";b:1') . '%', 'LIKE')->execute()->fetchCol();
     if ($result) {
         entity_delete_multiple('menu_link_content', $result);
     }
 }
示例#14
0
 /**
  * Overrides \Drupal\views\Plugin\views\display\callbackPluginBase::buildOptionsForm().
  */
 public function buildOptionsForm(&$form, &$form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     switch ($form_state['section']) {
         case 'menu':
             $form['#title'] .= t('Menu item entry');
             $form['menu'] = array('#prefix' => '<div class="clearfix">', '#suffix' => '</div>', '#tree' => TRUE);
             $menu = $this->getOption('menu');
             if (empty($menu)) {
                 $menu = array('type' => 'none', 'title' => '', 'weight' => 0);
             }
             $form['menu']['type'] = array('#prefix' => '<div class="views-left-30">', '#suffix' => '</div>', '#title' => t('Type'), '#type' => 'radios', '#options' => array('none' => t('No menu entry'), 'normal' => t('Normal menu entry'), 'tab' => t('Menu tab'), 'default tab' => t('Default menu tab')), '#default_value' => $menu['type']);
             $form['menu']['title'] = array('#prefix' => '<div class="views-left-50">', '#title' => t('Menu link title'), '#type' => 'textfield', '#default_value' => $menu['title'], '#states' => array('visible' => array(array(':input[name="menu[type]"]' => array('value' => 'normal')), array(':input[name="menu[type]"]' => array('value' => 'tab')), array(':input[name="menu[type]"]' => array('value' => 'default tab')))));
             $form['menu']['description'] = array('#title' => t('Description'), '#type' => 'textfield', '#default_value' => $menu['description'], '#description' => t("Shown when hovering over the menu link."), '#states' => array('visible' => array(array(':input[name="menu[type]"]' => array('value' => 'normal')), array(':input[name="menu[type]"]' => array('value' => 'tab')), array(':input[name="menu[type]"]' => array('value' => 'default tab')))));
             // Only display the menu selector if Menu UI module is enabled.
             if (\Drupal::moduleHandler()->moduleExists('menu_ui')) {
                 $form['menu']['name'] = array('#title' => t('Menu'), '#type' => 'select', '#options' => menu_ui_get_menus(), '#default_value' => $menu['name'], '#states' => array('visible' => array(array(':input[name="menu[type]"]' => array('value' => 'normal')), array(':input[name="menu[type]"]' => array('value' => 'tab')))));
             } else {
                 $form['menu']['name'] = array('#type' => 'value', '#value' => $menu['name']);
                 $form['menu']['markup'] = array('#markup' => t('Menu selection requires the activation of Menu UI module.'));
             }
             $form['menu']['weight'] = array('#title' => t('Weight'), '#type' => 'textfield', '#default_value' => isset($menu['weight']) ? $menu['weight'] : 0, '#description' => t('In the menu, the heavier links will sink and the lighter links will be positioned nearer the top.'), '#states' => array('visible' => array(array(':input[name="menu[type]"]' => array('value' => 'normal')), array(':input[name="menu[type]"]' => array('value' => 'tab')), array(':input[name="menu[type]"]' => array('value' => 'default tab')))));
             $form['menu']['context'] = array('#title' => t('Context'), '#suffix' => '</div>', '#type' => 'checkbox', '#default_value' => !empty($menu['context']), '#description' => t('Displays the link in contextual links'), '#states' => array('visible' => array(':input[name="menu[type]"]' => array('value' => 'tab'))));
             break;
         case 'tab_options':
             $form['#title'] .= t('Default tab options');
             $tab_options = $this->getOption('tab_options');
             if (empty($tab_options)) {
                 $tab_options = array('type' => 'none', 'title' => '', 'weight' => 0);
             }
             $form['tab_markup'] = array('#markup' => '<div class="form-item description">' . t('When providing a menu item as a tab, Drupal needs to know what the parent menu item of that tab will be. Sometimes the parent will already exist, but other times you will need to have one created. The path of a parent item will always be the same path with the last part left off. i.e, if the path to this view is <em>foo/bar/baz</em>, the parent path would be <em>foo/bar</em>.') . '</div>');
             $form['tab_options'] = array('#prefix' => '<div class="clearfix">', '#suffix' => '</div>', '#tree' => TRUE);
             $form['tab_options']['type'] = array('#prefix' => '<div class="views-left-25">', '#suffix' => '</div>', '#title' => t('Parent menu item'), '#type' => 'radios', '#options' => array('none' => t('Already exists'), 'normal' => t('Normal menu item'), 'tab' => t('Menu tab')), '#default_value' => $tab_options['type']);
             $form['tab_options']['title'] = array('#prefix' => '<div class="views-left-75">', '#title' => t('Title'), '#type' => 'textfield', '#default_value' => $tab_options['title'], '#description' => t('If creating a parent menu item, enter the title of the item.'), '#states' => array('visible' => array(array(':input[name="tab_options[type]"]' => array('value' => 'normal')), array(':input[name="tab_options[type]"]' => array('value' => 'tab')))));
             $form['tab_options']['description'] = array('#title' => t('Description'), '#type' => 'textfield', '#default_value' => $tab_options['description'], '#description' => t('If creating a parent menu item, enter the description of the item.'), '#states' => array('visible' => array(array(':input[name="tab_options[type]"]' => array('value' => 'normal')), array(':input[name="tab_options[type]"]' => array('value' => 'tab')))));
             // Only display the menu selector if Menu UI module is enabled.
             if (\Drupal::moduleHandler()->moduleExists('menu_ui')) {
                 $form['tab_options']['name'] = array('#title' => t('Menu'), '#type' => 'select', '#options' => menu_ui_get_menus(), '#default_value' => $tab_options['name'], '#description' => t('Insert item into an available menu.'), '#states' => array('visible' => array(':input[name="tab_options[type]"]' => array('value' => 'normal'))));
             } else {
                 $form['tab_options']['name'] = array('#type' => 'value', '#value' => $tab_options['name']);
                 $form['tab_options']['markup'] = array('#markup' => t('Menu selection requires the activation of Menu UI module.'));
             }
             $form['tab_options']['weight'] = array('#suffix' => '</div>', '#title' => t('Tab weight'), '#type' => 'textfield', '#default_value' => $tab_options['weight'], '#size' => 5, '#description' => t('If the parent menu item is a tab, enter the weight of the tab. Heavier tabs will sink and the lighter tabs will be positioned nearer to the first menu item.'), '#states' => array('visible' => array(':input[name="tab_options[type]"]' => array('value' => 'tab'))));
             break;
     }
 }
 /**
  * Returns an array of existing menus on site.
  *
  * @return array
  */
 protected function getExistingMenus()
 {
     return menu_ui_get_menus();
 }