private function installTemplateContent($template_name) { $default_content_folder = mw_includes_path() . 'install' . DIRECTORY_SEPARATOR; $default_content_file = $default_content_folder . 'mw_default_content.zip'; if ($template_name) { if (function_exists('templates_path')) { $template_dir = templates_path() . DS . $template_name; $template_dir = normalize_path($template_dir, true); if (is_dir($template_dir)) { $template_default_content = $template_dir . 'mw_default_content.zip'; if (is_file($template_default_content) and is_readable($template_default_content)) { $default_content_file = $template_default_content; $default_content_folder = $template_dir; } } } } if (is_file($default_content_file)) { $restore = new \Microweber\Utils\Backup(); $restore->backups_folder = $default_content_folder; $restore->backup_file = 'mw_default_content.zip'; ob_start(); try { $rest = $restore->exec_restore(); } catch (Exception $e) { return false; } ob_get_clean(); return true; } else { return false; } }
/** * @desc Get the template layouts info under the layouts subdir on your active template * @param $options * $options ['type'] - 'layout' is the default type if you dont define any. You can define your own types as post/form, etc in the layout.txt file * @return array * @author Microweber Dev Team * @since Version 1.0 */ public function site_templates($options = false) { $args = func_get_args(); $function_cache_id = ''; foreach ($args as $k => $v) { $function_cache_id = $function_cache_id . serialize($k) . serialize($v); } $cache_id = __FUNCTION__ . crc32($function_cache_id); $cache_group = 'templates'; $cache_content = false; // $cache_content = $this->app->cache_manager->get($cache_id, $cache_group); if ($cache_content != false) { // return $cache_content; } if (!isset($options['path'])) { $path = templates_path(); } else { $path = $options['path']; } $path_to_layouts = $path; $layout_path = $path; $map = $this->directory_map($path, TRUE, TRUE); $to_return = array(); if (!is_array($map) or empty($map)) { return false; } foreach ($map as $dir) { //$filename = $path . $dir . DIRECTORY_SEPARATOR . 'layout.php'; $filename = $path . DIRECTORY_SEPARATOR . $dir; $filename_location = false; $filename_dir = false; $filename = normalize_path($filename); $filename = rtrim($filename, '\\'); $filename = substr($filename, 0, 1) === '.' ? substr($filename, 1) : $filename; if (!@is_file($filename) and @is_dir($filename)) { $fn1 = normalize_path($filename, true) . 'config.php'; $fn2 = normalize_path($filename); if (is_file($fn1)) { $config = false; include $fn1; if (!empty($config)) { $c = $config; $c['dir_name'] = $dir; $screensshot_file = $fn2 . '/screenshot.png'; $screensshot_file = normalize_path($screensshot_file, false); if (is_file($screensshot_file)) { $c['screenshot'] = $this->app->url_manager->link_to_file($screensshot_file); } $to_return[] = $c; } } else { $filename_dir = false; } // $path = $filename; } } //$this->app->cache_manager->save($to_return, $cache_id, $cache_group, 'files'); return $to_return; }
/** * Defines all constants that are needed to parse the page layout * * It accepts array or $content that must have $content['id'] set * * @example * <code> * Define constants for some page * $ref_page = $this->get_by_id(1); * $this->define_constants($ref_page); * print PAGE_ID; * print POST_ID; * print CATEGORY_ID; * print MAIN_PAGE_ID; * print DEFAULT_TEMPLATE_DIR; * print DEFAULT_TEMPLATE_URL; * </code> * * @package Content * @subpackage Advanced * @const PAGE_ID Defines the current page id * @const POST_ID Defines the current post id * @const CATEGORY_ID Defines the current category id if any * @const ACTIVE_PAGE_ID Same as PAGE_ID * @const CONTENT_ID current post or page id * @const MAIN_PAGE_ID the parent page id * @const DEFAULT_TEMPLATE_DIR the directory of the site's default template * @const DEFAULT_TEMPLATE_URL the url of the site's default template * * * * @param array|bool $content * @option integer "id" [description] * @option string "content_type" [description] * @return void */ public function define_constants($content = false) { if ($content == false) { if (isset($_SERVER['HTTP_REFERER'])) { $ref_page = $_SERVER['HTTP_REFERER']; if ($ref_page != '') { $ref_page = $this->get_by_url($ref_page); if ($ref_page != false and !empty($ref_page)) { $content = $ref_page; } } } } $page = false; if (is_array($content)) { if (!isset($content['active_site_template']) and isset($content['id']) and $content['id'] != 0) { $content = $this->get_by_id($content['id']); $page = $content; } else { if (isset($content['id']) and $content['id'] == 0) { $page = $content; } else { if (isset($content['active_site_template'])) { $page = $content; } } } if ($page == false) { $page = $content; } } if (is_array($page)) { if (isset($page['content_type']) and ($page['content_type'] == "post" or $page['content_type'] != "page")) { if (isset($page['id']) and $page['id'] != 0) { $content = $page; $current_categorys = $this->app->category_manager->get_for_content($page['id']); if (!empty($current_categorys)) { $current_category = end($current_categorys); if (defined('CATEGORY_ID') == false and isset($current_category['id'])) { define('CATEGORY_ID', $current_category['id']); } } $page = $this->get_by_id($page['parent']); if (defined('POST_ID') == false) { define('POST_ID', $content['id']); } if ($page['content_type'] == "product") { if (defined('PRODUCT_ID') == false) { define('PRODUCT_ID', $content['id']); } } } } else { $content = $page; if (defined('POST_ID') == false) { define('POST_ID', false); } } if (defined('ACTIVE_PAGE_ID') == false) { if (!isset($page['id'])) { $page['id'] = 0; } define('ACTIVE_PAGE_ID', $page['id']); } if (!defined('CATEGORY_ID')) { //define('CATEGORY_ID', $current_category['id']); } if (defined('CATEGORY_ID') == false) { $cat_url = $this->app->url_manager->param('category', $skip_ajax = true); if ($cat_url != false) { define('CATEGORY_ID', intval($cat_url)); } } if (!defined('CATEGORY_ID')) { define('CATEGORY_ID', false); } if (defined('CONTENT_ID') == false and isset($content['id'])) { define('CONTENT_ID', $content['id']); } if (defined('PAGE_ID') == false and isset($content['id'])) { define('PAGE_ID', $page['id']); } if (isset($page['parent'])) { $parent_page_check_if_inherited = $this->get_by_id($page['parent']); if (isset($parent_page_check_if_inherited["layout_file"]) and $parent_page_check_if_inherited["layout_file"] == 'inherit') { $inherit_from_id = $this->get_inherited_parent($parent_page_check_if_inherited["id"]); if (defined('MAIN_PAGE_ID') == false) { define('MAIN_PAGE_ID', $inherit_from_id); } } //$root_parent = $this->get_inherited_parent($page['parent']); // $this->get_inherited_parent($page['id']); // if ($par_page != false) { // $par_page = $this->get_by_id($page['parent']); // } if (defined('ROOT_PAGE_ID') == false) { $root_page = $this->get_parents($page['id']); if (!empty($root_page) and isset($root_page[0])) { $root_page[0] = end($root_page); } else { $root_page[0] = $page['parent']; } define('ROOT_PAGE_ID', $root_page[0]); } if (defined('MAIN_PAGE_ID') == false) { if ($page['parent'] == 0) { define('MAIN_PAGE_ID', $page['id']); } else { define('MAIN_PAGE_ID', $page['parent']); } } if (defined('PARENT_PAGE_ID') == false) { define('PARENT_PAGE_ID', $page['parent']); } } } if (defined('ACTIVE_PAGE_ID') == false) { define('ACTIVE_PAGE_ID', false); } if (defined('CATEGORY_ID') == false) { define('CATEGORY_ID', false); } if (defined('CONTENT_ID') == false) { define('CONTENT_ID', false); } if (defined('POST_ID') == false) { define('POST_ID', false); } if (defined('PAGE_ID') == false) { define('PAGE_ID', false); } if (defined('MAIN_PAGE_ID') == false) { define('MAIN_PAGE_ID', false); } if (isset($page) and isset($page['active_site_template']) and $page['active_site_template'] != '' and strtolower($page['active_site_template']) != 'inherit' and strtolower($page['active_site_template']) != 'default') { $the_active_site_template = $page['active_site_template']; } else { if (isset($page) and isset($page['active_site_template']) and $page['active_site_template'] != '' and strtolower($page['active_site_template']) != 'default') { $the_active_site_template = $page['active_site_template']; } else { if (isset($content) and isset($content['active_site_template']) and $content['active_site_template'] != '' and strtolower($content['active_site_template']) != 'default') { $the_active_site_template = $content['active_site_template']; } else { $the_active_site_template = $this->app->option_manager->get('current_template', 'template'); // } } } if (isset($content['parent']) and $content['parent'] != 0 and isset($content['layout_file']) and $content['layout_file'] == 'inherit') { $inh = $this->get_inherited_parent($content['id']); if ($inh != false) { $inh_parent = $this->get_by_id($inh); if (isset($inh_parent['active_site_template']) and $inh_parent['active_site_template'] != '' and strtolower($inh_parent['active_site_template']) != 'default') { $the_active_site_template = $inh_parent['active_site_template']; } else { if (isset($inh_parent['active_site_template']) and $inh_parent['active_site_template'] != '' and strtolower($inh_parent['active_site_template']) == 'default') { $the_active_site_template = $this->app->option_manager->get('current_template', 'template'); } else { if (isset($inh_parent['active_site_template']) and $inh_parent['active_site_template'] == '') { $the_active_site_template = $this->app->option_manager->get('current_template', 'template'); } } } } } if (isset($the_active_site_template) and $the_active_site_template != 'default' and $the_active_site_template == 'mw_default') { $the_active_site_template = 'default'; } if ($the_active_site_template == false) { $the_active_site_template = 'default'; } if (defined('THIS_TEMPLATE_DIR') == false and $the_active_site_template != false) { define('THIS_TEMPLATE_DIR', templates_path() . $the_active_site_template . DS); } if (defined('THIS_TEMPLATE_FOLDER_NAME') == false and $the_active_site_template != false) { define('THIS_TEMPLATE_FOLDER_NAME', $the_active_site_template); } $the_active_site_template_dir = normalize_path(templates_path() . $the_active_site_template . DS); if (defined('DEFAULT_TEMPLATE_DIR') == false) { define('DEFAULT_TEMPLATE_DIR', templates_path() . 'default' . DS); } if (defined('DEFAULT_TEMPLATE_URL') == false) { define('DEFAULT_TEMPLATE_URL', templates_url() . '/default/'); } if (trim($the_active_site_template) != 'default') { if (!strstr($the_active_site_template, DEFAULT_TEMPLATE_DIR)) { $use_default_layouts = $the_active_site_template_dir . 'use_default_layouts.php'; if (is_file($use_default_layouts)) { if (isset($page['layout_file'])) { $template_view = DEFAULT_TEMPLATE_DIR . $page['layout_file']; } else { $template_view = DEFAULT_TEMPLATE_DIR; } if (isset($page)) { if (!isset($page['layout_file']) or (isset($page['layout_file']) and $page['layout_file'] == 'inherit' or $page['layout_file'] == '')) { $par_page = $this->get_inherited_parent($page['id']); if ($par_page != false) { $par_page = $this->get_by_id($par_page); } if (isset($par_page['layout_file'])) { $the_active_site_template = $par_page['active_site_template']; $page['layout_file'] = $par_page['layout_file']; $page['active_site_template'] = $par_page['active_site_template']; $template_view = templates_path() . $page['active_site_template'] . DS . $page['layout_file']; } } } if (is_file($template_view) == true) { if (defined('THIS_TEMPLATE_DIR') == false) { define('THIS_TEMPLATE_DIR', templates_path() . $the_active_site_template . DS); } if (defined('THIS_TEMPLATE_URL') == false) { $the_template_url = templates_url() . '/' . $the_active_site_template; $the_template_url = $the_template_url . '/'; if (defined('THIS_TEMPLATE_URL') == false) { define("THIS_TEMPLATE_URL", $the_template_url); } if (defined('TEMPLATE_URL') == false) { define("TEMPLATE_URL", $the_template_url); } } $the_active_site_template = 'default'; $the_active_site_template_dir = DEFAULT_TEMPLATE_DIR; } } } } if (defined('ACTIVE_TEMPLATE_DIR') == false) { define('ACTIVE_TEMPLATE_DIR', $the_active_site_template_dir); } if (defined('THIS_TEMPLATE_DIR') == false) { define('THIS_TEMPLATE_DIR', $the_active_site_template_dir); } if (defined('THIS_TEMPLATE_URL') == false) { $the_template_url = templates_url() . '/' . $the_active_site_template; $the_template_url = $the_template_url . '/'; if (defined('THIS_TEMPLATE_URL') == false) { define("THIS_TEMPLATE_URL", $the_template_url); } } if (defined('TEMPLATE_NAME') == false) { define('TEMPLATE_NAME', $the_active_site_template); } if (defined('TEMPLATE_DIR') == false) { define('TEMPLATE_DIR', $the_active_site_template_dir); } if (defined('ACTIVE_SITE_TEMPLATE') == false) { define('ACTIVE_SITE_TEMPLATE', $the_active_site_template); } if (defined('TEMPLATES_DIR') == false) { define('TEMPLATES_DIR', templates_path()); } $the_template_url = templates_url() . $the_active_site_template; $the_template_url = $the_template_url . '/'; if (defined('TEMPLATE_URL') == false) { define("TEMPLATE_URL", $the_template_url); } if (defined('LAYOUTS_DIR') == false) { $layouts_dir = TEMPLATE_DIR . 'layouts/'; define("LAYOUTS_DIR", $layouts_dir); } else { $layouts_dir = LAYOUTS_DIR; } if (defined('LAYOUTS_URL') == false) { $layouts_url = reduce_double_slashes($this->app->url_manager->link_to_file($layouts_dir) . '/'); define("LAYOUTS_URL", $layouts_url); } return true; }
public function frontend() { if (isset($_GET['debug'])) { if ($this->app->make('config')->get('app.debug')) { DB::enableQueryLog(); } } event_trigger('mw.controller.index'); if ($this->render_this_url == false and $this->app->url_manager->is_ajax() == false) { $page_url = $this->app->url_manager->string(); } elseif ($this->render_this_url == false and $this->app->url_manager->is_ajax() == true) { $page_url = $this->app->url_manager->string(1); } else { $page_url = $this->render_this_url; $this->render_this_url = false; } if ($this->page_url != false) { $page_url = $this->page_url; } if (strtolower($page_url) == 'index.php') { $page_url = ''; } if ($this->create_new_page == true and $this->page_url != false) { $page_url = $this->page_url; } $page = false; if ($page == false and !empty($this->page)) { $page = $this->page; } $page_url = rtrim($page_url, '/'); $is_admin = $this->app->user_manager->is_admin(); $page_url_orig = $page_url; $simply_a_file = false; $show_404_to_non_admin = false; // if this is a file path it will load it if (isset($_REQUEST['view'])) { $is_custom_view = $_REQUEST['view']; } else { $is_custom_view = $this->app->url_manager->param('view'); if ($is_custom_view and $is_custom_view != false) { $is_custom_view = str_replace('..', '', $is_custom_view); $page_url = $this->app->url_manager->param_unset('view', $page_url); } } $is_editmode = $this->app->url_manager->param('editmode'); $is_no_editmode = $this->app->url_manager->param('no_editmode'); $is_quick_edit = $this->app->url_manager->param('mw_quick_edit'); if ($is_quick_edit != false) { $page_url = $this->app->url_manager->param_unset('mw_quick_edit', $page_url); } $is_preview_template = $this->app->url_manager->param('preview_template'); if (!$is_preview_template) { $is_preview_template = false; if ($this->return_data == false) { if (!defined('MW_FRONTEND')) { define('MW_FRONTEND', true); } } if (mw()->user_manager->session_id() and $is_editmode and $is_no_editmode == false) { if ($is_editmode == 'n') { $is_editmode = false; $page_url = $this->app->url_manager->param_unset('editmode', $page_url); $this->app->user_manager->session_set('back_to_editmode', true); $this->app->user_manager->session_set('editmode', false); return $this->app->url_manager->redirect($this->app->url_manager->site_url($page_url)); } else { $editmode_sess = $this->app->user_manager->session_get('editmode'); $page_url = $this->app->url_manager->param_unset('editmode', $page_url); if ($is_admin == true) { if ($editmode_sess == false) { $this->app->user_manager->session_set('editmode', true); $this->app->user_manager->session_set('back_to_editmode', false); $is_editmode = false; } return $this->app->url_manager->redirect($this->app->url_manager->site_url($page_url)); } else { $is_editmode = false; } } } if (mw()->user_manager->session_id() and !$is_no_editmode) { $is_editmode = $this->app->user_manager->session_get('editmode'); } else { $is_editmode = false; $page_url = $this->app->url_manager->param_unset('no_editmode', $page_url); } } else { $is_editmode = false; $page_url = $this->app->url_manager->param_unset('preview_template', $page_url); } if ($is_quick_edit == true) { $is_editmode = true; } $preview_module = false; $preview_module_template = false; $preview_module_id = false; $template_relative_layout_file_from_url = false; $is_preview_module = $this->app->url_manager->param('preview_module'); if ($is_preview_module != false) { if ($this->app->user_manager->is_admin()) { $is_preview_module = module_name_decode($is_preview_module); if (is_module($is_preview_module)) { $is_preview_module_skin = $this->app->url_manager->param('preview_module_template'); $preview_module_id = $this->app->url_manager->param('preview_module_id'); $preview_module = $is_preview_module; if ($is_preview_module_skin != false) { $preview_module_template = module_name_decode($is_preview_module_skin); $is_editmode = false; } } } } $is_layout_file = $this->app->url_manager->param('preview_layout'); if (!$is_layout_file) { $is_layout_file = false; } else { $page_url = $this->app->url_manager->param_unset('preview_layout', $page_url); } if (isset($_REQUEST['content_id']) and intval($_REQUEST['content_id']) != 0) { $page = $this->app->content_manager->get_by_id($_REQUEST['content_id']); } if ($is_quick_edit or $is_preview_template == true or isset($_REQUEST['isolate_content_field']) or $this->create_new_page == true) { if (isset($_REQUEST['content_id']) and intval($_REQUEST['content_id']) != 0) { $page = $this->app->content_manager->get_by_id($_REQUEST['content_id']); } else { $page['id'] = 0; $page['content_type'] = 'page'; if (isset($_REQUEST['content_type'])) { $page['content_type'] = $this->app->database_manager->escape_string($_REQUEST['content_type']); } if (isset($_REQUEST['subtype'])) { $page['subtype'] = $this->app->database_manager->escape_string($_REQUEST['subtype']); } template_var('new_content_type', $page['content_type']); $page['parent'] = '0'; if (isset($_REQUEST['parent_id']) and $_REQUEST['parent_id'] != 0) { $page['parent'] = intval($_REQUEST['parent_id']); } //$page['url'] = $this->app->url_manager->string(); if (isset($is_preview_template) and $is_preview_template != false) { $page['active_site_template'] = $is_preview_template; } else { } if (isset($is_layout_file) and $is_layout_file != false) { $page['layout_file'] = $is_layout_file; } if (isset($_REQUEST['inherit_template_from']) and $_REQUEST['inherit_template_from'] != 0) { $page['parent'] = intval($_REQUEST['inherit_template_from']); $inherit_from = $this->app->content_manager->get_by_id($_REQUEST['inherit_template_from']); //$page['parent'] = $inherit_from ; if (isset($inherit_from['layout_file']) and $inherit_from['layout_file'] == 'inherit') { $inherit_from_id = $this->app->content_manager->get_inherited_parent($inherit_from['id']); $inherit_from = $this->app->content_manager->get_by_id($inherit_from_id); } if (is_array($inherit_from) and isset($inherit_from['active_site_template'])) { $page['active_site_template'] = $inherit_from['active_site_template']; $is_layout_file = $page['layout_file'] = $inherit_from['layout_file']; } } if (isset($_REQUEST['content_type']) and $_REQUEST['content_type'] != false) { $page['content_type'] = $_REQUEST['content_type']; } if ($this->content_data != false) { $page = $this->content_data; } template_var('new_page', $page); } } $output_cache_timeout = false; if (isset($is_preview_template) and $is_preview_template != false) { if (!defined('MW_NO_SESSION')) { define('MW_NO_SESSION', true); } } if (isset($_REQUEST['recart']) and $_REQUEST['recart'] != false) { event_trigger('recover_shopping_cart', $_REQUEST['recart']); } if ($output_cache_timeout != false) { $output_cache_id = __FUNCTION__ . crc32($_SERVER['REQUEST_URI']); $output_cache_group = 'content/preview'; $output_cache_content = $this->app->cache_manager->get($output_cache_id, $output_cache_group, $output_cache_timeout); if ($output_cache_content != false) { echo $output_cache_content; return; } } $the_active_site_template = $this->app->option_manager->get('current_template', 'template'); $date_format = $this->app->option_manager->get('date_format', 'website'); if ($date_format == false) { $date_format = 'Y-m-d H:i:s'; } if ($page == false or $this->create_new_page == true) { if (trim($page_url) == '' and $preview_module == false) { $page = $this->app->content_manager->homepage(); } else { $found_mod = false; $page = $this->app->content_manager->get_by_url($page_url); $page_exact = $this->app->content_manager->get_by_url($page_url, true); $page_url_segment_1 = $this->app->url_manager->segment(0, $page_url); if ($preview_module != false) { $page_url = $preview_module; } if ($the_active_site_template == false or $the_active_site_template == '') { $the_active_site_template = 'default'; } if ($page_exact == false and $found_mod == false and $this->app->modules->is_installed($page_url) and $page_url != 'settings' and $page_url != 'admin') { $found_mod = true; $page['id'] = 0; $page['content_type'] = 'page'; $page['parent'] = '0'; $page['url'] = $this->app->url_manager->string(); $page['active_site_template'] = $the_active_site_template; template_var('no_edit', 1); $mod_params = ''; if ($preview_module_template != false) { $mod_params = $mod_params . " template='{$preview_module_template}' "; } if ($preview_module_id != false) { $mod_params = $mod_params . " id='{$preview_module_id}' "; } $found_mod = $page_url; $page['content'] = '<microweber module="' . $page_url . '" ' . $mod_params . ' />'; // $page['simply_a_file'] = 'clean.php'; $page['layout_file'] = 'clean.php'; template_var('content', $page['content']); template_var('new_page', $page); } if ($found_mod == false) { if (empty($page)) { $the_new_page_file = false; $page_url_segment_1 = $this->app->url_manager->segment(0, $page_url); $td = templates_path() . $page_url_segment_1; $td_base = $td; $page_url_segment_2 = $this->app->url_manager->segment(1, $page_url); $directly_to_file = false; $page_url_segment_3 = $this->app->url_manager->segment(-1, $page_url); $page_url_segment_1 = $the_active_site_template = $this->app->option_manager->get('current_template', 'template'); $td_base = templates_path() . $the_active_site_template . DS; $page_url_segment_3_str = implode(DS, $page_url_segment_3); if ($page_url_segment_3_str != '') { $page_url_segment_3_str = rtrim($page_url_segment_3_str, DS); $page_url_segment_3_str = rtrim($page_url_segment_3_str, '\\'); $page_url_segment_3_str_copy = $page_url_segment_3_str; $is_ext = get_file_extension($page_url_segment_3_str); if ($is_ext == false or $is_ext != 'php') { $page_url_segment_3_str = $page_url_segment_3_str . '.php'; } $td_f = $td_base . DS . $page_url_segment_3_str; $td_fd = $td_base . DS . $page_url_segment_3_str_copy; $td_fd2 = $td_base . DS . $page_url_segment_3[0]; if (is_file($td_f)) { $the_new_page_file = $page_url_segment_3_str; $simply_a_file = $directly_to_file = $td_f; } else { if (is_dir($td_fd)) { $td_fd_index = $td_fd . DS . 'index.php'; if (is_file($td_fd_index)) { $the_new_page_file = $td_fd_index; $simply_a_file = $directly_to_file = $td_fd_index; } } else { $is_ext = get_file_extension($td_fd); if ($is_ext == false or $is_ext != 'php') { $td_fd = $td_fd . '.php'; } $is_ext = get_file_extension($td_fd2); if ($is_ext == false or $is_ext != 'php') { $td_fd2 = $td_fd2 . '.php'; } if (is_file($td_fd)) { $the_new_page_file = $td_fd; $simply_a_file = $directly_to_file = $td_fd; } elseif (is_file($td_fd2)) { $the_new_page_file = $td_fd2; $simply_a_file = $directly_to_file = $td_fd2; } else { $td_basedef = templates_path() . 'default' . DS . $page_url_segment_3_str; if (is_file($td_basedef)) { $the_new_page_file = $td_basedef; $simply_a_file = $directly_to_file = $td_basedef; } } } } } $fname1 = 'index.php'; $fname2 = $page_url_segment_2 . '.php'; $fname3 = $page_url_segment_2; $tf1 = $td . DS . $fname1; $tf2 = $td . DS . $fname2; $tf3 = $td . DS . $fname3; if ($directly_to_file == false and is_dir($td)) { if (is_file($tf1)) { $simply_a_file = $tf1; $the_new_page_file = $fname1; } if (is_file($tf2)) { $simply_a_file = $tf2; $the_new_page_file = $fname2; } if (is_file($tf3)) { $simply_a_file = $tf3; $the_new_page_file = $fname3; } if ($simply_a_file != false) { $simply_a_file = str_replace('..', '', $simply_a_file); $simply_a_file = normalize_path($simply_a_file, false); } } if ($simply_a_file == false) { //$page = $this->app->content_manager->homepage(); $page = false; if (!is_array($page)) { $page = array(); $page['id'] = 0; $page['content_type'] = 'page'; $page['parent'] = '0'; $page['url'] = $this->app->url_manager->string(); // $page['active_site_template'] = $page_url_segment_1; $page['simply_a_file'] = 'clean.php'; $page['layout_file'] = 'clean.php'; $show_404_to_non_admin = true; } if (is_array($page_url_segment_3)) { foreach ($page_url_segment_3 as $mvalue) { if ($found_mod == false and $this->app->modules->is_installed($mvalue)) { $found_mod = true; $page['id'] = 0; $page['content_type'] = 'page'; $page['parent'] = '0'; $page['url'] = $this->app->url_manager->string(); $page['active_site_template'] = $page_url_segment_1; $page['content'] = '<module type="' . $mvalue . '" />'; $page['simply_a_file'] = 'clean.php'; $page['layout_file'] = 'clean.php'; template_var('content', $page['content']); template_var('new_page', $page); $show_404_to_non_admin = false; } } } } else { if (!is_array($page)) { $page = array(); } $page['id'] = 0; if (isset($page_data) and isset($page_data['id'])) { // $page['id'] = $page_data['id']; } $page['content_type'] = 'page'; $page['parent'] = '0'; $page['url'] = $this->app->url_manager->string(); $page['active_site_template'] = $page_url_segment_1; $page['layout_file'] = $the_new_page_file; $page['simply_a_file'] = $simply_a_file; template_var('new_page', $page); template_var('simply_a_file', $simply_a_file); } } } } } if ($page['id'] != 0) { // if(!isset($page['layout_file']) or $page['layout_file'] == false){ $page = $this->app->content_manager->get_by_id($page['id']); // } if ($page['content_type'] == 'post' and isset($page['parent'])) { $content = $page; $page = $this->app->content_manager->get_by_id($page['parent']); } else { $content = $page; } } else { $content = $page; } if (isset($content['created_at']) and trim($content['created_at']) != '') { $content['created_at'] = date($date_format, strtotime($content['created_at'])); } if (isset($content['updated_at']) and trim($content['updated_at']) != '') { $content['updated_at'] = date($date_format, strtotime($content['updated_at'])); } if ($is_preview_template != false) { $is_preview_template = str_replace('____', DS, $is_preview_template); $is_preview_template = str_replace('..', '', $is_preview_template); $content['active_site_template'] = $is_preview_template; } if ($is_layout_file != false and $is_admin == true) { $is_layout_file = str_replace('____', DS, $is_layout_file); if ($is_layout_file == 'inherit') { if (isset($_REQUEST['inherit_template_from']) and intval($_REQUEST['inherit_template_from']) != 0) { $inherit_layout_from_this_page = $this->app->content_manager->get_by_id($_REQUEST['inherit_template_from']); if (isset($inherit_layout_from_this_page['layout_file']) and $inherit_layout_from_this_page['layout_file'] != 'inherit') { $is_layout_file = $inherit_layout_from_this_page['layout_file']; } if (isset($inherit_layout_from_this_page['layout_file']) and $inherit_layout_from_this_page['layout_file'] != 'inherit') { $is_layout_file = $inherit_layout_from_this_page['layout_file']; } } } $content['layout_file'] = $is_layout_file; } if ($is_custom_view and $is_custom_view != false) { $content['custom_view'] = $is_custom_view; } if (isset($content['is_active']) and ($content['is_active'] == 'n' or $content['is_active'] == 0)) { if ($this->app->user_manager->is_admin() == false) { $page_non_active = array(); $page_non_active['id'] = 0; $page_non_active['content_type'] = 'page'; $page_non_active['parent'] = '0'; $page_non_active['url'] = $this->app->url_manager->string(); $page_non_active['content'] = 'This page is not published!'; $page_non_active['simply_a_file'] = 'clean.php'; $page_non_active['layout_file'] = 'clean.php'; $page_non_active['page_non_active'] = true; template_var('content', $page_non_active['content']); $content = $page_non_active; } } elseif (isset($content['is_deleted']) and $content['is_deleted'] == 1) { if ($this->app->user_manager->is_admin() == false) { $page_non_active = array(); $page_non_active['id'] = 0; $page_non_active['content_type'] = 'page'; $page_non_active['parent'] = '0'; $page_non_active['url'] = $this->app->url_manager->string(); $page_non_active['content'] = 'This page is deleted!'; $page_non_active['simply_a_file'] = 'clean.php'; $page_non_active['layout_file'] = 'clean.php'; $page_non_active['page_is_deleted'] = true; template_var('content', $page_non_active['content']); $content = $page_non_active; } } if (isset($content['require_login']) and $content['require_login'] == 1) { if ($this->app->user_manager->id() == 0) { $page_non_active = array(); $page_non_active['id'] = 0; $page_non_active['content_type'] = 'page'; $page_non_active['parent'] = '0'; $page_non_active['url'] = $this->app->url_manager->string(); $page_non_active['content'] = ' <module type="users/login" class="user-require-login-on-view" /> '; $page_non_active['simply_a_file'] = 'clean.php'; $page_non_active['layout_file'] = 'clean.php'; $page_non_active['page_require_login'] = true; template_var('content', $page_non_active['content']); $content = $page_non_active; } } if (!defined('IS_HOME')) { if (isset($content['is_home']) and $content['is_home'] == 1) { define('IS_HOME', true); } } $this->app->content_manager->define_constants($content); event_trigger('mw.front', $content); event_trigger('mw_frontend', $content); $render_file = $this->app->template->get_layout($content); $content['render_file'] = $render_file; if (defined('TEMPLATE_DIR')) { $load_template_functions = TEMPLATE_DIR . 'functions.php'; if (is_file($load_template_functions)) { include_once $load_template_functions; } } if ($this->return_data != false) { return $content; } if (isset($content['original_link']) and $content['original_link'] != '') { $content['original_link'] = str_ireplace('{site_url}', $this->app->url_manager->site(), $content['original_link']); $redirect = $this->app->format->prep_url($content['original_link']); if ($redirect != '') { return $this->app->url_manager->redirect($redirect); } } if (!isset($page['title'])) { $page['title'] = 'New page'; } if (!isset($content['title'])) { $content['title'] = 'New content'; } $category = false; if (defined('CATEGORY_ID')) { $category = $this->app->category_manager->get_by_id(CATEGORY_ID); } if ($render_file) { $render_params = array(); if ($show_404_to_non_admin) { if (!is_admin()) { $load_template_404 = template_dir() . '404.php'; if (is_file($load_template_404)) { $render_file = $load_template_404; } } } $render_params['render_file'] = $render_file; $render_params['page_id'] = PAGE_ID; $render_params['content_id'] = CONTENT_ID; $render_params['post_id'] = POST_ID; $render_params['category_id'] = CATEGORY_ID; $render_params['content'] = $content; $render_params['category'] = $category; $render_params['page'] = $page; $l = $this->app->template->render($render_params); if (is_object($l)) { return $l; } // used for preview from the admin wysiwyg if (isset($_REQUEST['isolate_content_field'])) { require_once MW_PATH . 'Utils' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'phpQuery.php'; $pq = \phpQuery::newDocument($l); $isolated_head = pq('head')->eq(0)->html(); $found_field = false; if (isset($_REQUEST['isolate_content_field'])) { foreach ($pq['[field=content]'] as $elem) { $isolated_el = $l = pq($elem)->htmlOuter(); } } $is_admin = $this->app->user_manager->is_admin(); if ($is_admin == true and isset($isolated_el) != false) { $tb = mw_includes_path() . DS . 'toolbar' . DS . 'editor_tools' . DS . 'wysiwyg' . DS . 'index.php'; //$layout_toolbar = file_get_contents($filename); $layout_toolbar = new \Microweber\View($tb); $layout_toolbar = $layout_toolbar->__toString(); if ($layout_toolbar != '') { if (strstr($layout_toolbar, '{head}')) { if ($isolated_head != false) { $layout_toolbar = str_replace('{head}', $isolated_head, $layout_toolbar); } } if (strpos($layout_toolbar, '{content}')) { $l = str_replace('{content}', $l, $layout_toolbar); } //$layout_toolbar = mw()->parser->process($layout_toolbar, $options = array('no_apc' => 1)); } } } $modify_content = event_trigger('on_load', $content); if ($is_editmode == true and !defined('IN_EDIT')) { define('IN_EDIT', true); } if (isset($is_quick_edit) and $is_quick_edit == true and !defined('QUICK_EDIT')) { define('QUICK_EDIT', true); } $l = $this->app->parser->process($l, $options = false); if ($preview_module_id != false) { $_REQUEST['embed_id'] = $preview_module_id; } if (isset($_REQUEST['embed_id'])) { $find_embed_id = trim($_REQUEST['embed_id']); $l = $this->app->parser->get_by_id($find_embed_id, $l); } $apijs_loaded = $this->app->template->get_apijs_url(); //$apijs_loaded = $this->app->template->get_apijs_url() . '?id=' . CONTENT_ID; $is_admin = $this->app->user_manager->is_admin(); $default_css = '<link rel="stylesheet" href="' . mw_includes_url() . 'default.css" type="text/css" />'; $headers = event_trigger('site_header', TEMPLATE_NAME); $template_headers_append = ''; $one = 1; if (is_array($headers)) { foreach ($headers as $modify) { if ($modify != false and is_string($modify) and $modify != '') { $template_headers_append = $template_headers_append . $modify; } } if ($template_headers_append != false and $template_headers_append != '') { $l = str_ireplace('</head>', $template_headers_append . '</head>', $l, $one); } } $template_headers_src = $this->app->template->head(true); $template_footer_src = $this->app->template->foot(true); $template_headers_src_callback = $this->app->template->head_callback($page); if (is_array($template_headers_src_callback) and !empty($template_headers_src_callback)) { foreach ($template_headers_src_callback as $template_headers_src_callback_str) { if (is_string($template_headers_src_callback_str)) { $template_headers_src = $template_headers_src . "\n" . $template_headers_src_callback_str; } } } if (isset($page['created_by'])) { $author = $this->app->user_manager->get_by_id($page['created_by']); if (is_array($author) and isset($author['profile_url']) and $author['profile_url'] != false) { $template_headers_src = $template_headers_src . "\n" . '<link rel="author" href="' . trim($author['profile_url']) . '" />' . "\n"; } } if ($template_headers_src != false and is_string($template_headers_src)) { $l = str_ireplace('</head>', $template_headers_src . '</head>', $l, $one); } if ($template_footer_src != false and is_string($template_footer_src)) { $l = str_ireplace('</body>', $template_footer_src . '</body>', $l, $one); } $l = str_ireplace('<head>', '<head>' . $default_css, $l); if (!stristr($l, $apijs_loaded)) { //$apijs_settings_loaded = $this->app->template->get_apijs_settings_url() . '?id=' . CONTENT_ID . '&category_id=' . CATEGORY_ID;; $apijs_settings_loaded = $this->app->template->get_apijs_settings_url(); $apijs_settings_script = "\r\n" . '<script src="' . $apijs_settings_loaded . '"></script>' . "\r\n"; $apijs_settings_script .= '<script src="' . $apijs_loaded . '"></script>' . "\r\n"; $l = str_ireplace('<head>', '<head>' . $apijs_settings_script, $l); } if (isset($content['active_site_template']) and $content['active_site_template'] == 'default' and $the_active_site_template != 'default' and $the_active_site_template != 'mw_default') { $content['active_site_template'] = $the_active_site_template; } if (isset($content['active_site_template']) and trim($content['active_site_template']) != '' and $content['active_site_template'] != 'default') { if (!defined('CONTENT_TEMPLATE')) { define('CONTENT_TEMPLATE', $content['active_site_template']); } $custom_live_edit = TEMPLATES_DIR . DS . $content['active_site_template'] . DS . 'live_edit.css'; $live_edit_css_folder = userfiles_path() . 'css' . DS . $content['active_site_template'] . DS; $live_edit_url_folder = userfiles_url() . 'css/' . $content['active_site_template'] . '/'; $custom_live_edit = $live_edit_css_folder . DS . 'live_edit.css'; } else { if (!defined('CONTENT_TEMPLATE')) { define('CONTENT_TEMPLATE', $the_active_site_template); } // if ($the_active_site_template == 'mw_default') { // $the_active_site_template = 'default'; // } $custom_live_edit = TEMPLATE_DIR . DS . 'live_edit.css'; $live_edit_css_folder = userfiles_path() . 'css' . DS . $the_active_site_template . DS; $live_edit_url_folder = userfiles_url() . 'css/' . $the_active_site_template . '/'; $custom_live_edit = $live_edit_css_folder . 'live_edit.css'; } $custom_live_edit = normalize_path($custom_live_edit, false); if (is_file($custom_live_edit)) { $custom_live_editmtime = filemtime($custom_live_edit); $liv_ed_css = '<link rel="stylesheet" href="' . $live_edit_url_folder . 'live_edit.css?version=' . $custom_live_editmtime . '" id="mw-template-settings" type="text/css" />'; $l = str_ireplace('</head>', $liv_ed_css . '</head>', $l); } $liv_ed_css = $this->app->template->get_custom_css_url(); if ($liv_ed_css != false) { $liv_ed_css = '<link rel="stylesheet" href="' . $liv_ed_css . '" id="mw-custom-user-css" type="text/css" />'; $l = str_ireplace('</head>', $liv_ed_css . '</head>', $l); } $website_head_tags = $this->app->option_manager->get('website_head', 'website'); $rep_count = 1; if ($website_head_tags != false) { $l = str_ireplace('</head>', $website_head_tags . '</head>', $l, $rep_count); } if (defined('MW_VERSION')) { $generator_tag = "\n" . '<meta name="generator" content="Microweber" />' . "\n"; $l = str_ireplace('</head>', $generator_tag . '</head>', $l, $rep_count); } if ($is_editmode == true and $this->isolate_by_html_id == false and !isset($_REQUEST['isolate_content_field'])) { if ($is_admin == true) { $tb = mw_includes_path() . DS . 'toolbar' . DS . 'toolbar.php'; $layout_toolbar = new \Microweber\View($tb); $is_editmode_basic = false; $user_data = $this->app->user_manager->get(); if (isset($user_data['basic_mode']) and trim($user_data['basic_mode'] == 'y')) { $is_editmode_basic = true; } if (isset($is_editmode_basic) and $is_editmode_basic == true) { $layout_toolbar->assign('basic_mode', true); } else { $layout_toolbar->assign('basic_mode', false); } event_trigger('mw.live_edit'); $layout_toolbar = $layout_toolbar->__toString(); if ($layout_toolbar != '') { $layout_toolbar = $this->app->parser->process($layout_toolbar, $options = array('no_apc' => 1)); $c = 1; $l = str_ireplace('</body>', $layout_toolbar . '</body>', $l, $c); } $custom_live_edit = TEMPLATES_DIR . DS . TEMPLATE_NAME . DS . 'live_edit.php'; $custom_live_edit = normalize_path($custom_live_edit, false); if (is_file($custom_live_edit)) { $layout_live_edit = new \Microweber\View($custom_live_edit); $layout_live_edit = $layout_live_edit->__toString(); if ($layout_live_edit != '') { $l = str_ireplace('</body>', $layout_live_edit . '</body>', $l, $c); } } } } elseif ($is_editmode == false and $is_admin == true and mw()->user_manager->session_id() and !(mw()->user_manager->session_all() == false) and mw()->user_manager->session_get('back_to_editmode')) { if (!isset($_REQUEST['isolate_content_field']) and !isset($_REQUEST['content_id'])) { $back_to_editmode = $this->app->user_manager->session_get('back_to_editmode'); if ($back_to_editmode == true) { $tb = mw_includes_path() . DS . 'toolbar' . DS . 'toolbar_back.php'; $layout_toolbar = new \Microweber\View($tb); $layout_toolbar = $layout_toolbar->__toString(); if ($layout_toolbar != '') { $layout_toolbar = $this->app->parser->process($layout_toolbar, $options = array('no_apc' => 1)); $c = 1; $l = str_ireplace('</body>', $layout_toolbar . '</body>', $l, $c); } } } } $l = str_replace('{TEMPLATE_URL}', TEMPLATE_URL, $l); $l = str_replace('{THIS_TEMPLATE_URL}', THIS_TEMPLATE_URL, $l); $l = str_replace('{DEFAULT_TEMPLATE_URL}', DEFAULT_TEMPLATE_URL, $l); $l = str_replace('%7BTEMPLATE_URL%7D', TEMPLATE_URL, $l); $l = str_replace('%7BTHIS_TEMPLATE_URL%7D', THIS_TEMPLATE_URL, $l); $l = str_replace('%7BDEFAULT_TEMPLATE_URL%7D', DEFAULT_TEMPLATE_URL, $l); $meta = array(); $meta['content_image'] = ''; $meta['description'] = ''; if (is_home()) { $meta['content_url'] = site_url(); } else { $meta['content_url'] = $this->app->url_manager->current(1); } $meta['og_description'] = $this->app->option_manager->get('website_description', 'website'); $meta['og_type'] = 'website'; $meta_content_id = PAGE_ID; if (CONTENT_ID > 0) { $meta_content_id = CONTENT_ID; } if ($meta_content_id > 0) { $meta = $this->app->content_manager->get_by_id($meta_content_id); $content_image = $this->app->media_manager->get_picture($meta_content_id); if ($content_image) { $meta['content_image'] = $content_image; } else { $meta['content_image'] = ''; } $meta['content_url'] = $this->app->content_manager->link($meta_content_id); $meta['og_type'] = $meta['content_type']; if ($meta['og_type'] != 'page' and trim($meta['subtype']) != '') { $meta['og_type'] = $meta['subtype']; } if ($meta['description'] != false and trim($meta['description']) != '') { $meta['description'] = $meta['description']; } elseif ($meta['content'] != false and trim($meta['content']) != '') { $meta['description'] = str_replace("\n", ' ', $this->app->format->limit($this->app->format->clean_html(strip_tags($meta['content'])), 500)); } if (isset($meta['description']) and $meta['description'] != '') { $meta['og_description'] = $meta['description']; } else { $meta['og_description'] = trim($this->app->format->limit($this->app->format->clean_html(strip_tags($meta['content'])), 500)); } } else { $meta['title'] = $this->app->option_manager->get('website_title', 'website'); $meta['description'] = $this->app->option_manager->get('website_description', 'website'); $meta['content_meta_keywords'] = $this->app->option_manager->get('website_keywords', 'website'); } $meta['og_site_name'] = $this->app->option_manager->get('website_title', 'website'); if (!empty($meta)) { if (isset($meta['content_meta_title']) and $meta['content_meta_title'] != '') { $meta['title'] = $meta['content_meta_title']; } elseif (isset($meta['title']) and $meta['title'] != '') { } else { $meta['title'] = $this->app->option_manager->get('website_title', 'website'); } if (isset($meta['description']) and $meta['description'] != '') { } else { $meta['description'] = $this->app->option_manager->get('website_description', 'website'); } if (isset($meta['description']) and $meta['description'] != '') { $meta['content_meta_description'] = strip_tags($meta['description']); unset($meta['description']); } elseif (isset($meta['content']) and $meta['content'] != '') { $meta['content_meta_description'] = strip_tags($meta['content']); } elseif (isset($meta['title']) and $meta['title'] != '') { $meta['content_meta_description'] = strip_tags($meta['title']); } if (isset($meta['title']) and $meta['title'] != '') { $meta['content_meta_title'] = strip_tags($meta['title']); } elseif (isset($found_mod) and $found_mod != false) { $meta['content_meta_title'] = ucwords(str_replace('/', ' ', $found_mod)); } else { $meta['content_meta_title'] = ucwords(str_replace('/', ' ', $this->app->url_manager->segment(0))); } if (isset($meta['content_meta_keywords']) and $meta['content_meta_keywords'] != '') { } else { $meta['content_meta_keywords'] = $this->app->option_manager->get('website_keywords', 'website'); } if (is_array($meta)) { foreach ($meta as $key => $item) { if (is_string($item)) { $item = html_entity_decode($item); $item = strip_tags($item); $item = str_replace('&zwnj;', ' ', $item); $item = str_replace('"', ' ', $item); $item = str_replace("'", ' ', $item); $item = str_replace('>', '', $item); $item = str_replace('&quot;', ' ', $item); $item = str_replace('quot;', ' ', $item); $item = str_replace('&', ' ', $item); $item = str_replace('amp;', ' ', $item); $item = str_replace('nbsp;', ' ', $item); $item = str_replace('#039;', ' ', $item); $item = str_replace('&nbsp;', ' ', $item); $item = str_replace('&', ' ', $item); $item = str_replace(';', ' ', $item); $item = str_replace(' ', ' ', $item); $item = str_replace(' ', ' ', $item); $l = str_replace('{' . $key . '}', $item, $l); } elseif ($item == false) { $l = str_replace('{' . $key . '}', '', $l); } } } } if ($page != false and empty($this->page)) { $this->page = $page; } $l = execute_document_ready($l); event_trigger('frontend'); $is_embed = $this->app->url_manager->param('embed'); if ($is_embed != false) { $this->isolate_by_html_id = $is_embed; } if ($this->isolate_by_html_id != false) { $id_sel = $this->isolate_by_html_id; $this->isolate_by_html_id = false; require_once MW_PATH . 'Utils' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'phpQuery.php'; $pq = \phpQuery::newDocument($l); foreach ($pq['#' . $id_sel] as $elem) { $l = pq($elem)->htmlOuter(); } } if (mw()->user_manager->session_id() and !(mw()->user_manager->session_all() == false) and $is_editmode) { session_set('last_content_id', CONTENT_ID); } if ($output_cache_timeout != false) { $this->app->cache_manager->save($l, $output_cache_id, $output_cache_group); } if (isset($_REQUEST['debug'])) { if ($this->app->make('config')->get('app.debug')) { $is_admin = $this->app->user_manager->is_admin(); if ($is_admin == true) { include mw_includes_path() . 'debug.php'; } } } if ($show_404_to_non_admin) { $response = \Response::make($l); $response->setStatusCode(404); return $response; } return $l; } else { echo 'Error! Page is not found? Please login in the admin and make a page.'; $this->app->cache_manager->clear(); return; } }
private function install_from_market($item) { if (isset($item['url']) and !isset($item['download'])) { $item['download'] = $item['url']; } elseif (isset($item['download_url']) and !isset($item['download'])) { $item['download'] = $item['download_url']; } $download_target = false; if (isset($item['download']) and !isset($item['size'])) { $url = $item['download']; $download_target = $this->temp_dir . md5($url) . basename($url); $download_target_extract_lock = $this->temp_dir . md5($url) . basename($url) . '.unzip_lock'; $this->_log_msg('Downloading from marketplace'); //if (!is_file($download_target)){ $dl = $this->http()->url($url)->download($download_target); //} } else { if (isset($item['download']) and isset($item['size'])) { $expected = intval($item['size']); $download_link = $item['download']; $ext = get_file_extension($download_link); if ($ext != 'zip') { return; } if ($download_link != false and $expected > 0) { $text = $download_link; $regex = '/\\b((?:[\\w\\d]+\\:\\/\\/)?(?:[\\w\\-\\d]+\\.)+[\\w\\-\\d]+(?:\\/[\\w\\-\\d]+)*(?:\\/|\\.[\\w\\-\\d]+)?(?:\\?[\\w\\-\\d]+\\=[\\w\\-\\d]+\\&?)?(?:\\#[\\w\\-\\d]*)?)\\b/'; preg_match_all($regex, $text, $matches, PREG_SET_ORDER); foreach ($matches as $match) { if (isset($match[0])) { $url = $download_link; $download_target = $this->temp_dir . basename($download_link); $download_target_extract_lock = $this->temp_dir . basename($download_link) . '.unzip_lock'; $expectd_item_size = $item['size']; if (!is_file($download_target) or filesize($download_target) != $item['size']) { $dl = $this->http()->url($url)->download($download_target); if ($dl == false) { if (is_file($download_target) and filesize($download_target) != $item['size']) { $fs = filesize($download_target); return array('size' => $fs, 'expected_size' => $expected, 'try_again' => "true", 'warning' => "Only " . $fs . ' bytes downloaded of total ' . $expected); } } } } } } } } if ($download_target != false and is_file($download_target)) { $where_to_unzip = MW_ROOTPATH; if (isset($item['item_type'])) { if ($item['item_type'] == 'module') { $where_to_unzip = modules_path(); } elseif ($item['item_type'] == 'module_template') { $where_to_unzip = modules_path(); } elseif ($item['item_type'] == 'template') { $where_to_unzip = templates_path(); } elseif ($item['item_type'] == 'element') { $where_to_unzip = elements_path(); } if (isset($item['install_path']) and $item['install_path'] != false) { if ($item['item_type'] == 'module_template') { $where_to_unzip = $where_to_unzip . DS . $item['install_path'] . DS . 'templates' . DS; } else { $where_to_unzip = $where_to_unzip . DS . $item['install_path']; } } $where_to_unzip = str_replace('..', '', $where_to_unzip); $where_to_unzip = normalize_path($where_to_unzip, true); $this->_log_msg('Unzipping in ' . $where_to_unzip); $unzip = new \Microweber\Utils\Unzip(); $target_dir = $where_to_unzip; $result = $unzip->extract($download_target, $target_dir, $preserve_filepath = true); $new_composer = $target_dir . 'composer.json'; if (is_file($new_composer)) { // $this->composer_merge($new_composer); } $num_files = count($result); return array('files' => $result, 'location' => $where_to_unzip, 'success' => "Item is installed. {$num_files} files extracted in {$where_to_unzip}"); } } }
public function index() { $is_installed = mw_is_installed(); if (!$is_installed) { App::abort(403, 'Unauthorized action. Microweber MUST be installed to use modules.'); } if (!defined('MW_API_CALL')) { // define('MW_API_CALL', true); } if (!defined('MW_NO_SESSION')) { $is_ajax = $this->app->url_manager->is_ajax(); if (!mw()->user_manager->session_id() and $is_ajax == false) { if (!defined('MW_SESS_STARTED')) { define('MW_SESS_STARTED', true); // //session_start(); } } $editmode_sess = $this->app->user_manager->session_get('editmode'); if ($editmode_sess == true and !defined('IN_EDIT')) { define('IN_EDIT', true); } } $page = false; $custom_display = false; if (isset($_REQUEST['data-display']) and $_REQUEST['data-display'] == 'custom') { $custom_display = true; } if (isset($_REQUEST['data-module-name'])) { $_REQUEST['module'] = $_REQUEST['data-module-name']; $_REQUEST['data-type'] = $_REQUEST['data-module-name']; if (!isset($_REQUEST['id'])) { $_REQUEST['id'] = $this->app->url_manager->slug($_REQUEST['data-module-name'] . '-' . date('YmdHis')); } } if (isset($_REQUEST['data-type'])) { $_REQUEST['module'] = $_REQUEST['data-type']; } if (isset($_REQUEST['display']) and $_REQUEST['display'] == 'custom') { $custom_display = true; } if (isset($_REQUEST['view']) and $_REQUEST['view'] == 'admin') { $custom_display = false; } if ($custom_display == true) { $custom_display_id = false; if (isset($_REQUEST['id'])) { $custom_display_id = $_REQUEST['id']; } if (isset($_REQUEST['data-id'])) { $custom_display_id = $_REQUEST['data-id']; } } if (isset($_REQUEST['from_url'])) { $from_url = $_REQUEST['from_url']; } elseif (isset($_SERVER['HTTP_REFERER'])) { $from_url = $_SERVER['HTTP_REFERER']; } if (isset($from_url) and $from_url != false) { if (stristr($from_url, 'editor_tools/wysiwyg')) { if (!defined('IN_EDITOR_TOOLS')) { define('IN_EDITOR_TOOLS', true); } } $url = $from_url; $from_url2 = str_replace('#', '/', $from_url); $content_id = $this->app->url_manager->param('content_id', false, $from_url2); if ($content_id == false) { $content_id = $this->app->url_manager->param('editpage', false, $from_url2); } if ($content_id == false) { $content_id = $this->app->url_manager->param('editpost', false, $from_url2); } if ($content_id == false) { $content_id = $this->app->url_manager->param('mw-adm-content-id', false, $from_url2); } if ($content_id == false) { $action_test = $this->app->url_manager->param('action', false, $from_url2); if ($action_test != false) { $action_test = str_ireplace('editpage:', '', $action_test); $action_test = str_ireplace('editpost:', '', $action_test); $action_test = str_ireplace('edit:', '', $action_test); $action_test = intval($action_test); if ($action_test != 0) { $content_id = $action_test; $this->app->content_manager->define_constants(array('id' => $content_id)); } } } if (strpos($url, '#')) { $url = substr($url, 0, strpos($url, '#')); } //$url = $_SERVER["HTTP_REFERER"]; $url = explode('?', $url); $url = $url[0]; if ($content_id != false) { $page = array(); $page['id'] = $content_id; if ($content_id) { $page = $this->app->content_manager->get_by_id($content_id); $url = $page['url']; } } else { if (trim($url) == '' or trim($url) == $this->app->url_manager->site()) { //var_dump($from_url); //$page = $this->app->content_manager->get_by_url($url); $page = $this->app->content_manager->homepage(); if (!defined('IS_HOME')) { define('IS_HOME', true); } if (isset($from_url2)) { $mw_quick_edit = $this->app->url_manager->param('mw_quick_edit', false, $from_url2); if ($mw_quick_edit) { $page = false; } } } else { if (!stristr($url, admin_url())) { $page = $this->app->content_manager->get_by_url($url); } else { $page = false; if (!defined('PAGE_ID')) { define('PAGE_ID', false); } if (!defined('POST_ID')) { define('POST_ID', false); } if (!defined('CONTENT_ID')) { define('CONTENT_ID', false); } } } } } else { $url = $this->app->url_manager->string(); } if (!defined('IS_HOME')) { if (isset($page['is_home']) and $page['is_home'] == 'y') { define('IS_HOME', true); } } if ($page == false) { if (!isset($content_id)) { return; } $this->app->content_manager->define_constants(array('id' => $content_id)); } else { $this->app->content_manager->define_constants($page); } if (defined('TEMPLATE_DIR')) { $load_template_functions = TEMPLATE_DIR . 'functions.php'; if (is_file($load_template_functions)) { include_once $load_template_functions; } } if ($custom_display == true) { $u2 = $this->app->url_manager->site(); $u1 = str_replace($u2, '', $url); $this->render_this_url = $u1; $this->isolate_by_html_id = $custom_display_id; $this->index(); exit; } $url_last = false; if (!isset($_REQUEST['module'])) { $url = $this->app->url_manager->string(0); if ($url == __FUNCTION__) { $url = $this->app->url_manager->string(0); } /* $is_ajax = $this->app->url_manager->is_ajax(); if ($is_ajax == true) { $url = $this->app->url_manager->string(true); }*/ $url = $this->app->format->replace_once('module/', '', $url); $url = $this->app->format->replace_once('module_api/', '', $url); $url = $this->app->format->replace_once('m/', '', $url); if (is_module($url)) { $_REQUEST['module'] = $url; $mod_from_url = $url; } else { $url1 = $url_temp = explode('/', $url); $url_last = array_pop($url_temp); $try_intil_found = false; $temp1 = array(); foreach ($url_temp as $item) { $temp1[] = implode('/', $url_temp); $url_laset = array_pop($url_temp); } $i = 0; foreach ($temp1 as $item) { if ($try_intil_found == false) { if (is_module($item)) { $url_tempx = explode('/', $url); $_REQUEST['module'] = $item; $url_prev = $url_last; $url_last = array_pop($url_tempx); $url_prev = array_pop($url_tempx); // d($url_prev); $mod_from_url = $item; $try_intil_found = true; } } ++$i; } } } $module_info = $this->app->url_manager->param('module_info', true); if ($module_info) { if ($_REQUEST['module']) { $_REQUEST['module'] = str_replace('..', '', $_REQUEST['module']); $try_config_file = modules_path() . '' . $_REQUEST['module'] . '_config.php'; $try_config_file = normalize_path($try_config_file, false); if (is_file($try_config_file)) { include $try_config_file; if (!isset($config) or !is_array($config)) { return false; } if (!isset($config['icon']) or $config['icon'] == false) { $config['icon'] = modules_path() . '' . $_REQUEST['module'] . '.png'; $config['icon'] = $this->app->url_manager->link_to_file($config['icon']); } echo json_encode($config); exit; } } } $admin = $this->app->url_manager->param('admin', true); $mod_to_edit = $this->app->url_manager->param('module_to_edit', true); $embed = $this->app->url_manager->param('embed', true); $mod_iframe = false; if ($mod_to_edit != false) { $mod_to_edit = str_ireplace('_mw_slash_replace_', '/', $mod_to_edit); $mod_iframe = true; } //$data = $_REQUEST; if ($_POST) { $data = $_POST; } else { $url = $this->app->url_manager->segment(); if (!empty($url)) { foreach ($url as $k => $v) { $kv = explode(':', $v); if (isset($kv[0]) and isset($kv[1])) { $data[$kv[0]] = $kv[1]; } } } } $tags = false; $mod_n = false; if (isset($data['type']) != false) { if (trim($data['type']) != '') { $mod_n = $data['data-type'] = $data['type']; } } if (isset($data['data-module-name'])) { $mod_n = $data['data-type'] = $data['data-module-name']; unset($data['data-module-name']); } if (isset($data['data-type']) != false) { $mod_n = $data['data-type']; } if (isset($data['data-module']) != false) { if (trim($data['data-module']) != '') { $mod_n = $data['module'] = $data['data-module']; } } if (isset($data['module'])) { $mod_n = $data['data-type'] = $data['module']; unset($data['module']); } if (isset($data['type'])) { $mod_n = $data['data-type'] = $data['type']; unset($data['type']); } if (isset($data['data-type']) != false) { $data['data-type'] = rtrim($data['data-type'], '/'); $data['data-type'] = rtrim($data['data-type'], '\\'); $data['data-type'] = str_replace('__', '/', $data['data-type']); } if (!isset($data)) { $data = $_REQUEST; } if (!isset($data['module']) and isset($mod_from_url) and $mod_from_url != false) { $data['module'] = $mod_from_url; } if (!isset($data['id']) and isset($_REQUEST['id']) == true) { $data['id'] = $_REQUEST['id']; } if (isset($data['ondrop'])) { if (!defined('MW_MODULE_ONDROP')) { define('MW_MODULE_ONDROP', true); } unset($data['ondrop']); } if ($mod_n == 'layout') { if (isset($data['template'])) { $t = str_replace('..', '', $data['template']); $possible_layout = templates_path() . $t; $possible_layout = normalize_path($possible_layout, false); if (is_file($possible_layout)) { $l = new \Microweber\View($possible_layout); $layout = $l->__toString(); $layout = $this->app->parser->process($layout, $options = false); echo $layout; return; } } } $has_id = false; if (isset($data) and is_array($data)) { foreach ($data as $k => $v) { if ($k != 'ondrop') { if ($k == 'id') { $has_id = true; } if (is_array($v)) { $v1 = $this->app->format->array_to_base64($v); $tags .= "{$k}=\"{$v1}\" "; } else { $v = $this->app->format->clean_html($v); //$v = $this->app->database_manager->escape_string($v); $tags .= "{$k}=\"{$v}\" "; } } } } if ($has_id == false) { // $mod_n = $this->app->url_manager->slug($mod_n) . '-' . date("YmdHis"); // $tags .= "id=\"$mod_n\" "; } $tags = "<module {$tags} />"; $opts = array(); if ($_REQUEST) { $opts = $_REQUEST; } if (isset($_REQUEST['live_edit'])) { event_trigger('mw.live_edit'); } $opts['admin'] = $admin; if ($admin == 'admin') { event_trigger('mw_backend'); event_trigger('mw.admin'); } else { event_trigger('mw_frontend'); } // if (isset($_SERVER['HTTP_REFERER']) and $_SERVER['HTTP_REFERER'] != false) { $get_arr_from_ref = $_SERVER['HTTP_REFERER']; if (strstr($get_arr_from_ref, $this->app->url_manager->site())) { $get_arr_from_ref_arr = parse_url($get_arr_from_ref); if (isset($get_arr_from_ref_arr['query']) and $get_arr_from_ref_arr['query'] != '') { $restore_get = parse_str($get_arr_from_ref_arr['query'], $get_array); if (is_array($get_array)) { mw_var('mw_restore_get', $get_array); } // } } } $res = $this->app->parser->process($tags, $opts); $res = preg_replace('~<(?:!DOCTYPE|/?(?:html|head|body))[^>]*>\\s*~i', '', $res); if ($embed != false) { $p_index = mw_includes_path() . 'api/index.php'; $p_index = normalize_path($p_index, false); $l = new \Microweber\View($p_index); $layout = $l->__toString(); $res = str_replace('{content}', $res, $layout); } $aj = $this->app->url_manager->is_ajax(); if (isset($_REQUEST['live_edit']) and $aj == false) { $p_index = mw_includes_path() . DS . 'toolbar' . DS . 'editor_tools' . DS . 'module_settings' . DS . 'index.php'; $p_index = normalize_path($p_index, false); $l = new \Microweber\View($p_index); $l->params = $data; $layout = $l->__toString(); $res = str_replace('{content}', $res, $layout); $res = $this->app->parser->process($res, $options = false); } $res = execute_document_ready($res); if (!defined('MW_NO_OUTPUT')) { $res = $this->app->url_manager->replace_site_url_back($res); echo $res; } if ($url_last != __FUNCTION__) { if (function_exists($url_last)) { // $this->api($url_last); } elseif (isset($url_prev) and function_exists($url_prev)) { $this->api($url_last); } elseif (class_exists($url_last, false)) { $this->api($url_last); } elseif (isset($url_prev) and class_exists($url_prev, false)) { $this->api($url_prev); } } exit; }
/** * module_templates * * Gets all templates for a module * * @package modules * @subpackage functions * @category modules api */ public function templates($module_name, $template_name = false, $get_settings_file = false) { $module_name = str_replace('admin', '', $module_name); $module_name_l = $this->locate($module_name); if ($module_name_l == false) { $module_name_l = modules_path() . DS . $module_name . DS; $module_name_l = normalize_path($module_name_l, 1); } else { $module_name_l = dirname($module_name_l) . DS . 'templates' . DS; $module_name_l = normalize_path($module_name_l, 1); } $module_name_l_theme = ACTIVE_TEMPLATE_DIR . 'modules' . DS . $module_name . DS . 'templates' . DS; $module_name_l_theme = normalize_path($module_name_l_theme, 1); if (!is_dir($module_name_l) and !is_dir($module_name_l_theme)) { return false; } else { if ($template_name == false) { $options = array(); $options['for_modules'] = 1; $options['no_cache'] = 1; $options['path'] = $module_name_l; $module_name_l = $this->app->layouts_manager->scan($options); if (is_dir($module_name_l_theme)) { $options['path'] = $module_name_l_theme; $module_skins_from_theme = $this->app->layouts_manager->scan($options); if (is_array($module_skins_from_theme)) { if (!is_array($module_name_l)) { $module_name_l = array(); } $file_names_found = array(); if (is_array($module_skins_from_theme)) { $comb = array_merge($module_skins_from_theme, $module_name_l); if (is_array($comb) and !empty($comb)) { foreach ($comb as $k1 => $itm) { if (!in_array($itm['layout_file'], $file_names_found)) { if (isset($itm['visible'])) { if ($itm['visible'] == 'false' or $itm['visible'] == 'no' or $itm['visible'] == 'n') { // skip } else { $file_names_found[] = $itm['layout_file']; } } else { $file_names_found[] = $itm['layout_file']; } } else { unset($comb[$k1]); } } } $module_name_l = $comb; } } } return $module_name_l; } else { $template_name = str_replace('..', '', $template_name); $template_name_orig = $template_name; if ($get_settings_file == true) { $is_dot_php = get_file_extension($template_name); if ($is_dot_php != false and $is_dot_php == 'php') { $template_name = str_ireplace('.php', '', $template_name); } $template_name = $template_name . '_settings'; } $is_dot_php = get_file_extension($template_name); if ($is_dot_php != false and $is_dot_php != 'php') { $template_name = $template_name . '.php'; } $tf = $module_name_l . $template_name; $tf_theme = $module_name_l_theme . $template_name; $tf_from_other_theme = templates_path() . $template_name; $tf_from_other_theme = normalize_path($tf_from_other_theme, false); $tf_other_module = modules_path() . $template_name; $tf_other_module = normalize_path($tf_other_module, false); if (strstr($tf_from_other_theme, 'modules') and is_file($tf_from_other_theme)) { return $tf_from_other_theme; } else { if (is_file($tf_theme)) { return $tf_theme; } else { if (is_file($tf)) { return $tf; } else { if (strtolower($template_name_orig) != 'default' and is_file($tf_other_module)) { return $tf_other_module; } else { return false; } } } } } } }
</tr> <tr> <td>userfiles_folder</td> <td><?php print modules_url(); ?> </td> </tr> <tr> <td>site_url</td> <td><?php print site_url(); ?> </td> </tr> <tr> <td>templates_path</td> <td><?php print templates_path(); ?> </td> </tr> <tr> <td>templates_url</td> <td><?php print templates_url(); ?> </td> </tr> </table>
function template_save_css($params) { $is_admin = $this->app->user_manager->is_admin(); if ($is_admin == false) { return false; } if (is_string($params)) { $params = parse_params($params); } $ref_page = false; if (!isset($params['active_site_template'])) { if (!isset($params['content_id'])) { if (isset($_SERVER['HTTP_REFERER'])) { $ref_page_url = $_SERVER['HTTP_REFERER']; if ($ref_page_url != '') { $ref_page_url_rel = str_ireplace(site_url(), '', $ref_page_url); if ($ref_page_url_rel == '') { $ref_page1 = $this->app->content_manager->homepage(); } else { $ref_page1 = $this->app->content_manager->get_by_url($ref_page_url, true); } if (isset($ref_page1['id'])) { $ref_page = $this->app->content_manager->get_by_id(intval($ref_page1['id'])); } } } } else { $ref_page = $this->app->content_manager->get_by_id(intval($params['content_id'])); } if (isset($ref_page['id']) and isset($ref_page['content_type']) and $ref_page['content_type'] != 'page') { $ref_page_parent = $this->app->content_manager->get_by_id(intval($ref_page['id'])); if (isset($ref_page_partent['parent']) and intval($ref_page_partent['parent']) != 0) { $ref_page = $this->app->content_manager->get_by_id(intval($ref_page_partent['id'])); } else { $ref_page_parents = $this->app->content_manager->get_parents(intval($ref_page['id'])); if (!empty($ref_page_parents)) { $ref_page_parent = array_pop($ref_page_parents); $ref_page = $this->app->content_manager->get_by_id($ref_page_parent); } } } } else { $ref_page = $params; } if (!is_array($ref_page) or empty($ref_page)) { return false; } $pd = $ref_page; if ($is_admin == true and is_array($pd)) { $save_page = $pd; if (isset($save_page["layout_file"]) and $save_page["layout_file"] == 'inherit') { $inherit_from_id = $this->app->content_manager->get_inherited_parent($save_page["id"]); $inherit_from = $this->app->content_manager->get_by_id($inherit_from_id); if (is_array($inherit_from) and isset($inherit_from['active_site_template'])) { $save_page['active_site_template'] = $inherit_from['active_site_template']; $save_page['layout_file'] = $inherit_from['layout_file']; } } $template = false; if (!isset($save_page['active_site_template']) or $save_page['active_site_template'] == '') { $template = 'default'; } else { if (isset($save_page['active_site_template'])) { $template = $save_page['active_site_template']; } } if ($template == 'default') { $site_template_settings = $this->app->option_manager->get('current_template', 'template'); if ($site_template_settings != false and $site_template_settings != 'default') { $template = $site_template_settings; } } $final_file_blocks = array(); if ($template != false) { if (isset($_POST['save_template_settings'])) { $json = json_encode($_POST); $option = array(); $option['option_value'] = $json; $option['option_key'] = 'template_settings'; $option['option_group'] = 'template_' . $template; save_option($option); } $template_folder = templates_path() . $template . DS; $template_url = templates_url() . $template . '/'; $this_template_url = THIS_TEMPLATE_URL; $template_folder = userfiles_path() . 'css' . DS . $template . DS; if (!is_dir($template_folder)) { mkdir_recursive($template_folder); } $live_edit_css = $template_folder . 'live_edit.css'; $fcont = ''; if (is_file($live_edit_css)) { $fcont = file_get_contents($live_edit_css); } $css_cont = $fcont; $css_cont_new = $css_cont; //@import on top $sort_params = array(); $sort_params2 = array(); foreach ($params as $item) { if (isset($item['selector']) and trim($item['selector']) == '@import' and isset($item["value"])) { if ($item['value'] != 'reset') { $sort_params[] = $item; } } else { $sort_params2[] = $item; } } $params = array_merge($sort_params, $sort_params2); foreach ($params as $item) { $curr = ""; if (!isset($item["css"]) and isset($item["property"]) and isset($item['value'])) { if ($item['value'] == 'reset') { $item["css"] = 'reset'; } else { if (isset($item['selector']) and trim($item['selector']) == '@import' and isset($item["value"])) { $props = explode(',', $item['property']); foreach ($props as $prop) { $curr .= $prop . " " . $item['value'] . ";"; } } else { $props = explode(',', $item['property']); $curr = ""; foreach ($props as $prop) { if (isset($item["value"]) and trim($item["value"]) != '') { $curr .= $prop . ":" . $item['value'] . ";"; } } } if ($curr != '') { $item["css"] = $curr; } } } if (isset($item['selector']) and trim($item['selector']) != '' and isset($item["css"])) { $item["selector"] = str_ireplace('.element-current', '', $item["selector"]); $item["selector"] = str_ireplace('.mwfx', '', $item["selector"]); $item["selector"] = str_ireplace('.mw_image_resizer', '', $item["selector"]); $item["selector"] = str_ireplace('.ui-resizable', '', $item["selector"]); $item["selector"] = str_ireplace('.ui-draggable', '', $item["selector"]); $item["css"] = str_ireplace('background:url(;', '', $item["css"]); $item["css"] = str_ireplace('background:;', '', $item["css"]); $item["css"] = str_ireplace('background-image:url(;', '', $item["css"]); $item["css"] = str_ireplace('background-image: url("");', 'background-image: none;', $item["css"]); $sel = trim($item['selector']); $css = trim($item["css"]); if (trim($sel) != '' and strlen($sel) > 2 and strlen($css) > 2) { $delim = "\n /* {$sel} */ \n"; //$item["css"] = str_ireplace($this_template_url, '', $item["css"]); //$item["css"] = str_ireplace($template_url, '', $item["css"]); $item["css"] = str_ireplace('http://', '//', $item["css"]); $item["css"] = str_ireplace('https://', '//', $item["css"]); $is_existing = explode($delim, $css_cont_new); if (!empty($is_existing)) { $srings = $this->app->format->string_between($css_cont_new, $delim, $delim); if ($srings != false) { $css_cont_new = str_ireplace($srings, '', $css_cont_new); $css_cont_new = str_ireplace($delim, '', $css_cont_new); } } if (trim($item["css"]) != 'reset' and trim($item["css"]) != 'reset;') { $css_cont_new .= $delim; if (isset($sel) and trim($sel) == '@import') { $css_cont_new .= $sel . ' ' . $item["css"] . ' '; } else { $css_cont_new .= $sel . ' { ' . $item["css"] . ' }'; } $css_cont_new .= $delim; } } } } $resp = array(); $resp['url'] = $this->app->url_manager->link_to_file($live_edit_css); if ($css_cont_new != '' and $css_cont != $css_cont_new) { file_put_contents($live_edit_css, $css_cont_new); // print $css_cont_new; } $resp['content'] = $css_cont_new; return $resp; } } }
} ?> <?php } ?> <?php if (is_array($site_templates)) { ?> <?php foreach ($site_templates as $site_template) { ?> <?php if (isset($site_template['dir_name'])) { ?> <?php $template_dir = templates_path() . $site_template['dir_name']; $possible_dir = $template_dir . DS . 'modules' . DS . $mod_name . DS; $possible_dir = normalize_path($possible_dir, false); ?> <?php if (is_dir($possible_dir)) { ?> <?php $options = array(); $options['for_modules'] = 1; $options['path'] = $possible_dir; $templates = mw()->layouts_manager->get_all($options); ?> <?php if (is_array($templates)) { ?>
/** * Return the path to the layout file that will render the page * */ public function get_layout($page = array()) { $function_cache_id = ''; if (is_array($page)) { ksort($page); } $function_cache_id = $function_cache_id . serialize($page); $cache_id = __FUNCTION__ . crc32($function_cache_id); $cache_group = 'content/global'; if (!defined('ACTIVE_TEMPLATE_DIR')) { if (isset($page['id'])) { $this->app->content_manager->define_constants($page); } } $cache_content = false; // $cache_content = $this->app->cache_manager->get($cache_id, $cache_group); if ($cache_content != false) { // return $cache_content; } $override = $this->app->event_manager->trigger('mw.front.get_layout', $page); $render_file = false; $look_for_post = false; $template_view_set_inner = false; $fallback_render_internal_file = false; $site_template_settings = $this->app->option_manager->get('current_template', 'template'); if (!isset($page['active_site_template'])) { $page['active_site_template'] = 'default'; } elseif (isset($page['active_site_template']) and $page['active_site_template'] == '') { $page['active_site_template'] = $site_template_settings; } if ($page['active_site_template'] and ($page['active_site_template'] == 'default' or $page['active_site_template'] == 'mw_default')) { if ($site_template_settings != 'default' and $page['active_site_template'] == 'mw_default') { $page['active_site_template'] = 'default'; $site_template_settings = 'default'; } if ($site_template_settings != false) { $site_template_settings = str_replace('..', '', $site_template_settings); $site_template_settings_dir = TEMPLATES_DIR . $site_template_settings . DS; if (is_dir($site_template_settings_dir) != false) { $page['active_site_template'] = $site_template_settings; } } } if (isset($page['content_type'])) { $page['content_type'] = str_replace('..', '', $page['content_type']); } if (isset($page['subtype'])) { $page['subtype'] = str_replace('..', '', $page['subtype']); } if (isset($page['layout_file'])) { $page['layout_file'] = str_replace('..', '', $page['layout_file']); } if (isset($page['active_site_template'])) { $page['active_site_template'] = str_replace('..', '', $page['active_site_template']); } if (is_array($override)) { foreach ($override as $resp) { if (isset($resp['render_file']) and $resp['render_file'] != false) { $render_file = $resp['render_file']; } elseif (is_array($resp) and !empty($resp)) { $page = array_merge($page, $resp); } } } if ($render_file == false) { if (isset($page['active_site_template']) and isset($page['layout_file'])) { $page['layout_file'] = str_replace('___', DS, $page['layout_file']); $page['layout_file'] = str_replace('__', DS, $page['layout_file']); $page['layout_file'] = str_replace('..', '', $page['layout_file']); $template_d = $page['active_site_template']; if ($template_d == 'mw_default') { $template_d = 'default'; } $render_file_temp = normalize_path(TEMPLATES_DIR . $template_d . DS . $page['layout_file'], false); $render_use_default = normalize_path(TEMPLATES_DIR . $template_d . DS . 'use_default_layouts.php', false); $render_file_module_temp = modules_path() . DS . $page['layout_file']; $render_file_module_temp = normalize_path($render_file_module_temp, false); if (is_file($render_file_temp)) { $render_file = $render_file_temp; } elseif (is_file($render_file_module_temp)) { $render_file = $render_file_module_temp; } elseif (is_file($render_use_default)) { $render_file_temp = DEFAULT_TEMPLATE_DIR . $page['layout_file']; if (is_file($render_file_temp)) { $render_file = $render_file_temp; } } } } if ($render_file == false and isset($page['content_type']) and isset($page['parent']) and $page['content_type'] != 'page') { $get_layout_from_parent = false; $par = $this->app->content_manager->get_by_id($page['parent']); if (isset($par['layout_file']) and $par['layout_file'] != '' and $par['layout_file'] != 'inherit') { $get_layout_from_parent = $par; } elseif (isset($par['is_home']) and isset($par['active_site_template']) and (!isset($par['layout_file']) or $par['layout_file'] == '') and $par['is_home'] == 'y') { $par['layout_file'] = 'index.php'; $get_layout_from_parent = $par; } else { $inh = $this->app->content_manager->get_inherited_parent($page['parent']); if ($inh != false) { $par = $this->app->content_manager->get_by_id($inh); if (isset($par['active_site_template']) and isset($par['layout_file']) and $par['layout_file'] != '') { $get_layout_from_parent = $par; } else { if (isset($par['active_site_template']) and isset($par['is_home']) and $par['is_home'] == 'y' and (!isset($par['layout_file']) or $par['layout_file'] == '')) { $par['layout_file'] = 'index.php'; $get_layout_from_parent = $par; } } } } if (isset($get_layout_from_parent['layout_file'])) { if (!isset($get_layout_from_parent['active_site_template'])) { $get_layout_from_parent['active_site_template'] = 'default'; } if ($get_layout_from_parent['active_site_template'] == 'default') { $get_layout_from_parent['active_site_template'] = $site_template_settings; } if ($get_layout_from_parent['active_site_template'] == 'mw_default') { $get_layout_from_parent['active_site_template'] = 'default'; } $get_layout_from_parent['layout_file'] = str_replace('___', DS, $get_layout_from_parent['layout_file']); $get_layout_from_parent['layout_file'] = str_replace('..', '', $get_layout_from_parent['layout_file']); $render_file_temp = TEMPLATES_DIR . $get_layout_from_parent['active_site_template'] . DS . $get_layout_from_parent['layout_file']; $render_use_default = TEMPLATES_DIR . $get_layout_from_parent['active_site_template'] . DS . 'use_default_layouts.php'; $render_file_temp = normalize_path($render_file_temp, false); $render_use_default = normalize_path($render_use_default, false); $render_file_module_temp = modules_path() . DS . $get_layout_from_parent['layout_file']; $render_file_module_temp = normalize_path($render_file_module_temp, false); //if (!isset($page['content_type']) or $page['content_type'] == 'page') { if (is_file($render_file_temp)) { $render_file = $render_file_temp; } elseif (is_file($render_use_default)) { $render_file_temp = DEFAULT_TEMPLATE_DIR . $get_layout_from_parent['layout_file']; if (is_file($render_file_temp)) { $render_file = $render_file_temp; } } elseif (is_file($render_file_module_temp)) { $render_file = $render_file_module_temp; } } } if ($render_file == false and !isset($page['active_site_template']) and isset($page['layout_file'])) { $test_file = str_replace('___', DS, $page['layout_file']); $test_file = str_replace('..', '', $test_file); $render_file_temp = $test_file; $render_file_temp = normalize_path($render_file_temp, false); if (is_file($render_file_temp)) { $render_file = $render_file_temp; } } if ($render_file == false and isset($page['active_site_template']) and isset($page['active_site_template']) and isset($page['layout_file']) and $page['layout_file'] != 'inherit' and $page['layout_file'] != '') { $test_file = str_replace('___', DS, $page['layout_file']); $test_file = str_replace('..', '', $test_file); $render_file_temp = TEMPLATES_DIR . $page['active_site_template'] . DS . $test_file; $render_file_module_temp = modules_path() . DS . $test_file; $render_file_module_temp = normalize_path($render_file_module_temp, false); if (is_file($render_file_temp)) { $render_file = $render_file_temp; } elseif (is_file($render_file_module_temp)) { $render_file = $render_file_module_temp; } } if ($render_file == false and isset($page['id']) and intval($page['id']) == 0) { $url_file = $this->app->url_manager->string(1, 1); $test_file = str_replace('___', DS, $url_file); $render_file_temp = ACTIVE_TEMPLATE_DIR . DS . $test_file . '.php'; $render_file_temp2 = ACTIVE_TEMPLATE_DIR . DS . $url_file . '.php'; if (is_file($render_file_temp)) { $render_file = $render_file_temp; } elseif (is_file($render_file_temp2)) { $render_file = $render_file_temp2; } } if (isset($page['active_site_template']) and $page['active_site_template'] == 'default') { $page['active_site_template'] = $site_template_settings; } if (isset($page['active_site_template']) and $page['active_site_template'] != 'default' and $page['active_site_template'] == 'mw_default') { $page['active_site_template'] = 'default'; } if ($render_file == false and isset($page['id']) and isset($page['active_site_template']) and isset($page['layout_file']) and $page['layout_file'] != 'inherit') { $render_file_temp = TEMPLATES_DIR . $page['active_site_template'] . DS . $page['layout_file']; $render_file_temp = normalize_path($render_file_temp, false); if (is_file($render_file_temp)) { $render_file = $render_file_temp; } else { $render_file_temp = DEFAULT_TEMPLATE_DIR . $page['layout_file']; if (is_file($render_file_temp)) { $render_file = $render_file_temp; } } } if ($render_file == false and isset($page['id']) and isset($page['active_site_template']) and (!isset($page['layout_file']) or isset($page['layout_file']) and $page['layout_file'] == 'inherit' or $page['layout_file'] == false)) { $inherit_from = $this->app->content_manager->get_parents($page['id']); $found = 0; if ($inherit_from == false) { if (isset($page['parent']) and $page['parent'] != false) { $par_test = $this->app->content_manager->get_by_id($page['parent']); if (is_array($par_test)) { $inherit_from = array(); if (isset($page['layout_file']) and $page['layout_file'] != 'inherit') { $inherit_from[] = $page['parent']; } else { $inh = $this->app->content_manager->get_inherited_parent($page['parent']); $inherit_from[] = $inh; } } } } if (!empty($inherit_from)) { foreach ($inherit_from as $value) { if ($found == 0 and $value != $page['id']) { $par_c = $this->app->content_manager->get_by_id($value); if (isset($par_c['id']) and isset($par_c['active_site_template']) and isset($par_c['layout_file']) and $par_c['layout_file'] != 'inherit') { $page['layout_file'] = $par_c['layout_file']; $page['layout_file'] = str_replace('__', DS, $page['layout_file']); $page['active_site_template'] = $par_c['active_site_template']; $page['active_site_template'] = str_replace('..', '', $page['active_site_template']); if ($page['active_site_template'] == 'default') { $page['active_site_template'] = $site_template_settings; } if ($page['active_site_template'] != 'default' and $page['active_site_template'] == 'mw_default') { $page['active_site_template'] = 'default'; } $render_file_temp = TEMPLATES_DIR . $page['active_site_template'] . DS . $page['layout_file']; $render_file_temp = normalize_path($render_file_temp, false); $render_file_module_temp = modules_path() . DS . $page['layout_file']; $render_file_module_temp = normalize_path($render_file_module_temp, false); if (is_file($render_file_temp)) { $render_file = $render_file_temp; } elseif (is_file($render_file_module_temp)) { $render_file = $render_file_module_temp; } else { $render_file_temp = DEFAULT_TEMPLATE_DIR . $page['layout_file']; if (is_file($render_file_temp)) { $fallback_render_internal_file = $render_file_temp; } } $found = 1; } } } } } if ($render_file != false and (isset($page['content_type']) and $page['content_type'] != 'page')) { $f1 = $render_file; $f2 = $render_file; $stringA = $f1; $stringB = "_inner"; $length = strlen($stringA); $temp1 = substr($stringA, 0, $length - 4); $temp2 = substr($stringA, $length - 4, $length); $f1 = $temp1 . $stringB . $temp2; $f1 = normalize_path($f1, false); if (is_file($f1)) { $render_file = $f1; } else { $stringA = $f2; $stringB = '_' . $page['content_type']; $length = strlen($stringA); $temp1 = substr($stringA, 0, $length - 4); $temp2 = substr($stringA, $length - 4, $length); $f3 = $temp1 . $stringB . $temp2; $f3 = normalize_path($f3, false); if (is_file($f3)) { $render_file = $f3; } else { $found_subtype_layout = false; if (isset($page['subtype'])) { $stringA = $f2; $stringB = '_' . $page['subtype']; $length = strlen($stringA); $temp1 = substr($stringA, 0, $length - 4); $temp2 = substr($stringA, $length - 4, $length); $f3 = $temp1 . $stringB . $temp2; $f3 = normalize_path($f3, false); if (is_file($f3)) { $found_subtype_layout = true; $render_file = $f3; } } $check_inner = dirname($render_file); if ($found_subtype_layout == false and is_dir($check_inner)) { if (isset($page['subtype'])) { $stringA = $check_inner; $stringB = $page['subtype'] . '.php'; $length = strlen($stringA); $f3 = $stringA . DS . $stringB; $f3 = normalize_path($f3, false); if (is_file($f3)) { $found_subtype_layout = true; $render_file = $f3; } } if ($found_subtype_layout == false) { $in_file = $check_inner . DS . 'inner.php'; $in_file = normalize_path($in_file, false); $in_file2 = $check_inner . DS . $page['content_type'] . '.php'; $in_file2 = normalize_path($in_file2, false); if (is_file($in_file2)) { $render_file = $in_file2; } elseif (is_file($in_file)) { $render_file = $in_file; } } } } } } if ($render_file == false and isset($page['content_type']) and $page['content_type'] != false and $page['content_type'] != '') { $look_for_post = $page; if (isset($page['parent'])) { $par_page = false; $inh_par_page = $this->app->content_manager->get_inherited_parent($page['parent']); if ($inh_par_page != false) { $par_page = $this->app->content_manager->get_by_id($inh_par_page); } else { $par_page = $this->app->content_manager->get_by_id($page['parent']); } if (is_array($par_page)) { if (isset($par_page['active_site_template']) and $par_page['active_site_template'] != false) { $page['active_site_template'] = $par_page['active_site_template']; } if (isset($par_page['layout_file']) and $par_page['layout_file'] != false) { //$page['layout_file'] = $par_page['layout_file']; } } else { $template_view_set_inner = ACTIVE_TEMPLATE_DIR . DS . 'inner.php'; $template_view_set_inner2 = ACTIVE_TEMPLATE_DIR . DS . 'layouts/inner.php'; } } else { $template_view_set_inner = ACTIVE_TEMPLATE_DIR . DS . 'inner.php'; $template_view_set_inner2 = ACTIVE_TEMPLATE_DIR . DS . 'layouts/inner.php'; } } if ($render_file == false and isset($page['simply_a_file'])) { $simply_a_file2 = ACTIVE_TEMPLATE_DIR . $page['simply_a_file']; $simply_a_file3 = ACTIVE_TEMPLATE_DIR . 'layouts' . DS . $page['simply_a_file']; if ($render_file == false and is_file($simply_a_file3) == true) { $render_file = $simply_a_file3; } if ($render_file == false and is_file($simply_a_file2) == true) { $render_file = $simply_a_file2; } if ($render_file == false and is_file($page['simply_a_file']) == true) { $render_file = $page['simply_a_file']; } } if (!isset($page['active_site_template'])) { $page['active_site_template'] = ACTIVE_SITE_TEMPLATE; } if ($render_file == false and isset($page['active_site_template']) and trim($page['active_site_template']) != 'default') { $use_default_layouts = TEMPLATES_DIR . $page['active_site_template'] . DS . 'use_default_layouts.php'; if (is_file($use_default_layouts)) { $page['active_site_template'] = 'default'; } } if ($render_file == false and isset($page['content_type']) and $page['content_type'] == 'page' and isset($page['layout_file']) and trim($page['layout_file']) == 'inherit') { $use_index = TEMPLATE_DIR . DS . 'clean.php'; $use_index2 = TEMPLATE_DIR . DS . 'layouts/clean.php'; $use_index = normalize_path($use_index, false); $use_index2 = normalize_path($use_index2, false); if (is_file($use_index)) { $render_file = $use_index; } elseif (is_file($use_index2)) { $render_file = $use_index2; } } // if ($render_file == false and isset($page['active_site_template']) and isset($page['layout_file']) and trim($page['layout_file']) == '') { // $use_index = TEMPLATES_DIR . $page['active_site_template'] . DS . 'index.php'; // if (is_file($use_index)) { // $render_file = $use_index; // } // } if ($render_file == false and isset($page['active_site_template']) and $page['active_site_template'] == 'default') { $page['active_site_template'] = ACTIVE_SITE_TEMPLATE; } if ($render_file == false and isset($page['active_site_template']) and isset($page['content_type']) and isset($page['layout_file'])) { $page['active_site_template'] = trim(str_replace('..', '', $page['active_site_template'])); $page['layout_file'] = str_replace('__', DS, $page['layout_file']); $page['layout_file'] = trim(urldecode(str_replace('..', '', $page['layout_file']))); $page['layout_file'] = str_replace('\\', '/', $page['layout_file']); $render_file_test = TEMPLATES_DIR . $page['active_site_template'] . DS . $page['layout_file']; $render_file_test = normalize_path($render_file_test, false); if (is_file($render_file_test)) { $render_file = $render_file_test; } } if ($render_file == false and isset($page['active_site_template']) and isset($page['layout_file'])) { if (isset($page['content_type']) and $page['content_type'] == 'page') { $look_for_post = false; } $page['layout_file'] = str_replace('__', DS, $page['layout_file']); if ($look_for_post != false) { $f1 = $page['layout_file']; $stringA = $f1; $stringB = "_inner"; $length = strlen($stringA); $temp1 = substr($stringA, 0, $length - 4); $temp2 = substr($stringA, $length - 4, $length); $f1 = $temp1 . $stringB . $temp2; if (strtolower($page['active_site_template']) == 'default') { $template_view = ACTIVE_TEMPLATE_DIR . DS . $f1; } else { $template_view = TEMPLATES_DIR . $page['active_site_template'] . DS . $f1; } if (is_file($template_view) == true) { $render_file = $template_view; } else { $dn = dirname($template_view); $dn1 = $dn . DS; $f1 = $dn1 . 'inner.php'; if (is_file($f1) == true) { $render_file = $f1; } else { $dn = dirname($dn); $dn1 = $dn . DS; $f1 = $dn1 . 'inner.php'; if (is_file($f1) == true) { $render_file = $f1; } else { $dn = dirname($dn); $dn1 = $dn . DS; $f1 = $dn1 . 'inner.php'; if (is_file($f1) == true) { $render_file = $f1; } } } } } if ($render_file == false) { if (strtolower($page['active_site_template']) == 'default') { $template_view = ACTIVE_TEMPLATE_DIR . DS . $page['layout_file']; } else { $template_view = TEMPLATES_DIR . $page['active_site_template'] . DS . $page['layout_file']; } if (is_file($template_view) == true) { $render_file = $template_view; } else { if (trim($page['active_site_template']) != 'default') { $use_default_layouts = TEMPLATES_DIR . $page['active_site_template'] . DS . 'use_default_layouts.php'; if (is_file($use_default_layouts)) { $page['active_site_template'] = 'default'; } } } } } if ($render_file == false and (!isset($page['layout_file']) or $page['layout_file'] == false) and isset($page['url']) and $page['url'] != '') { $page['url'] = trim(str_replace('..', '', $page['url'])); $template_view = ACTIVE_TEMPLATE_DIR . strtolower($page['url']) . '.php'; if (is_file($template_view) == true) { $render_file = $template_view; } } if ($render_file == false and isset($page['subtype']) and $page['subtype'] != '') { $page['subtype'] = trim(str_replace('..', '', $page['subtype'])); $template_view = ACTIVE_TEMPLATE_DIR . strtolower($page['subtype']) . '.php'; if (is_file($template_view) == true) { $render_file = $template_view; } } if ($render_file == false and isset($page['content_type']) and $page['content_type'] != '') { $page['content_type'] = trim(str_replace('..', '', $page['content_type'])); $template_view = ACTIVE_TEMPLATE_DIR . strtolower($page['content_type']) . '.php'; if (is_file($template_view) == true) { $render_file = $template_view; } } if (isset($page['active_site_template']) and $render_file == false and (strtolower($page['active_site_template']) == 'default' or $page['active_site_template'] == $site_template_settings)) { if ($render_file == false and isset($page['active_site_template']) and isset($page['id'])) { if (isset($look_for_post) and $look_for_post != false) { if (isset($look_for_post['content_type'])) { $ct = str_replace('..', '', $look_for_post['content_type']); $template_view = ACTIVE_TEMPLATE_DIR . $ct . '.php'; if ($render_file == false and is_file($template_view) == true) { $render_file = $template_view; } } $template_view = ACTIVE_TEMPLATE_DIR . 'index_inner.php'; if ($render_file == false and is_file($template_view) == true) { $render_file = $template_view; } if (isset($look_for_post['content_type']) and $look_for_post['content_type'] != 'page') { $template_view = ACTIVE_TEMPLATE_DIR . 'inner.php'; if ($render_file == false and is_file($template_view) == true) { $render_file = $template_view; } } } } // if ($render_file == false and isset($page['parent']) and $page['parent'] == 0) { if ($render_file == false and isset($page['layout_file']) and $page['layout_file'] == 'inherit') { $t_dir = ACTIVE_TEMPLATE_DIR; if (isset($page['active_site_template'])) { $t_dir = templates_path() . DS . $page['active_site_template'] . DS; $t_dir = normalize_path($t_dir, 1); } $template_view_cl = $t_dir . 'clean.php'; $template_view_cl2 = $t_dir . 'layouts/clean.php'; if ($render_file == false and is_file($template_view_cl) == true) { $render_file = $template_view_cl; } if ($render_file == false and is_file($template_view_cl2) == true) { $render_file = $template_view_cl2; } } } if ($render_file == false and isset($page['layout_file']) and $page['layout_file'] != false and $page['layout_file'] != 'index.php' and $page['layout_file'] != 'inherit') { if ($render_file == false and isset($page['layout_file']) and $page['layout_file'] != false) { $page['layout_file'] = str_replace('__', DS, $page['layout_file']); $template_view = ACTIVE_TEMPLATE_DIR . DS . $page['layout_file']; $template_view = normalize_path($template_view, false); if (is_file($template_view) == true) { $render_file = $template_view; } else { if (!isset($page['is_home']) or $page['is_home'] != 1) { $template_view = ACTIVE_TEMPLATE_DIR . DS . 'clean.php'; if (is_file($template_view) == true) { $render_file = $template_view; } } } } } $template_view = ACTIVE_TEMPLATE_DIR . 'index.php'; if ($render_file == false and is_file($template_view) == true) { $render_file = $template_view; } } if ($render_file == false and isset($page['active_site_template'])) { $url_file = $this->app->url_manager->string(1, 1); $test_file = str_replace('___', DS, $url_file); $template_view = ACTIVE_TEMPLATE_DIR . $test_file . '.php'; $template_view = normalize_path($template_view, false); if (is_file($template_view) == true) { $render_file = $template_view; } } if ($render_file == false and $fallback_render_internal_file != false) { if (is_file($fallback_render_internal_file)) { $render_file = $fallback_render_internal_file; } } if ($render_file == false and isset($page['active_site_template']) and strtolower($page['active_site_template']) != 'default') { $template_view = ACTIVE_TEMPLATE_DIR . 'index.php'; if (is_file($template_view) == true) { $render_file = $template_view; } } if ($render_file == false and isset($page['active_site_template']) and strtolower($page['active_site_template']) != 'default') { $template_view = ACTIVE_TEMPLATE_DIR . 'index.html'; if (is_file($template_view) == true) { $render_file = $template_view; } } if (isset($page['active_site_template']) and $render_file == false and strtolower($page['active_site_template']) != 'default') { $template_view = ACTIVE_TEMPLATE_DIR . 'index.htm'; if (is_file($template_view) == true) { $render_file = $template_view; } } if ($render_file == false and $template_view_set_inner != false) { if (isset($template_view_set_inner2)) { $template_view_set_inner2 = normalize_path($template_view_set_inner2, false); if (is_file($template_view_set_inner2) == true) { $render_file = $template_view_set_inner2; } } $template_view_set_inner = normalize_path($template_view_set_inner, false); if ($render_file == false and is_file($template_view_set_inner) == true) { $render_file = $template_view_set_inner; } } if ($render_file != false and isset($page['custom_view'])) { $check_custom = dirname($render_file) . DS; $check_custom_parent = dirname($render_file) . DS; $cv = trim($page['custom_view']); $cv = str_replace('..', '', $cv); $cv = str_ireplace('.php', '', $cv); $check_custom_f = $check_custom . $cv . '.php'; if (is_file($check_custom_f)) { $render_file = $check_custom_f; } } if ($render_file == false and isset($page['layout_file']) and $page['layout_file'] != false) { $page['layout_file'] = str_replace('__', DS, $page['layout_file']); $template_view = ACTIVE_TEMPLATE_DIR . DS . $page['layout_file']; $template_view = normalize_path($template_view, false); if (is_file($template_view) == true) { $render_file = $template_view; } } // $this->app->cache_manager->save($render_file, $cache_id, $cache_group); return $render_file; }
</tr> <tr> <td>userfiles_folder</td> <td><?php echo modules_url(); ?> </td> </tr> <tr> <td>site_url</td> <td><?php echo site_url(); ?> </td> </tr> <tr> <td>templates_path</td> <td><?php echo templates_path(); ?> </td> </tr> <tr> <td>templates_url</td> <td><?php echo templates_url(); ?> </td> </tr> </table>
event_trigger('mw_db_init_modules'); __mw_install_log('Scanning for modules'); mw()->modules->scan_for_modules("skip_cache=1&cleanup_db=1"); __mw_install_log('Installing modules'); mw()->modules->update_db(); __mw_install_log('Loading modules'); event_trigger('mw_scan_for_modules'); clearstatcache(); _reload_c(); if (isset($to_save['with_default_content'])) { if ($to_save['with_default_content'] != '{with_default_content}' and $to_save['with_default_content'] != 'no') { $default_content_folder = mw_includes_path() . 'install' . DIRECTORY_SEPARATOR; $default_content_file = $default_content_folder . 'mw_default_content.zip'; if (isset($to_save['default_template']) and $to_save['default_template'] != false and $to_save['default_template'] != '{default_template}') { if (defined('templates_path()')) { $template_dir = templates_path() . DS . $to_save['default_template']; $template_dir = normalize_path($template_dir, true); if (is_dir($template_dir)) { $template_default_content = $template_dir . 'mw_default_content.zip'; if (is_file($template_default_content) and is_readable($template_default_content)) { $default_content_file = $template_default_content; $default_content_folder = $template_dir; } } } } if (is_file($default_content_file)) { __mw_install_log('Installing default content'); define("MW_NO_DEFAULT_CONTENT", true); $restore = new \Microweber\Utils\Backup(); $restore->backups_folder = $default_content_folder;