Changeset 24 for trunk


Ignore:
Timestamp:
Sep 6, 2019, 10:58:26 PM (5 years ago)
Author:
chronos
Message:
  • Added: Search field for searching name in runners, teams and families.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/index.php

    r23 r24  
    4949  function YearList($Path, $SelectedYear)
    5050  {
    51     $Output = '<div class="year-list">Year: ';
     51    $Output = 'Year: ';
    5252    $DbResult = $this->Database->query('SELECT DISTINCT(Year) AS Year FROM `Runner` ORDER BY Year ASC');
    5353    while ($DbRow = $DbResult->fetch_assoc())
     
    5858      $Output .= $Item.' ';
    5959    }
    60     $Output .= '</div>';
    6160    return $Output;
    6261  }
     
    306305    $Output = '';
    307306    $Output .= '<div class="page-title">Families</div>';
    308 
    309     $Year = 0;
    310     if ((count($this->PathItems) > 0) and ($this->PathItems[count($this->PathItems) - 1] != ''))
    311       $Year = $this->PathItems[count($this->PathItems) - 1] * 1;
    312     if ($Year == 0) $Year = $this->GetLatestYear();
    313 
    314     $Output .= $this->YearList('/families/', $Year);
     307    $Year = $this->GetYear();
     308
     309    $Output .= '<div class="section-title">'.$this->YearList('/families/', $Year).' Name: '.$this->ShowSearch().'</div>';
    315310    $Where = '(IsFamily=1) AND (Year='.$Year.')';
     311    if (array_key_exists('query', $_GET) and ($_GET['query'] != ''))
     312    {
     313      $Where .= ' AND (Name LIKE "%'.addslashes($_GET['query']).'%")';
     314    }
    316315
    317316    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Team` WHERE '.$Where);
     
    426425    $Output = '';
    427426    $Output .= '<div class="page-title">Teams</div>';
    428 
    429     $Year = 0;
    430     if ((count($this->PathItems) > 0) and ($this->PathItems[count($this->PathItems) - 1] != ''))
    431       $Year = $this->PathItems[count($this->PathItems) - 1] * 1;
    432     if ($Year == 0) $Year = $this->GetLatestYear();
    433 
    434     $Output .= $this->YearList('/teams/', $Year);
     427    $Year = $this->GetYear();
    435428
    436429    $Where = '(IsFamily=0) AND (Year='.$Year.')';
     430    if (array_key_exists('query', $_GET) and ($_GET['query'] != ''))
     431    {
     432      $Where .= ' AND (Name LIKE "%'.addslashes($_GET['query']).'%")';
     433    }
     434    $Output .= '<div class="section-title">'.$this->YearList('/teams/', $Year).' Name: '.$this->ShowSearch().'</div>';
    437435
    438436    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Team` WHERE '.$Where);
     
    554552    $PrefixMultiplier = new PrefixMultiplier();
    555553
    556     $Output = '<div class="section-title">Detailed</div>';
     554    $Output = '<div class="section-title">Lap progress</div>';
    557555    $Where = $Table.'Stat.'.$Table.'='.$Id;
    558556    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `'.$Table.'Stat` WHERE '.$Where);
     
    611609    $PageList = GetPageList($DbRow[0]);
    612610
    613     $Output = '<div class="section-title">Daily</div>';
     611    $Output = '<div class="section-title">Daily progress</div>';
    614612    $Output .= '<div id="list_content">';
    615613    $Output .= $PageList['Output'];
     
    652650  }
    653651
     652  function ShowSearch()
     653  {
     654    if (array_key_exists('query', $_GET)) $Query = $_GET['query'];
     655      else $Query = '';
     656    $Output = '<form action="?" method="get" style="display: inline;">';
     657    $Output .= '<input type="text" size="10" name="query" value="'.$Query.'"/> '.
     658      '<input type="submit" value="Search"/>';
     659    $Output .= '</form>';
     660    return $Output;
     661  }
     662
    654663  function ShowRunners()
    655664  {
    656665    $Output = '<div class="page-title">Runners</div>';
    657 
    658     $Year = 0;
    659     if ((count($this->PathItems) > 0) and ($this->PathItems[count($this->PathItems) - 1] != ''))
    660       $Year = $this->PathItems[count($this->PathItems) - 1] * 1;
    661     if ($Year == 0) $Year = $this->GetLatestYear();
    662 
    663     $Output .= $this->YearList('/runners/', $Year);
    664 
    665     $Where = 'Year='.$Year;
     666    $Year = $this->GetYear();
     667
     668    $Output .= '<div class="section-title">'.$this->YearList('/runners/', $Year).' Name: '.$this->ShowSearch().'</div>';
     669    $Where = '(Year='.$Year.')';
     670    if (array_key_exists('query', $_GET) and ($_GET['query'] != ''))
     671    {
     672      $Where .= ' AND (Name LIKE "%'.addslashes($_GET['query']).'%")';
     673    }
     674
    666675    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Runner` WHERE '.$Where);
    667676    $DbRow = $DbResult->fetch_row();
     
    736745  }
    737746
     747  function GetYear()
     748  {
     749    $Year = 0;
     750    if (count($this->PathItems) > 0)
     751    {
     752      $Param = $this->PathItems[count($this->PathItems) - 1];
     753      if (is_numeric($this->PathItems[count($this->PathItems) - 1]))
     754        $Year = $this->PathItems[count($this->PathItems) - 1] * 1;
     755    }
     756    if ($Year == 0) $Year = $this->GetLatestYear();
     757    return $Year;
     758  }
     759
    738760  function ShowMain()
    739761  {
     
    741763    $Output .= '<p>This website collects data from offical <a href="'.$this->LeaderboardURL.'">leaderboard</a> site and tracks and presents progress of runners.</p>';
    742764    $Output .= '<div class="page-title">Summary</div>';
    743 
    744     $Year = 0;
    745     if ((count($this->PathItems) > 0) and ($this->PathItems[count($this->PathItems) - 1] != ''))
    746       $Year = $this->PathItems[count($this->PathItems) - 1] * 1;
    747     if ($Year == 0) $Year = $this->GetLatestYear();
    748 
    749     $Output .= $this->YearList('/', $Year);
     765    $Year = $this->GetYear();
     766
     767    $Output .= '<div class="section-title">'.$this->YearList('/', $Year).'</div>';
    750768
    751769    $Runners = $this->GetTotals('(Year='.$Year.')');
  • trunk/style.css

    r21 r24  
    8181  padding-bottom: 7px;
    8282}
    83 
    84 .year-list
    85 {
    86   text-align: center;
    87   padding-bottom: 7px;
    88 }
Note: See TracChangeset for help on using the changeset viewer.