<?php
/**
*
* @author Benjamin Gillissen <hide@address.com>
*
* **************************************************************
Copyright (C) 2009 Benjamin Gillissen
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details at:
http://www.gnu.org/copyleft/gpl.html
* **************************************************************
*/
class pages {
private static $PAGE;
private static function init(){
if ( isset(self::$PAGE) ){ return TRUE; }
//get engine from objects conf for __CLASS__
$eng = configs::get('pagegen', 'engine');
if ( $eng != 'db' AND $eng != 'conf' AND $eng != 'xml' ){
errors::raise('Missing or Invalid engine option into pagegen configuration file !', CORE_LOG_FATAL, 'PGEN');
return FALSE;
}
$c = 'page_'.$eng;
self::$PAGE = new $c();
return TRUE;
}
public static function exists($pid){
if ( !self::init() ){ return FALSE; }
return self::$PAGE->exists($pid);
}
public static function listall(){
if ( !self::init() ){ return FALSE; }
return self::$PAGE->listall();
}
public static function get_realm($pid){
if ( !self::init() ){ return FALSE; }
return self::$PAGE->get_infobypid('realm', $pid);
}
public static function get_challenge($pid){
if ( !self::init() ){ return FALSE; }
return self::$PAGE->get_infobypid('chal', $pid);
}
public static function get_type($pid){
if ( !self::init() ){ return FALSE; }
return self::$PAGE->get_infobypid('type', $pid);
}
public static function get_conf($pid){
if ( !self::init() ){ return FALSE; }
return self::$PAGE->get_infobypid('conf', $pid);
}
public static function get_parent($pid){
if ( !self::init() ){ return FALSE; }
return self::$PAGE->get_infobypid('parent', $pid);
}
public static function get_args($pid){
if ( !self::init() ){ return FALSE; }
$r = self::$PAGE->get_infobypid('args', $pid);
if ( empty($r) ){ return; }
return split(';',$r);
}
public static function get_title($pid){
if ( !self::init() ){ return FALSE; }
return self::$PAGE->get_infobypid('title', $pid);
}
public static function get_depth($pid){
if ( !self::init() ){ return FALSE; }
return self::$PAGE->get_infobypid('depth', $pid);
}
public static function is_hidden($pid){
if ( !self::init() ){ return FALSE; }
$r = self::$PAGE->get_infobypid('hidden', $pid);
return ( $r == 1);
}
public static function get_childs($pid){
if ( !self::init() ){ return FALSE; }
return self::$PAGE->get_childs($pid);
}
public static function got_childpage($pid){
if ( !self::init() ){ return FALSE; }
return self::$PAGE->got_childpage($pid);
}
public static function get_pathto($pid){
$o[] = self::get_title($pid);
$depth = self::$PAGE->get_infobypid('depth', $pid);
while( $depth != 0 ){
$pid = self::get_parent($pid);
$o[] = self::get_title($pid);
$depth = self::$PAGE->get_infobypid('depth', $pid);
}
krsort($o);
return implode('/', $o);
}
public static function getby_namelvl($name, $lvl){
if ( !self::init() ){ return FALSE; }
return self::$PAGE->pidby_namelvl($name, $lvl);
}
}