/**
  * 
  * @param type $params
  * @return \yii\data\ActiveDataProvider
  */
 public function search($params = [])
 {
     $query = ServiceUser::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => WidgetPageSize::getPageSize()]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     return $dataProvider;
 }
Пример #2
0
 /**
  * Creating model search query.
  * @return ActiveDataProvider|\yii\data\DataProviderInterface
  */
 public function search($params = [])
 {
     $query = Advert::find()->with('owner.profile');
     $dataProvider = new \roman444uk\yii\data\ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => \roman444uk\yii\widgets\WidgetPageSize::getPageSize()]]);
     if ($params && !($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $this->buildQuery($query, $params);
     return $dataProvider;
 }
Пример #3
0
 /**
  * Creating model search query.
  * @return ActiveDataProvider|\yii\data\DataProviderInterface
  */
 public function search($params = [])
 {
     $query = City::find();
     $dataProvider = new \roman444uk\yii\data\ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => \roman444uk\yii\widgets\WidgetPageSize::getPageSize()]]);
     if ($params && !($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     if (!empty($params['name'])) {
         $ids = [];
         foreach ((new \yii\sphinx\Query())->from(self::tableName())->match($params['content'])->all() as $row) {
             array_push($ids, $row['id']);
         }
         $query->andWhere([self::tableName() . '.id' => $ids]);
     }
     $query->orderBy(self::tableName() . '.created_at desc');
     return $dataProvider;
 }
Пример #4
0
 /**
  * 
  * 
  * @param type $params
  * 
  * @return \yii\db\ActiveDataProvider instance
  */
 public function search($params = [])
 {
     $query = User::find();
     $query->with(['roles', 'serviceIdentities']);
     if (!Yii::$app->user->isSuperadmin) {
         $query->where(['superadmin' => 0]);
     }
     $dataProvider = new \roman444uk\yii\data\ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => WidgetPageSize::getPageSize(), 'defaultPageLast' => true], 'sort' => ['defaultOrder' => ['id' => SORT_ASC]]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     if ($this->gridRoleSearch) {
         $query->joinWith(['roles']);
     }
     $query->andFilterWhere(['id' => $this->id, 'superadmin' => $this->superadmin, 'status' => $this->status, Yii::$app->getModule('users')->auth_item_table . '.name' => $this->gridRoleSearch, 'registration_ip' => $this->registration_ip, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'email_confirmed' => $this->email_confirmed]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'email', $this->email]);
     return $dataProvider;
 }
