3 * A ??? template engine class
5 * @author Roland Haeder <webmaster@ship-simu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Core Developer Team
8 * @license GNU GPL 3.0 or any newer version
9 * @link http://www.ship-simu.org
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 class ???TemplateEngine extends BaseTemplateEngine implements CompileableTemplate {
26 * Protected constructor
30 protected function __construct () {
31 // Call parent constructor
32 parent::__construct(__CLASS__);
36 * Creates an instance of the class TemplateEngine and prepares it for usage
38 * @param $appInstance A manageable application
39 * @return $tplInstance An instance of TemplateEngine
40 * @throws BasePathIsEmptyException If the provided $templateBasePath is empty
41 * @throws InvalidBasePathStringException If $templateBasePath is no string
42 * @throws BasePathIsNoDirectoryException If $templateBasePath is no
43 * directory or not found
44 * @throws BasePathReadProtectedException If $templateBasePath is
47 public final static function create???TemplateEngine (ManageableApplication $appInstance) {
49 $tplInstance = new ???TemplateEngine();
51 // Get language and file I/O instances from application
52 $langInstance = $appInstance->getLanguageInstance();
53 $ioInstance = $appInstance->getFileIoInstance();
55 // Determine base path
56 $templateBasePath = $tplInstance->getConfigInstance()->getConfigEntry('application_base_path') . $appInstance->getRequestInstance()->getRequestElement('app') . '/';
58 // Is the base path valid?
59 if (empty($templateBasePath)) {
61 throw new BasePathIsEmptyException($tplInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
62 } elseif (!is_string($templateBasePath)) {
64 throw new InvalidBasePathStringException(array($tplInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING);
65 } elseif (!is_dir($templateBasePath)) {
67 throw new BasePathIsNoDirectoryException(array($tplInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
68 } elseif (!is_readable($templateBasePath)) {
70 throw new BasePathReadProtectedException(array($tplInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
73 // Get configuration instance
74 $configInstance = FrameworkConfiguration::getInstance();
77 $tplInstance->setTemplateBasePath($templateBasePath);
79 // Set the language and IO instances
80 $tplInstance->setLanguageInstance($langInstance);
81 $tplInstance->setFileIoInstance($ioInstance);
83 // Set template extensions
84 $tplInstance->setRawTemplateExtension($configInstance->getConfigEntry('raw_template_extension'));
85 $tplInstance->setCodeTemplateExtension($configInstance->getConfigEntry('code_template_extension'));
87 // Absolute output path for compiled templates
88 $tplInstance->setCompileOutputPath($configInstance->getConfigEntry('base_path') . $configInstance->getConfigEntry('compile_output_path'));
90 // Return the prepared instance