S3Browser::getBreadcrumb PHP Method

getBreadcrumb() public static method

Returns directory data for all levels of the given path to be used when displaying a breadcrumb.
public static getBreadcrumb ( string $path = '/' ) : array
$path string
return array
    public static function getBreadcrumb($path = '/')
    {
        if ($path == '/') {
            return array('/' => '');
        }
        $path = trim($path, '/');
        // so we don't get nulls when exploding
        $parts = explode('/', $path);
        $crumbs = array('/' => '');
        for ($i = 0; $i < count($parts); $i++) {
            $crumbs[$parts[$i]] = implode('/', array_slice($parts, 0, $i + 1)) . '/';
        }
        return $crumbs;
    }

Usage Example

Esempio n. 1
0
  <div id="contents">
    
    <div class="breadcrumb">
      Index of 
      <ul>
        <li>
          <a href="<?php 
echo $config['base-path'];
?>
/"><?php 
echo $config['bucket-name'];
?>
/</a>
        </li>
        <?php 
foreach (S3Browser::getBreadcrumb($dir) as $key => $name) {
    ?>
        <?php 
    if ($key != '/') {
        ?>
        <li><a href="<?php 
        echo $config['base-path'];
        ?>
/<?php 
        echo $name;
        ?>
"><?php 
        echo $key;
        ?>
/</a></li>
        <?php