Skip to content

Commit

Permalink
EasyPIBA 4.4.0
Browse files Browse the repository at this point in the history
Fix some bugs
Update sitemap controller
  • Loading branch information
al3x2508 committed Dec 19, 2017
1 parent 189d92a commit e63600f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 39 deletions.
20 changes: 11 additions & 9 deletions Module/Pages/Controller.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
Expand Down
47 changes: 18 additions & 29 deletions Module/Sitemap/Page.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<url>
<loc>' . $siteUrl . '</loc>
<changefreq>weekly</changefreq>
<priority>1.00</priority>
</url>
<url>
<loc>' . $siteUrl . 'login</loc>
<changefreq>weekly</changefreq>
<priority>1.00</priority>
</url>
<url>
<loc>' . $siteUrl . 'password_reset</loc>
<changefreq>weekly</changefreq>
<priority>1.00</priority>
</url>
<url>
<loc>' . $siteUrl . 'testimonials</loc>
<changefreq>weekly</changefreq>
<priority>1.00</priority>
</url>
<url>
<loc>' . $siteUrl . 'news/</loc>
<changefreq>daily</changefreq>
<priority>1.00</priority>
</url>' . 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 .= ' <url>
<loc>' . $siteUrl . $page->url . '</loc>
$langUrl = ($page->language == _DEFAULT_LANGUAGE_) ? '' : $page->language . '/';
$return .= ' <url>
<loc>' . $siteUrl . $langUrl . $page->url . '</loc>
<changefreq>monthly</changefreq>
<priority>0.90</priority>
</url>' . 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 .= ' <url>
<loc>' . $siteUrl . $route->url . '</loc>
<changefreq>monthly</changefreq>
<priority>0.90</priority>
</url>' . PHP_EOL;
}
$news = new Model('news');
$news->status = 1;
$news->order('date_published DESC');
$news = $news->get();
foreach($news AS $n) {
Expand All @@ -62,6 +50,7 @@ public static function output() {
</url>' . PHP_EOL;
}
$testimonials = new Model('testimonials');
$testimonials->status = 1;
$testimonials->order('id DESC');
$testimonials = $testimonials->get();
foreach($testimonials AS $testimonial) {
Expand Down
15 changes: 14 additions & 1 deletion Utils/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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], '/'));
}

Expand Down

0 comments on commit e63600f

Please sign in to comment.