本文整理匯總了PHP中GridField::getDataFieldValue方法的典型用法代碼示例。如果您正苦於以下問題:PHP GridField::getDataFieldValue方法的具體用法?PHP GridField::getDataFieldValue怎麽用?PHP GridField::getDataFieldValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類GridField
的用法示例。
在下文中一共展示了GridField::getDataFieldValue方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: generateExportFileData
/**
* Generate export fields for CSV.
*
* @param GridField $gridField
* @return array
*/
public function generateExportFileData($gridField)
{
$separator = $this->csvSeparator;
$singl = singleton($gridField->getModelClass());
if ($singl->hasMethod('exportedFields')) {
$fallbackColumns = $singl->exportedFields();
} else {
$fallbackColumns = $singl->summaryFields();
}
$csvColumns = $this->exportColumns ? $this->exportColumns : $fallbackColumns;
$fileData = '';
$columnData = array();
$fieldItems = new ArrayList();
if ($this->csvHasHeader) {
$headers = array();
// determine the CSV headers. If a field is callable (e.g. anonymous function) then use the
// source name as the header instead
foreach ($csvColumns as $columnSource => $columnHeader) {
$headers[] = !is_string($columnHeader) && is_callable($columnHeader) ? utf8_decode($columnSource) : utf8_decode($columnHeader);
}
$fileData .= "\"" . implode("\"{$separator}\"", array_values($headers)) . "\"";
$fileData .= "\n";
}
$items = $gridField->getList();
foreach ($items as $item) {
if (!$item->hasMethod('canView') || $item->canView()) {
$columnData = array();
foreach ($csvColumns as $columnSource => $columnHeader) {
if (!is_string($columnHeader) && is_callable($columnHeader)) {
if ($item->hasMethod($columnSource)) {
$relObj = $item->{$columnSource}();
} else {
$relObj = $item->relObject($columnSource);
}
$value = $columnHeader($relObj);
} else {
$value = $gridField->getDataFieldValue($item, $columnSource);
if (!$value) {
$value = $gridField->getDataFieldValue($item, $columnHeader);
}
}
$value = str_replace(array("\r", "\n"), "\n", $value);
$columnData[] = '"' . str_replace('"', '""', utf8_decode($value)) . '"';
}
$fileData .= implode($separator, $columnData);
$fileData .= "\n";
}
if ($item->hasMethod('destroy')) {
$item->destroy();
}
}
return $fileData;
}
示例2: getColumnContent
/**
* HTML for the column, content of the <td> element.
*
* @param GridField $gridField
* @param DataObject $record - Record displayed in this row
* @param string $columnName
* @return string - HTML for the column. Return NULL to skip.
*/
public function getColumnContent($gridField, $record, $columnName)
{
$field = new TextareaField('MetaDescription');
$value = $gridField->getDataFieldValue($record, $columnName);
$value = $this->formatValue($gridField, $record, $columnName, $value);
$field->setName($this->getFieldName($field->getName(), $gridField, $record));
$field->setValue($value);
return $field->Field() . $this->getErrorMessages();
}
開發者ID:helpfulrobot,項目名稱:littlegiant-silverstripe-seo-editor,代碼行數:17,代碼來源:SEOEditorMetaDescriptionColumn.php
示例3: generateExportFileData
/**
* Generate export fields for CSV.
*
* @param GridField $gridField
* @return array
*/
public function generateExportFileData($gridField)
{
$separator = $this->csvSeparator;
$csvColumns = $this->exportColumns ? $this->exportColumns : singleton($gridField->getModelClass())->summaryFields();
$fileData = '';
$columnData = array();
$fieldItems = new ArrayList();
if ($this->csvHasHeader) {
$headers = array();
// determine the CSV headers. If a field is callable (e.g. anonymous function) then use the
// source name as the header instead
foreach ($csvColumns as $columnSource => $columnHeader) {
$headers[] = !is_string($columnHeader) && is_callable($columnHeader) ? $columnSource : $columnHeader;
}
$fileData .= "\"" . implode("\"{$separator}\"", array_values($headers)) . "\"";
$fileData .= "\n";
}
$items = $gridField->getList();
// Apply filters for a datalist
if ($items instanceof DataList) {
if (!empty($this->filter)) {
$items = $items->filter($this->filter);
}
if (!empty($this->exclude)) {
$items = $items->exclude($this->exclude);
}
if (!empty($this->filterAny)) {
$items = $items->filterAny($this->filterAny);
}
if (!empty($this->where)) {
$items = $items->where($this->where);
}
}
foreach ($items as $item) {
$columnData = array();
foreach ($csvColumns as $columnSource => $columnHeader) {
if (!is_string($columnHeader) && is_callable($columnHeader)) {
if ($item->hasMethod($columnSource)) {
$relObj = $item->{$columnSource}();
} else {
$relObj = $item->relObject($columnSource);
}
$value = $columnHeader($relObj);
} else {
$value = $gridField->getDataFieldValue($item, $columnSource);
}
$value = str_replace(array("\r", "\n"), "\n", $value);
$columnData[] = '"' . str_replace('"', '\\"', $value) . '"';
}
$fileData .= implode($separator, $columnData);
$fileData .= "\n";
$item->destroy();
}
return $fileData;
}
開發者ID:helpfulrobot,項目名稱:lekoala-silverstripe-form-extras,代碼行數:61,代碼來源:GridFieldExportFilteredButton.php