purl_extension.inc in Persistent URL 7
File
includes/purl_extension.inc
View source
<?php
class purl_extension implements purl_processor {
public function admin_form(&$form, $id) {
}
public function detect($q) {
$last = explode('.', array_pop(explode('/', $q)));
if (count($last) > 1) {
return array_pop($last);
}
return '';
}
public function method() {
return 'extension';
}
public function description() {
return t('Enter a extension for this context, such as "csv".');
}
public function parse($valid_values, $q) {
$parsed = array();
if (isset($valid_values[$q])) {
$parsed[$q] = $valid_values[$q];
}
return purl_path_elements($this, $parsed);
}
public function adjust(&$value, $item, &$q) {
$q = $this
->remove($q, $item);
$value = $this
->remove($value, $item);
}
public function remove($q, $element) {
$args = explode('.', $q);
if (count($args > 1)) {
$extension = array_pop($args);
if ($element->value == $extension) {
return implode('.', $args);
}
}
return $q;
}
public function rewrite(&$path, &$options, $element) {
}
}