[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/admin/ -> define_mainpage.php (source)

   1  <?php
   2  /*

   3  $Id: define_mainpage.php 14 2006-07-28 17:42:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax2005 osCMax, 2002 osCommerce

   9  

  10    //////////////////////////////////////////////////////////////////////////

  11  

  12    define_mainpage.php Version 1.2

  13  

  14    DESCRIPTION:

  15  

  16    An extremely simple hack of define_languages.php, this file

  17    ALWAYS looks for the file mainpage.php in the language directory.

  18    This is a nice example to show how easy you can adapt existing code

  19    to your needs; apart from the translation and filename(s) I only had to

  20    add ONE SINGLE LINE to define_languages.php to make it into this.

  21  

  22    06/04/02 Matthijs ([email protected])

  23  

  24    This file has been edit to be up to date with the current snapshot...some

  25    minor and slight additions where added and simple little things where fixed:

  26    July 29, 2002

  27  

  28    Steven Pignataro ([email protected])

  29  

  30    /////////////////////////////////////////////////////////////////////////

  31  

  32    Released under the GNU General Public License

  33  */
  34  
  35    require ('includes/application_top.php');
  36    require (DIR_FCKEDITOR . 'fckeditor.php');
  37  // This will cause it to look for 'mainpage.php'

  38  
  39    $HTTP_GET_VARS['filename'] = FILENAME_DEFINE_MAINPAGE_CONTENT;
  40  
  41    switch ($HTTP_GET_VARS['action']) {
  42      case 'save':
  43        if ( ($HTTP_GET_VARS['lngdir']) && ($HTTP_GET_VARS['filename']) ) {
  44          if ($HTTP_GET_VARS['filename'] == $language . '.php') {
  45            $file = DIR_FS_CATALOG_LANGUAGES . $HTTP_GET_VARS['filename'];
  46          } else {
  47            $file = DIR_FS_CATALOG_LANGUAGES . $HTTP_GET_VARS['lngdir'] . '/' . $HTTP_GET_VARS['filename'];
  48          }
  49          if (file_exists($file)) {
  50            if (file_exists('bak' . $file)) {
  51              @unlink('bak' . $file);
  52            }
  53            @rename($file, 'bak' . $file);
  54            $new_file = fopen($file, 'w');
  55            $file_contents = stripslashes($HTTP_POST_VARS['file_contents']);
  56            fwrite($new_file, $file_contents, strlen($file_contents));
  57            fclose($new_file);
  58          }
  59          tep_redirect(tep_href_link(FILENAME_DEFINE_MAINPAGE, 'lngdir=' . $HTTP_GET_VARS['lngdir']));
  60        }
  61        break;
  62    }
  63  
  64    if (!$HTTP_GET_VARS['lngdir']) $HTTP_GET_VARS['lngdir'] = $language;
  65  
  66    $languages_array = array();
  67    $languages = tep_get_languages();
  68    $lng_exists = false;
  69    for ($i=0; $i<sizeof($languages); $i++) {
  70      if ($languages[$i]['directory'] == $HTTP_GET_VARS['lngdir']) $lng_exists = true;
  71  
  72      $languages_array[] = array('id' => $languages[$i]['directory'],
  73                                 'text' => $languages[$i]['name']);
  74    }
  75    if (!$lng_exists) $HTTP_GET_VARS['lngdir'] = $language;
  76  ?>
  77  <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  78  <html <?php echo HTML_PARAMS; ?>>
  79  <head>
  80  <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  81  <title><?php echo TITLE; ?></title>
  82  <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
  83  </head>
  84  <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="HTMLArea.replaceAll(config);">
  85  <!-- header //-->
  86  <?php require (DIR_WS_INCLUDES . 'header.php'); ?>
  87  <!-- header_eof //-->
  88  
  89  <!-- body //-->
  90  <table border="0" width="100%" cellspacing="2" cellpadding="2">
  91    <tr>
  92      <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
  93  <!-- left_navigation //-->
  94  <?php require (DIR_WS_INCLUDES . 'column_left.php'); ?>
  95  <!-- left_navigation_eof //-->
  96      </table></td>
  97  <!-- body_text //-->
  98      <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  99        <tr>
 100          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 101            <tr><?php echo tep_draw_form('lng', FILENAME_DEFINE_MAINPAGE, '', 'get'); ?>
 102              <td class="pageHeading"><?php echo BOX_CATALOG_DEFINE_MAINPAGE; ?></td>
 103              <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', '1', HEADING_IMAGE_HEIGHT); ?></td>
 104              <td class="pageHeading" align="right"><?php echo tep_draw_pull_down_menu('lngdir', $languages_array, '', 'onChange="this.form.submit();"'); ?></td>
 105            </form></tr>
 106          </table></td>
 107        </tr>
 108        <tr>
 109          <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
 110  <?php
 111    if ( ($HTTP_GET_VARS['lngdir']) && ($HTTP_GET_VARS['filename']) ) {
 112      if ($HTTP_GET_VARS['filename'] == $language . '.php') {
 113        $file = DIR_FS_CATALOG_LANGUAGES . $HTTP_GET_VARS['filename'];
 114      } else {
 115        $file = DIR_FS_CATALOG_LANGUAGES . $HTTP_GET_VARS['lngdir'] . '/' . $HTTP_GET_VARS['filename'];
 116      }
 117      if (file_exists($file)) {
 118        $file_array = @file($file);
 119        $file_contents = @implode('', $file_array);
 120  
 121        $file_writeable = true;
 122        if (!is_writeable($file)) {
 123          $file_writeable = false;
 124          $messageStack->reset();
 125          $messageStack->add(sprintf(ERROR_DESTINATION_NOT_WRITEABLE, $file), 'error');
 126          echo $messageStack->output();
 127        }
 128  
 129  ?>
 130            <tr><?php echo tep_draw_form('language', FILENAME_DEFINE_MAINPAGE, 'lngdir=' . $HTTP_GET_VARS['lngdir'] . '&filename=' . $HTTP_GET_VARS['filename'] . '&action=save'); ?>
 131              <td><table border="0" cellspacing="0" cellpadding="2">
 132                <tr>
 133                  <td class="main"><b><?php echo $HTTP_GET_VARS['filename']; ?></b></td>
 134                </tr>
 135                <tr>
 136                  <td class="main"><?php if (HTML_AREA_WYSIWYG_DISABLE_DEFINE == 'Enable') {
 137  // Line Changed - MOD: Ajustable Editor Window

 138                  echo tep_draw_fckeditor('file_contents', HTML_AREA_WYSIWYG_EDITOR_WIDTH, HTML_AREA_WYSIWYG_EDITOR_HEIGHT, $file_contents, (($file_writeable) ? '' : 'readonly')) . '</td>';
 139                } else { echo tep_draw_textarea_field('file_contents', 'soft', '100%', '30', $file_contents, (($file_writeable) ? '' : 'readonly')) . '</td>';
 140                 }
 141                 ?>
 142                 </tr>
 143                <tr>
 144                  <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 145                </tr>
 146                <tr>
 147                  <td align="right"><?php if ($file_writeable) { echo tep_image_submit('button_save.gif', IMAGE_SAVE) . '&nbsp;<a href="' . tep_href_link(FILENAME_DEFINE_MAINPAGE, 'lngdir=' . $HTTP_GET_VARS['lngdir']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; } else { echo '<a href="' . tep_href_link(FILENAME_DEFINE_MAINPAGE, 'lngdir=' . $HTTP_GET_VARS['lngdir']) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; } ?></td>
 148                </tr>
 149              </table></td>
 150            </form></tr>
 151  <?php
 152      } else {
 153  ?>
 154            <tr>
 155              <td class="main"><b><?php echo TEXT_FILE_DOES_NOT_EXIST; ?></b></td>
 156            </tr>
 157            <tr>
 158              <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 159            </tr>
 160            <tr>
 161              <td><?php echo '<a href="' . tep_href_link(FILENAME_DEFINE_MAINPAGE, 'lngdir=' . $HTTP_GET_VARS['lngdir']) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
 162            </tr>
 163  <?php
 164      }
 165    } else {
 166      $filename = $HTTP_GET_VARS['lngdir'] . '.php';
 167  ?>
 168            <tr>
 169              <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
 170                <tr>
 171                  <td class="smallText"><a href="<?php echo tep_href_link(FILENAME_DEFINE_MAINPAGE, 'lngdir=' . $HTTP_GET_VARS['lngdir'] . '&filename=' . $filename); ?>"><b><?php echo $filename; ?></b></a></td>
 172  <?php
 173      $dir = dir(DIR_FS_CATALOG_LANGUAGES . $HTTP_GET_VARS['lngdir']);
 174      $left = false;
 175      if ($dir) {
 176        $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
 177        while ($file = $dir->read()) {
 178          if (substr($file, strrpos($file, '.')) == $file_extension) {
 179            echo '                <td class="smallText"><a href="' . tep_href_link(FILENAME_DEFINE_MAINPAGE, 'lngdir=' . $HTTP_GET_VARS['lngdir'] . '&filename=' . $file) . '">' . $file . '</a></td>' . "\n";
 180            if (!$left) {
 181              echo '              </tr>' . "\n" .
 182                   '              <tr>' . "\n";
 183            }
 184            $left = !$left;
 185          }
 186        }
 187        $dir->close();
 188      }
 189  ?>
 190  
 191  
 192  
 193                </tr>
 194              </table></td>
 195            </tr>
 196            <tr>
 197              <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 198            </tr>
 199            <tr>
 200              <td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_FILE_MANAGER, 'current_path=' . DIR_FS_CATALOG_LANGUAGES . $HTTP_GET_VARS['lngdir']) . '">' . tep_image_button('button_file_manager.gif', IMAGE_FILE_MANAGER) . '</a>'; ?></td>
 201            </tr>
 202  <?php
 203    }
 204  ?>
 205          </table></td>
 206        </tr>
 207      </table></td>
 208  <!-- body_text_eof //-->
 209    </tr>
 210  </table>
 211  <!-- body_eof //-->
 212  
 213  <!-- footer //-->
 214  <?php require (DIR_WS_INCLUDES . 'footer.php'); ?>
 215  <!-- footer_eof //-->
 216  <br>
 217  </body>
 218  </html>
 219  <?php require (DIR_WS_INCLUDES . 'application_bottom.php'); ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7