本文整理匯總了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);
}
}