Files
shopPRO/autoload/front/factory/class.Pages.php
Jacek Pyziak 285cbe5515 ver. 0.282: Banners frontend migration, Cache cleanup, Shared\Cache namespace
- Banners frontend: front\Views\Banners (new), BannerRepository +2 frontend methods,
  front\view\Site przepięty, usunięte front\factory\Banners i front\view\Banners
- Cache cleanup: eliminacja legacy class.Cache.php (file-based cache),
  13 metod front\factory przepiętych z \Cache::fetch/store na CacheHandler
- Shared\Cache namespace: CacheHandler i RedisConnection przeniesione do Shared\Cache\,
  60 odwołań CacheHandler i 12 odwołań RedisConnection przepiętych,
  usunięte backward-compat wrappery class.CacheHandler.php i class.RedisConnection.php
- Naprawione rozbieżności kluczy cache (random_products, category_name)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 21:25:50 +01:00

93 lines
2.3 KiB
PHP

<?php
namespace front\factory;
class Pages
{
public static function page_sort( $page_id )
{
global $mdb;
$cacheHandler = new \Shared\Cache\CacheHandler();
$cacheKey = "\front\factory\Pages::page_sort:$page_id";
$objectData = $cacheHandler -> get( $cacheKey );
if ( !$objectData )
{
$sort = $mdb -> get( 'pp_pages', 'sort_type', [ 'id' => $page_id ] );
$cacheHandler -> set( $cacheKey, $sort );
}
else
{
return unserialize( $objectData );
}
return $sort;
}
public static function lang_url( $page_id, $lang_id )
{
$page = self::page_details( $page_id, $lang_id );
$page['language']['seo_link'] ? $url = '/' . $page['language']['seo_link'] : $url = '/s-' . $page['id'] . '-' . \S::seo( $page['language']['title'] );
if ( $lang_id != ( new \Domain\Languages\LanguagesRepository( $GLOBALS['mdb'] ) )->defaultLanguage() and $url != '#' )
$url = '/' . $lang_id . $url;
return $url;
}
public static function page_details( $id = '', $lang_tmp = '' )
{
global $mdb, $lang_id;
if ( !$id )
$id = self::main_page_id();
if ( $lang_tmp )
$lang_id = $lang_tmp;
$cacheHandler = new \Shared\Cache\CacheHandler();
$cacheKey = "\front\factory\Pages::page_details:$id:$lang_id";
$objectData = $cacheHandler->get($cacheKey);
if ( !$objectData ) {
$page = $mdb->get('pp_pages', '*', ['id' => (int)$id]);
$page['language'] = $mdb->get('pp_pages_langs', '*', ['AND' => ['page_id' => (int)$id, 'lang_id' => $lang_id]]);
$cacheHandler->set($cacheKey, $page);
} else {
return unserialize($objectData);
}
return $page;
}
public static function main_page_id()
{
global $mdb;
$cacheHandler = new \Shared\Cache\CacheHandler();
$cacheKey = "\front\factory\Pages::main_page_id";
$objectData = $cacheHandler->get($cacheKey);
if ( !$objectData )
{
$id = $mdb -> get( 'pp_pages', 'id', [ 'AND' => [ 'status' => 1, 'start' => 1 ] ] );
if ( !$id )
$id = $mdb -> get( 'pp_pages', 'id', [ 'status' => 1, 'ORDER' => [ 'menu_id' => 'ASC', 'o' => 'ASC' ], 'LIMIT' => 1 ] );
$cacheHandler -> set( $cacheKey, $id );
}
else
{
return unserialize($objectData);
}
return $id;
}
}