Skip to content

Commit

Permalink
Added portal module for latest donations
Browse files Browse the repository at this point in the history
  • Loading branch information
GodMod committed Feb 10, 2017
1 parent d72641f commit 2215870
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 1 deletion.
1 change: 1 addition & 0 deletions donations_plugin_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public function __construct()
$this->add_pdh_write_module('donations');

$this->add_portal_module('donations');
$this->add_portal_module('latestdonations');
}

/**
Expand Down
4 changes: 4 additions & 0 deletions language/english/lang_main.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@
'donations_f_show_progress' => 'Show donation progress',
'donations_f_text' => 'Donation text',
'donations_months_short' => 'Mo.',

'donations_f_show_count' => 'Count of latest donations',
'donations_f_text_latest' => 'Descriptiontext (optional)',
'latestdonations' => 'Latest donations',
);

?>
4 changes: 4 additions & 0 deletions language/german/lang_main.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@
'donations_f_show_progress' => 'Spenden-Fortschritt anzeigen',
'donations_f_text' => 'Spenden-Text',
'donations_months_short' => 'Mo.',

'donations_f_show_count' => 'Anzahl der letzten angezeigten Spenden',
'donations_f_text_latest' => 'Optionaler Beschreibungstext',
'latestdonations' => 'Letzte Spenden',
);

?>
2 changes: 1 addition & 1 deletion page_objects/donate_pageobject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public function display()

$this->tpl->assign_block_vars('wallofdonators_row', array(
'VALUE' => '<span class="'.$class.'">'.$fltAmount.'</span>',
'CURRENCY' => $arrData['currency'],
'CURRENCY' => sanitize($arrData['currency']),
'DATE' => $this->time->user_date($arrData['date']),
'COMMENT' => sanitize($arrData['description']),
'USERNAME' => ($arrData['public']) ? $strUsername : '<i style="font-style:italic;">Anonymous</i>',
Expand Down
114 changes: 114 additions & 0 deletions portal/latestdonations_portal.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php
/* Project: EQdkp-Plus
* Package: mc_featured_media Plugin
* Link: http://eqdkp-plus.eu
*
* Copyright (C) 2006-2015 EQdkp-Plus Developer Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

if (!defined('EQDKP_INC')){
header('HTTP/1.0 404 Not Found'); exit;
}

/*+----------------------------------------------------------------------------
| latestdonations_portal
+--------------------------------------------------------------------------*/
class latestdonations_portal extends portal_generic{

/**
* Portal path
*/
protected static $path = 'latestdonations';
/**
* Portal data
*/
/**
* Portal data
*/
protected static $data = array(
'name' => 'Latest Donations Module',
'version' => '0.1.0',
'author' => 'GodMod',
'contact' => 'https://eqdkp-plus.eu',
'description' => 'Displays latest donations',
'lang_prefix' => 'donations_',
'multiple' => false,
);

protected static $apiLevel = 20;

protected static $multiple = false;

public function get_settings($state){

$settings = array(
'show_count' => array(
'type' => 'spinner',
'default' => 5,
),
'text_latest' => array(
'type' => 'bbcodeeditor',
)
);

return $settings;
}

/**
* output
* Get the portal output
*
* @returns string
*/
public function output(){
$strText = $this->config('text_latest');
$output = "";
if($strText && strlen($strText)){
$output .= $this->bbcode->toHTML($strText);
}

$arrCompletedIDs = $this->pdh->get('donations', 'completed_id_list');
$intMax = intval($this->config('show_count'));
$intCount = 0;

$output .= '<table class="table fullwidth colorswitch">';
foreach($arrCompletedIDs as $donationID){
if($intCount >= $intMax) break;

//Datum, Benutzername, Wert, Kommentar
$arrData = $this->pdh->get('donations', 'data', array($donationID));

if($arrData['user_id'] > 0){
$username = $this->pdh->get('user', 'name', array($arrData['user_id']));
$strUsername = '<a href="'.register('routing')->build('user', $username, 'u'.$arrData['user_id']).'" data-user-id="'.$arrData['user_id'].'">'.$username.'</a>';
} else {
$strUsername = sanitize($arrData['username']);
}


$fltAmount = number_format(round($arrData['amount'],2),2);
$class = ($fltAmount < 0) ? 'negative' : 'positive';

$intCount++;

$output .= '<tr><td>'.$this->time->user_date($arrData['date']).'</td><td>'.(($arrData['public']) ? $strUsername : '<i style="font-style:italic;">Anonymous</i>').'</td><td><span class="'.$class.'">'.$fltAmount.'</span> '.sanitize($arrData['currency']).'</td></tr>';
}
$output .= '</table>';
return $output;
}
}

?>

0 comments on commit 2215870

Please sign in to comment.