Files
kon-trans.eu/autoload/front/factory/class.Layouts.php
2026-03-09 00:13:00 +01:00

58 lines
1.5 KiB
PHP

<?php
namespace front\factory;
class Layouts
{
public static function layout_details( $layout_id )
{
global $mdb, $cache;
if ( !$layout = \Cache::fetch( "layout_details:$layout_id" ) )
{
$layout = $mdb -> get( 'pp_layouts', '*', [ 'id' => (int)$layout_id ] );
if ( !$layout )
$layout = $mdb -> get( 'pp_layouts', '*', [ 'status' => 1 ] );
\Cache::store( "layout_details:$layout_id", $layout );
}
return $layout;
}
public static function article_layout( $article_id )
{
global $mdb, $cache;
if ( !$layout = \Cache::fetch( "article_layout:$article_id" ) )
{
$layout = $mdb -> get( 'pp_layouts', [ '[><]pp_articles' => [ 'id' => 'layout_id' ] ], '*', [ 'pp_articles.id' => (int)$article_id ] );
if ( !$layout )
$layout = $mdb -> get( 'pp_layouts', '*', [ 'status' => 1 ] );
\Cache::store( "article_layout:$article_id", $layout );
}
return $layout;
}
public static function active_layout( $page_id )
{
global $mdb, $cache;
if ( !$layout = \Cache::fetch( "active_layouts:$page_id" ) )
{
try {
$layout = $mdb -> get( 'pp_layouts', [ '[><]pp_layouts_pages' => [ 'id' => 'layout_id' ] ], '*', [ 'pp_layouts_pages.page_id' => (int)$page_id ] );
} catch ( \PDOException $e ) {
$layout = false;
}
if ( !$layout )
$layout = $mdb -> get( 'pp_layouts', '*', [ 'status' => 1 ] );
\Cache::store( "active_layouts:$page_id", $layout );
}
return $layout;
}
}