예제 #1
0
 public function action_index()
 {
     //$addmodule = ORM::factory('model')->where("id>13")->get_all();
     $addmodule = Model_Model::getAllModule();
     $this->assign('addmodule', $addmodule);
     $this->display('stourtravel/module/index');
 }
예제 #2
0
 public function action_found()
 {
     $addmodule = Model_Model::getAllModule();
     $menu = Common::getConfig('menu_sub');
     $this->assign('menu', $menu);
     $this->assign('addmodule', $addmodule);
     $this->display('stourtravel/public/found');
 }
예제 #3
0
$menu = Common::getConfig('menu_sub.' . $parentkey);
foreach ($menu as $row) {
    $class = $row['itemid'] == $itemid ? " class='active' " : '';
    echo '<a href="javascript:;"' . $class . ' data-url="' . $row['url'] . '">' . $row['name'] . '</a>';
}
if ($parentkey == 'product') {
    //$addmodule = ORM::factory('model')->where("id>13")->get_all();
    $addmodule = Model_Model::getAllModule();
    foreach ($addmodule as $row) {
        $class = $row['id'] == $itemid ? " class='active' " : '';
        echo '<a href="javascript:;"' . $class . ' data-url="tongyong/index/typeid/' . $row['id'] . '/parentkey/product/itemid/' . $v['id'] . '">' . $row['modulename'] . '</a>';
    }
}
if ($parentkey == 'order') {
    //$addmodule = ORM::factory('model')->where("id>13")->get_all();
    $addmodule = Model_Model::getAllModule();
    foreach ($addmodule as $row) {
        $class = $row['id'] == $itemid ? " class='active' " : '';
        echo '<a href="javascript:;"' . $class . ' data-url="order/index/parentkey/order/itemid/' . $row['id'] . '/typeid/' . $row['id'] . '">' . $row['modulename'] . '</a>';
    }
}
?>
      </div>
    </div>
