Example #1
0
 public function getBlocks($page)
 {
     $sort = explode(',', $page->sort);
     $html = '';
     foreach ($sort as $p) {
         if ($p[0] == 'i') {
             $blockId = explode('_', $p);
             $blockId = $blockId[1];
             $block = Block::find()->where(['id' => $blockId])->one();
             $html .= $block->code;
         }
         if ($p == 'sub') {
         }
         if ($p == 'des') {
             /*$html .= "<div class='description'>$page->description</div>";*/
         }
         if ($p[0] == 'y') {
             $blockId = explode('_', $p);
             $blockId = $blockId[1];
             $block = Block::find()->where(['id' => $blockId])->one();
             $html .= $block->code;
         }
     }
     return eval('?>' . $html . '<?php;');
 }
Example #2
0
 /**
  * Creates data provider instance with search query applied
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Block::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'slug' => $this->slug, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'title', $this->title]);
     $query->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Example #3
0
 /**
  * Creates data provider instance with search query applied
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Block::find();
     if (!\Yii::$app->user->can('administrator')) {
         $query->forDomain();
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'slug' => $this->slug, 'status' => $this->status, 'domain_id' => $this->domain_id]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'body', $this->body])->andFilterWhere(['like', 'before_body', $this->before_body])->andFilterWhere(['like', 'after_body', $this->after_body])->andFilterWhere(['like', 'on_scenario', $this->on_scenario]);
     return $dataProvider;
 }
Example #4
0
 /**
  * Updates an existing Pages 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);
     $media = Media::find()->orderBy('id DESC')->all();
     $block = Block::find()->where(['type' => ''])->all();
     $arr[0] = 'Нет';
     foreach ($block as $b) {
         $arr[$b->id] = $b->name;
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['update', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'media' => $media, 'block' => $arr]);
     }
 }
Example #5
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]);
     }
 }
Example #6
0
 public function saveSort($sort)
 {
     // $blocks_id=array();
     $this->sort = $sort;
     //получаем массив значений значений
     $blocks_id = explode(':', $this->sort);
     //print_r($blocks_id);
     //die();
     /*
             $models = Block::find()
                 ->leftJoin('landing_block', '`landing_block`.`block_id` = `block`.`block_id`')
                 ->where(['not in', 'landing_block.landing_id', $blocks_id])
                 ->orWhere(['landing_block.landing_id' => NULL]);
     
             return $models;
     */
     // Делаем невидимыми все блоки лендинга
     $blocks = Block::find()->where(['landing_id' => $this->landing_id])->all();
     foreach ($blocks as $block) {
         $block->visible = 0;
         $block->save();
     }
     $i = 1;
     foreach ($blocks_id as $block_id) {
         $landingBlock = Block::findOne($block_id);
         //    ->where(['block_id' => $block_id,'landing_id' => $this->landing_id])
         //    ->one();
         if ($landingBlock !== null) {
         } else {
             die('Ошибка 678');
             //$landingBlock = new Block();
             //$landingBlock->type_id = $block_id;
             //$landingBlock->landing_id = $this->landing_id;
         }
         $landingBlock->visible = 1;
         $landingBlock->sort = $i;
         $landingBlock->save();
         $i++;
     }
 }
<?
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use common\models\Block;
use common\models\Type;

// Провайдер по блокам
$query = Block::find()->where(['landing_id'=>$model->landing_id])->orderBy('sort');


$blocks_array = $query->all();

// Подгрузка параметров из конфига
$phone = \Yii::$app->params['phone'];


// Меню лендинга
$menu = array();

// Добавление пунктов
foreach ($blocks_array as $block_array){

	// Тип блока
	$type = Type::findOne($block_array->type_id);

	if (($block_array->menu_label) and ($type->code)) {
		$menu[] = [
			'label' => $block_array->menu_label,
			'url' => '#' . $type->code,
			'options' => [
Example #8
0
 /**
  * Finds the Block model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Block the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Block::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #9
0
File: _form.php Project: apuc/admin
        unset($sortDefault[$value_to_delete]);
        //Удаляем элемент массива
        $sortDefault = array_flip($sortDefault);
        //Меняем местами ключи и значения
    }
}
foreach ($sortDefault as $sd) {
    if ($sd[0] == 'y') {
        $name = explode('_', $sd);
        $name = \common\models\Block::find()->where(['id' => $name[1]])->one();
        $name = $name->name;
        echo '<li class="noPublick sortAll" data-type="' . $sd . '">' . $name . ' | <a class="toPublick" href="#">Опубликовать</a> | <a class="delCustBlock" href="#">Удалить</a></li>';
    } elseif ($sd[0] == 'i') {
        $blockId = explode('_', $sd);
        $blockId = $blockId[1];
        $block = \common\models\Block::find()->where(['id' => $blockId])->one();
        $name = $block->name;
        echo '<li class="noPublick sortAll" data-type="' . $sd . '">Индивидуальный блок (' . $name . ') | <a class="toPublick" href="#">Опубликовать</a> | <a href="#" data-block-id="' . $blockId . '">Редактировать</a> | <a data-confirm="Удалить блок?" class="delCustBlock" href="#">Удалить</a></li>';
    } else {
        $name = \common\classes\Template::getBlockName($sd);
        echo '<li class="noPublick sortAll" data-type="' . $sd . '">' . $name . ' | <a class="toPublick" href="#">Опубликовать</a></li>';
    }
}
?>
                </ul>
            </div>
        </div>
        <div id="panel3" class="tab-pane fade <?php 
echo $tabContent3;
?>
">
Example #10
0
 public function afterDelete()
 {
     $model = Block::find()->andWhere(['locale_group_id' => $this->locale_group_id, 'domain_id' => Yii::$app->user->identity->domain_id])->one();
     if ($model) {
         $model->delete();
     }
     return parent::afterDelete();
 }
Example #11
0
 public function afterDelete()
 {
     Block::deleteAll(['locale_group_id' => $this->locale_group_id]);
     return parent::afterDelete();
 }
Example #12
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\Block;
use common\models\Type;
use yii\data\ActiveDataProvider;
use yii\widgets\ListView;
use yii\grid\GridView;
use yii\grid\ActionColumn;
// Получаем переменные
$blocks_selected = new ActiveDataProvider(['query' => Block::find()->where(['landing_id' => $model->landing_id])->orderBy('sort'), 'pagination' => ['pageSize' => 100]]);
$blocks_selected_array = Type::getLandingBlocks($model->landing_id)->asArray()->all();
$blocks_id_selected = array();
foreach ($blocks_selected_array as $block_selected_array) {
    $blocks_id_selected[] = $block_selected_array['type_id'];
}
$blocks_not_selected = new ActiveDataProvider(['query' => Type::getNotLandingBlocks($blocks_id_selected)]);
//
?>

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

<div class="row">
    <div class="col-md-4">
        <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => true]);
?>
    </div>
Example #13
0
 public static function get_block($key)
 {
     $block = Block::find()->where(['key' => $key])->one();
     eval('?>' . $block->code . '<?php;');
 }
Example #14
0
 public function getBlock()
 {
     return $this->hasMany(Block::className(), ['type_id' => 'type_id']);
 }