public function actionActive($id)
 {
     // проверяем число
     $id = (int) $id;
     if (empty($id)) {
         return $this->redirect('index');
     }
     $categ = new Categories();
     $categ->updateAll(['categ_active_to' => null], ['categ_id' => $id]);
     return $this->redirect('index');
 }
示例#2
0
 public function actionIndex($slug)
 {
     $this->layout = 'category';
     $query = News::find();
     $category = Categories::findOne(['slug' => $slug]);
     if (!$category) {
         $this->redirect("/");
     }
     if ('all' != $slug) {
         $catArr = [];
         $catArr[] = $category->id;
         if ($subcatList = $category->child) {
             foreach ($subcatList as $subcat) {
                 $catArr[] = $subcat->id;
             }
         }
         $query->join('INNER JOIN', NewsHasCategory::tableName(), NewsHasCategory::tableName() . ".news_id = " . News::tableName() . ".id");
         $query->where([NewsHasCategory::tableName() . '.category_id' => $catArr]);
     }
     $query->orderBy(['id' => SORT_DESC]);
     $provider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 26]]);
     $breadCrumbs = [];
     $breadCrumbs[] = ['label' => 'Главная', 'url' => '/'];
     $breadCrumbs[] = ['label' => 'Категории', 'url' => '/category/all'];
     $breadCrumbs[] = ['label' => isset($category) ? $category->name : "Все новости"];
     Yii::$app->view->title = isset($category) ? $category->name : "Все новости";
     Yii::$app->view->registerMetaTag(['name' => 'keywords', 'content' => (isset($category) ? $category->name : "Все новости") . ' новости, свежие новости, новости украины, новости сегодня, агрегатор новостей']);
     Yii::$app->view->registerMetaTag(['name' => 'description', 'content' => 'Свежие новости со всех Украинских сайтов в одном сайте. Агрегатор новостей'], 'description');
     Yii::$app->view->registerMetaTag(['name' => 'og:title', 'content' => Yii::$app->view->title], 'og:title');
     return $this->render('index', ['provider' => $provider, 'slug' => $slug, 'category' => isset($category) ? $category->name : "Все новости", 'breadcrumbs' => $breadCrumbs]);
 }
示例#3
0
 /**
  * Displays homepage.
  *
  * @param null $category
  * @param null $rubric
  * @param null $price_before
  * @param null $price_after
  * @return mixed
  */
 public function actionIndex($category = null, $rubric = null, $price_before = null, $price_after = null)
 {
     $categories = ArrayHelper::map(Categories::find()->all(), 'id', 'name');
     $rubrics = [];
     if ($category) {
         $rubrics = ArrayHelper::map(Rubrics::find()->where(['category_id' => $category])->all(), 'id', 'name');
         if ($rubric && !in_array($rubric, $rubrics)) {
             $rubric = null;
         }
     } else {
         $rubrics = ArrayHelper::map(Rubrics::find()->all(), 'id', 'name');
     }
     $query = Goods::find();
     if ($rubric) {
         $query->where(['rubric_id' => $rubric]);
     } else {
         if ($category) {
             $query->where(['rubric_id' => array_keys($rubrics)]);
         }
     }
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count()]);
     $pages->pageSize = 12;
     $models = $query->offset($pages->offset)->limit($pages->limit)->all();
     $session = Yii::$app->getSession();
     $cart = $session->has('cart') ? $session->get('cart') : [];
     return $this->render('index', ['goods' => $models, 'cart' => $cart, 'pages' => $pages, 'categories' => $categories, 'rubrics' => $rubrics, 'active_category' => $category, 'active_rubric' => $rubric, 'price_before' => $price_before, 'price_after' => $price_after]);
 }
示例#4
0
 public function actionIndex()
 {
     $params = yii::$app->getRequest()->getQueryParams();
     if (empty($params['parent_id'])) {
         $query = Categories::find()->where(["category_parent_id" => $params['parent_id']]);
     }
     return new yii\data\ActiveDataProvider(['query' => $query, 'pagination' => array('pageSize' => 50)]);
 }
