@@ -205,9 +205,10 @@ protected function load_core_files()
*/
public function load($path)
{
$loaded = $this->_loadLanguage($path, $this->language . '.ini');
$loaded = $this->loadLanguage($path, $this->language . '.ini');
if ($loaded === false) {
Services::Debug()->set('LanguageServices: cannot load file: ' . $path . '/' . $this->language . '.ini');
Services::Debug()->set('LanguageServices: cannot load file: '
. $path . '/' . $this->language . '.ini');
} else {
return true;
}
@@ -217,9 +218,10 @@ public function load($path)
return false;
}

$loaded = $this->_loadLanguage($path, $default . '.ini');
$loaded = $this->loadLanguage($path, $default . '.ini');
if ($loaded === false) {
Services::Debug()->set('LanguageServices 2: cannot load default language file: ' . $path . '/' . $default . '.ini');
Services::Debug()->set('LanguageServices 2: cannot load default language file: '
. $path . '/' . $default . '.ini');
return false;
}
return $loaded;
@@ -280,7 +282,7 @@ public function translate($key)
}

/**
* _loadLanguage
* loadLanguage
*
* Parses standard and override language files and merges strings
*
@@ -289,7 +291,7 @@ public function translate($key)
* @return boolean
* @since 1.0
*/
protected function _loadLanguage($path, $file)
protected function loadLanguage($path, $file)
{
$filename = $path . '/' . $file;

@@ -299,7 +301,7 @@ protected function _loadLanguage($path, $file)
}

