From b4e61290f1786bf30790695f9ed7d58d042c761e Mon Sep 17 00:00:00 2001 From: Nate Jones Date: Mon, 25 Aug 2014 18:01:26 +0000 Subject: [PATCH] Function: Moved recur_sounds_dir() to functions.php, removed from ivr_menu_edit.php and conference_center_edit.php. --- .../conference_center_edit.php | 49 +-------- app/ivr_menu/ivr_menu_edit.php | 49 +-------- resources/functions.php | 103 +++++++++++++----- 3 files changed, 80 insertions(+), 121 deletions(-) diff --git a/app/conference_centers/conference_center_edit.php b/app/conference_centers/conference_center_edit.php index 3dcba26d7e..b425e73105 100644 --- a/app/conference_centers/conference_center_edit.php +++ b/app/conference_centers/conference_center_edit.php @@ -277,54 +277,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) //function to show the list of sound files - function recur_sounds_dir($dir) { - global $dir_array; - global $dir_path; - $dir_list = opendir($dir); - while ($file = readdir ($dir_list)) { - if ($file != '.' && $file != '..') { - $newpath = $dir.'/'.$file; - $level = explode('/',$newpath); - if (substr($newpath, -4) == ".svn") { - //ignore .svn dir and subdir - } - else { - if (is_dir($newpath)) { //directories - recur_sounds_dir($newpath); - } - else { //files - if (strlen($newpath) > 0) { - //make the path relative - $relative_path = substr($newpath, strlen($dir_path), strlen($newpath)); - //remove the 8000-48000 khz from the path - $relative_path = str_replace("/8000/", "/", $relative_path); - $relative_path = str_replace("/16000/", "/", $relative_path); - $relative_path = str_replace("/32000/", "/", $relative_path); - $relative_path = str_replace("/48000/", "/", $relative_path); - //remove the default_language, default_dialect, and default_voice (en/us/callie) from the path - $file_array = explode( "/", $relative_path ); - $x = 1; - $relative_path = ''; - foreach( $file_array as $tmp) { - if ($x == 5) { $relative_path .= $tmp; } - if ($x > 5) { $relative_path .= '/'.$tmp; } - $x++; - } - //add the file if it does not exist in the array - if (isset($dir_array[$relative_path])) { - //already exists - } - else { - //add the new path - if (strlen($relative_path) > 0) { $dir_array[$relative_path] = '0'; } - } - } - } - } - } - } - closedir($dir_list); - } + // moved to functions.php //pre-populate the form if (count($_GET)>0 && $_POST["persistformvar"] != "true") { diff --git a/app/ivr_menu/ivr_menu_edit.php b/app/ivr_menu/ivr_menu_edit.php index 2fa9acbd31..d47030b30d 100644 --- a/app/ivr_menu/ivr_menu_edit.php +++ b/app/ivr_menu/ivr_menu_edit.php @@ -46,54 +46,7 @@ else { $log->log("debug", check_str($_POST["ivr_menu_uuid"])); //function to show the list of sound files - function recur_sounds_dir($dir) { - global $dir_array; - global $dir_path; - $dir_list = opendir($dir); - while ($file = readdir ($dir_list)) { - if ($file != '.' && $file != '..') { - $newpath = $dir.'/'.$file; - $level = explode('/',$newpath); - if (substr($newpath, -4) == ".svn") { - //ignore .svn dir and subdir - } - else { - if (is_dir($newpath)) { //directories - recur_sounds_dir($newpath); - } - else { //files - if (strlen($newpath) > 0) { - //make the path relative - $relative_path = substr($newpath, strlen($dir_path), strlen($newpath)); - //remove the 8000-48000 khz from the path - $relative_path = str_replace("/8000/", "/", $relative_path); - $relative_path = str_replace("/16000/", "/", $relative_path); - $relative_path = str_replace("/32000/", "/", $relative_path); - $relative_path = str_replace("/48000/", "/", $relative_path); - //remove the default_language, default_dialect, and default_voice (en/us/callie) from the path - $file_array = explode( "/", $relative_path ); - $x = 1; - $relative_path = ''; - foreach( $file_array as $tmp) { - if ($x == 5) { $relative_path .= $tmp; } - if ($x > 5) { $relative_path .= '/'.$tmp; } - $x++; - } - //add the file if it does not exist in the array - if (isset($dir_array[$relative_path])) { - //already exists - } - else { - //add the new path - if (strlen($relative_path) > 0) { $dir_array[$relative_path] = '0'; } - } - } - } - } - } - } - closedir($dir_list); - } + // moved to functions.php //action add or update if (strlen($_REQUEST["id"]) > 0) { diff --git a/resources/functions.php b/resources/functions.php index 3fbb06c87d..d3a66476a5 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -988,33 +988,86 @@ function number_pad($number,$n) { } // validate email address syntax -if(!function_exists('validate_email')) { - function valid_email($email) { - $regex = '/^[A-z0-9][\w.-]*@[A-z0-9][\w\-\.]+\.[A-z0-9]{2,6}$/'; - if ($email != "" && preg_match($regex, $email) == 0) { - return false; // email address does not have valid syntax - } - else { - return true; // email address has valid syntax - } - } -} - -// ellipsisnicely truncate long text -if(!function_exists('ellipsis')) { - function ellipsis($string, $max_characters, $preserve_word = true) { - if ($max_characters+$x >= strlen($string)) { return $string; } - if ($preserve_word) { - for ($x = 0; $x < strlen($string); $x++) { - if ($string{$max_characters+$x} == " ") { - return substr($string,0,$max_characters+$x)." ..."; - } - else { continue; } + if(!function_exists('validate_email')) { + function valid_email($email) { + $regex = '/^[A-z0-9][\w.-]*@[A-z0-9][\w\-\.]+\.[A-z0-9]{2,6}$/'; + if ($email != "" && preg_match($regex, $email) == 0) { + return false; // email address does not have valid syntax + } + else { + return true; // email address has valid syntax } } - else { - return substr($string,0,$max_characters)." ..."; + } + +// ellipsis nicely truncate long text + if(!function_exists('ellipsis')) { + function ellipsis($string, $max_characters, $preserve_word = true) { + if ($max_characters+$x >= strlen($string)) { return $string; } + if ($preserve_word) { + for ($x = 0; $x < strlen($string); $x++) { + if ($string{$max_characters+$x} == " ") { + return substr($string,0,$max_characters+$x)." ..."; + } + else { continue; } + } + } + else { + return substr($string,0,$max_characters)." ..."; + } } } -} + +//function to show the list of sound files + if (!function_exists('recur_sounds_dir')) { + function recur_sounds_dir($dir) { + global $dir_array; + global $dir_path; + $dir_list = opendir($dir); + while ($file = readdir ($dir_list)) { + if ($file != '.' && $file != '..') { + $newpath = $dir.'/'.$file; + $level = explode('/',$newpath); + if (substr($newpath, -4) == ".svn") { + //ignore .svn dir and subdir + } + else { + if (is_dir($newpath)) { //directories + recur_sounds_dir($newpath); + } + else { //files + if (strlen($newpath) > 0) { + //make the path relative + $relative_path = substr($newpath, strlen($dir_path), strlen($newpath)); + //remove the 8000-48000 khz from the path + $relative_path = str_replace("/8000/", "/", $relative_path); + $relative_path = str_replace("/16000/", "/", $relative_path); + $relative_path = str_replace("/32000/", "/", $relative_path); + $relative_path = str_replace("/48000/", "/", $relative_path); + //remove the default_language, default_dialect, and default_voice (en/us/callie) from the path + $file_array = explode( "/", $relative_path ); + $x = 1; + $relative_path = ''; + foreach( $file_array as $tmp) { + if ($x == 5) { $relative_path .= $tmp; } + if ($x > 5) { $relative_path .= '/'.$tmp; } + $x++; + } + //add the file if it does not exist in the array + if (isset($dir_array[$relative_path])) { + //already exists + } + else { + //add the new path + if (strlen($relative_path) > 0) { $dir_array[$relative_path] = '0'; } + } + } + } + } + } + } + closedir($dir_list); + } + } + ?>