i18n::translate('Most Viewed Items'),
'type'=>'both',
'descr'=>i18n::translate('This block will show the 10 records that have been viewed the most. This block requires that Hit Counters be enabled in the GEDCOM configuration settings.'),
'canconfig'=>true,
'config'=>array(
'cache'=>1,
'num'=>10,
'count_placement'=>'left'
)
);
function top10_pageviews($block=true, $config="", $side, $index) {
global $TBLPREFIX, $INDEX_DIRECTORY, $WT_BLOCKS, $ctype, $WT_IMAGES, $WT_IMAGE_DIR, $SHOW_COUNTER, $SHOW_SOURCES, $TEXT_DIRECTION;
if (empty($config)) {
$config = $WT_BLOCKS["top10_pageviews"]["config"];
}
if (isset($config["count_placement"])) {
$CountSide = $config["count_placement"];
} else {
$CountSide = "left";
}
$id = "top10hits";
$title='';
if ($WT_BLOCKS["top10_pageviews"]["canconfig"]) {
if ($ctype=="gedcom" && WT_USER_GEDCOM_ADMIN || $ctype=="user" && WT_USER_ID) {
if ($ctype=="gedcom") {
$name = WT_GEDCOM;
} else {
$name = WT_USER_NAME;
}
$title .= "";
$title .= "";
}
}
$title .= i18n::translate('Most Viewed Items');
$title .= help_link('index_top10_pageviews');
$content = "";
// if the counter file does not exist then don't do anything
if (!$SHOW_COUNTER) {
if (WT_USER_IS_ADMIN) {
$content .= "".i18n::translate('Hit counters must be enabled in the GEDCOM configuration, Display and Layout section, Hide and Show group.')."";
}
} else {
// load the lines from the file
$top10=WT_DB::prepareLimit(
"SELECT page_parameter, page_count".
" FROM {$TBLPREFIX}hit_counter".
" WHERE gedcom_id=? AND page_name IN ('individual.php','family.php','source.php','repo.php','note.php','mediaviewer.php')".
" ORDER BY page_count DESC",
$config['num']
)->execute(array(WT_GED_ID))->FetchAssoc();
if ($top10) {
if ($block) {
$content .= "
| ['.$count.'] | '; } $content .= ''.PrintReady($record->getFullName()).' | '; if ($CountSide=='right') { $content .= '['.$count.'] | '; } $content .= '