BxBasePage.php 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. require_once(BX_DIRECTORY_PATH_INC . 'design.inc.php');
  10. /**
  11. * Page representation.
  12. * @see BxDolPage
  13. */
  14. class BxBasePage extends BxDolPage
  15. {
  16. protected $_oTemplate;
  17. protected $_sStorage; //--- Storage object for page's images like custom cover, HTML block attachments, etc.
  18. protected $_oPageCacheObject = null;
  19. protected $_oBlockCacheObject = null;
  20. protected $_sJsClassName = '';
  21. protected $_sJsObjectName = '';
  22. protected $_aHtmlIds = [];
  23. protected $_bStickyColumns = false;
  24. protected $_bSubPage = false;
  25. public function __construct ($aObject, $oTemplate)
  26. {
  27. parent::__construct ($aObject);
  28. if ($oTemplate)
  29. $this->_oTemplate = $oTemplate;
  30. else
  31. $this->_oTemplate = BxDolTemplate::getInstance();
  32. $this->_sStorage = 'sys_images';
  33. $this->_sJsClassName = 'BxDolPage';
  34. $this->_sJsObjectName = 'oBxDolPage';
  35. $this->_bStickyColumns = isset($this->_aObject['sticky_columns']) && $this->_aObject['sticky_columns'] == 1;
  36. $sHtmlId = str_replace(array('_' , ' '), array('-', '-'), $this->_sObject);
  37. $this->_aHtmlIds = array(
  38. 'help_popup' => $sHtmlId . '-help-popup-',
  39. );
  40. $this->addMarkers(array('site_title' => getParam('site_title')));
  41. }
  42. public function performActionGetHelp ()
  43. {
  44. $iBlockId = (int)bx_get('block_id');
  45. if(empty($iBlockId))
  46. return;
  47. $aBlock = $this->_oQuery->getPageBlock($iBlockId);
  48. if(empty($aBlock) || !is_array($aBlock) || empty($aBlock['help']))
  49. return;
  50. echo $this->_oTemplate->parseHtmlByName('designbox_help_popup.html', array(
  51. 'content' => _t($aBlock['help'])
  52. ));
  53. }
  54. public function performActionGetShare ()
  55. {
  56. $aEmbedData = BxDolPage::getEmbedData(bx_get('url'));
  57. if(!isset($aEmbedData['url']))
  58. return;
  59. $sMenu = '';
  60. if(getParam('sys_a2a_enable') != 'on') {
  61. if(($oMenu = BxDolMenu::getObjectInstance('sys_social_sharing')) !== false) {
  62. $oMenu->addMarkers([
  63. 'url' => $aEmbedData['url'],
  64. 'img_url_encoded' => '',
  65. 'title_encoded' => ''
  66. ]);
  67. $sMenu = $oMenu->getCode();
  68. }
  69. }
  70. else
  71. $sMenu = getParam('sys_a2a_code');
  72. echo PopupBox('sys_share_popup', _t('_sys_txt_share_popup_header'), $this->_oTemplate->parseHtmlByName('designbox_share_popup.html', [
  73. 'url' => bx_process_output($aEmbedData['url']),
  74. 'menu' => $sMenu,
  75. 'code' => htmlspecialchars($aEmbedData['html']),
  76. ]), true);
  77. }
  78. public function performActionEmbed ()
  79. {
  80. $aCover = $this->getPageCoverImage();
  81. $sTitle = $this->_getPageTitle();
  82. $this->_oTemplate->getEmbed($this->_oTemplate->parseHtmlByName('embed_card.html', [
  83. 'title' => $sTitle,
  84. 'url' => BxDolPermalinks::getInstance()->permalink($this->_aObject['url']),
  85. 'bx_if:thumb' => [
  86. 'condition' => $this->isPageCover() && count($aCover) > 0,
  87. 'content' => [
  88. 'title' => $sTitle,
  89. 'url' => BxDolPermalinks::getInstance()->permalink($this->_aObject['url']),
  90. 'background' => BxDolCover::getInstance(BxDolTemplate::getInstance())->getCoverImageUrl($aCover)
  91. ],
  92. ],
  93. 'bx_if:no_thumb' => [
  94. 'condition' => count($aCover) == 0 || !$this->isPageCover(),
  95. 'content' => [
  96. 'title' => $sTitle,
  97. 'url' => BxDolPermalinks::getInstance()->permalink($this->_aObject['url']),
  98. ]
  99. ]
  100. ]
  101. ));
  102. }
  103. /**
  104. * Very similar to BxBasePage::getCode
  105. * but adds css and js files which are needed for the corect page display
  106. */
  107. public function getCodeDynamic ()
  108. {
  109. // TODO: remake to use use collect* template methods
  110. $oTemplate = BxDolTemplate::getInstance();
  111. // get js&css before the page code is generated
  112. $aCssBefore = $oTemplate->getCss();
  113. $aJsBefore = $oTemplate->getJs();
  114. // generate page code
  115. $sContent = $this->getCode();
  116. // get js&css after the page code is generated
  117. $aCssAfter = $oTemplate->getCss();
  118. $aJsAfter = $oTemplate->getJs();
  119. // compare files which were added before and after page code is generated
  120. $f = function ($a1, $a2) {
  121. return strcasecmp($a1['url'], $a2['url']);
  122. };
  123. $aCssNew = array_udiff($aCssAfter, $aCssBefore, $f);
  124. $aJsNew = array_udiff($aJsAfter, $aJsBefore, $f);
  125. // add newly added js&css files in static mode
  126. $sCss = $sJs = '';
  127. foreach ($aCssNew as $a)
  128. $sCss .= $oTemplate->addCss($a['url'], true);
  129. foreach ($aJsNew as $a)
  130. $sJs .= $oTemplate->addJs($a['url'], true);
  131. return $sJs . $sCss . $sContent;
  132. }
  133. /**
  134. * Get page code with automatic caching, adding necessary css/js files and system template vars.
  135. * @return string.
  136. */
  137. public function getCode ()
  138. {
  139. if (bx_get('dynamic') && ($iBlockId = (int)bx_get('pageBlock'))) {
  140. if (self::isLockedFromUnauthenticated($this->_aObject['uri']) || !$this->_isVisiblePage($this->_aObject)) {
  141. header('HTTP/1.0 403 Forbidden');
  142. exit;
  143. }
  144. bx_alert('system', 'page_output_block', 0, false, array(
  145. 'page_name' => $this->_sObject,
  146. 'page_object' => $this,
  147. 'page_query' => $this->_oQuery,
  148. 'block_id' => (int)$iBlockId,
  149. ));
  150. header( 'Content-type:text/html;charset=utf-8' );
  151. BxDolTemplate::getInstance()->collectingStart();
  152. $s = $this->_getBlockOnlyCode($iBlockId);
  153. $sCss = bx_get('includedCss');
  154. $sJs = bx_get('includedJs');
  155. echo BxDolTemplate::getInstance()->collectingEndGetCode($sCss ? @json_decode($sCss) : [], $sJs ? @json_decode($sJs) : []);
  156. echo $s;
  157. exit;
  158. }
  159. if (($mixedAvailable = $this->_isAvailablePage($this->_aObject)) !== true)
  160. return $this->_getPageNotFoundMsg($mixedAvailable);
  161. if (($mixedVisible = $this->_isVisiblePage($this->_aObject)) !== true)
  162. return $this->_getPageAccessDeniedMsg($mixedVisible);
  163. $this->_addJsCss();
  164. if (!$this->_bSubPage) {
  165. $this->_addSysTemplateVars();
  166. $this->_selectMenu();
  167. $this->_setSubmenu(array());
  168. }
  169. if (bx_is_dbg() || !getParam('sys_page_cache_enable') || !$this->_aObject['cache_lifetime'] || (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST')) {
  170. $sPageCode = $this->_getPageCode();
  171. }
  172. else {
  173. $oCache = $this->_getPageCacheObject();
  174. $sKey = $this->_getPageCacheKey();
  175. $sKeyCssJs = 'cssjs_' . $sKey;
  176. $mixedRet = $oCache->getData($sKey, $this->_aObject['cache_lifetime']);
  177. $aRetCssJs = $oCache->getData($sKeyCssJs, $this->_aObject['cache_lifetime']);
  178. if ($mixedRet !== null && $aRetCssJs !== null) {
  179. BxDolTemplate::getInstance()->collectingStart();
  180. BxDolTemplate::getInstance()->collectingInject($aRetCssJs['css'], $aRetCssJs['js']);
  181. $sPageCode = BxDolTemplate::getInstance()->collectingEndGetCode();
  182. $sPageCode .= $mixedRet;
  183. } else {
  184. BxDolTemplate::getInstance()->collectingStart();
  185. $sPageCode = $this->_getPageCode();
  186. $aPageCssJs = BxDolTemplate::getInstance()->collectingEndGetCode(array(), array(), 'array');
  187. $oCache->setData($sKey, $sPageCode, $this->_aObject['cache_lifetime']);
  188. $oCache->setData($sKeyCssJs, $aPageCssJs, $this->_aObject['cache_lifetime']);
  189. }
  190. }
  191. bx_alert('system', 'page_output', 0, false, array(
  192. 'page_name' => $this->_sObject,
  193. 'page_object' => $this,
  194. 'page_query' => $this->_oQuery,
  195. 'page_code' => &$sPageCode,
  196. 'sub_page' => $this->_bSubPage,
  197. ));
  198. if (!$this->_bSubPage)
  199. $sPageCode .= $this->getJsScript();
  200. return $sPageCode;
  201. }
  202. public function getJsClassName()
  203. {
  204. return $this->_sJsClassName;
  205. }
  206. public function getJsObjectName()
  207. {
  208. return $this->_sJsObjectName;
  209. }
  210. function _wrapInTagJsCode($sCode)
  211. {
  212. return "<script language=\"javascript\">\n<!--\n" . $sCode . "\n-->\n</script>";
  213. }
  214. public function getJsScript()
  215. {
  216. $sJsObjName = $this->getJsObjectName();
  217. $sJsObjClass = $this->getJsClassName();
  218. $sCode = "if(window['" . $sJsObjName . "'] == undefined) var " . $sJsObjName . " = new " . $sJsObjClass . "(" . json_encode(array(
  219. 'sObjName' => $sJsObjName,
  220. 'sObject' => $this->_sObject,
  221. 'sRootUrl' => BX_DOL_URL_ROOT,
  222. 'aHtmlIds' => $this->_aHtmlIds,
  223. 'isStickyColumns' => $this->_bStickyColumns
  224. )) . ");";
  225. return $this->_wrapInTagJsCode($sCode);
  226. }
  227. /**
  228. * Is page cover enabled.
  229. * @return string
  230. */
  231. public function isPageCover()
  232. {
  233. $bResult = false;
  234. switch((int)$this->_aObject['cover']) {
  235. case 1: //--- Enabled for all
  236. $bResult = true;
  237. break;
  238. case 2: //--- Enabled for visitors only
  239. $bResult = !isLogged();
  240. break;
  241. case 3: //--- Enabled for members only
  242. $bResult = isLogged();
  243. break;
  244. }
  245. return $bResult;
  246. }
  247. public function setSubPage($b = true)
  248. {
  249. $this->_bSubPage = $b;
  250. }
  251. public function setPageCover($bCover = true)
  252. {
  253. $this->_aObject['cover'] = (bool)$bCover;
  254. }
  255. public function getPageCoverImage($bTranscoder = true)
  256. {
  257. $iId = (int)$this->_aObject['cover_image'];
  258. if(empty($iId)) {
  259. $iId = (int)getParam('sys_site_cover_common');
  260. if(empty($iId))
  261. return array();
  262. }
  263. $aResult = array(
  264. 'id' => $iId
  265. );
  266. if($bTranscoder)
  267. $aResult['transcoder'] = BX_DOL_TRANSCODER_OBJ_COVER;
  268. else
  269. $aResult['object'] = $this->_sStorage;
  270. return $aResult;
  271. }
  272. public function getPageCoverParams()
  273. {
  274. $aParams = [
  275. 'title' => $this->_getPageTitle(),
  276. 'actions' => '',
  277. 'bx_if:image' => [
  278. 'condition' => false,
  279. 'content' => []
  280. ],
  281. 'bx_if:icon' => [
  282. 'condition' => false,
  283. 'content' => []
  284. ],
  285. ];
  286. if(($oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu')) !== false) {
  287. $aCoverParams = $oMenuSubmenu->getPageCoverParams();
  288. if(!empty($aCoverParams) && is_array($aCoverParams))
  289. $aParams = $aCoverParams;
  290. }
  291. if(!empty($this->_aObject['cover_title'])) {
  292. $sCoverTitle = _t($this->_aObject['cover_title']);
  293. if($sCoverTitle && strcmp($sCoverTitle, $this->_aObject['cover_title']) != 0)
  294. $aParams['title'] = $sCoverTitle;
  295. }
  296. return $aParams;
  297. }
  298. /**
  299. * Get block title.
  300. * @return string
  301. */
  302. public function getBlockTitle ($aBlock)
  303. {
  304. return $this->_replaceMarkers(_t($aBlock['title']), array('block_id' => $aBlock['id']));
  305. }
  306. /**
  307. * Get help control if help is available for the block.
  308. * @return string
  309. */
  310. public function getBlockHelp ($aBlock)
  311. {
  312. if(empty($aBlock['help']) || empty(strip_tags(_t($aBlock['help']))))
  313. return '';
  314. return $this->_oTemplate->parseHtmlByName('designbox_help.html', array(
  315. 'js_object' => $this->_sJsObjectName,
  316. 'block_id' => $aBlock['id']
  317. ));
  318. }
  319. /**
  320. * Get code to load block asyncroniously
  321. * @param $aBlock block code
  322. * @param $iAsync if greater than 0 the it defines loading indicator for the block
  323. * @return HTML code string
  324. */
  325. public function getBlockAsyncCode($aBlock, $iAsync)
  326. {
  327. $aContentPlaceholder = $this->_oQuery->getPageBlockContentPlaceholder($iAsync);
  328. if (!$aContentPlaceholder)
  329. return _t('_sys_txt_error_occured');
  330. $oTemplate = $this->_oTemplate;
  331. if ('system' != $aContentPlaceholder['module']) {
  332. $oModule = BxDolModule::getInstance($aContentPlaceholder['module']);
  333. if (!$oModule)
  334. return _t('_sys_txt_error_occured');
  335. $oTemplate = $oModule->_oTemplate;
  336. }
  337. return $oTemplate->parseHtmlByName($aContentPlaceholder['template'], $aBlock);
  338. }
  339. /**
  340. * Get page array with all cells and blocks
  341. */
  342. public function getPageAPI ($aBlocks = [])
  343. {
  344. define('BX_API_PAGE', true);
  345. $query_string = '';
  346. if (isset(bx_get('params')[2]) && bx_get('params')[2] != ''){
  347. $array = json_decode(bx_get('params')[2], true);
  348. $query_string = http_build_query($array);
  349. parse_str($query_string, $_GET);
  350. }
  351. $sMetaTitle = $this->_getPageMetaTitle();
  352. $sName = $this->_getPageTitle();
  353. $a = [
  354. 'id' => $this->_aObject['id'],
  355. 'title' => $sMetaTitle ? $sMetaTitle : $sName,
  356. 'name' => $sName,
  357. 'uri' => $this->_aObject['uri'],
  358. 'url' => ((bx_get('params')[0] ? bx_get('params')[0] : $this->_aObject['uri'] ) . ($query_string != '' ? '?' . $query_string : '')),
  359. 'author' => $this->_aObject['author'],
  360. 'added' => $this->_aObject['added'],
  361. 'module' => $this->getModule(),
  362. 'type' => $this->getType (),
  363. 'layout' => str_replace('.html', '', $this->_aObject['template']),
  364. 'cover_block' => '',
  365. 'menu_top' => '',
  366. 'menu' => '',
  367. 'menu_bottom' => '',
  368. 'menu_add' => '',
  369. 'elements' => $this->getPageBlocksAPI($aBlocks),
  370. ];
  371. if (BxDolCover::getInstance($this)->isCover() && isset($this->_aProfileInfo)) {
  372. $oModule = BxDolModule::getInstance($this->getModule());
  373. $aContentInfo = bx_srv($this->getModule(), 'get_info', [$this->_aProfileInfo['content_id'], false]);
  374. $a['cover_block'] = [
  375. 'profile' => BxDolProfile::getData($this->_aProfileInfo['id'], [
  376. 'get_avatar' => 'getAvatarBig',
  377. 'with_info' => true
  378. ]),
  379. 'actions_menu' => '',
  380. 'meta_menu' => '',
  381. 'badges' => BxDolProfile::getInstance($this->_aProfileInfo['id'])->getBadges(),
  382. 'cover' => $oModule->serviceGetCover($this->_aProfileInfo['content_id']),
  383. 'allow_edit' => $oModule->checkAllowedChangeCover($aContentInfo) === CHECK_ACTION_RESULT_ALLOWED
  384. ];
  385. $CNF = $oModule->_oConfig->CNF;
  386. if(!empty($CNF['OBJECT_MENU_VIEW_ENTRY_META'])){
  387. $oMetaMenu = BxTemplMenu::getObjectInstance($CNF['OBJECT_MENU_VIEW_ENTRY_META']);
  388. $a['cover_block']['meta_menu'] = $oMetaMenu->getCodeAPI();
  389. }
  390. $oConnection = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTIONS']);
  391. if ($oConnection){
  392. $a['cover_block']['members_list'] = $oConnection->getConnectedListAPI($this->_aProfileInfo['id'], false, BX_CONNECTIONS_CONTENT_TYPE_INITIATORS, 10);
  393. }
  394. if(!empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY'])){
  395. $oActionMenu = BxTemplMenu::getObjectInstance($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_ALL']);
  396. $a['cover_block']['actions_menu'] = $oActionMenu->getCodeAPI();
  397. }
  398. }
  399. $sMenuTop = getParam('sys_api_menu_top');
  400. if (!empty($sMenuTop) && ($oMenuTop = BxDolMenu::getObjectInstance($sMenuTop)) !== false)
  401. $a['menu_top'] = $oMenuTop->getCodeAPI();
  402. if (($oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu')) !== false) {
  403. if(($sSubmenu = $this->getSubMenu()) !== '')
  404. $oMenuSubmenu->setObjectSubmenu($sSubmenu, []);
  405. $a['menu'] = $oMenuSubmenu->getCodeAPI();
  406. }
  407. if (isLogged()) {
  408. /* temporatery commented
  409. if(($oMenuAddContent = BxDolMenu::getObjectInstance('sys_add_content')) !== false)
  410. $a['menu_add'] = $oMenuAddContent->getCodeAPI();
  411. */
  412. $o = BxDolProfile::getInstance();
  413. $oAccount = $o->getAccountObject();
  414. $a['user'] = [
  415. 'id' => $o->id(),
  416. 'email' => $o->getAccountObject()->getEmail(),
  417. 'display_name' => $o->getDisplayName(),
  418. 'url' => bx_api_get_relative_url($o->getUrl()),
  419. 'avatar' => $o->getAvatar(),
  420. 'settings' => $o->getSettings(),
  421. //'level' => BxDolAcl::getInstance()->getMemberMembershipInfo($o->id()),
  422. 'moderator' => (bool)BxDolAcl::getInstance()->isMemberLevelInSet([MEMBERSHIP_ID_ADMINISTRATOR, MEMBERSHIP_ID_MODERATOR], $o->id()),
  423. 'operator' => isAdmin(),
  424. //'info' => $o->getInfo(),
  425. 'confirmed' => $oAccount->isConfirmed(),
  426. 'notifications' => 0,
  427. 'cart' => 0,
  428. 'active' => $o->isActive(),
  429. 'status' => $o->getStatus(),
  430. ];
  431. $oInformer = BxDolInformer::getInstance(BxDolTemplate::getInstance());
  432. $sRet = $oInformer ? $oInformer->display() : '';
  433. if ($sRet){
  434. $a['user']['informer'] = $sRet;
  435. }
  436. $sModuleNotifications = 'bx_notifications';
  437. if(BxDolRequest::serviceExists($sModuleNotifications, 'get_unread_notifications_num'))
  438. $a['user']['notifications'] = bx_srv($sModuleNotifications, 'get_unread_notifications_num', [$o->id()]);
  439. $oPayments = BxDolPayments::getInstance();
  440. if($oPayments->isActive())
  441. $a['user']['cart'] = $oPayments->getCartItemsCount();
  442. }
  443. $aExtras = [
  444. 'page' => $this,
  445. 'blocks' => $aBlocks,
  446. 'data' => &$a,
  447. ];
  448. if(!$this->_isAvailablePage($this->_aObject))
  449. $a['page_status'] = 404;
  450. else if(!$this->_isVisiblePage($this->_aObject))
  451. $a['page_status'] = 403;
  452. bx_alert('system', 'get_page_api', 0, 0, $aExtras);
  453. return $a;
  454. }
  455. public function getPageBlocksAPI($aBlocks = [])
  456. {
  457. $bBlocks = !empty($aBlocks) && is_array($aBlocks);
  458. $aFieldsUnset = ['object', 'cell_id', 'title_system', 'class', 'submenu', 'tabs', 'async', 'visible_for_levels', 'hidden_on', 'type', 'text', 'text_updated', 'help', 'cache_lifetime', 'active', 'active_api', 'copyable', 'deletable', 'order'];
  459. $aCells = $this->_oQuery->getPageBlocks(true);
  460. foreach($aCells as $sKey => &$aCell) {
  461. foreach($aCell as $i => $aBlock) {
  462. if(!$this->_isVisibleBlock($aBlock)) {
  463. unset($aCells[$sKey][$i]);
  464. continue;
  465. }
  466. $this->processPageBlock($aCells[$sKey][$i], true);
  467. $aBlock = $aCells[$sKey][$i];
  468. $sSource = '';
  469. if($aBlock['type'] == 'service') {
  470. $aContent = @unserialize($aBlock['content']);
  471. if(isset($aContent['module'], $aContent['method']))
  472. $sSource = $aContent['module'] . ':' . $aContent['method'];
  473. }
  474. else{
  475. $sSource = 'system:block_' . $aBlock['id'];
  476. }
  477. if($bBlocks && !in_array($sSource, $aBlocks)) {
  478. unset($aCells[$sKey][$i]);
  479. continue;
  480. }
  481. $sFunc = '_getBlock' . ucfirst($aBlock['type']);
  482. $mBlock = method_exists($this, $sFunc) ? $this->$sFunc($aBlock) : $aBlock['content'];
  483. $aCells[$sKey][$i] = array_merge($aCells[$sKey][$i], [
  484. 'title' => isset($mBlock['title']) ? $mBlock['title'] : $this->getBlockTitle($aBlock),
  485. 'content' => isset($mBlock['content']) ? $mBlock['content'] : $mBlock,
  486. 'menu' => isset($mBlock['menu']) ? $mBlock['menu'] : '',
  487. 'source' => $sSource
  488. ]);
  489. $aCells[$sKey][$i] = array_diff_key($aCells[$sKey][$i], array_flip($aFieldsUnset));
  490. }
  491. }
  492. return array_map('array_values', $aCells);
  493. }
  494. /**
  495. * Get page code vars
  496. * @return string
  497. */
  498. protected function _getPageCodeVars ()
  499. {
  500. $aHiddenOn = array(
  501. pow(2, BX_DB_HIDDEN_PHONE - 1) => 'bx-def-media-phone-hide',
  502. pow(2, BX_DB_HIDDEN_TABLET - 1) => 'bx-def-media-tablet-hide',
  503. pow(2, BX_DB_HIDDEN_DESKTOP - 1) => 'bx-def-media-desktop-hide',
  504. pow(2, BX_DB_HIDDEN_MOBILE - 1) => 'bx-def-mobile-app-hide'
  505. );
  506. $aVars = array (
  507. 'page_id' => 'bx-page-' . $this->_aObject['uri'],
  508. 'bx_if:show_layout_row_dump' => array(
  509. 'condition' => false,
  510. 'content' => array()
  511. )
  512. );
  513. $aBlocks = $this->_oQuery->getPageBlocks();
  514. foreach ($aBlocks as $sKey => $aCell) {
  515. $sCell = '';
  516. foreach ($aCell as $aBlock) {
  517. $this->processPageBlock($aBlock, false);
  518. $sContentWithBox = $this->_getBlockCodeWithCache($aBlock, $aBlock['async']);
  519. $sClassAdd = '';
  520. if(!empty($aBlock['class']))
  521. $sClassAdd .= ' ' . $aBlock['class'];
  522. if(!empty($aBlock['hidden_on']))
  523. foreach($aHiddenOn as $iHiddenOn => $sHiddenOnClass)
  524. if((int)$aBlock['hidden_on'] & $iHiddenOn)
  525. $sClassAdd .= ' ' . $sHiddenOnClass;
  526. if ($sContentWithBox)
  527. $sCell .= $this->_oTemplate->parseHtmlByName('designbox_container.html', array(
  528. 'class_add' => $sClassAdd,
  529. 'bx_if:show_html_id' => array(
  530. 'condition' => true,
  531. 'content' => array(
  532. 'html_id' => 'bx-page-block-' . $aBlock['id']
  533. ),
  534. ),
  535. 'content' => $sContentWithBox
  536. ));
  537. }
  538. $aVars[$sKey] = $sCell;
  539. }
  540. return $aVars;
  541. }
  542. /**
  543. * Process block values, especially if someting need to be overrided
  544. */
  545. protected function processPageBlock(&$aBlock, $bApi = false)
  546. {
  547. }
  548. /**
  549. * Get page code only.
  550. * @return string
  551. */
  552. protected function _getPageCode ()
  553. {
  554. $aVars = $this->_getPageCodeVars ();
  555. return $this->_oTemplate->parseHtmlByName($this->_aObject['template'], $aVars);
  556. }
  557. /**
  558. * Get one block code only.
  559. * @return string
  560. */
  561. protected function _getBlockOnlyCode ($iBlockId)
  562. {
  563. if (!($aBlock = $this->_oQuery->getPageBlock((int)$iBlockId)))
  564. return '';
  565. return $this->_getBlockCodeWithCache($aBlock, 0);
  566. }
  567. protected function _getBlockCodeWithCache(&$aBlock, $iAsync = 0)
  568. {
  569. if (bx_is_dbg() || !getParam('sys_pb_cache_enable') || !$aBlock['cache_lifetime'] || $iAsync || (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST')) {
  570. $sBlockCode = $this->_getBlockCode($aBlock, $iAsync);
  571. }
  572. else {
  573. $oCache = $this->_getBlockCacheObject();
  574. $sKey = $this->_getBlockCacheKey(false, $aBlock);
  575. $sKeyCssJs = 'cssjs_' . $sKey;
  576. $mixedRet = $oCache->getData($sKey, $aBlock['cache_lifetime']);
  577. $aRetCssJs = $oCache->getData($sKeyCssJs, $aBlock['cache_lifetime']);
  578. if ($mixedRet !== null && $aRetCssJs !== null) {
  579. BxDolTemplate::getInstance()->collectingStart();
  580. BxDolTemplate::getInstance()->collectingInject($aRetCssJs['css'], $aRetCssJs['js']);
  581. $sBlockCode = BxDolTemplate::getInstance()->collectingEndGetCode();
  582. $sBlockCode .= $mixedRet;
  583. } else {
  584. BxDolTemplate::getInstance()->collectingStart();
  585. $sBlockCode = $this->_getBlockCode($aBlock, $iAsync);
  586. $aBlockCssJs = BxDolTemplate::getInstance()->collectingEndGetCode(array(), array(), 'array');
  587. $oCache->setData($sKey, $sBlockCode, $aBlock['cache_lifetime']);
  588. $oCache->setData($sKeyCssJs, $aBlockCssJs, $aBlock['cache_lifetime']);
  589. }
  590. }
  591. return $sBlockCode;
  592. }
  593. /**
  594. * Get block code.
  595. * @return string
  596. */
  597. protected function _getBlockCode(&$aBlock, $iAsync = 0)
  598. {
  599. $sContentWithBox = '';
  600. $oFunctions = $this->_oTemplate->getTemplateFunctions();
  601. if (isset($GLOBALS['bx_profiler'])) $GLOBALS['bx_profiler']->beginPageBlock(_t($aBlock['title']), $aBlock['id']);
  602. $aDbNoTitle = [BX_DB_CONTENT_ONLY, BX_DB_PADDING_CONTENT_ONLY, BX_DB_NO_CAPTION, BX_DB_PADDING_NO_CAPTION];
  603. $sTitle = $this->getBlockTitle($aBlock);
  604. $sHelp = $this->getBlockHelp($aBlock);
  605. $sFunc = '_getBlock' . ucfirst($aBlock['type']);
  606. $bBlockVisible = $this->_isVisibleBlock($aBlock);
  607. if ($iAsync && $bBlockVisible) {
  608. $iDesignboxId = $aBlock['designbox_id'];
  609. $sHelpTitle = $sHelpContent = '';
  610. if(!in_array($iDesignboxId, $aDbNoTitle))
  611. $sHelpTitle = $sHelp;
  612. else
  613. $sHelpContent = $sHelp;
  614. $sContent = $this->getBlockAsyncCode($aBlock, $iAsync);
  615. $aParams = array(
  616. $sTitle . $sHelpTitle,
  617. $sContent . $sHelpContent,
  618. $iDesignboxId
  619. );
  620. $sContentWithBox = call_user_func_array(array($oFunctions, 'designBoxContent'), $aParams);
  621. }
  622. elseif ($bBlockVisible && method_exists($this, $sFunc)) {
  623. $mixedContent = $this->$sFunc($aBlock);
  624. if(!empty($aBlock['content_empty'])) {
  625. $sEmpty = _t($aBlock['content_empty']);
  626. $sRegExp = '/(<[A-Za-z0-9]+\b.[^<]*[\pPi\pPf]bx\-msg\-box\b.*[\pPi\pPf][^>]*>)(' . _t('_Empty') . ')(<\/[A-Za-z0-9]+>)/su';
  627. if(is_string($mixedContent))
  628. $mixedContent = preg_replace($sRegExp, "\${1}" . $sEmpty . "\${3}", $mixedContent);
  629. else if(is_array($mixedContent) && !empty($mixedContent['content']))
  630. $mixedContent['content'] = preg_replace($sRegExp, "\${1}" . $sEmpty . "\${3}", $mixedContent['content']);
  631. }
  632. $this->_oQuery->setReadOnlyMode(true);
  633. if(is_array($mixedContent) && !empty($mixedContent['content'])) {
  634. $iDesignboxId = isset($mixedContent['designbox_id']) ? $mixedContent['designbox_id'] : $aBlock['designbox_id'];
  635. $sHelpTitle = $sHelpContent = '';
  636. if(!in_array($iDesignboxId, $aDbNoTitle))
  637. $sHelpTitle = $sHelp;
  638. else
  639. $sHelpContent = $sHelp;
  640. $aParams = array(
  641. (isset($mixedContent['title']) ? $mixedContent['title'] : $sTitle) . $sHelpTitle,
  642. $mixedContent['content'] . $sHelpContent,
  643. $iDesignboxId
  644. );
  645. $mixedMenu = false;
  646. if(isset($mixedContent['menu']))
  647. $mixedMenu = $mixedContent['menu'];
  648. else if(!empty($aBlock['submenu']))
  649. $mixedMenu = $aBlock['submenu'];
  650. $aParams[] = $mixedMenu;
  651. if(isset($mixedContent['buttons']))
  652. $aParams[] = $mixedContent['buttons'];
  653. else if($mixedMenu)
  654. $aParams[] = (int)$aBlock['tabs'] == 1 ? true : array();
  655. if(isset($mixedContent['class']))
  656. $aBlock['class'] = $mixedContent['class'];
  657. }
  658. else if(is_string($mixedContent) && !empty($mixedContent)) {
  659. $iDesignboxId = $aBlock['designbox_id'];
  660. $sHelpTitle = $sHelpContent = '';
  661. if(!in_array($iDesignboxId, $aDbNoTitle))
  662. $sHelpTitle = $sHelp;
  663. else
  664. $sHelpContent = $sHelp;
  665. $aParams = array(
  666. $sTitle . $sHelpTitle,
  667. $mixedContent . $sHelpContent,
  668. $iDesignboxId
  669. );
  670. $mixedMenu = !empty($aBlock['submenu']) ? $aBlock['submenu'] : false;
  671. $aParams[] = $mixedMenu;
  672. if($mixedMenu)
  673. $aParams[] = (int)$aBlock['tabs'] == 1 ? true : array();
  674. }
  675. if(!empty($aParams))
  676. $sContentWithBox = call_user_func_array(array($oFunctions, 'designBoxContent'), $aParams);
  677. }
  678. if (isset($GLOBALS['bx_profiler'])) $GLOBALS['bx_profiler']->endPageBlock($aBlock['id'], $sContentWithBox ? false : true, false );
  679. return $sContentWithBox;
  680. }
  681. /**
  682. * Add necessary js and css files.
  683. */
  684. protected function _addJsCss()
  685. {
  686. $this->_oTemplate->addJs(array('BxDolPage.js', 'theia-sticky-sidebar/theia-sticky-sidebar.min.js', 'theia-sticky-sidebar/ResizeSensor.min.js'));
  687. $this->_oTemplate->addCss('page_layouts.css');
  688. }
  689. /**
  690. * Set system template variables, like page title, meta description, meta keywords and meta robots.
  691. */
  692. protected function _addSysTemplateVars ()
  693. {
  694. $oTemplate = BxDolTemplate::getInstance();
  695. $sPageTitle = $this->_getPageTitle();
  696. if ($sPageTitle)
  697. $oTemplate->setPageHeader ($sPageTitle);
  698. $sMetaTitle = $this->_getPageMetaTitle();
  699. if ($sMetaTitle)
  700. $oTemplate->setPageMetaTitle ($sMetaTitle);
  701. $sMetaDesc = $this->_getPageMetaDesc();
  702. if ($sMetaDesc)
  703. $oTemplate->setPageDescription ($sMetaDesc);
  704. $sMetaRobots = $this->_getPageMetaRobots();
  705. if ($sMetaRobots)
  706. $oTemplate->setPageMetaRobots ($sMetaRobots);
  707. $sMetaImage = $this->_getPageMetaImage();
  708. if ($sMetaImage)
  709. $oTemplate->addPageMetaImage($sMetaImage);
  710. $sMetaKeywords = $this->_getPageMetaKeywords();
  711. if ($sMetaKeywords)
  712. $oTemplate->addPageKeywords ($sMetaKeywords);
  713. }
  714. /**
  715. * Select menu from page properties.
  716. */
  717. protected function _selectMenu ()
  718. {
  719. BxDolMenu::setSelectedGlobal ($this->_aObject['module'], $this->_aObject['uri']);
  720. }
  721. /**
  722. * Set page submenu if it's specified
  723. */
  724. protected function _setSubmenu ($aParams)
  725. {
  726. if(empty($this->_aObject['submenu']) || $this->_aObject['submenu'] == 'disabled')
  727. return;
  728. $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
  729. if(!$oMenuSubmenu)
  730. return;
  731. $oMenuSubmenu->setObjectSubmenu($this->_aObject['submenu'], $aParams);
  732. }
  733. /**
  734. * Get content for 'raw' block type.
  735. * @return string
  736. */
  737. protected function _getBlockRaw ($aBlock)
  738. {
  739. if (bx_is_api()){
  740. return [bx_api_get_block('raw', ['title' => _t($aBlock['title']), 'content' => BxDolTemplate::getInstance()->parseHtmlByContent($aBlock['content'], array())])];
  741. }
  742. $s = '<div class="bx-page-raw-container bx-def-vanilla-html max-w-none">' . BxDolTemplate::getInstance()->parseHtmlByContent($aBlock['content'], array()) . '</div>';
  743. $s = $this->_replaceMarkers($s, array('block_id' => $aBlock['id']));
  744. $s = bx_process_macros($s);
  745. return $s;
  746. }
  747. /**
  748. * Get content for 'custom' block type.
  749. * @return string
  750. */
  751. protected function _getBlockCustom ($aBlock)
  752. {
  753. if (bx_is_api()){
  754. return [bx_api_get_block('custom', ['title' => _t($aBlock['title']), 'content' => BxDolTemplate::getInstance()->parseHtmlByContent($aBlock['content'], array())])];
  755. }
  756. $s = '<div class="bx-page-custom-container">' . BxDolTemplate::getInstance()->parseHtmlByContent($aBlock['content'], array()) . '</div>';
  757. $s = $this->_replaceMarkers($s, array('block_id' => $aBlock['id']));
  758. $s = bx_process_macros($s);
  759. return $s;
  760. }
  761. /**
  762. * Get content for 'html' block type.
  763. * @return string
  764. */
  765. protected function _getBlockHtml ($aBlock)
  766. {
  767. if (bx_is_api()){
  768. return [bx_api_get_block('html', ['title' => _t($aBlock['title']), 'content' => $aBlock['content']])];
  769. }
  770. $s = '<div class="bx-page-html-container bx-def-vanilla-html max-w-none">' . $aBlock['content'] . '</div>';
  771. $s = $this->_replaceMarkers($s, array('block_id' => $aBlock['id']));
  772. $s = bx_process_macros($s);
  773. return $s;
  774. }
  775. /**
  776. * Get content for 'wiki' block type.
  777. * @return string
  778. */
  779. protected function _getBlockWiki ($aBlock)
  780. {
  781. $oWiki = BxDolWiki::getObjectInstance($this->_aObject['module']);
  782. if (!$oWiki) {
  783. $sContent = _t('_sys_wiki_error_missing_wiki_object', $this->_aObject['module']);
  784. }
  785. else {
  786. $sContent = $oWiki->getBlockContent($aBlock['id'], false, (int)bx_get($aBlock['id'].'rev') ? (int)bx_get($aBlock['id'].'rev') : false);
  787. }
  788. $s = '<div id="bx-page-wiki-container-' . $aBlock['id'] . '" class="bx-page-wiki-container markdown-body bx-def-vanilla-html">' . $sContent . '</div>';
  789. $s = $this->_replaceMarkers($s, array('block_id' => $aBlock['id']));
  790. $s = bx_process_macros($s);
  791. return $s;
  792. }
  793. /**
  794. * Get content for 'lang' block type.
  795. * @return string
  796. */
  797. protected function _getBlockLang ($aBlock)
  798. {
  799. if (bx_is_api()){
  800. return [bx_api_get_block('lang', ['title' => _t($aBlock['title']), 'content' => bx_process_macros(_t(trim($aBlock['content'])))])];
  801. }
  802. $s = '<div class="bx-page-lang-container bx-def-vanilla-html max-w-none">' . _t(trim($aBlock['content'])) . '</div>';
  803. $s = $this->_replaceMarkers($s, array('block_id' => $aBlock['id']));
  804. $s = bx_process_macros($s);
  805. return $s;
  806. }
  807. /**
  808. * Get content for 'image' block type.
  809. * @return string
  810. */
  811. protected function _getBlockImage ($aBlock)
  812. {
  813. if (empty($aBlock['content']))
  814. return false;
  815. list($iFileId, $sAlign ) = explode('#', $aBlock['content']);
  816. $iFileId = (int)$iFileId;
  817. if (!$iFileId)
  818. return false;
  819. $oStorage = BxDolStorage::getObjectInstance(BX_DOL_STORAGE_OBJ_IMAGES);
  820. if (!$oStorage)
  821. return false;
  822. $sUrl = $oStorage->getFileUrlById($iFileId);
  823. if (!$sUrl)
  824. return false;
  825. $sStyleAdd = '';
  826. if ('center' == $sAlign || 'left' == $sAlign || 'right' == $sAlign)
  827. $sStyleAdd = 'style="text-align:' . $sAlign . '"';
  828. return '<div class="bx-page-image-container" ' . $sStyleAdd . '><img src="' . $sUrl . '" /></div>';
  829. }
  830. /**
  831. * Get content for 'rss' block type.
  832. * @return string
  833. */
  834. protected function _getBlockRss ($aBlock)
  835. {
  836. if (empty($aBlock['content']))
  837. return false;
  838. list( $sUrl, $iNum ) = explode('#', $aBlock['content']);
  839. $iNum = (int)$iNum;
  840. return BxDolRss::getObjectInstance('sys_page_block')->getHolder($aBlock['id'], $iNum);
  841. }
  842. /**
  843. * Get content for 'menu' block type.
  844. * @return string
  845. */
  846. protected function _getBlockMenu ($aBlock)
  847. {
  848. $oMenu = BxTemplMenu::getObjectInstance($aBlock['content']);
  849. return $oMenu ? $oMenu->getCode () : '';
  850. }
  851. /**
  852. * Get content for 'service' block type.
  853. * @return string
  854. */
  855. protected function _getBlockService ($aBlock)
  856. {
  857. $aMarkers = array_merge($this->_aMarkers, [
  858. 'block_id' => $aBlock['id']
  859. ]);
  860. return BxDolService::callSerialized($aBlock['content'], $aMarkers);
  861. }
  862. /**
  863. * Get page title.
  864. * @return string
  865. */
  866. protected function _getPageTitle()
  867. {
  868. return $this->_replaceMarkers(_t($this->_aObject['title']));
  869. }
  870. /**
  871. * Get page meta description.
  872. * @return string
  873. */
  874. protected function _getPageMetaDesc()
  875. {
  876. return $this->_replaceMarkers(_t($this->_aObject['meta_description']));
  877. }
  878. /**
  879. * Get page meta title.
  880. * @return string
  881. */
  882. protected function _getPageMetaTitle()
  883. {
  884. return $this->_replaceMarkers(_t($this->_aObject['meta_title']));
  885. }
  886. /**
  887. * Get page meta image.
  888. * @return string
  889. */
  890. protected function _getPageMetaImage()
  891. {
  892. return '';
  893. }
  894. /**
  895. * Get page meta keywords.
  896. * @return string
  897. */
  898. protected function _getPageMetaKeywords()
  899. {
  900. return $this->_replaceMarkers(_t($this->_aObject['meta_keywords']));
  901. }
  902. /**
  903. * Get page meta robots.
  904. * @return string
  905. */
  906. protected function _getPageMetaRobots()
  907. {
  908. return _t($this->_aObject['meta_robots']);
  909. }
  910. /**
  911. * Get page not found message.
  912. * @return string
  913. */
  914. protected function _getPageNotFoundMsg ($mixedMsg = false)
  915. {
  916. $this->_oTemplate->displayPageNotFound();
  917. exit;
  918. }
  919. /**
  920. * Get access denied message.
  921. * @return string
  922. */
  923. protected function _getPageAccessDeniedMsg ($mixedMsg = false)
  924. {
  925. return MsgBox($mixedMsg !== false ? $mixedMsg : _t('_Access denied'));
  926. }
  927. /**
  928. * Get page cache object.
  929. * @return cache object instance
  930. */
  931. protected function _getPageCacheObject ()
  932. {
  933. return $this->_getCacheObject ();
  934. }
  935. /**
  936. * Get block cache object.
  937. * @return cache object instance
  938. */
  939. protected function _getBlockCacheObject ()
  940. {
  941. return $this->_getCacheObject ('Block', 'pb');
  942. }
  943. protected function _getCacheObject ($sSuffixObj = 'Page', $sSuffixParam = 'page')
  944. {
  945. $sObj = '_o' . $sSuffixObj . 'CacheObject';
  946. $sParam = 'sys_' . $sSuffixParam . '_cache_engine';
  947. if ($this->{$sObj} != null) {
  948. return $this->{$sObj};
  949. } else {
  950. $sEngine = getParam($sParam);
  951. $this->{$sObj} = bx_instance ('BxDolCache' . $sEngine);
  952. if (!$this->{$sObj}->isAvailable())
  953. $this->{$sObj} = bx_instance ('BxDolCacheFile');
  954. return $this->{$sObj};
  955. }
  956. }
  957. /**
  958. * Get page cache key.
  959. * @param $isPrefixOnly return key prefix only.
  960. * @return string
  961. */
  962. protected function _getPageCacheKey ($isPrefixOnly = false)
  963. {
  964. $s = 'page_' . $this->_aObject['object'] . '_';
  965. if ($isPrefixOnly)
  966. return $s;
  967. $s .= $this->_getPageCacheParams ();
  968. $s .= bx_site_hash() . '.php';
  969. return $s;
  970. }
  971. /**
  972. * Get block cache key.
  973. * @param $isPrefixOnly return key prefix only.
  974. * @return string
  975. */
  976. protected function _getBlockCacheKey ($isPrefixOnly = false, $aBlock = array())
  977. {
  978. $s = $this->_getPageCacheKey(true) . 'block_';
  979. if ($isPrefixOnly)
  980. return $s;
  981. $s .= ($aBlock ? $aBlock['id'] : 0) . '_' . $this->_getPageCacheParams ();
  982. $s .= bx_site_hash() . '.php';
  983. return $s;
  984. }
  985. /**
  986. * Additional cache key. In the case of dynamic page.
  987. * For example - profile page, where each profile has own page.
  988. * @return string
  989. */
  990. protected function _getPageCacheParams ()
  991. {
  992. return md5(serialize($_GET) . bx_lang_name());
  993. }
  994. /**
  995. * Clean page cache.
  996. * @param $isDelAllWithPagePrefix delete cache by prefix, it can be used for dynamic pages, like profile view, where for each profile separate cache is generated.
  997. * @return string
  998. */
  999. protected function cleanCache ($isDelAllWithPagePrefix = false)
  1000. {
  1001. $a = ['Page', 'Block'];
  1002. $bRet = false;
  1003. foreach ($a as $s) {
  1004. $oCache = $this->{'_get' . $s . 'CacheObject'} ();
  1005. $sKey = $this->{'_get'. $s . 'CacheKey'} ($isDelAllWithPagePrefix);
  1006. if ($isDelAllWithPagePrefix)
  1007. $bRet = $bRet && $oCache->removeAllByPrefix($sKey);
  1008. else
  1009. $bRet = $bRet && $oCache->delData($sKey);
  1010. }
  1011. return $bRet;
  1012. }
  1013. }
  1014. /** @} */