Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class pages_controller extends base_controller {
- public function index( ) {
- }
- public function show( $id ) {
- $this->registry->template->node = $this->node( $id );
- $this->registry->template->parent = $this->getParent( $id );
- $this->registry->template->children = $this->getChildren( $id );
- $this->registry->template->show('public_header');
- $this->registry->template->show('public_header_bar');
- $this->registry->template->show('public_home');
- $this->registry->template->show('public_footer');
- }
- /**
- * print out a list of all the pages at root level
- */
- public function listNodes( $node_index ) {
- $node_index = (!is_numeric($node_index))?0:$node_index;
- $db = db::getInstance();
- $roots = $db->select("*")->where("pages_id = $node_index")->get("pages");
- $this->registry->template->roots = $roots;
- $this->registry->template->show('admin_header');
- $this->registry->template->show('admin_header_bar');
- $this->registry->template->show('admin_pageroots');
- $this->registry->template->show('admin_footer');
- }
- public function listRoots() {
- $this->listNodes(0);
- }
- // show article by id, or new art, and list any child arts.
- public function admin( $id ) {
- $db = db::getInstance();
- $roots = $db->select("*")->where("pages_id = $id")->get("pages");
- $this->registry->template->roots = $roots;
- $this->registry->template->show('admin_header');
- $this->registry->template->show('admin_header_bar');
- $this->scaffold_model(
- 'pages',
- array('title', 'content'),
- '/pages/admin',
- $id
- );
- $this->registry->template->show('admin_pageroots');
- $this->registry->template->show('admin_footer');
- }
- protected function getParent( $id ) {
- $db = db::getInstance();
- $tmparr = $db->select("*")->where(
- "id = (SELECT DISTINCT pages_id as pid FROM pages as ppages " .
- "WHERE ppages.id = $id)"
- )->get("pages", 1);
- return $tmparr[0];
- }
- protected function getChildren( $id ) {
- $db = db::getInstance();
- return $db->select("id, title")->where("pages_id = $id")->get("pages");
- }
- protected function node( $id ) {
- $node = pages::find( $id );
- $result = array();
- $result['title'] = $node->title;
- $result['content'] = $node->content;
- // more attributes to add to the result array here...
- // attach an array of any attached images to the result set.
- $result['images'] = array();
- $result['children_ids'] = $this->getChildren( $id );
- return $result;
- }
- public function jsonNode( $id ) {
- echo json_encode( $this->node( $id ) );
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement