Inheritance: extends Core, use trait skeeks\cms\traits\ValidateRulesTrait
示例#1
0
 public function init()
 {
     parent::init();
     if (!$this->filter) {
         $this->filter = \yii\helpers\ArrayHelper::map(\skeeks\cms\models\CmsSite::find()->all(), 'code', 'name');
     }
 }
示例#2
0
 protected function _run()
 {
     $key = $this->getCacheKey() . 'run';
     $dependency = new TagDependency(['tags' => [$this->className() . (string) $this->namespace, (new CmsSite())->getTableCacheTag()]]);
     $result = \Yii::$app->cache->get($key);
     if ($result === false || $this->enabledRunCache == Cms::BOOL_N) {
         $this->activeQuery = CmsSite::find();
         if ($this->active == Cms::BOOL_Y) {
             $this->activeQuery->active();
         } else {
             if ($this->active == Cms::BOOL_N) {
                 $this->activeQuery->active(false);
             }
         }
         if ($this->limit) {
             $this->activeQuery->limit($limit);
         }
         if ($this->orderBy) {
             $this->activeQuery->orderBy([$this->orderBy => (int) $this->order]);
         }
         $result = parent::_run();
         \Yii::$app->cache->set($key, $result, (int) $this->runCacheDuration, $dependency);
     }
     return $result;
 }
示例#3
0
 /**
  * @return CmsSite
  */
 public function getSite()
 {
     if ($this->_site === null) {
         if (\Yii::$app instanceof \yii\console\Application) {
             $this->_site = CmsSite::find()->active()->andWhere(['def' => Cms::BOOL_Y])->one();
         } else {
             $this->_serverName = \Yii::$app->getRequest()->getServerName();
             $dependencySiteDomain = new TagDependency(['tags' => [(new CmsSiteDomain())->getTableCacheTag()]]);
             $cmsDomain = CmsSiteDomain::getDb()->cache(function ($db) {
                 return CmsSiteDomain::find()->where(['domain' => $this->_serverName])->one();
             }, null, $dependencySiteDomain);
             /**
              * @var CmsSiteDomain $cmsDomain
              */
             if ($cmsDomain) {
                 $this->_site = $cmsDomain->cmsSite;
             } else {
                 $this->_site = CmsSiteDomain::getDb()->cache(function ($db) {
                     return CmsSite::find()->active()->andWhere(['def' => Cms::BOOL_Y])->one();
                 }, null, new TagDependency(['tags' => [(new CmsSite())->getTableCacheTag()]]));
             }
         }
     }
     return $this->_site;
 }
示例#4
0
 /**
  * @return CmsSite
  */
 public function getSite()
 {
     if ($this->_site === null) {
         if (\Yii::$app instanceof \yii\console\Application) {
             $this->_site = CmsSite::find()->active()->andWhere(['def' => Cms::BOOL_Y])->one();
         } else {
             $this->_serverName = \Yii::$app->getRequest()->getServerName();
             try {
                 $dependencySiteDomain = new TagDependency(['tags' => [(new CmsSiteDomain())->getTableCacheTag()]]);
                 $cmsDomain = CmsSiteDomain::getDb()->cache(function ($db) {
                     return CmsSiteDomain::find()->where(['domain' => $this->_serverName])->one();
                 }, null, $dependencySiteDomain);
                 /**
                  * @var CmsSiteDomain $cmsDomain
                  */
                 if ($cmsDomain) {
                     $this->_site = $cmsDomain->cmsSite;
                 } else {
                     $this->_site = CmsSiteDomain::getDb()->cache(function ($db) {
                         return CmsSite::find()->active()->andWhere(['def' => Cms::BOOL_Y])->one();
                     }, null, new TagDependency(['tags' => [(new CmsSite())->getTableCacheTag()]]));
                 }
             } catch (Exception $e) {
                 if (in_array($e->getCode(), NotConnectedToDbException::$invalidConnectionCodes)) {
                     throw new NotConnectedToDbException();
                 }
             }
         }
     }
     return $this->_site;
 }
示例#5
0
 public function init()
 {
     $this->name = "Управление сайтами";
     $this->modelShowAttribute = "name";
     $this->modelClassName = CmsSite::className();
     parent::init();
 }
