本文整理汇总了PHP中JFactory::config方法的典型用法代码示例。如果您正苦于以下问题:PHP JFactory::config方法的具体用法?PHP JFactory::config怎么用?PHP JFactory::config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFactory
的用法示例。
在下文中一共展示了JFactory::config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Class constructor.
*
* @since 3.1
*/
public function __construct()
{
// Run the parent constructor
parent::__construct();
// Load and set the dispatcher
$this->loadDispatcher();
// Enable sessions by default.
if (is_null($this->config->get('session'))) {
$this->config->set('session', true);
}
// Set the session default name.
if (is_null($this->config->get('session_name'))) {
$this->config->set('session_name', 'installation');
}
// Create the session if a session name is passed.
if ($this->config->get('session') !== false) {
$this->loadSession();
// Register the session with JFactory
JFactory::$session = $this->getSession();
}
// Store the debug value to config based on the JDEBUG flag
$this->config->set('debug', JDEBUG);
// Register the config to JFactory
JFactory::$config = $this->config;
// Register the application to JFactory
JFactory::$application = $this;
// Set the root in the URI based on the application name
JUri::root(null, str_ireplace('/installation', '', JUri::base(true)));
}
示例2: __construct
/**
* Constructor.
*
* @since 3.2
*/
public function __construct()
{
parent::__construct();
// Overrides application config and set the configuration.php file so the send function will work
JFactory::$config = null;
JFactory::getConfig(JPATH_SITE . '/configuration.php');
}
示例3: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @return void
*/
protected function setUp()
{
$this->saveFactoryState();
JFactory::$application = $this->getMockCmsApp();
JFactory::$config = $this->getMockConfig();
parent::setUp();
}
示例4: __construct
/**
* Class constructor.
*
* @since 3.1
*/
public function __construct()
{
// Run the parent constructor
parent::__construct();
// Load and set the dispatcher
$this->loadDispatcher();
// Enable sessions by default.
if (is_null($this->config->get('session'))) {
$this->config->set('session', true);
}
// Set the session default name.
if (is_null($this->config->get('session_name'))) {
$this->config->set('session_name', 'installation');
}
// Create the session if a session name is passed.
if ($this->config->get('session') !== false) {
$this->loadSession();
// Register the session with JFactory
JFactory::$session = $this->getSession();
}
// Store the debug value to config based on the JDEBUG flag
$this->config->set('debug', JDEBUG);
// Register the config to JFactory
JFactory::$config = $this->config;
// Register the application to JFactory
JFactory::$application = $this;
// Register the application name
$this->_name = 'installation';
// Register the client ID
$this->_clientId = 2;
// Set the root in the URI one level up.
$parts = explode('/', JUri::base(true));
array_pop($parts);
JUri::root(null, implode('/', $parts));
}
示例5: __construct
/**
* Constructor.
*
* @since 3.1
*/
public function __construct()
{
parent::__construct();
// Overrides application config and set the configuration.php file so tokens and database works
JFactory::$config = null;
JFactory::getConfig(JPATH_SITE . '/configuration.php');
}
示例6: testCalendar
/**
* Tests JHtml::calendar() method with and without 'readonly' attribute.
*/
public function testCalendar()
{
// Create a world for the test
jimport('joomla.session.session');
jimport('joomla.application.application');
jimport('joomla.document.document');
$cfg = new JObject();
JFactory::$session = $this->getMock('JSession', array('_start'));
JFactory::$application = $this->getMock('ApplicationMock');
JFactory::$config = $cfg;
JFactory::$application->expects($this->any())->method('getTemplate')->will($this->returnValue('atomic'));
$cfg->live_site = 'http://example.com';
$cfg->offset = 'Europe/Kiev';
$_SERVER['HTTP_USER_AGENT'] = 'Test Browser';
// two sets of test data
$test_data = array('date' => '2010-05-28 00:00:00', 'friendly_date' => 'Friday, 28 May 2010', 'name' => 'cal1_name', 'id' => 'cal1_id', 'format' => '%Y-%m-%d', 'attribs' => array());
$test_data_ro = array_merge($test_data, array('attribs' => array('readonly' => 'readonly')));
foreach (array($test_data, $test_data_ro) as $data) {
// Reset the document
JFactory::$document = JDocument::getInstance('html', array('unique_key' => serialize($data)));
$input = JHtml::calendar($data['date'], $data['name'], $data['id'], $data['format'], $data['attribs']);
$this->assertEquals((string) $xml->input['title'], $data['friendly_date'], 'Line:' . __LINE__ . ' The calendar input should have `title == "' . $data['friendly_date'] . '"`');
$this->assertEquals((string) $xml->input['name'], $data['name'], 'Line:' . __LINE__ . ' The calendar input should have `name == "' . $data['name'] . '"`');
$this->assertEquals((string) $xml->input['id'], $data['id'], 'Line:' . __LINE__ . ' The calendar input should have `id == "' . $data['id'] . '"`');
$head_data = JFactory::getDocument()->getHeadData();
if (!isset($data['attribs']['readonly']) || !$data['attribs']['readonly'] === 'readonly') {
$this->assertArrayHasKey('/media/system/js/calendar.js', $head_data['scripts'], 'Line:' . __LINE__ . ' JS file "calendar.js" should be loaded');
$this->assertArrayHasKey('/media/system/js/calendar-setup.js', $head_data['scripts'], 'Line:' . __LINE__ . ' JS file "calendar-setup.js" should be loaded');
}
}
}
示例7: getConfig
/**
* Return a config object populated with the config from the Joomlas config file
*/
public static function getConfig()
{
if (!self::$config) {
self::$config = new FakeConfig();
}
return self::$config;
}
示例8: testEncrypt
/**
* Testing testEncrypt().
*
* @param string $text The text to be encrypted
* @param string $key The key to use
* @param string $expected The expected result of encryption
*
* @return void
* @dataProvider casesEncryption
*/
public function testEncrypt($text, $key, $expected)
{
$cfg = $this->getMock('JObject', array('get'));
$cfg->expects($this->any())->method('get')->will($this->returnValue(''));
JFactory::$config = $cfg;
$this->object = new JSimpleCrypt($key);
$this->assertThat($this->object->encrypt($text), $this->equalTo($expected));
}
示例9: testGetConfig
/**
* Tests the JFactory::getConfig method.
*
* @return void
*
* @since 11.3
* @covers JFactory::getConfig
* @covers JFactory::createConfig
*/
function testGetConfig()
{
// Temporarily override the config cache in JFactory.
$temp = JFactory::$config;
JFactory::$config = null;
$this->assertInstanceOf('JRegistry', JFactory::getConfig(JPATH_TESTS . '/config.php'), 'Line: ' . __LINE__);
JFactory::$config = $temp;
}
示例10: testGetConfig
/**
* Tests the JFactory::getConfig method.
*
* @return void
*
* @since 11.3
*/
function testGetConfig()
{
// Temporarily override the config cache in JFactory.
$temp = JFactory::$config;
JFactory::$config = null;
$this->assertThat(JFactory::getConfig(JPATH_TESTS . '/config.php'), $this->isInstanceOf('JRegistry'));
JFactory::$config = $temp;
}
示例11: testGetHash
/**
* Testing JApplication::getHash
*
* @return void
*/
public function testGetHash()
{
// Temporarily override the config cache in JFactory.
$temp = JFactory::$config;
JFactory::$config = new JObject(array('secret' => 'foo'));
$this->assertThat(JApplication::getHash('This is a test'), $this->equalTo(md5('foo' . 'This is a test')), 'Tests that the secret string is added to the hash.');
JFactory::$config = $temp;
}
示例12: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->saveFactoryState();
$_SERVER['HTTP_HOST'] = 'localhost';
$_SERVER['SCRIPT_NAME'] = '';
JFactory::$application = $this->getMockApplication();
JFactory::$config = $this->getMockConfig();
$this->object = new JDocumentOpensearch();
}
示例13: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->saveFactoryState();
$_SERVER['HTTP_HOST'] = 'localhost';
$_SERVER['SCRIPT_NAME'] = '';
JFactory::$application = $this->getMock('JApplication', array('get', 'getCfg', 'getRouter', 'getTemplate'), array(array('session' => false)));
JFactory::$config = $this->getMock('JConfig', array('get'));
$this->object = new JDocumentOpensearch();
}
示例14: getConfig
/**
* Get a configuration object
*
* Returns the global {@link JRegistry} object, only creating it
* if it doesn't already exist.
*
* @param string The path to the configuration file
* @param string The type of the configuration file
* @return object JRegistry
*/
public static function getConfig($file = null, $type = 'PHP')
{
if (!is_object(JFactory::$config)) {
if ($file === null) {
$file = dirname(__FILE__) . DS . 'config.php';
}
JFactory::$config = JFactory::_createConfig($file, $type);
}
return JFactory::$config;
}
示例15: getConfig
/**
* Get a configuration object
*
* Returns the global {@link JRegistry} object, only creating it
* if it doesn't already exist.
*
* @param string $file The path to the configuration file
* @param string $type The type of the configuration file
*
* @return JRegistry object
*/
public static function getConfig($file = null, $type = 'PHP')
{
if (!self::$config) {
if ($file === null) {
$file = dirname(__FILE__) . DS . 'config.php';
}
self::$config = self::_createConfig($file, $type);
}
return self::$config;
}