本文整理汇总了PHP中Posts::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Posts::validate方法的具体用法?PHP Posts::validate怎么用?PHP Posts::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Posts
的用法示例。
在下文中一共展示了Posts::validate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPostModelValidates
public function testPostModelValidates()
{
//arrange
$post = new Posts();
$post->title = 'GGC Test Post!';
$post->message = 'This is a fake data blah blah blah';
//act
$result = $post->validate();
//assert
$this->assertTrue($result);
}
示例2: addPost
public static function addPost($uid)
{
$model = new Posts();
$colid = zmf::filterInput($_POST['Posts']['colid']);
$_colid = zmf::filterInput($_POST['colid']);
$columnid = zmf::filterInput($_POST['columnid']);
if ($colid == '0' or !$colid) {
$colid = $columnid;
}
if (!$columnid) {
$colid = $_colid;
}
$_POST['Posts']['colid'] = $colid;
$intoData = $_POST['Posts'];
if (!empty($_POST['tagname'])) {
$tagNames = array_unique(array_filter($_POST['tagname']));
}
$intoKeyid = zmf::filterInput($_POST['Posts']['id'], 't', 1);
$intoData['status'] = 1;
$content = $_POST['Posts']['content'];
$pattern = "/<[img|IMG].*?data=[\\'|\"](.*?)[\\'|\"].*?[\\/]?>/i";
preg_match_all($pattern, $content, $match);
if (!empty($match[0])) {
$arr = array();
foreach ($match[0] as $key => $val) {
$_key = $match[1][$key];
$arr[$_key] = $val;
$arr_attachids[] = $match[1][$key];
}
if (!empty($arr)) {
foreach ($arr as $thekey => $imgsrc) {
$content = str_ireplace("{$imgsrc}", '[attach]' . $thekey . '[/attach]', $content);
}
}
}
$attachid = zmf::filterInput($_POST['Posts']['attachid'], 't', 1);
$intoData['content'] = $content;
$intoData['attachid'] = $attachid;
if ($_POST['Posts']['secretinfo'] != '') {
$_POST['Posts']['secretinfo'] = tools::jiaMi($_POST['Posts']['secretinfo']);
}
$model->attributes = $intoData;
if ($model->validate()) {
if ($model->updateByPk($intoKeyid, $intoData)) {
if (!empty($arr_attachids)) {
$ids = join(',', $arr_attachids);
if ($ids != '') {
Attachments::model()->updateAll(array('status' => Posts::STATUS_DELED), "logid={$intoKeyid} AND uid={$uid} AND classify='posts'");
Attachments::model()->updateAll(array('status' => Posts::STATUS_PASSED), "id IN({$ids})");
}
}
zmf::delFCache("notSavePosts{$uid}");
return true;
} else {
$info = $_POST['Posts'];
}
} else {
$info = $_POST['Posts'];
}
return $info;
}