示例#5
0
 /**
  * Updates an existing Rubrics model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $categories = ArrayHelper::map(Categories::find()->all(), 'id', 'name');
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'categories' => $categories]);
     }
 }
示例#6
0
 public function actionCategory()
 {
     $blog = Blog::getInstance();
     $category = Categories::findOne(['uri' => \Yii::$app->request->get('uri')]);
     if (!$category) {
         \Yii::$app->session->setFlash('incorrectCategoryUri', 'warning');
         return $this->redirect(['/category'], 302);
     }
     if (!($data = $blog->getArticlesPage($category))) {
         return $this->render('@note', ['msg' => 'noArticles']);
     }
     return $this->render('index', ['data' => $data]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Categories::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, 'parent_id' => $this->parent_id]);
     $query->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }
示例#8
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Categories::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, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Categories::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;
     }
     if (!$this->parent_id) {
         $this->parent_id = 0;
     }
     $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id, 'position' => $this->position, 'publish' => $this->publish, 'create_date' => $this->create_date, 'update_date' => $this->update_date]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'alias', $this->alias]);
     return $dataProvider;
 }
示例#10
0
 public static function getTreeSelect($parent_id, $level = 0)
 {
     $cat = Categories::find()->where(['parent_id' => $parent_id])->all();
     $arr[0] = 'Нет';
     foreach ($cat as $c) {
         $tire = '-';
         if ($level != 0) {
             for ($i = 1; $i <= $level; $i++) {
                 $tire .= "-";
             }
         }
         $arr[$c->id] = $tire . $c->name;
         $level++;
         $arr2 = self::getTreeSelect($c->id, $level);
         $arr = $arr + $arr2;
         $level--;
     }
     return $arr;
 }
示例#11
0
 /**
  * Updates an existing Category model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $parent = Categories::find()->all();
     $media = Media::find()->orderBy('id DESC')->all();
     $block = Block::find()->where(['type' => ''])->all();
     $arr = CategoryTree::getTreeSelect(0);
     $arr1[0] = 'Нет';
     foreach ($block as $v) {
         $arr1[$v->id] = $v->name;
     }
     /*$arr[0] = 'Нет';
       foreach($parent as $v){
           $arr[$v->id]=$v->name;
       }*/
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['update', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'parent' => $arr, 'media' => $media, 'block' => $arr1]);
     }
 }
