本文整理汇总了PHP中KLoader::addAdapter方法的典型用法代码示例。如果您正苦于以下问题:PHP KLoader::addAdapter方法的具体用法?PHP KLoader::addAdapter怎么用?PHP KLoader::addAdapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KLoader
的用法示例。
在下文中一共展示了KLoader::addAdapter方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($subject, $config = array())
{
// Turn off E_STRICT errors for now
error_reporting(error_reporting() & ~E_STRICT);
// Check if database type is MySQLi
if (JFactory::getApplication()->getCfg('dbtype') != 'mysqli') {
if (JFactory::getApplication()->getName() === 'administrator') {
$string = version_compare(JVERSION, '1.6', '<') ? 'mysqli' : 'MySQLi';
$link = JRoute::_('index.php?option=com_config');
$error = 'In order to use Joomlatools framework, your database type in Global Configuration should be set to <strong>%1$s</strong>. Please go to <a href="%2$s">Global Configuration</a> and in the \'Server\' tab change your Database Type to <strong>%1$s</strong>.';
JError::raiseWarning(0, sprintf(JText::_($error), $string, $link));
}
return;
}
// Set pcre.backtrack_limit to a larger value
// See: https://bugs.php.net/bug.php?id=40846
if (version_compare(PHP_VERSION, '5.3.6', '<=') && @ini_get('pcre.backtrack_limit') < 1000000) {
@ini_set('pcre.backtrack_limit', 1000000);
}
//Set constants
define('KDEBUG', JDEBUG);
//Set path definitions
define('JPATH_FILES', JPATH_ROOT);
define('JPATH_IMAGES', JPATH_ROOT . DIRECTORY_SEPARATOR . 'images');
//Set exception handler
set_exception_handler(array($this, 'exceptionHandler'));
// Koowa : setup
require_once JPATH_LIBRARIES . '/koowa/koowa.php';
Koowa::getInstance(array('cache_prefix' => md5(JFactory::getApplication()->getCfg('secret')) . '-cache-koowa', 'cache_enabled' => false));
KLoader::addAdapter(new KLoaderAdapterModule(array('basepath' => JPATH_BASE)));
KLoader::addAdapter(new KLoaderAdapterPlugin(array('basepath' => JPATH_ROOT)));
KLoader::addAdapter(new KLoaderAdapterComponent(array('basepath' => JPATH_BASE)));
KServiceIdentifier::addLocator(KService::get('koowa:service.locator.module'));
KServiceIdentifier::addLocator(KService::get('koowa:service.locator.plugin'));
KServiceIdentifier::addLocator(KService::get('koowa:service.locator.component'));
KServiceIdentifier::setApplication('site', JPATH_SITE);
KServiceIdentifier::setApplication('admin', JPATH_ADMINISTRATOR);
KService::setAlias('koowa:database.adapter.mysqli', 'com://admin/default.database.adapter.mysqli');
KService::setAlias('translator', 'com:default.translator');
//Setup the request
if (JFactory::getApplication()->getName() !== 'site') {
KRequest::root(str_replace('/' . JFactory::getApplication()->getName(), '', KRequest::base()));
}
//Load the koowa plugins
JPluginHelper::importPlugin('koowa', null, true);
//Bugfix : Set offset accoording to user's timezone
if (!JFactory::getUser()->guest) {
if ($offset = JFactory::getUser()->getParam('timezone')) {
if (version_compare(JVERSION, '3.0', '>=')) {
JFactory::getConfig()->set('offset', $offset);
} else {
JFactory::getConfig()->setValue('config.offset', $offset);
}
}
}
// Load language files for the framework
KService::get('com:default.translator')->loadLanguageFiles();
parent::__construct($subject, $config);
}
示例2: __construct
public function __construct($subject, $config = array())
{
// Check if Koowa is active
if (JFactory::getApplication()->getCfg('dbtype') != 'mysqli') {
JError::raiseWarning(0, JText::_("Koowa plugin requires MySQLi Database Driver. Please change your database configuration settings to 'mysqli'"));
return;
}
// Check for suhosin
if (in_array('suhosin', get_loaded_extensions())) {
//Attempt setting the whitelist value
@ini_set('suhosin.executor.include.whitelist', 'tmpl://, file://');
//Checking if the whitelist is ok
if (!@ini_get('suhosin.executor.include.whitelist') || strpos(@ini_get('suhosin.executor.include.whitelist'), 'tmpl://') === false) {
JError::raiseWarning(0, sprintf(JText::_('Your server has Suhosin loaded. Please follow <a href="%s" target="_blank">this</a> tutorial.'), 'https://nooku.assembla.com/wiki/show/nooku-framework/Known_Issues'));
return;
}
}
//Set constants
define('KDEBUG', JDEBUG);
define('JPATH_IMAGES', JPATH_ROOT . '/images');
//Set exception handler
set_exception_handler(array($this, 'exceptionHandler'));
// Require the library loader
JLoader::import('libraries.koowa.koowa', JPATH_ROOT);
JLoader::import('libraries.koowa.loader.loader', JPATH_ROOT);
//Setup the loader
KLoader::addAdapter(new KLoaderAdapterKoowa(Koowa::getPath()));
KLoader::addAdapter(new KLoaderAdapterJoomla(JPATH_LIBRARIES));
KLoader::addAdapter(new KLoaderAdapterModule(JPATH_BASE));
KLoader::addAdapter(new KLoaderAdapterPlugin(JPATH_ROOT));
KLoader::addAdapter(new KLoaderAdapterComponent(JPATH_BASE));
//Setup the factory
KFactory::addAdapter(new KFactoryAdapterKoowa());
KFactory::addAdapter(new KFactoryAdapterJoomla());
KFactory::addAdapter(new KFactoryAdapterModule());
KFactory::addAdapter(new KFactoryAdapterPlugin());
KFactory::addAdapter(new KFactoryAdapterComponent());
//Setup the identifier application paths
KIdentifier::registerApplication('site', JPATH_SITE);
KIdentifier::registerApplication('admin', JPATH_ADMINISTRATOR);
//Setup the request
KRequest::root(str_replace('/' . JFactory::getApplication()->getName(), '', KRequest::base()));
//Set factory identifier aliasses
KFactory::map('lib.koowa.database.adapter.mysqli', 'admin::com.default.database.adapter.mysqli');
//Load the koowa plugins
JPluginHelper::importPlugin('koowa', null, true, KFactory::get('lib.koowa.event.dispatcher'));
//Bugfix : Set offset accoording to user's timezone
if (!KFactory::get('lib.joomla.user')->guest) {
if ($offset = KFactory::get('lib.joomla.user')->getParam('timezone')) {
KFactory::get('lib.joomla.config')->setValue('config.offset', $offset);
}
}
parent::__construct($subject, $config);
}
示例3: __construct
/**
* 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())
{
//store the path
$this->_path = dirname(__FILE__);
//instantiate koowa
Koowa::getInstance(array('cache_prefix' => $config['cache_prefix'], 'cache_enabled' => $config['cache_enabled']));
//if caching is not enabled then reset the apc cache to
//to prevent corrupt identifier
if (!$config['cache_enabled']) {
clean_apc_with_prefix($config['cache_prefix']);
}
require_once dirname(__FILE__) . '/loader/adapter/anahita.php';
KLoader::addAdapter(new AnLoaderAdapterAnahita(array('basepath' => dirname(__FILE__))));
KLoader::addAdapter(new AnLoaderAdapterDefault(array('basepath' => JPATH_LIBRARIES . '/default')));
AnServiceClass::getInstance();
KServiceIdentifier::addLocator(new AnServiceLocatorAnahita());
KServiceIdentifier::addLocator(new AnServiceLocatorRepository());
//register an empty path for the application
//a workaround to remove the applicaiton path from an identifier
KServiceIdentifier::setApplication('', '');
//create a central event dispatcher
KService::set('anahita:event.dispatcher', KService::get('koowa:event.dispatcher'));
}
示例4: jimport
jimport('joomla.user.user');
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');
示例5: jimport
if (!file_exists(JPATH_CONFIGURATION . '/configuration.php') || filesize(JPATH_CONFIGURATION . '/configuration.php') < 10) {
echo 'No configuration file found. Exciting...';
exit;
}
// Joomla : setup
require_once JPATH_LIBRARIES . '/joomla/import.php';
jimport('joomla.application.application');
jimport('joomla.user.user');
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');
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'));
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');
KLoader::getInstance()->loadIdentifier('com://admin/application.aliases');
示例6: jimport
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' );
// Koowa : setup loader
JLoader::import('libraries.koowa.koowa' , JPATH_ROOT);
JLoader::import('libraries.koowa.loader.loader', JPATH_ROOT);
KLoader::addAdapter(new KLoaderAdapterKoowa(Koowa::getPath()));
KLoader::addAdapter(new KLoaderAdapterJoomla(JPATH_LIBRARIES));
KLoader::addAdapter(new KLoaderAdapterModule(JPATH_BASE));
KLoader::addAdapter(new KLoaderAdapterPlugin(JPATH_ROOT));
KLoader::addAdapter(new KLoaderAdapterComponent(JPATH_BASE));
// Koowa : setup factory
KFactory::addAdapter(new KFactoryAdapterKoowa());
KFactory::addAdapter(new KFactoryAdapterJoomla());
KFactory::addAdapter(new KFactoryAdapterModule());
KFactory::addAdapter(new KFactoryAdapterPlugin());
KFactory::addAdapter(new KFactoryAdapterComponent());
//Koowa : register identifier application paths
KIdentifier::registerApplication('site' , JPATH_SITE);
KIdentifier::registerApplication('admin', JPATH_ADMINISTRATOR);
//Koowa : setup factory mappings
KFactory::map('koowa:database.adapter.mysqli', 'com://admin/default.database.adapter.mysqli');
示例7: jimport
}
}
// System includes
require_once JPATH_LIBRARIES . '/joomla/import.php';
// Joomla : setup
jimport('joomla.application.menu');
jimport('joomla.user.user');
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');
// Koowa : setup
require_once JPATH_CONFIGURATION . '/configuration.php';
$config = new JConfig();
require_once JPATH_LIBRARIES . '/koowa/koowa.php';
Koowa::getInstance(array('cache_prefix' => md5($config->secret) . '-cache-koowa', 'cache_enabled' => $config->caching));
unset($config);
KLoader::addAdapter(new KLoaderAdapterModule(array('basepath' => JPATH_BASE)));
KLoader::addAdapter(new KLoaderAdapterPlugin(array('basepath' => JPATH_ROOT)));
KLoader::addAdapter(new KLoaderAdapterComponent(array('basepath' => JPATH_BASE)));
KServiceIdentifier::addLocator(KService::get('koowa:service.locator.module'));
KServiceIdentifier::addLocator(KService::get('koowa:service.locator.plugin'));
KServiceIdentifier::addLocator(KService::get('koowa:service.locator.component'));
KServiceIdentifier::setApplication('site', JPATH_SITE);
KServiceIdentifier::setApplication('admin', JPATH_ADMINISTRATOR);
KService::setAlias('koowa:database.adapter.mysqli', 'com://admin/default.database.adapter.mysqli');
示例8: ComLearnLoaderAdapterYaml
<?php
KLoader::addAdapter(new ComLearnLoaderAdapterYaml(JPATH_BASE));
KLoader::addAdapter(new ComLearnLoaderAdapterMarkdown(JPATH_BASE));
echo KFactory::get('com://admin/learn.dispatcher')->dispatch();
示例9: __construct
public function __construct($subject, $config = array())
{
// Turn off E_STRICT errors for now
error_reporting(error_reporting() & ~E_STRICT);
// Command line fixes for Joomla
if (PHP_SAPI === 'cli') {
if (!isset($_SERVER['HTTP_HOST'])) {
$_SERVER['HTTP_HOST'] = '';
}
if (!isset($_SERVER['REQUEST_METHOD'])) {
$_SERVER['REQUEST_METHOD'] = '';
}
}
// Check if Koowa is active
if (JFactory::getApplication()->getCfg('dbtype') != 'mysqli') {
JError::raiseWarning(0, JText::_("Koowa plugin requires MySQLi Database Driver. Please change your database configuration settings to 'mysqli'"));
return;
}
// Check for suhosin
if (in_array('suhosin', get_loaded_extensions())) {
//Attempt setting the whitelist value
@ini_set('suhosin.executor.include.whitelist', 'tmpl://, file://');
//Checking if the whitelist is ok
if (!@ini_get('suhosin.executor.include.whitelist') || strpos(@ini_get('suhosin.executor.include.whitelist'), 'tmpl://') === false) {
JError::raiseWarning(0, sprintf(JText::_('Your server has Suhosin loaded. Please follow <a href="%s" target="_blank">this</a> tutorial.'), 'http://www.joomlatools.com/framework-known-issues'));
return;
}
}
//Safety Extender compatibility
if (extension_loaded('safeex') && strpos('tmpl', @ini_get('safeex.url_include_proto_whitelist')) === false) {
$whitelist = @ini_get('safeex.url_include_proto_whitelist');
$whitelist = (strlen($whitelist) ? $whitelist . ',' : '') . 'tmpl';
@ini_set('safeex.url_include_proto_whitelist', $whitelist);
}
// Set pcre.backtrack_limit to a larger value
// See: https://bugs.php.net/bug.php?id=40846
if (version_compare(PHP_VERSION, '5.3.6', '<=') && @ini_get('pcre.backtrack_limit') < 1000000) {
@ini_set('pcre.backtrack_limit', 1000000);
}
//Set constants
define('KDEBUG', JDEBUG);
//Set path definitions
define('JPATH_FILES', JPATH_ROOT);
define('JPATH_IMAGES', JPATH_ROOT . DS . 'images');
//Set exception handler
set_exception_handler(array($this, 'exceptionHandler'));
// Koowa : setup
require_once JPATH_LIBRARIES . '/koowa/koowa.php';
Koowa::getInstance(array('cache_prefix' => md5(JFactory::getApplication()->getCfg('secret')) . '-cache-koowa', 'cache_enabled' => false));
KLoader::addAdapter(new KLoaderAdapterModule(array('basepath' => JPATH_BASE)));
KLoader::addAdapter(new KLoaderAdapterPlugin(array('basepath' => JPATH_ROOT)));
KLoader::addAdapter(new KLoaderAdapterComponent(array('basepath' => JPATH_BASE)));
KServiceIdentifier::addLocator(KService::get('koowa:service.locator.module'));
KServiceIdentifier::addLocator(KService::get('koowa:service.locator.plugin'));
KServiceIdentifier::addLocator(KService::get('koowa:service.locator.component'));
KServiceIdentifier::setApplication('site', JPATH_SITE);
KServiceIdentifier::setApplication('admin', JPATH_ADMINISTRATOR);
KService::setAlias('koowa:database.adapter.mysqli', 'com://admin/default.database.adapter.mysqli');
KService::setAlias('translator', 'com:default.translator');
//Setup the request
KRequest::root(str_replace('/' . JFactory::getApplication()->getName(), '', KRequest::base()));
//Load the koowa plugins
JPluginHelper::importPlugin('koowa', null, true, KService::get('com://admin/default.event.dispatcher'));
//Bugfix : Set offset accoording to user's timezone
if (!JFactory::getUser()->guest) {
if ($offset = JFactory::getUser()->getParam('timezone')) {
JFactory::getConfig()->setValue('config.offset', $offset);
}
}
// Load language files for the framework
KService::get('com:default.translator')->loadLanguageFiles();
parent::__construct($subject, $config);
}
示例10: createAdminUser
/**
* Creates the admin user
*/
public static function createAdminUser(&$vars)
{
$DBtype = JArrayHelper::getValue($vars, 'DBtype', 'mysqli');
$DBhostname = JArrayHelper::getValue($vars, 'DBhostname', '');
$DBuserName = JArrayHelper::getValue($vars, 'DBuserName', '');
$DBpassword = JArrayHelper::getValue($vars, 'DBpassword', '');
$DBname = JArrayHelper::getValue($vars, 'DBname', '');
$DBPrefix = JArrayHelper::getValue($vars, 'DBPrefix', '');
$adminPassword = JArrayHelper::getValue($vars, 'adminPassword', '');
$adminEmail = JArrayHelper::getValue($vars, 'adminEmail', '');
jimport('joomla.user.helper');
// Create random salt/password for the admin user
$salt = JUserHelper::genRandomPassword(32);
$crypt = JUserHelper::getCryptedPassword($adminPassword, $salt);
$cryptpass = $crypt . ':' . $salt;
$db =& JInstallationHelper::getDBO($DBtype, $DBhostname, $DBuserName, $DBpassword, $DBname, $DBPrefix);
$vars = array_merge(array('adminLogin' => 'admin', 'adminName' => 'Administrator'), $vars);
$adminLogin = $vars['adminLogin'];
$adminName = $vars['adminName'];
// create the admin user
$installdate = date('Y-m-d H:i:s');
$nullDate = $db->getNullDate();
$query = "INSERT INTO #__users VALUES (62, '{$adminName}', '{$adminLogin}', " . $db->Quote($adminEmail) . ", " . $db->Quote($cryptpass) . ", 'Super Administrator', 0, 1, 25, '{$installdate}', '{$nullDate}', '', '')";
$db->setQuery($query);
if (!$db->query()) {
// is there already and existing admin in migrated data
if ($db->getErrorNum() == 1062) {
$vars['adminLogin'] = JText::_('Admin login in migrated content was kept');
$vars['adminPassword'] = JText::_('Admin password in migrated content was kept');
return;
} else {
echo $db->getErrorMsg();
return;
}
}
// add the ARO (Access Request Object)
$query = "INSERT INTO #__core_acl_aro VALUES (10,'users','62',0,'Administrator',0)";
$db->setQuery($query);
if (!$db->query()) {
echo $db->getErrorMsg();
return;
}
// add the map between the ARO and the Group
$query = "INSERT INTO #__core_acl_groups_aro_map VALUES (25,'',10)";
$db->setQuery($query);
if (!$db->query()) {
echo $db->getErrorMsg();
return;
}
//Anahita Installation
require_once JPATH_LIBRARIES . '/anahita/anahita.php';
//instantiate anahita and nooku
Anahita::getInstance(array('cache_prefix' => uniqid(), 'cache_enabled' => false));
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'));
KService::setAlias('anahita:domain.space', 'com:base.domain.space');
KService::set('koowa:database.adapter.mysqli', KService::get('koowa:database.adapter.mysqli', array('connection' => $db->_resource, 'table_prefix' => $DBPrefix)));
KService::set('anahita:domain.store.database', KService::get('anahita:domain.store.database', array('adapter' => KService::get('koowa:database.adapter.mysqli'))));
KService::set('plg:storage.default', new KObject());
$person = KService::get('repos://site/people')->getEntity()->setData(array('name' => $adminName, 'userId' => 62, 'username' => $adminLogin, 'userType' => 'Super Administrator', 'email' => $adminEmail));
$note = KService::get('repos://site/notes')->getEntity()->setData(array('author' => $person, 'owner' => $person, 'body' => 'Welcome to Anahita!'));
$comment = $note->addComment(array('author' => $person, 'body' => 'The best Social Platform there is', 'component' => 'com_notes'));
$story = KService::get('repos://site/stories')->getEntity()->setData(array('component' => 'com_notes', 'name' => 'note_comment', 'object' => $note, 'comment' => $comment, 'target' => $person, 'owner' => $person, 'subject' => $person));
$entities = array();
$comment->save($entities);
return true;
}