public function actionCreate() { $token = \Yii::$app->request->headers->get('token'); $content = \Yii::$app->request->post()['content']; $create_content = new Content(); $create_content->content = $content; $create_content->author_id = $token; if (isset($token) && $create_content->save()) { $array = ['error_no' => 0, 'error_msg' => '']; echo json_encode($array); } }
public function show($slug) { $article = Content::article()->active()->published()->where('slug', $slug)->firstOrFail(); $comments = Comment::where('content_id', $article['id'])->active()->paginate(10); $pageTitle = $article['title']; return view('frontend.articles.show', compact('article', 'comments', 'pageTitle')); }
public function actionAbout() { $content = Content::findOne(1); $cats = $content->cats; print_r($cats); die; return $this->render('about', ['test' => $cats]); }
public function actionEditcontent($id) { $model = Content::findOne($id); if ($model->load(Yii::$app->request->post())) { $model->save(); $this->refresh(); } return $this->render('edit_content', ['model' => $model]); }
public function actionIndex() { $model = new ContentForm(); $contentModel = Content::findOne(1); if ($model->load(Yii::$app->request->post())) { } else { return $this->render('index', ['model' => $model, 'contentModel' => $contentModel]); } }
public function actions() { $ret = []; foreach (Yii::$app->params["languages"] as $lng => $name) { $model = Content::find()->andWhere('name="briefing"')->andWhere('language="' . $lng . '"')->one(); $ret[$lng] = ['class' => BriefingAction::className(), 'model' => $model]; } return $ret; }
public function makeDropDown($langs = null) { global $data; $langs = $langs ? $langs : 'thai'; $data = array(); $parents = Content::find()->where(['langs' => $langs])->all(); foreach ($parents as $parent) { $data[$parent->id] = $parent->title; } return $data; }
public function actionShow() { $request = Yii::$app->request; $surl = $request->get('surl'); if (!($content = Content::findOneByURL($surl))) { throw new NotFoundHttpException('The requested page does not exist.'); } if ($content->getSURLString() !== $surl) { return $this->redirect(Url::toRoute(['posts/' . $content->getSURLString()])); } return $this->render('index', ['content' => $content]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Content::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, 'status' => $this->status]); $query->andFilterWhere(['like', 'title_uk', $this->title_uk])->andFilterWhere(['like', 'title_ru', $this->title_ru])->andFilterWhere(['like', 'title_en', $this->title_en])->andFilterWhere(['like', 'content_uk', $this->content_uk])->andFilterWhere(['like', 'content_ru', $this->content_ru])->andFilterWhere(['like', 'content_en', $this->content_en])->andFilterWhere(['like', 'tags_uk', $this->tags_uk])->andFilterWhere(['like', 'tags_ru', $this->tags_ru])->andFilterWhere(['like', 'tags_en', $this->tags_en])->andFilterWhere(['like', 'type', $this->type]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Content::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, 'courses_id' => $this->courses_id]); $query->andFilterWhere(['like', 'text', $this->text]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Content::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, 'user_id' => $this->user_id, 'category_id' => $this->category_id, 'create_time' => $this->create_time]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'summary', $this->summary]); return $dataProvider; }
/** * 更新内容 * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function update(Request $request, $id) { $content = Content::findOrFail($id); $data['title'] = $request->get('title'); $data['seo_title'] = $request->get('seo_title'); $data['slug'] = str_slug($request->get('slug')); $data['description'] = $request->get('description'); $data['class_id'] = $request->get('class_id'); $data['tag_id'] = $request->get('tag_id'); $data['content'] = $request->get('content'); $data['type'] = $request->get('type'); $update = $content->update($data); if (!$update) { return redirect()->back(); } Cache::forget('com.tanteng.share.page.' . $data['slug']); return redirect()->route('content.index'); }
public function postPage(Request $request) { //echo '<pre>',print_r($request->all()),'</pre>'; $chk = Content::where('content_type', $request->input('content_type'))->first(); $content = $chk ? $chk : new Content(); $content->content_subject = $request->input('content_subject'); $content->content_description = $request->input('seo_description'); $content->content_detail = $request->input('content_detail'); $content->content_type = $request->input('content_type'); $content->save(); $cseo = Seo::where('ref_id', $content->id)->where('seo_type', $content->content_type)->first(); $seo = $cseo ? $cseo : new Seo(); $seo->title = $request->input('seo_title'); $seo->keywords = $request->input('seo_keywords'); $seo->description = $request->input('seo_description'); $seo->ref_id = $content->id; $seo->seo_type = $content->content_type; $seo->save(); return redirect()->back(); }
function index() { // –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– // LATEST NEWS // –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– $data['news'] = Content::published('now')->latest('published_at')->limit(5)->get(); // –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– // UPCOMING EVENTS // –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– $data['upcoming_events'] = Event::published('now')->upcoming()->oldest('started_at')->limit(10)->get(); // –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– // KULINER // –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– $data['kuliner'] = Directory::published('now')->orderByRaw('rand()')->limit(1)->get(); // –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– // GENERATE VIEW // –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– $this->layout->main = view($this->views['pages'] . 'home'); $this->layout->main->views = $this->views; foreach ($data as $k => $v) { $this->layout->main->{$k} = $v; } return $this->layout; }
protected function migrate_serba_serbi() { $website = Website::first(); $data_users = User::get(); foreach ($data_users as $user) { $users[$user['username']] = $user; } // get old articles DB::connection('mongodb')->collection('posts')->where('category', 'regex', '/serba/i')->chunk(1000, function ($data) use($new_collection, $users, $website) { foreach ($data as $x) { unset($tags); $tags[] = 'serba-serbi'; if (str_is('*tokoh*', strtolower($x['title']))) { $tags[] = 'tokoh'; } if ($x['tgl_published']) { $news = new Content(['title' => $x['title'], 'slug' => str_replace('.', '', $x['url']), 'summary' => str_limit(strip_tags(str_replace("\n", "", $x['full'])), 125), 'content' => $x['full'], 'published_at' => date('Y-m-d H:i:s', $x['tgl_published']->sec), 'created_at' => $x['tgl'], 'updated_at' => $x['tgl'], 'user_id' => array_key_exists($x['author'], $users) ? $users[$x['author']]->id : $users['dita']->id]); if (!$news->save()) { print_r($news->toArray()); dd($news->getErrors()); } // ---------------------------------------------------------------------------------------------------- // IMAGE // ---------------------------------------------------------------------------------------------------- $s_image = new Image(['name' => 'sm', 'path' => $x['thumbmail'], 'title' => '', 'description' => '']); $m_image = new Image(['name' => 'md', 'path' => $x['image'], 'title' => '', 'description' => '']); $l_image = new Image(['name' => 'lg', 'path' => $x['image'], 'title' => '', 'description' => '']); $news->images()->updateOrCreate(['name' => 'sm'], $s_image->toArray()); $news->images()->updateOrCreate(['name' => 'md'], $m_image->toArray()); $news->images()->updateOrCreate(['name' => 'lg'], $l_image->toArray()); // ---------------------------------------------------------------------------------------------------- // TAG // ---------------------------------------------------------------------------------------------------- unset($tags_model); $tags_model = new Collection(); foreach ($tags as $tag) { $tags_model[] = Tag::firstOrCreate(['name' => $tag]); } foreach ($tags_model as $k => $v) { if (!$tags_model[$k]->save()) { dd($tags_model[$k]->getErrors()); } } if (count($tags_model)) { $news->tags()->sync($tags_model->lists('id')); } // ---------------------------------------------------------------------------------------------------- // WEBSITE // ---------------------------------------------------------------------------------------------------- $news->websites()->sync([$website->id]); // ---------------------------------------------------------------------------------------------------- // LOG // ---------------------------------------------------------------------------------------------------- // $news->authored()->attach(array_key_exists($x['author'], $users) ? $users[$x['author']]->id : $users['dita']->id, ['original_data' => json_encode([]), 'updated_data' => $news->toJson()]); } // $news->websites()->associate($website); // $news->save(); } }); // save to new tables }
/** * Finds the Content model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Content the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Content::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionPost() { $user = new User(); $user = \Yii::$app->user; if (\Yii::$app->user->isGuest) { return $this->redirect(['login']); } $query = Content::find()->where(['user_id' => $user->id]); $pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]); $contents = $query->orderBy('id')->offset($pagination->offset)->limit($pagination->limit)->all(); return $this->render('post', ['contents' => $contents, 'user' => $user, 'pagination' => $pagination]); }
/** * @return \yii\db\ActiveQuery */ public function getContents() { return $this->hasMany(Content::className(), ['user_id' => 'id']); }
public function getDestroy($id) { Content::query()->findOrFail($id)->delete(); return redirect(\URL::action('Backend\\ArticleController@getIndex')); }
function saving($model) { if (\App\Models\Content::validate($model) === false) { return false; } }
/** * @return \yii\db\ActiveQuery */ public function getContent() { return $this->hasOne(Content::className(), ['id' => 'content_id']); }
public function actionDelete($id) { $model = Content::find($id); $model->delete(); return $this->redirect(array('index')); }
'fbLink' => '', //<-- this is the link to your division facebook account, leave it blank if you don't use it 'vkLink' => '', //<-- this is the link to your division Vkontakte account, leave it blank if you don't use it 'divisionSite' => '' //<-- this is the link to your division site, leave it blank if you don't use it 'adminsvids' => [11111,00000], //<-- the list of administator's VID's. It's mandatory to fill at least one VID 'languages' => ['ru'=>'Русский','en'=>'English'], //<-- list of available briefing languages, you can configure it as you wish. Change this before install 'api_url' => 'https://login.ivao.aero/index.php?url=<b>http://URL_OF_YOUR_RFE_SITE</b>/site/login', //<--change to your http(s) host. Ensure the IVAO LOGIN API is available for your domain. 'installed' => true, //<-- change to false. It's mandatory to proceed install </pre> </li> <li> Just <b>update this page</b> </li> <li> <?php try { $p = \app\models\Content::findOne(1); if (!empty($p)) { ?> <b style="color: green">Congratulations! You just install the RFE/MSE software.</b><br> Don't forget to change <b>installed</b> parameter to <b>true</b> in <b>"config/params.php"</b> <?php } } catch (\yii\base\Exception $e) { if (Yii::$app->params['installed'] === false) { echo "Something wrong... I realy do not understand this"; } else { echo "Installation can not continue due to installed parameter setted to true"; } } ?> </li>
public function actionAbout() { $model = Content::find()->where(['id' => 1])->one(); \Yii::$app->view->registerMetaTag(['name' => 'description', 'content' => $model->name]); $this->getMetaTagsDefault(); return $this->render('about', ['model' => $model]); }
public function article(Route $route) { $article = Content::query()->with('category')->findOrFail($route->parameter('id')); return \View::make('frontend.article', ['article' => $article]); }
public function actionList() { $dataProvider = new ActiveDataProvider(['query' => Content::find(), 'pagination' => ['pageSize' => 2]]); return $this->render('list', ['dataProvider' => $dataProvider]); }
public static function findOneByURL($url) { return Content::find()->select('content.*')->leftJoin('surl', 'surl.content_id = content.id')->where(['surl.name' => $url])->one(); }
/** * Display the specified resource. * * @param string $slug * @return \Illuminate\Http\Response */ public function show($slug) { $category = Category::article()->active()->where('slug', '=', $slug)->firstOrFail(); $articles = Content::article()->active()->where('category_id', '=', $category['id'])->paginate(10); return view('frontend.categories.show', compact('category', 'articles')); }
public function destroy($id) { Content::find($id)->delete(); return Redirect::route('admin.content.index'); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $article = Content::article()->where('id', '=', $id)->get(); $this->authorize($article); if ($article->delete()) { return \Response::json(['status' => true]); } return \Response::json(['status' => false])->setStatusCode(404); }