예제 #1
0
 /**
  * TODO: test
  */
 public function saveAction()
 {
     $this->_check();
     $request = $this->getRequest();
     $io = new RawIO();
     if ($request->isPost()) {
         $post = $request->getPost();
         $io->saveContent($code);
     }
 }
예제 #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();
 }