/** * 添加滚动图 */ function create() { $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'carousel', roleModel::POWER_INSERT)) { $pic = $this->file->pic; if (!empty($pic)) { $image = new image(); $pic = $image->resizeImage($pic, 640, 320); } else { //滚动图的默认图片 $pic = ROOT . '/application/assets/global/plugins/jcrop/demos/demo_files/image3.jpg'; } $title = $this->post->title; $stop = $this->post->stop; $type = $this->post->type; $src_product = filter::int($this->post->src_product); $src_url = filter::url($this->post->src_url); $src_theme = filter::int($this->post->src_theme); switch ($type) { case 'url': $src = $src_url; break; case 'product': $src = $src_product; break; case 'theme': $src = $src_theme; break; default: $src = ''; break; } $carouselModel = $this->model('carousel'); $id = $carouselModel->create($title, $pic, $stop, $type, $src); return new json(json::OK, NULL, $id); } else { return new json(json::NO_POWER); } }