当前位置: 首页>>代码示例>>PHP>>正文


PHP Tag::model方法代码示例

本文整理汇总了PHP中Tag::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::model方法的具体用法?PHP Tag::model怎么用?PHP Tag::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tag的用法示例。


在下文中一共展示了Tag::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     $tags = Tag::model()->findAll();
     if ($tags) {
         foreach ($tags as $tag) {
             $post = Post::model()->findAll("FIND_IN_SET(:tag, tags)", array(':tag' => $tag->tag_name));
             $image = Image::model()->findAll("FIND_IN_SET(:tag, tags)", array(':tag' => $tag->tag_name));
             $soft = Soft::model()->findAll("FIND_IN_SET(:tag, seo_keywords)", array(':tag' => $tag->tag_name));
             $video = Video::model()->findAll("FIND_IN_SET(:tag, seo_keywords)", array(':tag' => $tag->tag_name));
             if (!$post && !$image && !$soft && !$video) {
                 $tag->delete();
             } else {
                 $tag->data_count = count($post) + count($image) + count($soft);
                 $tag->save();
             }
         }
     }
     $tagdatas = TagData::model()->findAll();
     if ($tagdatas) {
         foreach ($tagdatas as $value) {
             $modelType = ModelType::model()->findByPk($value->type);
             $model = $modelType->model;
             $data = $model::model()->findByPk($value->content_id);
             if (!$data) {
                 $value->delete();
             }
         }
     }
     $this->controller->message('success', Yii::t('admin', 'Reset Tags Success'), $this->controller->createUrl('index'));
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:30,代码来源:ResetAction.php

示例2: run

    public function run()
    {
        /* @var WebUser $webUser */
        /** @noinspection PhpUndefinedFieldInspection */
        $webUser = Yii::app()->user;

        $models = Tag::model()->userId($webUser->id)->findAll();
        $tagCount = EntryHasTag::model()->userId($webUser->id)->count();

        $tags = array();
        foreach ($models as $model) {
            /* @var Tag $model */

            $entryCount = 0;
            foreach ($model->entries as $entry) {
                if ($entry->userId == $webUser->id) {
                    $entryCount++;
                }
            }

            if ($entryCount > 0) {
                $tags[] = array(
                    'name' => $model->name,
                    'weight' => ceil($entryCount / $tagCount * 10)
                );
            }
        }

        $this->render('cloud', array('tags' => $tags));
    }
开发者ID:hersoncruz,项目名称:ppma,代码行数:30,代码来源:TagCloudWidget.php

示例3: suggestTags

 /**
  * Suggest Tags for Object
  * @param type $keyword 
  */
 public function suggestTags($keyword)
 {
     $tags = Tag::model()->suggestTags($keyword);
     if ($tags !== array()) {
         echo implode("\n", $tags);
     }
 }
开发者ID:pramana08,项目名称:GXC-CMS-2,代码行数:11,代码来源:ObjectExtraWorkWidget.php

示例4: resaveTags

    /**
     * @return void
     */
    public function resaveTags()
    {
        // delete all tag relations
        $this->deleteTags();

        // save tags and tag relations
        foreach ($this->tags as $tag) {
            /* @var WebUser $webUser */
            /** @noinspection PhpUndefinedFieldInspection */
            $webUser = Yii::app()->user;

            // try to receive tag from db
            $model = Tag::model()->name($tag->name)->userId($webUser->id)->find();

            if (!is_object($model)) {
                $model = $tag;
            }

            // save tag
            $model->name = $tag->name;
            $model->save();

            // save relation
            $relation = new EntryHasTag();
            $relation->entryId = $this->id;
            $relation->tagId = $model->id;
            $relation->save();
        }
    }
开发者ID:hersoncruz,项目名称:ppma,代码行数:32,代码来源:Entry.php

示例5: upgradeTo02

 /**
  * @return void
  */
 protected function upgradeTo02()
 {
     // Add Tag-column
     /* @var CDbCommand $cmd */
     $cmd = Yii::app()->db->createCommand();
     $cmd->addColumn('Tag', 'userId', 'integer NOT NULL');
     $cmd->addForeignKey('user', 'Tag', 'userId', 'User', 'id', 'CASCADE', 'CASCADE');
     // Refresh DB-Schema
     Yii::app()->db->schema->refresh();
     Tag::model()->refreshMetaData();
     // Set user-IDs
     foreach (Tag::model()->findAll() as $model) {
         // Collect User-IDs
         $userIds = array();
         foreach ($model->entries as $entry) {
             $userIds[$entry->userId] = $entry->userId;
         }
         // Save tag with user relation
         foreach ($userIds as $userId) {
             $tag = new Tag();
             $tag->name = $model->name;
             $tag->userId = $userId;
             $tag->save(false);
         }
         // Remove tag
         $model->delete();
     }
 }
