function prepare_markdown_template($path = null) { if (is_null($path)) { $path = get_cache_path(settings('mde_template_filename')); } if (!file_exists($path) || filemtime($path) < filemtime(settings('user_config_filename'))) { $html5_quick_template = get_demo_builder_file_path(settings('html5_quick_template')); $mde_opts = settings('mde_settings'); $opts = array_merge(settings(), $mde_opts); $opts['settings'] = array_merge(settings('hqt_settings'), $mde_opts['hqt_settings']); $ctt = get_view($html5_quick_template, $opts); if (false === file_put_contents($path, $ctt)) { throw new ErrorException(sprintf('Cannot write template file "%s"!', $path)); } } return true; }
define('DEMO_BASEDIR', isset($_SERVER['PHP_SELF']) ? dirname($_SERVER['PHP_SELF']) : __DIR__ . '/../'); } settings('app_name', md5(DEMO_BASEDIR)); // config.json if (file_exists($cfg = __DIR__ . '/config.json')) { $config = load_config($cfg); settings($config); } else { die(sprintf('Demo-Builder default config not found at "%s"!', $cfg)); } // defaults $settings = load_config(get_demo_builder_file_path(settings('default_config_filename'))); settings($settings); //settings('hqt_settings', $settings['hqt_settings']); // MDE defaults $mde_settings = load_config(get_demo_builder_file_path(settings('md_config_filename'))); settings('mde_settings', $mde_settings); // load config load_user_config(); $cfg = settings('user_config'); // request args if (!IS_CLI) { settings(array('arg_ln' => isset($_GET['ln']) ? $_GET['ln'] : settings('default_language'), 'arg_page' => isset($_GET['page']) ? $_GET['page'] : settings('default_page'), 'arg_action' => isset($_GET['action']) ? $_GET['action'] : null)); } // distribute if (is_null($action = settings('arg_action'))) { $content = load_page(settings('arg_page')); echo $content; } else { switch ($action) { case 'template':