本文整理汇总了PHP中DataObjectCollection::getHeadings方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObjectCollection::getHeadings方法的具体用法?PHP DataObjectCollection::getHeadings怎么用?PHP DataObjectCollection::getHeadings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataObjectCollection
的用法示例。
在下文中一共展示了DataObjectCollection::getHeadings方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
//.........这里部分代码省略.........
$do = $report->createDataObject($display_fields, $idField, $this->getColumns($report->tablename));
$doc = new DataObjectCollection($do);
$sh = new SearchHandler($doc, FALSE);
$sh->setGroupby($display_fields);
$sh->setOrderby($display_fields);
if (!isset($this->_data['Search'])) {
$this->_data['Search'] = array();
}
// we don't need a condition here... always display the search box
$this->search = $report->createSearch($search_fields, $this->_data['Search']);
$cc = $this->search->toConstraintChain();
$cc->removeByField('report_id');
$sh->addConstraintChain($cc);
// if the filter constraint chain has been set, use it
if (isset($filter_cc)) {
$sh->addConstraintChain($filter_cc);
}
$measure_fields = array_merge(array('' => 'report'), $measure_fields);
/// merge the aggregate methods array in with the display fields array
// the aggregate methods array is preset as an array to allow for empty values
// we don't use the array_merge function as we want to maintain keys (representing position)
$display_fields = (array) $display_fields + (array) $aggregate_methods;
if (count($aggregate_fields) === 0) {
$this->view->set('aggregate_count', 0);
}
// sort display fields by key (position)
ksort($display_fields);
// prepend the id field to the display fields...
// at this stage the items are in order, so keys don't matter
$display_fields = array_merge(array($idField), $display_fields);
$sh->setFields($display_fields);
$data = $doc->load($sh, null, RETURN_ROWS);
$this->view->set('total_records', $doc->total_records);
$headings = $doc->getHeadings();
// loop through headings...
foreach ($headings as $key => $field) {
if (!array_search($key, $original_fields)) {
// if item isn't in original fields remove it from headings array
unset($headings[$key]);
} else {
// if label exists, use that for heading
if (!empty($options[$key]['normal_field_label'])) {
$headings[$key] = $options[$key]['normal_field_label'];
}
}
}
$heading_keys = array_keys($headings);
$this->view->set('headings', $headings);
/*
* Build the data array
*
* There is no point in processing everything just to output the
* print dialog OR is we're CSVing the output.
*/
if (!isset($this->_data['printaction']) && !isset($this->_data['printAction']) || $this->_data['print']['printtype'] !== 'csv') {
$response = $this->buildArray($data, $headings, $measure_fields, $aggregate_fields, $heading_keys, $options);
$data_arr = $response['data_arr'];
$sub_total_keys = $response['sub_total_keys'];
}
$this->view->set('options', $options);
// are we being called from a print dialog or are we actually printing?
if (isset($this->_data['printaction']) || isset($this->_data['printAction']) || isset($this->_data['ajax_print'])) {
if ($this->_data['print']['printtype'] === 'csv') {
$dialog_options['csv_source'] = $this->generate_csv($this->_data['print'], $data_arr, array_keys($headings));
} else {
// build xml
示例2: PrintCollection
public function PrintCollection($collection = NULL)
{
if (!$this->isPrinting()) {
return parent::printCollection($collection);
}
if (!isset($this->_data) || !$this->loadData()) {
$this->dataError();
sendBack();
}
$dataset = $this->_uses[$this->modeltype];
$model = $this->newModel($dataset);
$title = $model->getTitle();
$s_data = array();
$search_id = $_SESSION['printing'][$this->_data['session_key']]['search_id'];
$collection = new DataObjectCollection($model, $this->_schema . '.' . $dataset->name . '_overview');
$collection->getHeadings();
$sh = $this->setSearchHandler($collection, $search_id, TRUE);
$sh->setLimit(0);
$this->load_collection($collection, $sh);
parent::printCollection($collection);
}
示例3: build_print_resources
public function build_print_resources(DataObjectCollection $collection, $args = array())
{
// by this point the collection must already have been loaded
// create report title
$report_title = $this->generate_collection_name(FALSE, $collection->title);
// get the headings from the collection, loop through and remove and id fields
$coll_headers = array();
$fields = $collection->getHeadings();
foreach ($fields as $field => $title) {
if (substr($field, -2) != 'id') {
$coll_headers[$field] = $title;
}
}
// allow extra headers to be added
if (isset($args['coll_headers'])) {
$coll_headers = array_merge($coll_headers, $args['coll_headers']);
}
$col_widths = '';
if (isset($this->_data['col_widths'])) {
$col_widths = $this->_data['col_widths'];
}
$measure_fields = array();
// get the data
if (isset($_SESSION['printing'][$this->_data['index_key']]['break']['measure_fields'])) {
$measure_fields = $_SESSION['printing'][$this->_data['index_key']]['break']['measure_fields'];
}
$aggregate_fields = array();
if (isset($_SESSION['printing'][$this->_data['index_key']]['break']['aggregate_fields'])) {
$aggregate_fields = $_SESSION['printing'][$this->_data['index_key']]['break']['aggregate_fields'];
}
if (!empty($measure_fields) || !empty($aggregate_fields)) {
$field_formatting = array();
if (isset($_SESSION['printing'][$this->_data['index_key']]['break']['field_formatting'])) {
$field_formatting = $_SESSION['printing'][$this->_data['index_key']]['break']['field_formatting'];
}
$default_options = array('normal_field_label' => '', 'normal_display_field' => TRUE, 'normal_break_on' => FALSE, 'normal_method' => 'dont_total', 'normal_total' => 'none', 'normal_enable_formatting' => FALSE, 'normal_decimal_places' => 0, 'normal_red_negative_numbers' => FALSE, 'normal_thousands_seperator' => FALSE);
foreach ($fields as $field => $title) {
foreach ($default_options as $option => $value) {
if (!isset($field_formatting[$field][$option])) {
if ($option == 'normal_break_on' && isset($measure_fields[$field])) {
$field_formatting[$field][$option] = TRUE;
} else {
$field_formatting[$field][$option] = $value;
}
}
}
}
$formatting_options = array_merge($default_options, $field_formatting);
$arr_data = $this->generate_subtotals($collection, $coll_headers, $measure_fields, $aggregate_fields, array_keys($coll_headers), $formatting_options);
$coll_data = $arr_data['data_arr'];
$subtotal_keys = $arr_data['sub_total_keys'];
} else {
if ($collection instanceof DataObjectCollection || is_array($collection)) {
foreach ($collection as $detailRow) {
$printDetail[] = $this->construct_line($detailRow, $coll_headers);
}
$coll_data = $printDetail;
$formatting_options = array();
$subtotal_keys = array();
}
}
// build the custom XSL
// $xsl = $this->build_custom_xsl($collection, 'CustomReport', $report_title, $coll_headers, $col_widths, $formatting_options);
$xsl = $this->build_custom_xsl($collection, $this->_data['print']['report'], $report_title, $coll_headers, $col_widths, $formatting_options);
if ($xsl === FALSE) {
return FALSE;
}
// construct basic XML of data
$xml = $this->build_custom_xml($coll_data, $coll_headers, $formatting_options, $subtotal_keys);
return array('xml' => $xml, 'xsl' => $xsl);
}