コード例 #1
0
 public function update($req, $res, $args)
 {
     $plugin = PluginModel::getData($args['name']);
     $user = $req->getAttribute('user');
     // Ensure plugin exists and user has rights to update it
     if (!$plugin || $plugin->author != $user->username && !$user->is_admmod) {
         $notFoundHandler = Container::get('notFoundHandler');
         return $notFoundHandler($req, $res);
     }
     PluginModel::downloadData($plugin->id, $plugin->vendor_name);
     return Router::redirect(Router::pathFor('plugins.view', ['name' => $plugin->vendor_name]), 'Plugin updated!');
 }
コード例 #2
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();
 }