开发者ID:humantech,项目名称:ppma,代码行数:31,代码来源:UpgradeController.php

示例6: setTagsArray

 public function setTagsArray(array $data)
 {
     // reset dei tag per semplificare lo script
     ProductTag::model()->deleteAll('product=:p', array(':p' => $this->id));
     // data attuale
     $now = new DateTime();
     $timestamp = $now->format('Y-m-d H-i-s');
     // ricerca dei tag e creazione dei link
     foreach ($data as $tagName) {
         $tag = Tag::model()->find('name=:nm', array(':nm' => $tagName));
         /** @var Tag $tag */
         if ($tag == null) {
             $tag = new Tag();
             $tag->name = $tagName;
             $tag->description = ucwords($tagName);
             $tag->timestamp = $timestamp;
             $tag->insert();
         }
         $productTag = ProductTag::model()->find('product=:p AND tag=:t', array(':p' => $this->id, ':t' => $tag->id));
         /** @var ProductTag $productTag */
         if ($productTag == null) {
             $productTag = new ProductTag();
             $productTag->product = $this->id;
             $productTag->tag = $tag->id;
             $productTag->insert();
         }
     }
 }
开发者ID:KuRLiC,项目名称:PHPTest,代码行数:28,代码来源:Product.php

示例7: actionWrite

 public function actionWrite()
 {
     $post = new Post();
     $post->blog_id = Yii::app()->getRequest()->getParam('blog-id');
     if ($postId = (int) Yii::app()->getRequest()->getQuery('id')) {
         $post = Post::model()->findUserPost($postId, Yii::app()->getUser()->getId());
         if ($post === null) {
             throw new CHttpException(404);
         }
     }
     if (Yii::app()->getRequest()->getIsPostRequest() && !empty($_POST['Post'])) {
         $data = Yii::app()->getRequest()->getPost('Post');
         $data['user_id'] = Yii::app()->getUser()->getId();
         $data['status'] = Yii::app()->getRequest()->getPost('draft', Post::STATUS_PUBLISHED);
         $data['tags'] = Yii::app()->getRequest()->getPost('tags');
         if ($post->createPublicPost($data)) {
             $message = Yii::t('BlogModule.blog', 'Post sent for moderation!');
             $redirect = ['/blog/publisher/my'];
             if ($post->isDraft()) {
                 $message = Yii::t('BlogModule.blog', 'Post saved!');
             }
             if ($post->isPublished()) {
                 $message = Yii::t('BlogModule.blog', 'Post published!');
                 $redirect = ['/blog/post/view', 'slug' => $post->slug];
             }
             Yii::app()->getUser()->setFlash(\yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, $message);
             $this->redirect($redirect);
         }
     }
     $this->render('write', ['post' => $post, 'blogs' => (new Blog())->getListForUser(Yii::app()->getUser()->getId()), 'tags' => array_values(CHtml::listData(Tag::model()->findAll(), 'id', 'name'))]);
 }
开发者ID:syrexby,项目名称:domovoishop.by,代码行数:31,代码来源:PublisherController.php

