/**
  * Options getter
  *
  * @return array
  */
 public function toOptionArray()
 {
     $url = Mage::getBaseDir('media') . '/banner_images/default';
     function dirImages($dir)
     {
         $d = dir($dir);
         //Open Directory
         while (false !== ($file = $d->read())) {
             // $extension = substr($file, strrpos($file, '.')); // Gets the File Extension
             // echo $file;
             $extension = explode(".", $file);
             //print_r($extension);
             $extensionsdir = strtolower($extension[1]);
             // echo $extensionsdir;
             if ($extensionsdir == "jpg" || $extensionsdir == "jpeg" || $extensionsdir == "gif" | $extensionsdir == "png") {
                 // Extensions Allowed
                 $images[$file] = $file;
             }
             // Store in Array
         }
         $d->close();
         return $images;
     }
     $array = dirImages($url);
     function DateCmp($a, $b)
     {
         return $a[1] < $b[1] ? -1 : 0;
     }
     function SortByDate(&$Files)
     {
         usort($Files, 'DateCmp');
     }
     SortByDate($array);
     //To list in the select box.
     foreach ($array as $key => $image) {
         $selectvalue[] = array('value' => $image, 'label' => Mage::helper('adminhtml')->__($image));
     }
     return $selectvalue;
 }
function GetMessageArray($vm_folder, $vm_mailbox)
{
    // Get all messages in a folder
    // also convert the messages to MP3 during the loop
    global $g_debug;
    global $g_voicemail_context_path;
    $arr = array();
    // Get the paths set up
    $voicemail_path = $g_voicemail_context_path . $vm_mailbox . "/" . $vm_folder . "/";
    // Open the voicemail directory and look for files
    if (is_dir($voicemail_path)) {
        $dir = dir($voicemail_path);
        // **********************************************************************
        // Load the files for this directory, then sort (by Date)
        // **********************************************************************
        // Get an array of files and unix timestamp
        $arr_vm_files = GetMessages($voicemail_path);
        // Sort that array by the timestamp
        SortByDate($arr_vm_files);
        // Get the size of the array of files
        $array_size = sizeof($arr_vm_files);
        // If there are no files, show a message, otherwise show the header
        if ($array_size > 0) {
            // Loop through the array
            for ($i = $array_size - 1; $i >= 0; $i--) {
                // Get the file name
                $file = $arr_vm_files[$i][0];
                $loopcount = 0;
                if ($file != "." && $file != "..") {
                    // We're looking for the txt files as the proof that there is a voicemail here.
                    // Then we work from there...
                    if (strpos($file, ".txt") != FALSE) {
                        // We got a .txt file (which is like our INI file)
                        // Read INI File
                        $ini_array = parse_ini_file($voicemail_path . $file, false);
                        // Strip extension from file name
                        $file_noext = substr($file, 0, strpos($file, ".txt"));
                        // Add .wav and .mp3 on to file name
                        $file_wav = $file_noext . ".wav";
                        $file_mp3 = $file_noext . ".mp3";
                        // Return a better date
                        $origdate = str_replace("  ", " ", $ini_array['origdate']);
                        list($day, $month, $date, $time, $ampm, $tz, $year) = split(' ', $origdate);
                        $origdate_unix = strtotime("{$month} {$date} {$year} {$time} {$ampm}");
                        //$datetimebetter = date("D M j Y, g:i a", $origdate_unix); Sun Feb 02 2008
                        $datetimebetter = date("M j Y, g:i a", $origdate_unix);
                        $arr[$i] = array('file' => $file_noext, 'calleridname' => CallerIdGetName($ini_array['callerid']), 'calleridnumber' => CallerIdGetNumber($ini_array['callerid']), 'datetime' => $ini_array['origdate'], 'datetimebetter' => $datetimebetter, 'duration' => $ini_array['duration']);
                        // **********************************************************************
                        // See if there is a MP3 file. If not, create one.
                        // **********************************************************************
                        if (!file_exists($voicemail_path . $file_noext . ".mp3")) {
                            // Create a standard wav file
                            //$cmd = "sox ".$voicemail_path.$file_noext.".WAV -r 8000 -c 1 -s ".$voicemail_path.$file_noext.".wav";
                            //echo($cmd . "<br />\n");
                            //exec($cmd);
                            // Create a mp3 file from the wav file
                            $cmd = "lame --resample 11.025 " . $voicemail_path . $file_noext . ".wav " . $voicemail_path . $file_noext . ".mp3";
                            //echo($cmd . "<br />\n");
                            exec($cmd);
                            // Delete the wav file
                            //$cmd = "unlink ".$voicemail_path.$file_noext.".wav";
                            //echo($cmd . "<br />\n");
                            //exec($cmd);
                            // Touch the mp3 file to set the timestamp to match the .wav file.
                            // This is so the auto cleanup script will work.
                            // To set the date to 7:30 am 1st October 2015
                            // TOUCH /t 2015 10 01 07 30 00 MyFile.txt
                            $origdate = $ini_array['origdate'];
                            // Fix a bug in the asterisk date. It puts an extra space in
                            $origdate = str_replace("  ", " ", $origdate);
                            list($day, $month, $date, $time, $ampm, $tz, $year) = split(' ', $origdate);
                            $monthnumber = MonthToMonthNumber($month);
                            if (strlen($date) == 1) {
                                $date = "0" . $date;
                            }
                            // Pad a 0 to the beginning of date
                            list($hour, $minute, $second) = split(":", $time);
                            if ($ampm == "PM") {
                                $hour = $hour + 12;
                            }
                            // Compensate for PM
                            $touchcmd = "touch -t " . $year . $monthnumber . $date . $hour . $minute . " " . $voicemail_path . $file_noext . ".mp3";
                            exec($touchcmd);
                        }
                    }
                    $loopcount++;
                }
                // end if . or ..
            }
            // end while
            $dir->close();
        }
    }
    return $arr;
}