From b153f4645b9063f94730e034a9cc82d28a079b5e Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 30 Sep 2011 21:39:27 +0200 Subject: [PATCH] Template and API overhaul Changed MultipleLinkPage to use the new Iterator-API for DatabaseObjectLists and modified templates to use hascontent instead of lame if-conditions --- .../files/acp/templates/acpSessionLog.tpl | 28 +++-- .../files/acp/templates/acpSessionLogList.tpl | 32 ++--- .../files/acp/templates/cronjobList.tpl | 118 +++++++++--------- .../files/acp/templates/cronjobLogList.tpl | 40 +++--- .../files/acp/templates/packageList.tpl | 4 +- .../files/acp/templates/updateServerList.tpl | 48 +++---- .../files/acp/templates/userGroupList.tpl | 68 +++++----- .../acp/page/ACPSessionLogListPage.class.php | 15 +-- .../lib/acp/page/ACPSessionLogPage.class.php | 1 - .../lib/acp/page/CronjobListPage.class.php | 11 -- .../lib/acp/page/CronjobLogListPage.class.php | 11 -- .../lib/acp/page/PackageListPage.class.php | 9 -- .../acp/page/UpdateServerListPage.class.php | 1 - .../lib/acp/page/UserGroupListPage.class.php | 1 - .../files/lib/page/MultipleLinkPage.class.php | 10 +- 15 files changed, 177 insertions(+), 220 deletions(-) diff --git a/wcfsetup/install/files/acp/templates/acpSessionLog.tpl b/wcfsetup/install/files/acp/templates/acpSessionLog.tpl index 75a5547c1c..e594a097d0 100644 --- a/wcfsetup/install/files/acp/templates/acpSessionLog.tpl +++ b/wcfsetup/install/files/acp/templates/acpSessionLog.tpl @@ -11,7 +11,7 @@ {pages print=true assign=pagesLinks link="index.php?page=ACPSessionLog&sessionLogID=$sessionLogID&pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"|concat:SID_ARG_2ND_NOT_ENCODED} -{if $sessionAccessLogs|count} +{hascontent}

{lang}wcf.acp.sessionLog.access.list{/lang} {#$items}

@@ -33,19 +33,21 @@ - {foreach from=$sessionAccessLogs item=sessionAccessLog} - -

{@$sessionAccessLog->sessionAccessLogID}

- ipAddress != $sessionLog->ipAddress} style="color: red"{/if}>

{$sessionAccessLog->ipAddress}

-

{@$sessionAccessLog->time|time}

-

{$sessionAccessLog->packageName}

-

{$sessionAccessLog->className}

-

{if !$sessionAccessLog->hasProtectedURI()}{$sessionAccessLog->requestURI|truncate:50}{else}{$sessionAccessLog->requestURI|truncate:50}{/if}

-

{$sessionAccessLog->requestMethod}

+ {content} + {foreach from=$objects item=sessionAccessLog} + +

{@$sessionAccessLog->sessionAccessLogID}

+ ipAddress != $sessionLog->ipAddress} style="color: red"{/if}>

{$sessionAccessLog->ipAddress}

+

{@$sessionAccessLog->time|time}

+

{$sessionAccessLog->packageName}

+

{$sessionAccessLog->className}

+

{if !$sessionAccessLog->hasProtectedURI()}{$sessionAccessLog->requestURI|truncate:50}{else}{$sessionAccessLog->requestURI|truncate:50}{/if}

+

{$sessionAccessLog->requestMethod}

