Esempio n. 1
0
 public function preDisplay()
 {
     parent::preDisplay();
     // Set header if needed
     $this->setHeader($this->data['currentFolderName'] . ' - ' . SITE_NAME, 'title');
     if (isset($this->data['folders'])) {
         foreach ($this->data['folders'] as $key => $folder) {
             if ($folder['filesNum'] == 0 && $folder['subFoldersNum'] == 0) {
                 $folder['link'] = '#';
             } else {
                 $folder['link'] = '/list/' . $folder['fd_id'];
             }
             $folder['desc'] = '(含' . $folder['subFoldersNum'] . '个图集, ' . $folder['filesNum'] . '张图片)';
             $this->data['folders'][$key] = $folder;
         }
         if ($this->data['subFolderPager'] == 'more') {
             $this->data['subFolderPager'] = '<div id="pagerMore"><a href="/list_subfolders/' . $this->data['currentFolderId'] . '">更多</a></div>';
         } else {
             import('Pager');
             $pager = new Pager($this->data['limitNum'], $this->data['subFolderTotal'], $this->data['page'], '/list_subfolders/' . $this->data['currentFolderId'] . '/');
             $this->data['subFolderPager'] = $pager->generatePages();
         }
     }
     if (isset($this->data['files'])) {
         if ($this->data['filesPager'] == 'more') {
             $this->data['filesPager'] = '<div id="pagerMore"><a href="/list_files/' . $this->data['currentFolderId'] . '">更多</a></div>';
         } else {
             import('Pager');
             $pager = new Pager($this->data['limitNum'], $this->data['filesTotal'], $this->data['page'], '/list_files/' . $this->data['currentFolderId'] . '/');
             $this->data['filesPager'] = $pager->generatePages();
         }
     }
 }
Esempio n. 2
0
function showlist()
{
    global $db;
    global $smarty;
    $page_size = getPageSize();
    // 每页显示的条目数
    $sub_pages = getSubPages();
    // 每次显示的页数
    $current_page = empty($_GET["p"]) ? "1" : $_GET["p"];
    // 当前被选中的页
    // 消息类型: 0表示用户发送  1表示管理员回复 2表示管理员群发消息 3 自动回复  4聊天室信息
    $sql = "SELECT a.*, b.nickname, b.localnickname, b.backup,  \r\n\t\tCONCAT(SUBSTR(b.headimgurl,1,(LENGTH(b.headimgurl) - 1)),'46') as headimgurl, c.content as replycontent , TIMESTAMPDIFF(SECOND  ,a.createtime, date_format(now(),'%Y%m%d%h%m%s')) timeInterval\r\n    \tfrom wx_user_msg a \r\n\t\tleft join wx_user_info b\r\n\t\t\ton a.createby = b.openid \r\n\t\tleft join wx_user_msg c\r\n\t\t\ton a.id = c.replyid\r\n\t\twhere a.msgtype in('0', '4', '5')\r\n\t\torder by createtime desc";
    $res = $db->query_page_list2($sql, $page_size, $current_page);
    $rowList = $db->fetch_all($res);
    // 查总记录数
    $countres = $db->query("SELECT count(1) as totalcount from wx_user_msg a where a.msgtype in('0', '4')");
    $countObj = $db->fetch($countres);
    // 总条目数
    $nums = $countObj["totalcount"];
    //echo $nums."=======>";
    $pager = new Pager($page_size, $nums, $current_page, $sub_pages);
    //$pagerlinker = $pager -> commonPager();
    $pagerlinker = $pager->mod5();
    //echo print_r($rowList);
    $smarty->assign('pager', $pagerlinker);
    $smarty->assign('messageArray', $rowList);
    $smarty->display('sysadmin/wxmessagelist.html');
}
Esempio n. 3
0
/**
 * Smarty page modifier plugin
 *
 * Type:     modifier<br>
 * Name:     page<br>
 * Date:     JUNE 19, 2008
 * Purpose:  get page list by count
 * Input:    count int 
 * Input:    page_size int 
 * Example:  {$count|page:20}
 * @version 1.0
 * @param 	(int)	$count	| 分页的总数
 * @param 	(int)	$page_size		| 每页多少条记录
 * @return 	(String)	分页字符串
 */
