예제 #1
0
 /**
  * 设置目录权限
  */
 public function siteDir()
 {
     $dir_list = array('/data', '/data/session', '/data/databack', '/share', '/cache', '/templates', '/templates/', '/admin/templates', '/admin/templates/templates_c', '/system/templates', '/system/templates/templates_c', '/attachments', '/attachments/brandlogo', '/attachments/subjectimg', '/attachments/upimg', '/attachments/linklogo', '/attachments/adfile', '/attachments/languageimage', '/language');
     include_once 'fileoperate.class.php';
     $array = array();
     foreach ($dir_list as $v) {
         FileOperate::WriteDirOrFile(BasePath . $v, 'dir');
         $array[$v] = $this->writeFile(BasePath . $v);
         //清除文件状态缓存
         clearstatcache();
     }
     return $array;
 }
예제 #2
0
 /**
  * 创建商品分类数组文件
  *
  */
 function createGoodsClassArray()
 {
     $creatfile = BasePath . "/share/shop_goods_class_show.php";
     require_once "fileoperate.class.php";
     /**
      * 生成 多维数组 形式的
      */
     $class_array = $this->getGoodsClass(array('order_by_class_sort' => 'yes'), '', "*");
     $productClassArray = array();
     foreach ($class_array as $va) {
         if ($va['class_top_id'] != 0) {
             $sub_class = $this->GetList('and class_top_id=' . $va['class_id'], '', 'shop_goods_class', 'class_id', 0);
             if (count($sub_class) > 0) {
                 $class_sub_state = 1;
             } else {
                 $class_sub_state = 0;
             }
         } else {
             $class_sub_state = 1;
         }
         $productClassArray[] = array(0 => $va['class_id'], 1 => $va['class_top_id'], 5 => $class_sub_state);
     }
     $k = 0;
     $ar = array();
     foreach ($class_array as $val) {
         if ($val['class_top_id'] == 0) {
             $ar[$k] = $val;
             $k++;
             $sub_array = $this->getArrayById($productClassArray, $result, $val['class_id']);
             if (is_array($sub_array) and count($sub_array) > 0) {
                 foreach ($sub_array as $sub_val) {
                     foreach ($class_array as $value) {
                         if ($value['class_id'] == $sub_val) {
                             $ar[$k] = $value;
                             $k++;
                         }
                     }
                 }
             }
         } else {
             break;
         }
     }
     //定义目标数组
     $d = array();
     //定义索引数组,用于记录节点在目标数组的位置
     $ind = array();
     foreach ($ar as $v) {
         $v[child] = array();
         //给每个节点附加一个child项
         if ($v[class_top_id] == 0) {
             $i = count($d);
             $d[$i] = $v;
             $ind[$v[class_id]] =& $d[$i];
         } else {
             $i = count($ind[$v[class_top_id]][child]);
             $ind[$v[class_top_id]][child][$i] = $v;
             $ind[$v[class_id]] =& $ind[$v[class_top_id]][child][$i];
         }
     }
     unset($ind);
     /*将生成的多维数组写入文件,用于前台*/
     if (is_array($d)) {
         $string = $this->makeArray($d, array(0 => 'class_id', 1 => 'class_top_id', 2 => 'class_name', 3 => 'class_sort', 4 => '$depth', 5 => 'class_keywords', 6 => 'class_description'), 0);
     }
     FileOperate::makeClassFlie($string, $creatfile);
     /*生成一维数组,用于后台新增和修改页面的下拉列表*/
     $result = array();
     $string = $this->getOneLevelArray($result, $d, '0', array(0 => 'class_id', 1 => 'class_top_id', 2 => 'class_name', 3 => 'class_sort', 4 => '$depth', 5 => 'class_keywords', 6 => 'class_description'));
     $file_string = $this->getOneLevelString($string);
     FileOperate::makeClassFlie($file_string, $creatfile);
     return true;
 }