Ignore:
Timestamp:
Apr 7, 2020, 10:15:48 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved code formatting.
File:
1 edited

Legend:

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

    r857 r880  
    2020      'Title' => T('Shoutbox'), 'Channel' => 'shoutbox', 'Callback' => array('PageShoutBox', 'ShowRSS'),
    2121      'Permission' => LICENCE_ANONYMOUS));
    22     if(array_key_exists('Search', $this->System->ModuleManager->Modules))
     22    if (array_key_exists('Search', $this->System->ModuleManager->Modules))
    2323      $this->System->ModuleManager->Modules['Search']->RegisterSearch('shoutbox',
    2424      T('Shoutbox'), array('UserName', 'Text'), '`ShoutBox`', $this->System->Link('/shoutbox/?search='));
     
    2929    $Output = '<strong><a href="'.$this->System->Link('/shoutbox/').'">'.T('Shoutbox').':</a></strong>';
    3030
    31     if($this->System->User->Licence(LICENCE_USER))
     31    if ($this->System->User->Licence(LICENCE_USER))
    3232      $Output .= ' <a href="'.$this->System->Link('/shoutbox/?a=add').'">'.T('Add').'</a>';
    3333    $Output .= '<div class="box"><div class="shoutbox"><table>';
    3434    $DbResult = $this->Database->query('SELECT * FROM `ShoutBox` ORDER BY `ID` DESC LIMIT 30');
    35     while($Line = $DbResult->fetch_assoc())
     35    while ($Line = $DbResult->fetch_assoc())
    3636      $Output .= '<tr><td><strong>'.$Line['UserName'].'</strong>: '.MakeActiveLinks($Line['Text']).'</td></tr>';
    3737    $Output .= '</table></div></div>';
    38     return($Output);
     38    return $Output;
    3939  }
    4040}
     
    4545  {
    4646    $this->Title = T('Shoutbox');
    47     if(array_key_exists('a', $_POST)) $Action = $_POST['a'];
    48       else if(array_key_exists('a', $_GET)) $Action = $_GET['a'];
     47    if (array_key_exists('a', $_POST)) $Action = $_POST['a'];
     48      else if (array_key_exists('a', $_GET)) $Action = $_GET['a'];
    4949      else $Action = '';
    50     if($Action == 'add2') $Output = $this->AddFinish();
    51     if($Action == 'add') $Output = $this->ShowAddForm();
     50    if ($Action == 'add2') $Output = $this->AddFinish();
     51    if ($Action == 'add') $Output = $this->ShowAddForm();
    5252    else $Output = $this->ShowList();
    53     return($Output);
     53    return $Output;
    5454  }
    5555
     
    5757  {
    5858    $Output = '';
    59     if(array_key_exists('search', $_GET)) $_SESSION['search'] = $_GET['search'];
    60     else if(!array_key_exists('search', $_SESSION)) $_SESSION['search'] = '';
    61     if(array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = '';
    62     if($_SESSION['search'] != '')
     59    if (array_key_exists('search', $_GET)) $_SESSION['search'] = $_GET['search'];
     60    else if (!array_key_exists('search', $_SESSION)) $_SESSION['search'] = '';
     61    if (array_key_exists('search', $_GET) and ($_GET['search'] == '')) $_SESSION['search'] = '';
     62    if ($_SESSION['search'] != '')
    6363    {
    6464      $SearchQuery = ' AND (`Text` LIKE "%'.$_SESSION['search'].'%")';
     
    7171
    7272    $Output .= '<h3>'.T('Shoutbox').'</h3>';
    73     if($this->System->User->Licence(LICENCE_USER))
     73    if ($this->System->User->Licence(LICENCE_USER))
    7474      $Output .= ' <a href="'.$this->System->Link('/shoutbox/?a=add').'">'.T('Add').'</a>';
    7575    $Output .= $PageList['Output'];
    7676    $Output .= '<div class="shoutbox">';
    7777    $DbResult = $this->System->Database->query('SELECT * FROM `ShoutBox`  WHERE 1'.$SearchQuery.' ORDER BY `ID` DESC '.$PageList['SQLLimit']);
    78     while($Line = $DbResult->fetch_assoc())
     78    while ($Line = $DbResult->fetch_assoc())
    7979      $Output .= '<div><strong>'.$Line['UserName'].'</strong>: '.MakeActiveLinks($Line['Text']).'</div>';
    8080    $Output .= '</div>'.$PageList['Output'];
    81     return($Output);
     81    return $Output;
    8282  }
    8383
     
    8585  {
    8686    $Output = '';
    87     if($this->System->User->Licence(LICENCE_USER))
     87    if ($this->System->User->Licence(LICENCE_USER))
    8888    {
    8989        $Output .= '<form action="?" method="post">'.
    9090            '<fieldset><legend>'.T('New message').'</legend>'.
    9191            'Uživatel: ';
    92         if($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />';
     92        if ($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />';
    9393        else $Output .= '<input type="text" name="user" /><br />';
    9494      $Output .= 'Text zprávy: <br/>'.
     
    9999    } else $Output .= ShowMessage('Pro vkládaní zpráv musíte byt registrováni.', MESSAGE_CRITICAL);
    100100    $Output .= $this->ShowList();
    101     return($Output);
     101    return $Output;
    102102  }
    103103
     
    105105  {
    106106    $Output = '';
    107     if($this->System->User->Licence(LICENCE_USER))
     107    if ($this->System->User->Licence(LICENCE_USER))
    108108    {
    109       if(array_key_exists('text', $_POST))
     109      if (array_key_exists('text', $_POST))
    110110      {
    111111        $Text = $_POST['text'];
    112         if(trim($Text) == '') $Output .= ShowMessage('Nelze vložit prázdnou zprávu.', MESSAGE_WARNING);
     112        if (trim($Text) == '') $Output .= ShowMessage('Nelze vložit prázdnou zprávu.', MESSAGE_WARNING);
    113113        else
    114114        {
     
    116116          $DbResult = $this->System->Database->query('SELECT `Text` FROM `ShoutBox` WHERE (`User` = "'.
    117117              $this->System->User->Id.'") ORDER BY `Date` DESC LIMIT 1');
    118           if($DbResult->num_rows > 0)
     118          if ($DbResult->num_rows > 0)
    119119          {
    120120            $DbRow = $DbResult->fetch_assoc();
    121121          } else $DbRow['Text'] = '';
    122122
    123           if($DbRow['Text'] == $Text) $Output .= ShowMessage('Nelze vložit stejnou zprávu vícekrát za sebou.', MESSAGE_WARNING);
     123          if ($DbRow['Text'] == $Text) $Output .= ShowMessage('Nelze vložit stejnou zprávu vícekrát za sebou.', MESSAGE_WARNING);
    124124          else
    125125          {
     
    134134    } else $Output .= ShowMessage('Pro vkládaní zpráv musíte byt registrováni.', MESSAGE_CRITICAL);
    135135    $Output .= $this->ShowList();
    136     return($Output);
     136    return $Output;
    137137  }
    138138
     
    143143    mb_internal_encoding('utf-8');
    144144    $DbResult = $this->Database->query('SELECT UNIX_TIMESTAMP(`Date`) AS `UnixDate`, `User`, `UserName`, `Text` FROM `ShoutBox` ORDER BY `ID` DESC LIMIT 20');
    145     while($DbRow = $DbResult->fetch_assoc())
     145    while ($DbRow = $DbResult->fetch_assoc())
    146146    {
    147147      $Title = mb_substr($DbRow['Text'], 0, $TitleLength);
    148       if(mb_strlen($Title) == $TitleLength) $Title .= '...';
     148      if (mb_strlen($Title) == $TitleLength) $Title .= '...';
    149149      $Items[] = array
    150150      (
     
    163163      'Items' => $Items,
    164164    ));
    165     return($Output);
     165    return $Output;
    166166  }
    167167}
Note: See TracChangeset for help on using the changeset viewer.