Changeset 880 for trunk/Modules/News


Ignore:
Timestamp:
Apr 7, 2020, 10:15:48 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved code formatting.
Location:
trunk/Modules/News
Files:
2 edited

Legend:

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

    r862 r880  
    3535    $DbResult = $this->Database->query('SELECT `News`.`Time`, `User`.`Name`, `News`.`Text`,`News`.`Title`, `News`.`Id` '.
    3636      ' FROM `News` JOIN `User` ON `User`.`ID` = `News`.`User` ORDER BY `Time` DESC LIMIT '.$Count);
    37     while($DbRow = $DbResult->fetch_assoc())
     37    while ($DbRow = $DbResult->fetch_assoc())
    3838    {
    3939      $Output .= '<h4><a href="'.$this->System->Link('/news/?a=item&amp;i='.$DbRow['Id']).'">'.$DbRow['Title'].'</a> ('.HumanDate($DbRow['Time']).')</h4>'.
     
    4141    }
    4242    $Output .= '</div></div>';
    43     return($Output);
     43    return $Output;
    4444  }
    4545
     
    4848    $this->RSSChannels[$Channel['Channel']] = $Channel;
    4949
    50     if(is_null($Pos)) $this->RSSChannelsPos[] = $Channel['Channel'];
     50    if (is_null($Pos)) $this->RSSChannelsPos[] = $Channel['Channel'];
    5151    else {
    5252      array_splice($this->RSSChannelsPos, $Pos, 0, $Channel['Channel']);
     
    5757  {
    5858    $Output = '';
    59     foreach($this->RSSChannels as $Channel)
     59    foreach ($this->RSSChannels as $Channel)
    6060    {
    61       if($this->System->User->Licence($Channel['Permission']))
     61      if ($this->System->User->Licence($Channel['Permission']))
    6262        $Output .= ' <link rel="alternate" title="'.$Channel['Title'].'" href="'.
    6363          $this->System->Link('/rss/?channel='.$Channel['Channel']).'" type="application/rss+xml" />';
    6464    }
    65     return($Output);
     65    return $Output;
    6666  }
    6767}
     
    7272  {
    7373    $this->Title = T('News');
    74     if(array_key_exists('a', $_POST)) $Action = $_POST['a'];
    75       else if(array_key_exists('a', $_GET)) $Action = $_GET['a'];
     74    if (array_key_exists('a', $_POST)) $Action = $_POST['a'];
     75      else if (array_key_exists('a', $_GET)) $Action = $_GET['a'];
    7676      else $Action = '';
    77     if($Action == 'add2') $Output = $this->SaveNew();
    78     else if($Action == 'add') $Output = $this->ShowAddForm();
    79     else if($Action == 'item') $Output = $this->ShowItem();
     77    if ($Action == 'add2') $Output = $this->SaveNew();
     78    else if ($Action == 'add') $Output = $this->ShowAddForm();
     79    else if ($Action == 'item') $Output = $this->ShowItem();
    8080    else $Output = $this->ShowList();
    81     return($Output);
     81    return $Output;
    8282  }
    8383
     
    8989
    9090    $Output = '<h3>'.T('News').'</h3>';
    91     if($this->System->User->Licence(LICENCE_ADMIN))
     91    if ($this->System->User->Licence(LICENCE_ADMIN))
    9292      $Output .= ' <a href="?a=add">'.T('Add').'</a>';
    9393    $Output .= $PageList['Output'];
     
    9595    $DbResult = $this->System->Database->query('SELECT `News`.`Time`, `News`.`Text`, `News`.`Title`, `News`.`Id`, '.
    9696        '`User`.`Name` AS `User` FROM `News` JOIN `User` ON `User`.`Id`=`News`.`User` ORDER BY `News`.`Time` DESC '.$PageList['SQLLimit']);
    97     while($Line = $DbResult->fetch_assoc())
     97    while ($Line = $DbResult->fetch_assoc())
    9898    {
    9999      $Output .= '<h4><a href="?a=item&amp;i='.$Line['Id'].'">'.$Line['Title'].'</a> ('.HumanDate($Line['Time']).')</h4><div>'.$Line['Text'].' ('.$Line['User'].')</div>';
    100100    }
    101101    $Output .= '</div>'.$PageList['Output'];
    102     return($Output);
     102    return $Output;
    103103  }
    104104
    105105  function ShowItem()
    106106  {
    107     if(array_key_exists('i', $_GET))
     107    if (array_key_exists('i', $_GET))
    108108    {
    109109      $Output = '<h3>'.T('News').'</h3>';
    110110      $DbResult = $this->System->Database->query('SELECT `News`.`Time`, `News`.`Text`, `News`.`Title`, `News`.`Id`, '.
    111111        '`User`.`Name` AS `User` FROM `News` JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `News`.`Id` = '.($_GET['i'] * 1));
    112       if($DbResult->num_rows == 1)
     112      if ($DbResult->num_rows == 1)
    113113      {
    114114        $Line = $DbResult->fetch_assoc();
     
    117117    } else $Output = ShowMessage(T('Item not found'), MESSAGE_CRITICAL);
    118118    $Output .= '<br/><a href="'.$this->System->Link('/news/').'">'.T('All news').'</a>';
    119     return($Output);
     119    return $Output;
    120120  }
    121121
    122122  function ShowAddForm()
    123123  {
    124     if($this->System->User->Licence(LICENCE_ADMIN))
     124    if ($this->System->User->Licence(LICENCE_ADMIN))
    125125    {
    126126      $Output = '<form action="?" method="POST">'.
     
    134134    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    135135    $Output .= $this->ShowList();
    136     return($Output);
     136    return $Output;
    137137  }
    138138
    139139  function SaveNew()
    140140  {
    141     if($this->System->User->Licence(LICENCE_ADMIN))
     141    if ($this->System->User->Licence(LICENCE_ADMIN))
    142142    {
    143       if(array_key_exists('text', $_POST) and array_key_exists('title', $_POST))
     143      if (array_key_exists('text', $_POST) and array_key_exists('title', $_POST))
    144144      {
    145145        $querty = 'INSERT INTO `News` (`Title`, `Time` ,`User` ,`Text`) VALUES ( "'.$_POST['title'].'", NOW( ) , '.
     
    151151      } else $Output = ShowMessage(T('Data not specified'), MESSAGE_CRITICAL);
    152152    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    153     return($Output);
     153    return $Output;
    154154  }
    155155
     
    160160      '`News`.`Title`, `News`.`Time`, `User`.`Name`, `News`.`Text`, `News`.`Id` '.
    161161      'FROM `News` JOIN `User` ON `User`.`ID` = `News`.`User` ORDER BY `Time` DESC LIMIT 10');
    162     while($DbRow = $DbResult->fetch_assoc())
     162    while ($DbRow = $DbResult->fetch_assoc())
    163163    {
    164164     $Items[] = array
     
    178178      'Items' => $Items,
    179179    ));
    180     return($Output);
     180    return $Output;
    181181  }
    182182}
  • trunk/Modules/News/RSS.php

    r876 r880  
    1515      "    <pubDate>".date('r')."</pubDate>\n".
    1616      "    <ttl>20</ttl>\n";
    17   foreach($Data['Items'] as $Item)
     17  foreach ($Data['Items'] as $Item)
    1818  {
    1919    $Result .= "    <item>\n".
     
    2626  $Result .= "  </channel>\n".
    2727      "</rss>";
    28   return($Result);
     28  return $Result;
    2929}
    3030
     
    3535    $this->RawPage = true;
    3636
    37     if(array_key_exists('channel', $_GET)) $ChannelName = $_GET['channel'];
     37    if (array_key_exists('channel', $_GET)) $ChannelName = $_GET['channel'];
    3838      else $ChannelName = '';
    39     if(array_key_exists('token', $_GET)) $Token = $_GET['token'];
     39    if (array_key_exists('token', $_GET)) $Token = $_GET['token'];
    4040      else $Token = '';
    41     if(array_key_exists($ChannelName, $this->System->ModuleManager->Modules['News']->RSSChannels))
     41    if (array_key_exists($ChannelName, $this->System->ModuleManager->Modules['News']->RSSChannels))
    4242    {
    4343      $Channel = $this->System->ModuleManager->Modules['News']->RSSChannels[$ChannelName];
    44       if($this->System->User->Licence($Channel['Permission']) or
     44      if ($this->System->User->Licence($Channel['Permission']) or
    4545      $this->System->User->CheckToken($Channel['Permission'], $Token))
    4646      {
    47         if(is_string($Channel['Callback'][0]))
     47        if (is_string($Channel['Callback'][0]))
    4848        {
    4949          $Class = new $Channel['Callback'][0]($this->System);
     
    5353      } else $Output = T('Access denied');
    5454    } else $Output = 'Nezadán žádný kanál';
    55     return($Output);
     55    return $Output;
    5656  }
    5757}
Note: See TracChangeset for help on using the changeset viewer.