summaryrefslogtreecommitdiff
path: root/modules_v3/top10_givnnames/module.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules_v3/top10_givnnames/module.php')
-rw-r--r--modules_v3/top10_givnnames/module.php70
1 files changed, 37 insertions, 33 deletions
diff --git a/modules_v3/top10_givnnames/module.php b/modules_v3/top10_givnnames/module.php
index 341253df1a..5d9ee0a144 100644
--- a/modules_v3/top10_givnnames/module.php
+++ b/modules_v3/top10_givnnames/module.php
@@ -1,6 +1,6 @@
<?php
// webtrees: Web based Family History software
-// Copyright (C) 2014 webtrees development team.
+// Copyright (C) 2015 webtrees development team.
//
// Derived from PhpGedView
// Copyright (C) 2010 John Finlay
@@ -20,6 +20,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use WT\Auth;
+use WT\Theme;
/**
* Class top10_givnnames_WT_Module
@@ -36,72 +37,75 @@ class top10_givnnames_WT_Module extends WT_Module implements WT_Module_Block {
}
/** {@inheritdoc} */
- public function getBlock($block_id, $template=true, $cfg=null) {
+ public function getBlock($block_id, $template = true, $cfg = null) {
global $TEXT_DIRECTION, $ctype;
- $num=get_block_setting($block_id, 'num', 10);
- $infoStyle=get_block_setting($block_id, 'infoStyle', 'table');
- $block=get_block_setting($block_id, 'block', false);
+ $num = get_block_setting($block_id, 'num', '10');
+ $infoStyle = get_block_setting($block_id, 'infoStyle', 'table');
+ $block = get_block_setting($block_id, 'block', '0');
+
if ($cfg) {
foreach (array('num', 'infoStyle', 'block') as $name) {
if (array_key_exists($name, $cfg)) {
- $$name=$cfg[$name];
+ $$name = $cfg[$name];
}
}
}
- $stats=new WT_Stats(WT_GEDCOM);
+ $stats = new WT_Stats(WT_GEDCOM);
$id = $this->getName() . $block_id;
$class = $this->getName() . '_block';
if ($ctype === 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype === 'user' && Auth::check()) {
- $title = '<i class="icon-admin" title="'.WT_I18N::translate('Configure').'" onclick="modalDialog(\'block_edit.php?block_id='.$block_id.'\', \''.$this->getTitle().'\');"></i>';
+ $title = '<i class="icon-admin" title="' . WT_I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>';
} else {
$title = '';
}
if ($num == 1) {
// I18N: i.e. most popular given name.
- $title.=WT_I18N::translate('Top given name');
+ $title .= WT_I18N::translate('Top given name');
} else {
// I18N: Title for a list of the most common given names, %s is a number. Note that a separate translation exists when %s is 1
- $title.=WT_I18N::plural('Top %s given name', 'Top %s given names', $num, WT_I18N::number($num));
+ $title .= WT_I18N::plural('Top %s given name', 'Top %s given names', $num, WT_I18N::number($num));
}
$content = '<div class="normal_inner_block">';
//Select List or Table
switch ($infoStyle) {
case "list": // Output style 1: Simple list style. Better suited to left side of page.
- if ($TEXT_DIRECTION=='ltr') $padding = 'padding-left: 15px';
- else $padding = 'padding-right: 15px';
- $params=array(1,$num,'rcount');
+ if ($TEXT_DIRECTION == 'ltr') {
+ $padding = 'padding-left: 15px';
+ } else {
+ $padding = 'padding-right: 15px';
+ }
+ $params = array(1, $num, 'rcount');
//List Female names
- $totals=$stats->commonGivenFemaleTotals($params);
+ $totals = $stats->commonGivenFemaleTotals($params);
if ($totals) {
- $content.='<b>'.WT_I18N::translate('Females').'</b><div class="wrap" style="'.$padding.'">'.$totals.'</div><br>';
+ $content .= '<b>' . WT_I18N::translate('Females') . '</b><div class="wrap" style="' . $padding . '">' . $totals . '</div><br>';
}
//List Male names
- $totals=$stats->commonGivenMaleTotals($params);
+ $totals = $stats->commonGivenMaleTotals($params);
if ($totals) {
- $content.='<b>'.WT_I18N::translate('Males').'</b><div class="wrap" style="'.$padding.'">'.$totals.'</div><br>';
+ $content .= '<b>' . WT_I18N::translate('Males') . '</b><div class="wrap" style="' . $padding . '">' . $totals . '</div><br>';
}
break;
case "table": // Style 2: Tabular format. Narrow, 2 or 3 column table, good on right side of page
- $params=array(1,$num,'rcount');
- $content.='<table style="margin:auto;">
+ $params = array(1, $num, 'rcount');
+ $content .= '<table style="margin:auto;">
<tr valign="top">
- <td>'.$stats->commonGivenFemaleTable($params).'</td>
- <td>'.$stats->commonGivenMaleTable($params).'</td>';
- $content.='</tr></table>';
+ <td>'.$stats->commonGivenFemaleTable($params) . '</td>
+ <td>'.$stats->commonGivenMaleTable($params) . '</td>';
+ $content .= '</tr></table>';
break;
}
- $content .= "</div>";
+ $content .= "</div>";
if ($template) {
if ($block) {
- require WT_THEME_DIR.'templates/block_small_temp.php';
- } else {
- require WT_THEME_DIR.'templates/block_main_temp.php';
+ $class .= ' small_inner_block';
}
+ return Theme::theme()->formatBlock($id, $title, $class, $content);
} else {
return $content;
}
@@ -125,29 +129,29 @@ class top10_givnnames_WT_Module extends WT_Module implements WT_Module_Block {
/** {@inheritdoc} */
public function configureBlock($block_id) {
if (WT_Filter::postBool('save') && WT_Filter::checkCsrf()) {
- set_block_setting($block_id, 'num', WT_Filter::postInteger('num', 1, 10000, 10));
+ set_block_setting($block_id, 'num', WT_Filter::postInteger('num', 1, 10000, 10));
set_block_setting($block_id, 'infoStyle', WT_Filter::post('infoStyle', 'list|table', 'table'));
- set_block_setting($block_id, 'block', WT_Filter::postBool('block'));
- exit;
+ set_block_setting($block_id, 'block', WT_Filter::postBool('block'));
}
- require_once WT_ROOT.'includes/functions/functions_edit.php';
+ require_once WT_ROOT . 'includes/functions/functions_edit.php';
+
+ $num = get_block_setting($block_id, 'num', '10');
+ $infoStyle = get_block_setting($block_id, 'infoStyle', 'table');
+ $block = get_block_setting($block_id, 'block', '0');
- $num=get_block_setting($block_id, 'num', 10);
echo '<tr><td class="descriptionbox wrap width33">';
echo WT_I18N::translate('Number of items to show');
echo '</td><td class="optionbox">';
echo '<input type="text" name="num" size="2" value="', $num, '">';
echo '</td></tr>';
- $infoStyle=get_block_setting($block_id, 'infoStyle', 'table');
echo '<tr><td class="descriptionbox wrap width33">';
echo WT_I18N::translate('Presentation style');
echo '</td><td class="optionbox">';
echo select_edit_control('infoStyle', array('list'=>WT_I18N::translate('list'), 'table'=>WT_I18N::translate('table')), null, $infoStyle, '');
echo '</td></tr>';
- $block=get_block_setting($block_id, 'block', false);
echo '<tr><td class="descriptionbox wrap width33">';
echo /* I18N: label for a yes/no option */ WT_I18N::translate('Add a scrollbar when block contents grow');
echo '</td><td class="optionbox">';