/** * Class Constructor * * @param Config $configs Konfigurasi */ public function __construct(Config $conf = null) { // Menerapkan konfigurasi $this->conf = $conf; // Menerapkan konfigurasi (@link http://php.net/manual/en/function.ob-get-level.php) $this->buffer = ob_get_level(); self::$instance =& $this; // Default konfigurasi $baseurl if ($this->conf('baseurl') == '' && isset($_SERVER['HTTP_HOST'])) { $this->conf('baseurl', '//' . $_SERVER['HTTP_HOST'] . '/'); } session_name($this->conf('basename')); session_start(); // Inisiasi routing container $this->add('routes', function ($c) { return []; }); // Inisiasi uri container $this->add('uri', function ($c) { return new Uri(); }); // Inisiasi modules container $this->add('modules', function ($c, $name) { $modules = new Modules($name); // Menyimpan sementara semua modules yang ada dalam cache $c->add($name, $modules->all()); return $modules; }); }
/** * Class Constructor * * @param Config $configs Konfigurasi */ public function __construct(Config $conf = null) { // Menerapkan konfigurasi $this->conf = $conf; // Menerapkan konfigurasi (@link http://php.net/manual/en/function.ob-get-level.php) $this->buffer = ob_get_level(); self::$instance =& $this; // Default konfigurasi $baseurl if ($this->conf('baseurl') == '' && isset($_SERVER['HTTP_HOST'])) { $this->conf('baseurl', '//' . $_SERVER['HTTP_HOST'] . '/'); } session_name($this->conf('basename')); session_start(); // Inisiasi routing container $this->add('errors', function () { if (!class_exists('Error')) { require_once __DIR__ . '/Error.php'; } return new Error(); }); // Inisiasi routing container $this->add('routes', function () { return []; }); // Inisiasi uri container $this->add('uri', function () { return new Uri(); }); $this->conf('asset.css', ['asset/lib/jquery-ui.css', 'asset/reset.css', 'asset/style.css']); $this->conf('asset.js', ['asset/lib/jquery.min.js', 'asset/lib/jquery-ui.min.js', 'asset/lib/jquery-validate.min.js', 'asset/lib/nicedit.js', 'asset/script.js']); // Inisiasi modules container $this->add('modules', function ($c, $name) { $modules = new Modules($name); // Menyimpan sementara semua modules yang ada dalam cache $c->add($name, $modules->all()); return $modules; }); }
} $uploads['basedir'] = ROOT . '/data/uploads/media'; $uploads['path'] = $uploads['basedir'] . $uploads['subdir']; if ($upload_url_path) { $uploads['baseurl'] = $upload_url_path; $uploads['url'] = $uploads['baseurl'] . $uploads['subdir']; } return $uploads; }); //解决上传文件名中文乱码问题 add_filter('sanitize_file_name', function ($filename) { $ext = pathinfo($filename, PATHINFO_EXTENSION); $newname = date('YmdHis') . floor(microtime() * 1000) . substr(md5($filename), 16) . ($ext ? ".{$ext}" : ''); return $newname; }, 10); show_admin_bar(false); /** * @see http://zmingcx.com/wordpress-4-2-edition-problem.html */ function init_smilies() { global $wpsmiliestrans; $wpsmiliestrans = array(':mrgreen:' => 'icon_mrgreen.gif', ':neutral:' => 'icon_neutral.gif', ':twisted:' => 'icon_twisted.gif', ':arrow:' => 'icon_arrow.gif', ':shock:' => 'icon_eek.gif', ':smile:' => 'icon_smile.gif', ':???:' => 'icon_confused.gif', ':cool:' => 'icon_cool.gif', ':evil:' => 'icon_evil.gif', ':grin:' => 'icon_biggrin.gif', ':idea:' => 'icon_idea.gif', ':oops:' => 'icon_redface.gif', ':razz:' => 'icon_razz.gif', ':roll:' => 'icon_rolleyes.gif', ':wink:' => 'icon_wink.gif', ':cry:' => 'icon_cry.gif', ':eek:' => 'icon_surprised.gif', ':lol:' => 'icon_lol.gif', ':mad:' => 'icon_mad.gif', ':sad:' => 'icon_sad.gif', '8-)' => 'icon_cool.gif', '8-O' => 'icon_eek.gif', ':-(' => 'icon_sad.gif', ':-)' => 'icon_smile.gif', ':-?' => 'icon_confused.gif', ':-D' => 'icon_biggrin.gif', ':-P' => 'icon_razz.gif', ':-o' => 'icon_surprised.gif', ':-x' => 'icon_mad.gif', ':-|' => 'icon_neutral.gif', ';-)' => 'icon_wink.gif', '8O' => 'icon_eek.gif', ':(' => 'icon_sad.gif', ':)' => 'icon_smile.gif', ':?' => 'icon_confused.gif', ':D' => 'icon_biggrin.gif', ':P' => 'icon_razz.gif', ':o' => 'icon_surprised.gif', ':x' => 'icon_mad.gif', ':|' => 'icon_neutral.gif', ';)' => 'icon_wink.gif', ':!:' => 'icon_exclaim.gif', ':?:' => 'icon_question.gif'); } add_action('init', 'init_smilies', 5); //require __DIR__.'/extra/remove-category-parents.php'; /** @type \YCMS\Modules\Module $module */ foreach (\Modules::all() as $module) { \register_theme_directory(dirname($module->getPath())); } View::addLocation(realpath(get_template_directory() . '/Resources/views') ?: get_template_directory());