34 lines
922 B
PHP
34 lines
922 B
PHP
<?php
|
|
namespace menu;
|
|
|
|
class FMenu {
|
|
|
|
public function loadMenu( $id )
|
|
{
|
|
global $db , $cache , $config , $sys;
|
|
|
|
$current_lang = $sys -> getSessionVar( 'current_lang' );
|
|
$key = 'loadMenu:' . $id . ':' . $current_lang;
|
|
|
|
if ( !$sites = $cache -> fetch( $key ) )
|
|
{
|
|
$query = $db -> prepare( 'SELECT id FROM pcms_page WHERE id_menu = :id_menu AND enabled = :enabled ORDER BY o' );
|
|
$query -> bindValue( ':id_menu' , $id , \PDO::PARAM_INT );
|
|
$query -> bindValue( ':enabled' , 1 , \PDO::PARAM_STR );
|
|
$query -> execute();
|
|
if ( $query -> rowCount() ) while( $row = $query -> fetch() )
|
|
{
|
|
$sites[] = \site\FSite::loadSite( $row['id'] );
|
|
}
|
|
$query -> closeCursor();
|
|
$cache -> store( $key , $sites , $config['cache_expire'] );
|
|
}
|
|
$menu = new \menu\Menu;
|
|
$menu -> set_id( $id );
|
|
$menu -> set_sites( $sites );
|
|
|
|
return $menu;
|
|
}
|
|
}
|
|
?>
|