categories.php
来自「全新且完善的强大网上商店系统」· PHP 代码 · 共 385 行 · 第 1/2 页
PHP
385 行
$query = $db->query("SELECT categories_id, categories_image,parent_id,sort_order FROM $table_categories WHERE categories_id ='" . (int)$cID . "'");
$category_details = $db->fetch_array($query);
$category_inputs_string = '';
$languages = tep_get_languages();
for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
$category_query = $db->query("select categories_name from $table_categories_description where categories_id = '" . (int)$cID . "' and language_id = '" . (int)$languages[$i]['id']. "'");
$category = $db->fetch_array($category_query);
$category_inputs_string .= '<br><img src="'.$soobic.'./'.IMGDIR.'/'.$languages[$i]['directory'] . '/' . $languages[$i]['image'].'" border="0" alt="'.$languages[$i]['name'].'"> <input type="text" size="30" name="categories_name[' . $languages[$i]['id'] . ']" value="'.$category['categories_name'].'">';
}
?>
<form method="post" action="<?=tep_href_link('admincp.php','act=catalog&cPath='.$cPath)?>" enctype="multipart/form-data">
<input type="hidden" name="categories_id" value="<?=$cID?>">
<input type="hidden" name="action" value="change_category">
<table border="0" cellspacing="1" cellpadding="6" width="95%" class="tableout" align="center">
<tr class="header"><td colspan="7"><?=TEXT_INFO_HEADING_EDIT_CATEGORY;?></td></tr>
<tr align="center" bgcolor="<?=ALTBG1?>"><td width="40%" align="right"><?=TEXT_CATEGORIES_NAME;?></td>
<td align="left"><?=$category_inputs_string;?></td>
</tr>
<tr align="center" bgcolor="<?=ALTBG2?>"><td align="right"><?=TEXT_CATEGORIES_IMAGE;?></td>
<td align="left"><? if($category_details['categories_image']){?><img src="upload/images/category/<?=$category_details['categories_image'];?>"><br><input type="checkbox" name="delete" value="1">删除<?}else{ echo TEXT_CATEGORIES_IMAGE_NO;}?></td>
</tr>
<tr align="center" bgcolor="<?=ALTBG2?>"><td align="right"><?=TEXT_CATEGORIES_IMAGE_NEW;?></td>
<td align="left"><input type="file" name="categories_image"></td>
</tr>
<tr align="center" bgcolor="<?=ALTBG2?>"><td align="right"><?=TEXT_SORT_ORDER;?></td>
<td align="left"><input type="text" size="2" name="sort_order" value="<?=$category_details['sort_order'];?>"></td>
</tr>
</table>
<br><center><?=$warning?>
<input type="submit" name="submit" value="<?=SUBMIT?>"> <input type="button" value="<?=BACK?>" onClick="history.go(-1);">
</center></form><br><br>
<?
break;
case 'move_category':
$categories_query = $db->query("select c.categories_id, cd.categories_name from $table_categories c, $table_categories_description cd where c.categories_id = '" . (int)$cID. "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by c.sort_order, cd.categories_name");
$categories = $db->fetch_array($categories_query);
@extract($categories);
?>
<br>
<form method="post" name="categories" action="<?=tep_href_link('admincp.php', 'act=catalog&action=move_category_confirm&cPath='.$cPath)?>">
<table border="0" cellspacing="1" cellpadding="6" width="95%" class="tableout" align="center">
<tr class="header" ><td colspan="2"><?=SPECIALS_NOTICE?></td></tr>
<tr bgcolor="<?=ALTBG1?>"><td colspan="2" width="60%"><li><?=sprintf(TEXT_MOVE_CATEGORIES_INTRO, $categories_name)?></td></tr>
<tr bgcolor="<?=ALTBG1?>"><td ><li><?=sprintf(TEXT_INFO_HEADING_NEW_CATEGORY, $categories_name)?></td>
<td><li><?=tep_draw_pull_down_menu('move_to_category_id', tep_get_category_tree(), $categories_id)?></td></tr>
</table>
<br>
<input type="hidden" name="categories_id" value="<?=$categories_id;?>">
<br><center>
<?=tep_image_submit('button_move.gif', IMAGE_MOVE)?> <a href="<?=tep_href_link('admincp.php', 'act=catalog&cPath=' . $cPath . '&cID=' . $categories_id)?>"><?=tep_image_button('button_cancel.gif', IMAGE_CANCEL)?></a>
</center></form><br><br>
<?
break;
default:
}
}else{
$cPath_back = '';
if (sizeof($cPath_array) > 0) {
for ($i=0, $n=sizeof($cPath_array)-1; $i<$n; $i++) {
if (empty($cPath_back)) {
$cPath_back .= $cPath_array[$i];
} else {
$cPath_back .= '_' . $cPath_array[$i];
}
}
}
$cPath_back = (tep_not_null($cPath_back)) ? 'cPath=' . $cPath_back . '&' : '';
if ($messageStack->size('category') > 0) {
$message_all=$messageStack->output('category');
}
?>
<br>
<?php
if (is_array($message_all)) {
?>
<br>
<table border="0" cellspacing="<?=BORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="<?=TABLEWIDTH?>" class="tableout" align="center">
<?
foreach($message_all as $key=>$value){
?>
<tr bgcolor="<?=ALTBG1?>" style="color:red"><td><?=$value['text']?></td></tr>
<?php
}
?>
</table>
<?
}
?>
<br>
<table border="0" cellspacing="1" cellpadding="6" width="95%" class="tableout" align="center">
<tr class="header"><td><?=SPECIALS_NOTICE?></td></tr>
<tr bgcolor="<?=ALTBG1?>"><td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr><td><?=TEXT_SPECIALS_NOTICE_1?></td>
<td align="right" class="bold"><?php if (sizeof($cPath_array) > 0) echo '<a href="'.tep_href_link('admincp.php','act=catalog&'.$cPath_back.'&cID=' . $current_category_id).'">'.IMAGE_BACK.'</a> '; if (!isset($HTTP_GET_VARS['search'])) echo '<a href="'.tep_href_link('admincp.php','act=catalog&cPath=' . $cPath . '&type=new_category').'">'.IMAGE_NEW_CATEGORY.'</a> <a href="'.tep_href_link('admincp.php','act=products&cPath=' . $cPath . '&type=new_product').'">'.IMAGE_NEW_PRODUCT.'</a>'; ?> </td>
</tr></table></td></tr></table>
<br>
<table border="0" cellspacing="1" cellpadding="6" width="95%" class="tableout" align="center">
<tr class="header" align="center">
<td ><?php echo TABLE_HEADING_CATEGORIES_PRODUCTS; ?></td><td ><?php echo TABLE_HEADING_STATUS; ?></td><td ><?php echo TABLE_HEADING_ACTION; ?></td></tr>
<?php
$categories_count = 0;
$rows = 0;
if (isset($HTTP_GET_VARS['search'])) {
$search = trim(stripslashes($HTTP_GET_VARS['search']));
$categories_query = $db->query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified from $table_categories c, $table_categories_description cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and cd.categories_name like '%" . addslashes($search) . "%' order by c.sort_order, cd.categories_name");
} else {
$categories_query = $db->query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified from $table_categories c, $table_categories_description cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by c.sort_order, cd.categories_name");
}
while ($categories = $db->fetch_array($categories_query)) {
$categories_count++;
$rows++;
if (isset($HTTP_GET_VARS['search'])) $cPath= $categories['parent_id'];
if ((!isset($HTTP_GET_VARS['cID']) && !isset($HTTP_GET_VARS['pID']) || (isset($HTTP_GET_VARS['cID']) && ($HTTP_GET_VARS['cID'] == $categories['categories_id']))) && !isset($cInfo) && (substr($action, 0, 3) != 'new')) {
$cInfo_array = array_merge($categories, $category_childs, $category_products);
}
?>
<tr>
<td bgcolor="<?=ALTBG2?>"><?php echo '<a href="admincp.php?act=catalog&'.tep_get_path($categories['categories_id']) .'&'. SID.'"><img src="images/icons/folder.gif" border="0" alt="进入下级分类"> <b>' . $categories['categories_name'] . '</b></a>'; ?></td>
<td bgcolor="<?=ALTBG1?>" align="center"> </td>
<td bgcolor="<?=ALTBG2?>" align="center" width="20%">
<a href="<?=tep_href_link('admincp.php','act=catalog&type=change_category&cPath=' . $cPath . '&cID=' . $categories['categories_id'])?>">修改</a>
<a href="<?=tep_href_link('admincp.php','act=catalog&type=delete_category&cPath=' . $cPath . '&cID=' . $categories['categories_id'])?>">删除</a>
<a href="<?=tep_href_link('admincp.php','act=catalog&type=move_category&cPath=' . $cPath . '&cID=' . $categories['categories_id'])?>"><?=IMAGE_MOVE?></a>
</tr>
<?php
}
?>
</table>
<br><br>
<table border="0" cellspacing="1" cellpadding="6" width="95%" class="tableout" align="center">
<tr class="header" align="center">
<td ><?php echo TABLE_HEADING_CATEGORIES_PRODUCTS; ?></td><td ><?php echo TABLE_HEADING_STATUS; ?></td><td ><?php echo TABLE_HEADING_ACTION; ?></td></tr>
<?php
$products_count = 0;
if (isset($HTTP_GET_VARS['search'])) {
$products_query = $db->query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_id from $table_products p, $table_products_description pd, $table_products_to_categories p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . ($search) . "%' order by pd.products_name");
} else {
$products_query = $db->query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status from $table_products p, $table_products_description pd, $table_products_to_categories p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by pd.products_name");
}
while ($products = $db->fetch_array($products_query)) {
$products_count++;
$rows++;
if (isset($HTTP_GET_VARS['search'])) $cPath = $products['categories_id'];
if ( (!isset($HTTP_GET_VARS['pID']) && !isset($HTTP_GET_VARS['cID']) || (isset($HTTP_GET_VARS['pID']) && ($HTTP_GET_VARS['pID'] == $products['products_id']))) && !isset($pInfo) && !isset($cInfo) && (substr($action, 0, 3) != 'new')) {
$reviews_query = $db->query("select (avg(reviews_rating) / 5 * 100) as average_rating from $table_reviews where products_id = '" . (int)$products['products_id'] . "'");
$reviews = $db->fetch_array($reviews_query);
$pInfo_array = array_merge($products, $reviews);
@extract($pInfo_array);
}
?>
<tr>
<td bgcolor="<?=ALTBG2?>"><?php echo '<img src="images/icons/preview.gif" alt="'.ICON_PREVIEW.'" border="0"> ' . $products['products_name']; ?></td>
<td bgcolor="<?=ALTBG2?>" align="center">
<?php
if ($products['products_status'] == '1') {
echo '<img src="images/icons/icon_status_green.gif" alt="'.IMAGE_ICON_STATUS_GREEN.'" border="0"> <a href="' . tep_href_link('admincp.php', 'act=products&action=setflag&flag=0&pID=' . $products['products_id'] . '&cPath=' . $cPath) . '"><img src="images/icons/icon_status_red_light.gif" alt="'.IMAGE_ICON_STATUS_RED_LIGHT.'" border="0"></a>';
} else {
echo '<a href="' . tep_href_link('admincp.php', 'act=products&action=setflag&flag=1&pID=' . $products['products_id'] . '&cPath=' . $cPath) . '"><img src="images/icons/icon_status_green_light.gif" alt="'.IMAGE_ICON_STATUS_GREEN_LIGHT.'" border="0"></a> <img src="images/icons/icon_status_red.gif" alt="'.IMAGE_ICON_STATUS_RED.'" border="0">';
}
?>
</td><td bgcolor="<?=ALTBG1?>" align="center" width="25%">
<a href="<?=tep_href_link('admincp.php', 'act=products&type=new_product&cPath=' . $cPath . '&cID=' .(int)$current_category_id.'&pID='.$products['products_id'])?>">修改</a>
<a href="<?=tep_href_link('admincp.php', 'act=products&type=delete_product&cPath=' . $cPath . '&cID=' .(int)$current_category_id.'&pID='.$products['products_id'])?>">删除</a>
<a href="<?=tep_href_link('admincp.php', 'act=products&type=move_product&cPath=' . $cPath . '&cID=' .(int)$current_category_id.'&pID='.$products['products_id'])?>">移动</a>
<a href="<?=tep_href_link('admincp.php', 'act=products&type=copy_product&cPath=' . $cPath . '&cID=' .(int)$current_category_id.'&pID='.$products['products_id'])?>"><?=IMAGE_COPY_TO?></a>
</td></tr>
<?php
}
?>
</table>
<?
}
?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?