Commit c67a064e authored by Colan Schwartz's avatar Colan Schwartz
Browse files

Revert "Issue #1529708 by imperial_dalek, torpy, janekD7, helmo: Allow...

Revert "Issue #1529708 by imperial_dalek, torpy, janekD7, helmo: Allow ordering of site map content"

This reverts commit 7124eb73.
Kicking this out until there's a working JS file accompanying it.
parent 8128f554
Loading
Loading
Loading
Loading
+35 −1
Original line number Diff line number Diff line
@@ -32,7 +32,41 @@
    </div>
  <?php endif; ?>

  <?php print $site_map; ?>
  <?php if($front_page): ?>
    <div class="site-map-front-page">
      <?php print $front_page; ?>
    </div>
  <?php endif; ?>

  <?php if($blogs): ?>
    <div class="site-map-blogs">
      <?php print $blogs; ?>
    </div>
  <?php endif; ?>

  <?php if($books): ?>
    <div class="site-map-books">
      <?php print $books; ?>
    </div>
  <?php endif; ?>

  <?php if($menus): ?>
    <div class="site-map-menus">
      <?php print $menus; ?>
    </div>
  <?php endif; ?>

  <?php if($faq): ?>
    <div class="site-map-faq">
      <?php print $faq; ?>
    </div>
  <?php endif; ?>

  <?php if($taxonomys): ?>
    <div class="site-map-taxonomys">
      <?php print $taxonomys; ?>
    </div>
  <?php endif; ?>

  <?php if($additional): ?>
    <div class="site-map-additional">
+2 −32
Original line number Diff line number Diff line
@@ -31,14 +31,12 @@ function site_map_admin_settings_form() {
    '#type' => 'fieldset',
    '#title' => t('Site map content'),
  );
  $site_map_ordering = array();
  $form['site_map_content']['site_map_show_front'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show front page'),
    '#default_value' => variable_get('site_map_show_front', 1),
    '#description' => t('When enabled, this option will include the front page in the site map.'),
  );
  $site_map_ordering['front'] = t('Front page');
  $form['site_map_content']['site_map_show_titles'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show titles'),
@@ -52,7 +50,6 @@ function site_map_admin_settings_form() {
      '#default_value' => variable_get('site_map_show_blogs', 1),
      '#description' => t('When enabled, this option will show the 10 most active blog authors.'),
    );
    $site_map_ordering['blogs'] = t('Active blog authors');
  }
  if (module_exists('book')) {
    $book_options = array();
@@ -72,13 +69,11 @@ function site_map_admin_settings_form() {
      '#default_value' => variable_get('site_map_books_expanded', 1),
      '#description' => t('When enabled, this option will show all children pages for each book.'),
    );
    $site_map_ordering['books'] = t('Books');
  }

  $menu_options = array();
  $menu_options = menu_get_menus();
  foreach ($menu_options as $menu_id => $menu_title) {
    $site_map_ordering['menus_' . $menu_id] = $menu_title;
  }

  $form['site_map_content']['site_map_show_menus'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Menus to include in the site map'),
@@ -100,13 +95,11 @@ function site_map_admin_settings_form() {
      '#default_value' => variable_get('site_map_show_faq', 0),
      '#description' => t('When enabled, this option will include the content from the FAQ module in the site map.'),
    );
    $site_map_ordering['faq'] = t('FAQ content');
  }
  $vocab_options = array();
  if (module_exists('taxonomy')) {
    foreach (taxonomy_get_vocabularies() as $vocabulary) {
      $vocab_options[$vocabulary->machine_name] = $vocabulary->name;
      $site_map_ordering['vocabularies_' . $vocabulary->machine_name] = $vocabulary->name;
    }
  }
  $form['site_map_content']['site_map_show_vocabularies'] = array(
@@ -116,29 +109,6 @@ function site_map_admin_settings_form() {
    '#options' => $vocab_options,
    '#multiple' => TRUE,
  );
  $form['site_map_content']['site_map_order'] = array(
    '#type' => 'item',
    '#title' => t('Site map order'),
    '#theme' => 'site_map_order',
  );
  $site_map_order_defaults = variable_get('site_map_order', array());
  foreach ($site_map_ordering as $content_id => $content_title) {
    $form['site_map_content']['site_map_order'][$content_id] = array(
      'content' => array(
        '#markup' => $content_title,
      ),
      'weight' => array(
        '#type' => 'weight',
        '#title' => t('Weight for @title', array('@title' => $content_title)),
        '#title_display' => 'invisible',
        '#delta' => 50,
        '#default_value' => isset($site_map_order_defaults[$content_id])? $site_map_order_defaults[$content_id] : -50,
        '#parents' => array('site_map_order', $content_id),
      ),
      '#weight' => isset($site_map_order_defaults[$content_id])? $site_map_order_defaults[$content_id] : -50,
    );
  }
  $form['#attached']['js'][] = drupal_get_path('module', 'site_map') . '/site_map.admin.js';

  $form['site_map_taxonomy_options'] = array(
    '#type' => 'fieldset',
+47 −44
Original line number Diff line number Diff line
@@ -64,10 +64,6 @@ function site_map_theme() {
      'variables' => array(),
      'file' => 'site_map.theme.inc',
    ),
    'site_map_order' => array(
      'render element' => 'element',
      'file' => 'site_map.theme.inc',
    ),
  );
}