<script>
         $(document).ready(function(e) {
             /*$(".global_nav").mouseover(function(){
                $(this).children(".mc").show()
                    $(this).children().children(".tall").show()
                    })
                   $(".global_nav").mouseout(function(){
예제 #4
0
 public function action_destination()
 {
     $action = $this->params['action'];
     if (empty($action)) {
         $typeid = $this->params['typeid'];
         $typeid = empty($typeid) ? 0 : $typeid;
         if (!empty($typeid)) {
             $moduleinfo = Model_Model::getModuleInfo($typeid);
             //$product_dest_table='sline_'.$this->product_arr[$typeid].'_kindlist';
             $product_dest_table = $moduleinfo['pinyin'] . '_kindlist';
         }
         $addmodule = ORM::factory('model')->where("id>13")->get_all();
         //扩展模型
         $allmodule = Model_Model::getAllModule();
         //$position = $typeid==0 ? '全局目的地':$this->name_arr[$typeid].'目的地';
         $position = $typeid == 0 ? '全局目的地' : $moduleinfo['modulename'] . '目的地';
         $this->assign('typeid', $typeid);
         $this->assign('position', $position);
         $this->assign('addmodule', $addmodule);
         $this->assign('allmodule', $allmodule);
         $this->display('stourtravel/destination/destination');
     } else {
         if ($action == 'read') {
             $node = Arr::get($_GET, 'node');
             $typeid = Arr::get($_GET, 'typeid');
             $node_arr = explode('_', $node);
             if (!empty($typeid)) {
                 $moduleinfo = Model_Model::getModuleInfo($typeid);
                 //$product_dest_table='sline_'.$this->product_arr[$typeid].'_kindlist';
                 $product_dest_table = 'sline_' . $moduleinfo['pinyin'] . '_kindlist';
             }
             $pid = $node_arr[1] == 'root' ? 0 : $node_arr[1];
             if (empty($typeid)) {
                 $sql = "select * from sline_destinations where pid={$pid}";
             } else {
                 $bfields = 'b.kindid,b.seotitle,b.keyword,b.description,b.tagword,b.jieshao,b.isfinishseo,b.isnav,b.ishot,b.displayorder';
                 $sql = "select a.id,a.kindname,if(find_in_set({$typeid},opentypeids),1,0) as isopen,a.pinyin,a.iswebsite,{$bfields} from sline_destinations a left join {$product_dest_table} b on a.id=b.kindid where a.pid={$pid}";
             }
             $list = DB::query(Database::SELECT, $sql)->execute()->as_array();
             if ($typeid == 0) {
                 $list[] = array('leaf' => true, 'id' => $pid . 'add', 'kindname' => '<button class="dest-add-btn df-add-btn" onclick="addSub(' . $pid . ')">添加</button>', 'allowDrag' => false, 'allowDrop' => false, 'displayorder' => 'add', 'isopen' => 'add', 'iswebsite' => 'add', 'isnav' => 'add', 'istopnav' => 'add', 'ishot' => 'add', 'pinyin' => 'add');
             }
             echo json_encode(array('success' => true, 'text' => '', 'children' => $list));
         } else {
             if ($action == 'update') {
                 $id = Arr::get($_POST, 'id');
                 $field = Arr::get($_POST, 'field');
                 $val = Arr::get($_POST, 'val');
                 $typeid = Arr::get($_POST, 'typeid');
                 if ($typeid == 0) {
                     $model = ORM::factory('destinations', $id);
                     $model->{$field} = $val;
                     if ($field == 'weburl') {
                         $ar = explode('.', $val);
                         $py = str_replace('http://', '', $ar[0]);
                         $m = ORM::factory('destinations')->where("webprefix='{$py}' and id!={$id}")->find();
                         if (!$m->loaded()) {
                             $model->webprefix = $py;
                         } else {
                             echo 'py_repeat';
                             exit;
                         }
                     }
                     $model->save();
                     if ($model->saved()) {
                         echo 'ok';
                     } else {
                         echo 'no';
                     }
                 } else {
                     if ($field == 'isopen') {
                         $result = Model_Destinations::setTypeidOpen($id, $typeid, $val);
                         if ($result) {
                             echo 'ok';
                         } else {
                             echo 'no';
                         }
                     } else {
                         $moduleinfo = Model_Model::getModuleInfo($typeid);
                         //$product_dest_table='sline_'.$this->product_arr[$typeid].'_kindlist';
                         $product_dest_table = $moduleinfo['pinyin'] . '_kindlist';
                         //$model=ORM::factory($this->product_arr[$typeid].'_kindlist')->where("kindid=$id")->find();
                         $model = new Model_Tongyong($product_dest_table);
                         $model = $model->where("kindid={$id}")->find();
                         if (!$model->loaded()) {
                             //$model = ORM::factory($this->product_arr[$typeid].'_kindlist');
                             $model->kindid = $id;
                         }
                         $model->{$field} = $val;
                         $model->save();
                         if ($model->saved()) {
                             echo 'ok';
                         } else {
                             echo 'no';
                         }
                     }
                 }
             } else {
                 if ($action == 'save') {
                     $rawdata = file_get_contents('php://input');
                     $field = Arr::get($_GET, 'field');
                     $typeid = Arr::get($_GET, 'typeid');
                     $current_pinyin = Arr::get($_GET, 'pinyin');
                     $data = json_decode($rawdata);
                     $dest_id_arr = explode('_', $data->id);
                     $dest_id = $dest_id_arr[1];
                     if (!empty($typeid)) {
                         $moduleinfo = Model_Model::getModuleInfo($typeid);
                         //$product_dest_table='sline_'.$this->product_arr[$typeid].'_kindlist';
                         $product_dest_table = $moduleinfo['pinyin'] . '_kindlist';
                     }
                     if (!is_numeric($dest_id_arr[1])) {
                         echo json_encode(array('success' => false));
                     }
                     if ($typeid == 0) {
                         $dest = ORM::factory('destinations', $dest_id_arr[1]);
                         if ($field) {
                             if ($field == 'kindname') {
                                 $dest->pinyin = empty($current_pinyin) ? Common::getPinYin($data->{$field}) : $current_pinyin;
                             }
                             $dest->{$field} = $data->{$field};
                         } else {
                             unset($data->id);
                             unset($data->parentId);
                             unset($data->leaf);
                             unset($data->issel);
                             unset($data->shownum);
                             foreach ($data as $k => $v) {
                                 $dest->{$k} = $v;
                             }
                         }
                     } else {
                         //$dest=ORM::factory($this->product_arr[$typeid].'_kindlist')->where("kindid=$dest_id")->find();
                         $dest = new Model_Tongyong($product_dest_table);
                         $dest = $dest->where("kindid={$dest_id}")->find();
                         if (!$dest->loaded()) {
                             $dest->kindid = $dest_id;
                             $dest->displayorder = $data->displayorder;
                         } else {
                             unset($data->id);
                             unset($data->parentId);
                             unset($data->leaf);
                             unset($data->kindname);
                             unset($data->isopen);
                             unset($data->iswebsite);
                             unset($data->istopnav);
                             unset($data->pinyin);
                             unset($data->pid);
                             unset($data->kindtype);
                             unset($data->litpic);
                             unset($data->piclist);
                             unset($data->issel);
                             unset($data->shownum);
                             unset($data->templet);
                             unset($data->weburl);
                             foreach ($data as $k => $v) {
                                 $dest->{$k} = $v;
                             }
                             $dest->displayorder = $data->displayorder;
                         }
                     }
                     $dest->displayorder = empty($dest->displayorder) ? 9999 : $dest->displayorder;
                     $dest->save();
                     if ($dest->saved()) {
                         echo json_encode(array('success' => true));
                     } else {
                         echo json_encode(array('success' => false));
                     }
                 } else {
                     if ($action == 'uploadfile') {
                         $file = $_FILES['Filedata'];
                         $rootpath = realpath(DOCROOT . '../');
                         $dir = $rootpath . "/uploads/main/" . date('Ymd');
                         if (!file_exists($dir)) {
                             mkdir($dir);
                         }
                         $path_info = pathinfo($_FILES['Filedata']['name']);
                         $filename = date('His') . '.' . $path_info['extension'];
                         Upload::$default_directory = $dir;
                         //默认保存文件夹
                         Upload::$remove_spaces = true;
                         //上传文件删除空格
                         if (Upload::valid($file)) {
                             if (Upload::size($file, "1M")) {
                                 if (Upload::type($file, array('jpg', 'png', 'gif'))) {
                                     if (Upload::save($file, $filename)) {
                                         $newfile = $dir . '/' . $filename;
                                         Image::factory($newfile)->resize(600, 400, Image::AUTO)->save($newfile);
                                         echo substr(substr($newfile, strpos($dir, '/uploads') - 1), 1);
                                     } else {
                                         echo "error_no";
                                     }
                                 } else {
                                     echo "error_type";
                                 }
                             } else {
                                 echo "error_size";
                             }
                         } else {
                             echo "error_null";
                         }
                     } else {
                         if ($action == 'addsub') {
                             $pid = Arr::get($_POST, 'pid');
                             $dest = ORM::factory('destinations');
                             $dest->pid = $pid;
                             $dest->kindname = "未命名";
                             $dest->save();
                             if ($dest->saved()) {
                                 $dest->reload();
                                 $dest->updateSibling('add');
                                 echo json_encode($dest->as_array());
                             }
                         } else {
                             if ($action == 'drag') {
                                 $moveid = Arr::get($_POST, 'moveid');
                                 $overid = Arr::get($_POST, 'overid');
                                 $position = Arr::get($_POST, 'position');
                                 $moveDest = ORM::factory('destinations', $moveid);
                                 $overDest = ORM::factory('destinations', $overid);
                                 if ($position == 'append') {
                                     $moveDest->pid = $overid;
                                 } else {
                                     $moveDest->pid = $overDest->pid;
                                 }
                                 $moveDest->save();
                                 if ($moveDest->saved()) {
                                     echo 'ok';
                                 } else {
                                     echo 'no';
                                 }
                             } else {
                                 if ($action == 'search') {
                                     $keyword = trim(Arr::get($_POST, 'keyword'));
                                     $list = DB::query(Database::SELECT, "select id,pid from sline_destinations where kindname like '%{$keyword}%'")->execute()->as_array();
                                     $new_arr = array();
                                     foreach ($list as $k => $v) {
                                         $temp_arr = array();
                                         if ($v['pid'] != 0) {
                                             $temp_id = $v['pid'];
                                             $temp_arr = array($v['pid'], $v['id']);
                                             while (true) {
                                                 $temp_dest = ORM::factory('destinations', $temp_id)->as_array();
                                                 if ($temp_dest['pid'] != 0) {
                                                     array_unshift($temp_arr, $temp_dest['pid']);
                                                     $temp_id = $temp_dest['pid'];
                                                 } else {
                                                     break;
                                                 }
                                             }
                                             $new_arr[] = $temp_arr;
                                         } else {
                                             $new_arr[] = array($v['id']);
                                         }
                                     }
                                     if (empty($new_arr)) {
                                         echo 'no';
                                     } else {
                                         echo json_encode($new_arr);
                                     }
                                 } else {
                                     if ($action == 'delete') {
                                         $rawdata = file_get_contents('php://input');
                                         $field = Arr::get($_GET, 'field');
                                         $data = json_decode($rawdata);
                                         $dest_id_arr = explode('_', $data->id);
                                         if (!is_numeric($dest_id_arr[1])) {
                                             echo json_encode(array('success' => false));
                                             exit;
                                         }
                                         $dest = ORM::factory('destinations', $dest_id_arr[1]);
                                         $dest->deleteClear();
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }