[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/administrator/components/com_modules/models/ -> module.php (source)

   1  <?php
   2  /**
   3   * @version        $Id: module.php 14401 2010-01-26 14:10:00Z louis $
   4   * @package        Joomla
   5   * @subpackage    Modules
   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
   9   * to the GNU General Public License, and as distributed it includes or
  10   * is derivative of works licensed under the GNU General Public License or
  11   * other free or open source software licenses.
  12   * See COPYRIGHT.php for copyright notices and details.
  13   */
  14  
  15  // no direct access
  16  defined( '_JEXEC' ) or die( 'Restricted access' );
  17  
  18  jimport( 'joomla.application.component.model' );
  19  
  20  /**
  21   * @package        Joomla
  22   * @subpackage    Modules
  23   */
  24  class ModulesModelModule extends JModel
  25  {
  26      var $_xml;
  27  
  28      function &getModule()
  29      {
  30          static $instance;
  31  
  32          if (!$instance)
  33          {
  34              $instance = $this->getTable( 'Module', 'JTable' );
  35              if ($id = $this->getState( 'id' )) {
  36                  $instance->load( (int) $id );
  37              }
  38          }
  39          return $instance;
  40      }
  41  
  42      function &_getXML()
  43      {
  44          if (!$this->_xml)
  45          {
  46              $clientId    = $this->getState( 'clientId', 0 );
  47              $path        = ($clientId == 1) ? 'mod1_xml' : 'mod0_xml';
  48              $module        = &$this->getModule();
  49  
  50              if ($module->module == 'custom') {
  51                  $xmlpath = JApplicationHelper::getPath( $path, 'mod_custom' );
  52              } else {
  53                  $xmlpath = JApplicationHelper::getPath( $path, $module->module );
  54              }
  55  
  56              if (file_exists($xmlpath))
  57              {
  58                  $xml =& JFactory::getXMLParser('Simple');
  59                  if ($xml->loadFile($xmlpath)) {
  60                      $this->_xml = &$xml;
  61                  }
  62              }
  63          }
  64          return $this->_xml;
  65      }
  66  
  67      function &getParams()
  68      {
  69          // Get the state parameters
  70          $module    =& $this->getModule();
  71          $params    = new JParameter($module->params);
  72  
  73          if ($xml =& $this->_getXML())
  74          {
  75              if ($ps = & $xml->document->params) {
  76                  foreach ($ps as $p)
  77                  {
  78                      $params->setXML( $p );
  79                  }
  80              }
  81          }
  82          return $params;
  83      }
  84  
  85  	function getPositions()
  86      {
  87          jimport('joomla.filesystem.folder');
  88  
  89          $client =& JApplicationHelper::getClientInfo($this->getState('clientId'));
  90          if ($client === false) {
  91              return false;
  92          }
  93  
  94          //Get the database object
  95          $db    =& JFactory::getDBO();
  96  
  97          // template assignment filter
  98          $query = 'SELECT DISTINCT(template) AS text, template AS value'.
  99                  ' FROM #__templates_menu' .
 100                  ' WHERE client_id = '.(int) $client->id;
 101          $db->setQuery( $query );
 102          $templates = $db->loadObjectList();
 103  
 104          // Get a list of all module positions as set in the database
 105          $query = 'SELECT DISTINCT(position)'.
 106                  ' FROM #__modules' .
 107                  ' WHERE client_id = '.(int) $client->id;
 108          $db->setQuery( $query );
 109          $positions = $db->loadResultArray();
 110          $positions = (is_array($positions)) ? $positions : array();
 111  
 112          // Get a list of all template xml files for a given application
 113  
 114          // Get the xml parser first
 115          for ($i = 0, $n = count($templates); $i < $n; $i++ )
 116          {
 117              $path = $client->path.DS.'templates'.DS.$templates[$i]->value;
 118  
 119              $xml =& JFactory::getXMLParser('Simple');
 120              if ($xml->loadFile($path.DS.'templateDetails.xml'))
 121              {
 122                  $p =& $xml->document->getElementByPath('positions');
 123                  if (is_a($p, 'JSimpleXMLElement') && count($p->children()))
 124                  {
 125                      foreach ($p->children() as $child)
 126                      {
 127                          if (!in_array($child->data(), $positions)) {
 128                              $positions[] = $child->data();
 129                          }
 130                      }
 131                  }
 132              }
 133          }
 134  
 135          if(defined('_JLEGACY') && _JLEGACY == '1.0')
 136          {
 137              $positions[] = 'left';
 138              $positions[] = 'right';
 139              $positions[] = 'top';
 140              $positions[] = 'bottom';
 141              $positions[] = 'inset';
 142              $positions[] = 'banner';
 143              $positions[] = 'header';
 144              $positions[] = 'footer';
 145              $positions[] = 'newsflash';
 146              $positions[] = 'legals';
 147              $positions[] = 'pathway';
 148              $positions[] = 'breadcrumb';
 149              $positions[] = 'user1';
 150              $positions[] = 'user2';
 151              $positions[] = 'user3';
 152              $positions[] = 'user4';
 153              $positions[] = 'user5';
 154              $positions[] = 'user6';
 155              $positions[] = 'user7';
 156              $positions[] = 'user8';
 157              $positions[] = 'user9';
 158              $positions[] = 'advert1';
 159              $positions[] = 'advert2';
 160              $positions[] = 'advert3';
 161              $positions[] = 'debug';
 162              $positions[] = 'syndicate';
 163          }
 164  
 165          $positions = array_unique($positions);
 166          sort($positions);
 167  
 168          return $positions;
 169      }
 170  }


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