stanley-king před 9 roky
rodič
revize
5f6e1834ec

+ 27 - 0
data/sales/category.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<category>
+  <item title="护肤" id ="1" cids="50011977,50011978,50011979" img="">
+    <subitem title="洁面" id ="10" cids="50011977" img="" />
+    <subitem title="化妆水" id ="11" cids="50011978" img="" />
+    <subitem title="面部精华" id ="12" cids="50011979" img="" />
+    <subitem title="乳液/面霜" id ="13" cids="50011980" img="" />
+    <subitem title="眼霜" id ="14" cids="121484013" img="" />
+    <subitem title="面膜" id ="15" cids="121474010" img="" />
+    <subitem title="防晒/隔离" id ="16" cids="50011982" img="" />
+    <subitem title="去角质" id ="17" cids="50011997" img="" />
+  </item>
+  <item title="彩妆" id ="2" cids="50011990,50013794,50010789" img="">
+    <subitem title="卸妆" id ="20" cids="50011990" img="" />
+    <subitem title="BB霜" id ="21" cids="50013794" img="" />
+    <subitem title="粉底液" id ="22" cids="50010789" img="" />
+    <subitem title="散粉" id ="23" cids="50010792" img="" />
+    <subitem title="粉饼" id ="24" cids="50010790" img="" />
+    <subitem title="腮红" id ="25" cids="50010805" img="" />
+    <subitem title="遮瑕" id ="26" cids="50010803" img="" />
+    <subitem title="睫毛膏" id ="27" cids="50010794" img="" />
+    <subitem title="眼线" id ="28" cids="50010797" img="" />
+    <subitem title="眼影" id ="29" cids="50010796" img="" />
+    <subitem title="眉笔/眉粉" id ="290" cids="50010798" img="" />
+    <subitem title="唇膏/唇彩" id ="291" cids="50010808" img="" />
+  </item>
+</category>

+ 108 - 0
helper/category_helper.php

@@ -0,0 +1,108 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 16/5/9
+ * Time: 下午9:06
+ */
+
+class category_helper
+{
+    private $file_name = '';
+    private $mCategories = NULL;
+    private $mCids = NULL;
+
+    static private $stInstance = NULL;
+    static public function instance()
+    {
+        if(self::$stInstance == NULL) {
+            self::$stInstance = new category_helper();
+        }
+        return self::$stInstance;
+    }
+
+    private function __construct()
+    {
+        $this->mCids = array();
+        $this->file_name = BASE_DATA_PATH . '/sales/category.xml';
+        self::load_xml($this->file_name);
+    }
+
+    private function load_xml($file)
+    {
+        $xml = simplexml_load_file($file);
+        if($xml === false) {
+            throw new Exception("无法解析XML文件");
+        }
+
+        $this->mCategories = array();
+        foreach($xml->children() as $xitem)
+        {
+            $item = array();
+            $attrs = $xitem->attributes();
+
+            $title = $attrs['title']->__toString();
+            $pid = $attrs['id']->__toString();
+            $cids = $attrs['cids']->__toString();
+            $img = $attrs['img']->__toString();
+
+            $item['title'] = $title;
+            $item['id'] = $pid;
+            $item['img'] = $img;
+
+            $item['subitem'] = array();
+            $this->add_cids($pid,$cids);
+
+            foreach($xitem->children() as $xsubitem) {
+                $subitem = array();
+                $sattrs = $xsubitem->attributes();
+
+                $title = $sattrs['title']->__toString();
+                $sid = $sattrs['id']->__toString();
+                $cids = $sattrs['cids']->__toString();
+                $img = $sattrs['img']->__toString();
+
+                $subitem['title'] = $title;
+                $subitem['id'] = $sid;
+                $subitem['img'] = $img;
+
+                array_push($item['subitem'],$subitem);
+
+                $this->add_cids($sid,$cids);
+                $this->add_cids($pid,$cids);
+            }
+
+            array_push($this->mCategories,$item);
+        }
+    }
+
+    private function add_cids($id,$cids)
+    {
+        if(!in_array($id,$this->mCids)) {
+            $this->mCids[$id] = array();
+        }
+        $cids = explode(',',$cids);
+        foreach($cids as $val)
+        {
+            $cur_cids = &$this->mCids[$id];
+            if(!empty($val) && !in_array($val,$cur_cids)) {
+                array_push($cur_cids,$val);
+            }
+        }
+    }
+
+
+    public function categories()
+    {
+        return $this->mCategories;
+    }
+
+    public function cids($id)
+    {
+        if(!in_array($id,$this->mCids)) {
+            return array();
+        } else {
+            return $this->mCids[$id];
+        }
+    }
+}

+ 1 - 1
helper/sensitive/DFAItem.php

@@ -12,6 +12,6 @@ namespace sensitive_word;
 class DFAItem
 {
     private $word = array();
-    
+
 
 }

+ 21 - 0
mobile/control/category.php

@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 16/5/9
+ * Time: 下午9:05
+ */
+defined('InShopNC') or exit('Access Invalid!');
+
+require_once(BASE_ROOT_PATH . '/helper/category_helper.php');
+
+class categoryControl extends mobileControl
+{
+    public function indexOp()
+    {
+        $cats = category_helper::instance()->categories();
+        return self::outsuccess($cats);
+
+    }
+}

+ 14 - 0
research/research_run.php

@@ -5,7 +5,16 @@
 //include BASE_ROOT_PATH . "/research/sms_test.php";
 //include BASE_ROOT_PATH . "/research/wxpay.php";
 
+define('BASE_CORE_PATH',BASE_ROOT_PATH.'/core');
+define('BASE_DATA_PATH',BASE_ROOT_PATH.'/data');
+define('BASE_MOBILE_PATH',BASE_ROOT_PATH.'/mobile');
+define('BASE_CRONTAB_PATH',BASE_ROOT_PATH.'/crontab');
+define('BASE_UPLOAD_PATH',BASE_DATA_PATH.'/upload');
+define('BASE_UTIL_PATH',BASE_ROOT_PATH.'/util');
+
 require_once (BASE_ROOT_PATH . '/helper/text_filter.php');
+require_once (BASE_ROOT_PATH . '/helper/category_helper.php');
+
 
 define('InShopNC',true);
 
@@ -42,6 +51,11 @@ EOT;
 
 $str = text_filter::filter_html($str);
 
+category_helper::instance()->
+
+
+
+
 
 $x = time();