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


PHP Tag::find_by_name方法代码示例

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


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

示例1: required_params

<?php

required_params('tag_name');
$tag = Tag::find_by_name(Request::$params->tag_name);
if ($tag) {
    $tag->delete();
}
unset(Request::$get_params['tag_name']);
respond_to_success('Tag deleted', array('#index', Request::$get_params));
开发者ID:laiello,项目名称:my-imouto-booru,代码行数:9,代码来源:delete.php

示例2: array

<?php

include '../../inc/init.inc';
if (isset($tag)) {
    $conditions = array('id in (?)', Questions_Tag::find('all', array('conditions' => array('tag_id' => Tag::find_by_name($tag)->id)))->asQuestion_ID());
}
isset($conditions) ? $args['conditions'] = $conditions : ($args['conditions'] = 'title NOT LIKE ""');
$res->total = isset($args) ? Question::count($args) : Question::count();
$res->currentPage = isset($currentPage) ? $currentPage : 1;
$res->limit = $args['limit'] = isset($limit) ? $limit : 7;
$args['offset'] = ($res->currentPage - 1) * $args['limit'];
$args['order'] = isset($order) ? $order : 'created_at desc';
$res->questions = Question::all($args);
$res->tags = Tag::find('all', array('order' => 'Rand()', 'limit' => 20));
if (!isset($infos)) {
    $infos = array();
}
$res->search_opts = array(0 => array('label' => 'Quelle question vous posez vous ?', 'field' => 'title', 'type' => 'text', 'class' => 'xxlarge'));
$res->useTemplate("Questions - Reponses", $infos);
开发者ID:Osin,项目名称:Intranet,代码行数:19,代码来源:q2a.php

示例3:

<?php

if (!empty(Request::$params->tag['name'])) {
    $tag = Tag::find_by_name(Request::$params->tag['name']);
    if ($tag) {
        $tag->update_attributes(Request::$params->tag);
    }
}
respond_to_success("Tag updated", '#index');
开发者ID:laiello,项目名称:my-imouto-booru,代码行数:9,代码来源:update.php

示例4: find_related

 static function find_related($tags)
 {
     if (is_array($tags) && count($tags) > 1) {
         return $this->calculate_related($tags);
     } elseif (($tags = current($tags)) && !empty($tags)) {
         $t = Tag::find_by_name($tags);
         if ($t) {
             return $t->related();
         }
     }
     return array();
 }
开发者ID:laiello,项目名称:my-imouto-booru,代码行数:12,代码来源:tag.php

示例5: commit_tags

 function commit_tags()
 {
     if ($this->is_empty_model()) {
         return;
     }
     $this->tags = array_filter(explode(' ', str_replace(array("\r", "\n"), '', $this->tags)));
     $this->current_tags = array_keys($this->parsed_cached_tags);
     if (empty($this->old_tags)) {
         $this->old_tags = $this->tags;
     } elseif (!is_array($this->old_tags)) {
         $this->old_tags = array_filter(explode(' ', $this->old_tags));
     }
     $this->commit_metatags();
     foreach ($this->tags as $k => $tag) {
         if (!preg_match('~^(-pool|pool|rating|parent|child):|^[qse]$~', $tag)) {
             continue;
         }
         if (in_array($tag, array('q', 's', 'e'))) {
             $tag = "rating:{$tag}";
         }
         $subparam = explode(':', $tag);
         $metatag = array_shift($subparam);
         $param = array_shift($subparam);
         $subparam = empty($subparam) ? null : array_shift($subparam);
         switch ($metatag) {
             case 'rating':
                 # Change rating. This will override rating selected on radio buttons.
                 if (in_array($param, array('q', 's', 'e'))) {
                     $this->rating = $param;
                 }
                 unset($this->tags[$k]);
                 break;
             case 'pool':
                 try {
                     $name = $param;
                     $seq = $subparam;
                     # Workaround: I don't understand how can the pool be found when finding_by_name
                     # using the id.
                     if (ctype_digit($name)) {
                         $pool = Pool::find_by_id($name);
                     } else {
                         $pool = Pool::find_by_name($name);
                     }
                     # Set :ignore_already_exists, so pool:1:2 can be used to change the sequence number
                     # of a post that already exists in the pool.
                     $options = array('user' => User::find($this->updater_user_id), 'ignore_already_exists' => true);
                     if ($seq) {
                         $options['sequence'] = $seq;
                     }
                     if (!$pool and !ctype_digit($name)) {
                         $pool = Pool::create(array('name' => $name, 'is_public' => false, 'user_id' => $this->updater_user_id));
                     }
                     if (!$pool) {
                         continue;
                     }
                     if (!$pool->can_change(User::$current, null)) {
                         continue;
                     }
                     $pool->add_post($this->id, $options);
                 } catch (PostAlreadyExistsError $e) {
                 } catch (AccessDeniedError $e) {
                 }
                 unset($this->tags[$k]);
                 break;
             case '-pool':
                 unset($this->tags[$k]);
                 $name = $param;
                 $cmd = $subparam;
                 $pool = Pool::find_by_name($name);
                 if (!$pool->can_change(User::$current, null)) {
                     break;
                 }
                 if ($cmd == "parent") {
                     # If we have a parent, remove ourself from the pool and add our parent in
                     # our place.  If we have no parent, do nothing and leave us in the pool.
                     if (!empty($this->parent_id)) {
                         $pool->transfer_post_to_parent($this->id, $this->parent_id);
                         break;
                     }
                 }
                 $pool && $pool->remove_post($id);
                 break;
             case 'source':
                 $this->source = $param;
                 unset($this->tags[$k]);
                 break;
             case 'parent':
                 if (is_numeric($param)) {
                     $this->parent_id = (int) $param;
                 }
                 unset($this->tags[$k]);
                 break;
             case 'child':
                 unset($this->tags[$k]);
                 break;
             default:
                 unset($this->tags[$k]);
                 break;
         }
     }
//.........这里部分代码省略.........
开发者ID:laiello,项目名称:my-imouto-booru,代码行数:101,代码来源:post.php

示例6: array

<?php

include '../../inc/init.inc';
if ((!isset($title) || $title == "") && !isset($question_id) || (!isset($content) || $content == "")) {
    $res->load('questions', array());
} else {
    if (isset($title)) {
        $args['title'] = $title;
    }
    if (isset($question_id)) {
        $args['question_id'] = $question_id;
    }
    $args['content'] = $content;
    $args['user_id'] = $res->user->id;
    $question = Question::create($args);
    if (isset($tag_list_values)) {
        $tags = explode(',', $tag_list_values);
        foreach ($tags as $tagName) {
            $tagName = strtoupper($tagName);
            if (Tag::exists(array('name' => $tagName))) {
                $tag = Tag::find_by_name($tagName);
            } else {
                $tag = Tag::create(array('name' => $tagName));
            }
            Questions_Tag::create(array('question_id' => $question->id, 'tag_id' => $tag->id));
        }
    }
}
$res->load('question', array('id' => $question->id));
开发者ID:Osin,项目名称:Intranet,代码行数:29,代码来源:action.question.post.php


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