3 * This file is (c) Copyright 2011 by Sabri LABBENE, Institut TELECOM
5 * This file is part of FusionForge.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * This program has been developed in the frame of the COCLICO
22 * project with financial support of its funders.
27 * TODO Enter description here ...
28 * @param unknown_type $params
30 class CompactResource {
36 * @param unknown_type $params
38 public function __construct($params) {
39 $this->params = $params;
43 * TODO Enter description here ... to be overloaded in subclasses
45 public function getResourceLink() {
50 * Enter description here ...
51 * @param array $params : 'resource_type' => 'user' | 'group', 'username' => $username, 'user_id' => $user_id, 'size' => $size, 'user_link' => ''
52 * @return UserCompactResource|GroupCompactResource|CompatResource|string
54 public static function createCompactResource($params) {
55 switch ($params['resource_type']) {
57 return new LocalUserCompactResource($params);
60 return new LocalGroupCompactResource($params);
63 return new CompatResource($params);
66 return 'Unknown resource type !';
73 * Enter description here ...
77 class UserCompactResource extends CompactResource {
79 protected function getCssClass() {
83 public function getResourceLink() {
84 $username = $this->params['username'];
85 $user_id = $this->params['user_id'];
87 // invoke user_logo hook
88 $logo_params = array('user_id' => $user_id, 'size' => $this->params['size'], 'content' => '');
89 plugin_hook_by_reference('user_logo', $logo_params);
92 // construct a link that is the base for a hover popup (see oslcTooltip.js)
93 //$url = '<a class="resourcePopupTrigger" href="'. util_make_url_u ($username, $user_id) .
94 // '" rel="user,' . $username . '">'. $username . '</a>';
95 $resource_url = util_make_url_u ($username, $user_id);
97 //$url = '<a class="resourcePopupTrigger" href="'. $resource_url .
98 // '" rel="'. $resource_url .'">'. $username . '</a>';
99 $css_class = $this->getCssClass();
101 $url = '<a class="'. $css_class .
102 '" href="'. $resource_url .'">'. $username .'</a>';
103 if ($logo_params['content']) {
104 $html = $logo_params['content'] . $url .'<div class="new_line"></div>';
114 class LocalUserCompactResource extends UserCompactResource {
115 protected function getCssClass() {
116 return 'resourceLocalPopupTrigger';
120 class OslcUserCompactResource extends UserCompactResource {
121 protected function getCssClass() {
122 return 'resourceOslcPopupTrigger';
128 * Enter description here ...
132 class GroupCompactResource extends CompactResource {
134 protected function getCssClass() {
140 class LocalGroupCompactResource extends GroupCompactResource {
141 protected function getCssClass() {
142 return 'resourceLocalPopupTrigger';
144 public function getResourceLink() {
145 $group_name = $this->params['group_name'];
146 $group_id = $this->params['group_id'];
147 $link_text = $this->params['link_text'];
148 $resource_url = util_make_url_g ($group_name, $group_id);
149 $css_class = $this->getCssClass();
150 return '<a class="'.$css_class .'" href="'. $resource_url .
151 '">'. $link_text . '</a>';
155 class OslcGroupCompactResource extends GroupCompactResource {
156 protected function getCssClass() {
157 return 'resourceOslcPopupTrigger';
159 public function getResourceLink() {
160 $name = $this->params['name'];
161 $resource_url = $this->params['url'];
162 $css_class = $this->getCssClass();
163 return '<a class="'.$css_class .'" href="'. $resource_url .
164 '">'. $name . '</a>';