示例#6
0
 public function init()
 {
     $this->name = \Yii::t('skeeks/cms', "Site management");
     $this->modelShowAttribute = "name";
     $this->modelClassName = CmsSite::className();
     parent::init();
 }
 /**
  * @inheritdoc
  */
 public function actions()
 {
     return ArrayHelper::merge(parent::actions(), ['index' => ['columns' => [['attribute' => 'status', 'class' => \yii\grid\DataColumn::className(), 'filter' => \skeeks\cms\comments2\models\Comments2Message::$statuses, 'format' => 'raw', 'value' => function (\skeeks\cms\comments2\models\Comments2Message $model) {
         if ($model->status == \skeeks\cms\comments2\models\Comments2Message::STATUS_NEW) {
             $class = "default";
         } else {
             if ($model->status == \skeeks\cms\comments2\models\Comments2Message::STATUS_PROCESSED) {
                 $class = "warning";
             } else {
                 if ($model->status == \skeeks\cms\comments2\models\Comments2Message::STATUS_CANCELED) {
                     $class = "danger";
                 } else {
                     if ($model->status == \skeeks\cms\comments2\models\Comments2Message::STATUS_ALLOWED) {
                         $class = "success";
                     }
                 }
             }
         }
         return '<span class="label label-' . $class . '">' . \yii\helpers\ArrayHelper::getValue(\skeeks\cms\comments2\models\Comments2Message::$statuses, $model->status) . '</span>';
     }], ['class' => \skeeks\cms\grid\CreatedAtColumn::className(), 'label' => 'Добавлен'], ['class' => \skeeks\cms\grid\CreatedByColumn::className()], ['attribute' => 'site_code', 'class' => \yii\grid\DataColumn::className(), 'filter' => \yii\helpers\ArrayHelper::map(\skeeks\cms\models\CmsSite::find()->all(), 'code', 'name'), 'value' => function (\skeeks\cms\comments2\models\Comments2Message $model) {
         return $model->site->name;
     }], ['attribute' => 'element_id', 'relation' => 'element', 'class' => \skeeks\cms\grid\CmsContentElementColumn::className()], ['filter' => \yii\helpers\ArrayHelper::map(\skeeks\cms\models\CmsContent::find()->all(), 'id', 'name'), 'attribute' => 'content_id', 'class' => \yii\grid\DataColumn::className(), 'value' => function (\skeeks\cms\comments2\models\Comments2Message $model) {
         return $model->element->cmsContent->name;
     }]]], "status-allowed-multi" => ['class' => AdminMultiModelEditAction::className(), "name" => \skeeks\cms\comments2\Module::t('app', 'Approve'), "eachCallback" => [$this, 'eachMultiStatusAllowed']], "status-canceled-multi" => ['class' => AdminMultiModelEditAction::className(), "name" => \skeeks\cms\comments2\Module::t('app', 'Reject'), "eachCallback" => [$this, 'eachMultiStatusCanceled']], "status-processed-multi" => ['class' => AdminMultiModelEditAction::className(), "name" => \skeeks\cms\comments2\Module::t('app', 'In progress'), "eachCallback" => [$this, 'eachMultiStatusProcessed']]]);
 }
 public function safeUp()
 {
     $tableExist = $this->db->getTableSchema("{{%shop_tax}}", true);
     if ($tableExist) {
         return true;
     }
     $tableOptions = null;
     if ($this->db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
     }
     $this->createTable("{{%shop_tax}}", ['id' => $this->primaryKey(), 'created_by' => $this->integer(), 'updated_by' => $this->integer(), 'created_at' => $this->integer(), 'updated_at' => $this->integer(), 'name' => $this->string(255)->notNull(), 'description' => $this->text(), 'code' => $this->string(50)->notNull(), 'site_code' => $this->string(15)], $tableOptions);
     $this->createIndex('updated_by', '{{%shop_tax}}', 'updated_by');
     $this->createIndex('created_by', '{{%shop_tax}}', 'created_by');
     $this->createIndex('created_at', '{{%shop_tax}}', 'created_at');
     $this->createIndex('updated_at', '{{%shop_tax}}', 'updated_at');
     $this->createIndex('name', '{{%shop_tax}}', 'name');
     $this->createIndex('code', '{{%shop_tax}}', 'code');
     $this->createIndex('site_code', '{{%shop_tax}}', 'site_code');
     $this->execute("ALTER TABLE {{%shop_tax}} COMMENT = 'Налоги';");
     $this->addForeignKey('shop_tax_created_by', "{{%shop_tax}}", 'created_by', '{{%cms_user}}', 'id', 'SET NULL', 'SET NULL');
     $this->addForeignKey('shop_tax_updated_by', "{{%shop_tax}}", 'updated_by', '{{%cms_user}}', 'id', 'SET NULL', 'SET NULL');
     $this->addForeignKey('shop_tax_site_code', "{{%shop_tax}}", 'site_code', '{{%cms_site}}', 'code', 'SET NULL', 'SET NULL');
     $site_code = null;
     $site = \skeeks\cms\models\CmsSite::find()->def()->one();
     if ($site) {
         $site_code = $site->code;
     }
     $this->insert('{{%shop_tax}}', ['name' => 'НДС', 'code' => 'NDS', 'site_code' => $site_code]);
 }
