@@ -4,9 +4,10 @@
* @copyright Copyright (C) 2012 Amy Stephen. All rights reserved.
* @license GNU General Public License Version 2, or later http://www.gnu.org/licenses/gpl.html
*/

namespace Molajo\Application\Service;

use Molajo\Application\Services; // Registry, Folder, User
use Molajo\Application\Services;

defined('MOLAJO') or die;
/**
@@ -21,12 +22,12 @@
/**
* Instance of each specific language
*
* $_languages
* $languages
*
* @var array
* @since 1.0
*/
protected static $_languages = array();
protected static $languages = array();

/**
* Language
@@ -101,7 +102,7 @@
protected $loaded_strings;

/**
* Overrides loaded
* :paOverrides loaded
*
* @var array
* @since 1.0
@@ -120,11 +121,11 @@
*/
public static function getInstance($language = null)
{
if (isset(self::$_languages[$language])) {
if (isset(self::$languages[$language])) {
} else {
self::$_languages[$language] = new LanguageService($language);
self::$languages[$language] = new LanguageService($language);
}
return self::$_languages[$language];
return self::$languages[$language];
}

/**
@@ -140,6 +141,7 @@ protected function __construct($language = null)
if ($language == null || $language == '') {
$language = $this->getDefault();
}

$this->language = $language;
$this->loaded_override_strings = array();
$this->loaded_strings = array();
@@ -399,9 +401,7 @@ protected function _parse($filename)
public function getDefault()
{
/** Installed Languages */
$languages = $this->getLanguages(
EXTENSIONS_LANGUAGES
);
$languages = $this->getLanguages(EXTENSIONS_LANGUAGES);

$installed = array();
foreach ($languages as $language) {
@@ -115,7 +115,7 @@ public function startServices()
/** class name */
$entry = (string)$item . 'Service';
$serviceClass = 'Molajo\\Application\\Service\\' . $entry;

echo $serviceClass.'<br />';
/** method name */
$serviceMethod = 'getInstance';

@@ -50,7 +50,7 @@ public function __construct()
{
if (!is_callable('mcrypt_encrypt'))
{
throw new RuntimeException('The mcrypt extension is not available.');
throw new \RuntimeException('The mcrypt extension is not available.');
}
}

@@ -69,7 +69,7 @@ public function decrypt($data, JCryptKey $key)
// Validate key.
if ($key->type != $this->keyType)
{
throw new InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected ' . $this->keyType . '.');
throw new \InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected ' . $this->keyType . '.');
}

// Decrypt the data.
@@ -93,7 +93,7 @@ public function encrypt($data, JCryptKey $key)
// Validate key.
if ($key->type != $this->keyType)
{
throw new InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected ' . $this->keyType . '.');
throw new \InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected ' . $this->keyType . '.');
}

// Encrypt the data.
@@ -36,7 +36,7 @@ public function decrypt($data, JCryptKey $key)
// Validate key.
if ($key->type != 'simple')
{
throw new InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected simple.');
throw new \InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected simple.');
}

// Initialise variables.
@@ -78,7 +78,7 @@ public function encrypt($data, JCryptKey $key)
// Validate key.
if ($key->type != 'simple')
{
throw new InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected simple.');
throw new \InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected simple.');
}

// Initialise variables.
@@ -9,7 +9,7 @@

namespace Joomla\filesystem;

use Joomla\log\JFile;
use Joomla\log\JLog;

defined('JPATH_PLATFORM') or die;

@@ -7,10 +7,9 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/

defined('JPATH_PLATFORM') or die;
namespace Joomla\filesystem;

jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
defined('JPATH_PLATFORM') or die;

/**
* File system helper
@@ -7,10 +7,11 @@
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\filesystem;

defined('JPATH_PLATFORM') or die;
use Joomla\log\JLog;

jimport('joomla.filesystem.file');
defined('JPATH_PLATFORM') or die;

/**
* A Unified Diff Format Patcher class
@@ -161,7 +162,7 @@ public function apply()
// If no modifications were found, throw an exception
if (!$done)
{
throw new RuntimeException('Invalid Diff');
throw new \RuntimeException('Invalid Diff');
}
}
}
@@ -294,13 +295,13 @@ protected static function findHeader(&$lines, &$src, &$dst)
$line = next($lines);
if ($line === false)
{
throw new RuntimeException('Unexpected EOF');
throw new \RuntimeException('Unexpected EOF');
}

// Search the destination file
if (!preg_match(self::DST_FILE, $line, $m))
{
throw new RuntimeException('Invalid Diff file');
throw new \RuntimeException('Invalid Diff file');
}

// Set the destination file
@@ -309,7 +310,7 @@ protected static function findHeader(&$lines, &$src, &$dst)
// Advance to the next line
if (next($lines) === false)
{
throw new RuntimeException('Unexpected EOF');
throw new \RuntimeException('Unexpected EOF');
}
return true;
}
@@ -357,7 +358,7 @@ protected static function findHunk(&$lines, &$src_line, &$src_size, &$dst_line,

if (next($lines) === false)
{
throw new RuntimeException('Unexpected EOF');
throw new \RuntimeException('Unexpected EOF');
}

return true;
@@ -409,7 +410,7 @@ protected function applyHunk(&$lines, $src, $dst, $src_line, $src_size, $dst_lin
{
if ($src_left == 0)
{
throw new RuntimeException(JText::sprintf('JLIB_FILESYSTEM_PATCHER_REMOVE_LINE', key($lines)));
throw new \RuntimeException(JText::sprintf('JLIB_FILESYSTEM_PATCHER_REMOVE_LINE', key($lines)));
}
$source[] = substr($line, 1);
$src_left--;
@@ -418,7 +419,7 @@ protected function applyHunk(&$lines, $src, $dst, $src_line, $src_size, $dst_lin
{
if ($dst_left == 0)
{
throw new RuntimeException(JText::sprintf('JLIB_FILESYSTEM_PATCHER_ADD_LINE', key($lines)));
throw new \RuntimeException(JText::sprintf('JLIB_FILESYSTEM_PATCHER_ADD_LINE', key($lines)));
}
$destin[] = substr($line, 1);
$dst_left--;
@@ -440,7 +441,7 @@ protected function applyHunk(&$lines, $src, $dst, $src_line, $src_size, $dst_lin
$src_lines = & $this->getSource($src);
if (!isset($src_lines))
{
throw new RuntimeException(JText::sprintf('JLIB_FILESYSTEM_PATCHER_UNEXISING_SOURCE', $src));
throw new \RuntimeException(JText::sprintf('JLIB_FILESYSTEM_PATCHER_UNEXISING_SOURCE', $src));
}
}
if ($dst_size > 0)
@@ -454,7 +455,7 @@ protected function applyHunk(&$lines, $src, $dst, $src_line, $src_size, $dst_lin
{
if ($src_lines[$l] != $source[$l - $src_line])
{
throw new RuntimeException(JText::sprintf('JLIB_FILESYSTEM_PATCHER_FAILED_VERIFY', $src, $l));
throw new \RuntimeException(JText::sprintf('JLIB_FILESYSTEM_PATCHER_FAILED_VERIFY', $src, $l));
}
}
array_splice($dst_lines, $dst_line, count($source), $destin);
@@ -474,7 +475,7 @@ protected function applyHunk(&$lines, $src, $dst, $src_line, $src_size, $dst_lin
$line = next($lines);
}
while ($line !== false);
throw new RuntimeException('Unexpected EOF');
throw new \RuntimeException('Unexpected EOF');
}

/**
@@ -7,9 +7,11 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/

defined('JPATH_PLATFORM') or die;
namespace Joomla\filesystem;

use Joomla\log\JLog;

jimport('joomla.filesystem.path');
defined('JPATH_PLATFORM') or die;

/**
* A Folder handling class
@@ -53,17 +55,17 @@ public static function copy($src, $dest, $path = '', $force = false, $use_stream

if (!self::exists($src))
{
throw new RuntimeException('Source folder not found', -1);
throw new \RuntimeException('Source folder not found', -1);
}
if (self::exists($dest) && !$force)
{
throw new RuntimeException('Destination folder not found', -1);
throw new \RuntimeException('Destination folder not found', -1);
}

// Make sure the destination exists
if (!self::create($dest))
{
throw new RuntimeException('Cannot create destination folder', -1);
throw new \RuntimeException('Cannot create destination folder', -1);
}

// If we're using ftp and don't have streams enabled
@@ -74,7 +76,7 @@ public static function copy($src, $dest, $path = '', $force = false, $use_stream

if (!($dh = @opendir($src)))
{
throw new RuntimeException('Cannot open source folder', -1);
throw new \RuntimeException('Cannot open source folder', -1);
}
// Walk through the directory copying files and recursing into folders.
while (($file = readdir($dh)) !== false)
@@ -99,7 +101,7 @@ public static function copy($src, $dest, $path = '', $force = false, $use_stream
$dfid = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $dfid), '/');
if (!$ftp->store($sfid, $dfid))
{
throw new RuntimeException('Copy file failed', -1);
throw new \RuntimeException('Copy file failed', -1);
}
break;
}
@@ -109,7 +111,7 @@ public static function copy($src, $dest, $path = '', $force = false, $use_stream
{
if (!($dh = @opendir($src)))
{
throw new RuntimeException('Cannot open source folder', -1);
throw new \RuntimeException('Cannot open source folder', -1);
}
// Walk through the directory copying files and recursing into folders.
while (($file = readdir($dh)) !== false)
@@ -135,14 +137,14 @@ public static function copy($src, $dest, $path = '', $force = false, $use_stream
$stream = JFactory::getStream();
if (!$stream->copy($sfid, $dfid))
{
throw new RuntimeException('Cannot copy file: ' . $stream->getError(), -1);
throw new \RuntimeException('Cannot copy file: ' . $stream->getError(), -1);
}
}
else
{
if (!@copy($sfid, $dfid))
{
throw new RuntimeException('Copy file failed', -1);
throw new \RuntimeException('Copy file failed', -1);
}
}
break;
@@ -324,7 +326,6 @@ public static function delete($path)
if (is_link($folder))
{
// Don't descend into linked directories, just delete the link.
jimport('joomla.filesystem.file');
if (JFile::delete($folder) !== true)
{
// JFile::delete throws an error
@@ -7,6 +7,8 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/

namespace Joomla\filesystem;

defined('JPATH_PLATFORM') or die;

// Define a boolean constant as true if a Windows based host
@@ -169,14 +171,14 @@ public static function check($path, $ds = DIRECTORY_SEPARATOR)
if (strpos($path, '..') !== false)
{
// Don't translate
throw new Exception('JPath::check Use of relative paths not permitted', 20);
throw new \Exception('JPath::check Use of relative paths not permitted', 20);
}

$path = self::clean($path);
if ((JPATH_ROOT != '') && strpos($path, self::clean(JPATH_ROOT)) !== 0)
{
// Don't translate
throw new Exception('JPath::check Snooping out of bounds @ ' . $path, 20);
throw new \Exception('JPath::check Snooping out of bounds @ ' . $path, 20);
}

return $path;
@@ -220,7 +222,6 @@ public static function clean($path, $ds = DIRECTORY_SEPARATOR)
*/
public static function isOwner($path)
{
jimport('joomla.filesystem.file');

$tmp = md5(mt_rand());
$ssp = ini_get('session.save_path');
@@ -264,7 +265,7 @@ public static function isOwner($path)
public static function find($paths, $file)
{
// Force to array
if (!is_array($paths) && !($paths instanceof Iterator))
if (!is_array($paths) && !($paths instanceof \Iterator))
{
settype($paths, 'array');
}
@@ -7,6 +7,11 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/

namespace Joomla\filesystem;

use Joomla\log\JLog;
use Joomla\object\JObject;

defined('JPATH_PLATFORM') or die;

/**
@@ -7,9 +7,11 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/

defined('JPATH_PLATFORM') or die;
namespace Joomla\filesystem\streams;

use Joomla\filesystem\support\JStringController;

jimport('joomla.filesystem.support.stringcontroller');
defined('JPATH_PLATFORM') or die;

/**
* String Stream Wrapper
@@ -7,6 +7,8 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/

namespace Joomla\filesystem\support;

defined('JPATH_PLATFORM') or die;

/**
@@ -1,7 +1,11 @@
/**
* Molajo Hacks
*
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
Added namespaces to all classes.
Added use statements for all classes used in the class.
Commented out all JImports, JLoader, includes, requires, imports, etc.
Changed all stdClass to /stdClass.
Added class file to each class that matched the file name and extended the JClass name.
Commented out all JLog deprecation statements (those methods are not used.)
Removed all JText::_() calls and simply allowed the untranslated error to return (uncouple translation)
Changed all PHP classes to default (ex. stdClass to /stdClass, Exception to /Exception, etc).
Added phpConsole logger
@@ -3,7 +3,7 @@
/*
* This file is part of the symfony package.
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@@ -133,7 +133,7 @@ public function offsetGet($name)
{
if (!array_key_exists($name, $this->parameters))
{
throw new InvalidArgumentException(sprintf('The event "%s" has no "%s" parameter.', $this->name, $name));
throw new \InvalidArgumentException(sprintf('The event "%s" has no "%s" parameter.', $this->name, $name));
}

return $this->parameters[$name];
@@ -143,7 +143,7 @@ public function offsetGet($name)
* Sets a parameter (implements the ArrayAccess interface).
*
* @param string $name The parameter name
* @param mixed $value The parameter value
* @param mixed $value The parameter value
*/
public function offsetSet($name, $value)
{