function smarty_modifier_page($count, $page_size = 20)
{
    $count = intval($count);
    $page_size = intval($page_size);
    $pager = new Pager(array('rowCount' => $count, 'pageSize' => $page_size));
    return $pager->genYuan();
}
Esempio n. 4
0
 public function action_list()
 {
     $cid = Arr::get($_GET, 'cid');
     $where = array();
     $where['cid'] = $cid;
     $where['status'] = 'open';
     $where['ORDER'] = 'id DESC';
     $where = array_filter($where);
     $m_article = Model::factory('article', 'cms');
     $total = $m_article->count($where);
     $pager = new Pager($total, 10);
     $list = $m_article->select($pager->offset, $pager->size, $where)->as_array();
     $m_category = Model::factory('category', 'cms');
     $cat_list = $m_category->getAll()->as_array('id', 'name');
     foreach ($list as &$item) {
         $item['cat_name'] = isset($cat_list[$item['cid']]) ? $cat_list[$item['cid']] : '';
     }
     unset($item);
     if (isset($_GET['get_next_page'])) {
         $content = View::factory('article/list_incr');
         $content->list = $list;
         $next_page = $pager->next_page ? $pager->url($pager->next_page, array('cid' => $cid, 'get_next_page' => 'ajax')) : '';
         header('Content-Type: application/json; charset=utf-8');
         $ret = array('content' => (string) $content, 'next_page' => $next_page);
         echo json_encode($ret);
         exit;
     }
     $this->content = View::factory('article_list');
     $this->content->list = $list;
     $this->content->pager = $pager->render('common/pager');
     $this->content->next_page = $pager->next_page ? $pager->url($pager->next_page, array('cid' => $cid, 'get_next_page' => 'ajax')) : '';
 }
Esempio n. 5
0
function get_all_articles()
{
    $con = new database();
    $query = "select articles.articleID, articles.stageID, articles.title, articles.created from articles";
    $page = new Pager($query, 'navlist', '../templates/data_table.tpl.php');
    return $page->display_record($_GET['page']);
}
Esempio n. 6
0
 /**
  * @param \Sonata\AdminBundle\Admin\AdminInterface $admin
  * @param array $values
  * @return \Sonata\AdminBundle\Datagrid\DatagridInterface
  */
 public function getBaseDatagrid(AdminInterface $admin, array $values = array())
 {
     $pager = new Pager();
     $pager->setCountColumn($admin->getModelManager()->getIdentifierFieldNames($admin->getClass()));
     $formBuilder = $this->formFactory->createNamedBuilder('form', 'filter', array(), array('csrf_protection' => false));
     return new Datagrid($admin->createQuery(), $admin->getList(), $pager, $formBuilder, $values);
 }
Esempio n. 7
0
function pagestring($count, $pagesize, $wap = false)
{
    if (isset($_GET['page']) && intval($_GET['page']) == 0) {
        $pagesize = $count;
    }
    $p = new Pager($count, $pagesize, 'page');
    return array($pagesize, $p->pageNo, $p->genBasic());
}
Esempio n. 8
0
 /**
  * Тег постраничной навигации
  *
  * @param  array $config конфиг
  * @param  int   $total  Общее кол-во страниц
  *
  * @return string        формированный блок с постраничкой
  */
 public static function pages($config, $total)
 {
     $config['total_items'] = $total;
     $pages = '';
     if ($total > $config['items_per_page']) {
         $pagination = new Pager($config);
         // Сформированный блок с постраничкой
         $pages = $pagination->render();
     }
     return $pages;
 }
Esempio n. 9
0
 public function testNoRecords()
 {
     $pager = new Pager();
     $pager->total_records = 0;
     $pager->records_per_page = 10;
     $pager->shown_pages = 5;
     $pager->shown_pages_wing = 2;
     // try last page first
     $this->assertEquals(0, $pager->getOffsetOf(10));
     $this->assertEquals([], $pager->getPages());
 }
