当前位置: 首页>>代码示例>>PHP>>正文


PHP headers::model方法代码示例

本文整理汇总了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));
     }
 }
开发者ID:amarble,项目名称:project-byz,代码行数:56,代码来源:itemsController.php


注:本文中的headers::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。