Changeset 52 for trunk


Ignore:
Timestamp:
Jan 4, 2020, 11:59:33 AM (4 years ago)
Author:
chronos
Message:
  • Added: New filter data type Boolean for representing on/off switches.
  • Added: Show only upcoming events. Allow to show also past events.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Global.php

    r46 r52  
    194194    foreach ($this->rItems as $Item)
    195195    {
    196       if (($Item['Type'] == 'String') or ($Item['Type'] == 'Enumeration'))
     196      if (($Item['Type'] == 'String') or ($Item['Type'] == 'Enumeration') or ($Item['Type'] == 'Boolean'))
    197197      {
    198198        if (!array_key_exists($Item['Name'], $_SESSION)) $_SESSION[$Item['Name']] = '';
     
    213213          if (array_key_exists($Item['Name'], $_GET) ) $_SESSION[$Item['Name']] = $_GET[$Item['Name']];
    214214        } else
    215         if ($Item['Type'] == 'Enumeration')
     215        if (($Item['Type'] == 'Enumeration') or ($Item['Type'] == 'Boolean'))
    216216        {
    217217          if (array_key_exists($Item['Name'], $_GET) ) $_SESSION[$Item['Name']] = $_GET[$Item['Name']];
     
    226226        }
    227227      }
    228     } else {
     228    } else
     229    {
    229230      $Output .= '<script type="text/javascript">function reloadlist(){ $(\'#meetlist\').load(document.URL + \' #meetlist\');}'.
    230231      ' var load_timer = 100;
    231232   var ltimer = null;
    232233
    233    function checkOut(kc,obj){
    234       if(kc==13) $(obj).blur();
     234   function checkOut(kc, obj)
     235   {
     236      if (kc == 13) $(obj).blur();
    235237   }
    236    function initLTimer(tm){
    237       if(ltimer) clearTimeout(ltimer);
    238       ltimer = setTimeout("freloader()",tm);
     238   function initLTimer(tm)
     239   {
     240      if (ltimer) clearTimeout(ltimer);
     241      ltimer = setTimeout("freloader()", tm);
    239242   }
    240    function stopLTimer(){
    241       if(ltimer) clearTimeout(ltimer);
     243   function stopLTimer()
     244   {
     245      if (ltimer) clearTimeout(ltimer);
    242246      ltimer = null;
    243247   }
     
    245249   var cf = {};
    246250
    247    function setupc(key,val){
    248       //console.log(\'setup-control-\'+key+\' = \'+val);
     251   function setupc(key,val)
     252   {
     253      //console.log(\'setup-control-\' + key + \' = \' + val);
    249254      ';
    250255      $Keys = array();
     
    253258        if ($Item['Type'] == 'Integer')
    254259        {
    255           $Keys[] = 'key==\''.$Item['Name'].'od\'';
    256           $Keys[] = 'key==\''.$Item['Name'].'do\'';
     260          $Keys[] = 'key == \''.$Item['Name'].'od\'';
     261          $Keys[] = 'key == \''.$Item['Name'].'do\'';
    257262        }
    258263      }
    259264      if (count($Keys) > 0)
    260265      {
    261         $Output .= 'if ('.implode(' || ', $Keys).') {
    262           var ccv = $(\'#\'+key).val();
    263           if(ccv!=val) $(\'#\'+key).val(val==0?\'\':val);
     266        $Output .= 'if ('.implode(' || ', $Keys).')
     267        {
     268          var ccv = $(\'#\' + key).val();
     269          if (ccv != val) $(\'#\' + key).val(val == 0 ? \'\' : val);
    264270        }
    265271        ';
     
    269275      foreach ($this->Items as $Item)
    270276      {
    271         if ($Item['Type'] == 'Enumeration')
    272         {
    273           $Keys[] = 'key==\''.$Item['Name'].'\'';
     277        if (($Item['Type'] == 'Enumeration') or ($Item['Type'] == 'Boolean'))
     278        {
     279          $Keys[] = 'key == \''.$Item['Name'].'\'';
    274280        }
    275281      }
    276282      if (count($Keys) > 0)
    277283      {
    278         $Output .= 'if('.implode(' || ', $Keys).') {
    279            $(\'.c\'+key).removeClass(\'active\');
    280            $(\'#\'+key+val).addClass(\'active\');
     284        $Output .= 'if ('.implode(' || ', $Keys).')
     285        {
     286           $(\'.c\' + key).removeClass(\'active\');
     287           $(\'#\' + key + val).addClass(\'active\');
    281288        }
    282289        ';
     
    285292   }
    286293
    287    function upf(key,val,lonreload){
    288       if(key!=\'first\') cf[\'first\']=0; else st();
    289       setupc(key,val);
    290       cf[key]=val;
    291       if(lonreload) initLTimer(1000); else initLTimer(100);
     294   function upf(key, val, lonreload)
     295   {
     296      if (key != \'first\') cf[\'first\'] = 0;
     297        else st();
     298      setupc(key, val);
     299      cf[key] = val;
     300      if (lonreload) initLTimer(1000);
     301        else initLTimer(100);
    292302   }
    293303
    294    function freloader(){
     304   function freloader()
     305   {
    295306      ltimer = null;
    296       var qp = jQuery.param( cf );
    297       $(\'#list_content\').html(\'\'); $(\'#list_loading\').show();
    298       $.get(\''.$Link.'?lvm=seznam&\'+qp,function(data){$(\'#list_loading\').hide();$(\'#list_content\').html(data);})
     307      var qp = jQuery.param(cf);
     308      $(\'#list_content\').html(\'\');
     309      $(\'#list_loading\').show();
     310      $.get(\''.$Link.'?lvm=seznam&\' + qp, function(data)
     311      {
     312        $(\'#list_loading\').hide();
     313        $(\'#list_content\').html(data);
     314      });
    299315   }'.
    300316      '</script>
     
    310326            '</div> ';
    311327        } else
     328        if ($Item['Type'] == 'Boolean')
     329        {
     330          $Output .= '<div class="btn-group ma3">';
     331          $Output .= '<button class="btn btn-filter';
     332          $Output .= ' c'.$Item['Name'].'" onclick="upf(\''.$Item['Name'].'\',cf.'.$Item['Name'].'?0:1)" id="'.$Item['Name'].'1" data-toggle="tooltip" '.
     333            'data-placement="top" title="'.$Item['Title'].'"><span>'.$Item['Title'].'</span></button>';
     334          $Output .= '</div>';
     335        } else
    312336        if ($Item['Type'] == 'Enumeration')
    313337        {
     
    316340          foreach ($Item['States'] as $EnumIndex => $EnumItem)
    317341          {
    318             $Output .= '<button class="btn btn-filter c'.$Item['Name'].' btn-ico" onclick="upf(\''.$Item['Name'].'\','.$EnumIndex.')" id="'.$Item['Name'].$EnumIndex.'" data-toggle="tooltip" '.
     342            $Output .= '<button class="btn btn-filter c'.$Item['Name'].' btn-ico" onclick="upf(\''.$Item['Name'].'\','.$EnumIndex.')" id="'.
     343              $Item['Name'].$EnumIndex.'" data-toggle="tooltip" '.
    319344              'data-placement="top" title="'.$EnumItem.'"><span class="icon-'.$EnumIndex.'"></span></button>';
    320345          }
     
    345370    foreach($this->Items as $Item)
    346371    {
    347       if ($Item['Type'] == 'String')
    348       {
    349         if ($_SESSION[$Item['Name']] != '')
    350           $Where .= ' AND ('.$Item['DbName'].' LIKE "%'.$Database->real_escape_string($_SESSION[$Item['Name']]).'%")';
    351       } else
    352       if ($Item['Type'] == 'Enumeration')
    353       {
    354         if ($_SESSION[$Item['Name']] != '')
    355           $Where .= ' AND ('.$Item['DbName'].' = '.$Database->real_escape_string($_SESSION[$Item['Name']]).')';
    356       } else
    357       if ($Item['Type'] == 'Integer')
    358       {
    359         if ($_SESSION[$Item['Name'].'od'] != '')
    360           $Where .= ' AND ('.$Item['DbName'].' >= '.$Database->real_escape_string($_SESSION[$Item['Name'].'od']).')';
    361         if ($_SESSION[$Item['Name'].'do'] != '')
    362           $Where .= ' AND ('.$Item['DbName'].' <= '.$Database->real_escape_string($_SESSION[$Item['Name'].'do']).')';
     372      if ($Item['DbName'] != '')
     373      {
     374        if ($Item['Type'] == 'String')
     375        {
     376          if ($_SESSION[$Item['Name']] != '')
     377            $Where .= ' AND ('.$Item['DbName'].' LIKE "%'.$Database->real_escape_string($_SESSION[$Item['Name']]).'%")';
     378        } else
     379        if ($Item['Type'] == 'Boolean')
     380        {
     381          if ($_SESSION[$Item['Name']] != '')
     382            $Where .= ' AND ('.$Item['DbName'].' = '.$Database->real_escape_string($_SESSION[$Item['Name']]).')';
     383        } else
     384        if ($Item['Type'] == 'Enumeration')
     385        {
     386          if ($_SESSION[$Item['Name']] != '')
     387            $Where .= ' AND ('.$Item['DbName'].' = '.$Database->real_escape_string($_SESSION[$Item['Name']]).')';
     388        } else
     389        if ($Item['Type'] == 'Integer')
     390        {
     391          if ($_SESSION[$Item['Name'].'od'] != '')
     392            $Where .= ' AND ('.$Item['DbName'].' >= '.$Database->real_escape_string($_SESSION[$Item['Name'].'od']).')';
     393          if ($_SESSION[$Item['Name'].'do'] != '')
     394            $Where .= ' AND ('.$Item['DbName'].' <= '.$Database->real_escape_string($_SESSION[$Item['Name'].'do']).')';
     395        }
    363396      }
    364397    }
  • trunk/Modules/Event/Event.php

    r51 r52  
    5858  public $Id;
    5959  public $Database;
     60  public $AddedCount;
     61
     62  function ImportInternal()
     63  {
     64  }
    6065
    6166  function Import()
    6267  {
    6368    $this->AddedCount = 0;
    64     $Output = 'Parsing '.$this->Name.' ('.$this->Id.')...</br>';
     69    $Output = 'Parsing '.$this->Name.' ('.$this->Id.')...';
     70    $this->ImportInternal();
     71    $Output .= 'done.';
     72    if ($this->AddedCount > 0) $Output .= ' '.$this->AddedCount.' new.';
     73    $Output .= '</br>'."\n";
    6574    return $Output;
    6675  }
  • trunk/Modules/Event/EventPage.php

    r51 r52  
    3838    $Filter = new Filter();
    3939    $Filter->Items = array(
     40      array('Name' => 'past', 'Type' => 'Boolean', 'DbName' => '', 'Title' => 'Proběhlé'),
    4041      array('Name' => 'title', 'Type' => 'String', 'DbName' => 'Title', 'Title' => 'Titulek'),
    4142      array('Name' => 'description', 'Type' => 'String', 'DbName' => 'Description', 'Title' => 'Popis'),
    42       array('Name' => 'price', 'Type' => 'String', 'DbName' => 'Price', 'Title' => 'Cena'),
     43      array('Name' => 'price', 'Type' => 'Integer', 'DbName' => 'Price', 'Title' => 'Cena'),
    4344      array('Name' => 'location', 'Type' => 'String', 'DbName' => 'Location', 'Title' => 'Umístění'),
    4445      array('Name' => 'source', 'Type' => 'String', 'DbName' => 'SourceName', 'Title' => 'Import'),
     
    5354    $Output .= $Filter->GetOutput($this->System->Link('/udalosti/'));
    5455    $Where = $Filter->GetWhere($this->Database);
     56    if ($_SESSION['past'] != 1) $Where .= ' AND (TimeFrom > NOW())';
    5557
    5658    $DbResult = $this->Database->query('SELECT COUNT(*) FROM (SELECT *, '.
     
    7173      array('Name' => '', 'Title' => 'Detail'),
    7274    );
    73     $Order = GetOrderTableHeader($TableColumns, 'TimeFrom', 1);
     75    $Order = GetOrderTableHeader($TableColumns, 'TimeFrom', 0);
    7476    $Output .= '<table class="WideTable">';
    7577    $Output .= $Order['Output'];
  • trunk/Modules/Event/Import/JoeClub.php

    r51 r52  
    33class EventSourceJoeClub extends EventSource
    44{
    5   function Import()
     5  function ImportInternal()
    66  {
    7     $Output = parent::Import();
     7    $Output = '';
    88    $Content = file_get_contents($this->URL);
    99
     
    6262    $Event->Price = trim(str_replace('Kč', '', $Event->Price));
    6363    if ($Event->Price == 'Zdarma') $Event->Price = 0;
     64    if ($Event->Price == '') $Event->Price = 0;
    6465    return $Output;
    6566  }
Note: See TracChangeset for help on using the changeset viewer.