system/modules/hideaway/elements/CeHideawayRegionHeaderReader.php line 72

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 CeHideawayRegionHeaderReader extends \ContentElement
  23. {
  24. /**
  25. * Template
  26. * @var string
  27. */
  28. protected $strTemplate = 'ce_hideaway_region_header_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. $objTemplate = new \BackendTemplate('be_wildcard');
  38. $objTemplate->wildcard = '### Hideaway Region Header Reader ###';
  39. $objTemplate->title = $this->headline;
  40. return $objTemplate->parse();
  41. }
  42. // Set the item from the auto_item parameter
  43. if (!isset($_GET['items']) && $GLOBALS['TL_CONFIG']['useAutoItem'] && isset($_GET['auto_item']))
  44. {
  45. \Input::setGet('items', \Input::get('auto_item'));
  46. }
  47. return parent::generate();
  48. }
  49. /**
  50. * Generate the module
  51. */
  52. protected function compile()
  53. {
  54. global $objPage;
  55. $this->import('Hideaway');
  56. $region = $this->Hideaway->getRegionByUrl();
  57. $this->Template->entry = $region;
  58. // Testimonials über das zugehörige Land laden
  59. $testimonials = array();
  60. if ($region && isset($region['row']['country']))
  61. {
  62. $objTestimonials = \Database::getInstance()
  63. ->prepare("SELECT * FROM tl_hideaway_testimonial WHERE published='1' AND country=? ORDER BY sorting ASC")
  64. ->execute($region['row']['country']);
  65. while ($objTestimonials->next())
  66. {
  67. $testimonials[] = (object) array(
  68. 'name' => $objTestimonials->name,
  69. 'rating' => (int) $objTestimonials->rating,
  70. 'title' => $objTestimonials->title,
  71. 'text' => $objTestimonials->text,
  72. );
  73. }
  74. }
  75. $this->Template->testimonials = $testimonials;
  76. }
  77. }