Skip to content

Commit

Permalink
Replace KunenaFolder by Jommla! Folder class only where it's possible (
Browse files Browse the repository at this point in the history
  • Loading branch information
xillibit authored and 810 committed Mar 16, 2019
1 parent cb3dd54 commit f44c06b
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 37 deletions.
Expand Up @@ -18,6 +18,7 @@
use Joomla\CMS\Session\Session;
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;

/**
* Kunena Backend Templates Controller
Expand Down Expand Up @@ -234,10 +235,10 @@ public function install()
File::move($dest . $template->directory . '/assets/css/custom.css', $tmp_kunena . $template->sourcedir . '/assets/css/custom.css');
}

KunenaFolder::delete($dest . $template->directory);
Folder::delete($dest . $template->directory);
}

$success = KunenaFolder::move($tmp_kunena . $template->sourcedir, $dest . $template->directory);
$success = Folder::move($tmp_kunena . $template->sourcedir, $dest . $template->directory);

if ($success !== true)
{
Expand All @@ -252,7 +253,7 @@ public function install()
// Delete the tmp install directory
if (is_dir($tmp_kunena))
{
KunenaFolder::delete($tmp_kunena);
Folder::delete($tmp_kunena);
}

// Clear all cache, just in case.
Expand Down Expand Up @@ -327,7 +328,7 @@ public function uninstall()
// Delete the template directory
if (is_dir($tpl))
{
$retval = KunenaFolder::delete($tpl);
$retval = Folder::delete($tpl);

// Clear all cache, just in case.
KunenaCacheHelper::clearAll();
Expand Down
Expand Up @@ -15,6 +15,7 @@
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\Registry\Registry;
use Joomla\CMS\Filesystem\Folder;

jimport('joomla.application.component.model');
jimport('joomla.html.pagination');
Expand Down Expand Up @@ -145,7 +146,7 @@ public function getAdminOptions()
$lists['display_children'] = HTMLHelper::_('select.genericlist', $options, 'params[display][index][children]', 'class="inputbox" size="1"', 'value', 'text', $category->params->get('display.index.children', '3'));

$topicicons = array();
$topiciconslist = KunenaFolder::folders(JPATH_ROOT . '/media/kunena/topic_icons');
$topiciconslist = Folder::folders(JPATH_ROOT . '/media/kunena/topic_icons');

foreach ($topiciconslist as $icon)
{
Expand Down
5 changes: 3 additions & 2 deletions src/administrator/components/com_kunena/models/rank.php
Expand Up @@ -13,6 +13,7 @@

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\Folder;

jimport('joomla.application.component.modellist');

Expand All @@ -36,7 +37,7 @@ public function getRankspaths()
$selected = $this->getRank();

$rankpath = $template->getRankPath();
$files1 = (array) KunenaFolder::Files(JPATH_SITE . '/' . $rankpath, false, false, false, array('index.php', 'index.html'));
$files1 = (array) Folder::Files(JPATH_SITE . '/' . $rankpath, false, false, false, array('index.php', 'index.html'));
$files1 = (array) array_flip($files1);

foreach ($files1 as $key => &$path)
Expand All @@ -45,7 +46,7 @@ public function getRankspaths()
}

$rankpath = 'media/kunena/ranks/';
$files2 = (array) KunenaFolder::Files(JPATH_SITE . '/' . $rankpath, false, false, false, array('index.php', 'index.html'));
$files2 = (array) Folder::Files(JPATH_SITE . '/' . $rankpath, false, false, false, array('index.php', 'index.html'));
$files2 = (array) array_flip($files2);

foreach ($files2 as $key => &$path)
Expand Down
5 changes: 3 additions & 2 deletions src/administrator/components/com_kunena/models/smiley.php
Expand Up @@ -13,6 +13,7 @@

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\Folder;

jimport('joomla.application.component.modellist');

Expand All @@ -35,7 +36,7 @@ public function getSmileyspaths()
$selected = $this->getSmiley();

$smileypath = $template->getSmileyPath();
$files1 = (array) KunenaFolder::Files(JPATH_SITE . '/' . $smileypath, false, false, false, array('index.php', 'index.html'));
$files1 = (array) Folder::Files(JPATH_SITE . '/' . $smileypath, false, false, false, array('index.php', 'index.html'));
$files1 = (array) array_flip($files1);

foreach ($files1 as $key => &$path)
Expand All @@ -44,7 +45,7 @@ public function getSmileyspaths()
}

$smileypath = 'media/kunena/emoticons/';
$files2 = (array) KunenaFolder::Files(JPATH_SITE . '/' . $smileypath, false, false, false, array('index.php', 'index.html'));
$files2 = (array) Folder::Files(JPATH_SITE . '/' . $smileypath, false, false, false, array('index.php', 'index.html'));
$files2 = (array) array_flip($files2);

foreach ($files2 as $key => &$path)
Expand Down
13 changes: 7 additions & 6 deletions src/administrator/components/com_kunena/models/tools.php
Expand Up @@ -15,6 +15,7 @@
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Filesystem\Folder;

jimport('joomla.application.component.model');
require_once __DIR__ . '/cpanel.php';
Expand Down Expand Up @@ -327,7 +328,7 @@ protected function getReportData()
}
else
{
$this->mbstring = '[u]mbstring:[/u] [color=#FF0000]Not installed[/color]';
$this->mbstring = '[u]mbstring:[/u] � [color=#FF0000]Not installed[/color]';
}

if (extension_loaded('gd'))
Expand All @@ -337,7 +338,7 @@ protected function getReportData()
}
else
{
$this->gd_support = '[u]GD:[/u] [color=#FF0000]Not installed[/color]';
$this->gd_support = '[u]GD:[/u] � [color=#FF0000]Not installed[/color]';
}

$this->maxExecTime = ini_get('max_execution_time');
Expand Down Expand Up @@ -608,7 +609,7 @@ protected function _getTablesCollation()
{
if (!empty($row->Collation) && !preg_match('`utf8`', $row->Collation))
{
$collation .= $table . ' [color=#FF0000]have wrong collation of type ' . $row->Collation . ' [/color] on field ' . $row->Field . ' ';
$collation .= $table . ' � [color=#FF0000]have wrong collation of type ' . $row->Collation . ' [/color] on field ' . $row->Field . ' ';
}
}
}
Expand All @@ -618,7 +619,7 @@ protected function _getTablesCollation()
{
if (!empty($row->Collation) && !preg_match('`utf8`', $row->Collation))
{
$collation .= $table . ' [color=#FF0000]have wrong collation of type ' . $row->Collation . ' [/color] on field ' . $row->Field . ' ';
$collation .= $table . ' � [color=#FF0000]have wrong collation of type ' . $row->Collation . ' [/color] on field ' . $row->Field . ' ';
}
}
}
Expand All @@ -628,7 +629,7 @@ protected function _getTablesCollation()

if (empty($collation))
{
$collation = ' The collation of your table fields are correct';
$collation = '✔ The collation of your table fields are correct';
}

return $collation;
Expand Down Expand Up @@ -742,7 +743,7 @@ public function findExtensionVersion($path)
elseif (is_dir($path))
{
// Get an array of all the XML files from the directory
$xmlfiles = KunenaFolder::files($path, '\.xml$', 1, true);
$xmlfiles = Folder::files($path, '\.xml$', 1, true);
}

$version = null;
Expand Down
Expand Up @@ -14,6 +14,7 @@
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Filesystem\Folder;

/**
* Class ComponentKunenaControllerUserEditAvatarDisplay
Expand Down Expand Up @@ -126,7 +127,7 @@ protected function getGalleries($path)
}

// TODO: Allow recursive paths.
$folders = KunenaFolder::folders($path);
$folders = Folder::folders($path);

foreach ($folders as $folder)
{
Expand Down Expand Up @@ -154,7 +155,7 @@ protected function getGalleries($path)
*/
protected function getGallery($path)
{
return KunenaFolder::files($path, $this->imageFilter);
return Folder::files($path, $this->imageFilter);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/components/com_kunena/controllers/user.php
Expand Up @@ -20,6 +20,7 @@
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;

/**
* Kunena User Controller
Expand Down Expand Up @@ -1065,7 +1066,7 @@ protected function deleteOldAvatars()
// Delete old uploaded avatars:
if (is_dir(KPATH_MEDIA . '/avatars/resized'))
{
$deletelist = KunenaFolder::folders(KPATH_MEDIA . '/avatars/resized', '.', false, true);
$deletelist = Folder::folders(KPATH_MEDIA . '/avatars/resized', '.', false, true);

foreach ($deletelist as $delete)
{
Expand Down
3 changes: 2 additions & 1 deletion src/components/com_kunena/layout/topic/edit/editor.php
Expand Up @@ -12,6 +12,7 @@

use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Filesystem\Folder;

/**
* KunenaLayoutTopicEditEditor
Expand Down Expand Up @@ -46,7 +47,7 @@ public function getCodeTypes()
continue;
}

$files = KunenaFolder::files($path, ".php");
$files = Folder::files($path, ".php");
$options = array();
$options[] = HTMLHelper::_('select.option', '', Text::_('COM_KUNENA_EDITOR_CODE_TYPE'));

Expand Down
3 changes: 2 additions & 1 deletion src/components/com_kunena/layout/widget/editor.php
Expand Up @@ -12,6 +12,7 @@

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Filesystem\Folder;

/**
* KunenaLayoutTopicEditEditor
Expand Down Expand Up @@ -48,7 +49,7 @@ public function getCodeTypes()
continue;
}

$files = KunenaFolder::files($path, ".php");
$files = Folder::files($path, ".php");
$options = array();
$options[] = HTMLHelper::_('select.option', '', Text::_('COM_KUNENA_EDITOR_CODE_TYPE'));

Expand Down
2 changes: 1 addition & 1 deletion src/libraries/kunena/attachment/attachment.php
Expand Up @@ -754,7 +754,7 @@ public function saveFile($source, $basename = null, $extension = null, $unlink =
}

// Create target directory if it does not exist.
if (!KunenaFolder::exists(JPATH_ROOT . "/{$this->folder}") && !KunenaFolder::create(JPATH_ROOT . "/{$this->folder}"))
if (!Folder::exists(JPATH_ROOT . "/{$this->folder}") && !Folder::create(JPATH_ROOT . "/{$this->folder}"))
{
throw new RuntimeException(Text::_('Failed to create attachment directory.'));
}
Expand Down
9 changes: 5 additions & 4 deletions src/libraries/kunena/cache/helper.php
Expand Up @@ -11,6 +11,7 @@
defined('_JEXEC') or die();

use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\Folder;

/**
* Class KunenaCacheHelper has helper functions to clear all caches that affects Kunena.
Expand Down Expand Up @@ -96,10 +97,10 @@ public static function clearCacheFiles()

if (is_dir($cacheDir))
{
KunenaFolder::delete($cacheDir);
Folder::delete($cacheDir);
}

KunenaFolder::create($cacheDir);
Folder::create($cacheDir);
}

/**
Expand All @@ -114,10 +115,10 @@ public static function clearTemplateFiles()

if (is_dir($cacheDir))
{
KunenaFolder::delete($cacheDir);
Folder::delete($cacheDir);
}

KunenaFolder::create($cacheDir);
Folder::create($cacheDir);
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/libraries/kunena/file/file.php
Expand Up @@ -10,15 +10,12 @@
**/
defined('_JEXEC') or die;

jimport('joomla.filesystem.file');

/**
* Class KunenaFile
*
* @see JFile
* @since Kunena
*/
class KunenaFile extends JFile
class KunenaFile
{
/**
* @param string $file file
Expand Down
3 changes: 2 additions & 1 deletion src/libraries/kunena/image/helper.php
Expand Up @@ -11,6 +11,7 @@
defined('_JEXEC') or die;

use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;

/**
* Helper class for image manipulation.
Expand Down Expand Up @@ -38,7 +39,7 @@ public static function version($file, $folder, $filename, $maxWidth = 800, $maxH
try
{
// Create target directory if it does not exist.
if (!KunenaFolder::exists($folder) && !KunenaFolder::create($folder))
if (!Folder::exists($folder) && !Folder::create($folder))
{
return false;
}
Expand Down
3 changes: 2 additions & 1 deletion src/libraries/kunena/template/helper.php
Expand Up @@ -11,6 +11,7 @@
defined('_JEXEC') or die();

use Joomla\CMS\Language\Text;
use Joomla\CMS\Filesystem\Folder;

/**
* Kunena Template Helper Class
Expand Down Expand Up @@ -74,7 +75,7 @@ public static function parseXmlFiles($templateBaseDir = null)
return array('' => $data);
}

$templateDirs = KunenaFolder::folders($templateBaseDir);
$templateDirs = Folder::folders($templateBaseDir);
$rows = array();

// Check that the directory contains an xml file
Expand Down
11 changes: 6 additions & 5 deletions src/libraries/kunena/template/template.php
Expand Up @@ -19,6 +19,7 @@
use Leafo\ScssPhp\Compiler;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;

jimport('joomla.html.parameter');

Expand Down Expand Up @@ -909,7 +910,7 @@ public function clearCache()

if (is_dir($path))
{
KunenaFolder::delete($path);
Folder::delete($path);
}
}

Expand Down Expand Up @@ -1741,7 +1742,7 @@ public function compileLess($inputFile, $outputFile)

if (!is_dir($cacheDir))
{
KunenaFolder::create($cacheDir);
Folder::create($cacheDir);
}

$cacheFile = "{$cacheDir}/kunena.{$this->name}.{$inputFile}.cache";
Expand All @@ -1759,7 +1760,7 @@ public function compileLess($inputFile, $outputFile)

if (!is_dir($outputDir))
{
KunenaFolder::create($outputDir);
Folder::create($outputDir);
}

$outputFile = "{$outputDir}/{$outputFile}";
Expand Down Expand Up @@ -1801,7 +1802,7 @@ public function compileScss($inputFile, $outputFile)

if (!is_dir($cacheDir))
{
KunenaFolder::create($cacheDir);
Folder::create($cacheDir);
}

$cacheFile = "{$cacheDir}/kunena.{$this->name}.{$inputFile}.cache";
Expand All @@ -1819,7 +1820,7 @@ public function compileScss($inputFile, $outputFile)

if (!is_dir($outputDir))
{
KunenaFolder::create($outputDir);
Folder::create($outputDir);
}

$outputFile = "{$outputDir}/{$outputFile}";
Expand Down

0 comments on commit f44c06b

Please sign in to comment.