Files
shopPRO/autoload/front/factory/class.Pages.php
Jacek Pyziak 431add234c ver. 0.283: Legacy class cleanup — S, Html, Email, Image, Log, Mobile_Detect → Shared namespace
- Migrate class.S → Shared\Helpers\Helpers (140+ files), remove 12 unused methods
- Migrate class.Html → Shared\Html\Html
- Migrate class.Email → Shared\Email\Email
- Migrate class.Image → Shared\Image\ImageManipulator
- Delete class.Log (unused), class.Mobile_Detect (outdated UA detection)
- Remove grid library loading from admin (index.php, ajax.php)
- Replace gridEdit usage in 10 admin templates with grid-edit-replacement.php
- Fix grid-edit-replacement.php AJAX to send values as JSON (grid.js compat)
- Remove mobile layout conditionals (m_html/m_css/m_js) from Site + LayoutsRepository
- Remove \Log::save_log() calls from OrderAdminService, ShopOrder, Order

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 23:06:06 +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'] . '-' . \Shared\Helpers\Helpers::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;
}
}