| 1 | <?php |
| 2 | |
| 3 | namespace wcf\system\template; |
| 4 | |
| 5 | use wcf\system\application\ApplicationHandler; |
| 6 | |
| 7 | /** |
| 8 | * Loads and displays template in the ACP. |
| 9 | * |
| 10 | * @author Alexander Ebert |
| 11 | * @copyright 2001-2019 WoltLab GmbH |
| 12 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> |
| 13 | */ |
| 14 | class ACPTemplateEngine extends TemplateEngine |
| 15 | { |
| 16 | /** |
| 17 | * @inheritDoc |
| 18 | */ |
| 19 | protected $environment = 'admin'; |
| 20 | |
| 21 | /** |
| 22 | * @inheritDoc |
| 23 | */ |
| 24 | protected function init() |
| 25 | { |
| 26 | parent::init(); |
| 27 | |
| 28 | $this->templatePaths = ['wcf' => WCF_DIR . 'acp/templates/']; |
| 29 | $this->compileDir = WCF_DIR . 'acp/templates/compiled/'; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Deletes all compiled acp templates. |
| 34 | * |
| 35 | * @param string $compileDir |
| 36 | */ |
| 37 | public static function deleteCompiledACPTemplates($compileDir = '') |
| 38 | { |
| 39 | if (empty($compileDir)) { |
| 40 | $compileDir = WCF_DIR . 'acp/templates/compiled/'; |
| 41 | } |
| 42 | |
| 43 | self::deleteCompiledTemplates($compileDir); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * @inheritDoc |
| 48 | */ |
| 49 | public function getCompiledFilename($templateName, $application) |
| 50 | { |
| 51 | $abbreviation = 'wcf'; |
| 52 | if (PACKAGE_ID) { |
| 53 | $abbreviation = ApplicationHandler::getInstance()->getActiveApplication()->getAbbreviation(); |
| 54 | } |
| 55 | |
| 56 | return $this->getCompileFilePrefix($templateName) . '_' . $abbreviation . '_' . $this->languageID . '_' . $templateName . '.php'; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * This method always throws, because changing the template group is not supported. |
| 61 | * |
| 62 | * @param int $templateGroupID |
| 63 | * @throws \BadMethodCallException |
| 64 | */ |
| 65 | public function setTemplateGroupID($templateGroupID) |
| 66 | { |
| 67 | throw new \BadMethodCallException("You may not change the template group of the acp template engine"); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * @inheritDoc |
| 72 | */ |
| 73 | public function getTemplateListenerCode($templateName, $eventName) |
| 74 | { |
| 75 | // skip template listeners within WCFSetup |
| 76 | if (!PACKAGE_ID) { |
| 77 | return ''; |
| 78 | } |
| 79 | |
| 80 | return parent::getTemplateListenerCode($templateName, $eventName); |
| 81 | } |
| 82 | } |