mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Cleaning up GridFieldAddExistingAutocompleter
This commit is contained in:
parent
8028387c84
commit
bdf9e97b0e
@ -59,7 +59,7 @@ class GridFieldAddExistingAutocompleter
|
|||||||
* 'Team.Name'
|
* 'Team.Name'
|
||||||
* )
|
* )
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $searchFields = array();
|
protected $searchFields = array();
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ class GridFieldAddExistingAutocompleter
|
|||||||
protected $resultsFormat = '$Title';
|
protected $resultsFormat = '$Title';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var String Text shown on the search field, instructing what to search for.
|
* @var string Text shown on the search field, instructing what to search for.
|
||||||
*/
|
*/
|
||||||
protected $placeholderText;
|
protected $placeholderText;
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ class GridFieldAddExistingAutocompleter
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param GridField $gridField
|
* @param GridField $gridField
|
||||||
* @return string - HTML
|
* @return string[] - HTML
|
||||||
*/
|
*/
|
||||||
public function getHTMLFragments($gridField) {
|
public function getHTMLFragments($gridField) {
|
||||||
$dataClass = $gridField->getList()->dataClass();
|
$dataClass = $gridField->getList()->dataClass();
|
||||||
@ -215,17 +215,20 @@ class GridFieldAddExistingAutocompleter
|
|||||||
->limit($this->getResultsLimit());
|
->limit($this->getResultsLimit());
|
||||||
|
|
||||||
$json = array();
|
$json = array();
|
||||||
$originalSourceFileComments = Config::inst()->get('SSViewer', 'source_file_comments');
|
Config::nest();
|
||||||
Config::inst()->update('SSViewer', 'source_file_comments', false);
|
Config::inst()->update('SSViewer', 'source_file_comments', false);
|
||||||
|
$viewer = SSViewer::fromString($this->resultsFormat);
|
||||||
foreach($results as $result) {
|
foreach($results as $result) {
|
||||||
$json[$result->ID] = html_entity_decode(SSViewer::fromString($this->resultsFormat)->process($result));
|
$json[$result->ID] = html_entity_decode($viewer->process($result));
|
||||||
}
|
}
|
||||||
Config::inst()->update('SSViewer', 'source_file_comments', $originalSourceFileComments);
|
Config::unnest();
|
||||||
return Convert::array2json($json);
|
return Convert::array2json($json);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param String
|
* @param string $format
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setResultsFormat($format) {
|
public function setResultsFormat($format) {
|
||||||
$this->resultsFormat = $format;
|
$this->resultsFormat = $format;
|
||||||
@ -233,7 +236,7 @@ class GridFieldAddExistingAutocompleter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getResultsFormat() {
|
public function getResultsFormat() {
|
||||||
return $this->resultsFormat;
|
return $this->resultsFormat;
|
||||||
@ -247,10 +250,11 @@ class GridFieldAddExistingAutocompleter
|
|||||||
*/
|
*/
|
||||||
public function setSearchList(SS_List $list) {
|
public function setSearchList(SS_List $list) {
|
||||||
$this->searchList = $list;
|
$this->searchList = $list;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Array
|
* @param array $fields
|
||||||
*/
|
*/
|
||||||
public function setSearchFields($fields) {
|
public function setSearchFields($fields) {
|
||||||
$this->searchFields = $fields;
|
$this->searchFields = $fields;
|
||||||
@ -258,7 +262,7 @@ class GridFieldAddExistingAutocompleter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getSearchFields() {
|
public function getSearchFields() {
|
||||||
return $this->searchFields;
|
return $this->searchFields;
|
||||||
@ -269,8 +273,8 @@ class GridFieldAddExistingAutocompleter
|
|||||||
* Falls back to {@link DataObject->summaryFields()} if
|
* Falls back to {@link DataObject->summaryFields()} if
|
||||||
* no custom search fields are defined.
|
* no custom search fields are defined.
|
||||||
*
|
*
|
||||||
* @param String the class name
|
* @param string $dataClass the class name
|
||||||
* @return Array|null names of the searchable fields
|
* @return array|null names of the searchable fields
|
||||||
*/
|
*/
|
||||||
public function scaffoldSearchFields($dataClass) {
|
public function scaffoldSearchFields($dataClass) {
|
||||||
$obj = singleton($dataClass);
|
$obj = singleton($dataClass);
|
||||||
@ -306,8 +310,9 @@ class GridFieldAddExistingAutocompleter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param String The class of the object being searched for
|
* @param string $dataClass The class of the object being searched for
|
||||||
* @return String
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPlaceholderText($dataClass) {
|
public function getPlaceholderText($dataClass) {
|
||||||
$searchFields = ($this->getSearchFields())
|
$searchFields = ($this->getSearchFields())
|
||||||
@ -339,10 +344,13 @@ class GridFieldAddExistingAutocompleter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param String
|
* @param string $text
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setPlaceholderText($text) {
|
public function setPlaceholderText($text) {
|
||||||
$this->placeholderText = $text;
|
$this->placeholderText = $text;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -356,8 +364,11 @@ class GridFieldAddExistingAutocompleter
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $limit
|
* @param int $limit
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setResultsLimit($limit) {
|
public function setResultsLimit($limit) {
|
||||||
$this->resultsLimit = $limit;
|
$this->resultsLimit = $limit;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user