You are here

class space_taxonomy in Spaces 6.3

Same name and namespace in other branches
  1. 7.3 spaces_taxonomy/plugins/space_taxonomy.inc \space_taxonomy
  2. 7 spaces_taxonomy/plugins/space_taxonomy.inc \space_taxonomy

Taxonomy integration for Spaces.

Hierarchy

Expanded class hierarchy of space_taxonomy

2 string references to 'space_taxonomy'
spaces_taxonomy_spaces_plugins in spaces_taxonomy/spaces_taxonomy.module
Implementation of hook_spaces_plugins().
spaces_taxonomy_spaces_registry in spaces_taxonomy/spaces_taxonomy.module
Implementation of hook_spaces_registry().

File

spaces_taxonomy/plugins/space_taxonomy.inc, line 6

View source
class space_taxonomy extends space_type_purl {
  var $term = NULL;

  /**
   * Override of title().
   */
  function title() {
    return $this->term->name;
  }

  /**
   * Override of load().
   */
  function load() {

    // The 0 id means a new term is being saved. Instantiate a space
    // so preset values can become active.
    if ($this->id === 0) {
      return TRUE;
    }
    else {
      if ($this->term = taxonomy_get_term($this->id)) {
        return TRUE;
      }
    }
    return FALSE;
  }

  /**
   * Override of router().
   */
  function router($op, $object = NULL) {
    switch ($op) {
      case 'init':
        if (implode('/', array(
          arg(0),
          arg(1),
        )) === 'taxonomy/term' && arg(2)) {
          $terms = taxonomy_terms_parse_string(arg(2));
          if (!empty($terms['tids'])) {
            foreach ($terms['tids'] as $tid) {
              if ($term = taxonomy_get_term($tid)) {
                $this
                  ->router_term($term);
              }
            }
          }
        }
        break;
      case 'node':
        $node = $object;
        if (!empty($node->taxonomy)) {
          foreach ($node->taxonomy as $term) {
            if ($term->vid == variable_get('spaces_taxonomy_vid', 0)) {
              $this
                ->router_term($term);
            }
          }
        }
        break;
    }
    return;
  }

  /**
   * Router helper with logic for individual taxonomy terms.
   */
  protected function router_term($term) {
    if ($term->vid == variable_get('spaces_taxonomy_vid', 0)) {
      $space = spaces_load('taxonomy', $term->tid);

      // If there is no active taxonomy space or the spaces do not match, activate this term's space.
      if ($space && (!$this->active || $this->id != $space->id)) {
        $space
          ->activate();
      }
    }
  }

  /**
   * Override of views_filter().
   */
  function views_filter(&$query, $base_table = '', $relationship = '') {
    switch ($base_table) {
      case 'node':
        $table = $query
          ->ensure_table('term_node', $relationship);
        $query
          ->add_where(0, "{$table}.tid = %d", $this->id);
        break;
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
space::$active property
space::$controllers property
space::$id property
space::$type property
space::get_controllers protected function Instantiate controllers for this space.
space::init_overrides function Initialize any overrides as necessary.
space::__construct function Constructor.
space_taxonomy::$term property
space_taxonomy::load function Override of load(). Overrides space::load
space_taxonomy::router function Override of router(). Overrides space_type::router
space_taxonomy::router_term protected function Router helper with logic for individual taxonomy terms.
space_taxonomy::title function Override of title(). Overrides space_type::title
space_taxonomy::views_filter function Override of views_filter(). Overrides space_type::views_filter
space_type::access_admin function Grant a user administrative access to this space. 2
space_type::access_feature function Grant a user access to the specified feature in this space. 2
space_type::access_space function Grant a user access to anything in this space. This method can be used to deny access to any page where this space is active. 1
space_type::access_user function Grant a user access to the given account in this space. 1
space_type::feature_options function Get the possible feature setting values for this space.
space_type_purl::activate function Override of activate(). Ensure that the PURL modifier is present when the space is active. Overrides space::activate 1
space_type_purl::deactivate function Override of deactivate(). Ensure that the PURL modifier is not present when the space is not active. Overrides space::deactivate
space_type_purl::excluded_paths protected function Return an array of paths from which the space should never be active. 1
space_type_purl::purge_request_destination function Pull the destination out of the $_REQUEST to prevent a redirect directly to it within purl_goto. This function should be used immediately before a call to purl_goto.
space_type_purl::verify_purl protected function Verify that this space's PURL modifier is present for the current page request.