I'm trying to add a link to each slideshow image in joomla, but I've got stuck at getting the filenames from the photos without the extensions. 
This is the related code:

```
<?php
$imgrootdir = "templates/".$this->template."/images/";
if ($headerType == "0" || $headerType == "2") {
  echo '<img src="'.$imgrootdir.$myimage.'" alt="" />';
} elseif ($headerType == "1" || $headerType == "3") {
  $picDir= $imgrootdir.$myfolder;
  $picDir .="/";
  if (file_exists($picDir) && is_readable($picDir)) {
    $folder = opendir($picDir);
  } else {
    echo '<div class="message">Error! Please check the parameter settings and make sure you have entered a valid image folder path!</div>';
    return;
  }
  $allowed_types = array("jpg","JPG","jpeg","JPEG","gif","GIF","png","PNG","bmp","BMP");
  $index = array();
  while ($file = readdir ($folder)) {
    if(in_array(substr(strtolower($file), strrpos($file,".") + 1),$allowed_types)) {array_push($index,$file);}
  }
  closedir($folder);
  if($display == 'random') {shuffle($index);} else {sort($index);}

  foreach ($index as $file) {
    $finalpath = $picDir.$file;  
    // output
    echo '<a href="http://testcl.net46.net/index.php/''"><img src="'.$finalpath.'" alt="'.$file.'" /></a>';

  }
  if ($showControl) echo '<div id="slcontrol"> </div>';
}
?>

```