vendor/isotope/isotope-core/system/modules/isotope/library/Isotope/Template.php line 45

Open in your IDE?
  1. <?php
  2. /*
  3.  * Isotope eCommerce for Contao Open Source CMS
  4.  *
  5.  * Copyright (C) 2009 - 2019 terminal42 gmbh & Isotope eCommerce Workgroup
  6.  *
  7.  * @link       https://isotopeecommerce.org
  8.  * @license    https://opensource.org/licenses/lgpl-3.0.html
  9.  */
  10. namespace Isotope;
  11. use Contao\FrontendTemplate;
  12. use Contao\StringUtil;
  13. use Contao\TemplateLoader;
  14. /**
  15.  * Provide methods to handle Isotope templates.
  16.  */
  17. class Template extends FrontendTemplate
  18. {
  19.     /**
  20.      * Check the Isotope config directory for a particular template
  21.      *
  22.      * @param string $strTemplate
  23.      * @param string $strFormat
  24.      *
  25.      * @return string
  26.      */
  27.     public static function getTemplate($strTemplate$strFormat 'html5')
  28.     {
  29.         $arrAllowed StringUtil::trimsplit(','$GLOBALS['TL_CONFIG']['templateFiles'] ?? '');
  30.         if (\is_array($GLOBALS['TL_CONFIG']['templateFiles'] ?? null) && !\in_array($strFormat$arrAllowed)) {
  31.             throw new \InvalidArgumentException("Invalid output format $strFormat");
  32.         }
  33.         $strKey      $strTemplate '.' $strFormat;
  34.         $strPath     TL_ROOT '/templates';
  35.         $strTemplate basename($strTemplate);
  36.         // Check the templates subfolder
  37.         $strTemplateGroup str_replace(array('../''templates/'), ''Isotope::getConfig()->templateGroup);
  38.         if ($strTemplateGroup != '') {
  39.             $strFile $strPath '/' $strTemplateGroup '/' $strKey;
  40.             if (file_exists($strFile)) {
  41.                 return $strFile;
  42.             }
  43.             if (file_exists($strFile)) {
  44.                 return $strFile;
  45.             }
  46.         }
  47.         return parent::getTemplate($strTemplate$strFormat);
  48.     }
  49.     /**
  50.      * Find a particular template file and return its path
  51.      *
  52.      * @param string  $strTemplate The name of the template
  53.      * @param string  $strFormat   The file extension
  54.      * @param boolean $blnDefault  If true, the default template path is returned
  55.      *
  56.      * @return string The path to the template file
  57.      */
  58.     protected function getTemplatePath($strTemplate$strFormat='html5'$blnDefault=false)
  59.     {
  60.         if ($blnDefault)
  61.         {
  62.             return TemplateLoader::getDefaultPath($strTemplate$strFormat);
  63.         }
  64.         return static::getTemplate($strTemplate$strFormat);
  65.     }
  66. }