function _GetPropertyValueIndex(&$el, $propertyName) { // example: $propertyName = "Image.URL": get $el's property "Image.URL" and return index of value (in DBValues array) linked to it if (!$propertyName || !$el || empty($el['Properties'])) { return -1; } $property = OEDynUtils::_FindInArray($el['Properties'], $propertyName); if ($property === null) { return -1; } return intval($property); // index in DBValues array }
protected function _connect($params) { //echo 'Connecting start:';var_dump($this); if (!$this->sqliteOk || !isset($params['dbname'])) { $this->_sqliteerrorexit('SQLite engine not initialized'); return false; } // make sure directory for the database file exists: global $dynManager; $relPath = isset($dynManager->JSData['PageRelPath']) ? $dynManager->JSData['PageRelPath'] : ''; if (!$this->_handleDBFolder($relPath, $params['dbname'])) { return false; } if ($this->sqliteVers >= 3) { if (!defined('SQLITE3_INTEGER')) { // sometimes these constants are not defined define('SQLITE3_INTEGER', 1); define('SQLITE3_FLOAT', 2); define('SQLITE3_TEXT', 3); define('SQLITE3_BLOB', 4); } if (!$this->modePDO) { // direct SQLite try { $this->sqlConn = new SQLite3($relPath . $params['dbname']); } catch (Exception $ex) { $message = 'SQLite database creation error : cannot create database. It may happen if the full path to your project contains accented characters or other non-basic symbols. Please copy your project folder to another place, ex. C:\\OEProjects\\MySite(1), and try again<br/><br/>' . 'SQLite - erreur de creation de base de donnees: impossible de creer la base. Ca peut arriver si le chemin complet vers votre projet contient des caracteres accentes (speciaux) ou d\'autres symboles non-basiques. Veuillez copier le dossier de votre projet a un autre emplacement, par exemple C:\\OEProjects\\MonSite(1), et re-essayez<br/><br/>'; OEDynUtils::OutputStop($message); // stop PHP } $this->typeCorrespondence['s'] = SQLITE3_TEXT; $this->typeCorrespondence['i'] = SQLITE3_INTEGER; $this->typeCorrespondence['d'] = SQLITE3_FLOAT; } else { // PDO mode $this->sqlConn = new PDO('sqlite:' . $relPath . $params['dbname']); $this->sqlConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // check $this->typeCorrespondence['s'] = defined('PDO::PARAM_STR') ? PDO::PARAM_STR : PDO_PARAM_STR; $this->typeCorrespondence['i'] = defined('PDO::PARAM_INT') ? PDO::PARAM_INT : PDO_PARAM_INT; $this->typeCorrespondence['d'] = $this->typeCorrespondence['s']; //echo 'Connecting PDO SQLite:';var_dump($this->sqlConn);echo ' db:'.$relPath.$params['dbname'].'<br>'; } if (!$this->sqlConn) { $this->_sqliteerrorexit('SQLite engine not initialized'); } return !!$this->sqlConn; } else { $this->_sqliteerrorexit('SQLite engine not initialized'); return false; } }
function __SplitCodeIntoColumns($st, &$allDBValues) { /* Split inner iterator code into "output columns" - synchronous parts, normally corresponding to <td> tags. If there is no split, code is considered to be 1 column "Output column" is, for example, a column of DBGrid (html table showing query results) Main reason to split is that a column may have rows with ROWSPANS, if data is grouped (ex. several values in column B corresponding to 1 value in column A) * * * */ //echo "Entering __SplitCodeIntoColumns()<br/>";var_dump($st); $arCodeParts = array(); $arCodeParts[]['code'] = ''; $arCodeParts[0]['codeNoSubIt'] = ''; $arCodeParts[0]['usedDBValues'] = array(); if ($st === null || $st === '' || strpos($st, '</td>') === false) { // no parts return $this->__AddAllCodeAsOnePart($st, $arCodeParts, $allDBValues); // a single part, no html columns } // go through all <td> that are not in subiterators: $currLen = 0; // part of string currently processed or already processed $lastPartEnd = -1; // pos of last character of code already added to $arCodeParts $posAfterLastIterator = 0; // pos of first character after last-found subiterator $inTD = false; // currently inside <td> $posTD = -1; // position of last-found <td> tag in $st $partInd = -1; // part counter, modified in __AddAndAnalyseCodePart() while (true) { // process till next subiterator or till end of code string: $posIterator = strpos($st, $this->ITSTART, $posAfterLastIterator); // find next <!--__OEITSTART $stBeforeIterator = $posIterator !== false ? substr($st, $posAfterLastIterator, $posIterator - $posAfterLastIterator) : substr($st, $posAfterLastIterator); $currLen = $posAfterLastIterator + strlen($stBeforeIterator); //echo "\$stBeforeIterator:<br/>";var_dump($stBeforeIterator); // the following loop applies to substring before/between/after subiterator block(s): // in the currently processed substring, process <td></td> as well as html outside them // (note that beginning of <td> may be before last subiterator, i.e. in one of previous substrings, not in $stBeforeIterator) while (true) { if ($inTD) { // currently inside <td> // find </td> nd see if it's inside $stBeforeIterator (before next subiterator): $pos = OEDynUtils::FindEndBlock($st, $posTD + 1, '<td', '</td>'); // find closing </td>, consider possible sub-tables inside <td> if ($pos === false || $pos < $posTD) { echo '<br/><br/>!!!!!!!!!!!!IT ERR 1<br/>$st<br/>'; return $this->__AddAllCodeAsOnePart($st, $arCodeParts, $allDBValues); } // error - <td> tag is not closed $pos += strlen('</td>') - 1; // pos of last character of code part if ($pos >= $currLen) { break; } // </td> is after subiterator, not in current substring; process in next WHILE iteration // add and analyse new code part corresponding to <td>..</td>: $this->__AddAndAnalyseCodePart($st, $posTD, $pos, $partInd, $arCodeParts, $allDBValues); // ex ....[<td....</td>].... $lastPartEnd = $pos; $inTD = false; // quitting <td> //echo "outTD<br/>"; } $endReached = $lastPartEnd + 1 === strlen($st); // true if no more code left if ($endReached) { return $arCodeParts; } // all processed if (!$inTD) { // currently outside <td> $pos = strpos($st, '<td', $lastPartEnd + 1); if ($pos === false) { // no more <td>, but some code remains at the end - add as last part and exit: $this->__AddAndAnalyseCodePart($st, $lastPartEnd + 1, strlen($st), $partInd, $arCodeParts, $allDBValues); // ex ....</td>[</tr>] return $arCodeParts; } if ($pos >= $currLen) { break; } // <td> is after subiterator, not in current substring; process in next WHILE iteration // new <td> found: //echo "inTD<br/>"; $posTD = $pos; $inTD = true; // now we are inside <td> // if there's any code before this <td> (ex. <tr> at beginning of iterator) not yet added as a part, add new part: if ($posTD - ($lastPartEnd + 1) > 0) { $this->__AddAndAnalyseCodePart($st, $lastPartEnd + 1, $posTD - 1, $partInd, $arCodeParts, $allDBValues); // ex [<tr>]<td>.... $lastPartEnd = $posTD - 1; } } if (!$inTD) { break; } // no more parts } if ($posIterator === false) { echo '<br/><br/>!!!!!!!!!!!!IT ERR 0<br/>$st<br/>'; // error, normally should never happen return $this->__AddAllCodeAsOnePart($st, $arCodeParts, $allDBValues); } // Bypass subiterator: // find substring corresponding to iterator: $posAfterLastIterator = OEDynUtils::FindEndBlock($st, $posIterator + 1, $this->ITSTART, $this->ITEND); if ($posAfterLastIterator < 0) { echo '<br/><br/>!!!!!!!!!!!!IT ERR 2<br/>$st<br/>'; // error, missing end of subiterator return $this->__AddAllCodeAsOnePart($st, $arCodeParts, $allDBValues); } $posAfterLastIterator += strlen($this->ITEND); // position just after the iterator } return $arCodeParts; }
public static function RemoveBlocksFromString($st, $tagStartBlock, $tagEndBlock, $posStart = 0) { // Remove all blocks/substrings starting with $tagStartBlock and ending with $tagEndBlock, ex. "<div" and "</div>" removes all divs from html code if (empty($st)) { return $st; } $r = ""; $posLastEnd = $posStart; while (true) { // find bounds of next block: $posBlock = strpos($st, $tagStartBlock, $posLastEnd); $addstr = $posBlock !== false ? substr($st, $posLastEnd, $posBlock - $posLastEnd) : substr($st, $posLastEnd); $r .= $addstr; // add to result the substring before block (starts from 0 or from end of last block) or remaining part after all blocks if ($posBlock === false) { break; } // no more blocks $posLastEnd = OEDynUtils::FindEndBlock($st, $posBlock + 1, $tagStartBlock, $tagEndBlock); // end of this block if ($posLastEnd < 0) { return $st; } // error, non-terminated block $posLastEnd += strlen($tagEndBlock); // first character after this block } return $r; // = $st with all blocks removed }
function GetContainerTypeByInd($ind) { $containerName = $this->GetContainerNameByInd($ind); if (!$containerName) { return null; } // Special containers: switch ($containerName) { case 'FormInputs': case 'ConstVals': return "Special"; break; case 'FormattedItems': return "FI"; break; } // see if container is one of the actions' result, in which case return action type: $actions = $this->Manager->JSData['DynActions']; if (!$actions) { return; } // all action of this page $action = OEDynUtils::_FindByName($actions, $containerName); if ($action && !empty($action['Type'])) { return $action['Type']; // action's type, ex. 'DBGet' for result of db SELECT queries } return $containerName; }