Permalink
Browse files

Cleanup of mopfrontend controller

  • Loading branch information...
1 parent fc2806e commit 900503c1403c0423a7defb18763fb5555d61e634 Deepwinter committed Jun 6, 2011
Showing with 39 additions and 39 deletions.
  1. +39 −39 moptools/mopfrontend/classes/controller/mopfrontend.php
@@ -39,45 +39,45 @@ public function validSlug($uri){
* Returns: nothing, renders full webpage to browser or sents html if AJAX request
*/
- public function action_page($pageidorslug=null) {
-
- self::$slug = $pageidorslug;
-
- $page = ORM::Factory('page')->where('slug', '=', $pageidorslug)->find();
- //some access control
- $viewName = null;
- if ($page->loaded()) {
- if ($page->published == false || $page->activity != null) {
- throw new Kohana_User_Exception('Page not availabled', 'The page with identifier ' . $id . ' is does not exist or is not available');
- }
- //look for the template, if it's not there just print out all the data raw
- $viewName = $page->template->templatename;
- $viewPath = $viewName;
- if (file_exists('application/views/frontend/' . $viewName . '.php')) {
- $viewPath = 'frontend/'.$viewPath;
- } else if(file_exists('application/views/generated/' . $viewPath . '.php')) {
- $viewPath = 'generated/'.$viewPath;
- } else {
- $viewPath = 'default';
- }
- $this->view = new View($viewPath);
- } else {
- //check for a virtual page specified in frontend.xml
- //a virtual page will be one that does not match a template
- $viewname = $pageidorslug;
- $this->view = new View($viewname);
- }
-
- //call this->view load data
- //get all the data for the page
- $viewContent = mop::getViewContent($viewName, $pageidorslug);
- foreach ($viewContent as $key => $value) {
- $this->view->$key = $value;
- }
-
- //possible hook for processing content
-
- $this->response->body($this->view->render());
+ public function action_page($pageidorslug=null) {
+
+ self::$slug = $pageidorslug;
+
+ $page = ORM::Factory('page')->where('slug', '=', $pageidorslug)->find();
+ //some access control
+ $viewName = null;
+ if ($page->loaded()) {
+ if ($page->published == false || $page->activity != null) {
+ throw new Kohana_User_Exception('Page not availabled', 'The page with identifier ' . $id . ' is does not exist or is not available');
+ }
+ //look for the template, if it's not there just print out all the data raw
+ $viewName = $page->template->templatename;
+ $viewPath = $viewName;
+ if (file_exists('application/views/frontend/' . $viewName . '.php')) {
+ $viewPath = 'frontend/'.$viewPath;
+ } else if(file_exists('application/views/generated/' . $viewPath . '.php')) {
+ $viewPath = 'generated/'.$viewPath;
+ } else {
+ $viewPath = 'default';
+ }
+ $this->view = new View($viewPath);
+ } else {
+ //check for a virtual page specified in frontend.xml
+ //a virtual page will be one that does not match a template
+ $viewname = $pageidorslug;
+ $this->view = new View($viewname);
+ }
+
+ //call this->view load data
+ //get all the data for the page
+ $viewContent = mop::getViewContent($viewName, $pageidorslug);
+ foreach ($viewContent as $key => $value) {
+ $this->view->$key = $value;
+ }
+
+ //possible hook for processing content
+
+ $this->response->body($this->view->render());
}

0 comments on commit 900503c

Please sign in to comment.