<?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.
*/
  echo '<p class="Headline">'.$L_Headline28.':</p>';
  $xUserRightAddNews = getCurrentUserVar('UserRightAddNews');
  $xUserRightEditNews = getCurrentUserVar('UserRightEditNews');
  $xUserRightDeleteNews = getCurrentUserVar('UserRightDeleteNews');
    include ('news/functions.php');
    if ( AnzahlAllerNewsInDatenbank()=='0' )
    {
      echo $L_167.'<br /><br />';
    }
    else
    {
      // Session-Variable 'Anzahl' definieren
        if ( isset($_POST['Anzahl']) ) { $_SESSION["Anzahl"] = $_POST['Anzahl']; $_SESSION['CurrentPageShowAllNews']=1; }
        if ( !isset($_SESSION["Anzahl"]) ) { $_SESSION["Anzahl"] = "25"; }
        $EntriesPerPage = $_SESSION["Anzahl"];

      $NumberOfEntries = AnzahlAllerNewsInDatenbank();
      if ( $EntriesPerPage!='all' ) { $NumberOfPages = ceil($NumberOfEntries/$EntriesPerPage); }
      else {
        $NumberOfPages = 0;
        $EntriesPerPage = 99999; } // v1.2.77_013 Bugfix
      if (isset($_REQUEST['page'])) {
        $_SESSION['CurrentPageShowAllNews'] = $_REQUEST['page']; }
      else
        $_SESSION['CurrentPageShowAllNews'] = 1; // For new Pagination since v1.2.80_039
      if ( !isset($_SESSION['CurrentPageShowAllNews']) ) { $_SESSION['CurrentPageShowAllNews'] = "1"; }
      $CurrentPage = $_SESSION['CurrentPageShowAllNews'];
      $TopEntry  = $EntriesPerPage*($CurrentPage-1);

      // Ansichts-Parameter
        echo '<div id="Box_ParameterShowGigs">
                <form method="post" action="index.php?submenue=news&amp;content=backend_showAllNews" accept-charset="UTF-8">
                  <fieldset>
                    <input type="hidden" name="thread[threadid]" value="$thread[threadid]" />
                    <select name="Anzahl" onchange="this.form.submit()">
                      <option value="all"'; if ($EntriesPerPage=="all") echo ' selected="selected"'; echo'>'.$L_ShowAllGigs.'</option>';
                    for ($i=10; $i<=100; $i++)
                    {
                      echo '<option value="'.$i.'"'; if ($EntriesPerPage==$i) echo ' selected="selected"'; echo'>'.$i.'</option>';
                    }
                  echo '</select>
                  </fieldset>
                </form>';
        echo getNewsBackEndPagination();
        echo '</div>';
        
      // Publish or Not
      if (isset($_POST['Publish_x'])) { changePublishing ($_POST['Date']); }

      // Datensatz-Ausgabe festlegen
        $SQLQuery = "SELECT * FROM ".$prefix."news order by Date DESC";
        $SQLQuery = $SQLQuery." LIMIT ".$TopEntry.", ";
        if ( $EntriesPerPage=='all') { $SQLQuery = $SQLQuery.$NumberOfEntries; }
        else { $SQLQuery = $SQLQuery.$EntriesPerPage; }
        $Result = mysqli_query($db, $SQLQuery);

      echo '<table id="WideTable" summary="Table_ShowAllNews">';
      // Spalten definieren
            echo '<colgroup>';
            if ( $xUserRightDeleteNews ) { echo'<col class="SpalteIcon" />'; }
            if ( $xUserRightEditNews ) { echo'<col class="SpalteIcon" />'; }
            if ( !$xUserRightDeleteNews AND !$xUserRightEditNews )  { echo'<col class="SpalteIcon" />'; }
            echo '<col />';
            echo '<col />';
            echo '<col />';
            echo '<col class="TabellenSpalte_Rechts" />';
            echo '</colgroup>';
      echo '<tr>';
          if ( $xUserRightDeleteNews ) { echo'<th>&nbsp;</th>'; }
          if ( $xUserRightEditNews ) { echo'<th>&nbsp;</th>'; }
          if ( !$xUserRightDeleteNews AND !$xUserRightEditNews )  { echo'<th>&nbsp;</th>'; }
          echo '<th>'.$L_NewsDate.'</th>
                <th>'.$L_NewsTitle.'</th>
                <th>'.$L_NewsPublish.'</th>
                <th class="TabellenSpalte_Rechts">'.$L_NewsLastEdit.'</th>
              </tr>';
          while ($row = mysqli_fetch_array($Result))
          {
            extract($row);
            $DateString = DatumMitUhrzeitAusTimestamp($Date);
            $DateOfLastEditString = DatumMitUhrzeitAusTimestamp($DateOfLastEdit);
            echo '<tr>';
            if ( $xUserRightDeleteNews )
            {
              echo '<td>
                      <a href="index.php?submenue=news&amp;content=backend_delNews&amp;newsid='.$NewsID.'">
                        <img src="images/delete.gif" alt="'.$L_009.'" title="'.$L_009.'" /></a>
                    </td>';
            }
            if ( $xUserRightEditNews )
            {
              echo '<td>
                      <a href="index.php?submenue=news&amp;content=backend_addNews&amp;job=edit&amp;newsid='.$NewsID.'">
                        <img src="images/edit.gif" alt="'.$L_010.'" title="'.$L_010.'" /></a>
                    </td>';
            }
            if ( !$xUserRightDeleteNews AND !$xUserRightEditNews )
            {
              echo '<td>
                      <a href="index.php?submenue=news&amp;content=backend_showNews&amp;newsid='.$NewsID.'">
                        <img src="images/show.png" alt="'.$L_153.'" title="'.$L_153.'" /></a>
                    </td>';
            }
            // Datum
            echo '<td>'.$DateString.' ('.$AddedFrom.')</td>';
            // Titel
                echo '<td title="'.$Title.'">'.$Title.'</td>';
            // Veröffentlichen
              echo '<td>';
              if ($Publish==0)
              {
                $img = 'dontexist';
                $value = 1;
                $Title=$L_200;
              }
              if ($Publish==1)
              {
                $img = 'exist';
                $value = 0;
                $Title=$L_201;
              }
              if ( $xUserRightEditNews )
                echo '<form method="post" action="index.php?submenue=news&amp;content=backend_showAllNews" accept-charset="UTF-8">
                      <fieldset>
                        <input type="hidden" name="Date" value="'.$Date.'" />
                        <input title="'.$Title.'" name="Publish" src="images/'.$img.'.gif" style="border:0; width:16px;" type="image" value="'.$value.'" />
                      </fieldset>
                    </form>';
              else echo '<img src="images/'.$img.'.gif" alt="images/'.$img.'.gif" style="border:0; width:16px;" />';
              echo '</td>';
              // Letzte Bearbeitung
              echo '<td>'.$DateOfLastEditString;
                    if ($LastEditor) echo ' (';
                    echo $LastEditor;
                    if ($LastEditor) echo ')';
                    echo '</td>';
            echo '</tr>';
          }
          echo '</table>';
    }
    if ( $xUserRightAddNews )
      echo '<a href="index.php?submenue=news&amp;content=backend_addNews&amp;job=add">
                  <img src="images/add.gif" alt="'.$L_168.'" title="'.$L_168.'" /></a>';
?>