For more details and usage information on ListView, see the guide article on data widgets.
Since: 2.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends BaseListView
Esempio n. 1
4
 public function run()
 {
     $ret_val = '';
     if (isset($this->header) && is_string($this->header) && !is_bool($this->header)) {
         $ret_val = Html::tag('h2', $this->header);
     }
     switch ($this->displayAs) {
         case 'grid':
             $this->items = is_array($this->items) ? $this->items : [$this->items];
             $this->widgetOptions = array_merge(['summary' => false, 'layout' => '{items}', 'showHeader' => $this->header, 'dataProvider' => new \yii\data\ArrayDataProvider(['allModels' => $this->items]), 'columns' => $this->attributes], $this->widgetOptions);
             $ret_val .= \kartik\grid\GridView::widget($this->widgetOptions);
             break;
         case 'list':
             $this->widgetOptions = array_merge(['itemOptions' => ['tag' => false], 'summary' => false, 'dataProvider' => new \yii\data\ArrayDataProvider(['allModels' => $this->items]), 'itemView' => function ($model, $key, $index, $widget) {
                 return $this->renderListItem($model, $key, $index, $widget);
             }], $this->widgetOptions);
             $ret_val .= \yii\widgets\ListView::widget($this->widgetOptions);
             break;
         case 'csv':
             $ret_val = [];
             foreach ($this->items as $index => $item) {
                 $ret_val[] = $this->renderCsvItem($item, $index);
             }
             $ret_val = Html::tag('div', implode(', ', $ret_val));
             break;
         case 'tags':
             foreach ($this->items as $index => $item) {
                 $ret_val .= $this->renderTagItem($item, $index);
             }
             $ret_val = Html::tag('div', $ret_val);
             break;
         default:
             $this->widgetOptions['class'] = isset($this->widgetOptions['class']) ? $this->widgetOptions['class'] : 'table';
             $this->widgetOptions = array_merge(['model' => $this->items, 'attributes' => $this->attributes, 'options' => ['class' => 'table']], $this->widgetOptions);
             $ret_val .= \yii\widgets\DetailView::widget($this->widgetOptions);
             break;
     }
     return $ret_val;
 }
Esempio n. 2
1
 /**
  * @inheritdoc
  */
 public function renderPager()
 {
     if ($this->dataProvider->getPagination()->pageSize == 0) {
         return '';
     }
     return parent::renderPager();
 }
Esempio n. 3
1
 public function init()
 {
     parent::init();
     $this->options['class'] .= ' row component component-resource-list';
     $this->itemOptions['tag'] = false;
     $this->summary = false;
 }
Esempio n. 4
1
 /**
  * @inheritdoc
  */
 public function run()
 {
     parent::run();
     $id = $this->options['id'];
     ListViewAsset::register($this->getView());
     $this->registerClientOptions($id);
     $this->registerClientEvents($id);
 }
Esempio n. 5
0
    public function run()
    {
        $header = Html::tag(ArrayHelper::remove($this->labelOptions, 'tag', 'h4'), 'Parents', $this->labelOptions);
        if (count($this->labelContainerOptions)) {
            $header = Html::tag(ArrayHelper::remove($this->labelContainerOptions, 'tag', 'div'), $header, $this->labelContainerOptions);
        }
        $list = ListView::widget(['summary' => false, 'emptyText' => Html::tag('ul', '', $this->options), 'options' => $this->options, 'itemOptions' => $this->itemOptions, 'dataProvider' => $this->dataProvider, 'itemView' => function ($model, $key, $index, $widget) {
            return $model->name . (!$this->viewOnly ? Html::tag('span', Html::a("Remove " . Icon::show('remove'), '/' . $this->model->isWhat() . "/remove-parent/" . $this->model->getId() . '/' . $model['id'], ['role' => 'parentListItem', 'style' => 'color:white']), ['class' => 'badge']) : '');
        }]);
        if (count($this->listOptions)) {
            $list = Html::tag(ArrayHelper::remove($this->listOptions, 'tag', 'div'), $list, $this->listOptions);
        }
        if (!$this->viewOnly) {
            $script = Html::tag('script', new \yii\web\jsExpression('$(document).ready(function () {
				$("#' . $this->options['id'] . '").find(\'[role="parentListItem"]\').each(function () {
					$(this).on("click", function (event) {
						event.preventDefault();
						var $element = $(this);
						$.post(this.href, function (result) {
							if(result) $element.parents("li").remove();
						});
					});
				});
			})'), ['type' => 'text/javascript']);
        } else {
            $script = '';
        }
        return Html::tag('div', $header . $list, $this->containerOptions) . $script;
    }
 /**
  * Renders a section of the specified name.
  * If the named section is not supported, false will be returned.
  * @param string $name the section name, e.g., `{summary}`, `{items}`.
  * @return string|boolean the rendering result of the section, or false if the named section is not supported.
  */
 public function renderSection($name)
 {
     if ($name == '{pagerTop}') {
         return $this->renderPagerTop();
     }
     return parent::renderSection($name);
 }
