<?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.
*/
  $_SESSION['MenuReminderWebsite'] = $page;
  $xUserRightAddNews = getCurrentUserVar('UserRightAddNews');
  $xUserRightEditNews = getCurrentUserVar('UserRightEditNews');
  $xUserRightDeleteNews = getCurrentUserVar('UserRightDeleteNews');
    include ('news/functions.php');
    if ( AnzahlAllerNewsInDatenbank()=='0' )
    {
      echo '<div id="PageMenu">';
      include('news/includes/buttonAddNews.php');
      echo '</div>';
      echo '<br />'.$L_167.'<br /><br />';
    }
    else
    {
      // Sessioin-Variable 'Anzahl' definieren
        if ( isset($_POST['Anzahl']) ) { $_SESSION["Anzahl"] = $_POST['Anzahl']; $_SESSION['CurrentPageShowAllNews']=1; }
        if ( !isset($_SESSION["Anzahl"]) ) { $_SESSION["Anzahl"] = "20"; }
        $EintraegeProSeite = $_SESSION["Anzahl"];

      $AnzahlEintraege = AnzahlAllerNewsInDatenbank();
      if ( $EintraegeProSeite!='all' ) { $AnzahlSeiten = ceil($AnzahlEintraege/$EintraegeProSeite); }
          else { $AnzahlSeiten = '0'; }
      if (isset($_REQUEST['page'])) { $_SESSION['CurrentPageShowAllNews'] = $_REQUEST['page']; }
      if ( !isset($_SESSION['CurrentPageShowAllNews']) ) { $_SESSION['CurrentPageShowAllNews'] = "1"; }
      $aktuelleSeite = $_SESSION['CurrentPageShowAllNews'];
      $obersterEintrag  = $EintraegeProSeite*($aktuelleSeite-1);

      // Ansichts-Parameter
        echo '<div id="PageMenu">
                <form method="post" action="index.php?submenu=news&amp;page=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 ($EintraegeProSeite=="all") echo ' selected="selected"'; echo'>'.$L_ShowAllGigs.'</option>';
                    for ($i=1; $i<=100; $i++)
                    {
                      echo '<option value="'.$i.'"'; if ($EintraegeProSeite==$i) echo ' selected="selected"'; echo'>'.$i.'</option>';
                    }

                  echo '</select>
                  </fieldset>
                </form>';
        include('news/includes/buttonAddNews.php');
        echo NewsBackendNavigation();
        echo '</div>';
        
      // Publish or Not
      if (isset($_POST['Publish_x'])) { changePublishing ($_POST['Date']); }

      // Datensatz-Ausgabe festlegen
        $sql = "SELECT * FROM ".DB_PREFIX."news order by Date DESC";
        $sql = $sql." LIMIT ".$obersterEintrag.", ";
        if ( $EintraegeProSeite=='all') { $sql = $sql.$AnzahlEintraege; }
        else { $sql = $sql.$EintraegeProSeite; }
        $resultat = mysql_query($sql);

      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 = mysql_fetch_array($resultat))
          {
            extract($row);
            $DateString = getDateAndTimeFromTimestamp($Date);
            $DateOfLastEditString = getDateAndTimeFromTimestamp($DateOfLastEdit);
            echo '<tr>';
            if ( $xUserRightDeleteNews )
            {
              echo '<td>
                      <a href="index.php?submenu=news&amp;page=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?submenu=news&amp;page=backend_addNews&amp;job=edit&amp;newsid='.$NewsID.'">
                        <img src="images/edit.png" alt="'.$L_010.'" title="'.$L_010.'" /></a>
                    </td>';
            }
            if ( !$xUserRightDeleteNews AND !$xUserRightEditNews )
            {
              echo '<td>
                      <a href="index.php?submenu=news&amp;page=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?submenu=news&amp;page=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>';
    }
?>