public function remove($tag_id) { Tags::destroy($tag_id); PostTag::where(['tag_id' => $tag_id])->delete(); Notifications::add('Tag removed', 'success'); return Redirect::back(); }
/** * Display a listing of the resource. * * @return Response */ public function post(Request $request, $post) { $qGetTags = Tags::all(); $qGetCategories = Categories::where('cID', '!=', 1)->get(); $qArticle = $post; return view('user.show-post', compact('qGetTags', 'qGetCategories', 'qArticle')); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Tags::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['TagID' => $this->TagID]); $query->andFilterWhere(['like', 'TagDescription', $this->TagDescription]); return $dataProvider; }
/** * 注册公共数据 */ public function setCommonData() { $data['navigationList'] = Navigation::getNavigationTreeArray(); //导航列表数组 $data['hotArticleList'] = Article::getHotArticleList(5); //热门文章列表 $data['tagsList'] = Tags::orderBy('number', 'desc')->limit(15)->get(); //标签云 $data['linkList'] = Links::orderBy('sequence')->limit(10)->get(); //友情链接列表 View::share($data); }
public function create(Request $request) { $qCategories = Categories::all(); $qTags = Tags::all(); $articleID = $request->aID ? $request->aID : 0; if ($articleID) { $qArticles = Articles::where("aID", $articleID)->first(); } else { $qArticles = new Articles(); } return view('admin.article.create', compact('qArticles', 'articleID', 'qCategories', 'qTags')); }
public function getPostsByTag($tag) { $slug = str_slug($tag, '_'); $key = 'post_tag_' . $slug; if (Cache::has($key)) { return Cache::get($key); } else { $posts = Tags::where('tag', 'like', $tag)->first()->posts()->active()->paginate(10); Cache::put($key, $posts, 5); } return $posts; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Tags::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'created' => $this->created, 'modified' => $this->modified]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
public function crawler(Request $request) { $this->allLinks = array(); if ($request->server('REQUEST_METHOD') == "POST") { $domain = strpos($request->domainURL, "http://") !== false ? $request->domainURL : "http://" . $request->domainURL; $this->domain = $domain; $this->count = $request->limitPages; $this->index_current = 0; $this->limit_page = $request->limitPages; $this->allLinks[0] = array("page" => $domain, "status" => "", "mark" => ""); $this->find_character = $request->checkCharacter; $this->spider($domain); } $allLinks = $this->allLinks; $qGetTags = Tags::all(); $qGetCategories = Categories::where('cID', '!=', 1)->get(); return view('functionally.crawler', compact('qGetTags', 'qGetCategories', 'allLinks')); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Tags::getDb()->cache(function ($db) { $query = Tags::find(); $query->joinWith(['tagType', 'parentTag']); return $query; }); $_columns = [Tags::tableName() . '.id', Tags::tableName() . '.tag_name_' . Yii::$app->language, Tags::tableName() . '.tag_type']; $dataProvider = new ActiveDataProvider(['query' => $query]); $query->select($_columns); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'create_date' => $this->create_date]); $query->andFilterWhere(['like', 'tag_name_ar', $this->tag_name_ar])->andFilterWhere(['like', 'tag_name_en', $this->tag_name_en])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'type_name', $this->tag_type]); //->andFilterWhere(['like', 'CONCAT(full_name,username)', $this->created_by]); return $dataProvider; }
/** * Finds the Tags model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Tags the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Tags::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getTag0() { return $this->hasOne(Tags::className(), ['tag_name' => 'tag']); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { if ($result = check_auth_to('BQGL_DELETE')) { return $result; } try { Tags::destroy($id); return redirect()->action('Admin\\TagsController@index')->with('operationstatus', 'sucess'); } catch (\Exception $e) { return redirect()->back()->withErrors(['error' => '删除标签失败,请重试(' . $e->getMessage() . ')']); } }
/** * @return \yii\db\ActiveQuery */ public function getTag() { return $this->hasOne(Tags::className(), ['id' => 'tag_id']); }
/** * EDITAR TAG || EDIT TAG * * @return Response */ public function editarTag() { $id = \Input::get('tag_id'); $tag = \Input::get('tag_titulo'); if ($id == '' || $tag == '') { return 'campovazio'; } else { $verTags = \App\Models\Tags::where('tag_titulo', $tag)->first(); if (count($verTags) <= 0) { $dados = array('tag_titulo' => $tag, 'tag_slug' => str_slug($tag), 'updated_at' => date('Y-m-d H:i:s')); if (Tags::where('tag_id', $id)->update($dados)) { return 'sucesso'; } else { return 'semodificacao'; } } else { return 'tagexiste'; } } }
<div class="col-lg-6"> <?php echo $form->field($model, 'tag_name_ar')->textInput(); ?> </div> <div class="col-lg-6"> <?php echo $form->field($model, 'tag_name_en')->textInput(); ?> </div> </div> <div class="row"> <div class="col-lg-6"> <?php echo $form->field($model, 'parent_id')->widget(Select2::className(), ['data' => Tags::getTagsList(), 'options' => ['placeholder' => 'Select parent tag..', 'multiple' => false], 'pluginOptions' => ['allowClear' => true]]); ?> </div> <div class="col-lg-6"> <?php echo $form->field($model, 'tag_type')->widget(Select2::className(), ['data' => TagType::getTagTypeList(), 'options' => ['tags' => true, 'placeholder' => 'Select tag type..', 'multiple' => false], 'pluginOptions' => ['allowClear' => true]]); ?> </div> </div> <hr> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div>
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy(Request $request) { Tags::destroy($request->tID); return "success"; }
public function getBlogSingle($slug) { $dados = array('post' => \App\Models\Posts::getPostsStatus($slug), 'tags' => \App\Models\Tags::all()); return view('themes.linexti.blog-single', $dados); }
/** * @return \yii\db\ActiveQuery */ public function getTag() { return $this->hasOne(Tags::className(), ['TagID' => 'TagID']); }
/** * @return \yii\db\ActiveQuery */ public function getMainTag() { return $this->hasOne(Tags::className(), ['id' => 'main_tag'])->from(Tags::tableName() . ' maintag'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $data = $request->all(); unset($data['_token'], $data['pic']); try { $data['tags'] = implode(',', Tags::saveArticleTags($data['tags'])); $data['user_id'] = session('loginUser')->user_id; if ($request->hasFile('pic')) { $data['pic'] = $this->fileUpload($request); } Article::find($id)->update($data); Article::resetRedisCache(); Cache::forget(Article::REIDS_ARTICLE_CACHE . $id); return redirect()->action('Admin\\ArticleController@index')->with(array('dialog' => array('title' => '修改文章成功', 'message' => $data))); } catch (\Exception $e) { return redirect()->back()->withErrors(['error' => '修改文章失败, 请重试' . $e->getMessage()])->with($data); } }
public function actionTag($tag) { $ids = Tags::getBlogsByTag($tag); $list = Blog::getByIds($ids); return $this->render('/site/list', ['data' => $list]); }
class="col-lg-6"> <?php echo $form->field($model, 'description_en')->textarea(['style' => 'min-height: 200px;']); ?> </div> </div> <div class="row"> <div class="col-lg-6"> <?php echo $form->field($model, 'video_lang')->widget(SwitchInput::classname(), ['name' => 'video_lang', 'pluginOptions' => ['onText' => 'Arabic', 'offText' => 'English', 'onColor' => 'success', 'offColor' => 'info']]); ?> </div> </div> <div class="row"> <div class="col-lg-6"> <?php echo $form->field($model, 'tags')->widget(Select2::classname(), ['data' => Tags::getTagsList(), 'size' => Select2::MEDIUM, 'options' => ['placeholder' => 'Select tags for this video', 'multiple' => true], 'pluginOptions' => ['tags' => true, 'allowClear' => true]]); ?> </div> </div> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?>
public static function edit(BlogForm $blogform) { $uid = \Yii::$app->user->getId(); $blog = Blog::findOne(['id' => $blogform->id, 'uid' => $uid]); $blog->title = htmlspecialchars($blogform->title); $blog->content = htmlspecialchars($blogform->content); if ($blog->tags != $blogform->tags) { $updateTags = true; } /* if ($blogform->status == self::STATUS_PUBLISH && $blog->status != self::STATUS_PUBLISH) { $countInc = true; } if ($blogform->status != self::STATUS_PUBLISH && $blog->status == self::STATUS_PUBLISH) { $countDec = true; } */ $analyse = self::analyse($blogform->content); if (!$blogform->description) { $blog->description = $analyse['description']; } else { $blog->description = $blogform->description; } //$blog->image = $blogform->image ? $blogform->image : $analyse['image']; $blog->image = $analyse['image']; $blog->thumb = $analyse['thumb']; $blog->tags = $blogform->tags; $blog->cid = $blogform->cid; $blog->status = $blogform->status ? $blogform->status : self::STATUS_PUBLISH; $blog->is_private = is_numeric($blogform->is_private) ? $blogform->is_private : 0; $blog->allow_review = is_numeric($blogform->allow_review) ? $blogform->allow_review : 1; $blog->uptime = time(); $res = $blog->save(); if ($res) { if (isset($updateTags) && $updateTags) { Tags::removeByBlogId($id); Tags::add($blog->tags, $id); } return true; } return false; }
public function postTags(Request $req) { $rules = ['tag_name' => ['required', 'min:2']]; $valid = Validator::make($req->input(), $rules); if (!$valid->fails()) { $tag = new Tags(); $tag->tag_name = strtolower(str_slug($req->input('tag_name'))); if ($tag->save()) { return redirect()->back()->with('msg', 'Successfully Saved Tag'); } } else { return redirect()->back()->withErrors($valid->errors()); } }
private function _setTags($tags_str, $post_id) { PostTag::where('post_id', $post_id)->delete(); $tags = explode(', ', $tags_str); foreach ($tags as $tag) { if (trim($tag) == '') { continue; } $tag = mb_strtolower($tag); $dbtag = Tags::where('tag', 'like', $tag)->first(); if (empty($dbtag)) { $dbtag = new Tags(); $dbtag->tag = strip_tags($tag); $dbtag->save(); } $post_tag = new PostTag(); $post_tag->post_id = $post_id; $post_tag->tag_id = $dbtag->id; $post_tag->save(); } }
/** * @return ActiveQuery */ public function getSubTags() { return $this->hasMany(Tags::className(), ['parent_id' => 'id'])->where(['status' => 'active']); }
public function getSearch(Request $req) { $query = rawurldecode($req->input('q')); $words = explode(' ', $query); $skipKeywords = ['in', 'are', 'of', 'at', 'a', 'is', 'to', 'an', 'for', 'and', 'or', 'with']; $tags = []; $keywords = array_diff($words, $skipKeywords); $diary = Diary::with('tags')->where(function ($q) use($keywords) { foreach ($keywords as $tag) { $q->orWhere('diary.title', 'like', '%' . $tag . '%'); } })->where('diary.status', 1)->orderBy('title', 'asc')->paginate(10); if (count($diary) < 1) { $tags = Tags::where(function ($q) use($words) { foreach ($words as $word) { $q->orWhere('tag_name', 'like', '%' . $word . '%'); } })->get(['tag_name', 'id']); } return view('site.diary.diary', ['pageInfo' => ['pageLogo' => 'diary', 'siteTitle' => 'Search | ' . $query, 'pageHeading' => 'Search | ' . $query, 'pageHeadingSlogan' => 'Search everything what I write'], 'data' => $diary, 'tags' => $tags]); }
* Items category */ Route::resource('items_category', 'ItemsCategoryController'); Route::post('getShop', ['uses' => 'ItemsCategoryController@getShop', 'as' => 'getShop']); $router->post('/ads/flush', 'AdsController@flush'); $router->post('/questions/flush', 'QuestionsController@flush'); $router->post('/questions/upload', 'QuestionsController@store'); $router->post('/questions/{id}', 'QuestionsController@show'); $router->bind('pagename', function ($id) { return \AppAdmin\Models\PageName::find($id); }); $router->bind('categories', function ($id) { return \App\Models\Category::find($id); }); $router->bind('tags', function ($id) { return \App\Models\Tags::find($id); }); $router->bind('ads', function ($id) { return \App\Models\Advertisement::find($id); }); $router->bind('country', function ($title) { return \App\Models\Country::where('title', '=', $title)->first(); }); /** * PROFILE */ $router->bind('profile', function ($user_name) { $user = \App\Models\User::where('user_name', $user_name)->first(); if (!$user) { $user = \App\Models\User::where('user_name', Auth::user()->user_name)->first(); }
public function getTags() { $tags = Tags::select(DB::raw('id as value, tag_name as text'))->get(); return response()->json($tags); }
public static function getBlogsByTag($tag) { $list = Tags::find()->where(['name' => $tag])->select(['blog_id'])->asArray()->all(); return self::format($list); }