Esempio n. 10
0
 public function renderDefault()
 {
     $files = $this->files->order($this->order . " " . $this->sort);
     // vyhledavani
     if ($this->q) {
         $files->where("file.name LIKE ?", "%" . $this->q . "%");
         $this['search']['q']->setDefaultValue($this->q);
         $this->template->search = TRUE;
     } else {
         $this->template->search = FALSE;
     }
     $this->pagerFiles->itemCount = $files->count();
     $this->template->files = $files->limit($this->pagerFiles->getLimit(), $this->pagerFiles->getOffset());
 }
Esempio n. 11
0
 function browse($path, $visible, $offset = 0, $limit = 10)
 {
     global $intl, $loader;
     $loader->import('saf.Database.Pager');
     $output = '';
     $res = $this->doc->query($path);
     if (!is_array($res)) {
         $this->error = $this->doc->error;
         return 0;
     }
     $pager = new Pager();
     printf('<p>%s</p>', $pager->link($this->browseLink, $limit, $offset, count($res)));
     // create table header
     $output .= "<table border='1' cellpadding='5'>\n";
     $output .= "\t<tr>\n";
     $output .= "\t\t<th><input type='submit' name='action' value='" . $intl->get('Delete') . "' /></th>\n";
     $output .= "\t\t<th><input type='submit' value='" . $intl->get('Select All') . "' /></th>\n";
     foreach ($visible as $node) {
         $output .= "\t\t<th>" . ucwords(str_replace('_', ' ', $node)) . "</th>\n";
     }
     $output .= "\t</tr>\n";
     for ($i = $offset; $i < $offset + $limit; $i++) {
         if (!is_object($res[$i])) {
             break;
         }
         $row = $res[$i]->makeObj();
         $path = urlencode($res[$i]->path());
         $output .= "\t<tr>\n";
         $output .= "\t\t<td align='center'>";
         $output .= "<input type='checkbox' name='del_items[]' value='" . $path . "' />";
         //			$output .= $intl->get ('Delete');
         $output .= "</td>\n";
         $output .= "\t\t<td>";
         $output .= "<a href='" . $this->editLink . $path . "'>";
         $output .= $intl->get('Edit');
         $output .= '</a>';
         $output .= ' | ';
         $output .= "<a href='" . $this->downloadLink . $path . "'>";
         $output .= $intl->get('Download');
         $output .= '</a>';
         $output .= "</td>\n";
         foreach ($visible as $node) {
             $output .= "\t\t<td>" . $row->{$node} . "</td>\n";
         }
         $output .= "\t</tr>\n";
     }
     // create table footer
     $output .= "</table>\n";
     return $output;
 }
Esempio n. 12
0
 public function set_recovery_post()
 {
     $PagerList = new ObjList(['db_where_Arr' => ['status' => -1], 'db_where_deletenull_Bln' => TRUE, 'model_name_Str' => 'Pager', 'limitstart_Num' => 0, 'limitcount_Num' => 100]);
     foreach ($PagerList->obj_Arr as $key => $value_pager) {
         $Pager = new Pager(['pagerid_Num' => $value_pager->pagerid_Num]);
         $Pager->recovery();
     }
     if (!empty($PagerList->obj_Arr)) {
         $this->load->model('Message');
         $this->Message->show(['message' => '復原成功', 'url' => 'admin/base/pager/set/set']);
     } else {
         $this->load->model('Message');
         $this->Message->show(['message' => '已無可復原的項目', 'url' => 'admin/base/pager/set/set']);
     }
 }
Esempio n. 13
0
 public function actionNewsList()
 {
     $id = yii::app()->request->getParam('id');
     $page = yii::app()->request->getParam('page');
     $channel = TSChannel::model()->find('Channel_Identify=:id', array(':id' => $id));
     $criteria = new CDbCriteria();
     $criteria->condition = "Article_Is_Publish = 1 AND Channel_Identify ='" . $id . "'";
     $criteria->order = 'Article_Create_Time desc';
     $count = TSArticle::model()->count($criteria);
     $pages = new Pager($count);
     $pages->currentPage = (int) $page;
     $pages->pageSize = 3;
     $pages->applyLimit($criteria);
     $models = TSArticle::model()->findAll($criteria);
     $this->render('news_list', array('articles' => $models, 'pages' => $pages, 'id' => $id, 'channel' => $channel));
 }
