public function testGetFolderPath()
 {
     // We first get the base path
     $base = filemanager_helpers_FileUtils::getBasePath();
     $filePath = $base . 'Animals/puss-in-boots.png';
     $folderPath = filemanager_helpers_FileUtils::getFolderPath($filePath);
     $this->assertEquals($folderPath, '/Animals/');
     // It does not exist!
     $filePath = $base . 'Animals/hippo-in-boots.png';
     $folderPath = filemanager_helpers_FileUtils::getFolderPath($filePath);
     $this->assertNull($folderPath);
     $base = 'C:\\wamp3\\www\\taotrunk\\filemanager\\views\\data\\';
     $filePath = $base . 'Animals/chicken.png';
     $folderPath = filemanager_helpers_FileUtils::getFolderPath($filePath, $base, false);
     $this->assertEquals($folderPath, '/Animals/');
     // Test a linux like test.
     $base = '/var/www/taoinstall/filemanager/views/data/';
     $filePath = $base . 'Animals/puss-in-boots.png';
     $folderPath = filemanager_helpers_FileUtils::getFolderPath($filePath, $base, false);
     $this->assertEquals($folderPath, '/Animals/');
     $filePath = $base . 'puss-in-boots.png';
     $folderPath = filemanager_helpers_FileUtils::getFolderPath($filePath, $base, false);
     $this->assertEquals($folderPath, '/');
 }
 /**
  * get the fileInfo
  *
  * @see Module::getData()
  * @author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu}
  */
 public function getInfo()
 {
     $response = array();
     if ($this->hasRequestParameter('file')) {
         $relUrl = urldecode($this->getRequestParameter('file'));
         // convert url to file path
         $file = str_replace('/', DIRECTORY_SEPARATOR, $relUrl);
         if (tao_helpers_File::securityCheck($file, true)) {
             $path = filemanager_helpers_FileUtils::cleanConcat(array(filemanager_helpers_FileUtils::getBasePath(), $file));
             $mimeType = filemanager_helpers_FileUtils::getMimeType($path);
             if ($this->isMimeTypeAllowed($mimeType)) {
                 if (file_exists($path) && is_readable($path)) {
                     $width = $height = '';
                     if (strpos($mimeType, 'image/') === 0) {
                         $this->setData('isImage', true);
                         $size = getimagesize($path);
                         $width = $size[0];
                         $height = $size[1];
                     } elseif (strpos($mimeType, 'video/') === 0) {
                         //@todo: get frame width and height
                     }
                     $response['width'] = $width;
                     $response['height'] = $height;
                     $response['type'] = $mimeType;
                     $response['url'] = filemanager_helpers_FileUtils::getUrl($file);
                     // try to get the folder path of the file.
                     $folderPath = filemanager_helpers_FileUtils::getFolderPath($path);
                     if (!empty($folderPath)) {
                         $response['dir'] = $folderPath;
                     }
                 }
             }
         }
     }
     print json_encode($response);
 }