ZenCart_Documentation  1.5.0
http://www.collinsharper.com
C:/xampp/htdocs/zen-cart/admin/template_select.php
Go to the documentation of this file.
00001 <?php
00010   require('includes/application_top.php');
00011 // get an array of template info
00012   $dir = @dir(DIR_FS_CATALOG_TEMPLATES);
00013   if (!$dir) die('DIR_FS_CATALOG_TEMPLATES NOT SET');
00014   while ($file = $dir->read()) {
00015     if (is_dir(DIR_FS_CATALOG_TEMPLATES . $file) && strtoupper($file) != 'CVS' && $file != 'template_default') {
00016       if (file_exists(DIR_FS_CATALOG_TEMPLATES . $file . '/template_info.php')) {
00017         require(DIR_FS_CATALOG_TEMPLATES . $file . '/template_info.php');
00018         $template_info[$file] = array('name' => $template_name,
00019                                       'version' => $template_version,
00020                                       'author' => $template_author,
00021                                       'description' => $template_description,
00022                                       'screenshot' => $template_screenshot);
00023       }
00024     }
00025   }
00026   $dir->close();
00027 
00028   $action = (isset($_GET['action']) ? $_GET['action'] : '');
00029 
00030   if (zen_not_null($action)) {
00031     switch ($action) {
00032       case 'insert':
00033         // @TODO: add duplicate-detection and empty-submission detection
00034         $sql = "select * from " . TABLE_TEMPLATE_SELECT . " where template_language = :lang:";
00035         $sql = $db->bindVars($sql, ':lang:', $_POST['lang'], 'string');
00036         $check_query = $db->Execute($sql);
00037         if ($check_query->RecordCount() < 1 ) {
00038           $sql = "insert into " . TABLE_TEMPLATE_SELECT . " (template_dir, template_language) values (:tpl:, :lang:)";
00039           $sql = $db->bindVars($sql, ':tpl:', $_POST['ln'], 'string');
00040           $sql = $db->bindVars($sql, ':lang:', $_POST['lang'], 'string');
00041           $db->Execute($sql);
00042           $_GET['tID'] = $db->Insert_ID();
00043         }
00044         $action="";
00045         break;
00046       case 'save':
00047         $sql = "update " . TABLE_TEMPLATE_SELECT . " set template_dir = :tpl: where template_id = :id:";
00048         $sql = $db->bindVars($sql, ':tpl:', $_POST['ln'], 'string');
00049         $sql = $db->bindVars($sql, ':id:', $_GET['tID'], 'integer');
00050         $db->Execute($sql);
00051         break;
00052       case 'deleteconfirm':
00053         $check_query = $db->Execute("select template_language from " . TABLE_TEMPLATE_SELECT . " where template_id = '" . (int)$_POST['tID'] . "'");
00054         if ( $check_query->fields['template_language'] != 0 ) {
00055           $db->Execute("delete from " . TABLE_TEMPLATE_SELECT . " where template_id = '" . (int)$_POST['tID'] . "'");
00056           zen_redirect(zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page']));
00057         }
00058         $action="";
00059         break;
00060     }
00061   }
00062 ?>
00063 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
00064 <html <?php echo HTML_PARAMS; ?>>
00065 <head>
00066 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
00067 <title><?php echo TITLE; ?></title>
00068 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
00069 <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
00070 <script language="javascript" src="includes/menu.js"></script>
00071 <script language="javascript" src="includes/general.js"></script>
00072 <script type="text/javascript">
00073   <!--
00074   function init()
00075   {
00076     cssjsmenu('navbar');
00077     if (document.getElementById)
00078     {
00079       var kill = document.getElementById('hoverJS');
00080       kill.disabled = true;
00081     }
00082   }
00083   // -->
00084 </script>
00085 </head>
00086 <body onLoad="init()">
00087 <!-- header //-->
00088 <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
00089 <!-- header_eof //-->
00090 <!-- body //-->
00091 <table border="0" width="100%" cellspacing="2" cellpadding="2">
00092   <tr>
00093     <!-- body_text //-->
00094     <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00095         <tr>
00096           <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
00097               <tr>
00098                 <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
00099                 <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
00100               </tr>
00101             </table></td>
00102         </tr>
00103         <tr>
00104           <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
00105               <tr>
00106                 <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00107                     <tr class="dataTableHeadingRow">
00108                       <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_LANGUAGE; ?></td>
00109                       <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_NAME; ?></td>
00110                       <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_DIRECTORY; ?></td>
00111                       <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
00112                     </tr>
00113                     <?php
00114   $template_query_raw = "select * from " . TABLE_TEMPLATE_SELECT;
00115   $template_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $template_query_raw, $template_query_numrows);
00116   $templates = $db->Execute($template_query_raw);
00117   while (!$templates->EOF) {
00118     if ((!isset($_GET['tID']) || (isset($_GET['tID']) && ($_GET['tID'] == $templates->fields['template_id']))) && !isset($tInfo) && (substr($action, 0, 3) != 'new')) {
00119       $tInfo = new objectInfo($templates->fields);
00120     }
00121 
00122     if (isset($tInfo) && is_object($tInfo) && ($templates->fields['template_id'] == $tInfo->template_id)) {
00123       echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $tInfo->template_id . '&action=edit') . '\'">' . "\n";
00124     } else {
00125       echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $templates->fields['template_id']) . '\'">' . "\n";
00126     }
00127     if ($templates->fields['template_language'] == 0) {
00128       $template_language = "Default(All)";
00129     } else {
00130       $ln = $db->Execute("select name
00131                           from " . TABLE_LANGUAGES . "
00132                           where languages_id = '" . $templates->fields['template_language'] . "'");
00133       $template_language = $ln->fields['name'];
00134     }
00135 ?>
00136                     <td class="dataTableContent"><?php echo $template_language; ?></td>
00137                     <td class="dataTableContent"><?php echo $template_info[$templates->fields['template_dir']]['name']; ?></td>
00138                     <td class="dataTableContent" align="center"><?php echo $templates->fields['template_dir']; ?></td>
00139                     <td class="dataTableContent" align="right">
00140                       <?php if (isset($tInfo) && is_object($tInfo) && ($templates->fields['template_id'] == $tInfo->template_id) ) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $templates->fields['template_id']) . '">' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>
00141                       &nbsp;</td>
00142                     </tr>
00143 <?php
00144     $templates->MoveNext();
00145   }
00146 ?>
00147                     <tr>
00148                       <td colspan="4"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00149                           <tr>
00150                             <td class="smallText" valign="top"><?php echo $template_split->display_count($template_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_TEMPLATES); ?></td>
00151                             <td class="smallText" align="right"><?php echo $template_split->display_links($template_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_GET['page']); ?></td>
00152                           </tr>
00153                           <?php
00154   if (empty($action)) {
00155 ?>
00156                           <tr>
00157                             <td colspan="2" align="right"><?php echo '<a href="' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&action=new') . '">' . zen_image_button('button_new_language.gif', IMAGE_NEW_TEMPLATE) . '</a>'; ?></td>
00158                           </tr>
00159                           <?php
00160   }
00161 ?>
00162                         </table></td>
00163                     </tr>
00164                   </table></td>
00165                 <?php
00166   $heading = array();
00167   $contents = array();
00168 
00169   switch ($action) {
00170     case 'new':
00171       $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_TEMPLATE . '</b>');
00172 
00173       $contents = array('form' => zen_draw_form('zones', FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&action=insert'));
00174       $contents[] = array('text' => TEXT_INFO_INSERT_INTRO);
00175       while (list ($key, $value) = each($template_info) ) {
00176         $template_array[] = array('id' => $key, 'text' => $value['name']);
00177       }
00178       $lns = $db->Execute("select name, languages_id from " . TABLE_LANGUAGES);
00179       while (!$lns->EOF) {
00180         $language_array[] = array('text' => $lns->fields['name'], 'id' => $lns->fields['languages_id']);
00181         $lns->MoveNext();
00182       }
00183       $contents[] = array('text' => '<br>' . TEXT_INFO_TEMPLATE_NAME . '<br>' . zen_draw_pull_down_menu('ln', $template_array));
00184       $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_NAME . '<br>' . zen_draw_pull_down_menu('lang', $language_array, $_POST['lang']));
00185       $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_insert.gif', IMAGE_INSERT) . '&nbsp;<a href="' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page']) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
00186       break;
00187     case 'edit':
00188       $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_EDIT_TEMPLATE . '</b>');
00189 
00190       $contents = array('form' => zen_draw_form('templateselect', FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $tInfo->template_id . '&action=save'));
00191       $contents[] = array('text' => TEXT_INFO_EDIT_INTRO);
00192       reset($template_info);
00193       while (list ($key, $value) = each($template_info) ) {
00194         $template_array[] = array('id' => $key, 'text' => $value['name']);
00195       }
00196       $contents[] = array('text' => '<br>' . TEXT_INFO_TEMPLATE_NAME . '<br>' . zen_draw_pull_down_menu('ln', $template_array, $templates->fields['template_dir']));
00197       $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_update.gif', IMAGE_UPDATE) . '&nbsp;<a href="' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $tInfo->template_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
00198       break;
00199     case 'delete':
00200       $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_TEMPLATE . '</b>');
00201 
00202       $contents = array('form' => zen_draw_form('zones', FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&action=deleteconfirm') . zen_draw_hidden_field('tID', $tInfo->template_id));
00203       $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
00204       $contents[] = array('text' => '<br><b>' . $template_info[$tInfo->template_dir]['name'] . '</b>');
00205       $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_delete.gif', IMAGE_DELETE) . '&nbsp;<a href="' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $tInfo->template_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
00206       break;
00207     default:
00208       if (isset($tInfo) && is_object($tInfo)) {
00209         $heading[] = array('text' => '<b>' . $template_info[$tInfo->template_dir]['name'] . '</b>');
00210         if ($tInfo->template_language == 0) {
00211           $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $tInfo->template_id . '&action=edit') . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '</a>');
00212         } else {
00213           $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $tInfo->template_id . '&action=edit') . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . zen_href_link(FILENAME_TEMPLATE_SELECT, 'page=' . $_GET['page'] . '&tID=' . $tInfo->template_id . '&action=delete') . '">' . zen_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
00214         }
00215         $contents[] = array('text' => '<br>' . TEXT_INFO_TEMPLATE_AUTHOR  . $template_info[$tInfo->template_dir]['author']);
00216         $contents[] = array('text' => '<br>' . TEXT_INFO_TEMPLATE_VERSION  . $template_info[$tInfo->template_dir]['version']);
00217         $contents[] = array('text' => '<br>' . TEXT_INFO_TEMPLATE_DESCRIPTION  . '<br />' . $template_info[$tInfo->template_dir]['description']);
00218         $contents[] = array('text' => '<br>' . TEXT_INFO_TEMPLATE_INSTALLED  . '<br />');
00219         while (list ($key, $value) = each($template_info) ) {
00220           $contents[] = array('text' => '<a href="' . DIR_WS_CATALOG_TEMPLATE . $key . '/images/' . $value['screenshot'] . '" target = "_blank">' . zen_image_button('button_preview.gif', IMAGE_PREVIEW) . '</a>&nbsp;&nbsp;' . $value['name']);
00221         }
00222       }
00223       break;
00224   }
00225 
00226   if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) {
00227     echo '            <td width="25%" valign="top">' . "\n";
00228 
00229     $box = new box;
00230     echo $box->infoBox($heading, $contents);
00231 
00232     echo '            </td>' . "\n";
00233   }
00234 ?>
00235               </tr>
00236             </table></td>
00237         </tr>
00238       </table></td>
00239     <!-- body_text_eof //-->
00240   </tr>
00241 </table>
00242 <!-- body_eof //-->
00243 <!-- footer //-->
00244 <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
00245 <!-- footer_eof //-->
00246 <br>
00247 </body>
00248 </html>
00249 <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
 All Data Structures Namespaces Files Functions Variables Enumerations