/**
  * Sets and return or return an environment status
  *
  * @since ADD MVC 0.8
  */
 public static function environment_status($new_status = null)
 {
     /**
      *
      * @see http://code.google.com/p/add-mvc-framework/issues/detail?id=33
      */
     if (!add::is_developer()) {
         if (add::$environment_status != 'live' || isset($new_status) && $new_status != 'live') {
             $new_status = 'live';
         }
     }
     if ($new_status) {
         if (is_string($new_status)) {
             if ($new_status === 'development') {
                 if (add::is_developer()) {
                     add::$environment_status = $new_status;
                 } else {
                     add::$environment_status = "live";
                 }
             } else {
                 if ($new_status === 'live') {
                     add::$environment_status = 'live';
                 } else {
                     throw new e_developer("Invalid environment_status: {$new_status}");
                 }
             }
         } else {
             if ($new_status !== true) {
                 throw new e_developer("Invalid new environment status", $new_status);
             }
         }
         /**
          * No errors if live
          *
          * @since ADD MVC 0.7.2
          */
         if (add::is_live()) {
             error_reporting(0);
             ini_set('display_errors', 0);
             add::$handle_shutdown = false;
         } else {
             error_reporting(E_ALL);
             ini_set('display_errors', 1);
             /**
              * When development, record the time spent on script execution
              *
              * @since ADD MVC 0.7.2
              */
             if (add::is_development()) {
                 add::$handle_shutdown = true;
                 if (!isset($GLOBALS['add_mvc_root_timer'])) {
                     $GLOBALS['add_mvc_root_timer'] = add_development_timer::start("Framework Configuration");
                 }
                 add::config()->root_timer = $GLOBALS['add_mvc_root_timer'];
             }
         }
     }
     return add::$environment_status;
 }
 /**
  * Sets and return or return an environment status
  *
  * @since ADD MVC 0.8
  */
 public static function environment_status($new_status = null)
 {
     if ($new_status) {
         if (is_string($new_status)) {
             if ($new_status === 'development') {
                 if (add::is_developer()) {
                     add::$environment_status = $new_status;
                 } else {
                     add::$environment_status = "live";
                 }
             } else {
                 if ($new_status === 'live') {
                     add::$environment_status = 'live';
                 } else {
                     throw new e_developer("Invalid environment_status: {$new_status}");
                 }
             }
         }
         /**
          * No errors if live
          *
          * @since ADD MVC 0.7.2
          */
         if (add::is_live()) {
             error_reporting(0);
             add::$handle_shutdown = false;
         } else {
             error_reporting(E_ALL);
             /**
              * When development, record the time spent on script execution
              *
              * @since ADD MVC 0.7.2
              */
             if (add::is_development()) {
                 add::$handle_shutdown = true;
                 if (!isset($GLOBALS['add_mvc_root_timer'])) {
                     $GLOBALS['add_mvc_root_timer'] = add_development_timer::start("Framework Configuration");
                 }
                 add::config()->root_timer = $GLOBALS['add_mvc_root_timer'];
             }
         }
     }
     return add::$environment_status;
 }
 /**
  * Sets and return or return an environment status
  *
  * @since ADD MVC 0.8
  */
 public static function environment_status($new_status = null)
 {
     if ($new_status) {
         add::config()->environment_status = $new_status;
     }
     /**
      * No errors if live
      *
      * @since ADD MVC 0.7.2
      */
     if (add::is_live()) {
         error_reporting(0);
     } else {
         error_reporting(E_ALL);
         /**
          * When development, record the time spent on script execution
          *
          * @since ADD MVC 0.7.2
          */
         if (add::is_development()) {
             add::$handle_shutdown = true;
             $GLOBALS['add_mvc_root_timer'] = add_development_timer::start("Framework Configuration");
             add::config()->root_timer = $GLOBALS['add_mvc_root_timer'];
         }
     }
     return add::config()->environment_status;
 }
 public static function current_user_allowed()
 {
     return !add::is_live();
 }
 /**
  * include() include file path
  * example add::include_include_file('functions/date.functions.php')
  *
  * @param string $include_path the include path
  * @param boolean $include_once weather to include it only once
  *
  * @since ADD MVC 1.0
  */
 protected static function include_include_file($include_path, $include_once = true)
 {
     $filepath = static::include_filepath($include_path);
     if (!add::is_live()) {
         static::php_check_syntax($filepath);
     }
     if ($include_once) {
         return include_once $filepath;
     } else {
         return include $filepath;
     }
 }
set_include_path($C->incs_dir);
/**
 * assets
 * @author albertdiones@gmail.com
 */
$C->assets_path = $C->base_url . 'assets/';
$C->css_path = $C->assets_path . 'css/';
$C->js_path = $C->assets_path . 'js/';
$C->images_path = $C->assets_path . 'images/';
$C->assets_libs_path = $C->assets_path . 'libs/';
/**
 * No errors if live
 *
 * @since ADD MVC 0.7.2
 */
if (add::is_live()) {
    error_reporting(0);
} else {
    error_reporting(E_ALL);
    /**
     * When development, record the time spent on script execution
     *
     * @since ADD MVC 0.7.2
     */
    if (add::is_development()) {
        $GLOBALS['add_mvc_root_timer'] = add_development_timer::start("Framework Configuration");
        add::config()->root_timer = $GLOBALS['add_mvc_root_timer'];
    }
}
add::load_functions('common');
/**
 /**
  * Print errors
  */
 static function print_errors()
 {
     $default_error_tpl = "errors/default.tpl";
     $smarty = new add_smarty();
     foreach (static::$errors as $error_index => $errors) {
         $error_tpl = "errors/" . strtolower($error_index) . ".tpl";
         if (!$smarty->templateExists($error_tpl)) {
             $error_tpl = $default_error_tpl;
         }
         foreach ($errors as $error) {
             # The chunk of code on the location of the error
             if (!add::is_live()) {
                 $code_on_error = "";
                 $file_codes = file($error['file']);
                 $code_on_error_padding = 3;
                 $code_on_error_start = max($error['line'] - 3, 1);
                 $smarty->assign('code_on_error_start', $code_on_error_start);
                 for ($code_on_error_x = $code_on_error_start; $code_on_error_x <= $error['line'] + $code_on_error_padding; $code_on_error_x++) {
                     $code_on_error .= $file_codes[$code_on_error_x - 1];
                 }
                 $smarty->assign('code_on_error', highlight_string($code_on_error, true));
                 $smarty->assign('code_on_error_end', $code_on_error_x);
             }
             $error['file'] = basename($error['file']);
             $error['file_lines'] = array();
             foreach ($error['backtrace'] as $backtrace_data) {
                 $error['file_lines'][] = array('file' => basename($backtrace_data['file']), 'line' => $backtrace_data['line']);
             }
             if ($smarty->templateExists($error_tpl)) {
                 $smarty->assign("error", $error);
                 $smarty->display($error_tpl);
             } else {
                 echo "<div>{$error['type']} : {$error['file']}:{$error['line']} : <b>{$error['message']}</b></div>";
             }
         }
     }
 }