Example #1
0
 public function get_repositories_list()
 {
     $response = Update::request('https://api.github.com/users/KodiCMS/repos');
     $response = json_decode($response, true);
     $local_plugins = array_keys(Plugins::find_all());
     $repo_plugins = array();
     foreach ($response as $repo) {
         if (strpos($repo['name'], 'plugin-') !== 0) {
             continue;
         }
         $replo_plugin_name = substr($repo['name'], strlen('plugin-'));
         $repo_plugins[] = array('id' => $replo_plugin_name, 'name' => ucfirst(Inflector::humanize($replo_plugin_name)), 'description' => $repo['description'], 'url' => $repo['html_url'], 'clone_url' => $repo['clone_url'], 'archive_url' => $repo['html_url'] . '/archive/' . $repo['default_branch'] . '.zip', 'is_installed' => in_array($replo_plugin_name, $local_plugins), 'is_new' => time() - strtotime($repo['created_at']) < Date::MONTH, 'last_update' => Date::format(strtotime($repo['updated_at'])), 'homepage' => $repo['homepage'], 'plugin_path' => DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, array('cms', 'plugins', $replo_plugin_name)), 'stars' => $repo['stargazers_count'], 'watchers' => $repo['watchers_count']);
     }
     $this->response($repo_plugins);
 }
Example #2
0
 /**
  * 
  * @return array
  */
 public static function find_remote()
 {
     $respoonse = Update::request('https://api.github.com/repos/KodiCMS/patches/git/trees/master?recursive=true');
     $respoonse = json_decode($respoonse, TRUE);
     $patches = array();
     $cache = Cache::instance();
     $cached_patches = $cache->get('patches_cache');
     if ($cached_patches !== NULL) {
         return $cached_patches;
     }
     if (isset($respoonse['tree'])) {
         $installed_patches = self::installed();
         foreach ($respoonse['tree'] as $row) {
             if (!in_array($row['path'], $installed_patches) and pathinfo($row['path'], PATHINFO_EXTENSION) == 'php') {
                 $patches[$row['path']] = 'https://raw.githubusercontent.com/KodiCMS/patches/master/' . $row['path'];
             }
         }
         $cache->set('patches_cache', $patches);
     }
     return $patches;
 }