Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
image.php
Aller à la documentation de ce fichier.
1 <?php
2 /**
3  * @package Joomla.Platform
4  * @subpackage Document
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  * DocumentImage class, provides an easy interface to output image data
14  *
15  * @package Joomla.Platform
16  * @subpackage Document
17  * @since 12.1
18  */
20 {
21  /**
22  * Class constructor
23  *
24  * @param array $options Associative array of options
25  *
26  * @since 12.1
27  */
28  public function __construct($options = array())
29  {
30  parent::__construct($options);
31 
32  // Set mime type
33  $this->_mime = 'image/png';
34 
35  // Set document type
36  $this->_type = 'image';
37  }
38 
39  /**
40  * Render the document.
41  *
42  * @param boolean $cache If true, cache the output
43  * @param array $params Associative array of attributes
44  *
45  * @return The rendered data
46  *
47  * @since 12.1
48  */
49  public function render($cache = false, $params = array())
50  {
51  // Get the image type
52  $type = JFactory::getApplication()->input->get('type', 'png');
53 
54  switch ($type)
55  {
56  case 'jpg':
57  case 'jpeg':
58  $this->_mime = 'image/jpeg';
59  break;
60  case 'gif':
61  $this->_mime = 'image/gif';
62  break;
63  case 'png':
64  default:
65  $this->_mime = 'image/png';
66  break;
67  }
68 
69  $this->_charset = null;
70 
71  parent::render();
72  return $this->getBuffer();
73  }
74 }