本文整理汇总了PHP中headers::model方法的典型用法代码示例。如果您正苦于以下问题:PHP headers::model方法的具体用法?PHP headers::model怎么用?PHP headers::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类headers
的用法示例。
在下文中一共展示了headers::model方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
/**
* Prepares a list of products and renders accordingly
*
* If the request comes from an AJAX request containing pagination data, the resultant table will be
* paginated appropriately. Otherwise, a default pagination state (no sorting, no filtering, page 1)
* will be created.
*/
public function actionIndex()
{
$statuses = statuses::model()->getAll();
$vendors = vendors::model()->getAll();
$tags = tags::model()->getAll();
$showColumns = Auth::User()->getColumns();
if (count($showColumns) == 0) {
$showColumns = array(1, 2, 3);
}
$columnHeaders = headers::model()->getAll();
$allHeaders = array();
foreach ($columnHeaders as $header) {
$allHeaders[$header->id] = $header;
}
$headers = array('show' => $showColumns, 'headers' => $allHeaders);
$pagination = array('limit' => array(0, 10), 'filter' => 'All categories', 'sortAttribute' => null, 'sortDirection' => null);
if (!empty($_GET['ajax'])) {
//handle ajax requests
//get the pagination data from the query string
if (isset($_GET['headers'])) {
$headers['show'] = explode(',', $_GET['headers']);
Auth::User()->setColumns($_GET['headers']);
}
$sortHeader = headers::model()->getbyPK($_GET['sortAttribute']);
$pagination['sortAttribute'] = $sortHeader->sortName;
$pagination['sortDirection'] = $_GET['sortDirection'];
$pagination['limit'] = array($_GET['paginationPageNumber'], $_GET['paginationPerPage']);
$pagination['filter'] = $_GET['filter'];
$conditions = null;
$params = null;
//if there is a filter in place, create the conditions and parameters needed
if (!empty($pagination['filter']) && $pagination['filter'] != 'All categories') {
$conditions = "category = :category";
$category = categories::model()->getByAttribute('name', $pagination['filter']);
$params = array('category' => $category->id);
}
$models = items::model(true)->getAll($conditions, $params, $pagination);
$count = items::model()->getCount($conditions, $params);
$pagination['count'] = $count;
$pagination['sortAttribute'] = $_GET['sortAttribute'];
$this->renderPartial('table', array('data' => $models, 'statuses' => $statuses, 'pagination' => $pagination, 'vendors' => $vendors, 'tags' => $tags, 'headers' => $headers));
} else {
//handle default requests
$models = items::model(true)->getAll(null, null, $pagination);
$count = items::model()->getCount(null);
$pagination['count'] = $count;
$this->render('index', array('models' => $models, 'statuses' => $statuses, 'vendors' => $vendors, 'tags' => $tags, 'pagination' => $pagination, 'headers' => $headers));
}
}