'Homepage', 'music' => 'Shared Music', 'video' => 'Shared Video', 'photo' => 'Shared Photo', 'ads' => 'Classifieds', 'member' => 'Account', 'profile' => 'Profile' ); function BxDolPageViewAdmin( $sDBTable, $sCacheFile ) { $this -> sDBTable = $sDBTable; $this -> sCacheFile = $sCacheFile; $sPage = process_pass_data( isset( $_REQUEST['Page'] ) ? trim( $_REQUEST['Page'] ) : '' ); $this -> getPages(); if( strlen($sPage) ) /* @var $this->oPage BxDolPVAPage */ $this -> oPage = new BxDolPVAPage( $sPage, $this ); $this -> checkAjaxMode(); if( $this -> bAjaxMode and $this -> oPage ) { $this -> sPage_db = addslashes( $this -> oPage -> sName ); switch( $_REQUEST['action'] ) { case 'load': header( 'Content-type:text/javascript' ); send_headers_page_changed(); echo $this -> oPage -> getJSON(); break; case 'saveColsWidths': if( is_array( $_POST['widths'] ) ) { $this -> saveColsWidths( $_POST['widths'] ); $this -> createCache(); } break; case 'saveBlocks': if( is_array( $_POST['columns'] ) ) { $this -> saveBlocks( $_POST['columns'] ); $this -> createCache(); } break; case 'loadEditForm': if( $iBlockID = (int)$_POST['id'] ) $this -> showPropForm( $iBlockID ); break; case 'saveItem': if( (int)$_POST['id'] ) { $this -> saveItem( $_POST ); $this -> createCache(); } break; case 'deleteBlock': if( $iBlockID = (int)$_REQUEST['id'] ) { $this -> deleteBlock( $iBlockID ); $this -> createCache(); } break; case 'checkNewBlock': if( $iBlockID = (int)$_REQUEST['id'] ) $this -> checkNewBlock( $iBlockID ); break; case 'savePageWidth': if( $sPageWidth = process_pass_data( $_POST['width'] ) ) { $this -> savePageWidth( $sPageWidth ); $this -> createCache(); if( $this -> oPage -> sName == 'index' ) { if( $sPageWidth == '100%' ) setParam( 'promoWidth', '960' ); else setParam( 'promoWidth', (int)$sPageWidth ); ResizeAllPromos(); } } break; case 'saveOtherPagesWidth': if( $sWidth = $_REQUEST['width'] ) { setParam( 'main_div_width', $sWidth ); echo 'OK'; } break; case 'resetPage': $this -> resetPage(); $this -> createCache(); break; } exit; } else { $this -> showMainPage(); } } function savePageWidth( $sPageWidth ) { $sPageWidth = addslashes( $sPageWidth ); $sQuery = "UPDATE `{$this -> sDBTable}` SET `PageWidth` = '$sPageWidth' WHERE `Page` = '{$this -> sPage_db}'"; db_res( $sQuery ); echo 'OK'; } function createCache() { $oCacher = new BxDolPageViewCacher( $this -> sDBTable, $this -> sCacheFile ); $oCacher -> createCache(); } function checkNewBlock( $iBlockID ) { $sQuery = "SELECT `Desc`, `Caption`, `Func`, `Content`, `Visible` FROM `{$this -> sDBTable}` WHERE `ID` = $iBlockID"; $aBlock = db_assoc_arr( $sQuery ); if( $aBlock['Func'] == 'Sample' ) { $sQuery = " INSERT INTO `{$this -> sDBTable}` SET `Desc` = '" . addslashes( $aBlock['Desc'] ) . "', `Caption` = '" . addslashes( $aBlock['Caption'] ) . "', `Func` = '{$aBlock['Content']}', `Visible` = '{$aBlock['Visible']}', `Page` = '{$this -> sPage_db}' "; db_res( $sQuery ); echo mysql_insert_id(); $this -> createCache(); } } function deleteBlock( $iBlockID ) { $sQuery = "DELETE FROM `{$this -> sDBTable}` WHERE `Page` = '{$this -> sPage_db}' AND `ID` = $iBlockID"; db_res( $sQuery ); } function resetPage() { if( $this -> oPage -> bResetable ) { $sQuery = "DELETE FROM `{$this -> sDBTable}` WHERE `Page` = '{$this -> sPage_db}'"; db_res($sQuery); execSqlFile( $this -> oPage -> sDefaultSqlFile ); if( $this -> oPage -> sName == 'index' ) { setParam( 'promoWidth', '960' ); ResizeAllPromos(); } } echo (int)$this -> oPage -> bResetable; } function saveItem( $aData ) { $iID = (int)$aData['id']; $sQuery = "SELECT `Func` FROM `{$this -> sDBTable}` WHERE `ID` = $iID"; $sFunc = db_value( $sQuery ); if( !$sFunc ) return; $sCaption = process_db_input($aData['Caption']); $sVisible = is_array( $aData['Visible'] ) ? implode( ',', $aData['Visible'] ) : ''; if( $sFunc == 'RSS' ) $sContentUpd = "`Content` = '" . process_db_input($aData['Url']) . '#' . (int)$aData['Num'] . "',"; elseif( $sFunc == 'Echo' ) $sContentUpd = "`Content` = '" . process_db_input($aData['Content']) . "',"; else $sContentUpd = ''; $sQuery = " UPDATE `{$this -> sDBTable}` SET `Caption` = '$sCaption', $sContentUpd `Visible` = '$sVisible' WHERE `ID` = $iID "; db_res( $sQuery ); echo _t( process_pass_data($aData['Caption']) ); } function saveColsWidths( $aWidths ) { $iCounter = 0; foreach( $aWidths as $iWidth ) { $iCounter ++; $iWidth = (int)$iWidth; $sQuery = "UPDATE `{$this -> sDBTable}` SET `ColWidth` = $iWidth WHERE `Page` = '{$this -> sPage_db}' AND `Column` = $iCounter"; db_res( $sQuery ); } echo 'OK'; } function saveBlocks( $aColumns ) { //reset blocks on this page $sQuery = "UPDATE `{$this -> sDBTable}` SET `Column` = 0, `Order` = 0 WHERE `Page` = '{$this -> sPage_db}'"; db_res( $sQuery ); $iColCounter = 0; foreach( $aColumns as $sBlocks ) { $iColCounter ++; $aBlocks = explode( ',', $sBlocks ); foreach( $aBlocks as $iOrder => $iBlockID ) { $iBlockID = (int)$iBlockID; $sQuery = "UPDATE `{$this -> sDBTable}` SET `Column` = $iColCounter, `Order` = $iOrder WHERE `ID` = $iBlockID AND `Page` = '{$this -> sPage_db}'"; db_res( $sQuery ); } } echo 'OK'; } function showMainPage() { global $_page; global $site; $_page['header'] = 'Page Builder'; $_page['css_name'] = 'pageBuilder.css'; $_page['extraCodeInHead'] = << BLAH; $_page['extraCodeInBody'] = <<