本文整理汇总了PHP中CRM_Report_Form::alterDisplay方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Report_Form::alterDisplay方法的具体用法?PHP CRM_Report_Form::alterDisplay怎么用?PHP CRM_Report_Form::alterDisplay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Report_Form
的用法示例。
在下文中一共展示了CRM_Report_Form::alterDisplay方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: alterDisplay
function alterDisplay(&$rows)
{
parent::alterDisplay($rows);
//THis is all generic functionality which can hopefully go into the parent class
// it introduces the option of defining an alter display function as part of the column definition
// @tod tidy up the iteration so it happens in this function
list($firstRow) = $rows;
// no result to alter
if (empty($firstRow)) {
return;
}
$selectedFields = array_keys($firstRow);
$alterfunctions = $altermap = array();
foreach ($this->_columns as $tablename => $table) {
if (array_key_exists('fields', $table)) {
foreach ($table['fields'] as $field => $specs) {
if (in_array($tablename . '_' . $field, $selectedFields) && array_key_exists('alter_display', $specs)) {
$alterfunctions[$tablename . '_' . $field] = $specs['alter_display'];
$altermap[$tablename . '_' . $field] = $field;
}
}
}
}
if (empty($alterfunctions)) {
// - no manipulation to be done
return;
}
foreach ($rows as $index => &$row) {
foreach ($row as $selectedfield => $value) {
if (array_key_exists($selectedfield, $alterfunctions)) {
$rows[$index][$selectedfield] = $this->{$alterfunctions}[$selectedfield]($value, $row, $selectedfield, $altermap[$selectedfield]);
}
}
}
}
示例2: alterDisplay
/**
* @param $rows
*/
function alterDisplay(&$rows) {
parent::alterDisplay($rows);
//THis is all generic functionality which can hopefully go into the parent class
// it introduces the option of defining an alter display function as part of the column definition
// @todo tidy up the iteration so it happens in this function
if (!empty($this->_rollup) && !empty($this->_groupBysArray)) {
$this->assignSubTotalLines($rows);
}
if (empty($rows)) {
return;
}
list($firstRow) = $rows;
// no result to alter
if (empty($firstRow)) {
return;
}
$selectedFields = array_keys($firstRow);
$alterFunctions = $alterMap = array();
foreach ($this->_columns as $tableName => $table) {
if (array_key_exists('fields', $table)) {
foreach ($table['fields'] as $field => $specs) {
if (in_array($tableName . '_' . $field, $selectedFields)) {
if (array_key_exists('alter_display', $specs)) {
$alterFunctions[$tableName . '_' . $field] = $specs['alter_display'];
$alterMap[$tableName . '_' . $field] = $field;
$alterSpecs[$tableName . '_' . $field] = NULL;
}
if ($this->_editableFields && array_key_exists('crm_editable', $specs)) {
//id key array is what the array would look like if the ONLY group by field is our id field
// in which case it should be editable - in any other group by scenario it shouldn't be
$idKeyArray = array($this->_aliases[$specs['crm_editable']['id_table']] . "." . $specs['crm_editable']['id_field']);
if (empty($this->_groupByArray) || $this->_groupByArray == $idKeyArray) {
$alterFunctions[$tableName . '_' . $field] = 'alterCrmEditable';
$alterMap[$tableName . '_' . $field] = $field;
$alterSpecs[$tableName . '_' . $field] = $specs['crm_editable'];
$alterSpecs[$tableName . '_' . $field]['field_name'] = $specs['name'];
}
}
}
}
}
}
if (empty($alterFunctions)) {
// - no manipulation to be done
return;
}
foreach ($rows as $index => & $row) {
foreach ($row as $selectedField => $value) {
if (array_key_exists($selectedField, $alterFunctions)) {
$rows[$index][$selectedField] = $this->$alterFunctions[$selectedField]($value, $row, $selectedField, $alterMap[$selectedField], $alterSpecs[$selectedField]);
}
}
}
if ($this->_rollup) {
//we want to be able to unset rows so here
$this->alterRollupRows($rows);
}
}