1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8//this script may only be included - so its better to die if called directly. 9if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) { 10 header("location: index.php"); 11 exit; 12} 13 14/** 15 * @return array 16 */ 17function module_directory_last_sites_info() 18{ 19 return [ 20 'name' => tra('Newest Directory Sites'), 21 'description' => tra('Displays the specified number of the directory sites most recently added.'), 22 'prefs' => ['feature_directory'], 23 'params' => [ 24 'absurl' => [ 25 'name' => tra('Absolute URL'), 26 'description' => tra('If set to "y", some of the links use an absolute URL instead of a relative one. This can avoid broken links if the module is to be sent in a newsletter, for example.') . " " . tr('Default: "n".'), 27 ], 28 'categoryId' => [ 29 'name' => tra('Directory category identifier'), 30 'description' => tra('If set to a directory category identifier, only displays the sites in the specified directory category.') . " " . tr('Not set by default.'), 31 'profile_reference' => 'category', 32 ], 33 'more' => [ 34 'name' => tra('More'), 35 'description' => tra('If set to "y", displays a button labelled "More" that links to the directory.') . " " . tr('Not set by default.'), 36 ], 37 'desc' => [ 38 'name' => tra('Show description'), 39 'description' => tra('If set to "y", the description of the directory site appears.') . " " . tr('Default: "n".'), 40 'filter' => 'word', 41 ], 42 'maxdesc' => [ 43 'name' => tra('Maximum length of description'), 44 '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.'), 45 'filter' => 'int', 46 ] 47 48 ], 49 'common_params' => ['nonums', 'rows'] 50 ]; 51} 52 53/** 54 * @param $mod_reference 55 * @param $module_params 56 */ 57function module_directory_last_sites($mod_reference, $module_params) 58{ 59 global $prefs; 60 $smarty = TikiLib::lib('smarty'); 61 $tikilib = TikiLib::lib('tiki'); 62 if (isset($module_params['categoryId'])) { 63 global $dirlib; 64 include_once('lib/directory/dirlib.php'); 65 $ranking = $dirlib->dir_list_sites($module_params['categoryId'], 0, $mod_reference["rows"]); 66 } else { 67 $ranking = $tikilib->dir_list_all_valid_sites2(0, $mod_reference["rows"], 'created_desc', ''); 68 } 69 70 $smarty->assign('modLastdirSites', $ranking["data"]); 71 $smarty->assign('absurl', isset($module_params["absurl"]) ? $module_params["absurl"] : 'n'); 72 73 $smarty->assign('desc', isset($module_params['desc']) ? $module_params['desc'] : 'n'); 74 75 // only allow truncation if showing description 76 if ($module_params['desc'] != 'n') { 77 if ($module_params['maxdesc'] >= 1) { 78 $smarty->assign('maxdesc', $module_params['maxdesc']); 79 } 80 } 81} 82