本文整理汇总了PHP中zmf::pinyin方法的典型用法代码示例。如果您正苦于以下问题:PHP zmf::pinyin方法的具体用法?PHP zmf::pinyin怎么用?PHP zmf::pinyin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zmf
的用法示例。
在下文中一共展示了zmf::pinyin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findAndAdd
public static function findAndAdd($title, $classify, $logid)
{
$title = zmf::filterInput($title, 't', 1);
if (!$title) {
return false;
}
$info = Tags::model()->find('title=:title AND classify=:classify', array(':title' => $title, ':classify' => $classify));
if (!$info) {
if (Yii::app()->session['checkHasBadword'] == 'yes') {
$status = Posts::STATUS_STAYCHECK;
} else {
$status = Posts::STATUS_PASSED;
}
unset(Yii::app()->session['checkHasBadword']);
$_data = array('title' => $title, 'name' => zmf::pinyin($title), 'classify' => $classify, 'status' => $status, 'cTime' => time(), 'length' => mb_strlen($title, 'GBK'));
$modelB = new Tags();
$modelB->attributes = $_data;
if ($modelB->save()) {
$tagid = $modelB->id;
}
} else {
$tagid = $info['id'];
}
if ($tagid && $logid) {
$_info = TagRelation::model()->find('tagid=:tagid AND logid=:logid AND classify=:classify', array(':tagid' => $tagid, ':logid' => $logid, ':classify' => $classify));
if (!$_info) {
$_tagre = array('tagid' => $tagid, 'logid' => $logid, 'classify' => $classify, 'cTime' => zmf::now());
$modelC = new TagRelation();
$modelC->attributes = $_tagre;
$modelC->save();
}
}
return $tagid;
}
示例2: checkAndWriteTag
/**
* 检查传入的标签是否已存在,不存在则创建,并检查是否已存在对应关系,不存在则创建
* @param type $id
* @param type $crumb
*/
public function checkAndWriteTag($id, $crumb, $tagid = 0)
{
if (!$tagid) {
$_crumb = strip_tags(trim($crumb));
$_taginfo = Tags::model()->find('title=:title', array(':title' => $_crumb));
if (!$_taginfo) {
$_tagdata = array('title' => $_crumb, 'name' => zmf::pinyin($_crumb), 'classify' => 'posts', 'cTime' => time(), 'status' => 1);
$model_tag = new Tags();
$model_tag->attributes = $_tagdata;
$_tagid = $model_tag->save(false);
} else {
$_tagid = $_taginfo['id'];
}
} else {
$_tagid = $tagid;
}
$_tagrel = array('logid' => $id, 'tagid' => $_tagid, 'classify' => 'posts');
$reinfo = TagRelation::model()->find('logid=:logid AND tagid=:tagid AND classify="posts"', array(':logid' => $id, ':tagid' => $_tagid));
if (!$reinfo) {
$model_tagrel = new TagRelation();
$model_tagrel->attributes = $_tagrel;
$model_tagrel->save(false);
}
}