Changeset 760


Ignore:
Timestamp:
Jan 22, 2014, 6:12:46 PM (10 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
Location:
trunk
Files:
11 added
5 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>'.
  • trunk/Modules/Search/Search.php

    r636 r760  
    4343                else if(array_key_exists('text', $_POST)) $Search = $_POST['text'];
    4444                else $Search = '';
    45                 $SearchHTML = htmlentities($Search);
     45                $SearchHTML = urlencode($Search);
    4646               
    4747                $Output = '<table class="BaseTable"><tr><th>'.T('Section').'</th><th>'.T('Found count').'</th></tr>';
     
    5252                        {
    5353                          $ColumnQuery[] = '(`'.$Column.'` LIKE "%'.$Search.'%")';
    54                   }
     54                  } 
    5555                  $ColumnQuery = implode(' OR ', $ColumnQuery);
    5656                  if($SearchItem['Query'] != '')
    57                   {
     57                  {                      
    5858                    $DbResult = $this->Database->query('SELECT COUNT(*) FROM '.$SearchItem['Query'].' WHERE '.$ColumnQuery);
    5959                  $Line = $DbResult->fetch_row();
    6060                  $Line = $Line[0];
    6161                  } else $Line = '';
    62                 $Output .= '<tr><td><a href="'.$SearchItem['Link'].$SearchHTML.'">'.$SearchItem['Name'].'</a></td><td>'.$Line.'</td></tr>';
     62      if ($Line <> 0)
     63                  $Output .= '<tr><td><a href="'.$SearchItem['Link'].$SearchHTML.'">'.$SearchItem['Name'].'</a></td><td>'.$Line.'</td></tr>';
    6364                }
    6465 
  • trunk/Modules/User/Profile.php

    r728 r760  
    116116        return($Output);
    117117  }
     118 
     119        function ShowLastForum()
     120  {
     121    $parser = new HTML_BBCodeParser2(array('filters' => array('Basic','Extended','Images','Links','Lists','Email')));
     122        $Count = 20;
     123        $Output = '<strong>Poslední příspěvky ve fóru:</strong>';
     124 
     125                $Output .= '<div class="shoutbox">';
     126                $DbResult = $this->System->Database->query('SELECT `ForumText`.`Text`, `ForumText`.`Date`, `ForumText`.`UserName`,`ForumThread`.`Text` as `ThreadName`,`ForumText`.`Thread` FROM `ForumText` JOIN `ForumThread` ON `ForumThread`.`ID` = `ForumText`.`Thread` WHERE `ForumText`.`User` = '.($_GET['user'] * 1).' ORDER BY `ForumText`.`Date` DESC LIMIT '.$Count);
     127                while($Line = $DbResult->fetch_assoc())
     128                        $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> ';
     129                $Output .= '</div>';
     130                return($Output);
     131
     132        return($Output);
     133  }
    118134               
    119135        function ShowProfile()
     
    149165                        '<td>'.$this->ExportList().'</td>'.
    150166                        '</tr></table>';
    151                
     167                $Output .= '<br />'.$this->ShowLastForum().'<br />';
    152168                if($this->System->User->Licence(LICENCE_MODERATOR))
    153169                {
  • trunk/includes/Version.php

    r759 r760  
    66// and system will need database update.
    77
    8 $Revision = 759; // Subversion revision
     8$Revision = 760; // Subversion revision
    99$DatabaseRevision = 748; // Database structure revision
    10 $ReleaseTime = '2014-01-20';
     10$ReleaseTime = '2014-01-22';
  • trunk/includes/global.php

    r758 r760  
    3333include_once(dirname(__FILE__).'/../Modules/Download/Download.php');
    3434include_once(dirname(__FILE__).'/../Modules/Forum/Forum.php');
     35require_once(dirname(__FILE__).'/../HTML/BBCodeParser2.php');
    3536
    3637
Note: See TracChangeset for help on using the changeset viewer.