mod-func-directory_top_sites.php 1.92 KB
Newer Older
1
<?php
2
// (c) Copyright 2002-2015 by authors of the Tiki Wiki CMS Groupware Project
3
//
4 5 6
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
7 8

//this script may only be included - so its better to die if called directly.
9
if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) {
10 11 12 13
  header("location: index.php");
  exit;
}

14 15 16
/**
 * @return array
 */
17 18
function module_directory_top_sites_info()
{
19
	return array(
20
		'name' => tra('Top Directory Sites'),
21
		'description' => tra('Displays the specified number of the directory sites from most visited to least visited.'),
22
		'prefs' => array('feature_directory'),
23 24 25 26
		'params' => array(
			'desc' => array(
				'name' => tra('Show description'),
				'description' => tra('If set to "y", the description of the directory site appears.') . " " . tr('Default: "n".'),
27
				'filter' => 'word',
28 29 30 31
			),
			'maxdesc' => array (
				'name' => tra('Maximum length of description'),
				'description' => tra('If desc = "y", use maxdesc to set the maximum length of the directory site (in characters). Leave blank to set no maximum (show the entire description).') . " " . tr('Default: blank.'),
32
				'filter' => 'int',
33 34
			)
		),
35 36 37 38
		'common_params' => array('nonums')
	);
}

39 40 41 42
/**
 * @param $mod_reference
 * @param $module_params
 */
43 44
function module_directory_top_sites($mod_reference, $module_params)
{
45 46
	$tikilib = TikiLib::lib('tiki');
	$smarty = TikiLib::lib('smarty');
47 48
	$ranking = $tikilib->dir_list_all_valid_sites2(0, $mod_reference["rows"], 'hits_desc', '');

49 50 51
	$smarty->assign('desc', isset($module_params['desc']) ? $module_params['desc'] : 'n');	

	// only allow truncation if showing description
52 53
	if ($module_params['desc'] != 'n') {
		if ($module_params['maxdesc'] >= 1) {
54 55 56 57
			$smarty->assign('maxdesc', $module_params['maxdesc']);	
		}
	}
	
58 59
	$smarty->assign('modTopdirSites', $ranking["data"]);
}