From 169edfac67744d603b70861ec057aeabd9be2bd6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Tue, 2 Mar 2010 23:45:27 +0100 Subject: [PATCH] Factor code in MultiPageViews MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- core | 2 +- include/userset.inc.php | 73 +++++++++++++++---------------------------------- 2 files changed, 23 insertions(+), 52 deletions(-) diff --git a/core b/core index b9bd8dd..43343e2 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit b9bd8dd360cf1a593c9e5c8cbae62ff1ba723b4c +Subproject commit 43343e2a0a239089f1a77059513e12c9336006a1 diff --git a/include/userset.inc.php b/include/userset.inc.php index 6a1ed5d..3212ea3 100644 --- a/include/userset.inc.php +++ b/include/userset.inc.php @@ -145,7 +145,26 @@ class ArraySet extends UserSet } } -class MinificheView extends MultipageView +abstract class ProfileView extends MultipageView +{ + protected function getBoundValue($obj) + { + if ($obj instanceof Profile) { + switch ($this->bound_field) { + case 'name': + $name = $obj->name('%l'); + return strtoupper($name); + case 'promo': + return $obj->promo(); + default: + return null; + } + } + return null; + } +} + +class MinificheView extends ProfileView { public function __construct(PlSet &$set, $data, array $params) { @@ -176,22 +195,6 @@ class MinificheView extends MultipageView parent::__construct($set, $data, $params); } - protected function getBoundValue($obj) - { - if ($obj instanceof Profile) { - switch ($this->bound_field) { - case 'name': - $name = $obj->name('%l'); - return strtoupper($name); - case 'promo': - return $obj->promo(); - default: - return null; - } - } - return null; - } - public function bounds() { $order = Env::v('order', $this->defaultkey); @@ -215,7 +218,7 @@ class MinificheView extends MultipageView } } -class MentorView extends MultipageView +class MentorView extends ProfileView { public function __construct(PlSet &$set, $data, array $params) { @@ -234,22 +237,6 @@ class MentorView extends MultipageView parent::__construct($set, $data, $params); } - protected function getBoundValue($obj) - { - if ($obj instanceof Profile) { - switch ($this->bound_field) { - case 'name': - $name = $obj->name('%l'); - return strtoupper($name); - case 'promo': - return $obj->promo(); - default: - return null; - } - } - return null; - } - public function bounds() { $order = Env::v('order', $this->defaultkey); @@ -273,7 +260,7 @@ class MentorView extends MultipageView } } -class TrombiView extends MultipageView +class TrombiView extends ProfileView { public function __construct(PlSet &$set, $data, array $params) { @@ -294,22 +281,6 @@ class TrombiView extends MultipageView parent::__construct($set, $data, $params); } - protected function getBoundValue($obj) - { - if ($obj instanceof Profile) { - switch ($this->bound_field) { - case 'name': - $name = $obj->name('%l'); - return strtoupper($name); - case 'promo': - return $obj->promo(); - default: - return null; - } - } - return null; - } - public function bounds() { $order = Env::v('order', $this->defaultkey); -- 2.1.4