You are here

class purl_useragent in Persistent URL 6

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

User agent style.

Hierarchy

Expanded class hierarchy of purl_useragent

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

File

includes/purl_useragent.inc, line 6

View source
class purl_useragent implements purl_processor {
  public function method() {
    return 'useragent';
  }
  public function admin_form(&$form, $id) {
  }
  public function description() {
    return t('Enter a user agent for this context, such as "iPhone".');
  }
  public function detect($q) {
    $useragent = $_SERVER['HTTP_USER_AGENT'];
    if (!empty($useragent)) {
      return $useragent;
    }
    return '';
  }

  /**
   * See a valid value is present in the HTTP_USER_AGENT. Note: we're using
   * stripos() which makes this check relatively easy to pass..
   */
  public function parse($valid_values, $useragent) {
    foreach ($valid_values as $key => $value) {
      if (stripos($useragent, $key) !== FALSE) {
        return purl_path_elements($this, $valid_values);
      }
    }
  }

  /**
   * We cannot alter the user agent, no need to try.
   */
  public function adjust(&$value, $element, &$q) {
  }
  public function rewrite(&$path, &$options, $element) {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
purl_useragent::adjust public function We cannot alter the user agent, no need to try. Overrides purl_processor::adjust
purl_useragent::admin_form public function Allow extension of the admin setup form. Overrides purl_processor::admin_form
purl_useragent::description public function Provide a description of processor for the end user Overrides purl_processor::description
purl_useragent::detect public function Detect the the processor value for the current page request Overrides purl_processor::detect
purl_useragent::method public function Return the method the processor users. Overrides purl_processor::method
purl_useragent::parse public function See a valid value is present in the HTTP_USER_AGENT. Note: we're using stripos() which makes this check relatively easy to pass.. Overrides purl_processor::parse
purl_useragent::rewrite public function Responsible for rewriting outgoing links. Note: it's this functions job to make sure it doesn't alter a link that has already been treated. Overrides purl_processor::rewrite