本文整理汇总了PHP中TYPO3\CMS\Core\Utility\GeneralUtility::isAbsPath方法的典型用法代码示例。如果您正苦于以下问题:PHP GeneralUtility::isAbsPath方法的具体用法?PHP GeneralUtility::isAbsPath怎么用?PHP GeneralUtility::isAbsPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\GeneralUtility
的用法示例。
在下文中一共展示了GeneralUtility::isAbsPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayWarningMessages_postProcess
/**
* Checks RSA configuration and creates warnings if necessary.
*
* @param array $warnings Warnings
* @return void
* @see t3lib_BEfunc::displayWarningMessages()
*/
public function displayWarningMessages_postProcess(array &$warnings)
{
$backend = \TYPO3\CMS\Rsaauth\Backend\BackendFactory::getBackend();
if ($backend instanceof \TYPO3\CMS\Rsaauth\Backend\CommandLineBackend) {
// Not using the PHP extension!
$warnings['rsaauth_cmdline'] = $GLOBALS['LANG']->sL('LLL:EXT:rsaauth/hooks/locallang.xml:hook_using_cmdline');
// Check the path
$extconf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['rsaauth']);
$path = trim($extconf['temporaryDirectory']);
if ($path == '') {
// Path is empty
$warnings['rsaauth'] = $GLOBALS['LANG']->sL('LLL:EXT:rsaauth/hooks/locallang.xml:hook_empty_directory');
} elseif (!\TYPO3\CMS\Core\Utility\GeneralUtility::isAbsPath($path)) {
// Path is not absolute
$warnings['rsaauth'] = $GLOBALS['LANG']->sL('LLL:EXT:rsaauth/hooks/locallang.xml:hook_directory_not_absolute');
} elseif (!@is_dir($path)) {
// Path does not represent a directory
$warnings['rsaauth'] = $GLOBALS['LANG']->sL('LLL:EXT:rsaauth/hooks/locallang.xml:hook_directory_not_exist');
} elseif (!@is_writable($path)) {
// Directory is not writable
$warnings['rsaauth'] = $GLOBALS['LANG']->sL('LLL:EXT:rsaauth/hooks/locallang.xml:hook_directory_not_writable');
} elseif (substr($path, 0, strlen(PATH_site)) == PATH_site) {
// Directory is inside the site root
$warnings['rsaauth'] = $GLOBALS['LANG']->sL('LLL:EXT:rsaauth/hooks/locallang.xml:hook_directory_inside_siteroot');
}
}
}
示例2: setLogFile
/**
* Sets the path to the log file.
*
* Log file can be outside of given PATH_site directory
*
* @param string $logFile Path to the log file, relative to PATH_site
* @return \TYPO3\CMS\Core\Log\Writer\WriterInterface
*/
public function setLogFile($logFile)
{
if (strpos($logFile, '://') === false) {
if (!GeneralUtility::isAbsPath($logFile)) {
$logFile = PATH_site . $logFile;
}
}
$this->logFile = $logFile;
$this->openLogFile();
return $this;
}
示例3: changeDirectory
/**
* Changes directory to the given path.
*
* @param string $path Path to change to
* @return boolean
*/
public function changeDirectory($path)
{
if (GeneralUtility::isAbsPath($path)) {
$fullPath = $path;
} else {
$fullPath = $this->currentDirectory . $path;
}
// Make sure the path has a trailing slash
if (strrpos($fullPath, '/') !== strlen($fullPath) - 1) {
$fullPath .= '/';
}
$this->currentDirectory = $fullPath;
}
示例4: substituteExtensionPath
/**
* Replace the EXT:extkey prefix with the appropriate path.
*
* @param string $encodedTemplateRootPath
* @return string
*/
public static function substituteExtensionPath($encodedTemplateRootPath)
{
$result = '';
if (GeneralUtility::isFirstPartOfStr($encodedTemplateRootPath, 'EXT:')) {
list($extKey, $script) = explode('/', substr($encodedTemplateRootPath, 4), 2);
if ($extKey && ExtensionManagementUtility::isLoaded($extKey)) {
$result = ExtensionManagementUtility::extPath($extKey) . $script;
}
} elseif (GeneralUtility::isAbsPath($encodedTemplateRootPath)) {
$result = $encodedTemplateRootPath;
} else {
$result = PATH_site . $encodedTemplateRootPath;
}
return $result;
}
示例5: getModuleIconRelative
/**
* Returns relative path to the icon filename for use in img-tags
*
* @param string $iconFilename Icon filename
* @return string Icon filename with relative path
* @see getModuleIconAbsolute()
*/
protected function getModuleIconRelative($iconFilename)
{
if (GeneralUtility::isAbsPath($iconFilename)) {
$iconFilename = '../' . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($iconFilename);
}
return $iconFilename;
}
示例6: isAbsPath
/**
* For testing we must allow vfs:// as first part of file path
*
* @param string $path File path to evaluate
* @return bool
*/
public static function isAbsPath($path)
{
return self::isFirstPartOfStr($path, 'vfs://') || parent::isAbsPath($path);
}
示例7: loadNewTcaColumnsConfigFiles
/**
* Loads "columns" of a $TCA table definition if extracted
* to a "dynamicConfigFile". This method is called after each
* single ext_tables.php files was included to immediately have
* the full $TCA ready for the next extension.
*
* $TCA[$tableName]['ctrl']['dynamicConfigFile'] must be the
* absolute path to a file.
*
* Be aware that 'dynamicConfigFile' is obsolete, and all TCA
* table definitions should be moved to Configuration/TCA/tablename.php
* to be fully loaded automatically.
*
* Example:
* dynamicConfigFile = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'SysNote.php',
*
* @return void
* @throws \RuntimeException
* @internal Internal use ONLY. It is called by cache files and can not be protected. Do not call yourself!
* @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8. Table definition should be moved to <your_extension>/Configuration/TCA/<table_name>
*/
public static function loadNewTcaColumnsConfigFiles()
{
global $TCA;
foreach ($TCA as $tableName => $_) {
if (!isset($TCA[$tableName]['columns'])) {
$columnsConfigFile = $TCA[$tableName]['ctrl']['dynamicConfigFile'];
if ($columnsConfigFile) {
GeneralUtility::logDeprecatedFunction();
if (GeneralUtility::isAbsPath($columnsConfigFile)) {
include $columnsConfigFile;
} else {
throw new \RuntimeException('Columns configuration file not found', 1341151261);
}
}
}
}
}
示例8: getShortcutIcon
/**
* Gets the icon for the shortcut
*
* @param array $row
* @param array $shortcut
* @return string Shortcut icon as img tag
*/
protected function getShortcutIcon($row, $shortcut)
{
$databaseConnection = $this->getDatabaseConnection();
$languageService = $this->getLanguageService();
$titleAttribute = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.shortcut', TRUE);
switch ($row['module_name']) {
case 'xMOD_alt_doc.php':
$table = $shortcut['table'];
$recordid = $shortcut['recordid'];
$icon = '';
if ($shortcut['type'] == 'edit') {
// Creating the list of fields to include in the SQL query:
$selectFields = $this->fieldArray;
$selectFields[] = 'uid';
$selectFields[] = 'pid';
if ($table == 'pages') {
$selectFields[] = 'module';
$selectFields[] = 'extendToSubpages';
$selectFields[] = 'doktype';
}
if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
$selectFields = array_merge($selectFields, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']);
}
if ($GLOBALS['TCA'][$table]['ctrl']['type']) {
$selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['type'];
}
if ($GLOBALS['TCA'][$table]['ctrl']['typeicon_column']) {
$selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['typeicon_column'];
}
if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
$selectFields[] = 't3ver_state';
}
// Unique list!
$selectFields = array_unique($selectFields);
$permissionClause = $table === 'pages' && $this->perms_clause ? ' AND ' . $this->perms_clause : '';
$sqlQueryParts = array('SELECT' => implode(',', $selectFields), 'FROM' => $table, 'WHERE' => 'uid IN (' . $recordid . ') ' . $permissionClause . BackendUtility::deleteClause($table) . BackendUtility::versioningPlaceholderClause($table));
$result = $databaseConnection->exec_SELECT_queryArray($sqlQueryParts);
$row = $databaseConnection->sql_fetch_assoc($result);
$icon = IconUtility::getSpriteIconForRecord($table, (array) $row, array('title' => $titleAttribute));
} elseif ($shortcut['type'] == 'new') {
$icon = IconUtility::getSpriteIconForRecord($table, array(), array('title' => $titleAttribute));
}
break;
case 'file_edit':
$icon = IconUtility::getSpriteIcon('mimetypes-text-html', array('title' => $titleAttribute));
break;
case 'wizard_rte':
$icon = IconUtility::getSpriteIcon('mimetypes-word', array('title' => $titleAttribute));
break;
default:
if ($languageService->moduleLabels['tabs_images'][$row['module_name'] . '_tab']) {
$icon = $languageService->moduleLabels['tabs_images'][$row['module_name'] . '_tab'];
// Change icon of fileadmin references - otherwise it doesn't differ with Web->List
$icon = str_replace('mod/file/list/list.gif', 'mod/file/file.gif', $icon);
if (GeneralUtility::isAbsPath($icon)) {
$icon = '../' . PathUtility::stripPathSitePrefix($icon);
}
// @todo: hardcoded width as we don't have a way to address module icons with an API yet.
$icon = '<img src="' . htmlspecialchars($icon) . '" alt="' . $titleAttribute . '" width="16">';
} else {
$icon = IconUtility::getSpriteIcon('empty-empty', array('title' => $titleAttribute));
}
}
return $icon;
}
示例9: indexRegularDocument
/**
* Indexing a regular document given as $file (relative to PATH_site, local file)
*
* @param string $file Relative Filename, relative to PATH_site. It can also be an absolute path as long as it is inside the lockRootPath (validated with \TYPO3\CMS\Core\Utility\GeneralUtility::isAbsPath()). Finally, if $contentTmpFile is set, this value can be anything, most likely a URL
* @param bool $force If set, indexing is forced (despite content hashes, mtime etc).
* @param string $contentTmpFile Temporary file with the content to read it from (instead of $file). Used when the $file is a URL.
* @param string $altExtension File extension for temporary file.
* @return void
*/
public function indexRegularDocument($file, $force = false, $contentTmpFile = '', $altExtension = '')
{
// Init
$fI = pathinfo($file);
$ext = $altExtension ?: strtolower($fI['extension']);
// Create abs-path:
if (!$contentTmpFile) {
if (!GeneralUtility::isAbsPath($file)) {
// Relative, prepend PATH_site:
$absFile = GeneralUtility::getFileAbsFileName(PATH_site . $file);
} else {
// Absolute, pass-through:
$absFile = $file;
}
$absFile = GeneralUtility::isAllowedAbsPath($absFile) ? $absFile : '';
} else {
$absFile = $contentTmpFile;
}
// Indexing the document:
if ($absFile && @is_file($absFile)) {
if ($this->external_parsers[$ext]) {
$fileInfo = stat($absFile);
$cParts = $this->fileContentParts($ext, $absFile);
foreach ($cParts as $cPKey) {
$this->internal_log = array();
$this->log_push('Index: ' . str_replace('.', '_', basename($file)) . ($cPKey ? '#' . $cPKey : ''), '');
$Pstart = GeneralUtility::milliseconds();
$subinfo = array('key' => $cPKey);
// Setting page range. This is "0" (zero) when no division is made, otherwise a range like "1-3"
$phash_arr = $this->file_phash_arr = $this->setExtHashes($file, $subinfo);
$check = $this->checkMtimeTstamp($fileInfo['mtime'], $phash_arr['phash']);
if ($check > 0 || $force) {
if ($check > 0) {
$this->log_setTSlogMessage('Indexing needed, reason: ' . $this->reasons[$check], 1);
} else {
$this->log_setTSlogMessage('Indexing forced by flag', 1);
}
// Check external file counter:
if ($this->externalFileCounter < $this->maxExternalFiles || $force) {
// Divide into title,keywords,description and body:
$this->log_push('Split content', '');
$contentParts = $this->readFileContent($ext, $absFile, $cPKey);
$this->log_pull();
if (is_array($contentParts)) {
// Calculating a hash over what is to be the actual content. (see indexTypo3PageContent())
$content_md5h = IndexedSearchUtility::md5inthash(implode($contentParts, ''));
if ($this->checkExternalDocContentHash($phash_arr['phash_grouping'], $content_md5h) || $force) {
// Increment counter:
$this->externalFileCounter++;
// Splitting words
$this->log_push('Extract words from content', '');
$splitInWords = $this->processWordsInArrays($contentParts);
$this->log_pull();
// Analyse the indexed words.
$this->log_push('Analyse the extracted words', '');
$indexArr = $this->indexAnalyze($splitInWords);
$this->log_pull();
// Submitting page (phash) record
$this->log_push('Submitting page', '');
// Unfortunately I cannot determine WHEN a file is originally made - so I must return the modification time...
$this->submitFilePage($phash_arr, $file, $subinfo, $ext, $fileInfo['mtime'], $fileInfo['ctime'], $fileInfo['size'], $content_md5h, $contentParts);
$this->log_pull();
// Check words and submit to word list if not there
$this->log_push('Check word list and submit words', '');
if (IndexedSearchUtility::isTableUsed('index_words')) {
$this->checkWordList($indexArr);
$this->submitWords($indexArr, $phash_arr['phash']);
}
$this->log_pull();
// Set parsetime
$this->updateParsetime($phash_arr['phash'], GeneralUtility::milliseconds() - $Pstart);
} else {
// Update the timestamp
$this->updateTstamp($phash_arr['phash'], $fileInfo['mtime']);
$this->log_setTSlogMessage('Indexing not needed, the contentHash, ' . $content_md5h . ', has not changed. Timestamp updated.');
}
} else {
$this->log_setTSlogMessage('Could not index file! Unsupported extension.');
}
} else {
$this->log_setTSlogMessage('The limit of ' . $this->maxExternalFiles . ' has already been exceeded, so no indexing will take place this time.');
}
} else {
$this->log_setTSlogMessage('Indexing not needed, reason: ' . $this->reasons[$check]);
}
// Checking and setting sections:
$this->submitFile_section($phash_arr['phash']);
// Setting a section-record for the file. This is done also if the file is not indexed. Notice that section records are deleted when the page is indexed.
$this->log_pull();
}
} else {
//.........这里部分代码省略.........
示例10: getHtmlTemplate
/**
* Function to load a HTML template file with markers.
* When calling from own extension, use syntax getHtmlTemplate('EXT:extkey/template.html')
*
* @param string $filename tmpl name, usually in the typo3/template/ directory
* @return string HTML of template
*/
public function getHtmlTemplate($filename)
{
// setting the name of the original HTML template
$this->moduleTemplateFilename = $filename;
if ($GLOBALS['TBE_STYLES']['htmlTemplates'][$filename]) {
$filename = $GLOBALS['TBE_STYLES']['htmlTemplates'][$filename];
}
if (GeneralUtility::isFirstPartOfStr($filename, 'EXT:')) {
$filename = GeneralUtility::getFileAbsFileName($filename, true, true);
} elseif (!GeneralUtility::isAbsPath($filename)) {
$filename = GeneralUtility::resolveBackPath($filename);
} elseif (!GeneralUtility::isAllowedAbsPath($filename)) {
$filename = '';
}
$htmlTemplate = '';
if ($filename !== '') {
$htmlTemplate = GeneralUtility::getUrl($filename);
}
return $htmlTemplate;
}
示例11: getShortcutIcon
/**
* Gets the icon for the shortcut
*
* @param array $row
* @param array $shortcut
* @return string Shortcut icon as img tag
*/
protected function getShortcutIcon($row, $shortcut)
{
switch ($row['module_name']) {
case 'xMOD_alt_doc.php':
$table = $shortcut['table'];
$recordid = $shortcut['recordid'];
if ($shortcut['type'] == 'edit') {
// Creating the list of fields to include in the SQL query:
$selectFields = $this->fieldArray;
$selectFields[] = 'uid';
$selectFields[] = 'pid';
if ($table == 'pages') {
if (\TYPO3\CMS\Core\Extension\ExtensionManager::isLoaded('cms')) {
$selectFields[] = 'module';
$selectFields[] = 'extendToSubpages';
}
$selectFields[] = 'doktype';
}
if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
$selectFields = array_merge($selectFields, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']);
}
if ($GLOBALS['TCA'][$table]['ctrl']['type']) {
$selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['type'];
}
if ($GLOBALS['TCA'][$table]['ctrl']['typeicon_column']) {
$selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['typeicon_column'];
}
if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
$selectFields[] = 't3ver_state';
}
// Unique list!
$selectFields = array_unique($selectFields);
$permissionClause = $table == 'pages' && $this->perms_clause ? ' AND ' . $this->perms_clause : '';
$sqlQueryParts = array('SELECT' => implode(',', $selectFields), 'FROM' => $table, 'WHERE' => 'uid IN (' . $recordid . ') ' . $permissionClause . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table) . \TYPO3\CMS\Backend\Utility\BackendUtility::versioningPlaceholderClause($table));
$result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($sqlQueryParts);
$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
$icon = \TYPO3\CMS\Backend\Utility\IconUtility::getIcon($table, $row, $this->backPath);
} elseif ($shortcut['type'] == 'new') {
$icon = \TYPO3\CMS\Backend\Utility\IconUtility::getIcon($table, '', $this->backPath);
}
$icon = \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->backPath, $icon, '', 1);
break;
case 'xMOD_file_edit.php':
$icon = 'gfx/edit_file.gif';
break;
case 'xMOD_wizard_rte.php':
$icon = 'gfx/edit_rtewiz.gif';
break;
default:
if ($GLOBALS['LANG']->moduleLabels['tabs_images'][$row['module_name'] . '_tab']) {
$icon = $GLOBALS['LANG']->moduleLabels['tabs_images'][$row['module_name'] . '_tab'];
// Change icon of fileadmin references - otherwise it doesn't differ with Web->List
$icon = str_replace('mod/file/list/list.gif', 'mod/file/file.gif', $icon);
if (\TYPO3\CMS\Core\Utility\GeneralUtility::isAbsPath($icon)) {
$icon = '../' . substr($icon, strlen(PATH_site));
}
} else {
$icon = 'gfx/dummy_module.gif';
}
}
return '<img src="' . $icon . '" alt="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:toolbarItems.shortcut', TRUE) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:toolbarItems.shortcut', TRUE) . '" />';
}
示例12: backupExtension
/**
*
* @param \EBT\ExtensionBuilder\Domain\Model\Extension $extension
* @param string $backupDir
*
* @return void
*/
static function backupExtension(Model\Extension $extension, $backupDir)
{
if (empty($backupDir)) {
throw new \Exception('Please define a backup directory in extension configuration!');
} elseif (!GeneralUtility::validPathStr($backupDir)) {
throw new \Exception('Backup directory is not a valid path: ' . $backupDir);
} elseif (GeneralUtility::isAbsPath($backupDir)) {
if (!GeneralUtility::isAllowedAbsPath($backupDir)) {
throw new \Exception('Backup directory is not an allowed absolute path: ' . $backupDir);
}
} else {
$backupDir = PATH_site . $backupDir;
}
if (strrpos($backupDir, '/') < strlen($backupDir) - 1) {
$backupDir .= '/';
}
if (!is_dir($backupDir)) {
throw new \Exception('Backup directory does not exist: ' . $backupDir);
} elseif (!is_writable($backupDir)) {
throw new \Exception('Backup directory is not writable: ' . $backupDir);
}
$backupDir .= $extension->getExtensionKey();
// create a subdirectory for this extension
if (!is_dir($backupDir)) {
GeneralUtility::mkdir($backupDir);
}
if (strrpos($backupDir, '/') < strlen($backupDir) - 1) {
$backupDir .= '/';
}
$backupDir .= date('Y-m-d-') . time();
if (!is_dir($backupDir)) {
GeneralUtility::mkdir($backupDir);
}
$extensionDir = substr($extension->getExtensionDir(), 0, strlen($extension->getExtensionDir()) - 1);
try {
self::recurse_copy($extensionDir, $backupDir);
} catch (\Exception $e) {
throw new \Exception('Code generation aborted:' . $e->getMessage());
}
self::log('Backup created in ' . $backupDir);
}
示例13: readTextComment
/**
* Read image information from a associated text file.
* The text file should have the same name as the image but
* should end with '.txt'. Format
* <pre>
* {{title}}
* {{description}}
* {{author}}
* </pre>
*
* @param string $image: path to the image
* @return array title, description and author
*/
public function readTextComment($image)
{
if (!\TYPO3\CMS\Core\Utility\GeneralUtility::isAbsPath($image)) {
$image = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($image);
}
$data = array('title' => '', 'description' => '', 'author' => '');
$textfile = substr($image, 0, strrpos($image, '.')) . '.txt';
if (file_exists($textfile)) {
$lines = file($textfile);
if (count($lines)) {
$data['title'] = $lines[0];
$data['description'] = $lines[1];
$data['author'] = $lines[2];
}
}
return $data;
}
示例14: renderPreProcess
/**
* Insert javascript-tags for google-analytics
*
* @param array $params
* @param \TYPO3\CMS\Core\Page\PageRenderer $pObj
* @return void
*/
public function renderPreProcess($params, $pObj)
{
if (TYPO3_MODE === 'FE') {
// Get plugin-configuration
$conf = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_libjsanalytics.']['settings.'];
// Exclude the analytics-snippet on some pages
$pageExclude = GeneralUtility::trimExplode(',', $conf['pageExclude'], true);
// Generate script-tag for google-analytics if enabled
if ((int) $conf['enable'] && !in_array($GLOBALS['TSFE']->id, $pageExclude)) {
$analyticsPreScript = '';
$analyticsPostScript = '';
// Instruct analytics.js to use the name defined in typoscript
if (!empty($conf['gaObjectName']) && $conf['gaObjectName'] !== 'ga') {
$gaObjectName = $conf['gaObjectName'];
} else {
$gaObjectName = 'ga';
}
// Get filePath to analytics.js
$analyticsJavascriptFile = Tools::getConfParam('localFile');
if ($conf['forceCdn'] || !file_exists(PATH_site . $analyticsJavascriptFile)) {
$analyticsJavascriptFile = Tools::getConfParam('sourceFile');
} else {
// If local file is not available, fall back to CDN
if (empty($analyticsJavascriptFile)) {
$analyticsJavascriptFile = Tools::getConfParam('sourceFile');
} else {
// Prefix file with absRefPrefix if path is relative
if (!GeneralUtility::isAbsPath($analyticsJavascriptFile)) {
$analyticsJavascriptFile = $GLOBALS['TSFE']->absRefPrefix . $analyticsJavascriptFile;
}
// Append filename with version numbers
$analyticsJavascriptFile = GeneralUtility::createVersionNumberedFilename($analyticsJavascriptFile);
}
}
// Insert different codeblocks for different integration (old/new)
if ((int) $conf['alternative']) {
if ($conf['gaObjectName'] !== 'ga') {
$scriptTag .= LF . 'window.GoogleAnalyticsObject = \'' . $gaObjectName . '\';';
}
// Create an initial analytics() function
// The queued commands will be executed once analytics.js loads
$scriptTag .= LF . 'window.' . $gaObjectName . ' = window.' . $gaObjectName . ' || function() {' . '(' . $gaObjectName . '.q = ' . $gaObjectName . '.q || []).push(arguments)};';
// Set the time (as an integer) this tag was executed (Used for timing hits)
$scriptTag .= LF . $gaObjectName . '.l =+ new Date;';
// Compile final script-tag for analytics.js
$analyticsPostScript = LF . '<script src="' . $analyticsJavascriptFile . '" type="text/javascript" async="async"></script>';
} else {
// Compile final script-tag for analytics.js
$analyticsPreScript = LF . '(function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){' . LF . '(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),' . LF . 'm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)' . LF . '})(window,document,\'script\',\'' . $analyticsJavascriptFile . '\',\'' . $gaObjectName . '\');';
}
// Create the tracker
foreach ($conf['gaObject.'] as $gaName => $gaTracker) {
// Set the name of the tracker if defined in typoscript
$trackerName = '';
if ($gaName !== 'default.') {
$trackerName = $gaName;
}
// Check if analytics objects are defined
if (is_array($gaTracker)) {
$scriptTag .= $this->iterateTrackerMethods($gaObjectName, $trackerName, $gaTracker);
}
}
// TEST/TODO
// Add additional javascript to a single page if defined in PageTSConfig
//debug($GLOBALS['TSFE']->page['TSconfig']);
/*
$pageTS = BackendUtility::getPagesTSconfig($GLOBALS['TSFE']->id, [$GLOBALS['TSFE']->id]);
if (isset($pageTS['tx_libjsanalytics.'])) {
$analyticsPageTS = $pageTS['tx_libjsanalytics.'];
if (is_array($analyticsPageTS['additionalScript.'])) {
$scriptTag .= LF . $this->getCobject($analyticsPageTS['additionalScript'], $analyticsPageTS['additionalScript.']);
}
}
*/
// Compile final codeblock
$scriptTag = '<script type="text/javascript">' . LF . '/*<![CDATA[*/' . $analyticsPreScript . $scriptTag . LF . '/*]]>*/' . LF . '</script>' . $analyticsPostScript;
// Add final code to HTML
$pObj->addHeaderData($scriptTag);
}
}
}
示例15: validateIndexFilePath
/**
* Validates index file path.
*
* @param array $submittedData
* @param array $errors
* @return void
*/
protected function validateIndexFilePath(array &$submittedData, array &$errors)
{
if (GeneralUtility::isAbsPath($submittedData['indexFilePath'])) {
$errors[] = 'scheduler.error.badIndexFilePath';
} else {
$testPath = GeneralUtility::getFileAbsFileName($submittedData['indexFilePath'], TRUE);
if (!file_exists($testPath)) {
if (!@touch($testPath)) {
$errors[] = 'scheduler.error.badIndexFilePath';
} else {
unlink($testPath);
}
}
}
}