From b3d76d795c14b27334be23f50ec1df3ad51da17f Mon Sep 17 00:00:00 2001 From: wangchunsheng Date: Mon, 30 Apr 2012 07:58:00 +0000 Subject: [PATCH] * only set image size when view a story. * fix the bug when change a story with images. --- module/story/control.php | 2 +- module/story/model.php | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/module/story/control.php b/module/story/control.php index 97231ed3b7..02864f704d 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -348,7 +348,7 @@ class story extends control { $this->loadModel('action'); $storyID = (int)$storyID; - $story = $this->story->getById($storyID, $version); + $story = $this->story->getById($storyID, $version, true); if(!$story) die(js::error($this->lang->notFound) . js::locate('back')); $story->files = $this->loadModel('file')->getByObject('story', $storyID); diff --git a/module/story/model.php b/module/story/model.php index 01e7284b20..8e84f07064 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -18,10 +18,11 @@ class storyModel extends model * * @param int $storyID * @param int $version + * @param bool $setImgSize * @access public * @return object|bool */ - public function getById($storyID, $version = 0) + public function getById($storyID, $version = 0, $setImgSize = false) { $story = $this->dao->findById((int)$storyID)->from(TABLE_STORY)->fetch(); if(!$story) return false; @@ -29,8 +30,12 @@ class storyModel extends model if($version == 0) $version = $story->version; $spec = $this->dao->select('title,spec,verify')->from(TABLE_STORYSPEC)->where('story')->eq($storyID)->andWhere('version')->eq($version)->fetch(); $story->title = isset($spec->title) ? $spec->title : ''; - $story->spec = isset($spec->spec) ? $this->loadModel('file')->setImgSize($spec->spec) : ''; + $story->spec = isset($spec->spec) ? $spec->spec : ''; $story->verify = isset($spec->verify) ? $spec->verify : ''; + + if($setImgSize) $story->spec = $this->loadModel('file')->setImgSize($story->spec); + if($setImgSize) $story->verify = $this->file->setImgSize($story->verify); + $story->projects = $this->dao->select('t1.project, t2.name, t2.status') ->from(TABLE_PROJECTSTORY)->alias('t1') ->leftJoin(TABLE_PROJECT)->alias('t2') @@ -252,11 +257,14 @@ class storyModel extends model */ public function change($storyID) { - $now = helper::now(); - $oldStory = $this->getById($storyID); $specChanged = false; - if($this->post->spec != $oldStory->spec or $this->post->verify != $oldStory->verify or $this->post->title != $oldStory->title or $this->loadModel('file')->getCount()) $specChanged = true; + $oldStory = $this->getById($storyID); + $newTitle = stripslashes($this->post->title); + $newSpec = stripslashes($this->post->spec); + $newVerify = stripslashes($this->post->verify); + if($newSpec != $oldStory->spec or $newVerify != $oldStory->verify or $newTitle != $oldStory->title or $this->loadModel('file')->getCount()) $specChanged = true; + $now = helper::now(); $story = fixer::input('post') ->stripTags('title') ->callFunc('title', 'trim')