Exemplo n.º 1
0
 /**
  * Step 5
  *
  * @author Guillermo Rauch
  **/
 public function executeAdd5(sfWebRequest $request)
 {
     if ($request->isMethod('post')) {
         $addid = $request->getParameter('addid');
         $this->checkStep(4, $addid);
         $gitPath = $this->getUser()->getAttribute('github.path', '', 'plugin.add.' . $addid);
         $gitTags = $this->getUser()->getAttribute('github.tags', array(), 'plugin.add.' . $addid);
         $readme = new ForgeMDParser(file_get_contents($gitPath . '/README.md'));
         $manifest = new ForgeYamlParser(file_get_contents($gitPath . '/package.yml'));
         $params = array('author' => $manifest->get('author'), 'arbitrarySections' => $readme->getArbitrarySections(), 'stabletag' => $manifest->get('current'), 'screenshots' => $readme->getScreenshots(), 'category' => $manifest->get('category'), 'tags' => $manifest->get('tags'), 'gitTags' => $gitTags, 'title' => $manifest->get('name'), 'screenshot' => $readme->getScreenshot(), 'docsurl' => $manifest->get('docs'), 'demourl' => $manifest->get('demo'), 'howtouse' => $readme->getSection('how-to-use'), 'description' => $readme->getDescription());
         $form = new PluginAddStep5Form();
         $form->bind($params);
         if ($form->isValid()) {
             $this->getUser()->setAttribute('step', 5, 'plugin.add.' . $addid);
             $this->getUser()->setAttribute('github.params', $form->getValues(), 'plugin.add.' . $addid);
             return $this->renderJson(array('success' => true, 'status' => 'Verifying JS files'));
         }
         return $this->renderJson($form->toJson());
     }
 }
Exemplo n.º 2
0
 /**
  * Step 5
  *
  * @author Guillermo Rauch
  **/
 public function executeAdd5(sfWebRequest $request)
 {
     if ($request->isMethod('post')) {
         $addid = $request->getParameter('addid');
         $this->checkStep(4, $addid);
         $this->getUser()->getAttributeHolder()->getNames();
         $user = $this->getUser()->getAttribute('github.user', null, 'plugin.add.' . $addid);
         $repository = $this->getUser()->getAttribute('github.repository', null, 'plugin.add.' . $addid);
         // the validator just checks if files are in the repos. Because github changed
         // everything with version 3 this needs a complete rewrite.
         if (substr_count($repository, '.git') > 0) {
             $repository = substr($repository, 0, strrpos($repository, '.'));
         }
         $gitPath = '/repos/' . $user . '/' . $repository . '/contents';
         $gitTags = $this->getUser()->getAttribute('github.tags', array(), 'plugin.add.' . $addid);
         $readme = json_decode(GitHubFetcher::fetchContent($gitPath . '/README.md'));
         $readme = new ForgeMDParser(base64_decode(@$readme->content));
         $manifest = json_decode(GitHubFetcher::fetchContent($gitPath . '/package.yml'));
         $manifest = new ForgeYamlParser(base64_decode(@$manifest->content));
         $params = array('author' => $manifest->get('author'), 'arbitrarySections' => $readme->getArbitrarySections(), 'stabletag' => $manifest->get('current'), 'screenshots' => $readme->getScreenshots(), 'category' => $manifest->get('category'), 'tags' => $manifest->get('tags'), 'gitTags' => $gitTags, 'title' => $manifest->get('name'), 'screenshot' => $readme->getScreenshot(), 'docsurl' => $manifest->get('docs'), 'demourl' => $manifest->get('demo'), 'howtouse' => $readme->getSection('how-to-use'), 'description' => $readme->getDescription());
         $form = new PluginAddStep5Form();
         $form->bind($params);
         if ($form->isValid()) {
             $this->getUser()->setAttribute('step', 5, 'plugin.add.' . $addid);
             $this->getUser()->setAttribute('github.params', $form->getValues(), 'plugin.add.' . $addid);
             return $this->renderJson(array('success' => true, 'status' => 'Verifying JS files'));
         }
         return $this->renderJson($form->toJson());
     }
 }