src/Rhyme/WMassArtsHub/Module/Submission/CallsForArtReader.php line 82

Open in your IDE?
  1. <?php
  2. /**
  3.  * Copyright (C) 2019 Rhyme Digital, LLC.
  4.  *
  5.  * @link       https://rhyme.digital
  6.  * @license    http://www.gnu.org/licenses/lgpl-3.0.html LGPL
  7.  */
  8. namespace Rhyme\WMassArtsHub\Module\Submission;
  9. use Contao\Date;
  10. use Contao\Input;
  11. use Contao\Config;
  12. use Contao\Module;
  13. use Contao\PageModel;
  14. use Contao\StringUtil;
  15. use Contao\Environment;
  16. use Contao\BackendTemplate;
  17. use Patchwork\Utf8;
  18. use Contao\CoreBundle\Exception\PageNotFoundException;
  19. use Rhyme\WMassArtsHub\Model\Submission\CallsForArt;
  20. use Rhyme\WMassArtsHub\Model\Submission\Funding;
  21. use Rhyme\WMassArtsHub\Model\Submission\Space;
  22. /**
  23.  * Class CallsForArtReader
  24.  * @package Rhyme\WMassArtsHub\Module\Submission
  25.  */
  26. class CallsForArtReader extends Module
  27. {
  28.     /**
  29.      * Current date object
  30.      * @var Date
  31.      */
  32.     protected $Date;
  33.     /**
  34.      * Template
  35.      * @var string
  36.      */
  37.     protected $strTemplate 'mod_artshub_submission_reader';
  38.     /**
  39.      * Display a wildcard in the back end
  40.      *
  41.      * @return string
  42.      */
  43.     public function generate()
  44.     {
  45.         if (TL_MODE == 'BE') {
  46.             $objTemplate = new BackendTemplate('be_wildcard');
  47.             $objTemplate->wildcard '### ' Utf8::strtoupper($GLOBALS['TL_LANG']['FMD']['artshub_callsforart_reader'][0]) . ' ###';
  48.             $objTemplate->title $this->headline;
  49.             $objTemplate->id $this->id;
  50.             $objTemplate->link $this->name;
  51.             $objTemplate->href 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' $this->id;
  52.             return $objTemplate->parse();
  53.         }
  54.         // Set the item from the auto_item parameter
  55.         if (!isset($_GET['callsforartitem']) && Config::get('useAutoItem') && isset($_GET['auto_item']))
  56.         {
  57.             Input::setGet('callsforartitem'Input::get('auto_item'));
  58.         }
  59.         // Return an empty string if "callsforartitem" is not set
  60.         if (!Input::get('callsforartitem'))
  61.         {
  62.             return '';
  63.         }
  64.         return parent::generate();
  65.     }
  66.     /**
  67.      * Generate the module
  68.      */
  69.     protected function compile()
  70.     {
  71.         /** @var PageModel $objPage */
  72.         global $objPage;
  73.         $this->Template->item '';
  74.         // Get the current submission
  75.         $objSubmission CallsForArt::findPublishedByIdOrAlias(Input::get('callsforartitem'));
  76.         if (null === $objSubmission)
  77.         {
  78.             throw new PageNotFoundException('Page not found: ' Environment::get('uri'));
  79.         }
  80.         // Overwrite the page title (see #2853, #4955 and #87)
  81.         if ($objPage && $objSubmission->title)
  82.         {
  83.             $objPage->pageTitle $objSubmission->getPageTitle();
  84.             $objPage->description 'Check out ' $objSubmission->title ', an artists\' studio/space opportunity in western Massachusetts.';
  85.             $objPage->description .= StringUtil::substr(strip_tags($objSubmission->description), 100);
  86.         }
  87.         $this->Template->item $objSubmission->generate($this);
  88.     }
  89. }