Exemplo n.º 1
0
 public function remove($tag_id)
 {
     Tags::destroy($tag_id);
     PostTag::where(['tag_id' => $tag_id])->delete();
     Notifications::add('Tag removed', 'success');
     return Redirect::back();
 }
Exemplo n.º 2
0
 /**
  * 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'));
 }
Exemplo n.º 3
0
 /**
  * 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;
 }
Exemplo n.º 4
0
 /**
  * 注册公共数据
  */
 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);
 }
Exemplo n.º 5
0
 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'));
 }
Exemplo n.º 6
0
Arquivo: Posts.php Projeto: garf/0ez
 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;
 }
Exemplo n.º 7
0
 /**
  * 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'));
 }
Exemplo n.º 9
0
 /**
  * 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;
 }
Exemplo n.º 10
0
 /**
  * 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.');
     }
 }
Exemplo n.º 11
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTag0()
 {
     return $this->hasOne(Tags::className(), ['tag_name' => 'tag']);
 }
Exemplo n.º 12
0
 /**
  * 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() . ')']);
     }
 }
Exemplo n.º 13
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTag()
 {
     return $this->hasOne(Tags::className(), ['id' => 'tag_id']);
 }
Exemplo n.º 14
0
 /**
  * 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';
         }
     }
 }
Exemplo n.º 15
0
        <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>
Exemplo n.º 16
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Request $request)
 {
     Tags::destroy($request->tID);
     return "success";
 }
Exemplo n.º 17
0
 public function getBlogSingle($slug)
 {
     $dados = array('post' => \App\Models\Posts::getPostsStatus($slug), 'tags' => \App\Models\Tags::all());
     return view('themes.linexti.blog-single', $dados);
 }
Exemplo n.º 18
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTag()
 {
     return $this->hasOne(Tags::className(), ['TagID' => 'TagID']);
 }
Exemplo n.º 19
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMainTag()
 {
     return $this->hasOne(Tags::className(), ['id' => 'main_tag'])->from(Tags::tableName() . ' maintag');
 }
Exemplo n.º 20
0
 /**
  * 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);
     }
 }
Exemplo n.º 21
0
 public function actionTag($tag)
 {
     $ids = Tags::getBlogsByTag($tag);
     $list = Blog::getByIds($ids);
     return $this->render('/site/list', ['data' => $list]);
 }
Exemplo n.º 22
0
            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();
?>
Exemplo n.º 23
0
 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;
 }
Exemplo n.º 24
0
 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());
     }
 }
Exemplo n.º 25
0
 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();
     }
 }
Exemplo n.º 26
0
 /**
  * @return ActiveQuery
  */
 public function getSubTags()
 {
     return $this->hasMany(Tags::className(), ['parent_id' => 'id'])->where(['status' => 'active']);
 }
Exemplo n.º 27
0
 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]);
 }
Exemplo n.º 28
0
 * 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();
    }
Exemplo n.º 29
0
 public function getTags()
 {
     $tags = Tags::select(DB::raw('id as value, tag_name as text'))->get();
     return response()->json($tags);
 }
Exemplo n.º 30
0
 public static function getBlogsByTag($tag)
 {
     $list = Tags::find()->where(['name' => $tag])->select(['blog_id'])->asArray()->all();
     return self::format($list);
 }