Files
@ f43d1a4680a9
Branch filter:
Location: hot67beta/administrator/components/com_installer/models/components.php
f43d1a4680a9
4.0 KiB
text/x-php
menubar 0 to 10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | <?php
/**
* @version $Id: components.php 10710 2008-08-21 10:08:12Z eddieajau $
* @package Joomla
* @subpackage Menus
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant to the
* GNU General Public License, and as distributed it includes or is derivative
* of works licensed under the GNU General Public License or other free or open
* source software licenses. See COPYRIGHT.php for copyright notices and
* details.
*/
// Import library dependencies
require_once(dirname(__FILE__).DS.'extension.php');
/**
* Installer Components Model
*
* @package Joomla
* @subpackage Installer
* @since 1.5
*/
class InstallerModelComponents extends InstallerModel
{
/**
* Extension Type
* @var string
*/
var $_type = 'component';
/**
* Enable a component
*
* @static
* @return boolean True on success
* @since 1.0
*/
function enable($eid=array())
{
// Initialize variables
$result = false;
/*
* Ensure eid is an array of extension ids
* TODO: If it isn't an array do we want to set an error and fail?
*/
if (!is_array($eid)) {
$eid = array ($eid);
}
// Get a database connector
$db =& JFactory::getDBO();
// Get a table object for the extension type
$table = & JTable::getInstance($this->_type);
// Enable the extension in the table and store it in the database
foreach ($eid as $id)
{
$table->load($id);
$table->enabled = '1';
$result |= $table->store();
}
return $result;
}
/**
* Disable a component
*
* @return boolean True on success
* @since 1.5
*/
function disable($eid=array())
{
// Initialize variables
$result = false;
/*
* Ensure eid is an array of extension ids
* TODO: If it isn't an array do we want to set an error and fail?
*/
if (!is_array($eid)) {
$eid = array ($eid);
}
// Get a database connector
$db =& JFactory::getDBO();
// Get a table object for the extension type
$table = & JTable::getInstance($this->_type);
// Disable the extension in the table and store it in the database
foreach ($eid as $id)
{
$table->load($id);
$table->enabled = '0';
$result |= $table->store();
}
return $result;
}
function _loadItems()
{
global $mainframe, $option;
jimport('joomla.filesystem.folder');
/* Get a database connector */
$db =& JFactory::getDBO();
$query = 'SELECT *' .
' FROM #__components' .
' WHERE parent = 0' .
' ORDER BY iscore, name';
$db->setQuery($query);
$rows = $db->loadObjectList();
/* Get the component base directory */
$adminDir = JPATH_ADMINISTRATOR .DS. 'components';
$siteDir = JPATH_SITE .DS. 'components';
$numRows = count($rows);
for($i=0;$i < $numRows; $i++)
{
$row =& $rows[$i];
/* Get the component folder and list of xml files in folder */
$folder = $adminDir.DS.$row->option;
if (JFolder::exists($folder)) {
$xmlFilesInDir = JFolder::files($folder, '.xml$');
} else {
$folder = $siteDir.DS.$row->option;
if (JFolder::exists($folder)) {
$xmlFilesInDir = JFolder::files($folder, '.xml$');
} else {
$xmlFilesInDir = null;
}
}
if (count($xmlFilesInDir))
{
foreach ($xmlFilesInDir as $xmlfile)
{
if ($data = JApplicationHelper::parseXMLInstallFile($folder.DS.$xmlfile)) {
foreach($data as $key => $value) {
$row->$key = $value;
}
}
$row->jname = JString::strtolower(str_replace(" ", "_", $row->name));
}
}
}
$this->setState('pagination.total', $numRows);
// if the offset is greater than the total, then can the offset
if($this->_state->get('pagination.offset') > $this->_state->get('pagination.total')) {
$this->setState('pagination.offset',0);
}
if($this->_state->get('pagination.limit') > 0) {
$this->_items = array_slice( $rows, $this->_state->get('pagination.offset'), $this->_state->get('pagination.limit') );
} else {
$this->_items = $rows;
}
}
}
|