function media_browser_plus_construct_dir_path in Media Browser Plus 7.3
Same name and namespace in other branches
- 7 media_browser_plus.module \media_browser_plus_construct_dir_path()
- 7.2 media_browser_plus.module \media_browser_plus_construct_dir_path()
Construct the path of a media_folder term without scheme.
Always returns the same path if the filesystem handling is disabled.
Parameters
object|NULL $term: Containing term id and term name. If left empty the root folder will be returned.
Return value
string The path to the requested folder. Without the scheme and without a trailing slash.
20 calls to media_browser_plus_construct_dir_path()
- MediaBrowserPlusBypassTest::testBypassDueProperty in tests/
media_browser_plus.mbp_bypass.test - Test the ability to bypass folder processing setting mbp_bypass property.
- MediaBrowserPlusTest::testFileMovement in tests/
media_browser_plus.test - Test the ability to delete folders.
- MediaBrowserPlusTest::testFolderDeletion in tests/
media_browser_plus.test - Test the ability to delete folders.
- MediaBrowserPlusTest::testFolderDeletionWithUsedFiles in tests/
media_browser_plus.test - Test the ability to delete folders when files are used.
- MediaBrowserPlusTest::testFolderMovemet in tests/
media_browser_plus.test - Test the ability to move folders.
File
- ./
media_browser_plus.module, line 409 - Media Browser Plus - enhanced file management functions.
Code
function media_browser_plus_construct_dir_path($term = NULL) {
$path = '';
if ($root_folder = variable_get('media_root_folder')) {
$path = $root_folder;
}
// Always return the path to the defined media_root_folder if the folder
// handling is disabled.
if (!variable_get('media_browser_plus_filesystem_folders', TRUE)) {
return trim($path, '/');
}
// $root_folder_term can be FALSE during the installation of the module.
$root_folder_term = media_browser_plus_get_media_root_folder();
if ($term && $root_folder_term && $term->tid != $root_folder_term->tid) {
$parents = array_reverse(taxonomy_get_parents_all($term->tid));
array_pop($parents);
if (is_array($parents) && !empty($parents)) {
foreach ($parents as $parent) {
if ($parent->tid != $root_folder_term->tid) {
if (function_exists('transliteration_clean_filename')) {
$parent->name = transliteration_clean_filename($parent->name);
}
$path = file_create_filename($parent->name, $path);
}
}
}
if (function_exists('transliteration_clean_filename')) {
$term->name = transliteration_clean_filename($term->name);
}
$path = file_create_filename($term->name, $path);
}
$path = trim($path, '/');
return $path;
}