/** * Switches webspace to given repository path. * @param SwcConfig $config SWC config for the operation. * @param string $path Repository path to switch to * A path without repository root should be applied. * @return array Result of <i>svn switch</i> execution. * @see ExecSvnCmd * * @since v1.0.0 */ function SwitchWebspace($config, $path) { if ($path == NULL) { $path = $config->GetTrunkDir(); } $command = 'svn switch'; $switches = '--non-interactive'; $switches .= GetSvnUsr($config); $switches .= GetSvnPw($config); $arg = $config->GetRepositoryRoot(); $arg .= '/' . $path; $arg .= ' ' . $config->GetWebspaceRootDir(); return ExecSvnCmd($command, $arg); }
protected function svnListNode($realPath, $revision = null) { $command = 'svn list'; $switches = '--xml'; if ($revision != null) { $switches = '--xml -r' . $revision; } $_SESSION["SVN_COMMAND_RUNNING"] = true; //if(substr(strtolower(PHP_OS), 0, 3) == "win") session_write_close(); try { $res = ExecSvnCmd($command, $realPath, $switches); } catch (Exception $e) { return array(); } //if(substr(strtolower(PHP_OS), 0, 3) == "win") session_start(); unset($_SESSION["SVN_COMMAND_RUNNING"]); $domDoc = new DOMDocument(); $domDoc->loadXML($res[IDX_STDOUT]); $xPath = new DOMXPath($domDoc); $entriesList = $xPath->query("list/entry"); $entries = array(); foreach ($entriesList as $entry) { $logEntry = array(); $name = $xPath->query("name", $entry)->item(0)->nodeValue; $logEntry["last_revision"] = $xPath->query("commit/@revision", $entry)->item(0)->value; $logEntry["last_revision_author"] = $xPath->query("commit/author", $entry)->item(0)->nodeValue; $logEntry["last_revision_date"] = $xPath->query("commit/date", $entry)->item(0)->nodeValue; $logEntry["last_revision_size"] = $xPath->query("size", $entry)->item(0)->nodeValue; $entries[$name] = $logEntry; } return $entries; }
/** * 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; }