Main Page | Directories | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages | Examples

tslib_feTCE Class Reference

List of all members.

Public Member Functions

 start ($data, $FEData)
 Starting the processing of user input.
 checkDoublePostExist ($table, $doublePostField, $key)
 Checking if a "double-post" exists already.
 calcDoublePostKey ($array)
 Creates the double-post hash value from the input array.
 includeScripts ()
 Includes the submit scripts found in ->extScripts (filled in by the start() function).
 execNEWinsert ($table, $dataArr)
 Method available to the submit scripts for creating insert queries.
 clear_cacheCmd ($cacheCmd)
 Clear cache for page id.
 getConf ($table)
 Return TypoScript configuration for a table name.

Public Attributes

 $extScripts = array()
 $extScriptsConf = array()
 $newData = array()
 $extraList = 'pid'

Member Function Documentation

tslib_feTCE::calcDoublePostKey array  ) 
 

Creates the double-post hash value from the input array.

Parameters:
array The array with key/values to hash
Returns:
integer And unsigned 32bit integer hash private

Definition at line 200 of file class.tslib_fetce.php.

Referenced by start().

00200                                        {
00201       ksort($array); // Sorting by key
00202       $doublePostCheckKey = hexdec(substr(md5(serialize($array)),0,8)); // Making key
00203       return $doublePostCheckKey;
00204    }

tslib_feTCE::checkDoublePostExist table,
doublePostField,
key
 

Checking if a "double-post" exists already.

"Double-posting" is if someone refreshes a page with a form for the message board or guestbook and thus submits the element twice. Checking for double-posting prevents the second submission from being stored. This is done by saving the first record with a MD5 hash of the content - if this hash exists already, the record cannot be saved.

Parameters:
string The database table to check
string The fieldname from the database table to search
string The value to search for.
Returns:
integer The number of found rows. If zero then no "double-post" was found and its all OK. private

Definition at line 187 of file class.tslib_fetce.php.

References table().

Referenced by start().

00187                                                                {
00188       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, $doublePostField.'='.intval($key));
00189       $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
00190       return $row[0];
00191    }

tslib_feTCE::clear_cacheCmd cacheCmd  ) 
 

Clear cache for page id.

If the page id is the current page, then set_no_cache() is called (so page caching is disabled)

Parameters:
integer The page id for which to clear the cache
Returns:
void
See also:
tslib_fe::set_no_cache()

Definition at line 258 of file class.tslib_fetce.php.

00258                                        {
00259       $cacheCmd = intval($cacheCmd);
00260       if ($cacheCmd) {
00261          $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pages', 'page_id='.intval($cacheCmd));
00262          if ($cacheCmd == intval($GLOBALS['TSFE']->id))  {  // Setting no_cache true if the cleared-cache page is the current page!
00263             $GLOBALS['TSFE']->set_no_cache();
00264          }
00265       }
00266    }

tslib_feTCE::execNEWinsert table,
dataArr
 

Method available to the submit scripts for creating insert queries.

Automatically adds tstamp, crdate, cruser_id field/value pairs. Will allow only field names which are either found in $TCA[...][columns] OR in the $this->extraList Executes an insert query!

Parameters:
string The table name for which to create the insert statement
array Array with key/value pairs being field/values (already escaped)
Returns:
void

Definition at line 232 of file class.tslib_fetce.php.

00232                                              {
00233       $extraList=$this->extraList;
00234       if ($GLOBALS['TCA'][$table]['ctrl']['tstamp'])  {$field=$GLOBALS['TCA'][$table]['ctrl']['tstamp']; $dataArr[$field]=time(); $extraList.=','.$field;}
00235       if ($GLOBALS['TCA'][$table]['ctrl']['crdate'])  {$field=$GLOBALS['TCA'][$table]['ctrl']['crdate']; $dataArr[$field]=time(); $extraList.=','.$field;}
00236       if ($GLOBALS['TCA'][$table]['ctrl']['cruser_id'])  {$field=$GLOBALS['TCA'][$table]['ctrl']['cruser_id']; $dataArr[$field]=0; $extraList.=','.$field;}
00237 
00238       unset($dataArr['uid']); // uid can never be set
00239       $insertFields = array();
00240 
00241       foreach($dataArr as $f => $v) {
00242          if (t3lib_div::inList($extraList,$f) || isset($GLOBALS['TCA'][$table]['columns'][$f])) {
00243             $insertFields[$f] = $v;
00244          }
00245       }
00246 
00247       $GLOBALS['TYPO3_DB']->exec_INSERTquery($table, $insertFields);
00248    }

tslib_feTCE::getConf table  ) 
 

Return TypoScript configuration for a table name.

Parameters:
string The table name for which to return TypoScript configuration (From TS: FEData.[table])
Returns:
array TypoScript properties from FEData.[table] - if exists.

Definition at line 274 of file class.tslib_fetce.php.

00274                               {
00275       return $this->extScriptsConf[$table];
00276    }

tslib_feTCE::includeScripts  ) 
 

Includes the submit scripts found in ->extScripts (filled in by the start() function).

Returns:
void
See also:
tslib_fe::fe_tce(), includeScripts()

Definition at line 212 of file class.tslib_fetce.php.

