* It holds the database connection, access to template and language engine.
*
* @author Marcel Werk
- * @copyright 2001-2012 WoltLab GmbH
+ * @copyright 2001-2013 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system
// start application if not within ACP
if (!class_exists('wcf\system\WCFACP', false)) {
// add template path and abbreviation
- $this->getTPL()->addApplication($abbreviation, $application->packageID, $packageDir . 'templates/');
+ $this->getTPL()->addApplication($abbreviation, $packageDir . 'templates/');
// init application and assign it as template variable
$applicationObject = call_user_func(array($className, 'getInstance'));
// register template path in ACP
if (class_exists('wcf\system\WCFACP', false)) {
- $this->getTPL()->addApplication($abbreviation, $application->packageID, $packageDir . 'acp/templates/');
+ $this->getTPL()->addApplication($abbreviation, $packageDir . 'acp/templates/');
}
else if (!$isDependentApplication) {
// assign base tag
* Loads and displays template during the setup process.
*
* @author Alexander Ebert
- * @copyright 2001-2012 WoltLab GmbH
+ * @copyright 2001-2013 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.template
/**
* @see wcf\system\template\TemplateEngine::getSourceFilename()
*/
- public function getSourceFilename($templateName, $packageID) {
- return $this->templatePaths[PACKAGE_ID].'setup/template/'.$templateName.'.tpl';
+ public function getSourceFilename($templateName, $application) {
+ $sourceFilename = $this->templatePaths[$application].'setup/template/'.$templateName.'.tpl';
+ if (!empty($sourceFilename)) {
+ return $sourceFilename;
+ }
+
+ throw new SystemException("Unable to find template '".$templateName."'");
}
/**
public function getMetaDataFilename($templateName) {
return $this->compileDir.'setup/template/compiled/'.$this->languageID.'_'.$templateName.'.meta.php';
}
-
- /**
- * @see wcf\system\template\TemplateEngine::getPackageID()
- */
- public function getPackageID($templateName, $application = 'wcf') {
- $path = $this->templatePaths[PACKAGE_ID].'setup/template/'.$templateName.'.tpl';
- if (file_exists($path)) {
- return PACKAGE_ID;
- }
-
- throw new SystemException("Unable to find template '$templateName'");
- }
/**
* @see wcf\system\template\TemplateEngine::loadTemplateListeners()
* Loads and displays template.
*
* @author Alexander Ebert
- * @copyright 2001-2012 WoltLab GmbH
+ * @copyright 2001-2013 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.template
* @category Community Framework
*/
class TemplateEngine extends SingletonFactory {
- /**
- * list of abbreviations to package id
- * @var array<integer>
- */
- public $abbreviations = array();
-
/**
* directory used to cache previously compiled templates
* @var string
* @see wcf\system\SingletonFactory::init()
*/
protected function init() {
- $this->abbreviations['wcf'] = 1;
- $this->templatePaths = array(1 => WCF_DIR.'templates/');
+ $this->templatePaths = array('wcf' => WCF_DIR.'templates/');
$this->pluginNamespace = 'wcf\system\template\plugin\\';
$this->compileDir = WCF_DIR.'templates/compiled/';
* Adds a new application.
*
* @param string $abbreviation
- * @param integer $packageID
* @param string $templatePath
*/
- public function addApplication($abbreviation, $packageID, $templatePath) {
- $this->abbreviations[$abbreviation] = $packageID;
- $this->templatePaths[$packageID] = $templatePath;
+ public function addApplication($abbreviation, $templatePath) {
+ $this->templatePaths[$abbreviation] = $templatePath;
}
/**
if (!defined('NO_IMPORTS')) EventHandler::getInstance()->fireAction($this, 'shouldDisplay');
}
- $tplPackageID = $this->getPackageID($templateName, $application);
- $compiledFilename = $this->getCompiledFilename($templateName);
- $sourceFilename = $this->getSourceFilename($templateName, $tplPackageID);
+ $sourceFilename = $this->getSourceFilename($templateName, $application);
+ $compiledFilename = $this->getCompiledFilename($templateName, $application);
$metaDataFilename = $this->getMetaDataFilename($templateName);
$metaData = $this->getMetaData($templateName, $metaDataFilename);
}
/**
- * Returns path and corresponding file path.
+ * Returns the absolute filename of a template source.
*
* @param string $templateName
* @param string $application
- * @return integer
+ * @return string $path
*/
- public function getPackageID($templateName, $application = 'wcf') {
- $packageID = (isset($this->abbreviations[$application])) ? $this->abbreviations[$application] : null;
- if ($packageID === null) {
- throw new SystemException("Unable to find application for abbreviation '".$application."'");
+ public function getSourceFilename($templateName, $application) {
+ $sourceFilename = $this->getPath($this->templatePaths[$application], $templateName);
+ if (!empty($sourceFilename)) {
+ return $sourceFilename;
}
- // search within application
- if ($packageID != 1 && isset($this->templatePaths[$packageID])) {
- $path = $this->getPath($this->templatePaths[$packageID], $templateName);
-
- if (!empty($path)) {
- return $packageID;
+ // try to find template within WCF if not already searching WCF
+ if ($application != 'wcf') {
+ $sourceFilename = $this->getSourceFilename($templateName, 'wcf');
+ if (!empty($sourceFilename)) {
+ return $sourceFilename;
}
}
- // search within WCF
- $path = $this->getPath($this->templatePaths[1], $templateName);
- if (!empty($path)) {
- return 1;
- }
-
- throw new SystemException("Unable to find template '$templateName'");
- }
-
- /**
- * Returns the absolute filename of a template source.
- *
- * @param string $templateName
- * @param integer $packageID
- * @return string $path
- */
- public function getSourceFilename($templateName, $packageID) {
- return $this->getPath($this->templatePaths[$packageID], $templateName);
+ throw new SystemException("Unable to find template '".$templateName."'");
}
/**
* Returns the absolute filename of a compiled template.
*
* @param string $templateName
+ * @param string $application
* @return string
*/
- public function getCompiledFilename($templateName) {
- return $this->compileDir.$this->templateGroupID.'_'.$this->languageID.'_'.$templateName.'.php';
+ public function getCompiledFilename($templateName, $application) {
+ return $this->compileDir.$this->templateGroupID.'_'.$application.'_'.$this->languageID.'_'.$templateName.'.php';
}
/**
// check for meta data
if (!empty($metaData['include'])) {
foreach ($metaData['include'] as $includedTemplate) {
- $tplPackageID = $this->getPackageID($includedTemplate, $application);
- $includedTemplateFilename = $this->getSourceFilename($includedTemplate, $tplPackageID);
+ $includedTemplateFilename = $this->getSourceFilename($includedTemplate, $application);
$includedMTime = @filemtime($includedTemplateFilename);
if ($includedMTime >= $compileMTime) {