예제 #1
0
파일: index.php 프로젝트: moiseh/codegen
<?php

error_reporting(E_ALL);
date_default_timezone_set('UTC');
// session
if (!session_id()) {
    session_start();
}
require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/src/core.php';
\Meta\Installer::checkConfiguration();
// check configuration file
require __DIR__ . '/app/config.php';
\Meta\Installer::checkDbTables();
// check if initial database has installed
require __DIR__ . '/sql/migrations.php';
// load db migrations & init scripts
\Meta\DbMigration::execute(new \migrations());
\Meta\FileSystem::init();
// load page definitions
require_once __DIR__ . '/app/pages.php';
// routing dispatcher
if (!\Meta\Route::get()->dispatch()) {
    echo new \Meta\Page\NotFound();
}
예제 #2
0
파일: Page.php 프로젝트: moiseh/codegen
 public function register()
 {
     if (!$this->path) {
         throw new \Exception(t('Page path not defined'));
     }
     // add menu item
     if ($this->menu && $this->isUserAllowed()) {
         $this->menu->path = $this->path;
         // set menu label same as page title
         if (!$this->menu->label) {
             $this->menu->label = $this->title;
         }
         Menu::get()->add($this->menu);
     }
     // add route callback
     $obj = $this;
     Route::get()->add($this->path, function () use($obj) {
         if (!$obj->isUserAllowed()) {
             if (!User::hasLoggedUser()) {
                 redirect(page_login());
             }
             echo new Page\AccessDenied();
         }
         echo $obj->render();
     });
 }