Esempio n. 7
0
 /**
  * Runs the widget.
  */
 public function run()
 {
     parent::run();
     $options = Json::htmlEncode($this->getClientOptions());
     $view = $this->getView();
     ListViewAsset::register($view);
     $view->registerJs("jQuery('#{$this->id}').yiiListView({$options});");
 }
Esempio n. 8
0
 /**
  * @inheritdoc
  */
 public function renderEmpty()
 {
     // run normal parent implementation if view is not set
     if (empty($this->emptyView)) {
         return parent::renderEmpty();
     }
     // render closure/view
     return $this->emptyView instanceof Closure ? call_user_func($this->emptyView) : $this->getView()->render($this->emptyView, $this->emptyViewParams);
 }
Esempio n. 9
0
 public function init()
 {
     parent::init();
     $LatLngCenter = new LatLng(['lat' => $this->centerPoint['lat'], 'lng' => $this->centerPoint['lng']]);
     $this->map = new Map(['zoom' => $this->zoom, 'center' => $LatLngCenter, 'width' => '100%']);
     $this->initMarkers();
     $this->pushMarkers();
     $this->flushMap();
 }
Esempio n. 10
0
 public function testLabelsExplicit()
 {
     $dataProvider = new ActiveDataProvider(['query' => Order::find(), 'models' => [new Order()], 'totalCount' => 1, 'sort' => ['attributes' => ['total'], 'route' => 'site/index']]);
     ob_start();
     echo ListView::widget(['dataProvider' => $dataProvider, 'layout' => "{sorter}"]);
     $actualHtml = ob_get_clean();
     $this->assertFalse(strpos($actualHtml, '<a href="/index.php?r=site%2Findex&amp;sort=customer_id" data-sort="customer_id">Customer</a>') !== false);
     $this->assertTrue(strpos($actualHtml, '<a href="/index.php?r=site%2Findex&amp;sort=total" data-sort="total">Invoice Total</a>') !== false);
 }
Esempio n. 11
0
 /**
  * @inheritdoc
  */
 public function renderSection($name)
 {
     switch ($name) {
         case "{pagesizer}":
             return $this->renderPagesizer();
         default:
             return parent::renderSection($name);
     }
 }
Esempio n. 12
0
 public function init()
 {
     parent::init();
     foreach (['url', 'srcNode'] as $property) {
         if ($this->pluginOptions[$property] === null) {
             throw new InvalidConfigException("The \"{$property}\" property must be set to \"pluginOptions\".");
         }
     }
     Html::addCssStyle($this->itemOptions, ['display' => 'none']);
 }
Esempio n. 13
0
 /**
  * Runs the widget.
  */
 public function run()
 {
     $id = $this->options['id'];
     $view = $this->getView();
     $options = Json::encode(['options' => $this->clientOptions, 'encode' => $this->encode, 'action' => $this->action, 'method' => $this->method]);
     JuiAsset::register($this->getView());
     SortableListViewAsset::register($view);
     $view->registerJs("jQuery('#{$id}').sortableListView({$options});");
     parent::run();
 }
