本文整理汇总了PHP中JFactory::session方法的典型用法代码示例。如果您正苦于以下问题:PHP JFactory::session方法的具体用法?PHP JFactory::session怎么用?PHP JFactory::session使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFactory
的用法示例。
在下文中一共展示了JFactory::session方法的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;
// 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));
}
示例2: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
parent::setup();
$this->saveFactoryState();
JFactory::$session = $this->getMockSession();
$this->object = new JTableCategory(self::$dbo);
}
示例3: getSession
/**
* Get a session object
*
* Returns the global {@link JSession} object, only creating it
* if it doesn't already exist.
*
* @param array An array containing session options
* @return object JSession
*/
public static function getSession($options = array())
{
if (!is_object(JFactory::$session)) {
JFactory::$session = JFactory::_createSession($options);
}
return JFactory::$session;
}
示例4: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @return void
*
* @since 12.1
*/
protected function setUp()
{
parent::setUp();
$this->saveFactoryState();
// Set the session object for JUserHelper::addUserToGroup()
JFactory::$session = $this->getMockSession();
}
示例5: __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)));
}
示例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: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @return void
*
* @since 3.2
*/
protected function setUp()
{
parent::setUp();
$this->saveFactoryState();
JFactory::$application = $this->getMockCmsApp();
JFactory::$session = $this->getMockSession();
}
示例8: getSession
/**
* Get a session object
*
* Returns the global {@link JSession} object, only creating it
* if it doesn't already exist.
*
* @param array $options An array containing session options
*
* @return JSession object
*/
public static function getSession($options = array())
{
if (!self::$session) {
self::$session = self::_createSession($options);
}
return self::$session;
}
示例9: 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()
{
parent::setUp();
$this->saveFactoryState();
JFactory::$application = $this->getMockCmsApp();
JFactory::$session = $this->getMockSession();
$this->id = bin2hex(random_bytes(8));
}
示例10: __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');
JFactory::$session = null;
}
示例11: __construct
/**
* Constructor: Deletes the default installation config file and recreates it with the good config file.
*
* @since 3.1
*/
public function __construct()
{
// Overrides application config and set the configuration.php file so tokens and database works
JFactory::$config = null;
JFactory::getConfig(JPATH_SITE . '/configuration.php');
JFactory::$session = null;
parent::__construct();
}
示例12: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @return void
*
* @since 3.4
*/
protected function setUp()
{
parent::setUp();
$app = $this->getMockCmsApp();
JFactory::$application = $app;
JFactory::$session = $this->getMockSession();
$this->object = new JComponentRouterViewInspector($app, $app->getMenu());
}
示例13: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @return void
*
* @since 3.4
*/
protected function setUp()
{
parent::setUp();
$this->saveFactoryState();
JFactory::$application = $this->getMockCmsApp();
JFactory::$session = $this->getMockSession();
require_once dirname(__DIR__) . '/controller/JCacheControllerRaw.php';
}
示例14: 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()
{
parent::setUp();
// Get the mocks
$this->saveFactoryState();
JFactory::$session = $this->getMockSession();
$this->object = new JTableLanguage(self::$driver);
}
示例15: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @return void
*
* @since 3.1
*/
protected function setUp()
{
parent::setUp();
// Get the mocks
$this->saveFactoryState();
JFactory::$session = $this->getMockSession();
$this->object = new JTableCorecontent(static::$driver);
}