function createTempIcsFile($content, $filename) { $fileFunc = new \TYPO3\CMS\Core\Utility\File\BasicFileUtility(); $all_files = array(); $all_files['webspace']['allow'] = '*'; $all_files['webspace']['deny'] = ''; $fileFunc->init('', $all_files); $theDestFile = GeneralUtility::getFileAbsFileName('uploads/tx_cal/' . $filename); // $theDestFile = $fileFunc->getUniqueName($filename, 'uploads/tx_cal'); $fh = fopen($theDestFile, 'w'); fwrite($fh, $content); fclose($fh); return $theDestFile; }
protected function getFileMarker($marker, &$template, &$sims, &$rems) { if (!$this->isAllowed($marker)) { return; } $max = $GLOBALS['TCA']['tx_cal_' . $this->objectString]['columns'][$marker]['config']['maxitems']; $sims['###' . strtoupper($marker) . '###'] = ''; $sims['###' . strtoupper($marker) . '_VALUE###'] = ''; $sims['###' . strtoupper($marker) . '_CAPTION###'] = ''; $sims['###' . strtoupper($marker) . '_CAPTION_VALUE###'] = ''; if ($this->isConfirm) { $sims['###' . strtoupper($marker) . '###'] = ''; $fileFunc = new \TYPO3\CMS\Core\Utility\File\BasicFileUtility(); $all_files = array(); $all_files['webspace']['allow'] = '*'; $all_files['webspace']['deny'] = ''; $fileFunc->init('', $all_files); $allowedExt = array(); $denyExt = array(); if ($marker == 'image') { $allowedExt = explode(',', $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']); } else { if ($marker == 'attachment') { $allowedExt = explode(',', $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['allow']); $denyExt = explode(',', $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['deny']); } } $i = 0; // new files if (is_array($_FILES[$this->prefixId]['name'])) { foreach ($_FILES[$this->prefixId]['name'][$marker] as $id => $filename) { $theDestFile = ''; $iConf = $this->conf['view.'][$this->conf['view'] . '.'][strtolower($marker) . '_stdWrap.']; if ($_FILES[$this->prefixId]['error'][$marker][$id]) { continue; } else { $theFile = GeneralUtility::upload_to_tempfile($_FILES[$this->prefixId]['tmp_name'][$marker][$id]); $fI = GeneralUtility::split_fileref($filename); if (in_array($fI['fileext'], $denyExt)) { continue; } else { if ($marker == 'image' && !in_array($fI['fileext'], $allowedExt)) { continue; } } $theDestFile = $fileFunc->getUniqueName($fileFunc->cleanFileName($fI['file']), 'typo3temp'); GeneralUtility::upload_copy_move($theFile, $theDestFile); $iConf['file'] = $theDestFile; $return = '__NEW__' . basename($theDestFile); } $temp_sims = array(); $temp_sims['###INDEX###'] = $id; $temp_sims['###' . strtoupper($marker) . '_VALUE###'] = $return; $temp = ''; if ($marker == 'image') { $temp = $this->renderImage($iConf['file'], $this->controller->piVars[$marker . '_caption'][$id], $this->controller->piVars[$marker . '_title'][$id], $marker, true); } else { if ($marker == 'attachment' || $marker == 'ics_file') { $temp = $this->renderFile($iConf['file'], $this->controller->piVars[$marker . '_caption'][$id], $this->controller->piVars[$marker . '_title'][$id], $marker, true); } } if ($this->isAllowed($marker . '_caption')) { $temp .= $this->applyStdWrap($this->controller->piVars[$marker . '_caption'][$id], $marker . '_caption_stdWrap'); } if ($this->isAllowed($marker . '_title')) { $temp .= $this->applyStdWrap($this->controller->piVars[$marker . '_title'][$id], $marker . '_title_stdWrap'); } $sims['###' . strtoupper($marker) . '###'] .= \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($temp, $temp_sims, array(), array()); $i++; } } $removeFiles = $this->controller->piVars['remove_' . $marker] ? $this->controller->piVars['remove_' . $marker] : array(); $where = 'uid_foreign = ' . $this->conf['uid'] . ' AND tablenames=\'tx_cal_' . $this->objectString . '\' AND fieldname=\'' . $marker . '\' AND deleted=0'; if (!empty($removeFiles)) { $where .= ' AND uid not in (' . implode(',', array_values($removeFiles)) . ')'; } $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_file_reference', $where); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { if ($marker == 'image') { $temp = $this->renderImage($row, $row['description'], $row['title'], $marker, false); } else { if ($marker == 'attachment' || $marker == 'ics_file') { $temp = $this->renderFile($row, $row['description'], $row['title'], $marker, false); } } $temp_sims = array(); $temp_sims['###' . strtoupper($marker) . '_VALUE###'] = $row['uid']; foreach ($this->controller->piVars[$marker] as $index => $image) { if ($image == $row['uid']) { if (isset($this->controller->piVars[$marker . '_caption'][$index])) { $row['description'] = $this->controller->piVars[$marker . '_caption'][$index]; } if (isset($this->controller->piVars[$marker . '_title'][$index])) { $row['title'] = $this->controller->piVars[$marker . '_title'][$index]; } $temp_sims['###INDEX###'] = $index; break; } } if ($this->isAllowed($marker . '_caption')) { $temp .= $this->applyStdWrap($row['description'], $marker . '_caption_stdWrap'); } if ($this->isAllowed($marker . '_title')) { $temp .= $this->applyStdWrap($row['title'], $marker . '_title_stdWrap'); } $sims['###' . strtoupper($marker) . '###'] .= \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($temp, $temp_sims, array(), array()); } $GLOBALS['TYPO3_DB']->sql_free_result($result); foreach ($removeFiles as $removeFile) { $sims['###' . strtoupper($marker) . '###'] .= '<input type="hidden" name="tx_cal_controller[remove_' . $marker . '][]" value="' . $removeFile . '">'; } } else { if ($this->isEditMode && $this->rightsObj->isAllowedTo('edit', $this->objectString, $marker)) { $sims['###' . strtoupper($marker) . '###'] = ''; $i = 0; $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_file_reference', 'uid_foreign = ' . $this->conf['uid'] . ' AND tablenames=\'tx_cal_' . $this->objectString . '\' AND fieldname=\'' . $marker . '\' AND deleted=0'); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { $temp_sims = array(); $temp_sims['###' . strtoupper($marker) . '_VALUE###'] = $row['uid']; $temp = $this->cObj->stdWrap('', $this->conf['view.'][$this->conf['view'] . '.'][strtolower($marker) . '_stdWrap.']); if ($marker == 'image') { $temp_sims['###' . strtoupper($marker) . '_PREVIEW###'] = $this->renderImage($row, $row['description'], $row['title'], $marker, false); } else { if ($marker == 'attachment' || $marker == 'ics_file') { $temp_sims['###' . strtoupper($marker) . '_PREVIEW###'] = $this->renderFile($row, $row['description'], $row['title'], $marker, false); } } $temp = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($temp, $temp_sims, array(), array()); if ($this->isAllowed($marker . '_caption')) { $temp .= $this->applyStdWrap($row['description'], $marker . '_caption_stdWrap'); } if ($this->isAllowed($marker . '_title')) { $temp .= $this->applyStdWrap($row['title'], $marker . '_title_stdWrap'); } $temp_sims['###INDEX###'] = $i; $sims['###' . strtoupper($marker) . '###'] .= \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($temp, $temp_sims, array(), array()); $i++; } $GLOBALS['TYPO3_DB']->sql_free_result($result); $upload = ''; for (; $i < $max; $i++) { $temp_sims = array(); $upload .= $this->cObj->stdWrap('', $this->conf['view.'][$this->conf['view'] . '.'][$marker . 'Upload_stdWrap.']); if ($this->isAllowed($marker . '_caption')) { $upload .= $this->applyStdWrap('', $marker . '_caption_stdWrap'); } if ($this->isAllowed($marker . '_title')) { $upload .= $this->applyStdWrap('', $marker . '_title_stdWrap'); } $temp_sims['###INDEX###'] = $i; $upload = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($upload, $temp_sims, array(), array()); } $sims['###' . strtoupper($marker) . '###'] .= $upload; } else { if (!$this->isEditMode && $this->rightsObj->isAllowedTo('create', $this->objectString, $marker)) { for ($i = 0; $i < $max; $i++) { $value = ''; $upload = $this->cObj->stdWrap($value, $this->conf['view.'][$this->conf['view'] . '.'][$marker . 'Upload_stdWrap.']); $value = ''; if ($this->isAllowed($marker . '_caption')) { $upload .= $this->applyStdWrap('', $marker . '_caption_stdWrap'); } if ($this->isAllowed($marker . '_title')) { $upload .= $this->applyStdWrap('', $marker . '_title_stdWrap'); } $temp_sims['###INDEX###'] = $i; $sims['###' . strtoupper($marker) . '###'] .= \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($upload, $temp_sims, array(), array()); } } } } }