Override this controller by placing a copy in controllers directory of an application
Inheritance: extends AppController
function init($controller, $method)
{
    // include controller file
    require_once 'controllers/' . $controller . '.php';
    // create controller objects
    switch ($controller) {
        // special cases
        case 'pages':
            $controller = new PagesController();
            $controller->showPage($method);
            break;
        case 'error':
            $controller = new ErrorController();
            $controller->showError($method);
            break;
            // standard controllers
        // standard controllers
        case 'sorting':
            $controller = new SortingController();
    }
    // 'pages' and 'error' controllers do not use this
    if (method_exists($controller, $method)) {
        // call requested method from controller
        $controller->{$method}();
    }
}
Esempio n. 2
0
 /**
  * Display the specified resource.
  * @TODO pull out menu into its own model with a many to many relationship to
  *   Projects, Pages and Portfolios
  * @param  int  $id
  * @return Response
  */
 public function show($id = null)
 {
     $banner = FALSE;
     $type = "pages.show";
     $settings = $this->settings->first();
     if ($id == null) {
         $page = $this->pageModel->first();
         $pageCtrl = new \PagesController();
         return $pageCtrl->show($page);
     }
     //Try Page
     $page = $this->pageModel->where("slug", 'LIKE', '/' . $id)->first();
     if ($this->checkIfPublishedAndUserState($page)) {
         $page->slug === '/home' ? $banner = TRUE : ($banner = FALSE);
         $pageCtrl = new \PagesController();
         return $pageCtrl->show($page);
     }
     //Try Project
     $project = $this->project->where("slug", 'LIKE', '/' . $id)->first();
     if ($this->checkIfPublishedAndUserState($project)) {
         $projCtrl = new \ProjectsController();
         return $projCtrl->show($project);
     }
     //Try Portfolio
     $portfolio = $this->portfolio->where("slug", 'LIKE', '/' . $id)->first();
     if ($this->checkIfPublishedAndUserState($portfolio)) {
         $portfolioCtrl = new \PortfoliosController();
         return $portfolioCtrl->show($portfolio);
     }
     //Else 404
     return \View::make('404', compact('settings'));
 }
 /**
  * testDisplay method
  *
  * @return void
  */
 public function testDisplay()
 {
     App::build(array('View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)));
     $Pages = new PagesController(new CakeRequest(null, false), new CakeResponse());
     $Pages->viewPath = 'Posts';
     $Pages->display('index');
     $this->assertRegExp('/posts index/', $Pages->response->body());
     $this->assertEquals('index', $Pages->viewVars['page']);
     $Pages->viewPath = 'Themed';
     $Pages->display('TestTheme', 'Posts', 'index');
     $this->assertRegExp('/posts index themed view/', $Pages->response->body());
     $this->assertEquals('TestTheme', $Pages->viewVars['page']);
     $this->assertEquals('Posts', $Pages->viewVars['subpage']);
 }
Esempio n. 4
0
 /**
  * testDisplay method
  *
  * @access public
  * @return void
  */
 function testDisplay()
 {
     App::build(array('views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS, TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS)));
     $Pages = new PagesController(new CakeRequest(null, false));
     $Pages->viewPath = 'posts';
     $Pages->display('index');
     $this->assertPattern('/posts index/', $Pages->getResponse()->body());
     $this->assertEqual($Pages->viewVars['page'], 'index');
     $Pages->viewPath = 'themed';
     $Pages->display('test_theme', 'posts', 'index');
     $this->assertPattern('/posts index themed view/', $Pages->getResponse()->body());
     $this->assertEqual($Pages->viewVars['page'], 'test_theme');
     $this->assertEqual($Pages->viewVars['subpage'], 'posts');
 }
Esempio n. 5
0
 /**
  * testDisplay method
  *
  * @access public
  * @return void
  */
 function testDisplay()
 {
     if ($this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController')) {
         return;
     }
     App::build(array('views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS, TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS)));
     $Pages = new PagesController();
     $Pages->viewPath = 'posts';
     $Pages->display('index');
     $this->assertPattern('/posts index/', $Pages->output);
     $this->assertEqual($Pages->viewVars['page'], 'index');
     $this->assertEqual($Pages->pageTitle, 'Index');
     $Pages->viewPath = 'themed';
     $Pages->display('test_theme', 'posts', 'index');
     $this->assertPattern('/posts index themed view/', $Pages->output);
     $this->assertEqual($Pages->viewVars['page'], 'test_theme');
     $this->assertEqual($Pages->viewVars['subpage'], 'posts');
     $this->assertEqual($Pages->pageTitle, 'Index');
 }
Esempio n. 6
0
 public function run()
 {
     $uri = $this->getURI();
     if ($uri == null) {
         //Подключаем нужный контроллер
         $controllerFile = ROOT . '/controllers/PagesController.php';
         if (file_exists($controllerFile)) {
             include_once $controllerFile;
         }
         //Создаем обьект контроллера и вызываем его метод
         $controllerObject = new PagesController();
         $controllerObject->actionIndex();
     }
     //Проверяем наличие такого uri в роутах
     foreach ($this->routes as $uriPattern => $path) {
         //Проверка на совпадение введеннго uri и в роутах(#-delimiter(разделитель))
         if (preg_match("#{$uriPattern}#", $uri)) {
             //разделяем адрес на части
             $segments = explode('/', $path);
             //Получаем имя контроллера
             $controllerName = array_shift($segments) . 'Controller';
             //Делаем название контроллера с большой буквы
             $controllerName = ucfirst($controllerName);
             //Получаем имя метода
             $actionName = 'action' . ucfirst(array_shift($segments));
             //Подключаем нужный контроллер
             $controllerFile = ROOT . '/controllers/' . $controllerName . '.php';
             if (file_exists($controllerFile)) {
                 include_once $controllerFile;
             }
             //  echo $actionName;
             //Создаем обьект контроллера и вызываем его метод
             $controllerObject = new $controllerName();
             $result = $controllerObject->{$actionName}();
             if ($result != null) {
                 break;
             }
         }
     }
 }
 /**
  * Construct page versions controller
  *
  * @param Request $request
  * @return PageVersionsController
  */
 function __construct($request)
 {
     parent::__construct($request);
     if ($this->active_page->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     $version = $this->request->getId('version');
     if ($version) {
         $this->active_page_version = PageVersions::findById(array('page_id' => $this->active_page->getId(), 'version' => $version));
     }
     // if
     if (!instance_of($this->active_page_version, 'PageVersion')) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     $this->smarty->assign(array('active_page_version' => $this->active_page_version));
 }
 /**
  * Test that missing view in debug mode renders missing_view error page
  *
  * @expectedException MissingViewException
  * @expectedExceptionCode 500
  * @return void
  */
 public function testMissingViewInDebug()
 {
     Configure::write('debug', 1);
     $Pages = new PagesController(new CakeRequest(null, false), new CakeResponse());
     $Pages->display('non_existing_page');
 }
Esempio n. 9
0
    }
    public function getAccessList()
    {
        return $this->model->getAccessList();
    }
    public function changeAccess($pid, $acid)
    {
        return $this->model->changeAccess($pid, $acid);
    }
    public function deletePage($pid)
    {
        $result = $this->model->deletePage($pid);
        return $result;
    }
}
$controller = new PagesController();
if (isset($_GET['deletepage'])) {
    $delete = $controller->deletePage((int) $_GET['deletepage']);
    if ($delete === false) {
        Bufer::set(array('errors' => array('Ошибка при удалении страницы'), 'accessList' => $controller->getAccessList(), 'listPages' => array('data' => $controller->getListPages(), 'paginate' => $controller->paginate()), 'listSections' => $controller->getListSections()));
    } else {
        header("location: " . Route::getUrl('?mode=admin&route=pages'));
    }
}
if (isset($_GET['updateAccess'])) {
    $temp = explode(',', $_GET['updateAccess']);
    $pid = (int) $temp[0];
    $acid = (int) $temp[1];
    $result = $controller->changeAccess($pid, $acid);
    if ($result === false) {
        Bufer::set(array('errors' => array('Произошла ошибка при смене доступа к странице'), 'accessList' => $controller->getAccessList(), 'listPages' => array('data' => $controller->getListPages(), 'paginate' => $controller->paginate()), 'listSections' => $controller->getListSections()));
Esempio n. 10
0
			<ul>
				<li class="active"><a href="#" accesskey="1" title="">Homepage</a></li>
				<li><a href="#" accesskey="2" title="">Sign in</a></li>
				<li><a href="#" accesskey="3" title="">About Create Your own Adventure</a></li>
				<li><a href="#" accesskey="5" title="">Contact Us</a></li>
			</ul>
		</div>
	</div>
	<div id="banner" class="container">
		<div class="title">
                        <h2>Create Your Own Adventure!</h2>
			<span class="byline">The possibilities are endless...</span>
		</div>
		<ul class="actions">
                        <li><?php 
Router::link_to(PagesController::to_string(), "new_page_landing", "Get Started!", array("class" => "button"));
?>
</li>
		</ul>
	</div>
</div>
<!--
<div id="wrapper">
	<div id="three-column" class="container">
		<div class="title">
			<h2>Choose your story!</h2>
			<span class="byline">Story 1 Blah BLah</span>
		</div>
		<div class="boxA">
			<span class="fa fa-cloud-download"></span>
			<p>sample description</p>