Kaynağa Gözat

Typespecial for VERSION_GIT field

Piotr Labudda 11 yıl önce
ebeveyn
işleme
d95e1575bd
2 değiştirilmiş dosya ile 44 ekleme ve 2 silme
  1. 1 1
      SE/VERSION
  2. 43 1
      SE/se-lib/TypespecialVariable.php

+ 1 - 1
SE/VERSION

@@ -1 +1 @@
-3.9.4
+3.9.4.1

+ 43 - 1
SE/se-lib/TypespecialVariable.php

@@ -27,6 +27,7 @@ class TypespecialVariable extends TypespecialBase {
 			case '__ZASOB':
 			case '__COMPANIES':
 			case 'DEFAULT_ACL_GROUP':
+			case 'VERSION_GIT':
 				return new TypespecialVariable($fldID, $fldName);
 				break;
 		}
@@ -63,6 +64,7 @@ class TypespecialVariable extends TypespecialBase {
 			case 'A_ADM_COMPANY':
 			case 'A_CLASSIFIED':
 			case 'DEFAULT_ACL_GROUP':
+			case 'VERSION_GIT':
 				$jsonAllowCreate = 'false';
 				break;
 			default:
@@ -72,6 +74,15 @@ class TypespecialVariable extends TypespecialBase {
 			$jsonAllowCreate = ($params['allowCreate'])? 'true' : 'false';
 		}
 
+		$jsonPreload = 'false';
+		switch ($this->fldName) {
+			case 'VERSION_GIT':
+				//$jsonPreload = 'true';
+				break;
+			default:
+				$jsonAllowCreate = 'false';
+		}
+
 		$tsValue = V::get('typespecialValue', '', $params);
 		if (!empty($selValue) && !empty($tsValue)) {
 			$tsValue = "{$selValue}: {$tsValue}";
@@ -121,7 +132,7 @@ class TypespecialVariable extends TypespecialBase {
 		create: {$jsonAllowCreate},
 		delimiter: ';',
 		dataAttr: 'typespecial',
-//		preload: true,
+		preload: {$jsonPreload},
 		options: {$optionsJson},
 		render: {
 			item: function(item, escape) {
@@ -493,6 +504,37 @@ class TypespecialVariable extends TypespecialBase {
 				if(V::get('DBG_TS', 0, $_GET) > 2){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">values (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($values);echo'</pre>';}
 				break;
 			}
+			case 'VERSION_GIT': {
+				$gitPath = '/Library/Server/Web/Data/Sites/SE-production-git/';
+				$versions = array();
+				if (file_exists($gitPath)) {
+					$cmd = "cd {$gitPath} && git tag";
+					$cmdOut = null; $cmdRet = null;
+					exec($cmd, $cmdOut, $cmdRet);
+					if ($cmdRet == 0) {
+						if (!empty($cmdOut)) {
+							foreach ($cmdOut as $tag) {
+								array_unshift($versions, $tag);
+							}
+						}
+					}
+				}
+				foreach ($versions as $version) {
+					if (!empty($query)) {
+						if ($strict) {
+							if ($version != $query) {
+								continue;
+							}
+						}
+						else {
+							if (false === strpos($version, $query)) {
+								continue;
+							}
+						}
+					}
+					$values[] = (object)array('id'=>$version, 'param_out'=>$version);
+				}
+			}
 			default:
 				
 		}