Added template administration (WIP)
authorMarcel Werk <burntime@woltlab.com>
Thu, 25 Apr 2013 13:27:43 +0000 (15:27 +0200)
committerMarcel Werk <burntime@woltlab.com>
Thu, 25 Apr 2013 13:27:43 +0000 (15:27 +0200)
19 files changed:
com.woltlab.wcf/acpMenu.xml
com.woltlab.wcf/userGroupOption.xml
wcfsetup/install/files/acp/templates/languageItemList.tpl
wcfsetup/install/files/acp/templates/templateAdd.tpl [new file with mode: 0644]
wcfsetup/install/files/acp/templates/templateGroupAdd.tpl [new file with mode: 0644]
wcfsetup/install/files/acp/templates/templateGroupList.tpl [new file with mode: 0644]
wcfsetup/install/files/acp/templates/templateList.tpl [new file with mode: 0644]
wcfsetup/install/files/lib/acp/form/TemplateAddForm.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/acp/form/TemplateGroupAddForm.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/acp/form/TemplateGroupEditForm.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/acp/page/TemplateGroupListPage.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/acp/page/TemplateListPage.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/data/template/Template.class.php
wcfsetup/install/files/lib/data/template/TemplateAction.class.php
wcfsetup/install/files/lib/data/template/group/TemplateGroupAction.class.php
wcfsetup/install/files/lib/data/template/group/TemplateGroupEditor.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml
wcfsetup/setup/db/install.sql

index e2b0691afe6267a9eb2e9698bc60e0b9b9fe8314..255223befb56b1f019411127219dfc09cb556393 100644 (file)
                </acpmenuitem>
                <!-- /style -->
                
+               <!-- template -->
+               <acpmenuitem name="wcf.acp.menu.link.template">
+                       <parent>wcf.acp.menu.link.display</parent>
+               </acpmenuitem>
+               <acpmenuitem name="wcf.acp.menu.link.template.list">
+                       <controller><![CDATA[wcf\acp\page\TemplateListPage]]></controller>
+                       <parent>wcf.acp.menu.link.template</parent>
+                       <permissions>admin.template.canManageTemplate</permissions>
+               </acpmenuitem>
+               <acpmenuitem name="wcf.acp.menu.link.template.add">
+                       <controller><![CDATA[wcf\acp\form\TemplateAddForm]]></controller>
+                       <parent>wcf.acp.menu.link.template</parent>
+                       <permissions>admin.template.canManageTemplate</permissions>
+               </acpmenuitem>
+               <acpmenuitem name="wcf.acp.menu.link.template.group.list">
+                       <controller><![CDATA[wcf\acp\page\TemplateGroupListPage]]></controller>
+                       <parent>wcf.acp.menu.link.template</parent>
+                       <permissions>admin.template.canManageTemplate</permissions>
+               </acpmenuitem>
+               <acpmenuitem name="wcf.acp.menu.link.template.group.add">
+                       <controller><![CDATA[wcf\acp\form\TemplateGroupAddForm]]></controller>
+                       <parent>wcf.acp.menu.link.template</parent>
+                       <permissions>admin.template.canManageTemplate</permissions>
+               </acpmenuitem>
+               <!-- /template -->
+               
                <!-- language -->
                <acpmenuitem name="wcf.acp.menu.link.language">
                        <parent>wcf.acp.menu.link.display</parent>
index faafa5c716faeb6343dfb013a232d08e2c88b3b0..c40358e2bd2b6fe98fa74d991df906c00d2407a7 100644 (file)
@@ -47,6 +47,9 @@
                        <category name="admin.display.pageMenu">
                                <parent>admin.display</parent>
                        </category>
+                       <category name="admin.template">
+                               <parent>admin.display</parent>
+                       </category>
                        
                        <category name="admin.content">
                                <parent>admin</parent>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
-                               <showorder>1</showorder>
                        </option>
                        <option name="admin.style.canEditStyle">
                                <categoryname>admin.style</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
-                               <showorder>2</showorder>
                        </option>
                        <option name="admin.style.canDeleteStyle">
                                <categoryname>admin.style</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
-                               <showorder>3</showorder>
                        </option>
                        <option name="admin.style.canUseDisabledStyle">
                                <categoryname>admin.style</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
-                               <showorder>4</showorder>
                        </option>
                        <option name="admin.display.canManagePageMenu">
                                <categoryname>admin.display.pageMenu</categoryname>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
                        </option>
+                       <option name="admin.template.canManageTemplate">
+                               <categoryname>admin.template</categoryname>
+                               <optiontype>boolean</optiontype>
+                               <defaultvalue>0</defaultvalue>
+                               <admindefaultvalue>1</admindefaultvalue>
+                       </option>
                </options>
        </import>
 </data>
index 9a22112eae96b035d12bf28d5ac643ed0b3931d5..7bbdbd2dac52c98462461ba48e208e2d58c56eb7 100644 (file)
@@ -84,7 +84,7 @@
 
 {if $objects|count}
        <div class="container marginTop">
-               <ol class="containerList styleList">
+               <ol class="containerList">
                        {foreach from=$objects item=item}
                                <li>
                                        <div>
