Location: PHPKode > projects > OpenBizMap > openbizmap/mydata/script/run_filter.txt
<?php
/*
OpenDataBag - Data Web Interface
Copyright (C) 2004 Nawara

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

/*
Custom filtering

IN odb_filter0_name - filter name
IN odb_filter0      - filter value
IN odb_filter0_type - filter type (from | to | <empty>)
...
IN odb_filter99_name - filter name
IN odb_filter99      - filter value
IN odb_filter99_type - filter type (from | to | <empty>)

OUT odb_search
*/
$search='';
for($ii=0;$ii<100;$ii++)
{
  $filter_name=trim(get('filter'.$ii.'_name'));
  $filter_type=trim(get('filter'.$ii.'_type'));
  $filter_from=trim(get('filter'.$ii.'_from'));
  $filter_to=trim(get('filter'.$ii.'_to'));
  $filter_value=trim(get('filter'.$ii.''));


  $template=$filter_type;
  $show_mode=CFG_SAVE;
  if($filter_from)
  {
    $show_value=$filter_from;
    if(file_exists(cfg_data_path.'/config/script/fld_'.$template.'.txt'))
    {
      include(cfg_data_path.'/config/script/fld_'.$template.'.txt');
    }
    else
    {
      if(!file_exists(cfg_data_path.'/script/fld_'.$template.'.txt'))
        $template='';

      include(cfg_data_path.'/script/fld_'.$template.'.txt');
    }
    $filter_from=$show_value;
  }

  if($filter_to)
  {
    $show_value=$filter_to;
    if(file_exists(cfg_data_path.'/config/script/fld_'.$template.'.txt'))
    {
      include(cfg_data_path.'/config/script/fld_'.$template.'.txt');
    }
    else
    {
      if(!file_exists(cfg_data_path.'/script/fld_'.$template.'.txt'))
        $template='';

      include(cfg_data_path.'/script/fld_'.$template.'.txt');
    }
    $filter_to=$show_value;
  }

  if($filter_value)
  {
    $show_value=$filter_value;
    if(file_exists(cfg_data_path.'/config/script/fld_'.$template.'.txt'))
    {
      include(cfg_data_path.'/config/script/fld_'.$template.'.txt');
    }
    else
    {
      if(!file_exists(cfg_data_path.'/script/fld_'.$template.'.txt'))
        $template='';

      include(cfg_data_path.'/script/fld_'.$template.'.txt');
    }
    $filter_value=$show_value;
  }


  if(strlen($filter_from))
  {
    $tmp_search=$filter_name.'>'.$filter_from;
    
    if(strpos($tmp_search,' '))
      $search.='['.$tmp_search.'] ';
    else
      $search.=$tmp_search.' ';
  }
  
  if(strlen($filter_to))
  {
    $tmp_search=$filter_name.'<'.$filter_to;
    
    if(strpos($tmp_search,' '))
      $search.='['.$tmp_search.'] ';
    else
      $search.=$tmp_search.' ';
  }

  //support for old-style manual masks
  if(strlen($filter_value))
  {
    if(strlen($filter_name))
    {
      if(strpos($filter_name,' '))
        $search.='['.$filter_name.']';
      else
        $search.=$filter_name;

      if($filter_type=='from')
        $search.='>';
      elseif($filter_type=='to')
        $search.='<';
      else
        $search.='=';

      if(strpos($filter_value,' '))
        $search.='['.$filter_value.']';
      else
        $search.=$filter_value;

      $search.=' ';
    }
    else
    {
      $search.=$filter_value.' ';
    }
  }
}

?>
Return current item: OpenBizMap