Пример #1
0
/**
 * Returns the formated date of the
 * revision of the workspace.
 * @param SwcConfig $config SWC config for the operation.
 * @return string Date of webspace revision.
 *
 * @since v1.0.0
 */
function GetWebspaceRevisionDate($config)
{
    $info = GetWebspaceInfo($config);
    $timestamp = ParseArray($info[IDX_STDOUT], '<date>', '</date>');
    $timestamp = strtotime($timestamp);
    return GetLocalizedTimestamp($timestamp);
}
Пример #2
0
/**
 * Executed SVN commands according to $_SESSION[IDX_ACTION].
 * Stores all execution results within $_SESSION[IDX_EXEC_RES]
 * array.
 * @param array $results A result array that should be appended by the
 * result of the command execution. A new array is returned if this
 * parameter is set to NULL.
 * @return array Array containing results of command excution.
 *
 * @since v1.0.0
 */
function &SvnExecute(&$results = NULL)
{
    if ($results == NULL) {
        $results = array();
    }
    //PrintDebugArray($_SESSION, 'Svn Executor: SESSION');
    $config = GetSelectedConfig();
    if ($config == NULL) {
        return $results;
    }
    if (isset($_SESSION[IDX_ACTION])) {
        switch ($_SESSION[IDX_ACTION]) {
            case ACTION_LIST_REPOSITORY:
                $result = ListRepository($config, "");
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_REP_LIST);
                $results[] = $result;
                break;
            case ACTION_STATUS:
                $result = GetWebspaceStatus($config);
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_WS_STATUS);
                $results[] = $result;
                break;
            case ACTION_LOG:
                $result = GetWebspaceLog($config, "");
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_WS_LOG);
                $results[] = $result;
                break;
            case ACTION_INFO:
                $result = GetWebspaceInfo($config, false);
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_WS_INFO);
                $results[] = $result;
                break;
            case ACTION_UPDATE:
                $result = UpdateWebspace($config);
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_WS_UPDATE);
                $results[] = $result;
                break;
            case ACTION_CLEANUP:
                $result = CleanupWebspace($config);
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_WS_CLEANUP);
                $results[] = $result;
                break;
            case ACTION_SWITCH:
                $path = NULL;
                if (isset($_SESSION[IDX_SWITCH_PATH])) {
                    $path = $_SESSION[IDX_SWITCH_PATH];
                }
                $result = SwitchWebspace($config, $path);
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_WS_SWITCH);
                $results[] = $result;
                break;
            case ACTION_CHECKOUT:
                $result = CheckoutWebspace($config);
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_WS_CHECKOUT);
                $results[] = $result;
                break;
            case ACTION_SVN_HELP:
                $result[IDX_TITLE] = T(TK_RESULT_SVN_HELP_TITLE);
                $result[IDX_STDOUT] = array(T(TK_RESULT_SVN_HELP_HEADER), T(TK_RESULT_SVN_HELP_REP_SHORT), T(TK_RESULT_SVN_HELP_REP_LONG), T(TK_RESULT_SVN_HELP_WS_SHORT), T(TK_RESULT_SVN_HELP_WS_LONG));
                $results[] = $result;
                $result = GetSvnLookHelp();
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_SVNLOOK_HELP);
                $results[] = $result;
                $result = GetSvnHelp();
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_SVN_HELP);
                $results[] = $result;
                $result = GetSvnAdminHelp();
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_SVNADMIN_HELP);
                $results[] = $result;
                $result = GetSvnVersionHelp();
                $result[IDX_TITLE] = T(TK_RESULT_TITLE_SVNADMIN_HELP);
                $results[] = $result;
                break;
            case ACTION_SVN_CMD:
                $result = array();
                $result[IDX_TITLE] = T(TK_RESULT_ERROR_CMD_NOT_EXEC);
                $result[IDX_ERROUT] = array(T(TK_RESULT_ERROR_NO_CMD));
                if (isset($_SESSION[IDX_ACTION_COMMAND]) && $_SESSION[IDX_ACTION_COMMAND] != '') {
                    $cmd = $_SESSION[IDX_ACTION_COMMAND];
                    $cmd = str_replace('%repository%', $config->GetRepositoryRoot(), $cmd);
                    $cmd = str_replace('%webspace%', $config->GetWebspaceRootDir(), $cmd);
                    $cmd = str_replace('%rep%', $config->GetRepositoryRoot(), $cmd);
                    $cmd = str_replace('%ws%', $config->GetWebspaceRootDir(), $cmd);
                    $result[IDX_ERROUT] = array(T(TK_RESULT_ERROR_NO_SVN_CMD__CMD, $cmd));
                    $rc = stripos($cmd, 'svn');
                    if ($rc !== false && $rc == 0) {
                        $result = ExecSvnCmd($cmd);
                        $result[IDX_TITLE] = T(TK_RESULT_CMD_EXEC);
                    }
                }
                $results[] = $result;
                break;
        }
    }
    return $results;
}