Ejemplo n.º 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);
 }
Ejemplo n.º 2
0
 /**
  * Проверка файлов на различия, проверяется по размеру файла и наличие файла в ФС
  * @retun array
  */
 public static function check_files()
 {
     $respoonse = self::request('https://api.github.com/repos/:rep/git/trees/:branch?recursive=true');
     $respoonse = json_decode($respoonse, TRUE);
     $files = array('new_files' => array(), 'diff_files' => array(), 'third_party_plugins' => array());
     $cache = Cache::instance();
     $cached_files = $cache->get(self::CACHE_KEY_FILES);
     if ($cached_files !== NULL) {
         return $cached_files;
     }
     if (isset($respoonse['tree'])) {
         $plugins = array();
         foreach ($respoonse['tree'] as $row) {
             $filepath = DOCROOT . $row['path'];
             if (!file_exists($filepath)) {
                 $files['new_files'][] = self::build_remote_url('https://raw.githubusercontent.com/:rep/:branch/' . $row['path']);
                 continue;
             }
             if (is_dir($filepath)) {
                 if (preg_match('/cms\\/plugins\\/([\\w\\_]+)/', $filepath, $matches)) {
                     if (!empty($matches[1])) {
                         $plugins[$matches[1]] = $matches[1];
                     }
                 }
                 continue;
             }
             $filesize = filesize($filepath);
             if ($filesize != $row['size']) {
                 $diff = $filesize - self::_count_file_lines($filepath) - $row['size'];
                 if ($diff > 1 or $diff < -1) {
                     $files['diff_files'][] = array('diff' => Text::bytes($diff), 'url' => self::build_remote_url('https://raw.githubusercontent.com/:rep/:branch/' . $row['path']));
                 }
             }
         }
         if (!empty($plugins)) {
             $local_plugins = array_keys(Plugins::find_all());
             $files['third_party_plugins'] = array_diff($local_plugins, $plugins);
         }
         $cache->set(self::CACHE_KEY_FILES, $files);
     }
     return $files;
 }
Ejemplo n.º 3
0
<?php

defined('SYSPATH') or die('No direct access allowed.');
$plugins = Arr::get($post, 'plugins', array());
if (!empty($post['insert_test_data'])) {
    $plugins['test'] = 'test';
}
Plugins::find_all();
foreach ($plugins as $name) {
    $plugin = Plugins::get_registered($name);
    if ($plugin instanceof Plugin_Decorator and $plugin->is_installable()) {
        $plugin->activate();
    }
}
Ejemplo n.º 4
0
<?php

defined('SYSPATH') or die('No direct access allowed.');
Observer::observe('installer_step_other', function ($data) {
    $plugins = Plugins::find_all();
    echo View::factory('plugins/install', array('plugins' => $plugins, 'data' => $data));
});