Esempio n. 14
0
 public function run()
 {
     $this->view->registerJs('function refreshGpGallery() {
         $(".gpgallery").collagePlus({"targetHeight": 250, "allowPartialLastRow": true, "childrenFilterSelector": ".inline"});
         $(".gpgallery").collageCaption({"images": $(".inline:not(:has(div))")});
     }
     $(window).load(function() { refreshGpGallery(); });
     $(window).resize(function() { refreshGpGallery(); });');
     echo ListView::widget(['dataProvider' => $this->dataProvider, 'itemOptions' => ['tag' => false], 'itemView' => $this->itemView, 'layout' => "<div class=\"gpgallery\">{items}</div>\n{pager}", 'pager' => ['class' => \kop\y2sp\ScrollPager::className(), 'triggerOffset' => 999999, 'noneLeftText' => 'No more item to display', 'noneLeftTemplate' => '<div class="clearfix"></div><div class="ias-noneleft" style="text-align: center;"><small class="text-muted">{text}</small>', 'enabledExtensions' => [\kop\y2sp\ScrollPager::EXTENSION_TRIGGER, \kop\y2sp\ScrollPager::EXTENSION_SPINNER, \kop\y2sp\ScrollPager::EXTENSION_NONE_LEFT], 'eventOnRendered' => "function() { refreshGpGallery(); }"]]);
 }
Esempio n. 15
0
 /**
  * Renders a single data model.
  * @param mixed $model the data model to be rendered
  * @param mixed $key the key value associated with the data model
  * @param integer $index the zero-based index of the data model in the model array returned by [[dataProvider]].
  * @return string the rendering result
  */
 public function renderItem($model, $key, $index)
 {
     $dateLabel = $this->renderDateLabel($model);
     $icon = $this->renderIcon($model);
     $time = $this->renderTime($model);
     $itemBody = Html::tag('div', parent::renderItem($model, $key, $index), ['class' => 'timeline-body']);
     $itemHeader = $this->renderItemHeader($model);
     $itemFooter = $this->renderItemFooter($model);
     $item = Html::tag('div', $time . $itemHeader . $itemBody . $itemFooter, ['class' => 'timeline-item']);
     return $dateLabel . Html::tag('li', $icon . $item);
 }
Esempio n. 16
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     // 信息记录一般从尾页开始显示
     $pagination = $this->dataProvider->getPagination();
     $params = $pagination->params !== null ? $pagination->params : Yii::$app->getRequest()->getQueryParams();
     if (!(isset($params[$pagination->pageParam]) && is_scalar($params[$pagination->pageParam]))) {
         $pageSize = $pagination->getPageSize();
         $totalCount = $this->dataProvider->getTotalCount();
         $pagination->setPage((int) (($totalCount + $pageSize - 1) / $pageSize) - 1);
     }
 }
 public function init()
 {
     parent::init();
     $id = $this->getId();
     $this->options['id'] = $id;
     $classes = isset($this->options['class']) ? $this->options['class'] : '';
     $classes .= ' sortable';
     $this->options['class'] = trim($classes);
     $view = $this->getView();
     JuiAsset::register($view);
     $url = Url::toRoute($this->orderUrl);
     $sortOpts = array_merge($this->sortOptions, ['axis' => 'y', 'items' => '[data-key]', 'update' => new JsExpression("function(e, ui) {\n                jQuery('#{$this->id}').addClass('sorting');\n                jQuery.ajax({\n                    type: 'POST',\n                    url: '{$url}',\n                    data: {\n                        key: ui.item.data('key'),\n                        pos: ui.item.index('[data-key]')\n                    },\n                    complete: function() {\n                        jQuery('#{$this->id}').removeClass('sorting');\n                    }\n                });\n            }")]);
     $sortJson = Json::encode($sortOpts);
     $view->registerJs("jQuery('#{$id}').sortable({$sortJson});");
 }
 /**
  * @inheritdoc
  */
 public function renderItems()
 {
     if ($this->columns < 2) {
         parent::renderItems();
         return;
     }
     $models = $this->dataProvider->getModels();
     $keys = $this->dataProvider->getKeys();
     $rows = [];
     $layouts = ArrayHelper::getValue($this->columnsLayout, $this->columns, []);
     $this->itemOptions = empty($this->itemOptions) ? $this->buildItemOptions($layouts) : $this->itemOptions;
     foreach (array_values($models) as $index => $model) {
         $rows[] = $this->renderItem($model, $keys[$index], $index);
         // set a clearfix breaks for responsive columns
         if ($this->createRows) {
             $clearRows = $this->buildClearFixTag($layouts, $index + 1);
             if (empty($clearRows)) {
                 continue;
             }
             $rows[] = implode("\n", $clearRows);
         }
     }
     return Html::beginTag('div', $this->rowOptions) . implode($this->separator, $rows) . Html::endTag('div');
 }
