You are here

class space_customizer_menu in Spaces 6.2

Same name and namespace in other branches
  1. 5.2 spaces.module \space_customizer_menu
  2. 6 spaces.module \space_customizer_menu

Customizer for feature menus.

Hierarchy

Expanded class hierarchy of space_customizer_menu

1 string reference to 'space_customizer_menu'
spaces_spaces_customizers in ./spaces.module
Implementation of hook_spaces_customizers().

File

./spaces.spaces.inc, line 63

View source
class space_customizer_menu implements space_customizer {
  var $name = 'Menu';
  function form($space, $feature) {
    $menu = spaces_features_items('menu', $feature);
    if (!empty($menu)) {
      $form = array();
      $menu_items = menu_navigation_links('features');
      $default_items = $menu_items;
      $this
        ->customize($space, $menu_items);
      foreach ($menu_items as $key => $item) {
        if (in_array($item['href'], $menu)) {
          $form[$item['href']] = array(
            '#title' => $item['href'],
            '#type' => 'fieldset',
            '#tree' => TRUE,
          );
          $form[$item['href']]['title'] = array(
            '#title' => t('Title'),
            '#type' => 'textfield',
            '#size' => 40,
            '#maxlength' => 255,
            '#default_value' => $item['title'],
          );
          $form[$item['href']]['default'] = array(
            '#type' => 'value',
            '#value' => $default_items[$key]['title'],
          );
        }
      }
    }
    return $form;
  }
  function validate($space, $feature, $value) {
    return;
  }
  function submit($space, $feature, $value) {
    $customizer = $space->customizer['menu'];
    foreach ($value as $path => $item) {
      if ($item['title'] == $item['default']) {
        unset($customizer[$path]);
      }
      else {
        if ($item['title'] != $item['default']) {
          $customizer[$path] = $item['title'];
        }
      }
    }
    return $customizer;
  }
  function customize($space, &$menu = NULL) {
    foreach ($menu as $k => $item) {
      if (!empty($space->customizer['menu'][$item['href']])) {
        $menu[$k]['title'] = $space->customizer['menu'][$item['href']];
      }
    }
  }

}

Members