You are here

class space_customizer_views in Spaces 6

Same name and namespace in other branches
  1. 5.2 spaces.module \space_customizer_views

Customizer for views titles and headers.

Hierarchy

Expanded class hierarchy of space_customizer_views

File

./spaces.module, line 647

View source
class space_customizer_views implements space_customizer {
  var $name = 'Views';
  function form($space, $feature) {
    $features = spaces_features();
    $f = $features[$feature];
    $form = array();
    if (isset($f->views) && is_array($f->views)) {
      foreach ($f->views as $view_name) {
        $view = views_get_view($view_name);
        $view = $this
          ->customize($space, $feature, $view);

        // Only allow customization of page views for now
        // @TODO: add input format checking on headers/footers/etc.
        if ($view && $view->page == TRUE) {
          $form[$view_name] = array(
            '#title' => $view_name,
            '#type' => 'fieldset',
            '#tree' => TRUE,
          );

          // $default_page_title = isset($customizer['views'][$view_name]['page_title']) ? $customizer['views'][$view_name]['page_title'] : $view->page_title;
          $form[$view_name]['page_title'] = array(
            '#title' => t('Page title'),
            '#type' => 'textfield',
            '#size' => 40,
            '#default_value' => $view->page_title,
          );

          // $default_page_header = isset($customizer['views'][$view_name]['page_header']) ? $customizer['views'][$view_name]['page_header'] : $view->page_header;
          $form[$view_name]['page_header'] = array(
            '#title' => t('Page header'),
            '#type' => 'textarea',
            '#rows' => 2,
            '#cols' => 40,
            '#default_value' => $view->page_header,
          );
        }
      }
    }
    return $form;
  }
  function validate($space, $feature, $value) {
    return;
  }
  function submit($space, $feature, $value) {

    // Would like to prune unset values, but it appears that views
    // caching makes it unusable...
    return $value;
  }
  function customize($space, $feature, &$view = NULL) {
    if (isset($space->customizer[$feature]['views'][$view->name])) {

      // Apply customizations to the view object
      $customizer = $space->customizer[$feature]['views'][$view->name];
      foreach ($customizer as $property => $value) {
        $view->{$property} = $value;
      }
    }
    return $view;
  }

}

Members