You are here

class space_customizer_menu in Spaces 6

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

Customizer for feature menus.

Hierarchy

Expanded class hierarchy of space_customizer_menu

File

./spaces.module, line 583

View source
class space_customizer_menu implements space_customizer {
  var $name = 'Menu';
  function form($space, $feature) {
    $features = spaces_features();
    $f = $features[$feature];
    $form = array();

    // Customize menus
    if (isset($f->spaces['menu']) && count($f->spaces['menu'])) {
      $feature_menu = array();

      // Get customized values
      $feature_menu = $f->spaces['menu'];
      $feature_menu = $this
        ->customize($space, $feature, $feature_menu);
      foreach ($feature_menu as $key => $item) {
        $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'],
        );
      }
    }
    return $form;
  }
  function validate($space, $feature, $value) {
    return;
  }
  function submit($space, $feature, $value) {
    $features = spaces_features();
    $feature_menu = $features[$feature]->spaces['menu'];
    foreach ($value as $path => $item) {
      if ($item == $feature_menu[$path]) {
        unset($value[$path]);
      }
    }
    return $value;
  }
  function customize($space, $feature, &$menu = NULL) {
    $customizer = array();
    foreach ($space->customizer as $c) {
      $customizer = array_merge($customizer, $c['menu']);
    }
    foreach ($menu as $k => $item) {
      if (isset($customizer[$item['href']])) {
        $menu[$k]['title'] = $customizer[$item['href']]['title'];
      }
    }
    return $menu;
  }

}

Members