コード例 #1
0
ファイル: product.php プロジェクト: rootcave/9livesprints-web
 public function category()
 {
     if (isset($_POST['title'])) {
         $title = $_POST['title'];
     }
     if (isset($_POST['cateid'])) {
         $parent_id = $_POST['cateid'];
     }
     if (isset($_POST['ids'])) {
         $ids = $_POST['ids'];
     } else {
         $ids = array();
     }
     $dgClass = new dg();
     if (!empty($title)) {
         $categories = $dgClass->getCategories();
         $cate_data = array();
         $cate_id = 0;
         if ($parent_id == '') {
             $parent_id = 0;
         }
         foreach ($categories as $cate) {
             $cate_data[] = array('id' => $cate->id, 'parent_id' => $cate->parent_id, 'title' => $cate->title);
             if ($cate->id > $cate_id) {
                 $cate_id = $cate->id;
             }
         }
         $cate_data[] = array('id' => $cate_id + 1, 'parent_id' => $parent_id, 'title' => $title);
         $path = dirname(ROOT) . DS . 'data' . DS . 'categories.json';
         $check = $dgClass->WriteFile($path, json_encode($cate_data));
     } elseif (count($ids)) {
         $categories = $dgClass->getCategories();
         $cate_data = array();
         foreach ($categories as $val) {
             if (!in_array($val->id, $ids)) {
                 $cate_data[] = $val;
             }
         }
         $path = dirname(ROOT) . DS . 'data' . DS . 'categories.json';
         $check = $dgClass->WriteFile($path, json_encode($cate_data));
     }
     $categories = $dgClass->getCategories();
     $categories = $dgClass->categoriesToTree($categories);
     $data['content'] = $dgClass->dispayTree($categories, 0, array('type' => 'checkbox', 'name' => 'category[]'));
     $data['list'] = '<option value="0">' . lang('product_parent_category', true) . '</option>' . $dgClass->dispayTree($categories, 0, array('type' => 'select', 'name' => ''));
     echo json_encode($data);
     return;
 }
コード例 #2
0
							</div>
							<div class="panel-body">
								<label id="product_categories-lable"><?php 
echo lang('product_add_categories');
?>
</label>
								<button type="button" autocomplete="off" onclick="dgUI.product.removeCate(this);" id="loading-example-btn" data-loading-text="Loading..." class="btn btn-sm pull-right btn-primary">
								  <?php 
echo lang('remove');
?>
								</button>								
								<div class="form-group" id="product_categories">
									<?php 
$dgClass = new dg();
$categories = $dgClass->getCategories();
$categories = $dgClass->categoriesToTree($categories);
echo $dgClass->dispayTree($categories, 0, array('type' => 'checkbox', 'name' => 'category[]'), $data['cate_checked']);
?>
								</div>
								<div class="form-group">
									<a href="javascript:void(0)" onclick="dgUI.product.addCategoryJs(this)"><?php 
echo lang('product_add_category');
?>
</a>
								</div>
								
								<div class="form-group">
									<div class="add-new-category" style="display:none;">
										
										<!-- category language -->
										<div class="form-group">