Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class view extends Controller{
- public function index(Request $resquest){
- $this->data['feedback'] = SessionRegistry::instance()->getFeedback();
- //Check to see if the page id is present if not redirect to index
- if(!isset($_GET['page_id'])){
- header('Location: index.php');
- }
- //Load the News model to get the headlines
- $news = $this->getModel('News');
- $this->data['news'] = $news->getHeadlines();
- //Load the page model
- $page = $this->getModel('Page');
- $p = $page->getPage($_GET['page_id']);
- if($p == null){
- $this->data['pageTitle'] = 'Page Not Found';
- $this->data['pageContent'] = 'Page Not Found';
- }
- else{
- $this->data['pageTitle'] = $p['page_title'];
- $this->data['relatedInfo'] = $p['page_sub_text'];
- $this->data['pageContent'] = $p['page_content'];
- //Check to see if there are any blocks in the page content if so swap them out
- preg_match_all("[block:(\d+)]", $this->data['pageContent'], $blockMatches);
- //print_r($matches);
- if(count($blockMatches) > 0){
- //Load the model
- $content = $this->data['pageContent'];
- $block = $this->getModel('Block');
- foreach($blockMatches[1] as $m){
- $blockContent = trim($block->getBlockContent($m)); //Remove Whitespace off block as it breaks some layouts
- if(strlen($blockContent) < 1){
- $blockContent = "Block ID: $m Not Found";
- }
- $replaceString = "[block:$m]";
- $content = str_replace($replaceString, $blockContent,$content);
- }
- $this->data['pageContent'] = $content;
- }
- //Check to see if there are any gallery matches
- preg_match_all("[gallery:(\d+)]", $this->data['pageContent'], $galleryMatches);
- if(count($galleryMatches) > 0){
- //Load the model
- $content = $this->data['pageContent'];
- $gallery = $this->getModel('Gallery');
- foreach($galleryMatches[1] as $m){
- $images = $gallery->getGalleryImages($m);
- $info = $gallery->getGalleryInfo($m);
- $galleryHTML = $gallery->getHTML($images,'table');
- $replaceString = "[gallery:$m]";
- $content = str_replace($replaceString, $galleryHTML,$content);
- }
- $this->data['pageContent'] = $content;
- }
- }
- //Load the menu model and get the menu
- $menu = $this->getModel('Menu');
- $this->data['menu'] = $menu->getMenu();
- $breadcrumbs = array();
- $breadcrumbs[] = array('Home','index.php');
- $breadcrumbs[] = array($p['page_title'],'');
- $this->data['breadcrumbs'] = $breadcrumbs;
- $this->templates[] = 'view/template/default/common/header.php';
- $this->templates[] = 'view/template/default/page/view.php';
- //Switch the footer
- if($_GET['page_id'] == 1 || $_GET['page_id'] == 6){
- $this->templates[] = 'view/template/default/common/footer_complex.php';
- }
- else{
- $this->templates[] = 'view/template/default/common/footer_simplified.php';
- }
- echo $this->render();
- }
- }
- ?>
Add Comment
Please, Sign In to add comment