/** * Constructor * * Prevent creating instances of this class by making the contructor private * * @param array An optional array with configuration options. */ private final function __construct($config = array()) { //Initialize the path $this->_path = dirname(__FILE__); //Load the legacy functions require_once $this->_path . '/legacy.php'; //Setup the loader require_once $this->_path . '/loader/loader.php'; $loader = KLoader::getInstance($config); //Setup the factory $service = KService::getInstance($config); $service->set('koowa:loader', $loader); }
jimport('joomla.environment.uri'); jimport('joomla.html.html'); jimport('joomla.html.parameter'); jimport('joomla.utilities.utility'); jimport('joomla.event.event'); jimport('joomla.event.dispatcher'); jimport('joomla.language.language'); jimport('joomla.utilities.string'); jimport('joomla.plugin.helper'); require_once JPATH_CONFIGURATION . '/configuration.php'; require_once JPATH_LIBRARIES . '/anahita/anahita.php'; $config = new JConfig(); //instantiate anahita and nooku Anahita::getInstance(array('cache_prefix' => md5($config->secret) . '-cache-koowa', 'cache_enabled' => $config->caching)); KServiceIdentifier::setApplication('site', JPATH_SITE); KServiceIdentifier::setApplication('admin', JPATH_ADMINISTRATOR); KLoader::addAdapter(new AnLoaderAdapterComponent(array('basepath' => JPATH_BASE))); KServiceIdentifier::addLocator(KService::get('anahita:service.locator.component')); KLoader::addAdapter(new KLoaderAdapterPlugin(array('basepath' => JPATH_ROOT))); KServiceIdentifier::addLocator(KService::get('koowa:service.locator.plugin')); KLoader::addAdapter(new AnLoaderAdapterTemplate(array('basepath' => JPATH_BASE))); KServiceIdentifier::addLocator(KService::get('anahita:service.locator.template')); KService::setAlias('koowa:database.adapter.mysqli', 'com://admin/default.database.adapter.mysqli'); KService::setAlias('anahita:domain.store.database', 'com:base.domain.store.database'); KService::setAlias('anahita:domain.space', 'com:base.domain.space'); //make sure for the autoloader to be reigstered after nooku $autoloader = (require_once JPATH_VENDOR . '/autoload.php'); $autoloader->unregister(); $autoloader->register(); KLoader::getInstance()->loadIdentifier('com://site/application.aliases');
static function renderComponent($name, $params = array()) { global $mainframe, $option; // Define component path define('JPATH_COMPONENT', JPATH_BASE . DS . 'components' . DS . $name); define('JPATH_COMPONENT_SITE', JPATH_SITE . DS . 'components' . DS . $name); define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . DS . 'components' . DS . $name); if (!file_exists(JPATH_COMPONENT)) { JError::raiseError(404, JText::_('Component Not Found')); } $file = substr($name, 4); // get component path if ($mainframe->isAdmin() && file_exists(JPATH_COMPONENT . DS . 'admin.' . $file . '.php')) { $path = JPATH_COMPONENT . DS . 'admin.' . $file . '.php'; } else { $path = JPATH_COMPONENT . DS . $file . '.php'; } $identifier = KService::getIdentifier("com:{$file}.aliases"); $identifier->application = $mainframe->isAdmin() ? 'admin' : 'site'; $lang =& JFactory::getLanguage(); $lang->load($name); KLoader::getInstance()->loadIdentifier($identifier); //new way of doing it if (!file_exists($path)) { $identifier->name = 'dispatcher'; register_default(array('identifier' => $identifier, 'default' => 'ComBaseDispatcherDefault')); $dispatcher = ComBaseDispatcher::getInstance(); KService::setAlias('component.dispatcher', $dispatcher->getIdentifier()); KService::set('component.dispatcher', $dispatcher); return $dispatcher->dispatch(); } else { $contents = self::_renderComponent($path); // Build the component toolbar jimport('joomla.application.helper'); if (($path = JApplicationHelper::getPath('toolbar')) && $mainframe->isAdmin()) { // Get the task again, in case it has changed $task = JRequest::getString('task'); // Make the toolbar include_once $path; } return $contents; } }