Procházet zdrojové kódy

Form : Added some translations to the new form system

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3953 a333f486-631f-4898-b8df-5754b55c2be0
glajarige před 9 roky
rodič
revize
7b7deb0cbe

+ 8 - 14
sources/form/field/selectfield.class.inc.php

@@ -20,6 +20,7 @@
 namespace Combodo\iTop\Form\Field;
 namespace Combodo\iTop\Form\Field;
 
 
 use \Closure;
 use \Closure;
+use \Dict;
 use \Combodo\iTop\Form\Field\MultipleChoicesField;
 use \Combodo\iTop\Form\Field\MultipleChoicesField;
 
 
 /**
 /**
@@ -29,7 +30,7 @@ use \Combodo\iTop\Form\Field\MultipleChoicesField;
  */
  */
 class SelectField extends MultipleChoicesField
 class SelectField extends MultipleChoicesField
 {
 {
-	const DEFAULT_NULL_CHOICE_LABEL = 'TOTR: - Choisir une valeur -';
+	const DEFAULT_NULL_CHOICE_LABEL = 'UI:SelectOne';
 	const DEFAULT_STARTS_WITH_NULL_CHOICE = true;
 	const DEFAULT_STARTS_WITH_NULL_CHOICE = true;
 
 
 	protected $bStartsWithNullChoice;
 	protected $bStartsWithNullChoice;
@@ -55,30 +56,23 @@ class SelectField extends MultipleChoicesField
 	{
 	{
 		$this->bStartsWithNullChoice = $bStartsWithNullChoice;
 		$this->bStartsWithNullChoice = $bStartsWithNullChoice;
 
 
-		if (!array_key_exists(null, $this->aChoices))
-		{
-			$this->aChoices = array(null => static::DEFAULT_NULL_CHOICE_LABEL) + $this->aChoices;
-		}
-
 		return $this;
 		return $this;
 	}
 	}
 
 
 	/**
 	/**
-	 * Sets the choices for the fields
-	 * Overloads the methods for the super class in order to put a dummy choice first if necessary.
+	 * Returns the field choices with null choice first
 	 *
 	 *
-	 * @param array $aChoices
-	 * @return \Combodo\iTop\Form\Field\SelectField
+	 * @return array
 	 */
 	 */
-	public function SetChoices($aChoices)
+	public function GetChoices()
 	{
 	{
+		$aChoices = parent::GetChoices();
 		if ($this->bStartsWithNullChoice && !array_key_exists(null, $aChoices))
 		if ($this->bStartsWithNullChoice && !array_key_exists(null, $aChoices))
 		{
 		{
-			$aChoices = array(null => static::DEFAULT_NULL_CHOICE_LABEL) + $aChoices;
+			$aChoices = array(null => Dict::S(static::DEFAULT_NULL_CHOICE_LABEL)) + $aChoices;
 		}
 		}
 
 
-		parent::SetChoices($aChoices);
-		return $this;
+		return $aChoices;
 	}
 	}
 
 
 }
 }

+ 3 - 1
sources/renderer/bootstrap/fieldrenderer/bssimplefieldrenderer.class.inc.php

@@ -103,7 +103,7 @@ EOF
 					{
 					{
 						// Note : The test is a double equal on purpose as the type of the value received from the XHR is not always the same as the type of the allowed values. (eg : string vs int)
 						// Note : The test is a double equal on purpose as the type of the value received from the XHR is not always the same as the type of the allowed values. (eg : string vs int)
 						$sSelectedAtt = ($this->oField->GetCurrentValue() == $sChoice) ? 'selected' : '';
 						$sSelectedAtt = ($this->oField->GetCurrentValue() == $sChoice) ? 'selected' : '';
-						$oOutput->AddHtml('<option value="' . $sChoice . '" ' . $sSelectedAtt . ' >' . $sLabel . '</option>');
+						$oOutput->AddHtml('<option value="' . $sChoice . '" ' . $sSelectedAtt . ' >')->AddHtml($sLabel, true)->AddHtml('</option>');
 					}
 					}
 					$oOutput->AddHtml('</select>');
 					$oOutput->AddHtml('</select>');
 					$oOutput->AddHtml('</div>');
 					$oOutput->AddHtml('</div>');
@@ -267,6 +267,8 @@ EOF
 					$("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}']").portal_form_field_html($sFormFieldOptions);
 					$("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}']").portal_form_field_html($sFormFieldOptions);
 EOF
 EOF
 				);
 				);
+				// MagnificPopup on images
+				$oOutput->AddJs(InlineImage::FixImagesWidth());
 				break;
 				break;
 		}
 		}