From 490a2ce9d8359c1d94d4165b71e31871b35dc3b9 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 12 Oct 2011 15:11:14 +0200 Subject: [PATCH] Usage of LinkHandler including routing Search & Replace with RegEx FTW! --- .../files/acp/templates/acpSessionLog.tpl | 16 ++++++++-------- .../files/acp/templates/acpSessionLogList.tpl | 16 ++++++++-------- .../files/acp/templates/cronjobList.tpl | 18 +++++++++--------- .../files/acp/templates/cronjobLogList.tpl | 10 +++++----- .../templates/packageInstallationConfirm.tpl | 4 ++-- .../files/acp/templates/packageList.tpl | 2 +- .../files/acp/templates/packageView.tpl | 6 +++--- .../files/acp/templates/updateServerList.tpl | 14 +++++++------- .../files/acp/templates/userGroupList.tpl | 10 +++++----- .../install/files/acp/templates/userList.tpl | 8 ++++---- .../files/lib/system/request/Route.class.php | 4 ++++ .../plugin/LinkBlockTemplatePlugin.class.php | 7 ++++++- .../PagesFunctionTemplatePlugin.class.php | 11 ++++++++--- 13 files changed, 70 insertions(+), 56 deletions(-) diff --git a/wcfsetup/install/files/acp/templates/acpSessionLog.tpl b/wcfsetup/install/files/acp/templates/acpSessionLog.tpl index 28d759edde..7c920d1b20 100644 --- a/wcfsetup/install/files/acp/templates/acpSessionLog.tpl +++ b/wcfsetup/install/files/acp/templates/acpSessionLog.tpl @@ -8,7 +8,7 @@
- {pages print=true assign=pagesLinks link="index.php/ACPSessionLog/$sessionLogID/?pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"|concat:SID_ARG_2ND_NOT_ENCODED} + {pages print=true assign=pagesLinks controller='ACPSessionLog' id=$sessionLogID link="?pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"|concat:SID_ARG_2ND_NOT_ENCODED}
{hascontent} @@ -20,13 +20,13 @@ - - - - - - - + + + + + + + {if $additionalColumnHeads|isset}{@$additionalColumnHeads}{/if} diff --git a/wcfsetup/install/files/acp/templates/acpSessionLogList.tpl b/wcfsetup/install/files/acp/templates/acpSessionLogList.tpl index 67dc77e4af..dbf278e4eb 100644 --- a/wcfsetup/install/files/acp/templates/acpSessionLogList.tpl +++ b/wcfsetup/install/files/acp/templates/acpSessionLogList.tpl @@ -8,7 +8,7 @@
- {pages print=true assign=pagesLinks link="index.php/ACPSessionLogList/?pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"|concat:SID_ARG_2ND_NOT_ENCODED} + {pages print=true assign=pagesLinks controller="ACPSessionLogList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"}
{hascontent} @@ -20,13 +20,13 @@
{lang}wcf.global.objectID{/lang}{if $sortField == 'sessionAccessLogID'} {/if}{lang}wcf.user.ipAddress{/lang}{if $sortField == 'ipAddress'} {/if}{lang}wcf.acp.sessionLog.time{/lang}{if $sortField == 'time'} {/if}{lang}wcf.acp.sessionLog.packageName{/lang}{if $sortField == 'packageName'} {/if}{lang}wcf.acp.sessionLog.className{/lang}{if $sortField == 'className'} {/if}

{lang}wcf.acp.sessionLog.requestURI{/lang}{if $sortField == 'requestURI'} {/if}{lang}wcf.acp.sessionLog.requestMethod{/lang}{if $sortField == 'requestMethod'} {/if}{lang}wcf.global.objectID{/lang}{if $sortField == 'sessionAccessLogID'} {/if}{lang}wcf.user.ipAddress{/lang}{if $sortField == 'ipAddress'} {/if}{lang}wcf.acp.sessionLog.time{/lang}{if $sortField == 'time'} {/if}{lang}wcf.acp.sessionLog.packageName{/lang}{if $sortField == 'packageName'} {/if}{lang}wcf.acp.sessionLog.className{/lang}{if $sortField == 'className'} {/if}

