This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/modules/core/list_menu_files.inc.php
2011-05-03 09:49:04 +10:00

88 lines
2.5 KiB
PHP

<?php
/**
* AgileBill - Open Billing Software
*
* This body of work is free software; you can redistribute it and/or
* modify it under the terms of the Open AgileBill License
* License as published at http://www.agileco.com/agilebill/license1-4.txt
*
* Originally authored by Tony Landis, AgileBill LLC
*
* Recent modifications by Deon George
*
* @author Deon George <deonATleenooksDOTnet>
* @copyright 2009 Deon George
* @link http://osb.leenooks.net
*
* @link http://www.agileco.com/
* @copyright 2004-2008 Agileco, LLC.
* @license http://www.agileco.com/agilebill/license1-4.txt
* @author Tony Landis <tony@agileco.com>
* @package AgileBill
* @subpackage Smarty
*/
/**
* SMARTY template helper - list files
*/
function list_menu_files($id,$name,$default,$path,$pre,$ext,$class) {
global $C_translate;
switch ($path) {
case 'product_cat': $path = sprintf('%s%s/blocks/product_cat/',PATH_THEMES,DEF_THEME_N); break;
case 'whois_plugin': $path = sprintf('%s/whois/',PATH_PLUGINS); break;
case 'product': $path = sprintf('%s/product/',PATH_PLUGINS); break;
case 'e911': $path = sprintf('%s/e911/',PATH_PLUGINS); break;
case 'provision_plugin': $path = sprintf('%s/provision/',PATH_PLUGINS); break;
case 'affiliate_plugin': $path = sprintf('%s/affiliate/',PATH_PLUGINS); break;
case 'checkout_plugin': $path = sprintf('%s/checkout/',PATH_PLUGINS); break;
case 'theme': $path = PATH_THEMES; break;
case 'language': $path = sprintf('%s/core/',PATH_LANGUAGE); break;
}
$dir = opendir($path);
while ($file_name = readdir($dir)) {
$display = true;
if (in_array($file_name,array('.','..')))
continue;
if (! empty($ext)) {
$cute = preg_replace("/{$ext}$/",'',$file_name);
if (! preg_match("/{$ext}$/",$file_name))
$display = false;
}
if (! empty($pre)) {
$cute = preg_replace("/^{$pre}/",'',$cute);
if (! preg_match("/^{$pre}/",$file_name))
$display = false;
}
if ($display)
$arr[$cute] = preg_replace('/_/',' ',$cute);
}
asort($arr);
$return = sprintf('<select id="%s%s" name="%s" class="%s">',$id ? $name.'_' : $name,$id,$name,$class);
if ($id == 'all' || $default == 'all')
$return .= '<option value="" selected="selected">&nbsp;</option>';
if (! count($arr))
$return = $C_translate->translate('lists_none_defined');
else {
foreach ($arr as $key => $value)
$return .= sprintf('<option value="%s"%s>%s</option>',$key,($default == $key) ? ' selected="selected"' : '',$value);
$return .= '</select>';
}
echo $return;
}
?>