Esempio n. 14
0
 /**
  * Конструктор
  *
  * @param View $view объект класса, осуществляющий вывод постраничной навигации
  * @param String $dir_name путь к папке с файлами
  * @param Integer $items_per_page количество позиций на одной странице
  * @param Integer $links_count количество видимых ссылок слева и справа от текущей страницы
  * @param String $get_params дополнительные параметры, которые необходимо передавать по ссылкам
  * @param String $counter_param название GET-параметра, через который передается номер текущей страницы
  */
 public function __construct(View $view, $dir_name = '.', $items_per_page = 10, $links_count = 3, $get_params = null, $counter_param = 'page')
 {
     // Удаляем последний символ /, если он имеется
     $this->dirname = ltrim($dir_name, "/");
     // Инициализируем переменные через конструктор базового класса
     parent::__construct($view, $items_per_page, $links_count, $get_params, $counter_param);
 }
Esempio n. 15
0
 public function defaultAction()
 {
     $pageSize = 50;
     $page = Pager::get();
     $category = (int) Request::getGET('category', -1);
     $title = trim(Request::getGET('title', ''));
     $username = trim(Request::getGET('username', ''));
     $where = array();
     if ($category != -1) {
         $where[] = array('category', '=', $category);
     }
     if (!empty($username)) {
         $userInfo = UserCommonInterface::getByLoginName(array('login_name' => $username));
         $where[] = array('user_id', '=', Arr::get('id', $userInfo, 0));
     }
     if (!empty($title)) {
         $where[] = array('title', 'LIKE', "%{$title}%");
     }
     if ($category != -1) {
         $order = array('hidden' => 'ASC', 'title' => 'ASC', 'id' => 'DESC');
     } else {
         $order = array('id' => 'DESC');
     }
     $offset = ($page - 1) * $pageSize;
     $docList = DocInterface::getList(array('where' => $where, 'order' => $order, 'limit' => $pageSize, 'offset' => $offset));
     $allCount = empty($docList) ? 0 : DocInterface::getCount($where);
     $userIds = array_unique(array_column($docList, 'user_id'));
     $userHash = UserCommonInterface::getById(array('id' => $userIds));
     // 缓存部分的html
     $html = array();
     $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 7), 'widget/pager.php');
     $this->renderFramework(array('html' => $html, 'docList' => $docList, 'userHash' => $userHash), 'doc/list.php');
 }
Esempio n. 16
0
 public function defaultAction()
 {
     $pageSize = 20;
     // 获取参数
     $page = Pager::get();
     $title = Request::getGET('title');
     $status = (int) Request::getGET('status');
     // 构建where
     $where = array();
     $where[] = array('user_id', '=', $this->loginUserInfo['id']);
     if (!empty($title)) {
         $where[] = array('title', 'LIKE', "%{$title}%");
     }
     if (!empty($status) && $status != -1) {
         $where[] = array('hidden', '=', $status - 1);
     }
     // 获取数据
     $order = array('refresh_at' => 'DESC', 'id' => 'DESC');
     $offset = ($page - 1) * $pageSize;
     $setList = OjProblemSetInterface::getList(array('where' => $where, 'order' => $order, 'limit' => $pageSize, 'offset' => $offset));
     $allCount = OjProblemSetInterface::getCount($where);
     foreach ($setList as &$setInfo) {
         $problemJson = $setInfo['problem_set'];
         $globalIds = (array) json_decode($problemJson, true);
         $setInfo['count'] = count($globalIds);
     }
     // 缓存部分的html
     $html = array();
     $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php');
     // 输出
     $this->renderFramework(array('html' => $html, 'setList' => $setList), 'setup/set/list.php');
 }
