/** * Fetch next row into variable * @return bool if next row exists */ public function nextRow() { if ($this->source->nextRow()) { $this->row =& $this->source->row; if (empty($this->displayColumns) && !empty($this->source->displayColumns)) { $this->displayColumns = $this->source->displayColumns; } $origKeys = array_keys($this->row); $functionReturn = $this->functionEvaluator->evaluateFunction($this->functionArray, $this->row); if ($this->fieldToAssign) { $this->source->row[$this->fieldToAssign] = $functionReturn; if (!in_array($this->fieldToAssign, $this->displayColumns)) { $this->displayColumns[] = $this->fieldToAssign; } } else { if ($functionReturn === null || is_array($functionReturn)) { // $functionReturn when a reference was passed in and row may be modified // New row returned if (is_array($functionReturn)) { // function returns new array for the entry $this->source->row = $functionReturn; $this->row =& $this->source->row; } // Reconcile display columns // 1. Check for the addition of new columns to add to displays $newFieldsSeen = array(); $newKeys = array_keys($this->row); $addedKeys = array_diff($newKeys, $origKeys); if (!empty($addedKeys)) { foreach ($addedKeys as $add) { if (!in_array($add, $this->displayColumns)) { $this->displayColumns[] = $add; $newFieldsSeen[] = $add; } } } // 2. Remove display columns that no longer exist $updatedDisplays = array(); foreach ($this->displayColumns as $aDisplay) { if (in_array($aDisplay, $newKeys) || in_array($aDisplay, $newFieldsSeen)) { $updatedDisplays[] = $aDisplay; } } $this->displayColumns = $updatedDisplays; } } return true; } return false; }
/** * Fetch next row into variable * @return bool if next row exists */ public function nextRow() { if ($this->source->nextRow()) { $this->row =& $this->source->row; $functionReturn = $this->functionEvaluator->evaluateFunction($this->functionArray, $this->row); if ($this->fieldToAssign) { $this->source->row[$this->fieldToAssign] = $functionReturn; } else { if (is_array($functionReturn)) { // function returns new array for the entry $this->source->row = $functionReturn; $this->row =& $this->source->row; } } return true; } return false; }
/** * @param $converter CFDBValueConverter * @return void */ public function setComparisonValuePreprocessor($converter) { $this->functionEvaluator->setCompValuePreprocessor($converter); }
protected function setCommonOptions($htmlOptions = false) { if ($this->options && is_array($this->options)) { if (isset($this->options['debug']) && $this->options['debug'] != 'false') { $this->debug = true; } $this->isFromShortCode = isset($this->options['fromshortcode']) && $this->options['fromshortcode'] === true; if (!isset($this->options['unbuffered'])) { $this->options['unbuffered'] = $this->isFromShortCode ? 'false' : 'true'; } if (isset($this->options['showColumns'])) { $this->showColumns = $this->options['showColumns']; } else { if (isset($this->options['show'])) { $this->showColumns = preg_split('/,/', $this->options['show'], -1, PREG_SPLIT_NO_EMPTY); } } if (isset($this->options['hideColumns'])) { $this->hideColumns = $this->options['hideColumns']; } else { if (isset($this->options['hide'])) { $this->hideColumns = preg_split('/,/', $this->options['hide'], -1, PREG_SPLIT_NO_EMPTY); } } if ($htmlOptions) { if (isset($this->options['class'])) { $this->htmlTableClass = $this->options['class']; } else { $this->htmlTableClass = $this->defaultTableClass; } if (isset($this->options['id'])) { $this->htmlTableId = $this->options['id']; } else { $this->htmlTableId = 'cftble_' . rand(); } if (isset($this->options['style'])) { $this->style = $this->options['style']; } } $filters = array(); if (isset($this->options['filter'])) { require_once 'CF7FilterParser.php'; require_once 'DereferenceShortcodeVars.php'; $aFilter = new CF7FilterParser(); $aFilter->setComparisonValuePreprocessor(new DereferenceShortcodeVars()); $aFilter->parseFilterString($this->options['filter']); if ($this->debug) { echo '<pre>\'' . $this->options['filter'] . "'\n"; print_r($aFilter->tree); echo '</pre>'; } $filters[] = $aFilter; } if (isset($this->options['search'])) { require_once 'CF7SearchEvaluator.php'; $aFilter = new CF7SearchEvaluator(); $aFilter->setSearch($this->options['search']); $filters[] = $aFilter; } if (isset($this->options['cfilter'])) { if (function_exists($this->options['cfilter'])) { require_once 'CFDBFunctionEvaluator.php'; $aFilter = new CFDBFunctionEvaluator(); $aFilter->setFunction($this->options['cfilter']); $filters[] = $aFilter; } else { if (class_exists($this->options['cfilter'])) { require_once 'CFDBClassEvaluator.php'; $aFilter = new CFDBClassEvaluator(); $aFilter->setClassName($this->options['cfilter']); $filters[] = $aFilter; } } } $numFilters = count($filters); if ($numFilters == 1) { $this->rowFilter = $filters[0]; } else { if ($numFilters > 1) { require_once 'CFDBCompositeEvaluator.php'; $this->rowFilter = new CFDBCompositeEvaluator(); $this->rowFilter->setEvaluators($filters); } } if (isset($this->options['headers'])) { // e.g. "col1=Column 1 Display Name,col2=Column2 Display Name" $headersList = preg_split('/,/', $this->options['headers'], -1, PREG_SPLIT_NO_EMPTY); if (is_array($headersList)) { $this->headers = array(); foreach ($headersList as $nameEqualValue) { $nameEqualsValueArray = explode('=', $nameEqualValue, 2); // col1=Column 1 Display Name if (count($nameEqualsValueArray) >= 2) { $this->headers[$nameEqualsValueArray[0]] = $nameEqualsValueArray[1]; } } } } } }