method info documentation in bbn\Cdn\Library

Returns all the informations stored about a library.

Example

$info = $lib->info('bbn-vue'); // { // "name": "bbn-vue", // "fname": "bbn.vue", // "title": "bbn-vue", // "latest": "2.0.2", // "website": "https://bbn.io/bbn-vue", // "last_update": "2020-06-22 13:47:01", // "last_check": "2020-06-22 13:47:01", // "id": 210, // "version": "2.0.2", // "content": { // "files": [ // "src/vars.js", // "src/methods.js", // "src/mixins/basic.js", // "src/mixins/empty.js", // "src/mixins/dimensions.js", // "src/mixins/position.js", // "src/mixins/dropdown.js", // "src/mixins/keynav.js", // "src/mixins/toggle.js", // "src/mixins/localStorage.js", // "src/mixins/data.js", // "src/mixins/dataEditor.js", // "src/mixins/events.js", // "src/mixins/list.js", // "src/mixins/memory.js", // "src/mixins/input.js", // "src/mixins/resizer.js", // "src/mixins/close.js", // "src/mixins/field.js", // "src/mixins/view.js", // "src/mixins/observer.js", // "src/mixins/keepCool.js", // "src/mixins/url.js", // "src/mixins.js", // "src/defaults.js", // "src/init.js", // ], // "lang": [ // ], // "theme_files": [ // ], // }, // "internal": 0, // "prepend": [ // ], // } function(string $library) { $params = explode('|', $library); $lib = array_shift($params); $cfg = [ 'table' => 'libraries', 'fields' => [ 'libraries.name', 'libraries.fname', 'libraries.title', 'libraries.latest', 'libraries.website', 'libraries.last_update', 'libraries.last_check', 'libraries.git', 'libraries.npm', 'libraries.mode', 'versions.id', 'versions.content', 'versions.internal', 'version' => 'versions.name' ], 'join' => [ [ 'table' => 'versions', 'on' => [ 'conditions' => [ [ 'field' => 'versions.library', 'operator' => 'LIKE', 'exp' => '"libraries"."name"' ] ] ] ] ], 'where' => [ 'logic' => 'AND', 'conditions' => [ [ 'field' => 'libraries.name', 'operator' => '=', 'value' => $lib ] ] ] ]; if (!empty($params[0]) && ($params[0] !== 'latest')) { $cfg['where']['conditions'][] = [ 'field' => 'versions.name', 'operator' => '=', 'value' => $params[0] ]; } else { $cfg['where']['conditions'][] = [ 'field' => 'versions.name', 'operator' => '=', 'exp' => '"libraries"."latest"' ]; } // We take all the info from the database if ($info = $this->db->rselect($cfg)) { // Most of the info is in the JSON field, content $info['content'] = json_decode($info['content']); // The files from which the content will be prepended to corresponding files $info['prepend'] = []; if ($info['git']) { if (strpos($info['git'], 'https://github.com/') === 0) { $info['git'] = substr($info['git'], strlen('https://github.com/')); if (substr($info['git'], -4) === '.git') { $info['git'] = substr($info['git'], 0, -4); } } else { $info['git'] = null; } } // If there are theme files we want to add them to the list of files if (!empty($info['content']->theme_files) && isset($info['content']->files)) { // Parameters of the library sent through the URL if (!empty($params[1])) { $ths = explode('!', $params[1]); } elseif (isset($info['content']->default_theme)) { $ths = [$info['content']->default_theme]; } if (!empty($ths)) { foreach ($ths as $th) { if (!empty($info['content']->theme_prepend)) { foreach ($info['content']->theme_files as $tf) { foreach ($info['content']->files as $f) { /** @todo Remove(bool)! */ if (substr($f, -4) === 'less') { if (X::indexOf($tf, '%s') > -1) { $info['prepend'][$f][] = sprintf(str_replace('%s', '%1$s', $tf), $th); } else { $info['prepend'][$f][] = $tf; } } } } } else { foreach ($info['content']->theme_files as $tf) { if (X::indexOf($tf, '%s') > -1) { $info['content']->files[] = sprintf(str_replace('%s', '%1$s', $tf), $th); } else { $info['content']->files[] = $tf; } } } } } } // Themes if (!isset($ths) && isset($info['content']->themes)) { if (isset($params[1], $info['content']->themes->$params[1])) { $info['theme'] = $params[1]; } elseif (isset($info['content']->default_theme)) { $info['theme'] = $info['content']->default_theme; } if (isset($info['theme'], $info['content']->themes->{$info['theme']})) { if (!is_array($info['content']->themes->{$info['theme']})) { $info['content']->themes->$info['theme'] = [$info['content']->themes->$info['theme']]; } $info['content']->files = array_merge($info['content']->files, $info['content']->themes->$info['theme']); } } return $info; } return null; }

Returns all the informations stored about a library. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.