{lang}wcf.acp.sessionLog.requestURI{/lang}{if $sortField == 'requestURI'} {/if}{lang}wcf.acp.sessionLog.requestMethod{/lang}{if $sortField == 'requestMethod'} {/if}
- - - - - - - + + + + + + + {if $additionalColumnHeads|isset}{@$additionalColumnHeads}{/if} diff --git a/wcfsetup/install/files/acp/templates/cronjobList.tpl b/wcfsetup/install/files/acp/templates/cronjobList.tpl index 9cd63b0573..f7eb665dd3 100644 --- a/wcfsetup/install/files/acp/templates/cronjobList.tpl +++ b/wcfsetup/install/files/acp/templates/cronjobList.tpl @@ -35,7 +35,7 @@
- {pages print=true assign=pagesLinks link="index.php/CronjobList/?pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"|concat:SID_ARG_2ND_NOT_ENCODED} + {pages print=true assign=pagesLinks controller="CronjobList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"} {if $__wcf->session->getPermission('admin.system.cronjob.canAddCronjob')}
{lang}wcf.global.objectID{/lang}{if $sortField == 'sessionLogID'} {/if}{lang}wcf.user.username{/lang}{if $sortField == 'username'} {/if}{lang}wcf.user.ipAddress{/lang}{if $sortField == 'ipAddress'} {/if}{lang}wcf.user.userAgent{/lang}{if $sortField == 'userAgent'} {/if}{lang}wcf.acp.sessionLog.time{/lang}{if $sortField == 'time'} {/if}{lang}wcf.acp.sessionLog.lastActivityTime{/lang}{if $sortField == 'lastActivityTime'} {/if}{lang}wcf.acp.sessionLog.accesses{/lang}{if $sortField == 'accesses'} {/if}{lang}wcf.global.objectID{/lang}{if $sortField == 'sessionLogID'} {/if}{lang}wcf.user.username{/lang}{if $sortField == 'username'} {/if}{lang}wcf.user.ipAddress{/lang}{if $sortField == 'ipAddress'} {/if}{lang}wcf.user.userAgent{/lang}{if $sortField == 'userAgent'} {/if}{lang}wcf.acp.sessionLog.time{/lang}{if $sortField == 'time'} {/if}{lang}wcf.acp.sessionLog.lastActivityTime{/lang}{if $sortField == 'lastActivityTime'} {/if}{lang}wcf.acp.sessionLog.accesses{/lang}{if $sortField == 'accesses'} {/if}
- - - - - - - - + + + + + + + + {if $additionalHeadColumns|isset}{@$additionalHeadColumns}{/if} diff --git a/wcfsetup/install/files/acp/templates/cronjobLogList.tpl b/wcfsetup/install/files/acp/templates/cronjobLogList.tpl index fa498b6e44..35ff7dbfad 100644 --- a/wcfsetup/install/files/acp/templates/cronjobLogList.tpl +++ b/wcfsetup/install/files/acp/templates/cronjobLogList.tpl @@ -9,7 +9,7 @@
- {pages print=true assign=pagesLinks link="index.php/CronjobLogList/?pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"|concat:SID_ARG_2ND_NOT_ENCODED} + {pages print=true assign=pagesLinks controller="CronjobLogList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"}
{hascontent} @@ -22,10 +22,10 @@
{lang}wcf.global.objectID{/lang}{if $sortField == 'cronjobID'} {/if}{lang}wcf.acp.cronjob.startMinuteShort{/lang}{if $sortField == 'startMinute'} {/if}{lang}wcf.acp.cronjob.startHourShort{/lang}{if $sortField == 'startHour'} {/if}{lang}wcf.acp.cronjob.startDomShort{/lang}{if $sortField == 'startDom'} {/if}{lang}wcf.acp.cronjob.startMonthShort{/lang}{if $sortField == 'startMonth'} {/if}{lang}wcf.acp.cronjob.startDowShort{/lang}{if $sortField == 'startDow'} {/if}{lang}wcf.acp.cronjob.description{/lang}{if $sortField == 'description'} {/if}{lang}wcf.acp.cronjob.nextExec{/lang}{if $sortField == 'nextExec'} {/if}{lang}wcf.global.objectID{/lang}{if $sortField == 'cronjobID'} {/if}{lang}wcf.acp.cronjob.startMinuteShort{/lang}{if $sortField == 'startMinute'} {/if}{lang}wcf.acp.cronjob.startHourShort{/lang}{if $sortField == 'startHour'} {/if}{lang}wcf.acp.cronjob.startDomShort{/lang}{if $sortField == 'startDom'} {/if}{lang}wcf.acp.cronjob.startMonthShort{/lang}{if $sortField == 'startMonth'} {/if}{lang}wcf.acp.cronjob.startDowShort{/lang}{if $sortField == 'startDow'} {/if}{lang}wcf.acp.cronjob.description{/lang}{if $sortField == 'description'} {/if}{lang}wcf.acp.cronjob.nextExec{/lang}{if $sortField == 'nextExec'} {/if}
- - - - + + + + {if $additionalColumns|isset}{@$additionalColumns}{/if} diff --git a/wcfsetup/install/files/acp/templates/packageInstallationConfirm.tpl b/wcfsetup/install/files/acp/templates/packageInstallationConfirm.tpl index 7a8ec4a5bc..3b448dceb9 100644 --- a/wcfsetup/install/files/acp/templates/packageInstallationConfirm.tpl +++ b/wcfsetup/install/files/acp/templates/packageInstallationConfirm.tpl @@ -93,7 +93,7 @@ {foreach from=$updatableInstances item=$package} - + {/foreach} @@ -129,7 +129,7 @@ {/if}
- + {if $missingPackages == 0 && $excludingPackages|count == 0 && $excludedPackages|count == 0} {/if} diff --git a/wcfsetup/install/files/acp/templates/packageList.tpl b/wcfsetup/install/files/acp/templates/packageList.tpl index 02829605c2..2678766aec 100644 --- a/wcfsetup/install/files/acp/templates/packageList.tpl +++ b/wcfsetup/install/files/acp/templates/packageList.tpl @@ -69,7 +69,7 @@
diff --git a/wcfsetup/install/files/acp/templates/packageView.tpl b/wcfsetup/install/files/acp/templates/packageView.tpl index 1f2ec4a3af..64b0e53fab 100644 --- a/wcfsetup/install/files/acp/templates/packageView.tpl +++ b/wcfsetup/install/files/acp/templates/packageView.tpl @@ -143,7 +143,7 @@ {/if} {if $__wcf->session->getPermission('admin.system.package.canUninstallPackage') && $requiredPackage.package != 'com.woltlab.wcf' && $requiredPackage.packageID != PACKAGE_ID} - + {else} {/if} @@ -201,7 +201,7 @@ {/if} {if $__wcf->session->getPermission('admin.system.package.canUninstallPackage') && $dependentPackage.package != 'com.woltlab.wcf' && $dependentPackage.packageID != PACKAGE_ID} - + {else} {/if} @@ -244,7 +244,7 @@
{lang}wcf.global.objectID{/lang}{if $sortField == 'cronjobID'} {/if}{lang}wcf.acp.cronjob.className{/lang}{if $sortField == 'className'} {/if}{lang}wcf.acp.cronjob.description{/lang}{if $sortField == 'description'} {/if}{lang}wcf.acp.cronjob.log.execTime{/lang}{if $sortField == 'execTime'} {/if}{lang}wcf.global.objectID{/lang}{if $sortField == 'cronjobID'} {/if}{lang}wcf.acp.cronjob.className{/lang}{if $sortField == 'className'} {/if}{lang}wcf.acp.cronjob.description{/lang}{if $sortField == 'description'} {/if}{lang}wcf.acp.cronjob.log.execTime{/lang}{if $sortField == 'execTime'} {/if}