示例8: afterSave

 public function afterSave($event)
 {
     $model_id = get_class($this->owner);
     if (!isset($_POST[$model_id]['tags'])) {
         return true;
     }
     $tags = explode(',', $_POST[$model_id]['tags']);
     $ids = [];
     foreach ($tags as $tag_name) {
         $tag = Tag::model()->findByAttributes(['name' => $tag_name]);
         if (!$tag) {
             continue;
         }
         $ids[] = $tag->id;
         $exists = TagRel::model()->existsByAttributes(['tag_id' => $tag->id, 'object_id' => $this->owner->id, 'model_id' => $model_id]);
         if ($exists) {
             continue;
         }
         $tag_rel = new TagRel();
         $tag_rel->tag_id = $tag->id;
         $tag_rel->object_id = $this->owner->id;
         $tag_rel->model_id = $model_id;
         $tag_rel->save();
     }
     $this->_deleteRels($ids);
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:26,代码来源:TagBehavior.php

示例9: run

 public function run()
 {
     $criteria = new CdbCriteria();
     $criteria->limit = $this->data('limit');
     $criteria->offset = $this->data('offset');
     $criteria->condition = "post_status='publish' AND (post_modified <= '" . date('Y-m-d H:i:s') . "' AND post_modified >= '" . $this->data('time') . "')";
     $criteria->order = 'post_hits DESC';
     if ($this->data('autoByTerm')) {
         if (isset($_GET['id'])) {
             $category = Category::model()->findByPK((int) $_GET['id']);
             $label = Label::model()->findByPK((int) $_GET['id']);
             $topic = Topic::model()->findByPK((int) $_GET['id']);
             $tag = Tag::model()->findByPK((int) $_GET['id']);
             if ($category != null) {
                 $criteria = $this->getCriteriaTerm('categories', $criteria);
             } elseif ($label != null) {
                 $criteria = $this->getCriteriaTerm('labels', $criteria);
             } elseif ($topic != null) {
                 $criteria = $this->getCriteriaTerm('topics', $criteria);
             } elseif ($tag != null) {
                 $criteria = $this->getCriteriaTerm('tags', $criteria);
             }
         }
     }
     $model = Post::model()->findAll($criteria);
     if ($model != null) {
         $this->layout($model);
     }
 }
开发者ID:beckblurry,项目名称:Yii1-Base-Core-V.Alpha.1,代码行数:29,代码来源:widget_terpopuler.php

示例10: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Request();
     $modelJoin = new RequestJoinForm();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Request'], $_POST['RequestJoinForm'])) {
         $model->attributes = $_POST['Request'];
         $modelJoin->attributes = $_POST['RequestJoinForm'];
         $transaction = Yii::app()->db->beginTransaction();
         try {
             $model->save();
             if (isset($_POST['tags'])) {
                 $tags = Tag::model()->string2array($_POST['tags']);
                 foreach ($tags as $tagName) {
                     $tag = Tag::model()->findOrCreate($tagName);
                     $requestToTag = new RequestToTag();
                     $requestToTag->Request_ID = $model->Request_ID;
                     $requestToTag->Tag_ID = $tag->Tag_ID;
                     $requestToTag->save();
                 }
             }
             $modelJoin->request_ID = $model->Request_ID;
             $modelJoin->user_ID = $model->Create_User_ID;
             $modelJoin->save();
             $transaction->commit();
             $this->redirect(array('view', 'id' => $model->Request_ID));
         } catch (Exception $e) {
             $transaction->rollback();
         }
     }
     $this->render('create', array('model' => $model, 'modelJoin' => $modelJoin));
 }
开发者ID:noahkim,项目名称:kowop,代码行数:37,代码来源:RequestController.php

示例11: getByUserIdAndFileId

 /**
  * 根据用户ID与文件ID获得标签
  */
 public function getByUserIdAndFileId($userId, $fileId)
 {
     $condition = 'id in (select tag_id from ' . FileTag::model()->tableName();
     $condition .= ' where file_id=:file_id) and user_id in(0,:user_id)';
     $items = Tag::model()->findAll($condition, array(':file_id' => $fileId, ':user_id' => $userId));
     return $this->db2list($items);
 }
开发者ID:youngsun45,项目名称:miniyun,代码行数:10,代码来源:MiniTag.php

示例12: run

 public function run()
 {
     $config = new CConfiguration(Yii::app()->basePath . '/config/pager.php');
     $session = Yii::app()->session;
     $cookies = Yii::app()->request->cookies;
     // If referrer is not our action delete search parameters from session.
     if (strpos(Yii::app()->request->urlReferrer, '/tag/list') === false) {
         unset($session['search']);
     }
     if (!empty($_POST['search']) && is_array($_POST['search'])) {
         $search = $_POST['search'];
         $session['search'] = $search;
     } else {
         if (!empty($session['search'])) {
             $search = $session['search'];
         } else {
             $search = array('name' => '');
         }
     }
     $criteria = new CDbCriteria();
     $criteria->condition = 'name LIKE :name';
     $criteria->params = array(':name' => "%{$search['name']}%");
     $criteria->order = 'name';
     $pages = new CPagination(Tag::model()->count($criteria));
     $config->applyTo($pages);
     $pages->applyLimit($criteria);
     $tags = Tag::model()->with('quotesCount')->findAll($criteria);
     $showSearchForm = !empty($cookies['showSearchForm']) && $cookies['showSearchForm']->value ? true : false;
     $this->controller->render('list', array('tags' => $tags, 'pages' => $pages, 'search' => $search, 'showSearchForm' => $showSearchForm));
 }
开发者ID:vchimishuk,项目名称:itquotes,代码行数:30,代码来源:ListAction.php

