PageRenderTime 39ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/contentmanager/code/trunk/administrator/components/com_contentmanager/controllers/setup.php

https://bitbucket.org/eddieajau/the-art-of-joomla-archive
PHP | 70 lines | 31 code | 9 blank | 30 comment | 6 complexity | d7e5843cc7b38a88a8e2dd820f7e263e MD5 | raw file
  1. <?php
  2. /**
  3. * @version $Id: setup.php 52 2009-05-25 11:26:19Z eddieajau $
  4. * @copyright Copyright (C) 2009 New Life in IT Pty Ltd. All rights reserved.
  5. * @license GNU General Public License <http://www.gnu.org/copyleft/gpl.html>
  6. * @link http://www.theartofjoomla.com
  7. */
  8. // no direct access
  9. defined('_JEXEC') or die;
  10. jimport('joomla.application.component.controller');
  11. /**
  12. * The Setup Controller
  13. *
  14. * @package TAOJ.ContentManager
  15. * @subpackage com_contentmanager
  16. */
  17. class ContentManagerControllerSetup extends JController
  18. {
  19. /**
  20. * Method to manually install the component.
  21. *
  22. * @return void
  23. */
  24. public function install()
  25. {
  26. // Get the setup model.
  27. $model = &$this->getModel('Setup');
  28. // Attempt to run the manual install routine.
  29. if (!$model->install() || !$model->initAcl()) {
  30. $this->setMessage(JText::sprintf('TAOJ_Setup_Install_failed', $model->getError()), 'notice');
  31. }
  32. else {
  33. $this->setMessage(JText::_('TAOJ_Setup_install_success'));
  34. }
  35. // Set the redirect.
  36. $this->setRedirect('index.php?option=com_contentmanager');
  37. }
  38. /**
  39. * Method to process any available database upgrades.
  40. *
  41. * @return void
  42. */
  43. public function upgrade()
  44. {
  45. // Check for request forgeries
  46. JRequest::checkToken('request') or jexit(JText::_('ContMan_Invalid_Token'));
  47. // Get the upgrades.
  48. $version = new ContentManagerVersion();
  49. $upgrades = $version->getUpgrades();
  50. // Get the setup model.
  51. $model = &$this->getModel('Setup');
  52. // Attempt to run the upgrade routine.
  53. if ($model->upgrade() && $model->initAcl()) {
  54. $this->setMessage(JText::_('TAOJ_Setup_database_upgrade_success'));
  55. }
  56. else {
  57. $this->setMessage(JText::sprintf('TAOJ_Setup_database_upgrade_failed', $model->getError()), 'notice');
  58. }
  59. $this->setRedirect('index.php?option=com_contentmanager');
  60. }
  61. }