Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote-tracking branch 'upstream/master' into plgtpl

  • Loading branch information...
commit f2ac88e26488546a9750a64d64f0a47d545e5e98 2 parents 87c5dbb + 5da2f90
@phproberto phproberto authored
Showing with 3,085 additions and 2,696 deletions.
  1. +14 −2 build.xml
  2. +0 −145 build/phpcs/Joomla/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php
  3. +7 −8 build/phpcs/Joomla/ruleset.xml
  4. +11 −0 composer.json
  5. +6 −0 docs/manual/en-US/appendices/history.xml
  6. +3 −5 docs/manual/en-US/chapters/classes/jviewbase.xml
  7. +2 −2 docs/manual/en-US/chapters/classes/jviewhtml.xml
  8. +8 −4 libraries/import.legacy.php
  9. +1 −5 libraries/import.php
  10. +1 −1  libraries/joomla/access/rules.php
  11. +1 −1  libraries/joomla/application/base.php
  12. +1 −1  libraries/joomla/application/daemon.php
  13. +22 −6 libraries/joomla/application/web.php
  14. +11 −11 libraries/joomla/application/web/router.php
  15. +5 −5 libraries/joomla/application/web/router/base.php
  16. +9 −9 libraries/joomla/application/web/router/rest.php
  17. +1 −1  libraries/joomla/archive/archive.php
  18. +2 −0  libraries/joomla/archive/tar.php
  19. +7 −37 libraries/joomla/archive/zip.php
  20. +21 −17 libraries/joomla/base/adapter.php
  21. +4 −4 libraries/joomla/base/adapterinstance.php
  22. +0 −1  libraries/joomla/cache/cache.php
  23. +2 −2 libraries/joomla/cache/controller/callback.php
  24. +19 −6 libraries/joomla/cache/storage/cachelite.php
  25. +1 −5 libraries/joomla/client/ftp.php
  26. +1 −1  libraries/joomla/database/database.php
  27. +1 −1  libraries/joomla/database/driver.php
  28. +1 −1  libraries/joomla/database/driver/oracle.php
  29. +1 −4 libraries/joomla/database/driver/pdo.php
  30. +1 −14 libraries/joomla/database/driver/sqlite.php
  31. +0 −2  libraries/joomla/database/driver/sqlsrv.php
  32. +1 −238 libraries/joomla/database/exporter/mysql.php
  33. +239 −2 libraries/joomla/database/exporter/mysqli.php
  34. +1 −594 libraries/joomla/database/importer/mysql.php
  35. +595 −2 libraries/joomla/database/importer/mysqli.php
  36. +1 −0  libraries/joomla/date/date.php
  37. +12 −0 libraries/joomla/document/html/html.php
  38. +1 −1  libraries/joomla/document/html/renderer/head.php
  39. +1 −1  libraries/joomla/document/html/renderer/module.php
  40. +3 −2 libraries/joomla/factory.php
  41. +16 −5 libraries/joomla/filesystem/helper.php
  42. +0 −1  libraries/joomla/filesystem/patcher.php
  43. +1 −2  libraries/joomla/filesystem/path.php
  44. +1 −2  libraries/joomla/filesystem/stream.php
  45. +0 −1  libraries/joomla/filter/input.php
  46. +1 −1  libraries/joomla/form/field.php
  47. +1 −1  libraries/joomla/form/form.php
  48. 0  libraries/joomla/form/{rules → rule}/boolean.php
  49. 0  libraries/joomla/form/{rules → rule}/color.php
  50. 0  libraries/joomla/form/{rules → rule}/email.php
  51. 0  libraries/joomla/form/{rules → rule}/equals.php
  52. +1 −0  libraries/joomla/form/{rules → rule}/options.php
  53. 0  libraries/joomla/form/{rules → rule}/rules.php
  54. 0  libraries/joomla/form/{rules → rule}/tel.php
  55. 0  libraries/joomla/form/{rules → rule}/url.php
  56. 0  libraries/joomla/form/{rules → rule}/username.php
  57. +47 −47 libraries/joomla/grid/grid.php
  58. +76 −118 libraries/joomla/html/behavior.php
  59. +1 −2  libraries/joomla/html/grid.php
  60. +73 −13 libraries/joomla/html/html.php
  61. +10 −4 libraries/joomla/html/list.php
  62. +5 −15 libraries/joomla/html/sliders.php
  63. +6 −20 libraries/joomla/html/tabs.php
  64. +0 −1  libraries/joomla/http/factory.php
  65. +3 −2 libraries/joomla/http/transport/curl.php
  66. +12 −3 libraries/joomla/http/transport/stream.php
  67. +133 −0 libraries/joomla/image/image.php
  68. +1 −0  libraries/joomla/installer/adapters/component.php
  69. +3 −8 libraries/joomla/installer/adapters/file.php
  70. +1 −1  libraries/joomla/installer/adapters/language.php
  71. +2 −2 libraries/joomla/installer/adapters/library.php
  72. +1 −0  libraries/joomla/installer/adapters/module.php
  73. +1 −2  libraries/joomla/installer/adapters/package.php
  74. +1 −0  libraries/joomla/installer/adapters/plugin.php
  75. +1 −0  libraries/joomla/installer/adapters/template.php
  76. +2 −2 libraries/joomla/installer/extension.php
  77. +6 −10 libraries/joomla/installer/installer.php
  78. +0 −154 libraries/joomla/installer/librarymanifest.php
  79. +114 −0 libraries/joomla/installer/manifest.php
  80. +87 −0 libraries/joomla/installer/manifest/library.php
  81. +76 −0 libraries/joomla/installer/manifest/package.php
  82. +0 −141 libraries/joomla/installer/packagemanifest.php
  83. +1 −1  libraries/joomla/language/helper.php
  84. +5 −5 libraries/joomla/language/language.php
  85. +3 −2 libraries/joomla/language/text.php
  86. +1 −1  libraries/joomla/log/logger/callback.php
  87. +2 −2 libraries/joomla/log/logger/database.php
  88. +5 −4 libraries/joomla/mail/mail.php
  89. +1 −4 libraries/joomla/pagination/pagination.php
  90. +2 −2 libraries/joomla/plugin/helper.php
  91. +18 −3 libraries/joomla/session/session.php
  92. +6 −35 libraries/joomla/string/string.php
  93. +1 −1  libraries/joomla/table/asset.php
  94. +1 −1  libraries/joomla/table/language.php
  95. +2 −2 libraries/joomla/table/nested.php
  96. +1 −1  libraries/joomla/table/table.php
  97. +1 −1  libraries/joomla/table/update.php
  98. +1 −1  libraries/joomla/table/user.php
  99. +1 −1  libraries/joomla/table/usergroup.php
  100. +1 −1  libraries/joomla/table/viewlevel.php
  101. +20 −12 libraries/joomla/user/user.php
  102. +1 −1  libraries/joomla/utilities/arrayhelper.php
  103. +20 −8 libraries/legacy/application/application.php
  104. +2 −5 libraries/legacy/base/node.php
  105. +2 −2 libraries/legacy/base/tree.php
  106. +4 −7 libraries/legacy/categories/categories.php
  107. +5 −9 libraries/legacy/component/helper.php
  108. +0 −515 libraries/legacy/editor/editor.php
  109. +1 −1  libraries/legacy/model/admin.php
  110. +1 −1  libraries/legacy/model/form.php
  111. +1 −1  libraries/legacy/table/category.php
  112. +2 −2 libraries/legacy/table/content.php
  113. +2 −2 libraries/legacy/table/menu.php
  114. +1 −1  libraries/legacy/table/menu/type.php
  115. +1 −1  libraries/legacy/table/module.php
  116. +10 −1 libraries/legacy/table/session.php
  117. +6 −7 libraries/legacy/view/legacy.php
  118. +1 −16 libraries/legacy/web/web.php
  119. +4 −0 tests/bootstrap.php
  120. +8 −1 tests/core/case/database.php
  121. +8 −2 tests/core/case/database/oracle.php
  122. +0 −92 tests/suites/legacy/editor/JEditorTest.php
  123. +33 −1 tests/suites/unit/joomla/access/JAccessTest.php
  124. +26 −1 tests/suites/unit/joomla/access/JRuleTest.php
  125. +59 −0 tests/suites/unit/joomla/access/JRulesTest.php
  126. +11 −4 tests/suites/unit/joomla/application/JApplicationBaseTest.php
  127. +5 −5 tests/suites/unit/joomla/application/web/router/JApplicationWebRouterRestTest.php
  128. +44 −6 tests/suites/unit/joomla/archive/JArchiveBzip2Test.php
  129. +49 −9 tests/suites/unit/joomla/archive/JArchiveGzipTest.php
  130. +21 −7 tests/suites/unit/joomla/archive/JArchiveTarTest.php
  131. +18 −14 tests/suites/unit/joomla/archive/JArchiveTest.php
  132. +29 −0 tests/suites/unit/joomla/archive/JArchiveZipInspector.php
  133. +105 −28 tests/suites/unit/joomla/archive/JArchiveZipTest.php
  134. +121 −20 tests/suites/unit/joomla/document/JDocumentTest.php
  135. +23 −19 tests/suites/unit/joomla/filesystem/JFileTest.php
  136. +28 −26 tests/suites/unit/joomla/filesystem/JFilesystemHelperTest.php
  137. +14 −9 tests/suites/unit/joomla/filesystem/JFolderTest.php
  138. +12 −5 tests/suites/unit/joomla/form/fields/JFormFieldAccessLevelTest.php
  139. +12 −5 tests/suites/unit/joomla/form/fields/JFormFieldPluginsTest.php
  140. +12 −5 tests/suites/unit/joomla/form/fields/JFormFieldSQLTest.php
  141. +12 −5 tests/suites/unit/joomla/form/fields/JFormFieldUsergroupTest.php
  142. +0 −1  tests/suites/unit/joomla/form/{rules → rule}/JFormRuleBooleanTest.php
  143. +0 −1  tests/suites/unit/joomla/form/{rules → rule}/JFormRuleColorTest.php
  144. +0 −1  tests/suites/unit/joomla/form/{rules → rule}/JFormRuleEmailTest.php
  145. +0 −1  tests/suites/unit/joomla/form/{rules → rule}/JFormRuleEqualsTest.php
  146. +0 −1  tests/suites/unit/joomla/form/{rules → rule}/JFormRuleOptionsTest.php
  147. +0 −3  tests/suites/unit/joomla/form/{rules → rule}/JFormRuleRulesTest.php
  148. +0 −1  tests/suites/unit/joomla/form/{rules → rule}/JFormRuleTelTest.php
  149. +0 −3  tests/suites/unit/joomla/form/{rules → rule}/JFormRuleUrlTest.php
  150. +0 −1  tests/suites/unit/joomla/form/{rules → rule}/JFormRuleUsernameTest.php
  151. +46 −0 tests/suites/unit/joomla/installer/JInstallerManifestTest.php
  152. +1 −1  tests/suites/unit/joomla/installer/JInstallerTest.php
  153. +22 −0 tests/suites/unit/joomla/installer/data/joomla.xml
  154. +17 −0 tests/suites/unit/joomla/installer/data/pkg_joomla.xml
  155. +100 −0 tests/suites/unit/joomla/installer/manifest/JInstallerManifestLibraryTest.php
  156. +90 −0 tests/suites/unit/joomla/installer/manifest/JInstallerManifestPackageTest.php
  157. +27 −7 tests/suites/unit/joomla/language/JLanguageStemmerTest.php
  158. +3 −3 tests/suites/unit/joomla/log/JLogEntryTest.php
  159. +1 −0  tests/suites/unit/joomla/log/loggers/JLogLoggerMessageQueueTest.php
  160. +15 −2 tests/suites/unit/joomla/string/JStringInflectorTest.php
  161. +49 −42 tests/suites/unit/joomla/string/JStringNormaliseTest.php
  162. +34 −1 tests/suites/unit/joomla/string/JStringTest.php
  163. +1 −0  tests/suites/unit/joomla/user/JAuthenticationTest.php
  164. +4 −2 tests/suites/unit/joomla/user/JUserHelperTest.php
  165. +15 −1 tests/suites/unit/joomla/user/JUserTest.php
  166. +14 −0 tests/suites/unit/joomla/user/JUserTest.xml
  167. +18 −0 tests/suites/unit/joomla/utilities/JArrayHelperTest.php
  168. +2 −1  tests/suites/unit/joomla/utilities/JUtilityTest.php
  169. +138 −0 tests/version.php
