<tbody>
{foreach from=$objects item=template}
- <tr class="jsTemplateRow">
- <td class="columnIcon">
- <a href="{link controller='TemplateAdd'}copy={@$template->templateID}{/link}" title="{lang}wcf.acp.template.copy{/lang}" class="jsTooltip"><span class="icon icon16 fa-files-o"></span></a>
+ {if $template->canCopy()}
+ <tr class="jsTemplateRow">
+ <td class="columnIcon">
+ <a href="{link controller='TemplateAdd'}copy={@$template->templateID}{/link}" title="{lang}wcf.acp.template.copy{/lang}" class="jsTooltip"><span class="icon icon16 fa-files-o"></span></a>
+
+ {if $template->templateGroupID}
+ <a href="{link controller='TemplateDiff' id=$template->templateID}{/link}" title="{lang}wcf.acp.template.diff{/lang}" class="jsTooltip"><span class="icon icon16 fa-exchange"></span></a>
+ <a href="{link controller='TemplateEdit' id=$template->templateID}{/link}" title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip"><span class="icon icon16 fa-pencil"></span></a>
+ <span class="icon icon16 fa-times jsDeleteButton jsTooltip pointer" title="{lang}wcf.global.button.delete{/lang}" data-object-id="{@$template->templateID}" data-confirm-message-html="{lang __encode=true}wcf.acp.template.delete.sure{/lang}"></span>
+ {else}
+ <span class="icon icon16 fa-exchange disabled" title="{lang}wcf.acp.template.diff{/lang}"></span>
+ <span class="icon icon16 fa-pencil disabled" title="{lang}wcf.global.button.edit{/lang}"></span>
+ <span class="icon icon16 fa-times disabled" title="{lang}wcf.global.button.delete{/lang}"></span>
+ {/if}
+
+ {event name='rowButtons'}
+ </td>
+ <td class="columnID">{@$template->templateID}</td>
+ <td class="columnTitle columnTemplateName">{if $template->application != 'wcf'}<span class="badge label">{$template->application}</span> {/if}{if $template->templateGroupID}<a href="{link controller='TemplateEdit' id=$template->templateID}{/link}">{$template->templateName}</a>{else}{$template->templateName}{/if}</td>
+ <td class="columnDate columnLastModificationTime">{@$template->lastModificationTime|time}</td>
- {if $template->templateGroupID}
- <a href="{link controller='TemplateDiff' id=$template->templateID}{/link}" title="{lang}wcf.acp.template.diff{/lang}" class="jsTooltip"><span class="icon icon16 fa-exchange"></span></a>
- <a href="{link controller='TemplateEdit' id=$template->templateID}{/link}" title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip"><span class="icon icon16 fa-pencil"></span></a>
- <span class="icon icon16 fa-times jsDeleteButton jsTooltip pointer" title="{lang}wcf.global.button.delete{/lang}" data-object-id="{@$template->templateID}" data-confirm-message-html="{lang __encode=true}wcf.acp.template.delete.sure{/lang}"></span>
- {else}
- <span class="icon icon16 fa-exchange disabled" title="{lang}wcf.acp.template.diff{/lang}"></span>
- <span class="icon icon16 fa-pencil disabled" title="{lang}wcf.global.button.edit{/lang}"></span>
- <span class="icon icon16 fa-times disabled" title="{lang}wcf.global.button.delete{/lang}"></span>
- {/if}
-
- {event name='rowButtons'}
- </td>
- <td class="columnID">{@$template->templateID}</td>
- <td class="columnTitle columnTemplateName">{if $template->application != 'wcf'}<span class="badge label">{$template->application}</span> {/if}{if $template->templateGroupID}<a href="{link controller='TemplateEdit' id=$template->templateID}{/link}">{$template->templateName}</a>{else}{$template->templateName}{/if}</td>
- <td class="columnDate columnLastModificationTime">{@$template->lastModificationTime|time}</td>
-
- {event name='columns'}
- </tr>
+ {event name='columns'}
+ </tr>
+ {/if}
{/foreach}
</tbody>
</table>
* @property-read integer $lastModificationTime timestamp at which the template has been edited the last time
*/
class Template extends DatabaseObject {
+ /**
+ * list of system critical templates
+ * @var string[]
+ */
+ protected static $systemCriticalTemplates = ['headIncludeJavaScript', 'wysiwyg', 'wysiwygToolbar'];
+
/** @noinspection PhpMissingParentConstructorInspection */
/**
* @inheritDoc
public function getSource() {
return @file_get_contents($this->getPath());
}
+
+ /**
+ * Returns true if current template is considered system critical and
+ * may not be customized at any point.
+ *
+ * @return boolean
+ */
+ public function canCopy() {
+ if (self::isSystemCritical($this->templateName)) {
+ // system critical templates cannot be modified, because whatever the
+ // gain of a customized version is, the damage potential is much higher
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns true if current template is considered system critical and
+ * may not be customized at any point.
+ *
+ * @param string $templateName
+ * @return boolean
+ */
+ public static function isSystemCritical($templateName) {
+ return in_array($templateName, self::$systemCriticalTemplates);
+ }
}
<?php
namespace wcf\system\template;
+use wcf\data\template\Template;
use wcf\system\cache\builder\TemplateGroupCacheBuilder;
use wcf\system\cache\builder\TemplateListenerCodeCacheBuilder;
use wcf\system\event\EventHandler;
* active template compiler
* @var TemplateCompiler
*/
- protected $compilerObj = null;
+ protected $compilerObj;
/**
* forces the template engine to recompile all included templates
* @return string
*/
protected function getPath($templatePath, $templateName) {
- $templateGroupID = $this->getTemplateGroupID();
-
- while ($templateGroupID != 0) {
- $templateGroup = $this->templateGroupCache[$templateGroupID];
+ if (!Template::isSystemCritical($templateName)) {
+ $templateGroupID = $this->getTemplateGroupID();
- $path = $templatePath.$templateGroup->templateGroupFolderName.$templateName.'.tpl';
- if (file_exists($path)) {
- return $path;
+ while ($templateGroupID != 0) {
+ $templateGroup = $this->templateGroupCache[$templateGroupID];
+
+ $path = $templatePath . $templateGroup->templateGroupFolderName . $templateName . '.tpl';
+ if (file_exists($path)) {
+ return $path;
+ }
+
+ $templateGroupID = $templateGroup->parentTemplateGroupID;
}
-
- $templateGroupID = $templateGroup->parentTemplateGroupID;
}
// use default template