/** * Read and parse remote readme.txt. * * @return bool */ public function get_remote_readme() { if (!file_exists($this->type->local_path . 'readme.txt') && !file_exists($this->type->local_path_extended . 'readme.txt')) { return false; } $response = isset($this->response['readme']) ? $this->response['readme'] : false; if (!$response) { if (!isset($this->type->branch)) { $this->type->branch = 'master'; } $response = $this->api('/1.0/repositories/:owner/:repo/src/' . trailingslashit($this->type->branch) . 'readme.txt'); if (!$response) { $response = new \stdClass(); $response->message = 'No readme found'; } } if ($response && isset($response->data)) { $parser = new Readme_Parser(); $response = $parser->parse_readme($response->data); $this->set_transient('readme', $response); } if ($this->validate_response($response)) { return false; } $this->set_readme_info($response); return true; }
/** * Read and parse remote readme.txt. * * @return bool */ public function get_remote_readme() { if (!file_exists($this->type->local_path . 'readme.txt') && !file_exists($this->type->local_path_extended . 'readme.txt')) { return false; } $response = $this->get_transient('readme'); if (!$response) { $response = $this->api('/repos/:owner/:repo/contents/readme.txt'); } if ($response && isset($response->content)) { $parser = new Readme_Parser(); $response = $parser->parse_readme(base64_decode($response->content)); $this->set_transient('readme', $response); } if ($this->validate_response($response)) { return false; } $this->set_readme_info($response); return true; }
/** * Read and parse remote readme.txt. * * @return bool */ public function get_remote_readme() { if (!file_exists($this->type->local_path . 'readme.txt') && !file_exists($this->type->local_path_extended . 'readme.txt')) { return false; } $response = isset($this->response['readme']) ? $this->response['readme'] : false; /* * Set $response from local file if no update available. */ if (!$response && !$this->can_update($this->type)) { $response = new \stdClass(); $content = $this->get_local_info($this->type, 'readme.txt'); if ($content) { $response->content = $content; } else { $response = false; } } if (!$response) { $id = $this->get_gitlab_id(); self::$method = 'readme'; $response = $this->api('/projects/' . $id . '/repository/files?file_path=readme.txt'); if ($response) { $parser = new Readme_Parser(); $response = $parser->parse_readme(base64_decode($response->content)); $this->set_transient('readme', $response); } } if ($this->validate_response($response)) { return false; } $this->set_readme_info($response); return true; }
/** * Read and parse remote readme.txt. * * @return bool */ public function get_remote_readme() { if (!file_exists($this->type->local_path . 'readme.txt') && !file_exists($this->type->local_path_extended . 'readme.txt')) { return false; } $response = $this->get_transient('readme'); if (!$response) { $id = $this->get_gitlab_id(); self::$method = 'readme'; $response = $this->api('/projects/' . $id . '/repository/files?file_path=readme.txt'); if ($response) { $parser = new Readme_Parser(); $response = $parser->parse_readme(base64_decode($response->content)); $this->set_transient('readme', $response); } } if ($this->validate_response($response)) { return false; } $this->set_readme_info($response); return true; }