function _ProcessCodeContainingIterators($st) { // recursive /* ex. $st="somehtmlcode<!--__OEITSTART-->iteratorcode<!--__OEITEND--><!--__OEITSTART-->iteratorcode<!--__OEITEND-->somehtmlcode" where iteratorcode may = somehtmlcode<!--__OEITSTART-->subiteratorcode<!--__OEITEND-->somehtmlcode<!--__OEITSTART-->subiteratorcode<!--__OEITEND-->somehtmlcode apply values (HTML modifiers) in somehtmlcode (non-iterator parts) according to current values and row counters - _ApplyValuesInHTMLCode() then process each top-level iterator block - _ProcessIterator(), who recursively calls _ProcessCodeContainingIterators(iterator's inner code) for each row returns output html code string with all values and iterators applied See comments for _ProcessIterator() * * * */ //echo "Entering _ProcessCodeContainingIterators()<br/>"; if (!isset($st[0])) { return $st; } // fast check for non-empty string $r = ""; $posLastIterEnd = 0; while (true) { $tm_start2 = microtime(true); $posIterator = strpos($st, $this->ITSTART, $posLastIterEnd); // find next <!--__OEITSTART // apply inline HTML modifiers to not-yet-processed html BEFORE iterator block, or remaining code till the end if no more iterators: $codeOutsideIterator = $posIterator !== false ? substr($st, $posLastIterEnd, $posIterator - $posLastIterEnd) : substr($st, $posLastIterEnd); if ($codeOutsideIterator) { //echo '$codeOutsideIterator:';var_dump($codeOutsideIterator); $tm_start = microtime(true); $r .= $this->_ApplyValuesInHTMLCode($codeOutsideIterator); // outside-iterator code //echo "====TIME USED _ApplyValuesInHTMLCode::".((microtime(true) - $tm_start)*1000)." <br/>"; //echo "\$posIterator = $posIterator "; } if ($posIterator === false) { break; } // all processed // find substring corresponding to iterator (note that iterator may include subiterators): $tm_start = microtime(true); $posLastIterEnd = OEDynUtils::FindEndBlock($st, $posIterator + 1, $this->ITSTART, $this->ITEND); if ($posLastIterEnd < 0) { return $st; } // error, non-terminated block $posLastIterEnd += strlen($this->ITEND); // position just after the iterator //echo "\$posLastIterEnd = $posLastIterEnd "; // recursive-generate iterator code and apply it to output //echo '$codeIterator:';var_dump(substr($st, $posIterator, $posLastIterEnd-$posIterator)); $tm_start = microtime(true); $xCurrentRow = OEDataContainer::$iCurrentRow; $r .= $this->_ProcessIterator(substr($st, $posIterator, $posLastIterEnd - $posIterator)); // inside-iterator code OEDataContainer::$iCurrentRow = $xCurrentRow; // restore global row counter //echo "====TIME USED _ProcessIterator::".((microtime(true) - $tm_start)*1000)." <br/>"; //echo "====TIME USED inside CI while::".((microtime(true) - $tm_start2)*1000)." <br/>"; } //echo "_ProcessCodeContainingIterators:";var_dump($r); return $r; }
function NextRow() { if (empty($this->iRows)) { return false; } // no columns to iterate $advance = false; foreach ($this->iRows as $column => $row) { if (!array_key_exists($column, $this->Values)) { //echo 'Iterator ended 01 at '.$column.'<br/>'; return false; // column not found in container } if (!isset($this->lastGetNRows[$column])) { continue; } $numRows = $this->lastGetNRows[$column]; if ($row + 1 >= $numRows) { //echo 'Iterator ended 02 at '.$column.'<br/>'; // return false; // already at last row, stop iteration continue; } $advance = true; $this->iRow++; $this->iRows[$column]++; // select next row OEDataContainer::$iCurrentRow = $this->iRow; } return $advance; // next row selected in at least one of columns }