CORE UPDATE: Minor update concerning the autoloading class in the core, now it is also possible to give a loading order through the configuration
Minor update concerning the form factory classes in the core, now some javascript events are implemented as well, another update concerning functinoallity will follow soon.
Update on the example configuration file, implementing the autoloading order of interfaces, moduels and traits.
Update for multidatabase support, see the documentation on http://www.nibiru-framework.com
This commit is contained in:
31
README.md
31
README.md
@@ -34,9 +34,10 @@ Engine Implementation.</div>
|
||||
<ul>
|
||||
<li>framework documentation</li>
|
||||
<li>class documentation</li>
|
||||
<li>soap interface to a given SOAP server</li>
|
||||
<li>Dwoo tempalte eninge tests</li>
|
||||
<li>Twig tempalte eninge tests</li>
|
||||
<li>soap interface to a given SOAP server (canceled, not needed to old)</li>
|
||||
<li>bitcoin api, and payment gateway</li>
|
||||
<li>Dwoo tempalte engine tests</li>
|
||||
<li>Twig tempalte engine tests</li>
|
||||
<li>Database access functionallity for the db.php Factory</li>
|
||||
</ul>
|
||||
|
||||
@@ -51,11 +52,13 @@ Engine Implementation.</div>
|
||||
<ul>
|
||||
<li>framework documentation</li>
|
||||
<li>class documentation</li>
|
||||
<li>soap interface to a given SOAP server</li>
|
||||
<li>Dwoo tempalte eninge tests</li>
|
||||
<li>Twig tempalte eninge tests</li>
|
||||
<li>soap interface to a given SOAP server (canceled, not needed to old)</li>
|
||||
<li>bitcoin api, and payment gateway</li>
|
||||
<li>Dwoo tempalte engine tests</li>
|
||||
<li>Twig tempalte engine tests</li>
|
||||
</ul>
|
||||
<h1>Version 0.3 beta 04.02.2018</h1>
|
||||
|
||||
<p>Version 0.3 beta 04.02.2018</p>
|
||||
<ul>
|
||||
<li>Improved: The Router now accepts actions, either trough the _action as parameter, or on the URL pattern after the controller name Example: http://youdomain/[controllername]/[actionname]/</li>
|
||||
<li>It is now possible to load as many navigations on the page as wanted by passing the name to the <br>JsonNavigation::getInstance()->loadJsonNavigationArray('[NAME]'); <br>call in the navigationAction of the Controller</li>
|
||||
@@ -65,7 +68,7 @@ Engine Implementation.</div>
|
||||
</ul>
|
||||
</div>
|
||||
<h1>Previous version</h1>
|
||||
<p>Version 0.3.5 beta 14.03.2018</p>
|
||||
<h1>Version 0.3.5 beta 14.03.2018</h1>
|
||||
<ul>
|
||||
<li>Bugfix on the Router, now the currentPage will be returned correctly.</li>
|
||||
<li>Update for the database adapter, a detailed instruction on how to use it will be within the soon comming documentation</li>
|
||||
@@ -75,15 +78,13 @@ Engine Implementation.</div>
|
||||
</ul>
|
||||
|
||||
<h1>Update</h1>
|
||||
<p>Version 0.4.0 beta 09.07.2018</p>
|
||||
<p>Version 0.4.0 beta 28.08.2018</p>
|
||||
<ul>
|
||||
<li>Bugfix on the form classes, now the select option is correctly set back.</li>
|
||||
<li>Update for the database adapter</li>
|
||||
<li>Improvement of the form elements, added onchange on the select boxes, the form tag now can have no element if needed.</li>
|
||||
<li>Implementation of the Postgres and MySQL Adapter with proper Namespacing.</li>
|
||||
<li>Minor bugfixing</li>
|
||||
<li>Minor update concerning the autoloading class in the core, now it is also possible to give a loading order through the configuration</li>
|
||||
<li>Minor update concerning the form factory classes in the core, now some javascript events are implemented as well, another update concerning functinoallity will follow soon.</li>
|
||||
<li>Update on the example configuration file, implementing the autoloading order of interfaces, moduels and traits.</li>
|
||||
<li>Update for multidatabase support, see the documentation on http://www.nibiru-framework.com</li>
|
||||
</ul>
|
||||
|
||||
<div style="word-spacing: 2px; letter-spacing: 0.1px; font-size: 15px; margin-bottom: 15px;">The start is done, have success with PHP prototyping, and always remember to have fun!</div>
|
||||
|
||||
Author: Stephan Kasdorf<br><br>
|
||||
16
application/interfaces/users.php
Normal file
16
application/interfaces/users.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace Nibiru\Adapter;
|
||||
/**
|
||||
* @desc this file is for the autoloader to function properly,
|
||||
* you might as well use it as the primary user interface for your
|
||||
* application
|
||||
* Created by PhpStorm.
|
||||
* User: kasdorf
|
||||
* Date: 28.08.18
|
||||
* Time: 11:21
|
||||
*/
|
||||
|
||||
interface Users
|
||||
{
|
||||
|
||||
}
|
||||
18
application/module/users.php
Normal file
18
application/module/users.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace Nibiru\Module;
|
||||
/**
|
||||
* @desc this file is for the autoloader to function properly,
|
||||
* you might as well use it as the primary user class for your
|
||||
* application, the interface an the trait are currently implemented
|
||||
* Created by PhpStorm.
|
||||
* User: kasdorf
|
||||
* Date: 28.08.18
|
||||
* Time: 11:22
|
||||
*/
|
||||
use Nibiru\Adapter;
|
||||
use Nibiru\Messages;
|
||||
|
||||
class Users implements Adapter\Users
|
||||
{
|
||||
use Messages\Users;
|
||||
}
|
||||
@@ -9,6 +9,11 @@ config_dir = "/../../application/view/configs/"
|
||||
class_file = "core/l/Smarty/Smarty.class.php"
|
||||
debugbar = false
|
||||
|
||||
[AUTOLOADER]
|
||||
class.pos[] = "users"
|
||||
trait.pos[] = "users"
|
||||
iface.pos[] = "users"
|
||||
|
||||
[EMAIL]
|
||||
register.smtp = 1
|
||||
register.smtp[password] = "YOURPASSWORD"
|
||||
@@ -21,25 +26,27 @@ register.subject = "YOURSUBJECTLINE"
|
||||
register.text = "PATHTOYOURHTMLTEMPLATE"
|
||||
|
||||
[SETTINGS]
|
||||
pageurl = "YOURPAGEURLWITHPROTOCOL"
|
||||
navigation = "navigation.json"
|
||||
dbmodel = "/../../application/model/"
|
||||
module = "/../../application/module/"
|
||||
background.img[] = "public/img/nibiru3.jpg"
|
||||
smarty.css[] = "public/css/v3/roboto.css"
|
||||
smarty.css[] = "public/css/v3/toolkit-inverse.css"
|
||||
smarty.css[] = "public/css/v3/application.css"
|
||||
smarty.css[] = "public/css/v3/jquery-ui.css"
|
||||
smarty.css[] = "public/css/v3/nibiru-debug.css"
|
||||
smarty.css[] = "public/css/v3/tiamat-form.css"
|
||||
smarty.js[] = "public/js/v3/jquery.min.js"
|
||||
smarty.js[] = "public/js/v3/tether.min.js"
|
||||
smarty.js[] = "public/js/v3/jquery-ui.js"
|
||||
smarty.js[] = "public/js/v3/chart.js"
|
||||
smarty.js[] = "public/js/v3/tablesorter.min.js"
|
||||
smarty.js[] = "public/js/v3/toolkit.js"
|
||||
smarty.js[] = "public/js/v3/application.js"
|
||||
smarty.js[] = "public/js/v3/nibiru-debug.js"
|
||||
pageurl = "YOURPAGEURLWITHPROTOCOL"
|
||||
navigation = "navigation.json"
|
||||
dbmodel = "/../../application/model/"
|
||||
module = "/../../application/module/"
|
||||
interfaces = "/../../application/interfaces/"
|
||||
trait = "/../../application/trait/"
|
||||
background.img[] = "public/img/nibiru3.jpg"
|
||||
smarty.css[] = "public/css/v3/roboto.css"
|
||||
smarty.css[] = "public/css/v3/toolkit-inverse.css"
|
||||
smarty.css[] = "public/css/v3/application.css"
|
||||
smarty.css[] = "public/css/v3/jquery-ui.css"
|
||||
smarty.css[] = "public/css/v3/nibiru-debug.css"
|
||||
smarty.css[] = "public/css/v3/tiamat-form.css"
|
||||
smarty.js[] = "public/js/v3/jquery.min.js"
|
||||
smarty.js[] = "public/js/v3/tether.min.js"
|
||||
smarty.js[] = "public/js/v3/jquery-ui.js"
|
||||
smarty.js[] = "public/js/v3/chart.js"
|
||||
smarty.js[] = "public/js/v3/tablesorter.min.js"
|
||||
smarty.js[] = "public/js/v3/toolkit.js"
|
||||
smarty.js[] = "public/js/v3/application.js"
|
||||
smarty.js[] = "public/js/v3/nibiru-debug.js"
|
||||
|
||||
[ROUTING]
|
||||
route[index] = "/"
|
||||
|
||||
16
application/trait/users.php
Normal file
16
application/trait/users.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace Nibiru\Messages;
|
||||
/**
|
||||
* @desc this file is for the autoloader to function properly,
|
||||
* you might as well use it as the primary user trait for your
|
||||
* application
|
||||
* Created by PhpStorm.
|
||||
* User: kasdorf
|
||||
* Date: 28.08.18
|
||||
* Time: 11:24
|
||||
*/
|
||||
|
||||
trait Users
|
||||
{
|
||||
|
||||
}
|
||||
@@ -12,25 +12,114 @@ require_once __DIR__ . '/../i/db.php';
|
||||
*/
|
||||
class Autoloader
|
||||
{
|
||||
const MY_FILE_NAME = "autoloader.php";
|
||||
const DB_MODEL_FOLDER = "dbmodel";
|
||||
const MODULE_FOLDER = "module";
|
||||
|
||||
const MY_FILE_NAME = "autoloader.php";
|
||||
const DB_MODEL_FOLDER = "dbmodel";
|
||||
const MODULE_FOLDER = "module";
|
||||
const INTERFACE_FOLDER = "interfaces";
|
||||
const TRAIT_FOLDER = "trait";
|
||||
const SETTINGS_SECTION = "AUTOLOADER";
|
||||
const SETTINGS_CLASS_POS = "class.pos";
|
||||
const SETTINGS_TRAIT_POS = "trait.pos";
|
||||
const SETTINGS_IFACE_POS = "iface.pos";
|
||||
|
||||
private static $_filesInFoler = array();
|
||||
private static $_instance;
|
||||
|
||||
private static $_debug = false;
|
||||
private static $_modules = array();
|
||||
|
||||
protected function __construct()
|
||||
{
|
||||
self::_setFilesInFoler();
|
||||
}
|
||||
|
||||
|
||||
public static function getInstance()
|
||||
{
|
||||
$className = get_called_class();
|
||||
if(self::$_instance==null) self::$_instance = new $className();
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected static function isDebug(): bool
|
||||
{
|
||||
return self::$_debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc activate debug into the debugbar, before calling the autoloader
|
||||
* Autoloader::getInstance()->debug( true );
|
||||
* @param bool $debug
|
||||
*/
|
||||
public static function debug( bool $debug ): void
|
||||
{
|
||||
self::$_debug = $debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc will sort the array by a given sort order from the configuration file
|
||||
* just provided in the AUTOLOADER section.
|
||||
* @param array $modules
|
||||
* @return array
|
||||
*/
|
||||
private static function sortOrderModules( array $modules, $section ): array
|
||||
{
|
||||
(bool) $skip = false;
|
||||
(array) $normal = array();
|
||||
|
||||
if($section == self::SETTINGS_CLASS_POS)
|
||||
{
|
||||
$moduleSortOrder = Config::getInstance()->getConfig()[self::SETTINGS_SECTION][self::SETTINGS_CLASS_POS];
|
||||
}
|
||||
if($section == self::SETTINGS_TRAIT_POS)
|
||||
{
|
||||
$moduleSortOrder = Config::getInstance()->getConfig()[self::SETTINGS_SECTION][self::SETTINGS_TRAIT_POS];
|
||||
}
|
||||
if($section == self::SETTINGS_IFACE_POS)
|
||||
{
|
||||
$moduleSortOrder = Config::getInstance()->getConfig()[self::SETTINGS_SECTION][self::SETTINGS_IFACE_POS];
|
||||
}
|
||||
if(sizeof($moduleSortOrder)>0)
|
||||
{
|
||||
foreach ($modules as $module)
|
||||
{
|
||||
foreach ($moduleSortOrder as $sortOrder)
|
||||
{
|
||||
if($module['nfilename'] == $sortOrder)
|
||||
{
|
||||
$first[] = $module;
|
||||
}
|
||||
else
|
||||
{
|
||||
$skip = true;
|
||||
}
|
||||
}
|
||||
if($skip)
|
||||
{
|
||||
$normal[] = $module;
|
||||
$skip = false;
|
||||
}
|
||||
}
|
||||
if(array_key_exists(0, $first))
|
||||
{
|
||||
$sorted = array();
|
||||
foreach($moduleSortOrder as $item)
|
||||
{
|
||||
foreach ($first as $fmodule)
|
||||
{
|
||||
if($item==$fmodule['nfilename'])
|
||||
{
|
||||
$sorted[] = $fmodule;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$modules = array_merge($sorted, $normal);
|
||||
}
|
||||
return $modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc includes all database model files in preparation for the
|
||||
* database factory model
|
||||
@@ -39,10 +128,19 @@ class Autoloader
|
||||
{
|
||||
foreach (self::getFilesInFoler() as $file)
|
||||
{
|
||||
$required[] = $file;
|
||||
require_once $file;
|
||||
}
|
||||
if(self::isDebug())
|
||||
{
|
||||
View::getInstance()->assign(
|
||||
array(
|
||||
'ndbraw_output' => '<pre>' . print_r($required, true) . '</pre>'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -50,47 +148,106 @@ class Autoloader
|
||||
{
|
||||
return self::$_filesInFoler;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected static function getModules(): array
|
||||
{
|
||||
return self::$_modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $filesInFoler
|
||||
*/
|
||||
private static function _setFilesInFoler( )
|
||||
{
|
||||
$modelFolder = Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::DB_MODEL_FOLDER];
|
||||
if(is_array($modelFolder))
|
||||
/**
|
||||
* @desc arrays for sorting the module order, so they will load
|
||||
* alphabetically
|
||||
*/
|
||||
$modules = array();
|
||||
|
||||
if( is_array( Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::DB_MODEL_FOLDER] ) )
|
||||
{
|
||||
foreach ($modelFolder as $folder)
|
||||
foreach ( Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::DB_MODEL_FOLDER] as $modelfolder )
|
||||
{
|
||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__ . $folder ));
|
||||
foreach ($iterator as $item)
|
||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator( __DIR__ . $modelfolder ));
|
||||
foreach ( $iterator as $item )
|
||||
{
|
||||
if($item->getFileName()!= self::MY_FILE_NAME && $item->getFileName()!="." && $item->getFileName()!="..")
|
||||
{
|
||||
self::$_filesInFoler[] = $item->getPathName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__ . $modelFolder ));
|
||||
foreach ($iterator as $item)
|
||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::DB_MODEL_FOLDER] ));
|
||||
foreach ( $iterator as $item )
|
||||
{
|
||||
if($item->getFileName()!= self::MY_FILE_NAME && $item->getFileName()!="." && $item->getFileName()!="..")
|
||||
{
|
||||
self::$_filesInFoler[] = $item->getPathName();
|
||||
}
|
||||
}
|
||||
}
|
||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::MODULE_FOLDER] ));
|
||||
foreach ($iterator as $item)
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @desc run check on modules that should provide an interface as well as a trait
|
||||
*/
|
||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::INTERFACE_FOLDER] ));
|
||||
foreach ( $iterator as $item )
|
||||
{
|
||||
if($item->getFileName()!= self::MY_FILE_NAME && $item->getFileName()!="." && $item->getFileName()!="..")
|
||||
{
|
||||
self::$_filesInFoler[] = $item->getPathName();
|
||||
$interfaces[] = array(
|
||||
'nfilename' => str_replace('.php', '', $item->getFileName()),
|
||||
'filepathname' => $item->getPath() . '/' . $item->getFileName()
|
||||
);
|
||||
}
|
||||
}
|
||||
asort($interfaces);
|
||||
$Sinterfaces = self::sortOrderModules($interfaces, self::SETTINGS_IFACE_POS);
|
||||
foreach ($Sinterfaces as $interface)
|
||||
{
|
||||
self::$_filesInFoler[] = $interface['filepathname'];
|
||||
}
|
||||
|
||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::TRAIT_FOLDER] ));
|
||||
foreach ( $iterator as $item )
|
||||
{
|
||||
if($item->getFileName()!= self::MY_FILE_NAME && $item->getFileName()!="." && $item->getFileName()!="..")
|
||||
{
|
||||
$traits[] = array(
|
||||
'nfilename' => str_replace('.php', '', $item->getFileName()),
|
||||
'filepathname' => $item->getPath() . '/' . $item->getFileName()
|
||||
);
|
||||
}
|
||||
}
|
||||
asort($traits);
|
||||
$Straits = self::sortOrderModules($traits, self::SETTINGS_TRAIT_POS);
|
||||
foreach($Straits as $trait)
|
||||
{
|
||||
self::$_filesInFoler[] = $trait['filepathname'];
|
||||
}
|
||||
|
||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__ . Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS][self::MODULE_FOLDER] ));
|
||||
foreach ( $iterator as $item )
|
||||
{
|
||||
if($item->getFileName()!= self::MY_FILE_NAME && $item->getFileName()!="." && $item->getFileName()!="..")
|
||||
{
|
||||
$modules[] = array(
|
||||
'nfilename' => str_replace('.php', '', $item->getFileName()),
|
||||
'filepathname' => $item->getPath() . '/' . $item->getFileName()
|
||||
);
|
||||
}
|
||||
}
|
||||
asort($modules);
|
||||
$Smodules = self::sortOrderModules($modules, self::SETTINGS_CLASS_POS);
|
||||
foreach ($Smodules as $module)
|
||||
{
|
||||
self::$_filesInFoler[] = $module['filepathname'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -60,17 +60,23 @@ class FormAttributes
|
||||
$this->_element = str_replace(' CLASS', '', $this->_element);
|
||||
$this->_element = str_replace(' enctype="ENCTYPE"', '', $this->_element);
|
||||
$this->_element = str_replace(' onsubmit="ONSUBMIT"', '', $this->_element);
|
||||
$this->_element = str_replace(' onclick="ONCLICK"', '', $this->_element);
|
||||
$this->_element = str_replace(' action="ACTION"', '', $this->_element);
|
||||
$this->_element = str_replace(' SPEECH', '', $this->_element);
|
||||
$this->_element = str_replace(' FORM', '', $this->_element);
|
||||
$this->_element = str_replace(' placeholder="PLACEHOLDER"', '', $this->_element);
|
||||
$this->_element = str_replace(' required="REQUIRED"', '', $this->_element);
|
||||
$this->_element = str_replace(' value="VALUE"', '', $this->_element);
|
||||
$this->_element = str_replace(' name="NAME"', '', $this->_element);
|
||||
$this->_element = str_replace(' ', ' ', $this->_element);
|
||||
$this->_element = str_replace(' type="TYPE"', '', $this->_element);
|
||||
$this->_element = str_replace(' onchange="ONCHANGE"', '', $this->_element);
|
||||
$this->_element = str_replace(' target="TARGET"', '', $this->_element);
|
||||
$this->_element = str_replace(' method="METHOD"', '', $this->_element);
|
||||
$this->_element = str_replace(' data-toggle="DATA-TOGGLE"', '', $this->_element);
|
||||
$this->_element = str_replace(' SELECTED', '', $this->_element);
|
||||
$this->_element = str_replace(' CONTEXT', '', $this->_element);
|
||||
$this->_element = str_replace(' CHECKED', '', $this->_element);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,10 +24,16 @@ class Mysql implements IMysql
|
||||
|
||||
protected $_conn = self::PLACE_CONNECTION;
|
||||
|
||||
protected function __construct( )
|
||||
protected function __construct( $section = false )
|
||||
{
|
||||
|
||||
$settings = Config::getInstance()->getConfig()[self::SETTINGS_DATABASE];
|
||||
if($section)
|
||||
{
|
||||
$settings = Config::getInstance()->getConfig()[$section];
|
||||
}
|
||||
else
|
||||
{
|
||||
$settings = Config::getInstance()->getConfig()[self::SETTINGS_DATABASE];
|
||||
}
|
||||
$this->_setUsername($settings[self::PLACE_USERNAME]);
|
||||
$this->_setPassword($settings[self::PLACE_PASSWORD]);
|
||||
$this->_setDbname($settings[self::PLACE_DATABASE]);
|
||||
@@ -38,10 +44,10 @@ class Mysql implements IMysql
|
||||
$this->_setConn();
|
||||
}
|
||||
|
||||
public static function getInstance()
|
||||
public static function getInstance( $section = false )
|
||||
{
|
||||
$className = get_called_class();
|
||||
if(self::$_instance==null) self::$_instance = new $className();
|
||||
if(self::$_instance==null) self::$_instance = new $className( $section );
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,10 +17,16 @@ class Odbc extends Mysql implements IOdbc
|
||||
|
||||
private static $_instance;
|
||||
|
||||
protected function __construct( )
|
||||
protected function __construct( $section = false )
|
||||
{
|
||||
|
||||
$settings = Config::getInstance()->getConfig()[self::SETTINGS_DATABASE];
|
||||
if($section)
|
||||
{
|
||||
$settings = Config::getInstance()->getConfig()[$section];
|
||||
}
|
||||
else
|
||||
{
|
||||
$settings = Config::getInstance()->getConfig()[self::SETTINGS_DATABASE];
|
||||
}
|
||||
$this->_setUsername($settings[self::PLACE_USERNAME]);
|
||||
$this->_setPassword($settings[self::PLACE_PASSWORD]);
|
||||
$this->_setDbname($settings[self::PLACE_DATABASE]);
|
||||
@@ -32,10 +38,10 @@ class Odbc extends Mysql implements IOdbc
|
||||
$this->_setConn();
|
||||
}
|
||||
|
||||
public static function getInstance()
|
||||
public static function getInstance( $section = false )
|
||||
{
|
||||
$className = get_called_class();
|
||||
if(self::$_instance==null) self::$_instance = new $className();
|
||||
if(self::$_instance==null) self::$_instance = new $className( $section );
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,17 @@ namespace Nibiru;
|
||||
*/
|
||||
final class Pdo extends Mysql implements IPdo
|
||||
{
|
||||
|
||||
private static $section = false;
|
||||
|
||||
public static function settingsSection( $section = IOdbc::SETTINGS_DATABASE )
|
||||
{
|
||||
self::$section = $section;
|
||||
}
|
||||
|
||||
private static function getSettingsSection()
|
||||
{
|
||||
return self::$section;
|
||||
}
|
||||
/**
|
||||
* @param string $string
|
||||
*
|
||||
@@ -18,7 +28,7 @@ final class Pdo extends Mysql implements IPdo
|
||||
*/
|
||||
public static function query( $string = self::PLACE_NO_QUERY )
|
||||
{
|
||||
$query = parent::getInstance()->getConn()->query( $string );
|
||||
$query = parent::getInstance( self::getSettingsSection() )->getConn()->query( $string );
|
||||
while($row = $query->fetch())
|
||||
{
|
||||
$keys = array_keys($row);
|
||||
@@ -35,7 +45,7 @@ final class Pdo extends Mysql implements IPdo
|
||||
|
||||
public static function selectDatasetByFieldAndValue($tablename = self::PLACE_TABLE_NAME, $fieldAndValue = array() )
|
||||
{
|
||||
$result = parent::getInstance()->getConn()->query("SELECT * FROM " . $tablename . " WHERE " . $fieldAndValue['name'] . " = '" . $fieldAndValue['value'] . "';");
|
||||
$result = parent::getInstance( self::getSettingsSection() )->getConn()->query("SELECT * FROM " . $tablename . " WHERE " . $fieldAndValue['name'] . " = '" . $fieldAndValue['value'] . "';");
|
||||
return $result->fetchAll();
|
||||
}
|
||||
|
||||
@@ -45,7 +55,7 @@ final class Pdo extends Mysql implements IPdo
|
||||
$field_name = IMysql::PLACE_FIELD_NAME,
|
||||
$where_value = IMysql::PLACE_WHERE_VALUE )
|
||||
{
|
||||
$statement = parent::getInstance()->getConn();
|
||||
$statement = parent::getInstance( self::getSettingsSection() )->getConn();
|
||||
$query = "UPDATE " . $tablename . " SET " . $column_name . " = :" . $column_name . " WHERE " . $field_name . " = :". $field_name;
|
||||
$insert = $statement->prepare($query);
|
||||
$insert->bindParam( ':'.$column_name, $parameter_name );
|
||||
@@ -56,7 +66,7 @@ final class Pdo extends Mysql implements IPdo
|
||||
public static function fetchRowInArrayById($tablename = self::PLACE_TABLE_NAME, $id = self::NO_ID )
|
||||
{
|
||||
$result = array();
|
||||
$statement = parent::getInstance()->getConn();
|
||||
$statement = parent::getInstance( self::getSettingsSection() )->getConn();
|
||||
$describe = $statement->query('DESC ' . $tablename);
|
||||
$describe->execute();
|
||||
$tableInformation = $describe->fetchAll( \PDO::FETCH_ASSOC );
|
||||
@@ -93,7 +103,7 @@ final class Pdo extends Mysql implements IPdo
|
||||
$column_name = IMysql::PLACE_COLUMN_NAME,
|
||||
$parameter_name = IMysql::PLACE_SEARCH_TERM)
|
||||
{
|
||||
$statement = parent::getInstance()->getConn();
|
||||
$statement = parent::getInstance( self::getSettingsSection() )->getConn();
|
||||
$prepare = $statement->prepare("SELECT * FROM " . $tablename . " WHERE " . $column_name . " = :" . $column_name . ";");
|
||||
$prepare->bindParam(":".$column_name, $parameter_name, \PDO::PARAM_STR);
|
||||
$prepare->execute();
|
||||
@@ -116,7 +126,7 @@ final class Pdo extends Mysql implements IPdo
|
||||
|
||||
public static function fetchTableAsArray( $tablename = self::PLACE_TABLE_NAME )
|
||||
{
|
||||
$statement = parent::getInstance()->getConn()->query('SElECT * FROM ' . $tablename);
|
||||
$statement = parent::getInstance( self::getSettingsSection() )->getConn()->query('SElECT * FROM ' . $tablename);
|
||||
$statement->execute();
|
||||
$result = $statement->fetchAll( \PDO::FETCH_ASSOC );
|
||||
return $result;
|
||||
@@ -131,7 +141,7 @@ final class Pdo extends Mysql implements IPdo
|
||||
*/
|
||||
public static function insertArrayIntoTable( $tablename = IMysql::PLACE_TABLE_NAME, $array_name = IMysql::PLACE_ARRAY_NAME, $encrypted = IMysql::PLACE_DES_ENCRYPT )
|
||||
{
|
||||
$statement = parent::getInstance()->getConn();
|
||||
$statement = parent::getInstance( self::getSettingsSection() )->getConn();
|
||||
|
||||
if(is_array($array_name))
|
||||
{
|
||||
|
||||
@@ -9,6 +9,17 @@ namespace Nibiru;
|
||||
*/
|
||||
class Postgres extends Odbc implements IPostgres
|
||||
{
|
||||
private static $section = false;
|
||||
|
||||
public static function settingsSection( $section = IOdbc::SETTINGS_DATABASE )
|
||||
{
|
||||
self::$section = $section;
|
||||
}
|
||||
|
||||
private static function getSettingsSection()
|
||||
{
|
||||
return self::$section;
|
||||
}
|
||||
/**
|
||||
* @desc does a plain SQL query on a postgres database, and returns the
|
||||
* result as an array
|
||||
@@ -18,7 +29,7 @@ class Postgres extends Odbc implements IPostgres
|
||||
public static function query($string = IOdbc::PLACE_NO_QUERY)
|
||||
{
|
||||
$all = array();
|
||||
$result = \odbc_exec(parent::getInstance()->getConn(), $string);
|
||||
$result = \odbc_exec(parent::getInstance( self::getSettingsSection() )->getConn(), $string);
|
||||
for($i=1;$row=\odbc_fetch_object($result,$i);$i++)
|
||||
{
|
||||
$row_values = array();
|
||||
@@ -54,7 +65,7 @@ class Postgres extends Odbc implements IPostgres
|
||||
public static function fetchTableFieldsAsArray($tablename = IOdbc::PLACE_TABLE_NAME)
|
||||
{
|
||||
$columns = array();
|
||||
$result = \odbc_columns(parent::getInstance()->getConn(), null, null, $tablename);
|
||||
$result = \odbc_columns(parent::getInstance( self::getSettingsSection() )->getConn(), null, null, $tablename);
|
||||
for($i=0;$row=\odbc_fetch_object($result, $i);$i++)
|
||||
{
|
||||
foreach ($row as $key=>$entry)
|
||||
@@ -112,7 +123,7 @@ class Postgres extends Odbc implements IPostgres
|
||||
$row .= " )";
|
||||
$sql = 'INSERT INTO ' . $tablename . $row . ';';
|
||||
|
||||
\odbc_exec(parent::getInstance()->getConn(), $sql);
|
||||
\odbc_exec(parent::getInstance( self::getSettingsSection() )->getConn(), $sql);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -148,7 +159,7 @@ class Postgres extends Odbc implements IPostgres
|
||||
$row .= " )";
|
||||
$sql = 'INSERT INTO ' . $tablename . $row . ';';
|
||||
|
||||
\odbc_exec(parent::getInstance()->getConn(), $sql);
|
||||
\odbc_exec(parent::getInstance( self::getSettingsSection() )->getConn(), $sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,10 +12,11 @@ use Nibiru\Adapter;
|
||||
class TypeCheckbox extends FormAttributes implements IForm
|
||||
{
|
||||
private $_attributes = array(
|
||||
self::FORM_NAME => '',
|
||||
self::FORM_VALUE => '',
|
||||
self::FORM_ATTRIBUTE_ID => '',
|
||||
self::FORM_ATTRIBUTE_CLASS => ''
|
||||
self::FORM_NAME => '',
|
||||
self::FORM_VALUE => '',
|
||||
self::FORM_ATTRIBUTE_ID => '',
|
||||
self::FORM_ATTRIBUTE_CLASS => '',
|
||||
self::FORM_ATTRIBUTE_CHECKED => ''
|
||||
);
|
||||
|
||||
public function loadElement( $attributes )
|
||||
@@ -32,7 +33,7 @@ class TypeCheckbox extends FormAttributes implements IForm
|
||||
*/
|
||||
private function _setElement( )
|
||||
{
|
||||
$this->_element = '<input type="checkbox" name="NAME" value="VALUE" ID CLASS>' . 'VALUE<br>' . "\n";
|
||||
$this->_element = '<input type="checkbox" name="NAME" value="VALUE" CHECKED ID CLASS>' . 'VALUE<br>' . "\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@ namespace Nibiru\Factory;
|
||||
*/
|
||||
class Db
|
||||
{
|
||||
protected static $_model = null;
|
||||
const DATABASE_DRIVER_NS = "driver";
|
||||
protected static $_model = null;
|
||||
|
||||
/**
|
||||
* @desc loads the database model through the correct Factory,
|
||||
|
||||
@@ -39,6 +39,7 @@ interface IForm
|
||||
const FORM_ATTRIBUTE_ONSUBMIT = 'onsubmit';
|
||||
const FORM_ATTRIBUTE_SELECTED = 'selected';
|
||||
const FORM_ATTRIBUTE_CONTEXT = 'context';
|
||||
const FORM_ATTRIBUTE_CHECKED = 'checked';
|
||||
|
||||
/**
|
||||
* @desc loads the current Form element to the form
|
||||
|
||||
Reference in New Issue
Block a user