Commit 06b24311 authored by speedprogs_de's avatar speedprogs_de

renamed file utility

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/terfe/branches/ter_fe2@51501 735d13b6-9817-0410-8766-e36946ffe9aa
parent a5c34a9b
......@@ -60,7 +60,7 @@
* @return void
*/
public function __construct() {
$this->imageCachePath = Tx_TerFe2_Utility_Files::getAbsoluteDirectory($this->imageCachePath);
$this->imageCachePath = Tx_TerFe2_Utility_File::getAbsoluteDirectory($this->imageCachePath);
}
......@@ -113,7 +113,7 @@
$filename = $this->getFileName($version, $fileType);
// Check local cache first
if (Tx_TerFe2_Utility_Files::fileExists($this->imageCachePath . $filename)) {
if (Tx_TerFe2_Utility_File::fileExists($this->imageCachePath . $filename)) {
return t3lib_div::locationHeaderUrl($this->imageCachePath . $filename);
}
......@@ -121,7 +121,7 @@
$iconUrl = $this->getFileUrl($filename);
// Copy icon to local cache
Tx_TerFe2_Utility_Files::copyFile($iconUrl, $this->imageCachePath . $filename);
Tx_TerFe2_Utility_File::copyFile($iconUrl, $this->imageCachePath . $filename);
return $iconUrl;
}
......
......@@ -126,18 +126,18 @@
// Get filename on mirror server
$filename = $this->getMirrorFileUrl($filename);
if (Tx_TerFe2_Utility_Files::isLocalUrl($filename)) {
$filename = Tx_TerFe2_Utility_Files::getAbsolutePathFromUrl($filename);
if (Tx_TerFe2_Utility_File::isLocalUrl($filename)) {
$filename = Tx_TerFe2_Utility_File::getAbsolutePathFromUrl($filename);
}
// Check if file exists
if (!Tx_TerFe2_Utility_Files::fileExists($filename)) {
if (!Tx_TerFe2_Utility_File::fileExists($filename)) {
throw new Exception('File "' . $filename . '" not found');
}
// Get local url from absolute path
if (Tx_TerFe2_Utility_Files::isAbsolutePath($filename)) {
return Tx_TerFe2_Utility_Files::getUrlFromAbsolutePath($filename);
if (Tx_TerFe2_Utility_File::isAbsolutePath($filename)) {
return Tx_TerFe2_Utility_File::getUrlFromAbsolutePath($filename);
}
return $filename;
......@@ -325,7 +325,7 @@
// Check mirrors if file exits
$count = 1;
while (!Tx_TerFe2_Utility_Files::fileExists($this->mirrorUrl . $filename)) {
while (!Tx_TerFe2_Utility_File::fileExists($this->mirrorUrl . $filename)) {
$count++;
if ($count > $this->maxMirrorChecks) {
throw new Exception('File "' . $filename . '" could not be found on ' . $this->maxMirrorChecks . ' mirrors, break');
......@@ -353,8 +353,8 @@
// Fetch file from server
$filename = $this->generateFileName($extension, $version, 't3x');
$filename = $this->getMirrorFileUrl($filename);
if (Tx_TerFe2_Utility_Files::isLocalUrl($filename)) {
$filename = Tx_TerFe2_Utility_Files::getAbsolutePathFromUrl($filename);
if (Tx_TerFe2_Utility_File::isLocalUrl($filename)) {
$filename = Tx_TerFe2_Utility_File::getAbsolutePathFromUrl($filename);
$content = t3lib_div::getURL($filename);
} else {
$content = t3lib_div::getURL($filename, 0, array(TYPO3_user_agent));
......
......@@ -33,11 +33,6 @@
*/
protected $name = 'Tx_TerFe2';
/**
* @var array
*/
protected $content = array();
/**
* @var boolean
*/
......@@ -48,6 +43,11 @@
*/
protected $saveImmediately = TRUE;
/**
* @var array
*/
protected $content = array();
/**
* Set name
......@@ -60,6 +60,37 @@
}
/**
* Get name
*
* @return string Name of the persistence
*/
public function getName() {
return $this->name;
}
/**
* Set isLoaded
*
* @param boolean $isLoaded Is loaded state
* @return void
*/
public function setIsLoaded($isLoaded) {
$this->isLoaded = (bool) $isLoaded;
}
/**
* Get isLoaded
*
* @return boolean Is loaded state
*/
public function isLoaded() {
return (bool) $this->isLoaded;
}
/**
* Set saveImmediately
*
......@@ -71,6 +102,16 @@
}
/**
* Get saveImmediately
*
* @return boolean Save immediately state
*/
public function saveImmediately() {
return (bool) $this->saveImmediately;
}
/**
* Add value
*
......@@ -82,11 +123,11 @@
if (empty($key)) {
throw new Exception('Empty keys are not allowed');
}
if (!$this->isLoaded) {
if (!$this->isLoaded()) {
$this->load();
}
$this->content[$key] = $value;
if ($this->saveImmediately) {
if ($this->saveImmediately()) {
$this->save();
}
}
......@@ -112,7 +153,7 @@
* @return boolean TRUE if exists
*/
public function has($key) {
if (!$this->isLoaded) {
if (!$this->isLoaded()) {
$this->load();
}
return isset($this->content[$key]);
......@@ -139,7 +180,7 @@
* @return array Key <-> value pairs
*/
public function getAll() {
if (!$this->isLoaded) {
if (!$this->isLoaded()) {
$this->load();
}
return $this->content;
......@@ -156,7 +197,7 @@
if ($this->has($key)) {
unset($this->content[$key]);
}
if ($this->saveImmediately) {
if ($this->saveImmediately()) {
$this->save();
}
}
......@@ -168,11 +209,11 @@
* @return void
*/
public function removeAll() {
if (!$this->isLoaded) {
if (!$this->isLoaded()) {
$this->load();
}
$this->content = array();
if ($this->saveImmediately) {
if ($this->saveImmediately()) {
$this->save();
}
}
......
......@@ -40,10 +40,10 @@
* @return void
*/
public function load() {
if (!$this->isLoaded) {
if (!$this->isLoaded()) {
$this->registry = t3lib_div::makeInstance('t3lib_Registry');
$this->content = $this->registry->get($this->name, 'content');
$this->isLoaded = TRUE;
$this->setIsLoaded(TRUE);
}
}
......
......@@ -39,7 +39,7 @@
}
if (!$this->isLoaded) {
$this->content = $GLOBALS['TSFE']->fe_user->getKey('ses', $this->name);
$this->isLoaded = TRUE;
$this->setIsLoaded(TRUE);
}
}
......
......@@ -42,7 +42,7 @@
}
// Check if file already exists
if (!$overwrite && Tx_TerFe2_Utility_Files::fileExists($filename)) {
if (!$overwrite && Tx_TerFe2_Utility_File::fileExists($filename)) {
return TRUE;
}
......@@ -86,12 +86,12 @@
}
// Check if file exists
if (!Tx_TerFe2_Utility_Files::fileExists($filename)) {
if (!Tx_TerFe2_Utility_File::fileExists($filename)) {
throw new Exception('File "' . $filename . '" not found to extract');
}
// Check if path is writable
$path = Tx_TerFe2_Utility_Files::getAbsoluteDirectory($path);
$path = Tx_TerFe2_Utility_File::getAbsoluteDirectory($path);
if (!is_writable($path)) {
throw new Exception('Path "' . $path . '" is not writeable');
}
......@@ -132,7 +132,7 @@
}
// Check if file was cached
if (Tx_TerFe2_Utility_Files::fileExists($zipFile)) {
if (Tx_TerFe2_Utility_File::fileExists($zipFile)) {
return TRUE;
}
......@@ -147,7 +147,7 @@
// Create ext_emconf.php
if (!empty($content['extKey']) && !empty($content['EM_CONF']) && is_array($content['EM_CONF'])) {
$files['ext_emconf.php'] = Tx_TerFe2_Utility_Files::createExtEmconfFile(
$files['ext_emconf.php'] = Tx_TerFe2_Utility_File::createExtEmconfFile(
$content['extKey'],
$content['EM_CONF']
);
......@@ -172,8 +172,8 @@
}
// Get local file name if on same server
if (Tx_TerFe2_Utility_Files::isLocalUrl($filename)) {
$filename = Tx_TerFe2_Utility_Files::getAbsolutePathFromUrl($filename);
if (Tx_TerFe2_Utility_File::isLocalUrl($filename)) {
$filename = Tx_TerFe2_Utility_File::getAbsolutePathFromUrl($filename);
}
// Get file content
......
......@@ -26,7 +26,7 @@
/**
* Utilities to manage files
*/
class Tx_TerFe2_Utility_Files {
class Tx_TerFe2_Utility_File {
/**
* Check if a file, URL or directory exists
......
......@@ -27,7 +27,7 @@
'tx_terfe2_task_updateextensionlisttask' => $extensionClassesPath . 'Task/UpdateExtensionListTask.php',
'tx_terfe2_task_updateextensionlisttaskadditionalfieldprovider' => $extensionClassesPath . 'Task/UpdateExtensionListTaskAdditionalFieldProvider.php',
'tx_terfe2_utility_archive' => $extensionClassesPath . 'Utility/Archive.php',
'tx_terfe2_utility_files' => $extensionClassesPath . 'Utility/Files.php',
'tx_terfe2_utility_file' => $extensionClassesPath . 'Utility/File.php',
'tx_terfe2_utility_soap' => $extensionClassesPath . 'Utility/Soap.php',
'tx_terfe2_utility_typoscript' => $extensionClassesPath . 'Utility/TypoScript.php',
);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment