|
@@ -10,7 +10,8 @@
|
|
|
|
|
|
|
|
|
defined('InShopNC') or exit('Access Invalid!');
|
|
|
-class mb_adControl extends SystemControl{
|
|
|
+class mb_adControl extends SystemControl
|
|
|
+{
|
|
|
public function __construct(){
|
|
|
parent::__construct();
|
|
|
Language::read('mobile');
|
|
@@ -18,23 +19,22 @@ class mb_adControl extends SystemControl{
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
|
- public function mb_ad_listOp(){
|
|
|
+ public function mb_ad_listOp()
|
|
|
+ {
|
|
|
$model_mb_ad = Model('mb_ad');
|
|
|
-
|
|
|
$link_list = $model_mb_ad->getMbAdList(array());
|
|
|
Tpl::output('link_list',$link_list);
|
|
|
-
|
|
|
Tpl::showpage('mb_ad.list');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 广告删除
|
|
|
*/
|
|
|
- public function mb_ad_delOp(){
|
|
|
+ public function mb_ad_delOp()
|
|
|
+ {
|
|
|
$link_id = intval($_GET['link_id']);
|
|
|
if ($link_id > 0){
|
|
|
$model_mb_ad = Model('mb_ad');
|
|
|
-
|
|
|
//删除图片
|
|
|
$model_mb_ad->delMbAd($link_id);
|
|
|
showMessage(L('link_index_del_succ'),'index.php?act=mb_ad&op=mb_ad_list');
|
|
@@ -46,15 +46,16 @@ class mb_adControl extends SystemControl{
|
|
|
/**
|
|
|
* 添加
|
|
|
*/
|
|
|
- public function mb_ad_addOp(){
|
|
|
+ public function mb_ad_addOp()
|
|
|
+ {
|
|
|
$model_mb_ad = Model('mb_ad');
|
|
|
-
|
|
|
//最多发布6条
|
|
|
$count = $model_mb_ad->getMbAdCount();
|
|
|
if ($count > 5){
|
|
|
showMessage(L('link_add_count_limit'));
|
|
|
}
|
|
|
- if ($_POST['form_submit'] == 'ok'){
|
|
|
+ if ($_POST['form_submit'] == 'ok')
|
|
|
+ {
|
|
|
/**
|
|
|
* 验证
|
|
|
*/
|
|
@@ -65,9 +66,12 @@ class mb_adControl extends SystemControl{
|
|
|
array("input"=>$_POST["link_sort"], "require"=>"true", 'validator'=>'Number', "message"=>L('link_add_sort_int')),
|
|
|
);
|
|
|
$error = $obj_validate->validate();
|
|
|
- if ($error != ''){
|
|
|
+ if ($error != '')
|
|
|
+ {
|
|
|
showMessage($error);
|
|
|
- }else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
/**
|
|
|
* 上传图片
|
|
|
*/
|
|
@@ -90,7 +94,8 @@ class mb_adControl extends SystemControl{
|
|
|
$insert_array['link_sort'] = trim($_POST['link_sort']);
|
|
|
|
|
|
$result = $model_mb_ad->addMbAd($insert_array);
|
|
|
- if ($result){
|
|
|
+ if ($result)
|
|
|
+ {
|
|
|
$url = array(
|
|
|
array(
|
|
|
'url'=>'index.php?act=mb_ad&op=mb_ad_list',
|
|
@@ -110,9 +115,11 @@ class mb_adControl extends SystemControl{
|
|
|
/**
|
|
|
* 编辑
|
|
|
*/
|
|
|
- public function mb_ad_editOp(){
|
|
|
+ public function mb_ad_editOp()
|
|
|
+ {
|
|
|
$model_mb_ad = Model('mb_ad');
|
|
|
- if ($_POST['form_submit'] == 'ok'){
|
|
|
+ if ($_POST['form_submit'] == 'ok')
|
|
|
+ {
|
|
|
/**
|
|
|
* 验证
|
|
|
*/
|
|
@@ -123,38 +130,47 @@ class mb_adControl extends SystemControl{
|
|
|
array("input"=>$_POST["link_sort"], "require"=>"true", 'validator'=>'Number', "message"=>L('link_add_sort_int')),
|
|
|
);
|
|
|
$error = $obj_validate->validate();
|
|
|
- if ($error != ''){
|
|
|
+ if ($error != '')
|
|
|
+ {
|
|
|
showMessage($error);
|
|
|
- }else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
/**
|
|
|
* 上传图片
|
|
|
*/
|
|
|
- if ($_FILES['link_pic']['name'] != ''){
|
|
|
+ if ($_FILES['link_pic']['name'] != '')
|
|
|
+ {
|
|
|
$upload = new UploadFile();
|
|
|
$upload->set('default_dir',ATTACH_MOBILE.'/ad');
|
|
|
|
|
|
$result = $upload->upfile('link_pic');
|
|
|
if ($result){
|
|
|
$_POST['link_pic'] = $upload->file_name;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
showMessage($upload->error);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
$link_array = $model_mb_ad->getMbAdInfoByID(intval($_POST['link_id']));
|
|
|
$update_array = array();
|
|
|
$update_array['link_title'] = trim($_POST['link_title']);
|
|
|
$update_array['link_keyword'] = trim($_POST['link_keyword']);
|
|
|
- if ($_POST['link_pic']){
|
|
|
+
|
|
|
+ if ($_POST['link_pic']) {
|
|
|
$update_array['link_pic'] = $_POST['link_pic'];
|
|
|
}
|
|
|
+
|
|
|
$update_array['link_sort'] = trim($_POST['link_sort']);
|
|
|
|
|
|
$result = $model_mb_ad->editMbAd($update_array, array('link_id' => intval($_POST['link_id'])));
|
|
|
- if ($result){
|
|
|
+ if ($result)
|
|
|
+ {
|
|
|
//删除图片
|
|
|
- if (!empty($_POST['link_pic']) && !empty($link_array['link_pic'])){
|
|
|
+ if (!empty($_POST['link_pic']) && !empty($link_array['link_pic'])) {
|
|
|
@unlink(BASE_ROOT_PATH.DS.DIR_UPLOAD.DS.ATTACH_MOBILE.'/ad'.DS.$link_array['link_pic']);
|
|
|
}
|
|
|
+
|
|
|
$url = array(
|
|
|
array(
|
|
|
'url'=>'index.php?act=mb_ad&op=mb_ad_list',
|
|
@@ -162,7 +178,9 @@ class mb_adControl extends SystemControl{
|
|
|
)
|
|
|
);
|
|
|
showMessage(L('link_edit_succ'),$url);
|
|
|
- }else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
showMessage(L('link_edit_fail'));
|
|
|
}
|
|
|
}
|
|
@@ -179,8 +197,10 @@ class mb_adControl extends SystemControl{
|
|
|
/**
|
|
|
* ajax操作
|
|
|
*/
|
|
|
- public function ajaxOp(){
|
|
|
- switch ($_GET['branch']){
|
|
|
+ public function ajaxOp()
|
|
|
+ {
|
|
|
+ switch ($_GET['branch'])
|
|
|
+ {
|
|
|
/**
|
|
|
* 合作伙伴 排序
|
|
|
*/
|