浏览代码

New API for SelectObjectField, replaced OQL query by DBSearch

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3977 a333f486-631f-4898-b8df-5754b55c2be0
glajarige 9 年之前
父节点
当前提交
30f36ef9d1

+ 7 - 6
sources/form/field/selectobjectfield.class.inc.php

@@ -20,6 +20,7 @@
 namespace Combodo\iTop\Form\Field;
 
 use \Closure;
+use \DBSearch;
 use Combodo\iTop\Form\Validator\NotEmptyExtKeyValidator;
 
 /**
@@ -28,21 +29,21 @@ use Combodo\iTop\Form\Validator\NotEmptyExtKeyValidator;
  */
 class SelectObjectField extends Field
 {
-	protected $sOqlQuery;
+	protected $oSearch;
 	protected $iMaximumComboLength;
 	protected $iMinAutoCompleteChars;
 
 	public function __construct($sId, Closure $onFinalizeCallback = null)
 	{
 		parent::__construct($sId, $onFinalizeCallback);
-		$this->sOqlQuery = null;
+		$this->oSearch = null;
 		$this->iMaximumComboLength = null;
 		$this->iMinAutoCompleteChars = 3;
 	}
 
-	public function SetOqlQuery($sOqlQuery)
+	public function SetSearch(DBSearch $oSearch)
 	{
-		$this->sOqlQuery = $sOqlQuery;
+		$this->oSearch = $oSearch;
 	}
 
 	public function SetMaximumComboLength($iMaximumComboLength)
@@ -85,9 +86,9 @@ class SelectObjectField extends Field
 		return $this;
 	}
 
-	public function GetOqlQuery()
+	public function GetSearch()
 	{
-		return $this->sOqlQuery;
+		return $this->oSearch;
 	}
 
 	public function GetMaximumComboLength()

+ 2 - 2
sources/renderer/console/fieldrenderer/consolesimplefieldrenderer.class.inc.php

@@ -87,7 +87,7 @@ class ConsoleSimpleFieldRenderer extends FieldRenderer
 					$oOutput->AddHtml('<td class="form-field-content">');
 					if ($this->oField->GetReadOnly())
 					{
-						$oSearch = \DBSearch::FromOQL($this->oField->GetOqlQuery());
+						$oSearch = $this->oField->GetSearch()->DeepClone();
 						$oSearch->AddCondition('id', $this->oField->GetCurrentValue());
 						$oSet = new DBObjectSet($oSearch);
 						$oObject = $oSet->Fetch();
@@ -104,7 +104,7 @@ class ConsoleSimpleFieldRenderer extends FieldRenderer
 					}
 					else
 					{
-						$oSearch = \DBSearch::FromOQL($this->oField->GetOqlQuery());
+						$oSearch = $this->oField->GetSearch()->DeepClone();
 						$oSet = new \DBObjectSet($oSearch);
 						$oSet->OptimizeColumnLoad(array($oSearch->GetClassAlias() => array('friendlyname')));
 						$oOutput->AddHtml('<select class="form-field-data" id="'.$this->oField->GetGlobalId().'">');