123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461 |
- <?php
- /**
- * 会员中心——我是卖家
- *
- *
- *
- **by 好商城V3 www.33hao.com 运营版*/
- defined('InShopNC') or exit('Access Invalid!');
- class store_settingControl extends BaseSellerControl {
- public function __construct() {
- parent::__construct();
- Language::read('member_store_index');
- }
- /**
- * 卖家店铺设置
- *
- * @param string
- * @param string
- * @return
- */
- public function store_settingOp(){
- /**
- * 实例化模型
- */
- $model_class = Model('store');
- /**
- * 获取设置
- */
- // $setting_config = $GLOBALS['setting_config'];
- $config_subdomain_edit = C('subdomain_edit');
- $config_subdomain_times = C('subdomain_times');
- $config_subdomain_length = C('subdomain_length');
- $config_subdomain_reserved = C('subdomain_reserved');
- $config_enabled_subdomain = C('enabled_subdomain');
- $store_id = $_SESSION['store_id'];//当前店铺ID
- /**
- * 获取店铺信息
- */
- $store_info = $model_class->getStoreInfoByID($store_id);
- $subdomain_edit = intval($config_subdomain_edit);//二级域名是否可修改
- $subdomain_times = intval($config_subdomain_times);//系统设置二级域名可修改次数
- $store_domain_times = intval($store_info['store_domain_times']);//店铺已修改次数
- $subdomain_length = explode('-',$config_subdomain_length);
- $subdomain_length[0] = intval($subdomain_length[0]);
- $subdomain_length[1] = intval($subdomain_length[1]);
- if ($subdomain_length[0] < 1 || $subdomain_length[0] >= $subdomain_length[1]){//域名长度
- $subdomain_length[0] = 3;
- $subdomain_length[1] = 12;
- }
- Tpl::output('subdomain_length',$subdomain_length);
- /**
- * 保存店铺设置
- */
- if (chksubmit()){
- $_POST['store_domain'] = trim($_POST['store_domain']);
- $store_domain = strtolower($_POST['store_domain']);
- //判断是否设置二级域名
- if (!empty($store_domain) && $store_domain != $store_info['store_domain']){
- $store_domain_count = strlen($store_domain);
- if ($store_domain_count < $subdomain_length[0] || $store_domain_count > $subdomain_length[1]){
- showDialog(Language::get('store_setting_wrong_uri').': '.$config_subdomain_length,'reload','error');
- }
- if (!preg_match('/^[\w-]+$/i',$store_domain)){//判断域名是否正确
- showDialog(Language::get('store_setting_lack_uri'));
- }
- $store = $model_class->getStoreInfo(array(
- 'store_domain'=>$store_domain
- ));
- //二级域名存在,则提示错误
- if (!empty($store) && ($store_id != $store['store_id'])){
- showDialog(Language::get('store_setting_exists_uri'),'reload','error');
- }
- //判断二级域名是否为系统禁止
- $subdomain_reserved = @explode(',',$config_subdomain_reserved);
- if(!empty($subdomain_reserved) && is_array($subdomain_reserved)){
- if (in_array($store_domain,$subdomain_reserved)){
- showDialog(Language::get('store_setting_invalid_uri'));
- }
- }
- if($subdomain_times > $store_domain_times){//可继续修改
- $param = array();
- $param['store_domain'] = $store_domain;
- if (!empty($store_info['store_domain'])) $param['store_domain_times'] = $store_domain_times+1;//第一次保存不计数
- $model_class->editStore($param, array('store_id' => $store_id));
- }
- $_POST['store_domain'] = '';//避免重复更新
- }
- $upload = new UploadFile();
- /**
- * 上传店铺图片
- */
- if (!empty($_FILES['store_banner']['name'])){
- $upload->set('default_dir', ATTACH_STORE);
- $upload->set('thumb_ext', '');
- $upload->set('file_name','');
- $upload->set('ifremove',false);
- $result = $upload->upfile('store_banner');
- if ($result){
- $_POST['store_banner'] = $upload->file_name;
- }else {
- showDialog($upload->error);
- }
- }
- //删除旧店铺图片
- if (!empty($_POST['store_banner']) && !empty($store_info['store_banner'])){
- @unlink(BASE_UPLOAD_PATH.DS.ATTACH_STORE.DS.$store_info['store_banner']);
- }
- /**
- * 上传店铺图片
- */
- if (!empty($_FILES['store_label']['name'])){
- $upload->set('default_dir', ATTACH_STORE);
- $upload->set('thumb_ext', '');
- $upload->set('file_name','');
- $upload->set('ifremove',false);
- $result = $upload->upfile('store_label');
- if ($result){
- $_POST['store_label'] = $upload->file_name;
- }else {
- showDialog($upload->error);
- }
- }
- //删除旧店铺图片
- if (!empty($_POST['store_label']) && !empty($store_info['store_label'])){
- @unlink(BASE_UPLOAD_PATH.DS.ATTACH_STORE.DS.$store_info['store_label']);
- }
- //删除旧店铺图片
- if (!empty($_POST['store_logo']) && !empty($store_info['store_logo'])){
- @unlink(BASE_UPLOAD_PATH.DS.ATTACH_STORE.DS.$store_info['store_logo']);
- }
- /**
- * 更新入库
- */
- $param = array(
- 'store_label' => empty($_POST['store_label']) ? $store_info['store_label'] : $_POST['store_label'],
- 'store_banner' => empty($_POST['store_banner']) ? $store_info['store_banner'] : $_POST['store_banner'],
- 'store_avatar' => empty($_POST['store_avatar']) ? $store_info['store_avatar'] : $_POST['store_avatar'],
- 'store_qq' => $_POST['store_qq'],
- 'store_ww' => $_POST['store_ww'],
- 'store_phone' => $_POST['store_phone'],
- 'store_zy' => $_POST['store_zy'],
- 'store_keywords' => $_POST['seo_keywords'],
- 'store_description' => $_POST['seo_description']
- );
- if (!empty($_POST['store_theme'])){
- $param['store_theme'] = $_POST['store_theme'];
- }
-
- //v3-b11 编辑店铺名称
- $store_name=$_POST['store_name'];
- if (!empty($_POST['store_name'])){
-
- $store = $model_class->getStoreInfo(array(
- 'store_name'=>$store_name
- ));
- //店铺名存在,则提示错误
- if (!empty($store) && ($store_id != $store['store_id'])){
- showDialog('此店铺名称已被其它人使用,请换其它名称。','reload','error');
- return;
- }
- $param['store_name'] = $_POST['store_name'];
- }
- //end 33h ao.co m
- $model_class->editStore($param, array('store_id' => $store_id));
- showDialog(Language::get('nc_common_save_succ'),'index.php?act=store_setting&op=store_setting','succ');
- }
- /**
- * 实例化店铺等级模型
- */
- // $model_store_grade = Model('store_grade');
- // $store_grade = $model_store_grade->getOneGrade($store_info['grade_id']);
- // 从基类中读取店铺等级信息
- $store_grade = $this->store_grade;
- //编辑器多媒体功能
- $editor_multimedia = false;
- $sg_fun = @explode('|',$store_grade['sg_function']);
- if(!empty($sg_fun) && is_array($sg_fun)){
- foreach($sg_fun as $fun){
- if ($fun == 'editor_multimedia'){
- $editor_multimedia = true;
- }
- }
- }
- Tpl::output('editor_multimedia',$editor_multimedia);
- if($subdomain_edit == 1 && ($subdomain_times > $store_domain_times)){//可继续修改二级域名
- Tpl::output('subdomain_edit',$subdomain_edit);
- }
- /**
- * 输出店铺信息
- */
- self::profile_menu('store_setting');
- Tpl::output('store_info',$store_info);
- Tpl::output('store_grade',$store_grade);
- Tpl::output('subdomain',$config_enabled_subdomain);
- Tpl::output('subdomain_times',$config_subdomain_times);
- /**
- * 页面输出
- */
- Tpl::showpage('store_setting_form');
- }
- /**
- * 店铺幻灯片
- */
- public function store_slideOp() {
- /**
- * 模型实例化
- */
- $model_store = Model('store');
- $model_upload = Model('upload');
- /**
- * 保存店铺信息
- */
- if ($_POST['form_submit'] == 'ok'){
- // 更新店铺信息
- $update = array();
- $update['store_slide'] = implode(',', $_POST['image_path']);
- $update['store_slide_url'] = implode(',', $_POST['image_url']);
- $model_store->editStore($update, array('store_id' => $_SESSION['store_id']));
- // 删除upload表中数据
- $model_upload->delByWhere(array('upload_type'=>3,'item_id'=>$_SESSION['store_id']));
- showDialog(Language::get('nc_common_save_succ'),'index.php?act=store_setting&op=store_slide','succ');
- }
- // 删除upload中的无用数据
- $upload_info = $model_upload->getUploadList(array('upload_type'=>3,'item_id'=>$_SESSION['store_id']),'file_name');
- if(is_array($upload_info) && !empty($upload_info)){
- foreach ($upload_info as $val){
- @unlink(BASE_UPLOAD_PATH.DS.ATTACH_SLIDE.DS.$val['file_name']);
- }
- }
- $model_upload->delByWhere(array('upload_type'=>3,'item_id'=>$_SESSION['store_id']));
- $store_info = $model_store->getStoreInfoByID($_SESSION['store_id']);
- if($store_info['store_slide'] != '' && $store_info['store_slide'] != ',,,,'){
- Tpl::output('store_slide', explode(',', $store_info['store_slide']));
- Tpl::output('store_slide_url', explode(',', $store_info['store_slide_url']));
- }
- self::profile_menu('store_slide');
- /**
- * 页面输出
- */
- Tpl::showpage('store_slide_form');
- }
- /**
- * 店铺幻灯片ajax上传
- */
- public function silde_image_uploadOp(){
- $upload = new UploadFile();
- $upload->set('default_dir',ATTACH_SLIDE);
- $upload->set('max_size',C('image_max_filesize'));
- $result = $upload->upfile($_POST['id']);
- $output = array();
- if(!$result){
- /**
- * 转码
- */
- if (strtoupper(CHARSET) == 'GBK'){
- $upload->error = Language::getUTF8($upload->error);
- }
- $output['error'] = $upload->error;
- echo json_encode($output);die;
- }
- $img_path = $upload->file_name;
- /**
- * 模型实例化
- */
- $model_upload = Model('upload');
- if(intval($_POST['file_id']) > 0){
- $file_info = $model_upload->getOneUpload($_POST['file_id']);
- @unlink(BASE_UPLOAD_PATH.DS.ATTACH_SLIDE.DS.$file_info['file_name']);
- $update_array = array();
- $update_array['upload_id'] = intval($_POST['file_id']);
- $update_array['file_name'] = $img_path;
- $update_array['file_size'] = $_FILES[$_POST['id']]['size'];
- $model_upload->update($update_array);
- $output['file_id'] = intval($_POST['file_id']);
- $output['id'] = $_POST['id'];
- $output['file_name'] = $img_path;
- echo json_encode($output);die;
- }else{
- /**
- * 图片数据入库
- */
- $insert_array = array();
- $insert_array['file_name'] = $img_path;
- $insert_array['upload_type'] = '3';
- $insert_array['file_size'] = $_FILES[$_POST['id']]['size'];
- $insert_array['item_id'] = $_SESSION['store_id'];
- $insert_array['upload_time'] = time();
- $result = $model_upload->add($insert_array);
- if(!$result){
- @unlink(BASE_UPLOAD_PATH.DS.ATTACH_SLIDE.DS.$img_path);
- $output['error'] = Language::get('store_slide_upload_fail','UTF-8');
- echo json_encode($output);die;
- }
- $output['file_id'] = $result;
- $output['id'] = $_POST['id'];
- $output['file_name'] = $img_path;
- echo json_encode($output);die;
- }
- }
- /**
- * ajax删除幻灯片图片
- */
- public function dorp_imgOp(){
- /**
- * 模型实例化
- */
- $model_upload = Model('upload');
- $file_info = $model_upload->getOneUpload(intval($_GET['file_id']));
- if(!$file_info){
- }else{
- @unlink(BASE_UPLOAD_PATH.DS.ATTACH_SLIDE.DS.$file_info['file_name']);
- $model_upload->del(intval($_GET['file_id']));
- }
- echo json_encode(array('succeed'=>Language::get('nc_common_save_succ','UTF-8')));die;
- }
- /**
- * 卖家店铺主题设置
- *
- * @param string
- * @param string
- * @return
- */
- public function themeOp(){
- /**
- * 店铺信息
- */
- $store_class = Model('store');
- $store_info = $store_class->getStoreInfoByID($_SESSION['store_id']);
- /**
- * 主题配置信息
- */
- $style_data = array();
- $style_configurl = BASE_ROOT_PATH.DS.DIR_SHOP.'/templates/'.TPL_SHOP_NAME.DS.'store'.DS.'style'.DS."styleconfig.php";
- if (file_exists($style_configurl)){
- include_once($style_configurl);
- }
- /**
- * 转码
- */
- if (strtoupper(CHARSET) == 'GBK'){
- $style_data = Language::getGBK($style_data);
- }
- /**
- * 当前店铺主题
- */
- $curr_store_theme = !empty($store_info['store_theme'])?$store_info['store_theme']:'default';
- /**
- * 当前店铺预览图片
- */
- $curr_image = SHOP_TEMPLATES_URL.'/store/style/'.$curr_store_theme.'/images/preview.jpg';
- $curr_theme = array(
- 'curr_name'=>$curr_store_theme,
- 'curr_truename'=>$style_data[$curr_store_theme]['truename'],
- 'curr_image'=>$curr_image
- );
- // 自营店全部可用
- if (checkPlatformStore()) {
- $themes = array_keys($style_data);
- } else {
- /**
- * 店铺等级
- */
- $grade_class = Model('store_grade');
- $grade = $grade_class->getOneGrade($store_info['grade_id']);
- /**
- * 可用主题
- */
- $themes = explode('|',$grade['sg_template']);
- }
- /**
- * 可用主题预览图片
- */
- foreach ($style_data as $key => $val){
- if (in_array($key,$themes)){
- $theme_list[$key] = array(
- 'name'=>$key,
- 'truename'=>$val['truename'],
- 'image'=>SHOP_TEMPLATES_URL.'/store/style/'.$key.'/images/preview.jpg'
- );
- }
- }
- /**
- * 页面输出
- */
- self::profile_menu('store_theme','store_theme');
- Tpl::output('store_info',$store_info);
- Tpl::output('curr_theme',$curr_theme);
- Tpl::output('theme_list',$theme_list);
- Tpl::showpage('store_theme');
- }
- /**
- * 卖家店铺主题设置
- *
- * @param string
- * @param string
- * @return
- */
- public function set_themeOp(){
- //读取语言包
- $lang = Language::getLangContent();
- $style = isset($_GET['style_name']) ? trim($_GET['style_name']) : null;
- if (!empty($style) && file_exists(BASE_TPL_PATH.DS.'/store/style/'.$style.'/images/preview.jpg')){
- $store_class = Model('store');
- $rs = $store_class->editStore(array('store_theme'=>$style), array('store_id' => $_SESSION['store_id']));
- showDialog($lang['store_theme_congfig_success'],'reload','succ');
- }else{
- showDialog($lang['store_theme_congfig_fail'],'','succ');
- }
- }
- /**
- * 用户中心右边,小导航
- *
- * @param string $menu_type 导航类型
- * @param string $menu_key 当前导航的menu_key
- * @return
- */
- private function profile_menu($menu_key='') {
- Language::read('member_layout');
- $menu_array = array(
- 1=>array('menu_key'=>'store_setting','menu_name'=>Language::get('nc_member_path_store_config'),'menu_url'=>'index.php?act=store_setting&op=store_setting'),
- 4=>array('menu_key'=>'store_slide','menu_name'=>Language::get('nc_member_path_store_slide'),'menu_url'=>'index.php?act=store_setting&op=store_slide'),
- 5=>array('menu_key'=>'store_theme','menu_name'=>'店铺主题','menu_url'=>'index.php?act=store_setting&op=theme'),
- );
- Tpl::output('member_menu',$menu_array);
- Tpl::output('menu_key',$menu_key);
- }
- }
|