summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorŁukasz Wilenski <wooc@gazeta.pl>2011-01-27 21:25:22 +0000
committerŁukasz Wilenski <wooc@gazeta.pl>2011-01-27 21:25:22 +0000
commit4ec9988c1ff3d9d585f0bcc27199e76554c3d72c (patch)
treec6e0b24d66f2cef33b724f5ecbebab057e1e394b
parent20cbd7cf86ec2104416cedc1358d244398f912eb (diff)
downloadwebtrees-4ec9988c1ff3d9d585f0bcc27199e76554c3d72c.tar.gz
webtrees-4ec9988c1ff3d9d585f0bcc27199e76554c3d72c.tar.bz2
webtrees-4ec9988c1ff3d9d585f0bcc27199e76554c3d72c.zip
add parameters to show the hits
-rw-r--r--includes/hitcount.php5
-rw-r--r--library/WT/Stats.php45
-rw-r--r--modules/user_welcome/module.php6
3 files changed, 50 insertions, 6 deletions
diff --git a/includes/hitcount.php b/includes/hitcount.php
index 5e0a1c8ae0..96a8f3eae1 100644
--- a/includes/hitcount.php
+++ b/includes/hitcount.php
@@ -3,7 +3,7 @@
* Counts how many hits.
*
* webtrees: Web based Family History software
- * Copyright (C) 2010 webtrees development team.
+ * Copyright (C) 2011 webtrees development team.
*
* Derived from PhpGedView
* Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved.
@@ -53,9 +53,6 @@ case 'family.php':
case 'source.php':
$page_parameter=safe_GET('sid', WT_REGEX_XREF);
break;
-case 'source.php':
- $page_parameter=safe_GET('sid', WT_REGEX_XREF);
- break;
case 'repo.php':
$page_parameter=safe_GET('rid', WT_REGEX_XREF);
break;
diff --git a/library/WT/Stats.php b/library/WT/Stats.php
index 25f655885b..ba4a876087 100644
--- a/library/WT/Stats.php
+++ b/library/WT/Stats.php
@@ -3725,6 +3725,51 @@ class WT_Stats {
// Tools //
///////////////////////////////////////////////////////////////////////////////
+ // These functions provide access to hitcounter
+ // for use in the HTML block.
+
+ static private function getHitCount($page_name='index', $params=null) {
+ global $SHOW_COUNTER, $SEARCH_SPIDER, $hitCount;
+ if (is_array($params) && isset($params[0]) && $params[0] != '') {$page_parameter = $params[0];} else {$page_parameter = '';}
+ $countertext='';
+ if ($SHOW_COUNTER && !$SEARCH_SPIDER) {
+ switch ($page_name) {
+ case 'index':
+ // gedcom:WT_GED_ID;
+ $countertext .= WT_I18N::translate('Hit Count:')." ".$hitCount;
+ break;
+ case 'index.php':
+ // user:USER_ID;
+ $page_parameter = 'user:'.$page_parameter;
+ $hit=WT_DB::prepare(
+ "SELECT page_count FROM `##hit_counter`".
+ " WHERE gedcom_id=? AND page_name=? AND page_parameter=?"
+ )->execute(array(WT_GED_ID, $page_name, $page_parameter))->fetchOne();
+ $countertext .= WT_I18N::translate('Hit Count:').' <span class="hit-counter">'.$hit.'</span>';
+ break;
+ default:
+ $hit=WT_DB::prepare(
+ "SELECT page_count FROM `##hit_counter`".
+ " WHERE gedcom_id=? AND page_name=? AND page_parameter=?"
+ )->execute(array(WT_GED_ID, $page_name, $page_parameter))->fetchOne();
+ $countertext .= $hit;
+ break;
+ }
+ $countertext = "<div id='hitcounter' class='clearfloat'>".$countertext;
+ $countertext .= "</div>";
+ }
+ return $countertext;
+ }
+
+ static function hitCount() {return self::getHitCount();}
+ static function hitCountUser($params=null) {return self::getHitCount('index.php', $params);}
+ static function hitCountIndi($params=null) {return self::getHitCount('individual.php', $params);}
+ static function hitCountFam ($params=null) {return self::getHitCount('family.php', $params);}
+ static function hitCountSour($params=null) {return self::getHitCount('source.php', $params);}
+ static function hitCountRepo($params=null) {return self::getHitCount('repo.php', $params);}
+ static function hitCountNote($params=null) {return self::getHitCount('note.php', $params);}
+ static function hitCountObje($params=null) {return self::getHitCount('mediaviewer.php',$params);}
+
/*
* Leave for backwards compatability? Anybody using this?
*/
diff --git a/modules/user_welcome/module.php b/modules/user_welcome/module.php
index e8e47600a4..a9e97e5d54 100644
--- a/modules/user_welcome/module.php
+++ b/modules/user_welcome/module.php
@@ -41,7 +41,7 @@ class user_welcome_WT_Module extends WT_Module implements WT_Module_Block {
// Implement class WT_Module_Block
public function getBlock($block_id, $template=true, $cfg=null) {
- global $WT_IMAGES;
+ global $WT_IMAGES, $hitCount, $SHOW_COUNTER;
$id=$this->getName().$block_id;
$title=/* I18N: A greeting; %s is the user's name */ WT_I18N::translate('Welcome %s', getUserFullName(WT_USER_ID));
@@ -58,7 +58,9 @@ class user_welcome_WT_Module extends WT_Module implements WT_Module_Block {
$content .= "</tr><tr><td class=\"center\" colspan=\"3\">";
$content .= "<a href=\"javascript:;\" onclick=\"window.open('index_edit.php?name=".WT_USER_NAME."&amp;ctype=user"."', '_blank', 'top=50,left=10,width=705,height=355,scrollbars=1,resizable=1');\">".WT_I18N::translate('Customize My Page')."</a>";
$content .= help_link('mypage_customize');
- $content .= "<br />".format_timestamp(client_time());
+ $content .= "<br />".format_timestamp(client_time())."<br />";
+ if ($SHOW_COUNTER)
+ $content .= WT_I18N::translate('Hit Count:')." ".$hitCount."<br />";
$content .= "</td></tr></table>";
if ($template) {