Ejemplo n.º 1
0
 /**
  * Real time update called every X miliseconds defined in scripts.js (5000)
  */
 public function updateAction()
 {
     $this->_check();
     $result = array();
     $branchNavigation = new BranchNavigation();
     $branch = $branchNavigation->getActiveBranch();
     $branches = $branchNavigation->getBranches();
     foreach ($branches as $key => $value) {
         if ($value == $branch) {
             unset($branches[$key]);
         }
     }
     $remotes = new Remotes();
     $remotes->setUid($this->_user->loggedIn->uid);
     $status = new Status();
     $status->setUid($this->_user->loggedIn->uid);
     $recentStatus = $status->getStatusMessages();
     $repos = $remotes->getRepos();
     $result['remotes'] = $remotes->getRemotes();
     $result['avail']['uid'] = array_keys($repos);
     $result['avail']['user'] = array_values($repos);
     $result['status'] = $recentStatus;
     $result['locals'] = array_values($branches);
     $this->_helper->json($result);
 }
Ejemplo n.º 2
0
 public function indexAction()
 {
     $result = '';
     $request = $this->getRequest();
     $io = new RawIO();
     //handle file navagation
     $validFile = false;
     $fileNavigation = new FileNavigation();
     $branchNavigation = new BranchNavigation();
     $historyNavigation = new HistoryNavigation();
     $remotes = new Remotes();
     $remotes->setUid($this->_user->loggedIn->uid);
     $status = new Status();
     $status->setUid($this->_user->loggedIn->uid);
     $git = new Git();
     if ($request->isGet()) {
         //===begin file navigation===
         if ($request->getQuery('updir') != NULL) {
             $updirs = (int) $request->getQuery('updir');
             $fileNavigation->upDir($updirs);
         }
         if ($request->getQuery('dir') != NULL) {
             $fileNavigation->enterDir($request->getQuery('dir'));
         }
         if ($request->getQuery('file') != NULL) {
             if ($fileNavigation->validFile($request->getQuery('file'))) {
                 $io->setFile($fileNavigation->getPath(), $request->getQuery('file'));
                 $status->addStatus('open: /' . $fileNavigation->getDir() . $request->getQuery('file'));
             }
         }
         //===end file navigation===
         if ($request->getQuery('branch') != NULL) {
             $result = $branchNavigation->setBranch($request->getQuery('branch'));
             $status->addStatus('branch: ' . $request->getQuery('branch'));
         }
         if ($request->getQuery('sha') != NULL) {
             $result = $historyNavigation->setRev($request->getQuery('sha'));
             $status->addStatus('history: ' . $request->getQuery('sha'));
         }
         //===begin merger===
         if ($request->getQuery('merge') != NULL) {
             $result = $git->merge($request->getQuery('merge'));
             $status->addStatus('merge: ' . $request->getQuery('merge'));
         }
         if ($request->getQuery('pull') != NULL) {
             $result = $remotes->pullRemote($request->getQuery('pull'));
             $status->addStatus('pull: ' . $request->getQuery('pull'));
         }
         if ($request->getQuery('avail') != NULL) {
             $result = $remotes->addRemote($request->getQuery('avail'));
             $status->addStatus('add remote: ' . $request->getQuery('avail'));
         }
         //===end merger===
     }
     if (isset($_POST['code'])) {
         $code = $_POST['code'];
         if ($io->getFile() !== NULL) {
             $io->saveContent($code);
             $status->addStatus('save: ' . $io->getFile());
         }
         if (isset($_POST['commitMessage']) && $_POST['commitMessage'] != '') {
             $msg = $_POST['commitMessage'];
             $result = $git->autoCommit($msg);
             $status->addStatus('commit: ' . $msg);
         }
     }
     $this->view->result = $result;
     $this->view->content = $io->getContent();
     $this->view->editing = $io->getFile();
     $this->view->path = '/' . $fileNavigation->getDir();
     $this->view->files = $fileNavigation->ls();
     $this->view->branch = $branchNavigation->getActiveBranch();
     $this->view->branches = $branchNavigation->getBranches();
     $this->view->state = $branchNavigation->getState();
     $this->view->history = $historyNavigation->getHistory();
     $this->view->headName = $historyNavigation->getHeadName();
     $this->view->status = $status->getStatusMessages();
     $this->view->avail = $remotes->getRepos();
     $this->view->remotes = $remotes->getRemotes();
     $this->view->newFileForm = new NewFileForm();
     $this->view->newDirForm = new NewDirForm();
     $this->view->newBranchForm = new NewBranchForm();
 }