本文整理汇总了PHP中t3lib_div::unlink_tempfile方法的典型用法代码示例。如果您正苦于以下问题:PHP t3lib_div::unlink_tempfile方法的具体用法?PHP t3lib_div::unlink_tempfile怎么用?PHP t3lib_div::unlink_tempfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类t3lib_div
的用法示例。
在下文中一共展示了t3lib_div::unlink_tempfile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start
//.........这里部分代码省略.........
* @return void
*/
function start($V, $base64 = false)
{
$convCharset = FALSE;
// do we need to convert form data?
if ($GLOBALS['TSFE']->config['config']['formMailCharset']) {
// Respect formMailCharset if it was set
$this->charset = $GLOBALS['TSFE']->csConvObj->parse_charset($GLOBALS['TSFE']->config['config']['formMailCharset']);
$convCharset = TRUE;
} elseif ($GLOBALS['TSFE']->metaCharset != $GLOBALS['TSFE']->renderCharset) {
// Use metaCharset for mail if different from renderCharset
$this->charset = $GLOBALS['TSFE']->metaCharset;
$convCharset = TRUE;
}
parent::start();
if ($base64 || $V['use_base64']) {
$this->useBase64();
}
if (isset($V['recipient'])) {
// convert form data from renderCharset to mail charset
$val = $V['subject'] ? $V['subject'] : 'Formmail on ' . t3lib_div::getIndpEnv('HTTP_HOST');
$this->subject = $convCharset && strlen($val) ? $GLOBALS['TSFE']->csConvObj->conv($val, $GLOBALS['TSFE']->renderCharset, $this->charset) : $val;
$this->subject = $this->sanitizeHeaderString($this->subject);
$val = $V['from_name'] ? $V['from_name'] : ($V['name'] ? $V['name'] : '');
// Be careful when changing $val! It is used again as the fallback value for replyto_name
$this->from_name = $convCharset && strlen($val) ? $GLOBALS['TSFE']->csConvObj->conv($val, $GLOBALS['TSFE']->renderCharset, $this->charset) : $val;
$this->from_name = $this->sanitizeHeaderString($this->from_name);
$this->from_name = preg_match('/\\s|,/', $this->from_name) >= 1 ? '"' . $this->from_name . '"' : $this->from_name;
$val = $V['replyto_name'] ? $V['replyto_name'] : $val;
$this->replyto_name = $convCharset && strlen($val) ? $GLOBALS['TSFE']->csConvObj->conv($val, $GLOBALS['TSFE']->renderCharset, $this->charset) : $val;
$this->replyto_name = $this->sanitizeHeaderString($this->replyto_name);
$this->replyto_name = preg_match('/\\s|,/', $this->replyto_name) >= 1 ? '"' . $this->replyto_name . '"' : $this->replyto_name;
$val = $V['organisation'] ? $V['organisation'] : '';
$this->organisation = $convCharset && strlen($val) ? $GLOBALS['TSFE']->csConvObj->conv($val, $GLOBALS['TSFE']->renderCharset, $this->charset) : $val;
$this->organisation = $this->sanitizeHeaderString($this->organisation);
$this->from_email = $V['from_email'] ? $V['from_email'] : ($V['email'] ? $V['email'] : '');
$this->from_email = t3lib_div::validEmail($this->from_email) ? $this->from_email : '';
$this->replyto_email = $V['replyto_email'] ? $V['replyto_email'] : $this->from_email;
$this->replyto_email = t3lib_div::validEmail($this->replyto_email) ? $this->replyto_email : '';
$this->priority = $V['priority'] ? t3lib_div::intInRange($V['priority'], 1, 5) : 3;
// Auto responder.
$this->auto_respond_msg = trim($V['auto_respond_msg']) && $this->from_email ? trim($V['auto_respond_msg']) : '';
$this->auto_respond_msg = $this->sanitizeHeaderString($this->auto_respond_msg);
$Plain_content = '';
$HTML_content = '<table border="0" cellpadding="2" cellspacing="2">';
// Runs through $V and generates the mail
if (is_array($V)) {
foreach ($V as $key => $val) {
if (!t3lib_div::inList($this->reserved_names, $key)) {
$space = strlen($val) > 60 ? LF : '';
$val = is_array($val) ? implode($val, LF) : $val;
// convert form data from renderCharset to mail charset (HTML may use entities)
$Plain_val = $convCharset && strlen($val) ? $GLOBALS['TSFE']->csConvObj->conv($val, $GLOBALS['TSFE']->renderCharset, $this->charset, 0) : $val;
$HTML_val = $convCharset && strlen($val) ? $GLOBALS['TSFE']->csConvObj->conv(htmlspecialchars($val), $GLOBALS['TSFE']->renderCharset, $this->charset, 1) : htmlspecialchars($val);
$Plain_content .= strtoupper($key) . ': ' . $space . $Plain_val . LF . $space;
$HTML_content .= '<tr><td bgcolor="#eeeeee"><font face="Verdana" size="1"><strong>' . strtoupper($key) . '</strong></font></td><td bgcolor="#eeeeee"><font face="Verdana" size="1">' . nl2br($HTML_val) . ' </font></td></tr>';
}
}
}
$HTML_content .= '</table>';
if ($V['html_enabled']) {
$this->setHTML($this->encodeMsg($HTML_content));
}
$this->addPlain($Plain_content);
for ($a = 0; $a < 10; $a++) {
$varname = 'attachment' . ($a ? $a : '');
if (!isset($_FILES[$varname])) {
continue;
}
if (!is_uploaded_file($_FILES[$varname]['tmp_name'])) {
t3lib_div::sysLog('Possible abuse of t3lib_formmail: temporary file "' . $_FILES[$varname]['tmp_name'] . '" ("' . $_FILES[$varname]['name'] . '") was not an uploaded file.', 'Core', 3);
}
if ($_FILES[$varname]['tmp_name']['error'] !== UPLOAD_ERR_OK) {
t3lib_div::sysLog('Error in uploaded file in t3lib_formmail: temporary file "' . $_FILES[$varname]['tmp_name'] . '" ("' . $_FILES[$varname]['name'] . '") Error code: ' . $_FILES[$varname]['tmp_name']['error'], 'Core', 3);
}
$theFile = t3lib_div::upload_to_tempfile($_FILES[$varname]['tmp_name']);
$theName = $_FILES[$varname]['name'];
if ($theFile && file_exists($theFile)) {
if (filesize($theFile) < $GLOBALS['TYPO3_CONF_VARS']['FE']['formmailMaxAttachmentSize']) {
$this->addAttachment($theFile, $theName);
}
}
t3lib_div::unlink_tempfile($theFile);
}
$this->setHeaders();
$this->setContent();
$this->setRecipient($V['recipient']);
if ($V['recipient_copy']) {
$this->recipient_copy = trim($V['recipient_copy']);
}
// log dirty header lines
if ($this->dirtyHeaders) {
t3lib_div::sysLog('Possible misuse of t3lib_formmail: see TYPO3 devLog', 'Core', 3);
if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_DLOG']) {
t3lib_div::devLog('t3lib_formmail: ' . t3lib_div::arrayToLogString($this->dirtyHeaders, '', 200), 'Core', 3);
}
}
}
}
示例2: importData
//.........这里部分代码省略.........
$emURL = '';
$inFile = t3lib_div::getFileAbsFileName($inData['file']);
if ($inFile && @is_file($inFile)) {
$trow = array();
if ($import->loadFile($inFile, 1)) {
// Check extension dependencies:
$extKeysToInstall = array();
if (is_array($import->dat['header']['extensionDependencies'])) {
foreach ($import->dat['header']['extensionDependencies'] as $extKey) {
if (!t3lib_extMgm::isLoaded($extKey)) {
$extKeysToInstall[] = $extKey;
}
}
}
if (count($extKeysToInstall)) {
$passParams = t3lib_div::_POST('tx_impexp');
unset($passParams['import_mode']);
unset($passParams['import_file']);
$thisScriptUrl = t3lib_div::getIndpEnv('REQUEST_URI') . '?M=xMOD_tximpexp&id=' . $this->id . t3lib_div::implodeArrayForUrl('tx_impexp', $passParams);
$emURL = $this->doc->backPath . 'mod/tools/em/index.php?CMD[requestInstallExtensions]=' . implode(',', $extKeysToInstall) . '&returnUrl=' . rawurlencode($thisScriptUrl);
$extensionInstallationMessage = 'Before you can install this T3D file you need to install the extensions "' . implode('", "', $extKeysToInstall) . '". Clicking Import will first take you to the Extension Manager so these dependencies can be resolved.';
}
if ($inData['import_file']) {
if (!count($extKeysToInstall)) {
$import->importData($this->id);
t3lib_BEfunc::setUpdateSignal('updatePageTree');
} else {
t3lib_utility_Http::redirect($emURL);
}
}
$import->display_import_pid_record = $this->pageinfo;
$overviewContent = $import->displayContentOverview();
}
// Meta data output:
$trow[] = '<tr class="bgColor5">
<td colspan="2"><strong>' . $LANG->getLL('importdata_metaData', 1) . '</strong></td>
</tr>';
$opt = array('');
foreach ($filesInDir as $file) {
$opt[$file] = substr($file, strlen(PATH_site));
}
$trow[] = '<tr class="bgColor4">
<td><strong>' . $LANG->getLL('importdata_title', 1) . '</strong></td>
<td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['title'])) . '</td>
</tr>';
$trow[] = '<tr class="bgColor4">
<td><strong>' . $LANG->getLL('importdata_description', 1) . '</strong></td>
<td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['description'])) . '</td>
</tr>';
$trow[] = '<tr class="bgColor4">
<td><strong>' . $LANG->getLL('importdata_notes', 1) . '</strong></td>
<td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['notes'])) . '</td>
</tr>';
$trow[] = '<tr class="bgColor4">
<td><strong>' . $LANG->getLL('importdata_packager', 1) . '</strong></td>
<td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['packager_name'] . ' (' . $import->dat['header']['meta']['packager_username'] . ')')) . '<br/>
' . $LANG->getLL('importdata_email', 1) . ' ' . $import->dat['header']['meta']['packager_email'] . '</td>
</tr>';
// Thumbnail icon:
if (is_array($import->dat['header']['thumbnail'])) {
$pI = pathinfo($import->dat['header']['thumbnail']['filename']);
if (t3lib_div::inList('gif,jpg,png,jpeg', strtolower($pI['extension']))) {
// Construct filename and write it:
$fileName = PATH_site . 'typo3temp/importthumb.' . $pI['extension'];
t3lib_div::writeFile($fileName, $import->dat['header']['thumbnail']['content']);
// Check that the image really is an image and not a malicious PHP script...
if (getimagesize($fileName)) {
// Create icon tag:
$iconTag = '<img src="' . $this->doc->backPath . '../' . substr($fileName, strlen(PATH_site)) . '" ' . $import->dat['header']['thumbnail']['imgInfo'][3] . ' vspace="5" style="border: solid black 1px;" alt="" />';
$trow[] = '<tr class="bgColor4">
<td><strong>' . $LANG->getLL('importdata_icon', 1) . '</strong></td>
<td>' . $iconTag . '</td>
</tr>';
} else {
t3lib_div::unlink_tempfile($fileName);
}
}
}
$menuItems[] = array('label' => $LANG->getLL('importdata_metaData_1387'), 'content' => '
<table border="0" cellpadding="1" cellspacing="1">
' . implode('
', $trow) . '
</table>
');
}
// Print errors that might be:
$errors = $import->printErrorLog();
$menuItems[] = array('label' => $LANG->getLL('importdata_messages'), 'content' => $errors, 'stateIcon' => $errors ? 2 : 0);
// Output tabs:
$content = $this->doc->getDynTabMenu($menuItems, 'tx_impexp_import', -1);
if ($extensionInstallationMessage) {
$content = '<div style="border: 1px black solid; margin: 10px 10px 10px 10px; padding: 10px 10px 10px 10px;">' . $this->doc->icons(1) . htmlspecialchars($extensionInstallationMessage) . '</div>' . $content;
}
$this->content .= $this->doc->section('', $content, 0, 1);
// Print overview:
if ($overviewContent) {
$this->content .= $this->doc->section($inData['import_file'] ? $LANG->getLL('importdata_structureHasBeenImported', 1) : $LANG->getLL('filterpage_structureToBeImported', 1), $overviewContent, 0, 1);
}
}
}
示例3: main
//.........这里部分代码省略.........
case 'totop_resource':
if (is_array($val)) {
$resList = ',' . $resList . ',';
foreach ($val as $k => $file) {
$resList = str_replace(',' . $file . ',', ',', $resList);
$resList = ',' . $file . $resList;
}
}
break;
}
}
}
$resList = implode(',', t3lib_div::trimExplode(',', $resList, 1));
if (strcmp($resList, $tplRow['resources'])) {
$recData['sys_template'][$saveId]['resources'] = $resList;
}
if (count($recData)) {
// Create new tce-object
$tce = t3lib_div::makeInstance('t3lib_TCEmain');
$tce->stripslashes_values = 0;
$tce->alternativeFileName = $alternativeFileName;
// Initialize
$tce->start($recData, array());
// Saved the stuff
$tce->process_datamap();
// Clear the cache (note: currently only admin-users can clear the cache in tce_main.php)
$tce->clear_cacheCmd('all');
// tce were processed successfully
$this->tce_processed = true;
// re-read the template ...
$this->initialize_editor($this->pObj->id, $template_uid);
}
// Unlink any uploaded/new temp files there was:
t3lib_div::unlink_tempfile($tmp_upload_name);
t3lib_div::unlink_tempfile($tmp_newresource_name);
// If files has been edited:
if (is_array($edit)) {
if ($edit['filename'] && $tplRow['resources'] && t3lib_div::inList($tplRow['resources'], $edit['filename'])) {
// Check if there are resources, and that the file is in the resourcelist.
$path = PATH_site . $TCA['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $edit['filename'];
$fI = t3lib_div::split_fileref($edit['filename']);
if (@is_file($path) && t3lib_div::getFileAbsFileName($path) && t3lib_div::inList($this->pObj->textExtensions, $fI['fileext'])) {
// checks that have already been done.. Just to make sure
// @TODO: Check if the hardcorded value already has a config member, otherwise create one
if (filesize($path) < 30720) {
// checks that have already been done.. Just to make sure
t3lib_div::writeFile($path, $edit['file']);
$theOutput .= $this->pObj->doc->spacer(10);
$theOutput .= $this->pObj->doc->section('<font color=red>' . $GLOBALS['LANG']->getLL('fileChanged') . '</font>', sprintf($GLOBALS['LANG']->getLL('resourceUpdated'), $edit['filename']), 0, 0, 0, 1);
// Clear cache - the file has probably affected the template setup
// @TODO: Check if the edited file really had something to do with cached data and prevent this clearing if possible!
$tce = t3lib_div::makeInstance('t3lib_TCEmain');
$tce->stripslashes_values = 0;
$tce->start(array(), array());
$tce->clear_cacheCmd('all');
}
}
}
}
}
// hook Post updating template/TCE processing
if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'])) {
$postTCEProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'];
if (is_array($postTCEProcessingHook)) {
$hookParameters = array('POST' => $POST, 'tce' => $tce);
foreach ($postTCEProcessingHook as $hookFunction) {
示例4: spellCheckHandler
function spellCheckHandler($xml_parser, $string)
{
$incurrent = array();
$stringText = $string;
$words = preg_split($this->parserCharset == 'utf-8' ? '/\\P{L}+/u' : '/\\W+/', $stringText);
while (list(, $word) = each($words)) {
$word = preg_replace('/ /' . ($this->parserCharset == 'utf-8' ? 'u' : ''), '', $word);
if ($word && !is_numeric($word)) {
if ($this->pspell_is_available && !$this->forceCommandMode) {
if (!pspell_check($this->pspell_link, $word)) {
if (!in_array($word, $this->misspelled)) {
if (sizeof($this->misspelled) != 0) {
$this->suggestedWords .= ',';
}
$suggest = array();
$suggest = pspell_suggest($this->pspell_link, $word);
if (sizeof($suggest) != 0) {
$this->suggestionCount++;
$this->suggestedWordCount += sizeof($suggest);
}
$this->suggestedWords .= '"' . $word . '":"' . implode(',', $suggest) . '"';
$this->misspelled[] = $word;
unset($suggest);
}
if (!in_array($word, $incurrent)) {
$stringText = preg_replace('/\\b' . $word . '\\b/' . ($this->parserCharset == 'utf-8' ? 'u' : ''), '<span class="htmlarea-spellcheck-error">' . $word . '</span>', $stringText);
$incurrent[] = $word;
}
}
} else {
$tmpFileName = t3lib_div::tempnam($this->filePrefix);
if (!($filehandle = fopen($tmpFileName, 'wb'))) {
echo 'SpellChecker tempfile open error';
}
if (!fwrite($filehandle, $word)) {
echo 'SpellChecker tempfile write error';
}
if (!fclose($filehandle)) {
echo 'SpellChecker tempfile close error';
}
$AspellCommand = 'cat ' . escapeshellarg($tmpFileName) . ' | ' . $this->AspellDirectory . ' -a check --mode=none --sug-mode=' . escapeshellarg($this->pspellMode) . $this->personalDictsArg . ' --lang=' . escapeshellarg($this->dictionary) . ' --encoding=' . escapeshellarg($this->aspellEncoding) . ' 2>&1';
$AspellAnswer = shell_exec($AspellCommand);
$AspellResultLines = array();
$AspellResultLines = t3lib_div::trimExplode(LF, $AspellAnswer, 1);
if (substr($AspellResultLines[0], 0, 6) == 'Error:') {
echo "{$AspellAnswer}";
}
t3lib_div::unlink_tempfile($tmpFileName);
if (substr($AspellResultLines['1'], 0, 1) != '*') {
if (!in_array($word, $this->misspelled)) {
if (sizeof($this->misspelled) != 0) {
$this->suggestedWords .= ',';
}
$suggest = array();
$suggestions = array();
if (substr($AspellResultLines['1'], 0, 1) == '&') {
$suggestions = t3lib_div::trimExplode(':', $AspellResultLines['1'], 1);
$suggest = t3lib_div::trimExplode(',', $suggestions['1'], 1);
}
if (sizeof($suggest) != 0) {
$this->suggestionCount++;
$this->suggestedWordCount += sizeof($suggest);
}
$this->suggestedWords .= '"' . $word . '":"' . implode(',', $suggest) . '"';
$this->misspelled[] = $word;
unset($suggest);
unset($suggestions);
}
if (!in_array($word, $incurrent)) {
$stringText = preg_replace('/\\b' . $word . '\\b/' . ($this->parserCharset == 'utf-8' ? 'u' : ''), '<span class="htmlarea-spellcheck-error">' . $word . '</span>', $stringText);
$incurrent[] = $word;
}
}
unset($AspellResultLines);
}
$this->wordCount++;
}
}
$this->text .= $stringText;
unset($incurrent);
return;
}
示例5: excelExportImportAction
function excelExportImportAction($l10ncfgObj)
{
global $LANG, $BACK_PATH;
$service = t3lib_div::makeInstance('tx_l10nmgr_l10nBaseService');
// Buttons:
$_selectOptions = array('0' => '-default-');
$_selectOptions = $_selectOptions + $this->MOD_MENU["lang"];
$info = $LANG->getLL('export.xml.source-language.title') . $this->_getSelectField("export_xml_forcepreviewlanguage", '0', $_selectOptions) . '<br/>';
$info .= '<input type="submit" value="' . $LANG->getLL('general.action.refresh.button.title') . '" name="_" />';
$info .= '<input type="submit" value="' . $LANG->getLL('general.action.export.xml.button.title') . '" name="export_excel" />';
$info .= '<input type="submit" value="' . $LANG->getLL('general.action.import.xml.button.title') . '" name="import_excel" /><input type="file" size="60" name="uploaded_import_file" />';
$info .= '<br /><br /><input type="checkbox" value="1" name="check_exports" /> ' . $LANG->getLL('export.xml.check_exports.title') . '<br />';
// Read uploaded file:
if (t3lib_div::_POST('import_excel') && $_FILES['uploaded_import_file']['tmp_name'] && is_uploaded_file($_FILES['uploaded_import_file']['tmp_name'])) {
$uploadedTempFile = t3lib_div::upload_to_tempfile($_FILES['uploaded_import_file']['tmp_name']);
$factory = t3lib_div::makeInstance('tx_l10nmgr_translationDataFactory');
//TODO: catch exeption
$translationData = $factory->getTranslationDataFromExcelXMLFile($uploadedTempFile);
$translationData->setLanguage($this->sysLanguage);
t3lib_div::unlink_tempfile($uploadedTempFile);
$service->saveTranslation($l10ncfgObj, $translationData);
$info .= '<br/><br/>' . $this->doc->icons(1) . $LANG->getLL('import.success.message') . '<br/><br/>';
}
// If export of XML is asked for, do that (this will exit and push a file for download)
if (t3lib_div::_POST('export_excel')) {
// Render the XML
/** @var $viewClass tx_l10nmgr_excelXMLView */
$viewClass = t3lib_div::makeInstance('tx_l10nmgr_excelXMLView', $l10ncfgObj, $this->sysLanguage);
$export_xml_forcepreviewlanguage = intval(t3lib_div::_POST('export_xml_forcepreviewlanguage'));
if ($export_xml_forcepreviewlanguage > 0) {
$viewClass->setForcedSourceLanguage($export_xml_forcepreviewlanguage);
}
if ($this->MOD_SETTINGS['onlyChangedContent']) {
$viewClass->setModeOnlyChanged();
}
if ($this->MOD_SETTINGS['noHidden']) {
$viewClass->setModeNoHidden();
}
//Check the export
if (t3lib_div::_POST('check_exports') == '1' && $viewClass->checkExports() == FALSE) {
/** @var $flashMessage t3lib_FlashMessage */
$flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('export.process.duplicate.message'), $LANG->getLL('export.process.duplicate.title'), t3lib_FlashMessage::INFO);
$info .= $flashMessage->render();
$info .= $viewClass->renderExports();
} else {
try {
$filename = $this->downloadXML($viewClass);
// Prepare a success message for display
$link = sprintf('<a href="%s" target="_blank">%s</a>', t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $filename, $filename);
$title = $GLOBALS['LANG']->getLL('export.download.success');
$message = sprintf($GLOBALS['LANG']->getLL('export.download.success.detail'), $link);
$status = t3lib_FlashMessage::OK;
} catch (Exception $e) {
// Prepare an error message for display
$title = $GLOBALS['LANG']->getLL('export.download.error');
$message = $e->getMessage() . ' (' . $e->getCode() . ')';
$status = t3lib_FlashMessage::ERROR;
}
/** @var $flashMessage t3lib_FlashMessage */
$flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $message, $title, $status);
$info .= $flashMessage->render();
$info .= $viewClass->renderInternalMessagesAsFlashMessage($status);
}
}
return $info;
}
示例6: unlinkTempFiles
/**
* Cleaning up all the temporary files stored in typo3temp/ folder
*
* @return void
*/
function unlinkTempFiles()
{
foreach ($this->unlinkFiles as $fileName) {
if (t3lib_div::isFirstPartOfStr($fileName, PATH_site . 'typo3temp/')) {
t3lib_div::unlink_tempfile($fileName);
clearstatcache();
if (is_file($fileName)) {
$this->error('Error: ' . $fileName . ' was NOT unlinked as it should have been!', 1);
}
} else {
$this->error('Error: ' . $fileName . ' was not in temp-path. Not removed!', 1);
}
}
$this->unlinkFiles = array();
}
示例7: renderTemplateSelector
/**
* Renders the template selector.
*
* @param integer Position id. Can be positive and negative depending of where the new page is going: Negative always points to a position AFTER the page having the abs. value of the positionId. Positive numbers means to create as the first subpage to another page.
* @param string $templateType: The template type, 'tmplobj' or 't3d'
* @return string HTML output containing a table with the template selector
*/
function renderTemplateSelector($positionPid, $templateType = 'tmplobj')
{
global $LANG, $TYPO3_DB;
$storageFolderPID = $this->apiObj->getStorageFolderPid($positionPid);
$tmplHTML = array();
switch ($templateType) {
case 'tmplobj':
// Create the "Default template" entry
$previewIconFilename = $GLOBALS['BACK_PATH'] . '../' . t3lib_extMgm::siteRelPath($this->extKey) . 'res1/default_previewicon.gif';
$previewIcon = '<input type="image" class="c-inputButton" name="i0" value="0" src="' . $previewIconFilename . '" title="" />';
$description = htmlspecialchars($LANG->getLL('template_descriptiondefault'));
$tmplHTML[] = '<table style="float:left; width: 100%;" valign="top"><tr><td colspan="2" nowrap="nowrap">
<h3 class="bgColor3-20">' . htmlspecialchars($LANG->getLL('template_titledefault')) . '</h3></td></tr>
<tr><td valign="top">' . $previewIcon . '</td><td width="120" valign="top"><p>' . $description . '</p></td></tr></table>';
$tTO = 'tx_templavoila_tmplobj';
$tDS = 'tx_templavoila_datastructure';
$where = $tTO . '.parent=0 AND ' . $tTO . '.pid=' . intval($storageFolderPID) . ' AND ' . $tDS . '.scope=1' . $this->buildRecordWhere($tTO) . $this->buildRecordWhere($tDS) . t3lib_befunc::deleteClause($tTO) . t3lib_befunc::deleteClause($tDS) . t3lib_BEfunc::versioningPlaceholderClause($tTO) . t3lib_BEfunc::versioningPlaceholderClause($tDS);
$res = $TYPO3_DB->exec_SELECTquery($tTO . '.*', $tTO . ' LEFT JOIN ' . $tDS . ' ON ' . $tTO . '.datastructure = ' . $tDS . '.uid', $where);
while (false !== ($row = $TYPO3_DB->sql_fetch_assoc($res))) {
// Check if preview icon exists, otherwise use default icon:
$tmpFilename = 'uploads/tx_templavoila/' . $row['previewicon'];
$previewIconFilename = @is_file(PATH_site . $tmpFilename) ? $GLOBALS['BACK_PATH'] . '../' . $tmpFilename : $GLOBALS['BACK_PATH'] . '../' . t3lib_extMgm::siteRelPath($this->extKey) . 'res1/default_previewicon.gif';
// Note: we cannot use value of image input element because MSIE replaces this value with mouse coordinates! Thus on click we set value to a hidden field. See http://bugs.typo3.org/view.php?id=3376
$previewIcon = '<input type="image" class="c-inputButton" name="i' . $row['uid'] . '" onclick="document.getElementById(\'data_tx_templavoila_to\').value=' . $row['uid'] . '" src="' . $previewIconFilename . '" title="" />';
$description = $row['description'] ? htmlspecialchars($row['description']) : $LANG->getLL('template_nodescriptionavailable');
$tmplHTML[] = '<table style="width: 100%;" valign="top"><tr><td colspan="2" nowrap="nowrap"><h3 class="bgColor3-20">' . htmlspecialchars($row['title']) . '</h3></td></tr>' . '<tr><td valign="top">' . $previewIcon . '</td><td width="120" valign="top"><p>' . $description . '</p></td></tr></table>';
}
$tmplHTML[] = '<input type="hidden" id="data_tx_templavoila_to" name="data[tx_templavoila_to]" value="0" />';
break;
case 't3d':
if (t3lib_extMgm::isLoaded('impexp')) {
// Read template files from a certain folder. I suggest this is configurable in some way. But here it is hardcoded for initial tests.
$templateFolder = PATH_site . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '/export/templates/';
$files = t3lib_div::getFilesInDir($templateFolder, 't3d,xml', 1, 1);
// Traverse the files found:
foreach ($files as $absPath) {
// Initialize the import object:
$import = $this->getImportObject();
if ($import->loadFile($absPath)) {
if (is_array($import->dat['header']['pagetree'])) {
// This means there are pages in the file, we like that...:
// Page tree:
reset($import->dat['header']['pagetree']);
$pageTree = current($import->dat['header']['pagetree']);
// Thumbnail icon:
if (is_array($import->dat['header']['thumbnail'])) {
$pI = pathinfo($import->dat['header']['thumbnail']['filename']);
if (t3lib_div::inList('gif,jpg,png,jpeg', strtolower($pI['extension']))) {
// Construct filename and write it:
$fileName = PATH_site . 'typo3temp/importthumb_' . t3lib_div::shortMD5($absPath) . '.' . $pI['extension'];
t3lib_div::writeFile($fileName, $import->dat['header']['thumbnail']['content']);
// Check that the image really is an image and not a malicious PHP script...
if (getimagesize($fileName)) {
// Create icon tag:
$iconTag = '<img src="' . $this->doc->backPath . '../' . substr($fileName, strlen(PATH_site)) . '" ' . $import->dat['header']['thumbnail']['imgInfo'][3] . ' vspace="5" style="border: solid black 1px;" alt="" />';
} else {
t3lib_div::unlink_tempfile($fileName);
$iconTag = '';
}
}
}
$aTagB = '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('templateFile' => $absPath))) . '">';
$aTagE = '</a>';
$tmplHTML[] = '<table style="float:left; width: 100%;" valign="top"><tr><td colspan="2" nowrap="nowrap">
<h3 class="bgColor3-20">' . $aTagB . htmlspecialchars($import->dat['header']['meta']['title'] ? $import->dat['header']['meta']['title'] : basename($absPath)) . $aTagE . '</h3></td></tr>
<tr><td valign="top">' . $aTagB . $iconTag . $aTagE . '</td><td valign="top"><p>' . htmlspecialchars($import->dat['header']['meta']['description']) . '</p>
<em>Levels: ' . (count($pageTree) > 1 ? 'Deep structure' : 'Single page') . '<br/>
File: ' . basename($absPath) . '</em></td></tr></table>';
}
}
}
}
break;
}
if (is_array($tmplHTML) && count($tmplHTML)) {
$counter = 0;
$content .= '<table>';
foreach ($tmplHTML as $single) {
$content .= ($counter ? '' : '<tr>') . '<td valign="top">' . $single . '</td>' . ($counter ? '</tr>' : '');
$counter++;
if ($counter > 1) {
$counter = 0;
}
}
$content .= '</table>';
}
return $content;
}
示例8: __destruct
/**
* Do some cleanup at the end (deleting attachment files)
*/
public function __destruct()
{
foreach ($this->temporaryFiles as $file) {
t3lib_div::unlink_tempfile($file);
}
}
示例9: upload_copy_file
/**
* [Describe function...]
*
* @param [type] $typeDat: ...
* @param [type] $tplRow: ...
* @param [type] $theRealFileName: ...
* @param [type] $tmp_name: ...
* @return [type] ...
*/
function upload_copy_file($typeDat, &$tplRow, $theRealFileName, $tmp_name)
{
// extensions
$extList = $typeDat['paramstr'];
if ($extList == 'IMAGE_EXT') {
$extList = $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'];
}
$fI = t3lib_div::split_fileref($theRealFileName);
if ($theRealFileName && (!$extList || t3lib_div::inList($extList, $fI['fileext']))) {
$tmp_upload_name = t3lib_div::upload_to_tempfile($tmp_name);
// If there is an uploaded file, move it for the sake of safe_mode.
// Saving resource
$alternativeFileName = array();
$alternativeFileName[$tmp_upload_name] = $theRealFileName;
// Making list of resources
$resList = $tplRow['resources'];
$resList = $tmp_upload_name . ',' . $resList;
$resList = implode(t3lib_div::trimExplode(',', $resList, 1), ',');
// Making data-array
$saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid'];
$recData = array();
$recData['sys_template'][$saveId]['resources'] = $resList;
// Saving
$tce = t3lib_div::makeInstance('t3lib_TCEmain');
$tce->stripslashes_values = 0;
$tce->alternativeFileName = $alternativeFileName;
$tce->start($recData, array());
$tce->process_datamap();
t3lib_div::unlink_tempfile($tmp_upload_name);
$tmpRow = t3lib_BEfunc::getRecordWSOL('sys_template', $saveId, 'resources');
$tplRow['resources'] = $tmpRow['resources'];
// Setting the value
$var = $this->ext_setStar($theRealFileName);
}
return $var;
}
示例10: renderTemplateSelector
/**
* Renders the template selector.
*
* @param integer Position id. Can be positive and negative depending of where the new page is going: Negative always points to a position AFTER the page having the abs. value of the positionId. Positive numbers means to create as the first subpage to another page.
* @param string $templateType: The template type, 'tmplobj' or 't3d'
* @return string HTML output containing a table with the template selector
*/
function renderTemplateSelector($positionPid, $templateType = 'tmplobj')
{
global $LANG, $TYPO3_DB;
$storageFolderPID = $this->apiObj->getStorageFolderPid($positionPid);
$tmplHTML = array();
$defaultIcon = $this->doc->backPath . '../' . t3lib_extMgm::siteRelPath($this->extKey) . 'res1/default_previewicon.gif';
// look for TCEFORM.pages.tx_templavoila_ds.removeItems / TCEFORM.pages.tx_templavoila_to.removeItems
$disallowedPageTemplateItems = $this->getDisallowedTSconfigItemsByFieldName($positionPid, 'tx_templavoila_ds');
$disallowedDesignTemplateItems = $this->getDisallowedTSconfigItemsByFieldName($positionPid, 'tx_templavoila_to');
switch ($templateType) {
case 'tmplobj':
// Create the "Default template" entry
//Fetch Default TO
$fakeRow = array('uid' => abs($positionPid));
$defaultTO = $this->pObj->apiObj->getContentTree_fetchPageTemplateObject($fakeRow);
// Create the "Default template" entry
if ($defaultTO['previewicon']) {
$previewIconFilename = @is_file(PATH_site . 'uploads/tx_templavoila/' . $defaultTO['previewicon']) ? $GLOBALS['BACK_PATH'] . '../' . 'uploads/tx_templavoila/' . $defaultTO['previewicon'] : $defaultIcon;
} else {
$previewIconFilename = $defaultIcon;
}
$previewIcon = '<input type="image" class="c-inputButton" name="i0" value="0" src="' . $previewIconFilename . '" title="" />';
$description = $defaultTO['description'] ? htmlspecialchars($defaultTO['description']) : $LANG->getLL('template_descriptiondefault', 1);
$tmplHTML[] = '<table style="float:left; width: 100%;" valign="top">
<tr>
<td colspan="2" nowrap="nowrap">
<h3 class="bgColor3-20">' . htmlspecialchars($LANG->getLL('template_titleInherit')) . '</h3>
</td>
</tr><tr>
<td valign="top">' . $previewIcon . '</td>
<td width="120" valign="top">
<p><h4>' . htmlspecialchars($LANG->sL($defaultTO['title'])) . '</h4>' . $LANG->sL($description) . '</p>
</td>
</tr>
</table>';
$dsRepo = t3lib_div::makeInstance('tx_templavoila_datastructureRepository');
$toRepo = t3lib_div::makeInstance('tx_templavoila_templateRepository');
$dsList = $dsRepo->getDatastructuresByStoragePidAndScope($storageFolderPID, tx_templavoila_datastructure::SCOPE_PAGE);
foreach ($dsList as $dsObj) {
if (t3lib_div::inList($disallowedPageTemplateItems, $dsObj->getKey()) || !$dsObj->isPermittedForUser()) {
continue;
}
$toList = $toRepo->getTemplatesByDatastructure($dsObj, $storageFolderPID);
foreach ($toList as $toObj) {
if ($toObj->getKey() === $defaultTO['uid'] || !$toObj->isPermittedForUser() || t3lib_div::inList($disallowedDesignTemplateItems, $toObj->getKey())) {
continue;
}
$tmpFilename = $toObj->getIcon();
$previewIconFilename = @is_file(PATH_site . substr($tmpFilename, 3)) ? $GLOBALS['BACK_PATH'] . $tmpFilename : $defaultIcon;
// Note: we cannot use value of image input element because MSIE replaces this value with mouse coordinates! Thus on click we set value to a hidden field. See http://bugs.typo3.org/view.php?id=3376
$previewIcon = '<input type="image" class="c-inputButton" name="i' . $row['uid'] . '" onclick="document.getElementById(\'data_tx_templavoila_to\').value=' . $toObj->getKey() . '" src="' . $previewIconFilename . '" title="" />';
$description = $toObj->getDescription() ? htmlspecialchars($toObj->getDescription()) : $LANG->getLL('template_nodescriptionavailable');
$tmplHTML[] = '<table style="width: 100%;" valign="top"><tr><td colspan="2" nowrap="nowrap"><h3 class="bgColor3-20">' . htmlspecialchars($toObj->getLabel()) . '</h3></td></tr>' . '<tr><td valign="top">' . $previewIcon . '</td><td width="120" valign="top"><p>' . $LANG->sL($description) . '</p></td></tr></table>';
}
}
$tmplHTML[] = '<input type="hidden" id="data_tx_templavoila_to" name="data[tx_templavoila_to]" value="0" />';
break;
case 't3d':
if (t3lib_extMgm::isLoaded('impexp')) {
// Read template files from a certain folder. I suggest this is configurable in some way. But here it is hardcoded for initial tests.
$templateFolder = PATH_site . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '/export/templates/';
$files = t3lib_div::getFilesInDir($templateFolder, 't3d,xml', 1, 1);
// Traverse the files found:
foreach ($files as $absPath) {
// Initialize the import object:
$import = $this->getImportObject();
if ($import->loadFile($absPath)) {
if (is_array($import->dat['header']['pagetree'])) {
// This means there are pages in the file, we like that...:
// Page tree:
reset($import->dat['header']['pagetree']);
$pageTree = current($import->dat['header']['pagetree']);
// Thumbnail icon:
if (is_array($import->dat['header']['thumbnail'])) {
$pI = pathinfo($import->dat['header']['thumbnail']['filename']);
if (t3lib_div::inList('gif,jpg,png,jpeg', strtolower($pI['extension']))) {
// Construct filename and write it:
$fileName = PATH_site . 'typo3temp/importthumb_' . t3lib_div::shortMD5($absPath) . '.' . $pI['extension'];
t3lib_div::writeFile($fileName, $import->dat['header']['thumbnail']['content']);
// Check that the image really is an image and not a malicious PHP script...
if (getimagesize($fileName)) {
// Create icon tag:
$iconTag = '<img src="' . $this->doc->backPath . '../' . substr($fileName, strlen(PATH_site)) . '" ' . $import->dat['header']['thumbnail']['imgInfo'][3] . ' vspace="5" style="border: solid black 1px;" alt="" />';
} else {
t3lib_div::unlink_tempfile($fileName);
$iconTag = '';
}
}
}
$aTagB = '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('templateFile' => $absPath))) . '">';
$aTagE = '</a>';
$tmplHTML[] = '<table style="float:left; width: 100%;" valign="top"><tr><td colspan="2" nowrap="nowrap">
<h3 class="bgColor3-20">' . $aTagB . htmlspecialchars($import->dat['header']['meta']['title'] ? $import->dat['header']['meta']['title'] : basename($absPath)) . $aTagE . '</h3></td></tr>
//.........这里部分代码省略.........
示例11: displayDetail
//.........这里部分代码省略.........
$html_attachments = array();
$text_attachments = array();
if (isset($_FILES['tx_dmmjobcontrol_pi1']['name']['apply']['file']) && $_FILES['tx_dmmjobcontrol_pi1']['name']['apply']['file']) {
if (isset($this->conf['apply.']['allowed_file_extensions']) && $this->conf['apply.']['allowed_file_extensions']) {
$allowed_file_extensions = $this->conf['apply.']['allowed_file_extensions'];
} else {
$allowed_file_extensions = 'doc,docx,pdf,odt,sxw,rtf';
}
foreach ($_FILES['tx_dmmjobcontrol_pi1']['name']['apply']['file'] as $index => $name) {
if ($name) {
$fileInfo = pathinfo($_FILES['tx_dmmjobcontrol_pi1']['name']['apply']['file'][$index]);
if (t3lib_div::inList($allowed_file_extensions, strtolower($fileInfo['extension'])) && t3lib_div::verifyFilenameAgainstDenyPattern($name)) {
$source = $_FILES['tx_dmmjobcontrol_pi1']['tmp_name']['apply']['file'][$index];
$destination = PATH_site . 'typo3temp/' . $fileInfo['basename'];
t3lib_div::upload_copy_move($source, $destination);
$html_attachments[] = $destination;
$text_attachments[] = $GLOBALS['TSFE']->baseUrlWrap('typo3temp/' . $fileInfo['basename']);
} else {
$htmlBody .= '<p><i>The uploaded file "' . $fileInfo['basename'] . '" was not attached because it was not in a valid file format.</i></p>';
$textBody .= "\n\nThe uploaded file " . $fileInfo['basename'] . " was not attached because it was not in a valid file format.";
}
}
}
}
// Is there a contact person added to the job?
if ($row['contact']) {
$contact_res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', ' tx_dmmjobcontrol_contact', 'uid=' . $row['contact']);
if ($contact_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($contact_res)) {
$this->conf['apply.']['to'] = $contact_row['email'];
}
}
if (isset($this->conf['htmlmail']) && $this->conf['htmlmail']) {
// Send HTML email with file attachment(s)
$htmlmailClass = t3lib_div::makeInstance('t3lib_mail_message');
$htmlmailClass->setFrom(array($this->conf['apply.']['to'] => $this->pi_getLL('mail_from_name')));
$htmlmailClass->setReplyTo(array($this->conf['apply.']['to'] => $this->pi_getLL('mail_from_name')));
$htmlmailClass->setTo($this->conf['apply.']['to']);
$htmlmailClass->setSubject($subject);
$htmlmailClass->setBody($body);
// Add CV as attachment
foreach ($html_attachments as $attachment) {
$htmlmailClass->attach(Swift_Attachment::fromPath($attachment));
}
$htmlmailClass->setBody($htmlBody, 'text/html');
$htmlmailClass->addPart($textBody, 'text/plain');
$htmlmailClass->send();
foreach ($html_attachments as $attachment) {
t3lib_div::unlink_tempfile($attachment);
}
} else {
// Send plain text email, CV and letter as download links
foreach ($text_attachments as $attachment) {
$textBody .= "\n\nUploaded file: " . $attachment;
}
$this->cObj->sendNotifyEmail($subject . "\n" . $textBody, $this->conf['apply.']['to'], '', $this->conf['apply.']['to'], 'JobControl job application');
}
if (isset($this->conf['apply.']['redirect']) && $this->conf['apply.']['redirect']) {
// redirect to given page
header('Location: /' . $this->cObj->getTypoLink_URL($this->conf['apply.']['redirect']));
exit;
}
// The thank-you page
$template['thanks'] = $this->cObj->getSubpart($this->templateCode, '###APPLY_THANKS_TEMPLATE###');
return $this->cObj->substituteMarkerArrayCached($template['thanks'], $markerArray);
} else {
// Show the detail page / apply form
// Get the template
if ($applyOnly) {
$this->templateCode = $this->cObj->fileResource($this->conf['template.']['apply']);
} else {
$this->templateCode = $this->cObj->fileResource($this->conf['template.']['detail']);
}
if (is_null($this->templateCode)) {
return $this->pi_getLL('template_not_found');
}
// Get the main part out of the template
$template['total'] = $this->cObj->getSubpart($this->templateCode, '###TEMPLATE###');
if ($applyOnly) {
// If we only have to show the apply form, then we are already done now
return $this->getApplyFormData($template['total'], $markerArray);
}
// On the detail page we have to fill the APPLY part of the template
$wrappedMarkerArray['###APPLY###'] = '';
if (isset($this->conf['apply.']['form']) && $this->conf['apply.']['form']) {
$applyForm = '';
if ($this->conf['apply.']['form'] == 1) {
$applyForm = $this->cObj->fileResource($this->conf['template.']['apply']);
$applyForm = $this->cObj->getSubpart($applyForm, '###TEMPLATE###');
}
$template['apply'] = $this->cObj->getSubpart($template['total'], '###APPLY###');
$template['apply'] = $this->cObj->substituteMarkerArrayCached($template['apply'], array('###INCLUDE_APPLY_FORM###' => $applyForm));
$wrappedMarkerArray['###APPLY###'] = $this->getApplyFormData($template['apply'], $markerArray);
}
return $this->cObj->substituteMarkerArrayCached($template['total'], $markerArray, $wrappedMarkerArray);
}
}
}
// Job not found or job_uid not set at all
return $this->notFound();
}
示例12: importExtFromRep
/**
* Imports an extensions from the online repository
* NOTICE: in version 4.0 this changed from "importExtFromRep_old($extRepUid,$loc,$uploadFlag=0,$directInput='',$recentTranslations=0,$incManual=0,$dontDelete=0)"
*
* @param string Extension key
* @param string Version
* @param string Install scope: "L" or "G" or "S"
* @param boolean If true, extension is uploaded as file
* @param boolean If true, extension directory+files will not be deleted before writing the new ones. That way custom files stored in the extension folder will be kept.
* @param array Direct input array (like from kickstarter)
* @return string Return false on success, returns error message if error.
*/
function importExtFromRep($extKey, $version, $loc, $uploadFlag = 0, $dontDelete = 0, $directInput = '')
{
$uploadSucceed = false;
$uploadedTempFile = '';
if (is_array($directInput)) {
$fetchData = array($directInput, '');
$loc = $loc === 'G' || $loc === 'S' ? $loc : 'L';
} elseif ($uploadFlag) {
if (($uploadedTempFile = $this->CMD['alreadyUploaded']) || $_FILES['upload_ext_file']['tmp_name']) {
// Read uploaded file:
if (!$uploadedTempFile) {
if (!is_uploaded_file($_FILES['upload_ext_file']['tmp_name'])) {
t3lib_div::sysLog('Possible file upload attack: ' . $_FILES['upload_ext_file']['tmp_name'], 'Extension Manager', 3);
$flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('ext_import_file_not_uploaded'), '', t3lib_FlashMessage::ERROR);
return $flashMessage->render();
}
$uploadedTempFile = t3lib_div::upload_to_tempfile($_FILES['upload_ext_file']['tmp_name']);
}
$fileContent = t3lib_div::getUrl($uploadedTempFile);
if (!$fileContent) {
$flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('ext_import_file_empty'), '', t3lib_FlashMessage::ERROR);
return $flashMessage->render();
}
// Decode file data:
$fetchData = $this->terConnection->decodeExchangeData($fileContent);
if (is_array($fetchData)) {
$extKey = $fetchData[0]['extKey'];
if ($extKey) {
if (!$this->CMD['uploadOverwrite']) {
$loc = $loc === 'G' || $loc === 'S' ? $loc : 'L';
$comingExtPath = tx_em_Tools::typePath($loc) . $extKey . '/';
if (@is_dir($comingExtPath)) {
$flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf($GLOBALS['LANG']->getLL('ext_import_ext_present_no_overwrite'), $comingExtPath) . '<br />' . $GLOBALS['LANG']->getLL('ext_import_ext_present_nothing_done'), '', t3lib_FlashMessage::ERROR);
return $flashMessage->render();
}
// ... else go on, install...
}
// ... else go on, install...
} else {
$flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('ext_import_no_key'), '', t3lib_FlashMessage::ERROR);
return $flashMessage->render();
}
} else {
$flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf($GLOBALS['LANG']->getLL('ext_import_wrong_file_format'), $fetchData), '', t3lib_FlashMessage::ERROR);
return $flashMessage->render();
}
} else {
$flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('ext_import_no_file'), '', t3lib_FlashMessage::ERROR);
return $flashMessage->render();
}
} else {
$this->xmlHandler->searchExtensionsXMLExact($extKey, '', '', true, true);
// Fetch extension from TER:
if (!strlen($version)) {
$versions = array_keys($this->xmlHandler->extensionsXML[$extKey]['versions']);
$version = end($versions);
}
$fetchData = $this->terConnection->fetchExtension($extKey, $version, $this->xmlHandler->extensionsXML[$extKey]['versions'][$version]['t3xfilemd5'], $this->getMirrorURL());
}
// At this point the extension data should be present; so we want to write it to disc:
$content = $this->install->installExtension($fetchData, $loc, $version, $uploadedTempFile, $dontDelete);
$this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_import_results'), $content, 0, 1);
if ($uploadSucceed && $uploadedTempFile) {
t3lib_div::unlink_tempfile($uploadedTempFile);
}
return false;
}
示例13: importExtFromRep
//.........这里部分代码省略.........
$this->content .= $depStatus['html'];
if ($uploadedTempFile) {
$this->content .= '<input type="hidden" name="CMD[alreadyUploaded]" value="' . $uploadedTempFile . '" />';
}
} else {
$res = $this->clearAndMakeExtensionDir($fetchData[0], $loc, $dontDelete);
if (is_array($res)) {
$extDirPath = trim($res[0]);
if ($extDirPath && @is_dir($extDirPath) && substr($extDirPath, -1) == '/') {
$emConfFile = $this->construct_ext_emconf_file($extKey, $EM_CONF);
$dirs = $this->extractDirsFromFileList(array_keys($fetchData[0]['FILES']));
$res = $this->createDirsInPath($dirs, $extDirPath);
if (!$res) {
$writeFiles = $fetchData[0]['FILES'];
$writeFiles['ext_emconf.php']['content'] = $emConfFile;
$writeFiles['ext_emconf.php']['content_md5'] = md5($emConfFile);
// Write files:
foreach ($writeFiles as $theFile => $fileData) {
t3lib_div::writeFile($extDirPath . $theFile, $fileData['content']);
if (!@is_file($extDirPath . $theFile)) {
$content .= sprintf($GLOBALS['LANG']->getLL('ext_import_file_not_created'), $extDirPath . $theFile) . '<br />';
} elseif (md5(t3lib_div::getUrl($extDirPath . $theFile)) != $fileData['content_md5']) {
$content .= sprintf($GLOBALS['LANG']->getLL('ext_import_file_corrupted'), $extDirPath . $theFile) . '<br />';
}
}
t3lib_div::fixPermissions($extDirPath, TRUE);
// No content, no errors. Create success output here:
if (!$content) {
$messageContent = sprintf($GLOBALS['LANG']->getLL('ext_import_success_folder'), $extDirPath) . '<br />';
$uploadSucceed = true;
// Fix TYPO3_MOD_PATH for backend modules in extension:
$modules = t3lib_div::trimExplode(',', $EM_CONF['module'], 1);
if (count($modules)) {
foreach ($modules as $mD) {
$confFileName = $extDirPath . $mD . '/conf.php';
if (@is_file($confFileName)) {
$messageContent .= $this->writeTYPO3_MOD_PATH($confFileName, $loc, $extKey . '/' . $mD . '/') . '<br />';
} else {
$messageContent .= sprintf($GLOBALS['LANG']->getLL('ext_import_no_conf_file'), $confFileName) . '<br />';
}
}
}
// NOTICE: I used two hours trying to find out why a script, ext_emconf.php, written twice and in between included by PHP did not update correct the second time. Probably something with PHP-A cache and mtime-stamps.
// But this order of the code works.... (using the empty Array with type, EMCONF and files hereunder).
// Writing to ext_emconf.php:
$sEMD5A = $this->serverExtensionMD5Array($extKey, array('type' => $loc, 'EM_CONF' => array(), 'files' => array()));
$EM_CONF['_md5_values_when_last_written'] = serialize($sEMD5A);
$emConfFile = $this->construct_ext_emconf_file($extKey, $EM_CONF);
t3lib_div::writeFile($extDirPath . 'ext_emconf.php', $emConfFile);
$messageContent .= 'ext_emconf.php: ' . $extDirPath . 'ext_emconf.php<br />';
$messageContent .= $GLOBALS['LANG']->getLL('ext_import_ext_type') . ' ';
$messageContent .= $this->typeLabels[$loc] . '<br />';
$messageContent .= '<br />';
// Remove cache files:
$updateContent = '';
if (t3lib_extMgm::isLoaded($extKey)) {
if ($this->removeCacheFiles()) {
$messageContent .= $GLOBALS['LANG']->getLL('ext_import_cache_files_removed') . '<br />';
}
list($new_list) = $this->getInstalledExtensions();
$updateContent = $this->updatesForm($extKey, $new_list[$extKey], 1, 'index.php?CMD[showExt]=' . $extKey . '&SET[singleDetails]=info');
}
$flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $messageContent, $GLOBALS['LANG']->getLL('ext_import_success'));
$content = $flashMessage->render() . $updateContent;
// Install / Uninstall:
if (!$this->CMD['standAlone']) {
$content .= '<h3>' . $GLOBALS['LANG']->getLL('ext_import_install_uninstall') . '</h3>';
$content .= $new_list[$extKey] ? '<a href="' . htmlspecialchars('index.php?CMD[showExt]=' . $extKey . '&CMD[remove]=1&CMD[clrCmd]=1&SET[singleDetails]=info') . '">' . $this->removeButton() . ' ' . $GLOBALS['LANG']->getLL('ext_import_uninstall') . '</a>' : '<a href="' . htmlspecialchars('index.php?CMD[showExt]=' . $extKey . '&CMD[load]=1&CMD[clrCmd]=1&SET[singleDetails]=info') . '">' . $this->installButton() . ' ' . $GLOBALS['LANG']->getLL('ext_import_install') . '</a>';
} else {
$content = $GLOBALS['LANG']->getLL('ext_import_imported') . '<br /><br /><a href="javascript:opener.top.content.document.forms[0].submit();window.close();">' . $GLOBALS['LANG']->getLL('ext_import_close_check') . '</a>';
}
}
} else {
$content = $res;
}
} else {
$content = sprintf($GLOBALS['LANG']->getLL('ext_import_ext_path_different'), $extDirPath);
}
} else {
$content = $res;
}
}
} else {
$content = sprintf($GLOBALS['LANG']->getLL('ext_import_ext_only_here'), $this->typePaths[$EM_CONF['lockType']], $EM_CONF['lockType']);
}
} else {
$content = $GLOBALS['LANG']->getLL('ext_import_no_ext_key_files');
}
} else {
$content = sprintf($GLOBALS['LANG']->getLL('ext_import_data_transfer'), $fetchData);
}
} else {
$content = sprintf($GLOBALS['LANG']->getLL('ext_import_no_install_here'), $this->typePaths[$loc]);
}
$this->content .= $this->doc->section($GLOBALS['LANG']->getLL('ext_import_results'), $content, 0, 1);
if ($uploadSucceed && $uploadedTempFile) {
t3lib_div::unlink_tempfile($uploadedTempFile);
}
return false;
}
示例14: generateGraphic
/**
* The actual sprite generator, renders the command for Im/GM and executes
*
* @return void
*/
protected function generateGraphic()
{
$iconParameters = array();
$tempSprite = t3lib_div::tempnam($this->spriteName);
$filePath = array('mainFile' => PATH_site . $this->spriteFolder . $this->spriteName . '.png', 'gifFile' => NULL);
// create black true color image with given size
$newSprite = imagecreatetruecolor($this->spriteWidth, $this->spriteHeight);
imagesavealpha($newSprite, TRUE);
// make it transparent
imagefill($newSprite, 0, 0, imagecolorallocatealpha($newSprite, 0, 255, 255, 127));
foreach ($this->iconsData as $icon) {
$function = 'imagecreatefrom' . strtolower($icon['fileExtension']);
if (function_exists($function)) {
$currentIcon = $function($icon['fileName']);
imagecopy($newSprite, $currentIcon, $icon['left'], $icon['top'], 0, 0, $icon['width'], $icon['height']);
}
}
imagepng($newSprite, $tempSprite . '.png');
if ($this->generateGIFCopy) {
$filePath['gifFile'] = PATH_site . $this->spriteFolder . $this->spriteName . '.gif';
$gifSprite = imagecreatetruecolor($this->spriteWidth, $this->spriteHeight);
// make it transparent
imagefill($gifSprite, 0, 0, imagecolorallocate($gifSprite, 127, 127, 127));
foreach ($this->iconsData as $icon) {
$function = 'imagecreatefrom' . strtolower($icon['fileExtension']);
if (function_exists($function)) {
$currentIcon = $function($icon['fileName']);
imagecopy($gifSprite, $currentIcon, $icon['left'], $icon['top'], 0, 0, $icon['width'], $icon['height']);
}
}
imagecolortransparent($gifSprite, imagecolorallocate($gifSprite, 127, 127, 127));
imagegif($gifSprite, $tempSprite . '.gif');
}
t3lib_div::upload_copy_move($tempSprite . '.png', $filePath['mainFile']);
t3lib_div::unlink_tempfile($tempSprite . '.png');
if ($this->generateGIFCopy) {
t3lib_div::upload_copy_move($tempSprite . '.gif', $filePath['gifFile']);
t3lib_div::unlink_tempfile($tempSprite . '.gif');
}
}
示例15: unlinkTempFiles
/**
* Delete registered temporary files.
*
* @param string File name with absolute path.
* @return void
*/
function unlinkTempFiles()
{
foreach ($this->tempFiles as $absFile) {
t3lib_div::unlink_tempfile($absFile);
}
$this->tempFiles = array();
}