JFactory/1.6
JFactory class is in joomla core files which is Defined in line 21 of file libraries/joomla/factory.php.
Member Function Documentation
1.static JFactory::_createConfig
( $ file, $ type = 'PHP' ) [static, private]
Parameters: string $file The path to the configuration file string $type The type of the configuration file
Returns: JRegistry object Use : Create a configuration object
2.static JFactory::_createDbo ( ) [static, private] Create an database object
Returns: JDatabase object Ex. $db = JFactory::getDBO();
3.static JFactory::_createDocument ( )
[static, private]
Create a document object
Returns: JDocument object
4.static JFactory::_createLanguage ( ) [static, private]
Create a language object
Returns: JLanguage object
4. static JFactory::_createMailer ( ) [static, private]
Create a mailer object private
Returns: JMail object
5.static JFactory::_createSession ( $ options = array()) [static, private]
Create a session object
Parameters: array $options An array containing session options
Returns: JSession object
6. static JFactory::getACL (
) [static]
Get an authorization object Returns the global JACL object, only creating it if it doesn't already exist.
Returns: JACL object
Ex.
$userId = 63 ; //Sample user to get aid
$acl=&JFactory::getACL() ;
$grp=$acl->getAroGroup($userId);
if ($acl->is_group_child_of($grp->name, 'Registered') || $acl->is_group_child_of($grp->name, 'Public Backend')){
$aid = 2 ;
}else{
$aid = 1 ;
}
7. static JFactory::getApplication ( $ id = null,
$
config = array(),
$
prefix = 'J'
) [static]
Get a application object
Returns the global JApplication object, only creating it if it doesn't already exist.
Parameters: mixed $id A client identifier or name. array $config An optional associative array of configuration settings. string $prefix application prefix
Returns:
JApplication object
8. static JFactory::getCache ( $ group = ,
$
handler = 'callback',
$
storage = null
)
[static]
Get a cache object Returns the global JCache object
Parameters: string $group The cache group name string $handler The handler to use string $storage The storage method
Returns: JCache object
9.
static JFactory::getConfig ( $ file = null,
$
type = 'PHP'
)
[static]
Get a configuration object
Returns the global JRegistry object, only creating it if it doesn't already exist.
Parameters: string $file The path to the configuration file string $type The type of the configuration file
Returns: JRegistry object
Ex. This method is used to get access to the global configuration variables. In this example, the site name is retrieved.
$config =& JFactory::getConfig(); echo 'Site name is ' . $config->getValue( 'config.sitename' );
10.
static JFactory::getDate' ( $ time = 'now',
$
tzOffset = null
)
[static]
Return the JDate object
Parameters: mixed $time The initial time for the JDate object mixed $tzOffset The timezone offset.
Returns: JDate object
example: the current date and time is retrieved and output in the current default locale format.
$date =& JFactory::getDate(); echo 'Current date and time is: ' . $date->toFormat() . "\n";
If the current language is English then this will output something like
Current date and time is: 2008-11-22 18:14:08
11.
static JFactory::getDBO (
) [static]
Get a database object
Returns the global JDatabase object, only creating it if it doesn't already exist.
Returns: JDatabase object Ex. $db = JFactory::getDBO();
Where getDBO will create database object named $db
12.
static JFactory::getDocument (
) [static]
Get a document object
Returns the global JDocument object, only creating it if it doesn't already exist.
Returns: JDocument object
Ex. In this example, the current page title is retrieved.
$doc =& JFactory::getDocument(); echo 'Current title is: ' . $doc->getTitle();
13. static JFactory::getLanguage (
) [static]
Get a language object
Returns the global JLanguage object, only creating it if it doesn't already exist.
Returns: JLanguage object
Ex. $lang =& JFactory::getLanguage(); echo 'Current language is: ' . $lang->getName(); 14. static JFactory::getSession ( $ options = array() ) [static] Get a session object Returns the global JSession object, only creating it if it doesn't already exist.
Parameters: array $options
An array containing session options
Returns: JSession object
Ex. $session=JFactory::getSession(); which will assign sessions
15. static JFactory::getURI ( $ uri = 'SERVER' ) [static]
Return a reference to the JURI object
Parameters:
string $uri uri name
Returns:
JURI object
Ex. In this example, the global URI object is output as a string.
$u =& JFactory::getURI();
echo 'URI is ' . $u->toString() . "\n";
o/p will be :URI is http://www.example.com/joomla/index.php?task=view&id=12&Itemid=29
16.
static JFactory::getUser ( $ id = null ) [static] Get an user object Returns the global JUser object, only creating it if it doesn't already exist.
Parameters: int $id The user to load - Can be an integer or string - If string, it is converted to ID automatically.
Returns: JUser object
Ex. $user =& JFactory::getUser(); Where $user will be currently logged in user
17. getMailer() function getMailer( )
Get a mailer object
Returns a reference to the global JMail object, only creating it if it doesn't already exist
Parameters Returns object JMail Access public Ex. $mailThis =& JFactory::getMailer(); $mailThis -> setSender('noreply@worldwide-api.com'); $mailThis -> addRecipient('user22@hotmail.com'); // you can repeat this command to add more recipient $mailThis -> setSubject('worldwide api - test mail'); $mailThis -> setBody('hello jensen,'.chr(10).'this is an email notification'); $mailThis -> Send();