Skip to content

Commit

Permalink
Merge branch 'master' of github.com:joomla/joomla-platform into files…
Browse files Browse the repository at this point in the history
…ystem
  • Loading branch information
chdemko committed Mar 29, 2012
2 parents dd67421 + 86b76c2 commit 0c920a2
Show file tree
Hide file tree
Showing 18 changed files with 471 additions and 406 deletions.
14 changes: 6 additions & 8 deletions docs/coding-standards/en-US/chapters/php.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@


<para>For files that contain only PHP code, the closing tag (?&gt;) should not be included. It is not required by PHP. <para>For files that contain only PHP code, the closing tag (?&gt;) should not be included. It is not required by PHP.
Leaving this out prevents trailing white space from being accidentally injected into the output that can introduce errors in Leaving this out prevents trailing white space from being accidentally injected into the output that can introduce errors in
the Joomla session (see the PHP manual on instruction separation at the Joomla session (see the PHP manual on <ulink url="http://php.net/basic-syntax.instruction-separation">Instruction separation</ulink>.</para>
http://php.net/basic-syntax.instruction-separation).</para>


<para>Files should always end with a blank new line.</para> <para>Files should always end with a blank new line.</para>


Expand Down Expand Up @@ -646,7 +645,7 @@ class JClass extends JObject


<para>Exceptions should be used for error handling.</para> <para>Exceptions should be used for error handling.</para>


<para>The follow sections outline how to semantically use SPL exceptions</para> <para>The follow sections outline how to semantically use <ulink url="http://php.net/manual/en/spl.exceptions.php">SPL exceptions</ulink>.</para>


<section> <section>
<title>Logic Exceptions</title> <title>Logic Exceptions</title>
Expand All @@ -655,7 +654,7 @@ class JClass extends JObject
being used. For example:</para> being used. For example:</para>


<simplelist> <simplelist>
<member>A dependancy has failed (you try to operate on an object that has not been loaded yet).</member> <member>A dependency has failed (you try to operate on an object that has not been loaded yet).</member>
</simplelist> </simplelist>


<para>The following child classes can also be used in appropriate situations.</para> <para>The following child classes can also be used in appropriate situations.</para>
Expand All @@ -679,8 +678,7 @@ class JClass extends JObject


<simplelist> <simplelist>
<member><methodname>is_callable</methodname>, or similar, fails on a class method.</member> <member><methodname>is_callable</methodname>, or similar, fails on a class method.</member>

<member>Arguments passed to a magic call method are missing.</member>
<member>There where missing arguments passed to a magic call method.</member>
</simplelist> </simplelist>
</section> </section>


Expand Down Expand Up @@ -723,7 +721,7 @@ class JClass extends JObject


<para>The <exceptionname>RuntimeException</exceptionname> is thrown when some sort of external entity or environment causes <para>The <exceptionname>RuntimeException</exceptionname> is thrown when some sort of external entity or environment causes
a problem that is beyond your control providing the input is valid. This exception is the default case for when the cause of a problem that is beyond your control providing the input is valid. This exception is the default case for when the cause of
an error can't explicity be determined. For example:</para> an error can't explicitly be determined. For example:</para>


<simplelist> <simplelist>
<member>Tried to connect to a database but the database was not available (server down, etc).</member> <member>Tried to connect to a database but the database was not available (server down, etc).</member>
Expand All @@ -734,7 +732,7 @@ class JClass extends JObject
<section> <section>
<title>UnexpectedValueException</title> <title>UnexpectedValueException</title>


<para>This type of exception should be used when an unecpected result is encountered. For example:</para> <para>This type of exception should be used when an unexpected result is encountered. For example:</para>


<simplelist> <simplelist>
<member>A function call returned a string when a boolean was expected.</member> <member>A function call returned a string when a boolean was expected.</member>
Expand Down
59 changes: 47 additions & 12 deletions libraries/joomla/application/base.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,20 +21,28 @@
abstract class JApplicationBase extends JObject abstract class JApplicationBase extends JObject
{ {
/** /**
* The application input object. * The application dispatcher object.
* *
* @var JInput * @var JDispatcher
* @since 12.1 * @since 12.1
*/ */
public $input = null; protected $dispatcher;


/** /**
* The application dispatcher object. * The application identity object.
* *
* @var JDispatcher * @var JUser
* @since 12.1 * @since 12.1
*/ */
protected $dispatcher; protected $identity;

/**
* The application input object.
*
* @var JInput
* @since 12.1
*/
public $input = null;


/** /**
* Method to close the application. * Method to close the application.
Expand All @@ -43,6 +51,7 @@ abstract class JApplicationBase extends JObject
* *
* @return void * @return void
* *
* @codeCoverageIgnore
* @since 12.1 * @since 12.1
*/ */
public function close($code = 0) public function close($code = 0)
Expand Down Expand Up @@ -91,16 +100,42 @@ public function triggerEvent($event, array $args = null)
} }


/** /**
* Method to create an event dispatcher for the application. The logic and options for creating * Allows the application to load a custom or default dispatcher.
* this object are adequately generic for default cases but for many applications it will make
* sense to override this method and create event dispatchers based on more specific needs.
* *
* @return void * The logic and options for creating this object are adequately generic for default cases
* but for many applications it will make sense to override this method and create event
* dispatchers, if required, based on more specific needs.
*
* @param JDispatcher $dispatcher An optional dispatcher object. If omitted, the factory dispatcher is created.
*
* @return JApplicationBase This method is chainable.
* *
* @since 12.1 * @since 12.1
*/ */
protected function loadDispatcher() public function loadDispatcher(JDispatcher $dispatcher = null)
{ {
$this->dispatcher = JDispatcher::getInstance(); $this->dispatcher = ($dispatcher === null) ? JDispatcher::getInstance() : $dispatcher;

return $this;
}

/**
* Allows the application to load a custom or default identity.
*
* The logic and options for creating this object are adequately generic for default cases
* but for many applications it will make sense to override this method and create an identity,
* if required, based on more specific needs.
*
* @param JUser $identity An optional identity object. If omitted, the factory user is created.
*
* @return JApplicationBase This method is chainable.
*
* @since 12.1
*/
public function loadIdentity(JUser $identity = null)
{
$this->identity = ($identity === null) ? JFactory::getUser() : $identity;

return $this;
} }
} }
11 changes: 1 addition & 10 deletions libraries/joomla/application/cli.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -82,16 +82,7 @@ public function __construct(JInputCli $input = null, JRegistry $config = null, J
$this->config = new JRegistry; $this->config = new JRegistry;
} }


