Changeset 873 for trunk/Modules/News


Ignore:
Timestamp:
Apr 6, 2020, 11:17:40 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved code format.
Location:
trunk/Modules/News
Files:
7 edited

Legend:

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

    r790 r873  
    1616$doc = new DOMDocument();
    1717$doc->load($SourceURL);
    18 foreach($doc->getElementsByTagName('item') as $node)
     18foreach ($doc->getElementsByTagName('item') as $node)
    1919{
    2020  $Title = $node->getElementsByTagName('title')->item(0)->nodeValue;
     
    2626  $Description = str_replace("\r", '', $Description);
    2727  $Description = str_replace("\n", '<br>', $Description);
    28   //if(($CommaPos = strpos($Date, ',')) !== FALSE)
     28  //if (($CommaPos = strpos($Date, ',')) !== FALSE)
    2929  //  $Date = substr($Date, $CommaPos + 1);
    3030  $Date = TimeToMysqlDateTime(strtotime($Date));
     
    3232  $Query = 'SELECT Id FROM News WHERE (`Title`="'.$System->Database->real_escape_string($Title).'") AND (`Category`='.$Category.') AND (`Content` = "'.$System->Database->real_escape_string($Description).'") AND (`Link` = "'.$System->Database->real_escape_string($Link).'")';
    3333  $DbResult = $System->Database->query($Query);
    34   if($DbResult->num_rows == 0)
     34  if ($DbResult->num_rows == 0)
    3535  {
    3636    $System->Database->insert('News', array('Title' => $Title, 'Date' => $Date, 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link));
  • trunk/Modules/News/ImportObecHovezi.php

    r827 r873  
    1616$doc = new DOMDocument();
    1717@$doc->load($SourceURL);
    18 foreach($doc->getElementsByTagName('item') as $node)
     18foreach ($doc->getElementsByTagName('item') as $node)
    1919{
    2020  $Title = $node->getElementsByTagName('title')->item(0)->nodeValue;
     
    2626  $Description = str_replace("\r", '', $Description);
    2727  $Description = str_replace("\n", '<br>', $Description);
    28   //if(($CommaPos = strpos($Date, ',')) !== FALSE)
     28  //if (($CommaPos = strpos($Date, ',')) !== FALSE)
    2929  //  $Date = substr($Date, $CommaPos + 1);
    3030  $Date = TimeToMysqlDateTime(strtotime($Date));
     
    3333  $DbResult = $System->Database->select('News', 'Id', '(`Title`="'.$System->Database->real_escape_string($Title).'") AND (`Category`='.$Category.') AND (`Content` = "'.$System->Database->real_escape_string($Description).'") AND (`Link` = "'.$System->Database->real_escape_string($Link).'")');
    3434  //echo($System->Database->LastQuery);
    35   if($DbResult->num_rows == 0)
     35  if ($DbResult->num_rows == 0)
    3636  {
    3737    $System->Database->insert('News', array('Title' => $Title, 'Date' => $Date, 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link));
     
    4444//$Content = addslashes($Encoding->ToUTF8(file_get_contents($SourceURL), 'win1250'));
    4545$Content = file_get_contents($SourceURL);
    46 while(strpos($Content, $StartText) !== false)
     46while (strpos($Content, $StartText) !== false)
    4747{
    4848  $Content = substr($Content, strpos($Content, $StartText) + strlen($StartText));
     
    7474  $DbResult = $System->Database->select('News', 'Id', '(`Title`="'.$Title.'") AND (`Category`='.$Category.') AND (`Content` = "'.$Description.'") AND (`Link` = "'.$Link.'")');
    7575  //echo($System->Database->LastQuery);
    76   if($DbResult->num_rows == 0)
     76  if ($DbResult->num_rows == 0)
    7777  {
    7878    $System->Database->insert('News', array('Title' => $Title, 'Date' => 'NOW()', 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link));
  • trunk/Modules/News/ImportTvBeskyd.php

    r827 r873  
    1717//$Content = addslashes($Encoding->ToUTF8(file_get_contents($SourceURL), 'win1250'));
    1818$Content = @file_get_contents($SourceURL);
    19 while(strpos($Content, $StartText) !== false)
     19while (strpos($Content, $StartText) !== false)
    2020{
    2121  $Content = substr($Content, strpos($Content, $StartText) + strlen($StartText));
     
    3737  $DbResult = $System->Database->select('News', 'Id', '`Title`="'.$System->Database->real_escape_string($Title).'" AND `Category`='.$Category);
    3838  //echo($System->Database->LastQuery);
    39   if($DbResult->num_rows == 0)
     39  if ($DbResult->num_rows == 0)
    4040  {
    4141    $System->Database->insert('News', array('Title' => $Title, 'Date' => 'NOW()', 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link));
  • trunk/Modules/News/ImportZdechovCzNews.php

    r827 r873  
    1616$Author = 'Automat';
    1717$Content = @file_get_contents($SourceURL);
    18 while(strpos($Content, $StartText) !== false)
     18while (strpos($Content, $StartText) !== false)
    1919{
    2020  $Content = substr($Content, strpos($Content, $StartText) + strlen($StartText));
     
    2525  $Content = substr($Content, strpos($Content, $StartLink) + strlen($StartLink));
    2626  $Link = substr($Content, 0, strpos($Content, '"'));
    27   if(substr($Link, 0, 7) != 'http://') $Link = 'http://www.zdechov.cz/'.$Link;
     27  if (substr($Link, 0, 7) != 'http://') $Link = 'http://www.zdechov.cz/'.$Link;
    2828  $Content = substr($Content, strpos($Content, $StartTitle) + strlen($StartTitle));
    2929  $Title = substr($Content, 0, strpos($Content, '<'));
     
    4040  $DbResult = $System->Database->select('News', 'Id', '`Title`="'.$System->Database->real_escape_string($Title).'" AND `Date`="'.$Date.'" AND `Category`='.$Category);
    4141  //echo($System->Database->LastQuery);
    42   if($DbResult->num_rows == 0)
     42  if ($DbResult->num_rows == 0)
    4343  {
    4444    $System->Database->insert('News', array('Title' => $Title, 'Date' => $Date, 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link));
  • trunk/Modules/News/ImportZdechovCzRecords.php

    r827 r873  
    1616$Author = 'Automat';
    1717$Content = @file_get_contents($SourceURL);
    18 while(strpos($Content, $StartText) !== false)
     18while (strpos($Content, $StartText) !== false)
    1919{
    2020  $Content = substr($Content, strpos($Content, $StartText) + strlen($StartText));
     
    2222  $Date = substr($Content, 0, strpos($Content, '<'));
    2323  $DateParts = explode('.', $Date);
    24   if(count($DateParts) >= 3)
     24  if (count($DateParts) >= 3)
    2525    $Date = $DateParts[2].'-'.$DateParts[1].'-'.$DateParts[0];
    2626      else break;
    2727  $Content = substr($Content, strpos($Content, $StartLink) + strlen($StartLink));
    2828  $Link = substr($Content, 0, strpos($Content, '"'));
    29   if(substr($Link, 0, 7) != 'http://') $Link = 'http://www.zdechov.cz/'.$Link;
     29  if (substr($Link, 0, 7) != 'http://') $Link = 'http://www.zdechov.cz/'.$Link;
    3030  $Content = substr($Content, strpos($Content, $StartTitle) + strlen($StartTitle));
    3131  $Title = substr($Content, 0, strpos($Content, '<'));
     
    4242  $DbResult = $System->Database->select('News', 'Id', '`Title`="'.$System->Database->real_escape_string($Title).'" AND `Date`="'.$Date.'" AND `Category`='.$Category);
    4343  //echo($System->Database->LastQuery);
    44   if($DbResult->num_rows == 0)
     44  if ($DbResult->num_rows == 0)
    4545  {
    4646    $System->Database->insert('News', array('Title' => $Title, 'Date' => $Date, 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link));
  • trunk/Modules/News/News.php

    r790 r873  
    55function CategoryItemCompare($Item1, $Item2)
    66{
    7   if ($Item1['Index'] == $Item2['Index']) return(0);
     7  if ($Item1['Index'] == $Item2['Index']) return (0);
    88  return ($Item1['Index'] > $Item2['Index']) ? -1 : 1;
    99}
     
    8181    ));
    8282
    83     if($this->System->ModuleManager->ModulePresent('Search'))
     83    if ($this->System->ModuleManager->ModulePresent('Search'))
    8484    {
    8585      $this->System->ModuleManager->Modules['Search']->RegisterSearch('Novinky', 'News', array('Title', 'Content'));
     
    9595    $Output = '<div class="NewsPanel"><div class="Title">'.$Row['Caption'];
    9696    $Output .= '<div class="Action"><a href="aktuality/?category='.$Category.'">Zobrazit</a>';
    97     if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category))
     97    if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category))
    9898      $Output .= ' <a href="aktuality/?action=add&amp;category='.$Category.'">Přidat</a>';
    9999    $Output .= '</div></div><div class="Content">';
     
    102102    $Index = 0;
    103103    $FontSize = 12;
    104     if($DbResult->num_rows > 0)
     104    if ($DbResult->num_rows > 0)
    105105    {
    106106      $Output .= '<table class="NewsTable">';
    107       while($Row = $DbResult->fetch_array())
    108       {
    109         if($Row['Name'] == '') $Author = $Row['Author'];
     107      while ($Row = $DbResult->fetch_array())
     108      {
     109        if ($Row['Name'] == '') $Author = $Row['Author'];
    110110          else $Author = $Row['Name'];
    111111        $Output .= '<tr><td onclick="window.location=\'aktuality/?action=view&amp;id='.$Row['Id'].
     
    114114          '<td align="right" style="font-size: '.$FontSize.'pt">'.$Author.' ('.HumanDate($Row['Date']).')</td></tr></table>';
    115115        $Output .= '<div id="new'.$Category.$Index.'" class="NewsTableItem">'.$this->ModifyContent($Row['Content']);
    116         if($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
    117 
    118         if($Row['Enclosure'] != '')
     116        if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
     117
     118        if ($Row['Enclosure'] != '')
    119119        {
    120120          $Output .= '<br />Přílohy: ';
    121121          $Enclosures = explode(';', $Row['Enclosure']);
    122           foreach($Enclosures as $Enclosure)
     122          foreach ($Enclosures as $Enclosure)
    123123          {
    124             if(file_exists($this->UploadedFilesFolder.$Enclosure))
     124            if (file_exists($this->UploadedFilesFolder.$Enclosure))
    125125              $Output .= ' <a href="'.$this->UploadedFilesFolder.$Enclosure.'">'.$Enclosure.'</a>';
    126126          }
     
    133133    }
    134134    $Output .= '</div></div>';
    135     return($Output);
     135    return ($Output);
    136136  }
    137137
     
    142142    $I = 1;
    143143    $DbResult = $this->Database->select('NewsCategory', '*', '1 ORDER BY Sequence');
    144     while($NewsCategory = $DbResult->fetch_array())
     144    while ($NewsCategory = $DbResult->fetch_array())
    145145    {
    146146      $this->NewsSetting[] = array('CategoryId' => $NewsCategory['Id'], 'Index' => $I, 'Enabled' => 1,
     
    149149    }
    150150    // Merge defaults with user setting
    151     if(array_key_exists('NewsSetting', $_COOKIE))
     151    if (array_key_exists('NewsSetting', $_COOKIE))
    152152    {
    153153      $NewsSettingCookie = unserialize($_COOKIE['NewsSetting']);
    154       foreach($this->NewsSetting as $Index => $this->NewSetting)
    155       {
    156         if(array_key_exists($Index, $NewsSettingCookie))
     154      foreach ($this->NewsSetting as $Index => $this->NewSetting)
     155      {
     156        if (array_key_exists($Index, $NewsSettingCookie))
    157157          $this->NewsSetting[$Index] = array_merge($this->NewSetting, $NewsSettingCookie[$Index]);
    158158      }
     
    166166    $this->LoadSettingsFromCookies();
    167167
    168     if(array_key_exists('Action', $_GET))
     168    if (array_key_exists('Action', $_GET))
    169169    {
    170170      // Show news customize menu
    171       if($_GET['Action'] == 'CustomizeNews')
     171      if ($_GET['Action'] == 'CustomizeNews')
    172172      {
    173173        $Output .= $this->ShowCustomizeMenu();
     
    179179    $ColumnCount = 2;
    180180    $Output .= '<table style="width: 100%"><tr>';
    181     for($Column = 1; $Column <= $ColumnCount; $Column++)
     181    for ($Column = 1; $Column <= $ColumnCount; $Column++)
    182182    {
    183183      $Output .= '<td style="vertical-align: top; width: '.round(100 / $ColumnCount).'%;">';
    184       foreach($this->NewsSetting as $SettingItem)
    185         if(($SettingItem['Enabled'] == 1) and ($SettingItem['Group'] == $Column))
     184      foreach ($this->NewsSetting as $SettingItem)
     185        if (($SettingItem['Enabled'] == 1) and ($SettingItem['Group'] == $Column))
    186186          $Output .= $this->ShowNews($SettingItem['CategoryId'], $SettingItem['ItemCount'], $SettingItem['DaysAgo']);
    187187      $Output .= '</td>';
     
    191191    $Output .= '<a href="aktuality/subscription"><img class="RSSIcon" src="images/rss20.png" alt="Aktuality přes RSS" /></a>  <a href="aktuality/subscription">Automatické sledování novinek</a>';
    192192    $Output .= '</div>';
    193     return($Output);
     193    return ($Output);
    194194  }
    195195
     
    200200    $Output .= '<tr><th>Kategorie</th><th>Pozice</th><th>Zobrazit</th><th>Max. počet</th><th>Posledních dnů</th><th>Sloupec</th></tr>';
    201201    $I = 0;
    202     foreach($this->NewsSetting as $SettingItem)
     202    foreach ($this->NewsSetting as $SettingItem)
    203203    {
    204204      $DbResult = $this->Database->select('NewsCategory', '*', 'Id='.$SettingItem['CategoryId']);
    205205      $NewsCategory = $DbResult->fetch_array();
    206206      $Output .= '<tr><td>'.$NewsCategory['Caption'].'</td><td align="center"><input type="text" size="2" name="NewsCategoryIndex'.$I.'" value="'.$SettingItem['Index'].'" /></td><td align="center"><input type="checkbox" name="NewsCategoryEnabled'.$I.'"';
    207       if($SettingItem['Enabled'] == 1) $Output .= ' checked="checked"';
     207      if ($SettingItem['Enabled'] == 1) $Output .= ' checked="checked"';
    208208      $Output .= ' /></td>'.
    209209      '<td align="center"><input type="text" size="2" name="NewsCategoryCount'.$I.'" value="'.$SettingItem['ItemCount'].'" />'.
     
    214214    }
    215215    $Output .= '</table><input type="hidden" name="NewsCategoryCount" value="'.count($this->NewsSetting).'" /><input type="submit" value="Uložit" /></form></td></tr></table><br>';
    216     return($Output);
     216    return ($Output);
    217217  }
    218218
     
    221221    $Checkbox = array('' => 0, 'on' => 1);
    222222    $Setting = array();
    223     for($I = 0; $I < $_POST['NewsCategoryCount']; $I++)
    224     {
    225       if(($_POST['NewsCategoryDaysAgo'.$I] * 1) < 0) $_POST['NewsCategoryIndex'.$I] = 0;
    226       if(($_POST['NewsCategoryCount'.$I] * 1) < 0) $_POST['NewsCategoryCount'.$I] = 0;
    227       if(($_POST['NewsColumn'.$I] * 1) < 1) $_POST['NewsColumn'.$I] = 1;
    228       if(!array_key_exists('NewsCategoryEnabled'.$I, $_POST)) $_POST['NewsCategoryEnabled'.$I] = '';
     223    for ($I = 0; $I < $_POST['NewsCategoryCount']; $I++)
     224    {
     225      if (($_POST['NewsCategoryDaysAgo'.$I] * 1) < 0) $_POST['NewsCategoryIndex'.$I] = 0;
     226      if (($_POST['NewsCategoryCount'.$I] * 1) < 0) $_POST['NewsCategoryCount'.$I] = 0;
     227      if (($_POST['NewsColumn'.$I] * 1) < 1) $_POST['NewsColumn'.$I] = 1;
     228      if (!array_key_exists('NewsCategoryEnabled'.$I, $_POST)) $_POST['NewsCategoryEnabled'.$I] = '';
    229229      $Setting[] = array('CategoryId' => $_POST['NewsCategoryId'.$I], 'Enabled' => $Checkbox[$_POST['NewsCategoryEnabled'.$I]], 'ItemCount' => ($_POST['NewsCategoryCount'.$I]*1), 'DaysAgo' => ($_POST['NewsCategoryDaysAgo'.$I]*1), 'Index' => ($_POST['NewsCategoryIndex'.$I]*1),
    230230      'Group' => $_POST['NewsColumn'.$I]);
     
    234234    $Setting = array_reverse($Setting);
    235235    // Normalize indexes
    236     foreach($Setting as $Index => $Item)
     236    foreach ($Setting as $Index => $Item)
    237237      $Setting[$Index]['Index'] = $Index + 1;
    238238
     
    248248    // Make HTML link from URL
    249249    $I = 0;
    250     while(strpos($Content, 'http://') !== false)
     250    while (strpos($Content, 'http://') !== false)
    251251    {
    252252      $I = strpos($Content, 'http://');
    253       if(($I > 0) and ($Content{$I - 1} != '"'))
     253      if (($I > 0) and ($Content{$I - 1} != '"'))
    254254      {
    255255        $Result .= substr($Content, 0, $I);
    256256        $Content = substr($Content, $I);
    257         if(strpos($Content, ' ') !== false)
     257        if (strpos($Content, ' ') !== false)
    258258          $URL = substr($Content, 0, strpos($Content, ' '));
    259259        else $URL = substr($Content, 0);
     
    267267    }
    268268    $Result .= $Content;
    269     return($Result);
     269    return ($Result);
    270270  }
    271271}
  • trunk/Modules/News/NewsPage.php

    r839 r873  
    1111  {
    1212    $this->UploadedFilesFolder = $this->System->ModuleManager->Modules['News']->UploadedFilesFolder;
    13     if(count($this->System->PathItems) > 1)
    14     {
    15       if($this->System->PathItems[1] == 'subscription') return($this->ShowSubscription());
    16         else if($this->System->PathItems[1] == 'rss') return($this->ShowRSS());
    17         else return(PAGE_NOT_FOUND);
    18     } else return($this->ShowMain());
     13    if (count($this->System->PathItems) > 1)
     14    {
     15      if ($this->System->PathItems[1] == 'subscription') return ($this->ShowSubscription());
     16        else if ($this->System->PathItems[1] == 'rss') return ($this->ShowRSS());
     17        else return (PAGE_NOT_FOUND);
     18    } else return ($this->ShowMain());
    1919  }
    2020
     
    2222  {
    2323    $Output = '';
    24     if(!$this->System->User->CheckPermission('News', 'Display', 'Item')) $Output .= 'Nemáte oprávnění';
     24    if (!$this->System->User->CheckPermission('News', 'Display', 'Item')) $Output .= 'Nemáte oprávnění';
    2525    else
    2626    {
    2727      $Category = $this->GetCategory();
    28       if(array_key_exists('id', $_GET)) $Id = $_GET['id'] * 1;
     28      if (array_key_exists('id', $_GET)) $Id = $_GET['id'] * 1;
    2929      $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` '.
    3030        'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `News`.`Id`='.$Id);
    31       if($DbResult->num_rows > 0)
     31      if ($DbResult->num_rows > 0)
    3232      {
    3333        $Row = $DbResult->fetch_array();
    34         if($Row['Name'] == '') $Author = $Row['Author'];
     34        if ($Row['Name'] == '') $Author = $Row['Author'];
    3535          else $Author = $Row['Name'];
    3636        $Output .= '<div class="Panel"><div class="Title">'.$Row['Title'].' ('.HumanDate($Row['Date']).', '.$Author.')';
    37         if(($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])))
     37        if (($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])))
    3838        {
    3939          $Output .= '<div class="Action">';
     
    4343        }
    4444        $Output .= '</div><div class="Content">'.$this->System->ModuleManager->Modules['News']->ModifyContent($Row['Content']).'<br />';
    45         if($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
    46         if($Row['Enclosure'] != '')
     45        if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
     46        if ($Row['Enclosure'] != '')
    4747        {
    4848          $Output .= '<br />Přílohy: ';
    4949          $Enclosures = explode(';', $Row['Enclosure']);
    50           foreach($Enclosures as $Enclosure)
     50          foreach ($Enclosures as $Enclosure)
    5151          {
    52             if(file_exists($this->UploadedFilesFolder.$Enclosure))
     52            if (file_exists($this->UploadedFilesFolder.$Enclosure))
    5353              $Output .= ' <a href="'.$this->System->Link('/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';
    5454          }
     
    5757      } else $Output .= 'Položka nenalezena.';
    5858    }
    59     return($Output);
     59    return ($Output);
    6060  }
    6161
     
    6464    $Output = '';
    6565    $Category = $this->GetCategory();
    66     if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
     66    if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
    6767    {
    6868      $this->System->PageHeaders[] = array($this, 'GetPageHeader');
    6969      $Output = '<strong>Vložení nové aktuality:</strong><br />';
    7070      // TODO: Static reference to dynamic category item
    71       if($Category['Id'] == 2) $Output .= 'U inzerátů uvádějte co nejvíce informací ať případný zájemce ví co kupuje. Uvádějte kontaktní údaje jako Jméno, email, tel. číslo, ICQ. Dále navrženou cenu, detajlní popis předmětu nejlépe s odkazem na stránky výrobce. Pokud váš inzerát již není platný, připište do něj např. "Prodáno" pomocí editace.';
     71      if ($Category['Id'] == 2) $Output .= 'U inzerátů uvádějte co nejvíce informací ať případný zájemce ví co kupuje. Uvádějte kontaktní údaje jako Jméno, email, tel. číslo, ICQ. Dále navrženou cenu, detajlní popis předmětu nejlépe s odkazem na stránky výrobce. Pokud váš inzerát již není platný, připište do něj např. "Prodáno" pomocí editace.';
    7272      $Output .= '<form enctype="multipart/form-data" action="?action=add2" method="post">'.
    7373        'Kategorie: <select name="category">';
    7474      $DbResult = $this->Database->select('NewsCategory', '*');
    75       while($DbRow = $DbResult->fetch_array())
    76       {
    77         if($this->System->User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id']))
    78         {
    79           if($DbRow['Id'] == $Category['Id']) $Selected = ' selected="1"';
     75      while ($DbRow = $DbResult->fetch_array())
     76      {
     77        if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id']))
     78        {
     79          if ($DbRow['Id'] == $Category['Id']) $Selected = ' selected="1"';
    8080            else $Selected = '';
    8181          $Output .= '<option value="'.$DbRow['Id'].'"'.$Selected.'>'.$DbRow['Caption'].'</option>';
     
    9393        '</form>';
    9494    } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!';
    95     return($Output);
     95    return ($Output);
    9696  }
    9797
     
    101101    $RemoteAddr = GetRemoteAddress();
    102102    $Category = $this->GetCategory();
    103     if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
     103    if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
    104104    {
    105105      // Process uploaded file
     
    107107      $EnclosureFileNames = array('enclosure1', 'enclosure2', 'enclosure3');
    108108      $Enclosures = '';
    109       foreach($EnclosureFileNames as $EnclosureName)
    110         if(array_key_exists($EnclosureName, $_FILES) and ($_FILES[$EnclosureName]['name'] != ''))
     109      foreach ($EnclosureFileNames as $EnclosureName)
     110        if (array_key_exists($EnclosureName, $_FILES) and ($_FILES[$EnclosureName]['name'] != ''))
    111111        {
    112112          $UploadedFilePath = $this->UploadedFilesFolder.basename($_FILES[$EnclosureName]['name']);
    113           if(move_uploaded_file($_FILES[$EnclosureName]['tmp_name'], $UploadedFilePath))
     113          if (move_uploaded_file($_FILES[$EnclosureName]['tmp_name'], $UploadedFilePath))
    114114          {
    115115            $Output .= 'Soubor '.basename($_FILES[$EnclosureName]['name']).' byl uložen na serveru.<br />';
     
    130130        $this->System->ModuleManager->Modules['Log']->NewRecord('News', 'Aktualita přidána', $this->Database->insert_id);
    131131    } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!';
    132     return($Output);
     132    return ($Output);
    133133  }
    134134
    135135  function GetPageHeader()
    136136  {
    137     return('<script src="'.$this->System->Link('/Packages/TinyMCE/tinymce.min.js').'"></script>'.
     137    return ('<script src="'.$this->System->Link('/Packages/TinyMCE/tinymce.min.js').'"></script>'.
    138138        "<script>tinymce.init({
    139139  selector: 'textarea',
     
    156156    $Output = '';
    157157    $Category = $this->GetCategory();
    158     if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
     158    if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
    159159    {
    160160      $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']);
    161161      $Row = $DbResult->fetch_array();
    162       if(($this->System->User->User['Id'] == $Row['User']))
     162      if (($this->System->User->User['Id'] == $Row['User']))
    163163      {
    164164        $this->System->PageHeaders[] = array($this, 'GetPageHeader');
     
    174174      } else $Output .= 'Nepovolená operace!';
    175175    } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!';
    176     return($Output);
     176    return ($Output);
    177177  }
    178178
     
    182182    $RemoteAddr = GetRemoteAddress();
    183183    $Category = $this->GetCategory();
    184     if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
     184    if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
    185185    {
    186186      $_POST['id'] = $_POST['id'] * 1;
    187187      $DbResult = $this->Database->select('News', '*', '`Id`='.$_POST['id']);
    188       if($DbResult->num_rows > 0)
     188      if ($DbResult->num_rows > 0)
    189189      {
    190190        $Row = $DbResult->fetch_array();
    191         if($this->System->User->User['Id'] == $Row['User'])
     191        if ($this->System->User->User['Id'] == $Row['User'])
    192192        {
    193193          $this->Database->update('News', 'Id='.$_POST['id'], array('Title' => $_POST['title'],
     
    198198      } else $Output .= 'ID nenalezeno!';
    199199    } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!';
    200     return($Output);
     200    return ($Output);
    201201  }
    202202
     
    205205    $Output = '';
    206206    $Category = $this->GetCategory();
    207     if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
     207    if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
    208208    {
    209209      $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']);
    210210      $Row = $DbResult->fetch_array();
    211       if($this->System->User->User['Id'] == $Row['User'])
     211      if ($this->System->User->User['Id'] == $Row['User'])
    212212      {
    213213        // TODO: Make upload using general File class
    214         if($Row['Enclosure'] != '')
     214        if ($Row['Enclosure'] != '')
    215215        {
    216216          $Output .= '<br />Přílohy: ';
    217217          $Enclosures = explode(';', $Row['Enclosure']);
    218           foreach($Enclosures as $Enclosure)
     218          foreach ($Enclosures as $Enclosure)
    219219          {
    220             if(file_exists($this->UploadedFilesFolder.$Enclosure)) unlink($this->UploadedFilesFolder.$Enclosure);
     220            if (file_exists($this->UploadedFilesFolder.$Enclosure)) unlink($this->UploadedFilesFolder.$Enclosure);
    221221          }
    222222        }
     
    225225      } else $Output .= 'Nemáte oprávnění.';
    226226    } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!';
    227     return($Output);
     227    return ($Output);
    228228  }
    229229
     
    232232    $Output = '';
    233233    $Category = $this->GetCategory();
    234     if($this->System->User->CheckPermission('News', 'Display', 'Group', $Category['Id']))
     234    if ($this->System->User->CheckPermission('News', 'Display', 'Group', $Category['Id']))
    235235    {
    236236      $PerPage = 20;
     
    238238      $RowTotal = $DbResult->fetch_array();
    239239      $PageMax = $RowTotal[0];
    240       if(array_key_exists('page', $_GET)) $Page = $_GET['page'];
     240      if (array_key_exists('page', $_GET)) $Page = $_GET['page'];
    241241        else $Page = 0; //round($PageMax/$PerPage);
    242242      $Output .= '<strong>Seznam aktualit kategorie '.$Category['Caption'].':</strong><div style="font-size: small;">';
     
    245245      $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` '.
    246246        'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `Category`='.$Category['Id'].' ORDER BY `News`.`Id` DESC LIMIT '.($Page * $PerPage).','.$PerPage);
    247       while($Row = $DbResult->fetch_array())
    248       {
    249         if($Row['Name'] == '') $Author = $Row['Author'];
     247      while ($Row = $DbResult->fetch_array())
     248      {
     249        if ($Row['Name'] == '') $Author = $Row['Author'];
    250250          else $Author = $Row['Name'];
    251251        $Output .= '<div class="Panel"><div class="Title"><a href="?action=view&amp;id='.$Row['Id'].'">'.$Row['Title'].'</a> ('.HumanDate($Row['Date']).', '.$Author.')';
    252         if(($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])))
     252        if (($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])))
    253253        {
    254254          $Output .= '<div class="Action">';
     
    258258        }
    259259        $Output .= '</div><div class="Content">'.$this->System->ModuleManager->Modules['News']->ModifyContent($Row['Content']).'<br />';
    260         if($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
    261         if($Row['Enclosure'] != '')
     260        if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
     261        if ($Row['Enclosure'] != '')
    262262        {
    263263          $Output .= '<br />Přílohy: ';
    264264          $Enclosures = explode(';', $Row['Enclosure']);
    265           foreach($Enclosures as $Enclosure)
     265          foreach ($Enclosures as $Enclosure)
    266266          {
    267             if(file_exists($this->UploadedFilesFolder.$Enclosure))
     267            if (file_exists($this->UploadedFilesFolder.$Enclosure))
    268268              $Output .= ' <a href="'.$this->System->Link('/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';
    269269          }
     
    274274      $Output .= '</div>';
    275275    } else $Output .= 'Nemáte oprávnění.';
    276     return($Output);
     276    return ($Output);
    277277  }
    278278
     
    280280  {
    281281    $Category = array('Id' => 1); // Default category
    282     if(array_key_exists('category', $_GET)) $Category['Id'] = $_GET['category'] * 1;
    283     if(array_key_exists('category', $_POST)) $Category['Id'] = $_POST['category'] * 1;
    284     //if(is_null($Category)) throw new Exception('Kategorie neurčena');
     282    if (array_key_exists('category', $_GET)) $Category['Id'] = $_GET['category'] * 1;
     283    if (array_key_exists('category', $_POST)) $Category['Id'] = $_POST['category'] * 1;
     284    //if (is_null($Category)) throw new Exception('Kategorie neurčena');
    285285    else
    286286    {
    287287      $DbResult = $this->Database->select('NewsCategory', '*', '`Id`='.$Category['Id'].' ORDER BY `Sequence`');
    288       if($DbResult->num_rows > 0) $Category = $DbResult->fetch_array();
     288      if ($DbResult->num_rows > 0) $Category = $DbResult->fetch_array();
    289289        else $Category = array('Id' => 0); //throw new Exception('Kategorie nenalezena');
    290290    }
    291     return($Category);
     291    return ($Category);
    292292  }
    293293
     
    295295  {
    296296    $Output = '';
    297     if(array_key_exists('action',$_GET)) $Action = $_GET['action'];
     297    if (array_key_exists('action',$_GET)) $Action = $_GET['action'];
    298298      else $Action = '';
    299     if($Action == 'view') $Output .= $this->ShowView();
    300     else if($Action == 'add') $Output .= $this->ShowAdd();
    301     else if($Action == 'add2') $Output .= $this->ShowAdd2();
    302     else if($Action == 'edit') $Output .= $this->ShowEdit();
    303     else if($Action == 'update') $Output .= $this->ShowUpdate();
    304     else if($Action == 'del') $Output .= $this->ShowDelete();
     299    if ($Action == 'view') $Output .= $this->ShowView();
     300    else if ($Action == 'add') $Output .= $this->ShowAdd();
     301    else if ($Action == 'add2') $Output .= $this->ShowAdd2();
     302    else if ($Action == 'edit') $Output .= $this->ShowEdit();
     303    else if ($Action == 'update') $Output .= $this->ShowUpdate();
     304    else if ($Action == 'del') $Output .= $this->ShowDelete();
    305305    else $Output .= $this->ShowList();
    306     return($Output);
     306    return ($Output);
    307307  }
    308308
    309309  function ShowSubscription()
    310310  {
    311     if(array_key_exists('build', $_GET))
     311    if (array_key_exists('build', $_GET))
    312312    {
    313313      $Select = '';
    314       foreach($_POST as $Index => $Item)
    315       {
    316         if(substr($Index, 0, 8) == 'category') $Select .= '-'.substr($Index, 8);
     314      foreach ($_POST as $Index => $Item)
     315      {
     316        if (substr($Index, 0, 8) == 'category') $Select .= '-'.substr($Index, 8);
    317317      }
    318318      $Select = $this->System->Config['Web']['RootFolder'].'/aktuality/rss/?select='.substr($Select, 1);
     
    324324      $Output .= '<form action="?build=1" method="post">';
    325325      $DbResult = $this->Database->select('NewsCategory', '*', '1 ORDER BY `Caption`');
    326       while($Category = $DbResult->fetch_array())
     326      while ($Category = $DbResult->fetch_array())
    327327      {
    328328        $Output .= '<input type="checkbox" name="category'.$Category['Id'].'" />'.$Category['Caption'].'<br />';
     
    331331        '</form>';
    332332    }
    333     return($Output);
     333    return ($Output);
    334334  }
    335335
     
    349349
    350350    // Prepare WHERE condition
    351     if(array_key_exists('select', $_GET))
     351    if (array_key_exists('select', $_GET))
    352352    {
    353353      $Where = '';
    354354      $Parts = explode('-', $_GET['select']);
    355       foreach($Parts as $Part)
     355      foreach ($Parts as $Part)
    356356      {
    357357        $Where .= 'OR (`Category`='.($Part * 1).')';
     
    363363    $Categories = array();
    364364    $DbResult = $this->Database->select('NewsCategory', '*');
    365     while($Category = $DbResult->fetch_array())
     365    while ($Category = $DbResult->fetch_array())
    366366    {
    367367      $Categories[$Category['Id']] = $Category['Caption'];
     
    375375    $Index = 0;
    376376    //echo(DB_NumRows().',');
    377     while($Row = $DbResult->fetch_array())
     377    while ($Row = $DbResult->fetch_array())
    378378    {
    379379      $Row['post_text'] = StrTr($Row['post_text'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");
     
    390390      //echo('category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"');
    391391      $DbResult2 = $Database->select('news', '*', 'category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"');
    392       if($DbResult2->num_rows == 0) //echo('.'); else echo('x');
     392      if ($DbResult2->num_rows == 0) //echo('.'); else echo('x');
    393393        $Database->insert('news', array('category' => $ForumCategory, 'title' => $Title, 'content' => $Content, 'author' => $Author, 'date' => $Date));
    394394        //echo($Date);
     
    400400    // Get news from database by selected categories
    401401    $DbResult = $this->Database->query('SELECT *, UNIX_TIMESTAMP(`Date`) AS `UnixTime` FROM `News` LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE '.$Where.' ORDER BY News.Date DESC LIMIT 0,'.$NewsCount);
    402     while($Row = $DbResult->fetch_assoc())
     402    while ($Row = $DbResult->fetch_assoc())
    403403    {
    404404      $EnclosuresText = '';
    405       if($Row['Enclosure'] != '')
     405      if ($Row['Enclosure'] != '')
    406406      {
    407407        $EnclosuresText .= '<br />Přílohy: ';
    408408        $Enclosures = explode(';', $Row['Enclosure']);
    409         foreach($Enclosures as $Enclosure)
    410         {
    411           if(file_exists($this->UploadedFilesFolder.$Enclosure))
     409        foreach ($Enclosures as $Enclosure)
     410        {
     411          if (file_exists($this->UploadedFilesFolder.$Enclosure))
    412412            $EnclosuresText .= ' <a href="'.$this->System->Link('/aktuality/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';
    413413        }
    414414      }
    415       if($Row['Name'] == '') $Author = $Row['Author'];
     415      if ($Row['Name'] == '') $Author = $Row['Author'];
    416416        else $Author = $Row['Name'];
    417417      $Items[] = array(
     
    429429    $RSS->WebmasterEmail = $this->System->Config['Web']['AdminEmail'];
    430430    $RSS->Items = $Items;
    431     return($RSS->Generate());
     431    return ($RSS->Generate());
    432432  }
    433433}
Note: See TracChangeset for help on using the changeset viewer.