Esempio n. 17
0
 /**
  * Initializes the pager. Must be called before using the component.
  *
  * Takes user configuration and creates pager object ($this->Pager)
  *
  * @access public
  * @param array $config Configuration options for Pager::factory() method
  * @see http://pear.php.net/manual/en/package.html.pager.factory.php
  * @return void
  */
 function init($config)
 {
     // Get the correct URL, even with admin routes
     $here = array();
     if (defined('CAKE_ADMIN') && !empty($this->Controller->params[CAKE_ADMIN])) {
         $here[0] = $this->Controller->params[CAKE_ADMIN];
         $here[2] = substr($this->Controller->params['action'], strlen($this->Controller->params[CAKE_ADMIN]) + 1);
     } else {
         $here[2] = $this->Controller->params['action'];
     }
     $here[1] = Inflector::underscore($this->Controller->params['controller']);
     ksort($here);
     $url = implode('/', $here);
     // Set up the default configuration vars
     $this->params = array('mode' => 'Sliding', 'perPage' => 10, 'delta' => 5, 'totalItems' => '', 'httpMethod' => 'GET', 'currentPage' => 1, 'linkClass' => 'pager', 'altFirst' => 'First page', 'altPrev ' => 'Previous page', 'altNext' => 'Next page', 'altLast' => 'Last page', 'separator' => '', 'spacesBeforeSeparator' => 1, 'spacesAfterSeparator' => 1, 'useSessions' => false, 'firstPagePre' => '', 'firstPagePost' => '', 'firstPageText' => '<img src="' . $this->Controller->base . '/img/first.gif" alt="">', 'lastPagePre' => '', 'lastPagePost' => '', 'lastPageText' => '<img src="' . $this->Controller->base . '/img/last.gif" alt="">', 'prevImg' => '<img src="' . $this->Controller->base . '/img/prev.gif" alt="">', 'nextImg' => '<img src="' . $this->Controller->base . '/img/next.gif" alt="">', 'altPage' => 'Page', 'clearIfVoid' => true, 'append' => false, 'path' => '', 'fileName' => $this->Controller->base . DS . $url . DS . '%d', 'urlVar' => '');
     vendor('Pear/Pager/Pager');
     // Merge with user config
     $this->params = array_merge($this->params, $config);
     // sanitize requested page number
     if (!in_array($this->params['currentPage'], range(1, ceil($this->params['totalItems'] / $this->params['perPage'])))) {
         $this->params['currentPage'] = 1;
     }
     $this->Pager =& Pager::factory($this->params);
     // Set the template vars
     $this->Controller->set('pageLinks', $this->Pager->getLinks());
     $this->Controller->set('currentPage', $this->params['currentPage']);
     $this->Controller->set('isFirstPage', $this->Pager->isFirstPage());
     $this->Controller->set('isLastPage', $this->Pager->isLastPage());
 }
Esempio n. 18
0
 public function defaultAction()
 {
     $pageSize = 20;
     // 获取参数
     $page = Pager::get();
     $status = (int) Request::getGET('status');
     // 构建where
     $where = array();
     $where[] = array('remote', '=', StatusVars::REMOTE_HQU);
     $where[] = array('user_id', '=', $this->loginUserInfo['id']);
     if (!empty($status) && $status != -1) {
         $where[] = array('hidden', '=', $status - 1);
     }
     // 获取数据
     $offset = ($page - 1) * $pageSize;
     $problemList = OjProblemInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset));
     $allCount = OjProblemInterface::getCount($where);
     $userIds = array_unique(array_column($problemList, 'user_id'));
     $userHash = UserCommonInterface::getById(array('id' => $userIds));
     // 缓存部分的html
     $html = array();
     $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 5), 'widget/pager.php');
     // 输出
     $this->renderFramework(array('problemList' => $problemList, 'userHash' => $userHash, 'html' => $html), 'setup/problem/list.php');
 }
Esempio n. 19
0
 public function calculate()
 {
     parent::calculate();
     // load records .. see $this->firstRecord, $this->perPage
     $limitSql = sprintf(' LIMIT %s,%s', $this->firstRecord, $this->perPage);
     $this->records = array_values(DBObject::glob($this->itemClass, $this->pageSql . $limitSql));
 }
