first commit
This commit is contained in:
53
autoload/menu/class.FMenu.php
Normal file
53
autoload/menu/class.FMenu.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace menu;
|
||||
|
||||
class FMenu {
|
||||
|
||||
public static function loadMenu( $id )
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db -> prepare( 'SELECT * FROM pp_menu WHERE id = :id AND enabled = "1"' );
|
||||
$query -> bindValue( ':id', $id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while ( $row = $query -> fetch() )
|
||||
{
|
||||
$menu = new \menu\Menu;
|
||||
$menu -> set_id( $id );
|
||||
$menu -> set_sites( self::loadMenuPages( $id ) );
|
||||
$menu -> set_type( $row['type'] );
|
||||
}
|
||||
$query -> closeCursor();
|
||||
|
||||
return $menu;
|
||||
}
|
||||
|
||||
public static function loadMenuPages( $id, $parent_id = 0 )
|
||||
{
|
||||
global $db , $cache , $config;
|
||||
|
||||
|
||||
$current_lang = \System::getSessionVar( 'current_lang' );
|
||||
$key = 'loadMenu:' . $id . ':' . $current_lang . ':' . $parent_id;
|
||||
|
||||
if ( !$sites = $cache -> fetch( $key . 'a' ) )
|
||||
{
|
||||
$query = $db -> prepare( 'SELECT id FROM pp_pages WHERE id_menu = :id_menu AND enabled = :enabled AND parent_id = :parent_id ORDER BY o' );
|
||||
$query -> bindValue( ':id_menu', $id, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':enabled', 1, \PDO::PARAM_INT );
|
||||
$query -> bindValue( ':parent_id', $parent_id, \PDO::PARAM_INT );
|
||||
$query -> execute();
|
||||
if ( $query -> rowCount() ) while( $row = $query -> fetch() )
|
||||
{
|
||||
$site = new \site\Site( $row['id'] );
|
||||
$site -> _values['subpages'] = self::loadMenuPages( $id, $row['id'] );
|
||||
$sites[] = $site;
|
||||
}
|
||||
$query -> closeCursor();
|
||||
$cache -> store( $key , $sites , $config['cache_expire'] );
|
||||
}
|
||||
|
||||
return $sites;
|
||||
}
|
||||
}
|
||||
?>
|
||||
38
autoload/menu/class.Menu.php
Normal file
38
autoload/menu/class.Menu.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace menu;
|
||||
|
||||
class Menu {
|
||||
|
||||
private $_sites;
|
||||
private $_id;
|
||||
private $_type;
|
||||
|
||||
public function get_type() {
|
||||
return $this->_type;
|
||||
}
|
||||
|
||||
public function set_type($_type) {
|
||||
$this->_type = $_type;
|
||||
}
|
||||
|
||||
public function get_sites()
|
||||
{
|
||||
return $this->_sites;
|
||||
}
|
||||
|
||||
public function set_sites($_sites)
|
||||
{
|
||||
$this->_sites = $_sites;
|
||||
}
|
||||
|
||||
public function get_id()
|
||||
{
|
||||
return $this->_id;
|
||||
}
|
||||
|
||||
public function set_id($_id)
|
||||
{
|
||||
$this->_id = $_id;
|
||||
}
|
||||
}
|
||||
?>
|
||||
24
autoload/menu/class.VMenu.php
Normal file
24
autoload/menu/class.VMenu.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace menu;
|
||||
|
||||
class VMenu {
|
||||
|
||||
public static function drawSubpages( $pages, $menu_id , $step = 0, $type = 0 )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _pages = $pages;
|
||||
$tpl -> _menu_id = $menu_id;
|
||||
$tpl -> _step = $step;
|
||||
$tpl -> _type = $type;
|
||||
return $tpl -> fetch( 'menu/subpages' );
|
||||
}
|
||||
|
||||
public static function show( $id )
|
||||
{
|
||||
$tpl = new \Savant3;
|
||||
$tpl -> _menu = \menu\FMenu::loadMenu( $id );
|
||||
|
||||
return $tpl -> fetch( 'menu/pages' );
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user