/**
  * Start function
  * This class is able to generate a mail in formmail-style from the data in $V
  * Fields:
  *
  * [recipient]:			email-adress of the one to receive the mail. If array, then all values are expected to be recipients
  * [attachment]:		....
  *
  * [subject]:			The subject of the mail
  * [from_email]:		Sender email. If not set, [email] is used
  * [from_name]:			Sender name. If not set, [name] is used
  * [replyto_email]:		Reply-to email. If not set [from_email] is used
  * [replyto_name]:		Reply-to name. If not set [from_name] is used
  * [organisation]:		Organization (header)
  * [priority]:			Priority, 1-5, default 3
  * [html_enabled]:		If mail is sent as html
  * [use_base64]:		If set, base64 encoding will be used instead of quoted-printable
  *
  * @param	array		Contains values for the field names listed above (with slashes removed if from POST input)
  * @param	boolean		Whether to base64 encode the mail content
  * @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) . '&nbsp;</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
0
    /**
     * Import part of module
     *
     * @param	array		Content of POST VAR tx_impexp[]..
     * @return	void		Setting content in $this->content
     */
    function importData($inData)
    {
        global $TCA, $LANG, $BE_USER;
        $access = is_array($this->pageinfo) ? 1 : 0;
        if ($this->id && $access || $BE_USER->user['admin'] && !$this->id) {
            if ($BE_USER->user['admin'] && !$this->id) {
                $this->pageinfo = array('title' => '[root-level]', 'uid' => 0, 'pid' => 0);
            }
            if ($inData['new_import']) {
                unset($inData['import_mode']);
            }
            $import = t3lib_div::makeInstance('tx_impexp');
            $import->init(0, 'import');
            $import->update = $inData['do_update'];
            $import->import_mode = $inData['import_mode'];
            $import->enableLogging = $inData['enableLogging'];
            $import->global_ignore_pid = $inData['global_ignore_pid'];
            $import->force_all_UIDS = $inData['force_all_UIDS'];
            $import->showDiff = !$inData['notShowDiff'];
            $import->allowPHPScripts = $inData['allowPHPScripts'];
            $import->softrefInputValues = $inData['softrefInputValues'];
            // OUTPUT creation:
            $menuItems = array();
            // Make input selector:
            $path = $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'];
            // must have trailing slash.
            $filesInDir = t3lib_div::getFilesInDir(PATH_site . $path, 't3d,xml', 1, 1);
            $userPath = $this->userSaveFolder();
            //Files from User-Dir
            $filesInUserDir = t3lib_div::getFilesInDir($userPath, 't3d,xml', 1, 1);
            $filesInDir = array_merge($filesInUserDir, $filesInDir);
            if (is_dir(PATH_site . $path . 'export/')) {
                $filesInDir = array_merge($filesInDir, t3lib_div::getFilesInDir(PATH_site . $path . 'export/', 't3d,xml', 1, 1));
            }
            $tempFolder = $this->userTempFolder();
            if ($tempFolder) {
                $temp_filesInDir = t3lib_div::getFilesInDir($tempFolder, 't3d,xml', 1, 1);
                $filesInDir = array_merge($filesInDir, $temp_filesInDir);
            }
            // Configuration
            $row = array();
            $opt = array('');
            foreach ($filesInDir as $file) {
                $opt[$file] = substr($file, strlen(PATH_site));
            }
            $row[] = '<tr class="bgColor5">
					<td colspan="2"><strong>' . $LANG->getLL('importdata_selectFileToImport', 1) . '</strong></td>
				</tr>';
            $row[] = '<tr class="bgColor4">
				<td><strong>' . $LANG->getLL('importdata_file', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'importFile', $GLOBALS['BACK_PATH'], '') . '</td>
				<td>' . $this->renderSelectBox('tx_impexp[file]', $inData['file'], $opt) . '<br />' . sprintf($LANG->getLL('importdata_fromPathS', 1), $path) . (!$import->compress ? '<br /><span class="typo3-red">' . $LANG->getLL('importdata_noteNoDecompressorAvailable', 1) . '</span>' : '') . '</td>
				</tr>';
            $row[] = '<tr class="bgColor5">
					<td colspan="2"><strong>' . $LANG->getLL('importdata_importOptions', 1) . '</strong></td>
				</tr>';
            $row[] = '<tr class="bgColor4">
				<td><strong>' . $LANG->getLL('importdata_update', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'update', $GLOBALS['BACK_PATH'], '') . '</td>
				<td>
					<input type="checkbox" name="tx_impexp[do_update]" id="checkDo_update" value="1"' . ($inData['do_update'] ? ' checked="checked"' : '') . ' />
					<label for="checkDo_update">' . $LANG->getLL('importdata_updateRecords', 1) . '</label><br/>
				<em>(' . $LANG->getLL('importdata_thisOptionRequiresThat', 1) . ')</em>' . ($inData['do_update'] ? '	<hr/>
					<input type="checkbox" name="tx_impexp[global_ignore_pid]" id="checkGlobal_ignore_pid" value="1"' . ($inData['global_ignore_pid'] ? ' checked="checked"' : '') . ' />
					<label for="checkGlobal_ignore_pid">' . $LANG->getLL('importdata_ignorePidDifferencesGlobally', 1) . '</label><br/>
					<em>(' . $LANG->getLL('importdata_ifYouSetThis', 1) . ')</em>
					' : '') . '</td>
				</tr>';
            $row[] = '<tr class="bgColor4">
				<td><strong>' . $LANG->getLL('importdata_options', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'options', $GLOBALS['BACK_PATH'], '') . '</td>
				<td>
					<input type="checkbox" name="tx_impexp[notShowDiff]" id="checkNotShowDiff" value="1"' . ($inData['notShowDiff'] ? ' checked="checked"' : '') . ' />
					<label for="checkNotShowDiff">' . $LANG->getLL('importdata_doNotShowDifferences', 1) . '</label><br/>
					<em>(' . $LANG->getLL('importdata_greenValuesAreFrom', 1) . ')</em>
					<br/><br/>

					' . ($GLOBALS['BE_USER']->isAdmin() ? '
					<input type="checkbox" name="tx_impexp[allowPHPScripts]" id="checkAllowPHPScripts" value="1"' . ($inData['allowPHPScripts'] ? ' checked="checked"' : '') . ' />
					<label for="checkAllowPHPScripts">' . $LANG->getLL('importdata_allowToWriteBanned', 1) . '</label><br/>' : '') . (!$inData['do_update'] && $GLOBALS['BE_USER']->isAdmin() ? '
					<br/>
					<input type="checkbox" name="tx_impexp[force_all_UIDS]" id="checkForce_all_UIDS" value="1"' . ($inData['force_all_UIDS'] ? ' checked="checked"' : '') . ' />
					<label for="checkForce_all_UIDS"><span class="typo3-red">' . $LANG->getLL('importdata_force_all_UIDS', 1) . '</span></label><br/>
					<em>(' . $LANG->getLL('importdata_force_all_UIDS_descr', 1) . ')</em>' : '') . '
				</td>
				</tr>';
            $row[] = '<tr class="bgColor4">
				<td><strong>' . $LANG->getLL('importdata_action', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'action', $GLOBALS['BACK_PATH'], '') . '</td>
				<td>' . (!$inData['import_file'] ? '<input type="submit" value="' . $LANG->getLL('importdata_preview', 1) . '" />' . ($inData['file'] ? ' - <input type="submit" value="' . ($inData['do_update'] ? $LANG->getLL('importdata_update_299e', 1) : $LANG->getLL('importdata_import', 1)) . '" name="tx_impexp[import_file]" onclick="return confirm(\'' . $LANG->getLL('importdata_areYouSure', 1) . '\');" />' : '') : '<input type="submit" name="tx_impexp[new_import]" value="' . $LANG->getLL('importdata_newImport', 1) . '" />') . '
					<input type="hidden" name="tx_impexp[action]" value="import" /></td>
				</tr>';
            $row[] = '<tr class="bgColor4">
				<td><strong>' . $LANG->getLL('importdata_enableLogging', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'enableLogging', $GLOBALS['BACK_PATH'], '') . '</td>
				<td>
					<input type="checkbox" name="tx_impexp[enableLogging]" id="checkEnableLogging" value="1"' . ($inData['enableLogging'] ? ' checked="checked"' : '') . ' />
					<label for="checkEnableLogging">' . $LANG->getLL('importdata_writeIndividualDbActions', 1) . '</label><br/>
					<em>(' . $LANG->getLL('importdata_thisIsDisabledBy', 1) . ')</em>
				</td>
				</tr>';
            $menuItems[] = array('label' => $LANG->getLL('importdata_import', 1), 'content' => '
					<table border="0" cellpadding="1" cellspacing="1">
						' . implode('
						', $row) . '
					</table>
				');
            // Upload file:
            $tempFolder = $this->userTempFolder();
            if ($tempFolder) {
                $row = array();
                $row[] = '<tr class="bgColor5">
						<td colspan="2"><strong>' . $LANG->getLL('importdata_uploadFileFromLocal', 1) . '</strong></td>
					</tr>';
                $row[] = '<tr class="bgColor4">
						<td>' . $LANG->getLL('importdata_browse', 1) . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'upload', $GLOBALS['BACK_PATH'], '') . '</td>
						<td>

								<input type="file" name="upload_1"' . $this->doc->formWidth(35) . ' size="40" />
								<input type="hidden" name="file[upload][1][target]" value="' . htmlspecialchars($tempFolder) . '" />
								<input type="hidden" name="file[upload][1][data]" value="1" /><br />

								<input type="submit" name="_upload" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit', 1) . '" />
								<input type="checkbox" name="overwriteExistingFiles" id="checkOverwriteExistingFiles" value="1" checked="checked" /> <label for="checkOverwriteExistingFiles">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.php:overwriteExistingFiles', 1) . '</label>
						</td>
					</tr>';
                if (t3lib_div::_POST('_upload')) {
                    $row[] = '<tr class="bgColor4">
							<td>' . $LANG->getLL('importdata_uploadStatus', 1) . '</td>
							<td>' . ($this->fileProcessor->internalUploadMap[1] ? $LANG->getLL('importdata_success', 1) . ' ' . substr($this->fileProcessor->internalUploadMap[1], strlen(PATH_site)) : '<span class="typo3-red">' . $LANG->getLL('importdata_failureNoFileUploaded', 1) . '</span>') . '</td>
						</tr>';
                }
                $menuItems[] = array('label' => $LANG->getLL('importdata_upload'), 'content' => '
						<table border="0" cellpadding="1" cellspacing="1">
							' . implode('
							', $row) . '
						</table>
					');
            }
            // Perform import or preview depending:
            $overviewContent = '';
            $extensionInstallationMessage = '';
            $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);
            }
        }
    }
    /**
     * The main processing method if this class
     *
     * @return	string		Information of the template status or the taken actions as HTML string
     */
    function main()
    {
        global $SOBE, $BE_USER, $LANG, $BACK_PATH, $TCA_DESCR, $TCA, $CLIENT, $TYPO3_CONF_VARS;
        global $tmpl, $tplRow, $theConstants;
        $edit = $this->pObj->edit;
        $e = $this->pObj->e;
        t3lib_div::loadTCA('sys_template');
        // **************************
        // Checking for more than one template an if, set a menu...
        // **************************
        $manyTemplatesMenu = $this->pObj->templateMenu();
        $template_uid = 0;
        if ($manyTemplatesMenu) {
            $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage'];
        }
        // **************************
        // Initialize
        // **************************
        $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid);
        // initialize
        if ($existTemplate) {
            $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid'];
        }
        // **************************
        // Create extension template
        // **************************
        $newId = $this->pObj->createTemplate($this->pObj->id, $saveId);
        if ($newId) {
            // switch to new template
            t3lib_utility_Http::redirect('index.php?id=' . $this->pObj->id . '&SET[templatesOnPage]=' . $newId);
        }
        if ($existTemplate) {
            // Update template ?
            $POST = t3lib_div::_POST();
            if ($POST['submit'] || t3lib_div::testInt($POST['submit_x']) && t3lib_div::testInt($POST['submit_y']) || $POST['saveclose'] || t3lib_div::testInt($POST['saveclose_x']) && t3lib_div::testInt($POST['saveclose_y'])) {
                // Set the data to be saved
                $recData = array();
                $alternativeFileName = array();
                $resList = $tplRow['resources'];
                $tmp_upload_name = '';
                $tmp_newresource_name = '';
                // Set this to blank
                if (is_array($POST['data'])) {
                    foreach ($POST['data'] as $field => $val) {
                        switch ($field) {
                            case 'constants':
                            case 'config':
                            case 'title':
                            case 'sitetitle':
                            case 'description':
                                $recData['sys_template'][$saveId][$field] = $val;
                                break;
                            case 'resources':
                                $tmp_upload_name = t3lib_div::upload_to_tempfile($_FILES['resources']['tmp_name']);
                                // If there is an uploaded file, move it for the sake of safe_mode.
                                if ($tmp_upload_name) {
                                    if ($tmp_upload_name != 'none' && $_FILES['resources']['name']) {
                                        $alternativeFileName[$tmp_upload_name] = trim($_FILES['resources']['name']);
                                        $resList = $tmp_upload_name . ',' . $resList;
                                    }
                                }
                                break;
                            case 'new_resource':
                                $newName = trim(t3lib_div::_GP('new_resource'));
                                if ($newName) {
                                    $newName .= '.' . t3lib_div::_GP('new_resource_ext');
                                    $tmp_newresource_name = t3lib_div::tempnam('new_resource_');
                                    $alternativeFileName[$tmp_newresource_name] = $newName;
                                    $resList = $tmp_newresource_name . ',' . $resList;
                                }
                                break;
                            case 'makecopy_resource':
                                if (is_array($val)) {
                                    $resList = ',' . $resList . ',';
                                    foreach ($val as $k => $file) {
                                        $tmp_name = PATH_site . $TCA['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $file;
                                        $resList = $tmp_name . ',' . $resList;
                                    }
                                }
                                break;
                            case 'remove_resource':
                                if (is_array($val)) {
                                    $resList = ',' . $resList . ',';
                                    foreach ($val as $k => $file) {
                                        $resList = str_replace(',' . $file . ',', ',', $resList);
                                    }
                                }
                                break;
                            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) {
                        t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
                    }
                }
            }
            $theOutput .= $this->pObj->doc->spacer(5);
            $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('templateInformation'), t3lib_iconWorks::getSpriteIconForRecord('sys_template', $tplRow) . '<strong>' . htmlspecialchars($tplRow['title']) . '</strong>' . htmlspecialchars(trim($tplRow['sitetitle']) ? ' - (' . $tplRow['sitetitle'] . ')' : ''), 0, 1);
            if ($manyTemplatesMenu) {
                $theOutput .= $this->pObj->doc->section('', $manyTemplatesMenu);
                $theOutput .= $this->pObj->doc->divider(5);
            }
            #$numberOfRows= t3lib_div::intInRange($this->pObj->MOD_SETTINGS["ts_template_editor_TArows"],0,150);
            #if (!$numberOfRows)
            $numberOfRows = 35;
            // If abort pressed, nothing should be edited:
            if ($POST['abort'] || t3lib_div::testInt($POST['abort_x']) && t3lib_div::testInt($POST['abort_y']) || $POST['saveclose'] || t3lib_div::testInt($POST['saveclose_x']) && t3lib_div::testInt($POST['saveclose_y'])) {
                unset($e);
            }
            if ($e['title']) {
                $outCode = '<input type="Text" name="data[title]" value="' . htmlspecialchars($tplRow['title']) . '"' . $this->pObj->doc->formWidth() . '>';
                $outCode .= '<input type="Hidden" name="e[title]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('title'), $outCode);
            }
            if ($e['sitetitle']) {
                $outCode = '<input type="Text" name="data[sitetitle]" value="' . htmlspecialchars($tplRow['sitetitle']) . '"' . $this->pObj->doc->formWidth() . '>';
                $outCode .= '<input type="Hidden" name="e[sitetitle]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('sitetitle'), $outCode);
            }
            if ($e['description']) {
                $outCode = '<textarea name="data[description]" rows="5" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, '', '') . '>' . t3lib_div::formatForTextarea($tplRow['description']) . '</textarea>';
                $outCode .= '<input type="Hidden" name="e[description]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('description'), $outCode);
            }
            if ($e['resources']) {
                // Upload
                $outCode = '<input type="File" name="resources"' . $this->pObj->doc->formWidth() . ' size="50">';
                $outCode .= '<input type="Hidden" name="data[resources]" value="1">';
                $outCode .= '<input type="Hidden" name="e[resources]" value="1">';
                $outCode .= '<BR>' . $GLOBALS['LANG']->getLL('allowedExtensions') . ' <strong>' . $TCA['sys_template']['columns']['resources']['config']['allowed'] . '</strong>';
                $outCode .= '<BR>' . $GLOBALS['LANG']->getLL('maxFilesize') . ' <strong>' . t3lib_div::formatSize($TCA['sys_template']['columns']['resources']['config']['max_size'] * 1024) . '</strong>';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('uploadResource'), $outCode);
                // New
                $opt = explode(',', $this->pObj->textExtensions);
                $optTags = '';
                foreach ($opt as $extVal) {
                    $optTags .= '<option value="' . $extVal . '">.' . $extVal . '</option>';
                }
                $outCode = '<input type="text" name="new_resource"' . $this->pObj->doc->formWidth(20) . '>
					<select name="new_resource_ext">' . $optTags . '</select>';
                $outCode .= '<input type="Hidden" name="data[new_resource]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('newTextResource'), $outCode);
                // Make copy
                $rL = $this->resourceListForCopy($this->pObj->id, $template_uid);
                if ($rL) {
                    $theOutput .= $this->pObj->doc->spacer(20);
                    $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('copyResource'), $rL);
                }
                // Update resource list
                $rL = $this->procesResources($tplRow['resources'], 1);
                if ($rL) {
                    $theOutput .= $this->pObj->doc->spacer(20);
                    $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('updateResourceList'), $rL);
                }
            }
            if ($e['constants']) {
                $outCode = '<textarea name="data[constants]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off') . ' class="fixed-font">' . t3lib_div::formatForTextarea($tplRow['constants']) . '</textarea>';
                $outCode .= '<input type="Hidden" name="e[constants]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('constants'), '');
                $theOutput .= $this->pObj->doc->sectionEnd() . $outCode;
            }
            if ($e['file']) {
                $path = PATH_site . $TCA['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $e[file];
                $fI = t3lib_div::split_fileref($e[file]);
                if (@is_file($path) && t3lib_div::inList($this->pObj->textExtensions, $fI['fileext'])) {
                    if (filesize($path) < $TCA['sys_template']['columns']['resources']['config']['max_size'] * 1024) {
                        $fileContent = t3lib_div::getUrl($path);
                        $outCode = $GLOBALS['LANG']->getLL('file') . ' <strong>' . $e[file] . '</strong><BR>';
                        $outCode .= '<textarea name="edit[file]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off') . ' class="fixed-font">' . t3lib_div::formatForTextarea($fileContent) . '</textarea>';
                        $outCode .= '<input type="Hidden" name="edit[filename]" value="' . $e[file] . '">';
                        $outCode .= '<input type="Hidden" name="e[file]" value="' . htmlspecialchars($e[file]) . '">';
                        $theOutput .= $this->pObj->doc->spacer(15);
                        $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('editResource'), '');
                        $theOutput .= $this->pObj->doc->sectionEnd() . $outCode;
                    } else {
                        $theOutput .= $this->pObj->doc->spacer(15);
                        $fileToBig = sprintf($GLOBALS['LANG']->getLL('filesizeExceeded'), $TCA['sys_template']['columns']['resources']['config']['max_size']);
                        $filesizeNotAllowed = sprintf($GLOBALS['LANG']->getLL('notAllowed'), $TCA['sys_template']['columns']['resources']['config']['max_size']);
                        $theOutput .= $this->pObj->doc->section('<font color=red>' . $fileToBig . '</font>', $filesizeNotAllowed, 0, 0, 0, 1);
                    }
                }
            }
            if ($e['config']) {
                $outCode = '<textarea name="data[config]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, "width:98%;height:70%", "off") . ' class="fixed-font">' . t3lib_div::formatForTextarea($tplRow["config"]) . '</textarea>';
                if (t3lib_extMgm::isLoaded('tsconfig_help')) {
                    $url = $BACK_PATH . 'wizard_tsconfig.php?mode=tsref';
                    $params = array('formName' => 'editForm', 'itemName' => 'data[config]');
                    $outCode .= '<a href="#" onClick="vHWin=window.open(\'' . $url . t3lib_div::implodeArrayForUrl('', array('P' => $params)) . '\',\'popUp' . $md5ID . '\',\'height=500,width=780,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;">' . t3lib_iconWorks::getSpriteIcon('actions-system-typoscript-documentation-open', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:tsRef', true))) . '</a>';
                }
                $outCode .= '<input type="Hidden" name="e[config]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('setup'), '');
                $theOutput .= $this->pObj->doc->sectionEnd() . $outCode;
            }
            // Processing:
            $outCode = '';
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('title'), htmlspecialchars($tplRow['title']), 'title');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('sitetitle'), htmlspecialchars($tplRow['sitetitle']), 'sitetitle');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('description'), nl2br(htmlspecialchars($tplRow['description'])), 'description');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('resources'), $this->procesResources($tplRow['resources']), 'resources');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('constants'), sprintf($GLOBALS['LANG']->getLL('editToView'), trim($tplRow[constants]) ? count(explode(LF, $tplRow[constants])) : 0), 'constants');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('setup'), sprintf($GLOBALS['LANG']->getLL('editToView'), trim($tplRow[config]) ? count(explode(LF, $tplRow[config])) : 0), 'config');
            $outCode = '<br /><br /><table class="t3-table-info">' . $outCode . '</table>';
            // Edit all icon:
            $outCode .= '<br /><a href="#" onClick="' . t3lib_BEfunc::editOnClick(rawurlencode('&createExtension=0') . '&amp;edit[sys_template][' . $tplRow['uid'] . ']=edit', $BACK_PATH, '') . '"><strong>' . t3lib_iconWorks::getSpriteIcon('actions-document-open', array('title' => $GLOBALS['LANG']->getLL('editTemplateRecord'))) . $GLOBALS['LANG']->getLL('editTemplateRecord') . '</strong></a>';
            $theOutput .= $this->pObj->doc->section('', $outCode);
            // hook	after compiling the output
            if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'])) {
                $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'];
                if (is_array($postOutputProcessingHook)) {
                    $hookParameters = array('theOutput' => &$theOutput, 'POST' => $POST, 'e' => $e, 'tplRow' => $tplRow, 'numberOfRows' => $numberOfRows);
                    foreach ($postOutputProcessingHook as $hookFunction) {
                        t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
                    }
                }
            }
        } else {
            $theOutput .= $this->pObj->noTemplate(1);
        }
        return $theOutput;
    }
 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
