當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Tags::addRelation方法代碼示例

本文整理匯總了PHP中Tags::addRelation方法的典型用法代碼示例。如果您正苦於以下問題:PHP Tags::addRelation方法的具體用法?PHP Tags::addRelation怎麽用?PHP Tags::addRelation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Tags的用法示例。


在下文中一共展示了Tags::addRelation方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionUpdate

 public function actionUpdate($type)
 {
     if (!in_array($type, array('info', 'passwd', 'tags'))) {
         $this->message(0, '您的操作有誤');
     }
     if (isset($_POST) and !empty($_POST)) {
         $model = new Users();
         if ($type == 'info') {
             $intoData['truename'] = zmf::filterInput($_POST['truename'], 't', 1);
             if (!$intoData['truename']) {
                 $this->message(0, '用戶名不能為空');
             }
             //如果用戶修改了用戶名,則判斷是否被使用
             if ($intoData['truename'] != $this->userInfo['truename']) {
                 $info = Users::getInfoByName($intoData['truename']);
                 if ($info) {
                     $this->message(0, '該用戶名已被使用');
                 }
             }
             $intoData['sex'] = tools::val('sex');
             $intoData['areaid'] = tools::val('areaid');
             $intoData['content'] = zmf::filterInput($_POST['desc'], 't', 1);
         } elseif ($type == 'passwd') {
             $old = zmf::filterInput($_POST['old_password'], 't', 1);
             $info = Users::model()->findByPk($this->uid);
             if (!$old) {
                 $this->message(0, '請輸入原始密碼');
             } elseif (md5($old) != $info['password']) {
                 $this->message(0, '原始密碼不正確');
             }
             if (!$_POST['password']) {
                 $this->message(0, '請輸入密碼');
             } elseif (strlen($_POST['password']) < 5) {
                 $this->message(0, '新密碼過短,請重新輸入');
             }
             $intoData['password'] = md5($_POST['password']);
         } elseif ($type == 'tags') {
             //相關標簽
             $tags = $_POST['tagnames'];
             $tags = !empty($tags) ? array_unique(array_filter($tags)) : array();
             $tagids = array();
             if (!empty($tags)) {
                 foreach ($tags as $str) {
                     $_tmp = explode('-', $str);
                     if ($_tmp[1] > 0) {
                         //添加對應關係
                         if (Tags::addRelation($_tmp[1], $this->uid, 'user')) {
                             $tagids[] = $_tmp[1];
                         }
                     } else {
                         //查找是否有對應話題
                         $_tagid = Tags::findAndAdd($_tmp[0], 'user', $this->uid);
                         if ($_tagid) {
                             $tagids[] = $_tagid;
                         }
                     }
                 }
                 $tagids = !empty($tagids) ? array_unique(array_filter($tagids)) : array();
             }
             $tagStr = join(',', $tagids);
             $intoData['tagids'] = $tagStr;
         }
         zmf::delFCache("userInfo-{$this->uid}");
         if ($model->updateByPk($this->uid, $intoData)) {
             $this->message(1, '修改成功', Yii::app()->createUrl('users/config'));
         } else {
             $this->message(1, '修改成功', Yii::app()->createUrl('users/config'));
         }
     }
     $suggestTags = array();
     if ($type == 'tags') {
         //推薦的標簽
         $suggestTags = Tags::getTops('posts');
     }
     $data = array('info' => $this->userInfo, 'type' => $type, 'suggestTags' => $suggestTags);
     $this->render('update', $data);
 }
開發者ID:ph7pal,項目名稱:wedding,代碼行數:77,代碼來源:UsersController.php

