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/ShoutBox/ShoutBox.php

    r622 r626  
    2020          'Title' => 'Kecátko', 'Channel' => 'shoutbox', 'Callback' => array('PageShoutBox', 'ShowRSS'),
    2121          'Permission' => LICENCE_ANONYMOUS));           
     22    if(array_key_exists('Search', $this->System->ModuleManager->Modules))
     23      $this->System->ModuleManager->Modules['Search']->RegisterSearch('shoutbox',
     24      T('Shoutbox'), array('UserName', 'Text'), '`ShoutBox`', $this->System->Link('/shoutbox/?search='));
    2225  }
    2326 
    2427  function ShowBox()
    2528  {
    26         $Output = '<strong><a href="'.$this->System->Link('/shoutbox/').'">'.T('Chatbox').':</a></strong>';
     29        $Output = '<strong><a href="'.$this->System->Link('/shoutbox/').'">'.T('Shoutbox').':</a></strong>';
    2730         
    2831        if($this->System->User->Licence(LICENCE_USER))
     
    5255        function ShowList()
    5356        {
    54         $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `ShoutBox`');
     57                $Output = '';
     58                if(array_key_exists('search', $_GET)) $_SESSION['search'] = $_GET['search'];
     59                else if(!array_key_exists('search', $_SESSION)) $_SESSION['search'] = '';
     60                if(array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = '';
     61                if($_SESSION['search'] != '')
     62                {
     63                        $SearchQuery = ' AND (`Text` LIKE "%'.$_SESSION['search'].'%")';
     64                        $Output .= '<div><a href="?search=">'.sprintf(T('Disable filter "%s"'), $_SESSION['search']).'</a></div>';
     65                } else $SearchQuery = '';                       
     66
     67        $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `ShoutBox` WHERE 1'.$SearchQuery);
    5568                $DbRow = $DbResult->fetch_row();
    56                 $PageList = GetPageList($DbRow[0]);
    57                
    58                 $Output = '<h3>Kecátko</h3>'.$PageList['Output'];
     69                $PageList = GetPageList($DbRow[0]);     
     70
     71                $Output .= '<h3>'.T('Shoutbox').'</h3>'.$PageList['Output'];
    5972                if($this->System->User->Licence(LICENCE_USER))
    6073                        $Output .= ' <a href="'.$this->System->Link('/shoutbox/?a=add').'">'.T('Add').'</a>';
    6174                $Output .= '<div class="shoutbox">';
    62                 $DbResult = $this->System->Database->query('SELECT * FROM `ShoutBox` ORDER BY `ID` DESC '.$PageList['SQLLimit']);
     75                $DbResult = $this->System->Database->query('SELECT * FROM `ShoutBox`  WHERE 1'.$SearchQuery.' ORDER BY `ID` DESC '.$PageList['SQLLimit']);
    6376                while($Line = $DbResult->fetch_assoc())
    6477                        $Output .= '<div><strong>'.$Line['UserName'].'</strong>: '.MakeActiveLinks($Line['Text']).'</div>';
Note: See TracChangeset for help on using the changeset viewer.