<?php
/*
    CREATIVE COMMONS - Attribution-No Derivative Works 3.0 Germany:
    - You may not alter, transform, or build upon this work.
    - Dieses Werk darf nicht bearbeitet oder in anderer Weise verändert werden.
*/
  $Path = str_replace('\\','/', __FILE__);
  $Path = str_replace('news/news.php', '', $Path);
  
  include ($Path."/includes/error_reporting.php");
  include_once ($Path."gigkalender.ini.php");
  include_once ($Path."functions/standard.php");
  include_once ($Path."news/functions.php");
  include_once($Path."includes/frontend_language_selector.php");
  echo '<div class="GigKalender"><div id="News">';
  $EntriesPerPage = getSetup('SetupNewsEntriesPerPage');
  $NumberOfEntries = getNumberOfPublishedNewsEntries();
  if ($EntriesPerPage!=0) $NumberOfPages = ceil($NumberOfEntries/$EntriesPerPage);
    else $NumberOfPages = 1;
  if ($NumberOfEntries!=0) // Einträge vorhanden
  {
    if ( isset($_REQUEST['news_page']) ) { $CurrentPage = $_REQUEST['news_page']; }
      else { $CurrentPage=$NumberOfPages; }
    // wenn Seite aus einem Feed-Reader aufgerufen wird
    if ( isset($_REQUEST['NewsID']) ) 
    {
      $CurrentPage = '';
      $NewsID = $_REQUEST['NewsID'];
      // v1.2.78_018
      if (is_numeric($NewsID)) {
        if ($NewsID<=$NumberOfEntries)
          $CurrentPage = $NumberOfPages-floor(($NumberOfEntries-$NewsID)/$EntriesPerPage);
        else {
          echo '<p class="ErrorMessage">ERROR: Unknown News ID! Article got moved or removed.</p>';
          $CurrentPage = $NumberOfPages; // Bugfix v1.2.78_017
        }
      }
    }
    $TopEntry  = ($NumberOfPages-$CurrentPage)*$EntriesPerPage;
    // Datensatz-Ausgabe festlegen
      $SQLQuery = "SELECT * FROM ".$prefix."news WHERE Publish= 1 order by Date DESC LIMIT ".$TopEntry.", ".$EntriesPerPage;
    // Saemtliche Datensatz-Ausgabe durchfuehren
      $Result = mysqli_query($db, $SQLQuery);
    $NewsFrontendPagination = getNewsFrontendPagination();
    if ($NumberOfPages>1) echo $NewsFrontendPagination;
    $CurrentEntry = $NumberOfEntries-$TopEntry;

    while ( $row = mysqli_fetch_array($Result))
    {
      extract($row);
      if ( $Publish=='1')
      {
        echo '<div id="news'.$CurrentEntry.'"><div class="NewsEntry">
                <h2 class="NewsEntryHeadline">
                  <span class="NewsEntryDate">'; 
        echo '['.date($SetupFrontendNewsDateFormat, $Date).']</span> '.$CurrentEntry.'. ';
        echo $Title; 
        echo '</h2>
              <div class="NewsEntryText">';
                echo $Text;
        echo '</div></div></div>';
        $CurrentEntry--;
      }
    }
    if ($NumberOfPages>1) echo $NewsFrontendPagination;
  }
  else // Keine Einträge vorhanden
  {
    echo '<p>'.$L_167.'</p>';
  }
  echo '</div></div>';
?>