BxDolPageQuery.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup DolphinCore Dolphin Core
  7. * @{
  8. */
  9. bx_import('BxDolDb');
  10. /**
  11. * Database queries for pages.
  12. * @see BxDolPage
  13. */
  14. class BxDolPageQuery extends BxDolDb
  15. {
  16. protected $_aObject;
  17. public function __construct($aObject)
  18. {
  19. parent::__construct();
  20. $this->_aObject = $aObject;
  21. }
  22. static public function getPageObject ($sObject)
  23. {
  24. $oDb = BxDolDb::getInstance();
  25. $sQuery = $oDb->prepare("SELECT `o`.*, `l`.`template`, `l`.`cells_number` FROM `sys_objects_page` AS `o` INNER JOIN `sys_pages_layouts` AS `l` ON (`l`.`id` = `o`.`layout_id`) WHERE `o`.`object` = ?", $sObject);
  26. $aObject = $oDb->getRow($sQuery);
  27. if (!$aObject || !is_array($aObject))
  28. return false;
  29. return $aObject;
  30. }
  31. static public function getPageObjectNameByURI($sURI)
  32. {
  33. $oDb = BxDolDb::getInstance();
  34. $sQuery = $oDb->prepare("SELECT `object` FROM `sys_objects_page` WHERE `uri` = ?", $sURI);
  35. return $oDb->getOne($sQuery);
  36. }
  37. public function getPageBlocks()
  38. {
  39. $aRet = array ();
  40. for ($i = 1 ; $i <= $this->_aObject['cells_number'] ; ++$i) {
  41. $sQuery = $this->prepare("SELECT * FROM `sys_pages_blocks` WHERE `object` = ? AND `cell_id` = ? AND `active` = 1 ORDER BY `order` ASC", $this->_aObject['object'], $i);
  42. $aRet['cell_'.$i] = $this->getAll($sQuery);
  43. }
  44. return $aRet;
  45. }
  46. public function getPageBlock($iBlockId)
  47. {
  48. $sQuery = $this->prepare("SELECT * FROM `sys_pages_blocks` WHERE `object` = ? AND `id` = ?", $this->_aObject['object'], $iBlockId);
  49. return $this->getRow($sQuery);
  50. }
  51. public function getPageBlockContent($iId)
  52. {
  53. $sQuery = $this->prepare("SELECT `content` FROM `sys_pages_blocks` WHERE `id` = ?", $iId);
  54. return $this->getOne($sQuery);
  55. }
  56. }
  57. /** @} */