BxDolPageQuery.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. protected $_aObject;
  16. public function __construct($aObject) {
  17. parent::__construct();
  18. $this->_aObject = $aObject;
  19. }
  20. static public function getPageObject ($sObject) {
  21. $oDb = BxDolDb::getInstance();
  22. $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);
  23. $aObject = $oDb->getRow($sQuery);
  24. if (!$aObject || !is_array($aObject))
  25. return false;
  26. return $aObject;
  27. }
  28. static public function getPageObjectNameByURI($sURI) {
  29. $oDb = BxDolDb::getInstance();
  30. $sQuery = $oDb->prepare("SELECT `object` FROM `sys_objects_page` WHERE `uri` = ?", $sURI);
  31. return $oDb->getOne($sQuery);
  32. }
  33. public function getPageBlocks() {
  34. $aRet = array ();
  35. for ($i = 1 ; $i <= $this->_aObject['cells_number'] ; ++$i) {
  36. $sQuery = $this->prepare("SELECT * FROM `sys_pages_blocks` WHERE `object` = ? AND `cell_id` = ? AND `active` = 1 ORDER BY `order` ASC", $this->_aObject['object'], $i);
  37. $aRet['cell_'.$i] = $this->getAll($sQuery);
  38. }
  39. return $aRet;
  40. }
  41. public function getPageBlock($iBlockId) {
  42. $sQuery = $this->prepare("SELECT * FROM `sys_pages_blocks` WHERE `object` = ? AND `id` = ?", $this->_aObject['object'], $iBlockId);
  43. return $this->getRow($sQuery);
  44. }
  45. public function getPageBlockContent($iId) {
  46. $sQuery = $this->prepare("SELECT `content` FROM `sys_pages_blocks` WHERE `id` = ?", $iId);
  47. return $this->getOne($sQuery);
  48. }
  49. }
  50. /** @} */