00212                               {
00213       reset($this->extScripts);
00214       while(list($incFile_table,$incFile)=each($this->extScripts))   {
00215          if (@is_file($incFile) && $GLOBALS['TSFE']->checkFileInclude($incFile)) {
00216             include($incFile);   // Always start the incFiles with a check of the object fe_tce.  is_object($this);
00217             $GLOBALS['TT']->setTSlogMessage('Included '.$incFile,0);
00218          } else $GLOBALS['TT']->setTSlogMessage('"'.$incFile.'" was not found!',2);
00219       }
00220    }

tslib_feTCE::start data,
FEData
 

Starting the processing of user input.

Traverses the input data and fills in the array, $this->extScripts with references to files which are then included by includeScripts() (called AFTER start() in tslib_fe) These scripts will then put the content into the database.

Parameters:
array Input data coming from typ. $_POST['data'] vars
array TypoScript configuration for the FEDATA object, $this->config['FEData.']
Returns:
void
See also:
tslib_fe::fe_tce(), includeScripts()

Definition at line 100 of file class.tslib_fetce.php.

References calcDoublePostKey(), checkDoublePostExist(), and table().

00100                                  {
00101       reset($data);
00102       while(list($table,$id_arr)=each($data))   {
00103          t3lib_div::loadTCA($table);
00104          if (is_array($id_arr))  {
00105             $sep=$FEData[$table.'.']['separator']?$FEData[$table.'.']['separator']:chr(10);
00106             reset($id_arr);
00107             while(list($id,$field_arr)=each($id_arr)) {
00108                $this->newData[$table][$id]=Array();
00109                if (strstr($id,'NEW'))  {     // NEW
00110                      // Defaults:
00111                   if ($FEData[$table.'.']['default.'])   {
00112                      $this->newData[$table][$id] = $FEData[$table.'.']['default.'];
00113                   }
00114                   if ($FEData[$table.'.']['autoInsertPID']) {
00115                      $this->newData[$table][$id]['pid'] = intval($GLOBALS['TSFE']->page['uid']);
00116                   }
00117                      // Insert external data:
00118                   if (is_array($field_arr))  {
00119                      reset($field_arr);
00120                      while(list($field,$value)=each($field_arr))  {
00121                         if ($FEData[$table.'.']['allowNew.'][$field])   {
00122                            if (is_array($value)) {
00123                               $this->newData[$table][$id][$field] = implode($sep,$value);
00124                            } else {
00125                               $this->newData[$table][$id][$field] = $value;
00126                            }
00127                         }
00128                      }
00129                   }
00130                      // Double post check
00131                   $dPC_field = $FEData[$table.'.']['doublePostCheck'];
00132                   if (is_array($this->newData[$table][$id]) && $dPC_field) {
00133                      $doublePostCheckKey = $this->calcDoublePostKey($this->newData[$table][$id]);
00134                      if ($this->checkDoublePostExist($table,$dPC_field,$doublePostCheckKey)) {
00135                         unset($this->newData[$table][$id]); // Unsetting the whole thing, because it's not going to be saved.
00136                         $GLOBALS['TT']->setTSlogMessage('"FEData": Submitted record to table $table was doublePosted (key: $doublePostCheckKey). Nothing saved.',2);
00137                      } else {
00138                         $this->newData[$table][$id][$dPC_field] = $doublePostCheckKey; // Setting key value
00139                         $this->extraList.=','.$dPC_field;
00140                      }
00141                   }
00142                } else {    // EDIT
00143                      // Insert external data:
00144                   if (is_array($field_arr))  {
00145                      reset($field_arr);
00146                      while(list($field,$value)=each($field_arr))  {
00147                         if ($FEData[$table.'.']['allowEdit.'][$field])  {
00148                            if (is_array($value)) {
00149                               $this->newData[$table][$id][$field] = implode($sep,$value);
00150                            } else {
00151                               $this->newData[$table][$id][$field] = $value;
00152                            }
00153                         }
00154                      }
00155                   }
00156                      // Internal Override
00157                   if (is_array($FEData[$table.'.']['overrideEdit.']))   {
00158                      reset($FEData[$table.'.']['overrideEdit.']);
00159                      while(list($field,$value)=each($FEData[$table.'.']['overrideEdit.']))   {
00160                         $this->newData[$table][$id][$field] = $value;
00161                      }
00162                   }
00163                }
00164                if ($FEData[$table.'.']['userIdColumn']) {
00165                   $this->newData[$table][$id][$FEData[$table.'.']['userIdColumn']] = intval($GLOBALS['TSFE']->fe_user->user['uid']);
00166                }
00167             }
00168             $incFile = $GLOBALS['TSFE']->tmpl->getFileName($FEData[$table.'.']['processScript']);
00169             if ($incFile)  {
00170                $this->extScripts[$table]=$incFile;
00171                $this->extScriptsConf[$table]=$FEData[$table.'.']['processScript.'];
00172             }
00173          }
00174       }
00175    }


Member Data Documentation

tslib_feTCE::$extraList = 'pid'
 

Definition at line 88 of file class.tslib_fetce.php.

tslib_feTCE::$extScripts = array()
 

Definition at line 85 of file class.tslib_fetce.php.

tslib_feTCE::$extScriptsConf = array()
 

Definition at line 86 of file class.tslib_fetce.php.

tslib_feTCE::$newData = array()
 

Definition at line 87 of file class.tslib_fetce.php.


The documentation for this class was generated from the following file:
Generated on Sun Oct 3 01:07:37 2004 for TYPO3core 3.7.0 dev by  doxygen 1.3.8-20040913