/**
  * Lists all BlogCatalog models.
  * @return mixed
  */
 public function actionIndex()
 {
     //if(!Yii::$app->user->can('readPost')) throw new HttpException(403, 'No Auth');
     $searchModel = new BlogCatalogSearch();
     $dataProvider = BlogCatalog::get(0, BlogCatalog::find()->all());
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Esempio n. 2
0
 public function run()
 {
     $cacheId = Yii::$app->params["domain"] . '_blog_catalog';
     $catalogs = Yii::$app->cache->get($cacheId);
     if ($catalogs === false) {
         $queryCatalogs = BlogCatalog::find();
         $catalogs = $queryCatalogs->all();
         Yii::$app->cache->set($cacheId, $catalogs, $this->cacheDuration);
     }
     $dataProvider = BlogCatalog::get(0, $catalogs, 0, 2, ' ');
     return $this->render('catalogsList', ['title' => $this->title, 'dataProvider' => $dataProvider, 'cacheDuration' => $this->cacheDuration]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = BlogCatalog::find();
     $query->orderBy(['sort_order' => SORT_ASC, 'create_time' => SORT_DESC]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id, 'is_nav' => $this->is_nav, 'sort_order' => $this->sort_order, 'page_size' => $this->page_size, 'status' => $this->status, 'create_time' => $this->create_time, 'update_time' => $this->update_time]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'surname', $this->surname])->andFilterWhere(['like', 'banner', $this->banner])->andFilterWhere(['like', 'template', $this->template])->andFilterWhere(['like', 'redirect_url', $this->redirect_url]);
     return $dataProvider;
 }
 public function actionView()
 {
     $this->layout = 'mainView';
     if (Yii::$app->request->get('surname')) {
         $post = BlogPost::findOne(['surname' => Yii::$app->request->get('surname')]);
         if ($post) {
             $post->updateCounters(['click' => 1]);
         } else {
             $this->redirect(['blog']);
         }
     } else {
         $this->redirect(['blog']);
     }
     $cacheId = Yii::$app->params["domain"] . '_blog_catalog';
     $catalogs = Yii::$app->cache->get($cacheId);
     if ($catalogs === false) {
         $queryCatalogs = BlogCatalog::find();
         $catalogs = $queryCatalogs->all();
         Yii::$app->cache->set($cacheId, $catalogs, $this->cacheDuration);
     }
     return $this->render('view', ['catalogs' => $catalogs, 'post' => $post]);
 }
Esempio n. 5
0
use sircovsw\blog\models\BlogCatalog;
use kartik\markdown\MarkdownEditor;
use mihaildev\ckeditor\CKEditor;
/* @var $this yii\web\View */
/* @var $model backend\modules\blog\models\BlogPost */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="blog-post-form">

	<?php 
$form = ActiveForm::begin(['options' => ['class' => 'form-horizontal', 'enctype' => 'multipart/form-data'], 'fieldConfig' => ['template' => "{label}\n<div class=\"col-lg-10\">{input}</div>\n<div class=\"col-lg-5\">{error}</div>", 'labelOptions' => ['class' => 'col-lg-2 control-label']]]);
?>

	<?php 
echo $form->field($model, 'catalog_id')->dropDownList(ArrayHelper::map(BlogCatalog::get(0, BlogCatalog::find()->all()), 'id', 'str_label'));
?>

	<?php 
echo $form->field($model, 'title')->textInput(['maxlength' => 128]);
?>

	<?php 
echo $form->field($model, 'brief')->textarea(['rows' => 6]);
?>

	<?php 
echo $form->field($model, 'content')->widget(CKEditor::className(), ['editorOptions' => ['preset' => 'full', 'inline' => false]]);
?>

	<?php 
