Example #1
0
 public function actionIndex($path = null)
 {
     $_GET['currentDir'] = RepoManager::getModuleDir();
     if (isset($_GET['dir'])) {
         $dir = trim(trim($_GET['dir'], '/'), '\\');
         $_GET['currentDir'] = $_GET['currentDir'] . DIRECTORY_SEPARATOR . $dir;
     }
     $this->renderForm('Repo');
 }
Example #2
0

    <div class="modal-dialog" style="z-index:1100;">
        <div class="modal-content">
            <div class="modal-body">

                <div class="well well-sm" style="margin-bottom:5px;font-size:12px;"><i class="fa fa-folder-open-o"></i> {{ path}}</div>
                <div style="border:1px solid #ddd;">
                    <div oc-lazy-load="{name: 'ngGrid', files: [
                         '<?php 
echo Yii::app()->controller->staticUrl('/js/lib/ng-grid.debug.js');
?>
'
                         , '<?php 
echo Yii::app()->controller->staticUrl('/css/ng-grid.css');
?>
' ]}">
                        <div ng-if="gridReady" ng-grid="gridOptions" style="height:300px;"></div>
                    </div>
                </div>
                <div class="clearfix">
                </div>
            </div>
        </div>
    </div>
    <data name="repodata" class="hide">
        <?php 
echo json_encode(RepoManager::model()->browse(RepoManager::getModuleDir())['item']);
?>
    </data>
</div>
Example #3
0
 public function browse($dir = "")
 {
     if (!is_dir(Setting::get('repo.path'))) {
         mkdir(Setting::get('repo.path'));
     }
     $originaldir = $dir;
     $isRelativePath = false;
     if ($dir == "" || $dir == DIRECTORY_SEPARATOR) {
         $dir = $this->repoPath;
         $parent = "";
     } else {
         if (strpos($this->repoPath, $dir) === 0) {
             $isRelativePath = true;
         }
         $dir = $this->repoPath . DIRECTORY_SEPARATOR . trim($dir, DIRECTORY_SEPARATOR);
         $parent = dirname($dir);
     }
     if (!realpath($dir) && $isRelativePath) {
         $dir = getcwd() . DIRECTORY_SEPARATOR . $dir;
     }
     $list = [];
     if (!is_dir($dir)) {
         if (RepoManager::getModuleDir() == $originaldir) {
             mkdir($dir);
         } else {
             return false;
         }
     }
     ## listing dir
     $list = [];
     if ($handle = opendir($dir)) {
         $count = 0;
         while (false !== ($entry = readdir($handle))) {
             if ($entry != "." && $entry != "..") {
                 $path = RepoManager::resolve($dir . DIRECTORY_SEPARATOR . $entry);
                 $perm = RepoManager::getPerms($path);
                 $size = filesize($path);
                 $path = $this->relativePath($dir . DIRECTORY_SEPARATOR . $entry);
                 $path = substr($path, strlen($this->repoPath));
                 $list[] = ['name' => $entry, 'type' => $perm[0] == 'd' ? "dir" : "." . substr($entry, strrpos($entry, '.') + 1), 'size' => $size, 'downloadPath' => base64_encode($path), 'path' => $path];
                 $count++;
             }
         }
         closedir($handle);
     }
     usort($list, ['RepoManager', 'sortItem']);
     $count = count($list);
     if ($originaldir != "" && $originaldir != RepoManager::getModuleDir()) {
         $parent = $this->relativePath($parent);
         $parent = substr($parent, strlen($this->repoPath));
     } else {
         $parent = "";
     }
     $detail = ['parent' => $parent, 'path' => $this->relativePath($dir), 'type' => 'dir', 'item' => $list, 'count' => $count];
     return $detail;
 }