0
 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;
 }
 /**
  * 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();
 }
    /**
     * 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;
    }
 /**
  * Do some cleanup at the end (deleting attachment files)
  */
 public function __destruct()
 {
     foreach ($this->temporaryFiles as $file) {
         t3lib_div::unlink_tempfile($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;
 }
    /**
     * 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>
					<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;
    }
 /**
  * The function to display the detailview of one job
  *
  * @param bool $applyOnly Show only the apply form?
  * @return string The content that is displayed on the website
  */
 function displayDetail($applyOnly = false)
 {
     if (isset($this->piVars['ref']) && $this->piVars['ref']) {
         // Find the job_uid by searching the reference number
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'tx_dmmjobcontrol_job', 'reference=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->piVars['ref'], 'tx_dmmjobcontrol_job') . ' AND ' . $this->whereAdd);
         if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             $this->piVars['job_uid'] = $row['uid'];
         }
     }
     if (isset($this->piVars['job_uid']) && $this->piVars['job_uid']) {
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tx_dmmjobcontrol_job', 'uid=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->piVars['job_uid'], 'tx_dmmjobcontrol_job') . ' AND ' . $this->whereAdd);
         if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             // This sets the jobtitle as the page title (also for use in indexed search results)
             if (isset($this->conf['substitutePageTitle']) && $this->conf['substitutePageTitle']) {
                 $GLOBALS['TSFE']->indexedDocTitle = $row['job_title'];
                 $GLOBALS['TSFE']->page['title'] = $row['job_title'];
                 $this->cObj->LOAD_REGISTER(array('JOBTITLE' => $row['job_title']), '');
                 $this->cObj->LOAD_REGISTER(array('JOBLOCATION' => $row['location']), '');
             }
             // Which fields are required?
             if (isset($this->conf['apply.']['required']) && $this->conf['apply.']['required']) {
                 $this->requiredFields = t3lib_div::trimExplode(',', $this->conf['apply.']['required']);
             }
             // Get all the labels and job data
             $labels = $this->getLabels();
             $jobData = $this->getJobData($row);
             if (isset($this->conf['hide_empty']) && $this->conf['hide_empty']) {
                 $markerArray = $this->hideEmpty($labels, $jobData, $row);
             } else {
                 $markerArray = $labels + $jobData;
             }
             // Process the apply form: send out email
             if (isset($this->piVars['apply_submit']) && ($applyOnly || $this->conf['apply.']['form'] != 0)) {
                 // Get the apply templates
                 $this->templateCode = $this->cObj->fileResource($this->conf['template.']['apply']);
                 if (is_null($this->templateCode)) {
                     return $this->pi_getLL('template_not_found');
                 }
                 // Spamblock?
                 if (isset($this->conf['apply.']['spamblock']) && $this->conf['apply.']['spamblock']) {
                     $session = $GLOBALS['TSFE']->fe_user->getKey('ses', $this->prefixId);
                     if (!is_array($session['spamblock']) || !$this->piVars['sessioncheck'] || !in_array($this->piVars['sessioncheck'], $session['spamblock'])) {
                         $template['thanks'] = $this->cObj->getSubpart($this->templateCode, '###APPLY_THANKS_TEMPLATE###');
                         return $this->cObj->substituteMarkerArrayCached($template['thanks'], $markerArray);
                     }
                 }
                 // TODO: server-side check for $this->requiredFields
                 // Extend the markerArray with the posted values
                 $markerArray['###FULLNAME_VALUE###'] = $this->piVars['apply']['fullname'];
                 $markerArray['###EMAIL_VALUE###'] = $this->piVars['apply']['email'];
                 $markerArray['###MOTIVATION_VALUE###'] = $this->piVars['apply']['motivation'];
                 if (isset($this->conf['htmlmail']) && $this->conf['htmlmail']) {
                     $markerArray['###MOTIVATION_VALUE###'] = nl2br($this->piVars['apply']['motivation']);
                 }
                 // Extend the markerArray with user function?
                 if (isset($this->conf['applyArrayFunction']) && $this->conf['applyArrayFunction']) {
                     $funcConf = $this->conf['applyArrayFunction.'];
                     $funcConf['parent'] =& $this;
                     $markerArray = $this->cObj->callUserFunction($this->conf['applyArrayFunction'], $funcConf, $markerArray);
                 }
                 $subject = $this->pi_getLL('apply_email_subject') . $row['job_title'];
                 // HTML email body
                 $template['htmlEmail'] = $this->cObj->getSubpart($this->templateCode, '###HTML_EMAIL_TEMPLATE###');
                 $htmlBody = $this->cObj->substituteMarkerArrayCached($template['htmlEmail'], $markerArray);
                 // Plain text email boby
                 $template['textEmail'] = $this->cObj->getSubpart($this->templateCode, '###TEXT_EMAIL_TEMPLATE###');
                 $textBody = $this->cObj->substituteMarkerArrayCached($template['textEmail'], $markerArray);
                 // The uploaded files
                 $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
0
 /**
  * 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;
 }
 /**
  * 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);
                     return $GLOBALS['LANG']->getLL('ext_import_file_not_uploaded');
                 }
                 $uploadedTempFile = t3lib_div::upload_to_tempfile($_FILES['upload_ext_file']['tmp_name']);
             }
             $fileContent = t3lib_div::getUrl($uploadedTempFile);
             if (!$fileContent) {
                 return $GLOBALS['LANG']->getLL('ext_import_file_empty');
             }
             // 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 = PATH_site . $this->typePaths[$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 {
                     return $GLOBALS['LANG']->getLL('ext_import_no_key');
                 }
             } else {
                 return sprintf($GLOBALS['LANG']->getLL('ext_import_wrong_file_format'), $fetchData);
             }
         } else {
             return $GLOBALS['LANG']->getLL('ext_import_no_file');
         }
     } 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:
     if ($this->importAsType($loc)) {
         if (is_array($fetchData)) {
             // There was some data successfully transferred
             if ($fetchData[0]['extKey'] && is_array($fetchData[0]['FILES'])) {
                 $extKey = $fetchData[0]['extKey'];
                 if (!isset($fetchData[0]['EM_CONF']['constraints'])) {
                     $fetchData[0]['EM_CONF']['constraints'] = $this->xmlhandler->extensionsXML[$extKey]['versions'][$version]['dependencies'];
                 }
                 $EM_CONF = $this->fixEMCONF($fetchData[0]['EM_CONF']);
                 if (!$EM_CONF['lockType'] || !strcmp($EM_CONF['lockType'], $loc)) {
                     // check dependencies, act accordingly if ext is loaded
                     list($instExtInfo, ) = $this->getInstalledExtensions();
                     $depStatus = $this->checkDependencies($extKey, $EM_CONF, $instExtInfo);
                     if (t3lib_extMgm::isLoaded($extKey) && !$depStatus['returnCode']) {
                         $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;
 }
 /**
  * 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');
     }
 }
 /**
  * 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();
 }