<?php
/*
###################################################################################
  Bigware Shop 2.3
  Release Datum: 23.08.2015
  
  Bigware Shop
  http://www.bigware.de

  Copyright (c) 2015 Bigware LTD
  (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
  (c) 2015	Bigware LTD

  Copyrightvermerke duerfen nicht entfernt werden.
  ------------------------------------------------------------------------
  Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
  der GNU General Public License, wie von der Free Software Foundation
  veroeffentlicht, weitergeben und/oder modifizieren, entweder gemaess Version 2 
  der Lizenz oder (nach Ihrer Option) jeder spaeteren Version.
  Die Veroeffentlichung dieses Programms erfolgt in der Hoffnung, dass es Ihnen
  von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE, sogar ohne die
  implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT FUER EINEN
  BESTIMMTEN ZWECK. Details finden Sie in der GNU General Public License.
  
  Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
  Programm erhalten haben. Falls nicht, schreiben Sie an die Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

  Infos:
  ------------------------------------------------------------------------
  Der Bigware Shop wurde vor vielen Jahren bereits aus dem bekannten Shopsystem osCommerce
  weiter- und neuentwickelt.
  Der Bigware Shop legt im hohen Masse Wert auf Bedienerfreundlichkeit, beinhaltet eine leichte
  Installation, viele neue professionelle Werkzeuge und zeichnet sich aus durch eine grosse 
  Community, die bei Problemen weiterhelfen kann.
  
  Der Bigware Shop ist auf jedem System lauffaehig, welches eine PHP Umgebung
  (ab PHP 4.1.3) und mySQL zur Verfuegung stellt und auf Linux basiert.
 
  Hilfe erhalten Sie im Forum auf www.bigware.de 
  
  -----------------------------------------------------------------------
  
 ##################################################################################




*/
?>
<?php
  require('load_this/load_bigware_11.php');
  //go_db_query("update " . DB_TBL_PAGES . " set language_id='" . $languages_id . "' where language_id='2'"); 
  
  $action = (isset($_GET['action']) ? $_GET['action'] : ''); 
  function go_set_page_status($pages_id, $status) {
    if ($status == '1') {
      return go_db_query("update " . DB_TBL_PAGES . " set status = '1'  where pages_id = '" . $pages_id . "'");
    } elseif ($status == '0') {
      return go_db_query("update " . DB_TBL_PAGES . " set status = '0'  where pages_id = '" . $pages_id . "'");
    } else {
      return -1;
    }
  }
  if (go_not_null($action)) {
    switch ($action) {
      case 'setflag':
        if ( ($_GET['flag'] == '0') || ($_GET['flag'] == '1') ) {
          go_set_page_status($_GET['bigwareID'], $_GET['flag']);
          $messageStack->add_session(SUCCESS_PAGE_STATUS_UPDATED, 'success');
        } else {
          $messageStack->add_session(ERROR_UNKNOWN_STATUS_FLAG, 'error');
        }
        go_forward(go_href_link(NAME_OF_FILE_PAGE_MANAGER, 'page=' . $_GET['page'] . '&bigwareID=' . $_GET['bigwareID']));
        break;
      case 'insert':
      case 'update':
        if (isset($_POST['pages_id'])) $pages_id = go_db_producing_input($_POST['pages_id']);  
        $sort_order = go_db_producing_input($_POST['sort_order']);
        
        $page_error = false;
        if (empty($_POST['pages_title'])) {
          $messageStack->add(ERROR_PAGE_TITLE_REQUIRED, 'error');
          $page_error = true;
        }
        if (empty($_POST['pages_html_text'])) {
        }
        if ($page_error == false) { 
        
        $languages = go_get_languages();
        for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
            $language_id = $languages[$i]['id']; 
            $sql_data_array = array('pages_title'=>go_db_producing_input($_POST['pages_title'][$language_id]),
            												'pages_html_text' => go_db_producing_input($_POST['pages_html_text'.$language_id]),
                                    'sort_order' => $sort_order,
                                    'language_id' => $language_id);
          
       
           
       $existing_page_query = go_db_query("select pages_id,language_id from ".DB_TBL_PAGES." where pages_id='".$pages_id."' and language_id='".$language_id."'"); 
       if (go_db_fetch_array($existing_page_query)) {
        go_db_carry(DB_TBL_PAGES, $sql_data_array, 'update', "pages_id = '" . (int)$pages_id . "' and language_id='".(int)$language_id."'");
        $messageStack->add_session(SUCCESS_PAGE_UPDATED, 'success');
       } 
       else { 
        $insert_sql_data = array('status' => '1');
     
         $sql_data_array_pages_id = array('pages_id'=>$pages_id);
         $sql_data_array = array_merge($sql_data_array,$sql_data_array_pages_id);
         $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
         go_db_carry(DB_TBL_PAGES, $sql_data_array);
      
         $pages_id = go_db_insert_id();
       
        $messageStack->add_session(SUCCESS_PAGE_INSERTED, 'success');
       }
       
          }//language 
          go_forward(go_href_link(NAME_OF_FILE_PAGE_MANAGER, (isset($_GET['page']) ? 'page=' . $_GET['page'] . '&' : '') . 'bigwareID=' . $pages_id));
        } else {
          $action = 'new';
        }
        break;
      case 'deleteconfirm':
        $pages_id = go_db_producing_input($_GET['bigwareID']);
        go_db_query("delete from " . DB_TBL_PAGES . " where pages_id = '" . (int)$pages_id . "'");
        $messageStack->add_session(SUCCESS_PAGE_REMOVED, 'success');
        go_forward(go_href_link(NAME_OF_FILE_PAGE_MANAGER, 'page=' . $_GET['page']));
        break;
    }
  }
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="load_this/style.css">
<script language="javascript" src="load_this/menu.js"></script>
<script language="javascript" src="load_this/general.js"></script>
<script language="javascript" src="tiny_mce/tiny_mce.js"></script>
<script language="javascript" src="tiny_mce/tiny_mce_init.js"></script>
<script language="javascript"><!--
function popupImageWindow(url) {
  window.open(url,'popupImageWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}
//--></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<div id="spiffycalendar" class="text"></div>
<!-- header //-->
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_9.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>
    <td width="<?php echo FRAME_WIDTH; ?>" valign="top"></td>
<!-- body_text //-->
    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageGeneralsign"><?php echo ABOVE_TITLE; ?></td>
            <td class="pageGeneralsign" align="right"><?php echo go_fetch_dividing_up('tranparentes.gif', ABOVE_PICTURE_WIDTH, ABOVE_PICTURE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
<?php
  if ($action == 'new') {
    $form_action = 'insert';
    $parameters = array('pages_title' => '',
                        'pages_html_text' => '',
                        'sort_order' =>'',
                        'status' =>'');
    $bInfo = new objectInfo($parameters);
    if (isset($_GET['bigwareID'])) {
      $form_action = 'update';
      $bigwareID = go_db_producing_input($_GET['bigwareID']);
      $page_query = go_db_query("select pages_id,pages_title, pages_html_text, language_id, status, sort_order from " . DB_TBL_PAGES . " where pages_id = '" . (int)$bigwareID . "' group by pages_id");
      $page = go_db_fetch_array($page_query);
      $bInfo->objectInfo($page);
    } elseif (go_not_null($_POST)) {
      $bInfo->objectInfo($_POST);
    }
?>
      <tr>
        <td><?php echo go_fetch_dividing_up('tranparentes.gif', '1', '10'); ?></td>
      </tr>
      <tr><?php echo go_fetch_form('new_page', NAME_OF_FILE_PAGE_MANAGER, (isset($_GET['page']) ? 'page=' . $_GET['page'] . '&' : '') . 'action=' . $form_action, 'post', 'enctype="multipart/form-data"'); if ($form_action == 'update') echo go_fetch_hidden_field('pages_id', $bigwareID);?>
        <td><table border="0" cellspacing="0" cellpadding="2">
         <tr>
            <td class="main" rowspan="3"><?php echo TEXT_PAGES_TITLE; ?></td>
<?php 
 $languages = go_get_languages();
 
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
?>
          
            <td class="main"><?php echo go_picture(FOLDER_RELATIV_LANG_TEMPLATES . $languages[$i]['directory'] . '/picture/' . $languages[$i]['picture'], $languages[$i]['name']) . '&nbsp;' . go_fetch_inputfeld('pages_title[' . $languages[$i]['id'] . ']', (isset($pages_title[$languages[$i]['id']]) ? $pages_title[$languages[$i]['id']] : go_get_pages_title($bInfo->pages_id, $languages[$i]['id'])),'size="80"'); ?></td>
          </tr><tr>
<?php
    } 
?>

          <tr>
            <td class="main"><?php echo TEXT_PAGES_SORT_ORDER; ?></td>
            <td class="main"><?php echo go_fetch_inputfeld('sort_order', $bInfo->sort_order, '', false); ?></td>
          </tr>
          <tr>
            <td colspan="2"><?php echo go_fetch_dividing_up('tranparentes.gif', '1', '10'); ?></td>
          </tr>            
<?php 
 $languages = go_get_languages();
 
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
?> 
           <tr>
            <td valign="top" class="main"><?php echo TEXT_PAGES_HTML_TEXT; ?>
            <td class="main"><?php echo go_picture(FOLDER_RELATIV_LANG_TEMPLATES . $languages[$i]['directory'] . '/picture/' . $languages[$i]['picture'], $languages[$i]['name']) . '&nbsp;'; ?>
<?php 
	echo '<textarea class="mce" name="pages_html_text'.$languages[$i]['id'].'">'.stripslashes((isset($pages_html_text[$languages[$i]['id']]) ? $pages_html_text[$languages[$i]['id']] : go_get_pages_html_text($bInfo->pages_id, $languages[$i]['id']))).'</textarea>';
?>              
   </td>        
           </tr>
<?php
    } 
?>
       
          
          <tr>
            <td colspan="2"><?php echo go_fetch_dividing_up('tranparentes.gif', '1', '10'); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo go_fetch_dividing_up('tranparentes.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
          <tr>
            <td class="main" align="center"><?php echo TEXT_PAGES_PAGE_NOTE . '<br>'; ?></td>
            <td class="main" align="right" valign="top" nowrap><?php echo (($form_action == 'insert') ? go_picture_submit('button_insert.gif', PICTURE_INSERT) : go_picture_submit('button_update.gif', PICTURE_UPDATE)). '&nbsp;&nbsp;<a href="' . go_href_link(NAME_OF_FILE_PAGE_MANAGER, (isset($_GET['page']) ? 'page=' . $_GET['page'] . '&' : '') . (isset($_GET['bigwareID']) ? 'bigwareID=' . $_GET['bigwareID'] : '')) . '">' . go_picture_button('button_cancel.gif', PICTURE_CANCEL) . '</a>'; ?></td>
          </tr>
        </table></td>
      </form></tr>
<?php
} else {
// $languages_id;
?>
      <tr>
        <td><table cellpadding="5" border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="top"><table border="0" cellpadding="5" cellspacing="1" style="border-collapse: collapse" width="100%" id="AutoNumber1">
              <tr class="tbUPCountData" width="100%">
                <td class="tbUPDataInside"><?php echo DB_TBL_ABOVE_PAGES; ?></td>
                <td class="tbUPDataInside"></td>
                <td class="tbUPDataInside"><?php echo DB_TBL_ABOVE_SORT_ORDER; ?></td>
                <td class="tbUPDataInside" align="center"><?php echo DB_TBL_ABOVE_STATUS; ?></td>
                <td class="tbUPDataInside"></td>
                <td class="tbUPDataInside"></td>
              </tr>
<?php
    $pages_query_raw = "select pages_id, pages_title, status, sort_order from " . DB_TBL_PAGES . " where language_id='$languages_id' group by pages_id order by sort_order, pages_title";
    $pages_split = new splitPageResults($_GET['page'], MAX_SHOW_SEARCH_RESULTS, $pages_query_raw, $pages_query_numrows);
    $pages_query = go_db_query($pages_query_raw);
    while ($pages = go_db_fetch_array($pages_query)) {
      if ((!isset($_GET['bigwareID']) || (isset($_GET['bigwareID']) && ($_GET['bigwareID'] == $pages['pages_id']))) && !isset($bInfo) && (substr($action, 0, 3) != 'new')) { 
        $bInfo_array = $pages;
        $bInfo = new objectInfo($bInfo_array);
      }
      if (isset($bInfo) && is_object($bInfo) && ($pages['pages_id'] == $bInfo->pages_id)) {
        echo '              <tr id="defaultSelected" class="tbCountDataSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . go_href_link(NAME_OF_FILE_PAGE_MANAGER, 'page=' . $_GET['page'] . '&bigwareID=' . $pages['pages_id']) . '\'">' . "\n";
      } else {
        echo '              <tr class="tbCountData" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . go_href_link(NAME_OF_FILE_PAGE_MANAGER, 'page=' . $_GET['page'] . '&bigwareID=' . $pages['pages_id']) . '\'">' . "\n";
      }
?>
                <td class="TbInsideData"><?php echo '<a href="javascript:popupImageWindow(\'' . NAME_OF_FILE_POPUP_PICTURE . '?page=' . $pages['pages_id'] . '\')">' . go_picture(FOLDER_RELATIV_PICTURES . 'icon_popup.gif', 'View Page') . '</a>&nbsp;' . $pages['pages_title']; ?></td>
                <td class="TbInsideData" align="right"></td>
                <td class="TbInsideData"><?php echo $pages['sort_order']; ?></td>
                <td class="TbInsideData" align="center">
<?php
      if ($pages['status'] == '1') {
        echo go_picture(FOLDER_RELATIV_PICTURES . 'icon_status_green.gif', 'Active', 10, 10) . '&nbsp;&nbsp;<a href="' . go_href_link(NAME_OF_FILE_PAGE_MANAGER, 'page=' . $_GET['page'] . '&bigwareID=' . $pages['pages_id'] . '&action=setflag&flag=0') . '">' . go_picture(FOLDER_RELATIV_PICTURES . 'icon_status_red_light.gif', 'Set Inactive', 10, 10) . '</a>';
      } else {
        echo '<a href="' . go_href_link(NAME_OF_FILE_PAGE_MANAGER, 'page=' . $_GET['page'] . '&bigwareID=' . $pages['pages_id'] . '&action=setflag&flag=1') . '">' . go_picture(FOLDER_RELATIV_PICTURES . 'icon_status_green_light.gif', 'Set Active', 10, 10) . '</a>&nbsp;&nbsp;' . go_picture(FOLDER_RELATIV_PICTURES . 'icon_status_red.gif', 'Inactive', 10, 10);
      }
?></td>
                <td class="TbInsideData" align="right"></td>
               <td class="TbInsideData" align="right"><?php if (isset($bInfo) && is_object($bInfo) && ($pages['pages_id'] == $bInfo->pages_id)) { echo go_picture(FOLDER_RELATIV_PICTURES . 'icon_arrow_right.gif'); } else { echo '<a href="' . go_href_link(NAME_OF_FILE_PAGE_MANAGER, 'page=' . $_GET['page'] . '&bigwareID=' . $pages['pages_id']) . '">' . go_picture(FOLDER_RELATIV_PICTURES . 'icon_info.gif', PICTURE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
              </tr>
<?php
    }
?>
              <tr>
                <td colspan="5"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                  <tr>
                    <td class="smallText" valign="top"><?php echo $pages_split->display_count($pages_query_numrows, MAX_SHOW_SEARCH_RESULTS, $_GET['page'], TEXT_SHOW_NUMBER_OF_PAGES); ?></td>
                    <td class="smallText" align="right"><?php echo $pages_split->display_links($pages_query_numrows, MAX_SHOW_SEARCH_RESULTS, MAX_SHOW_PAGE_LINKS, $_GET['page']); ?></td>
                  </tr>
                  <tr>
                    <td align="right" colspan="2"><?php echo '<a href="' . go_href_link(NAME_OF_FILE_PAGE_MANAGER, 'action=new') . '">' . go_picture_button('button_new_file.gif', PICTURE_NEW_PAGE) . '</a>'; ?></td>
                  </tr>
                </table></td>
              </tr>
            </table></td>
<?php
  $heading = array();
  $contents = array();
  switch ($action) {
    case 'delete':
      $heading[] = array('text' => '<b>' . $bInfo->pages_title . '</b>');
      $contents = array('form' => go_fetch_form('pages', NAME_OF_FILE_PAGE_MANAGER, 'page=' . $_GET['page'] . '&bigwareID=' . $bInfo->pages_id . '&action=deleteconfirm'));
      $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
      $contents[] = array('text' => '<br><b>' . $bInfo->pages_title . '</b>');
      if ($bInfo->pages_picture) $contents[] = array('text' => '<br>' . go_fetch_checkbox_field('delete_picture', 'on', true) . ' ' . TEXT_INFO_DELETE_PICTURE);
      $contents[] = array('align' => 'center', 'text' => '<br>' . go_picture_submit('button_delete.gif', PICTURE_DELETE) . '&nbsp;<a href="' . go_href_link(NAME_OF_FILE_PAGE_MANAGER, 'page=' . $_GET['page'] . '&bigwareID=' . $_GET['bigwareID']) . '">' . go_picture_button('button_cancel.gif', PICTURE_CANCEL) . '</a>');
      break;
    default:
      if (is_object($bInfo)) {
        $heading[] = array('text' => '<b>' . $bInfo->pages_title . '</b>');
        $contents[] = array('align' => 'center', 'text' => '<br><br><a href="' . go_href_link(NAME_OF_FILE_PAGE_MANAGER, 'page=' . $_GET['page'] . '&bigwareID=' . $bInfo->pages_id . '&action=new') . '">' . go_picture_button('button_change.gif', PICTURE_CHANGE) . '</a> <a href="' . go_href_link(NAME_OF_FILE_PAGE_MANAGER, 'page=' . $_GET['page'] . '&bigwareID=' . $bInfo->pages_id . '&action=delete') . '">' . go_picture_button('button_delete.gif', PICTURE_DELETE) . '</a><br><br><br>');
        if ($bInfo->date_scheduled) $contents[] = array('text' => '<br>' . sprintf(TEXT_PAGES_SCHEDULED_AT_DATE, go_date_short($bInfo->date_scheduled)));
        if ($bInfo->expires_date) {
          $contents[] = array('text' => '<br>' . sprintf(TEXT_PAGES_EXPIRES_AT_DATE, go_date_short($bInfo->expires_date)));
        } elseif ($bInfo->expires_impressions) {
          $contents[] = array('text' => '<br>' . sprintf(TEXT_PAGES_EXPIRES_AT_IMPRESSIONS, $bInfo->expires_impressions));
        }
        if ($bInfo->date_status_change) $contents[] = array('text' => '<br>' . sprintf(TEXT_PAGES_STATUS_CHANGE, go_date_short($bInfo->date_status_change)));
      }
      break;
  }
  if ( (go_not_null($heading)) && (go_not_null($contents)) ) {
    echo '            <td width="25%" valign="top"><br>' . "\n";
    $frame = new frame;
    echo $frame->infoBox($heading, $contents);
    echo '            </td>' . "\n";
  }
?>
          </tr>
        </table></td>
      </tr>
<?php
  }
?>
    </table></td>
<!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_7.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_6.php'); ?>
