/** * 请求数据检测 * @param $sType 操作类型 add:添加,edit:修改: * @param $iOptype 操作类型 0:保存,1:发布 * @return mixed * */ public function _checkData($sType = 'add', $param = array()) { $aRow = empty($param) ? $this->_getParams() : $param; //保存和发布都需要做的判断 if (!Util_Validate::isCLength($aRow['sTitle'], 5, 22)) { return $this->showMsg('资讯标题长度范围为5到22个字!', false); } if (!empty($param) || $aRow['iOptype'] > 0) { if (!Util_Validate::isCLength($aRow['sShortTitle'], 5, 15)) { return $this->showMsg('短标题长度范围为5到15个字!', false); } if (!Util_Validate::isCLength($aRow['sAuthor'], 2, 20)) { return $this->showMsg('资讯作者长度范围为2到20个字!', false); } if (!Util_Validate::isCLength($aRow['sMedia'], 1, 20)) { return $this->showMsg('媒体来源长度范围为1到20个字!', false); } if (!Util_Validate::isCLength($aRow['sKeyword'], 2, 50)) { return $this->showMsg('关键字长度范围为2到20个字!', false); } if (empty($aRow['sImage'])) { return $this->showMsg('请选择一张默认图片!', false); } if (!Util_Validate::isCLength($aRow['sAbstract'], 60, 90)) { return $this->showMsg('资讯摘要长度范围为60到90个字!', false); } if (!Util_Validate::isCLength($aRow['sContent'], 100, 16777215)) { return $this->showMsg('资讯内容长度范围为100到65535个字!', false); } if ($aRow['iCategoryID'] < 0) { return $this->showMsg('请选择一个资讯分类!', false); } if ($aRow['iPublishTime'] == 0) { $iPublishTime = time(); } if (!Model_Author::getAuthorByName($aRow['sAuthor'])) { return $this->showMsg('作者不存在', false); } /** if (Model_News::EVALUATION_NEWS == $this->_getTypeID()) { if (empty($aRow['sLoupanID'])) { return $this->showMsg('请添加推送楼盘', false); } }*/ if ($aRow['sLoupanID']) { $aLoupanID = explode(',', $aRow['sLoupanID']); foreach ($aLoupanID as $key => $value) { if (!Model_CricUnit::getLoupanByID($value)) { unset($aLoupanID[$key]); $iLouChange = 1; //楼盘ID过滤标记 //return $this->showMsg('推送楼盘不存在', false); } } if (isset($iLouChange)) { $aRow['sLoupanID'] = implode(',', $aLoupanID); } } if ($aRow['sTag']) { $sTag = explode(',', $aRow['sTag']); foreach ($sTag as $key => $value) { $aTag = Model_Tag::getDetail($value); if (empty($aTag) || $aTag['iStatus'] != 1 || $aTag['iTypeID'] != $this->_getTypeTag()) { return $this->showMsg('资讯标签不存在,无效标签名称为(' . $value . ')', false); } } } } //去掉非字段的元素 unset($aRow['iOptype']); return $aRow; }