BxBasePage.php 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207
  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. 'cover' => $oModule->serviceGetCover($this->_aProfileInfo['content_id']),
  382. 'allow_edit' => $oModule->checkAllowedChangeCover($aContentInfo) === CHECK_ACTION_RESULT_ALLOWED
  383. ];
  384. $CNF = $oModule->_oConfig->CNF;
  385. if(!empty($CNF['OBJECT_MENU_VIEW_ENTRY_META'])){
  386. $oMetaMenu = BxTemplMenu::getObjectInstance($CNF['OBJECT_MENU_VIEW_ENTRY_META']);
  387. $a['cover_block']['meta_menu'] = $oMetaMenu->getCodeAPI();
  388. }
  389. $oConnection = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTIONS']);
  390. if ($oConnection){
  391. $a['cover_block']['members_list'] = $oConnection->getConnectedListAPI($this->_aProfileInfo['id'], false, BX_CONNECTIONS_CONTENT_TYPE_INITIATORS, 10);
  392. }
  393. if(!empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY'])){
  394. $oActionMenu = BxTemplMenu::getObjectInstance($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY_ALL']);
  395. $a['cover_block']['actions_menu'] = $oActionMenu->getCodeAPI();
  396. }
  397. }
  398. $sMenuTop = getParam('sys_api_menu_top');
  399. if (!empty($sMenuTop) && ($oMenuTop = BxDolMenu::getObjectInstance($sMenuTop)) !== false)
  400. $a['menu_top'] = $oMenuTop->getCodeAPI();
  401. if (($oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu')) !== false) {
  402. if(($sSubmenu = $this->getSubMenu()) !== '')
  403. $oMenuSubmenu->setObjectSubmenu($sSubmenu, []);
  404. $a['menu'] = $oMenuSubmenu->getCodeAPI();
  405. }
  406. if (isLogged()) {
  407. /* temporatery commented
  408. if(($oMenuAddContent = BxDolMenu::getObjectInstance('sys_add_content')) !== false)
  409. $a['menu_add'] = $oMenuAddContent->getCodeAPI();
  410. */
  411. $o = BxDolProfile::getInstance();
  412. $oAccount = $o->getAccountObject();
  413. $a['user'] = [
  414. 'id' => $o->id(),
  415. 'email' => $o->getAccountObject()->getEmail(),
  416. 'display_name' => $o->getDisplayName(),
  417. 'url' => bx_api_get_relative_url($o->getUrl()),
  418. 'avatar' => $o->getAvatar(),
  419. 'settings' => $o->getSettings(),
  420. //'level' => BxDolAcl::getInstance()->getMemberMembershipInfo($o->id()),
  421. 'moderator' => (bool)BxDolAcl::getInstance()->isMemberLevelInSet([MEMBERSHIP_ID_ADMINISTRATOR, MEMBERSHIP_ID_MODERATOR], $o->id()),
  422. 'operator' => isAdmin(),
  423. //'info' => $o->getInfo(),
  424. 'confirmed' => $oAccount->isConfirmed(),
  425. 'notifications' => 0,
  426. 'cart' => 0,
  427. 'active' => $o->isActive(),
  428. 'status' => $o->getStatus(),
  429. ];
  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. if ('center' == $sAlign || 'left' == $sAlign || 'right' == $sAlign)
  826. $sStyleAdd = 'style="text-align:' . $sAlign . '"';
  827. return '<div class="bx-page-image-container" ' . $sStyleAdd . '><img src="' . $sUrl . '" /></div>';
  828. }
  829. /**
  830. * Get content for 'rss' block type.
  831. * @return string
  832. */
  833. protected function _getBlockRss ($aBlock)
  834. {
  835. if (empty($aBlock['content']))
  836. return false;
  837. list( $sUrl, $iNum ) = explode('#', $aBlock['content']);
  838. $iNum = (int)$iNum;
  839. return BxDolRss::getObjectInstance('sys_page_block')->getHolder($aBlock['id'], $iNum);
  840. }
  841. /**
  842. * Get content for 'menu' block type.
  843. * @return string
  844. */
  845. protected function _getBlockMenu ($aBlock)
  846. {
  847. $oMenu = BxTemplMenu::getObjectInstance($aBlock['content']);
  848. return $oMenu ? $oMenu->getCode () : '';
  849. }
  850. /**
  851. * Get content for 'service' block type.
  852. * @return string
  853. */
  854. protected function _getBlockService ($aBlock)
  855. {
  856. $aMarkers = array_merge($this->_aMarkers, [
  857. 'block_id' => $aBlock['id']
  858. ]);
  859. return BxDolService::callSerialized($aBlock['content'], $aMarkers);
  860. }
  861. /**
  862. * Get page title.
  863. * @return string
  864. */
  865. protected function _getPageTitle()
  866. {
  867. return $this->_replaceMarkers(_t($this->_aObject['title']));
  868. }
  869. /**
  870. * Get page meta description.
  871. * @return string
  872. */
  873. protected function _getPageMetaDesc()
  874. {
  875. return $this->_replaceMarkers(_t($this->_aObject['meta_description']));
  876. }
  877. /**
  878. * Get page meta title.
  879. * @return string
  880. */
  881. protected function _getPageMetaTitle()
  882. {
  883. return $this->_replaceMarkers(_t($this->_aObject['meta_title']));
  884. }
  885. /**
  886. * Get page meta image.
  887. * @return string
  888. */
  889. protected function _getPageMetaImage()
  890. {
  891. return '';
  892. }
  893. /**
  894. * Get page meta keywords.
  895. * @return string
  896. */
  897. protected function _getPageMetaKeywords()
  898. {
  899. return $this->_replaceMarkers(_t($this->_aObject['meta_keywords']));
  900. }
  901. /**
  902. * Get page meta robots.
  903. * @return string
  904. */
  905. protected function _getPageMetaRobots()
  906. {
  907. return _t($this->_aObject['meta_robots']);
  908. }
  909. /**
  910. * Get page not found message.
  911. * @return string
  912. */
  913. protected function _getPageNotFoundMsg ($mixedMsg = false)
  914. {
  915. $this->_oTemplate->displayPageNotFound();
  916. exit;
  917. }
  918. /**
  919. * Get access denied message.
  920. * @return string
  921. */
  922. protected function _getPageAccessDeniedMsg ($mixedMsg = false)
  923. {
  924. return MsgBox($mixedMsg !== false ? $mixedMsg : _t('_Access denied'));
  925. }
  926. /**
  927. * Get page cache object.
  928. * @return cache object instance
  929. */
  930. protected function _getPageCacheObject ()
  931. {
  932. return $this->_getCacheObject ();
  933. }
  934. /**
  935. * Get block cache object.
  936. * @return cache object instance
  937. */
  938. protected function _getBlockCacheObject ()
  939. {
  940. return $this->_getCacheObject ('Block', 'pb');
  941. }
  942. protected function _getCacheObject ($sSuffixObj = 'Page', $sSuffixParam = 'page')
  943. {
  944. $sObj = '_o' . $sSuffixObj . 'CacheObject';
  945. $sParam = 'sys_' . $sSuffixParam . '_cache_engine';
  946. if ($this->{$sObj} != null) {
  947. return $this->{$sObj};
  948. } else {
  949. $sEngine = getParam($sParam);
  950. $this->{$sObj} = bx_instance ('BxDolCache' . $sEngine);
  951. if (!$this->{$sObj}->isAvailable())
  952. $this->{$sObj} = bx_instance ('BxDolCacheFile');
  953. return $this->{$sObj};
  954. }
  955. }
  956. /**
  957. * Get page cache key.
  958. * @param $isPrefixOnly return key prefix only.
  959. * @return string
  960. */
  961. protected function _getPageCacheKey ($isPrefixOnly = false)
  962. {
  963. $s = 'page_' . $this->_aObject['object'] . '_';
  964. if ($isPrefixOnly)
  965. return $s;
  966. $s .= $this->_getPageCacheParams ();
  967. $s .= bx_site_hash() . '.php';
  968. return $s;
  969. }
  970. /**
  971. * Get block cache key.
  972. * @param $isPrefixOnly return key prefix only.
  973. * @return string
  974. */
  975. protected function _getBlockCacheKey ($isPrefixOnly = false, $aBlock = array())
  976. {
  977. $s = $this->_getPageCacheKey(true) . 'block_';
  978. if ($isPrefixOnly)
  979. return $s;
  980. $s .= ($aBlock ? $aBlock['id'] : 0) . '_' . $this->_getPageCacheParams ();
  981. $s .= bx_site_hash() . '.php';
  982. return $s;
  983. }
  984. /**
  985. * Additional cache key. In the case of dynamic page.
  986. * For example - profile page, where each profile has own page.
  987. * @return string
  988. */
  989. protected function _getPageCacheParams ()
  990. {
  991. return md5(serialize($_GET) . bx_lang_name());
  992. }
  993. /**
  994. * Clean page cache.
  995. * @param $isDelAllWithPagePrefix delete cache by prefix, it can be used for dynamic pages, like profile view, where for each profile separate cache is generated.
  996. * @return string
  997. */
  998. protected function cleanCache ($isDelAllWithPagePrefix = false)
  999. {
  1000. $a = ['Page', 'Block'];
  1001. $bRet = false;
  1002. foreach ($a as $s) {
  1003. $oCache = $this->{'_get' . $s . 'CacheObject'} ();
  1004. $sKey = $this->{'_get'. $s . 'CacheKey'} ($isDelAllWithPagePrefix);
  1005. if ($isDelAllWithPagePrefix)
  1006. $bRet = $bRet && $oCache->removeAllByPrefix($sKey);
  1007. else
  1008. $bRet = $bRet && $oCache->delData($sKey);
  1009. }
  1010. return $bRet;
  1011. }
  1012. }
  1013. /** @} */