示例#9
0
    /**
     * @inheritdoc
     */
    public function actions()
    {
        return ArrayHelper::merge(parent::actions(), ['index' => ["columns" => [['class' => CreatedAtColumn::className()], 'id', ['class' => DataColumn::className(), 'attribute' => 'status_code', 'format' => 'raw', 'filter' => ArrayHelper::map(ShopOrderStatus::find()->all(), 'code', 'name'), 'value' => function (ShopOrder $order) {
            return Html::label($order->status->name, null, ['style' => "background: {$order->status->color}", 'class' => "label"]) . "<br />" . Html::tag("small", \Yii::$app->formatter->asDatetime($order->status_at) . " (" . \Yii::$app->formatter->asRelativeTime($order->status_at) . ")");
        }], ['class' => BooleanColumn::className(), 'attribute' => 'payed', 'format' => 'raw'], ['class' => DataColumn::className(), 'attribute' => "canceled", 'format' => "raw", 'filter' => ['Y' => \Yii::t('app', 'Yes'), 'N' => \Yii::t('app', 'No')], 'value' => function (ShopOrder $shopOrder) {
            return $shopOrder->canceled == "Y" ? \Yii::t('app', 'Yes') : \Yii::t('app', 'No');
        }], ['class' => DataColumn::className(), 'attribute' => "user_id", 'label' => \skeeks\cms\shop\Module::t('app', 'Buyer'), 'format' => "raw", 'value' => function (ShopOrder $shopOrder) {
            return (new \skeeks\cms\shop\widgets\AdminBuyerUserWidget(['user' => $shopOrder->user]))->run();
        }], ['class' => DataColumn::className(), 'filter' => false, 'format' => 'raw', 'label' => \skeeks\cms\shop\Module::t('app', 'Good'), 'value' => function (ShopOrder $model) {
            if ($model->shopBaskets) {
                $result = [];
                foreach ($model->shopBaskets as $shopBasket) {
                    $money = \Yii::$app->money->intlFormatter()->format($shopBasket->money);
                    $result[] = Html::a($shopBasket->name, $shopBasket->product->cmsContentElement->url, ['target' => '_blank']) . <<<HTML
  — {$shopBasket->quantity} {$shopBasket->measure_name}
HTML;
                }
                return implode('<hr style="margin: 0px;"/>', $result);
            }
        }], ['class' => DataColumn::className(), 'format' => 'raw', 'attribute' => 'price', 'label' => \skeeks\cms\shop\Module::t('app', 'Sum'), 'value' => function (ShopOrder $model) {
            return \Yii::$app->money->intlFormatter()->format($model->money);
        }], ['class' => DataColumn::className(), 'filter' => ArrayHelper::map(CmsSite::find()->active()->all(), 'id', 'name'), 'attribute' => 'site_id', 'format' => 'raw', 'visible' => false, 'label' => \skeeks\cms\shop\Module::t('app', 'Site'), 'value' => function (ShopOrder $model) {
            return $model->site->name . " [{$model->site->code}]";
        }]]], "view" => ['class' => AdminOneModelEditAction::className(), "name" => \Yii::t('app', "Информация"), "icon" => "glyphicon glyphicon-eye-open", "priority" => 5, "callback" => [$this, 'view']]]);
    }
示例#10
0
 public function indexData()
 {
     if (self::$indexData) {
         return self::$indexData;
     }
     $models = Tree::findRoots()->joinWith('cmsSiteRelation')->orderBy([CmsSite::tableName() . ".priority" => SORT_ASC])->all();
     self::$indexData = ['models' => $models];
     return self::$indexData;
 }
 public function safeUp()
 {
     $tableExist = $this->db->getTableSchema("{{%shop_person_type_site}}", true);
     if ($tableExist) {
         return true;
     }
     $tableOptions = null;
     if ($this->db->driverName === 'mysql') {
         $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
     }
     $this->createTable("{{%shop_person_type_site}}", ['person_type_id' => $this->integer()->notNull(), 'site_code' => "CHAR(15) NOT NULL"], $tableOptions);
     $this->createIndex('site_code__person_type_id', '{{%shop_person_type_site}}', ['person_type_id', 'site_code'], true);
     $this->execute("ALTER TABLE {{%shop_person_type_site}} COMMENT = 'Связь плательщиков с сайтами';");
     $this->addForeignKey('shop_person_type_site_person_type_id', "{{%shop_person_type_site}}", 'person_type_id', '{{%shop_person_type}}', 'id', 'CASCADE', 'CASCADE');
     $this->addForeignKey('shop_person_type_site_site_code', "{{%shop_person_type_site}}", 'site_code', '{{%cms_site}}', 'code', 'CASCADE', 'CASCADE');
     $persons = \skeeks\cms\shop\models\ShopPersonType::find()->all();
     $site = \skeeks\cms\models\CmsSite::find()->def()->one();
     if ($persons && $site) {
         foreach ($persons as $person) {
             $this->insert('{{%shop_person_type_site}}', ['person_type_id' => $person->id, 'site_code' => $site->code]);
         }
     }
 }