Esempio n. 20
0
 private function get_results($all = false)
 {
     $archive = Database_Mongo::collection('discrepancies');
     $filters = array();
     if (Arr::get($_GET, 'ticket')) {
         $tickets = array();
         foreach (explode(',', $_GET['ticket']) as $ticket) {
             if (preg_match('/^T1W[0-9]{12}$/', $ticket)) {
                 $tickets[] = $ticket;
             } else {
                 $tickets[] = new MongoRegex('/.*' . $ticket . '.*/i');
             }
         }
         $filters['job_key']['$in'] = $tickets;
     }
     if (Arr::get($_GET, 'file')) {
         $filters['filename'] = $_GET['file'];
     }
     if (Arr::get($_GET, 'start')) {
         $start = strtotime($_GET['start']);
         $filters['update_time']['$gt'] = $start;
     }
     if (isset($filters['end'])) {
         $end = strtotime($_GET['end']);
         $filters['update_time']['$lt'] = $end;
     }
     $result = $archive->find($filters)->sort(array('update_time' => -1, 'job_key' => 1));
     if (!$all) {
         Pager::$count = $result->count();
         $result->skip(Pager::offset())->limit(Pager::limit());
     }
     $list = array();
     $ids = array();
     foreach ($result as $row) {
         $list[] = $row;
         $ids[$row['job_key']] = 1;
     }
     $result = Database_Mongo::collection('jobs')->find(array('_id' => array('$in' => array_keys($ids))));
     $jobs = array();
     foreach ($result as $job) {
         $jobs[$job['_id']] = Arr::get($job, 'data');
     }
     $items = array();
     foreach ($list as $row) {
         $row['data'] = array_intersect_key($row['data'], Columns::get_visible());
         $row['current'] = array();
         $row['discr'] = 1;
         foreach ($row['data'] as $key => $value) {
             $row['current'][$key] = Arr::path($jobs, array($row['job_key'], $key));
             if ($row['current'][$key] != $value['old_value']) {
                 $row['discr'] = 0;
             }
         }
         foreach (Columns::get_static() as $static => $show) {
             $row['static'][$static] = Arr::path($jobs, array($row['job_key'], $static));
         }
         $items[] = $row;
     }
     return $items;
 }
 public function defaultAction()
 {
     $pageSize = 20;
     // 获取参数
     $page = Pager::get();
     $status = (int) Request::getGET('status', -1);
     $contestId = (int) Request::getGET('contest-id', 0);
     $where = array();
     $where[] = array('is_diy', '=', 0);
     if (!empty($contestId)) {
         $where[] = array('contest_id', '=', $contestId);
     }
     if ($status != -1) {
         $where[] = array('status', '=', $status);
     }
     // 获取数据
     $offset = ($page - 1) * $pageSize;
     $applyList = OjContestApplyInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset));
     $allCount = 0;
     $userHash = array();
     $contestHash = array();
     if (!empty($applyList)) {
         $allCount = OjContestApplyInterface::getCount($where);
         $userIds = array_column($applyList, 'user_id');
         $userHash = UserCommonInterface::getById(array('id' => $userIds));
         $contestIds = array_unique(array_column($applyList, 'contest_id'));
         $contestHash = OjContestInterface::getById(array('id' => $contestIds));
     }
     // 缓存部分的html
     $html = array();
     $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php');
     $this->renderFramework(array('html' => $html, 'applyList' => $applyList, 'contestHash' => $contestHash, 'userHash' => $userHash), 'contest/apply_list.php');
 }
 public function defaultAction()
 {
     $pageSize = 50;
     // 获取参数
     $page = Pager::get();
     $contestId = (int) Request::getGET('contest-id');
     $status = (int) Request::getGET('status', -1);
     $contestInfo = OjContestInterface::getById(array('id' => $contestId));
     if (empty($contestInfo) || $contestInfo['hidden'] || $contestInfo['type'] != ContestVars::TYPE_APPLY) {
         $this->renderError('竞赛不存在,或者竞赛不需要报名!');
     }
     // 构建where
     $where = array();
     $where[] = array('contest_id', '=', $contestId);
     if ($status != -1) {
         $where[] = array('status', '=', $status);
     }
     // 获取数据
     $offset = ($page - 1) * $pageSize;
     $applyList = OjContestApplyInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset));
     $allCount = OjContestApplyInterface::getCount($where);
     // userHash
     $userIds = array_unique(array_column($applyList, 'user_id'));
     $userHash = UserCommonInterface::getById(array('id' => $userIds));
     // 缓存部分的html
     $html = array();
     $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php');
     $this->renderFramework(array('html' => $html, 'applyList' => $applyList, 'contestInfo' => $contestInfo, 'userHash' => $userHash), 'contest/apply_list.php');
 }
