Ejemplo n.º 1
0
<?php

require_once __DIR__ . '/client/GitHubClient.php';
$repos = array('server', 'installer');
$client = new GitHubClient();
foreach ($repos as $repo) {
    $client->setPage();
    $client->setPageSize(2);
    $commits = $client->repos->commits->listCommitsOnRepository('kaltura', $repo);
    echo "Count: " . count($commits) . "\n";
    foreach ($commits as $commit) {
        /* @var $commit GitHubCommit */
        echo get_class($commit) . " - Sha: " . $commit->getSha() . "\n";
    }
    $commits = $client->getNextPage();
    echo "Count: " . count($commits) . "\n";
    foreach ($commits as $commit) {
        /* @var $commit GitHubCommit */
        echo get_class($commit) . " - Sha: " . $commit->getSha() . "\n";
    }
}
Ejemplo n.º 2
0
 /**
  * This function must be implemented, it is define in the abstract class
  *
  */
 function render()
 {
     include LIBRARYPHP_PATH . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'github-php-client-master' . DIRECTORY_SEPARATOR . 'client' . DIRECTORY_SEPARATOR . 'GitHubClient.php';
     $client = new GitHubClient();
     $client->setPage();
     $issuesPerPage = 100;
     $par = explode('/', $_REQUEST['params']);
     //
     if (isset($par[2])) {
         if ($par[2] == 'next') {
             $client->getNextPage();
         } elseif ($par[2] == 'previous') {
             $client->getPreviousPage();
         } else {
             $issuesPerPage = $par[2];
         }
     }
     $client->setPageSize($issuesPerPage);
     //Authenticate user with username and password
     //$this->login($client);
     //Authenticate user TYPE OAUTH BASIC
     //$client->setAuthType(GitHubClientBase::GITHUB_AUTH_TYPE_OAUTH_BASIC);
     //$client->setOauthKey($_SESSION['signup_data']['token']); //This does the same this as $this->login($client);, but returns a 404 not sure why because the scope is user , repo (also added public_repo, repo_deployment, notifications, gist)
     //$client->setDebug(true);
     //Authenticate user TYPE OAUTH WEBFLOW
     $client->setAuthType(GitHubClientBase::GITHUB_AUTH_TYPE_OAUTH_WEBFLOW);
     $client->setOauthToken($_SESSION['signup_data']['token']);
     $issues = $client->issues->listIssues(OWNER, REPO);
     $row_content = "";
     foreach ($issues as $issue) {
         /* @var $issue GitHubIssue */
         $comments = $client->issues->comments->listCommentsOnAnIssue(OWNER, REPO, $issue->getNumber());
         $labels = $client->issues->labels->listLabelsOnAnIssue(OWNER, REPO, $issue->getNumber());
         //Get all Labels for this issue
         $priority = "";
         $client_name = "";
         $category = "";
         if (!empty($labels)) {
             foreach ($labels as $label) {
                 if (strlen($label->getName()) > 2) {
                     $tempArr = explode(":", $label->getName());
                     switch ($tempArr[0]) {
                         case 'P':
                             $priority = $tempArr[1];
                             break;
                         case 'C':
                             $client_name = $tempArr[1];
                             break;
                         case 'Cat':
                             $category = $tempArr[1];
                             break;
                     }
                 }
             }
         }
         //Get all comments for this issue
         $comment_text = "";
         if (!empty($comments)) {
             foreach ($comments as $comment) {
                 if ($comment_text != "") {
                     '<br><br>' . ($comment_text .= $comment->getBody());
                 } else {
                     $comment_text .= $comment->getBody();
                 }
             }
         }
         $assignee = "";
         if (!empty($issue->getAssignee())) {
             $assignee = $issue->getAssignee()->getLogin();
         }
         $row_content .= '<tr>
                             <td>' . $client_name . '</td><td>' . $issue->getTitle() . '</td><td>' . $issue->getBody() . '</td><td>#' . $issue->getNumber() . '</td><td>' . $priority . '</td><td>' . $category . '</td><td>' . $assignee . '</td><td>' . $comment_text . '</td><td>' . $issue->getState() . '</td>
                         </tr>';
     }
     include MODULE_PATH . 'Issue' . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . 'issue.phtml';
 }