Esempio n. 19
0
            </div>
        </div>
        -->
        <!--/discount  panel end-->
    </div>
</div>

<!--right column-->
<div class="col-lg-9 col-md-9 col-sm-12">
    <div class="w100 clearfix category-top">
        <?php 
echo Html::tag('h2', $this->title);
?>
        <div class="categoryImage">
            <img src="/images/site/category.jpg" class="img-responsive" alt="img">
        </div>
    </div>

            <?php 
Pjax::begin();
?>
            <?php 
echo ListView::widget(['options' => ['id' => 'product-listview'], 'layout' => $template, 'dataProvider' => $dataProvider, 'itemOptions' => ['class' => 'item col-lg-3 col-md-3 col-sm-6 col-xs-12'], 'itemView' => function ($model, $key, $index, $widget) {
    return $this->render('_product_item', ['model' => $model]);
}, 'summaryOptions' => ['class' => 'pull-left']]);
?>
            <?php 
Pjax::end();
?>
    <!--/.categoryFooter-->
</div>
Esempio n. 20
0
        </div>

        <div class="col-md-3 pull-right view">
            <span>Nézet</span>
            <?php 
echo Html::a("Rács", Yii::$app->urlManager->createAbsoluteUrl(["/category/view", "justcategory" => $categoryData["slug"], "tipus" => 'racs']), ['class' => 'racs ' . ($type == "racs" ? "active" : "")]);
echo Html::a("Lista", Yii::$app->urlManager->createAbsoluteUrl(["/category/view", "justcategory" => $categoryData["slug"], "tipus" => 'lista']), ['class' => 'lista ' . ($type == "lista" ? "active" : "")]);
?>
        </div>
        <div class="clearfix"></div>
    </div>

    <div class="product-categories-index">

        <?php 
echo ListView::widget(['dataProvider' => $dataProvider, 'itemOptions' => ['class' => 'product-item col-md-6'], 'itemView' => 'itemview']);
?>

    </div>
