Changeset 46 for trunk/Modules/Meet/MeetPage.php
- Timestamp:
- Nov 10, 2019, 1:42:40 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Meet/MeetPage.php
r38 r46 17 17 function Start() 18 18 { 19 $this->System->RegisterPage('seznamka', 'PageMeetList'); 19 $this->System->RegisterPage('seznamka', 'PageMeetList'); 20 20 $this->System->RegisterPage(array('seznamka', 'inzerat'), 'PageMeetItem'); 21 21 $this->System->RegisterPage(array('seznamka', 'aktualizace'), 'PageMeetUpdate'); 22 22 $this->System->RegisterPage(array('seznamka', 'rss'), 'PageMeetRss'); 23 23 $this->System->RegisterMenuItem('/seznamka', 'Seznamka'); 24 } 24 } 25 25 } 26 26 … … 36 36 function Show() 37 37 { 38 $Filter Items = 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' => 'vek do', 'Type' => 'Integer', 'DbName' => 'Age', 'Operation' => '<='),44 array('Name' => 'vyska od', 'Type' => 'Integer', 'DbName' => 'Height', 'Operation' => '>='),45 array('Name' => 'v yskado', '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'), 49 49 ); 50 50 51 foreach ($FilterItems as $Item) 52 { 53 if (!array_key_exists($Item['Name'], $_SESSION)) $_SESSION[$Item['Name']] = ''; 54 } 55 51 $Output = ''; 56 52 $this->Title = 'Seznamka - '.$this->Title; 57 $Output = '';58 53 if (array_key_exists('lvm', $_GET) and ($_GET['lvm'] == 'seznam')) 59 {60 54 $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); 187 62 $DbRow = $DbResult->fetch_row(); 188 63 $PageList = GetPageList($DbRow[0]); … … 206 81 $Output .= '<table class="WideTable">'; 207 82 $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']); 210 86 while($MeetItem = $DbResult->fetch_assoc()) 211 87 { … … 217 93 '<td>'.$MeetItem['Weight'].'</td>'. 218 94 '<td>'.$MeetItem['Location'].'</td>'. 219 //'<td>'.$MeetItem['Email'].'</td>'.220 //'<td>'.$MeetItem['Phone'].'</td>'.221 95 '<td>'.$Gender[$MeetItem['Gender']].'</td>'. 222 96 '<td>'.$MeetItem['Message'].'</td>'. … … 249 123 250 124 function Show() 251 { 125 { 252 126 $MeetSources = new MeetSources(); 253 127 $MeetSources->Database = $this->Database;
Note:
See TracChangeset
for help on using the changeset viewer.