- {if $additionalColumns.$sessionAccessLog->sessionAccessLogID|isset}{@$additionalColumns.$sessionAccessLog->sessionAccessLogID}{/if} - - {/foreach} + {if $additionalColumns.$sessionAccessLog->sessionAccessLogID|isset}{@$additionalColumns.$sessionAccessLog->sessionAccessLogID}{/if} + + {/foreach} + {/content} diff --git a/wcfsetup/install/files/acp/templates/acpSessionLogList.tpl b/wcfsetup/install/files/acp/templates/acpSessionLogList.tpl index 09dbf68d98..18fb1583b5 100644 --- a/wcfsetup/install/files/acp/templates/acpSessionLogList.tpl +++ b/wcfsetup/install/files/acp/templates/acpSessionLogList.tpl @@ -11,7 +11,7 @@ {pages print=true assign=pagesLinks link="index.php?page=ACPSessionLogList&pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"|concat:SID_ARG_2ND_NOT_ENCODED}
-{if $sessionLogs|count} +{hascontent}

{lang}wcf.acp.sessionLog.list{/lang} {#$items}

@@ -26,26 +26,28 @@ {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.actions{/lang}{if $sortField == 'actions'} {/if} + {lang}wcf.acp.sessionLog.accesses{/lang}{if $sortField == 'accesses'} {/if} {if $additionalColumnHeads|isset}{@$additionalColumnHeads}{/if} - {foreach from=$sessionLogs item=sessionLog} - -

{@$sessionLog->sessionLogID}

-

{if $__wcf->user->userID == $sessionLog->userID}{/if} {$sessionLog->username}

-

{$sessionLog->ipAddress}{if $sessionLog->hostname != $sessionLog->ipAddress}
{$sessionLog->hostname}{/if}

-

{$sessionLog->userAgent}

-

{@$sessionLog->time|time}

-

{@$sessionLog->lastActivityTime|time}

-

{#$sessionLog->actions}

+ {content} + {foreach from=$objects item=sessionLog} + +

{@$sessionLog->sessionLogID}

+

{if $__wcf->user->userID == $sessionLog->userID}{/if} {$sessionLog->username}

+

{$sessionLog->ipAddress}{if $sessionLog->hostname != $sessionLog->ipAddress}
{$sessionLog->hostname}{/if}

+

{$sessionLog->userAgent}

+

{@$sessionLog->time|time}

+

{@$sessionLog->lastActivityTime|time}

+

{#$sessionLog->accesses}

- {if $additionalColumns.$sessionLog->sessionLogID|isset}{@$additionalColumns.$sessionLog->sessionLogID}{/if} - - {/foreach} + {if $additionalColumns.$sessionLog->sessionLogID|isset}{@$additionalColumns.$sessionLog->sessionLogID}{/if} + + {/foreach} + {/content} @@ -54,6 +56,6 @@ -{/if} +{/hascontent} {include file='footer'} diff --git a/wcfsetup/install/files/acp/templates/cronjobList.tpl b/wcfsetup/install/files/acp/templates/cronjobList.tpl index a01e53012c..4fea907636 100644 --- a/wcfsetup/install/files/acp/templates/cronjobList.tpl +++ b/wcfsetup/install/files/acp/templates/cronjobList.tpl @@ -44,13 +44,7 @@ {/if}
-{if !$items} -
-
-

{lang}wcf.acp.cronjob.noneAvailable{/lang}

-
-
-{else} +{hascontent}

{lang}wcf.acp.cronjob.list{/lang} {#$items}

@@ -73,59 +67,61 @@ - {foreach from=$cronjobs item=cronjob} - - - {if $__wcf->session->getPermission('admin.system.cronjob.canEditCronjob')} - - {else} - - {/if} + {content} + {foreach from=$objects item=cronjob} + + + {if $__wcf->session->getPermission('admin.system.cronjob.canEditCronjob')} + + {else} + + {/if} - {if $cronjob->canBeDisabled()} - - {else} - {if $cronjob->active} - - {else} - - {/if} - {/if} + {if $cronjob->canBeDisabled()} + + {else} + {if $cronjob->active} + + {else} + + {/if} + {/if} - {if $cronjob->isEditable()} - - {else} - - {/if} - {if $cronjob->isDeletable()} - - {else} - - {/if} - {if $additionalButtons[$cronjob->cronjobID]|isset}{@$additionalButtons[$cronjob->cronjobID]}{/if} - -

{@$cronjob->cronjobID}

-

{$cronjob->startMinute|truncate:30:' ...'}

-

{$cronjob->startHour|truncate:30:' ...'}

-

{$cronjob->startDom|truncate:30:' ...'}

-

{$cronjob->startMonth|truncate:30:' ...'}

-

{$cronjob->startDow|truncate:30:' ...'}

- - {if $cronjob->isEditable()} -

{$cronjob->description|truncate:50:" ..."}

- {else} -

{$cronjob->description|truncate:50:' ...'}

- {/if} - - - {if $cronjob->active && $cronjob->nextExec != 1} -

{@$cronjob->nextExec|plainTime}

- {/if} - + {if $cronjob->isEditable()} + + {else} + + {/if} + {if $cronjob->isDeletable()} + + {else} + + {/if} + {if $additionalButtons[$cronjob->cronjobID]|isset}{@$additionalButtons[$cronjob->cronjobID]}{/if} + +

{@$cronjob->cronjobID}

+

{$cronjob->startMinute|truncate:30:' ...'}

+

{$cronjob->startHour|truncate:30:' ...'}

+

{$cronjob->startDom|truncate:30:' ...'}

+

{$cronjob->startMonth|truncate:30:' ...'}

+

{$cronjob->startDow|truncate:30:' ...'}

+ + {if $cronjob->isEditable()} +

{$cronjob->description|truncate:50:" ..."}

+ {else} +

{$cronjob->description|truncate:50:' ...'}

+ {/if} + + + {if $cronjob->active && $cronjob->nextExec != 1} +

{@$cronjob->nextExec|plainTime}

+ {/if} + - {if $additionalColumns[$cronjob->cronjobID]|isset}{@$additionalColumns[$cronjob->cronjobID]}{/if} - - {/foreach} + {if $additionalColumns[$cronjob->cronjobID]|isset}{@$additionalColumns[$cronjob->cronjobID]}{/if} + + {/foreach} + {/content} @@ -140,6 +136,12 @@ {/if}
-{/if} +{hascontentelse} +
+
+

{lang}wcf.acp.cronjob.noneAvailable{/lang}

+
+
+{/hascontent} {include file='footer'} diff --git a/wcfsetup/install/files/acp/templates/cronjobLogList.tpl b/wcfsetup/install/files/acp/templates/cronjobLogList.tpl index a702f77318..3c45e95841 100644 --- a/wcfsetup/install/files/acp/templates/cronjobLogList.tpl +++ b/wcfsetup/install/files/acp/templates/cronjobLogList.tpl @@ -32,27 +32,27 @@ - {content} - {foreach from=$cronjobLogs item=cronjobLog} - -

{@$cronjobLog->cronjobID}

-

{$cronjobLog->className}

-

{$cronjobLog->description}

- {if $cronjobLog->success} -

{@$cronjobLog->execTime|time} {lang}wcf.acp.cronjob.log.success{/lang}

- {elseif $cronjobLog->error} - -

{@$cronjobLog->execTime|time} {lang}wcf.acp.cronjob.log.error{/lang}
- {@$cronjobLog->error}

- - {else} - - {/if} + {content} + {foreach from=$objects item=cronjobLog} + +

{@$cronjobLog->cronjobID}

+

{$cronjobLog->className}

+

{$cronjobLog->description}

+ {if $cronjobLog->success} +

{@$cronjobLog->execTime|time} {lang}wcf.acp.cronjob.log.success{/lang}

+ {elseif $cronjobLog->error} + +

{@$cronjobLog->execTime|time} {lang}wcf.acp.cronjob.log.error{/lang}
+ {@$cronjobLog->error}

+ + {else} + + {/if} - {if $cronjobLog->additionalColumns|isset}{@$cronjobLog->additionalColumns}{/if} - - {/foreach} - {/content} + {if $cronjobLog->additionalColumns|isset}{@$cronjobLog->additionalColumns}{/if} + + {/foreach} + {/content} diff --git a/wcfsetup/install/files/acp/templates/packageList.tpl b/wcfsetup/install/files/acp/templates/packageList.tpl index 3a7e27e8f7..975e53f60a 100644 --- a/wcfsetup/install/files/acp/templates/packageList.tpl +++ b/wcfsetup/install/files/acp/templates/packageList.tpl @@ -31,7 +31,7 @@ {/if} -{if $packages|count > 0} +{if $objects|count > 0}

{lang}wcf.acp.package.list{/lang} {#$items}

@@ -51,7 +51,7 @@ - {foreach from=$packages item=$package} + {foreach from=$objects item=$package} {if $__wcf->session->getPermission('admin.system.package.canUpdatePackage')} diff --git a/wcfsetup/install/files/acp/templates/updateServerList.tpl b/wcfsetup/install/files/acp/templates/updateServerList.tpl index c062784afe..0c109d5525 100644 --- a/wcfsetup/install/files/acp/templates/updateServerList.tpl +++ b/wcfsetup/install/files/acp/templates/updateServerList.tpl @@ -28,11 +28,7 @@
-{if !$items} -
-

{lang}wcf.acp.updateServer.list.noneAvailable{/lang}

-
-{else} +{hascontent}

{lang}wcf.acp.updateServer.list{/lang} {#$items}

@@ -53,25 +49,27 @@ - {foreach from=$updateServers item=updateServer} - - - - - + {content} + {foreach from=$objects item=updateServer} + + + + + - {if $additionalButtons[$updateServer->packageUpdateServerID]|isset}{@$additionalButtons[$updateServer->packageUpdateServerID]}{/if} - -

{@$updateServer->packageUpdateServerID}

-

{$updateServer->serverURL}

-

{#$updateServer->packages}

-

{@$updateServer->status}

-

{@$updateServer->errorMessage|truncate:"30"}

-

{if $updateServer->lastUpdateTime}{@$updateServer->lastUpdateTime|time}{/if}

+ {if $additionalButtons[$updateServer->packageUpdateServerID]|isset}{@$additionalButtons[$updateServer->packageUpdateServerID]}{/if} + +

{@$updateServer->packageUpdateServerID}

+

{$updateServer->serverURL}

+

{#$updateServer->packages}

+

{@$updateServer->status}

+

{@$updateServer->errorMessage|truncate:"30"}

+

{if $updateServer->lastUpdateTime}{@$updateServer->lastUpdateTime|time}{/if}

- {if $additionalColumns[$updateServer->packageUpdateServerID]|isset}{@$additionalColumns[$updateServer->packageUpdateServerID]}{/if} - - {/foreach} + {if $additionalColumns[$updateServer->packageUpdateServerID]|isset}{@$additionalColumns[$updateServer->packageUpdateServerID]}{/if} + + {/foreach} + {/content} @@ -84,6 +82,10 @@
-{/if} +{hascontentelse} +
+

{lang}wcf.acp.updateServer.list.noneAvailable{/lang}

+
+{/hascontent} {include file='footer'} diff --git a/wcfsetup/install/files/acp/templates/userGroupList.tpl b/wcfsetup/install/files/acp/templates/userGroupList.tpl index 8533495ec7..595ebcbbc2 100644 --- a/wcfsetup/install/files/acp/templates/userGroupList.tpl +++ b/wcfsetup/install/files/acp/templates/userGroupList.tpl @@ -17,7 +17,7 @@ -{if $groups|count} +{hascontent}

{lang}wcf.acp.group.list{/lang} {#$items}

@@ -35,43 +35,45 @@ - {foreach from=$groups item=group} - - - {if $group->isEditable()} - - {else} - - {/if} - {if $group->isDeletable()} - - {else} - - {/if} + {content} + {foreach from=$objects item=group} + + + {if $group->isEditable()} + + {else} + + {/if} + {if $group->isDeletable()} + + {else} + + {/if} - {if $additionalButtons[$group->groupID]|isset}{@$additionalButtons[$group->groupID]}{/if} - -

{@$group->groupID}

- {if $group->isEditable()}

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

{/if} -

{#$group->members}

+ {if $additionalButtons[$group->groupID]|isset}{@$additionalButtons[$group->groupID]}{/if} + +

{@$group->groupID}

+ {if $group->isEditable()}

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

{/if} +

{#$group->members}

- {if $additionalColumns[$group->groupID]|isset}{@$additionalColumns[$group->groupID]}{/if} - - {/foreach} + {if $additionalColumns[$group->groupID]|isset}{@$additionalColumns[$group->groupID]}{/if} + + {/foreach} + {/content}
-{/if} - -
- {@$pagesLinks} - -
+ +
+ {@$pagesLinks} + +
+{/hascontent} {include file='footer'} diff --git a/wcfsetup/install/files/lib/acp/page/ACPSessionLogListPage.class.php b/wcfsetup/install/files/lib/acp/page/ACPSessionLogListPage.class.php index fd0178189b..60203337c2 100755 --- a/wcfsetup/install/files/lib/acp/page/ACPSessionLogListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/ACPSessionLogListPage.class.php @@ -38,7 +38,7 @@ class ACPSessionLogListPage extends SortablePage { /** * @see wcf\page\SortablePage::$validSortFields */ - public $validSortFields = array('sessionLogID', 'username', 'ipAddress', 'userAgent', 'time', 'lastActivityTime', 'actions'); + public $validSortFields = array('sessionLogID', 'username', 'ipAddress', 'userAgent', 'time', 'lastActivityTime', 'accesses'); /** * @see wcf\page\MultipleLinkPage::$objectListClassName @@ -49,22 +49,11 @@ class ACPSessionLogListPage extends SortablePage { * @see wcf\page\MultipleLinkPage::readObjects() */ public function readObjects() { - $this->sqlOrderBy = (($this->sortField != 'actions' && $this->sortField != 'username') ? 'acp_session_log.' : '').$this->sortField." ".$this->sortOrder; + $this->sqlOrderBy = (($this->sortField != 'accesses' && $this->sortField != 'username') ? 'acp_session_log.' : '').$this->sortField." ".$this->sortOrder; parent::readObjects(); } - /** - * @see wcf\page\IPage::assignVariables() - */ - public function assignVariables() { - parent::assignVariables(); - - WCF::getTPL()->assign(array( - 'sessionLogs' => $this->objectList->getObjects() - )); - } - /** * @see wcf\page\IPage::show() */ diff --git a/wcfsetup/install/files/lib/acp/page/ACPSessionLogPage.class.php b/wcfsetup/install/files/lib/acp/page/ACPSessionLogPage.class.php index 9e668ce9b4..a2ad57d0bd 100755 --- a/wcfsetup/install/files/lib/acp/page/ACPSessionLogPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/ACPSessionLogPage.class.php @@ -93,7 +93,6 @@ class ACPSessionLogPage extends SortablePage { parent::assignVariables(); WCF::getTPL()->assign(array( - 'sessionAccessLogs' => $this->objectList->getObjects(), 'sessionLogID' => $this->sessionLogID, 'sessionLog' => $this->sessionLog )); diff --git a/wcfsetup/install/files/lib/acp/page/CronjobListPage.class.php b/wcfsetup/install/files/lib/acp/page/CronjobListPage.class.php index e99f7dd955..aadff1c727 100755 --- a/wcfsetup/install/files/lib/acp/page/CronjobListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/CronjobListPage.class.php @@ -51,17 +51,6 @@ class CronjobListPage extends SortablePage { $this->sqlOrderBy = "cronjob.".$this->sortField." ".$this->sortOrder; } - /** - * @see wcf\page\IPage::assignVariables() - */ - public function assignVariables() { - parent::assignVariables(); - - WCF::getTPL()->assign(array( - 'cronjobs' => $this->objectList->getObjects() - )); - } - /** * @see wcf\page\IPage::show() */ diff --git a/wcfsetup/install/files/lib/acp/page/CronjobLogListPage.class.php b/wcfsetup/install/files/lib/acp/page/CronjobLogListPage.class.php index 7da37780a9..16a7f413a4 100755 --- a/wcfsetup/install/files/lib/acp/page/CronjobLogListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/CronjobLogListPage.class.php @@ -71,17 +71,6 @@ class CronjobLogListPage extends SortablePage { parent::readObjects(); } - /** - * @see wcf\page\IPage::assignVariables() - */ - public function assignVariables() { - parent::assignVariables(); - - WCF::getTPL()->assign(array( - 'cronjobLogs' => $this->objectList->getObjects() - )); - } - /** * @see wcf\page\IPage::show() */ diff --git a/wcfsetup/install/files/lib/acp/page/PackageListPage.class.php b/wcfsetup/install/files/lib/acp/page/PackageListPage.class.php index e0463ab0b2..466c14d6f0 100755 --- a/wcfsetup/install/files/lib/acp/page/PackageListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/PackageListPage.class.php @@ -60,15 +60,6 @@ class PackageListPage extends SortablePage { parent::readObjects(); } - /** - * @see wcf\page\IPage::assignVariables() - */ - public function assignVariables() { - parent::assignVariables(); - - WCF::getTPL()->assign('packages', $this->objectList->getObjects()); - } - /** * @see wcf\page\IPage::show() */ diff --git a/wcfsetup/install/files/lib/acp/page/UpdateServerListPage.class.php b/wcfsetup/install/files/lib/acp/page/UpdateServerListPage.class.php index 250b5b45a3..0b766057ef 100755 --- a/wcfsetup/install/files/lib/acp/page/UpdateServerListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/UpdateServerListPage.class.php @@ -71,7 +71,6 @@ class UpdateServerListPage extends SortablePage { parent::assignVariables(); WCF::getTPL()->assign(array( - 'updateServers' => $this->objectList->getObjects(), 'deletedPackageUpdateServerID' => $this->deletedPackageUpdateServerID )); } diff --git a/wcfsetup/install/files/lib/acp/page/UserGroupListPage.class.php b/wcfsetup/install/files/lib/acp/page/UserGroupListPage.class.php index d91b79d9d2..c6fae86d96 100755 --- a/wcfsetup/install/files/lib/acp/page/UserGroupListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/UserGroupListPage.class.php @@ -83,7 +83,6 @@ class UserGroupListPage extends SortablePage { parent::assignVariables(); WCF::getTPL()->assign(array( - 'groups' => $this->objectList->getObjects(), 'deletedGroups' => $this->deletedGroups )); } diff --git a/wcfsetup/install/files/lib/page/MultipleLinkPage.class.php b/wcfsetup/install/files/lib/page/MultipleLinkPage.class.php index 088f4c11b5..4cb015d98f 100644 --- a/wcfsetup/install/files/lib/page/MultipleLinkPage.class.php +++ b/wcfsetup/install/files/lib/page/MultipleLinkPage.class.php @@ -65,12 +65,6 @@ abstract class MultipleLinkPage extends AbstractPage { */ public $objectListClassName = ''; - /** - * list of DatabaseObject objects - * @var array - */ - public $objects = array(); - /** * @see wcf\data\DatabaseObjectList::$sqlLimit */ @@ -140,8 +134,6 @@ abstract class MultipleLinkPage extends AbstractPage { $this->objectList->sqlOffset = $this->sqlOffset; $this->objectList->sqlOrderBy = $this->sqlOrderBy; $this->objectList->readObjects(); - - $this->objects = $this->objectList->getObjects(); } /** @@ -193,7 +185,7 @@ abstract class MultipleLinkPage extends AbstractPage { 'itemsPerPage' => $this->itemsPerPage, 'startIndex' => $this->startIndex, 'endIndex' => $this->endIndex, - 'objects' => $this->objects + 'objects' => $this->objectList )); } } -- 2.20.1