示例13: testRemove

 public function testRemove()
 {
     $tag = 'iphone';
     $data = array('site_id' => TagSite::getSiteId('ent'), 'news_id' => ArticleTags::genId(1), 'type' => 1, 'time' => util_time(7));
     $tag_id = Tag::model()->fetch($tag)->id;
     $count = TagArticles::model()->count($tag_id);
     $this->assertEquals(2, $count);
     $count = TagArticles::model()->count($tag_id, $data['site_id']);
     $this->assertEquals(1, $count);
     $count = TagArticles::model()->count($tag_id, 0, $data['type']);
     $this->assertEquals(1, $count);
     $count = TagArticles::model()->count($tag_id, $data['site_id'], $data['type']);
     $this->assertEquals(1, $count);
     $result = TagArticles::model()->removeIndex($tag_id, $data);
     //$this->assertTrue($result);
     $count = TagArticles::model()->count($tag_id);
     $this->assertEquals(1, $count);
     $count = TagArticles::model()->count($tag_id, $data['site_id']);
     $this->assertEquals(0, $count);
     $count = TagArticles::model()->count($tag_id, 0, $data['type']);
     $this->assertEquals(0, $count);
     $count = TagArticles::model()->count($tag_id, $data['site_id'], $data['type']);
     $this->assertEquals(0, $count);
     $result = TagArticles::model()->index($tag_id, $data);
     //$this->assertTrue($result);
 }
开发者ID:reedboat,项目名称:TagProject,代码行数:26,代码来源:TagArticleTest.php

示例14: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $question = new Question();
     if (isset($_POST['Question'])) {
         $this->forcePostRequest();
         $_POST = Yii::app()->input->stripClean($_POST);
         $question->attributes = $_POST['Question'];
         $question->content->populateByForm();
         $question->post_type = "question";
         if ($question->validate()) {
             $question->save();
             if (isset($_POST['Tags'])) {
                 // Split tag string into array
                 $tags = explode(", ", $_POST['Tags']);
                 foreach ($tags as $tag) {
                     $tag = Tag::model()->firstOrCreate($tag);
                     $question_tag = new QuestionTag();
                     $question_tag->question_id = $question->id;
                     $question_tag->tag_id = $tag->id;
                     $question_tag->save();
                 }
             }
             $this->redirect($this->createUrl('//questionanswer/question/view', array('id' => $question->id)));
         }
     }
     $this->render('create', array('model' => $question));
 }
开发者ID:tejrajs,项目名称:humhub-modules-questionanswer,代码行数:31,代码来源:QuestionController.php

示例15: actionIndex

 /**
  * 首页
  */
 public function actionIndex()
 {
     $catalog_id = trim($this->_request->getParam('catalog_id'));
     $keyword = trim($this->_request->getParam('keyword'));
     //获取子孙分类(包括本身)
     $data = Catalog::model()->getChildren($catalog_id);
     $catalog = $data['catalog'];
     $db_in_ids = $data['db_in_ids'];
     //SEO
     $navs = array();
     if ($catalog) {
         $this->_seoTitle = $catalog->seo_title ? $catalog->seo_title : $catalog->catalog_name . ' - ' . $this->_setting['site_name'];
         $this->_seoKeywords = $catalog->seo_keywords;
         $this->_seoDescription = $catalog->seo_description;
         $navs[] = array('url' => $this->createUrl('image/index', array('catalog_id' => $catalog->id)), 'name' => $catalog->catalog_name);
     } else {
         $seo = ModelType::getSEO('image');
         $this->_seoTitle = $seo['seo_title'] . ' - ' . $this->_setting['site_name'];
         $this->_seoKeywords = $seo['seo_keywords'];
         $this->_seoDescription = $seo['seo_description'];
         $navs[] = array('url' => $this->_request->getUrl(), 'name' => $this->_seoTitle);
     }
     //获取所有符合条件的图集
     $condition = '';
     $catalog && ($condition .= ' AND catalog_id IN (' . $db_in_ids . ')');
     $datalist = Image::model()->getList(array('condition' => $condition, 'limit' => 15, 'order' => $order_by, 'page' => true), $pages);
     //标签
     $tags = Tag::model()->findAll(array('order' => 'data_count DESC', 'limit' => 20));
     //最近的图集
     $last_images = Image::model()->getList(array('condition' => $condition, 'limit' => 10));
     //加载css,js
     Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/list.css");
     Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js");
     $this->render('index', array('navs' => $navs, 'datalist' => $datalist, 'pagebar' => $pages, 'tags' => $tags, 'last_images' => $last_images));
 }
开发者ID:SallyU,项目名称:yiicms,代码行数:38,代码来源:ImageController.php


注:本文中的Tag::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。