芝麻web文件管理V1.00
编辑当前文件:/home/asmplong/www/ancien-site-2019/site/libraries/joomla/base/adapter.php
_basepath = $basepath; $this->_classprefix = $classprefix ? $classprefix : 'J'; $this->_adapterfolder = $adapterfolder ? $adapterfolder : 'adapters'; $this->_db = JFactory::getDBO(); } /** * Get the database connector object * * @return object Database connector object * * @since 11.1 */ public function getDBO() { return $this->_db; } /** * Set an adapter by name * * @param string $name Adapter name * @param object $adapter Adapter object * @param array $options Adapter options * * @return boolean True if successful * * @since 11.1 */ public function setAdapter($name, &$adapter = null, $options = Array()) { if (!is_object($adapter)) { $fullpath = $this->_basepath . '/' . $this->_adapterfolder . '/' . strtolower($name).'.php'; if (!file_exists($fullpath)) { return false; } // Try to load the adapter object require_once $fullpath; $class = $this->_classprefix.ucfirst($name); if (!class_exists($class)) { return false; } $adapter = new $class($this, $this->_db, $options); } $this->_adapters[$name] = &$adapter; return true; } /** * Return an adapter. * * @param string $name Name of adapter to return * @param array $options Adapter options * * @return object Adapter of type 'name' or false * * @since 11.1 */ public function getAdapter($name, $options = Array()) { if (!array_key_exists($name, $this->_adapters)) { if (!$this->setAdapter($name, $options)) { $false = false; return $false; } } return $this->_adapters[$name]; } /** * Loads all adapters. * * @param array $options Adapter options * * @return void * * @since 11.1 */ public function loadAllAdapters($options = array()) { $list = JFolder::files($this->_basepath . '/' . $this->_adapterfolder); foreach ($list as $filename) { if (JFile::getExt($filename) == 'php') { // Try to load the adapter object require_once $this->_basepath . '/' . $this->_adapterfolder . '/' . $filename; $name = JFile::stripExt($filename); $class = $this->_classprefix.ucfirst($name); if (!class_exists($class)) { continue; // skip to next one } $adapter = new $class($this, $this->_db, $options); $this->_adapters[$name] = clone $adapter; } } } }