GetDataAction.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * summary: 获取目录列表
  4. * author: justin
  5. * date: 2014.03.04
  6. */
  7. class GetDataAction extends CAction
  8. {
  9. public function run(){
  10. $filter_status = intval(Yii::app()->request->getParam('filter_status', 1));
  11. $criteria = new EMongoCriteria();
  12. if ($filter_status < 10){
  13. $criteria->status('==', $filter_status);
  14. }
  15. $criteria->sort('sort', EMongoCriteria::SORT_ASC);
  16. $cursor = AdminMenuAR::model()->findAll($criteria);
  17. $rows = array();
  18. $total = 0;
  19. $i = 1;
  20. foreach ($cursor as $v){
  21. $temp = $v->attributes;
  22. $temp['_id'] = (string)$temp['_id'];
  23. $temp['id'] = $i ++;
  24. if ($temp['parent']){
  25. $temp['parent'] = $temp['_parentId'] = (string)$temp['parent'];
  26. } else {
  27. $temp['parent'] = $temp['_parentId'] = '';
  28. }
  29. if ($temp['url'] == ''){
  30. $temp['state'] = 'closed';
  31. }
  32. $rows[] = $temp;
  33. if ($temp['level'] == 1){
  34. $total ++;
  35. }
  36. }
  37. $total = $cursor->count();
  38. if ($total > 0){
  39. $total = 1;
  40. }
  41. echo CommonFn::composeDatagridData($rows, $total);
  42. }
  43. }