Source for file version.php

Documentation is available at version.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Libraries
  4.  * @subpackage  Version
  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('_JEXEC'or die;
  11.  
  12. /**
  13.  * Version information class for the Joomla CMS.
  14.  *
  15.  * @package     Joomla.Libraries
  16.  * @subpackage  Version
  17.  * @since       1.0
  18.  */
  19. final class JVersion
  20. {
  21.     /** @var  string  Product name. */
  22.     public $PRODUCT = 'Joomla!';
  23.  
  24.     /** @var  string  Release version. */
  25.     public $RELEASE = '3.2';
  26.  
  27.     /** @var  string  Maintenance version. */
  28.     public $DEV_LEVEL = '0.rc';
  29.  
  30.     /** @var  string  Development STATUS. */
  31.     public $DEV_STATUS = 'Release Candidate';
  32.  
  33.     /** @var  string  Build number. */
  34.     public $BUILD = '';
  35.  
  36.     /** @var  string  Code name. */
  37.     public $CODENAME = 'Ember';
  38.  
  39.     /** @var  string  Release date. */
  40.     public $RELDATE = '24-October-2013';
  41.  
  42.     /** @var  string  Release time. */
  43.     public $RELTIME = '14:00';
  44.  
  45.     /** @var  string  Release timezone. */
  46.     public $RELTZ = 'GMT';
  47.  
  48.     /** @var  string  Copyright Notice. */
  49.     public $COPYRIGHT = 'Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.';
  50.  
  51.     /** @var  string  Link text. */
  52.     public $URL = '<a href="http://www.joomla.org">Joomla!</a> is Free Software released under the GNU General Public License.';
  53.  
  54.     /**
  55.      * Compares two a "PHP standardized" version number against the current Joomla version.
  56.      *
  57.      * @param   string  $minimum  The minimum version of the Joomla which is compatible.
  58.      *
  59.      * @return  bool    True if the version is compatible.
  60.      *
  61.      * @see     http://www.php.net/version_compare
  62.      * @since   1.0
  63.      */
  64.     public function isCompatible($minimum)
  65.     {
  66.         return version_compare(JVERSION$minimum'ge');
  67.     }
  68.  
  69.     /**
  70.      * Method to get the help file version.
  71.      *
  72.      * @return  string  Version suffix for help files.
  73.      *
  74.      * @since   1.0
  75.      */
  76.     public function getHelpVersion()
  77.     {
  78.         return '.' str_replace('.'''$this->RELEASE);
  79.     }
  80.  
  81.     /**
  82.      * Gets a "PHP standardized" version string for the current Joomla.
  83.      *
  84.      * @return  string  Version string.
  85.      *
  86.      * @since   1.5
  87.      */
  88.     public function getShortVersion()
  89.     {
  90.         return $this->RELEASE . '.' $this->DEV_LEVEL;
  91.     }
  92.  
  93.     /**
  94.      * Gets a version string for the current Joomla with all release information.
  95.      *
  96.      * @return  string  Complete version string.
  97.      *
  98.      * @since   1.5
  99.      */
  100.     public function getLongVersion()
  101.     {
  102.         return $this->PRODUCT . ' ' $this->RELEASE . '.' $this->DEV_LEVEL . ' '
  103.             . $this->DEV_STATUS . ' [ ' $this->CODENAME . ' ] ' $this->RELDATE . ' '
  104.             . $this->RELTIME . ' ' $this->RELTZ;
  105.     }
  106.  
  107.     /**
  108.      * Returns the user agent.
  109.      *
  110.      * @param   string  $component    Name of the component.
  111.      * @param   bool    $mask         Mask as Mozilla/5.0 or not.
  112.      * @param   bool    $add_version  Add version afterwards to component.
  113.      *
  114.      * @return  string  User Agent.
  115.      *
  116.      * @since   1.0
  117.      */
  118.     public function getUserAgent($component null$mask false$add_version true)
  119.     {
  120.         if ($component === null)
  121.         {
  122.             $component 'Framework';
  123.         }
  124.  
  125.         if ($add_version)
  126.         {
  127.             $component .= '/' $this->RELEASE;
  128.         }
  129.  
  130.         // If masked pretend to look like Mozilla 5.0 but still identify ourselves.
  131.         if ($mask)
  132.         {
  133.             return 'Mozilla/5.0 ' $this->PRODUCT . '/' $this->RELEASE . '.' $this->DEV_LEVEL . ($component ' ' $component '');
  134.         }
  135.         else
  136.         {
  137.             return $this->PRODUCT . '/' $this->RELEASE . '.' $this->DEV_LEVEL . ($component ' ' $component '');
  138.         }
  139.     }
  140.  
  141.     /**
  142.      * Generate a media version string for assets
  143.      * Public to allow third party developers to use it
  144.      *
  145.      * @return  string 
  146.      *
  147.      * @since    3.2
  148.      */
  149.     public function generateMediaVersion()
  150.     {
  151.         $date   new JDate;
  152.         $config JFactory::getConfig();
  153.  
  154.         return md5($this->getLongVersion($config->get('secret'$date->toSql());
  155.     }
  156.  
  157.     /**
  158.      * Gets a media version which is used to append to Joomla core media files.
  159.      *
  160.      * This media version is used to append to Joomla core media in order to trick browsers into
  161.      * reloading the CSS and JavaScript, because they think the files are renewed.
  162.      * The media version is renewed after Joomla core update, install, discover_install and uninstallation.
  163.      *
  164.      * @return  string  The media version.
  165.      *
  166.      * @since    3.2
  167.      */
  168.     public function getMediaVersion()
  169.     {
  170.         // Load the media version and cache it for future use
  171.         static $mediaVersion null;
  172.  
  173.         if ($mediaVersion === null)
  174.         {
  175.             $config JFactory::getConfig();
  176.             $debugEnabled $config->get('debug'0);
  177.  
  178.             // Get the joomla library params
  179.             $params JLibraryHelper::getParams('joomla');
  180.  
  181.             // Get the media version
  182.             $mediaVersion $params->get('mediaversion''');
  183.  
  184.             // Refresh assets in debug mode or when the media version is not set
  185.             if ($debugEnabled || empty($mediaVersion))
  186.             {
  187.                 $mediaVersion $this->generateMediaVersion();
  188.  
  189.                 $this->setMediaVersion($mediaVersion);
  190.             }
  191.         }
  192.  
  193.         return $mediaVersion;
  194.     }
  195.  
  196.     /**
  197.      * Function to refresh the media version
  198.      *
  199.      * @return  JVersion  Instance of $this to allow chaining.
  200.      *
  201.      * @since    3.2
  202.      */
  203.     public function refreshMediaVersion()
  204.     {
  205.         $newMediaVersion $this->generateMediaVersion();
  206.  
  207.         return $this->setMediaVersion($newMediaVersion);
  208.     }
  209.  
  210.     /**
  211.      * Sets the media version which is used to append to Joomla core media files.
  212.      *
  213.      * @param   string  $mediaVersion  The media version.
  214.      *
  215.      * @return  JVersion  Instance of $this to allow chaining.
  216.      *
  217.      * @since    3.2
  218.      */
  219.     public function setMediaVersion($mediaVersion)
  220.     {
  221.         // Do not allow empty media versions
  222.         if (!empty($mediaVersion))
  223.         {
  224.             // Get library parameters
  225.             $params JLibraryHelper::getParams('joomla');
  226.  
  227.             $params->set('mediaversion'$mediaVersion);
  228.  
  229.             // Save modified params
  230.             JLibraryHelper::saveParams('joomla'$params);
  231.         }
  232.  
  233.         return $this;
  234.     }
  235. }

Documentation generated on Tue, 19 Nov 2013 15:16:45 +0100 by phpDocumentor 1.4.3