Skip to content

Commit

Permalink
Filesystem
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Lodder committed Mar 12, 2019
1 parent d6842db commit caa2086
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
11 changes: 6 additions & 5 deletions build/build-modules-js/namespace.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ const RootPath = require('./utils/rootpath.es6.js')._();


const jregex = /defined\('(JPATH_BASE|_JEXEC|JPATH_PLATFORM)'\) or die;/gm;
const oldClassName = 'JPath';
const newClassName = 'Path';
const classUse = 'use Joomla\\CMS\\Filesystem\\Path;';
const oldClassName = 'JFile';
const classUse = 'use Joomla\\CMS\\Filesystem\\File;';
const newClassName = classUse.substr(classUse.lastIndexOf('\\') + 1).slice(0, -1);
const root = `${RootPath}/`;
const filesToIgnore = [
'classmap.php',
'finder_indexer.php',
'behavior.php',
'restore.php',
'com_finder',
'Provider',
]
Expand Down Expand Up @@ -58,8 +60,7 @@ const readFile = (path) => {
};

const getInstances = (content, path) => {
//const regex = /[^\s*](?=\S)(?!\/\*\*)(?!\/\/)(?!\*)(\\?JText)/gm;
const regex = /(?=\S)(?!\/\*\*)(?!\/\/)(?!\*)(\\?JPath)/gm;
const regex = /(?=\S)(?!\/\*\*)(?!\/\/)(?!\*)(\\?JFile)/gm;
const matches = content.match(regex);

if (matches !== null) {
Expand Down
4 changes: 3 additions & 1 deletion libraries/src/Filesystem/FilesystemHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Filesystem\FilesystemHelper;

/**
* File system helper
*
Expand Down Expand Up @@ -298,7 +300,7 @@ public static function isJoomlaStream($streamname)
/**
* Calculates the maximum upload file size and returns string with unit or the size in bytes
*
* Call it with JFilesystemHelper::fileUploadMaxSize();
* Call it with FilesystemHelper::fileUploadMaxSize();
*
* @param bool $unit_output This parameter determines whether the return value should be a string with a unit
*
Expand Down
7 changes: 4 additions & 3 deletions libraries/src/Filesystem/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Joomla\CMS\Client\ClientHelper;
use Joomla\CMS\Client\FtpClient;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Log\Log;

Expand Down Expand Up @@ -261,7 +262,7 @@ public static function create($path = '', $mode = 0755)

if ($inBaseDir == false)
{
// Return false for JFolder::create because the path to be created is not in open_basedir
// Return false for Folder::create because the path to be created is not in open_basedir
Log::add(__METHOD__ . ': ' . Text::_('JLIB_FILESYSTEM_ERROR_FOLDER_PATH'), Log::WARNING, 'jerror');

return false;
Expand Down Expand Up @@ -671,7 +672,7 @@ public static function listFolderTree($path, $filter, $maxLevel = 3, $level = 0,

if ($level == 0)
{
$GLOBALS['_JFolder_folder_tree_index'] = 0;
$GLOBALS['_Folder_folder_tree_index'] = 0;
}

if ($level < $maxLevel)
Expand All @@ -681,7 +682,7 @@ public static function listFolderTree($path, $filter, $maxLevel = 3, $level = 0,
// First path, index foldernames
foreach ($folders as $name)
{
$id = ++$GLOBALS['_JFolder_folder_tree_index'];
$id = ++$GLOBALS['_Folder_folder_tree_index'];
$fullName = Path::clean($path . '/' . $name);
$dirs[] = array(
'id' => $id,
Expand Down
6 changes: 4 additions & 2 deletions plugins/filesystem/local/Adapter/LocalAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
use Joomla\Component\Media\Administrator\Exception\InvalidPathException;
use Joomla\Image\Image;



/**
* Local file adapter.
*
Expand Down Expand Up @@ -615,7 +617,7 @@ private function moveFolder(string $sourcePath, string $destinationPath, bool $f

if (is_dir($destinationPath))
{
// We need to bypass exception thrown in JFolder when destination exists
// We need to bypass exception thrown in Folder when destination exists
// So we only copy it in forced condition, then delete the source to simulate a move
if (!Folder::copy($sourcePath, $destinationPath, '', true))
{
Expand Down Expand Up @@ -800,7 +802,7 @@ private function checkContent(string $localPath, string $mediaContent)
$helper = new MediaHelper;

// @todo find a better way to check the input, by not writing the file to the disk
$tmpFile = Path::clean(dirname($localPath) . '/' . uniqid() . '.' . \JFile::getExt($name));
$tmpFile = Path::clean(dirname($localPath) . '/' . uniqid() . '.' . File::getExt($name));

if (!File::write($tmpFile, $mediaContent))
{
Expand Down

0 comments on commit caa2086

Please sign in to comment.