示例#12
0
 public function actionIndex()
 {
     Yii::$app->view->title = 'Свежие новости';
     Yii::$app->view->registerMetaTag(['name' => 'keywords', 'content' => 'новости, свежие новости, новости украины, новости сегодня, агрегатор новостей']);
     Yii::$app->view->registerMetaTag(['name' => 'description', 'content' => 'Свежие новости со всех Украинских сайтов в одном сайте. Агрегатор новостей'], 'description');
     Yii::$app->view->registerMetaTag(['name' => 'og:title', 'content' => Yii::$app->view->title], 'og:title');
     $this->layout = 'front';
     $notInIds = [];
     $sliders = News::find()->where("created_at BETWEEN NOW() - INTERVAL '6 hour' AND NOW() AND thumb  IS NOT NULL")->orderBy(["cnt" => SORT_DESC])->limit(8)->all();
     foreach ($sliders as $item) {
         $notInIds[] = $item->id;
     }
     $topNews = News::find()->where("created_at BETWEEN NOW() - INTERVAL '6 hour' AND NOW() AND thumb  IS NOT NULL  AND id NOT IN(" . implode(",", $notInIds) . ")")->orderBy(["cnt" => SORT_DESC])->limit(4)->all();
     foreach ($topNews as $item) {
         $notInIds[] = $item->id;
     }
     $hotNews = News::find()->where("thumb  IS NOT NULL AND id NOT IN(" . implode(",", $notInIds) . ")")->orderBy(["id" => SORT_DESC])->limit(4)->all();
     foreach ($hotNews as $item) {
         $notInIds[] = $item->id;
     }
     $category = Categories::findOne(['slug' => 'ato']);
     $atoNews = News::find()->joinWith(['newsHasCategories'])->where(NewsHasCategory::tableName() . ".category_id = {$category->id} AND " . News::tableName() . ".id NOT IN(" . implode(",", $notInIds) . ")")->orderBy(["id" => SORT_DESC])->limit(7)->all();
     foreach ($atoNews as $item) {
         $notInIds[] = $item->id;
     }
     $category = Categories::findOne(['slug' => 'economic']);
     $ecoNews = News::find()->joinWith(['newsHasCategories'])->where(NewsHasCategory::tableName() . ".category_id = {$category->id} AND " . News::tableName() . ".id NOT IN(" . implode(",", $notInIds) . ")")->orderBy(["id" => SORT_DESC])->limit(7)->all();
     foreach ($ecoNews as $item) {
         $notInIds[] = $item->id;
     }
     $category = Categories::findOne(['slug' => 'sport']);
     $sportNews = News::find()->joinWith(['newsHasCategories'])->where(NewsHasCategory::tableName() . ".category_id = {$category->id} AND " . News::tableName() . ".id NOT IN(" . implode(",", $notInIds) . ")")->orderBy(["id" => SORT_DESC])->limit(3)->all();
     foreach ($sportNews as $item) {
         $notInIds[] = $item->id;
     }
     $category = Categories::findOne(['slug' => 'politics']);
     $politicsNews = News::find()->joinWith(['newsHasCategories'])->where(NewsHasCategory::tableName() . ".category_id = {$category->id} AND " . News::tableName() . ".id NOT IN(" . implode(",", $notInIds) . ")")->orderBy(["id" => SORT_DESC])->limit(3)->all();
     return $this->render('index', ['topNews' => $topNews, 'hotNews' => $hotNews, 'atoNews' => $atoNews, 'ecoNews' => $ecoNews, 'sportNews' => $sportNews, 'politicsNews' => $politicsNews, 'sliders' => $sliders]);
 }
示例#13
0
文件: Category.php 项目: apuc/admin
 public static function getParentCategories($id)
 {
     $cat = Categories::find()->where(['parent_id' => $id])->all();
     $html = '';
     foreach ($cat as $c) {
         $html .= '<div class="product">
                 ' . Html::a($c->name, ['/category', 'c' => $c->id]) . '
                 <div class="info">
                     <span></span>
                     <div class="hint">
                        ' . $c->description . '
                     </div>
                 </div>
             </div>';
         //Debag::prn('123');
     }
     if (count($cat) > 4) {
         $html .= '</div><a href="#" class="showall">показать все</a>';
     } else {
         $html .= '</div><div class="empty"></div>';
     }
     return $html;
 }
示例#14
0
 public function getCategory()
 {
     return $this->hasOne(Categories::className(), array('id' => 'category'));
 }
示例#15
0
 /**
  * Get Breadcrumbs
  *
  * @param $id
  * @return array
  */
 private function _getBreadcrumbs($id)
 {
     $breadcrumbs = [];
     if ($id > 0) {
         $this->_categories = Categories::find()->indexBy('id')->asArray()->all();
         $catId = (int) $id;
         while (true) {
             if ($catId === 0) {
                 break;
             }
             array_unshift($breadcrumbs, ['label' => $this->_categories[$catId]['title'], 'url' => $this->_categories[$catId]['id']]);
             $catId = (int) $this->_categories[$catId]['parent_id'];
         }
     }
     return $breadcrumbs;
 }
