Source for file module.php

Documentation is available at module.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Legacy
  4.  * @subpackage  Table
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die;
  11.  
  12. /**
  13.  * Module table
  14.  *
  15.  * @package     Joomla.Legacy
  16.  * @subpackage  Table
  17.  * @since       11.1
  18.  */
  19. class JTableModule extends JTable
  20. {
  21.     /**
  22.      * Constructor.
  23.      *
  24.      * @param   JDatabaseDriver  $db  Database driver object.
  25.      *
  26.      * @since   11.1
  27.      */
  28.     public function __construct(JDatabaseDriver $db)
  29.     {
  30.         parent::__construct('#__modules''id'$db);
  31.  
  32.         $this->access = (int) JFactory::getConfig()->get('access');
  33.     }
  34.  
  35.     /**
  36.      * Method to compute the default name of the asset.
  37.      * The default name is in the form table_name.id
  38.      * where id is the value of the primary key of the table.
  39.      *
  40.      * @return  string 
  41.      *
  42.      * @since   11.1
  43.      */
  44.     protected function _getAssetName()
  45.     {
  46.         $k $this->_tbl_key;
  47.  
  48.         return 'com_modules.module.' . (int) $this->$k;
  49.     }
  50.  
  51.     /**
  52.      * Method to return the title to use for the asset table.
  53.      *
  54.      * @return  string 
  55.      *
  56.      * @since   11.1
  57.      */
  58.     protected function _getAssetTitle()
  59.     {
  60.         return $this->title;
  61.     }
  62.  
  63.     /**
  64.      * Method to get the parent asset id for the record
  65.      *
  66.      * @param   JTable   $table  A JTable object (optional) for the asset parent
  67.      * @param   integer  $id     The id (optional) of the content.
  68.      *
  69.      * @return  integer 
  70.      *
  71.      * @since   11.1
  72.      */
  73.     protected function _getAssetParentId(JTable $table null$id null)
  74.     {
  75.         $assetId null;
  76.  
  77.         // This is a module that needs to parent with the extension.
  78.         if ($assetId === null)
  79.         {
  80.             // Build the query to get the asset id of the parent component.
  81.             $query $this->_db->getQuery(true)
  82.                 ->select($this->_db->quoteName('id'))
  83.                 ->from($this->_db->quoteName('#__assets'))
  84.                 ->where($this->_db->quoteName('name'' = ' $this->_db->quote('com_modules'));
  85.  
  86.             // Get the asset id from the database.
  87.             $this->_db->setQuery($query);
  88.  
  89.             if ($result $this->_db->loadResult())
  90.             {
  91.                 $assetId = (int) $result;
  92.             }
  93.         }
  94.  
  95.         // Return the asset id.
  96.         if ($assetId)
  97.         {
  98.             return $assetId;
  99.         }
  100.         else
  101.         {
  102.             return parent::_getAssetParentId($table$id);
  103.         }
  104.     }
  105.  
  106.     /**
  107.      * Overloaded check function.
  108.      *
  109.      * @return  boolean  True if the instance is sane and able to be stored in the database.
  110.      *
  111.      * @see     JTable::check()
  112.      * @since   11.1
  113.      */
  114.     public function check()
  115.     {
  116.         // Check for valid name
  117.         if (trim($this->title== '')
  118.         {
  119.             $this->setError(JText::_('JLIB_DATABASE_ERROR_MUSTCONTAIN_A_TITLE_MODULE'));
  120.  
  121.             return false;
  122.         }
  123.  
  124.         // Check the publish down date is not earlier than publish up.
  125.         if ((int) $this->publish_down && $this->publish_down $this->publish_up)
  126.         {
  127.             // Swap the dates.
  128.             $temp $this->publish_up;
  129.             $this->publish_up $this->publish_down;
  130.             $this->publish_down $temp;
  131.         }
  132.  
  133.         return true;
  134.     }
  135.  
  136.     /**
  137.      * Overloaded bind function.
  138.      *
  139.      * @param   array  $array   Named array.
  140.      * @param   mixed  $ignore  An optional array or space separated list of properties to ignore while binding.
  141.      *
  142.      * @return  mixed  Null if operation was satisfactory, otherwise returns an error
  143.      *
  144.      * @see     JTable::bind()
  145.      * @since   11.1
  146.      */
  147.     public function bind($array$ignore '')
  148.     {
  149.         if (isset($array['params']&& is_array($array['params']))
  150.         {
  151.             $registry new JRegistry;
  152.             $registry->loadArray($array['params']);
  153.             $array['params'= (string) $registry;
  154.         }
  155.  
  156.         // Bind the rules.
  157.         if (isset($array['rules']&& is_array($array['rules']))
  158.         {
  159.             $rules new JAccessRules($array['rules']);
  160.             $this->setRules($rules);
  161.         }
  162.  
  163.         return parent::bind($array$ignore);
  164.     }
  165. }

Documentation generated on Tue, 19 Nov 2013 15:08:38 +0100 by phpDocumentor 1.4.3