Back to PhocaGalleryFile class

Method getTitleFromFile

public static
getTitleFromFile
(mixed &$filename, mixed $displayExt = 0)

Method getTitleFromFile - Source code

public static function getTitleFromFile(&$filename, $displayExt = 0)
{
    $filename = str_replace('//', '/', $filename);
    $filename = str_replace('\\', '/', $filename);
    $folderArray = explode('/', $filename);
    // Explode the filename (folder and file name)
    $countFolderArray = count($folderArray);
    // Count this array
    $lastArrayValue = $countFolderArray - 1;
    // The last array value is (Count array - 1)
    $title = new CMSObject();
    $title->with_extension = $folderArray[$lastArrayValue];
    $title->without_extension = PhocaGalleryFile::removeExtension($folderArray[$lastArrayValue]);
    if ($displayExt == 1) {
        return $title->with_extension;
    } else {
        if ($displayExt == 0) {
            return $title->without_extension;
        } else {
            return $title;
        }
    }
}