// If a dispatcher object is given use it. $this->loadDispatcher($dispatcher);
if ($dispatcher instanceof JDispatcher)
{
$this->dispatcher = $dispatcher;
}
// Create the dispatcher based on the application logic.
else
{
$this->loadDispatcher();
}


// Load the configuration object. // Load the configuration object.
$this->loadConfiguration($this->fetchConfigurationData()); $this->loadConfiguration($this->fetchConfigurationData());
Expand Down
113 changes: 50 additions & 63 deletions libraries/joomla/application/web.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ public static function getInstance($name = null)
* *
* @return JApplicationWeb Instance of $this to allow chaining. * @return JApplicationWeb Instance of $this to allow chaining.
* *
* @deprecated 13.1
* @see loadSession() * @see loadSession()
* @see loadDocument() * @see loadDocument()
* @see loadLanguage() * @see loadLanguage()
Expand All @@ -209,64 +210,25 @@ public static function getInstance($name = null)
*/ */
public function initialise($session = null, $document = null, $language = null, $dispatcher = null) public function initialise($session = null, $document = null, $language = null, $dispatcher = null)
{ {
// If a session object is given use it.
if ($session instanceof JSession)
{
$this->session = $session;
}
// We don't have a session, nor do we want one.
elseif ($session === false)
{
// Do nothing.
}
// Create the session based on the application logic. // Create the session based on the application logic.
else if ($session !== false)
{ {
$this->loadSession(); $this->loadSession($session);
} }


// If a document object is given use it.
if ($document instanceof JDocument)
{
$this->document = $document;
}
// We don't have a document, nor do we want one.
elseif ($document === false)
{
// Do nothing.
}
// Create the document based on the application logic. // Create the document based on the application logic.
else if ($document !== false)
{ {
$this->loadDocument(); $this->loadDocument($document);
} }


// If a language object is given use it.
if ($language instanceof JLanguage)
{
$this->language = $language;
}
// We don't have a language, nor do we want one.
elseif ($language === false)
{
// Do nothing.
}
// Create the language based on the application logic. // Create the language based on the application logic.
else if ($language !== false)
{ {
$this->loadLanguage(); $this->loadLanguage($language);
} }


// If a dispatcher object is given use it. $this->loadDispatcher($dispatcher);
if ($dispatcher instanceof JDispatcher)
{
$this->dispatcher = $dispatcher;
}
// Create the dispatcher based on the application logic.
else
{
$this->loadDispatcher();
}


return $this; return $this;
} }
Expand Down Expand Up @@ -1003,44 +965,67 @@ protected function header($string, $replace = true, $code = null)
} }


