You are here

class purl_pair in Persistent URL 6

Same name and namespace in other branches
  1. 7 includes/purl_pair.inc \purl_pair

Pair pair prefixer.

Hierarchy

Expanded class hierarchy of purl_pair

1 string reference to 'purl_pair'
purl_purl_processor in ./purl.module
Implementation of hook_purl_processor().

File

includes/purl_pair.inc, line 6

View source
class purl_pair extends purl_path {
  public function method() {
    return 'pair';
  }
  public function admin_form(&$form, $id) {

    // Note that while this form element's key includes the method ("pair"),
    // it will eventually save to the variable purl_method_[id]_key. See
    // element validator for how this occurs.
    $form[$id]['extra']["purl_method_pair_{$id}_key"] = array(
      // todo write update from path to pair
      '#title' => t('Key'),
      '#type' => 'textfield',
      '#size' => 12,
      '#default_value' => variable_get("purl_method_{$id}_key", ''),
      '#element_validate' => array(
        'purl_admin_form_key_validate',
      ),
      '#provider_id' => $id,
    );
  }
  public function parse($valid_values, $q) {
    $parsed = array();
    $args = explode('/', $q);
    $arg = $args[0];
    while (isset($valid_values[$arg])) {
      $parsed[$arg] = $valid_values[$arg];
      array_shift($args);
      $parsed[$arg]['id'] = array_shift($args);
      $arg = $args[0];
      if (in_array($arg, $parsed)) {
        break;
      }
    }
    return purl_path_elements($this, $parsed);
  }

  /**
   * Removes specific modifier pair from a query string.
   *
   * @param $q
   *   The current path.
   * @param $element
   *   a purl_path_element object
   * @return path string with the pair removed.
   */
  function remove($q, $element) {
    $args = explode('/', $q);
    array_splice($args, array_search($element->value, $args), 2);
    return implode('/', $args);
  }
  public function rewrite(&$path, &$options, $element) {
    if (!_purl_skip($element, $options)) {
      $items = explode('/', $path);
      array_unshift($items, "{$element->value}/{$element->id}");
      $path = implode('/', $items);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
purl_pair::admin_form public function Allow extension of the admin setup form. Overrides purl_path::admin_form
purl_pair::method public function Return the method the processor users. Overrides purl_path::method
purl_pair::parse public function Tear apart the path and iterate thought it looking for valid values. Overrides purl_path::parse
purl_pair::remove function Removes specific modifier pair from a query string. Overrides purl_path::remove
purl_pair::rewrite public function Just need to add the value to the front of the path. Overrides purl_path::rewrite
purl_path::adjust public function Rewrite the query string. Note that this is being passed through the custom_url_rewrite_inbound() stack and may *not* directly affect $_GET['q']. See purl_init() for how $_GET['q'] is affected by processors. Overrides purl_processor::adjust
purl_path::description public function Provide a description of processor for the end user Overrides purl_processor::description
purl_path::detect public function Detect a default value for 'q' when created. Overrides purl_processor::detect