{$package.packageName}{if $package.instanceNo > 1 && $package.instanceName == ''} (#{#$package.instanceNo}){/if}

{$package.packageName}{if $package.instanceNo > 1 && $package.instanceName == ''} (#{#$package.instanceNo}){/if}

{$package.packageVersion}

- - - - - - + + + + + + {if $additionalHeadColumns|isset}{@$additionalHeadColumns}{/if} diff --git a/wcfsetup/install/files/acp/templates/userGroupList.tpl b/wcfsetup/install/files/acp/templates/userGroupList.tpl index 5290fd4c79..9d9e06bd0d 100644 --- a/wcfsetup/install/files/acp/templates/userGroupList.tpl +++ b/wcfsetup/install/files/acp/templates/userGroupList.tpl @@ -8,7 +8,7 @@
- {pages print=true assign=pagesLinks link="index.php/UserGroupList/?pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"|concat:SID_ARG_2ND_NOT_ENCODED} + {pages print=true assign=pagesLinks controller="UserGroupList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"}
{lang}wcf.global.objectID{/lang}{if $sortField == 'packageUpdateServerID'} {/if}{lang}wcf.acp.updateServer.serverURL{/lang}{if $sortField == 'serverURL'} {/if}{lang}wcf.acp.updateServer.packages{/lang}{if $sortField == 'packages'} {/if}{lang}wcf.acp.updateServer.status{/lang}{if $sortField == 'status'} {/if}{lang}wcf.acp.updateServer.errorMessage{/lang}{if $sortField == 'errorMessage'} {/if}{lang}wcf.acp.updateServer.lastUpdateTime{/lang}{if $sortField == 'lastUpdateTime'} {/if}{lang}wcf.global.objectID{/lang}{if $sortField == 'packageUpdateServerID'} {/if}{lang}wcf.acp.updateServer.serverURL{/lang}{if $sortField == 'serverURL'} {/if}{lang}wcf.acp.updateServer.packages{/lang}{if $sortField == 'packages'} {/if}{lang}wcf.acp.updateServer.status{/lang}{if $sortField == 'status'} {/if}{lang}wcf.acp.updateServer.errorMessage{/lang}{if $sortField == 'errorMessage'} {/if}{lang}wcf.acp.updateServer.lastUpdateTime{/lang}{if $sortField == 'lastUpdateTime'} {/if}
- - - + + + {if $additionalHeadColumns|isset}{@$additionalHeadColumns}{/if} @@ -54,7 +54,7 @@ - + {if $additionalColumns[$group->groupID]|isset}{@$additionalColumns[$group->groupID]}{/if} diff --git a/wcfsetup/install/files/acp/templates/userList.tpl b/wcfsetup/install/files/acp/templates/userList.tpl index d2b771ac50..c95b51e342 100644 --- a/wcfsetup/install/files/acp/templates/userList.tpl +++ b/wcfsetup/install/files/acp/templates/userList.tpl @@ -20,7 +20,7 @@ {assign var=encodedURL value=$url|rawurlencode} {assign var=encodedAction value=$action|rawurlencode}
- {pages print=true assign=pagesLinks link="index.php/UserList/?pageNo=%d&searchID=$searchID&action=$encodedAction&sortField=$sortField&sortOrder=$sortOrder"|concat:SID_ARG_2ND_NOT_ENCODED} + {pages print=true assign=pagesLinks controller="UserList" link="pageNo=%d&searchID=$searchID&action=$encodedAction&sortField=$sortField&sortOrder=$sortOrder"}
- - + + {foreach from=$columnHeads key=column item=columnLanguageVariable} - + {/foreach} {if $additionalColumnHeads|isset}{@$additionalColumnHeads}{/if} diff --git a/wcfsetup/install/files/lib/system/request/Route.class.php b/wcfsetup/install/files/lib/system/request/Route.class.php index 561d7661e5..56ba929a32 100644 --- a/wcfsetup/install/files/lib/system/request/Route.class.php +++ b/wcfsetup/install/files/lib/system/request/Route.class.php @@ -224,6 +224,10 @@ class Route { public function buildLink(array $components) { $link = 'index.php/'; foreach ($this->routeSchema as $component) { + if (!isset($components[$component])) { + continue; + } + $link .= $components[$component] . '/'; unset($components[$component]); } diff --git a/wcfsetup/install/files/lib/system/template/plugin/LinkBlockTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/LinkBlockTemplatePlugin.class.php index 2c2fcefb93..52fc18519e 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/LinkBlockTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/LinkBlockTemplatePlugin.class.php @@ -2,6 +2,7 @@ namespace wcf\system\template\plugin; use wcf\system\request\LinkHandler; use wcf\system\template\TemplateEngine; +use wcf\util\StringUtil; /** * Shortcut for usage of LinkHandler::getInstance()->getLink() in template scripting. @@ -31,7 +32,11 @@ class LinkBlockTemplatePlugin implements IBlockTemplatePlugin { $tagArgs['application'] = 'wcf'; } - return LinkHandler::getInstance()->getLink($blockContent, $tagArgs); + if (isset($tagArgs['encode']) && !$tagArgs['encode']) { + return LinkHandler::getInstance()->getLink($blockContent, $tagArgs); + } + + return StringUtil::encodeHTML(LinkHandler::getInstance()->getLink($blockContent, $tagArgs)); } /** diff --git a/wcfsetup/install/files/lib/system/template/plugin/PagesFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/PagesFunctionTemplatePlugin.class.php index e7d35f8182..3bfba7a85f 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/PagesFunctionTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/PagesFunctionTemplatePlugin.class.php @@ -1,6 +1,7 @@ get('pages')) === null) { throw new SystemException("missing 'pages' argument in pages tag"); @@ -79,8 +81,11 @@ class PagesFunctionTemplatePlugin implements IFunctionTemplatePlugin { // define page link for js function $html .= ""; - // encode link - $tagArgs['link'] = StringUtil::encodeHTML($tagArgs['link']); + // create and encode route link + $routeComponents = array('controller' => $tagArgs['controller']); + if (isset($tagArgs['id'])) $routeComponents['id'] = $tagArgs['id']; + $routeURL = RouteHandler::getInstance()->buildRoute($routeComponents); + $tagArgs['link'] = StringUtil::encodeHTML($routeURL . $tagArgs['link']); if (!isset($tagArgs['page'])) { if (($tagArgs['page'] = $tplObj->get('pageNo')) === null) { -- 2.20.1
{lang}wcf.global.objectID{/lang}{if $sortField == 'groupID'} {/if}{lang}wcf.acp.group.groupName{/lang}{if $sortField == 'groupName'} {/if}{lang}wcf.acp.group.members{/lang}{if $sortField == 'members'} {/if}{lang}wcf.global.objectID{/lang}{if $sortField == 'groupID'} {/if}{lang}wcf.acp.group.groupName{/lang}{if $sortField == 'groupName'} {/if}{lang}wcf.acp.group.members{/lang}{if $sortField == 'members'} {/if}

{@$group->groupID}

{if $group->isEditable()}

{lang}{$group->groupName}{/lang}{else}{lang}{$group->groupName}{/lang}

{/if}

{#$group->members}

{#$group->members}

{lang}wcf.global.objectID{/lang}{if $sortField == 'userID'} {/if}{lang}wcf.user.username{/lang}{if $sortField == 'username'} {/if}{lang}wcf.global.objectID{/lang}{if $sortField == 'userID'} {/if}{lang}wcf.user.username{/lang}{if $sortField == 'username'} {/if}{lang}{$columnLanguageVariable}{/lang}{if $sortField == $column} {/if}{lang}{$columnLanguageVariable}{/lang}{if $sortField == $column} {/if}