public static function getInstance($type, $prefix = 'MTable', $config = array()) { // Sanitize and prepare the table class name. $type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type); $tableClass = $prefix . ucfirst($type); // Only try to load the class if it doesn't already exist. if (!class_exists($tableClass)) { // Search for the class file in the MTable include paths. mimport('framework.filesystem.path'); MTable::addIncludePath(MPATH_MIWI . '/proxy/database/table'); if ($path = MPath::find(MTable::addIncludePath(), strtolower($type) . '.php')) { // Import the class file. include_once $path; // If we were unable to load the proper class, raise a warning and return false. if (!class_exists($tableClass)) { MError::raiseWarning(0, MText::sprintf('MLIB_DATABASE_ERROR_CLASS_NOT_FOUND_IN_FILE', $tableClass)); return false; } } else { // If we were unable to find the class file in the MTable include paths, raise a warning and return false. MError::raiseWarning(0, MText::sprintf('MLIB_DATABASE_ERROR_NOT_SUPPORTED_FILE_NOT_FOUND', $type)); return false; } } // If a database object was passed in the configuration array use it, otherwise get the global one from MFactory. $db = isset($config['dbo']) ? $config['dbo'] : MFactory::getDbo(); // Instantiate a new table class and return it. return new $tableClass($db); }
public static function addTablePath($path) { mimport('framework.database.table'); MTable::addIncludePath($path); }
/** * @package MiwoSQL * @copyright 2009-2012 Mijosoft LLC, www.mijosoft.com * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html */ // no direct access defined('MIWI') or die('Restricted access'); if (version_compare(MVERSION, '1.6.0', 'ge')) { if (!MFactory::getUser()->authorise('core.manage', 'com_miwosql')) { return MError::raiseWarning(404, MText::_('MERROR_ALERTNOAUTHOR')); } } require_once MPATH_COMPONENT . '/mvc/model.php'; require_once MPATH_COMPONENT . '/mvc/view.php'; require_once MPATH_COMPONENT . '/mvc/controller.php'; require_once MPATH_COMPONENT . '/toolbar.php'; require_once MPATH_COMPONENT . '/helpers/helper.php'; MTable::addIncludePath(MPATH_COMPONENT . '/tables'); if ($controller = MRequest::getWord('controller')) { $path = MPATH_COMPONENT . '/controllers/' . $controller . '.php'; if (file_exists($path)) { require_once $path; } else { $controller = ''; } } $classname = 'MiwosqlController' . ucfirst($controller); $controller = new $classname(); $controller->execute(MRequest::getCmd('task')); $controller->redirect(); echo '<div style="margin: 10px; text-align: center;"><a href="http://miwisoft.com/wordpress-plugins/miwosql" target="_blank">MiwoSQL | Copyright © 2009-2014 Miwisoft LLC</a></div>';
public static function addTablePath($path) { MTable::addIncludePath($path); }