Esempio n. 6
0
use yii\helpers\StringHelper;
if (!empty($title)) {
    ?>
	<div class="row">
		<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
			<h3>
				<?php 
    echo $title;
    ?>
			</h3>
		</div>
	</div>
	<?php 
}
foreach ($dataProvider as $item) {
    $query = \sircovsw\blog\models\BlogCatalog::find();
    $query->where(['parent_id' => $item['id']]);
    $cacheId = Yii::$app->params["domain"] . '_blog_catalog_' . md5(serialize($query));
    $catalogs = Yii::$app->cache->get($cacheId);
    if ($catalogs === false) {
        $catalogs = $query->all();
        Yii::$app->cache->set($cacheId, $catalogs, $cacheDuration);
    }
    $isLink = 0;
    if (empty($catalogs)) {
        $isLink = 1;
    }
    ?>
	<div class="row">
		<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
			<?php 
Esempio n. 7
0
<?php

use yii\helpers\Html;
use yii\widgets\ListView;
use yii\widgets\LinkPager;
use sircovsw\blog\models\BlogCatalog;
if (!empty($_GET['surname'])) {
    $surname = $_GET['surname'];
    $mSurname = BlogCatalog::find()->where(['surname' => $surname])->one();
    $this->title = yii\helpers\Html::decode(Yii::$app->params['blogTitle'] . ' - статьи по рубрике &quot;' . $mSurname->title . '&quot;');
    $this->registerMetaTag(['content' => $this->title, 'name' => 'description']);
    $this->registerMetaTag(['content' => Yii::$app->params['blogKeywords'], 'name' => 'keywords']);
    $this->params['breadcrumbs'][] = ['url' => yii\helpers\Url::toRoute('/blog'), 'label' => '<span itemprop="title">Блог</span>', 'itemTemplate' => "<li itemscope itemtype='http://data-vocabulary.org/Breadcrumb'>{link}</li>"];
    $this->params['breadcrumbs'][] = ['label' => '<span itemprop="title">' . $mSurname->title . '</span>', 'itemTemplate' => "<li itemscope itemtype='http://data-vocabulary.org/Breadcrumb'>{link}</li>"];
} else {
    if (!empty($_GET['tag'])) {
        $tag = $_GET['tag'];
        $this->title = yii\helpers\Html::decode(Yii::$app->params['blogTitle'] . ' - статьи по тегу &quot;' . $tag . '&quot;');
        $this->registerMetaTag(['content' => $this->title, 'name' => 'description']);
        $this->registerMetaTag(['content' => Yii::$app->params['blogKeywords'], 'name' => 'keywords']);
        $this->params['breadcrumbs'][] = ['url' => yii\helpers\Url::toRoute('/blog'), 'label' => '<span itemprop="title">Блог</span>', 'itemTemplate' => "<li itemscope itemtype='http://data-vocabulary.org/Breadcrumb'>{link}</li>"];
        $this->params['breadcrumbs'][] = ['label' => '<span itemprop="title">' . $tag . '</span>', 'itemTemplate' => "<li itemscope itemtype='http://data-vocabulary.org/Breadcrumb'>{link}</li>"];
    } else {
        $this->params['breadcrumbs'][] = 'Блог';
        $this->title = yii\helpers\Html::decode(Yii::$app->params['blogTitle'] . ' - ' . Yii::$app->params['blogTitleSeo']);
        $this->registerMetaTag(['content' => Yii::$app->params['blogDescription'], 'name' => 'description']);
        $this->registerMetaTag(['content' => Yii::$app->params['blogKeywords'], 'name' => 'keywords']);
    }
}
?>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
Esempio n. 8
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use sircovsw\blog\models\BlogCatalog;
use sircovsw\blog\Module;
/* @var $this yii\web\View */
/* @var $model sircovsw\blog\models\BlogCatalog */
/* @var $form yii\widgets\ActiveForm */
//fix the issue that it can assign itself as parent
$parentCatalog = ArrayHelper::merge([0 => Module::t('blog', 'Root Catalog')], ArrayHelper::map(BlogCatalog::get(0, BlogCatalog::find()->all()), 'id', 'str_label'));
unset($parentCatalog[$model->id]);
?>

<div class="blog-catalog-form">

	<?php 
$form = ActiveForm::begin(['options' => ['class' => 'form-horizontal', 'enctype' => 'multipart/form-data'], 'fieldConfig' => ['template' => "{label}\n<div class=\"col-lg-3\">{input}</div>\n<div class=\"col-lg-5\">{error}</div>", 'labelOptions' => ['class' => 'col-lg-2 control-label']]]);
?>

	<?php 
echo $form->field($model, 'parent_id')->dropDownList($parentCatalog);
?>

	<?php 
echo $form->field($model, 'title')->textInput(['maxlength' => 255]);
?>

	<?php 
echo $form->field($model, 'surname')->textInput(['maxlength' => 128]);
Esempio n. 9
0
 /**
  * Normalizes the user-entered tags.
  */
 public static function getArrayCatalog()
 {
     return ArrayHelper::map(BlogCatalog::find()->all(), 'id', 'title');
 }