/** * Overrides method to try to load model from extension if it exists */ public static function &getInstance($type, $prefix = '', $config = array()) { $extensions = JoomleagueHelper::getExtensions(JRequest::getInt('p')); foreach ($extensions as $e => $extension) { $modelType = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type); $modelClass = $prefix . ucfirst($modelType) . ucfirst($extension); $result = false; if (!class_exists($modelClass)) { jimport('joomla.filesystem.path'); $path = JPath::find(JModel::addIncludePath(), JModel::_createFileName('model', array('name' => $modelType))); if ($path) { require_once $path; if (class_exists($modelClass)) { $result = new $modelClass($config); return $result; } } } else { $result = new $modelClass($config); return $result; } } $instance = parent::getInstance($type, $prefix, $config); return $instance; }
/** * Returns a Model object, always creating it * * @param string The model type to instantiate * @param string Prefix for the model class name. Optional. * @param array Configuration array for model. Optional. * @return mixed A model object, or false on failure */ public static function getInstance($type, $prefix = '', $config = array()) { $type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type); $modelClass = $prefix . ucfirst($type); if (!class_exists($modelClass)) { jimport('joomla.filesystem.path'); $path = JPath::find(JModel::addIncludePath(), JModel::_createFileName('model', array('name' => $type))); if ($path) { require_once $path; if (!class_exists($modelClass)) { JError::raiseWarning(0, 'Model class ' . $modelClass . ' not found in file.'); return false; } } else { return false; } } return new $modelClass($config); }
/** * Returns a Model object, always creating it * * @param string $type The model type to instantiate * @param string $prefix Prefix for the model class name. Optional. * @param array $config Configuration array for model. Optional. * * @return mixed A model object or false on failure * * @since 11.1 */ public static function getInstance($type, $prefix = '', $config = array()) { $type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type); $modelClass = $prefix . ucfirst($type); if (!class_exists($modelClass)) { jimport('joomla.filesystem.path'); $path = JPath::find(JModel::addIncludePath(null, $prefix), JModel::_createFileName('model', array('name' => $type))); if (!$path) { $path = JPath::find(JModel::addIncludePath(null, ''), JModel::_createFileName('model', array('name' => $type))); } if ($path) { require_once $path; if (!class_exists($modelClass)) { JError::raiseWarning(0, JText::sprintf('JLIB_APPLICATION_ERROR_MODELCLASS_NOT_FOUND', $modelClass)); return false; } } else { return false; } } return new $modelClass($config); }