/** * @throws \Exception */ public function retrieve() { /** * Check get vars */ $need = Core::checkRequiredGetVars("need") ? explode(self::NEED_SEPARATOR, $_GET["need"]) : array(); if (empty($need)) { $this->output($this->log("No lib to load", "warn")); } $needs = array(); $this->calculateNeeds($need, $needs); $needs = array_unique($needs); /** * Get lib contents */ foreach ($needs as $lib) { if (isset($this->manifest[$lib])) { if (!isset($this->manifest[$lib][$this->type]) || !is_array($this->manifest[$lib][$this->type])) { $this->output .= $this->log($lib . " is not available", "warn"); continue; } $files = $this->manifest[$lib][$this->type]; for ($i = 0, $max = count($files); $i < $max; $i++) { $absolute_link = preg_match('/^http\\:\\/\\//', $files[$i], $matches); if (!$absolute_link) { $files[$i] = dirname(self::MANIFEST) . "/" . $this->configuration["relative"] . $files[$i]; $content = File::read($files[$i]); self::$current_folder = dirname($files[$i]); if ($this->type == self::TYPE_CSS) { $content = preg_replace_callback('/(url\\(\\")([^\\"]+)/', 'core\\tools\\Dependencies::correctUrls', $content); } $this->output .= $content . "\r\n"; } else { $this->output .= Request::load($files[$i]); } } } else { $this->output .= $this->log($lib . " is not available", "warn"); } } /** * Minified / Uglyflied / gzip */ $accept_gzip = preg_match('/gzip/', $_SERVER['HTTP_ACCEPT_ENCODING'], $matches) && !Core::checkRequiredGetVars("output"); if ($accept_gzip) { Header::content_encoding("gzip"); $this->output = gzencode($this->output); } $this->output($this->output); }