示例#12
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSiteCodes()
 {
     return $this->hasMany(CmsSite::className(), ['code' => 'site_code'])->viaTable('{{%cms_event_email_template_site}}', ['event_email_template_id' => 'id']);
 }
示例#13
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCmsSites()
 {
     return $this->hasMany(CmsSite::className(), ['lang_code' => 'code']);
 }
示例#14
0
 /**
  * @param $model
  *
  * @return string
  */
 public function renderNodeName($model)
 {
     $result = $model->name;
     $additionalName = '';
     if ($model->level == 0) {
         $site = \skeeks\cms\models\CmsSite::findOne(['code' => $model->site_code]);
         if ($site) {
             $additionalName = $site->name;
         }
     }
     if ($additionalName) {
         $result .= " [{$additionalName}]";
     }
     return $result;
 }
示例#15
0
文件: _form.php 项目: skeeks-cms/cms

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

    <?php 
echo $form->fieldSet(\Yii::t('skeeks/cms', "Main"));
?>

            <? if ($code = \Yii::$app->request->get('site_code')) : ?>
                <?php 
echo $form->field($model, 'site_code')->hiddenInput(['value' => $code])->label(false);
?>
            <? else: ?>
                <?php 
echo $form->field($model, 'site_code')->widget(\skeeks\widget\chosen\Chosen::className(), ['items' => \yii\helpers\ArrayHelper::map(\skeeks\cms\models\CmsSite::find()->all(), "code", "name")]);
?>
            <? endif; ?>

        <?php 
echo $form->field($model, 'domain')->textInput();
?>

    <?php 
echo $form->fieldSetEnd();
echo $form->buttonsStandart($model);
?>

<?php 
ActiveForm::end();
示例#16
0
    <div class="row">
        <div class="col-lg-2">
            <ul class="nav nav-pills nav-stacked">
              <li role="presentation" class="<?php 
echo in_array(\Yii::$app->controller->action->id, ['index']) ? "active" : "";
?>
"><a href="<?php 
echo \yii\helpers\Url::to('index') . "?" . http_build_query(\Yii::$app->request->get());
?>
">
                 <i class="glyphicon glyphicon-asterisk"></i> <?php 
echo \Yii::t('skeeks/cms', 'The default settings');
?>
              </a></li>

                <? if (\skeeks\cms\models\CmsSite::find()->active()->count() > 1) : ?>
                  <li role="presentation" class="<?php 
echo in_array(\Yii::$app->controller->action->id, ['sites', 'site']) ? "active" : "";
?>
"><a href="<?php 
echo \yii\helpers\Url::to('sites') . "?" . http_build_query(\Yii::$app->request->get());
?>
">
                     <i class="glyphicon glyphicon-globe"></i> <?php 
echo \Yii::t('skeeks/cms', 'Sites settings');
?>
                  </a></li>
                <? endif; ?>

                <li role="presentation" class="<?php 
echo in_array(\Yii::$app->controller->action->id, ['users', 'user']) ? "active" : "";
示例#17
0
/* @var $dataProvider yii\data\ActiveDataProvider */
?>
<? $pjax = \skeeks\cms\modules\admin\widgets\Pjax::begin(); ?>

    <?php 
echo $this->render('_search', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
?>

<?php 
echo \skeeks\cms\modules\admin\widgets\GridViewStandart::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'adminController' => $controller, 'pjax' => $pjax, 'columns' => [['attribute' => 'status', 'class' => \yii\grid\DataColumn::className(), 'filter' => \skeeks\modules\cms\form2\models\Form2FormSend::getStatuses(), 'format' => 'raw', 'value' => function (\skeeks\modules\cms\form2\models\Form2FormSend $model) {
    if ($model->status == \skeeks\modules\cms\form2\models\Form2FormSend::STATUS_NEW) {
        $class = "danger";
    } else {
        if ($model->status == \skeeks\modules\cms\form2\models\Form2FormSend::STATUS_PROCESSED) {
            $class = "warning";
        } else {
            if ($model->status == \skeeks\modules\cms\form2\models\Form2FormSend::STATUS_EXECUTED) {
                $class = "success";
            }
        }
    }
    return '<span class="label label-' . $class . '">' . \yii\helpers\ArrayHelper::getValue(\skeeks\modules\cms\form2\models\Form2FormSend::getStatuses(), $model->status) . '</span>';
}], ['class' => \skeeks\cms\grid\DateTimeColumnData::className(), 'attribute' => 'processed_at'], ['class' => \skeeks\cms\grid\UserColumnData::className(), 'attribute' => 'processed_by'], ['attribute' => 'form_id', 'class' => \yii\grid\DataColumn::className(), 'filter' => \yii\helpers\ArrayHelper::map(\skeeks\modules\cms\form2\models\Form2Form::find()->all(), 'id', 'name'), 'value' => function (\skeeks\modules\cms\form2\models\Form2FormSend $model) {
    return $model->form->name;
}], ['class' => \skeeks\cms\grid\CreatedAtColumn::className(), 'label' => 'Отправлена'], ['attribute' => 'site_code', 'class' => \yii\grid\DataColumn::className(), 'filter' => \yii\helpers\ArrayHelper::map(\skeeks\cms\models\CmsSite::find()->all(), 'code', 'name'), 'value' => function (\skeeks\modules\cms\form2\models\Form2FormSend $model) {
    return $model->site->name;
}], 'comment']]);
?>