Esempio n. 23
0
 function testXSS()
 {
     $options = array('itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), 'perPage' => 5, 'nextImg' => '&raquo;');
     $this->pager = Pager::factory($options);
     $expected = '&nbsp;<a href="./&quot;&gt;test?pageID=2" title="next page">&raquo;</a>&nbsp;';
     $this->assertEqual($expected, $this->pager->_getNextLink());
 }
Esempio n. 24
0
 public function defaultAction()
 {
     $pageSize = 20;
     // 获取参数
     $page = Pager::get();
     $title = Request::getGET('title');
     $status = (int) Request::getGET('status');
     // 构建where
     $where = array(array('user_id', '=', $this->loginUserInfo['id']), array('is_diy', '=', 1));
     if (!empty($status) && $status != -1) {
         $where[] = array('hidden', '=', $status - 1);
     }
     if (!empty($title)) {
         $where[] = array('title', 'LIKE', "%{$title}%");
     }
     // 获取数据
     $offset = ($page - 1) * $pageSize;
     $contestList = OjContestInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset));
     $allCount = 0;
     if (!empty($contestList)) {
         $allCount = OjContestInterface::getCount($where);
     }
     $userIds = array_unique(array_column($contestList, 'user_id'));
     $userHash = UserCommonInterface::getById(array('id' => $userIds));
     // 缓存部分的html
     $html = array();
     $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php');
     // 输出
     $this->renderFramework(array('contestList' => $contestList, 'userHash' => $userHash, 'html' => $html), 'setup/contest/list.php');
 }
Esempio n. 25
0
 public function action_index()
 {
     $id = strval(Arr::get($_GET, 'ticket'));
     if (!$id) {
         throw new HTTP_Exception_404('Not found');
     }
     $filter = array('_id' => $id);
     if (!Group::current('allow_assign')) {
         $filter['$or'] = array(array('companies' => intval(User::current('company_id'))), array('ex' => intval(User::current('company_id'))));
     }
     $job = Database_Mongo::collection('jobs')->findOne($filter);
     if (!$job) {
         throw new HTTP_Exception_404('Not found');
     }
     $filter = array('job_key' => $id);
     if (!Group::current('allow_assign')) {
         $filter['user_id'] = array('$in' => DB::select('id')->from('users')->where('company_id', '=', User::current('company_id'))->execute()->as_array(NULL, 'id'));
     }
     $result = Database_Mongo::collection('submissions')->find($filter)->sort(array('update_time' => -1));
     Pager::$count = $result->count(true);
     $result->limit(Pager::limit())->skip(Pager::offset());
     $submissions = array();
     $users = array();
     while ($row = $result->next()) {
         $users[$row['user_id']] = 1;
         $submissions[] = $row;
     }
     if ($users) {
         User::get(array_keys($users));
     }
     $companies = DB::select('id', 'name')->from('companies')->execute()->as_array('id', 'name');
     $view = View::factory('Jobs/Submissions');
     $view->bind('submissions', $submissions)->bind('companies', $companies)->bind('job', $job);
     $this->response->body($view);
 }
 function testClearIfVoid()
 {
     $this->assertTrue(strlen($this->pager->links) > 0);
     $options = array('itemData' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), 'perPage' => 20, 'mode' => 'Sliding');
     $this->pager = Pager::factory($options);
     $this->assertEqual('', $this->pager->links);
 }
