diff options
Diffstat (limited to 'modules_v3/top10_pageviews/module.php')
| -rw-r--r-- | modules_v3/top10_pageviews/module.php | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/modules_v3/top10_pageviews/module.php b/modules_v3/top10_pageviews/module.php index 0f38a3c6b9..8378dd4ea9 100644 --- a/modules_v3/top10_pageviews/module.php +++ b/modules_v3/top10_pageviews/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_pageviews_WT_Module @@ -36,16 +37,17 @@ class top10_pageviews_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 $ctype; - $count_placement=get_block_setting($block_id, 'count_placement', 'before'); - $num=(int)get_block_setting($block_id, 'num', 10); - $block=get_block_setting($block_id, 'block', false); + $num = get_block_setting($block_id, 'num', '10'); + $count_placement = get_block_setting($block_id, 'count_placement', 'before'); + $block = get_block_setting($block_id, 'block', '0'); + if ($cfg) { foreach (array('count_placement', 'num', 'block') as $name) { if (array_key_exists($name, $cfg)) { - $$name=$cfg[$name]; + $$name = $cfg[$name]; } } } @@ -53,7 +55,7 @@ class top10_pageviews_WT_Module extends WT_Module implements WT_Module_Block { $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 = ''; } @@ -61,10 +63,10 @@ class top10_pageviews_WT_Module extends WT_Module implements WT_Module_Block { $content = ""; // load the lines from the file - $top10=WT_DB::prepare( - "SELECT page_parameter, page_count". - " FROM `##hit_counter`". - " WHERE gedcom_id = :tree_id AND page_name IN ('individual.php','family.php','source.php','repo.php','note.php','mediaviewer.php')". + $top10 = WT_DB::prepare( + "SELECT page_parameter, page_count" . + " FROM `##hit_counter`" . + " WHERE gedcom_id = :tree_id AND page_name IN ('individual.php','family.php','source.php','repo.php','note.php','mediaviewer.php')" . " ORDER BY page_count DESC LIMIT :limit" )->execute(array( 'tree_id' => WT_GED_ID, @@ -78,15 +80,15 @@ class top10_pageviews_WT_Module extends WT_Module implements WT_Module_Block { $content .= "<table>"; } foreach ($top10 as $id=>$count) { - $record=WT_GedcomRecord::getInstance($id); + $record = WT_GedcomRecord::getInstance($id); if ($record && $record->canShow()) { $content .= '<tr valign="top">'; - if ($count_placement=='before') { - $content .= '<td dir="ltr" align="right">['.$count.']</td>'; + if ($count_placement == 'before') { + $content .= '<td dir="ltr" align="right">[' . $count . ']</td>'; } - $content .= '<td class="name2" ><a href="'.$record->getHtmlUrl().'">'.$record->getFullName().'</a></td>'; - if ($count_placement=='after') { - $content .= '<td dir="ltr" align="right">['.$count.']</td>'; + $content .= '<td class="name2" ><a href="' . $record->getHtmlUrl() . '">' . $record->getFullName() . '</a></td>'; + if ($count_placement == 'after') { + $content .= '<td dir="ltr" align="right">[' . $count . ']</td>'; } $content .= '</tr>'; } @@ -95,10 +97,9 @@ class top10_pageviews_WT_Module extends WT_Module implements WT_Module_Block { 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; } @@ -122,28 +123,28 @@ class top10_pageviews_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, 'count_placement', WT_Filter::post('count_placement', 'before|after', 'before')); - 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'); + $count_placement = get_block_setting($block_id, 'count_placement', 'before'); + $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>'; - $count_placement=get_block_setting($block_id, 'count_placement', 'left'); echo "<tr><td class=\"descriptionbox wrap width33\">"; echo WT_I18N::translate('Place counts before or after name?'); echo "</td><td class=\"optionbox\">"; echo select_edit_control('count_placement', array('before'=>WT_I18N::translate('before'), 'after'=>WT_I18N::translate('after')), null, $count_placement, ''); 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">'; |