<? $pjax::end(); ?>
示例#18
0
<?php

/**
 * @author Semenov Alexander <*****@*****.**>
 * @link http://skeeks.com/
 * @copyright 2010 SkeekS (СкикС)
 * @date 18.12.2016
 */
/* @var $this yii\web\View */
/* @var $widget \skeeks\cms\widgets\tree\CmsTreeWidget */
/* @var $model \skeeks\cms\models\CmsTree */
$widget = $this->context;
$result = $model->name;
$additionalName = '';
if ($model->level == 0) {
    $site = \skeeks\cms\models\CmsSite::findOne(['code' => $model->site_code]);
    if ($site) {
        $additionalName = $site->name;
    }
} else {
    if ($model->name_hidden) {
        $additionalName = $model->name_hidden;
    }
}
if ($additionalName) {
    $result .= " [{$additionalName}]";
}
$controllElement = \Yii::$app->controller->renderNodeControll($model);
?>

<?php 
示例#19
0
$form = ActiveForm::begin();
?>

<?php 
echo $form->fieldSet(\skeeks\cms\shop\Module::t('app', 'Cumulative program'));
?>

    <?php 
echo $form->fieldCheckboxBoolean($model, 'active');
?>
    <?php 
echo $form->field($model, 'name')->textInput();
?>

    <?php 
echo $form->fieldSelect($model, 'site_id', \yii\helpers\ArrayHelper::map(\skeeks\cms\models\CmsSite::find()->all(), 'id', 'name'));
?>


<?php 
echo $form->fieldSetEnd();
?>

<?php 
echo $form->fieldSet(\skeeks\cms\shop\Module::t('app', 'Currency amount paid orders and discounts'));
?>
    <?php 
echo $form->fieldSelect($model, 'currency_code', \yii\helpers\ArrayHelper::map(\skeeks\modules\cms\money\models\Currency::find()->active()->all(), 'code', 'code'));
?>

<?php 
示例#20
0
echo \skeeks\cms\modules\admin\widgets\GridViewStandart::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'pjax' => $pjax, 'adminController' => \Yii::$app->controller, 'columns' => [['class' => \skeeks\cms\grid\UpdatedAtColumn::className()], ['class' => \yii\grid\DataColumn::className(), 'filter' => false, 'format' => 'raw', 'label' => \Yii::t('skeeks/shop/app', 'User'), 'value' => function (\skeeks\cms\shop\models\ShopFuser $model) {
    return $model->user ? (new \skeeks\cms\shop\widgets\AdminBuyerUserWidget(['user' => $model->user]))->run() : \Yii::t('skeeks/shop/app', 'Not authorized');
}], ['class' => \yii\grid\DataColumn::className(), 'filter' => false, 'format' => 'raw', 'label' => \Yii::t('skeeks/shop/app', 'Profile of buyer'), 'value' => function (\skeeks\cms\shop\models\ShopFuser $model) {
    if (!$model->buyer) {
        return null;
    }
    return \yii\helpers\Html::a($model->buyer->name . " [{$model->buyer->id}]", \skeeks\cms\helpers\UrlHelper::construct('shop/admin-buyer/related-properties', ['pk' => $model->buyer->id])->enableAdmin()->toString());
}], ['class' => \yii\grid\DataColumn::className(), 'filter' => \yii\helpers\ArrayHelper::map(\skeeks\cms\shop\models\ShopPersonType::find()->active()->all(), 'id', 'name'), 'attribute' => 'person_type_id', 'label' => \Yii::t('skeeks/shop/app', 'Profile type'), 'value' => function (\skeeks\cms\shop\models\ShopFuser $model) {
    return $model->personType ? $model->personType->name : "";
}], ['class' => \yii\grid\DataColumn::className(), 'filter' => false, 'label' => \Yii::t('skeeks/shop/app', 'Price of basket'), 'value' => function (\skeeks\cms\shop\models\ShopFuser $model) {
    return \Yii::$app->money->intlFormatter()->format($model->money);
}], ['class' => \yii\grid\DataColumn::className(), 'filter' => false, 'label' => \Yii::t('skeeks/shop/app', 'Number of items'), 'value' => function (\skeeks\cms\shop\models\ShopFuser $model) {
    return $model->countShopBaskets;
}], ['class' => \yii\grid\DataColumn::className(), 'filter' => false, 'format' => 'raw', 'label' => \Yii::t('skeeks/shop/app', 'Good'), 'value' => function (\skeeks\cms\shop\models\ShopFuser $model) {
    if ($model->shopBaskets) {
        $result = [];
        foreach ($model->shopBaskets as $shopBasket) {
            $money = \Yii::$app->money->intlFormatter()->format($shopBasket->money);
            $result[] = \yii\helpers\Html::a($shopBasket->name, $shopBasket->product ? $shopBasket->product->cmsContentElement->url : '#', ['target' => '_blank']) . <<<HTML
({$shopBasket->quantity} {$shopBasket->measure_name}) — {$money}
HTML;
        }
        return implode('<hr style="margin: 0px;"/>', $result);
    }
}], ['class' => \yii\grid\DataColumn::className(), 'filter' => \yii\helpers\ArrayHelper::map(\skeeks\cms\models\CmsSite::find()->active()->all(), 'id', 'name'), 'attribute' => 'site_id', 'format' => 'raw', 'visible' => false, 'label' => \Yii::t('skeeks/shop/app', 'Site'), 'value' => function (\skeeks\cms\shop\models\ShopFuser $model) {
    return $model->site->name . " [{$model->site->code}]";
}], ['class' => \skeeks\cms\grid\CreatedAtColumn::className()]]]);
?>

