Initial commit
This commit is contained in:
46
typo3conf/ext/vhs/Classes/Utility/CoreUtility.php
Normal file
46
typo3conf/ext/vhs/Classes/Utility/CoreUtility.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Utility;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
|
||||
|
||||
/**
|
||||
* Core Utility
|
||||
*
|
||||
* Utility to get core informations.
|
||||
*
|
||||
* @author Daniel Dorndorf <dorndorf@dreipunktnull.com>
|
||||
* @package Vhs
|
||||
* @subpackage Utility
|
||||
*/
|
||||
class CoreUtility {
|
||||
|
||||
/**
|
||||
* Returns the flag icons path depending on the current core version
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getLanguageFlagIconPath() {
|
||||
if (TRUE === version_compare(TYPO3_version, '7.1', '<')) {
|
||||
return ExtensionManagementUtility::extPath('t3skin') . 'images/flags/';
|
||||
}
|
||||
return ExtensionManagementUtility::extPath('core') . 'Resources/Public/Icons/Flags/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current core minor version
|
||||
*
|
||||
* @return string
|
||||
* @throws \TYPO3\CMS\Core\Package\Exception
|
||||
*/
|
||||
public static function getCurrentCoreVersion() {
|
||||
return substr(ExtensionManagementUtility::getExtensionVersion('core'), 0, 3);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Utility;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
/**
|
||||
* Frontend Simulation Utility
|
||||
*
|
||||
* Utility to simulate frontend enviroment in backend enviroment.
|
||||
*
|
||||
* @author Xaver Maierhofer <xaver.maierhofer@xwissen.info>
|
||||
* @package Vhs
|
||||
* @subpackage Utility
|
||||
*/
|
||||
class FrontendSimulationUtility {
|
||||
|
||||
/**
|
||||
* Sets the global variables $GLOBALS['TSFE']->csConvObj and $GLOBALS['TSFE']->renderCharset in Backend mode
|
||||
* This somewhat hacky work around is currently needed because the conv_case() and convCaseFirst() functions of tslib_cObj rely on those variables to be set
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function simulateFrontendEnvironment() {
|
||||
if ('BE' !== TYPO3_MODE) {
|
||||
return;
|
||||
}
|
||||
$tsfeBackup = isset($GLOBALS['TSFE']) ? $GLOBALS['TSFE'] : NULL;
|
||||
$GLOBALS['TSFE'] = new \stdClass();
|
||||
// preparing csConvObj
|
||||
if (FALSE === is_object($GLOBALS['TSFE']->csConvObj)) {
|
||||
if (TRUE === is_object($GLOBALS['LANG'])) {
|
||||
$GLOBALS['TSFE']->csConvObj = $GLOBALS['LANG']->csConvObj;
|
||||
} else {
|
||||
$GLOBALS['TSFE']->csConvObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Charset\\CharsetConverter');
|
||||
}
|
||||
}
|
||||
// preparing renderCharset
|
||||
if (FALSE === is_object($GLOBALS['TSFE']->renderCharset)) {
|
||||
if (TRUE === is_object($GLOBALS['LANG'])) {
|
||||
$GLOBALS['TSFE']->renderCharset = $GLOBALS['LANG']->charSet;
|
||||
} else {
|
||||
$GLOBALS['TSFE']->renderCharset = 'utf-8';
|
||||
}
|
||||
}
|
||||
return $tsfeBackup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets $GLOBALS['TSFE'] if it was previously changed by simulateFrontendEnvironment()
|
||||
*
|
||||
* @param mixed $tsfeBackup
|
||||
* @return void
|
||||
* @see simulateFrontendEnvironment()
|
||||
*/
|
||||
public static function resetFrontendEnvironment($tsfeBackup) {
|
||||
if ('BE' !== TYPO3_MODE) {
|
||||
return;
|
||||
}
|
||||
$GLOBALS['TSFE'] = $tsfeBackup;
|
||||
}
|
||||
|
||||
}
|
||||
45
typo3conf/ext/vhs/Classes/Utility/ResourceUtility.php
Normal file
45
typo3conf/ext/vhs/Classes/Utility/ResourceUtility.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\Utility;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\Resource\File;
|
||||
|
||||
/**
|
||||
* ViewHelper Utility
|
||||
*
|
||||
* Contains helper methods used in resources ViewHelpers
|
||||
*
|
||||
* @author Danilo Bürger <danilo.buerger@hmspl.de>, Heimspiel GmbH
|
||||
* @package Vhs
|
||||
* @subpackage Utility
|
||||
*/
|
||||
class ResourceUtility {
|
||||
|
||||
/**
|
||||
* Fixes a bug in TYPO3 6.2.0 that the properties metadata is not overlayed on localization.
|
||||
*
|
||||
* @param File $file
|
||||
* @return array
|
||||
*/
|
||||
public static function getFileArray(File $file) {
|
||||
$properties = $file->getProperties();
|
||||
$stat = $file->getStorage()->getFileInfo($file);
|
||||
$array = $file->toArray();
|
||||
|
||||
foreach ($properties as $key => $value) {
|
||||
$array[$key] = $value;
|
||||
}
|
||||
foreach ($stat as $key => $value) {
|
||||
$array[$key] = $value;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user