示例#16
0
 /**
  * Finds the Categories model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Categories the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Categories::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#17
0
" onblur="if(this.value=='') {this.value='Поиск.';
}"
                           onfocus="if(this.value=='Поиск.') {this.value='';
}" class="ft" name="q"/>
                    <input type="submit" value="" class="fs">
                </form>
            </div>

            <!-- Nav -->
            <nav id="nav">
                <ul class="sf-menu">
                    <?php 
if ($categories = \common\models\Categories::find()->where('parent_id IS NULL')->with('child')->orderBy('order ASC')->all()) {
    ?>
                        <?php 
    $current = \common\models\Categories::findOne(['slug' => isset(Yii::$app->requestedParams[0]) ? Yii::$app->requestedParams[0] : 'all']);
    ?>


                        <?php 
    foreach ($categories as $category) {
        ?>

                            <li <?php 
        if ($current && $current->id == $category->id) {
            ?>
class="current"<?php 
        }
        ?>
>
                                <a href="<?php 
示例#18
0
文件: _form.php 项目: iryska/nagginua
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $model common\models\CategoryWords */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="category-words-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'category_id')->dropDownList(ArrayHelper::map(\common\models\Categories::find()->asArray()->all(), 'id', 'name'), ['value' => $model->category_id]);
?>

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

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
 /**
  * Group data for Html::activeDropDownList method
  * @return array
  */
 private function getItems()
 {
     return ['categories' => ArrayHelper::map(Categories::find()->all(), 'id', 'name'), 'article_status' => [10 => 'Опубліковано', 0 => 'Прихована стаття'], 'comments_status' => [10 => 'Дозволені', 0 => 'Заборонені']];
 }
示例#20
0
文件: _form.php 项目: saqbest/res.dev
/* @var $this yii\web\View */
/* @var $model common\models\Places */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="places-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>
    <?php 
echo $form->field($model, 'category_id')->widget(Select2::classname(), ['data' => \yii\helpers\ArrayHelper::map(\common\models\Categories::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'Select a state ...'], 'pluginOptions' => ['allowClear' => true]]);
?>

    <?php 
echo $form->field($model, 'kitchensIds')->widget(Select2::classname(), ['data' => $model->getdropKitchens(), 'options' => ['placeholder' => 'Select a Kitchens ...', 'multiple' => true], 'pluginOptions' => ['allowClear' => true]])->label('Kitchens');
?>
    <?php 
echo $form->field($model, 'servicesIds')->widget(Select2::classname(), ['data' => $model->getdropServices(), 'options' => ['placeholder' => 'Select a Services ...', 'multiple' => true], 'pluginOptions' => ['allowClear' => true]])->label('Services');
?>

    <?php 
echo $form->field($model, 'metrosIds')->widget(Select2::classname(), ['data' => $model->getdropMetros(), 'options' => ['placeholder' => 'Select a Metros ...', 'multiple' => true], 'pluginOptions' => ['allowClear' => true]])->label('Metros');
?>

    <?php 
echo $form->field($model, 'description')->widget(CKEditor::className(), ['editorOptions' => ['preset' => 'basic', 'inline' => false]]);
示例#21
0
文件: _form.php 项目: iryska/nagginua
    ?>
]"
                       value="<?php 
    echo $pattern;
    ?>
" maxlength="255" placeholder="<?php 
    echo $placeholder;
    ?>
">
            </div>

        <?php 
}
?>

    <?php 
