[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/administrator/components/com_installer/models/ -> components.php (source)

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


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1