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 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382
|
<?php
/**
* Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
* Copyright 2012, Franck Villaume - TrivialDev
*
* This file is a part of Fusionforge.
*
* Fusionforge 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.
*
* Fusionforge 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 Fusionforge. If not, see <http://www.gnu.org/licenses/>.
*/
require_once 'common/widget/WidgetLayoutManager.class.php';
require_once 'common/widget/Widget_MySurveys.class.php';
require_once 'common/widget/Widget_MyProjects.class.php';
require_once 'common/widget/Widget_MyBookmarks.class.php';
require_once 'common/widget/Widget_MyMonitoredForums.class.php';
//require_once('common/widget/Widget_MyMonitoredFp.class.php');
require_once 'common/widget/Widget_MyLatestSvnCommits.class.php';
require_once 'common/widget/Widget_MyProjectsLastDocuments.class.php';
require_once 'common/widget/Widget_MyArtifacts.class.php';
//require_once('common/widget/Widget_MyBugs.class.php');
//require_once('common/widget/Widget_MySrs.class.php');
require_once 'common/widget/Widget_MyTasks.class.php';
require_once 'common/widget/Widget_MyRss.class.php';
require_once 'common/widget/Widget_MyAdmin.class.php';
/*
require_once 'common/widget/Widget_MyTwitterFollow.class.php';
require_once 'common/widget/Widget_MySystemEvent.class.php';
//require_once('common/widget/Widget_MyWikiPage.class.php');
*/require_once('common/widget/Widget_ProjectDescription.class.php');
//require_once('common/widget/Widget_ProjectClassification.class.php');
require_once 'common/widget/Widget_ProjectMembers.class.php';
require_once 'common/widget/Widget_ProjectInfo.class.php';
require_once 'common/widget/Widget_ProjectLatestFileReleases.class.php';
require_once 'common/widget/Widget_ProjectLatestDocuments.class.php';
require_once('common/widget/Widget_ProjectDocumentsActivity.class.php');
require_once 'common/widget/Widget_ProjectLatestNews.class.php';
require_once 'common/widget/Widget_ProjectPublicAreas.class.php';
require_once 'common/widget/Widget_ProjectRss.class.php';/*
require_once 'common/widget/Widget_ProjectLatestSvnCommits.class.php';
require_once 'common/widget/Widget_ProjectLatestCvsCommits.class.php';
require_once 'common/widget/Widget_ProjectTwitterFollow.class.php';
//require_once('common/widget/Widget_ProjectWikiPage.class.php');
require_once 'common/widget/Widget_ProjectSvnStats.class.php';
*/
require_once 'common/widget/Widget_MyMonitoredDocuments.class.php';
/**
* "Codendi" Layout Widget
*
*/
/* abstract */ class Widget {
var $content_id;
var $id;
var $hasPreferences;
var $buttons;
var $owner_id;
var $owner_type;
/**
* Constructor
*/
function Widget($id) {
$this->id = $id;
$this->content_id = 0;
}
function display($layout_id, $column_id, $readonly, $is_minimized, $display_preferences, $owner_id, $owner_type) {
$GLOBALS['HTML']->widget($this, $layout_id, $readonly, $column_id, $is_minimized, $display_preferences, $owner_id, $owner_type);
}
function getTitle() {
return '';
}
/**
* TODO : Enter description here ...
* @return string
*/
function getContent() {
return '';
}
function getPreferencesForm($layout_id, $owner_id, $owner_type) {
$prefs = '';
$prefs .= '<form method="post" action="/widgets/widget.php?owner='. $owner_type.$owner_id .'&action=update&name['. $this->id .']='. $this->getInstanceId() .'&content_id='. $this->getInstanceId() .'&layout_id='. $layout_id .'">';
$prefs .= '<fieldset><legend>'. _("Preferences") .'</legend>';
$prefs .= $this->getPreferences();
$prefs .= '<br />';
$prefs .= '<input type="submit" name="cancel" value="'. _("Cancel") .'" /> ';
$prefs .= '<input type="submit" value="'. _("Submit") .'" />';
$prefs .= '</fieldset>';
$prefs .= '</form>';
return $prefs;
}
function getInstallPreferences() {
return '';
}
function getPreferences() {
return '';
}
function hasPreferences() {
return false;
}
function hasButtons() {
return false;
}
function updatePreferences(&$request) {
return true;
}
function hasRss() {
return false;
}
function getRssUrl($owner_id, $owner_type) {
if ($this->hasRss()) {
return '/widgets/widget.php?owner='.$owner_type.$owner_id.'&action=rss&name['. $this->id .']='. $this->getInstanceId();
} else {
return false;
}
}
function isUnique() {
return true;
}
function isAvailable() {
return true;
}
function isAjax() {
return false;
}
function getInstanceId() {
return $this->content_id;
}
function loadContent($id) {
}
function setOwner($owner_id, $owner_type) {
$this->owner_id = $owner_id;
$this->owner_type = $owner_type;
}
function canBeUsedByProject(&$project) {
return false;
}
/**
* cloneContent
*
* Take the content of a widget, clone it and return the id of the new content
*
* @param $id the id of the content to clone
* @param $owner_id the owner of the widget of the new widget
* @param $owner_type the type of the owner of the new widget (see WidgetLayoutManager)
* @return int
*/
function cloneContent($id, $owner_id, $owner_type) {
return $this->getInstanceId();
}
function create(&$request) {
}
function destroy($id) {
}
/**
* getInstance - Returns an instance of a widget given its name
* @param string $widget_name
* @return Widget instance
*/
static function & getInstance($widget_name) {
$o = null;
switch($widget_name) {
case 'mysurveys':
$o = new Widget_MySurveys();
break;
case 'myprojects':
$o = new Widget_MyProjects();
break;
case 'mybookmarks':
$o = new Widget_MyBookmarks();
break;
case 'mymonitoredforums':
$o = new Widget_MyMonitoredForums();
break;
case 'mymonitoreddocuments':
$o = new Widget_MyMonitoredDocuments();
break;
case 'myprojectslastdocuments':
$o = new Widget_MyProjectsLastDocuments();
break;
case 'myartifacts':
$o = new Widget_MyArtifacts();
break;
case 'myrss':
$o = new Widget_MyRss();
break;
case 'mytasks':
$o = new Widget_MyTasks();
break;
case 'myadmin':
if (forge_check_global_perm('forge_admin')
|| forge_check_global_perm('approve_projects')
|| forge_check_global_perm('approve_news')) {
$o = new Widget_MyAdmin();
}
break;/*
case 'mysrs':
$o = new Widget_MySrs();
break;
case 'mymonitoredfp':
$o = new Widget_MyMonitoredFp();
break;
case 'mylatestsvncommits':
$o = new Widget_MyLatestSvnCommits();
break;
case 'mybugs':
$o = new Widget_MyBugs();
break;
case 'mytwitterfollow':
$o = new Widget_MyTwitterFollow();
break;
case 'mywikipage': //not yet
$o = new Widget_MyWikiPage();
break;
case 'mysystemevent':
// This widget is only for super admin
if (forge_check_global_perm('forge_admin')) {
$o = new Widget_MySystemEvent();
}
break;
case 'projectclassification':
$o = new Widget_ProjectClassification();
break;*/
case 'projectdescription':
$o = new Widget_ProjectDescription();
break;
case 'projectmembers':
$o = new Widget_ProjectMembers();
break;
case 'projectinfo':
$o = new Widget_ProjectInfo();
break;
case 'projectlatestfilereleases':
$o = new Widget_ProjectLatestFileReleases();
break;
case 'projectlatestdocuments':
$o = new Widget_ProjectLatestDocuments();
break;
case 'projectdocumentsactivity':
$o = new Widget_ProjectDocumentsActivity();
break;
case 'projectlatestnews':
$o = new Widget_ProjectLatestNews();
break;
case 'projectpublicareas':
$o = new Widget_ProjectPublicAreas();
break;
case 'projectrss':
$o = new Widget_ProjectRss();
break;/*
case 'projecttwitterfollow':
$o = new Widget_ProjectTwitterFollow();
break;
case 'projectsvnstats':
$o = new Widget_ProjectSvnStats();
break;
//case 'projectwikipage': //not yet
// $o = new Widget_ProjectWikiPage();
// break;
case 'projectlatestsvncommits':
$o = new Widget_ProjectLatestSvnCommits();
break;
case 'projectlatestcvscommits':
$o = new Widget_ProjectLatestCvsCommits();
break;*/
default:
//$em = EventManager::instance();
//$em->processEvent('widget_instance', array('widget' => $widget_name, 'instance' => &$o));
// calls the plugin's hook to get an instance of the widget
plugin_hook('widget_instance', array('widget' => $widget_name, 'instance' => &$o));
break;
}
if (!$o || !($o instanceof Widget)) {
$o = null;
}
return $o;
}
/**
* getCodendiWidgets - Static
* @param unknown_type $owner_type
* @return multitype:
*/
static function getCodendiWidgets($owner_type) {
switch ($owner_type) {
case WidgetLayoutManager::OWNER_TYPE_USER:
$widgets = array('myadmin', 'mysurveys', 'myprojects', 'mybookmarks',
'mymonitoredforums', 'mymonitoredfp', 'myartifacts', 'mybugs', //'mywikipage' //not yet
'mytasks', 'mysrs', 'mylatestsvncommits', 'mytwitterfollow',
'mysystemevent', 'myrss', 'mymonitoreddocuments', 'myprojectslastdocuments',
);
break;
case WidgetLayoutManager::OWNER_TYPE_GROUP:
// project home widgets
$widgets = array('projectdescription', 'projectmembers', 'projectinfo',
'projectlatestfilereleases', 'projectlatestdocuments', 'projectlatestnews', 'projectpublicareas', //'projectwikipage' //not yet
'projectlatestsvncommits', 'projectlatestcvscommits', 'projecttwitterfollow',
'projectsvnstats', 'projectrss', 'projectdocumentsactivity',
);
break;
case WidgetLayoutManager::OWNER_TYPE_HOME:
$widgets = array();
break;
default:
$widgets = array();
break;
}
// add widgets of the plugins, declared through hooks
$plugins_widgets = array();
//$em =& EventManager::instance();
//$em->processEvent('widgets', array('codendi_widgets' => &$plugins_widgets, 'owner_type' => $owner_type));
plugin_hook('widgets', array('codendi_widgets' => &$plugins_widgets, 'owner_type' => $owner_type));
plugin_hook('widgets', array('fusionforge_widgets' => &$plugins_widgets, 'owner_type' => $owner_type));
if (is_array($plugins_widgets)) {
$widgets = array_merge($widgets, $plugins_widgets);
}
return $widgets;
}
/* static */ function getExternalWidgets($owner_type) {
switch ($owner_type) {
case WidgetLayoutManager::OWNER_TYPE_USER:
$widgets = array(
);
break;
case WidgetLayoutManager::OWNER_TYPE_GROUP:
$widgets = array(
);
break;
case WidgetLayoutManager::OWNER_TYPE_HOME:
$widgets = array();
break;
default:
$widgets = array();
break;
}
$plugins_widgets = array();
$em =& EventManager::instance();
$em->processEvent('widgets', array('external_widgets' => &$plugins_widgets, 'owner_type' => $owner_type));
if (is_array($plugins_widgets)) {
$widgets = array_merge($widgets, $plugins_widgets);
}
return $widgets;
}
function getCategory() {
return _('General');
}
function getDescription() {
return '';
}
function getPreviewCssClass() {
$locale = UserManager::instance()->getCurrentUser()->getLanguage();
$locale = "en_US";
return 'widget-preview-'.($this->id).'-'.$locale;
}
function getAjaxUrl($owner_id, $owner_type) {
return '/widgets/widget.php?owner='. $owner_type.$owner_id .'&action=ajax&name['. $this->id .']='. $this->getInstanceId();
}
function getIframeUrl($owner_id, $owner_type) {
return '/widgets/widget.php?owner='. $owner_type.$owner_id .'&action=iframe&name['. $this->id .']='. $this->getInstanceId();
}
}
|