Permalink
Browse files

Native File functions added

  • Loading branch information...
1 parent 0eba67c commit 76a9a3e0fb4b85b7c9cb4f210e259e2919053ac0 @kaviththiranga committed Dec 11, 2012
View
20 libraries/joomla/media/collection.php
@@ -88,8 +88,12 @@ public function addFiles($files =array())
foreach ($files as $file)
{
// Check file ext for compatibility
- if (JFile::getExt($file) == $type)
+ if (pathinfo($file, PATHINFO_EXTENSION) == $type)
{
+ if (!file_exists($file))
+ {
+ throw new RuntimeException(sprintf("%s File not exists", $file));
+ }
// Check whether file already registered
if (!in_array($file, $this->sources))
{
@@ -99,7 +103,7 @@ public function addFiles($files =array())
}
else
{
- throw new RuntimeException(sprintf("Multiple File types detected in files array. %s"), $type);
+ throw new RuntimeException(sprintf("Multiple File types detected in files array. %s", $type));
}
}
@@ -121,7 +125,7 @@ public function addFiles($files =array())
public static function combineFiles($files, $options = array(), $destination = null)
{
// Detect file type
- $type = JFile::getExt($files[0]);
+ $type = pathinfo($files[0], PATHINFO_EXTENSION);
if (!self::isSupported($files[0]))
{
@@ -156,9 +160,9 @@ public static function combineFiles($files, $options = array(), $destination = n
{
$force = array_key_exists('OVERWRITE', $options) && !empty($options['OVERWRITE']) ? $options['OVERWRITE'] : false;
- if (!JFile::exists($destination) || (JFile::exists($destination) && $force))
+ if (!file_exists($destination) || (file_exists($destination) && $force))
{
- JFile::write($destination, $combiner->getCombined());
+ file_put_contents($destination, $combiner->getCombined());
return true;
}
else
@@ -211,11 +215,13 @@ public static function getCollectionTypes()
$combiners = array();
// Get a list of types.
- $types = JFolder::files(__DIR__ . '/collection');
+ $types = glob(__DIR__ . '/collection/*');
// Loop through the types and find the ones that are available.
foreach ($types as $type)
{
+ $type = basename($type);
+
// Ignore some files.
if ($type == 'index.html')
{
@@ -317,7 +323,7 @@ public static function isSupported($sourceFile)
foreach ($combiners as $class)
{
- if (strtolower(str_ireplace('JMediaCollection', '', $class)) === strtolower(JFile::getExt($sourceFile)))
+ if (strtolower(str_ireplace('JMediaCollection', '', $class)) === strtolower(pathinfo($sourceFile, PATHINFO_EXTENSION)))
{
return true;
}
View
10 libraries/joomla/media/collection/css.php
@@ -27,7 +27,7 @@ class JMediaCollectionCss extends JMediaCollection
*/
public function __construct($options = array())
{
- $this->options = array('COMPRESS' => false, 'FILE_COMMENTS' => true, 'COMPRESS_OPTIONS' => array());
+ $this->options = array('COMPRESS' => false, 'FILE_COMMENTS' => true, 'COMPRESS_OPTIONS' => array(), 'COMPRESSOR' => null);
parent::__construct($options);
}
@@ -46,7 +46,7 @@ public function combine()
{
if ($this->options['FILE_COMMENTS'])
{
- $this->combined .= '/** File : ' . JFile::getName($file) . ' : Start **/' . "\n\n";
+ $this->combined .= '/** File : ' . basename($file) . ' : Start **/' . "\n\n";
}
if ($this->options['COMPRESS'])
@@ -63,17 +63,17 @@ public function combine()
}
else
{
- $this->combined .= JMediaCompressor::compressString(JFile::read($file), $this->options['COMPRESS_OPTIONS']) . "\n\n";
+ $this->combined .= JMediaCompressor::compressString(file_get_contents($file), $this->options['COMPRESS_OPTIONS']) . "\n\n";
}
}
else
{
- $this->combined .= JFile::read($file) . "\n\n";
+ $this->combined .= file_get_contents($file) . "\n\n";
}
if ($this->options['FILE_COMMENTS'])
{
- $this->combined .= '/** File : ' . JFile::getName($file) . ' : End **/' . "\n\n";
+ $this->combined .= '/** File : ' . basename($file) . ' : End **/' . "\n\n";
}
}
View
10 libraries/joomla/media/collection/js.php
@@ -28,7 +28,7 @@ class JMediaCollectionJs extends JMediaCollection
*/
public function __construct($options = array())
{
- $this->options = array('COMPRESS' => false, 'FILE_COMMENTS' => true, 'COMPRESS_OPTIONS' => array());
+ $this->options = array('COMPRESS' => false, 'FILE_COMMENTS' => true, 'COMPRESS_OPTIONS' => array(), 'COMPRESSOR' => null);
parent::__construct($options);
}
@@ -47,7 +47,7 @@ public function combine()
{
if ($this->options['FILE_COMMENTS'])
{
- $this->combined .= '/** File : ' . JFile::getName($file) . ' : Start **/' . "\n\n";
+ $this->combined .= '/** File : ' . basename($file) . ' : Start **/' . "\n\n";
}
if ($this->options['COMPRESS'])
@@ -64,17 +64,17 @@ public function combine()
}
else
{
- $this->combined .= JMediaCompressor::compressString(JFile::read($file), $this->options['COMPRESS_OPTIONS']) . "\n\n";
+ $this->combined .= JMediaCompressor::compressString(file_get_contents($file), $this->options['COMPRESS_OPTIONS']) . "\n\n";
}
}
else
{
- $this->combined .= JFile::read($file) . "\n\n";
+ $this->combined .= file_get_contents($file) . "\n\n";
}
if ($this->options['FILE_COMMENTS'])
{
- $this->combined .= '/** File : ' . JFile::getName($file) . ' : End **/' . "\n\n";
+ $this->combined .= '/** File : ' . basename($file) . ' : End **/' . "\n\n";
}
}

0 comments on commit 76a9a3e

Please sign in to comment.