/** /**
* Method to create a document for the Web application. The logic and options for creating this * Allows the application to load a custom or default document.
* object are adequately generic for default cases but for many applications it will make sense
* to override this method and create document objects based on more specific needs.
* *
* @return void * The logic and options for creating this object are adequately generic for default cases
* but for many applications it will make sense to override this method and create a document,
* if required, based on more specific needs.
*
* @param JDocument $document An optional document object. If omitted, the factory document is created.
*
* @return JApplicationWeb This method is chainable.
* *
* @since 11.3 * @since 11.3
*/ */
protected function loadDocument() public function loadDocument(JDocument $document = null)
{ {
$this->document = JFactory::getDocument(); $this->document = ($document === null) ? JFactory::getDocument() : $document;

return $this;
} }


/** /**
* Method to create a language for the Web application. The logic and options for creating this * Allows the application to load a custom or default document.
* object are adequately generic for default cases but for many applications it will make sense
* to override this method and create language objects based on more specific needs.
* *
* @return void * The logic and options for creating this object are adequately generic for default cases
* but for many applications it will make sense to override this method and create an language,
* if required, based on more specific needs.
*
* @param JLanguage $language An optional language object. If omitted, the factory language is created.
*
* @return JApplicationWeb This method is chainable.
* *
* @since 11.3 * @since 11.3
*/ */
protected function loadLanguage() public function loadLanguage(JLanguage $language = null)
{ {
$this->language = JFactory::getLanguage(); $this->language = ($language === null) ? JFactory::getLanguage() : $language;

return $this;
} }


/** /**
* Method to create a session for the Web application. The logic and options for creating this * Allows the application to load a custom or default document.
* object are adequately generic for default cases but for many applications it will make sense
* to override this method and create session objects based on more specific needs.
* *
* @return void * The logic and options for creating this object are adequately generic for default cases
* but for many applications it will make sense to override this method and create a session,
* if required, based on more specific needs.
*
* @param JSession $session An optional session object. If omitted, the session is created.
*
* @return JApplicationWeb This method is chainable.
* *
* @since 11.3 * @since 11.3
*/ */
protected function loadSession() public function loadSession(JSession $session = null)
{ {
if ($session !== null)
{
$this->session = $session;

return $this;
}

// Generate a session name. // Generate a session name.
$name = md5($this->get('secret') . $this->get('session_name', get_class($this))); $name = md5($this->get('secret') . $this->get('session_name', get_class($this)));


Expand Down Expand Up @@ -1073,6 +1058,8 @@ protected function loadSession()


// Set the session object. // Set the session object.
$this->session = $session; $this->session = $session;

return $this;
} }


/** /**
Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/database/driver.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public static function getConnectors()
continue; continue;
} }


// Sweet! Our class exists, so now we just need to know if it passes it's test method. // Sweet! Our class exists, so now we just need to know if it passes its test method.
// @deprecated 12.3 Stop checking with test() // @deprecated 12.3 Stop checking with test()
if ($class::isSupported() || $class::test()) if ($class::isSupported() || $class::test())
{ {
Expand Down
8 changes: 4 additions & 4 deletions libraries/joomla/document/xml/xml.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class JDocumentXml extends JDocument
* Document name * Document name
* *
* @var string * @var string
* @since 11.1 * @since 12.1
*/ */
protected $_name = 'joomla'; protected $name = 'joomla';


/** /**
* Class constructor * Class constructor
Expand Down Expand Up @@ -71,7 +71,7 @@ public function render($cache = false, $params = array())
*/ */
public function getName() public function getName()
{ {
return $this->_name; return $this->name;
} }


/** /**
Expand All @@ -85,7 +85,7 @@ public function getName()
*/ */
public function setName($name = 'joomla') public function setName($name = 'joomla')
{ {
$this->_name = $name; $this->name = $name;


return $this; return $this;
} }
Expand Down
Loading

0 comments on commit 0c920a2

Please sign in to comment.