BxBasePage.php 41 KB

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