Skip to content

Commit

Permalink
JFile
Browse files Browse the repository at this point in the history
  • Loading branch information
brianteeman committed Jun 29, 2018
1 parent 32dc7b0 commit 1d78403
Show file tree
Hide file tree
Showing 18 changed files with 69 additions and 49 deletions.
Expand Up @@ -15,6 +15,7 @@
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Client\ClientHelper;
use Joomla\CMS\Fileystem\File;

/**
* Checks if the eAccelerator caching method is enabled.
Expand Down Expand Up @@ -68,7 +69,7 @@ function admin_postinstall_eaccelerator_action()
// Attempt to write the configuration file as a PHP class named JConfig.
$configuration = $config->toString('PHP', array('class' => 'JConfig', 'closingtag' => false));

if (!JFile::write($file, $configuration))
if (!File::write($file, $configuration))
{
JFactory::getApplication()->enqueueMessage(Text::_('COM_CONFIG_ERROR_WRITE_FAILED'), 'error');

Expand Down
3 changes: 2 additions & 1 deletion administrator/components/com_admin/script.php
Expand Up @@ -12,6 +12,7 @@
use Joomla\Database\UTF8MB4SupportInterface;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Extension\ExtensionHelper;
use Joomla\CMS\Fileystem\File;

/**
* Script file of Joomla CMS
Expand Down Expand Up @@ -3946,7 +3947,7 @@ public function deleteUnexistingFiles()

foreach ($files as $file)
{
if (JFile::exists(JPATH_ROOT . $file) && !JFile::delete(JPATH_ROOT . $file))
if (File::exists(JPATH_ROOT . $file) && !File::delete(JPATH_ROOT . $file))
{
echo Text::sprintf('FILES_JOOMLA_ERROR_FILE_FOLDER', $file) . '<br>';
}
Expand Down
5 changes: 3 additions & 2 deletions administrator/components/com_banners/Model/TracksModel.php
Expand Up @@ -15,6 +15,7 @@
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\Component\Banners\Administrator\Helper\BannersHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Fileystem\File;

/**
* Methods supporting a list of tracks.
Expand Down Expand Up @@ -503,9 +504,9 @@ public function getContent()

if (!empty($delete))
{
if (!\JFile::delete($delete))
if (!File::delete($delete))
{
// \JFile::delete throws an error
// File::delete throws an error
$this->setError(Text::_('COM_BANNERS_ERR_ZIP_DELETE_FAILURE'));

return false;
Expand Down
Expand Up @@ -13,6 +13,7 @@

use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Fileystem\File;

\JFormHelper::loadFieldClass('List');

Expand Down Expand Up @@ -58,7 +59,7 @@ protected function getOptions()
// Load language
$extension = $item->value;

if (\JFile::exists(JPATH_ADMINISTRATOR . '/components/' . $extension . '/config.xml'))
if (File::exists(JPATH_ADMINISTRATOR . '/components/' . $extension . '/config.xml'))
{
$source = JPATH_ADMINISTRATOR . '/components/' . $extension;
$lang->load("$extension.sys", JPATH_ADMINISTRATOR, null, false, true)
Expand Down
Expand Up @@ -24,6 +24,7 @@
use Joomla\CMS\Client\ClientHelper;
use Joomla\CMS\Cache\Exception\CacheConnectingException;
use Joomla\CMS\Cache\Exception\UnsupportedCacheException;
use Joomla\CMS\Fileystem\File;

/**
* Model for the global configuration
Expand Down Expand Up @@ -528,7 +529,7 @@ private function writeConfigFile(Registry $config)
// Attempt to write the configuration file as a PHP class named JConfig.
$configuration = $config->toString('PHP', array('class' => 'JConfig', 'closingtag' => false));

if (!\JFile::write($file, $configuration))
if (!File::write($file, $configuration))
{
throw new \RuntimeException(Text::_('COM_CONFIG_ERROR_WRITE_FAILED'));
}
Expand Down
Expand Up @@ -14,6 +14,7 @@
use Joomla\CMS\Table\ContentHistory;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Fileystem\File;

/**
* Categories helper.
Expand Down Expand Up @@ -170,7 +171,7 @@ public static function getFormFile(ContentType $typesTable)
// First, see if we have a file name in the $typesTable
$options = json_decode($typesTable->content_history_options);

if (is_object($options) && isset($options->formFile) && \JFile::exists(JPATH_ROOT . '/' . $options->formFile))
if (is_object($options) && isset($options->formFile) && File::exists(JPATH_ROOT . '/' . $options->formFile))
{
$result = JPATH_ROOT . '/' . $options->formFile;
}
Expand All @@ -182,8 +183,8 @@ public static function getFormFile(ContentType $typesTable)
{
$component = ($aliasArray[1] == 'category') ? 'com_categories' : $aliasArray[0];
$path = \JFolder::makeSafe(JPATH_ADMINISTRATOR . '/components/' . $component . '/models/forms/');
$file = \JFile::makeSafe($aliasArray[1] . '.xml');
$result = \JFile::exists($path . $file) ? $path . $file : false;
$file = File::makeSafe($aliasArray[1] . '.xml');
$result = File::exists($path . $file) ? $path . $file : false;
}
}

Expand Down
Expand Up @@ -9,6 +9,8 @@

defined('_JEXEC') or die;

use Joomla\CMS\Fileystem\File;

jimport('joomla.filesystem.file');

/**
Expand Down Expand Up @@ -212,7 +214,7 @@ public function index($item, $format = 'html')
*/
if ($group === static::PATH_CONTEXT)
{
$ip = JFile::stripExt($ip);
$ip = File::stripExt($ip);
$ip = str_replace('/', ' ', $ip);
$ip = str_replace('-', ' ', $ip);
}
Expand All @@ -236,7 +238,7 @@ public function index($item, $format = 'html')
*/
if ($group === static::PATH_CONTEXT)
{
$item->$property = JFile::stripExt($item->$property);
$item->$property = File::stripExt($item->$property);
$item->$property = str_replace('/', ' ', $item->$property);
$item->$property = str_replace('-', ' ', $item->$property);
}
Expand Down
Expand Up @@ -9,6 +9,8 @@

