You are here

function media_browser_plus_construct_dir_path in Media Browser Plus 7.2

Same name and namespace in other branches
  1. 7.3 media_browser_plus.module \media_browser_plus_construct_dir_path()
  2. 7 media_browser_plus.module \media_browser_plus_construct_dir_path()

Construct the path of a media_folder term.

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. Doesn't have a trailing slash.

13 calls to media_browser_plus_construct_dir_path()
MediaBrowserPlusTest::createTestFile in tests/media_browser_plus.test
Creates a test file.
MediaBrowserPlusTest::folderCreationHelper in tests/media_browser_plus.test
Helper to create a folder structure based on an given array.
MediaBrowserPlusTest::testFolderMovemet in tests/media_browser_plus.test
Test the ability to move folders.
media_browser_plus_folder_delete_submit in includes/media_browser_plus.folders.inc
@todo Document what this function is does.
media_browser_plus_folder_list_submit in includes/media_browser_plus.folders.inc
@todo Document what this function is does.

... See full list

File

./media_browser_plus.module, line 2029
Adds fields to the media browser forms for better UX

Code

function media_browser_plus_construct_dir_path($term = NULL) {
  $path = variable_get('file_default_scheme', 'public') . '://';
  if ($root_folder = variable_get('media_root_folder')) {
    $path .= $root_folder . '/';
  }
  $root_folder_term = media_browser_plus_get_media_root_folder();
  if ($term) {
    $parents = array_reverse(taxonomy_get_parents_all($term->tid));
    if (is_array($parents) && !empty($parents)) {
      foreach ($parents as $parent) {

        // @TODO Shouldn't we sanitize this?!? There can be special chars!
        $folder_name = $parent->name;
        if ($parent->tid != $root_folder_term->tid) {
          $path .= $folder_name . '/';
        }
      }
    }
  }
  return rtrim($path, '/');
}