示例2: actionCreate

 public function actionCreate($id = '')
 {
     $this->layout = 'common';
     $id = zmf::myint($id);
     if (!$this->uid) {
         $this->redirect(array('site/login'));
     }
     if ($id) {
         $model = $this->loadModel($id);
         $isNew = false;
     } else {
         $model = new Posts();
         $isNew = true;
     }
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'posts-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     if (isset($_POST['Posts'])) {
         //處理文本
         $filter = Posts::handleContent($_POST['Posts']['content']);
         $_POST['Posts']['content'] = $filter['content'];
         if (!empty($filter['attachids'])) {
             $attkeys = array_filter(array_unique($filter['attachids']));
             if (!empty($attkeys)) {
                 $_POST['Posts']['faceimg'] = $attkeys[0];
                 //默認將文章中的第一張圖作為封麵圖
             }
         } else {
             $_POST['Posts']['faceimg'] = '';
             //否則將封麵圖置為空(有可能編輯後沒有圖片了)
         }
         if (!$_POST['Posts']['mapZoom']) {
             //沒有縮放級別則認為用戶隻是點開看了一下
             $_POST['Posts']['lat'] = $_POST['Posts']['long'] = '';
         }
         $tagids = array_unique(array_filter($_POST['tags']));
         $model->attributes = $_POST['Posts'];
         if ($model->save()) {
             //將上傳的圖片置為通過
             Attachments::model()->updateAll(array('status' => Posts::STATUS_DELED), 'logid=:logid AND classify=:classify', array(':logid' => $model->id, ':classify' => 'posts'));
             if (!empty($attkeys)) {
                 $attstr = join(',', $attkeys);
                 if ($attstr != '') {
                     Attachments::model()->updateAll(array('status' => Posts::STATUS_PASSED, 'logid' => $model->id), 'id IN(' . $attstr . ')');
                 }
             }
             //處理標簽
             $intoTags = array();
             if (!empty($tagids)) {
                 foreach ($tagids as $tagid) {
                     $_info = Tags::addRelation($tagid, $model->id, 'posts');
                     if ($_info) {
                         $intoTags[] = $tagid;
                     }
                 }
             }
             if (!$isNew || !empty($intoTags)) {
                 Posts::model()->updateByPk($model->id, array('tagids' => join(',', $intoTags)));
             }
             if ($model->status == Posts::STATUS_NOTPASSED) {
                 $this->redirect(array('posts/index'));
             } else {
                 $this->redirect(array('/posts/view', 'id' => $model->id));
             }
         }
     }
     $tags = Tags::getClassifyTags('posts');
     $postTags = array();
     if (!$isNew) {
         $postTags = Tags::getByIds($model->tagids);
     }
     $this->pageTitle = '與世界分享你的旅行見聞 - ' . zmf::config('sitename');
     $this->render('create', array('model' => $model, 'tags' => $tags, 'postTags' => $postTags));
 }
開發者ID:ph7pal,項目名稱:momo,代碼行數:75,代碼來源:PostsController.php

示例3: actionCreate

 public function actionCreate()
 {
     $model = new WeddingGroup();
     if (isset($_POST['WeddingGroup'])) {
         $model->attributes = $_POST['WeddingGroup'];
         if ($model->save()) {
             //誰創建誰默認屬於本團隊成員
             $glinkAttr = array('groupid' => $model->id, 'uid' => $this->uid, 'isAdmin' => 1);
             $glModel = new GroupLink();
             $glModel->attributes = $glinkAttr;
             $glModel->save();
             //相關標簽
             $tags = $_POST['tagnames'];
             $tags = !empty($tags) ? array_unique(array_filter($tags)) : array();
             $tagids = array();
             if (!empty($tags)) {
                 foreach ($tags as $str) {
                     $_tmp = explode('-', $str);
                     if ($_tmp[1] > 0) {
                         //添加對應關係
                         if (Tags::addRelation($_tmp[1], $model->id, 'wgroup')) {
                             $tagids[] = $_tmp[1];
                         }
                     } else {
                         //查找是否有對應話題
                         $_tagid = Tags::findAndAdd($_tmp[0], 'wgroup', $model->id);
                         if ($_tagid) {
                             $tagids[] = $_tagid;
                         }
                     }
                 }
                 $tagids = !empty($tagids) ? array_unique(array_filter($tagids)) : array();
             }
             $tagStr = join(',', $tagids);
             WeddingGroup::model()->updateByPk($model->id, array('tagids' => $tagStr));
             $this->redirect(array('group/view', 'id' => $model->id));
         }
     }
     //未認證用戶不能創建團隊
     if (!$this->userInfo['creditStatus']) {
         $this->message(0, '請完善資料並提交個人認證', Yii::app()->createurl('users/config', array('type' => 'info')));
     } else {
         //todo,創建的團隊數量限製
     }
     //獲取所有受推薦地區
     $topAreas = Area::getTops(0);
     $areas = CHtml::listData($topAreas, 'id', 'title');
     $suggestTags = Tags::getTops('posts');
     $data = array('model' => $model, 'areas' => $areas, 'suggestTags' => $suggestTags);
     $this->render('create', $data);
 }
