/techne/expressionengine/controllers/cp/addons.php

https://github.com/mondomon916/LYBC · PHP · 162 lines · 87 code · 31 blank · 44 comment · 14 complexity · 7160ba04eb92f66737545a452f42c1ba MD5 · raw file

  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. /**
  3. * ExpressionEngine - by EllisLab
  4. *
  5. * @package ExpressionEngine
  6. * @author ExpressionEngine Dev Team
  7. * @copyright Copyright (c) 2003 - 2010, EllisLab, Inc.
  8. * @license http://expressionengine.com/user_guide/license.html
  9. * @link http://expressionengine.com
  10. * @since Version 2.0
  11. * @filesource
  12. */
  13. // ------------------------------------------------------------------------
  14. /**
  15. * ExpressionEngine CP Home Page Class
  16. *
  17. * @package ExpressionEngine
  18. * @subpackage Control Panel
  19. * @category Control Panel
  20. * @author ExpressionEngine Dev Team
  21. * @link http://expressionengine.com
  22. */
  23. class Addons extends CI_Controller {
  24. /**
  25. * Constructor
  26. */
  27. public function __construct()
  28. {
  29. parent::__construct();
  30. // Can't access addons? Can't see this page!
  31. if ( ! $this->cp->allowed_group('can_access_addons'))
  32. {
  33. show_error($this->lang->line('unauthorized_access'));
  34. }
  35. $this->lang->loadfile('addons');
  36. $this->load->model('addons_model');
  37. }
  38. // --------------------------------------------------------------------
  39. /**
  40. * Index function
  41. *
  42. * @access public
  43. * @return void
  44. */
  45. function index()
  46. {
  47. if ( ! $this->cp->allowed_group('can_access_addons'))
  48. {
  49. show_error($this->lang->line('unauthorized_access'));
  50. }
  51. $this->cp->set_variable('cp_page_title', $this->lang->line('addons'));
  52. $this->load->vars(array('controller' => 'addons'));
  53. $this->javascript->compile();
  54. $this->load->view('_shared/overview');
  55. }
  56. // --------------------------------------------------------------------
  57. /**
  58. * Package Editor
  59. *
  60. * Install and remove package components
  61. *
  62. * @access public
  63. * @return mixed
  64. */
  65. function package_settings()
  66. {
  67. if ( ! $this->cp->allowed_group('can_access_addons'))
  68. {
  69. show_error($this->lang->line('unauthorized_access'));
  70. }
  71. $this->load->library('addons');
  72. $this->load->library('table');
  73. $this->load->helper('form');
  74. $this->load->model('addons_model');
  75. $this->lang->loadfile('modules');
  76. $return = $this->input->get_post('return');
  77. $package = $this->input->get_post('package');
  78. if ( ! $package OR ! $this->addons->is_package($package))
  79. {
  80. show_error($this->lang->line('unauthorized_access'));
  81. }
  82. $this->cp->set_variable('cp_page_title', $this->lang->line('package_settings'));
  83. $components = $this->addons->_packages[$package];
  84. if (isset($components['plugin']))
  85. {
  86. unset($components['plugin']);
  87. }
  88. if (count($_POST))
  89. {
  90. $install = array();
  91. $uninstall = array();
  92. foreach($components as $type => $info)
  93. {
  94. if ($new_state = $this->input->get_post('install_'.$type))
  95. {
  96. $installed_f = $type.'_installed';
  97. if (method_exists($this->addons_model, $installed_f))
  98. {
  99. $is_installed = $this->addons_model->$installed_f($package);
  100. if ($is_installed && ($new_state == 'uninstall'))
  101. {
  102. $uninstall[] = $type;
  103. }
  104. elseif ( ! $is_installed && ($new_state == 'install'))
  105. {
  106. $install[] = $type;
  107. }
  108. }
  109. }
  110. }
  111. $this->load->library('addons/addons_installer');
  112. $this->addons_installer->install($package, $install, FALSE);
  113. $this->addons_installer->uninstall($package, $uninstall, FALSE);
  114. $this->functions->redirect(BASE.AMP.'C='.$_GET['return']);
  115. }
  116. $vars = array();
  117. foreach($components as $type => $info)
  118. {
  119. $inst_func = $type.'_installed';
  120. $components[$type]['installed'] = $this->addons_model->$inst_func($package);
  121. }
  122. $vars['form_action'] = 'C=addons'.AMP.'M=package_settings'.AMP.'package='.$package.AMP.'return='.$return;
  123. $vars['package'] = ucfirst(str_replace('_', ' ', $package));
  124. $vars['components'] = $components;
  125. $this->javascript->compile();
  126. $this->load->view('addons/package_settings', $vars);
  127. }
  128. }
  129. // END CLASS
  130. /* End of file addons.php */
  131. /* Location: ./system/expressionengine/controllers/cp/addons.php */