release 0.267: front layout/basket fixes and product redirect hardening
This commit is contained in:
@@ -8,6 +8,29 @@ class Layouts
|
||||
return $mdb -> get( 'pp_layouts', 'id', [ 'categories_default' => 1 ] );
|
||||
}
|
||||
|
||||
static public function default_layout()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheKey = "\front\factory\Layouts::default_layout";
|
||||
|
||||
$objectData = $cacheHandler -> get( $cacheKey );
|
||||
if ( $objectData )
|
||||
{
|
||||
$cachedLayout = @unserialize( $objectData );
|
||||
if ( is_array( $cachedLayout ) and !empty( $cachedLayout ) )
|
||||
return $cachedLayout;
|
||||
|
||||
$cacheHandler -> delete( $cacheKey );
|
||||
}
|
||||
|
||||
$layout = $mdb -> get( 'pp_layouts', '*', [ 'status' => 1 ] );
|
||||
$cacheHandler -> set( $cacheKey, $layout );
|
||||
|
||||
return $layout;
|
||||
}
|
||||
|
||||
static public function product_layout( $product_id )
|
||||
{
|
||||
global $mdb;
|
||||
@@ -16,18 +39,47 @@ class Layouts
|
||||
$cacheKey = "\front\factory\Layouts::product_layout:$product_id";
|
||||
|
||||
$objectData = $cacheHandler -> get( $cacheKey );
|
||||
|
||||
if ( !$objectData )
|
||||
if ( $objectData )
|
||||
{
|
||||
$layout = $mdb -> get( 'pp_layouts', [ '[><]pp_shop_products' => [ 'id' => 'layout_id' ] ], '*', [ 'pp_shop_products.id' => (int)$product_id ] );
|
||||
$cachedLayout = @unserialize( $objectData );
|
||||
if ( is_array( $cachedLayout ) and !empty( $cachedLayout ) )
|
||||
return $cachedLayout;
|
||||
|
||||
$cacheHandler -> set( $cacheKey, $layout );
|
||||
$cacheHandler -> delete( $cacheKey );
|
||||
}
|
||||
|
||||
$layoutRows = $mdb -> query(
|
||||
"SELECT pp_layouts.*
|
||||
FROM pp_layouts
|
||||
JOIN pp_shop_products ON pp_layouts.id = pp_shop_products.layout_id
|
||||
WHERE pp_shop_products.id = " . (int)$product_id . "
|
||||
ORDER BY pp_layouts.id DESC"
|
||||
) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
|
||||
if ( is_array( $layoutRows ) and isset( $layoutRows[0] ) )
|
||||
$layout = $layoutRows[0];
|
||||
else
|
||||
{
|
||||
return unserialize( $objectData );
|
||||
$layoutRows = $mdb -> query(
|
||||
"SELECT pp_layouts.*
|
||||
FROM pp_layouts
|
||||
JOIN pp_layouts_categories ON pp_layouts.id = pp_layouts_categories.layout_id
|
||||
JOIN pp_shop_products_categories ON pp_shop_products_categories.category_id = pp_layouts_categories.category_id
|
||||
WHERE pp_shop_products_categories.product_id = " . (int)$product_id . "
|
||||
ORDER BY pp_shop_products_categories.o ASC, pp_layouts.id DESC"
|
||||
) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
|
||||
if ( is_array( $layoutRows ) and isset( $layoutRows[0] ) )
|
||||
$layout = $layoutRows[0];
|
||||
else
|
||||
$layout = $mdb -> get( 'pp_layouts', '*', [ 'categories_default' => 1 ] );
|
||||
}
|
||||
|
||||
if ( !$layout )
|
||||
$layout = $mdb -> get( 'pp_layouts', '*', [ 'status' => 1 ] );
|
||||
|
||||
$cacheHandler -> set( $cacheKey, $layout );
|
||||
|
||||
return $layout;
|
||||
}
|
||||
|
||||
@@ -62,21 +114,34 @@ class Layouts
|
||||
$cacheKey = "\front\factory\Layouts::category_layout:$category_id";
|
||||
|
||||
$objectData = $cacheHandler -> get( $cacheKey );
|
||||
|
||||
if ( !$objectData )
|
||||
if ( $objectData )
|
||||
{
|
||||
$layout = $mdb -> query( "SELECT pp_layouts.* FROM pp_layouts JOIN pp_layouts_categories ON pp_layouts.id = pp_layouts_categories.layout_id WHERE pp_layouts_categories.category_id = " . (int)$category_id ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
if ( !$layout )
|
||||
$layout = $mdb -> get( 'pp_layouts', '*', [ 'categories_default' => 1 ] );
|
||||
$cachedLayout = @unserialize( $objectData );
|
||||
if ( is_array( $cachedLayout ) and !empty( $cachedLayout ) )
|
||||
return $cachedLayout;
|
||||
|
||||
$cacheHandler -> set( $cacheKey, $layout[0] );
|
||||
$cacheHandler -> delete( $cacheKey );
|
||||
}
|
||||
|
||||
$layoutRows = $mdb -> query(
|
||||
"SELECT pp_layouts.*
|
||||
FROM pp_layouts
|
||||
JOIN pp_layouts_categories ON pp_layouts.id = pp_layouts_categories.layout_id
|
||||
WHERE pp_layouts_categories.category_id = " . (int)$category_id . "
|
||||
ORDER BY pp_layouts.id DESC"
|
||||
) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
|
||||
if ( is_array( $layoutRows ) and isset( $layoutRows[0] ) )
|
||||
$layout = $layoutRows[0];
|
||||
else
|
||||
{
|
||||
return unserialize( $objectData );
|
||||
}
|
||||
$layout = $mdb -> get( 'pp_layouts', '*', [ 'categories_default' => 1 ] );
|
||||
|
||||
return $layout[0];
|
||||
if ( !$layout )
|
||||
$layout = $mdb -> get( 'pp_layouts', '*', [ 'status' => 1 ] );
|
||||
|
||||
$cacheHandler -> set( $cacheKey, $layout );
|
||||
|
||||
return $layout;
|
||||
}
|
||||
|
||||
static public function active_layout( $page_id )
|
||||
|
||||
Reference in New Issue
Block a user