<?php 
$this->registerJs('


    $(".listorder").on("change", function() {
        var url = $(this).find("option:selected").val();
        window.location = url;
    });

    $("input[name*=\\"topping\\"]").on("click", function() {
            var propPrice = parseInt($(this).data("price"));
            var currentPriceContainer = $(this).parents(".product-item").find(".price");
Esempio n. 21
0
<?php

/* @var $this yii\web\View */
$this->title = Yii::t('frontend', 'Articles');
echo $this->render('_typehead');
?>
<div id="article-index">
    <h1><?php 
echo Yii::t('frontend', 'Articles');
?>
</h1>
    <?php 
echo \yii\widgets\ListView::widget(['dataProvider' => $dataProvider, 'pager' => ['hideOnSinglePage' => true], 'itemView' => '_item']);
?>
</div>
use reportmanager\models\ReportsConditions;
?>

<?php 
echo Html::a(Yii::t('reportmanager', 'Add Condition'), ['condition', 'report_id' => $model->id], ['class' => 'btn btn-primary', 'name' => 'add-condition']);
?>

<?php 
echo ListView::widget(['dataProvider' => $condDataProvider, 'itemOptions' => ['class' => 'list'], 'itemView' => function ($model, $key, $index, $widget) use($condition) {
    $param = NULL;
    if ($model->functionObj->paramType) {
        if (is_array($model->value)) {
            $all_values = $model->config['values'];
            $values = array_map(function ($v) use($all_values) {
                return array_key_exists($v, $all_values) ? $all_values[$v] : NULL;
            }, $model->value);
            $param = join(', ', $values);
        } else {
            $param = $model->value;
        }
    }
    $title = '' . $model->operationsList[$model->operation] . ': ' . $model->conditionLabel . ' ' . $model->functionObj->label . ' ' . ($param ? $param : '');
    return '' . Html::a('▲', ['condition', 'report_id' => $model->report->id, 'id' => $model->id], ['data' => ['operation' => 'up']]) . Html::a('▼', ['condition', 'report_id' => $model->report->id, 'id' => $model->id], ['data' => ['operation' => 'down']]) . (isset($condition) && $condition->id == $model->id ? Html::tag('span', $title) : Html::a($title, ['condition', 'report_id' => $model->report->id, 'id' => $model->id]));
}]);
?>

<?php 
$this->registerJs('
if ($.support.pjax) {
    $(document).on("click", "a[data-operation]", function(event) {
        $.pjax.click(event, {type: "post", push: false, container: "#all", data: {operation: $(event.currentTarget).attr("data-operation")}})
    })
Esempio n. 23
0
} else {
    echo "RESULT";
}
?>
</h3>
        <div class="sort">
            <form id="sort-tour" class="form-inline" action="<?php 
echo \yii\helpers\Url::to(['tour/sort']);
?>
" method="post" role="form">
                <div class="form-group">
                    <label for="sort_tour">Sorting Tour</label>
                    <select name="sort-tour" id="sort" class="form-control">
                        <option value="">None</option>
                        <option value="Descending">Descending</option>
                        <option value="Ascending">Ascending</option>
                    </select>
                    <?php 
echo $sort->link('length', ['id' => 'length_desc', 'class' => 'sr-only']);
?>
                </div>
            </form>
        </div>
        <div class="thumb-content">
            <?php 
echo ListView::widget(['dataProvider' => $provider, 'summary' => '', 'itemView' => '_show']);
?>
        </div>

    </div>
</div>
Esempio n. 24
0
use yii\widgets\ListView;
/* @var $this yii\web\View */
/* @var $searchModel common\models\Search\UserSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Users';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Create User', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo ListView::widget(['dataProvider' => $dataProvider, 'itemOptions' => ['class' => 'item'], 'itemView' => function ($model, $key, $index, $widget) {
    return Html::a(Html::encode($model->id), ['view', 'id' => $model->id]);
}]);
?>

</div>
Esempio n. 25
0
    <div class="col-lg-12">
        <h1 class="page-header">Company: <?= $model->name?></h1>
    </div>
    <!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<?php

$dataProvider = $model->companyDetails;

echo ListView::widget([
    'dataProvider' => new ArrayDataProvider(['allModels' => $dataProvider,'pagination' => false]),
    'itemView' => '_row1',
    'summary' => false,
    'itemOptions' => [
        'class' => 'col-lg-3 col-md-6'
    ],
    'options' => [
        'class' => 'row',
        'id' => false
    ]
])?>
<!-- /.row -->
<div class="row">
    <div class="col-lg-8">
        <div class="chat-panel panel panel-green">
            <div class="panel-heading">
                <i class="fa fa-comments fa-fw"></i>
                Latest Dealer Bids
                <div class="btn-group pull-right">
                </div>
            </div>
Esempio n. 26
0
      },
      type:'POST'
    }).done(function(){container.slideUp()});
  }
  return false;
});

DEL;
$this->registerJs($deleteJS);
?>

<div class="panel-body">

<?php 
Pjax::begin(['id' => 'WidgetLocationPjax']);
echo ListView::widget(array('id' => 'LocationsTable', 'dataProvider' => $dpLocations, 'itemView' => '@frenzelgmbh/cmaddress/widgets/views/iviews/_location_view', 'layout' => '{items}'));
echo "<p>&nbsp;</p>";
?>

<div class="navbar navbar-default">
  <?php 
echo Html::a('<span class="btn btn-success navbar-btn pull-right tipster" title="add location">' . Icon::show('plus', ['class' => 'fa'], Icon::FA) . ' add location</span>', array("/posts/widgetconfig/addlocation", 'id' => $id, 'module' => $module), array('class' => 'create'));
?>
</div>

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

</div>
Esempio n. 27
0
?>

                    <hr>
                    <?php 
echo $this->render('tmpl/_total_income', ['budgetModel' => $model, 'type' => \app\models\BudgetItem::TYPE_INCOME]);
?>
                    <?php 
echo $this->render('tmpl/modal_income', ['budgetModel' => $model, 'modelHistory' => $modelHistory]);
?>

                </div>
                <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
                    <!--          costs      -->

                    <?php 
echo ListView::widget(['dataProvider' => $providerCost, 'itemView' => 'tmpl/_cost']);
?>

                    <hr>
                    <?php 
echo $this->render('tmpl/_total_costs', ['budgetModel' => $model, 'type' => \app\models\BudgetItem::TYPE_COST]);
?>
                    <?php 
echo $this->render('tmpl/modal_costs', ['budgetModel' => $model, 'modelHistory' => $modelHistory]);
?>
                </div>
            </div>
        </div>
    </div>
</div>
Esempio n. 28
0
<?php

use yii\helpers\Html;
use yii\widgets\ListView;
use yii\widgets\Menu;
/* @var $this yii\web\View */
$title = $category === null ? 'Bienvenido' : $category->title;
$this->title = Html::encode($title);
?>

<h1><?php 
echo Html::encode($title);
?>
</h1>

<div class="container-fluid">
  <div class="row">
      <div class="col-xs-4">
          <?php 
echo Menu::widget(['items' => $menuItems, 'options' => ['class' => 'menu']]);
?>
      </div>
      <div class="col-xs-8">
          <?php 
echo ListView::widget(['dataProvider' => $productsDataProvider, 'itemView' => '_product']);
?>
      </div>
  </div>
</div>
Esempio n. 29
0
<?php

$path = Yii::$app->urlManager->createAbsoluteUrl('/webroot/');
use giicms\forum\components\widgets\CategoryWidget;
use yii\widgets\ListView;
?>
<section class="content">
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-md-8">
                <!-- POST -->
                <?php 
echo ListView::widget(['dataProvider' => $dataProvider, 'options' => ['tag' => 'div'], 'layout' => "{pager}\n{items}\n{summary}", 'itemView' => '_post']);
?>
                


                <!-- POST -->
                
            </div>
            <div class="col-lg-4 col-md-4">

                <!-- -->

                <!-- -->
                <div class="sidebarblock">
                    <h3>Poll of the Week</h3>
                    <div class="divline"></div>
                    <div class="blocktxt">
                        <p>Which game you are playing this week?</p>
                        <form action="http://forum.azyrusthemes.com/index.html#" method="post" class="form">
Esempio n. 30
0
		</td>
		<td class="c23">

			<h1><?php 
echo Html::encode($model->title);
?>
</h1>

			<?//= Html::img('/image/bannerfans_15821322.jpg', ['width'=>'100%']); ?>
			<p><?php 
echo Html::encode($model->description);
?>
<br><br></p>

			<? if (!(Yii::$app->user->isGuest)) Pjax::begin(['id' => 'notes']); ?>
			<?php 
echo ListView::widget(['dataProvider' => $products, 'itemOptions' => ['class' => '_product'], 'layout' => "{items}\n{pager}\n", 'itemView' => '//product/_product', 'viewParams' => array('groups' => $groups)]);
?>
			<? if (!(Yii::$app->user->isGuest)) Pjax::end(); ?>

		</td>
	</tr>
</table>

<?php 
echo Html::input('hidden', 'this_category_id', $model->category_id, $options = ['class' => 'this_category_id']);
echo Html::input('hidden', 'group_this_category_id', $model->category_id, $options = ['class' => 'group_this_category_id']);
?>