<? $pjax::end(); ?>
示例#21
0
文件: _form.php 项目: skeeks-cms/cms
    <?php 
echo $form->fieldRadioListBoolean($model, 'enabledCurrentSite', \Yii::$app->cms->booleanFormat())->hint('Если будет выбрано "да", то в выборку разделов добавиться условие фильтрации, разделов сайта, где вызван компонент');
?>
    <?php 
echo $form->fieldSelect($model, 'active', \Yii::$app->cms->booleanFormat());
?>

    <?php 
echo $form->fieldSelectMulti($model, 'tree_type_ids', \yii\helpers\ArrayHelper::map(\skeeks\cms\models\CmsTreeType::find()->all(), 'id', 'name'));
?>

    <?php 
echo $form->fieldInputInt($model, 'level')->hint('Добавляет в выборку разделов, условие выбора вложенности. 0 — не будет использовать это условие вовсе.');
?>
    <?php 
echo $form->fieldSelectMulti($model, 'site_codes', \yii\helpers\ArrayHelper::map(\skeeks\cms\models\CmsSite::find()->active()->all(), 'code', 'name'));
?>
    <?php 
echo $form->field($model, 'treePid')->widget(\skeeks\cms\widgets\formInputs\selectTree\SelectTree::className(), ['mode' => \skeeks\cms\widgets\formInputs\selectTree\SelectTree::MOD_SINGLE, 'attributeSingle' => 'treePid']);
echo $form->fieldSetEnd();
?>

<?php 
echo $form->fieldSet('Сортировка');
?>
    <?php 
echo $form->fieldSelect($model, 'orderBy', (new \skeeks\cms\models\Tree())->attributeLabels());
?>
    <?php 
