<?php include_once '../doc-typo3-funcs.php'; $doxygen_vars = array( "title" => "TYPO3 4.0.1: typo3_src-4.0.1/t3lib/class.t3lib_install.php Source File", "datetime" => "Sat Dec 2 19:22:18 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?> <!-- Generated by Doxygen 1.4.6 --> <div class="tabs"> <ul> <li><a href="main.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="classes.html"><span>Classes</span></a></li> <li id="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> <li> <form action="search.php" method="get"> <table cellspacing="0" cellpadding="0" border="0"> <tr> <td><label> <u>S</u>earch for </label></td> <td><input type="text" name="query" value="" size="20" accesskey="s"/></td> </tr> </table> </form> </li> </ul></div> <div class="nav"> <a class="el" href="dir_c8daf1ad746050abf985cc546c89e248.html">typo3_src-4.0.1</a> » <a class="el" href="dir_9d0e5c424a38b69aeeedc616a9634e5f.html">t3lib</a></div> <h1>class.t3lib_install.php</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <?php <a name="l00002"></a>00002 <span class="comment">/***************************************************************</span> <a name="l00003"></a>00003 <span class="comment">* Copyright notice</span> <a name="l00004"></a>00004 <span class="comment">*</span> <a name="l00005"></a>00005 <span class="comment">* (c) 1999-2006 Kasper Skaarhoj (kasperYYYY@typo3.com)</span> <a name="l00006"></a>00006 <span class="comment">* All rights reserved</span> <a name="l00007"></a>00007 <span class="comment">*</span> <a name="l00008"></a>00008 <span class="comment">* This script is part of the TYPO3 project. The TYPO3 project is</span> <a name="l00009"></a>00009 <span class="comment">* free software; you can redistribute it and/or modify</span> <a name="l00010"></a>00010 <span class="comment">* it under the terms of the GNU General Public License as published by</span> <a name="l00011"></a>00011 <span class="comment">* the Free Software Foundation; either version 2 of the License, or</span> <a name="l00012"></a>00012 <span class="comment">* (at your option) any later version.</span> <a name="l00013"></a>00013 <span class="comment">*</span> <a name="l00014"></a>00014 <span class="comment">* The GNU General Public License can be found at</span> <a name="l00015"></a>00015 <span class="comment">* http://www.gnu.org/copyleft/gpl.html.</span> <a name="l00016"></a>00016 <span class="comment">* A copy is found in the textfile GPL.txt and important notices to the license</span> <a name="l00017"></a>00017 <span class="comment">* from the author is found in LICENSE.txt distributed with these scripts.</span> <a name="l00018"></a>00018 <span class="comment">*</span> <a name="l00019"></a>00019 <span class="comment">*</span> <a name="l00020"></a>00020 <span class="comment">* This script is distributed in the hope that it will be useful,</span> <a name="l00021"></a>00021 <span class="comment">* but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00022"></a>00022 <span class="comment">* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span> <a name="l00023"></a>00023 <span class="comment">* GNU General Public License for more details.</span> <a name="l00024"></a>00024 <span class="comment">*</span> <a name="l00025"></a>00025 <span class="comment">* This copyright notice MUST APPEAR in all copies of the script!</span> <a name="l00026"></a>00026 <span class="comment">***************************************************************/</span> <a name="l00074"></a>00074 require_once(PATH_t3lib.'<span class="keyword">class</span>.t3lib_sqlparser.php'); <a name="l00075"></a>00075 <a name="l00083"></a><a class="code" href="classt3lib__install.html">00083</a> <span class="keyword">class </span><a class="code" href="classt3lib__install.html">t3lib_install</a> { <a name="l00084"></a>00084 <a name="l00085"></a>00085 <a name="l00086"></a>00086 <span class="comment">// External, Static</span> <a name="l00087"></a><a class="code" href="classt3lib__install.html#6b670ef92746549feb1c20331c4dea24">00087</a> var <a class="code" href="classt3lib__install.html#6b670ef92746549feb1c20331c4dea24">$updateIdentity</a> = ''; <span class="comment">// Set to string which identifies the script using this class.</span> <a name="l00088"></a><a class="code" href="classt3lib__install.html#dea22f3e3f8b3a7d219b08cf930b49e0">00088</a> var <a class="code" href="classt3lib__install.html#dea22f3e3f8b3a7d219b08cf930b49e0">$deletedPrefixKey</a> = 'zzz_deleted_'; <span class="comment">// Prefix used for tables/fields when deleted/renamed.</span> <a name="l00089"></a><a class="code" href="classt3lib__install.html#77f29d4278cdc87e2566a4c94ed9bbf2">00089</a> var <a class="code" href="classt3lib__install.html#77f29d4278cdc87e2566a4c94ed9bbf2">$dbUpdateCheckboxPrefix</a> = 'TYPO3_INSTALL[database_update]'; <span class="comment">// Prefix for checkbox fields when updating database.</span> <a name="l00090"></a><a class="code" href="classt3lib__install.html#af7313647c28109d2f1daa1acc788950">00090</a> var <a class="code" href="classt3lib__install.html#af7313647c28109d2f1daa1acc788950">$localconf_addLinesOnly</a> = 0; <span class="comment">// If this is set, modifications to localconf.php is done by adding new lines to the array only. If unset, existing values are recognized and changed.</span> <a name="l00091"></a><a class="code" href="classt3lib__install.html#009e194656f2d2152f5c1a9229052cbe">00091</a> var <a class="code" href="classt3lib__install.html#009e194656f2d2152f5c1a9229052cbe">$localconf_editPointToken</a> = 'INSTALL SCRIPT EDIT POINT TOKEN - all lines after <span class="keyword">this</span> points may be changed by the install script!'; <span class="comment">// If set and addLinesOnly is disabled, lines will be change only if they are after this token (on a single line!) in the file</span> <a name="l00092"></a><a class="code" href="classt3lib__install.html#200c480c285f408cbfbc597b0f3963bd">00092</a> var <a class="code" href="classt3lib__install.html#200c480c285f408cbfbc597b0f3963bd">$allowUpdateLocalConf</a> = 0; <span class="comment">// If true, this class will allow the user to update the localconf.php file. Is set true in the init.php file.</span> <a name="l00093"></a><a class="code" href="classt3lib__install.html#598aa7dff053f7cbbe6e8d93a357c6c6">00093</a> var <a class="code" href="classt3lib__install.html#598aa7dff053f7cbbe6e8d93a357c6c6">$backPath</a> = '../'; <span class="comment">// Backpath (used for icons etc.)</span> <a name="l00094"></a>00094 <a name="l00095"></a><a class="code" href="classt3lib__install.html#8514e5c875c61a9467ade42957e1a39f">00095</a> var <a class="code" href="classt3lib__install.html#8514e5c875c61a9467ade42957e1a39f">$multiplySize</a> = 1; <span class="comment">// Multiplier of SQL field size (for char, varchar and text fields)</span> <a name="l00096"></a>00096 <a name="l00097"></a>00097 <span class="comment">// Internal, dynamic:</span> <a name="l00098"></a><a class="code" href="classt3lib__install.html#6d2f39391ceaf95ac7c80246fa62bea5">00098</a> var <a class="code" href="classt3lib__install.html#6d2f39391ceaf95ac7c80246fa62bea5">$setLocalconf</a> = 0; <span class="comment">// Used to indicate that a value is change in the line-array of localconf and that it should be written.</span> <a name="l00099"></a><a class="code" href="classt3lib__install.html#63f736d8c5343f3d99074cdff22cfa84">00099</a> var <a class="code" href="classt3lib__install.html#63f736d8c5343f3d99074cdff22cfa84">$messages</a> = array(); <span class="comment">// Used to set (error)messages from the executing functions like mail-sending, writing Localconf and such</span> <a name="l00100"></a><a class="code" href="classt3lib__install.html#3528090ce4be407ce61c9f14d430c7ee">00100</a> var <a class="code" href="classt3lib__install.html#3528090ce4be407ce61c9f14d430c7ee">$touchedLine</a> = 0; <span class="comment">// updated with line in localconf.php file that was changed.</span> <a name="l00101"></a>00101 <a name="l00102"></a>00102 <a name="l00108"></a><a class="code" href="classt3lib__install.html#d62e104aa6e02ffe901486ecce540e8c">00108</a> function <a class="code" href="classt3lib__install.html#d62e104aa6e02ffe901486ecce540e8c">t3lib_install</a>() { <a name="l00109"></a>00109 <span class="keywordflow">if</span> ($GLOBALS['TYPO3_CONF_VARS']['SYS']['multiplyDBfieldSize']>= 1 && $GLOBALS['TYPO3_CONF_VARS']['SYS']['multiplyDBfieldSize']<=5) { <a name="l00110"></a>00110 $this->multiplySize = (double)$GLOBALS['TYPO3_CONF_VARS']['SYS']['multiplyDBfieldSize']; <a name="l00111"></a>00111 } <a name="l00112"></a>00112 } <a name="l00113"></a>00113 <a name="l00114"></a>00114 <a name="l00115"></a>00115 <a name="l00116"></a>00116 <span class="comment">/**************************************</span> <a name="l00117"></a>00117 <span class="comment"> *</span> <a name="l00118"></a>00118 <span class="comment"> * Writing to localconf.php</span> <a name="l00119"></a>00119 <span class="comment"> *</span> <a name="l00120"></a>00120 <span class="comment"></span> <a name="l00121"></a>00121 <span class="comment"> **************************************/</span> <a name="l00122"></a>00122 <a name="l00132"></a><a class="code" href="classt3lib__install.html#4e657820881dd7db5e406f0a4ce1b0fc">00132</a> function <a class="code" href="classt3lib__install.html#4e657820881dd7db5e406f0a4ce1b0fc">setValueInLocalconfFile</a>(&$line_array, $variable, $value) { <a name="l00133"></a>00133 <span class="keywordflow">if</span> (!$this-><a class="code" href="classt3lib__install.html#372409ca2e8fd909bc31f784074a920b">checkForBadString</a>($value)) <span class="keywordflow">return</span> 0; <a name="l00134"></a>00134 <a name="l00135"></a>00135 <span class="comment">// Initialize:</span> <a name="l00136"></a>00136 $found = 0; <a name="l00137"></a>00137 $this->touchedLine = ''; <a name="l00138"></a>00138 $commentKey = '## '; <a name="l00139"></a>00139 $inArray = in_array($commentKey.$this->localconf_editPointToken,$line_array); <a name="l00140"></a>00140 $tokenSet = ($this->localconf_editPointToken && !$inArray); <span class="comment">// Flag is set if the token should be set but is not yet...</span> <a name="l00141"></a>00141 $stopAtToken = ($this->localconf_editPointToken && $inArray); <a name="l00142"></a>00142 $comment = ' Modified or inserted by '.$this->updateIdentity.<span class="charliteral">'.'</span>; <a name="l00143"></a>00143 <a name="l00144"></a>00144 <span class="comment">// Search for variable name:</span> <a name="l00145"></a>00145 <span class="keywordflow">if</span> (!$this->localconf_addLinesOnly && !$tokenSet) { <a name="l00146"></a>00146 $line_array = array_reverse($line_array); <a name="l00147"></a>00147 foreach($line_array as $k => $v) { <a name="l00148"></a>00148 $v2 = trim($v); <a name="l00149"></a>00149 <span class="keywordflow">if</span> ($stopAtToken && !strcmp($v2,$commentKey.$this->localconf_editPointToken)) <span class="keywordflow">break</span>; <span class="comment">// If stopAtToken and token found, break out of the loop..</span> <a name="l00150"></a>00150 <span class="keywordflow">if</span> (!strcmp(substr($v2,0,strlen($variable.<span class="charliteral">' '</span>)),$variable.<span class="charliteral">' '</span>)) { <a name="l00151"></a>00151 $mainparts = explode($variable,$v,2); <a name="l00152"></a>00152 <span class="keywordflow">if</span> (count($mainparts)==2) { <span class="comment">// should ALWAYS be....</span> <a name="l00153"></a>00153 $subparts = explode('<span class="comment">//',$mainparts[1],2);</span> <a name="l00154"></a>00154 $line_array[$k] = $mainparts[0].$variable.<span class="stringliteral">" = '"</span>.$this-><a class="code" href="classt3lib__install.html#a642771748cdfc71ba537a2ed6cd97e2">slashValueForSingleDashes</a>($value).<span class="stringliteral">"'; "</span>.('<span class="comment">//'.$comment.str_replace($comment,'',$subparts[1]));</span> <a name="l00155"></a>00155 $this->touchedLine = count($line_array)-$k-1; <a name="l00156"></a>00156 $found = 1; <a name="l00157"></a>00157 <span class="keywordflow">break</span>; <a name="l00158"></a>00158 } <a name="l00159"></a>00159 } <a name="l00160"></a>00160 } <a name="l00161"></a>00161 $line_array = array_reverse($line_array); <a name="l00162"></a>00162 } <a name="l00163"></a>00163 <span class="keywordflow">if</span> (!$found) { <a name="l00164"></a>00164 <span class="keywordflow">if</span> ($tokenSet) { <a name="l00165"></a>00165 $line_array[] = $commentKey.$this->localconf_editPointToken; <a name="l00166"></a>00166 $line_array[] = ''; <a name="l00167"></a>00167 } <a name="l00168"></a>00168 $line_array[] = $variable.<span class="stringliteral">" = '"</span>.$this-><a class="code" href="classt3lib__install.html#a642771748cdfc71ba537a2ed6cd97e2">slashValueForSingleDashes</a>($value).<span class="stringliteral">"'; // "</span>.$comment; <a name="l00169"></a>00169 $this->touchedLine = -1; <a name="l00170"></a>00170 } <a name="l00171"></a>00171 $this->messages[] = $variable.<span class="stringliteral">" = '"</span>.htmlspecialchars($value).<span class="stringliteral">"'"</span>; <a name="l00172"></a>00172 $this->setLocalconf = 1; <a name="l00173"></a>00173 } <a name="l00174"></a>00174 <a name="l00183"></a><a class="code" href="classt3lib__install.html#6afcc833d9df4684ef1711963b1cf226">00183</a> function <a class="code" href="classt3lib__install.html#6afcc833d9df4684ef1711963b1cf226">writeToLocalconf_control</a>($inlines='',$absFullPath='') { <a name="l00184"></a>00184 $tmpExt = '.TMP.php'; <a name="l00185"></a>00185 $writeToLocalconf_dat['file'] = $absFullPath ? $absFullPath : PATH_typo3conf.'localconf.php'; <a name="l00186"></a>00186 $writeToLocalconf_dat['tmpfile'] = $writeToLocalconf_dat['file'].$tmpExt; <a name="l00187"></a>00187 <a name="l00188"></a>00188 <span class="comment">// Checking write state of localconf.php:</span> <a name="l00189"></a>00189 <span class="keywordflow">if</span> (!$this->allowUpdateLocalConf) { <a name="l00190"></a>00190 die(<span class="stringliteral">"->allowUpdateLocalConf flag in the install object is not set and therefore 'localconf.php' cannot be altered."</span>); <a name="l00191"></a>00191 } <a name="l00192"></a>00192 <span class="keywordflow">if</span> (!@is_writable($writeToLocalconf_dat['file'])) { <a name="l00193"></a>00193 die($writeToLocalconf_dat['file'].' is not writable!'); <a name="l00194"></a>00194 } <a name="l00195"></a>00195 <a name="l00196"></a>00196 <span class="comment">// Splitting localconf.php file into lines:</span> <a name="l00197"></a>00197 $lines = explode(chr(10),str_replace(chr(13),'',trim(t3lib_div::getUrl($writeToLocalconf_dat['file'])))); <a name="l00198"></a>00198 $writeToLocalconf_dat['endLine'] = array_pop($lines); <span class="comment">// Getting "? >" ending.</span> <a name="l00199"></a>00199 <a name="l00200"></a>00200 <span class="comment">// Checking if "updated" line was set by this tool - if so remove old line.</span> <a name="l00201"></a>00201 $updatedLine = array_pop($lines); <a name="l00202"></a>00202 $writeToLocalconf_dat['updatedText'] = '<span class="comment">// Updated by '.$this->updateIdentity.' ';</span> <a name="l00203"></a>00203 <span class="keywordflow">if</span> (!strstr($updatedLine, $writeToLocalconf_dat['updatedText'])) { <a name="l00204"></a>00204 array_push($lines,$updatedLine); <a name="l00205"></a>00205 } <a name="l00206"></a>00206 <a name="l00207"></a>00207 <span class="keywordflow">if</span> (is_array($inlines)) { <span class="comment">// Setting a line and write:</span> <a name="l00208"></a>00208 <span class="comment">// Setting configuration</span> <a name="l00209"></a>00209 $updatedLine = $writeToLocalconf_dat['updatedText'].date('d-m-Y H:i:s'); <a name="l00210"></a>00210 array_push($inlines,$updatedLine); <a name="l00211"></a>00211 array_push($inlines,$writeToLocalconf_dat['endLine']); <a name="l00212"></a>00212 <a name="l00213"></a>00213 <span class="keywordflow">if</span> ($this->setLocalconf) { <a name="l00214"></a>00214 $success = FALSE; <a name="l00215"></a>00215 <span class="keywordflow">if</span> (!<a class="code" href="classt3lib__div.html#d6d2efcc3ac43b2bf2ebacc98d000292">t3lib_div::writeFile</a>($writeToLocalconf_dat['tmpfile'],implode(chr(10),$inlines))) { <a name="l00216"></a>00216 $msg = 'typo3conf/localconf.php'.$tmpExt.' could not be written - maybe a write access problem?'; <a name="l00217"></a>00217 } <a name="l00218"></a>00218 elseif (strcmp(t3lib_div::getUrl($writeToLocalconf_dat['tmpfile']), implode(chr(10),$inlines))) { <a name="l00219"></a>00219 @unlink($writeToLocalconf_dat['tmpfile']); <a name="l00220"></a>00220 $msg = 'typo3conf/localconf.php'.$tmpExt.' was NOT written properly (written content didn\'t match file content) - maybe a disk space problem?'; <a name="l00221"></a>00221 } <a name="l00222"></a>00222 elseif (!@copy($writeToLocalconf_dat['tmpfile'],$writeToLocalconf_dat['file'])) { <a name="l00223"></a>00223 $msg = 'typo3conf/localconf.php could not be replaced by typo3conf/localconf.php'.$tmpExt.' - maybe a write access problem?'; <a name="l00224"></a>00224 } <a name="l00225"></a>00225 <span class="keywordflow">else</span> { <a name="l00226"></a>00226 @unlink($writeToLocalconf_dat['tmpfile']); <a name="l00227"></a>00227 $success = TRUE; <a name="l00228"></a>00228 $msg = 'Configuration written to typo3conf/localconf.php'; <a name="l00229"></a>00229 } <a name="l00230"></a>00230 $this->messages[]= $msg; <a name="l00231"></a>00231 <a name="l00232"></a>00232 <span class="keywordflow">if</span> ($success) { <a name="l00233"></a>00233 <span class="keywordflow">return</span> '<span class="keywordflow">continue</span>'; <a name="l00234"></a>00234 } <span class="keywordflow">else</span> { <a name="l00235"></a>00235 <a class="code" href="classt3lib__div.html#56f257eb9149c7e62b1d3db0caddab64">t3lib_div::sysLog</a>($msg, 'Core', 3); <a name="l00236"></a>00236 <span class="keywordflow">return</span> 'nochange'; <a name="l00237"></a>00237 } <a name="l00238"></a>00238 } <span class="keywordflow">else</span> { <a name="l00239"></a>00239 <span class="keywordflow">return</span> 'nochange'; <a name="l00240"></a>00240 } <a name="l00241"></a>00241 } <span class="keywordflow">else</span> { <span class="comment">// Return lines found in localconf.php</span> <a name="l00242"></a>00242 <span class="keywordflow">return</span> $lines; <a name="l00243"></a>00243 } <a name="l00244"></a>00244 } <a name="l00245"></a>00245 <a name="l00253"></a><a class="code" href="classt3lib__install.html#372409ca2e8fd909bc31f784074a920b">00253</a> function <a class="code" href="classt3lib__install.html#372409ca2e8fd909bc31f784074a920b">checkForBadString</a>($string) { <a name="l00254"></a>00254 <span class="keywordflow">return</span> preg_match('/['.chr(10).chr(13).']/',$string) ? FALSE : TRUE; <a name="l00255"></a>00255 } <a name="l00256"></a>00256 <a name="l00264"></a><a class="code" href="classt3lib__install.html#a642771748cdfc71ba537a2ed6cd97e2">00264</a> function <a class="code" href="classt3lib__install.html#a642771748cdfc71ba537a2ed6cd97e2">slashValueForSingleDashes</a>($value) { <a name="l00265"></a>00265 $value = str_replace(<span class="stringliteral">"'.chr(10).'"</span>, '###INSTALL_TOOL_LINEBREAK###', $value); <a name="l00266"></a>00266 $value = str_replace(<span class="stringliteral">"'"</span>,<span class="stringliteral">"\'"</span>,str_replace(<span class="charliteral">'\\'</span>,'\\\\',$value)); <a name="l00267"></a>00267 $value = str_replace('###INSTALL_TOOL_LINEBREAK###', <span class="stringliteral">"'.chr(10).'"</span>, $value); <a name="l00268"></a>00268 <a name="l00269"></a>00269 <span class="keywordflow">return</span> $value; <a name="l00270"></a>00270 } <a name="l00271"></a>00271 <a name="l00272"></a>00272 <a name="l00273"></a>00273 <a name="l00274"></a>00274 <a name="l00275"></a>00275 <a name="l00276"></a>00276 <a name="l00277"></a>00277 <a name="l00278"></a>00278 <a name="l00279"></a>00279 <a name="l00280"></a>00280 <a name="l00281"></a>00281 <span class="comment">/*************************************</span> <a name="l00282"></a>00282 <span class="comment"> *</span> <a name="l00283"></a>00283 <span class="comment"> * SQL</span> <a name="l00284"></a>00284 <span class="comment"> *</span> <a name="l00285"></a>00285 <span class="comment"> *************************************/</span> <a name="l00286"></a>00286 <a name="l00293"></a><a class="code" href="classt3lib__install.html#c33eafc4c4fd46e6a28b4e99b84537b7">00293</a> function <a class="code" href="classt3lib__install.html#c33eafc4c4fd46e6a28b4e99b84537b7">getFieldDefinitions_sqlContent</a>($sqlContent) { <a name="l00294"></a>00294 $lines = <a class="code" href="classt3lib__div.html#cfb87d585b85e9b32841bde40beaa96c">t3lib_div::trimExplode</a>(chr(10), $sqlContent,1); <a name="l00295"></a>00295 $isTable = ''; <a name="l00296"></a>00296 $total = Array(); <a name="l00297"></a>00297 <a name="l00298"></a>00298 foreach($lines as $value) { <a name="l00299"></a>00299 <span class="keywordflow">if</span> ($value[0]!=<span class="charliteral">'#'</span>) { <a name="l00300"></a>00300 <span class="keywordflow">if</span> (!$isTable) { <a name="l00301"></a>00301 $parts = explode(<span class="charliteral">' '</span>,$value); <a name="l00302"></a>00302 <span class="keywordflow">if</span> ($parts[0]=='CREATE' && $parts[1]=='TABLE') { <a name="l00303"></a>00303 $isTable = str_replace( <span class="charliteral">'`'</span>, '', $parts[2]); <a name="l00304"></a>00304 <span class="keywordflow">if</span> (TYPO3_OS=='WIN') { <span class="comment">// tablenames are always lowercase on windows!</span> <a name="l00305"></a>00305 $isTable = strtolower($isTable); <a name="l00306"></a>00306 } <a name="l00307"></a>00307 } <a name="l00308"></a>00308 } <span class="keywordflow">else</span> { <a name="l00309"></a>00309 <span class="keywordflow">if</span> (substr($value,0,1)==<span class="charliteral">')'</span> && substr($value,-1)==<span class="charliteral">';'</span>) { <a name="l00310"></a>00310 $ttype = array(); <a name="l00311"></a>00311 preg_match('/(ENGINE|TYPE)=([a-zA-Z]*)/',$value,$ttype); <a name="l00312"></a>00312 $total[$isTable]['extra']['ttype'] = $ttype[2]; <a name="l00313"></a>00313 $isTable = ''; <a name="l00314"></a>00314 } <span class="keywordflow">else</span> { <a name="l00315"></a>00315 $lineV = preg_replace('/,$/<span class="charliteral">','</span>',$value); <a name="l00316"></a>00316 $lineV = str_replace('UNIQUE KEY', 'UNIQUE', $lineV); <a name="l00317"></a>00317 $parts = explode(<span class="charliteral">' '</span>,$lineV,2); <a name="l00318"></a>00318 <a name="l00319"></a>00319 <span class="comment">// Make sure there is no default value when auto_increment is set</span> <a name="l00320"></a>00320 <span class="keywordflow">if</span>(stristr($parts[1],'auto_increment')) { <a name="l00321"></a>00321 $parts[1] = preg_replace('/ <span class="keywordflow">default</span> \'0\'/i<span class="charliteral">','</span>',$parts[1]); <a name="l00322"></a>00322 } <a name="l00323"></a>00323 <span class="comment">// "default" is always lower-case</span> <a name="l00324"></a>00324 <span class="keywordflow">if</span>(strstr($parts[1], ' DEFAULT ')) { <a name="l00325"></a>00325 $parts[1] = str_replace(' DEFAULT ', ' <span class="keywordflow">default</span> ', $parts[1]); <a name="l00326"></a>00326 } <a name="l00327"></a>00327 <a name="l00328"></a>00328 <span class="comment">// Change order of "default" and "null" statements</span> <a name="l00329"></a>00329 $parts[1] = preg_replace('/(.*) (<span class="keywordflow">default</span> .*) (NOT NULL)/', '$1 $3 $2', $parts[1]); <a name="l00330"></a>00330 $parts[1] = preg_replace('/(.*) (<span class="keywordflow">default</span> .*) (NULL)/', '$1 $3 $2', $parts[1]); <a name="l00331"></a>00331 <a name="l00332"></a>00332 <span class="comment">// Remove double blanks</span> <a name="l00333"></a>00333 $parts[1] = preg_replace('/([^ ]+)[ ]+([^ ]+)/', '$1 $2', $parts[1]); <a name="l00334"></a>00334 <a name="l00335"></a>00335 <span class="keywordflow">if</span> ($parts[0]!='PRIMARY' && $parts[0]!='KEY' && $parts[0]!='UNIQUE') { <a name="l00336"></a>00336 $key = str_replace(<span class="charliteral">'`'</span>, '', $parts[0]); <a name="l00337"></a>00337 $total[$isTable]['fields'][$key] = $parts[1]; <a name="l00338"></a>00338 } <span class="keywordflow">else</span> { <a name="l00339"></a>00339 $newParts = explode(<span class="charliteral">' '</span>,$parts[1],2); <a name="l00340"></a>00340 $key = str_replace(<span class="charliteral">'`'</span>, '', ($parts[0]=='PRIMARY'?$parts[0]:$newParts[0])); <a name="l00341"></a>00341 $total[$isTable]['keys'][$key] = str_replace(<span class="charliteral">'`'</span>, '', $lineV); <a name="l00342"></a>00342 } <a name="l00343"></a>00343 } <a name="l00344"></a>00344 } <a name="l00345"></a>00345 } <a name="l00346"></a>00346 } <a name="l00347"></a>00347 <a name="l00348"></a>00348 $this-><a class="code" href="classt3lib__install.html#5d50fc38e25c1b23de1733decb89dd71">getFieldDefinitions_sqlContent_parseTypes</a>($total); <a name="l00349"></a>00349 <span class="keywordflow">return</span> $total; <a name="l00350"></a>00350 } <a name="l00351"></a>00351 <a name="l00361"></a><a class="code" href="classt3lib__install.html#5d50fc38e25c1b23de1733decb89dd71">00361</a> function <a class="code" href="classt3lib__install.html#5d50fc38e25c1b23de1733decb89dd71">getFieldDefinitions_sqlContent_parseTypes</a>(&$total) { <a name="l00362"></a>00362 <a name="l00363"></a>00363 $mSize = (double)$this->multiplySize; <a name="l00364"></a>00364 <span class="keywordflow">if</span> ($mSize > 1) { <a name="l00365"></a>00365 <a name="l00366"></a>00366 <span class="comment">// Init SQL parser:</span> <a name="l00367"></a>00367 $sqlParser = <a class="code" href="classt3lib__div.html#b47f8a8e8be44b79a0b8064dcd427bc1">t3lib_div::makeInstance</a>('<a class="code" href="classt3lib__sqlparser.html">t3lib_sqlparser</a>'); <a name="l00368"></a>00368 foreach($total as $table => $cfg) { <a name="l00369"></a>00369 <span class="keywordflow">if</span> (is_array($cfg['fields'])) { <a name="l00370"></a>00370 foreach($cfg['fields'] as $fN => $fType) { <a name="l00371"></a>00371 $orig_fType = $fType; <a name="l00372"></a>00372 $fInfo = $sqlParser->parseFieldDef($fType); <a name="l00373"></a>00373 <a name="l00374"></a>00374 <span class="keywordflow">switch</span>($fInfo['fieldType']) { <a name="l00375"></a>00375 <span class="keywordflow">case</span> '<span class="keywordtype">char</span>': <a name="l00376"></a>00376 <span class="keywordflow">case</span> 'varchar': <a name="l00377"></a>00377 $newSize = round($fInfo['value']*$mSize); <a name="l00378"></a>00378 <a name="l00379"></a>00379 <span class="keywordflow">if</span> ($newSize <= 255) { <a name="l00380"></a>00380 $fInfo['value'] = $newSize; <a name="l00381"></a>00381 } <span class="keywordflow">else</span> { <a name="l00382"></a>00382 $fInfo = array( <a name="l00383"></a>00383 'fieldType' => 'text', <a name="l00384"></a>00384 'featureIndex' => array( <a name="l00385"></a>00385 'NOTNULL' => array( <a name="l00386"></a>00386 'keyword' => 'NOT NULL' <a name="l00387"></a>00387 ) <a name="l00388"></a>00388 ) <a name="l00389"></a>00389 ); <a name="l00390"></a>00390 } <a name="l00391"></a>00391 <span class="keywordflow">break</span>; <a name="l00392"></a>00392 <span class="keywordflow">case</span> 'tinytext': <a name="l00393"></a>00393 $fInfo['fieldType'] = 'text'; <a name="l00394"></a>00394 <span class="keywordflow">break</span>; <a name="l00395"></a>00395 } <a name="l00396"></a>00396 <a name="l00397"></a>00397 $total[$table]['fields'][$fN] = $sqlParser->compileFieldCfg($fInfo); <a name="l00398"></a>00398 <span class="keywordflow">if</span> ($sqlParser->parse_error) die($sqlParser->parse_error); <a name="l00399"></a>00399 } <a name="l00400"></a>00400 } <a name="l00401"></a>00401 } <a name="l00402"></a>00402 } <a name="l00403"></a>00403 } <a name="l00404"></a>00404 <a name="l00410"></a><a class="code" href="classt3lib__install.html#4f2e9d698250da7cd8d6cf7ea5e57a3c">00410</a> function <a class="code" href="classt3lib__install.html#4f2e9d698250da7cd8d6cf7ea5e57a3c">getFieldDefinitions_database</a>() { <a name="l00411"></a>00411 $total = array(); <a name="l00412"></a>00412 $GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db); <a name="l00413"></a>00413 echo $GLOBALS['TYPO3_DB']->sql_error(); <a name="l00414"></a>00414 <a name="l00415"></a>00415 $tables = $GLOBALS['TYPO3_DB']->admin_get_tables(TYPO3_db); <a name="l00416"></a>00416 foreach($tables as $tableName) { <a name="l00417"></a>00417 <a name="l00418"></a>00418 <span class="comment">// Fields:</span> <a name="l00419"></a>00419 $fieldInformation = $GLOBALS['TYPO3_DB']->admin_get_fields($tableName); <a name="l00420"></a>00420 foreach($fieldInformation as $fN => $fieldRow) { <a name="l00421"></a>00421 $total[$tableName]['fields'][$fN] = $this-><a class="code" href="classt3lib__install.html#bbd5a9341a48317013502d426cb793ff">assembleFieldDefinition</a>($fieldRow); <a name="l00422"></a>00422 } <a name="l00423"></a>00423 <a name="l00424"></a>00424 <span class="comment">// Keys:</span> <a name="l00425"></a>00425 $keyInformation = $GLOBALS['TYPO3_DB']->admin_get_keys($tableName); <a name="l00426"></a>00426 foreach($keyInformation as $kN => $keyRow) { <a name="l00427"></a>00427 $tempKeys[$tableName][$keyRow['Key_name']][$keyRow['Seq_in_index']] = $keyRow['Column_name']; <a name="l00428"></a>00428 $tempKeysPrefix[$tableName][$keyRow['Key_name']]= ($keyRow['Key_name']=='PRIMARY<span class="charliteral">'?'</span>PRIMARY KEY':($keyRow['Non_unique']?'KEY<span class="charliteral">':'</span>UNIQUE').<span class="charliteral">' '</span>.$keyRow['Key_name']); <a name="l00429"></a>00429 } <a name="l00430"></a>00430 } <a name="l00431"></a>00431 <a name="l00432"></a>00432 <span class="comment">// Compile information:</span> <a name="l00433"></a>00433 <span class="keywordflow">if</span> (is_array($tempKeys)) { <a name="l00434"></a>00434 foreach($tempKeys as $table => $keyInf) { <a name="l00435"></a>00435 foreach($keyInf as $kName => $index) { <a name="l00436"></a>00436 ksort($index); <a name="l00437"></a>00437 $total[$table]['keys'][$kName] = $tempKeysPrefix[$table][$kName].' ('.implode(<span class="charliteral">','</span>,$index).<span class="charliteral">')'</span>; <a name="l00438"></a>00438 } <a name="l00439"></a>00439 } <a name="l00440"></a>00440 } <a name="l00441"></a>00441 <a name="l00442"></a>00442 <span class="keywordflow">return</span> $total; <a name="l00443"></a>00443 } <a name="l00444"></a>00444 <a name="l00455"></a><a class="code" href="classt3lib__install.html#6728d7574ed1fc0bf6f3fad86b23a8ff">00455</a> function getDatabaseExtra($FDsrc, $FDcomp, $onlyTableList='',$ignoreNotNullWhenComparing=<span class="keyword">true</span>) { <a name="l00456"></a>00456 $extraArr = array(); <a name="l00457"></a>00457 $diffArr = array(); <a name="l00458"></a>00458 <a name="l00459"></a>00459 <span class="keywordflow">if</span> (is_array($FDsrc)) { <a name="l00460"></a>00460 foreach($FDsrc as $table => $info) { <a name="l00461"></a>00461 <span class="keywordflow">if</span> (!strlen($onlyTableList) || <a class="code" href="classt3lib__div.html#d994a5608365c288d051d6022d4e9976">t3lib_div::inList</a>($onlyTableList, $table)) { <a name="l00462"></a>00462 <span class="keywordflow">if</span> (!isset($FDcomp[$table])) { <a name="l00463"></a>00463 $extraArr[$table] = $info; <span class="comment">// If the table was not in the FDcomp-array, the result array is loaded with that table.</span> <a name="l00464"></a>00464 $extraArr[$table]['whole_table']=1; <a name="l00465"></a>00465 } <span class="keywordflow">else</span> { <a name="l00466"></a>00466 $keyTypes = explode(<span class="charliteral">','</span>,'fields,keys'); <a name="l00467"></a>00467 foreach($keyTypes as $theKey) { <a name="l00468"></a>00468 <span class="keywordflow">if</span> (is_array($info[$theKey])) { <a name="l00469"></a>00469 foreach($info[$theKey] as $fieldN => $fieldC) { <a name="l00470"></a>00470 $fieldN = str_replace(<span class="charliteral">'`'</span>,'',$fieldN); <a name="l00471"></a>00471 <span class="keywordflow">if</span> (!isset($FDcomp[$table][$theKey][$fieldN])) { <a name="l00472"></a>00472 $extraArr[$table][$theKey][$fieldN] = $fieldC; <a name="l00473"></a>00473 } elseif (strcmp($FDcomp[$table][$theKey][$fieldN], $ignoreNotNullWhenComparing?str_replace(' NOT NULL', '', $fieldC):$fieldC)) { <a name="l00474"></a>00474 $diffArr[$table][$theKey][$fieldN] = $fieldC; <a name="l00475"></a>00475 $diffArr_cur[$table][$theKey][$fieldN] = $FDcomp[$table][$theKey][$fieldN]; <a name="l00476"></a>00476 } <a name="l00477"></a>00477 } <a name="l00478"></a>00478 } <a name="l00479"></a>00479 } <a name="l00480"></a>00480 } <a name="l00481"></a>00481 } <a name="l00482"></a>00482 } <a name="l00483"></a>00483 } <a name="l00484"></a>00484 <a name="l00485"></a>00485 $output = array( <a name="l00486"></a>00486 'extra' => $extraArr, <a name="l00487"></a>00487 'diff' => $diffArr, <a name="l00488"></a>00488 'diff_currentValues' => $diffArr_cur <a name="l00489"></a>00489 ); <a name="l00490"></a>00490 <a name="l00491"></a>00491 <span class="keywordflow">return</span> $output; <a name="l00492"></a>00492 } <a name="l00493"></a>00493 <a name="l00501"></a><a class="code" href="classt3lib__install.html#08052c1401f7aea66b39550bceca66f4">00501</a> function getUpdateSuggestions($diffArr,$keyList='extra,diff') { <a name="l00502"></a>00502 $statements = array(); <a name="l00503"></a>00503 $deletedPrefixKey = $this->deletedPrefixKey; <a name="l00504"></a>00504 $remove = 0; <a name="l00505"></a>00505 <span class="keywordflow">if</span> ($keyList == 'remove') { <a name="l00506"></a>00506 $remove = 1; <a name="l00507"></a>00507 $keyList = 'extra'; <a name="l00508"></a>00508 } <a name="l00509"></a>00509 $keyList = explode(<span class="charliteral">','</span>,$keyList); <a name="l00510"></a>00510 foreach($keyList as $theKey) { <a name="l00511"></a>00511 <span class="keywordflow">if</span> (is_array($diffArr[$theKey])) { <a name="l00512"></a>00512 foreach($diffArr[$theKey] as $table => $info) { <a name="l00513"></a>00513 $whole_table = array(); <a name="l00514"></a>00514 <span class="keywordflow">if</span> (is_array($info['fields'])) { <a name="l00515"></a>00515 foreach($info['fields'] as $fN => $fV) { <a name="l00516"></a>00516 <span class="keywordflow">if</span> ($info['whole_table']) { <a name="l00517"></a>00517 $whole_table[]=$fN.<span class="charliteral">' '</span>.$fV; <a name="l00518"></a>00518 } <span class="keywordflow">else</span> { <a name="l00519"></a>00519 <span class="keywordflow">if</span> ($theKey=='extra') { <a name="l00520"></a>00520 <span class="keywordflow">if</span> ($remove) { <a name="l00521"></a>00521 <span class="keywordflow">if</span> (substr($fN,0,strlen($deletedPrefixKey))!=$deletedPrefixKey) { <a name="l00522"></a>00522 $statement = 'ALTER TABLE '.$table.' CHANGE '.$fN.<span class="charliteral">' '</span>.$deletedPrefixKey.$fN.<span class="charliteral">' '</span>.$fV.<span class="charliteral">';'</span>; <a name="l00523"></a>00523 $statements['change'][md5($statement)] = $statement; <a name="l00524"></a>00524 } <span class="keywordflow">else</span> { <a name="l00525"></a>00525 $statement = 'ALTER TABLE '.$table.' DROP '.$fN.<span class="charliteral">';'</span>; <a name="l00526"></a>00526 $statements['drop'][md5($statement)] = $statement; <a name="l00527"></a>00527 } <a name="l00528"></a>00528 } <span class="keywordflow">else</span> { <a name="l00529"></a>00529 $statement = 'ALTER TABLE '.$table.' ADD '.$fN.<span class="charliteral">' '</span>.$fV.<span class="charliteral">';'</span>; <a name="l00530"></a>00530 $statements['add'][md5($statement)] = $statement; <a name="l00531"></a>00531 } <a name="l00532"></a>00532 } elseif ($theKey=='diff') { <a name="l00533"></a>00533 $statement = 'ALTER TABLE '.$table.' CHANGE '.$fN.<span class="charliteral">' '</span>.$fN.<span class="charliteral">' '</span>.$fV.<span class="charliteral">';'</span>; <a name="l00534"></a>00534 $statements['change'][md5($statement)] = $statement; <a name="l00535"></a>00535 $statements['change_currentValue'][md5($statement)] = $diffArr['diff_currentValues'][$table]['fields'][$fN]; <a name="l00536"></a>00536 } <a name="l00537"></a>00537 } <a name="l00538"></a>00538 } <a name="l00539"></a>00539 } <a name="l00540"></a>00540 <span class="keywordflow">if</span> (is_array($info['keys'])) { <a name="l00541"></a>00541 foreach($info['keys'] as $fN => $fV) { <a name="l00542"></a>00542 <span class="keywordflow">if</span> ($info['whole_table']) { <a name="l00543"></a>00543 $whole_table[] = $fV; <a name="l00544"></a>00544 } <span class="keywordflow">else</span> { <a name="l00545"></a>00545 <span class="keywordflow">if</span> ($theKey=='extra') { <a name="l00546"></a>00546 <span class="keywordflow">if</span> ($remove) { <a name="l00547"></a>00547 $statement = 'ALTER TABLE '.$table.($fN=='PRIMARY' ? ' DROP PRIMARY KEY' : ' DROP KEY '.$fN).<span class="charliteral">';'</span>; <a name="l00548"></a>00548 $statements['drop'][md5($statement)] = $statement; <a name="l00549"></a>00549 } <span class="keywordflow">else</span> { <a name="l00550"></a>00550 $statement = 'ALTER TABLE '.$table.' ADD '.$fV.<span class="charliteral">';'</span>; <a name="l00551"></a>00551 $statements['add'][md5($statement)] = $statement; <a name="l00552"></a>00552 } <a name="l00553"></a>00553 } elseif ($theKey=='diff') { <a name="l00554"></a>00554 $statement = 'ALTER TABLE '.$table.($fN=='PRIMARY' ? ' DROP PRIMARY KEY' : ' DROP KEY '.$fN).<span class="charliteral">';'</span>; <a name="l00555"></a>00555 $statements['change'][md5($statement)] = $statement; <a name="l00556"></a>00556 $statement = 'ALTER TABLE '.$table.' ADD '.$fV.<span class="charliteral">';'</span>; <a name="l00557"></a>00557 $statements['change'][md5($statement)] = $statement; <a name="l00558"></a>00558 } <a name="l00559"></a>00559 } <a name="l00560"></a>00560 } <a name="l00561"></a>00561 } <a name="l00562"></a>00562 <span class="keywordflow">if</span> ($info['whole_table']) { <a name="l00563"></a>00563 <span class="keywordflow">if</span> ($remove) { <a name="l00564"></a>00564 <span class="keywordflow">if</span> (substr($table,0,strlen($deletedPrefixKey))!=$deletedPrefixKey) { <a name="l00565"></a>00565 $statement = 'ALTER TABLE '.$table.' RENAME '.$deletedPrefixKey.$table.<span class="charliteral">';'</span>; <a name="l00566"></a>00566 $statements['change_table'][md5($statement)]=$statement; <a name="l00567"></a>00567 } <span class="keywordflow">else</span> { <a name="l00568"></a>00568 $statement = 'DROP TABLE '.$table.<span class="charliteral">';'</span>; <a name="l00569"></a>00569 $statements['drop_table'][md5($statement)]=$statement; <a name="l00570"></a>00570 } <a name="l00571"></a>00571 <span class="comment">// count:</span> <a name="l00572"></a>00572 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, ''); <a name="l00573"></a>00573 list($count) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res); <a name="l00574"></a>00574 $statements['tables_count'][md5($statement)] = $count?'Records in table: '.$count:''; <a name="l00575"></a>00575 } <span class="keywordflow">else</span> { <a name="l00576"></a>00576 $statement = 'CREATE TABLE '.$table.<span class="stringliteral">" (\n"</span>.implode(<span class="stringliteral">",\n"</span>,$whole_table).<span class="stringliteral">"\n)"</span>; <a name="l00577"></a>00577 $statement .= ($info['extra']['ttype']) ? ' TYPE='.$info['extra']['ttype'].<span class="charliteral">';'</span> : <span class="charliteral">';'</span>; <a name="l00578"></a>00578 $statements['create_table'][md5($statement)]=$statement; <a name="l00579"></a>00579 } <a name="l00580"></a>00580 } <a name="l00581"></a>00581 } <a name="l00582"></a>00582 } <a name="l00583"></a>00583 } <a name="l00584"></a>00584 <a name="l00585"></a>00585 <span class="keywordflow">return</span> $statements; <a name="l00586"></a>00586 } <a name="l00587"></a>00587 <a name="l00594"></a><a class="code" href="classt3lib__install.html#bbd5a9341a48317013502d426cb793ff">00594</a> function assembleFieldDefinition($row) { <a name="l00595"></a>00595 $field[] = $row['Type']; <a name="l00596"></a>00596 <span class="comment">// if (!$row['Null']) { $field[] = 'NOT NULL'; }</span> <a name="l00597"></a>00597 <span class="keywordflow">if</span> (!strstr($row['Type'],'blob') && !strstr($row['Type'],'text')) { <a name="l00598"></a>00598 <span class="comment">// Add a default value if the field is not auto-incremented (these fields never have a default definition).</span> <a name="l00599"></a>00599 <span class="keywordflow">if</span> (!stristr($row['Extra'],'auto_increment')) { <a name="l00600"></a>00600 $field[] = '<span class="keywordflow">default</span> '.<span class="stringliteral">"'"</span>.(addslashes($row['Default'])).<span class="stringliteral">"'"</span>; <a name="l00601"></a>00601 } <a name="l00602"></a>00602 } <a name="l00603"></a>00603 <span class="keywordflow">if</span> ($row['Extra']) { $field[] = $row['Extra']; } <a name="l00604"></a>00604 <a name="l00605"></a>00605 <span class="keywordflow">return</span> implode(<span class="charliteral">' '</span>,$field); <a name="l00606"></a>00606 } <a name="l00607"></a>00607 <a name="l00616"></a><a class="code" href="classt3lib__install.html#bfe7d54f2b914291cfb97081b1e79867">00616</a> function getStatementArray($sqlcode,$removeNonSQL=0,$query_regex='') { <a name="l00617"></a>00617 $sqlcodeArr = explode(chr(10),$sqlcode); <a name="l00618"></a>00618 <a name="l00619"></a>00619 <span class="comment">// Based on the assumption that the sql-dump has</span> <a name="l00620"></a>00620 $statementArray = array(); <a name="l00621"></a>00621 $statementArrayPointer = 0; <a name="l00622"></a>00622 <a name="l00623"></a>00623 foreach($sqlcodeArr as $line => $linecontent) { <a name="l00624"></a>00624 $is_set = 0; <a name="l00625"></a>00625 <span class="keywordflow">if</span>(stristr($linecontent,'auto_increment')) { <a name="l00626"></a>00626 $linecontent = eregi_replace(' <span class="keywordflow">default</span> \'0\'<span class="charliteral">','</span>',$linecontent); <a name="l00627"></a>00627 } <a name="l00628"></a>00628 <a name="l00629"></a>00629 <span class="keywordflow">if</span> (!$removeNonSQL || (strcmp(trim($linecontent),'') && substr(trim($linecontent),0,1)!=<span class="charliteral">'#'</span> && substr(trim($linecontent),0,2)!='--')) { <span class="comment">// '--' is seen as mysqldump comments from server version 3.23.49</span> <a name="l00630"></a>00630 $statementArray[$statementArrayPointer].= $linecontent; <a name="l00631"></a>00631 $is_set = 1; <a name="l00632"></a>00632 } <a name="l00633"></a>00633 <span class="keywordflow">if</span> (substr(trim($linecontent),-1)==<span class="charliteral">';'</span>) { <a name="l00634"></a>00634 <span class="keywordflow">if</span> (isset($statementArray[$statementArrayPointer])) { <a name="l00635"></a>00635 <span class="keywordflow">if</span> (!trim($statementArray[$statementArrayPointer]) || ($query_regex && !eregi($query_regex,trim($statementArray[$statementArrayPointer])))) { <a name="l00636"></a>00636 unset($statementArray[$statementArrayPointer]); <a name="l00637"></a>00637 } <a name="l00638"></a>00638 } <a name="l00639"></a>00639 $statementArrayPointer++; <a name="l00640"></a>00640 } elseif ($is_set) { <a name="l00641"></a>00641 $statementArray[$statementArrayPointer].=chr(10); <a name="l00642"></a>00642 } <a name="l00643"></a>00643 } <a name="l00644"></a>00644 <span class="keywordflow">return</span> $statementArray; <a name="l00645"></a>00645 } <a name="l00646"></a>00646 <a name="l00654"></a><a class="code" href="classt3lib__install.html#80496771fc33d1c00ace852fc23be2de">00654</a> function getCreateTables($statements, $insertCountFlag=0) { <a name="l00655"></a>00655 $crTables = array(); <a name="l00656"></a>00656 $insertCount = array(); <a name="l00657"></a>00657 foreach($statements as $line => $linecontent) { <a name="l00658"></a>00658 $reg = array(); <a name="l00659"></a>00659 <span class="keywordflow">if</span> (eregi('^create[[:space:]]*table[[:space:]]*[`]?([[:alnum:]_]*)[`]?',substr($linecontent,0,100),$reg)) { <a name="l00660"></a>00660 $table = trim($reg[1]); <a name="l00661"></a>00661 <span class="keywordflow">if</span> ($table) { <a name="l00662"></a>00662 <span class="keywordflow">if</span> (TYPO3_OS=='WIN') { $table=strtolower($table); } <span class="comment">// table names are always lowercase on Windows!</span> <a name="l00663"></a>00663 $sqlLines = explode(chr(10), $linecontent); <a name="l00664"></a>00664 foreach($sqlLines as $k=>$v) { <a name="l00665"></a>00665 <span class="keywordflow">if</span>(stristr($v,'auto_increment')) { <a name="l00666"></a>00666 $sqlLines[$k] = eregi_replace(' <span class="keywordflow">default</span> \'0\'<span class="charliteral">','</span>',$v); <a name="l00667"></a>00667 } <a name="l00668"></a>00668 } <a name="l00669"></a>00669 $linecontent = implode(chr(10), $sqlLines); <a name="l00670"></a>00670 $crTables[$table] = $linecontent; <a name="l00671"></a>00671 } <a name="l00672"></a>00672 } elseif ($insertCountFlag && eregi('^insert[[:space:]]*into[[:space:]]*[`]?([[:alnum:]_]*)[`]?',substr($linecontent,0,100),$reg)) { <a name="l00673"></a>00673 $nTable = trim($reg[1]); <a name="l00674"></a>00674 $insertCount[$nTable]++; <a name="l00675"></a>00675 } <a name="l00676"></a>00676 } <a name="l00677"></a>00677 <a name="l00678"></a>00678 <span class="keywordflow">return</span> array($crTables,$insertCount); <a name="l00679"></a>00679 } <a name="l00680"></a>00680 <a name="l00688"></a><a class="code" href="classt3lib__install.html#f9ae968320dec0cea4d54ecc338b7e6e">00688</a> function getTableInsertStatements($statements, $table) { <a name="l00689"></a>00689 $outStatements=array(); <a name="l00690"></a>00690 foreach($statements as $line => $linecontent) { <a name="l00691"></a>00691 $reg = array(); <a name="l00692"></a>00692 <span class="keywordflow">if</span> (preg_match('/^insert[[:space:]]*into[[:space:]]*[`]?([[:alnum:]_]*)[`]?/i',substr($linecontent,0,100),$reg)) { <a name="l00693"></a>00693 $nTable = trim($reg[1]); <a name="l00694"></a>00694 <span class="keywordflow">if</span> ($nTable && !strcmp($table,$nTable)) { <a name="l00695"></a>00695 $outStatements[]=$linecontent; <a name="l00696"></a>00696 } <a name="l00697"></a>00697 } <a name="l00698"></a>00698 } <a name="l00699"></a>00699 <span class="keywordflow">return</span> $outStatements; <a name="l00700"></a>00700 } <a name="l00701"></a>00701 <a name="l00709"></a><a class="code" href="classt3lib__install.html#1ae7a71f7dfee7d57371689abf48204a">00709</a> function performUpdateQueries($arr,$keyArr) { <a name="l00710"></a>00710 <span class="keywordflow">if</span> (is_array($arr)) { <a name="l00711"></a>00711 foreach($arr as $key => $string) { <a name="l00712"></a>00712 <span class="keywordflow">if</span> (isset($keyArr[$key]) && $keyArr[$key]) { <a name="l00713"></a>00713 $GLOBALS['TYPO3_DB']->admin_query($string); <a name="l00714"></a>00714 } <a name="l00715"></a>00715 } <a name="l00716"></a>00716 } <a name="l00717"></a>00717 } <a name="l00718"></a>00718 <a name="l00725"></a><a class="code" href="classt3lib__install.html#5f4e0444e19cbe54a3b40b699bd0f617">00725</a> function getListOfTables() { <a name="l00726"></a>00726 $whichTables = $GLOBALS['TYPO3_DB']->admin_get_tables(TYPO3_db); <a name="l00727"></a>00727 <span class="keywordflow">return</span> $whichTables; <a name="l00728"></a>00728 } <a name="l00729"></a>00729 <a name="l00741"></a><a class="code" href="classt3lib__install.html#0268392f04741c0e2418cad512b12886">00741</a> function generateUpdateDatabaseForm_checkboxes($arr,$label,$checked=1,$iconDis=0,$currentValue=array(),$cVfullMsg=0) { <a name="l00742"></a>00742 $out = array(); <a name="l00743"></a>00743 <span class="keywordflow">if</span> (is_array($arr)) { <a name="l00744"></a>00744 foreach($arr as $key => $string) { <a name="l00745"></a>00745 $ico = ''; <a name="l00746"></a>00746 <span class="keywordflow">if</span> ($iconDis) { <a name="l00747"></a>00747 <span class="keywordflow">if</span> (stristr($string,' user_')) { <a name="l00748"></a>00748 $ico.= '<img src=<span class="stringliteral">"'.$this->backPath.'gfx/icon_warning.gif"</span> width=<span class="stringliteral">"18"</span> height=<span class="stringliteral">"16"</span> align=<span class="stringliteral">"top"</span> alt=<span class="stringliteral">""</span> /><strong>(USER) </strong>'; <a name="l00749"></a>00749 } <a name="l00750"></a>00750 <span class="keywordflow">if</span> (stristr($string,' app_')) { <a name="l00751"></a>00751 $ico.= '<img src=<span class="stringliteral">"'.$this->backPath.'gfx/icon_warning.gif"</span> width=<span class="stringliteral">"18"</span> height=<span class="stringliteral">"16"</span> align=<span class="stringliteral">"top"</span> alt=<span class="stringliteral">""</span> /><strong>(APP) </strong>'; <a name="l00752"></a>00752 } <a name="l00753"></a>00753 <span class="keywordflow">if</span> (stristr($string,' ttx_') || stristr($string,' tx_')) { <a name="l00754"></a>00754 $ico.= '<img src=<span class="stringliteral">"'.$this->backPath.'gfx/icon_warning.gif"</span> width=<span class="stringliteral">"18"</span> height=<span class="stringliteral">"16"</span> align=<span class="stringliteral">"top"</span> alt=<span class="stringliteral">""</span> /><strong>(EXT) </strong>'; <a name="l00755"></a>00755 } <a name="l00756"></a>00756 } <a name="l00757"></a>00757 $out[]=' <a name="l00758"></a>00758 <tr> <a name="l00759"></a>00759 <td valign=<span class="stringliteral">"top"</span>><input type=<span class="stringliteral">"checkbox"</span> <span class="keywordtype">id</span>=<span class="stringliteral">"db-'.$key.'"</span> name=<span class="stringliteral">"'.$this->dbUpdateCheckboxPrefix.'['.$key.']"</span> value=<span class="stringliteral">"1"</span>'.($checked?' checked=<span class="stringliteral">"checked"</span><span class="charliteral">':'</span>').' /></td> <a name="l00760"></a>00760 <td nowrap=<span class="stringliteral">"nowrap"</span>><label <span class="keywordflow">for</span>=<span class="stringliteral">"db-'.$key.'"</span>>'.nl2br($ico.htmlspecialchars($string)).'</label></td> <a name="l00761"></a>00761 </tr>'; <a name="l00762"></a>00762 <span class="keywordflow">if</span> (isset($currentValue[$key])) { <a name="l00763"></a>00763 $out[]=' <a name="l00764"></a>00764 <tr> <a name="l00765"></a>00765 <td valign=<span class="stringliteral">"top"</span>></td> <a name="l00766"></a>00766 <td nowrap=<span class="stringliteral">"nowrap"</span> style=<span class="stringliteral">"color : #666666;"</span>>'.nl2br((!$cVfullMsg?<span class="stringliteral">"Current value: "</span>:<span class="stringliteral">""</span>).'<em>'.$currentValue[$key].'</em>').'</td> <a name="l00767"></a>00767 </tr>'; <a name="l00768"></a>00768 } <a name="l00769"></a>00769 } <a name="l00770"></a>00770 <a name="l00771"></a>00771 <span class="comment">// Compile rows:</span> <a name="l00772"></a>00772 $content = ' <a name="l00773"></a>00773 <!-- Update database fields / tables --> <a name="l00774"></a>00774 <h3>'.$label.'</h3> <a name="l00775"></a>00775 <table border=<span class="stringliteral">"0"</span> cellpadding=<span class="stringliteral">"2"</span> cellspacing=<span class="stringliteral">"2"</span> <span class="keyword">class</span>=<span class="stringliteral">"update-db-fields"</span>>'.implode('',$out).' <a name="l00776"></a>00776 </table>'; <a name="l00777"></a>00777 } <a name="l00778"></a>00778 <a name="l00779"></a>00779 <span class="keywordflow">return</span> $content; <a name="l00780"></a>00780 } <a name="l00781"></a>00781 } <a name="l00782"></a>00782 <a name="l00783"></a>00783 <span class="keywordflow">if</span> (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/<span class="keyword">class</span>.<a class="code" href="classt3lib__install.html">t3lib_install</a>.php']) { <a name="l00784"></a>00784 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/<span class="keyword">class</span>.<a class="code" href="classt3lib__install.html">t3lib_install</a>.php']); <a name="l00785"></a>00785 } <a name="l00786"></a>00786 ?> </pre></div><?php include_once '../doc-typo3-funcs.php'; get_footer(); ?>