本文整理汇总了PHP中Tag::findAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::findAll方法的具体用法?PHP Tag::findAll怎么用?PHP Tag::findAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tag
的用法示例。
在下文中一共展示了Tag::findAll方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
AuthUser::load();
if (!AuthUser::isLoggedIn()) {
echo 'Please Login';
header('location:index.php?job=login');
}
//首页最近文章
//$this->recent_post = Article::getPost(5, true);
//侧栏分类
$this->categories = Category::findAll();
if (is_array($this->categories) && count($this->categories) > 0) {
$temp = array();
foreach ($this->categories as $k => $v) {
$temp[$v->id] = get_object_vars($v);
}
$this->cahce_categories = $temp;
$temp = array();
}
//Tags 后期改进为热词形式
$hot_tags = Tag::findAll(20);
//mprint_r($hot_tags, '$hot_tags');
if (count($hot_tags) > 0) {
$first = current($hot_tags);
$last = end($hot_tags);
foreach ($hot_tags as $k => $v) {
$tags_list[$k]['word'] = $v->name;
$tags_list[$k]['size'] = tagClouds($v->count, $first->count, $last->count);
}
}
$this->tags_list = $tags_list;
$tags = Tag::findAll();
//var_dump($tags);
$content_tag = Record::findAllFrom('ContentTag');
//var_dump($content_tag);
//关系表中存在的文章ID以及tag集合到一个数组中tag_cache 避免在遍历生成文章静态页时重复读取数据库
//遍历所有tag 组合出方便调用的形式
if (is_array($tags) && count($tags) > 0) {
$temp_tags = array();
foreach ($tags as $k => $v) {
$temp_tags[$v->id] = $v->name;
}
}
//遍历关系表
if (is_array($content_tag) && count($content_tag) > 0) {
$this->cahce_tags = array();
foreach ($content_tag as $k => $v) {
if (isset($temp_tags[$v->tag_id])) {
$this->cahce_tags[$v->content_id][] = $temp_tags[$v->tag_id];
}
}
}
//清空临时数据
$tags = $content_tag = $temp_tags = array();
}
示例2: createPageFormBase
protected function createPageFormBase($name, $new)
{
$form = new AppForm($this, $name);
if (!$new) {
$form->addHidden("id");
}
$form->addText("name", "Name", 40, 50);
$form->addTextArea("description", "Description", 40, 3);
$form->addTextArea("text", "Text", 40, 15);
$form->addMultiSelect("tags", "Tags", Tag::findAll()->fetchPairs("id", "name"))->setOption("description", Html::el("a")->href($this->link("Tag:"))->setText("Edit tags"));
$form->addCheckbox("allowed", "Allowed");
$form->addSubmit("s", "Save");
return $form;
}
示例3: run
public function run()
{
$model = new Tag();
//条件
$criteria = new CDbCriteria();
$tag_name = trim(Yii::app()->request->getParam('tag_name'));
$tag_name && $criteria->addSearchCondition('tag_name', $tag_name);
$criteria->order = 't.id ASC';
$count = $model->count($criteria);
//分页
$pages = new CPagination($count);
$pages->pageSize = 20;
$pages->applyLimit($criteria);
//查询
$result = $model->findAll($criteria);
$this->controller->render('index', array('model' => $model, 'datalist' => $result, 'pagebar' => $pages));
}
示例4: testSet
public function testSet()
{
$page = Page::findByName("Clanek");
$tags = Tag::findAll();
$page->Tags = $tags;
$page->save();
$tagIds = array_map(function ($record) {
return $record->id;
}, $tags->toArray());
$q = $this->db->select("*")->from("connections")->execute();
$q->detectTypes();
$conn = $q->fetchAll();
$this->assertSame(3, count($conn));
foreach ($conn as $row) {
$this->assertSame($page->id, $row->pageId);
$this->assertTrue(in_array($row->tagId, $tagIds));
}
}
示例5: actionIndex
/**
* 标签管理
*
*/
public function actionIndex()
{
$model = new Tag();
$criteria = new CDbCriteria();
$condition = '1';
$tagName = $this->_request->getParam('tagName');
$tagName && ($condition .= ' AND tag_name LIKE \'%' . $tagName . '%\'');
$criteria->condition = $condition;
$criteria->order = 't.id DESC';
$count = $model->count($criteria);
$pages = new CPagination($count);
$pages->pageSize = 13;
$pageParams = $this->buildCondition($_GET, array('tagName'));
$pages->params = is_array($pageParams) ? $pageParams : array();
$criteria->limit = $pages->pageSize;
$criteria->offset = $pages->currentPage * $pages->pageSize;
$result = $model->findAll($criteria);
$this->render('index', array('datalist' => $result, 'pagebar' => $pages));
}
示例6: __construct
public function __construct()
{
/*
$cache = new FileCache();
$cache->cachePath = DATA_DIR.'cache/';
//侧栏分类
$categories = $cache->get('categories');
if($categories === false) {
$categories = array();
//获得所有分类
$categories[0] = Category::findAll();
if(is_array($categories[0]) && count($categories[0]) > 0) {
foreach($categories[0] as $k => $v) {
//$this->categories[$v->id] = get_object_vars($v);
$categories[1][$v->id] = $v;
$categories[1][$v->slug] = $v;
}
}
$cache->set('categories', $categories, 7200);//缓存2小时
del_cache();
}
//Tags 热词
$hot_tags = $cache->get('hot_tags');
if($hot_tags === false) {
$hot_tags = Tag::findAll(30);
$cache->set('hot_tags', $hot_tags, 7200);
}
*/
//--------------------------------
//首页最近文章
$this->recent_post = Article::getPost(5, true);
//侧栏分类
$this->categories = Category::findAll();
if (is_array($this->categories) && count($this->categories) > 0) {
$temp = array();
foreach ($this->categories as $k => $v) {
$temp[$v->id] = get_object_vars($v);
}
$this->cahce_categories = $temp;
$temp = array();
}
//Tags 后期改进为热词形式
$this->tags_list = Tag::findAll(30);
$tags = Tag::findAll();
$content_tag = Record::findAllFrom('ContentTag');
//遍历所有tag 组合出方便调用的形式
if (is_array($tags) && count($tags) > 0) {
$temp_tags = array();
foreach ($tags as $k => $v) {
$temp_tags[$v->id] = $v->name;
}
}
//遍历关系表
if (is_array($content_tag) && count($content_tag) > 0) {
$this->cahce_tags = array();
foreach ($content_tag as $k => $v) {
if (isset($temp_tags[$v->tag_id])) {
$this->cahce_tags[$v->content_id][] = $temp_tags[$v->tag_id];
}
}
}
//清空临时数据
$tags = $content_tag = $temp_tags = array();
}
示例7: createPostHtml
public function createPostHtml($obj = null)
{
global $tpl;
if (is_object($obj) && DEBUG === false) {
$post = clone $obj;
$post->content = processContent($post->content);
//上一篇文章
$previous = $obj->previous();
//下一篇文章
$next = $obj->next();
//首页最近文章
$recent_post = Article::getPost(5, false);
//侧栏分类
$categories = Category::findAll();
//Tags
$hot_tags = Tag::findAll(30);
//mprint_r($hot_tags, '$hot_tags');
if (count($hot_tags) > 0) {
$first = current($hot_tags);
$last = end($hot_tags);
foreach ($hot_tags as $k => $v) {
$tags_list[$k]['word'] = $v->name;
$tags_list[$k]['size'] = tagClouds($v->count, $first->count, $last->count);
}
}
//smarty
$tpl->assign('post', $post);
$tpl->assign('next', $next);
$tpl->assign('previous', $previous);
$tpl->assign('recent_post', $recent_post);
$tpl->assign('categories', $categories);
$tpl->assign('tag_list', $tags_list);
$filetpl = SYSTEM_ROOT . 'templates/' . DEFAULT_TEMPLATE . '/post.html';
$path = SYSTEM_ROOT . 'post/';
//$filename = !empty($obj->slug) ? str_replace(' ', '-', trim($obj->slug)) : $obj->id;
$filename = $obj->id;
$file = $path . $filename . '.html';
file_put_contents($file, $tpl->fetch($filetpl));
@chmod($file, 0777);
}
}
示例8: __construct
public function __construct()
{
global $tpl, $app;
$app->refresh();
$this->cache = new FileCache();
$this->cache->cachePath = DATA_DIR . 'cache/';
//侧栏分类
$categories = $this->cache->get('categories');
if ($categories === false) {
$categories = array();
//获得所有分类
$categories[0] = Category::findAll();
if (is_array($categories[0]) && count($categories[0]) > 0) {
foreach ($categories[0] as $k => $v) {
$categories[0][$k]->url = SITE_URL . 'category/' . $v->slug . '/';
//$this->categories[$v->id] = get_object_vars($v);
$categories[1][$v->id] = $v;
$categories[1][$v->slug] = $v;
}
}
if (DEBUG === false) {
$this->cache->set('categories', $categories, 7200);
//缓存2小时
del_cache();
}
}
//mprint_r($categories[0], 'a');
//分别以ID, slug为键值的分类组合
$this->categories = $categories[1];
//Tags 热词
$tags_list = $this->cache->get('hot_tags');
if ($tags_list === false) {
$hot_tags = Tag::findAll(20);
//mprint_r($hot_tags, '$hot_tags');
if (count($hot_tags) > 0) {
$first = current($hot_tags);
$last = end($hot_tags);
foreach ($hot_tags as $k => $v) {
$tags_list[$k]['word'] = $v->name;
$tags_list[$k]['size'] = tagClouds($v->count, $first->count, $last->count);
$tags_list[$k]['url'] = SITE_URL . 'tag/' . strtolower($v->name) . '/';
}
}
if (DEBUG === false) {
$this->cache->set('hot_tags', $tags_list, 7200);
}
}
//首页最近文章
$recent_post = $this->cache->get('recent_post');
if ($recent_post === false) {
$recent_post = Article::getPost(5);
if (is_array($recent_post) && count($recent_post) > 0) {
foreach ($recent_post as $key => $val) {
$recent_post[$key]->url = SITE_URL . 'post/' . $val->id . '.html';
}
}
if (DEBUG === false) {
$this->cache->set('recent_post', $recent_post, 7200);
//缓存2小时
del_cache();
}
}
//mprint_r($recent_post, '$recent_post');
$tpl->assign('recent_post', $recent_post);
$tpl->assign('categories', $categories[0]);
$tpl->assign('tag_list', $tags_list);
}
示例9: renderDefault
public function renderDefault()
{
$this->template->title = "Edit tags";
$this->template->tags = Tag::findAll()->orderBy("name");
}