class BxDolPageView {
var $sPageName;
var $aPage; // cache of this page
var $sCode = '';
var $sWhoViews = 'non';
var $iMemberID = 0;
var $bAjaxMode = false;
function BxDolPageView( $sPageName ) {
$this -> sPageName = $sPageName;
if( !$this -> load() )
return false;
$this -> getViewerInfo();
$this -> checkAjaxMode();
}
function checkAjaxMode() {
if( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) and $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' )
$this -> bAjaxMode = true;
}
function load() {
$sCacheFile = BX_DIRECTORY_PATH_INC . 'db_cached/PageView.inc';
if( !file_exists( $sCacheFile ) ) {
echo '
Warning PageView cache not found';
return false;
}
$sCache = @file_get_contents( $sCacheFile );
if( !strlen( $sCache ) ) {
echo '
Warning! PageView cache cannot be loaded. Please recompile.';
return false;
}
$aCache = @eval( $sCache );
if( !$aCache ) {
echo '
Warning! PageView cache cannot be evaluated. Please recompile.';
return false;
}
if( !array_key_exists( $this -> sPageName, $aCache ) ) {
echo '
Warning! The page not found in PageView cache.';
return false;
}
$this -> aPage = $aCache[ $this->sPageName ];
//echoDbg( $this -> aPage );
return true;
}
function getViewerInfo() {
global $logged;
if( $logged['member'] ) {
$this -> sWhoViews = 'memb';
$this -> iMemberID = (int)$_COOKIE['memberID'];
}
}
function gen() {
global $_page_cont, $_ni;
if( !$this -> aPage )
return false;
$this -> genColumnsHeader();
$_page_cont[$_ni]['main_div_width'] = $this -> aPage['Width'];
foreach( array_keys( $this -> aPage['Columns'] ) as $iColumn )
$this -> genColumn( $iColumn );
$this -> genColumnsFooter();
}
function genOnlyBlock( $iBlockID ) {
if( !$iBlockID )
return false;
// search block
foreach( array_keys( $this -> aPage['Columns'] ) as $iColumn ) {
$aColumn = $this -> aPage['Columns'][ $iColumn ];
if( !$aColumn )
return false;
foreach( $aColumn['Blocks'] as $iMyBlockID => $aBlock )
if( $iBlockID == $iMyBlockID ) {
$this -> genBlock( $iMyBlockID, $aBlock, false );
return true;
}
}
return false;
}
function getCode() {
if( !$this -> bAjaxMode )
$this -> gen();
else {
$this -> genOnlyBlock( (int)$_REQUEST['pageBlock'] );
echo $this -> sCode;
exit;
}
return $this -> sCode;
}
//for customizability
function genColumnsHeader() {
}
//for customizability
function genColumnsFooter() {
}
function genColumn( $iColumn ) {
$aColumn = $this -> aPage['Columns'][ $iColumn ];
if( !$aColumn )
return false;
$this -> genColumnHeader( $iColumn, $aColumn['Width'] );
foreach( $aColumn['Blocks'] as $iBlockID => $aBlock )
$this -> genBlock( $iBlockID, $aBlock );
$this -> genColumnFooter( $iColumn );
}
function getBlockCode_Topest($iColumn) {
return '';
}
function genColumnHeader( $iColumn, $iColumnWidth ) {
if( $iColumn == 1 )
$sAddClass = ' page_column_first';
elseif( $iColumn == count( $this -> aPage['Columns'] ) )
$sAddClass = ' page_column_last';
else
$sAddClass = '';
$this -> sCode .= '