コード例 #1
0
 public static function downloadData($plugin_id, $vendor_name, $user = "******")
 {
     // Get main files from Github
     $composer = Github::getContent($vendor_name, 'composer.json', $user);
     $featherbb = Github::getContent($vendor_name, 'featherbb.json', $user);
     $readme = Github::getContent($vendor_name, 'README.md', $user);
     if ($composer === false || $featherbb === false || $readme === false) {
         return false;
     }
     $composerDecoded = json_decode($composer);
     $featherDecoded = json_decode($featherbb);
     $plugin = ORM::for_table('market_plugins')->find_one($plugin_id);
     if ($plugin !== false) {
         $plugin->homepage = 'https://github.com/featherbb/' . $vendor_name;
         $plugin->status = 2;
         $plugin->vendor_name = $vendor_name;
         // $plugin->author = $featherDecoded->author->name;
         $plugin->last_version = $featherDecoded->version;
         $plugin->description = $composerDecoded->description;
         $plugin->keywords = serialize($composerDecoded->keywords);
         $plugin->readme = $readme;
         $plugin->save();
     }
     return $plugin;
 }
コード例 #2
0
 public static function downloadData($theme_id, $vendor_name)
 {
     $theme = ORM::for_table('market_themes')->find_one($theme_id);
     if ($theme === false) {
         return false;
     }
     // Get main files from Github
     $userGit = explode('/', str_ireplace(array('http://', 'https://'), '', $theme->homepage));
     $readme = Github::getContent($userGit[2], 'README.md', $userGit[1]);
     $featherbb = Github::getContent($userGit[2], 'featherbb.json', $userGit[1]);
     if ($featherbb === false || $readme === false) {
         return false;
     }
     $featherDecoded = json_decode($featherbb);
     $theme->status = 2;
     $theme->vendor_name = $vendor_name;
     $theme->last_version = $featherDecoded->version;
     $theme->last_update = time();
     $theme->keywords = serialize($featherDecoded->keywords);
     $theme->readme = $readme;
     $theme->save();
     return $theme;
 }
コード例 #3
0
 public function accept($req, $res, $args)
 {
     // Ensure user is admmod on forum
     $user = $req->getAttribute('user');
     if (!$user->is_admmod) {
         $notFoundHandler = Container::get('notFoundHandler');
         return $notFoundHandler($req, $res);
     }
     // Download archive and store info files to disk
     $vendor_name = Input::post('vendor_name');
     $plugin_id = Input::post('plugin_id');
     // Check required fields are sent from form
     if (!$vendor_name || !$plugin_id) {
         $notFoundHandler = Container::get('notFoundHandler');
         return $notFoundHandler($req, $res);
     }
     // Check vendor name is unique
     if (ORM::for_table('market_plugins')->where('vendor_name', $vendor_name)->where('status', 2)->count() > 0) {
         return 'Vendor name already exists!';
     }
     $repoURL = PluginModel::getUser($vendor_name);
     $userGit = explode('/', str_ireplace(array('http://', 'https://'), '', $repoURL));
     if (Input::post('accept_plugin')) {
         // If no errors while getting data from Github, store generic infos to DB, else throw 404
         if (PluginModel::downloadData($plugin_id, $vendor_name, $userGit[1]) === false) {
             $notFoundHandler = Container::get('notFoundHandler');
             return $notFoundHandler($req, $res);
         } else {
             GithubApi::forkRepo($userGit[1], $vendor_name);
         }
     } elseif (Input::post('delete_plugin')) {
         // TODO: Remove plugin from DB
     }
     return Router::redirect(Router::pathFor('plugins.pending'));
 }
コード例 #4
0
 public function view($req, $res, $args)
 {
     $plugin = PluginModel::getData($args['name']);
     if ($plugin === false) {
         $notFoundHandler = Container::get('notFoundHandler');
         return $notFoundHandler($req, $res);
     }
     $action = isset($args['action']) ? $args['action'] : 'description';
     $content = '';
     if ($action === 'history') {
         // $content = json_decode(GithubApi::getTags($args['name']));
         $content = GithubApi::getTags($args['name']);
     } elseif (!isset($plugin->menu_content[$action]) && isset($plugin->menu_content['description'])) {
         $content = Markdown::defaultTransform($plugin->menu_content['description']);
     } elseif (isset($plugin->menu_content[$action])) {
         $content = Markdown::defaultTransform($plugin->menu_content[$action]);
     }
     return View::setPageInfo(['plugin' => $plugin, 'content' => $content, 'active_menu' => $action, 'active_nav' => 'plugins'])->addBreadcrumb([Router::pathFor('plugins') => 'Plugins', htmlspecialchars($plugin->name)])->addTemplate('plugins/view.php')->display();
 }