/** * These functions provide access to hitcounter for use in the HTML block. * * @param string $page_name * @param string[] $params * * @return string */ private function hitCountQuery($page_name, $params) { if (is_array($params) && isset($params[0]) && $params[0] != '') { $page_parameter = $params[0]; } else { $page_parameter = ''; } if ($page_name === null) { // index.php?ctype=gedcom $page_name = 'index.php'; $page_parameter = 'gedcom:' . ($page_parameter ? Tree::findByName($page_parameter)->getTreeId() : $this->tree->getTreeId()); } elseif ($page_name == 'index.php') { // index.php?ctype=user $user = User::findByIdentifier($page_parameter); $page_parameter = 'user:'******'<span class="odometer">' . I18N::digits(HitCounter::getCount($this->tree, $page_name, $page_parameter)) . '</span>'; }
/** * How many times has the current page been shown? * * @param PageController $controller * * @return int Number of views, or zero for pages that aren't logged. */ protected function pageViews(PageController $controller) { if ($this->tree && $this->tree->getPreference('SHOW_COUNTER')) { if (isset($controller->record) && $controller->record instanceof GedcomRecord) { return HitCounter::countHit($this->tree, WT_SCRIPT_NAME, $controller->record->getXref()); } elseif (isset($controller->root) && $controller->root instanceof GedcomRecord) { return HitCounter::countHit($this->tree, WT_SCRIPT_NAME, $controller->root->getXref()); } elseif (WT_SCRIPT_NAME === 'index.php') { if (Auth::check() && Filter::get('ctype') !== 'gedcom') { return HitCounter::countHit($this->tree, WT_SCRIPT_NAME, 'user:'******'gedcom:' . $this->tree->getTreeId()); } } } return 0; }