system/modules/hideaway/elements/CeHideawayRegionContentReader.php line 80

Open in your IDE?
  1. <?php
  2. /**
  3. * Contao Open Source CMS
  4. *
  5. * Copyright (C) 2005-2013 Leo Feyer
  6. *
  7. * @package Comments
  8. * @link https://contao.org
  9. * @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL
  10. */
  11. /**
  12. * Run in a custom namespace, so the class can be replaced
  13. */
  14. namespace hideaway;
  15. /**
  16. * Class CeHideawayList
  17. *
  18. * @copyright Leo Feyer 2005-2013
  19. * @author Leo Feyer <https://contao.org>
  20. * @package Comments
  21. */
  22. class CeHideawayRegionContentReader extends \ContentElement
  23. {
  24. /**
  25. * Template
  26. * @var string
  27. */
  28. protected $strTemplate = 'ce_hideaway_region_content_reader';
  29. /**
  30. * Display a wildcard in the back end
  31. * @return string
  32. */
  33. public function generate()
  34. {
  35. if (TL_MODE == 'BE')
  36. {
  37. //$objp = \PageModel::findById($this->hideaway_jumpto);
  38. $objTemplate = new \BackendTemplate('be_wildcard');
  39. $objTemplate->wildcard = '### Hideaway Region Content Reader ###';
  40. //$objTemplate->title = 'Zielseite: '. $objp->title . ' ('.$this->hideaway_jumpto.')';
  41. return $objTemplate->parse();
  42. }
  43. // Set the item from the auto_item parameter
  44. if (!isset($_GET['items']) && $GLOBALS['TL_CONFIG']['useAutoItem'] && isset($_GET['auto_item']))
  45. {
  46. \Input::setGet('items', \Input::get('auto_item'));
  47. }
  48. return parent::generate();
  49. }
  50. /**
  51. * Generate the module
  52. */
  53. protected function compile()
  54. {
  55. global $objPage;
  56. $this->import('Hideaway');
  57. $region = $this->Hideaway->getRegionByUrl();
  58. $this->Template->entry = $region;
  59. $this->Template->hotels = $this->Hideaway->getHotelsByRegionId($region['row']['id']);
  60. $this->Template->travels = $this->Hideaway->getTravelsByRegionId($region['row']['id']);
  61. $this->Template->trips = $this->Hideaway->getTripsByRegionId($region['row']['id']);
  62. $this->Template->combis = $this->Hideaway->getCombisByRegionId($region['row']['id']);
  63. // Content-Elemente des Region-Datensatzes laden (zwei Bereiche)
  64. $db = \Database::getInstance();
  65. // Bereich oben
  66. $objTop = $db->prepare(
  67. "SELECT id FROM tl_content
  68. WHERE pid=? AND ptable='tl_hideaway_region'
  69. AND (hideaway_content_area='top' OR hideaway_content_area='')
  70. AND invisible=''
  71. AND (start='' OR start<=?) AND (stop='' OR stop>?)
  72. ORDER BY sorting ASC"
  73. )->execute($region['row']['id'], time(), time());
  74. $strTop = '';
  75. while ($objTop->next())
  76. {
  77. $strTop .= $this->getContentElement($objTop->id);
  78. }
  79. $this->Template->regionContentTop = $strTop;
  80. // Bereich unten
  81. $objBottom = $db->prepare(
  82. "SELECT id FROM tl_content
  83. WHERE pid=? AND ptable='tl_hideaway_region'
  84. AND hideaway_content_area='bottom'
  85. AND invisible=''
  86. AND (start='' OR start<=?) AND (stop='' OR stop>?)
  87. ORDER BY sorting ASC"
  88. )->execute($region['row']['id'], time(), time());
  89. $strBottom = '';
  90. while ($objBottom->next())
  91. {
  92. $strBottom .= $this->getContentElement($objBottom->id);
  93. }
  94. $this->Template->regionContentBottom = $strBottom;
  95. }
  96. }