- $OUT = ''; $ral = array();
- $basePath = sprintf("%stemplates/%s/html/rallye/", constant('PATH'), getLanguage());
- $dir = opendir($basePath) or mxchange_die(sprintf("Cannot open dir %s.", $basePath));
- while ($read = readdir($dir)) {
- // If it is no dir (so a file)
- if (!isDirectory($basePath.$read)) {
- // Accept only templates matching with rallye_????.tpl.xx
- if (eregi("^rallye_.*\.tpl", $read)) {
- $read = substr($read, 7, strpos($read, '.') - 7);
- // Accept only template names between 1 and 255 chars length
- if ((strlen($read) < 256) && (!empty($read))) $ral[] = $read;
- } // END - if
- } // END - if
+ $basePath = sprintf("templates/%s/html/rallye/", getLanguage());
+
+ // Read the directory
+ $templates = getArrayFromDirectory($basePath, 'rallye_', false, true, array(), '.tpl');
+
+ // And walk through
+ foreach ($templates as $read) {
+ // Cut prefix and extension away
+ $read = substr($read, 7, strpos($read, '.') - 7);
+
+ // Accept only template names between 1 and 255 chars length
+ if ((strlen($read) < 256) && (!empty($read))) $ral[] = $read;