[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

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

   1  <?php
   2  /**
   3   * @version        $Id: modules.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   * Extension Manager Modules Model
  23   *
  24   * @package        Joomla
  25   * @subpackage    Installer
  26   * @since        1.5
  27   */
  28  class InstallerModelModules extends InstallerModel
  29  {
  30      /**
  31       * Extension Type
  32       * @var    string
  33       */
  34      var $_type = 'module';
  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('filter.string', $mainframe->getUserStateFromRequest( 'com_installer.modules.string', 'filter', '', 'string' ));
  49          $this->setState('filter.client', $mainframe->getUserStateFromRequest( 'com_installer.modules.client', 'client', -1, 'int' ));
  50      }
  51  
  52  	function _loadItems()
  53      {
  54          global $mainframe, $option;
  55  
  56          $db = &JFactory::getDBO();
  57  
  58          $and = null;
  59          if ($this->_state->get('filter.client') < 0) {
  60              if ($search = $this->_state->get('filter.string')) {
  61                  $and = ' AND title LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false );
  62              }
  63          } else {
  64              if ($search = $this->_state->get('filter.string'))
  65              {
  66                  $and = ' AND client_id = '.(int)$this->_state->get('filter.client');
  67                  $and .= ' AND title LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false );
  68              }
  69              else {
  70                  $and = ' AND client_id = '.(int)$this->_state->get('filter.client');
  71              }
  72          }
  73  
  74          $query = 'SELECT id, module, client_id, title, iscore' .
  75                  ' FROM #__modules' .
  76                  ' WHERE module LIKE "mod_%" ' .
  77                  $and .
  78                  ' GROUP BY module, client_id' .
  79                  ' ORDER BY iscore, client_id, module';
  80          $db->setQuery($query);
  81          $rows = $db->loadObjectList();
  82  
  83          $n = count($rows);
  84          for ($i = 0; $i < $n; $i ++) {
  85              $row = & $rows[$i];
  86  
  87              // path to module directory
  88              if ($row->client_id == "1") {
  89                  $moduleBaseDir = JPATH_ADMINISTRATOR.DS."modules";
  90              } else {
  91                  $moduleBaseDir = JPATH_SITE.DS."modules";
  92              }
  93  
  94              // xml file for module
  95              $xmlfile = $moduleBaseDir . DS . $row->module .DS. $row->module.".xml";
  96  
  97              if (file_exists($xmlfile))
  98              {
  99                  if ($data = JApplicationHelper::parseXMLInstallFile($xmlfile)) {
 100                      foreach($data as $key => $value) {
 101                          $row->$key = $value;
 102                      }
 103                  }
 104              }
 105          }
 106          $this->setState('pagination.total', $n);
 107          // if the offset is greater than the total, then can the offset
 108          if($this->_state->get('pagination.offset') > $this->_state->get('pagination.total')) {
 109              $this->setState('pagination.offset',0);
 110          }
 111  
 112          if($this->_state->get('pagination.limit') > 0) {
 113              $this->_items = array_slice( $rows, $this->_state->get('pagination.offset'), $this->_state->get('pagination.limit') );
 114          } else {
 115              $this->_items = $rows;
 116          }
 117      }
 118  }


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