system/modules/hideaway/elements/CeHideawayCountryContentReader.php line 85

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 CeHideawayCountryContentReader extends \ContentElement
  23. {
  24. /**
  25. * Template
  26. * @var string
  27. */
  28. protected $strTemplate = 'ce_hideaway_country_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 Country 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. $id = $this->Input->get('items');
  57. $this->import('Hideaway');
  58. $country = $this->Hideaway->getCountryByUrl();
  59. $regions = $this->Hideaway->getRegionsByCountryId($country['row']['id'], $this->hideaway_jumpto);
  60. $combis = $this->Hideaway->getCombisByCountryId($country['row']['id']);
  61. $hotels = false;
  62. $travels = false;
  63. $trips = false;
  64. $hotels = $this->Hideaway->getHotelsByRegionId($country['row']['single_region']);
  65. if($country['row']['single_region'] > 0)
  66. {
  67. $travels = $this->Hideaway->getTravelsByRegionId($country['row']['single_region']);
  68. $this->Template->isSingleRegion = true;
  69. }
  70. else
  71. $this->Template->isSingleRegion = false;
  72. $trips = $this->Hideaway->getTripsByCountryId($country['row']['id']);
  73. $this->Template->combis = $combis;
  74. $this->Template->entry = $country;
  75. $this->Template->regions = $regions;
  76. $this->Template->region_jumpto = $this->hideaway_jumpto;
  77. $this->Template->hotels = $hotels;
  78. $this->Template->travels = $travels;
  79. $this->Template->trips = $trips;
  80. // Content-Elemente des Country-Datensatzes laden (zwei Bereiche)
  81. $db = \Database::getInstance();
  82. // Bereich oben (top = Standard für alle bisherigen Elemente)
  83. $objTop = $db->prepare(
  84. "SELECT id FROM tl_content
  85. WHERE pid=? AND ptable='tl_hideaway_country'
  86. AND (hideaway_content_area='top' OR hideaway_content_area='')
  87. AND invisible=''
  88. AND (start='' OR start<=?) AND (stop='' OR stop>?)
  89. ORDER BY sorting ASC"
  90. )->execute($country['row']['id'], time(), time());
  91. $strTop = '';
  92. while ($objTop->next())
  93. {
  94. $strTop .= $this->getContentElement($objTop->id);
  95. }
  96. $this->Template->countryContentTop = $strTop;
  97. // Bereich unten
  98. $objBottom = $db->prepare(
  99. "SELECT id FROM tl_content
  100. WHERE pid=? AND ptable='tl_hideaway_country'
  101. AND hideaway_content_area='bottom'
  102. AND invisible=''
  103. AND (start='' OR start<=?) AND (stop='' OR stop>?)
  104. ORDER BY sorting ASC"
  105. )->execute($country['row']['id'], time(), time());
  106. $strBottom = '';
  107. while ($objBottom->next())
  108. {
  109. $strBottom .= $this->getContentElement($objBottom->id);
  110. }
  111. $this->Template->countryContentBottom = $strBottom;
  112. }
  113. }