Changeset 46 for trunk/Modules/Meet


Ignore:
Timestamp:
Nov 10, 2019, 1:42:40 AM (5 years ago)
Author:
chronos
Message:
  • Modified: Table filter made more general.
  • Added: Filter for movies table.
Location:
trunk/Modules/Meet
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Meet/Meet.php

    r44 r46  
    273273  'sokolov' => 'Sokolov',
    274274  'mikulov' => 'Mikulov',
     275  'havířov' => 'Havířov',
     276  'kolín' => 'Kolín',
     277  'kroměříž' => 'Kroměříž',
    275278);
    276279
  • trunk/Modules/Meet/MeetPage.php

    r38 r46  
    1717  function Start()
    1818  {
    19     $this->System->RegisterPage('seznamka', 'PageMeetList');   
     19    $this->System->RegisterPage('seznamka', 'PageMeetList');
    2020    $this->System->RegisterPage(array('seznamka', 'inzerat'), 'PageMeetItem');
    2121    $this->System->RegisterPage(array('seznamka', 'aktualizace'), 'PageMeetUpdate');
    2222    $this->System->RegisterPage(array('seznamka', 'rss'), 'PageMeetRss');
    2323    $this->System->RegisterMenuItem('/seznamka', 'Seznamka');
    24   } 
     24  }
    2525}
    2626
     
    3636  function Show()
    3737  {
    38     $FilterItems = array(
    39       array('Name' => 'name', 'Type' => 'String', 'DbName' => 'Name'),
    40       array('Name' => 'location', 'Type' => 'String', 'DbName' => 'Location'),
    41       array('Name' => 'message', 'Type' => 'String', 'DbName' => 'Message'),
    42       array('Name' => 'vekod', 'Type' => 'Integer', 'DbName' => 'Age', 'Operation' => '>='),
    43       array('Name' => 'vekdo', 'Type' => 'Integer', 'DbName' => 'Age', 'Operation' => '<='),
    44       array('Name' => 'vyskaod', 'Type' => 'Integer', 'DbName' => 'Height', 'Operation' => '>='),
    45       array('Name' => 'vyskado', 'Type' => 'Integer', 'DbName' => 'Height', 'Operation' => '<='),
    46       array('Name' => 'vahaod', 'Type' => 'Integer', 'DbName' => 'Weight', 'Operation' => '>='),
    47       array('Name' => 'vahado', 'Type' => 'Integer', 'DbName' => 'Weight', 'Operation' => '<='),
    48       array('Name' => 'pohlavi', 'Type' => 'Integer', 'DbName' => 'Gender', 'Operation' => '=='),
     38    $Filter = new Filter();
     39    $Filter->Items = array(
     40      array('Name' => 'pohlavi', 'Type' => 'Enumeration', 'DbName' => 'Gender', 'Title' => 'Pohlaví',
     41        'States' => array(0 => 'Obě', 1 => 'Muži', 2 => 'Ženy')),
     42      array('Name' => 'name', 'Type' => 'String', 'DbName' => 'Name', 'Title' => 'Jméno'),
     43      array('Name' => 'vek', 'Type' => 'Integer', 'DbName' => 'Age', 'Title' => 'Věk', 'Units' => 'let'),
     44      array('Name' => 'vyska', 'Type' => 'Integer', 'DbName' => 'Height', 'Title' => 'Výška', 'Units' => 'cm'),
     45      array('Name' => 'vaha', 'Type' => 'Integer', 'DbName' => 'Weight', 'Title' => 'Váha', 'Units' => 'Kg'),
     46      array('Name' => 'message', 'Type' => 'String', 'DbName' => 'Message', 'Title' => 'Zpráva'),
     47      array('Name' => 'location', 'Type' => 'String', 'DbName' => 'Location', 'Title' => 'Umístění'),
     48      array('Name' => 'source', 'Type' => 'String', 'DbName' => 'SourceName', 'Title' => 'Import'),
    4949    );
    5050
    51     foreach ($FilterItems as $Item)
    52     {
    53       if (!array_key_exists($Item['Name'], $_SESSION)) $_SESSION[$Item['Name']] = '';
    54     }
    55 
     51    $Output = '';
    5652    $this->Title = 'Seznamka - '.$this->Title;
    57     $Output = '';
    5853    if (array_key_exists('lvm', $_GET) and ($_GET['lvm'] == 'seznam'))
    59     {
    6054      $this->ClearPage = true;
    61       foreach ($FilterItems as $Item)
    62       {
    63         if (array_key_exists($Item['Name'], $_GET) ) $_SESSION[$Item['Name']] = $_GET[$Item['Name']];
    64         if (($Item['Type'] == 'Integer') and ($_SESSION[$Item['Name']] == '0')) $_SESSION[$Item['Name']] = '';
    65       }
    66     } else {
    67     $Output .= '<script type="text/javascript">function reloadlist(){ $(\'#meetlist\').load(document.URL + \' #meetlist\');}'.
    68       ' var load_timer = 100;
    69    var ltimer = null;
    70 
    71    function checkOut(kc,obj){
    72       if(kc==13) $(obj).blur();
    73    }
    74    function initLTimer(tm){
    75       if(ltimer) clearTimeout(ltimer);
    76       ltimer = setTimeout("freloader()",tm);
    77    }
    78    function stopLTimer(){
    79       if(ltimer) clearTimeout(ltimer);
    80       ltimer = null;
    81    }
    82 
    83    var cf = {};
    84 
    85    function setupc(key,val){
    86       //console.log(\'setup-control-\'+key+\' = \'+val);
    87       if(key==\'vekod\' || key==\'vekdo\' || key==\'vyskaod\' || key==\'vyskado\' || key==\'vahaod\' || key==\'vahado\') {
    88          var ccv = $(\'#\'+key).val();
    89          if(ccv!=val) $(\'#\'+key).val(val==0?\'\':val);
    90       }
    91       if(key==\'pohlavi\') {
    92          $(\'.c\'+key).removeClass(\'active\');
    93          $(\'#\'+key+val).addClass(\'active\');
    94       }
    95    }
    96 
    97    function upf(key,val,lonreload){
    98       if(key!=\'first\') cf[\'first\']=0; else st();
    99       setupc(key,val);
    100       cf[key]=val;
    101       if(lonreload) initLTimer(1000); else initLTimer(100);
    102    }
    103 
    104    function freloader(){
    105       ltimer = null;
    106       var qp = jQuery.param( cf );
    107       $(\'#list_content\').html(\'\'); $(\'#list_loading\').show();
    108       $.get(\''.$this->System->Link('/seznamka/').'?lvm=seznam&\'+qp,function(data){$(\'#list_loading\').hide();$(\'#list_content\').html(data);htip()})
    109    }'.
    110       '</script>';
    111     $Output .= '<div class="title">Inzeráty</div>';
    112     $Output .= '<div class="btn-group ma3">'.
    113       '<div class="label-box">Pohlaví</div>'.
    114       '<button class="btn btn-filter cpohlavi btn-ico" onclick="upf(\'pohlavi\',0)" id="pohlavi0" data-toggle="tooltip" '.
    115       'data-placement="top" title="Obě"><span class="icon-both"></span></button>'.
    116       '<button class="btn btn-filter cpohlavi btn-ico" onclick="upf(\'pohlavi\',1)" id="pohlavi1" data-toggle="tooltip" '.
    117       'data-placement="top" title="Muži"><span class="icon-man"></span></button>'.
    118       '<button class="btn btn-filter cpohlavi btn-ico" onclick="upf(\'pohlavi\',2)" id="pohlavi2" data-toggle="tooltip" '.
    119       'data-placement="top" title="Ženy"><span class="icon-woman"></span></button>'.
    120       '</div> ';
    121     $Output .= '<div class="filter-num-box">'.
    122       '<div class="label-box">Jméno</div>'.
    123       '<input value="'.$_SESSION['name'].'" onkeyup="if(event.keyCode!=9) upf(\'name\',$(this).val(),(event.keyCode==13?0:1)); '.
    124       '" id="name" autocomplete="off" type="text"/>'.
    125       '</div> ';
    126     $Output .= '<div class="filter-num-box">'.
    127       '<div class="label-box">Věk</div>'.
    128       '<input value="'.$_SESSION['vekod'].'" onkeyup="if(event.keyCode!=9) upf(\'vekod\',$(this).val(),(event.keyCode==13?0:1)); '.
    129       '" id="vekod" autocomplete="off" type="text"/>'.
    130       '<div class="label-box">-</div>'.
    131       '<input value="'.$_SESSION['vekdo'].'" onkeyup="'.
    132       'if(event.keyCode!=9) upf(\'vekdo\',$(this).val(),(event.keyCode==13?0:1));" '.
    133       'id="vekdo" autocomplete="off" type="text"/>'.
    134       '<div class="label-box">let</div>'.
    135       '</div> ';
    136     $Output .= '<div class="filter-num-box">'.
    137       '<div class="label-box">Výška</div>'.
    138       '<input value="'.$_SESSION['vyskaod'].'" onkeyup="if(event.keyCode!=9) upf(\'vyskaod\',$(this).val(),(event.keyCode==13?0:1)); '.
    139       '" id="vyskaod" autocomplete="off" type="text"/>'.
    140       '<div class="label-box">-</div>'.
    141       '<input value="'.$_SESSION['vyskado'].'" onkeyup="'.
    142       'if(event.keyCode!=9) upf(\'vyskado\',$(this).val(),(event.keyCode==13?0:1));" '.
    143       'id="vyskado" autocomplete="off" type="text"/>'.
    144       '<div class="label-box">cm</div>'.
    145       '</div> ';
    146     $Output .= '<div class="filter-num-box">'.
    147       '<div class="label-box">Váha</div>'.
    148       '<input value="'.$_SESSION['vahaod'].'" onkeyup="if(event.keyCode!=9) upf(\'vahaod\',$(this).val(),(event.keyCode==13?0:1)); '.
    149       '" id="vahaod" autocomplete="off" type="text"/>'.
    150       '<div class="label-box">-</div>'.
    151       '<input value="'.$_SESSION['vahado'].'" onkeyup="'.
    152       'if(event.keyCode!=9) upf(\'vahado\',$(this).val(),(event.keyCode==13?0:1));" '.
    153       'id="vahado" autocomplete="off" type="text"/>'.
    154       '<div class="label-box">Kg</div>'.
    155       '</div> ';
    156     $Output .= '<div class="filter-num-box">'.
    157       '<div class="label-box">Umístění</div>'.
    158       '<input value="'.$_SESSION['location'].'" onkeyup="if(event.keyCode!=9) upf(\'location\',$(this).val(),(event.keyCode==13?0:1)); '.
    159       '" id="location" autocomplete="off" type="text"/>'.
    160       '</div> ';
    161     $Output .= '<div class="filter-num-box">'.
    162       '<div class="label-box">Zpráva</div>'.
    163       '<input value="'.$_SESSION['message'].'" onkeyup="if(event.keyCode!=9) upf(\'message\',$(this).val(),(event.keyCode==13?0:1)); '.
    164       '" id="message" autocomplete="off" type="text"/>'.
    165       '</div> ';
    166     }
    167 
    168     $Where = '';
    169     foreach($FilterItems as $Item)
    170     {
    171       if ($Item['Type'] == 'String') {
    172         if ($_SESSION[$Item['Name']] != '') $Where .= ' AND ('.$Item['DbName'].' LIKE "%'.$this->Database->real_escape_string($_SESSION[$Item['Name']]).'%")';
    173       } else
    174       if ($Item['Type'] == 'Integer') {
    175         if ($_SESSION[$Item['Name']] != '') {
    176           if ($Item['Operation'] == '>=') $Where .= ' AND ('.$Item['DbName'].' >= '.$this->Database->real_escape_string($_SESSION[$Item['Name']]).')';
    177           else if ($Item['Operation'] == '<=') $Where .= ' AND ('.$Item['DbName'].' <= '.$this->Database->real_escape_string($_SESSION[$Item['Name']]).')';
    178           else if ($Item['Operation'] == '==') $Where .= ' AND ('.$Item['DbName'].' = '.$this->Database->real_escape_string($_SESSION[$Item['Name']]).')';
    179         }
    180       }
    181     }
    182     if (substr($Where, 0, 4) == ' AND')
    183       $Where = substr($Where, 4);
    184     if ($Where == '') $Where = '1';
    185 
    186     $DbResult = $this->Database->query('SELECT COUNT(*) FROM `MeetItem` WHERE '.$Where);
     55      else $Output .= '<div class="title">Inzeráty</div>';
     56
     57    $Output .= $Filter->GetOutput($this->System->Link('/seznamka/'));
     58    $Where = $Filter->GetWhere($this->Database);
     59
     60    $DbResult = $this->Database->query('SELECT COUNT(*) FROM (SELECT *, '.
     61      '(SELECT MeetSource.Name FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceName FROM `MeetItem`) AS T WHERE '.$Where);
    18762    $DbRow = $DbResult->fetch_row();
    18863    $PageList = GetPageList($DbRow[0]);
     
    20681    $Output .= '<table class="WideTable">';
    20782    $Output .= $Order['Output'];
    208     $DbResult = $this->Database->select('MeetItem', '*, (SELECT MeetSource.Name FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceName, '.
    209       '(SELECT MeetSource.URL FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceURL', $Where.$Order['SQL'].$PageList['SQLLimit']);
     83    $DbResult = $this->Database->query('SELECT * FROM (SELECT *, (SELECT MeetSource.Name FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceName, '.
     84      '(SELECT MeetSource.URL FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceURL FROM MeetItem) AS T WHERE '.
     85      $Where.$Order['SQL'].$PageList['SQLLimit']);
    21086    while($MeetItem = $DbResult->fetch_assoc())
    21187    {
     
    21793        '<td>'.$MeetItem['Weight'].'</td>'.
    21894        '<td>'.$MeetItem['Location'].'</td>'.
    219         //'<td>'.$MeetItem['Email'].'</td>'.
    220         //'<td>'.$MeetItem['Phone'].'</td>'.
    22195        '<td>'.$Gender[$MeetItem['Gender']].'</td>'.
    22296        '<td>'.$MeetItem['Message'].'</td>'.
     
    249123
    250124  function Show()
    251   {   
     125  {
    252126    $MeetSources = new MeetSources();
    253127    $MeetSources->Database = $this->Database;
Note: See TracChangeset for help on using the changeset viewer.