コード例 #1
0
ファイル: SoohDBTestKVObj.php プロジェクト: hillstill/sooh
 /**
  * @dataProvider provider_paged
  */
 public function testPaged($sortDefine, $where, $rsTotal, $firstPage, $secondPage, $fifthPage, $thirdPage)
 {
     $obj = TstKVObj::getCopy(array('autoid' => 0));
     $pagesize = 2;
     $pager = new \Sooh\DB\Pager($pagesize, array(2), false);
     $this->AssertEquals($rsTotal, $obj->loopGetRecordsCount($where), ' rs-count error with autoid>3');
     //firstPage
     $pager->init($rsTotal, 1);
     $ret = $obj->loopGetRecordsPage($sortDefine, array('where' => $where), $pager);
     $this->AssertEquals($firstPage, $obj->fmtRecords($ret), ' failed at page 1');
     //secondPage
     $pager->init($rsTotal, 2);
     $ret = $obj->loopGetRecordsPage($sortDefine, $ret['lastPage'], $pager);
     $this->AssertEquals($secondPage, $obj->fmtRecords($ret), ' failed at page 2');
     $pager->init($rsTotal, 5);
     $ret = $obj->loopGetRecordsPage($sortDefine, $ret['lastPage'], $pager);
     $this->AssertEquals($fifthPage, $obj->fmtRecords($ret), ' failed at page 5');
     $pager->init($rsTotal, 3);
     $ret = $obj->loopGetRecordsPage($sortDefine, $ret['lastPage'], $pager);
     $this->AssertEquals($thirdPage, $obj->fmtRecords($ret), ' failed at page 3');
     TstKVObj::freeAll(array('autoid' => 0));
     $obj = null;
 }
コード例 #2
0
ファイル: Managers.php プロジェクト: hillstill/soohyaf
 public function indexAction()
 {
     if (!$this->manager) {
         return;
     }
     $pageid = $this->_request->get('pageid', 1) - 0;
     $pager = new \Sooh\DB\Pager($this->_request->get('pagesize', 10), array(10, 30, 100), false);
     $frm = \Sooh\Base\Form\Broker::getCopy('default')->init(\Sooh\Base\Tools::uri(), 'get', \Sooh\Base\Form\Broker::type_s);
     //$frm->addItem('_camefrom_eq', form_def::factory('', 'local', form_def::constval));
     $frm->addItem('_loginname_lk', form_def::factory('帐号关键词', '', form_def::text))->addItem('_nickname_lk', form_def::factory('昵称关键词', '', form_def::text))->addItem('_dtForbidden_eq', form_def::factory('', '', form_def::select)->initMore(new \Sooh\Base\Form\Options(array('2147123124' => '已禁用', '0' => '正常'), '不限')))->addItem('pageid', $pageid)->addItem('pagesize', $this->pager->page_size);
     $frm->fillValues($this->getInputs());
     if ($frm->flgIsThisForm) {
         $where = $frm->getWhere();
         $where['camefrom'] = 'local';
     } else {
         $where = array();
     }
     $pager->init($this->manager->getAccountNum($where), $pageid);
     $isDownloadExcel = $this->_request->get('__EXCEL__') == 1;
     $records = $this->manager->db()->getRecords($this->manager->tbname(), '*', $where, 'sort camefrom sort loginname', $pager->page_size, $pager->rsFrom());
     $headers = array('账号' => 70, '昵称' => 90, '最后登入时间' => 80, '最后登入IP' => 70, '权限' => '', '状态' => 90);
     if (!$isDownloadExcel) {
         $headers['其他操作'] = 90;
     }
     $menus = $this->manager->acl->getMenuEnum();
     $rightsMap = array();
     foreach ($menus->children as $menu) {
         foreach ($menu->children as $child) {
             $v = $child->options['_ModCtrl_'];
             $rightsMap[$v] = $menu->capt . '.' . $child->capt;
         }
     }
     if (!empty($records)) {
         foreach ($records as $rowid => $r) {
             $new = array($r['loginname'], $r['nickname'], date('m-d H:i', $r['lastDt']), $r['lastIP']);
             $tmp = explode(',', $r['rights']);
             $ret = array();
             foreach ($tmp as $k) {
                 list($i, $v) = explode('.', $rightsMap[$k]);
                 $ret[$i][] = $v;
             }
             $tmp = '';
             foreach ($ret as $k => $v) {
                 $tmp .= "【{$k}】:" . implode(',', $v) . ' ';
             }
             $new[] = $tmp;
             $new[] = $r['dtForbidden'] ? '禁用' : '正常';
             if (!$isDownloadExcel) {
                 $new[] = "<a class=\"button\" rel=\"dlg_default\" title=\"日志记录窗口\" target=\"dialog\" href=\"" . \Sooh\Base\Tools::uri(array('_pkey_val' => $pkey), 'showlog') . "\"><span>看日志</span></a>";
                 $new['_pkey_val_'] = \Lib\Misc\DWZ::encodePkey(array('camefrom' => 'local', 'loginname' => $r['loginname']));
             }
             $records[$rowid] = $new;
         }
     }
     if ($isDownloadExcel) {
         return $this->downExcel($records, array_keys($headers));
     } else {
         $this->_view->assign('headers', $headers);
         $this->_view->assign('records', $records);
         $this->_view->assign('pager', $pager);
     }
 }