ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilSubversionInformation Class Reference

Class ilSubversionInformation. More...

+ Inheritance diagram for ilSubversionInformation:
+ Collaboration diagram for ilSubversionInformation:

Public Member Functions

 getInformationAsHtml ()
 

Data Fields

const SVN_GET_17_FILE = '.svn/wc.db'
 
const SVN_LT_17_FILE = '.svn/entries'
 

Static Private Member Functions

static isSvnRevision ($revision)
 
static isProbablySubversion17 ()
 
static isProbablySubversionLower17 ()
 
static detect ()
 

Static Private Attributes

static $revision_information = null
 

Detailed Description

Member Function Documentation

◆ detect()

static ilSubversionInformation::detect ( )
staticprivate

Definition at line 55 of file class.ilSubversionInformation.php.

References $DIC, $info, $lng, $path, $result, $row, array, and file.

56  {
57  global $DIC;
58 
59  $lng = $DIC->language();
60 
61  if (null !== self::$revision_information) {
62  return self::$revision_information;
63  }
64 
65  $info = array();
66 
67  if (self::isProbablySubversion17()) {
68  if (extension_loaded('PDO') && extension_loaded('pdo_sqlite')) {
69  try {
70  $wcdb = new PDO('sqlite:' . self::SVN_GET_17_FILE);
71 
72  $result = $wcdb->query('SELECT MAX("revision") current_rev FROM "NODES"');
73  if ($result) {
74  foreach ($result as $row) {
75  $revision = $row['current_rev'];
76  if (self::isSvnRevision($revision)) {
77  $info[] = sprintf($lng->txt('svn_revision_current'), $revision);
78  }
79  break;
80  }
81  }
82 
83  $result = $wcdb->query('SELECT "changed_revision" last_changed_revision FROM "NODES" ORDER BY changed_revision DESC LIMIT 1');
84  if ($result) {
85  foreach ($result as $row) {
86  $revision = $row['last_changed_revision'];
87  if (self::isSvnRevision($revision)) {
88  $info[] = sprintf($lng->txt('svn_revision_last_change'), $revision);
89  }
90  break;
91  }
92  }
93 
94  $result = $wcdb->query('SELECT * FROM REPOSITORY ');
95  if ($result) {
96  foreach ($result as $row) {
97  $info[] = sprintf($lng->txt('svn_root'), $row['root']);
98  }
99  }
100 
101  $result = $wcdb->query('SELECT * FROM "NODES" WHERE local_relpath LIKE "%inc.ilias_version.php"');
102  if ($result) {
103  foreach ($result as $row) {
104  $path = dirname(dirname($row['repos_path']));
105  if ($path) {
106  $info[] = sprintf($lng->txt('svn_path'), $path);
107  }
108  }
109  }
110  } catch (Exception $e) {
111  }
112  }
113  } else {
114  if (function_exists('shell_exec') && is_callable('shell_exec')) {
115  $revision = trim(shell_exec('svnversion ' . realpath(getcwd())));
116  if (self::isSvnRevision($revision)) {
117  $info[] = sprintf($lng->txt('svn_revision_current'), $revision);
118  }
119  }
120  if (self::isProbablySubversionLower17()) {
121  $svnfile = file(self::SVN_LT_17_FILE);
122  $revision = $svnfile[3];
123  if (self::isSvnRevision($revision)) {
124  $info[] = sprintf($lng->txt('svn_revision_last_change'), $revision);
125  }
126  }
127  }
128 
129  self::$revision_information = $info;
130  }
$result
global $DIC
Definition: saml.php:7
Reload workbook from saved file
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
$info
Definition: index.php:5

◆ getInformationAsHtml()

ilSubversionInformation::getInformationAsHtml ( )
Returns
string

Implements ilVersionControlInformation.

Definition at line 135 of file class.ilSubversionInformation.php.

136  {
137  self::detect();
138 
139  return implode("<br />", self::$revision_information);
140  }

◆ isProbablySubversion17()

static ilSubversionInformation::isProbablySubversion17 ( )
staticprivate
Returns
bool

Definition at line 39 of file class.ilSubversionInformation.php.

40  {
41  return file_exists(self::SVN_GET_17_FILE) && is_file(self::SVN_GET_17_FILE) && is_readable(self::SVN_GET_17_FILE);
42  }

◆ isProbablySubversionLower17()

static ilSubversionInformation::isProbablySubversionLower17 ( )
staticprivate
Returns
bool

Definition at line 47 of file class.ilSubversionInformation.php.

48  {
49  return file_exists(self::SVN_LT_17_FILE) && is_file(self::SVN_LT_17_FILE) && is_readable(self::SVN_LT_17_FILE);
50  }

◆ isSvnRevision()

static ilSubversionInformation::isSvnRevision (   $revision)
staticprivate
Parameters
$revision
Returns
bool

Definition at line 31 of file class.ilSubversionInformation.php.

32  {
33  return (bool) preg_match('/^\d+(:\d+)*[MSP]*$/', $revision);
34  }

Field Documentation

◆ $revision_information

ilSubversionInformation::$revision_information = null
staticprivate

Definition at line 25 of file class.ilSubversionInformation.php.

◆ SVN_GET_17_FILE

const ilSubversionInformation::SVN_GET_17_FILE = '.svn/wc.db'

Definition at line 15 of file class.ilSubversionInformation.php.

◆ SVN_LT_17_FILE

const ilSubversionInformation::SVN_LT_17_FILE = '.svn/entries'

Definition at line 20 of file class.ilSubversionInformation.php.


The documentation for this class was generated from the following file: