Page PHP Class Code Examples

This page contains top rated real world PHP examples of class Page extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: content.php Project: KasaiDot/FoOlSlide
0
 /**
  * When you pages are added, this cleans up the chapter and adds new pages
  * 
  * @param int $chapter_id
  * @param array $new_pages_array 
  */
 public function _clean_chapter($chapter_id, $new_pages_array)
 {
     // found, let's get all chapters for this comic
     $pages = new Page();
     $pages->where('chapter_id', $chapter_id)->get();
     $pages = $pages->all_to_array();
     foreach ($new_pages_array as $key => $item) {
         foreach ($pages as $k => $i) {
             if ($item["id"] == $i["id"]) {
                 if ($item["filename"] != $i["filename"] || $item["size"] != $i["size"]) {
                     $page = new Page($item["id"]);
                     $page->remove_page();
                     unset($pages[$k]);
                     break;
                 }
                 unset($pages[$k]);
                 unset($new_pages_array[$key]);
                 break;
             }
         }
     }
     foreach ($new_pages_array as $key => $item) {
         $page = new Page();
         $page->from_array($item);
         $page->save_as_new();
     }
     foreach ($pages as $key => $item) {
         $page = new Page();
         $page->remove_page();
     }
 }
Example #2
Show file File: LoadPageData.php Project: isaacBats/carpintero
0
 public function load(ObjectManager $dm)
 {
     if (!$dm instanceof DocumentManager) {
         $class = get_class($dm);
         throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '{$class}' given.");
     }
     $parent = $dm->find(null, '/cms/pages');
     $rootPage = new Page();
     $rootPage->setTitle('main');
     $rootPage->setParentDocument($parent);
     $dm->persist($rootPage);
     $page = new Page();
     $page->setTitle('Home');
     $page->setParentDocument($rootPage);
     $page->setContent(<<<HERE
come to the homepage of this really basic CMS.
E

     $dm->persist($page);
     $page = new Page();
     $page->setTitle('About');
     $page->setParentDocument($rootPage);
     $page->setContent(<<<HERE
s page explains what its all about.
E

     $dm->persist($page);
     $dm->flush();
 }
Example #3
Show file File: PageController.php Project: gobjila/BackBee
0
 /**
  * Moves $page as first child of $parent
  *
  * @param Page      $page
  * @param Page|null $parent
  *
  * @throws BadRequestHttpException Raises if $parent is null
  */
 private function moveAsFirstChildOf(Page $page, Page $parent = null)
 {
     if (null === $parent) {
         throw new BadRequestHttpException('Parent uid doesn\'t exists');
     }
     $this->granted('EDIT', $parent);
     if (!$parent->hasMainSection()) {
         $this->getPageRepository()->saveWithSection($parent);
     }
     $this->getPageRepository()->moveAsFirstChildOf($page, $parent);
 }
Example #4
Show file File: OrderAction.class.php Project: ljhchshm/weixin
0
 public function index()
 {
     import('ORG.Util.Page');
     $m = D("Order");
     if (isset($_GET['order'])) {
         $_GET['order'];
         $result = $m->where(array('orderid' => $_GET['order']))->relation(true)->select();
         $count = 1;
         $Page = new Page($count, 10);
         // 实例化分页类 传入总记录数和每页显示的记录数
         $Page->setConfig('header', '条记录');
         $Page->setConfig('theme', '<li><a>%totalRow% %header%</a></li> <li>%upPage%</li> <li>%downPage%</li> <li>%first%</li>  <li>%prePage%</li>  <li>%linkPage%</li>  <li>%nextPage%</li> <li>%end%</li> ');
         //(对thinkphp自带分页的格式进行自定义)
         $show = $Page->show();
         // 分页显示输出
     } else {
         if (isset($_GET['type'])) {
             if ($_GET['type'] == 5) {
                 $count = $m->where(array('pay_status' => 1))->count();
                 // 查询满足要求的总记录数
             } elseif ($_GET['type'] == 6) {
                 $count = $m->where(array('pay_status' => 1, 'order_status' => 0))->count();
                 // 查询满足要求的总记录数
             } else {
                 $count = $m->where(array('order_status' => (int) $_GET['type']))->count();
                 // 查询满足要求的总记录数
             }
         } else {
             $count = $m->count();
             // 查询满足要求的总记录数
         }
         $Page = new Page($count, 10);
         // 实例化分页类 传入总记录数和每页显示的记录数
         $Page->setConfig('header', '条记录');
         $Page->setConfig('theme', '<li><a>%totalRow% %header%</a></li> <li>%upPage%</li> <li>%downPage%</li> <li>%first%</li>  <li>%prePage%</li>  <li>%linkPage%</li>  <li>%nextPage%</li> <li>%end%</li> ');
         //(对thinkphp自带分页的格式进行自定义)
         $show = $Page->show();
         // 分页显示输出
         $result = $m->limit($Page->firstRow . ',' . $Page->listRows)->order("id desc")->relation(true);
         if (isset($_GET['type'])) {
             if ($_GET['type'] == 5) {
                 $result = $result->where(array('pay_status' => 1));
             } elseif ($_GET['type'] == 6) {
                 $result = $result->where(array('pay_status' => 1, 'order_status' => 0));
             } else {
                 $result = $result->where(array('order_status' => (int) $_GET['type']));
             }
         }
         $result = $result->select();
     }
     $this->assign("result", $result);
     $this->assign("page", $show);
     // 赋值分页输出
     $this->display();
 }
Example #5
Show file File: CommAction.class.php Project: ysking/commlib
0
 public function page($select = null, $condition = null, $type = null, $custom = false)
 {
     $p = $this->_param("p");
     if (empty($p)) {
         $p = 1;
     }
     $this->pk = $select->getPk();
     $module = $select->getModelName();
     $page_size = C('PAGE_SIZE');
     if (empty($this->type)) {
         if (isset($type)) {
             $this->type = $type;
         } else {
             $this->type = ACTION_NAME;
         }
     }
     $this->module = $module;
     $this->columns = C("columns." . $module);
     $this->query = C("query." . $module);
     $this->pill = C("pill." . $module);
     if (isset($select)) {
         if (!$result) {
             $this->data = $select->page($p . ',' . $page_size)->where($condition)->select();
             $this->pk = $select->getPk();
         } else {
             $M = M();
             $this->data = $M->query($select->options['table']);
         }
         $count = $select->count();
     } else {
     }
     $param = array('listRows' => 10, 'parameter' => $condition, 'target' => "table-content-{$this->type}", 'pagesId' => 'page');
     $toolbar_tr = array('menu' => array('view', 'add', 'edit', 'delete'), 'index' => array('view', 'edit', 'delete'), 'module' => array('view', 'edit'), 'refer' => array('refer'), 'view' => array('view'));
     $this->toolbar_tr = $toolbar_tr[$this->type];
     extract($param);
     import("ORG.Util.Page");
     if ($target && $pagesId) {
         $Page = new Page($count, $page_size, $parameter, $url, $target, $pagesId);
     } else {
         $Page = new Page($count, $page_size, $parameter, $url);
     }
     $this->page = $Page->show();
     $this->prePage = $Page->prePage;
     $this->nextPage = $Page->nextPage;
     $this->pageinfo = $Page->nowPage . '/' . $Page->totalPages;
     layout(!$this->isAjax());
     if (!$custom) {
         if (!$this->isAjax()) {
             $this->display('Comm:Index:table-admin');
         } else {
             $this->display('Comm:Index:table-operate');
         }
     } else {
         $this->display();
     }
 }
Example #6
Show file File: SearchControl.class.php Project: jyht/v5
0
 public function search()
 {
     $word = Q('word');
     if (!$word) {
         $this->error("搜索内容不能为空");
     } else {
         $cid = Q('cid', 0, 'intval');
         $mid = $cid ? $modelCache[$categoryCache[$cid]['mid']] : 1;
         $pre = C('DB_PREFIX');
         $seachType = Q('type', 'title');
         $modelCache = cache('model');
         $categoryCache = cache('category');
         $contentModel = ContentViewModel::getInstance($mid);
         $table = $modelCache[$mid]['table_name'];
         if ($seachType == 'tag') {
             $db = M();
             $countSql = "SELECT count(*) AS c FROM \n\t\t\t\t\t\t(SELECT distinct(aid) FROM {$pre}tag AS t INNER JOIN {$pre}content_tag AS ct ON t.tid=ct.tid WHERE tag='{$word}' AND mid=1 GROUP BY aid) AS c";
             $count = $db->query($countSql);
             $page = new Page($count[0]['c'], 15);
             $DataSql = "SELECT * FROM {$pre}category as cat JOIN {$pre}{$table} AS c  ON cat.cid = c.cid JOIN {$pre}content_tag AS ct  ON c.aid=ct.aid INNER \n\t\t\t\t\t\t\t\t\t\tJOIN {$pre}tag AS t ON t.tid=ct.tid WHERE t.tag='{$word}' LIMIT " . $page->limit(true);
             $data = $db->query($DataSql);
         } else {
             $where = array();
             if ($cid) {
                 $where[] = $pre . "category.cid=" . $cid;
             }
             if (!empty($_GET['search_begin_time']) && !empty($_GET['search_end_time'])) {
                 $where[] = "addtime>=" . strtotime($_GET['search_begin_time']) . " AND addtime<=" . $_GET['search_end_time'];
             }
             switch ($seachType) {
                 case 'title':
                     $where[] = "title like '%{$word}%'";
                     $count = $contentModel->join('category')->where($where)->count();
                     $page = new Page($count, 15);
                     $data = $contentModel->join('category')->where($where)->all();
                     break;
                 case 'description':
                     $where[] = "description like '%{$word}%'";
                     $count = $contentModel->join('category')->where($where)->count();
                     $page = new Page($count, 15);
                     $data = $contentModel->join('category')->where($where)->all();
                     break;
                 case 'username':
                     $where[] = "username like '%{$word}%'";
                     $count = $contentModel->join('category,user')->where($where)->count();
                     $page = new Page($count, 15);
                     $data = $contentModel->join('category,user')->where($where)->all();
                     break;
             }
         }
         $this->assign('searchCategory', $categoryCache);
         $this->assign('page', $page);
         $this->assign('data', $data);
         $this->display();
     }
 }
Example #7
Show file File: system.php Project: KasaiDot/FoOlSlide
0
 function tools_check_library()
 {
     $type = $this->input->post('type');
     if ($type != 'page' && $type != 'chapter') {
         show_404();
     }
     $page = $this->input->post('page');
     if (!is_numeric($page)) {
         show_404();
     }
     $repair = FALSE;
     if ($this->input->post('repair') == 'repair') {
         $repair = TRUE;
     }
     if ($type == 'page') {
         $count = 300;
         if ($repair) {
             $count = 50;
         }
         $items = new Page();
     }
     if ($type == 'chapter') {
         $count = 15;
         if ($repair) {
             $count = 2;
         }
         $items = new Chapter();
     }
     $offset = $page * $count - $count;
     $items->limit($count, $offset)->get_iterated();
     if ($items->result_count() == 0) {
         if ($type == 'chapter') {
             $pages = new Page();
             $pages_count = $pages->count();
             $this->output->set_output(json_encode(array('status' => 'done', 'pages_count' => $pages_count)));
         } else {
             $this->output->set_output(json_encode(array('status' => 'done')));
         }
         return TRUE;
     }
     foreach ($items as $item) {
         $item->check($repair);
     }
     $warnings = array();
     foreach ($this->notices as $notice) {
         if ($notice['type'] == 'error') {
             if (!$this->input->is_cli_request()) {
                 $this->output->set_output(json_encode(array('status' => 'error', 'message' => $notice['message'])));
             }
             return FALSE;
         }
         if ($notice['type'] == 'warning') {
             $warnings[] = $notice['message'];
         }
     }
     $this->output->set_output(json_encode(array('status' => count($warnings) > 0 ? 'warning' : 'success', 'messages' => $warnings, 'processed' => $items->result_count())));
 }
Example #8
Show file File: archive.php Project: KasaiDot/FoOlSlide
0
 /**
  * Creates a compressed cache file for the chapter
  *
  * @author Woxxy
  * @return url to compressed file
  */
 function compress($comic, $language = 'en', $volume = null, $chapter = null, $subchapter = 0)
 {
     require_once FCPATH . 'assets/pclzip/pclzip.lib.php';
     $files = array();
     if (get_setting('fs_dl_volume_enabled') && $volume !== null && $chapter === null) {
         if ($volume == 0) {
             show_404();
         }
         $chapters = new Chapter();
         $chapters->where('comic_id', $comic->id)->where('volume', $volume)->order_by('volume', 'asc')->order_by('chapter', 'asc')->order_by('subchapter', 'asc')->get();
         if ($chapters->result_count() == 0) {
             show_404();
         }
         $volume_id = $volume;
         $chapter_id = $chapters->id;
         $filepath = $comic->directory();
         $filename = $this->filename_chapters_compressed($chapters);
         foreach ($chapters as $chaptere) {
             $pages = new Page();
             $pages->where('chapter_id', $chaptere->id)->get();
             foreach ($pages as $page) {
                 $files[] = array(PCLZIP_ATT_FILE_NAME => 'content/comics/' . $comic->directory() . '/' . $chaptere->directory() . '/' . $page->filename, PCLZIP_ATT_FILE_NEW_FULL_NAME => $this->filename_chapter_compressed($chaptere) . '/' . $page->filename);
             }
         }
     } else {
         $chaptere = new Chapter();
         $chaptere->where('comic_id', $comic->id)->where('language', $language)->where('volume', $volume)->where('chapter', $chapter)->where('subchapter', $subchapter);
         $chaptere->get();
         if ($chaptere->result_count() == 0) {
             show_404();
         }
         $volume_id = 0;
         $chapter_id = $chaptere->id;
         $filepath = $comic->directory() . '/' . $chaptere->directory();
         $filename = $this->filename_chapter_compressed($chaptere);
         $pages = new Page();
         $pages->where('chapter_id', $chaptere->id)->get();
         foreach ($pages as $page) {
             $files[] = 'content/comics/' . $comic->directory() . '/' . $chaptere->directory() . '/' . $page->filename;
         }
     }
     $this->where('comic_id', $comic->id)->where('volume_id', $volume_id)->where('chapter_id', $chapter_id)->get();
     if ($this->result_count() == 0 || !file_exists('content/comics/' . $filepath . '/' . $this->filename)) {
         $this->remove_old();
         $archive = new PclZip('content/comics/' . $filepath . '/' . $filename . '.zip');
         $archive->create($files, PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_NO_COMPRESSION);
         $this->comic_id = $comic->id;
         $this->volume_id = $volume_id;
         $this->chapter_id = $chapter_id;
         $this->filename = $filename . '.zip';
         $this->size = filesize('content/comics/' . $filepath . '/' . $filename . '.zip');
         $this->lastdownload = date('Y-m-d H:i:s', time());
         $this->save();
     } else {
         $this->lastdownload = date('Y-m-d H:i:s', time());
         $this->save();
     }
     return array("url" => site_url() . 'content/comics/' . $filepath . '/' . urlencode($this->filename), "server_path" => FCPATH . 'content/comics/' . $filepath . '/' . $this->filename);
 }
Example #9
Show file File: LoadPageData.php Project: creatiombe/SimpleCmsBundle
0
 public function load(ObjectManager $manager)
 {
     $base = $manager->find(null, '/test/page');
     $page = new Page();
     $page->setName('homepage');
     $page->setTitle('Homepage');
     $page->setLabel('Homepage');
     $page->setPublishable(true);
     $page->setAddLocalePattern(true);
     $page->setParent($base);
     $page->setBody($this->getContent('homepage.html'));
     $manager->persist($page);
     $page = new Page();
     $page->setName('french-page');
     $page->setTitle('French Page');
     $page->setLabel('French Page');
     $page->setPublishable(true);
     $page->setAddLocalePattern(true);
     $page->setLocale('fr');
     $page->setBody($this->getContent('french-page.html'));
     $page->setParent($base);
     $manager->persist($page);
     $page = new Page();
     $page->setName('no-locale-prefix');
     $page->setTitle('No Locale Prefix');
     $page->setLabel('No Locale Prefix');
     $page->setPublishable(true);
     $page->setParent($base);
     $page->setBody($this->getContent('no-locale-prefix.html'));
     $page->setParent($base);
     $manager->persist($page);
     $manager->flush();
 }
Example #10
Show file File: IndexAction.class - 副本 (2).php Project: bthtml/btnav
0
 public function index()
 {
     $this->article = M('article')->select();
     $count = M('article')->count();
     import('Class.Category', APP_PATH);
     import('ORG.Util.Page');
     $page = new Page($count, 15);
     $this->page = $page->show();
     $this->display();
     die;
     if (!$cl) {
         $this->error('页面不存在,3秒后跳转到首页', U('/'));
     } else {
         $id = $cl[0]['id'];
         import('Class.Category', APP_PATH);
         import('ORG.Util.Page');
         $columns = M('columns')->order('sort')->select();
         $cids = Category::getChildsID($columns, $id);
         $this->parent = Category::getParents($columns, $id);
         $cids[] = $id;
         $where = array('cid' => array('IN', $cids));
         $count = M('article')->where($where)->count();
         $page = new Page($count, 15);
         $limit = $page->firstRow . ',' . $page->listRows;
         $this->article = D("ArtView")->getAll($where, $limit);
         $this->cl = $cl;
         $this->page = $page->show();
         $this->display();
     }
 }
Example #11
Show file File: class-page.php Project: tommmic/inne
0
 public function GetPagesDataArray($hidden = false)
 {
     $pagesData = array();
     $mainCounter = 0;
     $subCounter = 0;
     $database = Mysql::getConnection();
     if ($hidden == false) {
         $data = $database->Query("SELECT * FROM " . TABLE_PREFIX . "pages WHERE pageParent='0' AND pageShow='1' ORDER BY pagePosition ASC;");
     } else {
         if ($hidden == true) {
             $data = $database->Query("SELECT * FROM " . TABLE_PREFIX . "pages WHERE pageParent='0' ORDER BY pagePosition ASC;");
         }
     }
     while ($row = $data->fetch_array()) {
         $pageId = $row["pageId"];
         $parentPage = new Page();
         $parentPage->GetInfo($pageId);
         $pagesData[$mainCounter][$subCounter]["pageId"] = $parentPage->pageId;
         $pagesData[$mainCounter][$subCounter]["pageTitle"] = $parentPage->pageTitle;
         $pagesData[$mainCounter][$subCounter]["pageType"] = $parentPage->pageType;
         $subPageData = $database->Query("SELECT * FROM " . TABLE_PREFIX . "pages WHERE pageParent='{$parentPage->pageId}' AND pageShow='1' ORDER BY pagePosition ASC;");
         while ($subRow = $subPageData->fetch_array()) {
             $subPageId = $subRow["pageId"];
             $subPage = new Page();
             $subPage->GetInfo($subPageId);
             $subCounter++;
             $pagesData[$mainCounter][$subCounter]["pageId"] = $subPage->pageId;
             $pagesData[$mainCounter][$subCounter]["pageTitle"] = $subPage->pageTitle;
             $pagesData[$mainCounter][$subCounter]["pageType"] = $parentPage->pageType;
         }
         $subCounter = 0;
         $mainCounter++;
     }
     return $pagesData;
 }
Example #12
Show file File: MsgAction.class.php Project: yunsite/jiaju-qianhoutai
0
 public function index()
 {
     header('Content-Type:text/html;charset=utf-8');
     load('extend');
     // 导入扩展函数(对中文字符串的截取,过滤html)
     import("ORG.Util.Page");
     // 导入分页类
     $m = M('msgs');
     $count = $m->count();
     $page = new Page($count, 20);
     $show = $page->show();
     //后台的首页查看未读留言
     if (isset($_GET['allmsg']) && isset($_GET['act'])) {
         if ($_GET['allmsg'] == 0 && $_GET['act'] == 'nread') {
             $list = checkTrip($m->where('m_status=0')->order('m_id desc')->select());
         }
         $this->assign('list', $list);
         $this->display();
         return;
     }
     if (!isset($_GET['search'])) {
         $list = checkTrip($m->order('m_time desc')->limit($page->firstRow . ',' . $page->listRows)->select());
     } else {
         //查看所有留言、已读、未读
         $sql = '';
         if (isset($_GET['allmsg'])) {
             if ($_GET['allmsg'] != 'status') {
                 $sql = 'm_status=' . $_GET['allmsg'];
             }
         }
         //按留言标题、姓名查找
         $methodone = isset($_GET['search_bzb']) ? $_GET['search_bzb'] : '';
         $bzb = $_GET['bzb'];
         if ($bzb !== '') {
             $and = isset($_GET['allmsg']) && $_GET['allmsg'] != 'status' ? ' and ' : '';
             $sql .= $and . $methodone . ' like "%' . $bzb . '%"';
         }
         //按添加时间排序
         $methodtwo = $_GET['search_tdb'];
         $px = $_GET['order'];
         $order = $methodtwo . ' ' . $px;
         foreach ($_GET as $k => $v) {
             if ($_GET[$k] === '') {
                 unset($_GET[$k]);
             }
         }
         //查找记录后,更新显示条数
         $count = $m->where($sql)->order($order)->count();
         $page = new Page($count, 20);
         $show = $page->show();
         $list = checkTrip($m->where($sql)->order($order)->limit($page->firstRow . ',' . $page->listRows)->select());
         foreach ($list as $key => $val) {
             $val[$methodone] = str_replace($bzb, '<p>' . $bzb . '</p>', $val[$methodone]);
             $list[$key][$methodone] = $val[$methodone];
         }
     }
     $this->assign('list', $list);
     $this->assign('page', $show);
     $this->display();
 }
Example #13
Show file File: HTMLEditorFieldTest.php Project: jacobbuck/silverstripe-framework
0
 public function testGetAnchors()
 {
     if (!class_exists('Page')) {
         $this->markTestSkipped();
     }
     $linkedPage = new Page();
     $linkedPage->Title = 'Dummy';
     $linkedPage->write();
     $html = <<<EOS
v name="foo"></div>
v name='bar'></div>
v id="baz"></div>
tetree_link id="{$linkedPage->ID}"]
v id='bam'></div>
v id = "baz"></div>
v id = ""></div>
v id="some'id"></div>
v id=bar></div>
;
     $expected = array('foo', 'bar', 'baz', 'bam', "some&#039;id");
     $page = new Page();
     $page->Title = 'Test';
     $page->Content = $html;
     $page->write();
     $this->useDraftSite(true);
     $request = new SS_HTTPRequest('GET', '/', array('PageID' => $page->ID));
     $toolBar = new HTMLEditorField_Toolbar(new Controller(), 'test');
     $toolBar->setRequest($request);
     $results = json_decode($toolBar->getanchors(), true);
     $this->assertEquals($expected, $results);
 }
Example #14
Show file File: XitieAction.class.php Project: fengsmith1988/weixin-1
0
 public function inputs()
 {
     $where['xid'] = $this->_get('id');
     $where['token'] = $this->_get('token');
     if (IS_POST) {
         $key = $this->_post('searchkey');
         if (empty($key)) {
             $this->error("关键词不能为空");
         }
         $where['name'] = array('like', "%{$key}%");
         $list = M('Canyu')->where($where)->order('time DESC')->select();
         $count = M('Canyu')->where($where)->count();
         $Page = new Page($count, 20);
         $show = $Page->show();
         $this->assign('key', $key);
     } else {
         $count = M('Canyu')->where($where)->count();
         $Page = new Page($count, 20);
         $show = $Page->show();
         $list = M('Canyu')->where($where)->order('time DESC')->select();
     }
     $num = 0;
     foreach ($list as $key => $val) {
         $num += $val['number'];
     }
     $this->assign('num', $num);
     $this->assign('list', $list);
     $this->assign('page', $show);
     $this->display();
 }
Example #15
Show file File: ForumAction.class.php Project: fengsmith1988/weixin-1
0
 public function cats()
 {
     $parentid = intval($_GET['parentid']);
     $parentid = $parentid == '' ? 0 : $parentid;
     $data = M('Forum_cat');
     $where = array('parentid' => $parentid, 'token' => session('token'));
     if (IS_POST) {
         $key = $this->_post('searchkey');
         if (empty($key)) {
             $this->error("关键词不能为空");
         }
         $map['token'] = $this->_get('token');
         $map['name|des'] = array('like', "%{$key}%");
         $list = $data->where($map)->select();
         $count = $data->where($map)->count();
         $Page = new Page($count, 20);
         $show = $Page->show();
     } else {
         $count = $data->where($where)->count();
         $Page = new Page($count, 20);
         $show = $Page->show();
         $list = $data->where($where)->limit($Page->firstRow . ',' . $Page->listRows)->select();
     }
     $this->assign('page', $show);
     $this->assign('list', $list);
     if ($parentid) {
         $parentCat = $data->where(array('id' => $parentid))->find();
     }
     $this->assign('parentCat', $parentCat);
     $this->assign('parentid', $parentid);
     $this->display();
 }
Example #16
Show file File: PostgreSQLDatabaseTest.php Project: helpfulrobot/silverstripe-postgresql
0
 function testReadOnlyTransaction()
 {
     if (DB::get_conn()->supportsTransactions() == true && DB::get_conn() instanceof PostgreSQLDatabase) {
         $page = new Page();
         $page->Title = 'Read only success';
         $page->write();
         DB::get_conn()->transactionStart('READ ONLY');
         try {
             $page = new Page();
             $page->Title = 'Read only page failed';
             $page->write();
         } catch (Exception $e) {
             //could not write this record
             //We need to do a rollback or a commit otherwise we'll get error messages
             DB::get_conn()->transactionRollback();
         }
         DB::get_conn()->transactionEnd();
         DataObject::flush_and_destroy_cache();
         $success = DataObject::get('Page', "\"Title\"='Read only success'");
         $fail = DataObject::get('Page', "\"Title\"='Read only page failed'");
         //This page should be in the system
         $this->assertTrue(is_object($success) && $success->exists());
         //This page should NOT exist, we had 'read only' permissions
         $this->assertFalse(is_object($fail) && $fail->exists());
     } else {
         $this->markTestSkipped('Current database is not PostgreSQL');
     }
 }
Example #17
Show file File: DpsPxPayPayment.php Project: helpfulrobot/sunnysideup-payment-dps
0
 function executeURL($url)
 {
     $url = str_replace("&", "&amp;", $url);
     $url = str_replace("&amp;&amp;", "&amp;", $url);
     //$url = str_replace("==", "", $url);
     if ($url) {
         /**
          * build redirection page
          **/
         $page = new Page();
         $page->Title = 'Redirection to DPS...';
         $page->Logo = '<img src="' . $this->config()->get("logo") . '" alt="Payments powered by DPS"/>';
         $page->Form = $this->DPSForm($url);
         $controller = new ContentController($page);
         Requirements::clear();
         Requirements::javascript(THIRDPARTY_DIR . "/jquery/jquery.js");
         //Requirements::block(THIRDPARTY_DIR."/jquery/jquery.js");
         //Requirements::javascript(Director::protocol()."ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js");
         return new Payment_Processing($controller->renderWith('PaymentProcessingPage'));
     } else {
         $page = new Page();
         $page->Title = 'Sorry, DPS can not be contacted at the moment ...';
         $page->Logo = 'Sorry, an error has occured in contacting the Payment Processing Provider, please try again in a few minutes...';
         $page->Form = $this->DPSForm($url);
         $controller = new ContentController($page);
         Requirements::javascript(THIRDPARTY_DIR . "/jquery/jquery.js");
         //Requirements::block(THIRDPARTY_DIR."/jquery/jquery.js");
         //Requirements::javascript(Director::protocol()."ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js");
         return new Payment_Failure($controller->renderWith('PaymentProcessingPage'));
     }
 }
Example #18
Show file File: PageTest.php Project: sfarkas1988/CmsBundle
0
 public function testRemoval()
 {
     $page = new Page();
     $page->setTitle('Default page')->setSlug('default')->setEnabled(true);
     $child = new Page();
     $child->setTitle('Child page')->setSlug('child')->setEnabled(true)->setParent($page);
     $page->addChild($child);
     $kernel = static::getKernel();
     /** @var EntityManager $em */
     $em = $kernel->getContainer()->get('doctrine')->getManager();
     $em->persist($page);
     $em->persist($child);
     $em->flush();
     $page = $em->getRepository(get_class($page))->find($page->getId());
     $children = $page->getChildren();
     /** @var Page $first */
     $first = $children[0];
     $this->assertEquals($child->getId(), $first->getId());
     $page->removeChild($child);
     $child->setParent(null);
     $em->remove($page);
     $em->flush();
     $child = $em->getRepository(get_class($child))->find($child->getId());
     $this->assertNull($child->getParent());
 }
Example #19
Show file File: Admin.php Project: klsf/kldns
0
 public function recordList($id = null, $uid = null)
 {
     if (!empty($uid)) {
         //指定用户的解析记录
         $this->assign("uid", $uid);
         if (!empty($id)) {
             $this->assign("domainId", $id);
             $pageList = new Page($this->pdo->getCount("select record_id from pre_records where domain_id=:id and uid=:uid", array(":id" => $id, ":uid" => $uid)), 10);
             $records = $this->pdo->selectAll("select a.*,b.`user`,c.`name` as domain_name from `pre_records` as a left join `pre_users` as b on b.uid = a.uid left join `pre_domains` as c on c.domain_id=a.domain_id where a.domain_id=:id and a.uid=:uid order by updatetime desc " . $pageList->limit, array(":id" => $id, ":uid" => $uid));
         } else {
             $pageList = new Page($this->pdo->getCount("select record_id from pre_records where uid=:uid", array(":uid" => $uid)), 10);
             $records = $this->pdo->selectAll("select a.*,b.`user`,c.`name` as domain_name from `pre_records` as a left join `pre_users` as b on b.uid = a.uid left join `pre_domains` as c on c.domain_id=a.domain_id where a.uid=:uid order by updatetime desc " . $pageList->limit, array(":uid" => $uid));
         }
     } else {
         if (!empty($id)) {
             $this->assign("domainId", $id);
             $pageList = new Page($this->pdo->getCount("select record_id from pre_records where domain_id=:id", array(":id" => $id)), 10);
             $records = $this->pdo->selectAll("select a.*,b.`user`,c.`name` as domain_name from `pre_records` as a left join `pre_users` as b on b.uid = a.uid left join `pre_domains` as c on c.domain_id=a.domain_id where a.domain_id=:id order by updatetime desc " . $pageList->limit, array(":id" => $id));
         } else {
             $pageList = new Page($this->pdo->getCount("select record_id from pre_records"), 10);
             $records = $this->pdo->selectAll("select a.*,b.`user`,c.`name` as domain_name from `pre_records` as a left join `pre_users` as b on b.uid = a.uid left join `pre_domains` as c on c.domain_id=a.domain_id order by updatetime desc " . $pageList->limit);
         }
     }
     //获取域名列表
     $domains = $this->pdo->selectAll("select * from pre_domains ");
     $this->assign("domains", $domains);
     $this->assign("pageList", $pageList);
     $this->assign("records", $records);
     $this->assign("webTitle", "记录列表");
     return $this->fetch("recordList");
 }
Example #20
Show file File: Issue1058Test.php Project: esserj/DoctrineExtensions
0
 /**
  * @test
  * @group issue1058
  */
 public function shouldHandleUniqueConstraintsBasedOnRelation()
 {
     $userFoo = new User();
     $this->em->persist($userFoo);
     $userBar = new User();
     $this->em->persist($userBar);
     $this->em->flush();
     $page = new Page();
     $page->setTitle('the title');
     $page->setUser($userFoo);
     $this->em->persist($page);
     $this->em->flush();
     $this->assertEquals('the-title', $page->getSlug());
     $page = new Page();
     $page->setTitle('the title');
     $page->setUser($userBar);
     $this->em->persist($page);
     $this->em->flush();
     $this->assertEquals('the-title', $page->getSlug());
     $page = new Page();
     $page->setTitle('the title');
     $page->setUser($userBar);
     $this->em->persist($page);
     $this->em->flush();
     $this->assertEquals('the-title-1', $page->getSlug());
     $page = new Page();
     $page->setTitle('the title');
     $page->setUser($userFoo);
     $this->em->persist($page);
     $this->em->flush();
     $this->em->clear();
     $this->assertEquals('the-title-1', $page->getSlug());
 }
Example #21
Show file File: RealShopAction.class.php Project: dlpc/wxshoppingmall
0
 public function index()
 {
     $status = $this->_get("status", "trim");
     if ($status == "4") {
         $count = $this->_mod_application->count();
         $Page = new Page($count, 15);
         // 实例化分页类 传入总记录数
         // 进行分页数据查询 注意page方法的参数的前面部分是当前的页数使用 $_GET[p]获取
         $nowPage = isset($_GET['p']) ? $_GET['p'] : 1;
         $show = $Page->show();
         // 分页显示输出
         $mod = $this->_mod_application->order('id ASC')->limit($Page->firstRow . ',' . $Page->listRows)->select();
     } else {
         if ($status == "") {
             $status = "2";
         }
         $where["HaveReal"] = $status;
         $count = $this->_mod_application->where($where)->count();
         $Page = new Page($count, 15);
         // 实例化分页类 传入总记录数
         // 进行分页数据查询 注意page方法的参数的前面部分是当前的页数使用 $_GET[p]获取
         $nowPage = isset($_GET['p']) ? $_GET['p'] : 1;
         $show = $Page->show();
         // 分页显示输出
         $mod = $this->_mod_application->where($where)->order('id ASC')->limit($Page->firstRow . ',' . $Page->listRows)->select();
     }
     //dump($mod);exit;
     $this->assign('page', $show);
     // 赋值分页输出
     $this->assign("list", $mod);
     $this->display();
 }
Example #22
Show file File: PageUrlPersistenceListenerTest.php Project: alexjobs/Aisel
0
 public function testDuplicatedUrlThrowsError()
 {
     $urlText = 'page-test-meta-url';
     $this->setExpectedException('LogicException', 'Given URL already exists');
     // Create Page 1
     $page1 = new Page();
     $page1->setLocale('en');
     $page1->setContent('...');
     $page1->setName('...');
     $page1->setStatus(true);
     $page1->setMetaUrl($urlText);
     $page1->setMetaTitle('...');
     $page1->setCommentStatus(true);
     $this->em->persist($page1);
     $this->em->flush();
     $this->em->clear();
     // Create Page 2
     $page2 = new Page();
     $page2->setLocale('en');
     $page2->setContent('...');
     $page2->setName('...');
     $page2->setStatus(true);
     $page2->setMetaUrl($urlText);
     $page2->setMetaTitle('...');
     $page2->setCommentStatus(true);
     $this->em->persist($page2);
     $this->em->flush();
     // Delete Page 1
     $page1 = $this->em->getRepository('Aisel\\PageBundle\\Entity\\Page')->findOneBy(['metaUrl' => $urlText]);
     $this->em->remove($page1);
     $this->em->flush();
     $this->em->clear();
 }
Example #23
Show file File: ZucheAction.class.php Project: fengsmith1988/weixin-1
0
 public function cats()
 {
     $parentid = intval($_GET['parentid']);
     $parentid = $parentid == '' ? 0 : $parentid;
     $data = M('Zuche_cat');
     $where = array('parentid' => $parentid, 'token' => $this->token);
     if ($this->storeid) {
         $where['storeid'] = $this->storeid;
     }
     if (IS_POST) {
         $key = $this->_post('searchkey');
         if (empty($key)) {
             $this->error("关键词不能为空");
         }
         $map['token'] = $this->_get('token');
         $map['name|des'] = array('like', "%{$key}%");
         $list = $data->where($map)->select();
         $count = $data->where($map)->count();
         $Page = new Page($count, 20);
         $show = $Page->show();
     } else {
         $count = $data->where($where)->count();
         $Page = new Page($count, 20);
         $show = $Page->show();
         $list = $data->where($where)->limit($Page->firstRow . ',' . $Page->listRows)->select();
     }
     $this->assign('page', $show);
     $this->assign('list', $list);
     if ($parentid) {
         $parentCat = $data->where(array('id' => $parentid))->find();
     }
     $this->assign('parentCat', $parentCat);
     $this->assign('parentid', $parentid);
     $this->display();
 }
Example #24
Show file File: SiteTreeBrokenLinksTest.php Project: helpfulrobot/comperio-silverstripe-cms
0
 public function testRevertToLiveFixesBrokenLinks()
 {
     // Create page and virutal page
     $p = new Page();
     $p->Title = "source";
     $p->write();
     $pageID = $p->ID;
     $this->assertTrue($p->doPublish());
     // Content links are one kind of link to pages
     $p2 = new Page();
     $p2->Title = "regular link";
     $p2->Content = "<a href=\"[sitetree_link,id={$p->ID}]\">test</a>";
     $p2->write();
     $this->assertTrue($p2->doPublish());
     // Virtual pages are another
     $vp = new VirtualPage();
     $vp->CopyContentFromID = $p->ID;
     $vp->write();
     // Redirector links are a third
     $rp = new RedirectorPage();
     $rp->Title = "redirector";
     $rp->LinkType = 'Internal';
     $rp->LinkToID = $p->ID;
     $rp->write();
     $this->assertTrue($rp->doPublish());
     // Confirm that there are no broken links to begin with
     $this->assertFalse($p2->HasBrokenLink);
     $this->assertFalse($vp->HasBrokenLink);
     $this->assertFalse($rp->HasBrokenLink);
     // Delete from draft and confirm that broken links are marked
     $pID = $p->ID;
     $p->delete();
     $vp->flushCache();
     $vp = DataObject::get_by_id('SiteTree', $vp->ID);
     $p2->flushCache();
     $p2 = DataObject::get_by_id('SiteTree', $p2->ID);
     $rp->flushCache();
     $rp = DataObject::get_by_id('SiteTree', $rp->ID);
     $this->assertEquals(1, $p2->HasBrokenLink);
     $this->assertEquals(1, $vp->HasBrokenLink);
     $this->assertEquals(1, $rp->HasBrokenLink);
     // Call doRevertToLive and confirm that broken links are restored
     $pLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $pID);
     $pLive->doRevertToLive();
     $p2->flushCache();
     $p2 = DataObject::get_by_id('SiteTree', $p2->ID);
     $vp->flushCache();
     $vp = DataObject::get_by_id('SiteTree', $vp->ID);
     $rp->flushCache();
     $rp = DataObject::get_by_id('SiteTree', $rp->ID);
     $this->assertFalse((bool) $p2->HasBrokenLink);
     $this->assertFalse((bool) $vp->HasBrokenLink);
     $this->assertFalse((bool) $rp->HasBrokenLink);
 }
Frequently Used Methods