View
16 build.xml
@@ -2,7 +2,7 @@
<project name="joomla-platform" default="build" basedir=".">
<property name="source" value="libraries" />
- <property name="joomlasource" value="libraries/joomla,libraries/platform.php,libraries/loader.php,libraries/import.php" />
+ <property name="joomlasource" value="libraries/joomla,libraries/legacy,libraries/compat,libraries/platform.php,libraries/loader.php,libraries/import.php" />
<target name="clean" description="Clean up and create artifact directories">
<delete dir="${basedir}/build/api" />
@@ -80,9 +80,10 @@
<target name="phpcs" description="Generate checkstyle.xml using PHP_CodeSniffer">
<exec executable="phpcs">
<arg value="--report=checkstyle" />
+ <arg value="--extensions=php,css" />
<arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
<arg value="--standard=${basedir}/build/phpcs/Joomla" />
- <arg value="--ignore=${source}/phpmailer,${source}/phputf8,${source}/simplepie/,${source}/config.example.php" />
+ <arg value="--ignore=config.example.php" />
<arg path="${source}" />
</exec>
</target>
@@ -111,5 +112,16 @@
</exec>
</target>
+ <target name="lint" description="Perform syntax check of sourcecode files">
+ <apply executable="php" failonerror="true">
+ <arg value="-l" />
+
+ <fileset dir="${source}">
+ <include name="**/*.php" />
+ <modified />
+ </fileset>
+ </apply>
+ </target>
+
<target name="build" depends="clean,phpunit,phpunit-legacy,parallelTasks,phpcb" />
</project>
View
145 build/phpcs/Joomla/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php
@@ -1,145 +0,0 @@
-<?php
-/**
- * Joomla_Sniffs_Whitespace_ScopeClosingBraceSniff.
- *
- * PHP version 5
- *
- * @category PHP
- * @package PHP_CodeSniffer
- * @author Greg Sherwood <gsherwood@squiz.net>
- * @author Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version CVS: $Id: ScopeClosingBraceSniff.php 287526 2009-08-21 05:42:05Z squiz $
- * @link http://pear.php.net/package/PHP_CodeSniffer
- */
-
-/**
- * Joomla_Sniffs_Whitespace_ScopeClosingBraceSniff.
- *
- * Checks that the closing braces of scopes are aligned correctly.
- *
- * @category PHP
- * @package PHP_CodeSniffer
- * @author Greg Sherwood <gsherwood@squiz.net>
- * @author Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version Release: 1.3.0RC2
- * @link http://pear.php.net/package/PHP_CodeSniffer
- */
-class Joomla_Sniffs_WhiteSpace_ScopeClosingBraceSniff implements PHP_CodeSniffer_Sniff
-{
-
-
- /**
- * Returns an array of tokens this test wants to listen for.
- *
- * @return array
- */
- public function register()
- {
- return PHP_CodeSniffer_Tokens::$scopeOpeners;
-
- }//end register()
-
-
- /**
- * Processes this test, when one of its tokens is encountered.
- *
- * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document.
- * @param int $stackPtr The position of the current token
- * in the stack passed in $tokens.
- *
- * @return void
- */
- public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
- {
- $tokens = $phpcsFile->getTokens();
-
- // If this is an inline condition (ie. there is no scope opener), then
- // return, as this is not a new scope.
- if (isset($tokens[$stackPtr]['scope_closer']) === false) {
- return;
- }
-
- $scopeStart = $tokens[$stackPtr]['scope_opener'];
- $scopeEnd = $tokens[$stackPtr]['scope_closer'];
-
- // If the scope closer doesn't think it belongs to this scope opener
- // then the opener is sharing its closer ith other tokens. We only
- // want to process the closer once, so skip this one.
- if ($tokens[$scopeEnd]['scope_condition'] !== $stackPtr) {
- return;
- }
-
- // We need to actually find the first piece of content on this line,
- // because if this is a method with tokens before it (public, static etc)
- // or an if with an else before it, then we need to start the scope
- // checking from there, rather than the current token.
- $lineStart = ($stackPtr - 1);
- for ($lineStart; $lineStart > 0; $lineStart--) {
- if (strpos($tokens[$lineStart]['content'], $phpcsFile->eolChar) !== false) {
- break;
- }
- }
-
- // We found a new line, now go forward and find the first non-whitespace
- // token.
- $lineStart= $phpcsFile->findNext(
- array(T_WHITESPACE),
- ($lineStart + 1),
- null,
- true
- );
-
- $startColumn = $tokens[$lineStart]['column'];
-
- // Check that the closing brace is on it's own line.
- $lastContent = $phpcsFile->findPrevious(
- array(T_WHITESPACE),
- ($scopeEnd - 1),
- $scopeStart,
- true
- );
-
- if ($tokens[$lastContent]['line'] === $tokens[$scopeEnd]['line']) {
- $error = 'Closing brace must be on a line by itself';
- $phpcsFile->addError($error, $scopeEnd, 'Line');
- return;
- }
-
- // Check now that the closing brace is lined up correctly.
- $braceIndent = $tokens[$scopeEnd]['column'];
- $isBreakCloser = ($tokens[$scopeEnd]['code'] === T_BREAK);
- if (in_array($tokens[$stackPtr]['code'], array(T_CASE, T_DEFAULT)) === true
- && $isBreakCloser === true
- ) {
- // BREAK statements should be indented 4 spaces from the
- // CASE or DEFAULT statement.
- if ($braceIndent !== ($startColumn + 4)) {
-// TODO AJE Allow for tab indents instead of spaces
-// $error = 'Break statement indented incorrectly; expected %s spaces, found %s';
-// $data = array(
-// ($startColumn + 3),
-// ($braceIndent - 1),
-// );
-// $phpcsFile->addError($error, $scopeEnd, 'BreakIdent', $data);
- }
- } else {
- if ($braceIndent !== $startColumn) {
- $error = 'Closing brace indented incorrectly; expected %s spaces, found %s';
- $data = array(
- ($startColumn - 1),
- ($braceIndent - 1),
- );
- $phpcsFile->addError($error, $scopeEnd, 'Indent', $data);
- }
- }
-
- }//end process()
-
-
-}//end class
-
-?>
View
15 build/phpcs/Joomla/ruleset.xml
@@ -2,15 +2,12 @@
<ruleset name="Joomla">
<description>The Joomla coding standard.</description>
- <!-- Exclude all javascript files. There are bugs and we don't have any rules anyways. -->
- <exclude-pattern>*.js</exclude-pattern>
-
<!-- Exclude 3rd party libraries. -->
- <exclude-pattern>*/phputf8/*</exclude-pattern>
- <exclude-pattern>*/simplepie/*</exclude-pattern>
- <exclude-pattern>*/phpmailer/phpmailer.php</exclude-pattern>
- <exclude-pattern>*/phpmailer/smtp.php</exclude-pattern>
- <exclude-pattern>*/phpmailer/pop3.php</exclude-pattern>
+ <exclude-pattern>phputf8/*</exclude-pattern>
+ <exclude-pattern>simplepie/*</exclude-pattern>
+ <exclude-pattern>phpmailer/phpmailer.php</exclude-pattern>
+ <exclude-pattern>phpmailer/smtp.php</exclude-pattern>
+ <exclude-pattern>phpmailer/pop3.php</exclude-pattern>
<exclude-pattern>*/mootree*.css</exclude-pattern>
<exclude-pattern>*/mooRainbow.css</exclude-pattern>
<exclude-pattern>*/modal.css</exclude-pattern>
@@ -52,6 +49,8 @@
<rule ref="Squiz.Scope.StaticThisUsage"/>
+ <rule ref="Squiz.WhiteSpace.ScopeClosingBrace"/>
+
<!-- Lines can be 85 chars long, but never show errors -->
<rule ref="Generic.Files.LineLength">
<properties>
View
11 composer.json
@@ -0,0 +1,11 @@
+{
+ "name": "joomla/joomla-platform",
+ "type": "library",
+ "description": "The Joomla Platform is a platform for writing Web and command line applications in PHP.",
+ "keywords": ["joomla","platform"],
+ "homepage": "https://github.com/joomla/joomla-platform",
+ "license": "GNU Public License",
+ "require": {
+ "php": ">=5.3.1"
+ }
+}
View
6 docs/manual/en-US/appendices/history.xml
@@ -8,6 +8,12 @@
<title>Release History</title>
<section>
+ <title>Version 12.1</title>
+
+ <para>Version 12.1 ("Louis Landry") of the Joomla Platform was tagged and released on 10 May 2012.</para>
+ </section>
+
+ <section>
<title>Version 11.4</title>
<para>Version 11.4 ("Brian Kernighan") of the Joomla Platform was tagged and released on 4 January 2012.</para>
View
8 docs/manual/en-US/chapters/classes/jviewbase.xml
@@ -10,11 +10,9 @@
<section>
<title>Construction</title>
- <para>The contructor for <classname>JViewBase</classname> takes a <classname>JModel</classname> object and a
- <classname>JController</classname> object. Both are mandatory.</para>
+ <para>The contructor for <classname>JViewBase</classname> takes a mandatory <classname>JModel</classname> parameter.</para>
- <para>Note that these are interfaces so the objects do no necessarily have to extend from <classname>JModelBase</classname> or
- <classname>JControllerBase</classname> classes. Given that, the view should only rely on the API that is exposed by the
+ <para>Note that JModel is an interface so the actual object passed does necessarily have to extend from <classname>JModelBase</classname> class. Given that, the view should only rely on the API that is exposed by the
interface and not concrete classes unless the contructor is changed in a derived class to take more explicit classes or
interaces as required by the developer.</para>
</section>
@@ -62,7 +60,7 @@ class MyView extends JViewBase
try
{
- $view = new MyView(new MyDatabaseModel, new MyController);
+ $view = new MyView(new MyDatabaseModel);
echo $view-&gt;render();
}
catch (RuntimeException $e)
View
4 docs/manual/en-US/chapters/classes/jviewhtml.xml
@@ -11,7 +11,7 @@
<title>Construction</title>
<para><classname>JViewHtml</classname> is extended from <classname>JViewBase</classname>. The constructor, in addition to the
- model and controller arguments, take an optional <classname>SplPriorityQueue</classname> object that serves as a lookup for
+ required model argument, take an optional <classname>SplPriorityQueue</classname> object that serves as a lookup for
layouts. If omitted, the view defers to the protected <methodname>loadPaths</methodname> method.</para>
</section>
@@ -69,7 +69,7 @@ try
$paths = new SplPriorityQueue;
$paths-&gt;insert(__DIR__ . '/layouts');
- $view = new MyView(new MyDatabaseModel, new MyController, $paths);
+ $view = new MyView(new MyDatabaseModel, $paths);
$view-&gt;setLayout('count');
echo $view-&gt;render();
View
12 libraries/import.legacy.php
@@ -18,15 +18,19 @@
{
define('IS_WIN', ($os === 'WIN') ? true : false);
}
-if (!defined('IS_MAC'))
-{
- define('IS_MAC', ($os === 'MAC') ? true : false);
-}
if (!defined('IS_UNIX'))
{
define('IS_UNIX', (($os !== 'MAC') && ($os !== 'WIN')) ? true : false);
}
+/**
+ * @deprecated 13.3 Use IS_UNIX instead
+ */
+if (!defined('IS_MAC'))
+{
+ define('IS_MAC', (IS_UNIX === true && ($os === 'DAR' || $os === 'MAC')) ? true : false);
+}
+
// Import the platform version library if necessary.
if (!class_exists('JPlatform'))
{
View
6 libraries/import.php
@@ -18,13 +18,9 @@
{
define('IS_WIN', ($os === 'WIN') ? true : false);
}
-if (!defined('IS_MAC'))
-{
- define('IS_MAC', ($os === 'MAC') ? true : false);
-}
if (!defined('IS_UNIX'))
{
- define('IS_UNIX', (($os !== 'MAC') && ($os !== 'WIN')) ? true : false);
+ define('IS_UNIX', (IS_WIN === false) ? true : false);
}
// Import the platform version library if necessary.
View
2  libraries/joomla/access/rules.php
@@ -178,7 +178,7 @@ public function allow($action, $identity)
*
* @param mixed $identity An integer representing the identity or an array of identities
*
- * @return object Allowed actions for the identity or identities
+ * @return JObject Allowed actions for the identity or identities
*
* @since 11.1
*/
View
2  libraries/joomla/application/base.php
@@ -73,7 +73,7 @@ public function getIdentity()
* Registers a handler to a particular event group.
*
* @param string $event The event name.
- * @param callback $handler The handler, a function or an instance of a event object.
+ * @param callable $handler The handler, a function or an instance of a event object.
*
* @return JApplicationBase The application to allow chaining.
*
View
2  libraries/joomla/application/daemon.php
@@ -858,7 +858,7 @@ protected function pcntlFork()
* Method to install a signal handler.
*
* @param integer $signal The signal number.
- * @param callback $handler The signal handler which may be the name of a user created function,
+ * @param callable $handler The signal handler which may be the name of a user created function,
* or method, or either of the two global constants SIG_IGN or SIG_DFL.
* @param boolean $restart Specifies whether system call restarting should be used when this
* signal arrives.
View
28 libraries/joomla/application/web.php
@@ -1038,19 +1038,18 @@ public function loadSession(JSession $session = null)
'force_ssl' => $this->get('force_ssl')
);
+ $this->registerEvent('onAfterSessionStart', array($this, 'afterSessionStart'));
+
// Instantiate the session object.
$session = JSession::getInstance($handler, $options);
- $session->initialise($this->input);
+ $session->initialise($this->input, $this->dispatcher);
if ($session->getState() == 'expired')
{
$session->restart();
}
-
- // If the session is new, load the user and registry objects.
- if ($session->isNew())
+ else
{
- $session->set('registry', new JRegistry);
- $session->set('user', new JUser);
+ $session->start();
}
// Set the session object.
@@ -1060,6 +1059,23 @@ public function loadSession(JSession $session = null)
}
/**
+ * After the session has been started we need to populate it with some default values.
+ *
+ * @return void
+ *
+ * @since 12.2
+ */
+ public function afterSessionStart()
+ {
+ $session = JFactory::getSession();
+ if ($session->isNew())
+ {
+ $session->set('registry', new JRegistry('session'));
+ $session->set('user', new JUser);
+ }
+ }
+
+ /**
* Method to load the system URI strings for the application.
*
* @param string $requestUri An optional request URI to use instead of detecting one from the
View
22 libraries/joomla/application/web/router.php
@@ -14,31 +14,31 @@
*
* @package Joomla.Platform
* @subpackage Application
- * @since 12.3
+ * @since 12.2
*/
abstract class JApplicationWebRouter
{
/**
* @var JApplicationWeb The web application on whose behalf we are routing the request.
- * @since 12.3
+ * @since 12.2
*/
protected $app;
/**
* @var string The default page controller name for an empty route.
- * @since 12.3
+ * @since 12.2
*/
protected $default;
/**
* @var string Controller class name prefix for creating controller objects by name.
- * @since 12.3
+ * @since 12.2
*/
protected $controllerPrefix;
/**
* @var JInput An input object from which to derive the route.
- * @since 12.3
+ * @since 12.2
*/
protected $input;
@@ -49,7 +49,7 @@
* @param JInput $input An optional input object from which to derive the route. If none
* is given than the input from the application object will be used.
*
- * @since 12.3
+ * @since 12.2
*/
public function __construct(JApplicationWeb $app, JInput $input = null)
{
@@ -64,7 +64,7 @@ public function __construct(JApplicationWeb $app, JInput $input = null)
*
* @return void
*
- * @since 12.3
+ * @since 12.2
* @throws InvalidArgumentException
* @throws RuntimeException
*/
@@ -87,7 +87,7 @@ public function execute($route)
*
* @return JApplicationWebRouter This object for method chaining.
*
- * @since 12.3
+ * @since 12.2
*/
public function setControllerPrefix($prefix)
{
@@ -103,7 +103,7 @@ public function setControllerPrefix($prefix)
*
* @return JApplicationWebRouter This object for method chaining.
*
- * @since 12.3
+ * @since 12.2
*/
public function setDefaultController($name)
{
@@ -119,7 +119,7 @@ public function setDefaultController($name)
*
* @return string The controller name for the given route excluding prefix.
*
- * @since 12.3
+ * @since 12.2
* @throws InvalidArgumentException
*/
abstract protected function parseRoute($route);
@@ -131,7 +131,7 @@ public function setDefaultController($name)
*
* @return JController
*
- * @since 12.3
+ * @since 12.2
* @throws RuntimeException
*/
protected function fetchController($name)
View
10 libraries/joomla/application/web/router/base.php
@@ -14,14 +14,14 @@
*
* @package Joomla.Platform
* @subpackage Application
- * @since 12.3
+ * @since 12.2
*/
class JApplicationWebRouterBase extends JApplicationWebRouter
{
/**
* @var array An array of rules, each rule being an associative array('regex'=> $regex, 'vars' => $vars, 'controller' => $controller)
* for routing the request.
- * @since 12.3
+ * @since 12.2
*/
protected $maps = array();
@@ -33,7 +33,7 @@ class JApplicationWebRouterBase extends JApplicationWebRouter
*
* @return JApplicationWebRouter This object for method chaining.
*
- * @since 12.3
+ * @since 12.2
*/
public function addMap($pattern, $controller)
{
@@ -104,7 +104,7 @@ public function addMap($pattern, $controller)
*
* @return JApplicationWebRouter This object for method chaining.
*
- * @since 12.3
+ * @since 12.2
*/
public function addMaps($maps)
{
@@ -123,7 +123,7 @@ public function addMaps($maps)
*
* @return string The controller name for the given route excluding prefix.
*
- * @since 12.3
+ * @since 12.2
* @throws InvalidArgumentException
*/
protected function parseRoute($route)
View
18 libraries/joomla/application/web/router/rest.php
@@ -14,20 +14,20 @@
*
* @package Joomla.Platform
* @subpackage Application
- * @since 12.3
+ * @since 12.2
*/
class JApplicationWebRouterRest extends JApplicationWebRouterBase
{
/**
* @var boolean A boolean allowing to pass _method as parameter in POST requests
*
- * @since 12.3
+ * @since 12.2
*/
protected $methodInPostRequest = false;
/**
* @var array An array of HTTP Method => controller suffix pairs for routing the request.
- * @since 12.3
+ * @since 12.2
*/
protected $suffixMap = array(
'GET' => 'Get',
@@ -46,7 +46,7 @@ class JApplicationWebRouterRest extends JApplicationWebRouterBase
*
* @return void
*
- * @since 12.3
+ * @since 12.2
* @throws InvalidArgumentException
* @throws RuntimeException
*/
@@ -73,7 +73,7 @@ public function execute($route)
*
* @return JApplicationWebRouter This object for method chaining.
*
- * @since 12.3
+ * @since 12.2
*/
public function setHttpMethodSuffix($method, $suffix)
{
@@ -89,7 +89,7 @@ public function setHttpMethodSuffix($method, $suffix)
*
* @return void
*
- * @since 12.3
+ * @since 12.2
*/
public function setMethodInPostRequest($value)
{
@@ -101,9 +101,9 @@ public function setMethodInPostRequest($value)
*
* @return boolean
*
- * @since 12.3
+ * @since 12.2
*/
- public function getMethodInPostRequest()
+ public function isMethodInPostRequest()
{
return $this->methodInPostRequest;
}
@@ -113,7 +113,7 @@ public function getMethodInPostRequest()
*
* @return string
*
- * @since 12.3
+ * @since 12.2
* @throws RuntimeException
*/
protected function fetchControllerSuffix()
View
2  libraries/joomla/archive/archive.php
@@ -171,7 +171,7 @@ public static function extract($archivename, $extractdir)
*
* @param string $type The type of adapter (bzip2|gzip|tar|zip).
*
- * @return object JArchiveExtractable
+ * @return JArchiveExtractable Adapter for the requested type
*
* @since 11.1
* @throws UnexpectedValueException
View
2  libraries/joomla/archive/tar.php
@@ -9,6 +9,8 @@
defined('JPATH_PLATFORM') or die;
+jimport('joomla.filesystem.folder');
+
/**
* Tar format adapter for the JArchive class
*
View
44 libraries/joomla/archive/zip.php
@@ -9,6 +9,8 @@
defined('JPATH_PLATFORM') or die;
+jimport('joomla.filesystem.folder');
+
/**
* ZIP format adapter for the JArchive class
*
@@ -89,7 +91,6 @@ class JArchiveZip implements JArchiveExtractable
*
* @param string $archive Path to save archive.
* @param array $files Array of files to add to archive.
- * @param array $options Compression options (unused).
*
* @return boolean True if successful.
*
@@ -97,7 +98,7 @@ class JArchiveZip implements JArchiveExtractable
*
* @todo Finish Implementation
*/
- public function create($archive, $files, array $options = array())
+ public function create($archive, $files)
{
$contents = array();
$ctrldir = array();
@@ -138,11 +139,11 @@ public function extract($archive, $destination, array $options = array())
if ($this->hasNativeSupport())
{
- return $this->_extractNative($archive, $destination, $options);
+ return $this->extractNative($archive, $destination);
}
else
{
- return $this->_extract($archive, $destination, $options);
+ return $this->extractCustom($archive, $destination);
}
}
@@ -196,14 +197,13 @@ public function checkZipData(&$data)
*
* @param string $archive Path to ZIP archive to extract.
* @param string $destination Path to extract archive into.
- * @param array $options Extraction options [unused].
*
* @return mixed True if successful
*
* @since 11.1
* @throws RuntimeException
*/
- private function _extract($archive, $destination, array $options)
+ protected function extractCustom($archive, $destination)
{
$this->_data = null;
$this->_metadata = null;
@@ -289,14 +289,13 @@ private function _extract($archive, $destination, array $options)
*
* @param string $archive Path to ZIP archive to extract
* @param string $destination Path to extract archive into
- * @param array $options Extraction options [unused]
*
* @return boolean True on success
*
* @since 11.1
* @throws RuntimeException
*/
- private function _extractNative($archive, $destination, array $options)
+ protected function extractNative($archive, $destination)
{
$zip = zip_open($archive);
if (is_resource($zip))
@@ -540,35 +539,6 @@ private function _getFileData($key)
}
/**
- * Converts a UNIX timestamp to a 4-byte DOS date and time format
- * (date in high 2-bytes, time in low 2-bytes allowing magnitude
- * comparison).
- *
- * @param integer $unixtime The current UNIX timestamp.
- *
- * @return integer The current date in a 4-byte DOS format.
- *
- * @since 11.1
- */
- private function _unix2DOSTime($unixtime = null)
- {
- $timearray = (is_null($unixtime)) ? getdate() : getdate($unixtime);
-
- if ($timearray['year'] < 1980)
- {
- $timearray['year'] = 1980;
- $timearray['mon'] = 1;
- $timearray['mday'] = 1;
- $timearray['hours'] = 0;
- $timearray['minutes'] = 0;
- $timearray['seconds'] = 0;
- }
-
- return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | ($timearray['hours'] << 11) |
- ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
- }
-
- /**
* Adds a "file" to the ZIP archive.
*
* @param array &$file File data array to add
View
38 libraries/joomla/base/adapter.php
@@ -9,9 +9,6 @@
defined('JPATH_PLATFORM') or die;
-jimport('joomla.filesystem.file');
-jimport('joomla.filesystem.folder');
-
/**
* Adapter Class
* Retains common adapter pattern functions
@@ -165,27 +162,34 @@ public function getAdapter($name, $options = array())
*/
public function loadAllAdapters($options = array())
{
- $list = JFolder::files($this->_basepath . '/' . $this->_adapterfolder);
+ $files = new DirectoryIterator($this->_basepath . '/' . $this->_adapterfolder);
- foreach ($list as $filename)
+ foreach ($files as $file)
{
- if (JFile::getExt($filename) == 'php')
+ $fileName = $file->getFilename();
+
+ // Only load for php files.
+ // Note: DirectoryIterator::getExtension only available PHP >= 5.3.6
+ if (!$file->isFile() || substr($fileName, strrpos($fileName, '.') + 1) != 'php')
{
- // Try to load the adapter object
- require_once $this->_basepath . '/' . $this->_adapterfolder . '/' . $filename;
+ continue;
+ }
- $name = JFile::stripExt($filename);
- $class = $this->_classprefix . ucfirst($name);
+ // Try to load the adapter object
+ require_once $this->_basepath . '/' . $this->_adapterfolder . '/' . $fileName;
- if (!class_exists($class))
- {
- // Skip to next one
- continue;
- }
+ // Derive the class name from the filename.
+ $name = str_ireplace('.php', '', ucfirst(trim($fileName)));
+ $class = $this->_classprefix . ucfirst($name);
- $adapter = new $class($this, $this->_db, $options);
- $this->_adapters[$name] = clone $adapter;
+ if (!class_exists($class))
+ {
+ // Skip to next one
+ continue;
}
+
+ $adapter = new $class($this, $this->_db, $options);
+ $this->_adapters[$name] = clone $adapter;
}
}
}
View
8 libraries/joomla/base/adapterinstance.php
@@ -21,7 +21,7 @@ class JAdapterInstance extends JObject
/**
* Parent
*
- * @var JInstaller
+ * @var JAdapter
* @since 11.1
*/
protected $parent = null;
@@ -43,7 +43,7 @@ class JAdapterInstance extends JObject
*
* @since 11.1
*/
- public function __construct($parent, $db, $options = array())
+ public function __construct(JAdapter $parent, JDatabaseDriver $db, array $options = array())
{
// Set the properties from the options array that is passed in
$this->setProperties($options);
@@ -52,13 +52,13 @@ public function __construct($parent, $db, $options = array())
$this->parent = $parent;
// Pull in the global dbo in case something happened to it.
- $this->db = $db ? $db : JFactory::getDBO();
+ $this->db = $db ?: JFactory::getDBO();
}
/**
* Retrieves the parent object
*
- * @return object parent
+ * @return JAdapter parent
*
* @since 11.1
*/
View
1  libraries/joomla/cache/cache.php
@@ -96,7 +96,6 @@ public static function getStores()
// Get an iterator and loop trough the driver classes.
$iterator = new DirectoryIterator(__DIR__ . '/storage');
- $names = array();
foreach ($iterator as $file)
{
$fileName = $file->getFilename();
View
4 libraries/joomla/cache/controller/callback.php
@@ -46,7 +46,7 @@ public function call()
/**
* Executes a cacheable callback if not found in cache else returns cached output and result
*
- * @param mixed $callback Callback or string shorthand for a callback
+ * @param mixed $callback Callable or string shorthand for a callback
* @param array $args Callback arguments
* @param string $id Cache id
* @param boolean $wrkarounds True to use wrkarounds
@@ -184,7 +184,7 @@ public function get($callback, $args = array(), $id = false, $wrkarounds = false
/**
* Generate a callback cache id
*
- * @param callback $callback Callback to cache
+ * @param callable $callback Callback to cache
* @param array $args Arguments to the callback method to cache
*
* @return string MD5 Hash : function cache id
View
25 libraries/joomla/cache/storage/cachelite.php
@@ -111,21 +111,34 @@ public function getAll()
parent::getAll();
$path = $this->_root;
- jimport('joomla.filesystem.folder');
- $folders = JFolder::folders($path);
+ $folders = new DirectoryIterator($path);
$data = array();
foreach ($folders as $folder)
{
- $files = JFolder::files($path . '/' . $folder);
- $item = new JCacheStorageHelper($folder);
+ if (!$folder->isDir() || $folder->isDot())
+ {
+ continue;
+ }
+
+ $foldername = $folder->getFilename();
+
+ $files = new DirectoryIterator($path . '/' . $foldername);
+ $item = new JCacheStorageHelper($foldername);
foreach ($files as $file)
{
- $item->updateSize(filesize($path . '/' . $folder . '/' . $file) / 1024);
+ if (!$file->isFile())
+ {
+ continue;
+ }
+
+ $filename = $file->getFilename();
+
+ $item->updateSize(filesize($path . '/' . $foldername . '/' . $filename) / 1024);
}
- $data[$folder] = $item;
+ $data[$foldername] = $item;
}
return $data;
View
6 libraries/joomla/client/ftp.php
@@ -121,7 +121,7 @@ class JClientFtp
* @var array
* @since 12.1
*/
- private $_lineEndings = array('UNIX' => "\n", 'MAC' => "\r", 'WIN' => "\r\n");
+ private $_lineEndings = array('UNIX' => "\n", 'WIN' => "\r\n");
/**
* @var array JClientFtp instances container.
@@ -847,10 +847,6 @@ public function read($remote, &$buffer)
{
$os = 'WIN';
}
- elseif (IS_MAC)
- {
- $os = 'MAC';
- }
$buffer = preg_replace("/" . CRLF . "/", $this->_lineEndings[$os], $buffer);
}
View
2  libraries/joomla/database/database.php
@@ -93,7 +93,7 @@ public function getErrorNum()
/**
* Method to return a JDatabaseDriver instance based on the given options. There are three global options and then
* the rest are specific to the database driver. The 'driver' option defines which JDatabaseDriver class is
- * used for the connection -- the default is 'mysql'. The 'database' option determines which database is to
+ * used for the connection -- the default is 'mysqli'. The 'database' option determines which database is to
* be used for the connection. The 'select' option determines whether the connector should automatically select
* the chosen database.
*
View
2  libraries/joomla/database/driver.php
@@ -851,7 +851,7 @@ public function insertObject($table, &$object, $key = null)
// Update the primary key if it exists.
$id = $this->insertid();
- if ($key && $id)
+ if ($key && $id && is_string($key))
{
$object->$key = $id;
}
View
2  libraries/joomla/database/driver/oracle.php
@@ -515,7 +515,7 @@ public function unlockTables()
*/
public static function isSupported()
{
- return in_array('oci', PDO::getAvailableDrivers());
+ return class_exists('PDO') && in_array('oci', PDO::getAvailableDrivers());
}
/**
View
5 libraries/joomla/database/driver/pdo.php
@@ -952,10 +952,7 @@ public function __sleep()
// Get properties of the current class
$properties = $reflect->getProperties();
- // Static properties of the current class
- $staticProperties = $reflect->getStaticProperties();
-
- foreach ($properties as $key => $property)
+ foreach ($properties as $property)
{
// Do not serialize properties that are PDO
if ($property->isStatic() == false && !($this->{$property->name} instanceof PDO))
View
15 libraries/joomla/database/driver/sqlite.php
@@ -39,19 +39,6 @@ class JDatabaseDriverSqlite extends JDatabaseDriverPdo
protected $nameQuote = '`';
/**
- * Constructor.
- *
- * @param array $options List of options used to configure the connection
- *
- * @since 12.1
- */
- public function __construct($options)
- {
- // Finalize initialisation
- parent::__construct($options);
- }
-
- /**
* Destructor.
*
* @since 12.1
@@ -391,6 +378,6 @@ public function unlockTables()
*/
public static function isSupported()
{
- return in_array('sqlite', PDO::getAvailableDrivers());
+ return class_exists('PDO') && in_array('sqlite', PDO::getAvailableDrivers());
}
}
View
2  libraries/joomla/database/driver/sqlsrv.php
@@ -651,8 +651,6 @@ public function execute()
*/
public function replacePrefix($sql, $prefix = '#__')
{
- $tablePrefix = 'jos_';
-
$escaped = false;
$startPos = 0;
$quoteChar = '';
View
239 libraries/joomla/database/exporter/mysql.php
@@ -16,182 +16,9 @@
* @subpackage Database
* @since 11.1
*/
-class JDatabaseExporterMysql extends JDatabaseExporter
+class JDatabaseExporterMysql extends JDatabaseExporterMysqli
{
/**
- * An array of cached data.
- *
- * @var array
- * @since 11.1
- */
- protected $cache = array();
-
- /**
- * The database connector to use for exporting structure and/or data.
- *
- * @var JDatabaseDriverMysql
- * @since 11.1
- */
- protected $db = null;
-
- /**
- * An array input sources (table names).
- *
- * @var array
- * @since 11.1
- */
- protected $from = array();
-
- /**
- * The type of output format (xml).
- *
- * @var string
- * @since 11.1
- */
- protected $asFormat = 'xml';
-
- /**
- * An array of options for the exporter.
- *
- * @var object
- * @since 11.1
- */
- protected $options = null;
-
- /**
- * Constructor.
- *
- * Sets up the default options for the exporter.
- *
- * @since 11.1
- */
- public function __construct()
- {
- $this->options = new stdClass;
-
- $this->cache = array('columns' => array(), 'keys' => array());
-
- // Set up the class defaults:
-
- // Export with only structure
- $this->withStructure();
-
- // Export as xml.
- $this->asXml();
-
- // Default destination is a string using $output = (string) $exporter;
- }
-
- /**
- * Magic function to exports the data to a string.
- *
- * @return string
- *
- * @since 11.1
- * @throws Exception if an error is encountered.
- */
- public function __toString()
- {
- // Check everything is ok to run first.
- $this->check();
-
- $buffer = '';
-
- // Get the format.
- switch ($this->asFormat)
- {
- case 'xml':
- default:
- $buffer = $this->buildXml();
- break;
- }
-
- return $buffer;
- }
-
- /**
- * Set the output option for the exporter to XML format.
- *
- * @return JDatabaseExporterMySQL Method supports chaining.
- *
- * @since 11.1
- */
- public function asXml()
- {
- $this->asFormat = 'xml';
-
- return $this;
- }
-
- /**
- * Builds the XML data for the tables to export.
- *
- * @return string An XML string
- *
- * @since 11.1
- * @throws Exception if an error occurs.
- */
- protected function buildXml()
- {
- $buffer = array();
-
- $buffer[] = '<?xml version="1.0"?>';
- $buffer[] = '<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
- $buffer[] = ' <database name="">';
-
- $buffer = array_merge($buffer, $this->buildXmlStructure());
-
- $buffer[] = ' </database>';
- $buffer[] = '</mysqldump>';
-
- return implode("\n", $buffer);
- }
-
- /**
- * Builds the XML structure to export.
- *
- * @return array An array of XML lines (strings).
- *
- * @since 11.1
- * @throws Exception if an error occurs.
- */
- protected function buildXmlStructure()
- {
- $buffer = array();
-
- foreach ($this->from as $table)
- {
- // Replace the magic prefix if found.
- $table = $this->getGenericTableName($table);
-
- // Get the details columns information.
- $fields = $this->db->getTableColumns($table, false);
- $keys = $this->db->getTableKeys($table);
-
- $buffer[] = ' <table_structure name="' . $table . '">';
-
- foreach ($fields as $field)
- {
- $buffer[] = ' <field Field="' . $field->Field . '"' . ' Type="' . $field->Type . '"' . ' Null="' . $field->Null . '"' . ' Key="' .
- $field->Key . '"' . (isset($field->Default) ? ' Default="' . $field->Default . '"' : '') . ' Extra="' . $field->Extra . '"' .
- ' />';
- }
-
- foreach ($keys as $key)
- {
- $buffer[] = ' <key Table="' . $table . '"' . ' Non_unique="' . $key->Non_unique . '"' . ' Key_name="' . $key->Key_name . '"' .
- ' Seq_in_index="' . $key->Seq_in_index . '"' . ' Column_name="' . $key->Column_name . '"' . ' Collation="' . $key->Collation . '"' .
- ' Null="' . $key->Null . '"' . ' Index_type="' . $key->Index_type . '"' . ' Comment="' . htmlspecialchars($key->Comment) . '"' .
- ' />';
- }
-
- $buffer[] = ' </table_structure>';
- }
-
- return $buffer;
- }
-
- /**
* Checks if all data and options are in order prior to exporting.
*
* @return JDatabaseExporterMySQL Method supports chaining.
@@ -218,54 +45,6 @@ public function check()
}
/**
- * Get the generic name of the table, converting the database prefix to the wildcard string.
- *
- * @param string $table The name of the table.
- *
- * @return string The name of the table with the database prefix replaced with #__.
- *
- * @since 11.1
- */
- protected function getGenericTableName($table)
- {
- // TODO Incorporate into parent class and use $this.
- $prefix = $this->db->getPrefix();
-
- // Replace the magic prefix if found.
- $table = preg_replace("|^$prefix|", '#__', $table);
-
- return $table;
- }
-
- /**
- * Specifies a list of table names to export.
- *
- * @param mixed $from The name of a single table, or an array of the table names to export.
- *
- * @return JDatabaseExporterMysql Method supports chaining.
- *
- * @since 11.1
- * @throws Exception if input is not a string or array.
- */
- public function from($from)
- {
- if (is_string($from))
- {
- $this->from = array($from);
- }
- elseif (is_array($from))
- {
- $this->from = $from;
- }
- else
- {
- throw new Exception('JPLATFORM_ERROR_INPUT_REQUIRES_STRING_OR_ARRAY');
- }
-
- return $this;
- }
-
- /**
* Sets the database connector to use for exporting structure and/or data from MySQL.
*
* @param JDatabaseDriverMysql $db The database connector.
@@ -280,20 +59,4 @@ public function setDbo(JDatabaseDriverMysql $db)
return $this;
}
-
- /**
- * Sets an internal option to export the structure of the input table(s).
- *
- * @param boolean $setting True to export the structure, false to not.
- *
- * @return JDatabaseExporterMysql Method supports chaining.
- *
- * @since 11.1
- */
- public function withStructure($setting = true)
- {
- $this->options->withStructure = (boolean) $setting;
-
- return $this;
- }
}
View
241 libraries/joomla/database/exporter/mysqli.php
@@ -10,15 +10,188 @@
defined('JPATH_PLATFORM') or die;
/**
- * MySQL export driver.
+ * MySQLi export driver.
*
* @package Joomla.Platform
* @subpackage Database
* @since 11.1
*/
-class JDatabaseExporterMysqli extends JDatabaseExporterMysql
+class JDatabaseExporterMysqli extends JDatabaseExporter
{
/**
+ * An array of cached data.
+ *
+ * @var array
+ * @since 11.1
+ */
+ protected $cache = array();
+
+ /**
+ * The database connector to use for exporting structure and/or data.
+ *
+ * @var JDatabaseDriverMysql
+ * @since 11.1
+ */
+ protected $db = null;
+
+ /**
+ * An array input sources (table names).
+ *
+ * @var array
+ * @since 11.1
+ */
+ protected $from = array();
+
+ /**
+ * The type of output format (xml).
+ *
+ * @var string
+ * @since 11.1
+ */
+ protected $asFormat = 'xml';
+
+ /**
+ * An array of options for the exporter.
+ *
+ * @var object
+ * @since 11.1
+ */
+ protected $options = null;
+
+ /**
+ * Constructor.
+ *
+ * Sets up the default options for the exporter.
+ *
+ * @since 11.1
+ */
+ public function __construct()
+ {
+ $this->options = new stdClass;
+
+ $this->cache = array('columns' => array(), 'keys' => array());
+
+ // Set up the class defaults:
+
+ // Export with only structure
+ $this->withStructure();
+
+ // Export as xml.
+ $this->asXml();
+
+ // Default destination is a string using $output = (string) $exporter;
+ }
+
+ /**
+ * Magic function to exports the data to a string.
+ *
+ * @return string
+ *
+ * @since 11.1
+ * @throws Exception if an error is encountered.
+ */
+ public function __toString()
+ {
+ // Check everything is ok to run first.
+ $this->check();
+
+ $buffer = '';
+
+ // Get the format.
+ switch ($this->asFormat)
+ {
+ case 'xml':
+ default:
+ $buffer = $this->buildXml();
+ break;
+ }
+
+ return $buffer;
+ }
+
+ /**
+ * Set the output option for the exporter to XML format.
+ *
+ * @return JDatabaseExporterMySQL Method supports chaining.
+ *
+ * @since 11.1
+ */
+ public function asXml()
+ {
+ $this->asFormat = 'xml';
+
+ return $this;
+ }
+
+ /**
+ * Builds the XML data for the tables to export.
+ *
+ * @return string An XML string
+ *
+ * @since 11.1
+ * @throws Exception if an error occurs.
+ */
+ protected function buildXml()
+ {
+ $buffer = array();
+
+ $buffer[] = '<?xml version="1.0"?>';
+ $buffer[] = '<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
+ $buffer[] = ' <database name="">';
+
+ $buffer = array_merge($buffer, $this->buildXmlStructure());
+
+ $buffer[] = ' </database>';
+ $buffer[] = '</mysqldump>';
+
+ return implode("\n", $buffer);
+ }
+
+ /**
+ * Builds the XML structure to export.
+ *
+ * @return array An array of XML lines (strings).
+ *
+ * @since 11.1
+ * @throws Exception if an error occurs.
+ */
+ protected function buildXmlStructure()
+ {
+ $buffer = array();
+
+ foreach ($this->from as $table)
+ {
+ // Replace the magic prefix if found.
+ $table = $this->getGenericTableName($table);
+
+ // Get the details columns information.
+ $fields = $this->db->getTableColumns($table, false);
+ $keys = $this->db->getTableKeys($table);
+
+ $buffer[] = ' <table_structure name="' . $table . '">';
+
+ foreach ($fields as $field)
+ {
+ $buffer[] = ' <field Field="' . $field->Field . '"' . ' Type="' . $field->Type . '"' . ' Null="' . $field->Null . '"' . ' Key="' .
+ $field->Key . '"' . (isset($field->Default) ? ' Default="' . $field->Default . '"' : '') . ' Extra="' . $field->Extra . '"' .
+ ' />';
+ }
+
+ foreach ($keys as $key)
+ {
+ $buffer[] = ' <key Table="' . $table . '"' . ' Non_unique="' . $key->Non_unique . '"' . ' Key_name="' . $key->Key_name . '"' .
+ ' Seq_in_index="' . $key->Seq_in_index . '"' . ' Column_name="' . $key->Column_name . '"' . ' Collation="' . $key->Collation . '"' .
+ ' Null="' . $key->Null . '"' . ' Index_type="' . $key->Index_type . '"' . ' Comment="' . htmlspecialchars($key->Comment) . '"' .
+ ' />';
+ }
+
+ $buffer[] = ' </table_structure>';
+ }
+
+ return $buffer;
+ }
+
+ /**
* Checks if all data and options are in order prior to exporting.
*
* @return JDatabaseExporterMysqli Method supports chaining.
@@ -44,6 +217,54 @@ public function check()
}
/**
+ * Get the generic name of the table, converting the database prefix to the wildcard string.
+ *
+ * @param string $table The name of the table.
+ *
+ * @return string The name of the table with the database prefix replaced with #__.
+ *
+ * @since 11.1
+ */
+ protected function getGenericTableName($table)
+ {
+ // TODO Incorporate into parent class and use $this.
+ $prefix = $this->db->getPrefix();
+
+ // Replace the magic prefix if found.
+ $table = preg_replace("|^$prefix|", '#__', $table);
+
+ return $table;
+ }
+
+ /**
+ * Specifies a list of table names to export.
+ *
+ * @param mixed $from The name of a single table, or an array of the table names to export.
+ *
+ * @return JDatabaseExporterMysql Method supports chaining.
+ *
+ * @since 11.1
+ * @throws Exception if input is not a string or array.
+ */
+ public function from($from)
+ {
+ if (is_string($from))
+ {
+ $this->from = array($from);
+ }
+ elseif (is_array($from))
+ {
+ $this->from = $from;
+ }
+ else
+ {
+ throw new Exception('JPLATFORM_ERROR_INPUT_REQUIRES_STRING_OR_ARRAY');
+ }
+
+ return $this;
+ }
+
+ /**
* Sets the database connector to use for exporting structure and/or data from MySQL.
*
* @param JDatabaseDriverMysqli $db The database connector.
@@ -58,4 +279,20 @@ public function setDbo(JDatabaseDriverMysqli $db)
return $this;
}
+
+ /**
+ * Sets an internal option to export the structure of the input table(s).
+ *
+ * @param boolean $setting True to export the structure, false to not.
+ *
+ * @return JDatabaseExporterMysql Method supports chaining.
+ *
+ * @since 11.1
+ */
+ public function withStructure($setting = true)
+ {
+ $this->options->withStructure = (boolean) $setting;
+
+ return $this;
+ }
}
View
595 libraries/joomla/database/importer/mysql.php
@@ -16,85 +16,9 @@
* @subpackage Database
* @since 11.1
*/
-class JDatabaseImporterMysql extends JDatabaseImporter
+class JDatabaseImporterMysql extends JDatabaseImporterMysqli
{
/**
- * @var array An array of cached data.
- * @since 11.1
- */
- protected $cache = array();
-
- /**
- * The database connector to use for exporting structure and/or data.
- *
- * @var JDatabaseDriverMysql
- * @since 11.1
- */
- protected $db = null;
-
- /**
- * The input source.
- *
- * @var mixed
- * @since 11.1
- */
- protected $from = array();
-
- /**
- * The type of input format (XML).
- *
- * @var string
- * @since 11.1
- */
- protected $asFormat = 'xml';
-
- /**
- * An array of options for the exporter.
- *
- * @var object
- * @since 11.1
- */
- protected $options = null;
-
- /**
- * Constructor.
- *
- * Sets up the default options for the exporter.
- *
- * @since 11.1
- */
- public function __construct()
- {
- $this->options = new stdClass;
-
- $this->cache = array('columns' => array(), 'keys' => array());
-
- // Set up the class defaults:
-
- // Import with only structure
- $this->withStructure();
-
- // Export as XML.
- $this->asXml();
-
- // Default destination is a string using $output = (string) $exporter;
- }
-
- /**
- * Set the output option for the exporter to XML format.
- *
- * @return JDatabaseImporterMysql Method supports chaining.
- *
- * @since 11.1
- */
- public function asXml()
- {
- $this->asFormat = 'xml';
-
- return $this;
- }
-
- /**
* Checks if all data and options are in order prior to exporting.
*
* @return JDatabaseImporterMysql Method supports chaining.
@@ -120,507 +44,6 @@ public function check()
}
/**
- * Specifies the data source to import.
- *
- * @param mixed $from The data source to import.
- *
- * @return JDatabaseImporterMysql Method supports chaining.
- *
- * @since 11.1
- */
- public function from($from)
- {
- $this->from = $from;
-
- return $this;
- }
-
- /**
- * Get the SQL syntax to add a column.
- *
- * @param string $table The table name.
- * @param SimpleXMLElement $field The XML field definition.
- *
- * @return string
- *
- * @since 11.1
- */
- protected function getAddColumnSQL($table, SimpleXMLElement $field)
- {
- $sql = 'ALTER TABLE ' . $this->db->quoteName($table) . ' ADD COLUMN ' . $this->getColumnSQL($field);
-
- return $sql;
- }
-
- /**
- * Get the SQL syntax to add a key.
- *
- * @param string $table The table name.
- * @param array $keys An array of the fields pertaining to this key.
- *
- * @return string
- *
- * @since 11.1
- */
- protected function getAddKeySQL($table, $keys)
- {
- $sql = 'ALTER TABLE ' . $this->db->quoteName($table) . ' ADD ' . $this->getKeySQL($keys);
-
- return $sql;
- }
-
- /**
- * Get alters for table if there is a difference.
- *
- * @param SimpleXMLElement $structure The XML structure pf the table.
- *
- * @return array
- *
- * @since 11.1
- */
- protected function getAlterTableSQL(SimpleXMLElement $structure)
- {
- $table = $this->getRealTableName($structure['name']);
- $oldFields = $this->db->getTableColumns($table);
- $oldKeys = $this->db->getTableKeys($table);
- $alters = array();
-
- // Get the fields and keys from the XML that we are aiming for.
- $newFields = $structure->xpath('field');
- $newKeys = $structure->xpath('key');
-
- // Loop through each field in the new structure.
- foreach ($newFields as $field)
- {
- $fName = (string) $field['Field'];
-
- if (isset($oldFields[$fName]))
- {
- // The field exists, check it's the same.
- $column = $oldFields[