19 $GLOBALS[
'oAdmTemplate']->addJsTranslation(array(
20 '_adm_pbuilder_Reset_page_warning',
21 '_adm_pbuilder_Column_non_enough_width_warn',
22 '_adm_pbuilder_Column_delete_confirmation',
23 '_adm_pbuilder_Add_column',
24 '_adm_pbuilder_Want_to_delete',
29 $this -> sCacheFile = $sCacheFile;
34 case 'loadNewPageForm':
35 header(
'Content-Type: text/html; charset=utf-8');
40 header(
'Content-Type:text/javascript');
45 header(
'Content-Type:text/javascript');
46 echo json_encode(array(
'result' =>
$GLOBALS[
'MySQL']->query(
"INSERT INTO `sys_page_compose` (`Page`, `PageWidth`, `Desc`, `Caption`, `Column`, `Order`, `Func`, `Content`, `DesignBox`, `ColWidth`, `Visible`, `MinWidth`, `Cache`) VALUES ('', '1140px', 'Simple PHP Block', '_Code Block', 0, 0, 'Sample', 'Code', 11, 0, 'non,memb', 0, 0)") ?
'ok' :
'fail'));
49 case 'removeCodeBlock':
50 header(
'Content-Type:text/javascript');
51 echo json_encode(array(
'result' =>
$GLOBALS[
'MySQL']->query(
"DELETE FROM `sys_page_compose` WHERE `Func` = 'Sample' AND `Content` = 'Code'") ?
'ok' :
'fail'));
61 if (strlen($sPage) && in_array($sPage, $this->aPages)) {
67 $this -> sPage_db = addslashes( $this -> oPage -> sName );
71 header(
'Content-type:text/javascript' );
73 echo $this -> oPage -> getJSON();
76 case 'saveColsWidths':
77 if( is_array( $_POST[
'widths'] ) ) {
84 if( is_array( $_POST[
'columns'] ) ) {
91 $iBlockID = (int)$_POST[
'id'];
93 header(
'Content-type:text/html;charset=utf-8' );
99 if( (
int)$_POST[
'id'] ) {
105 case 'deleteCustomPage' :
106 header(
'Content-type:text/html;charset=utf-8' );
107 $sPage = isset($_POST[
'Page']) ? $_POST[
'Page'] :
'';
110 echo
_t(
'_Error Occured');
124 case 'checkNewBlock':
129 case 'savePageWidth':
136 case 'saveOtherPagesWidth':
138 setParam(
'main_div_width', $sWidth );
149 if($this -> bAjaxMode)
158 'css_name' => array(
'pageBuilder.css',
'forms_adv.css'),
159 'js_name' => array(
'jquery.ui.core.min.js',
'jquery.ui.widget.min.js',
'jquery.ui.mouse.min.js',
'jquery.ui.sortable.min.js',
'jquery.ui.slider.min.js',
'jquery.cookie.min.js',
'ChWsbPageBuilder.js'),
160 'header' =>
_t(
'_adm_pbuilder_title'),
161 'header_text' =>
_t(
'_adm_pbuilder_box_title'),
173 return array(
'code' =>
'1',
'message' =>
'Page with the name ' .
$_REQUEST[
'uri'] .
' already exists.');
180 $res =
db_res(
"INSERT INTO `{$this -> sDBTable}_pages` (`Name`, `Title`, `Order`, `System`) SELECT '{$sUri}', '$sTitle', MAX(`Order`) + 1, '0' FROM `{$this -> sDBTable}_pages` LIMIT 1");
182 return array(
'code' =>
'1',
'message' =>
'Failed database insert');
185 $oZ =
new ChWsbAlerts(
'page_builder',
'page_add', $iPageId, 0, array(
'uri' => $sUri));
188 return array(
'code' =>
'0',
'message' =>
'OK',
'uri' => $sUri);
194 $sQuery =
"UPDATE `{$this -> sDBTable}` SET `PageWidth` = '{$sPageWidth}' WHERE `Page` = '{$this -> sPage_db}'";
206 $oCacheBlocks = $oCacher->getBlocksCacheObject ();
208 $iBlockId.true.
'tab'.
false,
209 $iBlockId.false.
'tab'.
false,
210 $iBlockId.true.
'popup'.
false,
211 $iBlockId.false.
'popup'.
false,
212 $iBlockId.true.
'tab'.
true,
213 $iBlockId.false.
'tab'.
true,
214 $iBlockId.true.
'popup'.
true,
215 $iBlockId.false.
'popup'.
true
217 foreach ($a
as $sKey)
218 $oCacheBlocks->delData($oCacher->genBlocksCacheKey ($sKey));
225 $iBlockID = (int) $iBlockID;
227 $sQuery =
"SELECT `Desc`, `Caption`, `Func`, `Content`, `Visible`, `DesignBox` FROM `{$this -> sDBTable}` WHERE `ID` = '{$iBlockID}'";
230 if( $aBlock[
'Func'] ==
'Sample' ) {
231 if(substr($aBlock[
'Content'], 0, 7) ==
'Custom_') {
232 $sName = str_replace(
'Custom_',
'', $aBlock[
'Content']);
233 $sQuery =
"SELECT `Eval` FROM `sys_custom_code_blocks` WHERE `Name` = '$sName'";
234 $sBlockContent =
db_value( $sQuery );
239 INSERT INTO `{$this -> sDBTable}` SET
240 `Desc` = '" . addslashes( $aBlock[
'Desc'] ) .
"',
241 `Caption` = '" . addslashes( $aBlock[
'Caption'] ) .
"',
242 `Func` = '{$aBlock['Content']}',
243 `Content` = '" . addslashes($sBlockContent) .
"',
244 `Visible` = '{$aBlock['Visible']}',
245 `DesignBox` = '{$aBlock['DesignBox']}',
246 `Page` = '{$this -> sPage_db}'
259 $sQuery =
"DELETE `{$this -> sDBTable}_pages`, `{$this -> sDBTable}` FROM `{$this -> sDBTable}_pages`
260 LEFT JOIN `{$this -> sDBTable}` ON `{$this -> sDBTable}`.`Page` = `{$this -> sDBTable}_pages`.`Name`
261 WHERE `{$this -> sDBTable}_pages`.`Name` = '{$sPageName}'";
274 $iBlockID = (int) $iBlockID;
275 $aBlock =
db_assoc_arr(
"SELECT * FROM `{$this -> sDBTable}` WHERE `ID`='{$iBlockID}'");
276 if(
empty($aBlock) || !is_array($aBlock))
279 $sQuery =
"DELETE FROM `{$this -> sDBTable}` WHERE `Page` = '{$this -> sPage_db}' AND `ID`='{$iBlockID}'";
283 $oZ =
new ChWsbAlerts(
'page_builder',
'block_delete', $iBlockID, 0, array(
'page_uri' => $aBlock[
'Page']));
291 if( $this -> oPage -> bResetable ) {
292 $sQuery =
"DELETE FROM `{$this -> sDBTable}` WHERE `Page` = '{$this -> sPage_db}'";
296 $oZ =
new ChWsbAlerts(
'page_builder',
'page_reset', 0, 0, array(
'uri' => $this -> sPage_db));
300 echo (
int)$this -> oPage -> bResetable;
305 $iID = (int)$aData[
'id'];
307 $sQuery =
"SELECT `Func` FROM `{$this -> sDBTable}` WHERE `ID` = $iID";
313 $iDesignBox = isset($aData[
'DesignBox']) > 0 ? (int)$aData[
'DesignBox'] : 1;
314 $sVisible = is_array( $aData[
'Visible'] ) ? implode(
',', $aData[
'Visible'] ) :
'';
315 $iCache = (int)$aData[
'Cache'] > 0 ? (
int)$aData[
'Cache'] : 0;
317 if( $sFunc ==
'RSS' )
319 elseif( $sFunc ==
'Echo' || $sFunc ==
'Text' || $sFunc ==
'Code' || $sFunc ==
'TrueText')
321 elseif( $sFunc ==
'XML' ) {
322 $iApplicationID = (int)$aData[
'application_id'];
323 $sContentUpd =
"`Content` = '" . $iApplicationID .
"',";
324 } elseif( substr($sFunc, 0, 7) ==
'Custom_' ) {
325 $sName = str_replace(
'Custom_',
'', $sFunc);
326 $sQuery =
"SELECT `allow_eval_edit` FROM `sys_custom_code_blocks` WHERE `Name` = '$sName'";
327 $bAllowEdit = (int)
db_value( $sQuery );
335 UPDATE `{$this -> sDBTable}` SET
336 `Caption` = '{$sCaption}',
338 `DesignBox` = '{$iDesignBox}',
339 `Visible` = '{$sVisible}',
340 `Cache` = '{$iCache}'
341 WHERE `ID` = '{$iID}'
348 $oZ =
new ChWsbAlerts(
'page_builder',
'block_form_save', $iID, 0, array(
'data' => $aData,
'caption_key' => &
$sCaption));
357 foreach( $aWidths
as $iWidth ) {
359 $iWidth = (float)$iWidth;
361 $sQuery =
"UPDATE `{$this -> sDBTable}` SET `ColWidth` = $iWidth WHERE `Page` = '{$this -> sPage_db}' AND `Column` = $iCounter";
371 $sQuery =
"UPDATE `{$this -> sDBTable}` SET `Column` = 0, `Order` = 0 WHERE `Page` = '{$this -> sPage_db}'";
375 foreach( $aColumns
as $sBlocks ) {
378 $aBlocks = explode(
',', $sBlocks );
379 foreach( $aBlocks
as $iOrder => $iBlockID ) {
380 $iBlockID = (int)$iBlockID;
381 $sQuery =
"UPDATE `{$this -> sDBTable}` SET `Column` = $iColCounter, `Order` = $iOrder WHERE `ID` = $iBlockID AND `Page` = '{$this -> sPage_db}'";
391 return $GLOBALS[
'oAdmTemplate']->addCss(array(
'general.css',
'forms_adv.css',
'plugins/jquery/themes/|jquery-ui.css'),
true);
396 $sEditorId = $sEditorCode =
'';
401 $sEditorId =
'buildZoneEditor';
402 $sEditorCode = $oEditor->attachEditor(
'#' . $sEditorId,
CH_EDITOR_FULL);
405 return $GLOBALS[
'oAdmTemplate']->parseHtmlByName(
'pbuilder_content.html', array(
407 'ch_if:page' => array(
408 'condition' => (
bool)$this -> oPage,
410 'ch_if:delete_link' => array(
411 'condition' => (isset($this->oPage->isSystem) && !$this->oPage->isSystem),
415 'ch_if:view_link' => array(
416 'condition' => (isset($this->oPage->isSystem) && !$this->oPage->isSystem),
418 'site_url' =>
$GLOBALS[
'site'][
'url'],
419 'page_name' => (!isset($this->oPage->sName)) ?: htmlspecialchars($this->oPage->sName)
423 'page_name' => (!isset($this->oPage->sName)) ?: addslashes($this->oPage->sName),
424 'page_width_min' =>
getParam(
'sys_template_page_width_min'),
425 'page_width_max' =>
getParam(
'sys_template_page_width_max'),
426 'page_width' => (!isset($this->oPage->iPageWidth)) ?: $this->oPage->iPageWidth,
427 'main_width' =>
getParam(
'main_div_width')
430 'ch_if:empty' => array(
431 'condition' => !(
bool)$this -> oPage,
436 'ch_if:editor' => array(
437 'condition' => !
empty($sEditorCode),
439 'editor_id' => $sEditorId,
440 'editor_code' => $sEditorCode
448 $bPage = !
empty($this->oPage->sName);
452 'title' =>
_t(
'_adm_txt_pb_select_page'),
453 'selected' => !$bPage ?
'selected="selected"' :
''
457 asort($this->aTitles);
462 'selected' => (isset($this->oPage->sName) && $this->oPage->sName ==
$sName) ?
'selected="selected"' :
''
465 return $GLOBALS[
'oAdmTemplate']->parseHtmlByName(
'pbuilder_cpanel.html', array(
467 'ch_if:show_add_column' => array(
468 'condition' => $bPage,
477 $sPagesQuery =
"SELECT `Name`, `Title` FROM `{$this -> sDBTable}_pages` ORDER BY `Order`";
479 $rPages =
db_res( $sPagesQuery );
480 while( $aPage = $rPages->fetch() ) {
481 $this -> aPages[] = $aPage[
'Name'];
482 $this -> aTitles[$aPage[
'Name']] = $aPage[
'Title'];
488 if( isset( $_SERVER[
'HTTP_X_REQUESTED_WITH'] )
and $_SERVER[
'HTTP_X_REQUESTED_WITH'] ==
'XMLHttpRequest' )
489 $this -> bAjaxMode =
true;
494 $sNoPropertiesC =
_t(
'_adm_pbuilder_This_block_has_no_properties');
495 $sProfileFieldsC =
_t(
'_adm_pbuilder_Profile_Fields');
496 $sHtmlBlockC =
_t(
'_adm_pbuilder_HTML_Block');
497 $sXmlBlockC =
_t(
'_adm_pbuilder_XML_Block');
498 $sRssBlockC =
_t(
'_adm_pbuilder_RSS_Feed');
499 $sCustomBlockC =
_t(
'_adm_pbuilder_Custom_Block');
500 $sPhpBlockC =
_t(
'_adm_pbuilder_Code_Block');
501 $sTextBlockC =
_t(
'_adm_pbuilder_Text_Block');
502 $sTrueTextBlockC =
_t(
'_adm_pbuilder_TrueText_Block');
503 $sSpecialBlockC =
_t(
'_adm_pbuilder_Special_Block');
504 $sXmlPathC =
_t(
'_adm_pbuilder_XML_path');
505 $sUrlRssFeedC =
_t(
'_adm_pbuilder_Url_of_RSS_feed');
506 $sNumbRssItemsC =
_t(
'_adm_pbuilder_Number_RSS_items');
507 $sTypeC =
_t(
'_Type');
508 $sDescriptionC =
_t(
'_Description');
509 $sCaptionLangKeyC =
_t(
'_adm_pbuilder_Caption_Lang_Key');
510 $sDesignBoxLangKeyC =
_t(
'_adm_pbuilder_DesignBox_Lang_Key');
511 $sVisibleForC =
_t(
'_adm_mbuilder_Visible_for');
512 $sGuestC =
_t(
'_Guest');
513 $sMemberC =
_t(
'_Member');
515 $sQuery =
"SELECT * FROM `{$this -> sDBTable}` WHERE `Page` = '{$this -> sPage_db}' AND `ID` = $iBlockID";
521 'showclosebtn' =>
true,
523 'class' =>
'MsgBoxInfo ch-def-font-large',
524 'buttonclass' =>
'ch-btn',
526 'showtitleclose' =>
true,
527 'titletext' =>
'Info!',
528 'titleclass' =>
'MsgBoxTitleInfo ch-def-font-large',
530 'icon' =>
'info-circle',
531 'iconclass' =>
'sys-icon icon-large',
533 return AdvMsgBox($sNoPropertiesC, $aOptions);
536 $sPageName = htmlspecialchars($this->oPage->sName);
539 switch( $aItem[
'Func'] ) {
540 case 'PFBlock': $sBlockType = $sProfileFieldsC;
break;
541 case 'Echo': $sBlockType = $sHtmlBlockC;
break;
542 case 'Text': $sBlockType = $sTextBlockC;
break;
543 case 'TrueText': $sBlockType = $sTrueTextBlockC;
break;
544 case 'Code': $sBlockType = $sPhpBlockC;
break;
545 case 'XML': $sBlockType = $sXmlBlockC;
break;
546 case 'RSS': $sBlockType = $sRssBlockC;
break;
547 default: $sBlockType = $sSpecialBlockC;
break;
550 if($sBlockType == $sSpecialBlockC) {
551 if(substr($aItem[
'Func'], 0, 7) ==
'Custom_') $sBlockType = $sCustomBlockC;
554 $aVisibleValues = array();
555 if(strpos($aItem[
'Visible'],
'non') !==
false)
556 $aVisibleValues[] =
'non';
557 if(strpos( $aItem[
'Visible'],
'memb' ) !==
false)
558 $aVisibleValues[] =
'memb';
561 'form_attrs' => array(
562 'name' =>
'formItemEdit',
575 'value' => $iBlockID,
580 'value' =>
'saveItem',
585 'value' => (
int)$aItem[
'Cache'],
590 'caption' => $sTypeC,
591 'value' => $sBlockType,
596 'caption' => $sDescriptionC,
597 'value' => $aItem[
'Desc'],
602 'caption' => $sCaptionLangKeyC,
603 'value' => $aItem[
'Caption'],
606 'DesignBox' => array(
608 'name' =>
'DesignBox',
609 'caption' => $sDesignBoxLangKeyC,
610 'value' => $aItem[
'DesignBox'],
612 array(
'key' => 2,
'value' =>
_t(
'_adm_pbuilder_DesignBox_2')),
613 array(
'key' => 0,
'value' =>
_t(
'_adm_pbuilder_DesignBox_0')),
614 array(
'key' => 11,
'value' =>
_t(
'_adm_pbuilder_DesignBox_11')),
615 array(
'key' => 1,
'value' =>
_t(
'_adm_pbuilder_DesignBox_1')),
616 array(
'key' => 13,
'value' =>
_t(
'_adm_pbuilder_DesignBox_13')),
617 array(
'key' => 3,
'value' =>
_t(
'_adm_pbuilder_DesignBox_3')),
622 'type' =>
'checkbox_set',
623 'caption' => $sVisibleForC,
625 'value' => $aVisibleValues,
634 $sBlockContent = $aItem[
'Content'];
637 if( $aItem[
'Func'] ==
'Echo' ) {
638 $sMceEditorKey =
'ch_mce_editor_disabled';
639 $bMceEditor = !isset($_COOKIE[$sMceEditorKey]) || (int)$_COOKIE[$sMceEditorKey] != 1;
641 $aForm[
'inputs'][
'Content'] = array(
642 'type' =>
'textarea',
646 'attrs' => array (
'id' =>
'form_input_html'.$iBlockID,
'style' =>
'height:250px;'),
648 'value' => $sBlockContent,
651 } elseif( $aItem[
'Func'] ==
'Text' || $aItem[
'Func'] ==
'Code' || $aItem[
'Func'] ==
'TrueText') {
653 $aForm[
'inputs'][
'Content'] = array(
654 'type' =>
'textarea',
656 'value' => $sBlockContent,
660 } elseif( substr($aItem[
'Func'], 0, 7) ==
'Custom_' ) {
661 $sName = str_replace(
'Custom_',
'', $aItem[
'Func']);
662 $sQuery =
"SELECT `allow_eval_edit` FROM `sys_custom_code_blocks` WHERE `Name` = '$sName'";
663 $bAllowEdit = (int)
db_value( $sQuery );
665 $aForm[
'inputs'][
'Content'] = array(
666 'type' =>
'textarea',
668 'caption' =>
'<div class="ch-form-caption ch-def-font-inputs-captions">' .
_t(
'_adm_pbuilder_eval_code') .
'</div>',
669 'value' => $sBlockContent,
674 } elseif( $aItem[
'Func'] ==
'XML' ) {
675 $aExistedApplications =
ChWsbService::call(
'open_social',
'get_admin_applications', array());
677 $aForm[
'inputs'][
'Applications'] = array(
679 'name' =>
'application_id',
680 'caption' =>
_t(
'_osi_Existed_applications'),
681 'values' => $aExistedApplications
683 } elseif( $aItem[
'Func'] ==
'RSS' ) {
684 list(
$sUrl, $iNum ) = explode(
'#', $aItem[
'Content'] );
687 $aForm[
'inputs'][
'Url'] = array(
690 'caption' => $sUrlRssFeedC,
694 $aForm[
'inputs'][
'Num'] = array(
697 'caption' => $sNumbRssItemsC,
703 $aForm[
'inputs'][
'controls'] = array(
704 'type' =>
'input_set',
708 'value' =>
_t(
'_Save')
712 if ($aItem[
'Func'] ==
'RSS' || $aItem[
'Func'] ==
'Echo' || $aItem[
'Func'] ==
'Text' || $aItem[
'Func'] ==
'TrueText' || $aItem[
'Func'] ==
'Code' || $aItem[
'Func'] ==
'XML') {
713 $aForm[
'inputs'][
'controls'][] = array(
716 'value' =>
_t(
'_Delete')
720 if (substr($aItem[
'Func'], 0, 7) ==
'Custom_') {
721 $aForm[
'inputs'][
'controls'][] = array(
724 'value' =>
_t(
'_Delete')
728 $oZ =
new ChWsbAlerts(
'page_builder',
'block_form_display', $iBlockID, 0, array(
'form' => &
$aForm));
739 return $GLOBALS[
'oFunctions']->popupBox(
'adm-pbuilder-properties',
_t(
'_adm_pbuilder_Block'),
$sContent);
745 'form_attrs' => array(
746 'name' =>
'formItemEdit',
753 'name' =>
'action_sys',
754 'value' =>
'createNewPage',
759 'value' =>
'newpage',
760 'caption' =>
_t(
'_Page URI'),
761 'info' =>
_t(
'_adm_pbuilder_uri_info', CH_WSB_URL_ROOT .
'page/newpage'),
766 'caption' =>
_t(
'_Page title'),
767 'value' =>
'New Page',
768 'info' =>
_t(
'_adm_pbuilder_title_info'),
772 'name' =>
'do_submit',
773 'value' =>
_t(
'_adm_btn_Create_page'),
783 return $GLOBALS[
'oFunctions']->popupBox(
'adm-pbuilder-add-page',
_t(
'_adm_pbuilder_Create_new_page'),
$sContent);
807 $this -> sName = $sPage;
808 $this -> sName_db = addslashes( $this -> sName );
813 $this -> sDefaultSqlFile = CH_DIRECTORY_PATH_ROOT .
"{$admin_dir}/default_builders/{$this -> oParent -> sDBTable}_{$this -> sName}.sql";
814 $this -> bResetable = file_exists( $this -> sDefaultSqlFile );
823 $sQuery =
"SELECT `System` FROM `{$this -> oParent -> sDBTable}_pages` WHERE `Name` = '{$this -> sName_db}'";
824 $this->isSystem = (int)$MySQL->getOne($sQuery) == 1;
827 $sQuery =
"SELECT `PageWidth` FROM `{$this -> oParent -> sDBTable}` WHERE `Page` = '{$this -> sName_db}' LIMIT 1";
828 $this->iPageWidth = $MySQL->getOne($sQuery);
830 if(!$this->iPageWidth)
831 $this->iPageWidth =
'960px';
837 FROM `{$this -> oParent -> sDBTable}`
844 $aColumns = $MySQL->getAllWithKey($sQuery,
'Column', [$this -> sName_db]);
848 foreach($aColumns
as $aColumn) {
849 $iColumn = (int)$aColumn[
'Column'];
850 $this -> aColsWidths[$iColumn] = (float)$aColumn[
'ColWidth'];
851 $this -> aBlocks[$iColumn] = array();
852 $this -> aBlocksOrder[$iColumn]= array();
855 $sQueryActive =
"SELECT
858 FROM `{$this -> oParent -> sDBTable}`
864 $aBlocks = $MySQL->getAll($sQueryActive, [$this -> sName_db, $iColumn]);
866 $this->aBlocks[$iColumn][$aBlock[
'ID']] =
_t($aBlock[
'Caption']);
867 $this->aBlocksOrder[$iColumn][] = $aBlock[
'ID'];
872 $sQuery =
"SELECT `ID`, `MinWidth` FROM `{$this -> oParent -> sDBTable}` WHERE `MinWidth` > 0 AND `Page`= ?";
873 $aBlocks = $MySQL->getAll($sQuery, [$this -> sName_db]);
875 $this->aMinWidths[(int)$aBlock[
'ID']] = (
int)$aBlock[
'MinWidth'];
887 FROM `{$this -> oParent -> sDBTable}`
889 `Page` = '{$this -> sName_db}' AND
897 FROM `{$this -> oParent -> sDBTable}`
902 $rInactive =
db_res( $sQueryInactive );
903 $rSamples =
db_res( $sQuerySamples );
905 while( $aBlock = $rInactive ->fetch() )
906 $this -> aBlocksInactive[ (string)$aBlock[
'ID'] .
' '] =
_t( $aBlock[
'Caption'] );
908 while( $aBlock = $rSamples ->fetch() )
909 $this -> aBlocksSamples[ (int)$aBlock[
'ID'] ] =
_t( $aBlock[
'Caption'] );
911 asort($this -> aBlocksInactive, SORT_STRING | SORT_FLAG_CASE);
917 return json_encode($oPVAPageJSON);
934 $this -> widths = $oParent -> aColsWidths;
935 $this -> min_widths = $oParent -> aMinWidths;
936 $this -> active = $oParent -> aBlocks;
937 $this -> active_order = $oParent -> aBlocksOrder;
938 $this -> inactive = $oParent -> aBlocksInactive;
939 $this -> samples = $oParent -> aBlocksSamples;
950 $this -> sDBTable = $sDBTable;
959 $oCacheBlocks->removeAllByPrefix (
'pb_');
961 $sCacheString =
"// cache of Page View composer\n\nreturn array(\n //pages\n";
965 $sQuery =
"SELECT `Page` AS `Name` FROM `{$this -> sDBTable}` WHERE `Page` != '' GROUP BY `Page`";
967 $rPages =
db_res( $sQuery );
969 while ($aPageN = $rPages->fetch()) {
971 $aPageN[
'Title'] =
db_value(
"SELECT `Title` FROM `{$this -> sDBTable}_pages` WHERE `Name` = '$sPageName'");
973 $sPageWidth =
db_value(
"SELECT `PageWidth` FROM `{$this -> sDBTable}` WHERE `Page` = '$sPageName' LIMIT 1");
974 $sPageWidth =
empty($sPageWidth) ?
'998px' : $sPageWidth;
976 $sCacheString .=
" '$sPageName' => array(\n";
977 $sCacheString .=
" 'Title' => '$sPageTitle',\n";
978 $sCacheString .=
" 'Width' => '$sPageWidth',\n";
979 $sCacheString .=
" 'Columns' => array(\n";
985 FROM `{$this -> sDBTable}`
991 $aColumns = $MySQL->getAllWithKey($sQuery,
'Column', [
$sPageName]);
995 foreach($aColumns
as $aColumn) {
996 $iColumn = $aColumn[
'Column'];
997 $iColWidth = $aColumn[
'ColWidth'];
999 $sCacheString .=
" $iColumn => array(\n";
1000 $sCacheString .=
" 'Width' => $iColWidth,\n";
1001 $sCacheString .=
" 'Blocks' => array(\n";
1012 FROM `{$this -> sDBTable}`
1016 ORDER BY `Order` ASC";
1017 $aBlocks = $MySQL->getAll($sQuery, [
$sPageName, $iColumn]);
1019 foreach($aBlocks
as $aBlock) {
1020 $sCacheString .=
" {$aBlock['ID']} => array(\n";
1022 $sCacheString .=
" 'Func' => '{$aBlock['Func']}',\n";
1023 $sCacheString .=
" 'Content' => '" . $this ->
addSlashes( $aBlock[
'Content'] ) .
"',\n";
1024 $sCacheString .=
" 'Caption' => '" . $this ->
addSlashes( $aBlock[
'Caption'] ) .
"',\n";
1025 $sCacheString .=
" 'Visible' => '{$aBlock['Visible']}',\n";
1026 $sCacheString .=
" 'DesignBox' => {$aBlock['DesignBox']},\n";
1027 $sCacheString .=
" 'Cache' => {$aBlock['Cache']}\n";
1029 $sCacheString .=
" ),\n";
1031 $sCacheString .=
" )\n";
1032 $sCacheString .=
" ),\n";
1035 $sCacheString .=
" )\n";
1036 $sCacheString .=
" ),\n";
1039 $sCacheString .=
");\n";
1043 $oCache = $MySQL->getDbCacheObject();
1044 $oCache->setData ($MySQL->genDbCacheKey($this -> sCacheFile),
$aResult);
1051 $sText = str_replace(
'\\',
'\\\\', $sText );
1052 $sText = str_replace(
'\'',
'\\\'', $sText );
1059 if ($this->oBlocksCacheObject !=
null) {
1062 $sEngine =
getParam(
'sys_pb_cache_engine');
1063 $this->oBlocksCacheObject =
ch_instance (
'ChWsbCache'.$sEngine);
1064 if (!$this->oBlocksCacheObject->isAvailable())
1065 $this->oBlocksCacheObject =
ch_instance (
'ChWsbCacheFile');