PageRenderTime 61ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/includes/modules/product/collect_info_metatags.php

https://github.com/bitweaver/commerce
PHP | 169 lines | 136 code | 6 blank | 27 comment | 15 complexity | e67d44a5c27c8919915f332da4c55592 MD5 | raw file
  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // |zen-cart Open Source E-commerce |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 2004 The zen-cart developers |
  7. // | |
  8. // | http://www.zen-cart.com/index.php |
  9. // | |
  10. // | Portions Copyright (c) 2003 osCommerce |
  11. // +----------------------------------------------------------------------+
  12. // | This source file is subject to version 2.0 of the GPL license, |
  13. // | that is bundled with this package in the file LICENSE, and is |
  14. // | available through the world-wide-web at the following url: |
  15. // | http://www.zen-cart.com/license/2_0.txt. |
  16. // | If you did not receive a copy of the zen-cart license and are unable |
  17. // | to obtain it through the world-wide-web, please send a note to |
  18. // | license@zen-cart.com so we can mail you a copy immediately. |
  19. // +----------------------------------------------------------------------+
  20. // $Id$
  21. //
  22. $parameters = array(
  23. 'products_name' => '',
  24. 'products_model' => '',
  25. 'metatags_title_status' => '',
  26. 'metatags_products_name_status' => '',
  27. 'metatags_model_status' => '',
  28. 'products_id' => '',
  29. 'metatags_price_status' => '',
  30. 'metatags_title_tagline_status' => '',
  31. 'metatags_title' => '',
  32. 'metatags_keywords' => '',
  33. 'metatags_description' => ''
  34. );
  35. $pInfo = new objectInfo($parameters);
  36. if (isset($_GET['products_id']) && empty($_POST)) {
  37. // check if new meta tags or existing
  38. $check_meta_tags_description = $gBitDb->Execute("select `products_id` from " . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . " where `products_id` ='" . (int)$_GET['products_id'] . "'");
  39. if ($check_meta_tags_description->RecordCount() <= 0) {
  40. $product = $gBitDb->Execute("select pd.`products_name`, p.`products_model`, p.`lowest_purchase_price`,
  41. p.`metatags_title_status`, p.`metatags_products_name_status`, p.`metatags_model_status`,
  42. p.`products_id`, p.`metatags_price_status`, p.`metatags_title_tagline_status`
  43. from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
  44. where p.`products_id` = '" . (int)$_GET['products_id'] . "'
  45. and p.`products_id` = pd.`products_id`
  46. and pd.`language_id` = '" . (int)$_SESSION['languages_id'] . "'");
  47. } else {
  48. $product = $gBitDb->Execute("select pd.`products_name`, p.`products_model`, p.`lowest_purchase_price`,
  49. p.`metatags_title_status`, p.`metatags_products_name_status`, p.`metatags_model_status`,
  50. p.`products_id`, p.`metatags_price_status`, p.`metatags_title_tagline_status`,
  51. mtpd.`metatags_title`, mtpd.`metatags_keywords`, mtpd.`metatags_description`
  52. from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . " mtpd
  53. where p.`products_id` = '" . (int)$_GET['products_id'] . "'
  54. and p.`products_id` = pd.`products_id`
  55. and pd.`language_id` = '" . (int)$_SESSION['languages_id'] . "'
  56. and p.`products_id` = mtpd.`products_id`
  57. and mtpd.`language_id` = '" . (int)$_SESSION['languages_id'] . "'");
  58. }
  59. $pInfo->objectInfo($product->fields);
  60. } elseif (zen_not_null($_POST)) {
  61. $pInfo->objectInfo($_POST);
  62. $metatags_title = $_POST['metatags_title'];
  63. $metatags_keywords = $_POST['metatags_keywords'];
  64. $metatags_description = $_POST['metatags_description'];
  65. }
  66. $languages = zen_get_languages();
  67. // metatags_products_name_status shows
  68. if (empty($pInfo->metatags_keywords) and empty($pInfo->metatags_description)) $pInfo->metatags_products_name_status = zen_get_show_product_switch($_GET['products_id'], 'metatags_products_name_status');
  69. switch ($pInfo->metatags_products_name_status) {
  70. case '0': $is_metatags_products_name_status = false; $not_metatags_products_name_status = true; break;
  71. case '1': $is_metatags_products_name_status = true; $not_metatags_products_name_status = false; break;
  72. default: $is_metatags_products_name_status = true; $not_metatags_products_name_status = false;
  73. }
  74. // metatags_title_status shows
  75. if (empty($pInfo->metatags_keywords) and empty($pInfo->metatags_description)) $pInfo->metatags_title_status = zen_get_show_product_switch($_GET['products_id'], 'metatags_title_status');
  76. switch ($pInfo->metatags_title_status) {
  77. case '0': $is_metatags_title_status = false; $not_metatags_title_status = true; break;
  78. case '1': $is_metatags_title_status = true; $not_metatags_title_status = false; break;
  79. default: $is_metatags_title_status = true; $not_metatags_title_status = false;
  80. }
  81. // metatags_model_status shows
  82. if (empty($pInfo->metatags_keywords) and empty($pInfo->metatags_description)) $pInfo->metatags_model_status = zen_get_show_product_switch($_GET['products_id'], 'metatags_model_status');
  83. switch ($pInfo->metatags_model_status) {
  84. case '0': $is_metatags_model_status = false; $not_metatags_model_status = true; break;
  85. case '1': $is_metatags_model_status = true; $not_metatags_model_status = false; break;
  86. default: $is_metatags_model_status = true; $not_metatags_model_status = false;
  87. }
  88. // metatags_price_status shows
  89. if (empty($pInfo->metatags_keywords) and empty($pInfo->metatags_description)) $pInfo->metatags_price_status = zen_get_show_product_switch($_GET['products_id'], 'metatags_price_status');
  90. switch ($pInfo->metatags_price_status) {
  91. case '0': $is_metatags_price_status = false; $not_metatags_price_status = true; break;
  92. case '1': $is_metatags_price_status = true; $not_metatags_price_status = false; break;
  93. default: $is_metatags_price_status = true; $not_metatags_price_status = false;
  94. }
  95. // metatags_title_tagline_status shows TITLE and TAGLINE in metatags_header.php
  96. if (empty($pInfo->metatags_keywords) and empty($pInfo->metatags_description)) $pInfo->metatags_title_tagline_status = zen_get_show_product_switch($_GET['products_id'], 'metatags_title_tagline_status');
  97. switch ($pInfo->metatags_title_tagline_status) {
  98. case '0': $is_metatags_title_tagline_status = false; $not_metatags_title_tagline_status = true; break;
  99. case '1': $is_metatags_title_tagline_status = true; $not_metatags_title_tagline_status = false; break;
  100. default: $is_metatags_title_tagline_status = true; $not_metatags_title_tagline_status = false;
  101. }
  102. ?>
  103. <?php
  104. // echo $type_admin_handler;
  105. echo zen_draw_form_admin('new_product_meta_tags', $type_admin_handler , 'cPath=' . $cPath . (isset($_GET['product_type']) ? '&product_type=' . $_GET['product_type'] : '') . (isset($_GET['products_id']) ? '&products_id=' . $_GET['products_id'] : '') . '&action=new_product_preview_meta_tags' . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''), 'post', 'enctype="multipart/form-data"'); ?>
  106. <h2><?php echo TEXT_META_TAG_TITLE_INCLUDES; ?></h2>
  107. <table border="1" cellspacing="0" cellpadding="2">
  108. <tr>
  109. <td class="main" align="center">
  110. <?php echo TEXT_PRODUCTS_METATAGS_PRODUCTS_NAME_STATUS . '<br />' . zen_draw_radio_field('metatags_products_name_status', '1', $is_metatags_products_name_status) . '&nbsp;' . TEXT_YES . '&nbsp;' . zen_draw_radio_field('metatags_products_name_status', '0', $not_metatags_products_name_status) . '&nbsp;' . TEXT_NO; ?>
  111. </td>
  112. <td class="main" align="center">
  113. <?php echo TEXT_PRODUCTS_METATAGS_TITLE_STATUS . '<br />' . zen_draw_radio_field('metatags_title_status', '1', $is_metatags_title_status) . '&nbsp;' . TEXT_YES . '&nbsp;' . zen_draw_radio_field('metatags_title_status', '0', $not_metatags_title_status) . '&nbsp;' . TEXT_NO; ?>
  114. </td>
  115. <td class="main" align="center">
  116. <?php echo TEXT_PRODUCTS_METATAGS_MODEL_STATUS . '<br />' . zen_draw_radio_field('metatags_model_status', '1', $is_metatags_model_status) . '&nbsp;' . TEXT_YES . '&nbsp;' . zen_draw_radio_field('metatags_model_status', '0', $not_metatags_model_status) . '&nbsp;' . TEXT_NO; ?>
  117. </td>
  118. <td class="main" align="center">
  119. <?php echo TEXT_PRODUCTS_METATAGS_PRICE_STATUS . '<br />' . zen_draw_radio_field('metatags_price_status', '1', $is_metatags_price_status) . '&nbsp;' . TEXT_YES . '&nbsp;' . zen_draw_radio_field('metatags_price_status', '0', $not_metatags_price_status) . '&nbsp;' . TEXT_NO; ?>
  120. </td>
  121. <td class="main" align="center">
  122. <?php echo TEXT_PRODUCTS_METATAGS_TITLE_TAGLINE_STATUS . '<br />' . zen_draw_radio_field('metatags_title_tagline_status', '1', $is_metatags_title_tagline_status) . '&nbsp;' . TEXT_YES . '&nbsp;' . zen_draw_radio_field('metatags_title_tagline_status', '0', $not_metatags_title_tagline_status) . '&nbsp;' . TEXT_NO; ?>
  123. </td>
  124. </tr>
  125. </table>
  126. <?php
  127. for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
  128. ?>
  129. <table >
  130. <tr>
  131. <td class="main" colspan="2">
  132. <?php echo zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . '<strong>' . TEXT_PRODUCTS_NAME . '</strong>' . '&nbsp;' . zen_get_products_name($_GET['products_id'], $languages[$i]['id']) . '&nbsp;&nbsp;&nbsp;<strong>' . TEXT_PRODUCTS_MODEL . '</strong>&nbsp;' . $pInfo->products_model . '&nbsp;&nbsp;&nbsp;<strong>' . TEXT_PRODUCTS_PRICE_INFO . '</strong>&nbsp;' . $currencies->format($pInfo->lowest_purchase_price); ?>
  133. </td>
  134. </tr>
  135. <tr>
  136. <td class="main"valign="top"><?php echo TEXT_META_TAGS_TITLE; ?>&nbsp;</td>
  137. <td class="main">
  138. <?php echo zen_draw_input_field('metatags_title[' . $languages[$i]['id'] . ']', (isset($metatags_title[$languages[$i]['id']]) ? stripslashes($metatags_title[$languages[$i]['id']]) : zen_get_metatags_title($pInfo->products_id, $languages[$i]['id'])), zen_set_field_length(TABLE_META_TAGS_PRODUCTS_DESCRIPTION, 'metatags_title', '', true)); //,'id="'.'metatags_title' . $languages[$i]['id'] . '"');?>
  139. </td>
  140. </tr>
  141. <tr>
  142. <td class="main"valign="top"><?php echo TEXT_META_TAGS_KEYWORDS; ?>&nbsp;</td>
  143. <td class="main">
  144. <?php echo zen_draw_textarea_field('metatags_keywords[' . $languages[$i]['id'] . ']', 'soft', '100%', '10', (isset($metatags_keywords[$languages[$i]['id']])) ? stripslashes($metatags_keywords[$languages[$i]['id']]) : zen_get_metatags_keywords($pInfo->products_id, $languages[$i]['id'])); //,'id="'.'metatags_keywords' . $languages[$i]['id'] . '"'); ?>
  145. </td>
  146. </tr>
  147. <tr>
  148. <td class="main"valign="top"><?php echo TEXT_META_TAGS_DESCRIPTION; ?>&nbsp;</td>
  149. <td class="main">
  150. <?php echo zen_draw_textarea_field('metatags_description[' . $languages[$i]['id'] . ']', 'soft', '100%', '10', (isset($metatags_description[$languages[$i]['id']])) ? stripslashes($metatags_description[$languages[$i]['id']]) : zen_get_metatags_description($pInfo->products_id, $languages[$i]['id'])); //,'id="'.'metatags_description' . $languages[$i]['id'] . '"'); ?>
  151. </td>
  152. </tr>
  153. </table>
  154. <?php
  155. }
  156. ?>
  157. <tr>
  158. <td class="main" align="left"><?php echo TEXT_INFO_META_TAGS_USAGE; ?></td>
  159. </tr>
  160. <tr>
  161. <td class="main" align="right"><?php echo zen_draw_hidden_field('products_model', $pInfo->products_model) . zen_draw_hidden_field('lowest_purchase_price', $pInfo->lowest_purchase_price) . zen_image_submit('button_preview.gif', IMAGE_PREVIEW) . '&nbsp;&nbsp;<a href="' . zen_href_link_admin(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($_GET['products_id']) ? '&products_id=' . $_GET['products_id'] : '') . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
  162. </tr>
  163. </table></form>