echo $form->fieldSelect($model, 'order', [SORT_ASC => "ASC (от меньшего к большему)", SORT_DESC => "DESC (от большего к меньшему)"]);
echo $form->fieldSetEnd();
 public function actionRemove()
 {
     $component = $this->_component;
     $rr = new RequestResponse();
     if ($rr->isRequestAjaxPost()) {
         if (\Yii::$app->request->post('do') == 'all') {
             if ($settings = \skeeks\cms\models\CmsComponentSettings::baseQuery($component)->all()) {
                 /**
                  * @var $setting CmsComponentSettings
                  */
                 foreach ($settings as $setting) {
                     //TODO: добавить отладочную информацию.
                     if ($setting->delete()) {
                     }
                 }
                 $component->invalidateCache();
                 $rr->message = 'Настройки успешно удалены';
                 $rr->success = true;
             }
         } else {
             if (\Yii::$app->request->post('do') == 'default') {
                 if ($settings = \skeeks\cms\models\CmsComponentSettings::fetchByComponentDefault($component)) {
                     $settings->delete();
                     $component->invalidateCache();
                     $rr->message = 'Настройки успешно удалены';
                     $rr->success = true;
                 }
             } else {
                 if (\Yii::$app->request->post('do') == 'sites') {
                     if ($settings = \skeeks\cms\models\CmsComponentSettings::baseQuerySites($component)->all()) {
                         /**
                          * @var $setting CmsComponentSettings
                          */
                         foreach ($settings as $setting) {
                             //TODO: добавить отладочную информацию.
                             if ($setting->delete()) {
                             }
                         }
                         $component->invalidateCache();
                         $rr->message = 'Настройки успешно удалены';
                         $rr->success = true;
                     }
                 } else {
                     if (\Yii::$app->request->post('do') == 'users') {
                         if ($settings = \skeeks\cms\models\CmsComponentSettings::baseQueryUsers($component)->all()) {
                             /**
                              * @var $setting CmsComponentSettings
                              */
                             foreach ($settings as $setting) {
                                 //TODO: добавить отладочную информацию.
                                 if ($setting->delete()) {
                                 }
                             }
                             $component->invalidateCache();
                             $rr->message = 'Настройки успешно удалены';
                             $rr->success = true;
                         }
                     } else {
                         if (\Yii::$app->request->post('do') == 'site') {
                             $code = \Yii::$app->request->post('code');
                             $site = CmsSite::find()->where(['code' => $code])->one();
                             if ($site) {
                                 if ($settings = \skeeks\cms\models\CmsComponentSettings::fetchByComponentSite($component, $site)) {
                                     $settings->delete();
                                     $component->invalidateCache();
                                     $rr->message = 'Настройки успешно удалены';
                                     $rr->success = true;
                                 }
                             }
                         } else {
                             if (\Yii::$app->request->post('do') == 'user') {
                                 $id = \Yii::$app->request->post('id');
                                 $user = User::find()->where(['id' => $id])->one();
                                 if ($user) {
                                     if ($settings = \skeeks\cms\models\CmsComponentSettings::fetchByComponentUser($component, $user)) {
                                         $settings->delete();
                                         $component->invalidateCache();
                                         $rr->message = 'Настройки успешно удалены';
                                         $rr->success = true;
                                     }
                                 }
                             } else {
                                 $rr->message = 'Все настройки удалены';
                                 $rr->success = true;
                             }
                         }
                     }
                 }
             }
         }
         return (array) $rr;
     }
     return $this->render($this->action->id, ['component' => $component]);
 }
示例#23
0
 /**
  *
  *
  * @param $model
  * @return string
  */
 public function getNodeName($model)
 {
     /**
      * @var $model \skeeks\cms\models\Tree
      */
     $result = $model->name;
     $additionalName = '';
     if ($model->level == 0) {
         $site = CmsSite::findOne(['code' => $model->site_code]);
         if ($site) {
             $additionalName = $site->name;
         }
     } else {
         if ($model->name_hidden) {
             $additionalName = $model->name_hidden;
         }
     }
     if ($additionalName) {
         $result .= " [{$additionalName}]";
     }
     return $result;
 }
 /**
  * @return CmsSite
  */
 public function getSite()
 {
     //return $this->hasOne(CmsSite::className(), ['code' => 'site_code']);
     return CmsSite::getByCode($this->site_code);
 }
示例#25
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSites()
 {
     return $this->hasMany(CmsSite::className(), ['code' => 'site_code'])->viaTable('{{%shop_person_type_site}}', ['person_type_id' => 'id']);
 }
示例#26
0
$form = ActiveForm::begin();
?>

<?php 
echo $form->fieldSet(\skeeks\cms\shop\Module::t('app', 'Main settings'));
?>


    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => 255]);
?>
    <?php 
echo $form->fieldRadioListBoolean($model, 'active');
?>
    <?php 
echo $form->field($model, 'siteCodes')->checkboxList(\yii\helpers\ArrayHelper::map(\skeeks\cms\models\CmsSite::find()->all(), 'code', 'name'));
?>
    <?php 
echo $form->fieldInputInt($model, 'priority');
?>

<?php 
echo $form->fieldSetEnd();
?>


<?php 
if (!$model->isNewRecord) {
    ?>
    <?php 
    echo $form->fieldSet('Свойства');
示例#27
0
文件: sites.php 项目: Liv1020/cms
                <i class="glyphicon glyphicon-remove"></i> <?php 
    echo \Yii::t('app', 'reset settings for all sites"');
    ?>
            </button>
            <small>.</small>
        <?php 
} else {
    ?>
            <small><?php 
    echo \Yii::t('app', 'Neither site does not have personal settings for this component');
    ?>
</small>
        <?php 
}
?>
    </div>

    <?php 
$search = new \skeeks\cms\models\Search(\skeeks\cms\models\CmsSite::className());
$search->search(\Yii::$app->request->get());
$search->getDataProvider()->query->andWhere(['active' => \skeeks\cms\components\Cms::BOOL_Y]);
?>
    <?php 