@@ -469,12 +465,14 @@ function _site_map_books() {
 * @return string
 *   Returns HTML string of site map for menus.
 */
function _site_map_menus($mid) {
function _site_map_menus() {
  $output = '';
  $class = array();
  $options = array();
  $mids = array_filter(variable_get('site_map_show_menus', array()));

  if (!empty($mid)) {
  if (!empty($mids)) {
    foreach ($mids as $mid) {
      $class = array();
      $menu = menu_load($mid);
      // Use menu_tree_all_data to retrieve the expanded tree.
      $tree = menu_tree_all_data($mid);
@@ -508,6 +506,7 @@ function _site_map_menus($mid) {
        ));
      }
    }
  }

  return $output;
}
@@ -546,17 +545,21 @@ function _site_map_faq() {
 * @return string
 *   Returns HTML string of site map for taxonomies.
 */
function _site_map_taxonomys($voc) {
function _site_map_taxonomys() {
  $output = '';
  $options = array();
  $vnames = array_filter(variable_get('site_map_show_vocabularies', array()));

  if (module_exists('taxonomy') && !empty($voc)) {
  if (module_exists('taxonomy') && !empty($vnames)) {
    $result = db_query('SELECT vid, name, description FROM {taxonomy_vocabulary} WHERE machine_name IN (:vnames) ORDER BY weight ASC, name', array(':vnames' => $vnames));
    foreach ($result as $voc) {
      if (module_exists('i18n_taxonomy')) {
        $voc->name = i18n_taxonomy_vocabulary_name($voc, $GLOBALS['language']->language);
      }

      $output .= _site_map_taxonomy_tree($voc->vid, $voc->name, $voc->description);
    }
    _site_map_set_option($options, 'site_map_show_titles', 1, 1, 'show_titles', TRUE);

  }

  return $output;
+17 −82
Original line number Diff line number Diff line
@@ -185,61 +185,30 @@ function template_preprocess_site_map(&$variables) {
    $variables['rss_legend'] = theme('site_map_rss_legend');
  }

  if (variable_get('site_map_show_titles', 1)) {
    $variables['show_titles'] = TRUE;
  if (variable_get('site_map_show_front', 1)) {
    $variables['front_page'] = _site_map_front_page();
  }

  $variables['site_map'] = '';
  $site_map_order = variable_get('site_map_order', array());
  asort($site_map_order);

  foreach ($site_map_order as $content => $weight) {
    // Get type of content
    $type = substr($content, 0, strpos($content, '_'));
    $id = substr($content, strpos($content, '_') + 1);
    if (empty($type)) {
      $type = $content;
      $id = NULL;
  if (variable_get('site_map_show_titles', 1)) {
    $variables['show_titles'] = TRUE;
  }

    switch ($type) {
      case 'front':
        if (variable_get('site_map_show_front', 1)) {
          $variables['site_map'] .= _site_map_front_page();
        }
      break;
      case 'blogs':
  if (variable_get('site_map_show_blogs', 1)) {
          $variables['site_map'] .= _site_map_blogs();
        }
      break;
      case 'books':
        $books = variable_get('site_map_show_books', array());
        if (!empty($books)) {
          $variables['site_map'] .= _site_map_books();
    $variables['blogs'] = _site_map_blogs();
  }
      break;
      case 'menus':
        $menus = variable_get('site_map_show_menus', array());
        if (!empty($menus[$id])) {
          $variables['site_map'] .= _site_map_menus($id);
        }
      break;
      case 'faq':

  // Compile the books trees.
  $variables['books'] = _site_map_books();

  // Compile the menu trees.
  $variables['menus'] = _site_map_menus();

  if (variable_get('site_map_show_faq', 0)) {
          $variables['site_map'] .= _site_map_faq();
    $variables['faq'] = _site_map_faq();
  }
      break;
      case 'vocabularies':
        $vocabulary = taxonomy_vocabulary_machine_name_load($id);
        $vocabularies = variable_get('site_map_show_vocabularies', array());

        if (!empty($vocabularies[$vocabulary->machine_name])) {
          $variables['site_map'] .= _site_map_taxonomys($vocabulary);
        }
      break;
    }
  }
  // Compile the vocabulary trees.
  $variables['taxonomys'] = _site_map_taxonomys();

  // Invoke all custom modules and integrate themed HTML into the site map.
  $additional = module_invoke_all('site_map');
@@ -247,37 +216,3 @@ function template_preprocess_site_map(&$variables) {
    $variables['additional'] .= $themed_site_map_code;
  }
}

/**
 * Returns HTML for the site map order form.
 *
 * Copied from the core theme_filter_admin_format_filter_order() function.
 *
 * @param $variables
 *   An associative array containing:
 *   - element: A render element representing the form.
 *
 * @ingroup themeable
 */
function theme_site_map_order($variables) {
  $element = $variables['element'];

  // Site map order (tabledrag).
  $rows = array();
  foreach (element_children($element, TRUE) as $name) {
    $element[$name]['weight']['#attributes']['class'][] = 'site-map-order-weight';
    $rows[] = array(
      'data' => array(
        drupal_render($element[$name]['content']),
        drupal_render($element[$name]['weight']),
      ),
      'class' => array('draggable'),
    );
  }
  $output = drupal_render_children($element);
  $output .= theme('table', array('rows' => $rows, 'attributes' => array('id' => 'site-map-order')));
  drupal_add_tabledrag('site-map-order', 'order', 'sibling', 'site-map-order-weight', NULL, NULL, TRUE);

  return $output;
}