function edit_post() { if (IS_POST) { if ($this->slide_obj->create()) { $_POST['slide_pic'] = sp_asset_relative_url($_POST['slide_pic']); if ($this->slide_obj->save() !== false) { $this->success("保存成功!", U("slide/index")); } else { $this->error("保存失败!"); } } else { $this->error($this->slide_obj->getError()); } } }
function edit_post() { if (IS_POST) { if ($this->ad_obj->create()) { $_POST['ad_imgurl'] = sp_asset_relative_url($_POST['ad_imgurl']); if ($this->ad_obj->save() !== false) { $this->success("保存成功!", Cookie('__forward__')); } else { $this->error("保存失败!"); } } else { $this->error($this->ad_obj->getError()); } } }
public function edit_headimg() { $headimg_obj = D("Common/HeadImg"); if (IS_POST) { $_POST['smeta']['thumb'] = sp_asset_relative_url($_POST['smeta']['thumb']); $page = I("post.headimg"); $page['img_url'] = $_POST['smeta']['thumb']; $page['create_time'] = time(); //dump($page); $result = $this->headimg_model->save($page); if ($result !== false) { // $this->success("保存成功!"); } else { $this->error("保存失败!"); } } }
public function edit_product() { $product_obj = D("Common/product"); if (IS_POST) { $_POST['smeta']['thumb'] = sp_asset_relative_url($_POST['smeta']['thumb']); $page = I("post.product"); $page['img_url'] = $_POST['smeta']['thumb']; $page['message'] = htmlspecialchars_decode($page['message']); $page['create_time'] = time(); $result = $this->product_model->save($page); if ($result !== false) { // $this->success("保存成功!"); } else { $this->error("保存失败!"); } } }
public function edit_story() { $story_obj = D("Common/Story"); if (IS_POST) { $_POST['smeta']['thumb'] = sp_asset_relative_url($_POST['smeta']['thumb']); unset($_POST['story']['story_author']); $page = I("post.story"); $page['img_url'] = $_POST['smeta']['thumb']; $page['content'] = htmlspecialchars_decode($page['content']); $page['create_time'] = time(); $result = $this->story_model->save($page); if ($result !== false) { // $this->success("保存成功!"); } else { $this->error("保存失败!"); } } }
public function edit_post() { if (IS_POST) { if (!empty($_POST['photos_alt']) && !empty($_POST['photos_url'])) { foreach ($_POST['photos_url'] as $key => $url) { $photourl = sp_asset_relative_url($url); $_POST['smeta']['photo'][] = array("url" => $photourl, "alt" => $_POST['photos_alt'][$key]); } } $_POST['smeta']['thumb'] = sp_asset_relative_url($_POST['smeta']['thumb']); $_POST['post']['smeta'] = json_encode($_POST['smeta']); unset($_POST['post']['post_author']); $result = $this->posts_obj->save($_POST['post']); //echo($this->posts_obj->getLastSql());die; if ($result !== false) { $this->success("保存成功!"); } else { $this->error("保存失败!"); } } }
public function edit_post() { if (IS_POST) { if (empty($_POST['term'])) { $this->error("请至少选择一个分类栏目!"); } $post_id = intval($_POST['post']['id']); $this->term_relationships_model->where(array("object_id" => $post_id, "term_id" => array("not in", implode(",", $_POST['term']))))->delete(); foreach ($_POST['term'] as $mterm_id) { $find_term_relationship = $this->term_relationships_model->where(array("object_id" => $post_id, "term_id" => $mterm_id))->count(); if (empty($find_term_relationship)) { $this->term_relationships_model->add(array("term_id" => intval($mterm_id), "object_id" => $post_id)); } else { $this->term_relationships_model->where(array("object_id" => $post_id, "term_id" => $mterm_id))->save(array("status" => 1)); } } if (!empty($_POST['photos_alt']) && !empty($_POST['photos_url'])) { foreach ($_POST['photos_url'] as $key => $url) { $photourl = sp_asset_relative_url($url); $_POST['smeta']['photo'][] = array("url" => $photourl, "alt" => $_POST['photos_alt'][$key]); } } $_POST['smeta']['thumb'] = sp_asset_relative_url($_POST['smeta']['thumb']); unset($_POST['post']['post_author']); $article = I("post.post"); $article['smeta'] = json_encode($_POST['smeta']); $article['post_content'] = htmlspecialchars_decode($article['post_content']); $result = $this->posts_model->save($article); if ($result !== false) { $this->success("保存成功!"); } else { $this->error("保存失败!"); } } }
public function edit_post() { $terms_obj = D("Common/Terms"); if (IS_POST) { $_POST['smeta']['thumb'] = sp_asset_relative_url($_POST['smeta']['thumb']); unset($_POST['post']['post_author']); $page = I("post.post"); $page['smeta'] = json_encode($_POST['smeta']); $page['post_content'] = htmlspecialchars_decode($page['post_content']); $result = $this->posts_model->save($page); if ($result !== false) { // $this->success("保存成功!"); } else { $this->error("保存失败!"); } } }
function edit_post() { if (IS_POST) { if ($this->ad1_obj->create()) { //图片存储的文件夹 $folder = "ad"; $pic = sp_asset_relative_url($_POST['ad_pic']); $ad_pic = str_replace("temp", $folder, $pic); $ad_thumb = str_replace("temp", "temp/thumb", $pic); $ad_cut_pic = str_replace("temp", $folder . "/thumb", $pic); if (!file_exists($ad_pic)) { rename($pic, $ad_pic); $_POST['ad_pic'] = $ad_pic; } if (!file_exists($ad_cut_pic)) { rename($ad_thumb, $ad_cut_pic); $_POST['ad_cut_pic'] = $ad_cut_pic; } if ($this->ad1_obj->save($_POST) !== false) { $this->success("保存成功!", U("ad1/index")); } else { unlink($_POST['ad_pic']); unlink($_POST['ad_cut_pic']); $this->error("保存失败!"); } } else { $this->error($this->slide_obj->getError()); } } }
/** * 转移上传图片路径 * @param string $desDir 目标文件夹 * @param string $image 图片原地址 * @return string $desc 图片地址 */ public function removeUploadImage($desDir, $image) { //源文件路径 $pic = sp_asset_relative_url($image); //缩略图原路径 $thumb = str_replace("temp", "temp/thumb", $pic); //目标路径 $desc = str_replace("temp", $desDir, $pic); //缩略图目标路径 $descThumb = str_replace("temp", $desDir . "/thumb", $pic); if (!file_exists($desc)) { rename($pic, $desc); } if (!file_exists($descThumb)) { rename($thumb, $descThumb); } return $desc; }
public function content_update() { if (IS_POST) { if (!in_array(I('post.post')['post_type'], ['paper', 'project', 'award', 'patent'])) { $this->error('post类型不正确'); } if (!isset($_POST['id'])) { $this->error("缺少参数"); } else { $where['id'] = $_POST['id']; } $dbContent = M('content_' . I('post.post')['post_type']); $_POST['smeta']['thumb'] = sp_asset_relative_url($_POST['smeta']['thumb']); $_POST['post']['post_modified'] = date("Y-m-d H:i:s", time()); $where['post_author'] = sp_get_current_userid(); $article = I("post.post"); $article['smeta'] = json_encode($_POST['smeta']); $article['provement'] = htmlspecialchars_decode($article['provement']); $article['status'] = 0; $result = $dbContent->where($where)->save($article); if ($result !== false) { $this->success("更新成功!"); } else { $this->ajaxReturn($dbContent->getLastSql()); //DEV //$this->error("添加失败!"); } } }
public function edit_post() { $terms_obj = D("Terms"); if (IS_POST) { $_POST['smeta']['thumb'] = sp_asset_relative_url($_POST['smeta']['thumb']); $_POST['post']['smeta'] = json_encode($_POST['smeta']); unset($_POST['post']['post_author']); $result = $this->posts_obj->save($_POST['post']); if ($result !== false) { // $this->success("保存成功!"); //$this->success(json_encode($_POST['meta'])); } else { $this->error("保存失败!"); } } }