ZenCart_Documentation  1.5.0
http://www.collinsharper.com
C:/xampp/htdocs/zen-cart/admin/define_pages_editor.php
Go to the documentation of this file.
00001 <?php
00010   require('includes/application_top.php');
00011 
00012   function zen_display_files() {
00013     global $check_directory, $found, $configuration_key_lookup;
00014     for ($i = 0, $n = sizeof($check_directory); $i < $n; $i++) {
00015 //echo 'I SEE ' . $check_directory[$i] . '<br>';
00016 
00017       $dir_check = $check_directory[$i];
00018       $file_extension = '.php';
00019 
00020       if ($dir = @dir($dir_check)) {
00021         while ($file = $dir->read()) {
00022           if (!is_dir($dir_check . $file)) {
00023             if (substr($file, strrpos($file, '.')) == $file_extension) {
00024               $directory_array[] = $file;
00025             }
00026           }
00027         }
00028         if (sizeof($directory_array)) {
00029           sort($directory_array);
00030         }
00031         $dir->close();
00032       }
00033     }
00034     return $directory_array;
00035   }
00036 
00037   $action = (isset($_GET['action']) ? $_GET['action'] : '');
00038 
00039   $za_who = $_GET['za_lookup'];
00040 
00041   if ($action == 'new_page') {
00042     $page = $_GET['define_it'];
00043 
00044     $check_directory = array();
00045     $check_directory[] = DIR_FS_CATALOG . DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/';
00046     $directory_files = zen_display_files();
00047 
00048     $za_lookup = array();
00049     for ($i = 0, $n = sizeof($directory_files); $i < $n; $i++) {
00050       $za_lookup[] = array('id' => $i, 'text' => $directory_files[$i]);
00051     }
00052 
00053 // This will cause it to look for 'define_conditions.php'
00054     $_GET['filename'] = $za_lookup[$page]['text'];
00055     $_GET['box_name'] = BOX_TOOLS_DEFINE_CONDITIONS;
00056   }
00057 
00058 // define template specific file name defines
00059   $file = zen_get_file_directory(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/html_includes/', $_GET['filename'], 'false');
00060 ?>
00061 <?php
00062   switch ($_GET['action']) {
00063       case 'set_editor':
00064         // Reset will be done by init_html_editor.php. Now we simply redirect to refresh page properly.
00065         $action='';
00066         zen_redirect(zen_href_link(FILENAME_DEFINE_PAGES_EDITOR));
00067         break;
00068     case 'save':
00069       if ( ($_GET['lngdir']) && ($_GET['filename']) ) {
00070         if (file_exists($file)) {
00071           if (file_exists('bak' . $file)) {
00072             @unlink('bak' . $file);
00073           }
00074           @rename($file, 'bak' . $file);
00075           $new_file = fopen($file, 'w');
00076           $file_contents = stripslashes($_POST['file_contents']);
00077           fwrite($new_file, $file_contents, strlen($file_contents));
00078           fclose($new_file);
00079         }
00080         zen_redirect(zen_href_link(FILENAME_DEFINE_PAGES_EDITOR));
00081       }
00082       break;
00083   }
00084 
00085   if (!$_SESSION['language']) $_SESSION['language'] = $language;
00086 
00087   $languages_array = array();
00088   $languages = zen_get_languages();
00089   $lng_exists = false;
00090   for ($i=0; $i<sizeof($languages); $i++) {
00091     if ($languages[$i]['directory'] == $_SESSION['language']) $lng_exists = true;
00092 
00093     $languages_array[] = array('id' => $languages[$i]['directory'],
00094                                'text' => $languages[$i]['name']);
00095   }
00096   if (!$lng_exists) $_SESSION['language'] = $language;
00097 ?>
00098 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
00099 <html <?php echo HTML_PARAMS; ?>>
00100 <head>
00101 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
00102 <title><?php echo TITLE; ?></title>
00103 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
00104 <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
00105 <script language="javascript" src="includes/menu.js"></script>
00106 <script language="javascript" src="includes/general.js"></script>
00107 <script type="text/javascript">
00108   <!--
00109   function init()
00110   {
00111     cssjsmenu('navbar');
00112     if (document.getElementById)
00113     {
00114       var kill = document.getElementById('hoverJS');
00115       kill.disabled = true;
00116     }
00117   if (typeof _editor_url == "string") HTMLArea.replaceAll();
00118   }
00119   // -->
00120 </script>
00121 <?php if ($editor_handler != '') include ($editor_handler); ?>
00122 </head>
00123 <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onLoad="init()">
00124 <div id="spiffycalendar" class="text"></div>
00125 <!-- header //-->
00126 <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
00127 <!-- header_eof //-->
00128 
00129 <!-- body //-->
00130 <table border="0" width="100%" cellspacing="2" cellpadding="2">
00131   <tr>
00132 <!-- body_text //-->
00133     <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00134       <tr>
00135         <td class="pageHeading"><?php echo HEADING_TITLE . '&nbsp;' . $_SESSION['language']; ?> &nbsp;&nbsp;
00136           <?php
00137             $check_directory = array();
00138             $check_directory[] = DIR_FS_CATALOG . DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/';
00139             $directory_files = zen_display_files();
00140 
00141             $za_lookup = array();
00142             $za_lookup[] = array('id' => -1, 'text' => TEXT_INFO_SELECT_FILE);
00143 
00144             for ($i = 0, $n = sizeof($directory_files); $i < $n; $i++) {
00145               $za_lookup[] = array('id' => $i, 'text' => $directory_files[$i]);
00146             }
00147 
00148             echo zen_draw_form('new_page', FILENAME_DEFINE_PAGES_EDITOR, '', 'get') . '&nbsp;&nbsp;' . zen_draw_pull_down_menu('define_it', $za_lookup, '-1', 'onChange="this.form.submit();"') .
00149             zen_hide_session_id() .
00150             zen_draw_hidden_field('action', 'new_page') . '&nbsp;&nbsp;</form>';
00151           ?>
00152 <?php
00153 // toggle switch for editor
00154         echo TEXT_EDITOR_INFO . zen_draw_form('set_editor_form', FILENAME_DEFINE_PAGES_EDITOR, '', 'get') . '&nbsp;&nbsp;' . zen_draw_pull_down_menu('reset_editor', $editors_pulldown, $current_editor_key, 'onChange="this.form.submit();"') .
00155         zen_draw_hidden_field('action', 'set_editor') .
00156         zen_hide_session_id() .
00157         '</form>';
00158 ?>
00159         </td>
00160       </tr>
00161 <?php
00162 // show editor
00163 if (isset($_GET['filename'])) {
00164 ?>
00165       <tr>
00166         <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
00167 <?php
00168   if ( ($_SESSION['language']) && ($_GET['filename']) ) {
00169     if (file_exists($file)) {
00170       $file_array = @file($file);
00171       $file_contents = @implode('', $file_array);
00172 
00173       $file_writeable = true;
00174       if (!is_writeable($file)) {
00175         $file_writeable = false;
00176         $messageStack->reset();
00177         $messageStack->add(sprintf(ERROR_FILE_NOT_WRITEABLE, $file), 'error');
00178         echo $messageStack->output();
00179       }
00180 
00181 ?>
00182               <tr>
00183             <td class="main"><b><?php echo TEXT_INFO_CAUTION . '<br /><br />' . TEXT_INFO_EDITING . '<br />' . $file . '<br />'; ?></b></td>
00184               </tr>
00185           <tr><?php echo zen_draw_form('language', FILENAME_DEFINE_PAGES_EDITOR, 'lngdir=' . $_SESSION['language'] . '&filename=' . $_GET['filename'] . '&action=save'); ?>
00186             <td><table border="0" cellspacing="0" cellpadding="2">
00187               <tr>
00188                 <td class="main"><?php echo zen_draw_textarea_field('file_contents', 'soft', '100%', '30', htmlspecialchars($file_contents, ENT_COMPAT, CHARSET, TRUE), (($file_writeable) ? '' : 'readonly') . ' id="file_contents"'); ?></td>
00189               </tr>
00190               <tr>
00191                 <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
00192               </tr>
00193               <tr>
00194                 <td align="right"><?php if ($file_writeable) { echo zen_image_submit('button_save.gif', IMAGE_SAVE) . '&nbsp;<a href="' . zen_href_link(FILENAME_DEFINE_PAGES_EDITOR, 'define_it=' .$_GET['define_it'] . '&action=new_page') . '">' . zen_image_button('button_reset.gif', IMAGE_RESET) . '</a>' . '&nbsp;' . '<a href="' . zen_href_link(FILENAME_DEFINE_PAGES_EDITOR . '.php') . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; } else { echo '<a href="' . zen_href_link(FILENAME_DEFINE_PAGES_EDITOR, 'lngdir=' . $_SESSION['language']) . '">' . zen_image_button('button_back.gif', IMAGE_BACK) . '</a>'; } ?></td>
00195               </tr>
00196             </table></td>
00197           </form></tr>
00198 <?php
00199     } else {
00200 ?>
00201           <tr>
00202             <td class="main"><b><?php echo sprintf(TEXT_FILE_DOES_NOT_EXIST, $file); ?></b></td>
00203           </tr>
00204           <tr>
00205             <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
00206           </tr>
00207           <tr>
00208             <td><?php echo '<a href="' . zen_href_link($_GET['filename'], 'lngdir=' . $_SESSION['language']) . '">' . zen_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
00209           </tr>
00210 <?php
00211     }
00212   } else {
00213     $filename = $_SESSION['language'] . '.php';
00214 ?>
00215           <tr>
00216             <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
00217               <tr>
00218                 <td class="smallText"><a href="<?php echo zen_href_link($_GET['filename'], 'lngdir=' . $_SESSION['language'] . '&filename=' . $filename); ?>"><b><?php echo $filename; ?></b></a></td>
00219 <?php
00220     $dir = dir(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language']);
00221     $left = false;
00222     if ($dir) {
00223       $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
00224       while ($file = $dir->read()) {
00225         if (substr($file, strrpos($file, '.')) == $file_extension) {
00226           echo '                <td class="smallText"><a href="' . zen_href_link($_GET['filename'], 'lngdir=' . $_SESSION['language'] . '&filename=' . $file) . '">' . $file . '</a></td>' . "\n";
00227           if (!$left) {
00228             echo '              </tr>' . "\n" .
00229                  '              <tr>' . "\n";
00230           }
00231           $left = !$left;
00232         }
00233       }
00234       $dir->close();
00235     }
00236 ?>
00237 
00238               </tr>
00239             </table></td>
00240           </tr>
00241 <?php
00242   }
00243 ?>
00244         </table></td>
00245 <?php } // filename ?>
00246       </tr>
00247     </table></td>
00248 <!-- body_text_eof //-->
00249   </tr>
00250 </table>
00251 <!-- body_eof //-->
00252 
00253 <!-- footer //-->
00254 <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
00255 <!-- footer_eof //-->
00256 <br />
00257 </body>
00258 </html>
00259 <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
 All Data Structures Namespaces Files Functions Variables Enumerations