Public Member Functions | |
getServiceInfo () | |
getServiceKey () | |
getServiceTitle () | |
getServiceOption ($optionName, $defaultValue='', $includeDefaultConfig=TRUE) | |
Returns service configuration values from the $TYPO3_CONF_VARS['SVCONF'] array. | |
devLog ($msg, $severity=0, $dataVar=FALSE) | |
Logs debug messages to t3lib_div::devLog(). | |
errorPush ($errNum=T3_ERR_SV_GENERAL, $errMsg='Unspecified error occured') | |
Puts an error on the error stack. | |
errorPull () | |
Removes the last error from the error stack. | |
getLastError () | |
Returns the last error number from the error stack. | |
getLastErrorMsg () | |
Returns the last message from the error stack. | |
getErrorMsgArray () | |
Returns all error messages as array. | |
getLastErrorArray () | |
Returns the last array from the error stack. | |
resetErrors () | |
Reset the error stack. | |
checkExec ($progList) | |
check the availability of external programs | |
deactivateService () | |
Deactivate the service. | |
checkInputFile ($absFile) | |
Check if a file exists and is readable. | |
readFile ($absFile, $length=0) | |
Read content from a file a file. | |
writeFile ($content, $absFile='') | |
Write content to a file. | |
tempFile ($filePrefix) | |
Create a temporary file. | |
registerTempFile ($absFile) | |
Register file which should be deleted afterwards. | |
unlinkTempFiles () | |
Delete registered temporary files. | |
setInput ($content, $type='') | |
Set the input content for service processing. | |
setInputFile ($absFile, $type='') | |
Set the input file name for service processing. | |
getInput () | |
Get the input content. | |
getInputFile ($createFile='') | |
Get the input file name. | |
setOutputFile ($absFile) | |
Set the output file name. | |
getOutput () | |
Get the output content. | |
getOutputFile ($absFile='') | |
Get the output file name. | |
init () | |
Initialization of the service. | |
reset () | |
Resets the service. | |
__destruct () | |
Clean up the service. | |
Public Attributes | |
$info = array() | |
service description array | |
$error = array() | |
error stack | |
$writeDevLog = false | |
Defines if debug messages should be written with t3lib_div::devLog. | |
$out = '' | |
The output content. | |
$inputFile = '' | |
The file that should be processed. | |
$inputContent = '' | |
The content that should be processed. | |
$inputType = '' | |
The type of the input content (or file). | |
$outputFile = '' | |
The file where the output should be written to. |
|
Clean up the service.
Definition at line 715 of file class.t3lib_svbase.php. References unlinkTempFiles(). Referenced by init(). 00715 { 00716 $this->unlinkTempFiles(); 00717 }
|
|
check the availability of external programs
Definition at line 373 of file class.t3lib_svbase.php. References t3lib_exec::checkCommand(), errorPush(), PATH_t3lib, and T3_ERR_SV_PROG_NOT_FOUND. Referenced by init(). 00373 { 00374 $ret = TRUE; 00375 00376 require_once(PATH_t3lib.'class.t3lib_exec.php'); 00377 00378 $progList = t3lib_div::trimExplode(',', $progList, 1); 00379 foreach($progList as $prog) { 00380 if (!t3lib_exec::checkCommand($prog)) { 00381 // program not found 00382 $this->errorPush('External program not found: '.$prog, T3_ERR_SV_PROG_NOT_FOUND); 00383 $ret = FALSE; 00384 } 00385 } 00386 return $ret; 00387 }
|
|
Check if a file exists and is readable.
Definition at line 439 of file class.t3lib_svbase.php. References errorPush(), T3_ERR_SV_FILE_NOT_FOUND, and T3_ERR_SV_FILE_READ. Referenced by getInputFile(), and readFile(). 00439 { 00440 if(@is_file($absFile)) { 00441 if(@is_readable($absFile)) { 00442 return $absFile; 00443 } else { 00444 $this->errorPush(T3_ERR_SV_FILE_READ, 'File is not readable: '.$absFile); 00445 } 00446 } else { 00447 $this->errorPush(T3_ERR_SV_FILE_NOT_FOUND, 'File not found: '.$absFile); 00448 } 00449 return FALSE; 00450 }
|
|
Deactivate the service. Use this if the service fails at runtime and will not be available.
Definition at line 395 of file class.t3lib_svbase.php. References t3lib_extMgm::deactivateService(). 00395 { 00396 t3lib_extMgm::deactivateService($this->info['serviceType'], $this->info['serviceKey']); 00397 }
|
|
Logs debug messages to t3lib_div::devLog().
Definition at line 255 of file class.t3lib_svbase.php. 00255 {
00256 if($this->writeDevLog) {
00257 t3lib_div::devLog($msg, $this->info['serviceKey'], $severity, $dataVar);
00258 }
00259 }
|
|
Removes the last error from the error stack.
Definition at line 284 of file class.t3lib_svbase.php. 00284 {
00285 array_pop($this->error);
00286
00287 // pop for $GLOBALS['TT']->setTSlogMessage is not supported
00288 }
|
|
Puts an error on the error stack. Calling without parameter adds a general error.
Definition at line 269 of file class.t3lib_svbase.php. Referenced by checkExec(), checkInputFile(), readFile(), tempFile(), and writeFile(). 00269 { 00270 array_push($this->error, array('nr'=>$errNum, 'msg'=>$errMsg)); 00271 00272 if (is_object($GLOBALS["TT"])) { 00273 $GLOBALS['TT']->setTSlogMessage($errMsg,2); 00274 } 00275 00276 }
|
|
Returns all error messages as array.
Definition at line 326 of file class.t3lib_svbase.php. References $error, error(), and reset(). 00326 { 00327 $errArr = array(); 00328 00329 if(count($this->error)) { 00330 reset($this->error); 00331 foreach($this->error as $error) { 00332 $errArr[] = $error['msg']; 00333 } 00334 } 00335 return $errArr; 00336 }
|
|
Get the input content. Will be read from input file if needed.
Definition at line 588 of file class.t3lib_svbase.php. References readFile(). 00588 { 00589 if ($this->inputContent=='') { 00590 $this->inputContent = $this->readFile($this->inputFile); 00591 } 00592 return $this->inputContent; 00593 }
|
|
Get the input file name. If the content was set by setContent a file will be created.
Definition at line 603 of file class.t3lib_svbase.php. References checkInputFile(), and writeFile(). 00603 { 00604 if($this->inputFile) { 00605 $this->inputFile = $this->checkInputFile($this->inputFile); 00606 } elseif ($this->inputContent) { 00607 $this->inputFile = $this->writeFile($this->inputContent, $createFile); 00608 } 00609 return $this->inputFile; 00610 }
|
|
Returns the last error number from the error stack.
Definition at line 296 of file class.t3lib_svbase.php. References $error. Referenced by init(). 00296 { 00297 if(count($this->error)) { 00298 $error = end($this->error); 00299 return $error['nr']; 00300 } else { 00301 return TRUE; // means all is ok - no error 00302 } 00303 }
|
|
Returns the last array from the error stack.
Definition at line 344 of file class.t3lib_svbase.php. 00344 {
00345 return end($this->error);
00346 }
|
|
Returns the last message from the error stack.
Definition at line 311 of file class.t3lib_svbase.php. References $error. 00311 { 00312 if(count($this->error)) { 00313 $error = end($this->error); 00314 return $error['msg']; 00315 } else { 00316 return ''; 00317 } 00318 }
|
|
Get the output content.
Definition at line 638 of file class.t3lib_svbase.php. References readFile(). 00638 { 00639 if ($this->outputFile) { 00640 $this->out = $this->readFile($this->outputFile); 00641 } 00642 return $this->out; 00643 }
|
|
Get the output file name.
Definition at line 652 of file class.t3lib_svbase.php. References writeFile(). 00652 { 00653 if (!$this->outputFile) { 00654 $this->outputFile = $this->writeFile($this->out, $absFile); 00655 } 00656 return $this->outputFile; 00657 }
|
|
Definition at line 191 of file class.t3lib_svbase.php. 00191 {
00192 return $this->info;
00193 }
|
|
Definition at line 199 of file class.t3lib_svbase.php. 00199 {
00200 return $this->info['serviceKey'];
00201 }
|
|
Returns service configuration values from the $TYPO3_CONF_VARS['SVCONF'] array.
Definition at line 220 of file class.t3lib_svbase.php. References $TYPO3_CONF_VARS. Referenced by tx_sv_authbase::initAuth(). 00220 { 00221 global $TYPO3_CONF_VARS; 00222 00223 $config = NULL; 00224 00225 $svOptions = $TYPO3_CONF_VARS['SVCONF'][$this->info['serviceType']]; 00226 00227 if(isset($svOptions[$this->info['serviceKey']][$optionName])) { 00228 $config = $svOptions['default'][$optionName]; 00229 } elseif($includeDefaultConfig AND isset($svOptions['default'][$optionName])) { 00230 $config = $svOptions['default'][$optionName]; 00231 } 00232 if(!isset($config)) { 00233 $config = $defaultValue; 00234 } 00235 return $config; 00236 }
|
|
Definition at line 207 of file class.t3lib_svbase.php. 00207 {
00208 return $this->info['title'];
00209 }
|
|
Initialization of the service. The class have to do a strict check if the service is available. example: check if the perl interpreter is available which is needed to run an extern perl script.
Definition at line 676 of file class.t3lib_svbase.php. References __destruct(), checkExec(), getLastError(), and reset(). 00676 { 00677 // do not work :-( but will not hurt 00678 register_shutdown_function(array(&$this, '__destruct')); 00679 // look in makeInstanceService() 00680 00681 $this->reset(); 00682 00683 // check for external programs which are defined by $info['exec'] 00684 if (trim($this->info['exec'])) { 00685 if (!$this->checkExec($this->info['exec'])) { 00686 // nothing todo here or? 00687 } 00688 } 00689 00690 return $this->getLastError(); 00691 }
|
|
Read content from a file a file.
Definition at line 460 of file class.t3lib_svbase.php. References $out, checkInputFile(), errorPush(), and T3_ERR_SV_FILE_READ. Referenced by getInput(), and getOutput(). 00460 { 00461 $out = FALSE; 00462 00463 if ($this->checkInputFile ($absFile)) { 00464 if ($fd = fopen ($absFile, 'rb')) { 00465 $length = intval($length) ? intval($length) : filesize ($absFile); 00466 if ($length > 0) { 00467 $out = fread ($fd, $length); 00468 } 00469 fclose ($fd); 00470 } else { 00471 $this->errorPush(T3_ERR_SV_FILE_READ, 'Can not read from file: '.$absFile); 00472 } 00473 } 00474 return $out; 00475 }
|
|
Register file which should be deleted afterwards.
Definition at line 529 of file class.t3lib_svbase.php. Referenced by tempFile(). 00529 { 00530 $this->tempFiles[] = $absFile; 00531 }
|
|
Resets the service. Will be called by init(). Should be used before every use if a service instance is used multiple times.
Definition at line 700 of file class.t3lib_svbase.php. References resetErrors(), and unlinkTempFiles(). Referenced by getErrorMsgArray(), and init(). 00700 { 00701 $this->unlinkTempFiles(); 00702 $this->resetErrors(); 00703 $this->out = ''; 00704 $this->inputFile = ''; 00705 $this->inputContent = ''; 00706 $this->inputType = ''; 00707 $this->outputFile = ''; 00708 }
|
|
Reset the error stack.
Definition at line 353 of file class.t3lib_svbase.php. References error(). Referenced by reset(). 00353 { 00354 $this->error=array(); 00355 }
|
|
Set the input content for service processing.
Definition at line 561 of file class.t3lib_svbase.php. 00561 { 00562 $this->inputContent = $content; 00563 $this->inputFile = ''; 00564 $this->inputType = $type; 00565 }
|
|
Set the input file name for service processing.
Definition at line 575 of file class.t3lib_svbase.php. 00575 { 00576 $this->inputContent = ''; 00577 $this->inputFile = $absFile; 00578 $this->inputType = $type; 00579 }
|
|
Set the output file name.
Definition at line 628 of file class.t3lib_svbase.php. 00628 { 00629 $this->outputFile = $absFile; 00630 }
|
|
Create a temporary file.
Definition at line 511 of file class.t3lib_svbase.php. References errorPush(), registerTempFile(), and T3_ERR_SV_FILE_WRITE. Referenced by writeFile(). 00511 { 00512 $absFile = t3lib_div::tempnam($filePrefix); 00513 if($absFile) { 00514 $ret = TRUE; 00515 $this->registerTempFile ($absFile); 00516 } else { 00517 $ret = FALSE; 00518 $this->errorPush(T3_ERR_SV_FILE_WRITE, 'Can not create temp file.'); 00519 } 00520 return ($ret ? $absFile : FALSE); 00521 }
|
|
Delete registered temporary files.
Definition at line 539 of file class.t3lib_svbase.php. Referenced by __destruct(), and reset(). 00539 { 00540 foreach ($this->tempFiles as $absFile) { 00541 t3lib_div::unlink_tempfile($absFile); 00542 } 00543 $this->tempFiles = array(); 00544 }
|
|
Write content to a file.
Definition at line 485 of file class.t3lib_svbase.php. References errorPush(), T3_ERR_SV_FILE_WRITE, and tempFile(). Referenced by getInputFile(), and getOutputFile(). 00485 { 00486 $ret = TRUE; 00487 00488 if (!$absFile) { 00489 $absFile = $this->tempFile($this->prefixId); 00490 } 00491 00492 if($absFile) { 00493 if ($fd = @fopen($absFile,'wb')) { 00494 @fwrite($fd, $content); 00495 @fclose($fd); 00496 } else { 00497 $this->errorPush(T3_ERR_SV_FILE_WRITE, 'Can not write to file: '.$absFile); 00498 $absFile = FALSE; 00499 } 00500 } 00501 00502 return $absFile; 00503 }
|
|
error stack
Definition at line 137 of file class.t3lib_svbase.php. Referenced by getErrorMsgArray(), getLastError(), and getLastErrorMsg(). |
|
service description array
Reimplemented in tx_sv_authbase. Definition at line 132 of file class.t3lib_svbase.php. |
|
The content that should be processed.
Definition at line 159 of file class.t3lib_svbase.php. |
|
The file that should be processed.
Definition at line 154 of file class.t3lib_svbase.php. |
|
The type of the input content (or file). Might be the same as the service subtypes. Definition at line 164 of file class.t3lib_svbase.php. |
|
The output content. That's what the services produced as result. Definition at line 149 of file class.t3lib_svbase.php. Referenced by readFile(). |
|
The file where the output should be written to.
Definition at line 169 of file class.t3lib_svbase.php. |
|
Defines if debug messages should be written with t3lib_div::devLog.
Definition at line 142 of file class.t3lib_svbase.php. |