Public Member Functions | |
| start ($itemlist, $tablelist, $MMtable='', $MMuid=0) | |
| Initialization of the class. | |
| readList ($itemlist) | |
| Explodes the item list and stores the parts in the internal arrays itemArray and tableArray from MM records. | |
| readMM ($tableName, $uid) | |
| Reads the record tablename/id into the internal arrays itemArray and tableArray from MM records. | |
| writeMM ($tableName, $uid, $prependTableName=0) | |
| Writes the internal itemArray to MM table:. | |
| getValueArray ($prependTableName='') | |
| After initialization you can extract an array of the elements from the object. | |
| convertPosNeg ($valueArray, $fTable, $nfTable) | |
| Converts id numbers from negative to positive. | |
| getFromDB () | |
| Reads all records from internal tableArray into the internal ->results array where keys are table names and for each table, records are stored with uids as their keys. | |
| readyForInterface () | |
| Prepare items from itemArray to be transferred to the TCEforms interface (as a comma list). | |
Public Attributes | |
| $fromTC = 1 | |
| $registerNonTableValues = 0 | |
| $tableArray = Array() | |
| $itemArray = Array() | |
| $nonTableArray = array() | |
| $additionalWhere = array() | |
| $checkIfDeleted = 1 | |
| $dbPaths = Array() | |
| $firstTable = '' | |
| $secondTable = '' | |
|
||||||||||||||||
|
Converts id numbers from negative to positive.
Definition at line 279 of file class.t3lib_loaddbgroup.php. References $val. 00279 {
00280 if (is_array($valueArray) && $fTable) {
00281 foreach($valueArray as $key => $val) {
00282 $val = strrev($val);
00283 $parts = explode('_',$val,2);
00284 $theID = strrev($parts[0]);
00285 $theTable = strrev($parts[1]);
00286
00287 if ( t3lib_div::testInt($theID) && (!$theTable || !strcmp($theTable,$fTable) || !strcmp($theTable,$nfTable)) ) {
00288 $valueArray[$key]= $theTable && strcmp($theTable,$fTable) ? $theID*-1 : $theID;
00289 }
00290 }
00291 }
00292 return $valueArray;
00293 }
|
|
|
Reads all records from internal tableArray into the internal ->results array where keys are table names and for each table, records are stored with uids as their keys. If $this->fromTC is set you can save a little memory since only uid,pid and a few other fields are selected.
Definition at line 301 of file class.t3lib_loaddbgroup.php. 00301 {
00302 // Traverses the tables listed:
00303 foreach($this->tableArray as $key => $val) {
00304 if (is_array($val)) {
00305 $itemList = implode(',',$val);
00306 if ($itemList) {
00307 $from = '*';
00308 if ($this->fromTC) {
00309 $from = 'uid,pid';
00310 if ($GLOBALS['TCA'][$key]['ctrl']['label']) {
00311 $from.= ','.$GLOBALS['TCA'][$key]['ctrl']['label']; // Titel
00312 }
00313 if ($GLOBALS['TCA'][$key]['ctrl']['thumbnail']) {
00314 $from.= ','.$GLOBALS['TCA'][$key]['ctrl']['thumbnail']; // Thumbnail
00315 }
00316 }
00317 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($from, $key, 'uid IN ('.$itemList.')'.$this->additionalWhere[$key]);
00318 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00319 $this->results[$key][$row['uid']]=$row;
00320 }
00321 }
00322 }
00323 }
00324 return $this->results;
00325 }
|
|
|
After initialization you can extract an array of the elements from the object. Use this function for that.
Definition at line 251 of file class.t3lib_loaddbgroup.php. 00251 {
00252 // INIT:
00253 $valueArray=Array();
00254 $tableC = count($this->tableArray);
00255
00256 // If there are tables in the table array:
00257 if ($tableC) {
00258 // If there are more than ONE table in the table array, then always prepend table names:
00259 $prep = ($tableC>1||$prependTableName) ? 1 : 0;
00260
00261 // Traverse the array of items:
00262 foreach($this->itemArray as $val) {
00263 $valueArray[]=(($prep && $val['table']!='_NO_TABLE') ? $val['table'].'_' : '').
00264 $val['id'];
00265 }
00266 }
00267 // Return the array
00268 return $valueArray;
00269 }
|
|
|
Explodes the item list and stores the parts in the internal arrays itemArray and tableArray from MM records.
Definition at line 140 of file class.t3lib_loaddbgroup.php. Referenced by start(). 00140 {
00141 if ((string)trim($itemlist)!='') {
00142 $tempItemArray = t3lib_div::trimExplode(',', $itemlist); // Changed to trimExplode 31/3 04; HMENU special type "list" didn't work if there were spaces in the list... I suppose this is better overall...
00143 foreach($tempItemArray as $key => $val) {
00144 $isSet = 0; // Will be set to "1" if the entry was a real table/id:
00145
00146 // Extract table name and id. This is un the formular [tablename]_[id] where table name MIGHT contain "_", hence the reversion of the string!
00147 $val = strrev($val);
00148 $parts = explode('_',$val,2);
00149 $theID = strrev($parts[0]);
00150
00151 // Check that the id IS an integer:
00152 if (t3lib_div::testInt($theID)) {
00153 // Get the table name: If a part of the exploded string, use that. Otherwise if the id number is LESS than zero, use the second table, otherwise the first table
00154 $theTable = trim($parts[1]) ? strrev(trim($parts[1])) : ($this->secondTable && $theID<0 ? $this->secondTable : $this->firstTable);
00155 // If the ID is not blank and the table name is among the names in the inputted tableList, then proceed:
00156 if ((string)$theID!='' && $theID && $theTable && isset($this->tableArray[$theTable])) {
00157 // Get ID as the right value:
00158 $theID = $this->secondTable ? abs(intval($theID)) : intval($theID);
00159 // Register ID/table name in internal arrays:
00160 $this->itemArray[$key]['id'] = $theID;
00161 $this->itemArray[$key]['table'] = $theTable;
00162 $this->tableArray[$theTable][] = $theID;
00163 // Set update-flag:
00164 $isSet=1;
00165 }
00166 }
00167
00168 // If it turns out that the value from the list was NOT a valid reference to a table-record, then we might still set it as a NO_TABLE value:
00169 if (!$isSet && $this->registerNonTableValues) {
00170 $this->itemArray[$key]['id'] = $tempItemArray[$key];
00171 $this->itemArray[$key]['table'] = '_NO_TABLE';
00172 $this->nonTableArray[] = $tempItemArray[$key];
00173 }
00174 }
00175 }
00176 }
|
|
||||||||||||
|
Reads the record tablename/id into the internal arrays itemArray and tableArray from MM records. You can call this function after start if you supply no list to start()
Definition at line 186 of file class.t3lib_loaddbgroup.php. Referenced by start(). 00186 {
00187 $key=0;
00188
00189 // Select all MM relations:
00190 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $tableName, 'uid_local='.intval($uid), '', 'sorting');
00191 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00192 $theTable = $row['tablenames'] ? $row['tablenames'] : $this->firstTable; // If tablesnames columns exists and contain a name, then this value is the table, else it's the the firstTable...
00193 if (($row['uid_foreign'] || $theTable=='pages') && $theTable && isset($this->tableArray[$theTable])) {
00194 $this->itemArray[$key]['id'] = $row['uid_foreign'];
00195 $this->itemArray[$key]['table'] = $theTable;
00196 $this->tableArray[$theTable][]= $row['uid_foreign'];
00197 } elseif ($this->registerNonTableValues) {
00198 $this->itemArray[$key]['id'] = $row['uid_foreign'];
00199 $this->itemArray[$key]['table'] = '_NO_TABLE';
00200 $this->nonTableArray[] = $row['uid_foreign'];
00201 }
00202 $key++;
00203 }
00204 $GLOBALS['TYPO3_DB']->sql_free_result($res);
00205 }
|
|
|
Prepare items from itemArray to be transferred to the TCEforms interface (as a comma list).
Definition at line 333 of file class.t3lib_loaddbgroup.php. 00333 {
00334 global $TCA;
00335
00336 if (!is_array($this->itemArray)) {return false;}
00337
00338 $output=array();
00339 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1); // For use when getting the paths....
00340 $titleLen=intval($GLOBALS['BE_USER']->uc['titleLen']);
00341
00342 foreach($this->itemArray as $key => $val) {
00343 $theRow = $this->results[$val['table']][$val['id']];
00344 if ($theRow && is_array($TCA[$val['table']])) {
00345 $label = t3lib_div::fixed_lgd_cs(strip_tags($theRow[$TCA[$val['table']]['ctrl']['label']]),$titleLen);
00346 $label = ($label)?$label:'[...]';
00347 $output[]=str_replace(',','',$val['table'].'_'.$val['id'].'|'.rawurlencode($label));
00348 }
00349 }
00350 return implode(',',$output);
00351 }
|
|
||||||||||||||||||||
|
Initialization of the class.
Definition at line 99 of file class.t3lib_loaddbgroup.php. References readList(), and readMM(). 00099 {
00100 // If the table list is "*" then all tables are used in the list:
00101 if (!strcmp(trim($tablelist),'*')) {
00102 $tablelist = implode(',',array_keys($GLOBALS['TCA']));
00103 }
00104
00105 // The tables are traversed and internal arrays are initialized:
00106 $tempTableArray = t3lib_div::trimExplode(',',$tablelist,1);
00107 foreach($tempTableArray as $key => $val) {
00108 $tName = trim($val);
00109 $this->tableArray[$tName] = Array();
00110 if ($this->checkIfDeleted && $GLOBALS['TCA'][$tName]['ctrl']['delete']) {
00111 $fieldN = $tName.'.'.$GLOBALS['TCA'][$tName]['ctrl']['delete'];
00112 $this->additionalWhere[$tName].=' AND NOT '.$fieldN;
00113 }
00114 }
00115
00116 if (is_array($this->tableArray)) {
00117 reset($this->tableArray);
00118 } else {return 'No tables!';}
00119
00120 // Set first and second tables:
00121 $this->firstTable = key($this->tableArray); // Is the first table
00122 next($this->tableArray);
00123 $this->secondTable = key($this->tableArray); // If the second table is set and the ID number is less than zero (later) then the record is regarded to come from the second table...
00124
00125 // Now, populate the internal itemArray and tableArray arrays:
00126 if ($MMtable) { // If MM, then call this function to do that:
00127 $this->readMM($MMtable,$MMuid);
00128 } else {
00129 // If not MM, then explode the itemlist by "," and traverse the list:
00130 $this->readList($itemlist);
00131 }
00132 }
|
|
||||||||||||||||
|
Writes the internal itemArray to MM table:.
Definition at line 215 of file class.t3lib_loaddbgroup.php. 00215 {
00216
00217 // Delete all relations:
00218 $GLOBALS['TYPO3_DB']->exec_DELETEquery($tableName, 'uid_local='.intval($uid));
00219
00220 // If there are tables...
00221 $tableC = count($this->tableArray);
00222 if ($tableC) {
00223 $prep = ($tableC>1||$prependTableName) ? 1 : 0;
00224 $c=0;
00225 $tName=array();
00226
00227 // For each item, insert it:
00228 foreach($this->itemArray as $val) {
00229 $c++;
00230
00231 $insertFields = array(
00232 'uid_local' => $uid,
00233 'uid_foreign' => $val['id'],
00234 'sorting' => $c
00235 );
00236 if ($prep || $val['table']=='_NO_TABLE') {
00237 $insertFields['tablenames'] = $val['table'];
00238 }
00239
00240 $GLOBALS['TYPO3_DB']->exec_INSERTquery($tableName, $insertFields);
00241 }
00242 }
00243 }
|
|
|
Definition at line 81 of file class.t3lib_loaddbgroup.php. |
|
|
Definition at line 82 of file class.t3lib_loaddbgroup.php. |
|
|
Definition at line 83 of file class.t3lib_loaddbgroup.php. |
|
|
Definition at line 84 of file class.t3lib_loaddbgroup.php. |
|
|
Reimplemented in FE_loadDBGroup. Definition at line 74 of file class.t3lib_loaddbgroup.php. |
|
|
Definition at line 79 of file class.t3lib_loaddbgroup.php. |
|
|
Definition at line 80 of file class.t3lib_loaddbgroup.php. |
|
|
Definition at line 75 of file class.t3lib_loaddbgroup.php. |
|
|
Definition at line 85 of file class.t3lib_loaddbgroup.php. |
|
|
Definition at line 78 of file class.t3lib_loaddbgroup.php. |
1.3.8-20040913