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


PHP ET::tagsModel方法代码示例

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


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

示例1: action_editPost

 /**
  * Edit a post.
  *
  * @param int $postId The post ID.
  * @return void
  */
 public function action_editPost($postId = false)
 {
     if (!($post = $this->getPostForEditing($postId))) {
         return;
     }
     // Set up a form.
     $form = ETFactory::make("form");
     $form->action = URL("conversation/editPost/" . $post["postId"]);
     $form->setValue("content", $post["content"]);
     if ($form->isPostBack("cancel")) {
         $this->redirect(URL(R("return", postURL($postId))));
     }
     // Are we saving the post?
     if ($form->validPostBack("save")) {
         ET::postModel()->editPost($post, $form->getValue("content"));
         // タグ情報の更新処理
         $mainPostFlg = $post["mainPostFlg"];
         ET::tagsModel()->editPost($post["conversationId"], $mainPostFlg, $form->getValue("tags"));
         $this->trigger("editPostAfter", array(&$post));
         // Normally, redirect back to the conversation.
         if ($this->responseType === RESPONSE_TYPE_DEFAULT) {
             redirect(URL(R("return", postURL($postId))));
         } elseif ($this->responseType === RESPONSE_TYPE_AJAX) {
             $this->data("post", $this->formatPostForTemplate($post, $post["conversation"]));
             if ($mainPostFlg) {
                 // タグリスト出力用
                 $this->data("tags", ET::tagsModel()->getTagsInfo($post["conversationId"]));
             }
             $this->render("conversation/post", "conversation/tagsPath");
             return;
         } else {
             // JSON?
         }
     }
     $this->data("form", $form);
     $this->data("post", $post);
     $this->data("controls", $this->getEditControls("p" . $post["postId"]));
     $this->render("conversation/editPost");
 }
开发者ID:m-mori,项目名称:forum,代码行数:45,代码来源:ETConversationController.class.php

示例2: getConversationIDs


//.........这里部分代码省略.........
     // and so on, until we have a list of IDs to pass to the final query.
     $goodConversationIDs = array();
     $badConversationIDs = array();
     $idCondition = "";
     foreach ($this->idFilters as $v) {
         list($sql, $negate) = $v;
         // Apply the list of good IDs to the query.
         $sql->where($idCondition);
         // Get the list of conversation IDs so that the next condition can use it in its query.
         $result = $sql->exec();
         $ids = array();
         while ($row = $result->nextRow()) {
             $ids[] = (int) reset($row);
         }
         // If this condition is negated, then add the IDs to the list of bad conversations.
         // If the condition is not negated, set the list of good conversations to the IDs, provided there are some.
         if ($negate) {
             $badConversationIDs = array_merge($badConversationIDs, $ids);
         } elseif (count($ids)) {
             $goodConversationIDs = $ids;
         } else {
             return false;
         }
         // Strip bad conversation IDs from the list of good conversation IDs.
         if (count($goodConversationIDs)) {
             $goodConversationIds = array_diff($goodConversationIDs, $badConversationIDs);
             if (!count($goodConversationIDs)) {
                 return false;
             }
         }
         // This will be the condition for the next query that restricts or eliminates conversation IDs.
         if (count($goodConversationIDs)) {
             $idCondition = "conversationId IN (" . implode(",", $goodConversationIDs) . ")";
         } elseif (count($badConversationIDs)) {
             $idCondition = "conversationId NOT IN (" . implode(",", $badConversationIDs) . ")";
         }
     }
     // Reverse the order if necessary - swap DESC and ASC.
     if ($this->orderReverse) {
         foreach ($this->orderBy as $k => $v) {
             $this->orderBy[$k] = strtr($this->orderBy[$k], array("DESC" => "ASC", "ASC" => "DESC"));
         }
     }
     // Now check if there are any fulltext keywords to filter by.
     $cnt = count($this->fulltext);
     if ($cnt > 0) {
         // タグID取得
         $tagsIds = ET::tagsModel()->getTagsIds($this->fulltext);
         // 投稿のタイトル・本文・コメントをLIKE(部分一致)検索する
         // タグを完全一致検索する
         // 下書きは検索しない
         $this->sql->from("post p", "p.conversationId=c.conversationId", "left");
         $this->sql->where("c.countPosts > 0");
         $strWhere = "";
         for ($i = 0; $i < $cnt; $i++) {
             $val = $this->fulltext[$i];
             $param = ":text" . $i;
             if ($i != 0) {
                 $strWhere .= " OR ";
             }
             $strWhere .= "c.title LIKE " . $param . " OR p.content LIKE " . $param;
             $this->sql->bind($param, '%' . $val . '%');
         }
         if (is_array($tagsIds) && count($tagsIds)) {
             // タグIDがある場合
             $this->sql->from("conversation_tags t", "t.conversationId=c.conversationId", "left");
             $strWhere .= " OR (t.tag0 IN (:tagsIds) OR t.tag1 IN (:tagsIds) OR t.tag2 IN (:tagsIds) OR t.tag3 IN (:tagsIds) OR t.tag4 IN (:tagsIds) OR t.tag5 IN (:tagsIds) OR t.tag6 IN (:tagsIds) OR t.tag7 IN (:tagsIds) OR t.tag8 IN (:tagsIds) OR t.tag9 IN (:tagsIds))";
             $this->sql->bind(":tagsIds", $tagsIds);
         }
         $this->sql->where($strWhere);
     }
     // 取得件数設定
     $this->limit = $searchLimit;
     // Set a default limit if none has previously been set.
     if (!$this->limit) {
         $this->limit = C("esoTalk.search.limit");
     }
     // Finish constructing the final query using the ID whitelist/blacklist we've come up with.
     // Get one more result than we'll actually need so we can see if there are "more results."
     if ($idCondition) {
         $this->sql->where($idCondition);
     }
     $this->sql->orderBy($this->orderBy)->limit($this->limit + 1);
     // Make sure conversations that the user isn't allowed to see are filtered out.
     ET::conversationModel()->addAllowedPredicate($this->sql);
     // Execute the query, and collect the final set of conversation IDs.
     $result = $this->sql->exec();
     $conversationIDs = array();
     while ($row = $result->nextRow()) {
         $conversationIDs[] = reset($row);
     }
     // If there's one more result than we actually need, indicate that there are "more results."
     if (count($conversationIDs) == $this->limit + 1) {
         array_pop($conversationIDs);
         if ($this->limit < C("esoTalk.search.limitMax")) {
             $this->areMoreResults = true;
         }
     }
     return count($conversationIDs) ? $conversationIDs : false;
 }
开发者ID:m-mori,项目名称:forum,代码行数:101,代码来源:ETSearchModel.class.php


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