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 * \brief Smarty modifier plugin to add user's country flag 15 * 16 * - type: modifier 17 * - name: countryflag 18 * - purpose: Returns a specified user's country flag 19 * 20 * @author 21 * @param string 22 * @return string 23 * 24 * Example: {$userinfo.login|countryflag} 25 */ 26 27function smarty_modifier_countryflag($user) 28{ 29 global $tikilib; 30 $flag = $tikilib->get_user_preference($user, 'country', 'Other'); 31 if ($flag == 'Other' || empty($flag)) { 32 return ''; 33 } 34 return "<img alt='" . tra(str_replace('_', ' ', $flag)) . "' src='img/flags/" . str_replace(' ', '_', $flag) . 35 ".png' title='" . tra(str_replace('_', ' ', $flag)) . "' />"; 36} 37