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'];
             }
         }
         if (isset($this->options['filter'])) {
             require_once 'CF7FilterParser.php';
             require_once 'DereferenceShortcodeVars.php';
             $this->rowFilter = new CF7FilterParser();
             $this->rowFilter->setComparisonValuePreprocessor(new DereferenceShortcodeVars());
             $this->rowFilter->parseFilterString($this->options['filter']);
             if ($this->debug) {
                 echo '<pre>\'' . $this->options['filter'] . "'\n";
                 print_r($this->rowFilter->tree);
                 echo '</pre>';
             }
         } else {
             if (isset($this->options['search'])) {
                 require_once 'CF7SearchEvaluator.php';
                 $this->rowFilter = new CF7SearchEvaluator();
                 $this->rowFilter->setSearch($this->options['search']);
             }
         }
     }
 }
 /**
  * Fetch next row into variable
  * @return bool if next row exists
  */
 public function nextRow()
 {
     if (!$this->results) {
         return false;
     }
     while (true) {
         if (!$this->onFirstRow) {
             $this->row = mysql_fetch_assoc($this->results);
         }
         $this->onFirstRow = false;
         if (!$this->row) {
             mysql_free_result($this->results);
             $this->results = null;
             return false;
         }
         // Format the date
         $submitTime = $this->row['Submitted'];
         $this->row['submit_time'] = $submitTime;
         $this->row['Submitted'] = $this->plugin->formatDate($submitTime);
         // Determine if row is filtered
         if ($this->rowFilter) {
             $match = $this->rowFilter->evaluate($this->row);
             if (!$match) {
                 continue;
             }
         }
         $this->idx += 1;
         if ($this->limitStart && $this->idx < $this->limitStart) {
             continue;
         }
         if ($this->limitEnd && $this->idx >= $this->limitEnd) {
             while (mysql_fetch_array($this->results)) {
             }
             mysql_free_result($this->results);
             $this->results = null;
             $this->row = null;
             return false;
         }
         // Keep the unformatted submitTime if needed
         if ($this->submitTimeKeyName) {
             $this->row[$this->submitTimeKeyName] = $submitTime;
         }
         break;
     }
     if (!$this->row) {
         mysql_free_result($this->results);
         $this->results = null;
     }
     return $this->row ? true : false;
 }
Exemplo n.º 3
0
 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];
                     }
                 }
             }
         }
     }
 }