/usr/share/gforge/plugins/compactpreview/include/CompactResource.class.php is in fusionforge-plugin-compactpreview 5.3.2+20141104-3+deb8u3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | <?php
/**
* This file is (c) Copyright 2011 by Sabri LABBENE, Institut TELECOM
*
* This file is part of FusionForge.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* This program has been developed in the frame of the COCLICO
* project with financial support of its funders.
*
*/
/**
* TODO Enter description here ...
* @param unknown_type $params
*/
class CompactResource {
public $params;
/**
* Constructor
* @param unknown_type $params
*/
public function __construct($params) {
$this->params = $params;
}
/**
* TODO Enter description here ... to be overloaded in subclasses
*/
public function getResourceLink() {
// TBD.
}
/**
* Enter description here ...
* @param array $params : 'resource_type' => 'user' | 'group', 'username' => $username, 'user_id' => $user_id, 'size' => $size, 'user_link' => ''
* @return UserCompactResource|GroupCompactResource|CompatResource|string
*/
public static function createCompactResource($params) {
switch ($params['resource_type']) {
case 'user' :
return new LocalUserCompactResource($params);
break;
case 'group' :
return new LocalGroupCompactResource($params);
break;
case 'artifact' :
return new CompatResource($params);
break;
default :
return 'Unknown resource type !';
break;
}
}
}
/**
* Enter description here ...
* @author olivier
*
*/
class UserCompactResource extends CompactResource {
protected function getCssClass() {
// TBD
}
public function getResourceLink() {
$username = $this->params['username'];
$user_id = $this->params['user_id'];
// invoke user_logo hook
$logo_params = array('user_id' => $user_id, 'size' => $this->params['size'], 'content' => '');
plugin_hook_by_reference('user_logo', $logo_params);
$html = '';
// construct a link that is the base for a hover popup (see oslcTooltip.js)
//$url = '<a class="resourcePopupTrigger" href="'. util_make_url_u ($username, $user_id) .
// '" rel="user,' . $username . '">'. $username . '</a>';
$resource_url = util_make_url_u ($username, $user_id);
//$url = '<a class="resourcePopupTrigger" href="'. $resource_url .
// '" rel="'. $resource_url .'">'. $username . '</a>';
$css_class = $this->getCssClass();
$url = '<a class="'. $css_class .
'" href="'. $resource_url .'">'. $username .'</a>';
if ($logo_params['content']) {
$html = $logo_params['content'] . $url .'<div class="new_line"></div>';
}
else {
$html = $url;
}
return $html;
}
}
class LocalUserCompactResource extends UserCompactResource {
protected function getCssClass() {
return 'resourceLocalPopupTrigger';
}
}
class OslcUserCompactResource extends UserCompactResource {
protected function getCssClass() {
return 'resourceOslcPopupTrigger';
}
}
/**
* Enter description here ...
* @author olivier
*
*/
class GroupCompactResource extends CompactResource {
protected function getCssClass() {
// TBD
}
}
class LocalGroupCompactResource extends GroupCompactResource {
protected function getCssClass() {
return 'resourceLocalPopupTrigger';
}
public function getResourceLink() {
$group_name = $this->params['group_name'];
$group_id = $this->params['group_id'];
$link_text = $this->params['link_text'];
$resource_url = util_make_url_g ($group_name, $group_id);
$css_class = $this->getCssClass();
return '<a class="'.$css_class .'" href="'. $resource_url .
'">'. $link_text . '</a>';
}
}
class OslcGroupCompactResource extends GroupCompactResource {
protected function getCssClass() {
return 'resourceOslcPopupTrigger';
}
public function getResourceLink() {
$name = $this->params['name'];
$resource_url = $this->params['url'];
$css_class = $this->getCssClass();
return '<a class="'.$css_class .'" href="'. $resource_url .
'">'. $name . '</a>';
}
}
|