開發者ID:ph7pal,項目名稱:wedding,代碼行數:51,代碼來源:GroupController.php

示例4: actionCreate

 /**
  * 已取消其他文章類型,默認為遊記
  * @param type $classify,分類
  */
 public function actionCreate($id = '')
 {
     $id = zmf::filterInput($id);
     if (!zmf::uid()) {
         $this->redirect(array('site/login'));
     }
     if ($id) {
         $model = $this->loadModel($id);
         if ($model->uid != zmf::uid()) {
             if (!Users::checkPower('editpost', false, true)) {
                 throw new CHttpException(403, '不被允許的操作.');
             }
         }
     } else {
         $model = new Posts();
         $model->classify = Posts::CLASSIFY_WEDDING;
         //文章分類
     }
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'posts-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     if (isset($_POST['Posts'])) {
         //判斷是否應被禁止
         //todo,應排除編輯
         //            $forbidInfo = Posts::isForbidden($_POST['Posts']['content'], 'post');
         //            if ($forbidInfo['status'] != Posts::STATUS_PASSED) {
         //                //todo,增加用戶非法操作次數
         //                $_POST['Posts']['status'] = Posts::STATUS_STAYCHECK;
         //            }
         //處理文本
         $filter = Posts::handleContent($_POST['Posts']['content']);
         $_POST['Posts']['content'] = $filter['content'];
         foreach ($_POST['Posts'] as $k => $val) {
             $_POST['Posts'][$k] = zmf::filterInput($val, 't');
         }
         if (Yii::app()->session['checkHasBadword'] == 'yes') {
             $_POST['Posts']['status'] = Posts::STATUS_STAYCHECK;
         }
         if (!$model->isNewRecord) {
             $_POST['Posts']['updateTime'] = zmf::now();
             $isNew = false;
         } else {
             $isNew = true;
         }
         unset(Yii::app()->session['checkHasBadword']);
         if (!empty($filter['attachids'])) {
             $attkeys = array_filter(array_unique($filter['attachids']));
             if (!empty($attkeys)) {
                 $_POST['Posts']['faceimg'] = $attkeys[0];
                 //默認將文章中的第一張圖作為封麵圖
             }
         } else {
             $_POST['Posts']['faceimg'] = '';
             //否則將封麵圖置為空(有可能編輯後沒有圖片了)
         }
         //相關標簽
         $tags = $_POST['tagnames'];
         $tags = !empty($tags) ? array_unique(array_filter($tags)) : array();
         $model->attributes = $_POST['Posts'];
         if ($model->save()) {
             //將上傳的圖片置為通過
             Attachments::model()->updateAll(array('status' => Posts::STATUS_DELED), 'logid=:logid AND classify=:classify', array(':logid' => $model->id, ':classify' => 'posts'));
             if (!empty($attkeys)) {
                 $attstr = join(',', $attkeys);
                 if ($attstr != '') {
                     Attachments::model()->updateAll(array('status' => Posts::STATUS_PASSED, 'logid' => $model->id), 'id IN(' . $attstr . ')');
                 }
             }
             //相關標簽
             $tagids = array();
             if (!empty($tags)) {
                 foreach ($tags as $str) {
                     $_tmp = explode('-', $str);
                     if ($_tmp[1] > 0) {
                         //添加對應關係
                         if (Tags::addRelation($_tmp[1], $model->id, 'posts')) {
                             $tagids[] = $_tmp[1];
                         }
                     } else {
                         //查找是否有對應話題
                         $_tagid = Tags::findAndAdd($_tmp[0], 'posts', $model->id);
                         if ($_tagid) {
                             $tagids[] = $_tagid;
                         }
                     }
                 }
                 $tagids = !empty($tagids) ? array_unique(array_filter($tagids)) : array();
                 $tagStr = join(',', $tagids);
                 if ($tagStr != '') {
                     Posts::model()->updateByPk($model->id, array('tagids' => $tagStr));
                 }
             }
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
//.........這裏部分代碼省略.........
開發者ID:ph7pal,項目名稱:wedding,代碼行數:101,代碼來源:PostsController.php


注:本文中的Tags::addRelation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。