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


PHP Tag::getTags方法代码示例

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


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

示例1: getTags

 public function getTags($id)
 {
     $tmp = array();
     $postTags = Post_tags::getPostTags($id);
     //        print_r (count($postTags->getModels()));
     for ($i = 0; $i < count($postTags->getModels()); $i++) {
         array_push($tmp, $postTags->getModels()[$i]['tag_id']);
     }
     //        print_r($tmp);
     $tags = implode("','", $tmp);
     $getTags = Tag::getTags($tags);
     //print_r($getTags->getModels());
     return $getTags;
 }
开发者ID:koakumasd,项目名称:blogsite,代码行数:14,代码来源:Post_tags.php

示例2: category

 /**
  * Get category and category posts
  *
  * @param Request $request
  * @param $alias
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
  */
 public function category(Request $request, $alias)
 {
     $category = Category::getCategoryByAlias($alias);
     if (empty($category)) {
         return redirect()->back();
     } else {
         $tags = Tag::getTags();
         if (!session()->get($category['id'])) {
             $category_visit = new CategoryVisit();
             $category_visit->category_id = $category['id'];
             $category_visit->save();
             session([$category['id'] => $category['id']]);
         }
         $posts = Category::getCategoryApprovedPosts($category['id'], 5, $request->input('search'), $request->input('tag'));
         $request->flash();
         return view('site.category', compact('category', 'posts', 'tags'));
     }
 }
开发者ID:GHarutyunyan,项目名称:cms,代码行数:25,代码来源:SiteController.php

示例3: export

 /**
  * Export tags
  */
 public function export()
 {
     $data = array(array('Name'));
     $tags = Tag::getTags();
     foreach ($tags as $tag) {
         $tag_array = array();
         $name = $tag['name'];
         array_push($tag_array, $name);
         array_push($data, $tag_array);
     }
     Excel::create('Tags', function ($excel) use($data) {
         $excel->sheet('Tags', function ($sheet) use($data) {
             $sheet->fromArray($data, null, 'A1', false, false);
             $sheet->cells('A1', function ($cells) {
                 $cells->setFontWeight('bold');
             });
         });
     })->export('xls');
 }
开发者ID:GHarutyunyan,项目名称:cms,代码行数:22,代码来源:TagController.php

示例4: edit

 /**
  * Edit post
  *
  * @param Request $request
  * @param int $id
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
  */
 public function edit(Request $request, $id = 0)
 {
     $post = Post::getPostById($id);
     if (empty($post)) {
         return redirect()->back();
     } else {
         if ($request->isMethod("post")) {
             $rules = ["title" => "required", "alias" => "required|unique:posts,alias," . $id, "content" => "required", 'image' => 'mimes:jpeg,jpg,png'];
             Validator::make($request->all(), $rules)->validate();
             $post->title = $request->input("title");
             $post->alias = $request->input("alias");
             $post->content = $request->input("content");
             $post->meta_keys = $request->input("meta_keys");
             $post->meta_desc = $request->input("meta_desc");
             if (!empty($request->file("image"))) {
                 if (!empty($post->image)) {
                     if (Storage::exists('uploads/' . $post->image) && Storage::exists('uploads/fb-' . $post->image)) {
                         Storage::delete('uploads/' . $post->image, 'uploads/fb-' . $post->image);
                     }
                 }
                 $generated_string = str_random(32);
                 $file = $request->file("image")->store('uploads');
                 $new_file = $generated_string . '.' . $request->file("image")->getClientOriginalExtension();
                 Storage::move($file, 'uploads/' . $new_file);
                 $img = Image::make($request->file('image'));
                 $img->crop(200, 200);
                 $img->save(storage_path('app/public/uploads/' . $new_file));
                 $img = Image::make($request->file('image'));
                 $img->resize(600, 315);
                 $img->save(storage_path('app/public/uploads/fb-' . $new_file));
                 $post->image = $new_file;
             }
             if ($request->has("category")) {
                 $post->category_id = $request->input("category");
             }
             $post->publish = $request->has("publish");
             $post->save();
             $new_tags = [];
             if ($request->has("tags")) {
                 $tags = $request->input("tags");
                 foreach ($tags as $tag) {
                     array_push($new_tags, $tag);
                 }
             }
             $post->tags()->sync($new_tags);
             return redirect()->route('posts');
         } else {
             $categories = Category::getCategoriesByPublish();
             $tags = Tag::getTags();
             return view("site.post.edit", compact("post", "categories", "tags"));
         }
     }
 }
开发者ID:GHarutyunyan,项目名称:cms,代码行数:60,代码来源:PostController.php

示例5: actionEdit

 public function actionEdit($id)
 {
     $request = Yii::$app->getRequest();
     $me = Yii::$app->getUser()->getIdentity();
     $model = $this->findTopicModel($id, ['content', 'node']);
     if (!$me->canEdit($model)) {
         throw new ForbiddenHttpException('您没有权限修改或已超过可修改时间。');
     }
     if ($me->isAdmin()) {
         $model->scenario = Topic::SCENARIO_ADMIN_EDIT;
     } else {
         $model->scenario = Topic::SCENARIO_AUTHOR_EDIT;
     }
     if (!($content = $model->content)) {
         $content = new TopicContent(['topic_id' => $model->id]);
     }
     $oldTags = $model->tags;
     if ($model->load($request->post()) && $model->validate() && $content->load($request->post()) && $content->validate()) {
         //			$model->tags = Tag::editTags($model->tags, $oldTags);
         $model->tags = Tag::getTags($model->tags);
         $model->save(false) && $content->save(false);
         Tag::afterTopicEdit($model->id, $model->tags, $oldTags);
         (new History(['user_id' => $me->id, 'action' => History::ACTION_EDIT_TOPIC, 'action_time' => $model->updated_at, 'target' => $model->id]))->save(false);
         return $this->redirect(Topic::getRedirectUrl($id, 0, $request->get('ip', 1), $request->get('np', 1)));
     }
     return $this->render('edit', ['model' => $model, 'content' => $content]);
 }
开发者ID:littleboss,项目名称:simpleforum,代码行数:27,代码来源:TopicController.php

示例6: actionList

 /**
  * 显示所有的tag标签
  */
 public function actionList()
 {
     return $this->render('list', ['tags' => Tag::getTags(1)]);
 }
开发者ID:heartshare,项目名称:yii2-crazydb-blog,代码行数:7,代码来源:TagController.php

示例7: foreach

<?php

/**
 * @author xbzbing <xbzbing@gmail.com>
 * @link http://www.crazydb.com
 */
use yii\web\View;
use yii\helpers\Url;
use app\models\Tag;
/* @var View $this */
$tags = Tag::getTags(false, 20);
$colors = ['default', 'primary', 'success', 'info', 'warning', 'danger'];
?>
<div class="widget aside-tags">
    <h3 class="widget_tit with-shadow">
        <i class="glyphicon glyphicon-tags"></i>标签
    </h3>

    <div class="with-shadow">
        <?php 
if ($tags) {
    foreach ($tags as $tag) {
        $color = $colors[mt_rand(0, 5)];
        echo <<<HTML
        <a href="{$tag['url']}" title="{$tag['name']}({$tag['totalCount']})" target="_blank">
            <span class="label label-{$color}">{$tag['name']}</span>
        </a>
HTML;
    }
} else {
    echo '<span class="label label-default">暂无标签</span>';
开发者ID:heartshare,项目名称:yii2-crazydb-blog,代码行数:31,代码来源:aside-tags.php


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