Changeset 4 for trunk/index.php


Ignore:
Timestamp:
Aug 5, 2018, 1:12:12 AM (6 years ago)
Author:
chronos
Message:
  • Added: RSS channel.
  • Added: Location and weight properties.
  • Modified: Better sorting and paging of table.
  • Added: Filtering by gender.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/index.php

    r3 r4  
    44include_once('Config.php');
    55include_once('Meet.php');
     6include_once('RSS.php');
     7include_once('Global.php');
    68
    79session_start();
    810
    9 function HumanDate($Time)
    10 {
    11   return(date('j.n.Y', $Time));
    12 }
    13  
    1411class Application
    1512{
     13  var $NoFullPage = false;
     14 
    1615  function Link($URL)
    1716  {
     
    6968      $Output .= '<th>'.$ResourceGroup['Name'].'</th>';
    7069    }
    71     $Output .= '</tr>';
     70    $Output .= '</tr>';     
    7271    $DbResult = $this->Database->select('Dance', '*, (SELECT Name FROM DanceGroup WHERE DanceGroup.Id=Dance.Group) AS GroupName', '1 ORDER BY `Name`');
    7372    while($Dance = $DbResult->fetch_assoc())
     
    118117  function ShowMeetList()
    119118  {
     119    $Output = '';
     120    //print_r($_GET);
    120121    if (array_key_exists('lvm', $_GET) and ($_GET['lvm'] == 'seznam'))
    121122    {
     
    125126      if (array_key_exists('vyskaod', $_GET) ) $_SESSION['vyskaod'] = $_GET['vyskaod'];
    126127      if (array_key_exists('vyskado', $_GET) ) $_SESSION['vyskado'] = $_GET['vyskado'];
     128      if (array_key_exists('vahaod', $_GET) ) $_SESSION['vahaod'] = $_GET['vahaod'];
     129      if (array_key_exists('vahado', $_GET) ) $_SESSION['vahado'] = $_GET['vahado'];
     130      if (array_key_exists('pohlavi', $_GET) ) {
     131        if ($_GET['pohlavi'] > 0) $_SESSION['pohlavi'] = $_GET['pohlavi'];
     132          else unset($_SESSION['pohlavi']);
     133      }
    127134    } else {
    128     $Output = '';
    129135    $Output .= '<script>function reloadlist(){ $(\'#meetlist\').load(document.URL + \' #meetlist\');}'.
    130136      ' var load_timer = 100;
     
    143149   }
    144150           
    145    var cf = {pohlavi:\'2\'};
     151   var cf = {};
    146152
    147153   function setupc(key,val){
     
    150156         var ccv = $(\'#\'+key).val();
    151157         if(ccv!=val) $(\'#\'+key).val(val==0?\'\':val);
     158      }
     159      if(key==\'pohlavi\') {
     160         $(\'.c\'+key).removeClass(\'active\');
     161         $(\'#\'+key+val).addClass(\'active\');
    152162      }
    153163   }
     
    167177   }'.
    168178      '</script>';
     179    $Output .= '<h4 style="text-align: center;">Inzeráty:</h4>';
     180    $Output .= '<div class="btn-group ma3">'.
     181      '<button class="btn btn-filter cpohlavi btn-ico" onclick="upf(\'pohlavi\',0)" id="pohlavi0" data-toggle="tooltip" '.
     182      'data-placement="top" title="Obě pohlaví"><span class="icon-both"></span></button>'.
     183      '<button class="btn btn-filter cpohlavi btn-ico" onclick="upf(\'pohlavi\',1)" id="pohlavi1" data-toggle="tooltip" '.
     184      'data-placement="top" title="Jen muži"><span class="icon-man"></span></button>'.
     185      '<button class="btn btn-filter cpohlavi btn-ico" onclick="upf(\'pohlavi\',2)" id="pohlavi2" data-toggle="tooltip" '.
     186      'data-placement="top" title="Jen ženy"><span class="icon-woman"></span></button>'.
     187      '</div>';
    169188    $Output .= '<div class="filter-num-box">'.
    170189      '<div class="label-box">Věk</div>'.
    171       '<input value="" onkeyup="if(event.keyCode!=9) upf(\'vekod\',$(this).val(),(event.keyCode==13?0:1)); '.
     190      '<input value="'.$_SESSION['vekod'].'" onkeyup="if(event.keyCode!=9) upf(\'vekod\',$(this).val(),(event.keyCode==13?0:1)); '.
    172191      '" id="vekod" autocomplete="off" type="text">'.
    173192      '<div class="label-box">-</div>'.
    174       '<input value="" onkeyup="'.
     193      '<input value="'.$_SESSION['vekdo'].'" onkeyup="'.
    175194      'if(event.keyCode!=9) upf(\'vekdo\',$(this).val(),(event.keyCode==13?0:1));" '.
    176195      'id="vekdo" autocomplete="off" type="text"><div class="label-box">let</div></div>'.
    177       '</div> '.
    178       '<div class="filter-num-box">'.
     196      '</div> ';
     197    $Output .= '<div class="filter-num-box">'.
    179198      '<div class="label-box">Výška</div>'.
    180       '<input value="" onkeyup="if(event.keyCode!=9) upf(\'vyskaod\',$(this).val(),(event.keyCode==13?0:1)); '.
     199      '<input value="'.$_SESSION['vyskaod'].'" onkeyup="if(event.keyCode!=9) upf(\'vyskaod\',$(this).val(),(event.keyCode==13?0:1)); '.
    181200      '" id="vyskaod" autocomplete="off" type="text">'.
    182201      '<div class="label-box">-</div>'.
    183       '<input value="" onkeyup="'.
     202      '<input value="'.$_SESSION['vyskado'].'" onkeyup="'.
    184203      'if(event.keyCode!=9) upf(\'vyskado\',$(this).val(),(event.keyCode==13?0:1));" '.
    185204      'id="vyskado" autocomplete="off" type="text"><div class="label-box">cm</div></div>'.
     205      '</div> ';
     206    $Output .= '<div class="filter-num-box">'.
     207      '<div class="label-box">Váha</div>'.
     208      '<input value="'.$_SESSION['vahaod'].'" onkeyup="if(event.keyCode!=9) upf(\'vahaod\',$(this).val(),(event.keyCode==13?0:1)); '.
     209      '" id="vahaod" autocomplete="off" type="text">'.
     210      '<div class="label-box">-</div>'.
     211      '<input value="'.$_SESSION['vahado'].'" onkeyup="'.
     212      'if(event.keyCode!=9) upf(\'vahado\',$(this).val(),(event.keyCode==13?0:1));" '.
     213      'id="vahado" autocomplete="off" type="text"><div class="label-box">cm</div></div>'.
    186214      '</div>';
    187       $Output .= '<h4 style="text-align: center;">Inzeráty:</h4>';
    188     }
    189    
    190     $Gender = array('', 'Muž', 'Žena');
    191     $Output .= '<div id="list_content">'.
    192       '<table class="WideTable">';
    193     $Output .= '<tr>'.
    194       '<th>Datum</th>'.
    195       '<th>Jméno</th>'.
    196       '<th>Výška</th>'.
    197       '<th>Věk</th>'.
    198       '<th>Váha</th>'.
    199       //'<th>Email</th>'.
    200       //'<th>Telefon</th>'.
    201       '<th>Pohlaví</th>'.
    202       '<th>Zpráva</th>'.
    203       '<th>Zdroj</th>';
    204     $Output .= '</tr>';
     215    }
     216   
    205217    $Where = '';   
    206218    if (array_key_exists('vekod', $_SESSION) and ($_SESSION['vekod'] != '')) $Where .= ' AND (Age >= '.$_SESSION['vekod'].')';
     
    208220    if (array_key_exists('vyskaod', $_SESSION) and ($_SESSION['vyskaod'] != '')) $Where .= ' AND (Height >= '.$_SESSION['vyskaod'].')';
    209221    if (array_key_exists('vyskado', $_SESSION) and ($_SESSION['vyskado'] != '')) $Where .= ' AND (Height <= '.$_SESSION['vyskado'].')';
     222    if (array_key_exists('vahaod', $_SESSION) and ($_SESSION['vahaod'] != '')) $Where .= ' AND (Weight >= '.$_SESSION['vahaod'].')';
     223    if (array_key_exists('vahado', $_SESSION) and ($_SESSION['vahado'] != '')) $Where .= ' AND (Weight <= '.$_SESSION['vahado'].')';
     224    if (array_key_exists('pohlavi', $_SESSION) and ($_SESSION['pohlavi'] != '')) $Where .= ' AND (Gender = '.$_SESSION['pohlavi'].')';
    210225    if (substr($Where, 0, 4) == ' AND') $Where = substr($Where, 4);
    211     if ($Where == '') $Where = '1';
     226    if ($Where == '') $Where = '1';   
     227   
     228    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `MeetItem` WHERE '.$Where);
     229    $DbRow = $DbResult->fetch_row();
     230    $PageList = GetPageList($DbRow[0]);
     231   
     232    $Gender = array('', 'Muž', 'Žena');
     233    $Output .= '<div id="list_content">';
     234    $Output .= $PageList['Output'];
     235    $TableColumns = array(
     236      array('Name' => 'Date', 'Title' => 'Datum'),
     237      array('Name' => 'Name', 'Title' => 'Jméno'),
     238      array('Name' => 'Height', 'Title' => 'Výška'),
     239      array('Name' => 'Age', 'Title' => 'Věk'),
     240      array('Name' => 'Weight', 'Title' => 'Váha'),
     241      array('Name' => 'Gender', 'Title' => 'Pohlaví'),
     242      array('Name' => 'Message', 'Title' => 'Zpráva'),
     243      array('Name' => 'Source', 'Title' => 'Zdroj'),
     244    );
     245    $Order = GetOrderTableHeader($TableColumns, 'Date', 1);
     246    $Output .= '<table class="WideTable">';
     247    $Output .= $Order['Output'];
    212248    $DbResult = $this->Database->select('MeetItem', '*, (SELECT MeetSource.Name FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceName, '.
    213       '(SELECT MeetSource.URL FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceURL', $Where.' ORDER BY `Date` DESC');
     249      '(SELECT MeetSource.URL FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceURL', $Where.$Order['SQL'].$PageList['SQLLimit']);
    214250    while($MeetItem = $DbResult->fetch_assoc())
    215251    {
     
    227263      $Output .= '</tr>';
    228264    }
    229     $Output .= '</table></div>';
    230 
    231     return($Output);
     265    $Output .= '</table>';
     266    $Output .= $PageList['Output'];
     267    $Output .= '</div>';
     268
     269    return($Output);
     270  }
     271 
     272  function ShowMeetListRss()
     273  {
     274    global $Config;
     275   
     276    $this->NoFullPage = true;
     277    $RSS = new RSS();
     278    $RSS->Title = 'Taneční seznamka';
     279    $RSS->Description = '';
     280    $RSS->Link = $Config['BaseURL'].'seznamka';
     281   
     282    $DbResult = $this->Database->select('MeetItem', '*, (SELECT MeetSource.Name FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceName, '.
     283      '(SELECT MeetSource.URL FROM MeetSource WHERE MeetSource.Id = MeetItem.Source) AS SourceURL', '1 ORDER BY `Date` DESC LIMIT 30');
     284    while($MeetItem = $DbResult->fetch_assoc())
     285    {
     286      $Title = $MeetItem['Name'];
     287      if ($MeetItem['Age'] != '') $Title .= ', '.$MeetItem['Age'].' let';
     288      if ($MeetItem['Weight'] != '') $Title .= ', '.$MeetItem['Height'].' cm';
     289      $Description = $MeetItem['Message'];
     290      if ($MeetItem['Email'] != '') $Description .= '<br/>Email: '.$MeetItem['Email'];
     291      if ($MeetItem['Phone'] != '') $Description .= '<br/>Telefon: '.$MeetItem['Phone'];
     292      $Description .= '<br/>Škola: <a href="'.$this->Link($MeetItem['SourceURL']).'">'.$MeetItem['SourceName'].'</a>';
     293      $RSS->Items[] = array(         
     294        'Title' => $Title,
     295        'Description' => $Description,
     296        'Time' => MysqlDateTimeToTime($MeetItem['Date']),
     297        'Link' => $Config['BaseURL'].'seznamka',
     298      );
     299      $Output .= '<tr>'.
     300        '<td>'.HumanDate(MysqlDateToTime($MeetItem['Date'])).'</td>'.
     301        '<td>'.$MeetItem['Name'].'</td>'.
     302        '<td>'.$MeetItem['Height'].'</td>'.
     303        '<td>'.$MeetItem['Age'].'</td>'.
     304        '<td>'.$MeetItem['Weight'].'</td>'.
     305        //'<td>'.$MeetItem['Email'].'</td>'.
     306        //'<td>'.$MeetItem['Phone'].'</td>'.
     307        '<td>'.$Gender[$MeetItem['Gender']].'</td>'.
     308        '<td>'.$MeetItem['Message'].'</td>'.
     309        '<td></td>';
     310      $Output .= '</tr>';
     311    }
     312
     313    return $RSS->Generate();
    232314  }
    233315
     
    240322      '<link rel="stylesheet" href="'.$this->Link('/style.css').'" type="text/css" media="all" />'.
    241323      '<meta http-equiv="content-type" content="application/xhtml+xml; charset='.$this->Config['Encoding'].'" />'.
    242       '<script src="jquery.js"></script>'.
    243       '<title>Tance</title>'.
     324      '<script src="jquery.js"></script>';
     325    $Output .= '<link rel="alternate" title="Taneční seznamka" href="'.
     326      $this->Config['BaseURL'].'seznamka-rss" type="application/rss+xml" />';
     327    $Output .= '<title>Tance</title>'.
    244328      '</head><body>';
    245329    $Output .= $Content;
     
    266350      else if($this->PathItems[0] == 'tance') $Output .= $this->ShowDanceList();
    267351      else if($this->PathItems[0] == 'seznamka') $Output .= $this->ShowMeetList();
     352      else if($this->PathItems[0] == 'seznamka-rss') $Output .= $this->ShowMeetListRss();
    268353      else if($this->PathItems[0] == 'seznamka-aktualizace') $Output .= $this->ShowMeetUpdate();
    269354      else $Output .= $this->ShowDanceList();
Note: See TracChangeset for help on using the changeset viewer.