/libraries/rokcommon/RokCommon/Platform/Definition/Joomla.php

https://bitbucket.org/pastor399/newcastleunifc · PHP · 130 lines · 95 code · 12 blank · 23 comment · 18 complexity · d695bb82c06c672796528b2013eea2d8 MD5 · raw file

  1. <?php
  2. /**
  3. * @version $Id: Joomla.php 52337 2012-04-09 22:46:49Z btowles $
  4. * @author RocketTheme http://www.rockettheme.com
  5. * @copyright Copyright (C) 2007 - ${copyright_year} RocketTheme, LLC
  6. * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
  7. */
  8. class RokCommon_Platform_Definition_Joomla extends RokCommon_Platform_BaseDefinition
  9. {
  10. /**
  11. * Check to see if this is the current platform running
  12. * @static
  13. * @return bool true if this is the current platform, false if not.
  14. */
  15. public static function isCurrentlyRunning()
  16. {
  17. if (defined('_JEXEC') && defined('JVERSION')) {
  18. return true;
  19. }
  20. return false;
  21. }
  22. /**
  23. *
  24. */
  25. public function __construct()
  26. {
  27. $this->_name = 'joomla';
  28. if (self::isCurrentlyRunning()) {
  29. if (version_compare(JVERSION, '1.5', '>=') && version_compare(JVERSION, '1.6', '<')) {
  30. $this->populateJoomla15Info();
  31. } elseif (version_compare(JVERSION, '1.6', '>=') && version_compare(JVERSION, '1.7', '<')) {
  32. $this->populateJoomla16Info();
  33. } elseif (version_compare(JVERSION, '1.7', '>=')) {
  34. $this->populateJoomla17Info();
  35. } else {
  36. $this->_version = JVERSION;
  37. $this->_javascriptInfo = new RokCommon_Platform_Javascript();
  38. $this->_javascriptInfo->setName(RokCommon_Platform_Definition::UNKNOWN);
  39. $this->_javascriptInfo->setVerison(RokCommon_Platform_Definition::UNKNOWN_VERSION);
  40. }
  41. $this->populateLoaderChecks();
  42. } else {
  43. $this->_version = RokCommon_Platform_Definition::UNKNOWN_VERSION;
  44. $this->_javascriptInfo = new RokCommon_Platform_Javascript();
  45. $this->_javascriptInfo->setName(RokCommon_Platform_Definition::UNKNOWN);
  46. $this->_javascriptInfo->setVerison(RokCommon_Platform_Definition::UNKNOWN_VERSION);
  47. }
  48. }
  49. /**
  50. * Populate base information for a Joomla 1.5 instance
  51. */
  52. protected function populateJoomla15Info()
  53. {
  54. $this->_version = JVERSION;
  55. $this->_shortversion = '1.5';
  56. $this->_javascriptInfo = new RokCommon_Platform_Javascript();
  57. $this->_javascriptInfo->setName('mootools');
  58. $app = JFactory::getApplication();
  59. if (version_compare(JVERSION, '1.5.15', '<=')) {
  60. $mootools_version = JFactory::getApplication()->get('MooToolsVersion', '1.11');
  61. } else {
  62. $mootools_version = JFactory::getApplication()->get('MooToolsVersion', '1.12');
  63. }
  64. $matches = array();
  65. if (preg_match('/(\d+\.\d+\.?\d*) \+Compat/', $mootools_version, $matches)) {
  66. $mootools_version = $matches[1];
  67. }
  68. $this->_javascriptInfo->setVerison($mootools_version);
  69. }
  70. /**
  71. * Populate base information for a Joomla 1.6 instance
  72. */
  73. protected function populateJoomla16Info()
  74. {
  75. $this->_version = JVERSION;
  76. $this->_shortversion = '1.6';
  77. $this->_javascriptInfo = new RokCommon_Platform_Javascript();
  78. $this->_javascriptInfo->setName('mootools');
  79. $this->_javascriptInfo->setVerison('1.3');
  80. }
  81. /**
  82. * Populate base information for a Joomla 1.7 instance
  83. */
  84. protected function populateJoomla17Info()
  85. {
  86. $this->_version = JVERSION;
  87. $this->_shortversion = '1.7';
  88. $this->_javascriptInfo = new RokCommon_Platform_Javascript();
  89. $this->_javascriptInfo->setName('mootools');
  90. }
  91. protected function populateLoaderChecks()
  92. {
  93. $compat_17_versions = array($this->_version, '1.6.6');
  94. if (version_compare(JVERSION, '1.7', '>=')) {
  95. if ($this->_version != RokCommon_Platform_Definition::UNKNOWN_VERSION) {
  96. foreach ($compat_17_versions as $compat_version) {
  97. if ($this->_version != RokCommon_Platform_Definition::UNKNOWN_VERSION) {
  98. $this->_loaderchecks = array_merge($this->_loaderchecks, self::getChecksForVersion($this->_name, $compat_version));
  99. }
  100. }
  101. }
  102. $this->_loaderchecks[] = $this->_name;
  103. } else {
  104. parent::populateLoaderChecks();
  105. }
  106. }
  107. public function getOldVersionPlatformId()
  108. {
  109. if (version_compare(JVERSION, '1.6', '>='))
  110. {
  111. return '16';
  112. }
  113. else
  114. {
  115. return '15';
  116. }
  117. }
  118. }