Ignore:
Timestamp:
Jan 22, 2014, 6:12:46 PM (11 years ago)
Author:
maron
Message:
  • Fixed: search with diacriticals
  • Modified: Not show items search when nothing was found
  • Added: bbcode in Forum.php
  • Added: search in forum
  • Added: Last post at forum in user profile
File:
1 edited

Legend:

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

    r750 r760  
    2020          'Title' => T('Forum'), 'Channel' => 'forum', 'Callback' => array('PageForum', 'ShowRSS'),
    2121          'Permission' => LICENCE_ANONYMOUS));           
    22                 $this->System->RegisterMenuItem(array(
     22   
     23    if(array_key_exists('Search', $this->System->ModuleManager->Modules))
     24      $this->System->ModuleManager->Modules['Search']->RegisterSearch('forum',
     25      T('Forum'), array('UserName', 'Text'), '`ForumText`', $this->System->Link('/forum/?search='));
     26    if(array_key_exists('Search', $this->System->ModuleManager->Modules))
     27      $this->System->ModuleManager->Modules['Search']->RegisterSearch('forumthread',
     28      'Název vlákna fóra', array('UserName', 'Text'), '`ForumThread`', $this->System->Link('/forum/?search='));
     29               
     30    $this->System->RegisterMenuItem(array(
    2331      'Title' => T('Forum'),
    2432      'Hint' => 'Forum na debatování ohledně překladu wow',
     
    3947          else if(array_key_exists('a', $_GET)) $Action = $_GET['a'];
    4048           else $Action = '';
     49    if (array_key_exists('search', $_GET))
     50      $Output .= $this->ShowSearchForum();
     51    else
    4152    if (array_key_exists('Thread', $_GET)) {
    4253                $Output .= '<h3>'.T('Forum - Thread').'</h3>';
     
    6273  }
    6374       
     75        function ShowSearchForum()
     76  {
     77    $parser = new HTML_BBCodeParser2(array('filters' => array('Basic','Extended','Images','Links','Lists','Email')));
     78        $Count = 20;
     79        $Output = '';
     80 
     81                $Output .= '<div class="shoutbox">';
     82    $where = '`ForumText`.`Text` LIKE "%'.($_GET['search'] ).'%" OR '.
     83    ' `ForumThread`.`Text` LIKE "%'.($_GET['search'] ).'%" OR `ForumThread`.`UserName` LIKE "%'.($_GET['search'] ).'%" OR '.
     84    ' `ForumText`.`UserName` LIKE "%'.($_GET['search'] ).'%"';
     85    $join = ' JOIN `ForumThread` ON `ForumThread`.`ID` = `ForumText`.`Thread`';
     86
     87        $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `ForumText` '.$join.' WHERE '.$where);
     88                $DbRow = $DbResult->fetch_row();
     89                $PageList = GetPageList($DbRow[0]);     
     90
     91                $Output .= $PageList['Output'];
     92
     93                $DbResult = $this->System->Database->query('SELECT `ForumText`.`Text`, `ForumText`.`Date`, `ForumText`.`UserName`,'.
     94    '`ForumThread`.`Text` as `ThreadName`,`ForumText`.`Thread` FROM `ForumText` '.$join.' WHERE '.$where.' ORDER BY `ForumText`.`Date` DESC '.$PageList['SQLLimit']);
     95                while($Line = $DbResult->fetch_assoc())
     96                        $Output .= '<div><a href="'.$this->System->Link('/forum/?Thread='.$Line['Thread']).'">'.$Line['ThreadName'].'</a><br /><strong>'.$Line['UserName'].'</strong> ('.HumanDate($Line['Date']).'): '.$parser->qparse($Line['Text']).'</div> ';
     97                $Output .= '</div>'.$PageList['Output'];
     98                return($Output);
     99
     100        return($Output);
     101  }
     102
    64103        function ShowListThread()
    65104        {
     
    74113                $DbResult = $this->System->Database->query('SELECT * FROM `ForumThread`  WHERE 1 ORDER BY `ID` DESC '.$PageList['SQLLimit']);
    75114                while($Line = $DbResult->fetch_assoc())
    76                         $Output .= '<div><a href="?Thread='.$Line['ID'].'">'.MakeActiveLinks(str_replace("\n", '',$Line['Text'])).'</a> (<strong>'.$Line['UserName'].'</strong>) - '.HumanDate($Line['Date']).'</div>';
     115                        $Output .= '<div><a href="?Thread='.$Line['ID'].'">'.str_replace("\n", '',$Line['Text']).'</a> (<strong>'.$Line['UserName'].'</strong>) - '.HumanDate($Line['Date']).'</div>';
    77116                $Output .= '</div>'.$PageList['Output'];
    78117                return($Output);
     
    82121        {
    83122                $Output = '';
     123   
     124    $parser = new HTML_BBCodeParser2(array('filters' => array('Basic','Extended','Images','Links','Lists','Email')));
     125  //  echo $parser->qparse('[youtube]http://www.youtube.com/watch?v=hwgO6p2Jh-A[/youtube][img]http://www.bbcode.org/images/lubeck_small.jpg[/img]normal [i][b]bold[/b][/i] [img]http://imageshack.com/a/img203/7462/6ctg.jpg[/img]  and normal again');
     126   
    84127                if(array_key_exists('search', $_GET)) $_SESSION['search'] = $_GET['search'];
    85128                else if(!array_key_exists('search', $_SESSION)) $_SESSION['search'] = '';
     
    103146                $DbResult = $this->System->Database->query('SELECT * FROM `ForumText`  WHERE `Thread` = '.$_GET['Thread'].' '.$SearchQuery.' ORDER BY `ID` DESC '.$PageList['SQLLimit']);
    104147                while($Line = $DbResult->fetch_assoc())
    105                         $Output .= '<div><strong>'.$Line['UserName'].'</strong> ('.HumanDate($Line['Date']).'): '.MakeActiveLinks($Line['Text']).'</div> ';
     148                        $Output .= '<div><strong>'.$Line['UserName'].'</strong> ('.HumanDate($Line['Date']).'): '.$parser->qparse($Line['Text']).'</div> ';
    106149                $Output .= '</div>'.$PageList['Output'];
    107150                return($Output);
     
    118161                                if($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />';
    119162                                else $Output .= '<input type="text" name="user" /><br />';
    120                         $Output .= 'Text zprávy: <br/>'.
    121                         '<textarea onkeydown="ResizeTextArea(this)" name="text" cols="40" ></textarea> <br/>'.
     163                        $Output .= 'Text zprávy: (Můžete využít <a href="http://www.bbcode.org/reference.php">BB kód</a>)<br/>'.                         
     164                        '<textarea onkeydown="ResizeTextArea(this)" name="text" cols="80"></textarea> <br/>'.
    122165                        '<input type="hidden" name="a" value="add2"/>'.
    123166                        '<input type="submit" value="Odeslat" /><br /></fieldset>'.
Note: See TracChangeset for help on using the changeset viewer.