/administrator/components/com_jce/installer/models/extension.php

https://github.com/rkern21/videoeditor · PHP · 132 lines · 70 code · 24 blank · 38 comment · 9 complexity · 0d5d69154e38de3f9289d9f694639979 MD5 · raw file

  1. <?php
  2. /**
  3. * @version $Id: extension.php 47 2009-05-26 18:06:30Z happynoodleboy $
  4. * @package Joomla
  5. * @subpackage Menus
  6. * @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
  7. * @license GNU/GPL, see LICENSE.php
  8. * Joomla! is free software. This version may have been modified pursuant to the
  9. * GNU General Public License, and as distributed it includes or is derivative
  10. * of works licensed under the GNU General Public License or other free or open
  11. * source software licenses. See COPYRIGHT.php for copyright notices and
  12. * details.
  13. */
  14. // Import library dependencies
  15. require_once(dirname(__FILE__).DS.'extensions.php');
  16. /**
  17. * Installer Plugins Model
  18. *
  19. * @package Joomla
  20. * @subpackage Installer
  21. * @since 1.5
  22. */
  23. class InstallerModelExtension extends InstallerModel
  24. {
  25. /**
  26. * Extension Type
  27. * @var string
  28. */
  29. var $_type = 'extension';
  30. /**
  31. * Overridden constructor
  32. * @access protected
  33. */
  34. function __construct()
  35. {
  36. global $mainframe;
  37. // Call the parent constructor
  38. parent::__construct();
  39. }
  40. function _loadItems()
  41. {
  42. global $mainframe, $option;
  43. $extensions = $this->findExtensions();
  44. $this->setState('pagination.total', count($extensions));
  45. if($this->_state->get('pagination.limit') > 0) {
  46. $this->_items = array_slice( $extensions, $this->_state->get('pagination.offset'), $this->_state->get('pagination.limit') );
  47. } else {
  48. $this->_items = $extensions;
  49. }
  50. }
  51. function findExtensions()
  52. {
  53. $db = & JFactory::getDBO();
  54. $query = 'SELECT name'
  55. . ' FROM #__jce_plugins'
  56. . ' WHERE type = '. $db->Quote('plugin')
  57. ;
  58. $db->setQuery($query);
  59. $plugins = $db->loadResultArray();
  60. /*$query = 'SELECT extension'
  61. . ' FROM #__jce_extensions'
  62. ;
  63. $db->setQuery($query);
  64. $installed = $db->loadResultArray();*/
  65. $extensions = array();
  66. $language =& JFactory::getLanguage();
  67. foreach ($plugins as $plugin) {
  68. $xml = JCE_PLUGINS.DS.$plugin.DS.$plugin.'.xml';
  69. $ext = JCE_PLUGINS.DS.$plugin.DS.'extensions';
  70. if (is_dir($ext) && file_exists($xml)) {
  71. $files = JFolder::files($ext, '\.xml$', true, true);
  72. foreach ($files as $file) {
  73. //if (!in_array(basename($file, '.xml'), $installed)) {
  74. $data = JApplicationHelper::parseXMLInstallFile($file);
  75. if (!is_array($data)) {
  76. continue;
  77. }
  78. $extension = new StdClass();
  79. // Populate the row from the xml meta file
  80. foreach ($data as $key => $value) {
  81. $extension->$key = $value;
  82. }
  83. $extension->id = '';
  84. // Read the file to see if it's a valid XML file
  85. $xml = & JFactory::getXMLParser('Simple');
  86. if ($xml->loadFile($file)) {
  87. if (is_object($xml->document) && $xml->document->attributes('type') == 'extension') {
  88. $plugin = $xml->document->attributes('plugin');
  89. $name = $xml->document->attributes('extension');
  90. $extension->id = $plugin.'.'.$xml->document->attributes('folder').'.'.$name;
  91. $language->load('com_jce_'.trim($plugin), JPATH_SITE);
  92. $language->load('com_jce_'.trim($plugin).'_'.trim($name), JPATH_SITE);
  93. $query = 'SELECT title'
  94. .' FROM #__jce_plugins'
  95. .' WHERE name = '.$db->Quote($xml->document->attributes('plugin'))
  96. ;
  97. $db->setQuery($query);
  98. $extension->plugin = $db->loadResult();
  99. }
  100. }
  101. $extensions[] = $extension;
  102. //}
  103. }
  104. }
  105. }
  106. return $extensions;
  107. }
  108. }