3 * Copyright 2020-2021, Franck Villaume - TrivialDev
4 * This file is a part of Fusionforge.
6 * Fusionforge is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * Fusionforge is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Fusionforge. If not, see <http://www.gnu.org/licenses/>.
20 require_once 'Widget.class.php';
21 require_once $gfcommon.'include/FusionForge.class.php';
23 class Widget_HomeHallOfFame extends Widget {
24 var $_hall_show = 'PDA';
25 function __construct() {
26 parent::__construct('homehalloffame');
27 if (session_loggedin()) {
28 $userPrefValue = session_get_user()->getPreference('my_home_hall_of_fame');
30 $this->_hall_show = $userPrefValue;
36 return _('Hall Of Fame');
39 function getContent() {
40 $ff = new FusionForge();
41 $objects = $ff->getHallOfFameObjects($this->_hall_show);
43 foreach($objects as $object) {
44 if (method_exists($object, 'getAbstract')) {
45 $content .= $object->getAbstract();
47 switch (get_class($object)) {
49 if (strstr($object->getDescription(),'<br/>')) {
50 // the news is html, fckeditor made for example
51 $arr = explode('<br/>', $object->getDescription());
53 $arr = explode("\n", $object->getDescription());
55 $summ_txt = util_make_links($arr[0]);
56 $arr_v = $object->getVotes();
57 $news = html_e('div', array('class' => 'widget-sticker-header box'), html_e('div', array(), util_make_link($object->getHomePage(), $object->getPublicName(), false, true).' - '.$arr_v[0].' '._('Vote(s)')));
58 $news .= html_e('div', array('class' => 'widget-sticker-body'), $summ_txt.html_e('br').util_make_link($object->getHomePage(), _('... Read more'), false, true));
59 $news .= html_e('div', array('class' => 'widget-sticker-footer'), _('Registered')._(': ').date(_('Y-m-d H:i'), $object->getStartDate()));
60 $content .= html_e('div', array('class' => 'widget-sticker-container'), $news);
63 $content .= 'BUILT The Abstract';
69 if (strlen($content)) {
70 return $content.html_e('div', array('style' => 'clear:both'), ' ');
74 function getDescription() {
75 return _('Display most voted projets, diaries, artifacts.');
78 function hasPreferences() {
79 if (session_loggedin()) {
85 function updatePreferences() {
86 $cancel = getStringFromRequest('cancel');
87 if (strlen($cancel) > 0) {
88 $show = getStringFromRequest('show');
91 $this->_hall_show = 'P';
94 $this->_hall_show = 'D';
97 $this->_hall_show = 'A';
100 $this->_hall_show = 'PA';
103 $this->_hall_show = 'PD';
106 $this->_hall_show = 'DA';
110 $this->_hall_show = 'PDA';
112 session_get_user()->setPreference('my_home_hall_of_fame', $this->_hall_show);
117 function getPreferences() {
118 $optionsArray = array('P', 'D', 'A', 'PA', 'PD', 'DA', 'PDA');
119 $textsArray = array();
120 $textsArray[] = _('Projets'.' [P]');
121 $textsArray[] = _('Diaries'.' [D]');
122 $textsArray[] = _('Artifacts'.' [A]');
123 $textsArray[] = _('Projects & Artifacts'.' [PA]');
124 $textsArray[] = _('Projects & Diaries'.' [PD]');
125 $textsArray[] = _('Diaries & Artifacts'.' [DA]');
126 $textsArray[] = _('Projects, Diaries & Artifacts'.' [PDA]');
127 $prefs = _('Select objects')._(': ').html_build_select_box_from_arrays($optionsArray, $textsArray, 'show', $this->_hall_show, false);