/**
  * Removes filtering from a {@link DataObject}. Does not remove
  * existing relations but does remove the extension.
  *
  * @param string classname to remove filters from
  * @param string relation to be removed from FilterOption object
  */
 public static function remove($class, $relation)
 {
     // Update the many many relations on
     $belongs = is_array(FilterOption::config()->belongs_many_many) ? FilterOption::config()->belongs_many_many : array();
     // Remove our relation
     if (isset($belongs["Filters"])) {
         unset($belongs["Filters"]);
     }
     // Now remove the class from our list of classes
     if (isset(self::$filtered_classes[$class])) {
         unset(self::$filtered_classes[$class]);
     }
     FilterOption::config()->belongs_many_many = $belongs;
     $class::remove_extension('FilterableObject');
 }
 public function filterby()
 {
     // Get a list of filterable classes
     $classes = Filterable::getFilteredClasses();
     $results = ArrayList::create();
     $get_vars = $this->owner->request->getVars();
     $filter_ids = array();
     if (isset($get_vars["filter"])) {
         // First trim uneeded characters from string
         $filter_vars = trim($get_vars["filter"], " :;\t\n\r\v");
         // Now explode the filters stored in our filter var
         $filter_vars = explode(";", $filter_vars);
         // Now get the filter options we need to filter objects by
         foreach ($filter_vars as $single_var) {
             $key_value = explode(":", $single_var);
             $filter_option = FilterOption::get()->filter(array("Parent.URLSegment:nocase" => $key_value[0], "URLSegment:nocase" => $key_value[1]))->first();
             if ($filter_option && $results->exists()) {
                 foreach ($results as $result) {
                     if (!$result->Filters()->find("ID", $filter_option->ID)) {
                         $results->remove($result);
                     }
                 }
             } elseif ($filter_option) {
                 foreach ($classes as $class) {
                     $list = $class::get()->filter("Filters.ID:ExactMatch", $filter_option->ID);
                     if ($list->exists()) {
                         $results->merge($list);
                     }
                 }
             }
         }
     } else {
         foreach ($classes as $class) {
             $list = $class::get();
             if ($list->exists()) {
                 $results->merge($list);
             }
         }
     }
     $results = new PaginatedList($results, $this->owner->request);
     $data = array('Results' => $results);
     $this->owner->extend("updateFilterBy", $data);
     $template = $this->owner->ClassName ? $this->owner->ClassName : "Page";
     return $this->owner->customise($data)->renderWith(array("{$template}_filterby", "FilterBy", "Page"));
 }