Esempio n. 1
0
    $versions = $db->get_rows("\n    SELECT versions.*, \n      CASE WHEN versions.name = libraries.latest THEN 1 ELSE 0 END AS is_latest\n    FROM versions\n    JOIN libraries\n      ON versions.library = libraries.name\n    WHERE versions.library = ?\n    ORDER BY internal DESC", $model->data['id_lib']);
    foreach ($versions as $i => $ver) {
        // Get all version's dependencies
        $versions[$i]['dependencies'] = $db->get_rows("\n      SELECT libraries.title, libraries.name, versions.name AS version\n      FROM dependencies\n        LEFT JOIN versions\n          ON id_master = versions.id\n        LEFT JOIN libraries\n          ON versions.library = libraries.name\n      WHERE id_slave = ?\n      GROUP BY libraries.title\n      ORDER BY libraries.name", $ver['id']);
        // Get all version's slave dependencies
        $versions[$i]['slave_dependencies'] = $db->get_rows("\n      SELECT libr.name, libr.title, vers.name AS version\n      FROM versions\n      JOIN libraries\n        ON versions.library = libraries.name\n        AND versions.name = libraries.latest\n      JOIN dependencies \n        ON versions.id = dependencies.id_master\n      JOIN versions AS vers\n        ON dependencies.id_slave = vers.id\n      JOIN libraries AS libr\n        ON vers.library = libr.name\n      WHERE versions.id = ?\n      GROUP BY libr.name\n      ORDER BY libr.title COLLATE NOCASE ASC, vers.internal DESC", $ver['id']);
        // Make version's files TreeView
        $versions[$i]['files_tree'] = \bbn\x::make_tree((array) json_decode($ver['content']));
    }
    return $versions;
} else {
    if (!empty($model->data['folder']) && !empty(BBN_CDN_PATH)) {
        // Library path
        $lib_path = BBN_CDN_PATH . 'lib/' . $model->data['folder'];
        // Check if the library's subfolders are already inserted into db and use the first not included as version
        if (is_dir($lib_path) && ($dirs = \bbn\file\dir::get_dirs($lib_path))) {
            $ver = [];
            foreach ($dirs as $dir) {
                if (empty($db->select('versions', [], ['name' => basename($dir), 'library' => $model->data['folder']]))) {
                    array_push($ver, $dir);
                }
            }
            if (empty($ver)) {
                return ['error' => _("All library's versions (subfolders) are existing into database.")];
            }
        } else {
            return ['error' => _("The library's directory isn't existing or you don't have a version folder inserted.")];
        }
        // Make the tree data
        function tree($path, $ver_path, $ext = false)
        {
Esempio n. 2
0
         }
     }
 } else {
     // Get files and folders
     $path = $path . (empty($model->data['path']) ? '' : $model->data['path']);
     $ff = \bbn\file\dir::get_files($path, 1);
     foreach ($ff as $f) {
         if (is_dir($f)) {
             // Folder name
             $fn = basename($f);
             // Add folder to array
             $folders[$fn] = ['path' => (empty($model->data['path']) ? '' : $model->data['path'] . '/') . $fn, 'name' => $fn, 'has_index' => \bbn\file\dir::has_file($f, 'index.php', 'index.html', 'index.htm') ? 1 : false, 'dir' => $current, 'parenthood' => true, 'is_svg' => false, 'is_viewable' => false, 'is_image' => false, 'default' => false, 'icon' => "folder-icon", 'bcolor' => $dir['bcolor'], 'type' => "dir"];
             if (empty($model->data['onlydir'])) {
                 $folders[$fn]['is_parent'] = count(\bbn\file\dir::get_files($f, 1)) > 0;
             } else {
                 $folders[$fn]['is_parent'] = count(\bbn\file\dir::get_dirs($f)) > 0;
             }
         } else {
             if (empty($model->data['onlydir']) && !in_array(\bbn\str::file_ext($f), $excluded)) {
                 // File extension
                 $ext = \bbn\str::file_ext($f);
                 // Filename
                 $fn = \bbn\str::file_ext($f, 1)[0];
                 // Add file
                 $files[$f] = ['path' => (empty($model->data['path']) ? '' : $model->data['path'] . '/') . basename($f), 'name' => $fn, 'has_index' => false, 'is_parent' => false, 'parenthood' => false, 'dir' => $current, 'is_svg' => $ext === 'svg', 'is_viewable' => in_array($ext, $file_check['viewables']) && $ext !== 'svg' ? true : false, 'is_image' => in_array($ext, $file_check['images']), 'default' => false, 'ext' => in_array($ext, $ext_icons) ? $ext : 'default', 'bcolor' => $dir['bcolor'], 'type' => "file"];
                 $files[$f]['default'] = !$files[$f]['is_svg'] && !$files[$f]['is_viewable'] && !$files[$f]['is_image'] ? true : false;
             }
         }
     }
 }
 if (ksort($folders, SORT_STRING | SORT_FLAG_CASE) && ksort($files, SORT_STRING | SORT_FLAG_CASE)) {