Esempio n. 27
0
    public function getContent()
    {
        global $sql;
        $pager = new Pager('users', Kio::getStat('total', 'users'), Kio::getConfig('limit', 'users'));
        $pager->sort(array(t('Nickname') => 'nickname', t('Group') => 'g_name', t('Gender') => 'gender', t('Title') => 'title', t('Location') => 'locality', t('Country') => 'country', t('Registered') => 'registered'), 'registered', 'asc');
        $query = $sql->query('
			SELECT id, name, inline, members
			FROM ' . DB_PREFIX . 'groups
			ORDER BY display_order');
        while ($row = $query->fetch()) {
            if ($row['inline']) {
                $row['name'] = sprintf($row['inline'], $row['name']);
            }
            $groups[] = $row;
        }
        $query = $sql->query('
			SELECT u.id, u.nickname, u.email, u.registered, u.group_id, u.gender, u.locality, u.country, u.communicator, u.title, g.name g_name
			FROM ' . DB_PREFIX . 'users u
			LEFT JOIN ' . DB_PREFIX . 'groups g ON g.id = u.group_id
			ORDER BY ' . $pager->orderBy . '
			LIMIT ' . $pager->limit . '
			OFFSET ' . $pager->offset);
        while ($row = $query->fetch()) {
            $row['nickname'] = User::format($row['id'], $row['nickname'], $row['group_id']);
            switch ($row['gender']) {
                case 1:
                    $row['gender'] = ' <img class="gender" src="' . LOCAL . 'themes/' . THEME . '/images/male.png" alt="' . t('Male') . '" title="' . t('Male') . '" />';
                    break;
                case 2:
                    $row['gender'] = ' <img class="gender" src="' . LOCAL . 'themes/' . THEME . '/images/female.png" alt="' . t('Female') . '" title="' . t('Female') . '" />';
                    break;
                default:
                    $row['gender'] = '';
            }
            $users[] = $row;
        }
        try {
            $tpl = new PHPTAL('modules/users/users.tpl.html');
            $tpl->sort = $pager->sorters;
            $tpl->users = $users;
            $tpl->groups = $groups;
            $tpl->pagination = $pager->getLinks();
            return $tpl->execute();
        } catch (Exception $e) {
            return template_error($e);
        }
    }
Esempio n. 28
0
 function testGetAndPost()
 {
     $this->pager =& Pager::factory($this->options);
     $this->assertNoPattern('/id=/', $this->pager->links);
     $_GET['id'] = 123;
     $this->pager =& Pager::factory($this->options);
     $this->assertPattern('/id=123/', $this->pager->links);
 }
Esempio n. 29
0
 function currentPageNumber()
 {
     if ($this->currentPage != $this->pageCount) {
         return parent::currentPageNumber();
     } else {
         return '';
     }
 }
Esempio n. 30
0
 public function action_list()
 {
     $database = $this->curr_db;
     $curr_table = $this->curr_table;
     $model = Model::factory($curr_table, $this->curr_db);
     $db = Cookie::get('db');
     $db = json_decode($db, true);
     if (!isset($db[$database][$curr_table]) || !is_array($db[$database][$curr_table])) {
         $columns = $model->list_columns($curr_table)->as_array(null, 'Field');
         $columns = array_map(function ($n) {
             return $n > 7 ? 0 : 1;
         }, array_flip($columns));
         $db[$database][$curr_table] = $columns;
         Cookie::set('db', json_encode($db));
     } else {
         $columns = $db[$database][$curr_table];
     }
     $where = array();
     $field_name = Arr::get($_GET, 'field_name');
     $field_value = Arr::get($_GET, 'field_value');
     $op = Arr::get($_GET, 'op', '=');
     if (!empty($field_name)) {
         $where[$field_name . '|' . $op] = $field_value;
     }
     $where = array_filter($where, 'strlen');
     if (isset($_GET['sort'])) {
         list($field, $order) = explode('|', $_GET['sort']);
         $fields = array_keys($columns);
         if (in_array($field, $fields) && in_array($order, array('asc', 'desc'))) {
             $where['ORDER'] = $field . ' ' . $order;
         }
     }
     $total = $model->count($where);
     $pager = new Pager($total, 10);
     $list = $model->select($pager->offset, $pager->size, $where);
     $this->content = View::factory('myadmin/list');
     $this->content->columns = $columns;
     $this->content->list = $list;
     $this->content->field = isset($field) ? $field : '';
     $this->content->order = isset($order) ? $order : '';
     $this->content->field_name = $field_name;
     $this->content->field_value = $field_value;
     $this->content->op = $op;
     $this->content->pager = $pager->render('myadmin/pager');
 }