Factor code in MultiPageViews
authorRaphaël Barrois <raphael.barrois@polytechnique.org>
Tue, 2 Mar 2010 22:45:27 +0000 (23:45 +0100)
committerRaphaël Barrois <raphael.barrois@polytechnique.org>
Tue, 2 Mar 2010 22:51:55 +0000 (23:51 +0100)
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
core
include/userset.inc.php

diff --git a/core b/core
index b9bd8dd..43343e2 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit b9bd8dd360cf1a593c9e5c8cbae62ff1ba723b4c
+Subproject commit 43343e2a0a239089f1a77059513e12c9336006a1
index 6a1ed5d..3212ea3 100644 (file)
@@ -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);