PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/contentmanager/code/trunk/administrator/components/com_contentmanager/models/config.php

https://bitbucket.org/eddieajau/the-art-of-joomla-archive
PHP | 90 lines | 38 code | 12 blank | 40 comment | 4 complexity | dfa52689bd4114e7cd1da62fb281dc60 MD5 | raw file
  1. <?php
  2. /**
  3. * @version $Id: config.php 39 2009-05-21 07:32:36Z 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. // import library dependencies
  11. jimport('joomla.application.component.model');
  12. /**
  13. * The configuration model
  14. *
  15. * @package TAOJ.ContentManager
  16. * @subpackage com_contentmanager
  17. */
  18. class ContentManagerModelConfig extends JModel
  19. {
  20. /**
  21. * Flag to indicate model state initialization.
  22. *
  23. * @access protected
  24. * @var boolean
  25. */
  26. var $__state_set = null;
  27. /**
  28. * Overridden method to get model state variables.
  29. *
  30. * @access public
  31. * @param string $property Optional parameter name.
  32. * @return object The property where specified, the state object where omitted.
  33. * @since 1.0
  34. */
  35. function getState($property = null)
  36. {
  37. // if the model state is uninitialized lets set some values we will need from the request.
  38. if (!$this->__state_set)
  39. {
  40. // Load the parameters.
  41. $this->setState('params', JComponentHelper::getParams('com_contentmanager'));
  42. $this->__state_set = true;
  43. }
  44. return parent::getState($property);
  45. }
  46. /**
  47. * Method to save the component configuration
  48. *
  49. * @return boolean True on success
  50. */
  51. public function save()
  52. {
  53. // Initialize variables.
  54. $table = &JTable::getInstance('component');
  55. $params = JRequest::getVar('params', array(), 'post', 'array');
  56. $row = array();
  57. $row['option'] = 'com_contentmanager';
  58. $row['params'] = $params;
  59. // load the component data for com_contentmanager
  60. if (!$table->loadByOption('com_contentmanager')) {
  61. $this->setError($table->getError());
  62. return false;
  63. }
  64. // Bind the new values
  65. $table->bind($row);
  66. // Check the row.
  67. if (!$table->check()) {
  68. $this->setError($table->getError());
  69. return false;
  70. }
  71. // Store the row.
  72. if (!$table->store()) {
  73. $this->setError($table->getError());
  74. return false;
  75. }
  76. return true;
  77. }
  78. }