Changeset 626 for trunk/Modules/Team


Ignore:
Timestamp:
Dec 4, 2013, 9:50:16 PM (11 years ago)
Author:
chronos
Message:
  • Modified: Search page generalized as dynamic configurable list. Other modules can register their search ability.
  • Modified: If sarch is invoked on some module then filter is added to table. Filter have to be disabled to view all items again.
  • Added: Shoutbox can be searched.
File:
1 edited

Legend:

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

    r622 r626  
    2020      'Title' => T('Teams'),
    2121      'Hint' => T('List of translating teams'),
    22       'Link' => $this->System->Link('/team/?search='),
     22      'Link' => $this->System->Link('/team/'),
    2323      'Permission' => LICENCE_ANONYMOUS,
    2424      'Icon' => '',
    2525    ), 1);
     26    if(array_key_exists('Search', $this->System->ModuleManager->Modules))
     27      $this->System->ModuleManager->Modules['Search']->RegisterSearch('team',
     28      T('Teams'), array('Name'), '`Team`', $this->System->Link('/team/?search='));
    2629  }
    2730}
     
    3639                $Output .= 'Týmy jsou seskupení překladatelů, kteří se hlásí k něčemu společnému jako např. WoW serveru, způsobu překladu, ke stejnému hernímu spolku, aj. Být členem týmu samo o sobě nemá žádný zásadní důsledek a spíše to může pomoci se lépe orientovat mezi překladateli někomu, kdo sestavuje export.<br/>';
    3740
    38     if($this->System->User->Licence(LICENCE_USER))
     41    if(array_key_exists('search', $_GET)) $_SESSION['search'] = $_GET['search'];
     42                else if(!array_key_exists('search', $_SESSION)) $_SESSION['search'] = '';
     43                if (array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = '';
     44       
     45          if($this->System->User->Licence(LICENCE_USER))
    3946                  $Output .= '<br /><div style="text-align: center;"><a href="?action=create">'.T('Create translating team').'</a></div><br/>';
     47                if($_SESSION['search'] != '')
     48                {
     49                        $SearchQuery = ' AND ((`Name` LIKE "%'.$_SESSION['search'].'%") OR (`Description` LIKE "%'.$_SESSION['search'].'%"))';
     50                        $Output .= '<div><a href="?search=">'.sprintf(T('Disable filter "%s"'), $_SESSION['search']).'</a></div>';
     51                } else $SearchQuery = '';               
    4052               
    41           $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Team`');
     53          $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Team` WHERE 1'.$SearchQuery);
    4254                $DbRow = $DbResult->fetch_row();
    4355                $PageList = GetPageList($DbRow[0]);
     
    5668       
    5769                $Order = GetOrderTableHeader($TableColumns, 'NumberUser', 1);
    58                 $Output .= $Order['Output'];
    59        
    60                 if(array_key_exists('search', $_GET)) $_SESSION['search'] = ' WHERE `Name` LIKE "%'.$_GET['search'].'%" OR `Description` LIKE "%'.$_GET['search'].'%"';
    61                 else if(!array_key_exists('search', $_SESSION)) $_SESSION['search'] = '';
    62                 if (array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = '';
     70                $Output .= $Order['Output'];   
    6371       
    6472                $DbResult = $this->Database->query('SELECT *, (SELECT COUNT(*) FROM `User` WHERE `User`.`Team` = `Team`.`Id`) AS `NumberUser`, '.
    6573                        '(SELECT `Name` FROM `User` WHERE `User`.`ID`=`Team`.`Leader`) AS `LeaderName` '.
    66                         'FROM `Team` '.$_SESSION['search'].$Order['SQL'].$PageList['SQLLimit']);
     74                        'FROM `Team` WHERE 1'.$SearchQuery.$Order['SQL'].$PageList['SQLLimit']);
    6775                while($Team = $DbResult->fetch_assoc())
    6876                {
Note: See TracChangeset for help on using the changeset viewer.