Exemplo n.º 1
0
 function parse()
 {
     try {
         $stories = Plandown::parse($_REQUEST['plandown']);
     } catch (InfoException $e) {
         return new Template(PATH . 'app/templates/parse-error.php', ['error' => $e->getMessage(), 'info' => new DescriptionList(['items' => $e->getInformation()])]);
     }
     $projects = collection($this->jira->get('project'))->orderByDescending('id')->select('name', 'id');
     $form = new Form(['action' => 'import', 'fields' => [new Input(['name' => 'stories', 'type' => 'hidden', 'value' => Json::encode($stories)]), 'Into project' => new Input(['type' => 'select', 'name' => 'project', 'attributes' => ['options' => $projects]]), new Input(['type' => 'submit', 'class' => 'btn btn-primary', 'value' => 'import'])]]);
     return new Template(PATH . 'app/templates/stories.php', ['stories' => $stories, 'form' => $form]);
 }
Exemplo n.º 2
0
 public function compare($old, $new)
 {
     $diff = ['added' => array_diff_key($new, $old), 'removed' => array_diff_key($old, $new), 'changes' => [], 'values' => []];
     $format = JSON_PRETTY_PRINT ^ \JSON_UNESCAPED_SLASHES;
     foreach ($old as $key => $oldValue) {
         if (array_key_exists($key, $new) === false) {
             continue;
             // skip newly added
         }
         $oldString = Json::encode($oldValue, $format);
         $newString = Json::encode($new[$key], $format);
         if ($oldString !== $newString) {
             $diff['changes'][$key] = new ColorDiff($oldString, $newString);
             $diff['values'][$key] = $newString;
         }
     }
     return $diff;
 }
Exemplo n.º 3
0
 function post($path, $data)
 {
     $url = new Url($this->baseUrl . $path);
     return $this->api([CURLOPT_POST => true, CURLOPT_URL => (string) $url, CURLOPT_POSTFIELDS => Json::encode($data), CURLOPT_HTTPHEADER => ['Content-Type: application/json']]);
 }
Exemplo n.º 4
0
 /**
  * Send an message to console.error().
  *
  * @param string $message The error message
  */
 public static function error($message)
 {
     return self::send('error', Json::encode($message));
 }