From e63600ffba1fb5c0833335accb7553ba6f1cbe8f Mon Sep 17 00:00:00 2001 From: Alex Glavan Date: Tue, 19 Dec 2017 12:44:24 +0200 Subject: [PATCH] EasyPIBA 4.4.0 Fix some bugs Update sitemap controller --- Module/Pages/Controller.class.php | 20 +++++++------ Module/Sitemap/Page.class.php | 47 ++++++++++++------------------- Utils/functions.php | 15 +++++++++- 3 files changed, 43 insertions(+), 39 deletions(-) diff --git a/Module/Pages/Controller.class.php b/Module/Pages/Controller.class.php index f21db15..38d8313 100644 --- a/Module/Pages/Controller.class.php +++ b/Module/Pages/Controller.class.php @@ -79,7 +79,7 @@ public function __construct($url, $language = _DEFAULT_LANGUAGE_) { } else { $module_routes = new Model('module_routes'); - $module_routes->where(array('(`url` = \'' . $url . '\' AND `type` = 0)' => 1, '(\'' . $url . '\' REGEXP `url` AND `type` = 1)' => 1)); + $module_routes->where(array('(`url` = \'' . str_replace('.html', '', $url) . '\' AND `type` = 0)' => 1, '(\'' . str_replace('.html', '', $url) . '\' REGEXP `url` AND `type` = 1)' => 1)); $module_routes->limit(1); $module_routes = $module_routes->get('OR'); if(count($module_routes)) { @@ -134,14 +134,16 @@ public static function getMenu() { $module_routes = $module_routes->get(); foreach($module_routes AS $module_route) { if($module_route->menu_position !== 2) { - $menuParent = (empty($module_route->menu_parent))?0:$module_route->menu_parent; - if($menuParent === 0) $module_route->menu_order += count($array_pages); - if(!array_key_exists($menuParent, $array_menu)) $array_menu[$menuParent] = array(); - $pag = array('url' => _FOLDER_URL_ . $langUrl . $module_route->url, 'menu_text' => $module_route->menu_text, 'submenu_text' => $module_route->submenu_text, 'menu_parent' => $menuParent); - //If page url is the same as the current url set link class as active - if($_SERVER['REQUEST_URI'] == _FOLDER_URL_ . $langUrl . $module_route->url || $_SERVER['REQUEST_URI'] == _FOLDER_URL_ . $langUrl . $module_route->url) $pag['classes'] = 'active'; - $array_menu[$menuParent][$module_route->menu_order] = $pag; - ksort($array_menu[$menuParent]); + if($userLanguage == _DEFAULT_LANGUAGE_) { + $menuParent = (empty($module_route->menu_parent)) ? 0 : $module_route->menu_parent; + if($menuParent === 0) $module_route->menu_order += count($array_pages); + if(!array_key_exists($menuParent, $array_menu)) $array_menu[$menuParent] = array(); + $pag = array('url' => _FOLDER_URL_ . $langUrl . $module_route->url, 'menu_text' => $module_route->menu_text, 'submenu_text' => $module_route->submenu_text, 'menu_parent' => $menuParent); + //If page url is the same as the current url set link class as active + if($_SERVER['REQUEST_URI'] == _FOLDER_URL_ . $langUrl . $module_route->url || $_SERVER['REQUEST_URI'] == _FOLDER_URL_ . $langUrl . $module_route->url) $pag['classes'] = 'active'; + $array_menu[$menuParent][$module_route->menu_order] = $pag; + ksort($array_menu[$menuParent]); + } } else { $menuParent = (empty($module_route->menu_parent))?0:$module_route->menu_parent; diff --git a/Module/Sitemap/Page.class.php b/Module/Sitemap/Page.class.php index f566434..fd48525 100644 --- a/Module/Sitemap/Page.class.php +++ b/Module/Sitemap/Page.class.php @@ -13,44 +13,32 @@ public static function output() { xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 - http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> - - ' . $siteUrl . ' - weekly - 1.00 - - - ' . $siteUrl . 'login - weekly - 1.00 - - - ' . $siteUrl . 'password_reset - weekly - 1.00 - - - ' . $siteUrl . 'testimonials - weekly - 1.00 - - - ' . $siteUrl . 'news/ - daily - 1.00 - ' . PHP_EOL; + http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' . PHP_EOL; $pages = new Model('pages'); $pages->visible = 1; - $pages->order('menu_parent ASC, menu_order ASC'); + $pages->order('language ASC, menu_parent ASC, menu_order ASC'); $pages = $pages->get(); foreach($pages AS $page) { - if(!empty($page->url)) $return .= ' - ' . $siteUrl . $page->url . ' + $langUrl = ($page->language == _DEFAULT_LANGUAGE_) ? '' : $page->language . '/'; + $return .= ' + ' . $siteUrl . $langUrl . $page->url . ' + monthly + 0.90 + ' . PHP_EOL; + } + $module_routes = new Model('module_routes'); + $module_routes->type = 0; + $module_routes->mustBeLoggedIn = 0; + $module_routes = $module_routes->get(); + foreach($module_routes AS $route) { + $return .= ' + ' . $siteUrl . $route->url . ' monthly 0.90 ' . PHP_EOL; } $news = new Model('news'); + $news->status = 1; $news->order('date_published DESC'); $news = $news->get(); foreach($news AS $n) { @@ -62,6 +50,7 @@ public static function output() { ' . PHP_EOL; } $testimonials = new Model('testimonials'); + $testimonials->status = 1; $testimonials->order('id DESC'); $testimonials = $testimonials->get(); foreach($testimonials AS $testimonial) { diff --git a/Utils/functions.php b/Utils/functions.php index 13ea8bc..40d2d4c 100644 --- a/Utils/functions.php +++ b/Utils/functions.php @@ -62,6 +62,17 @@ public static function getUserLanguage($user = false) { return _DEFAULT_LANGUAGE_; } + /** + * Set language + * @param string $language + * @return bool + */ + public static function setUserLanguage($language) { + $_SESSION['userLanguage'] = $language; + echo $_SESSION['userLanguage']; exit; + return setcookie('language', $language, time() + 60 * 60 * 24 * 30); + } + /** * Get the user IP * @return mixed @@ -271,14 +282,16 @@ public static function getCurrentUrl() { $page_url = ($query_position !== false) ? substr($_SERVER['REQUEST_URI'], 0, $query_position - 1) : $_SERVER['REQUEST_URI']; $page_url = preg_replace('/^(' . str_replace('/', '\/', _FOLDER_URL_) . ')(.*)/', '$2', $page_url); - preg_match('/^([a-z]{2,3})$/', $page_url, $matches); + preg_match('/^((?!amp)[a-z]{2,3})$/', $page_url, $matches); if(count($matches)) { $_COOKIE['language'] = $matches[1]; + $_SESSION['userLanguage'] = $matches[1]; $page_url = ''; } preg_match('/^((?!amp)[a-z]{2,3})(?=\/)\/(.*)$/', $page_url, $matches); if(count($matches)) { $_COOKIE['language'] = $matches[1]; + $_SESSION['userLanguage'] = $matches[1]; $page_url = str_replace('.html', '', trim($matches[2], '/')); }