echo \skeeks\cms\modules\admin\widgets\GridViewHasSettings::widget(['dataProvider' => $search->getDataProvider(), 'filterModel' => $search->getLoadedModel(), 'columns' => [['class' => \yii\grid\DataColumn::className(), 'value' => function (\skeeks\cms\models\CmsSite $model, $key, $index, $this) {
    return \yii\helpers\Html::a('<i class="glyphicon glyphicon-cog"></i>', \skeeks\cms\helpers\UrlHelper::constructCurrent()->setRoute('cms/admin-component-settings/site')->set('site_id', $model->id)->toString(), ['class' => 'btn btn-default btn-xs', 'title' => \Yii::t('app', 'Customize')]);
}, 'format' => 'raw'], 'name', 'code', ['class' => \skeeks\cms\grid\ComponentSettingsColumn::className(), 'component' => $component]]]);
?>


<?php 
echo $this->render('_footer');
示例#28
0
 public function actionTree()
 {
     return $this->render($this->action->id, ['models' => CmsTree::findRoots()->joinWith('cmsSiteRelation')->orderBy([CmsSite::tableName() . ".priority" => SORT_ASC])->all()]);
 }
示例#29
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSite()
 {
     return $this->hasOne(CmsSite::className(), ['code' => 'site_code']);
 }
示例#30
0
    /**
     * @inheritdoc
     */
    public function actions()
    {
        return ArrayHelper::merge(parent::actions(), ['index' => ["dataProviderCallback" => function (ActiveDataProvider $dataProvider) {
            $query = $dataProvider->query;
            /**
             * @var ActiveQuery $query
             */
            //$query->select(['app_company.*', 'count(`app_company_officer_user`.`id`) as countOfficer']);
            $query->groupBy(['shop_fuser.id']);
            $query->with('user');
            $query->with('personType');
            $query->with('buyer');
            $query->with('shopBaskets');
            $query->with('shopBaskets.product');
        }, "columns" => [['class' => UpdatedAtColumn::className()], ['class' => DataColumn::className(), 'filter' => false, 'format' => raw, 'label' => \skeeks\cms\shop\Module::t('app', 'User'), 'value' => function (ShopFuser $model) {
            return $model->user ? (new AdminBuyerUserWidget(['user' => $model->user]))->run() : \skeeks\cms\shop\Module::t('app', 'Not authorized');
        }], ['class' => DataColumn::className(), 'filter' => false, 'format' => 'raw', 'label' => \skeeks\cms\shop\Module::t('app', 'Profile of buyer'), 'value' => function (ShopFuser $model) {
            if (!$model->buyer) {
                return null;
            }
            return Html::a($model->buyer->name . " [{$model->buyer->id}]", UrlHelper::construct('shop/admin-buyer/related-properties', ['pk' => $model->buyer->id])->enableAdmin()->toString());
        }], ['class' => DataColumn::className(), 'filter' => ArrayHelper::map(ShopPersonType::find()->active()->all(), 'id', 'name'), 'attribute' => 'person_type_id', 'label' => \skeeks\cms\shop\Module::t('app', 'Profile type'), 'value' => function (ShopFuser $model) {
            return $model->personType->name;
        }], ['class' => DataColumn::className(), 'filter' => false, 'label' => \skeeks\cms\shop\Module::t('app', 'Price of basket'), 'value' => function (ShopFuser $model) {
            return \Yii::$app->money->intlFormatter()->format($model->money);
        }], ['class' => DataColumn::className(), 'filter' => false, 'label' => \skeeks\cms\shop\Module::t('app', 'Number of items'), 'value' => function (ShopFuser $model) {
            return $model->countShopBaskets;
        }], ['class' => DataColumn::className(), 'filter' => false, 'format' => 'raw', 'label' => \skeeks\cms\shop\Module::t('app', 'Good'), 'value' => function (ShopFuser $model) {
            if ($model->shopBaskets) {
                $result = [];
                foreach ($model->shopBaskets as $shopBasket) {
                    $money = \Yii::$app->money->intlFormatter()->format($shopBasket->money);
                    $result[] = Html::a($shopBasket->name, $shopBasket->product->cmsContentElement->url, ['target' => '_blank']) . <<<HTML
 ({$shopBasket->quantity} {$shopBasket->measure_name}) — {$money}
HTML;
                }
                return implode('<hr />', $result);
            }
        }], ['class' => DataColumn::className(), 'filter' => ArrayHelper::map(CmsSite::find()->active()->all(), 'id', 'name'), 'attribute' => 'site_id', 'format' => 'raw', 'label' => \skeeks\cms\shop\Module::t('app', 'Site'), 'value' => function (ShopFuser $model) {
            return $model->site->name . " [{$model->site->code}]";
        }], ['class' => CreatedAtColumn::className()]]]]);
    }