{extends "manage/manage.tpl.html"}

{block "javascripts"}
<script type="text/javascript">
function validateForm()
{
    if (!Validation.hasOneChecked('scm_integration'))  {
        alert('{t escape=js}Please choose whether the SCM integration feature should be enabled or not.{/t}');
        return false;
    }

    return true;
}

function disableSCMFields(bool)
{
  $('#scm_setup').css('display', !bool ? 'table-row' : 'none');
}

function setDisabledFields()
{
  if (Eventum.getField('scm_integration').first().is(':checked')) {
    disableSCMFields(false);
  } else {
    disableSCMFields(true);
  }
}

$(function() {
  $('#general_setup_form').submit(validateForm);
  $('input[name=scm_integration]').change(setDisabledFields);
  setDisabledFields();
});
</script>
{/block}

{block "manage_content"}

<form id="general_setup_form" method="post">
<input type="hidden" name="cat" value="update">
  <table class="bordered">
    <tr class="title">
      <th colspan="2">
        {t}SCM Integration{/t}
      </th>
    </tr>

    <tr>
      <th width="120">
        {t escape=no}SCM <br />Integration{/t}: {include file="help_link.tpl.html" topic="scm_integration"}
      </th>
      <td>
        <table>
          <tr>
            <td colspan="2">
              <label>
                <input type="radio" name="scm_integration" value="enabled" {if $setup.scm_integration|default:'' == 'enabled'}checked{/if}>
                {t}Enabled{/t}</label>&nbsp;&nbsp;
              <label>
                <input type="radio" name="scm_integration" value="disabled" {if $setup.scm_integration|default:'' != 'enabled'}checked{/if}>
                {t}Disabled{/t}
              </label>
            </td>
          </tr>
        </table>
      </td>
      </tr>
    <tr id="scm_setup">
      <th></th>
      <td>
        <p>
        {t escape=no 1=$scm_ping_url}The SCM ping endpoint url is: <b>%1</b>{/t}
        </p>
        {t escape=no}To add scm backends, add to your <b>setup.php</b> like{/t}:
        {literal}<pre>
  'scm' => array(
    'cvs' => array(
      // viewvc urls
      'name' => 'cvs',
      'checkout_url' => 'https://cvs.example.org/{FILE}?view=markup&revision={NEW_VERSION}',
      'diff_url' => 'https://cvs.example.org/{FILE}?r1={OLD_VERSION}&r2={NEW_VERSION}&f=h',
      'log_url' => 'https://cvs.example.org/{FILE}?r1={NEW_VERSION}#rev{NEW_VERSION}',
    ),
    'svn' => array(
      // trac urls
      'name' => 'svn',
      'checkout_url' => 'https://trac.example.org/browser/{FILE}?rev={CHANGESET}',
      'diff_url' => 'https://trac.example.org/changeset/{CHANGESET}/{FILE}',
      'log_url' => 'https://trac.example.org/log/{FILE}?rev={CHANGESET}',
      'changeset_url' => 'https://trac.example.org/changeset/{CHANGESET}',
    ),
    'git' => array(
      // gitweb urls
      'name' => 'git',
      'checkout_url' => 'https://git.example.org/?p={PROJECT}.git;a=blob;f={FILE};hb={CHANGESET}',
      'diff_url' => 'https://git.example.org/?p={PROJECT}.git;a=commitdiff;h={CHANGESET}',
      'log_url' => 'https://git.example.org/?p={PROJECT}.git;a=history;f={FILE};hb={CHANGESET}',
      'changeset_url' => 'https://git.example.org/?p={PROJECT}.git;a=commitdiff;h={CHANGESET}',
      'project_url' => 'https://git.example.org/?p={PROJECT}.git;a=summary',
    ),
    'gitlab' => array(
      // gitlab urls
      'name' => 'gitlab',
      'checkout_url' => 'https://gitlab.example.org/{PROJECT}/blob/{CHANGESET}/{FILE}',
      'diff_url' => 'https://gitlab.example.org/{PROJECT}/commit/{CHANGESET}#{FILE}',
      'log_url' => 'https://gitlab.example.org/{PROJECT}/commits/{CHANGESET}/{FILE}',
      'changeset_url' => 'https://gitlab.example.org/{PROJECT}/commit/{CHANGESET}',
      'branch_url' => 'https://gitlab.example.org/{PROJECT}/tree/{BRANCH}',
      'project_url' => 'https://gitlab.example.org/{PROJECT}',
      // push urls to identify this instance
      'urls' => array(
          'git@gitlab.example.net',
          'gitlab@gitlab.local'
      ),
      // branch filtering
      'only' => array(
          'master',
      ),
      'except' => array(
      ),
    ),
  )
</pre>{/literal}
      </td>
    </tr>

    <tr class="buttons">
      <td colspan="2" align="center">
        <input class="button" type="submit" value="{t}Update Setup{/t}">
        <input class="button" type="reset" value="{t}Reset{/t}">
      </td>
    </tr>
  </table>
</form>
{/block}
