*/
require_once(DOKU_PLUGIN.'syntax.php');
require_once(DOKU_PLUGIN.'git/lib/Git.php');
/**
* All DokuWiki plugins to extend the parser/rendering mechanism
* need to inherit from this class
*/
class syntax_plugin_git_localstatus extends DokuWiki_Syntax_Plugin {
var $helper = null;
function syntax_plugin_git_localstatus (){
$this->helper =& plugin_load('helper', 'git');
if(!$this->helper) msg('Loading the git helper in the git_localstatus class failed.', -1);
}
/**
* return some info
*/
function getInfo(){
return array(
'author' => 'Stephan Dekker',
'email' => 'Stephan@SparklingSoftware.com.au',
'date' => @file_get_contents(dirname(__FILE__) . '/VERSION'),
'name' => 'Git Remote Status Plugin',
'desc' => 'xml',
'url' => 'http://dokuwiki.org/plugin:git',
);
}
/**
* What kind of syntax are we?
*/
function getType(){
return 'substition';
}
/**
* What about paragraphs?
*/
function getPType(){
return 'normal';
}
/**
* Where to sort in?
*/
function getSort(){
return 990; //was 990
}
/**
* Connect pattern to lexer
*/
function connectTo($mode) {
$this->Lexer->addSpecialPattern('~~GITLocalStatus~~',$mode,'plugin_git_localstatus');
}
/**
* Handle the match
*/
function handle($match, $state, $pos, &$handler){
$match_array = array();
$match = substr($match,11,-2); //strip ~~REVISIONS: from start and ~~ from end
// Wolfgang 2007-08-29 suggests commenting out the next line
// $match = strtolower($match);
//create array, using ! as separator
$match_array = explode("!", $match);
// $match_array[0] will be all, or syntax error
// this return value appears in render() as the $data param there
return $match_array;
}
/**
* Create output
*/
function render($format, &$renderer, $data) {
global $INFO, $conf;
if($format == 'xhtml'){
try
{
// If not logged in, go bugger off...
if (is_array($INFO['userinfo']) === false)
{
$renderer->doc .= "
You need to be logged in to view this page. Please login.";
return;
}
// Get GIT commits
$this->getConf('');
$git_exe_path = $conf['plugin']['git']['git_exe_path'];
$datapath = $conf['savedir'];
$repo = new GitRepo($datapath);
$repo->git_path = $git_exe_path;
// Is there anything waiting to be commited?
$waiting_to_commit = $repo->get_status();
if ($waiting_to_commit !== "")
{
$renderer->doc .= '
They have not yet been commited. In order to see all changes to the workspace, commit them and reload this page.
'; // Add a semaphore commit, telling the rendering engine that this isn't a real commit, rather we want to see the current $commits = array(); if(!empty($commit)) unset($commit); $commit['hash'] = 'new'; $commits[] = $commit; // Render page $this->helper->render_changed_files_table($renderer, $commits, $repo); $this->helper->renderChangesMade($renderer, $repo, 'Commit local'); $this->renderCommitMessage($renderer, $repo); return; } // No local changes to be committed. Are we ready to push up? if ($repo->LocalCommitsExist()) { if($this->helper->haveChangesBeenSubmitted() === true) { $renderer->doc .= 'Other initiatives are approved while this has been waiting for approval. Those changes need to be merged into this workspace before these changes can be approved. Click the link in the banner on top of the screen to open the "Upstream changes" page to merge.
';
}
else
{
$renderer->doc .= '
One or more commits have been made to this workspace that are ready to be promoted to Live!
';
$renderer->doc .= 'These can include merges with changes made in other workspaces and approved by the SEPG.
To investigate the changes made in this workspace please select a commit in the drop down list to view the changes contained in each.
'; } else { $renderer->doc .= 'TODO: add more information here
'; $this->renderSubmitMessage($renderer, $repo); } // Get the list of commits since the last push $log = $repo->get_log('origin/master..HEAD'); $commits = $repo->get_commits($log); // Add the "Everything" semaphore commit if(!empty($commit)) unset($commit); $commit['hash'] = 'all'; $commit['message'] = 'All changes to this workspace'; array_push($commits, $commit); // Render combo-box $renderer->doc .= 'This short message will only be used within this workspace and is only intended to designate interim commits. You will be asked to opportunity to provide a detailed description of all the changes just before submitting this entire workspace= for approval.
'; $renderer->doc .= 'Before submitting, please consider the following: Has the content been reviewed for:'; $renderer->doc .= '
And finally: Please note that submitting the changes for approval will make this workspace read-only. Therefore, only submit fully completed IPs.
'; $renderer->doc .= '