| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: extension.php 14401 2010-01-26 14:10:00Z louis $ 4 * @package Joomla 5 * @subpackage Installer 6 * @copyright Copyright (C) 2005 - 2010 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 15 // Check to ensure this file is included in Joomla! 16 defined('_JEXEC') or die( 'Restricted access' ); 17 18 jimport( 'joomla.application.component.model' ); 19 20 /** 21 * Extension Manager Abstract Extension Model 22 * 23 * @abstract 24 * @package Joomla 25 * @subpackage Installer 26 * @since 1.5 27 */ 28 class InstallerModel extends JModel 29 { 30 /** @var array Array of installed components */ 31 var $_items = array(); 32 33 /** @var object JPagination object */ 34 var $_pagination = null; 35 36 /** 37 * Overridden constructor 38 * @access protected 39 */ 40 function __construct() 41 { 42 global $mainframe; 43 44 // Call the parent constructor 45 parent::__construct(); 46 47 // Set state variables from the request 48 $this->setState('pagination.limit', $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int')); 49 $this->setState('pagination.offset',$mainframe->getUserStateFromRequest('com_installer.limitstart.'.$this->_type, 'limitstart', 0, 'int')); 50 $this->setState('pagination.total', 0); 51 } 52 53 function &getItems() 54 { 55 if (empty($this->_items)) { 56 // Load the items 57 $this->_loadItems(); 58 } 59 return $this->_items; 60 } 61 62 function &getPagination() 63 { 64 if (empty($this->_pagination)) { 65 // Make sure items are loaded for a proper total 66 if (empty($this->_items)) { 67 // Load the items 68 $this->_loadItems(); 69 } 70 // Load the pagination object 71 jimport('joomla.html.pagination'); 72 $this->_pagination = new JPagination($this->_state->get('pagination.total'), $this->_state->get('pagination.offset'), $this->_state->get('pagination.limit')); 73 } 74 return $this->_pagination; 75 } 76 77 /** 78 * Remove (uninstall) an extension 79 * 80 * @static 81 * @param array An array of identifiers 82 * @return boolean True on success 83 * @since 1.0 84 */ 85 function remove($eid=array()) 86 { 87 global $mainframe; 88 89 // Initialize variables 90 $failed = array (); 91 92 /* 93 * Ensure eid is an array of extension ids in the form id => client_id 94 * TODO: If it isn't an array do we want to set an error and fail? 95 */ 96 if (!is_array($eid)) { 97 $eid = array($eid => 0); 98 } 99 100 // Get a database connector 101 $db =& JFactory::getDBO(); 102 103 // Get an installer object for the extension type 104 jimport('joomla.installer.installer'); 105 $installer = & JInstaller::getInstance(); 106 107 // Uninstall the chosen extensions 108 foreach ($eid as $id => $clientId) 109 { 110 $id = trim( $id ); 111 $result = $installer->uninstall($this->_type, $id, $clientId ); 112 113 // Build an array of extensions that failed to uninstall 114 if ($result === false) { 115 $failed[] = $id; 116 } 117 } 118 119 if (count($failed)) { 120 // There was an error in uninstalling the package 121 $msg = JText::sprintf('UNINSTALLEXT', JText::_($this->_type), JText::_('Error')); 122 $result = false; 123 } else { 124 // Package uninstalled sucessfully 125 $msg = JText::sprintf('UNINSTALLEXT', JText::_($this->_type), JText::_('Success')); 126 $result = true; 127 } 128 129 $mainframe->enqueueMessage($msg); 130 $this->setState('action', 'remove'); 131 $this->setState('name', $installer->get('name')); 132 $this->setState('message', $installer->message); 133 $this->setState('extension.message', $installer->get('extension.message')); 134 135 return $result; 136 } 137 138 function _loadItems() 139 { 140 return JError::raiseError( 500, JText::_('Method Not Implemented')); 141 } 142 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |