[Fusionforge-commits] FusionForge branch master updated. v6.0.5-1334-g0e75411

Franck Villaume nerville at libremir.placard.fr.eu.org
Thu Jan 12 17:08:58 CET 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  0e75411a6b3c6052e7def1662a8cd40a09a1937a (commit)
      from  c861ffded71094b933c3cd3f8e3932c2a07b8a56 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=0e75411a6b3c6052e7def1662a8cd40a09a1937a

commit 0e75411a6b3c6052e7def1662a8cd40a09a1937a
Author: Stéphane-Eymeric Bredthauer <sebredthauer at gmail.com>
Date:   Thu Jan 12 17:03:17 2017 +0100

    Tracker: Extra field type Effort Fix 1

diff --git a/src/common/tracker/EffortUnitFactory.class.php b/src/common/tracker/EffortUnitFactory.class.php
index e1757c6..29c584f 100644
--- a/src/common/tracker/EffortUnitFactory.class.php
+++ b/src/common/tracker/EffortUnitFactory.class.php
@@ -2,7 +2,7 @@
 /**
  * FusionForge Effort Unit Factory
  *
- * Copyright 2016, Stéphane-Eymeric Bredthauer - TrivialDev
+ * Copyright 2017, Stéphane-Eymeric Bredthauer - TrivialDev
  *
  * This file is part of FusionForge. FusionForge is free software;
  * you can redistribute it and/or modify it under the terms of the
@@ -143,4 +143,43 @@ class EffortUnitFactory extends FFError {
 		}
 		return false;
 	}
+
+	function encodedToValue($encoded){
+		$value = 0;
+		if (preg_match('/^(\d+)U(\d+)$/',$encoded,$matches)) {
+			$value = intval($matches[1]);
+		}
+		return $value;
+	}
+
+	function encodedToUnitId($encoded) {
+		if (preg_match('/^(\d+)U(\d+)$/',$encoded,$matches)) {
+			$unitId = intval($matches[2]);
+		} else {
+			$units = $this->getUnitsArr();
+			reset($units);
+			$unitId = key($units);
+		}
+		return $unitId;
+	}
+
+	function encodedToUnitName($encoded) {
+		$units = $this->getUnitsArr();
+		if (preg_match('/^(\d+)U(\d+)$/',$encoded,$matches)) {
+			$unitName = $units[$matches[2]];
+		} else {
+			$unitName = reset($units);
+		}
+		return $unitName;
+	}
+
+	function encodedToString($encoded) {
+		$units = $this->getUnitsArr();
+		if (preg_match('/^(\d+)U(\d+)$/',$encoded,$matches)) {
+			$string = intval($matches[1]).' '.$units[$matches[2]];
+		} else {
+			$string = '0 '.reset($units);
+		}
+		return $string;
+	}
 }
diff --git a/src/common/tracker/include/ArtifactTypeHtml.class.php b/src/common/tracker/include/ArtifactTypeHtml.class.php
index 5dd89ca..58b965a 100644
--- a/src/common/tracker/include/ArtifactTypeHtml.class.php
+++ b/src/common/tracker/include/ArtifactTypeHtml.class.php
@@ -276,6 +276,12 @@ class ArtifactTypeHtml extends ArtifactType {
 					$value = preg_replace_callback('/\b(\d+)\b/', create_function('$matches', 'return _artifactid2url($matches[1], \'title\');'), $value);
 				} elseif ($type == ARTIFACT_EXTRAFIELDTYPE_DATETIME && $value!='') {
 					$value =  date('Y-m-d H:i', $value);
+				} elseif ($type == ARTIFACT_EXTRAFIELDTYPE_EFFORT) {
+					if (!isset($effortUnitSet)) {
+						$effortUnitSet = New EffortUnitSet($this, $this->getEffortUnitSet());
+						$effortUnitFactory = New EffortUnitFactory($effortUnitSet);
+					}
+					$value = $effortUnitFactory->encodedToString($value);
 				}
 				$template = str_replace('{$PostName:'.$efarr[$i]['field_name'].'}', $post_name, $template);
 				$template = str_replace('{$'.$efarr[$i]['field_name'].'}', $value, $template);
@@ -1162,19 +1168,9 @@ class ArtifactTypeHtml extends ArtifactType {
 	function renderEffort ($extra_field_id, $contents, $size, $maxlength, $attrs = array()) {
 		$effortUnitSet = New EffortUnitSet($this, $this->getEffortUnitSet());
 		$effortUnitFactory = New EffortUnitFactory($effortUnitSet);
-		$units = $effortUnitFactory->getUnits();
-		if (!$contents) {
-			reset($units);
-			$contents = '0U'.key($units);
-		}
-		$pos = strpos($contents, 'U');
-		if ($pos) {
-			$value = substr($contents, 0, $pos);
-			$unitId = substr($contents, $pos+strlen($contents));
-		} else {
-			$value = 0;
-			$unitId = null;
-		}
+		$units = $effortUnitFactory->getUnitsArr();
+		$value = $effortUnitFactory->encodedToValue($contents);
+		$unitId = $effortUnitFactory->encodedToUnitId($contents);
 		if (isset($attrs['class'])) {
 			$attrs['class'] .= ' effort';
 		} else {

-----------------------------------------------------------------------

Summary of changes:
 src/common/tracker/EffortUnitFactory.class.php     | 41 +++++++++++++++++++++-
 .../tracker/include/ArtifactTypeHtml.class.php     | 22 +++++-------
 2 files changed, 49 insertions(+), 14 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list