[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/admin/ -> infobox_configuration.php (source)

   1  <?php
   2  /*

   3  $Id: infobox_configuration.php 3 2006-05-27 04:59:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax2005 osCMax, 2002 osCommerce

   9  

  10    Released under the GNU General Public License

  11  */
  12  
  13    require ('includes/application_top.php');
  14  
  15    if ($HTTP_GET_VARS['action']) {
  16      switch ($HTTP_GET_VARS['action']) {
  17  
  18        case 'setflag': //set the status of a news item.
  19          if ( ($HTTP_GET_VARS['flag'] == 'no') || ($HTTP_GET_VARS['flag'] == 'yes') ) {
  20            if ($HTTP_GET_VARS['cID']) {
  21              tep_db_query("update " . TABLE_THEME_CONFIGURATION . " set configuration_value = '" . $HTTP_GET_VARS['flag'] . "' where configuration_id = '" . $HTTP_GET_VARS['cID'] . "'");
  22            }
  23          }
  24  
  25  tep_redirect(tep_href_link(FILENAME_INFOBOX_CONFIGURATION, 'gID=1&cID=' . $cID));
  26          break;
  27        case 'setflagcolumn': //set the status of a box left or right.
  28          if ( ($HTTP_GET_VARS['flag'] == 'left') || ($HTTP_GET_VARS['flag'] == 'right') ) {
  29            if ($HTTP_GET_VARS['cID']) {
  30              tep_db_query("update " . TABLE_THEME_CONFIGURATION . " set configuration_column = '" . $HTTP_GET_VARS['flag'] . "' where configuration_id = '" . (int)$cID . "'");
  31            }
  32          }
  33  
  34  tep_redirect(tep_href_link(FILENAME_INFOBOX_CONFIGURATION, 'gID=1&cID=' . $cID));
  35          break;
  36        case 'save':
  37          $configuration_value = tep_db_prepare_input($HTTP_POST_VARS['configuration_value']);
  38          $configuration_column = tep_db_prepare_input($HTTP_POST_VARS['configuration_column']);
  39          $location = tep_db_prepare_input($HTTP_POST_VARS['location']);
  40          $cID = tep_db_prepare_input($HTTP_GET_VARS['cID']);
  41  
  42          tep_db_query("update " . TABLE_THEME_CONFIGURATION . " set location = '" . tep_db_input($location) . "',configuration_column = '" . tep_db_input($configuration_column) . "', configuration_value = '" . tep_db_input($configuration_value) . "', last_modified = now() where configuration_id = '" . tep_db_input($cID) . "'");
  43          tep_redirect(tep_href_link(FILENAME_INFOBOX_CONFIGURATION, 'gID=' . $HTTP_GET_VARS['gID'] . '&cID=' . $cID));
  44          break;
  45  
  46   case 'insert':
  47        $configuration_title = tep_db_prepare_input($HTTP_POST_VARS['configuration_title']);
  48        $configuration_key = tep_db_prepare_input($HTTP_POST_VARS['configuration_key']);
  49        $configuration_value = tep_db_prepare_input($HTTP_POST_VARS['configuration_value']);
  50        $configuration_column = tep_db_prepare_input($HTTP_POST_VARS['configuration_column']);
  51        $location = tep_db_prepare_input($HTTP_POST_VARS['location']);
  52        $box_heading = tep_db_prepare_input($HTTP_POST_VARS['box_heading']);
  53  
  54        tep_db_query("insert into " . TABLE_THEME_CONFIGURATION . " (configuration_title, configuration_value, configuration_key, configuration_column, location, box_heading) values ('" . tep_db_input($configuration_title) . "', '" . tep_db_input($configuration_value) . "', '" . tep_db_input($configuration_key) . "', '" . tep_db_input($configuration_column) . "', '" . tep_db_input($location) . "', '" . tep_db_input($box_heading) . "')");
  55          tep_redirect(tep_href_link(FILENAME_INFOBOX_CONFIGURATION, 'gID=1&cID=' . $cID));
  56  
  57          break;
  58      case 'deleteconfirm':
  59        $cID = tep_db_prepare_input($HTTP_GET_VARS['cID']);;
  60  
  61        tep_db_query("delete from " . TABLE_THEME_CONFIGURATION . " where configuration_id = '" . tep_db_input($cID) . "'");
  62  
  63          tep_redirect(tep_href_link(FILENAME_INFOBOX_CONFIGURATION, 'gID=1'));
  64        break;
  65  
  66  
  67        }
  68    }
  69  
  70  
  71  ?>
  72  <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  73  <html <?php echo HTML_PARAMS; ?>>
  74  <head>
  75  <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
  76  <title><?php echo TITLE; ?></title>
  77  <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
  78  <script language="javascript" src="includes/general.js"></script>
  79  </head>
  80  <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
  81  <!-- header //-->
  82  <?php require (DIR_WS_INCLUDES . 'header.php'); ?>
  83  <!-- header_eof //-->
  84  
  85  <!-- body //-->
  86  <table border="0" width="100%" cellspacing="2" cellpadding="2">
  87    <tr>
  88      <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
  89  <!-- left_navigation //-->
  90  <?php require (DIR_WS_INCLUDES . 'column_left.php'); ?>
  91  <!-- left_navigation_eof //-->
  92      </table></td>
  93  <!-- body_text //-->
  94      <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
  95        <tr>
  96          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
  97            <tr>
  98              <td class="pageHeading"><?php echo HEADER_TITLE;?></td>
  99              <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 100            </tr>
 101          </table></td>
 102        </tr>
 103        <tr>
 104          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 105            <tr>
 106              <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 107                <tr class="dataTableHeadingRow">
 108                  <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CONFIGURATION_TITLE; ?></td>
 109                  <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_CONFIGURATION_VALUE; ?></td>
 110                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_COLUMN; ?>&nbsp;</td>
 111                  <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_SORT_ORDER; ?>&nbsp;</td>
 112                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
 113                </tr>
 114  <?php
 115  $count_left=0;
 116  $count_right=0;
 117    $configuration_query = tep_db_query("select configuration_id, configuration_title, configuration_value, configuration_column, location from " . TABLE_THEME_CONFIGURATION . " where configuration_group_id = '" . $HTTP_GET_VARS['gID'] . "' order by configuration_column ");
 118    while ($configuration = tep_db_fetch_array($configuration_query)) {
 119  
 120        $cfgloc = $configuration['location'];
 121        $cfgValue = $configuration['configuration_value'];
 122        $cfgcol = $configuration['configuration_column'];
 123  if ($cfgcol != 'left') { $count_right++; } else { $count_left++; }
 124  
 125  
 126      if (((!$HTTP_GET_VARS['cID']) || (@$HTTP_GET_VARS['cID'] == $configuration['configuration_id'])) && (!$cInfo) && (substr($HTTP_GET_VARS['action'], 0, 3) != 'new')) {
 127        $cfg_extra_query = tep_db_query("select configuration_key, configuration_description, configuration_column,date_added, last_modified from " . TABLE_THEME_CONFIGURATION . " where configuration_id = '" . $configuration['configuration_id'] . "'");
 128        $cfg_extra = tep_db_fetch_array($cfg_extra_query);
 129  
 130        $cInfo_array = array_merge($configuration, $cfg_extra);
 131        $cInfo = new objectInfo($cInfo_array);
 132      }
 133  
 134      if ( (is_object($cInfo)) && ($configuration['configuration_id'] == $cInfo->configuration_id) ) {
 135        echo '                  <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . tep_href_link(FILENAME_INFOBOX_CONFIGURATION, 'gID=' . $HTTP_GET_VARS['gID'] . '&cID=' . $cInfo->configuration_id . '&action=edit') . '\'">' . "\n";
 136      } else {
 137        echo '                  <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . tep_href_link(FILENAME_INFOBOX_CONFIGURATION, 'gID=' . $HTTP_GET_VARS['gID'] . '&cID=' . $configuration['configuration_id']) . '\'">' . "\n";
 138      }
 139  ?>
 140                  <td class="dataTableContent"><?php echo $configuration['configuration_title']; ?></td>
 141                  <td class="dataTableContent">
 142  <?php
 143        if ($configuration['configuration_value'] == 'yes') {
 144          echo tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10) . '&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_INFOBOX_CONFIGURATION, 'action=setflag&flag=no&cID=' . $configuration['configuration_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 10, 10) . '</a>';
 145        } else {
 146          echo '<a href="' . tep_href_link(FILENAME_INFOBOX_CONFIGURATION, 'action=setflag&flag=yes&cID=' . $configuration['configuration_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 10, 10) . '</a>&nbsp;&nbsp;' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10);
 147        }
 148  ?></td>
 149                  <td class="dataTableContent" align="right"><?php
 150        if ($configuration['configuration_column'] == 'left') {
 151          echo tep_image(DIR_WS_IMAGES . 'icon_infobox_green.gif', IMAGE_INFOBOX_STATUS_GREEN, 14, 10) . '&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_INFOBOX_CONFIGURATION, 'action=setflagcolumn&flag=right&cID=' . $configuration['configuration_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_infobox_red_light.gif', IMAGE_INFOBOX_STATUS_RED_LIGHT, 14, 10) . '</a>';
 152        } else {
 153          echo '<a href="' . tep_href_link(FILENAME_INFOBOX_CONFIGURATION, 'action=setflagcolumn&flag=left&cID=' . $configuration['configuration_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_infobox_green_light.gif', IMAGE_INFOBOX_STATUS_GREEN_LIGHT, 14, 10) . '</a>&nbsp;&nbsp;' . tep_image(DIR_WS_IMAGES . 'icon_infobox_red.gif', IMAGE_INFOBOX_STATUS_RED, 14, 10);
 154        }
 155  ?></td>
 156                <!--  <td class="dataTableContent" align="right"><?php echo htmlspecialchars($cfgcol); ?></td> -->
 157                  <td class="dataTableContent" align="center"><?php echo htmlspecialchars($cfgloc); ?></td>
 158                  <td class="dataTableContent" align="right"><?php if ( (is_object($cInfo)) && ($configuration['configuration_id'] == $cInfo->configuration_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_INFOBOX_CONFIGURATION, 'gID=' . $HTTP_GET_VARS['gID'] . '&cID=' . $configuration['configuration_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
 159                </tr>
 160  <?php
 161    }
 162  ?>
 163  
 164              </table></td>
 165  <?php
 166    $heading = array();
 167    $contents = array();
 168    switch ($HTTP_GET_VARS['action']) {
 169      case 'edit':
 170        $heading[] = array('text' => '<b>' . $cInfo->configuration_title . '</b>');
 171  
 172        $value_field_value =  (tep_cfg_select_option(array('yes', 'no'),$cInfo->configuration_value));
 173  
 174        $value_field_column =  tep_draw_input_field('configuration_column', $cInfo->configuration_column);
 175  
 176  
 177        $value_field_location =  tep_draw_input_field('location', $cInfo->location);
 178  
 179        $contents = array('form' => tep_draw_form('configuration', FILENAME_INFOBOX_CONFIGURATION, 'gID=' . $HTTP_GET_VARS['gID'] . '&cID=' . $cInfo->configuration_id . '&action=save'));
 180        $contents[] = array('text' => TEXT_INFO_EDIT_INTRO);
 181        $contents[] = array('text' => '<br><b> Activate this box? </b><br>' . $value_field_value . '</b><br><br><b> Which column? </b><br>' . $value_field_column . '<br><br><b> What order? </b><br>' . $value_field_location);
 182        $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_update.gif', IMAGE_UPDATE) . '&nbsp;<a href="' . tep_href_link(FILENAME_INFOBOX_CONFIGURATION, 'gID=' . $HTTP_GET_VARS['gID'] . '&cID=' . $cInfo->configuration_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
 183        break;
 184  
 185  case 'new':
 186        $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_INFOBOX . '</b>');
 187  
 188        $value_field_value =  (tep_cfg_select_option(array('yes', 'no'),$cInfo->configuration_value));
 189  
 190  
 191        $contents = array('form' => tep_draw_form('TABLE_THEME_CONFIGURATION', FILENAME_INFOBOX_CONFIGURATION, tep_get_all_get_params(array('action')) . 'action=insert', 'post', 'onSubmit="return check_form();"') . tep_draw_hidden_field('cID', $cInfo->configuration_id));
 192  
 193        $contents[] = array('text' => TEXT_INFO_INSERT_INTRO);
 194        $contents[] = array('text' => '<br><a href="javascript:popupWindow(\'' . tep_href_link(FILENAME_POPUP_INFOBOX_HELP,'action=filename') . '\')">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a><b>   Filename</b><br> ' . tep_draw_input_field('configuration_title','what\'s new','','true'));
 195        $contents[] = array('text' => '<br><a href="javascript:popupWindow(\'' . tep_href_link(FILENAME_POPUP_INFOBOX_HELP,'action=heading') . '\')">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a><b>  The infoBox heading? </b>' . tep_draw_input_field('box_heading','What\'s New','','true'));
 196        $contents[] = array('text' => '<br><a href="javascript:popupWindow(\'' . tep_href_link(FILENAME_POPUP_INFOBOX_HELP,'action=define') . '\')">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a><b>  Define key </b><br>' . tep_draw_input_field('configuration_key','BOX_HEADING_????','','true'));
 197  
 198        $contents[] = array('text' => '<br><a href="javascript:popupWindow(\'' . tep_href_link(FILENAME_POPUP_INFOBOX_HELP,'action=column') . '\')">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a><b>  Which column? </b><br>' . tep_draw_input_field('configuration_column','','maxlength="5"','true'));
 199        $contents[] = array('text' => '<br><a href="javascript:popupWindow(\'' . tep_href_link(FILENAME_POPUP_INFOBOX_HELP,'action=position') . '\')">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a><b>  what Position? </b><br>' . tep_draw_input_field('location'));
 200  
 201        $contents[] = array('text' => '<br><a href="javascript:popupWindow(\'' . tep_href_link(FILENAME_POPUP_INFOBOX_HELP,'action=active') . '\')">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a><b>  Set this box Active? </b><br>' . $value_field_value . '</b><br>');
 202  
 203        $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_insert.gif', IMAGE_INSERT) . '&nbsp;<a href="' . tep_href_link(FILENAME_INFOBOX_CONFIGURATION, 'gID=' . $HTTP_GET_VARS['gID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
 204        break;
 205      case 'delete':
 206        $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_INFOBOX . '</b>');
 207  
 208        $contents = array('form' => tep_draw_form('configuration', FILENAME_INFOBOX_CONFIGURATION, 'gID=' . $HTTP_GET_VARS['gID'] . '&cID=' . $cInfo->configuration_id . '&action=deleteconfirm'));
 209        $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
 210        $contents[] = array('align' => 'center','text' => '<br><b>' . $cInfo->configuration_title . '</b>');
 211        $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . '&nbsp;<a href="' . tep_href_link(FILENAME_INFOBOX_CONFIGURATION, 'gID=' . $HTTP_GET_VARS['gID'] . '&cID=' . $cInfo->configuration_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
 212        break;
 213  
 214      default:
 215        if (is_object($cInfo)) {
 216          $heading[] = array('text' => '<b>' . $cInfo->configuration_title . '</b>');
 217  
 218          $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_INFOBOX_CONFIGURATION, 'gID=' . $HTTP_GET_VARS['gID'] . '&cID=' . $cInfo->configuration_id . '&action=edit') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_INFOBOX_CONFIGURATION, 'gID=' . $HTTP_GET_VARS['gID'] . '&cID=' . $cInfo->configuration_id . '&action=delete') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a><br><br><a href="' . tep_href_link(FILENAME_INFOBOX_CONFIGURATION, 'gID=' . $HTTP_GET_VARS['gID'] . '&action=new') . '">' . tep_image_button('button_new_infobox.gif', IMAGE_NEW_INFOBOX) . '</a> ');
 219          $contents[] = array('text' => '<br>' . $cInfo->configuration_description);
 220  
 221          $contents[] = array('text' => '<br>' . TEXT_INFO_DATE_ADDED . ' ' . tep_date_short($cInfo->date_added));
 222          if (tep_not_null($cInfo->last_modified)) $contents[] = array('text' => TEXT_INFO_LAST_MODIFIED . ' ' . tep_date_short($cInfo->last_modified));
 223          $contents[] = array('text' => '<br>There are currently <br>'. $count_left . ' boxes in the left column and <br>'. $count_right . ' boxes in the right column');
 224        }
 225        break;
 226    }
 227  
 228    if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
 229      echo '            <td width="25%" valign="top" align="center">' . "\n";
 230  
 231      $box = new box;
 232      echo $box->infoBox($heading, $contents);
 233  
 234      echo '            </td>' . "\n";
 235  
 236    }
 237  
 238  ?>
 239            </tr>
 240  
 241          </table></td>
 242        </tr>
 243      </table></td>
 244  <!-- body_text_eof //-->
 245    </tr>
 246  </table>
 247  <!-- body_eof //-->
 248  
 249  <!-- footer //-->
 250  <?php require (DIR_WS_INCLUDES . 'footer.php'); ?>
 251  <!-- footer_eof //-->
 252  <br>
 253  </body>
 254  </html>
 255  <?php require (DIR_WS_INCLUDES . 'application_bottom.php'); ?>
 256  <SCRIPT language=JavaScript>
 257  
 258  function check_form() {
 259    var error = 0;
 260    var error_message = "<?php echo JS_ERROR; ?>";
 261  
 262    var configuration_title = document.theme_configuration.configuration_title.value;
 263    var box_heading = document.theme_configuration.box_heading.value;
 264    var configuration_key = document.theme_configuration.configuration_key.value;
 265    var configuration_column = document.theme_configuration.configuration_column.value;
 266  
 267    if (configuration_title == "") {
 268      error_message = error_message + "<?php echo JS_INFO_BOX_FILENAME; ?>";
 269      error = 1;
 270    }
 271  
 272    if (box_heading == "") {
 273      error_message = error_message + "<?php echo JS_INFO_BOX_HEADING; ?>";
 274      error = 1;
 275    }
 276  
 277  
 278    if (configuration_key == "" || configuration_key == "BOX_HEADING_????") {
 279      error_message = error_message + "<?php echo JS_BOX_HEADING; ?>";
 280      error = 1;
 281    }
 282  
 283    if (configuration_column != "left" && configuration_column != "right") {
 284      error_message = error_message + "<?php echo JS_BOX_LOCATION; ?>";
 285      error = 1;
 286    }
 287  
 288    if (error == 1) {
 289      alert(error_message);
 290      return false;
 291    } else {
 292      return true;
 293    }
 294  }
 295  
 296  function popupWindow(url) {
 297    window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=500,height=280,screenX=150,screenY=150,top=150,left=150')
 298  }
 299  
 300  //--></script>


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