本文整理汇总了PHP中t3lib_div::writeFile方法的典型用法代码示例。如果您正苦于以下问题:PHP t3lib_div::writeFile方法的具体用法?PHP t3lib_div::writeFile怎么用?PHP t3lib_div::writeFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类t3lib_div
的用法示例。
在下文中一共展示了t3lib_div::writeFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeCsv
/**
* Schreibt die ganzen CSV Zeilen in eine Datei
*
* @param string $sDir
* @param string $sPrefix
* @param array $aData
* @param string $sFileName | gibt es einen festen dateinamen?
*
* @return string | Name der Datei
*/
public function writeCsv($sDir, $sPrefix = '', $aData = array(), $sFileName = '')
{
if (empty($aData)) {
$aData = $this->getCsvLines();
}
if (!$sFileName) {
if ($sPrefix) {
$sPrefix = $sPrefix . '_';
}
$sFileName = $sPrefix . date('dmy-Hi') . '.csv';
}
$sCsvLines = implode(chr(13) . chr(10), $aData);
if (t3lib_div::writeFile($sDir . $sFileName, $sCsvLines)) {
return $sFileName;
} else {
return false;
}
}
示例2: createSpritesForT3Skin
/**
* Generates the sprites for t3skin.
*
* @return string HTML content
*/
public function createSpritesForT3Skin()
{
/** @var $generator t3lib_SpriteManager_SpriteGenerator */
$generator = t3lib_div::makeInstance('t3lib_SpriteManager_SpriteGenerator', 't3skin');
$this->unlinkT3SkinFiles();
$data = $generator->setSpriteFolder(TYPO3_mainDir . 'sysext/t3skin/images/sprites/')->setCSSFolder(TYPO3_mainDir . 'sysext/t3skin/stylesheets/sprites/')->setOmmitSpriteNameInIconName(TRUE)->setIncludeTimestampInCSS(TRUE)->generateSpriteFromFolder(array(TYPO3_mainDir . 'sysext/t3skin/images/icons/'));
$version = Tx_Extdeveval_Compatibility::convertVersionNumberToInteger(TYPO3_version);
// IE6 fallback sprites have been removed with TYPO3 4.6
if ($version < 4006000) {
$gifSpritesPath = PATH_typo3 . 'sysext/t3skin/stylesheets/ie6/z_t3-icons-gifSprites.css';
if (FALSE === rename($data['cssGif'], $gifSpritesPath)) {
throw new tx_extdeveval_exception('The file "' . $data['cssGif'] . '" could not be renamed to "' . $gifSpritesPath . '"');
}
}
$stddbPath = PATH_site . 't3lib/stddb/tables.php';
$stddbContents = file_get_contents($stddbPath);
$newContent = '$GLOBALS[\'TBE_STYLES\'][\'spriteIconApi\'][\'coreSpriteImageNames\'] = array(' . LF . TAB . '\'' . implode('\',' . LF . TAB . '\'', $data['iconNames']) . '\'' . LF . ');' . LF;
$stddbContents = preg_replace('/\\$GLOBALS\\[\'TBE_STYLES\'\\]\\[\'spriteIconApi\'\\]\\[\'coreSpriteImageNames\'\\] = array\\([\\s\',\\w-]*\\);/', $newContent, $stddbContents);
if (FALSE === t3lib_div::writeFile($stddbPath, $stddbContents)) {
throw new tx_extdeveval_exception('Could not write file "' . $stddbPath . '"');
}
$output = 'Sprites successfully regenerated';
return $output;
}
示例3: main
//.........这里部分代码省略.........
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;
示例4: saveJqConf
/**
* Save the config to file
*
* @param array $formVars
* @return void
*/
function saveJqConf($formVars)
{
if ($this->createFolder()) {
t3lib_div::writeFile($this->configDir.'t3jquery.cfg', serialize($formVars));
}
}
示例5: updateTranslation
/**
* Install translations for all selected languages for an extension
*
* @param string $extKey The extension key to install the translations for
* @param string $lang Language code of translation to fetch
* @param string $mirrorURL Mirror URL to fetch data from
* @return mixed true on success, error string on fauilure
*/
function updateTranslation($extKey, $lang, $mirrorURL)
{
$l10n = $this->fetchTranslation($extKey, $lang, $mirrorURL);
if (is_array($l10n)) {
$file = PATH_site . 'typo3temp/' . $extKey . '-l10n-' . $lang . '.zip';
$path = 'l10n/' . $lang . '/';
if (!is_dir(PATH_typo3conf . $path)) {
t3lib_div::mkdir_deep(PATH_typo3conf, $path);
}
t3lib_div::writeFile($file, $l10n[0]);
if (tx_em_Tools::unzip($file, PATH_typo3conf . $path)) {
return TRUE;
}
}
return FALSE;
}
示例6: createDummyFile
/**
* Creates an empty dummy file with a unique file name in the calling
* extension's upload directory.
*
* @param string $fileName
* path of the dummy file to create, relative to the calling
* extension's upload directory, must not be empty
* @param string $content
* string content for the file to create, may be empty
*
* @return string
* the absolute path of the created dummy file, will not be empty
*
* @throws t3lib_exception
*/
public function createDummyFile($fileName = 'test.txt', $content = '')
{
$this->createDummyUploadFolder();
$uniqueFileName = $this->getUniqueFileOrFolderPath($fileName);
if (!t3lib_div::writeFile($uniqueFileName, $content)) {
throw new t3lib_exception('The file ' . $uniqueFileName . ' could not be created.', 1334439291);
}
$this->addToDummyFileList($uniqueFileName);
return $uniqueFileName;
}
示例7: rebuildCache
/**
* this method calls the main methods from the handler classes
* merges the results with the data from the skin, and cache it
*
* @return void
*/
protected function rebuildCache()
{
// ask the handlerClass to kindly rebuild our data
$this->handler->generate();
// get all Icons registered from skins, merge with core-Icon-List
$availableSkinIcons = (array) $GLOBALS['TBE_STYLES']['spriteIconApi']['coreSpriteImageNames'];
foreach ($GLOBALS['TBE_STYLES']['skins'] as $skinName => $skinData) {
$availableSkinIcons = array_merge($availableSkinIcons, (array) $skinData['availableSpriteIcons']);
}
// merge icon names whith them provided by the skin,
// registered from "complete sprites" and the ones detected
// by the handlerclass
$this->iconNames = array_merge($availableSkinIcons, (array) $GLOBALS['TBE_STYLES']['spritemanager']['spriteIconsAvailable'], $this->handler->getAvailableIconNames());
// serialize found icons, and cache them to file
$cacheString = addslashes(serialize($this->iconNames));
$fileContent = '<?php $GLOBALS[\'TBE_STYLES\'][\'spriteIconApi\'][\'iconsAvailable\'] = unserialize(stripslashes(\'' . $cacheString . '\')); ?>';
// delete old cache files
$oldFiles = t3lib_div::getFilesInDir(PATH_site . self::$tempPath, 'inc', 1);
foreach ($oldFiles as $file) {
@unlink($file);
}
// and write the new one
t3lib_div::writeFile($this->tempFileName, $fileContent);
}
示例8: TS_images_db
/**
* Transformation handler: 'ts_images' / direction: "db"
* Processing images inserted in the RTE.
* This is used when content goes from the RTE to the database.
* Images inserted in the RTE has an absolute URL applied to the src attribute. This URL is converted to a relative URL
* If it turns out that the URL is from another website than the current the image is read from that external URL and moved to the local server.
* Also "magic" images are processed here.
*
* @param string The content from RTE going to Database
* @return string Processed content
*/
function TS_images_db($value)
{
// Split content by <img> tags and traverse the resulting array for processing:
$imgSplit = $this->splitTags('img', $value);
foreach ($imgSplit as $k => $v) {
if ($k % 2) {
// image found, do processing:
// Init
$attribArray = $this->get_tag_attributes_classic($v, 1);
$siteUrl = $this->siteUrl();
$sitePath = str_replace(t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST'), '', $siteUrl);
$absRef = trim($attribArray['src']);
// It's always a absolute URL coming from the RTE into the Database.
// make path absolute if it is relative and we have a site path wich is not '/'
$pI = pathinfo($absRef);
if ($sitePath and !$pI['scheme'] && t3lib_div::isFirstPartOfStr($absRef, $sitePath)) {
// if site is in a subpath (eg. /~user_jim/) this path needs to be removed because it will be added with $siteUrl
$absRef = substr($absRef, strlen($sitePath));
$absRef = $siteUrl . $absRef;
}
// External image from another URL? In that case, fetch image (unless disabled feature).
if (!t3lib_div::isFirstPartOfStr($absRef, $siteUrl) && !$this->procOptions['dontFetchExtPictures']) {
$externalFile = $this->getUrl($absRef);
// Get it
if ($externalFile) {
$pU = parse_url($absRef);
$pI = pathinfo($pU['path']);
if (t3lib_div::inList('gif,png,jpeg,jpg', strtolower($pI['extension']))) {
$filename = t3lib_div::shortMD5($absRef) . '.' . $pI['extension'];
$origFilePath = PATH_site . $this->rteImageStorageDir() . 'RTEmagicP_' . $filename;
$C_origFilePath = PATH_site . $this->rteImageStorageDir() . 'RTEmagicC_' . $filename . '.' . $pI['extension'];
if (!@is_file($origFilePath)) {
t3lib_div::writeFile($origFilePath, $externalFile);
t3lib_div::writeFile($C_origFilePath, $externalFile);
}
$absRef = $siteUrl . $this->rteImageStorageDir() . 'RTEmagicC_' . $filename . '.' . $pI['extension'];
$attribArray['src'] = $absRef;
$params = t3lib_div::implodeAttributes($attribArray, 1);
$imgSplit[$k] = '<img ' . $params . ' />';
}
}
}
// Check image as local file (siteURL equals the one of the image)
if (strpos($absRef, 'http://') === FALSE and strpos($absRef, 'https://') === FALSE and strpos($absRef, 'ftp://') === FALSE) {
//XCLASS changed from: if (t3lib_div::isFirstPartOfStr($absRef,$siteUrl)) {
$path = rawurldecode(substr($absRef, strlen($siteUrl)));
// Rel-path, rawurldecoded for special characters.
$path = $absRef;
//XCLASS added
$filepath = t3lib_div::getFileAbsFileName($path);
// Abs filepath, locked to relative path of this project.
// Check file existence (in relative dir to this installation!)
if ($filepath && @is_file($filepath)) {
// If "magic image":
$pathPre = $this->rteImageStorageDir() . 'RTEmagicC_';
if (t3lib_div::isFirstPartOfStr($path, $pathPre)) {
// Find original file:
$pI = pathinfo(substr($path, strlen($pathPre)));
$filename = substr($pI['basename'], 0, -strlen('.' . $pI['extension']));
$origFilePath = PATH_site . $this->rteImageStorageDir() . 'RTEmagicP_' . $filename;
if (@is_file($origFilePath)) {
$imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
$imgObj->init();
$imgObj->mayScaleUp = 0;
$imgObj->tempPath = PATH_site . $imgObj->tempPath;
$curInfo = $imgObj->getImageDimensions($filepath);
// Image dimensions of the current image
$curWH = $this->getWHFromAttribs($attribArray);
// Image dimensions as set in the image tag
// Compare dimensions:
if ($curWH[0] != $curInfo[0] || $curWH[1] != $curInfo[1]) {
$origImgInfo = $imgObj->getImageDimensions($origFilePath);
// Image dimensions of the current image
$cW = $curWH[0];
$cH = $curWH[1];
$cH = 1000;
// Make the image based on the width solely...
$imgI = $imgObj->imageMagickConvert($origFilePath, $pI['extension'], $cW . 'm', $cH . 'm');
if ($imgI[3]) {
$fI = pathinfo($imgI[3]);
@copy($imgI[3], $filepath);
// Override the child file
// Removing width and heigth form style attribute
$attribArray['style'] = preg_replace('/((?:^|)\\s*(?:width|height)\\s*:[^;]*(?:$|;))/si', '', $attribArray['style']);
$attribArray['width'] = $imgI[0];
$attribArray['height'] = $imgI[1];
$params = t3lib_div::implodeAttributes($attribArray, 1);
$imgSplit[$k] = '<img ' . $params . ' />';
}
//.........这里部分代码省略.........
示例9: addMethodFromTemplateToNewClass
/**
* @test
*/
function addMethodFromTemplateToNewClass()
{
$templateClassFileObject = $this->parser->parseFile(t3lib_extmgm::extPath('php_parser_api') . 'Resources/Private/Templates/MethodTemplates.php');
$getPropertyMethod = $templateClassFileObject->getFirstClass()->getMethod('getPropertyName');
$newClassFileObject = new Tx_PhpParser_Domain_Model_File();
$newClassName = 'Tx_PhpParser_Test_NewClassWithTemplateMethod';
$newClass = new Tx_PhpParser_Domain_Model_Class($newClassName);
$newClass->addMethod($getPropertyMethod);
$newClassFileObject->addClass($newClass);
$newClassFilePath = $this->testDir . 'NewClassWithTemplateMethod.php';
t3lib_div::writeFile($newClassFilePath, "<?php\n\n" . $this->printer->renderFileObject($newClassFileObject) . "\n?>");
$this->assertTrue(file_exists($newClassFilePath));
require_once $newClassFilePath;
$this->assertTrue(class_exists($newClassName));
$this->compareClasses($newClassFileObject, $newClassFilePath);
}
示例10: renderFile
//.........这里部分代码省略.........
}
else {
// FCE defaults to inheritance
if (!isset($dataStruct['meta']['langDisable'])) {
$dataStruct['meta']['langDisable'] = '0';
$dataStruct['meta']['langChildren'] = '1';
}
}
}
}
// CMD switch:
switch($cmd) {
// If it is requested to save the current DS and mapping information to a DS and TO record, then...:
case 'saveDSandTO':
$newID = '';
// Init TCEmain object and store:
$tce = t3lib_div::makeInstance("t3lib_TCEmain");
$tce->stripslashes_values=0;
// DS:
// Modifying data structure with conversion of preset values for field types to actual settings:
$storeDataStruct = $dataStruct;
if (is_array($storeDataStruct['ROOT']['el'])) {
$this->eTypes->substEtypeWithRealStuff($storeDataStruct['ROOT']['el'],$contentSplittedByMapping['sub']['ROOT'],$dataArr['tx_templavoila_datastructure']['NEW']['scope']);
}
$dataProtXML = t3lib_div::array2xml_cs($storeDataStruct,'T3DataStructure', array('useCDATA' => 1));
if ($this->staticDS) {
$title = preg_replace('|[/,\."\']+|', '_', $this->_saveDSandTO_title) . ' (' . ($this->_saveDSandTO_type == 1 ? 'page' : 'fce') . ').xml';
$path = t3lib_div::getFileAbsFileName($this->_saveDSandTO_type == 2 ? $this->extConf['staticDS.']['path_fce'] : $this->extConf['staticDS.']['path_page']) . $title;
t3lib_div::writeFile($path, $dataProtXML);
$newID = substr($path, strlen(PATH_site));
} else {
$dataArr=array();
$dataArr['tx_templavoila_datastructure']['NEW']['pid'] = intval($this->_saveDSandTO_pid);
$dataArr['tx_templavoila_datastructure']['NEW']['title'] = $this->_saveDSandTO_title;
$dataArr['tx_templavoila_datastructure']['NEW']['scope'] = $this->_saveDSandTO_type;
$dataArr['tx_templavoila_datastructure']['NEW']['dataprot'] = $dataProtXML;
// start data processing
$tce->start($dataArr,array());
$tce->process_datamap();
$newID = intval($tce->substNEWwithIDs['NEW']);
}
// If that succeeded, create the TO as well:
if ($newID) {
$dataArr=array();
$dataArr['tx_templavoila_tmplobj']['NEW']['pid'] = intval($this->_saveDSandTO_pid);
$dataArr['tx_templavoila_tmplobj']['NEW']['title'] = $this->_saveDSandTO_title . ' [Template]';
$dataArr['tx_templavoila_tmplobj']['NEW']['datastructure'] = $newID;
$dataArr['tx_templavoila_tmplobj']['NEW']['fileref'] = substr($this->displayFile, strlen(PATH_site));
$dataArr['tx_templavoila_tmplobj']['NEW']['templatemapping'] = serialize($templatemapping);
$dataArr['tx_templavoila_tmplobj']['NEW']['fileref_mtime'] = @filemtime($this->displayFile);
$dataArr['tx_templavoila_tmplobj']['NEW']['fileref_md5'] = @md5_file($this->displayFile);
// Init TCEmain object and store:
$tce->start($dataArr,array());
$tce->process_datamap();
$newToID = intval($tce->substNEWwithIDs['NEW']);
if ($newToID) {
$msg[] = t3lib_iconWorks::getSpriteIcon('status-dialog-ok') .
sprintf($GLOBALS['LANG']->getLL('msgDSTOSaved'),
示例11: writeFileToTypo3tempDir
/**
* Writes $content to a filename in the typo3temp/ folder (and possibly a subfolder...)
* Accepts an additional subdirectory in the file path!
*
* @param string Absolute filepath to write to inside "typo3temp/". First part of this string must match PATH_site."typo3temp/"
* @param string Content string to write
* @return string Returns false on success, otherwise an error string telling about the problem.
*/
function writeFileToTypo3tempDir($filepath, $content)
{
// Parse filepath into directory and basename:
$fI = pathinfo($filepath);
$fI['dirname'] .= '/';
// Check parts:
if (t3lib_div::validPathStr($filepath) && $fI['basename'] && strlen($fI['basename']) < 60) {
if (defined('PATH_site')) {
$dirName = PATH_site . 'typo3temp/';
// Setting main temporary directory name (standard)
if (@is_dir($dirName)) {
if (t3lib_div::isFirstPartOfStr($fI['dirname'], $dirName)) {
// Checking if the "subdir" is found:
$subdir = substr($fI['dirname'], strlen($dirName));
if ($subdir) {
if (ereg('^[[:alnum:]_]+\\/$', $subdir)) {
$dirName .= $subdir;
if (!@is_dir($dirName)) {
t3lib_div::mkdir($dirName);
}
} else {
return 'Subdir, "' . $subdir . '", was NOT on the form "[a-z]/"';
}
}
// Checking dir-name again (sub-dir might have been created):
if (@is_dir($dirName)) {
if ($filepath == $dirName . $fI['basename']) {
t3lib_div::writeFile($filepath, $content);
if (!@is_file($filepath)) {
return 'File not written to disk! Write permission error in filesystem?';
}
} else {
return 'Calculated filelocation didn\'t match input $filepath!';
}
} else {
return '"' . $dirName . '" is not a directory!';
}
} else {
return '"' . $fI['dirname'] . '" was not within directory PATH_site + "typo3temp/"';
}
} else {
return 'PATH_site + "typo3temp/" was not a directory!';
}
} else {
return 'PATH_site constant was NOT defined!';
}
} else {
return 'Input filepath "' . $filepath . '" was generally invalid!';
}
}
示例12: renderTemplateSelector
/**
* Renders the template selector.
*
* @param integer Position id. Can be positive and negative depending of where the new page is going: Negative always points to a position AFTER the page having the abs. value of the positionId. Positive numbers means to create as the first subpage to another page.
* @param string $templateType: The template type, 'tmplobj' or 't3d'
* @return string HTML output containing a table with the template selector
*/
function renderTemplateSelector($positionPid, $templateType = 'tmplobj')
{
global $LANG, $TYPO3_DB;
$storageFolderPID = $this->apiObj->getStorageFolderPid($positionPid);
$tmplHTML = array();
$defaultIcon = $this->doc->backPath . '../' . t3lib_extMgm::siteRelPath($this->extKey) . 'res1/default_previewicon.gif';
// look for TCEFORM.pages.tx_templavoila_ds.removeItems / TCEFORM.pages.tx_templavoila_to.removeItems
$disallowedPageTemplateItems = $this->getDisallowedTSconfigItemsByFieldName($positionPid, 'tx_templavoila_ds');
$disallowedDesignTemplateItems = $this->getDisallowedTSconfigItemsByFieldName($positionPid, 'tx_templavoila_to');
switch ($templateType) {
case 'tmplobj':
// Create the "Default template" entry
//Fetch Default TO
$fakeRow = array('uid' => abs($positionPid));
$defaultTO = $this->pObj->apiObj->getContentTree_fetchPageTemplateObject($fakeRow);
// Create the "Default template" entry
if ($defaultTO['previewicon']) {
$previewIconFilename = @is_file(PATH_site . 'uploads/tx_templavoila/' . $defaultTO['previewicon']) ? $GLOBALS['BACK_PATH'] . '../' . 'uploads/tx_templavoila/' . $defaultTO['previewicon'] : $defaultIcon;
} else {
$previewIconFilename = $defaultIcon;
}
$previewIcon = '<input type="image" class="c-inputButton" name="i0" value="0" src="' . $previewIconFilename . '" title="" />';
$description = $defaultTO['description'] ? htmlspecialchars($defaultTO['description']) : $LANG->getLL('template_descriptiondefault', 1);
$tmplHTML[] = '<table style="float:left; width: 100%;" valign="top">
<tr>
<td colspan="2" nowrap="nowrap">
<h3 class="bgColor3-20">' . htmlspecialchars($LANG->getLL('template_titleInherit')) . '</h3>
</td>
</tr><tr>
<td valign="top">' . $previewIcon . '</td>
<td width="120" valign="top">
<p><h4>' . htmlspecialchars($LANG->sL($defaultTO['title'])) . '</h4>' . $LANG->sL($description) . '</p>
</td>
</tr>
</table>';
$dsRepo = t3lib_div::makeInstance('tx_templavoila_datastructureRepository');
$toRepo = t3lib_div::makeInstance('tx_templavoila_templateRepository');
$dsList = $dsRepo->getDatastructuresByStoragePidAndScope($storageFolderPID, tx_templavoila_datastructure::SCOPE_PAGE);
foreach ($dsList as $dsObj) {
if (t3lib_div::inList($disallowedPageTemplateItems, $dsObj->getKey()) || !$dsObj->isPermittedForUser()) {
continue;
}
$toList = $toRepo->getTemplatesByDatastructure($dsObj, $storageFolderPID);
foreach ($toList as $toObj) {
if ($toObj->getKey() === $defaultTO['uid'] || !$toObj->isPermittedForUser() || t3lib_div::inList($disallowedDesignTemplateItems, $toObj->getKey())) {
continue;
}
$tmpFilename = $toObj->getIcon();
$previewIconFilename = @is_file(PATH_site . substr($tmpFilename, 3)) ? $GLOBALS['BACK_PATH'] . $tmpFilename : $defaultIcon;
// Note: we cannot use value of image input element because MSIE replaces this value with mouse coordinates! Thus on click we set value to a hidden field. See http://bugs.typo3.org/view.php?id=3376
$previewIcon = '<input type="image" class="c-inputButton" name="i' . $row['uid'] . '" onclick="document.getElementById(\'data_tx_templavoila_to\').value=' . $toObj->getKey() . '" src="' . $previewIconFilename . '" title="" />';
$description = $toObj->getDescription() ? htmlspecialchars($toObj->getDescription()) : $LANG->getLL('template_nodescriptionavailable');
$tmplHTML[] = '<table style="width: 100%;" valign="top"><tr><td colspan="2" nowrap="nowrap"><h3 class="bgColor3-20">' . htmlspecialchars($toObj->getLabel()) . '</h3></td></tr>' . '<tr><td valign="top">' . $previewIcon . '</td><td width="120" valign="top"><p>' . $LANG->sL($description) . '</p></td></tr></table>';
}
}
$tmplHTML[] = '<input type="hidden" id="data_tx_templavoila_to" name="data[tx_templavoila_to]" value="0" />';
break;
case 't3d':
if (t3lib_extMgm::isLoaded('impexp')) {
// Read template files from a certain folder. I suggest this is configurable in some way. But here it is hardcoded for initial tests.
$templateFolder = PATH_site . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '/export/templates/';
$files = t3lib_div::getFilesInDir($templateFolder, 't3d,xml', 1, 1);
// Traverse the files found:
foreach ($files as $absPath) {
// Initialize the import object:
$import = $this->getImportObject();
if ($import->loadFile($absPath)) {
if (is_array($import->dat['header']['pagetree'])) {
// This means there are pages in the file, we like that...:
// Page tree:
reset($import->dat['header']['pagetree']);
$pageTree = current($import->dat['header']['pagetree']);
// Thumbnail icon:
if (is_array($import->dat['header']['thumbnail'])) {
$pI = pathinfo($import->dat['header']['thumbnail']['filename']);
if (t3lib_div::inList('gif,jpg,png,jpeg', strtolower($pI['extension']))) {
// Construct filename and write it:
$fileName = PATH_site . 'typo3temp/importthumb_' . t3lib_div::shortMD5($absPath) . '.' . $pI['extension'];
t3lib_div::writeFile($fileName, $import->dat['header']['thumbnail']['content']);
// Check that the image really is an image and not a malicious PHP script...
if (getimagesize($fileName)) {
// Create icon tag:
$iconTag = '<img src="' . $this->doc->backPath . '../' . substr($fileName, strlen(PATH_site)) . '" ' . $import->dat['header']['thumbnail']['imgInfo'][3] . ' vspace="5" style="border: solid black 1px;" alt="" />';
} else {
t3lib_div::unlink_tempfile($fileName);
$iconTag = '';
}
}
}
$aTagB = '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('templateFile' => $absPath))) . '">';
$aTagE = '</a>';
$tmplHTML[] = '<table style="float:left; width: 100%;" valign="top"><tr><td colspan="2" nowrap="nowrap">
<h3 class="bgColor3-20">' . $aTagB . htmlspecialchars($import->dat['header']['meta']['title'] ? $import->dat['header']['meta']['title'] : basename($absPath)) . $aTagE . '</h3></td></tr>
//.........这里部分代码省略.........
示例13: renderTemplateSelector
/**
* Renders the template selector.
*
* @param integer Position id. Can be positive and negative depending of where the new page is going: Negative always points to a position AFTER the page having the abs. value of the positionId. Positive numbers means to create as the first subpage to another page.
* @param string $templateType: The template type, 'tmplobj' or 't3d'
* @return string HTML output containing a table with the template selector
*/
function renderTemplateSelector($positionPid, $templateType = 'tmplobj')
{
global $LANG, $TYPO3_DB;
$storageFolderPID = $this->apiObj->getStorageFolderPid($positionPid);
$tmplHTML = array();
switch ($templateType) {
case 'tmplobj':
// Create the "Default template" entry
$previewIconFilename = $GLOBALS['BACK_PATH'] . '../' . t3lib_extMgm::siteRelPath($this->extKey) . 'res1/default_previewicon.gif';
$previewIcon = '<input type="image" class="c-inputButton" name="i0" value="0" src="' . $previewIconFilename . '" title="" />';
$description = htmlspecialchars($LANG->getLL('template_descriptiondefault'));
$tmplHTML[] = '<table style="float:left; width: 100%;" valign="top"><tr><td colspan="2" nowrap="nowrap">
<h3 class="bgColor3-20">' . htmlspecialchars($LANG->getLL('template_titledefault')) . '</h3></td></tr>
<tr><td valign="top">' . $previewIcon . '</td><td width="120" valign="top"><p>' . $description . '</p></td></tr></table>';
$tTO = 'tx_templavoila_tmplobj';
$tDS = 'tx_templavoila_datastructure';
$where = $tTO . '.parent=0 AND ' . $tTO . '.pid=' . intval($storageFolderPID) . ' AND ' . $tDS . '.scope=1' . $this->buildRecordWhere($tTO) . $this->buildRecordWhere($tDS) . t3lib_befunc::deleteClause($tTO) . t3lib_befunc::deleteClause($tDS) . t3lib_BEfunc::versioningPlaceholderClause($tTO) . t3lib_BEfunc::versioningPlaceholderClause($tDS);
$res = $TYPO3_DB->exec_SELECTquery($tTO . '.*', $tTO . ' LEFT JOIN ' . $tDS . ' ON ' . $tTO . '.datastructure = ' . $tDS . '.uid', $where);
while (false !== ($row = $TYPO3_DB->sql_fetch_assoc($res))) {
// Check if preview icon exists, otherwise use default icon:
$tmpFilename = 'uploads/tx_templavoila/' . $row['previewicon'];
$previewIconFilename = @is_file(PATH_site . $tmpFilename) ? $GLOBALS['BACK_PATH'] . '../' . $tmpFilename : $GLOBALS['BACK_PATH'] . '../' . t3lib_extMgm::siteRelPath($this->extKey) . 'res1/default_previewicon.gif';
// Note: we cannot use value of image input element because MSIE replaces this value with mouse coordinates! Thus on click we set value to a hidden field. See http://bugs.typo3.org/view.php?id=3376
$previewIcon = '<input type="image" class="c-inputButton" name="i' . $row['uid'] . '" onclick="document.getElementById(\'data_tx_templavoila_to\').value=' . $row['uid'] . '" src="' . $previewIconFilename . '" title="" />';
$description = $row['description'] ? htmlspecialchars($row['description']) : $LANG->getLL('template_nodescriptionavailable');
$tmplHTML[] = '<table style="width: 100%;" valign="top"><tr><td colspan="2" nowrap="nowrap"><h3 class="bgColor3-20">' . htmlspecialchars($row['title']) . '</h3></td></tr>' . '<tr><td valign="top">' . $previewIcon . '</td><td width="120" valign="top"><p>' . $description . '</p></td></tr></table>';
}
$tmplHTML[] = '<input type="hidden" id="data_tx_templavoila_to" name="data[tx_templavoila_to]" value="0" />';
break;
case 't3d':
if (t3lib_extMgm::isLoaded('impexp')) {
// Read template files from a certain folder. I suggest this is configurable in some way. But here it is hardcoded for initial tests.
$templateFolder = PATH_site . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '/export/templates/';
$files = t3lib_div::getFilesInDir($templateFolder, 't3d,xml', 1, 1);
// Traverse the files found:
foreach ($files as $absPath) {
// Initialize the import object:
$import = $this->getImportObject();
if ($import->loadFile($absPath)) {
if (is_array($import->dat['header']['pagetree'])) {
// This means there are pages in the file, we like that...:
// Page tree:
reset($import->dat['header']['pagetree']);
$pageTree = current($import->dat['header']['pagetree']);
// Thumbnail icon:
if (is_array($import->dat['header']['thumbnail'])) {
$pI = pathinfo($import->dat['header']['thumbnail']['filename']);
if (t3lib_div::inList('gif,jpg,png,jpeg', strtolower($pI['extension']))) {
// Construct filename and write it:
$fileName = PATH_site . 'typo3temp/importthumb_' . t3lib_div::shortMD5($absPath) . '.' . $pI['extension'];
t3lib_div::writeFile($fileName, $import->dat['header']['thumbnail']['content']);
// Check that the image really is an image and not a malicious PHP script...
if (getimagesize($fileName)) {
// Create icon tag:
$iconTag = '<img src="' . $this->doc->backPath . '../' . substr($fileName, strlen(PATH_site)) . '" ' . $import->dat['header']['thumbnail']['imgInfo'][3] . ' vspace="5" style="border: solid black 1px;" alt="" />';
} else {
t3lib_div::unlink_tempfile($fileName);
$iconTag = '';
}
}
}
$aTagB = '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('templateFile' => $absPath))) . '">';
$aTagE = '</a>';
$tmplHTML[] = '<table style="float:left; width: 100%;" valign="top"><tr><td colspan="2" nowrap="nowrap">
<h3 class="bgColor3-20">' . $aTagB . htmlspecialchars($import->dat['header']['meta']['title'] ? $import->dat['header']['meta']['title'] : basename($absPath)) . $aTagE . '</h3></td></tr>
<tr><td valign="top">' . $aTagB . $iconTag . $aTagE . '</td><td valign="top"><p>' . htmlspecialchars($import->dat['header']['meta']['description']) . '</p>
<em>Levels: ' . (count($pageTree) > 1 ? 'Deep structure' : 'Single page') . '<br/>
File: ' . basename($absPath) . '</em></td></tr></table>';
}
}
}
}
break;
}
if (is_array($tmplHTML) && count($tmplHTML)) {
$counter = 0;
$content .= '<table>';
foreach ($tmplHTML as $single) {
$content .= ($counter ? '' : '<tr>') . '<td valign="top">' . $single . '</td>' . ($counter ? '</tr>' : '');
$counter++;
if ($counter > 1) {
$counter = 0;
}
}
$content .= '</table>';
}
return $content;
}
示例14: getDiff
/**
* Produce a diff (using the "diff" application) between two strings
* The function will write the two input strings to temporary files, then execute the diff program, delete the temp files and return the result.
*
* @param string String 1
* @param string String 2
* @return array The result from the exec() function call.
* @access private
*/
function getDiff($str1, $str2)
{
// Create file 1 and write string
$file1 = t3lib_div::tempnam('diff1_');
t3lib_div::writeFile($file1, $str1);
// Create file 2 and write string
$file2 = t3lib_div::tempnam('diff2_');
t3lib_div::writeFile($file2, $str2);
// Perform diff.
$cmd = $GLOBALS['TYPO3_CONF_VARS']['BE']['diff_path'] . ' ' . $this->diffOptions . ' ' . $file1 . ' ' . $file2;
$res = array();
t3lib_utility_Command::exec($cmd, $res);
unlink($file1);
unlink($file2);
return $res;
}
示例15: generateInitialModelClassFile
/**
* Builds an initial class file to test parsing and modifiying of existing classes
*
* This class file is generated based on the CodeTemplates
* @param string $modelName
*/
function generateInitialModelClassFile($modelName)
{
$domainObject = $this->buildDomainObject($modelName);
$classFileContent = $this->codeGenerator->generateDomainObjectCode($domainObject, $this->extension);
$modelClassDir = 'Classes/Domain/Model/';
$result = t3lib_div::mkdir_deep($this->extension->getExtensionDir(), $modelClassDir);
$absModelClassDir = $this->extension->getExtensionDir() . $modelClassDir;
$this->assertTrue(is_dir($absModelClassDir), 'Directory ' . $absModelClassDir . ' was not created');
$modelClassPath = $absModelClassDir . $domainObject->getName() . '.php';
t3lib_div::writeFile($modelClassPath, $classFileContent);
}