[1575] | 1 | <?php |
---|
| 2 | /** |
---|
| 3 | * DOMPDF - PHP5 HTML to PDF renderer |
---|
| 4 | * |
---|
| 5 | * File: $RCSfile: list_bullet_image_frame_decorator.cls.php,v $ |
---|
| 6 | * Created on: 2005-06-28 |
---|
| 7 | * |
---|
| 8 | * Copyright (c) 2004 - Benj Carson <benjcarson@digitaljunkies.ca> |
---|
| 9 | * |
---|
| 10 | * This library is free software; you can redistribute it and/or |
---|
| 11 | * modify it under the terms of the GNU Lesser General Public |
---|
| 12 | * License as published by the Free Software Foundation; either |
---|
| 13 | * version 2.1 of the License, or (at your option) any later version. |
---|
| 14 | * |
---|
| 15 | * This library is distributed in the hope that it will be useful, |
---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 18 | * Lesser General Public License for more details. |
---|
| 19 | * |
---|
| 20 | * You should have received a copy of the GNU Lesser General Public License |
---|
| 21 | * along with this library in the file LICENSE.LGPL; if not, write to the |
---|
| 22 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
---|
| 23 | * 02111-1307 USA |
---|
| 24 | * |
---|
| 25 | * Alternatively, you may distribute this software under the terms of the |
---|
| 26 | * PHP License, version 3.0 or later. A copy of this license should have |
---|
| 27 | * been distributed with this file in the file LICENSE.PHP . If this is not |
---|
| 28 | * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
---|
| 29 | * |
---|
| 30 | * The latest version of DOMPDF might be available at: |
---|
| 31 | * http://www.digitaljunkies.ca/dompdf |
---|
| 32 | * |
---|
| 33 | * @link http://www.digitaljunkies.ca/dompdf |
---|
| 34 | * @copyright 2004 Benj Carson |
---|
| 35 | * @author Benj Carson <benjcarson@digitaljunkies.ca> |
---|
| 36 | * @package dompdf |
---|
| 37 | * @version 0.5.1 |
---|
| 38 | */ |
---|
| 39 | |
---|
| 40 | /* $Id: list_bullet_image_frame_decorator.cls.php,v 1.4 2006/07/07 21:31:03 benjcarson Exp $ */ |
---|
| 41 | |
---|
| 42 | /** |
---|
| 43 | * Decorates frames for list bullets with custom images |
---|
| 44 | * |
---|
| 45 | * @access private |
---|
| 46 | * @package dompdf |
---|
| 47 | */ |
---|
| 48 | class List_Bullet_Image_Frame_Decorator extends Frame_Decorator { |
---|
| 49 | |
---|
| 50 | /** |
---|
| 51 | * The underlying image frame |
---|
| 52 | * |
---|
| 53 | * @var Image_Frame_Decorator |
---|
| 54 | */ |
---|
| 55 | protected $_img; |
---|
| 56 | |
---|
| 57 | /** |
---|
| 58 | * The image's width in pixels |
---|
| 59 | * |
---|
| 60 | * @var int |
---|
| 61 | */ |
---|
| 62 | protected $_width; |
---|
| 63 | |
---|
| 64 | /** |
---|
| 65 | * The image's height in pixels |
---|
| 66 | * |
---|
| 67 | * @var int |
---|
| 68 | */ |
---|
| 69 | protected $_height; |
---|
| 70 | |
---|
| 71 | /** |
---|
| 72 | * Class constructor |
---|
| 73 | * |
---|
| 74 | * @param Frame $frame the bullet frame to decorate |
---|
| 75 | * @param DOMPDF $dompdf the document's dompdf object |
---|
| 76 | */ |
---|
| 77 | function __construct(Frame $frame, DOMPDF $dompdf) { |
---|
| 78 | $url = $frame->get_style()->list_style_image; |
---|
| 79 | $frame->get_node()->setAttribute("src", $url); |
---|
| 80 | $this->_img = new Image_Frame_Decorator($frame, $dompdf); |
---|
| 81 | parent::__construct($this->_img, $dompdf); |
---|
| 82 | list($width, $height) = getimagesize($this->_img->get_image_url()); |
---|
| 83 | |
---|
| 84 | // Resample the bullet image to be consistent with 'auto' sized images |
---|
| 85 | $this->_width = ((float)rtrim($width, "px")) * 72 / DOMPDF_DPI; |
---|
| 86 | $this->_height = ((float)rtrim($height, "px")) * 72 / DOMPDF_DPI; |
---|
| 87 | |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | /** |
---|
| 91 | * Return the bullet's width |
---|
| 92 | * |
---|
| 93 | * @return int |
---|
| 94 | */ |
---|
| 95 | function get_width() { |
---|
| 96 | return $this->_width; |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | /** |
---|
| 100 | * Return the bullet's height |
---|
| 101 | * |
---|
| 102 | * @return int |
---|
| 103 | */ |
---|
| 104 | function get_height() { |
---|
| 105 | return $this->_height; |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | /** |
---|
| 109 | * Override get_margin_width() |
---|
| 110 | * |
---|
| 111 | * @return int |
---|
| 112 | */ |
---|
| 113 | function get_margin_width() { |
---|
| 114 | return $this->_width + List_Bullet_Frame_Decorator::BULLET_PADDING; |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | /** |
---|
| 118 | * Override get_margin_height() |
---|
| 119 | * |
---|
| 120 | * @return int |
---|
| 121 | */ |
---|
| 122 | function get_margin_height() { |
---|
| 123 | return $this->_height + List_Bullet_Frame_Decorator::BULLET_PADDING; |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | /** |
---|
| 127 | * Return image url |
---|
| 128 | * |
---|
| 129 | * @return string |
---|
| 130 | */ |
---|
| 131 | function get_image_url() { |
---|
| 132 | return $this->_img->get_image_url(); |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | /** |
---|
| 136 | * Return the image extension |
---|
| 137 | * |
---|
| 138 | * @return string |
---|
| 139 | */ |
---|
| 140 | function get_image_ext() { |
---|
| 141 | return $this->_img->get_image_ext(); |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | ?> |
---|