public static function getPath() { if (self::$path == null) { $path = split("/", pathinfo(__FILE__, PATHINFO_DIRNAME)); self::$path = join("/", $path) . "/"; } return self::$path; }
public static function render($view, $data = [], $layout = null) { extract($data, EXTR_PREFIX_SAME, "wddx"); $content = Config::path('app') . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . $view . '.php'; if ($layout) { require_once Config::path('app') . DIRECTORY_SEPARATOR . 'themes/layouts' . DIRECTORY_SEPARATOR . $layout . '.php'; } else { require_once $content; } }
public static function to($location = null) { if ($location) { if (is_numeric($location)) { switch ($location) { case 404: header('HTTP/1.0 404 Not Found'); include Config::path('app') . '/includes/errors/404.php'; exit; break; } } header('Location: ' . URL::to($location)); exit; } }
function setLocalization($code) { $langCodes = array("en" => "en_US", "fr" => "fr_FR"); if (!isset($langCodes[strtolower($code)])) { return; } $baseLangDir = Config::path('app') . '/locale'; $appName = "messages"; $lang = $langCodes[strtolower($code)]; // Set language putenv('LC_ALL=' . $lang); setlocale(LC_ALL, $lang); // Specify the location of the translation tables bindtextdomain($appName, realpath($baseLangDir)); bind_textdomain_codeset($appName, 'UTF-8'); // Choose domain textdomain($appName); }
public static function setPath($path) { self::$path = $path; }
public function script($normalpath) { return "<script type='text/javascript' src='" . Config::path('public') . '/' . $normalpath . "'></script>"; }
/** * Convinient way to configure application * * @param array $config */ public static function configure(array $config = null) { defined("DS") or define("DS", DIRECTORY_SEPARATOR); defined("BASEPATH") or define("BASEPATH", realpath(__DIR__ . DS . ".." . DS . ".." . DS . ".." . DS . "..") . DS); // checking for configuration if (is_null($config)) { // checking config has been configured. If not - guess the configuration path Config::$path == "" and Config::$path = realpath(BASEPATH . "app" . DS . "config") . DS; // loading configuration $config = Config::get("app"); } /** * Are we on development or on production server * To set development environment add the following code in your apache configuration file * <code> * SetEnv APPLICATION_ENV development * </code> * * @var string */ defined("APPLICATION_ENV") or define("APPLICATION_ENV", getenv("APPLICATION_ENV") === "development" ? "development" : "production"); /** * Define DEBUG flag * Debug depends of is it on development or production, * or it can be manually set to true or false in config file or with * <code> * define("DEBUG", true); * define("DEBUG", false); * </code> * * @var string */ defined("DEBUG") or define("DEBUG", isset($config["debug"]) ? $config["debug"] : APPLICATION_ENV == "development"); /* * Set error reporting level * Error reporting depends of DEBUG */ error_reporting(DEBUG ? E_ALL | E_STRICT : E_ALL ^ E_NOTICE ^ E_USER_NOTICE ^ E_WARNING ^ E_DEPRECATED); /* * The errors are wellcome even in production if we use error and exception handlers to display * custom error page, rather than a blank page * Display errors can be set to false, or to DEBUG which will show errors on development and * hide them from production */ ini_set("display_errors", DEBUG); /* * Since we have no error_handler at this time, it's a good idea to see them in HTML format * can be set to true or false * or ini_get("diaplay_errors") which will make them appear in HTML format on the screen, or in text format when errors does not appear on screen */ ini_set("html_errors", ini_get("diaplay_errors")); // Set the default time zone if (!empty($config["timezone"])) { date_default_timezone_set($config["timezone"]); } // Register/Unregister default application autoloder if (isset($config["autoload"])) { if ($config["autoload"] and !static::$registered) { static::register(); } if (!$config["autoload"] and static::$registered) { static::unregister(); } } }
public function to($normalpath) { return Config::path('base') . '/' . $normalpath; }