Пример #5
0
 /**
  * Creating model search query.
  * @return ActiveDataProvider|\yii\data\DataProviderInterface
  */
 public function search($params = [])
 {
     $query = Advert::find()->with('owner.profile', 'files');
     // query city, bookmarks and likes
     $tableAdvert = self::tableName();
     $tableBookmark = Yii::$app->getModule('bookmarks')->tableBookmark;
     $query->select("{$tableAdvert}.*, ({$tableAdvert}.id = {$tableBookmark}.target_id) as bookmarked, city.name as cityName");
     $query->join('left join', $tableBookmark, "{$tableBookmark}.target_id = {$tableAdvert}.id");
     $query->join('left join', 'city', 'advert.city_id = city.id');
     // creating data provider
     $dataProvider = new \roman444uk\yii\data\ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => \roman444uk\yii\widgets\WidgetPageSize::getPageSize('advert-list')]]);
     if ($params && !($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $this->buildQuery($query, $params);
     if ($this->search_bookmarks) {
         $query->andWhere(["{$tableAdvert}.id" => Yii::$app->getModule('bookmarks')->manager->getIdList($this->bookmark_user_id, ['Advert'], true)]);
     }
     return $dataProvider;
 }
Пример #6
0
        
<?php 
Pjax::begin(['id' => 'user-grid-pjax']);
?>

    <?php 
echo GridView::widget(['id' => 'user-grid', 'dataProvider' => $dataProvider, 'itemsOrderDesc' => true, 'pager' => ['options' => ['class' => 'pagination pagination-sm'], 'hideOnSinglePage' => true, 'lastPageLabel' => '>>', 'firstPageLabel' => '<<'], 'filterModel' => $searchModel, 'layout' => '
            <div class="row">
                <div class="col-sm-4">
                    ' . GhostHtml::a('<span class="glyphicon glyphicon-plus-sign"></span> ' . UsersModule::t('back', 'Create'), ['/users/user/create'], ['id' => 'user-grid-create-button', 'class' => 'btn btn-success btn-sm']) . '
                </div>
                <div class="col-sm-4 text-center">
                    {summary}
                </div>
                <div class="col-sm-4 text-right">
                    ' . WidgetPageSize::widget(['pjaxId' => 'user-grid-pjax']) . '
                </div>
            </div>
            {items}
            <div class="row">
                <div class="col-sm-8">
                    {pager}
                </div>
                <div class="col-sm-4 text-right" style="padding: 20px">
                    ' . GridBulkActions::widget(['gridId' => 'user-grid']) . '
                </div>
            </div>
        ', 'columns' => [['class' => 'yii\\grid\\CheckboxColumn', 'options' => ['style' => 'width:10px']], ['class' => 'yii\\grid\\SerialColumn', 'options' => ['style' => 'width:10px']], ['class' => 'roman444uk\\yii\\grid\\StatusColumn', 'attribute' => 'superadmin', 'visible' => Yii::$app->user->isSuperadmin, 'filterInputOptions' => ['class' => 'form-control input-sm']], ['attribute' => 'username', 'value' => function (User $model) {
    return Html::a($model->username, ['view', 'id' => $model->id], ['data-pjax' => 0]);
}, 'format' => 'raw', 'filterInputOptions' => ['class' => 'form-control input-sm']], ['attribute' => 'email', 'format' => 'raw', 'visible' => User::hasPermission('viewUserEmail'), 'filterInputOptions' => ['class' => 'form-control input-sm']], ['class' => 'roman444uk\\yii\\grid\\StatusColumn', 'attribute' => 'email_confirmed', 'visible' => User::hasPermission('viewUserEmail'), 'filterInputOptions' => ['class' => 'form-control input-sm']], ['attribute' => 'gridRoleSearch', 'filter' => ArrayHelper::map(Role::getAvailableRoles(Yii::$app->user->isSuperAdmin), 'name', 'description'), 'value' => function (User $model) {
    return implode(', ', ArrayHelper::map($model->roles, 'name', 'description'));
Пример #7
0
<?php

use roman444uk\yii\widgets\WidgetPageSize;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\web\View;
$tag = ArrayHelper::remove($this->context->dropDownOptions, 'tag', 'div');
?>

<?php 
echo Html::beginTag($tag, $this->context->containerOptions);
?>
    <?php 
if ($this->context->enableClearFilters) {
    ?>
        <?php 
    echo Html::tag(ArrayHelper::remove($this->context->clearFiltersButtonOptions, 'tag', 'div'), WidgetPageSize::t('Clear filters'), $this->context->clearFiltersButtonOptions);
    ?>
    <?php 
}
?>

    <?php 
echo $this->context->text;
?>
    
    <?php 
echo Html::dropDownList('widget-page-size', \Yii::$app->request->cookies->getValue('_widget_page_size', $this->context->defaultValue), $this->context->dropDownOptions);
echo Html::endTag($tag);
Пример #8
0
 /**
  * Set page size for widget
  */
 public function actionWidgetPageSize()
 {
     $pageSize = Yii::$app->request->post(WidgetPageSize::PAGE_SIZE_PARAM_NAME);
     if ($pageSize) {
         WidgetPageSize::setPageSize($pageSize, Yii::$app->request->post(WidgetPageSize::WIDGET_ID_PARAM_NAME));
     }
 }
Пример #9
0
 /**
  * Renders widget content.
  * @return string content
  */
 public function renderContent()
 {
     $containerTag = ArrayHelper::remove($this->containerOptions, 'tag', 'div');
     $content = Html::beginTag($containerTag, $this->containerOptions);
     $buttonText = WidgetPageSize::t('app', 'Clear filters');
     $currentValue = self::getPageSize($this->widgetId);
     if ($this->enableClearFilters && $currentValue !== $this->defaultValue) {
         $content .= Html::tag(ArrayHelper::remove($this->clearFiltersButtonOptions, 'tag', 'span'), ArrayHelper::remove($this->clearFiltersButtonOptions, 'value', WidgetPageSize::t('Clear filters')), $this->clearFiltersButtonOptions);
     }
     $content .= " {$this->text} ";
     $content .= Html::dropDownList('widget-page-size', $currentValue, ArrayHelper::remove($this->dropDownOptions, 'items', []), $this->dropDownOptions);
     $content .= Html::endTag($containerTag);
     return $content;
 }
Пример #10
0
<?php

use yii\web\JsExpression;
use yii\widgets\ActiveForm;
use yii\widgets\Pjax;
use yii\helpers\Html;
use roman444uk\yii\widgets\WidgetPageSize;
use roman444uk\bookmarks\BookmarksModule;
?>

<?php 
Pjax::begin(['id' => 'advert-list-pjax']);
?>

    <?php 
echo \frontend\widgets\AdvertList::widget(['id' => 'advert-list', 'dataProvider' => $dataProvider, 'itemView' => '@frontend/views/advert/_advert', 'showOnEmpty' => true, 'layout' => "{summary}" . WidgetPageSize::widget(['pjaxId' => 'advert-list-pjax', 'viewFile' => '@frontend/widgets/views/widget-page-size', 'independentChanging' => true, 'enableClearFilters' => true, 'filterSelectors' => '#detaile-search-form input[type="text"], #detaile-search-form select', 'clearFiltersButtonOptions' => ['tag' => 'span', 'class' => 'button'], 'dropDownOptions' => ['items' => [5 => 5, 10 => 10, 20 => 20, 30 => 30, 50 => 50, 100 => 100]], 'containerOptions' => ['class' => 'widget-page-size'], 'text' => Yii::t('app', 'Count records')]) . "\n            <div class='clear'></div>\n            {pager}\n            {items}\n            <div class='clear'></div>\n            {pager}\n        ", 'itemOptions' => ['class' => 'advert-container']]);
?>
    
<?php 
Pjax::end();
?>

<?php 
\roman444uk\likes\widgets\Likes::widget();
?>

<?php 
(new \roman444uk\bookmarks\widgets\Bookmarks(['clientEvents' => ['onAdd' => "function(event, data) {\n    \$(this).addClass('bookmarked').attr('title', '" . BookmarksModule::t('Delete from bookmarks') . "');\n}", 'onRemove' => "function(event, data) {\n    \$(this).removeClass('bookmarked').attr('title', '" . BookmarksModule::t('Add to bookmarks') . "')\n}", 'onSuccess' => "function(event, data) {\n    jQuery('#bookmarks-count').html(data.count);\n}", 'onError' => "function(event, jqXHR, link) {\n    alert('Error adding bookmark');\n}"]]))->registerClientScript();
?>

<?php 
Пример #11
0
<?php 
Pjax::begin(['id' => 'advert-grid-pjax']);
?>

<?php 
echo \roman444uk\yii\grid\GridView::widget(['id' => 'advert-grid', 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'pager' => ['options' => ['class' => 'pagination pagination-sm'], 'hideOnSinglePage' => true, 'lastPageLabel' => '>>', 'firstPageLabel' => '<<'], 'layout' => '
        <div class="row">
            <div class="col-sm-4">
                ' . GhostHtml::a('<span class="glyphicon glyphicon-plus-sign"></span> Создать', ['/advert/create'], ['id' => 'advert-grid-create-button', 'class' => 'btn btn-success btn-sm']) . '
            </div>
            <div class="col-sm-4 text-center">
                {summary}
            </div>
            <div class="col-sm-4 text-right">
                ' . WidgetPageSize::widget(['pjaxId' => 'advert-grid-pjax']) . '
            </div>
        </div>
        {items}
        <div class="row">
            <div class="col-sm-8">
                {pager}
            </div>
            <div class="col-sm-4 text-right" style="padding-top: 20px">
                ' . GridBulkActions::widget(['gridId' => 'user-grid']) . '
            </div>
        </div>', 'columns' => [['class' => 'yii\\grid\\CheckboxColumn', 'options' => ['style' => 'width:10px']], ['class' => 'yii\\grid\\SerialColumn', 'options' => ['style' => 'width:10px']], ['attribute' => 'id', 'header' => '№', 'filterInputOptions' => ['class' => 'form-control input-sm']], ['attribute' => 'content', 'format' => 'raw', 'contentOptions' => ['style' => 'text-align: left'], 'filterInputOptions' => ['class' => 'form-control input-sm']], ['class' => 'roman444uk\\yii\\grid\\AjaxUpdateColumn', 'attribute' => 'status', 'fieldType' => AjaxUpdateColumn::FIELD_TYPE_DROPDOWN, 'fieldOptions' => ['class' => 'form-control input-sm', 'items' => Advert::getTranslatedStatusList()], 'filter' => Advert::getTranslatedStatusList(), 'filterInputOptions' => ['class' => 'form-control input-sm'], 'updateUrl' => function ($model, $key, $index) {
    return Yii::$app->urlManager->createUrl(['advert/update', 'id' => $key]);
}, 'errorUpdate' => new JsExpression("function() {\n                alert('error updating');\n            }")], ['class' => 'roman444uk\\yii\\grid\\AjaxUpdateColumn', 'attribute' => 'category', 'fieldType' => AjaxUpdateColumn::FIELD_TYPE_DROPDOWN, 'fieldOptions' => ['class' => 'form-control input-sm', 'items' => Category::getDropdownList()], 'filter' => Category::getDropdownList(), 'filterInputOptions' => ['class' => 'form-control input-sm'], 'updateUrl' => function ($model, $key, $index) {
    return Yii::$app->urlManager->createUrl(['advert/update', 'id' => $key]);
}, 'errorUpdate' => new JsExpression("function() {\n                alert('error updating');\n            }")], ['attribute' => 'city_id', 'header' => 'Город', 'value' => function ($model, $key, $index) {
Пример #12
0
<?php

use roman444uk\yii\widgets\WidgetPageSize;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\web\View;
$containerTag = ArrayHelper::remove($this->context->containerOptions, 'tag', 'div');
$clearButtonTag = ArrayHelper::remove($this->context->clearFiltersButtonOptions, 'tag', 'span');
?>

<?php 
echo Html::beginTag($containerTag, $this->context->containerOptions);
?>
    <?php 
if ($this->context->enableClearFilters || true) {
    ?>
        <?php 
    echo Html::tag($clearButtonTag, WidgetPageSize::t('Clear filters'), $this->context->clearFiltersButtonOptions);
    ?>
    <?php 
}
?>

    <?php 
echo $this->context->text;
?>

    <?php 
echo Html::dropDownList('grid-page-size', \Yii::$app->request->cookies->getValue('_widget_page_size', $this->context->defaultValue), ArrayHelper::remove($this->context->dropDownOptions, 'items', []), $this->context->dropDownOptions);
echo Html::endTag($containerTag);