Example #1
0
 public function main()
 {
     $slug = Req::get('slug');
     $this->set('slug', $slug);
     if (file_exists(Config::getBasePath() . '/assets/css/' . $slug . '.' . (Config::env() === 'development' ? 'less' : 'css'))) {
         $this->css[] = $slug;
     }
     if (file_exists(Config::getBasePath() . '/assets/js/' . $slug . '.' . (Config::env() === 'development' ? 'coffee' : 'js'))) {
         $this->js[] = $slug;
     }
     $page = $this->getPages()->{$slug};
     $this->set('slug', $slug);
     $this->set('page', $page);
     $this->set('pagetitle', $page->title);
     $this->set('pagedate', $page->date);
     $content = $this->loadTemplate($slug . '/content');
     $this->set('content', $content);
 }
Example #2
0
    if (is_string($js)) {
        ?>
			<script type="text/javascript" src="<?php 
        echo (strpos($js, 'http') === 0 ? '' : 'assets/js/') . $js . (strpos($js, 'http') === 0 ? '' : '.js');
        ?>
"></script>
		<?php 
    }
    ?>
	<?php 
}
?>

	<title><?php 
echo !empty($pagetitle) ? $pagetitle : Config::getPageTitle();
?>
</title>
</head>
<body <?php 
if (Config::env() === 'development') {
    ?>
data-development="1"<?php 
}
?>
>
<?php 
echo $body;
?>
</body>
</html>
Example #3
0
 public static function getDBConfig($key = 'default')
 {
     return self::$dbconfig[$key][Config::env(false)];
 }
Example #4
0
 /**
  * Sets the environment variable and include() for environment config file
  *
  * @param string  $environmentOverride | When set, will override the environment instead of setting it based on $_SERVER['SERVER_NAME']
  * @return boolean | TRUE on success / FALSE on failure
  */
 private static function setEnvironment($environmentOverride = FALSE)
 {
     if ($environmentOverride !== false) {
         $env = $environmentOverride;
         $filename = _PROJECT_ROOT_PATH . 'env/' . $environmentOverride . '.php';
         if (!file_exists($filename)) {
             _\_Log::fatal('*** Environment Override ' . $environmentOverride . ' is invalid. ***');
             return FALSE;
         }
         require_once $filename;
     } else {
         if (!isset($GLOBALS['environments'])) {
             throw new _Exception('*** Environment not set.  Check /env/environments.php ***');
         }
         self::$environments = $GLOBALS['environments'];
         $defaultConfig = isset($GLOBALS['environments']['_DEFAULT_']) ? $GLOBALS['environments']['_DEFAULT_'] : FALSE;
         // Get server name
         if (isset($_SERVER) && isset($_SERVER['SERVER_NAME'])) {
             $serverName = $_SERVER['SERVER_NAME'];
             if (isset(self::$environments[$serverName])) {
                 $env = self::$environments[$serverName];
             } elseif ($defaultConfig !== FALSE) {
                 _\_Log::warn('*** SERVER_NAME (' . $serverName . ') does not match any defined environments. Using default. ***');
                 $env = $defaultConfig;
             } else {
                 _\_Log::fatal('*** SERVER_NAME (' . $serverName . ') does not match any defined environments and no default was set. ***');
                 return FALSE;
             }
         } elseif ($defaultConfig !== FALSE) {
             _\_Log::warn('*** SERVER_NAME is not set.  Please set this variable in apache or use the $environmentOverride option on _Config::init().  Using default configuration.');
             $env = $defaultConfig;
         }
         $filename = _PROJECT_ROOT_PATH . 'env/' . $env . '.php';
     }
     self::$env = $env;
     if (!file_exists($filename)) {
         _\_Log::fatal('*** Environment file does not exist: ' . $filename . ' ***');
         return FALSE;
     }
     $filename = _PROJECT_ROOT_PATH . 'env/' . $env . '.php';
     require_once $filename;
     return TRUE;
 }