if (file_exists($filename)) {
$strings = $this->_parse($filename);
$strings = $this->parse($filename);
$this->loaded_files[$filename] = true;
} else {
$strings = array();
@@ -310,7 +312,7 @@ protected function _loadLanguage($path, $file)
$filename = $path . '/' . $this->language . '.override.ini';

if (file_exists($filename)) {
$override_strings = $this->_parse($filename);
$override_strings = $this->parse($filename);
$this->loaded_files[$filename] = true;
} else {
$override_strings = array();
@@ -354,7 +356,7 @@ protected function _loadLanguage($path, $file)
}

/**
* _parse
* parse
*
* Parses a language file.
*
@@ -363,7 +365,7 @@ protected function _loadLanguage($path, $file)
* @return array The array of parsed strings.
* @since 1.0
*/
protected function _parse($filename)
protected function parse($filename)
{
/** capture php errors during parsing */
$track_errors = ini_get('track_errors');
@@ -299,7 +299,11 @@ protected function processInput()
}
if ($attachment === false || $attachment == '') {
} else {
$this->mailInstance->AddAttachment($attachment, $name = 'Attachment', $encoding = 'base64', $type = 'application/octet-stream');
$this->mailInstance->AddAttachment(
$attachment,
$name = 'Attachment',
$encoding = 'base64',
$type = 'application/octet-stream');
}

return true;
@@ -35,6 +35,47 @@
*/
public $model;


/**
* Module Name
*
* @var string
* @since 1.0
*/
public $model_name;

/**
* Table Name
*
* @var string
* @since 1.0
*/
public $table_name;

/**
* Table XML
*
* @var object
* @since 1.0
*/
public $table_xml;

/**
* Primary Key
*
* @var integer
* @since 1.0
*/
public $primary_key;

/**
* DB Driver
*
* @var integer
* @since 1.0
*/
public $dbDriver;

/**
* Valid Query Object values
*
@@ -87,7 +128,12 @@ public static function getInstance()
}

/**
* Retrieve Table Definitions, create a model instance, and set model properties
* Prepares data needed for the model
*
* Single-table queries - retrieve Table Definitions, create a model instance, and sets model properties
* examples include User, Site Application, and Authorisation queries
*
* More complex queries
*
* @param string $table
*
@@ -96,30 +142,32 @@ public static function getInstance()
* @since 1.0
* @throws \RuntimeException
*/
public function connect ($table = 'Content')
public function connect ($table = null)
{

/** 1. Get definition file for table */
$table_xml = Services::Registry()->loadFile($table, 'Table');
$this->table_xml = Services::Registry()->loadFile($table, 'Table');

$model_name = (string)$table_xml['name'];
if ($model_name == '') {
$this->model_name = (string)$this->table_xml['name'];
if ($this->model_name == '') {
throw new \RuntimeException('No model name for table: ' . $table);
}

$table_name = (string)$table_xml['table'];
if ($table_name == '') {
$table_name = '#__content';
$this->table_name = (string)$this->table_xml['table'];
if ($this->table_name == '') {
$this->table_name = '#__content';
}

$primary_key = (string)$table_xml['primary_key'];
if ($primary_key === '') {
$primary_key = 'id';
$this->primary_key = (string)$this->table_xml['primary_key'];
if ($this->primary_key === '') {
$this->primary_key = 'id';
}

$dbDriver = (string)$table_xml['db'];
if ($dbDriver === '') {
$dbDriver = $this->default_dbDriver;
$this->dbDriver = (string)$this->table_xml['db'];
if ($this->dbDriver === '') {
$this->dbDriver = $this->default_dbDriver;
}
$dbo = $this->dbDriver;

/* 2. Instantiate Model Class */
$modelClass = 'Molajo\\MVC\\Model\\TableModel';
@@ -132,20 +180,21 @@ public function connect ($table = 'Content')
}

/** 3. Model Properties */
$this->model->set('model_name', $model_name);
$this->model->set('table', $table_name);
$this->model->set('table_xml', $table_xml);
$this->model->set('primary_key', $primary_key);
$this->model->set('model_name', $this->model_name);
$this->model->set('table', $this->table_name);
$this->model->set('table_xml', $this->table_xml);
$this->model->set('primary_key', $this->primary_key);
$this->model->set('primary_prefix', 'a');

$this->model->set('db', Services::$dbDriver()->get('db'));
$this->model->set('query', Services::$dbDriver()->getQuery());
$this->model->set('nullDate', Services::$dbDriver()->get('db')->getNullDate());
$this->model->set('now', Services::$dbDriver()->get('db')->getDateFormat());
/** 4. DB Properties */
$this->model->set('db', Services::$dbo()->get('db'));
$this->model->set('query', Services::$dbo()->getQuery());
$this->model->set('nullDate', Services::$dbo()->get('db')->getNullDate());
$this->model->set('now', Services::$dbo()->get('db')->getDateFormat());
$this->model->set('query_results', array());
$this->model->set('pagination', array());

Services::$dbDriver()->getQuery()->clear();
Services::$dbo()->getQuery()->clear();

return $this;
}
@@ -24,7 +24,7 @@
Class RedirectService
{
/**
* Response instance
* Instance
*
* @var object
* @since 1.0
@@ -34,16 +34,16 @@
/**
* $url
*
* @var string
* @since 1.0
* @var string
* @since 1.0
*/
public $url = null;

/**
* $code
*
* @var integer
* @since 1.0
* @var integer
* @since 1.0
*/
public $code = 0;

@@ -52,6 +52,7 @@
*
* @static
* @return object
*
* @since 1.0
*/
public static function getInstance($content = '', $status = 200, $headers = array())
@@ -63,12 +64,15 @@ public static function getInstance($content = '', $status = 200, $headers = arra
}

/**
* set
* Set the Redirect URL and Code
*
* @param null $url
*
* @param $code
*
* @param null $url
* @param $code
* @return mixed
* @since 1.0
*
* @since 1.0
*/
public function set($url = null, $code = 302)
{
@@ -84,13 +88,9 @@ public function set($url = null, $code = 302)
if (Services::Registry()->get('Configuration', 'sef', 1) == 1) {

if (Services::Registry()->get('Configuration', 'sef_rewrite', 0) == 0) {
$url = BASE_URL
. APPLICATION_URL_PATH
. 'index.php/' . $url;
$url = BASE_URL . APPLICATION_URL_PATH . 'index.php/' . $url;
} else {
$url = BASE_URL
. APPLICATION_URL_PATH
. $url;
$url = BASE_URL . APPLICATION_URL_PATH . $url;
}

if ((int)Services::Registry()->get('Configuration', 'sef_suffix', 0) == 1) {
@@ -191,7 +191,7 @@ public function get($namespace, $key = null, $default = null)
*/
public function set($namespace, $key, $value = '')
{
/** keep it all on the downlow */
/** keep it all on the down-low */
$key = strtolower($key);

/** Get the Registry (or create it) */
@@ -479,7 +479,6 @@ public static function loadFile($file, $type = 'Application')
return simplexml_load_file($path_and_file);

} catch (\Exception $e) {

throw new \RuntimeException ('Failure reading XML File: ' . $path_and_file . ' ' . $e->getMessage());
}
}
@@ -499,6 +498,7 @@ protected function getRegistry($namespace)
{
if (in_array($namespace, $this->registryKeys)) {
return $this->registry[$namespace];

} else {
return $this->createRegistry($namespace);
}
@@ -6,11 +6,12 @@
*/
namespace Molajo\Service\Services;

defined('MOLAJO') or die;

use Molajo\Service\Services;

use Symfony\Component\HttpFoundation\Response;

defined('MOLAJO') or die;

/**
* Response
*
@@ -33,23 +34,24 @@
/**
* $response
*
* @var object
* @since 1.0
* @var object
* @since 1.0
*/
protected $response;

/**
* getInstance
*
* @static
* @return object
* @since 1.0
* @return object
* @since 1.0
*/
public static function getInstance($content = '', $status = 200, $headers = array())
{
if (empty(self::$instance)) {
self::$instance = new ResponseService($content, $status, $headers);
}

return self::$instance;
}

@@ -63,6 +65,7 @@ public static function getInstance($content = '', $status = 200, $headers = arra
public function __construct($content, $status, $headers)
{
$this->response = new Response();

parent::__construct($content, $status, $headers);
}
}
@@ -62,12 +62,15 @@ public function process()
/** Dependency Injection */
if ((int)Services::Registry()->get('Override', 'catalog_id', 0) == 0) {
Services::Registry()->set('Request', 'catalog_id', 0);

} else {
Services::Registry()->set('Request', 'catalog_id',
(int)Services::Registry()->get('Override', 'catalog_id', 0));
}

if (Services::Registry()->get('Override', 'request_url', '') == '') {
$path = PAGE_REQUEST;

} else {
$path = Services::Registry()->get('Override', 'request_url', '');
}
@@ -78,6 +81,7 @@ public function process()
if ($continue == false) {
Services::Debug()->set('Application::Route()->checkHome() Redirect to Real Home');
return false;

} else {
Services::Debug()->set('Application::Route()->checkHome() No Redirect needed');
}
@@ -87,6 +91,7 @@ public function process()
Services::Error()->set(503);
Services::Debug()->set('Application::Route() Direct to Offline Mode');
return true;

} else {
Services::Debug()->set('Application::Route() Not in Offline Mode');
}
@@ -97,6 +102,7 @@ public function process()
if ($continue == false) {
Services::Debug()->set('Application::Route()->getNonRoutableParameters() Failed');
return false;

} else {
Services::Debug()->set('Application::Route()->getNonRoutableParameters() Successful');
}
@@ -108,6 +114,7 @@ public function process()
Services::Registry()->set('Request', 'status_found', false) ;
Services::Debug()->set('Application::Route()->getCatalog() Failed');
return false;

} else {
Services::Registry()->set('Request', 'status_found', true) ;
Services::Debug()->set('Application::Route()->getCatalog() Successful');

This file was deleted.