diff --git a/wcfsetup/install/files/acp/templates/templateAdd.tpl b/wcfsetup/install/files/acp/templates/templateAdd.tpl
new file mode 100644 (file)
index 0000000..7cf910f
--- /dev/null
@@ -0,0 +1,88 @@
+{include file='header'}
+
+<header class="boxHeadline">
+       <hgroup>
+               <h1>{lang}wcf.acp.template.{$action}{/lang}</h1>
+       </hgroup>
+</header>
+
+{if $errorField}
+       <p class="error">{lang}wcf.global.form.error{/lang}</p>
+{/if}
+
+{if $success|isset}
+       <p class="success">{lang}wcf.global.success.{$action}{/lang}</p>
+{/if}
+
+<div class="contentNavigation">
+       <nav>
+               <ul>
+                       <li><a href="{link controller='TemplateList'}{/link}" class="button"><span class="icon icon16 icon-list"></span> <span>{lang}wcf.acp.menu.link.template.list{/lang}</span></a></li>
+                       
+                       {event name='contentNavigationButtons'}
+               </ul>
+       </nav>
+</div>
+
+{if $availableTemplateGroups|count}
+       <form method="post" action="{if $action == 'add'}{link controller='TemplateAdd'}{/link}{else}{link controller='TemplateEdit' id=$templateID}{/link}{/if}">
+               <div class="container containerPadding marginTop">
+                       <fieldset>
+                               <legend>{lang}wcf.global.form.data{/lang}</legend>
+                               
+                               <dl>
+                                       <dt><label for="templateGroupID">{lang}wcf.acp.template.templateGroup{/lang}</label></dt>
+                                       <dd>
+                                               <select name="templateGroupID" id="templateGroupID">
+                                                       {foreach from=$availableTemplateGroups item=availableTemplateGroup}
+                                                               <option value="{@$availableTemplateGroup->templateGroupID}"{if $availableTemplateGroup->templateGroupID == $templateGroupID} selected="selected"{/if}>{$availableTemplateGroup->templateGroupName}</option>
+                                                       {/foreach}
+                                               </select>
+                                       </dd>
+                               </dl>
+                               
+                               <dl{if $errorField == 'templateName'} class="formError"{/if}>
+                                       <dt><label for="tplName">{lang}wcf.global.name{/lang}</label></dt>
+                                       <dd>
+                                               <input type="text" id="tplName" name="tplName" value="{$tplName}" required="required" class="long" />
+                                               {if $errorField == 'templateName'}
+                                                       <small class="innerError">
+                                                               {if $errorType == 'empty'}
+                                                                       {lang}wcf.global.form.error.empty{/lang}
+                                                               {else}
+                                                                       {lang}wcf.acp.template.name.error.{@$errorType}{/lang}
+                                                               {/if}
+                                                       </small>
+                                               {/if}
+                                       </dd>
+                               </dl>
+                               
+                               {event name='dataFields'}
+                       </fieldset>
+                       
+                       
+                       <fieldset>
+                               <legend><label for="templateSource">{lang}wcf.acp.template.source{/lang}</label></legend>
+                       
+                               <dl class="wide">
+                                       <dt><label for="templateSource">{lang}wcf.acp.template.source{/lang}</label></dt>
+                                       <dd>
+                                               <textarea id="templateSource" name="templateSource" cols="40" rows="20">{$templateSource}</textarea>
+                                       </dd>
+                               </dl>
+                       </fieldset>
+                               
+                       
+                       {event name='fieldsets'}
+               </div>
+               
+               <div class="formSubmit">
+                       <input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s" />
+               </div>
+       </form>
+{else}
+       <p class="error">{lang}wcf.acp.template.error.noGroups{/lang}</p>
+{/if}
+
+
+{include file='footer'}
diff --git a/wcfsetup/install/files/acp/templates/templateGroupAdd.tpl b/wcfsetup/install/files/acp/templates/templateGroupAdd.tpl
new file mode 100644 (file)
index 0000000..a4f1cea
--- /dev/null
@@ -0,0 +1,91 @@
+{include file='header'}
+
+<header class="boxHeadline">
+       <hgroup>
+               <h1>{lang}wcf.acp.template.group.{$action}{/lang}</h1>
+       </hgroup>
+</header>
+
+{if $errorField}
+       <p class="error">{lang}wcf.global.form.error{/lang}</p>
+{/if}
+
+{if $success|isset}
+       <p class="success">{lang}wcf.global.success.{$action}{/lang}</p>
+{/if}
+
+<div class="contentNavigation">
+       <nav>
+               <ul>
+                       <li><a href="{link controller='TemplateGroupList'}{/link}" class="button"><span class="icon icon16 icon-list"></span> <span>{lang}wcf.acp.menu.link.template.group.list{/lang}</span></a></li>
+                       
+                       {event name='contentNavigationButtons'}
+               </ul>
+       </nav>
+</div>
+
+<form method="post" action="{if $action == 'add'}{link controller='TemplateGroupAdd'}{/link}{else}{link controller='TemplateGroupEdit' id=$templateGroupID}{/link}{/if}">
+       <div class="container containerPadding marginTop">
+               <fieldset>
+                       <legend>{lang}wcf.global.form.data{/lang}</legend>
+                       
+                       {if $availableTemplateGroups|count}
+                               <dl>
+                                       <dt><label for="parentTemplateGroupID">{lang}wcf.acp.template.group.parentTemplateGroup{/lang}</label></dt>
+                                       <dd>
+                                               <select name="parentTemplateGroupID" id="parentTemplateGroupID">
+                                                       <option value="0"></option>
+                                                       {foreach from=$availableTemplateGroups item=availableTemplateGroup}
+                                                               <option value="{@$availableTemplateGroup->templateGroupID}"{if $availableTemplateGroup->templateGroupID == $parentTemplateGroupID} selected="selected"{/if}>{$availableTemplateGroup->templateGroupName}</option>
+                                                       {/foreach}
+                                               </select>
+                                       </dd>
+                               </dl>
+                       {/if}
+                       
+                       <dl{if $errorField == 'templateGroupName'} class="formError"{/if}>
+                               <dt><label for="templateGroupName">{lang}wcf.global.name{/lang}</label></dt>
+                               <dd>
+                                       <input type="text" id="templateGroupName" name="templateGroupName" value="{$templateGroupName}" required="required" class="long" />
+                                       {if $errorField == 'templateGroupName'}
+                                               <small class="innerError">
+                                                       {if $errorType == 'empty'}
+                                                               {lang}wcf.global.form.error.empty{/lang}
+                                                       {else}
+                                                               {lang}wcf.acp.template.group.name.error.{@$errorType}{/lang}
+                                                       {/if}
+                                               </small>
+                                       {/if}
+                               </dd>
+                       </dl>
+                       
+                       <dl{if $errorField == 'templateGroupFolderName'} class="formError"{/if}>
+                               <dt><label for="templateGroupFolderName">{lang}wcf.acp.template.group.folderName{/lang}</label></dt>
+                               <dd>
+                                       <input type="text" id="templateGroupFolderName" name="templateGroupFolderName" value="{$templateGroupFolderName}" required="required" class="long" />
+                                       {if $errorField == 'templateGroupFolderName'}
+                                               <small class="innerError">
+                                                       {if $errorType == 'empty'}
+                                                               {lang}wcf.global.form.error.empty{/lang}
+                                                       {else}
+                                                               {lang}wcf.acp.template.group.name.error.{@$errorType}{/lang}
+                                                       {/if}
+                                               </small>
+                                       {/if}
+                                       <small>{lang}wcf.acp.template.group.folderName.description{/lang}</small>
+                               </dd>
+                       </dl>
+                       
+                       {event name='dataFields'}
+               </fieldset>
+               
+               {event name='fieldsets'}
+       </div>
+       
+       <div class="formSubmit">
+               <input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s" />
+       </div>
+</form>
+
+
+{include file='footer'}
diff --git a/wcfsetup/install/files/acp/templates/templateGroupList.tpl b/wcfsetup/install/files/acp/templates/templateGroupList.tpl
new file mode 100644 (file)
index 0000000..59144f2
--- /dev/null
@@ -0,0 +1,84 @@
+{include file='header' pageTitle='wcf.acp.template.group.list'}
+
+<header class="boxHeadline">
+       <hgroup>
+               <h1>{lang}wcf.acp.template.group.list{/lang}</h1>
+       </hgroup>
+       
+       <script type="text/javascript">
+               //<![CDATA[
+               $(function() {
+                       new WCF.Action.Delete('wcf\\data\\template\\group\\TemplateGroupAction', '.jsTemplateGroupRow');
+               });
+               //]]>
+       </script>
+</header>
+
+<div class="contentNavigation">
+       {pages print=true assign=pagesLinks controller="TemplateGroupList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"}
+       
+       <nav>
+               <ul>
+                       <li><a href="{link controller='TemplateGroupAdd'}{/link}" class="button"><span class="icon icon16 icon-plus"></span> <span>{lang}wcf.acp.template.group.add{/lang}</span></a></li>
+                       
+                       {event name='contentNavigationButtonsTop'}
+               </ul>
+       </nav>
+</div>
+
+{if $objects|count}
+       <div class="tabularBox tabularBoxTitle marginTop">
+               <hgroup>
+                       <h1>{lang}wcf.acp.template.group.list{/lang} <span class="badge badgeInverse">{#$items}</span></h1>
+               </hgroup>
+               
+               <table class="table">
+                       <thead>
+                               <tr>
+                                       <th class="columnID columnTemplateGroupID{if $sortField == 'templateGroupID'} active {@$sortOrder}{/if}" colspan="2"><a href="{link controller='TemplateGroupList'}pageNo={@$pageNo}&sortField=templateGroupID&sortOrder={if $sortField == 'templateGroupID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.global.objectID{/lang}</a></th>
+                                       <th class="columnTitle columnTemplateGroupName{if $sortField == 'templateGroupName'} active {@$sortOrder}{/if}"><a href="{link controller='TemplateGroupList'}pageNo={@$pageNo}&sortField=templateGroupName&sortOrder={if $sortField == 'templateGroupName' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.global.name{/lang}</a></th>
+                                       <th class="columnText columnTemplateGroupFolderName{if $sortField == 'templateGroupFolderName'} active {@$sortOrder}{/if}"><a href="{link controller='TemplateGroupList'}pageNo={@$pageNo}&sortField=templateGroupFolderName&sortOrder={if $sortField == 'templateGroupFolderName' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.template.group.folderName{/lang}</a></th>
+                                       <th class="columnDigits columnTemplates{if $sortField == 'templates'} active {@$sortOrder}{/if}"><a href="{link controller='TemplateGroupList'}pageNo={@$pageNo}&sortField=templates&sortOrder={if $sortField == 'templates' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.template.group.templates{/lang}</a></th>
+                                       
+                                       {event name='columnHeads'}
+                               </tr>
+                       </thead>
+                       
+                       <tbody>
+                               {foreach from=$objects item=templateGroup}
+                                       <tr class="jsTemplateGroupRow">
+                                               <td class="columnIcon">
+                                                       <a href="{link controller='TemplateGroupEdit' id=$templateGroup->templateGroupID}{/link}" title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip"><span class="icon icon16 icon-pencil"></span></a>
+                                                       <span class="icon icon16 icon-remove jsDeleteButton jsTooltip pointer" title="{lang}wcf.global.button.delete{/lang}" data-object-id="{@$templateGroup->templateGroupID}" data-confirm-message="{lang}wcf.acp.template.group.delete.sure{/lang}"></span>
+                                                       
+                                                       {event name='rowButtons'}
+                                               </td>
+                                               <td class="columnID">{@$templateGroup->templateGroupID}</td>
+                                               <td class="columnTitle columnTemplateGroupName"><a href="{link controller='TemplateGroupEdit' id=$templateGroup->templateGroupID}{/link}">{$templateGroup->templateGroupName}</a></td>
+                                               <td class="columnText columnTemplateGroupFolderName">{$templateGroup->templateGroupFolderName}</td>
+                                               <td class="columnDigits columnTemplates">{#$templateGroup->templates}</td>
+                                               
+                                               {event name='columns'}
+                                       </tr>
+                               {/foreach}
+                       </tbody>
+               </table>
+               
+       </div>
+       
+       <div class="contentNavigation">
+               {@$pagesLinks}
+               
+               <nav>
+                       <ul>
+                               <li><a href="{link controller='TemplateGroupAdd'}{/link}" class="button"><span class="icon icon16 icon-plus"></span> <span>{lang}wcf.acp.template.group.add{/lang}</span></a></li>
+                       
+                               {event name='contentNavigationButtonsBottom'}
+                       </ul>
+               </nav>
+       </div>
+{else}
+       <p class="info">{lang}wcf.acp.template.group.noItems{/lang}</p>
+{/if}
+
+{include file='footer'}
diff --git a/wcfsetup/install/files/acp/templates/templateList.tpl b/wcfsetup/install/files/acp/templates/templateList.tpl
new file mode 100644 (file)
index 0000000..914f2ff
--- /dev/null
@@ -0,0 +1,124 @@
+{include file='header' pageTitle="wcf.acp.template.list"}
+
+<script type="text/javascript">
+       //<![CDATA[
+       $(function() {
+               new WCF.Action.Delete('wcf\\data\\template\\TemplateAction', '.jsTemplateRow');
+       });
+       //]]>
+</script>
+
+<header class="boxHeadline">
+       <hgroup>
+               <h1>{lang}wcf.acp.template.list{/lang}</h1>
+       </hgroup>
+</header>
+
+<form method="post" action="{link controller='TemplateList'}{/link}">
+       <div class="container containerPadding marginTop">
+               <fieldset>
+                       <legend>{lang}wcf.acp.template.list.filter{/lang}</legend>
+               
+                       <dl>
+                               <dt><label for="templateGroupID">{lang}wcf.acp.template.group{/lang}</label></dt>
+                               <dd>
+                                       <select name="templateGroupID" id="templateGroupID">
+                                               <option value="0">{lang}wcf.acp.template.group.default{/lang}</option>
+                                               {foreach from=$availableTemplateGroups item=availableTemplateGroup}
+                                                       <option value="{@$availableTemplateGroup->templateGroupID}"{if $availableTemplateGroup->templateGroupID == $templateGroupID} selected="selected"{/if}>{$availableTemplateGroup->templateGroupName}</option>
+                                               {/foreach}
+                                       </select>
+                               </dd>
+                       </dl>
+                       
+                       <dl>
+                               <dt><label for="searchTemplateName">{lang}wcf.global.name{/lang}</label></dt>
+                               <dd>
+                                       <input type="text" id="searchTemplateName" name="searchTemplateName" value="{$searchTemplateName}" class="long" />
+                               </dd>
+                       </dl>
+               </fieldset>
+       </div>
+       
+       <div class="formSubmit">
+               <input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s" />
+       </div>
+</form>
+
+<div class="contentNavigation">
+       {assign var='linkParameters' value=''}
+       {if $templateGroupID}{capture append=linkParameters}&templateGroupID={@$templateGroupID}{/capture}{/if}
+       {if $searchTemplateName}{capture append=linkParameters}&searchTemplateName={@$searchTemplateName|rawurlencode}{/capture}{/if}
+               
+       {pages print=true assign=pagesLinks controller="TemplateList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder$linkParameters"}
+       
+       <nav>
+               <ul>
+                       <li><a href="{link controller='TemplateAdd'}{/link}" class="button"><span class="icon icon16 icon-plus"></span> <span>{lang}wcf.acp.template.add{/lang}</span></a></li>
+                       
+                       {event name='contentNavigationButtonsTop'}
+               </ul>
+       </nav>
+</div>
+
+{if $objects|count}
+       <div class="tabularBox tabularBoxTitle marginTop">
+               <hgroup>
+                       <h1>{lang}wcf.acp.template.list{/lang} <span class="badge badgeInverse">{#$items}</span></h1>
+               </hgroup>
+               
+               <table class="table">
+                       <thead>
+                               <tr>
+                                       <th class="columnID columnTemplateID{if $sortField == 'templateID'} active {@$sortOrder}{/if}" colspan="2"><a href="{link controller='TemplateList'}pageNo={@$pageNo}&sortField=templateID&sortOrder={if $sortField == 'templateID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.global.objectID{/lang}</a></th>
+                                       <th class="columnTitle columnTemplateName{if $sortField == 'templateName'} active {@$sortOrder}{/if}"><a href="{link controller='TemplateList'}pageNo={@$pageNo}&sortField=templateName&sortOrder={if $sortField == 'templateName' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.global.name{/lang}</a></th>
+                                       <th class="columnDate columnLastModificationTime{if $sortField == 'lastModificationTime'} active {@$sortOrder}{/if}"><a href="{link controller='TemplateList'}pageNo={@$pageNo}&sortField=lastModificationTime&sortOrder={if $sortField == 'lastModificationTime' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.acp.template.lastModificationTime{/lang}</a></th>
+                                       
+                                       {event name='columnHeads'}
+                               </tr>
+                       </thead>
+                       
+                       <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 icon-copy"></span></a>
+                                                       
+                                                       {if $template->templateGroupID}
+                                                               <a href="{link controller='TemplateEdit' id=$template->templateID}{/link}" title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip"><span class="icon icon16 icon-pencil"></span></a>
+                                                               <span class="icon icon16 icon-remove jsDeleteButton jsTooltip pointer" title="{lang}wcf.global.button.delete{/lang}" data-object-id="{@$template->templateID}" data-confirm-message="{lang}wcf.acp.template.delete.sure{/lang}"></span>
+                                                       {else}
+                                                               <span class="icon icon16 icon-pencil disabled" title="{lang}wcf.global.button.edit{/lang}"></span>
+                                                               <span class="icon icon16 icon-remove 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->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>
+                               {/foreach}
+                       </tbody>
+               </table>
+               
+       </div>
+       
+       <div class="contentNavigation">
+               {@$pagesLinks}
+               
+               <nav>
+                       <ul>
+                               <li><a href="{link controller='TemplateAdd'}{/link}" class="button"><span class="icon icon16 icon-plus"></span> <span>{lang}wcf.acp.template.add{/lang}</span></a></li>
+                       
+                               {event name='contentNavigationButtonsBottom'}
+                       </ul>
+               </nav>
+       </div>
+{else}
+       <p class="info">{lang}wcf.acp.template.noItems{/lang}</p>
+{/if}
+
+{include file='footer'}
diff --git a/wcfsetup/install/files/lib/acp/form/TemplateAddForm.class.php b/wcfsetup/install/files/lib/acp/form/TemplateAddForm.class.php
new file mode 100644 (file)
index 0000000..c89bfb1
--- /dev/null
@@ -0,0 +1,198 @@
+<?php
+namespace wcf\acp\form;
+use wcf\data\template\group\TemplateGroup;
+use wcf\data\template\group\TemplateGroupAction;
+use wcf\data\template\group\TemplateGroupList;
+use wcf\data\template\Template;
+use wcf\data\template\TemplateAction;
+use wcf\form\AbstractForm;
+use wcf\system\exception\UserInputException;
+use wcf\system\WCF;
+use wcf\util\StringUtil;
+
+/**
+ * Shows the form for adding new templates.
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2013 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage acp.form
+ * @category   Community Framework
+ */
+class TemplateAddForm extends AbstractForm {
+       /**
+        * @see wcf\page\AbstractPage::$activeMenuItem
+        */
+       public $activeMenuItem = 'wcf.acp.menu.link.template.add';
+       
+       /**
+        * @see wcf\page\AbstractPage::$neededPermissions
+        */
+       public $neededPermissions = array('admin.template.canManageTemplate');
+       
+       /**
+        * template name
+        * @var string
+        */
+       public $tplName = '';
+       
+       /**
+        * template group id
+        * @var integer
+        */
+       public $templateGroupID = 0;
+       
+       /**
+        * template source code
+        * @var string
+        */
+       public $templateSource = '';
+       
+       /**
+        * available template groups
+        * @var array
+        */
+       public $availableTemplateGroups = array();
+       
+       /**
+        * template's package id
+        * @var integer
+        */
+       public $packageID = PACKAGE_ID;
+       
+       /**
+        * @see wcf\form\IForm::readFormParameters()
+        */
+       public function readFormParameters() {
+               parent::readFormParameters();
+               
+               if (isset($_POST['tplName'])) $this->tplName = StringUtil::trim($_POST['tplName']);
+               if (isset($_POST['templateSource'])) $this->templateSource = $_POST['templateSource'];
+               if (isset($_POST['templateGroupID'])) $this->templateGroupID = intval($_POST['templateGroupID']);
+               
+               // get package id for this template
+               $sql = "SELECT  packageID
+                       FROM    wcf".WCF_N."_template
+                       WHERE   templateName = ?
+                               AND templateGroupID IS NULL";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array($this->tplName));
+               $row = $statement->fetchArray();
+               if ($row !== false) {
+                       $this->packageID = $row['packageID'];
+               }
+       }
+       
+       /**
+        * @see wcf\form\IForm::validate()
+        */
+       public function validate() {
+               parent::validate();
+               
+               $this->validateName();
+               $this->validateGroup();
+       }
+       
+       /**
+        * Validates the template name.
+        */
+       protected function validateName() {
+               if (empty($this->tplName)) {
+                       throw new UserInputException('tplName');
+               }
+       
+               if (!preg_match('^/[a-z0-9_\-]+$/i', $this->tplName)) {
+                       throw new UserInputException('tplName', 'notValid');
+               }
+               
+               $sql = "SELECT  COUNT(*) AS count
+                       FROM    wcf".WCF_N."_template
+                       WHERE   templateName = ?
+                               AND packageID = ?
+                               AND templateGroupID = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array(
+                       $this->tplName,
+                       $this->packageID,
+                       $this->templateGroupID
+               ));
+               $row = $statement->fetchArray();
+               if ($row['count']) {
+                       throw new UserInputException('tplName', 'notUnique');
+               }
+       }
+       
+       /**
+        * Validates the selected template group.
+        */
+       protected function validateGroup() {
+               if (!$this->templateGroupID) {
+                       throw new UserInputException('templateGroupID');
+               }
+               
+               $templateGroup = new TemplateGroup($this->templateGroupID);
+               if (!$templateGroup->templateGroupID) {
+                       throw new UserInputException('templateGroupID');
+               }
+       }
+       
+       /**
+        * @see wcf\form\IForm::save()
+        */
+       public function save() {
+               parent::save();
+               
+               $this->objectAction = new TemplateAction(array(), 'create', array('data' => array(
+                       'templateName' => $this->templateName,
+                       'packageID' => $this->packageID,
+                       'templateGroupID' => ($this->templateGroupID)
+               ), 'source' => $this->templateSource));
+               $this->objectAction->executeAction();
+               $this->saved();
+               
+               // reset values
+               $this->templateName = $this->source = '';
+               $this->templateGroupID = 0;
+               
+               // show success
+               WCF::getTPL()->assign(array(
+                       'success' => true
+               ));
+       }
+       
+       /**
+        * @see wcf\page\IPage::readData()
+        */
+       public function readData() {
+               parent::readData();
+       
+               $templateGroupList = new TemplateGroupList();
+               $templateGroupList->readObjects();
+               $this->availableTemplateGroups = $templateGroupList->getObjects();
+               
+               if (!count($_POST)) {
+                       if (!empty($_REQUEST['copy'])) {
+                               $templateID = intval($_REQUEST['copy']);
+                               $template = new Template($templateID);
+                               $this->tplName = $template->templateName;
+                               $this->templateSource = $template->getSource();
+                       }
+               }
+       }
+       
+       /**
+        * @see wcf\page\IPage::assignVariables()
+        */
+       public function assignVariables() {
+               parent::assignVariables();
+               
+               WCF::getTPL()->assign(array(
+                       'action' => 'add',
+                       'tplName' => $this->tplName,
+                       'templateGroupID' => $this->templateGroupID,
+                       'templateSource' => $this->templateSource,
+                       'availableTemplateGroups' => $this->availableTemplateGroups
+               ));
+       }
+}
diff --git a/wcfsetup/install/files/lib/acp/form/TemplateGroupAddForm.class.php b/wcfsetup/install/files/lib/acp/form/TemplateGroupAddForm.class.php
new file mode 100644 (file)
index 0000000..b504e9f
--- /dev/null
@@ -0,0 +1,166 @@
+<?php
+namespace wcf\acp\form;
+use wcf\data\template\group\TemplateGroupAction;
+use wcf\data\template\group\TemplateGroupList;
+use wcf\form\AbstractForm;
+use wcf\system\exception\UserInputException;
+use wcf\system\WCF;
+use wcf\util\StringUtil;
+
+/**
+ * Shows the form for adding new template groups.
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2013 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage acp.form
+ * @category   Community Framework
+ */
+class TemplateGroupAddForm extends AbstractForm {
+       /**
+        * @see wcf\page\AbstractPage::$activeMenuItem
+        */
+       public $activeMenuItem = 'wcf.acp.menu.link.template.group.add';
+       
+       /**
+        * @see wcf\page\AbstractPage::$neededPermissions
+        */
+       public $neededPermissions = array('admin.template.canManageTemplate');
+       
+       /**
+        * template group name
+        * @var string
+        */
+       public $templateGroupName = '';
+       
+       /**
+        * template group folder
+        * @var integer
+        */
+       public $templateGroupFolderName = '';
+       
+       /**
+        * parent template group id
+        * @var integer
+        */
+       public $parentTemplateGroupID = 0;
+       
+       /**
+        * available template groups
+        * @var array
+        */
+       public $availableTemplateGroups = array();
+       
+       /**
+        * @see wcf\form\IForm::readFormParameters()
+        */
+       public function readFormParameters() {
+               parent::readFormParameters();
+               
+               if (isset($_POST['templateGroupName'])) $this->templateGroupName = StringUtil::trim($_POST['templateGroupName']);
+               if (isset($_POST['templateGroupFolderName'])) $this->templateGroupFolderName = StringUtil::trim($_POST['templateGroupFolderName']);
+               if (isset($_POST['parentTemplateGroupID'])) $this->parentTemplateGroupID = intval($_POST['parentTemplateGroupID']);
+       }
+       
+       /**
+        * @see wcf\form\IForm::validate()
+        */
+       public function validate() {
+               parent::validate();
+               
+               $this->validateName();
+               $this->validateFolderName();
+       }
+       
+       /**
+        * Validates the template group name.
+        */
+       protected function validateName() {
+               if (empty($this->templateGroupName)) {
+                       throw new UserInputException('templateGroupName');
+               }
+       
+               $sql = "SELECT  COUNT(*) AS count
+                       FROM    wcf".WCF_N."_template_group
+                       WHERE   templateGroupName = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array($this->templateGroupName));
+               $row = $statement->fetchArray();
+               if ($row['count']) {
+                       throw new UserInputException('templateGroupName', 'notUnique');
+               }
+       }
+       
+       /**
+        * Validates the template group folder name.
+        */
+       protected function validateFolderName() {
+               if (empty($this->templateGroupFolderName)) {
+                       throw new UserInputException('templateGroupFolderName');
+               }
+               
+               if ($this->templateGroupFolderName == '/') {
+                       throw new UserInputException('templateGroupFolderName', 'notUnique');
+               }
+       
+               $sql = "SELECT  COUNT(*) AS count
+                       FROM    wcf".WCF_N."_template_group
+                       WHERE   templateGroupFolderName = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute(array($this->templateGroupFolderName));
+               $row = $statement->fetchArray();
+               if ($row['count']) {
+                       throw new UserInputException('templateGroupFolderName', 'notUnique');
+               }
+       }
+       
+       /**
+        * @see wcf\form\IForm::save()
+        */
+       public function save() {
+               parent::save();
+               
+               $this->objectAction = new TemplateGroupAction(array(), 'create', array('data' => array(
+                       'templateGroupName' => $this->templateGroupName,
+                       'templateGroupFolderName' => $this->templateGroupFolderName,
+                       'parentTemplateGroupID' => ($this->parentTemplateGroupID ?: null)
+               )));
+               $this->objectAction->executeAction();
+               $this->saved();
+               
+               // reset values
+               $this->templateGroupName = $this->templateGroupFolderName = '';
+               
+               // show success
+               WCF::getTPL()->assign(array(
+                       'success' => true
+               ));
+       }
+       
+       /**
+        * @see wcf\page\IPage::readData()
+        */
+       public function readData() {
+               parent::readData();
+       
+               $templateGroupList = new TemplateGroupList();
+               $templateGroupList->readObjects();
+               $this->availableTemplateGroups = $templateGroupList->getObjects();
+       }
+       
+       /**
+        * @see wcf\page\IPage::assignVariables()
+        */
+       public function assignVariables() {
+               parent::assignVariables();
+               
+               WCF::getTPL()->assign(array(
+                       'action' => 'add',
+                       'templateGroupName' => $this->templateGroupName,
+                       'templateGroupFolderName' => $this->templateGroupFolderName,
+                       'parentTemplateGroupID' => $this->parentTemplateGroupID,
+                       'availableTemplateGroups' => $this->availableTemplateGroups
+               ));
+       }
+}
diff --git a/wcfsetup/install/files/lib/acp/form/TemplateGroupEditForm.class.php b/wcfsetup/install/files/lib/acp/form/TemplateGroupEditForm.class.php
new file mode 100644 (file)
index 0000000..009417f
--- /dev/null
@@ -0,0 +1,120 @@
+<?php
+namespace wcf\acp\form;
+use wcf\data\template\group\TemplateGroup;
+use wcf\data\template\group\TemplateGroupAction;
+use wcf\data\template\group\TemplateGroupList;
+use wcf\form\AbstractForm;
+use wcf\system\exception\IllegalLinkException;
+use wcf\system\WCF;
+
+/**
+ * Shows the form for editing template groups.
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2013 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage acp.form
+ * @category   Community Framework
+ */
+class TemplateGroupEditForm extends TemplateGroupAddForm {
+       /**
+        * @see wcf\page\AbstractPage::$activeMenuItem
+        */
+       public $activeMenuItem = 'wcf.acp.menu.link.template';
+       
+       /**
+        * template group id
+        * @var integer
+        */
+       public $templateGroupID = 0;
+       
+       /**
+        * template group object
+        * @var wcf\data\template\group\TemplateGroup
+        */
+       public $templateGroup = null;
+       
+       /**
+        * @see wcf\patge\IPage::readParameters()
+        */
+       public function readParameters() {
+               parent::readParameters();
+       
+               if (isset($_REQUEST['id'])) $this->templateGroupID = intval($_REQUEST['id']);
+               $this->templateGroup = new TemplateGroup($this->templateGroupID);
+               if (!$this->templateGroup->templateGroupID) {
+                       throw new IllegalLinkException();
+               }
+       }
+       
+       /**
+        * @see wcf\acp\form\TemplateGroupAddForm::validateName()
+        */
+       protected function validateName() {
+               if ($this->templateGroupName != $this->templateGroup->templateGroupName) {
+                       parent::validateName();
+               }
+       }
+       
+       /**
+        * @see wcf\acp\form\TemplateGroupAddForm::validateFolderName()
+        */
+       protected function validateFolderName() {
+               if ($this->templateGroupFolderName != $this->templateGroup->templateGroupFolderName) {
+                       parent::validateFolderName();
+               }
+       }
+       
+       /**
+        * @see wcf\form\IForm::save()
+        */
+       public function save() {
+               AbstractForm::save();
+               
+               $this->objectAction = new TemplateGroupAction(array($this->templateGroup), 'update', array('data' => array(
+                       'templateGroupName' => $this->templateGroupName,
+                       'templateGroupFolderName' => $this->templateGroupFolderName,
+                       'parentTemplateGroupID' => ($this->parentTemplateGroupID ?: null)
+               )));
+               $this->objectAction->executeAction();
+               $this->saved();
+               
+               // show success
+               WCF::getTPL()->assign(array(
+                       'success' => true
+               ));
+       }
+       
+       /**
+        * @see wcf\page\IPage::readData()
+        */
+       public function readData() {
+               AbstractForm::readData();
+       
+               $templateGroupList = new TemplateGroupList();
+               $templateGroupList->getConditionBuilder()->add('templateGroupID <> ?', array($this->templateGroupID));
+               $templateGroupList->readObjects();
+               $this->availableTemplateGroups = $templateGroupList->getObjects();
+       
+               // default values
+               if (!count($_POST)) {
+                       $this->templateGroupName = $this->templateGroup->templateGroupName;
+                       $this->templateGroupFolderName = $this->templateGroup->templateGroupFolderName;
+                       $this->parentTemplateGroupID = $this->templateGroup->parentTemplateGroupID;
+               }
+       }
+       
+       /**
+        * @see wcf\page\IPage::assignVariables()
+        */
+       public function assignVariables() {
+               parent::assignVariables();
+               
+               WCF::getTPL()->assign(array(
+                       'action' => 'edit',
+                       'templateGroupID' => $this->templateGroupID,
+                       'templateGroup' => $this->templateGroup
+               ));
+       }
+}
diff --git a/wcfsetup/install/files/lib/acp/page/TemplateGroupListPage.class.php b/wcfsetup/install/files/lib/acp/page/TemplateGroupListPage.class.php
new file mode 100644 (file)
index 0000000..ba1021b
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+namespace wcf\acp\page;
+use wcf\page\SortablePage;
+
+/**
+ * Shows a list of installed template groups.
+ * 
+ * @author     Marcel Werk
+ * @copyright  2001-2013 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage acp.page
+ * @category   Community Framework
+ */
+class TemplateGroupListPage extends SortablePage {
+       /**
+        * @see wcf\page\AbstractPage::$activeMenuItem
+        */
+       public $activeMenuItem = 'wcf.acp.menu.link.template.group.list';
+       
+       /**
+        * @see wcf\page\AbstractPage::$neededPermissions
+        */
+       public $neededPermissions = array('admin.template.canManageTemplate');
+       
+       /**
+        * @see wcf\page\SortablePage::$defaultSortField
+        */
+       public $defaultSortField = 'templateGroupName';
+       
+       /**
+        * @see wcf\page\MultipleLinkPage::$objectListClassName
+        */
+       public $objectListClassName = 'wcf\data\template\group\TemplateGroupList';
+       
+       /**
+        * @see wcf\page\SortablePage::$defaultSortField
+        */
+       public $validSortFields = array('templateGroupID', 'templateGroupName', 'templateGroupFolderName', 'templates');
+       
+       /**
+        * @see wcf\page\MultipleLinkPage::initObjectList
+        */
+       protected function initObjectList() {
+               parent::initObjectList();
+               
+               $this->objectList->sqlSelects = "(SELECT COUNT(*) FROM wcf".WCF_N."_template WHERE templateGroupID = template_group.templateGroupID) AS templates";
+       }
+}
diff --git a/wcfsetup/install/files/lib/acp/page/TemplateListPage.class.php b/wcfsetup/install/files/lib/acp/page/TemplateListPage.class.php
new file mode 100644 (file)
index 0000000..e014731
--- /dev/null
@@ -0,0 +1,113 @@
+<?php
+namespace wcf\acp\page;
+use wcf\data\template\group\TemplateGroupList;
+use wcf\page\SortablePage;
+use wcf\system\WCF;
+use wcf\util\StringUtil;
+
+/**
+ * Shows a list of templates.
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2013 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage acp.page
+ * @category   Community Framework
+ */
+class TemplateListPage extends SortablePage {
+       /**
+        * @see wcf\page\AbstractPage::$activeMenuItem
+        */
+       public $activeMenuItem = 'wcf.acp.menu.link.template.list';
+       
+       /**
+        * @see wcf\page\AbstractPage::$neededPermissions
+        */
+       public $neededPermissions = array('admin.template.canManageTemplate');
+       
+       /**
+        * @see wcf\page\MultipleLinkPage::$objectListClassName
+        */
+       public $objectListClassName = 'wcf\data\template\TemplateList';
+       
+       /**
+        * @see wcf\page\MultipleLinkPage::$itemsPerPage
+        */
+       public $itemsPerPage = 100;
+       
+       /**
+        * @see wcf\page\SortablePage::$itemsPerPage
+        */
+       public $defaultSortField = 'templateName';
+       
+       /**
+        * @see wcf\page\SortablePage::$validSortFields
+        */
+       public $validSortFields = array('templateID', 'templateName', 'lastModificationTime');
+       
+       /**
+        * template group id
+        * @var integer
+        */
+       public $templateGroupID = 0;
+       
+       /**
+        * template name
+        * @var string
+        */
+       public $searchTemplateName = '';
+       
+       /**
+        * available template groups
+        * @var array
+        */
+       public $availableTemplateGroups = array();
+       
+       /**
+        * @see wcf\page\IPage::readParameters()
+        */
+       public function readParameters() {
+               parent::readParameters();
+       
+               if (isset($_REQUEST['templateGroupID'])) $this->templateGroupID = intval($_REQUEST['templateGroupID']);
+               if (isset($_REQUEST['searchTemplateName'])) $this->searchTemplateName = StringUtil::trim($_REQUEST['searchTemplateName']);
+       }
+       
+       /**
+        * @see wcf\page\MultipleLinkPage::initObjectList()
+        */
+       protected function initObjectList() {
+               parent::initObjectList();
+               
+               if ($this->templateGroupID) $this->objectList->getConditionBuilder()->add('template.templateGroupID = ?', array($this->templateGroupID));
+               else $this->objectList->getConditionBuilder()->add('template.templateGroupID IS NULL');
+               
+               if ($this->searchTemplateName) $this->objectList->getConditionBuilder()->add('templateName LIKE ?', array($this->searchTemplateName.'%'));
+       }
+       
+       /**
+        * @see wcf\page\IPage::readData()
+        */
+       public function readData() {
+               parent::readData();
+               
+               // get template groups          
+               $templateGroupList = new TemplateGroupList();
+               $templateGroupList->readObjects();
+               $this->availableTemplateGroups = $templateGroupList->getObjects();
+       }
+       
+       /**
+        * @see wcf\page\IPage::assignVariables()
+        */
+       public function assignVariables() {
+               parent::assignVariables();
+       
+               WCF::getTPL()->assign(array(
+                       'templateGroupID' => $this->templateGroupID,
+                       'searchTemplateName' => $this->searchTemplateName,
+                       'availableTemplateGroups' => $this->availableTemplateGroups
+               ));
+       }
+}
index 3491ef5015c434c52af90e97717c32f5d2c05546..13600a0f8bbe63f454a33d45f80bb00d9f5da772 100644 (file)
@@ -32,13 +32,13 @@ class Template extends DatabaseObject {
         */
        public function __construct($id, $row = null, DatabaseObject $object = null) {
                if ($id !== null) {
-                       $sql = "SELECT          template.*, group.templateGroupFolderName, package.packageDir
+                       $sql = "SELECT          template.*, template_group.templateGroupFolderName, package.packageDir
                                FROM            wcf".WCF_N."_template template
-                               LEFT JOIN       wcf".WCF_N."_template_group group
-                               ON              (group.templateGroupID = template.templateGroupID)
+                               LEFT JOIN       wcf".WCF_N."_template_group template_group
+                               ON              (template_group.templateGroupID = template.templateGroupID)
                                LEFT JOIN       wcf".WCF_N."_package package
                                ON              (package.packageID = template.packageID)
-                               WHERE           template.templateID = ?".$id;
+                               WHERE           template.templateID = ?";
                        $statement = WCF::getDB()->prepareStatement($sql);
                        $statement->execute(array($id));
                        $row = $statement->fetchArray();
index afbf1166df0f8f64f1f45fa2200edbcd9d60b58d..94f5319d2559e56fe041c4d8a031f03442253405 100644 (file)
@@ -21,15 +21,15 @@ class TemplateAction extends AbstractDatabaseObjectAction {
        /**
         * @see wcf\data\AbstractDatabaseObjectAction::$permissionsCreate
         */
-       protected $permissionsCreate = array('admin.template.canAddTemplate');
+       protected $permissionsCreate = array('admin.template.canManageTemplate');
        
        /**
         * @see wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
         */
-       protected $permissionsDelete = array('admin.template.canDeleteTemplate');
+       protected $permissionsDelete = array('admin.template.canManageTemplate');
        
        /**
         * @see wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
         */
-       protected $permissionsUpdate = array('admin.template.canEditTemplate');
+       protected $permissionsUpdate = array('admin.template.canManageTemplate');
 }
index d3cb6a85ab6b5310f4bcb3faa3218e102b639941..51b6dc36888dba13e71f46132716a356b64959cf 100644 (file)
@@ -21,15 +21,15 @@ class TemplateGroupAction extends AbstractDatabaseObjectAction {
        /**
         * @see wcf\data\AbstractDatabaseObjectAction::$permissionsCreate
         */
-       protected $permissionsCreate = array('admin.template.canAddTemplateGroup');
+       protected $permissionsCreate = array('admin.template.canManageTemplate');
        
        /**
         * @see wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
         */
-       protected $permissionsDelete = array('admin.template.canDeleteTemplateGroup');
+       protected $permissionsDelete = array('admin.template.canManageTemplate');
        
        /**
         * @see wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
         */
-       protected $permissionsUpdate = array('admin.template.canEditTemplateGroup');
+       protected $permissionsUpdate = array('admin.template.canManageTemplate');
 }
index 99d1cf89d804e9d3c1fe165aced2d04f77d2984d..62c9f6c93e33d29fadc734b3bff00c6bccbf1a2c 100644 (file)
@@ -1,21 +1,21 @@
 <?php
 namespace wcf\data\template\group;
 use wcf\data\DatabaseObjectEditor;
-use wcf\system\WCF;
+use wcf\data\IEditableCachedObject;
+use wcf\system\cache\builder\TemplateGroupCacheBuilder;
 use wcf\util\DirectoryUtil;
-use wcf\util\FileUtil;
 
 /**
  * Provides functions to edit template groups.
  * 
  * @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 data.template.group
  * @category   Community Framework
  */
-class TemplateGroupEditor extends DatabaseObjectEditor {
+class TemplateGroupEditor extends DatabaseObjectEditor implements IEditableCachedObject {
        /**
         * @see wcf\data\DatabaseObjectDecorator::$baseClass
         */
@@ -28,67 +28,36 @@ class TemplateGroupEditor extends DatabaseObjectEditor {
                parent::update($parameters);
                
                if (isset($parameters['templateGroupFolderName']) && ($parameters['templateGroupFolderName'] != $this->templateGroupFolderName)) {
-                       $this->renameFolders($parameters['templateGroupFolderName']);
+                       @rename(WCF_DIR . 'templates/' . $this->templateGroupFolderName, WCF_DIR . 'templates/' . $parameters['templateGroupFolderName']);
                }
        }
        
        /**
-        * Renames the folders of this template group.
-        * 
-        * @param       string          $newFolderName
+        * @see wcf\data\IEditableObject::deleteAll()
         */
-       public function renameFolders($newFolderName) {
-               // default template dir
-               $folders = array(WCF_DIR . 'templates/' . $this->templateGroupFolderName => WCF_DIR . 'templates/' . $newFolderName);
-               
-               // get package dirs
-               $sql = "SELECT  packageDir
-                       FROM    wcf".WCF_N."_package
-                       WHERE   packageDir <> ''";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute();
-               while ($row = $statement->fetchArray()) {
-                       $packageDir = FileUtil::getRealPath(WCF_DIR . $row['packageDir']);
-                       $folders[$packageDir . 'templates/' . $this->templateGroupFolderName] = $packageDir . 'templates/' . $newFolderName;
+       public static function deleteAll(array $objectIDs = array()) {
+               $list = new TemplateGroupList();
+               $list->setObjectIDs($objectIDs);
+               $list->readObjects();
+               foreach ($list as $object) {
+                       $editor = new TemplateGroupEditor($object);
+                       $editor->deleteFolder();
                }
                
-               // rename folders
-               foreach ($folders as $oldName => $newName) {
-                       if (file_exists($oldName)) {
-                               @rename($oldName, $newName);
-                       }
-               }
+               return parent::deleteAll($objectIDs);
        }
        
        /**
-        * @see wcf\data\IEditableObject::delete()
+        * Deletes the folder of this template group.
         */
-       public function delete() {
-               // update children
-               $sql = "UPDATE  wcf".WCF_N."_template_group
-                       SET     parentTemplateGroupID = ?
-                       WHERE   parentTemplateGroupID = ?";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute(array($this->parentTemplateGroupID, $this->templateGroupID));
-               
-               parent::delete();
-               
-               $this->deleteFolders();
+       public function deleteFolder() {
+               DirectoryUtil::getInstance(WCF_DIR . 'templates/' . $this->templateGroupFolderName)->removeAll();
        }
        
        /**
-        * Deletes the folders of this template group.
+        * @see wcf\data\IEditableCachedObject::resetCache()
         */
-       public function deleteFolders() {
-               // get package dirs
-               $sql = "SELECT  packageDir
-                       FROM    wcf".WCF_N."_package
-                       WHERE   packageDir <> ''";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute();
-               while ($row = $statement->fetchArray()) {
-                       $packageDir = FileUtil::getRealPath(WCF_DIR . $row['packageDir']);
-                       DirectoryUtil::getInstance($packageDir . 'templates/' . $this->templateGroupFolderName)->deleteAll();
-               }
+       public static function resetCache() {
+               TemplateGroupCacheBuilder::getInstance()->reset();
        }
 }
index b468d7830ce20738aeccb59e6106b31bfe4419cf..a198ed8eac9814001b233ae83bf3c06dda2a9fd6 100644 (file)
                <item name="wcf.acp.menu.link.user.option.category.list"><![CDATA[Benutzerprofilfeld-Kategorien auflisten]]></item>
                <item name="wcf.acp.menu.link.user.option.category.add"><![CDATA[Benutzerprofilfeld-Kategorie hinzufügen]]></item>
                <item name="wcf.acp.menu.link.user.option.setDefaults"><![CDATA[Benutzerprofil-Einstellungen verwalten]]></item>
+               <item name="wcf.acp.menu.link.template"><![CDATA[Templates]]></item>
+               <item name="wcf.acp.menu.link.template.list"><![CDATA[Templates auflisten]]></item>
+               <item name="wcf.acp.menu.link.template.add"><![CDATA[Template hinzufügen]]></item>
+               <item name="wcf.acp.menu.link.template.group.list"><![CDATA[Templategruppen auflisten]]></item>
+               <item name="wcf.acp.menu.link.template.group.add"><![CDATA[Templategruppe hinzufügen]]></item>
        </category>
        
        <category name="wcf.acp.option">
index bfbc57261c52ecdf00202d8d99d2dc0b48786795..023aa42aee1730b22d827b2c8350b53fb21a2c28 100644 (file)
                <item name="wcf.acp.menu.link.user.option.category.list"><![CDATA[List Field Categories]]></item>
                <item name="wcf.acp.menu.link.user.option.category.add"><![CDATA[Add Field Category]]></item>
                <item name="wcf.acp.menu.link.user.option.setDefaults"><![CDATA[Manage User Field Settings]]></item>
+               <item name="wcf.acp.menu.link.template"><![CDATA[Templates]]></item>
+               <item name="wcf.acp.menu.link.template.list"><![CDATA[List Templates]]></item>
+               <item name="wcf.acp.menu.link.template.add"><![CDATA[Add Template]]></item>
+               <item name="wcf.acp.menu.link.template.group.list"><![CDATA[List Template Groups]]></item>
+               <item name="wcf.acp.menu.link.template.group.add"><![CDATA[Add Template Group]]></item>
        </category>
        
        <category name="wcf.acp.option">
index f0c130ad72aefb18eb7703908df8d4cd0b179800..0a0d3f9f904f7a43fb0d051bd9f03008a771859d 100644 (file)
@@ -585,7 +585,7 @@ CREATE TABLE wcf1_template (
        packageID INT(10) NOT NULL,
        templateName VARCHAR(255) NOT NULL DEFAULT '',
        templateGroupID INT(10),
-       obsolete TINYINT(1) NOT NULL DEFAULT 0,
+       lastModificationTime INT(10) NOT NULL DEFAULT 0,
        KEY packageID (packageID, templateName),
        KEY templateGroupID (packageID, templateGroupID, templateName)
 );
@@ -593,7 +593,7 @@ CREATE TABLE wcf1_template (
 DROP TABLE IF EXISTS wcf1_template_group;
 CREATE TABLE wcf1_template_group (
        templateGroupID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
-       parentTemplateGroupID INT(10) NOT NULL DEFAULT 0,
+       parentTemplateGroupID INT(10),
        templateGroupName VARCHAR(255) NOT NULL DEFAULT '',
        templateGroupFolderName VARCHAR(255) NOT NULL DEFAULT ''
 );
@@ -855,6 +855,8 @@ ALTER TABLE wcf1_style_variable_value ADD FOREIGN KEY (variableID) REFERENCES wc
 ALTER TABLE wcf1_template ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE;
 ALTER TABLE wcf1_template ADD FOREIGN KEY (templateGroupID) REFERENCES wcf1_template_group (templateGroupID) ON DELETE CASCADE;
 
+ALTER TABLE wcf1_template_group ADD FOREIGN KEY (parentTemplateGroupID) REFERENCES wcf1_template_group (templateGroupID) ON DELETE SET NULL;
+
 ALTER TABLE wcf1_template_listener ADD FOREIGN KEY (packageID) REFERENCES wcf1_package (packageID) ON DELETE CASCADE;
 
 ALTER TABLE wcf1_user_collapsible_content ADD FOREIGN KEY (objectTypeID) REFERENCES wcf1_object_type (objectTypeID) ON DELETE CASCADE;