Example #1
0
 public function testFindAll()
 {
     $set = Page::findAll();
     $this->assertType("Ormion\\Collection", $set);
     $this->assertType("Page", $set[0]);
     $set = Page::findAll(array("allowed" => true));
     $this->assertType("Ormion\\Collection", $set);
     $this->assertEquals(2, count($set));
 }
Example #2
0
 /**
  * Retrieves the given $url and returns the all matches for the nonce regex or false if not found.
  *
  * @param \Requests_Session $session The session to send the request from.
  * @param string $url The page URL.
  * @param string $regex The regex to use to find the nonce. It must have a single capture group.
  *
  * @return string|false The nonce if found, otherwise false.
  */
 public static function findAllOnPage(\Requests_Session $session, $url, $regex = '/name="_wpnonce"\\s+value="(.+?)"/')
 {
     //TODO: improve this to be more than just a dumb regex match
     $nonceMatches = Page::findAll($session, $url, $regex);
     if (!is_array($nonceMatches) || count($nonceMatches) < 2 || empty($nonceMatches[1])) {
         return false;
     }
     $nonces = [];
     foreach ($nonceMatches as $m) {
         $nonces[] = $m[1];
     }
     return $nonces;
 }
Example #3
0
 public function run()
 {
     $model = new Page();
     //条件
     $criteria = new CDbCriteria();
     $title = Yii::app()->request->getParam('title');
     $titleAlias = Yii::app()->request->getParam('titleAlias');
     $title && $criteria->addSearchCondition('title', $title);
     $titleAlias && $criteria->addSearchCondition('title_alias', $titleAlias);
     $criteria->order = 't.id DESC';
     $count = $model->count($criteria);
     //分页
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pages->applyLimit($criteria);
     //查询
     $result = $model->findAll($criteria);
     $this->controller->render('index', array('model' => $model, 'datalist' => $result, 'pagebar' => $pages));
 }
Example #4
0
 public function actionIndex()
 {
     $model = new Page();
     $criteria = new CDbCriteria();
     $condition = '1';
     $title = $this->_request->getParam('title');
     $titleAlias = $this->_request->getParam('titleAlias');
     $title && ($condition .= ' AND title LIKE \'%' . $title . '%\'');
     $titleAlias && ($condition .= ' AND title_alias LIKE \'%' . $titleAlias . '%\'');
     $criteria->condition = $condition;
     $criteria->order = 't.id DESC';
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 13;
     $pageParams = $this->buildCondition($_GET, array('page_name_alias', 'page_name'));
     $pages->params = is_array($pageParams) ? $pageParams : array();
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $model->findAll($criteria);
     $this->render('index', array('datalist' => $result, 'pagebar' => $pages));
 }
Example #5
0
 protected function beforeRender()
 {
     $this->template->pages = Page::findAll()->orderBy("created");
 }
Example #6
0
 public static function getPageByCategory($catid)
 {
     return Page::findAll(['category_id' => $catid]);
 }
Example #7
0
<?php

$page = isset($_GET['page']) ? $_GET['page'] : 1;
if (!preg_match('/^\\d+$/', $page)) {
    dispatch('core/backend/404');
    exit;
}
$objects = Page::findAll();
$html = new HTML();
$html->renderOut('core/backend/html_header', array('title' => i18n(array('en' => 'Page', 'zh' => '基本页面'))), true);
$html->output('<div id="wrapper">');
$html->renderOut('core/backend/header');
$perpage = 50;
$total = Page::countAll();
$total_page = ceil($total / $perpage);
$html->renderOut('page/backend/page_list', array('objects' => Page::findAllWithPage($page, $perpage), 'current_page' => $page, 'total_page' => $total_page, 'total' => $total, 'pager' => $html->render('core/components/pagination', array('total' => $total_page, 'page' => $page)), 'start_entry' => ($page - 1) * $perpage + 1, 'end_entry' => min(array($total, $page * $perpage))), true);
$html->output('</div>');
$html->renderOut('core/backend/html_footer');
exit;