echo $form->field($model, 'category_id')->dropDownList(\yii\helpers\ArrayHelper::map(array_merge(['id' => null, 'name' => null], \common\models\Categories::find()->orderBy('name')->asArray()->all()), 'id', 'name'), ['value' => $model->category_id]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
示例#22
0
文件: News.php 项目: iryska/nagginua
 public function getCategoryList()
 {
     return Categories::find()->join('inner join', NewsHasCategory::tableName(), NewsHasCategory::tableName() . ".category_id = " . Categories::tableName() . ".id")->where([NewsHasCategory::tableName() . ".news_id" => $this->id])->all();
 }
示例#23
0
 /**
  * Products.
  *
  * @return mixed
  */
 public function actionProducts()
 {
     try {
         $product_id = Yii::$app->request->queryParams["id"];
         $product = Products::getProductById($product_id);
         $model = Categories::getCategories($product['cat_id']);
         $modelParent = Categories::getCategoriesParent($product['cat_id']);
     } catch (InvalidParamException $e) {
         throw new BadRequestHttpException($e->getMessage());
     }
     // breadcrumbs
     $parent_breadcrumbs = array();
     $i = 0;
     $parent_breadcrumbs[$i] = Categories::getCategoriesParent($modelParent['parent_id']);
     $parent_cat = NULL;
     while ($parent_cat = Categories::getCategoriesParent($parent_breadcrumbs[$i]['parent_id'])) {
         $i++;
         $parent_breadcrumbs[$i] = $parent_cat;
     }
     return $this->render('products', ['model' => $model, 'modelParent' => $modelParent, 'parent_breadcrumbs' => $parent_breadcrumbs, 'product' => $product]);
 }
 /**
  * Lists all Products models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new SearchProducts();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'cat_id' => Yii::$app->request->queryParams["SearchProducts"]["cat_id"], 'back' => Categories::getParentParentId(Yii::$app->request->queryParams["SearchProducts"]["cat_id"])]);
 }
示例#25
0
 /**
  * Возвращает массив с одной категорией, если передана подкатегория
  *
  * @param null|integer $id
  * @return array
  */
 public static function catForSubs($id = null)
 {
     $query = Categories::find();
     if ($id != null && ($subCat = Subcategory::findOne($id)) !== null) {
         /** @var TorrentSearch $category */
         $category = self::find()->where(['forum_name_id_attr' => $id])->one();
         $query->andWhere(['id' => $category->category_attr]);
     }
     return ArrayHelper::map($query->asArray()->all(), 'id', 'category_name');
 }
 /**
  * Импорт категорий
  *
  * @param $path
  * @return array|\yii\db\ActiveRecord[]
  */
 private function importCategories($path)
 {
     $file = $path . DIRECTORY_SEPARATOR . 'category_info.csv';
     $row = 1;
     if (($handle = fopen($file, "r")) !== FALSE) {
         while (($data = fgetcsv($handle, 0, ";")) !== FALSE) {
             $row++;
             $this->stdout("Row " . $row . ":\n");
             $model = Categories::findOne($data[0]);
             if ($model === null) {
                 $model = new Categories(['id' => $data[0], 'category_name' => $data[1], 'file_name' => $data[2]]);
             }
             if ($model->save()) {
                 $this->stdout("Category {$model->id} with name '{$model->category_name}' imported\n");
             }
             $this->stdout("\n");
         }
     } else {
         return false;
     }
     return Categories::find()->all();
 }
示例#27
0
 public function init()
 {
     parent::init();
     $this->categories = Categories::findAll(['status' => self::STATUS_SIDEBAR_CATEGORY]);
 }
示例#28
0
                    {
                        var js, fjs = d.getElementsByTagName( s )[0], p = /^http:/.test( d.location ) ? 'http' : 'https';
                        if (! d.getElementById( id )) {
                            js = d.createElement( s );
                            js.id = id;
                            js.src = p + "://platform.twitter.com/widgets.js";
                            fjs.parentNode.insertBefore( js, fjs );
                        }
                    }( document, "script", "twitter-wjs" );</script>
            </div>
        </div>
        <div class="column-one-fourth">
            <h5 class="line"><span>Навигация.</span></h5>
            <ul class="footnav">
                <?php 
if ($categories = \common\models\Categories::find()->where('parent_id IS NULL')->orderBy('order ASC')->all()) {
    ?>

                    <?php 
    foreach ($categories as $category) {
        ?>
                        <li>
                            <a href="<?php 
        echo $category->getLink();
        ?>
"><i
                                    class="icon-right-open"></i><?php 
        echo \yii\helpers\Html::encode($category->name);
        ?>
</a>
                        </li>
示例#29
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCateg()
 {
     return $this->hasOne(Categories::className(), ['categ_id' => 'categ_id']);
 }
示例#30
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCategories()
 {
     return $this->hasMany(Categories::className(), ['inc_exp_id' => 'inc_exp_id']);
 }