defined('_JEXEC') or die;

use Joomla\CMS\Fileystem\File;

jimport('joomla.filesystem.file');

/**
Expand Down Expand Up @@ -204,7 +206,7 @@ public function index($item, $format = 'html')
*/
if ($group === static::PATH_CONTEXT)
{
$ip = JFile::stripExt($ip);
$ip = File::stripExt($ip);
$ip = str_replace('/', ' ', $ip);
$ip = str_replace('-', ' ', $ip);
}
Expand All @@ -228,7 +230,7 @@ public function index($item, $format = 'html')
*/
if ($group === static::PATH_CONTEXT)
{
$item->$property = JFile::stripExt($item->$property);
$item->$property = File::stripExt($item->$property);
$item->$property = str_replace('/', ' ', $item->$property);
$item->$property = str_replace('-', ' ', $item->$property);
}
Expand Down
Expand Up @@ -15,6 +15,7 @@
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Client\ClientHelper;
use Joomla\CMS\Fileystem\File;

/**
* Extension Manager Install Model
Expand Down Expand Up @@ -312,7 +313,7 @@ protected function _getPackageFromUpload()

// Move uploaded file.
jimport('joomla.filesystem.file');
\JFile::upload($tmp_src, $tmp_dest, false, true);
File::upload($tmp_src, $tmp_dest, false, true);

// Unpack the downloaded package file.
$package = \JInstallerHelper::unpack($tmp_dest, true);
Expand Down
5 changes: 3 additions & 2 deletions administrator/components/com_installer/Model/UpdateModel.php
Expand Up @@ -17,6 +17,7 @@
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Fileystem\File;

/**
* Installer Update Model
Expand Down Expand Up @@ -563,7 +564,7 @@ protected function preparePreUpdate($update, $table)

$path = JPATH_ADMINISTRATOR . '/components/' . $table->element . '/helpers/' . $fname;

if (\JFile::exists($path))
if (File::exists($path))
{
require_once $path;

Expand All @@ -580,7 +581,7 @@ protected function preparePreUpdate($update, $table)
$cname = str_replace('_', '', $table->element) . 'Helper';
$path = ($table->client_id ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/modules/' . $table->element . '/helper.php';

if (\JFile::exists($path))
if (File::exists($path))
{
require_once $path;

Expand Down
Expand Up @@ -15,6 +15,7 @@
use Joomla\CMS\Response\JsonResponse;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Client\ClientHelper;
use Joomla\CMS\Fileystem\File;

/**
* The Joomla! update controller for the Update view
Expand Down Expand Up @@ -293,7 +294,7 @@ public function captive()

\JLoader::import('joomla.filesystem.file');

if (empty($tempFile) || !\JFile::exists($tempFile))
if (empty($tempFile) || !File::exists($tempFile))
{
throw new \RuntimeException(Text::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403);
}
Expand Down
31 changes: 16 additions & 15 deletions administrator/components/com_joomlaupdate/Model/UpdateModel.php
Expand Up @@ -19,6 +19,7 @@
use Joomla\CMS\User\UserHelper;
use Joomla\CMS\Client\ClientHelper;
use Joomla\CMS\Client\FtpClient;
use Joomla\CMS\Fileystem\File;

jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
Expand Down Expand Up @@ -299,7 +300,7 @@ public function download()
$target = $tempdir . '/' . $basename;

// Do we have a cached file?
$exists = \JFile::exists($target);
$exists = File::exists($target);

if (!$exists)
{
Expand Down Expand Up @@ -365,7 +366,7 @@ protected function downloadPackage($url, $target)
jimport('joomla.filesystem.file');

// Make sure the target does not exist.
\JFile::delete($target);
File::delete($target);

// Download the package
try
Expand All @@ -383,7 +384,7 @@ protected function downloadPackage($url, $target)
}

// Write the file to disk
\JFile::write($target, $result->body);
File::write($target, $result->body);

return basename($target);
}
Expand Down Expand Up @@ -508,7 +509,7 @@ public function createRestorationFile($basename = null)
{
\JFolder::create($tempdir, 511);
$htaccessContents = "order deny,allow\ndeny from all\nallow from none\n";
\JFile::write($tempdir . '/.htaccess', $htaccessContents);
File::write($tempdir . '/.htaccess', $htaccessContents);
}

// If it exists and it is unwritable, try creating a writable admintools subdirectory.
Expand Down Expand Up @@ -576,13 +577,13 @@ public function createRestorationFile($basename = null)
// Remove the old file, if it's there...
$configpath = JPATH_COMPONENT_ADMINISTRATOR . '/restoration.php';

if (\JFile::exists($configpath))
if (File::exists($configpath))
{
\JFile::delete($configpath);
File::delete($configpath);
}

// Write new file. First try with \JFile.
$result = \JFile::write($configpath, $data);
$result = File::write($configpath, $data);

// In case \JFile used FTP but direct access could help.
if (!$result)
Expand Down Expand Up @@ -843,23 +844,23 @@ public function cleanUp()

if (!@unlink($target))
{
\JFile::delete($target);
File::delete($target);
}

// Remove the restoration.php file.
$target = JPATH_COMPONENT_ADMINISTRATOR . '/restoration.php';

if (!@unlink($target))
{
\JFile::delete($target);
File::delete($target);
}

// Remove joomla.xml from the site's root.
$target = JPATH_ROOT . '/joomla.xml';

if (!@unlink($target))
{
\JFile::delete($target);
File::delete($target);
}

// Unset the update filename from the session.
Expand Down Expand Up @@ -934,12 +935,12 @@ public function upload()

if (version_compare(\JVERSION, '3.4.0', 'ge'))
{
$result = \JFile::upload($tmp_src, $tmp_dest, false, true);
$result = File::upload($tmp_src, $tmp_dest, false, true);
}
else
{
// Old Joomla! versions didn't have UploadShield and don't need the fourth parameter to accept uploads
$result = \JFile::upload($tmp_src, $tmp_dest);
$result = File::upload($tmp_src, $tmp_dest);
}

if (!$result)
Expand Down Expand Up @@ -1001,7 +1002,7 @@ public function captiveFileExists()

\JLoader::import('joomla.filesystem.file');

if (empty($file) || !\JFile::exists($file))
if (empty($file) || !File::exists($file))
{
return false;
}
Expand All @@ -1027,11 +1028,11 @@ public function removePackageFiles()

foreach ($files as $file)
{
if (\JFile::exists($file))
if (File::exists($file))
{
if (!@unlink($file))
{
\JFile::delete($file);
File::delete($file);
}
}
}
Expand Down
Expand Up @@ -16,6 +16,7 @@
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\Component\Languages\Administrator\Helper\LanguagesHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Fileystem\File;

/**
* Languages Overrides Model
Expand Down Expand Up @@ -71,7 +72,7 @@ public function getOverrides($all = false)
// Delete the override.ini file if empty.
if (file_exists($filename) && empty($strings))
{
\JFile::delete($filename);
File::delete($filename);
}

// Filter the loaded strings according to the search box.
Expand Down
Expand Up @@ -14,6 +14,7 @@
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\Component\Postinstall\Administrator\Helper\PostinstallHelper;
use Joomla\Component\Postinstall\Administrator\Model\MessagesModel;
use Joomla\CMS\Fileystem\File;

/**
* Postinstall message controller.
Expand Down Expand Up @@ -102,7 +103,7 @@ public function action()
$helper = new PostinstallHelper;
$file = $helper->parsePath($item->action_file);

if (\JFile::exists($file))
if (File::exists($file))
{
require_once $file;

Expand Down

0 comments on commit 1d78403

Please sign in to comment.