This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
|||||||||||
|
0 ignored issues
–
show
|
||||||||||||
| 2 | // |
|||||||||||
| 3 | // FPDF_TPL - Version 1.1.2 |
|||||||||||
| 4 | // |
|||||||||||
| 5 | // Copyright 2004-2008 Setasign - Jan Slabon |
|||||||||||
| 6 | // |
|||||||||||
| 7 | // Licensed under the Apache License, Version 2.0 (the "License"); |
|||||||||||
| 8 | // you may not use this file except in compliance with the License. |
|||||||||||
| 9 | // You may obtain a copy of the License at |
|||||||||||
| 10 | // |
|||||||||||
| 11 | // http://www.apache.org/licenses/LICENSE-2.0 |
|||||||||||
| 12 | // |
|||||||||||
| 13 | // Unless required by applicable law or agreed to in writing, software |
|||||||||||
| 14 | // distributed under the License is distributed on an "AS IS" BASIS, |
|||||||||||
| 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||||||||||
| 16 | // See the License for the specific language governing permissions and |
|||||||||||
| 17 | // limitations under the License. |
|||||||||||
| 18 | // |
|||||||||||
| 19 | error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED); |
|||||||||||
| 20 | class FPDF_TPL extends \FPDF_FPDF {
|
|||||||||||
|
0 ignored issues
–
show
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.
You can fix this by adding a namespace to your class: namespace YourVendor;
class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries. Loading history...
|
||||||||||||
| 21 | /** |
|||||||||||
| 22 | * Array of Tpl-Data |
|||||||||||
| 23 | * @var array |
|||||||||||
| 24 | */ |
|||||||||||
| 25 | var $tpls = array(); |
|||||||||||
|
0 ignored issues
–
show
The visibility should be declared for property
$tpls.
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. Loading history...
|
||||||||||||
| 26 | ||||||||||||
| 27 | /** |
|||||||||||
| 28 | * Current Template-ID |
|||||||||||
| 29 | * @var int |
|||||||||||
| 30 | */ |
|||||||||||
| 31 | var $tpl = 0; |
|||||||||||
|
0 ignored issues
–
show
The visibility should be declared for property
$tpl.
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. Loading history...
|
||||||||||||
| 32 | ||||||||||||
| 33 | /** |
|||||||||||
| 34 | * "In Template"-Flag |
|||||||||||
| 35 | * @var boolean |
|||||||||||
| 36 | */ |
|||||||||||
| 37 | var $_intpl = false; |
|||||||||||
|
0 ignored issues
–
show
The visibility should be declared for property
$_intpl.
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. Loading history...
|
||||||||||||
| 38 | ||||||||||||
| 39 | /** |
|||||||||||
| 40 | * Nameprefix of Templates used in Resources-Dictonary |
|||||||||||
| 41 | * @var string A String defining the Prefix used as Template-Object-Names. Have to beginn with an / |
|||||||||||
| 42 | */ |
|||||||||||
| 43 | var $tplprefix = "/TPL"; |
|||||||||||
|
0 ignored issues
–
show
The visibility should be declared for property
$tplprefix.
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. Loading history...
|
||||||||||||
| 44 | ||||||||||||
| 45 | /** |
|||||||||||
| 46 | * Resources used By Templates and Pages |
|||||||||||
| 47 | * @var array |
|||||||||||
| 48 | */ |
|||||||||||
| 49 | var $_res = array(); |
|||||||||||
|
0 ignored issues
–
show
The visibility should be declared for property
$_res.
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. Loading history...
|
||||||||||||
| 50 | ||||||||||||
| 51 | /** |
|||||||||||
| 52 | * Start a Template |
|||||||||||
| 53 | * |
|||||||||||
| 54 | * This method starts a template. You can give own coordinates to build an own sized |
|||||||||||
| 55 | * Template. Pay attention, that the margins are adapted to the new templatesize. |
|||||||||||
| 56 | * If you want to write outside the template, for example to build a clipped Template, |
|||||||||||
| 57 | * you have to set the Margins and "Cursor"-Position manual after beginTemplate-Call. |
|||||||||||
| 58 | * |
|||||||||||
| 59 | * If no parameter is given, the template uses the current page-size. |
|||||||||||
| 60 | * The Method returns an ID of the current Template. This ID is used later for using this template. |
|||||||||||
| 61 | * Warning: A created Template is used in PDF at all events. Still if you don't use it after creation! |
|||||||||||
| 62 | * |
|||||||||||
| 63 | * @param int $x The x-coordinate given in user-unit |
|||||||||||
| 64 | * @param int $y The y-coordinate given in user-unit |
|||||||||||
| 65 | * @param int $w The width given in user-unit |
|||||||||||
| 66 | * @param int $h The height given in user-unit |
|||||||||||
| 67 | * @return int The ID of new created Template |
|||||||||||
| 68 | */ |
|||||||||||
| 69 | function beginTemplate($x=null, $y=null, $w=null, $h=null) {
|
|||||||||||
|
0 ignored issues
–
show
|
||||||||||||
| 70 | if ($this->page <= 0) |
|||||||||||
| 71 | $this->error("You have to add a page to fpdf first!");
|
|||||||||||
| 72 | ||||||||||||
| 73 | if ($x == null) |
|||||||||||
|
0 ignored issues
–
show
|
||||||||||||
| 74 | $x = 0; |
|||||||||||
| 75 | if ($y == null) |
|||||||||||
|
0 ignored issues
–
show
|
||||||||||||
| 76 | $y = 0; |
|||||||||||
| 77 | if ($w == null) |
|||||||||||
|
0 ignored issues
–
show
|
||||||||||||
| 78 | $w = $this->w; |
|||||||||||
| 79 | if ($h == null) |
|||||||||||
|
0 ignored issues
–
show
|
||||||||||||
| 80 | $h = $this->h; |
|||||||||||
| 81 | ||||||||||||
| 82 | // Save settings |
|||||||||||
| 83 | $this->tpl++; |
|||||||||||
| 84 | $tpl =& $this->tpls[$this->tpl]; |
|||||||||||
| 85 | $tpl = array( |
|||||||||||
| 86 | 'o_x' => $this->x, |
|||||||||||
| 87 | 'o_y' => $this->y, |
|||||||||||
| 88 | 'o_AutoPageBreak' => $this->AutoPageBreak, |
|||||||||||
| 89 | 'o_bMargin' => $this->bMargin, |
|||||||||||
| 90 | 'o_tMargin' => $this->tMargin, |
|||||||||||
| 91 | 'o_lMargin' => $this->lMargin, |
|||||||||||
| 92 | 'o_rMargin' => $this->rMargin, |
|||||||||||
| 93 | 'o_h' => $this->h, |
|||||||||||
| 94 | 'o_w' => $this->w, |
|||||||||||
| 95 | 'buffer' => '', |
|||||||||||
| 96 | 'x' => $x, |
|||||||||||
| 97 | 'y' => $y, |
|||||||||||
| 98 | 'w' => $w, |
|||||||||||
| 99 | 'h' => $h |
|||||||||||
| 100 | ); |
|||||||||||
| 101 | ||||||||||||
| 102 | $this->SetAutoPageBreak(false); |
|||||||||||
| 103 | ||||||||||||
| 104 | // Define own high and width to calculate possitions correct |
|||||||||||
| 105 | $this->h = $h; |
|||||||||||
| 106 | $this->w = $w; |
|||||||||||
| 107 | ||||||||||||
| 108 | $this->_intpl = true; |
|||||||||||
| 109 | $this->SetXY($x+$this->lMargin, $y+$this->tMargin); |
|||||||||||
| 110 | $this->SetRightMargin($this->w-$w+$this->rMargin); |
|||||||||||
| 111 | ||||||||||||
| 112 | return $this->tpl; |
|||||||||||
| 113 | } |
|||||||||||
| 114 | ||||||||||||
| 115 | /** |
|||||||||||
| 116 | * End Template |
|||||||||||
| 117 | * |
|||||||||||
| 118 | * This method ends a template and reset initiated variables on beginTemplate. |
|||||||||||
| 119 | * |
|||||||||||
| 120 | * @return mixed If a template is opened, the ID is returned. If not a false is returned. |
|||||||||||
| 121 | */ |
|||||||||||
| 122 | function endTemplate() {
|
|||||||||||
|
0 ignored issues
–
show
|
||||||||||||
| 123 | if ($this->_intpl) {
|
|||||||||||
| 124 | $this->_intpl = false; |
|||||||||||
| 125 | $tpl =& $this->tpls[$this->tpl]; |
|||||||||||
| 126 | $this->SetXY($tpl['o_x'], $tpl['o_y']); |
|||||||||||
| 127 | $this->tMargin = $tpl['o_tMargin']; |
|||||||||||
| 128 | $this->lMargin = $tpl['o_lMargin']; |
|||||||||||
| 129 | $this->rMargin = $tpl['o_rMargin']; |
|||||||||||
| 130 | $this->h = $tpl['o_h']; |
|||||||||||
| 131 | $this->w = $tpl['o_w']; |
|||||||||||
| 132 | $this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']); |
|||||||||||
| 133 | ||||||||||||
| 134 | return $this->tpl; |
|||||||||||
| 135 | } else {
|
|||||||||||
| 136 | return false; |
|||||||||||
| 137 | } |
|||||||||||
| 138 | } |
|||||||||||
| 139 | ||||||||||||
| 140 | /** |
|||||||||||
| 141 | * Use a Template in current Page or other Template |
|||||||||||
| 142 | * |
|||||||||||
| 143 | * You can use a template in a page or in another template. |
|||||||||||
| 144 | * You can give the used template a new size like you use the Image()-method. |
|||||||||||
| 145 | * All parameters are optional. The width or height is calculated automaticaly |
|||||||||||
| 146 | * if one is given. If no parameter is given the origin size as defined in |
|||||||||||
| 147 | * beginTemplate() is used. |
|||||||||||
| 148 | * The calculated or used width and height are returned as an array. |
|||||||||||
| 149 | * |
|||||||||||
| 150 | * @param int $tplidx A valid template-Id |
|||||||||||
| 151 | * @param int $_x The x-position |
|||||||||||
| 152 | * @param int $_y The y-position |
|||||||||||
| 153 | * @param int $_w The new width of the template |
|||||||||||
| 154 | * @param int $_h The new height of the template |
|||||||||||
| 155 | * @retrun array The height and width of the template |
|||||||||||
| 156 | */ |
|||||||||||
| 157 | function useTemplate($tplidx, $_x=null, $_y=null, $_w=0, $_h=0) {
|
|||||||||||
|
0 ignored issues
–
show
|
||||||||||||
| 158 | if ($this->page <= 0) |
|||||||||||
| 159 | $this->error("You have to add a page to fpdf first!");
|
|||||||||||
| 160 | ||||||||||||
| 161 | if (!isset($this->tpls[$tplidx])) |
|||||||||||
| 162 | $this->error("Template does not exist!");
|
|||||||||||
| 163 | ||||||||||||
| 164 | if ($this->_intpl) {
|
|||||||||||
| 165 | $this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx]; |
|||||||||||
| 166 | } |
|||||||||||
| 167 | ||||||||||||
| 168 | $tpl =& $this->tpls[$tplidx]; |
|||||||||||
| 169 | $x = $tpl['x']; |
|||||||||||
| 170 | $y = $tpl['y']; |
|||||||||||
| 171 | $w = $tpl['w']; |
|||||||||||
| 172 | $h = $tpl['h']; |
|||||||||||
| 173 | ||||||||||||
| 174 | if ($_x == null) |
|||||||||||
|
0 ignored issues
–
show
|
||||||||||||
| 175 | $_x = $x; |
|||||||||||
| 176 | if ($_y == null) |
|||||||||||
|
0 ignored issues
–
show
|
||||||||||||
| 177 | $_y = $y; |
|||||||||||
| 178 | $wh = $this->getTemplateSize($tplidx, $_w, $_h); |
|||||||||||
| 179 | $_w = $wh['w']; |
|||||||||||
| 180 | $_h = $wh['h']; |
|||||||||||
| 181 | ||||||||||||
| 182 | $this->_out(sprintf("q %.4f 0 0 %.4f %.2f %.2f cm", ($_w/$w), ($_h/$h), $_x*$this->k, ($this->h-($_y+$_h))*$this->k)); // Translate
|
|||||||||||
| 183 | $this->_out($this->tplprefix.$tplidx." Do Q"); |
|||||||||||
| 184 | ||||||||||||
| 185 | return array("w" => $_w, "h" => $_h);
|
|||||||||||
| 186 | } |
|||||||||||
| 187 | ||||||||||||
| 188 | /** |
|||||||||||
| 189 | * Get The calculated Size of a Template |
|||||||||||
| 190 | * |
|||||||||||
| 191 | * If one size is given, this method calculates the other one. |
|||||||||||
| 192 | * |
|||||||||||
| 193 | * @param int $tplidx A valid template-Id |
|||||||||||
| 194 | * @param int $_w The width of the template |
|||||||||||
| 195 | * @param int $_h The height of the template |
|||||||||||
| 196 | * @return array The height and width of the template |
|||||||||||
| 197 | */ |
|||||||||||
| 198 | function getTemplateSize($tplidx, $_w=0, $_h=0) {
|
|||||||||||
|
0 ignored issues
–
show
|
||||||||||||
| 199 | if (!$this->tpls[$tplidx]) |
|||||||||||
| 200 | return false; |
|||||||||||
| 201 | ||||||||||||
| 202 | $tpl =& $this->tpls[$tplidx]; |
|||||||||||
| 203 | $w = $tpl['w']; |
|||||||||||
| 204 | $h = $tpl['h']; |
|||||||||||
| 205 | ||||||||||||
| 206 | if ($_w == 0 and $_h == 0) {
|
|||||||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Using logical operators such as
and instead of && is generally not recommended.
PHP has two types of connecting operators (logical operators, and boolean operators):
The difference between these is the order in which they are executed. In most cases,
you would want to use a boolean operator like Let’s take a look at a few examples: // Logical operators have lower precedence:
$f = false or true;
// is executed like this:
($f = false) or true;
// Boolean operators have higher precedence:
$f = false || true;
// is executed like this:
$f = (false || true);
Logical Operators are used for Control-FlowOne case where you explicitly want to use logical operators is for control-flow such as this: $x === 5
or die('$x must be 5.');
// Instead of
if ($x !== 5) {
die('$x must be 5.');
}
Since // The following is currently a parse error.
$x === 5
or throw new RuntimeException('$x must be 5.');
These limitations lead to logical operators rarely being of use in current PHP code. Loading history...
|
||||||||||||
| 207 | $_w = $w; |
|||||||||||
| 208 | $_h = $h; |
|||||||||||
| 209 | } |
|||||||||||
| 210 | ||||||||||||
| 211 | if($_w==0) |
|||||||||||
| 212 | $_w = $_h*$w/$h; |
|||||||||||
| 213 | if($_h==0) |
|||||||||||
| 214 | $_h = $_w*$h/$w; |
|||||||||||
| 215 | ||||||||||||
| 216 | return array("w" => $_w, "h" => $_h);
|
|||||||||||
| 217 | } |
|||||||||||
| 218 | ||||||||||||
| 219 | /** |
|||||||||||
| 220 | * See FPDF-Documentation ;-) |
|||||||||||
| 221 | */ |
|||||||||||
| 222 | function SetFont($family, $style='', $size=0) {
|
|||||||||||
|
0 ignored issues
–
show
|
||||||||||||
| 223 | /** |
|||||||||||
| 224 | * force the resetting of font changes in a template |
|||||||||||
| 225 | */ |
|||||||||||
| 226 | if ($this->_intpl) |
|||||||||||
| 227 | $this->FontFamily = ''; |
|||||||||||
| 228 | ||||||||||||
| 229 | parent::SetFont($family, $style, $size); |
|||||||||||
| 230 | ||||||||||||
| 231 | $fontkey = $this->FontFamily.$this->FontStyle; |
|||||||||||
| 232 | ||||||||||||
| 233 | View Code Duplication | if ($this->_intpl) {
|
||||||||||
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
||||||||||||
| 234 | $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; |
|||||||||||
| 235 | } else {
|
|||||||||||
| 236 | $this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey]; |
|||||||||||
| 237 | } |
|||||||||||
| 238 | } |
|||||||||||
| 239 | ||||||||||||
| 240 | /** |
|||||||||||
| 241 | * See FPDF/TCPDF-Documentation ;-) |
|||||||||||
| 242 | */ |
|||||||||||
| 243 | function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link=''){
|
|||||||||||
|
0 ignored issues
–
show
|
||||||||||||
| 244 | //function Image($file, $x, $y, $w=0, $h=0, $type='', $link='', $align='', $resize=false, $dpi=300) {
|
|||||||||||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
62% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
||||||||||||
| 245 | if (!is_subclass_of($this, 'TCPDF') && func_num_args() > 7) {
|
|||||||||||
| 246 | $this->Error('More than 7 arguments for the Image method are only available in TCPDF.');
|
|||||||||||
| 247 | } |
|||||||||||
| 248 | ||||||||||||
| 249 | //parent::Image($file, $x, $y, $w, $h, $type, $link, $align, $resize, $dpi); |
|||||||||||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
71% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
||||||||||||
| 250 | parent::Image($file, $x, $y, $w, $h, $type, $link); |
|||||||||||
| 251 | View Code Duplication | if ($this->_intpl) {
|
||||||||||
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
||||||||||||
| 252 | $this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file]; |
|||||||||||
| 253 | } else {
|
|||||||||||
| 254 | $this->_res['page'][$this->page]['images'][$file] =& $this->images[$file]; |
|||||||||||
| 255 | } |
|||||||||||
| 256 | } |
|||||||||||
| 257 | ||||||||||||
| 258 | /** |
|||||||||||
| 259 | * See FPDF-Documentation ;-) |
|||||||||||
| 260 | * |
|||||||||||
| 261 | * AddPage is not available when you're "in" a template. |
|||||||||||
| 262 | */ |
|||||||||||
| 263 | function AddPage($orientation='', $size='', $rotation=0) {
|
|||||||||||
|
0 ignored issues
–
show
|
||||||||||||
| 264 | if ($this->_intpl) |
|||||||||||
| 265 | $this->Error('Adding pages in templates isn\'t possible!');
|
|||||||||||
| 266 | parent::AddPage($orientation, $format, $rotation); |
|||||||||||
|
0 ignored issues
–
show
|
||||||||||||
| 267 | } |
|||||||||||
| 268 | ||||||||||||
| 269 | /** |
|||||||||||
| 270 | * Preserve adding Links in Templates ...won't work |
|||||||||||
| 271 | */ |
|||||||||||
| 272 | function Link($x, $y, $w, $h, $link) {
|
|||||||||||
|
0 ignored issues
–
show
|
||||||||||||
| 273 | if ($this->_intpl) |
|||||||||||
| 274 | $this->Error('Using links in templates aren\'t possible!');
|
|||||||||||
| 275 | parent::Link($x, $y, $w, $h, $link); |
|||||||||||
| 276 | } |
|||||||||||
| 277 | ||||||||||||
| 278 | function AddLink() {
|
|||||||||||
|
0 ignored issues
–
show
|
||||||||||||
| 279 | if ($this->_intpl) |
|||||||||||
| 280 | $this->Error('Adding links in templates aren\'t possible!');
|
|||||||||||
| 281 | return parent::AddLink(); |
|||||||||||
| 282 | } |
|||||||||||
| 283 | ||||||||||||
| 284 | function SetLink($link, $y=0, $page=-1) {
|
|||||||||||
|
0 ignored issues
–
show
|
||||||||||||
| 285 | if ($this->_intpl) |
|||||||||||
| 286 | $this->Error('Setting links in templates aren\'t possible!');
|
|||||||||||
| 287 | parent::SetLink($link, $y, $page); |
|||||||||||
| 288 | } |
|||||||||||
| 289 | ||||||||||||
| 290 | /** |
|||||||||||
| 291 | * Private Method that writes the form xobjects |
|||||||||||
| 292 | */ |
|||||||||||
| 293 | function _putformxobjects() {
|
|||||||||||
|
0 ignored issues
–
show
|
||||||||||||
| 294 | $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; |
|||||||||||
| 295 | reset($this->tpls); |
|||||||||||
| 296 | foreach($this->tpls AS $tplidx => $tpl) {
|
|||||||||||
| 297 | ||||||||||||
| 298 | $p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer']; |
|||||||||||
| 299 | $this->_newobj(); |
|||||||||||
| 300 | $this->tpls[$tplidx]['n'] = $this->n; |
|||||||||||
| 301 | $this->_out('<<'.$filter.'/Type /XObject');
|
|||||||||||
| 302 | $this->_out('/Subtype /Form');
|
|||||||||||
| 303 | $this->_out('/FormType 1');
|
|||||||||||
| 304 | $this->_out(sprintf('/BBox [%.2f %.2f %.2f %.2f]',$tpl['x']*$this->k, ($tpl['h']-$tpl['y'])*$this->k, $tpl['w']*$this->k, ($tpl['h']-$tpl['y']-$tpl['h'])*$this->k));
|
|||||||||||
| 305 | $this->_out('/Resources ');
|
|||||||||||
| 306 | ||||||||||||
| 307 | $this->_out('<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
|
|||||||||||
| 308 | View Code Duplication | if (isset($this->_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) {
|
||||||||||
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
||||||||||||
| 309 | $this->_out('/Font <<');
|
|||||||||||
| 310 | foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) |
|||||||||||
| 311 | $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R');
|
|||||||||||
| 312 | $this->_out('>>');
|
|||||||||||
| 313 | } |
|||||||||||
| 314 | View Code Duplication | if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || |
||||||||||
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
||||||||||||
| 315 | isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) |
|||||||||||
| 316 | {
|
|||||||||||
| 317 | $this->_out('/XObject <<');
|
|||||||||||
| 318 | if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) {
|
|||||||||||
| 319 | foreach($this->_res['tpl'][$tplidx]['images'] as $image) |
|||||||||||
| 320 | $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R');
|
|||||||||||
| 321 | } |
|||||||||||
| 322 | if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) {
|
|||||||||||
| 323 | foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) |
|||||||||||
| 324 | $this->_out($this->tplprefix.$i.' '.$tpl['n'].' 0 R'); |
|||||||||||
| 325 | } |
|||||||||||
| 326 | $this->_out('>>');
|
|||||||||||
| 327 | } |
|||||||||||
| 328 | $this->_out('>>');
|
|||||||||||
| 329 | ||||||||||||
| 330 | $this->_out('/Length '.strlen($p).' >>');
|
|||||||||||
| 331 | $this->_putstream($p); |
|||||||||||
| 332 | $this->_out('endobj');
|
|||||||||||
| 333 | } |
|||||||||||
| 334 | } |
|||||||||||
| 335 | ||||||||||||
| 336 | /** |
|||||||||||
| 337 | * Private Method |
|||||||||||
| 338 | */ |
|||||||||||
| 339 | View Code Duplication | function _putresources() {
|
||||||||||
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
||||||||||||
| 340 | if (!is_subclass_of($this, 'TCPDF')) {
|
|||||||||||
| 341 | $this->_putfonts(); |
|||||||||||
| 342 | $this->_putimages(); |
|||||||||||
| 343 | $this->_putformxobjects(); |
|||||||||||
| 344 | //Resource dictionary |
|||||||||||
| 345 | $this->offsets[2]=strlen($this->buffer); |
|||||||||||
| 346 | $this->_out('2 0 obj');
|
|||||||||||
| 347 | $this->_out('<<');
|
|||||||||||
| 348 | $this->_putresourcedict(); |
|||||||||||
| 349 | $this->_out('>>');
|
|||||||||||
| 350 | $this->_out('endobj');
|
|||||||||||
| 351 | } else {
|
|||||||||||
| 352 | $this->_putextgstates(); |
|||||||||||
|
0 ignored issues
–
show
The method
_putextgstates() does not seem to exist on object<FPDF_TPL>.
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
||||||||||||
| 353 | $this->_putocg(); |
|||||||||||
|
0 ignored issues
–
show
The method
_putocg() does not seem to exist on object<FPDF_TPL>.
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
||||||||||||
| 354 | $this->_putfonts(); |
|||||||||||
| 355 | $this->_putimages(); |
|||||||||||
| 356 | $this->_putshaders(); |
|||||||||||
|
0 ignored issues
–
show
The method
_putshaders() does not seem to exist on object<FPDF_TPL>.
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
||||||||||||
| 357 | $this->_putformxobjects(); |
|||||||||||
| 358 | //Resource dictionary |
|||||||||||
| 359 | $this->offsets[2]=strlen($this->buffer); |
|||||||||||
| 360 | $this->_out('2 0 obj');
|
|||||||||||
| 361 | $this->_out('<<');
|
|||||||||||
| 362 | $this->_putresourcedict(); |
|||||||||||
| 363 | $this->_out('>>');
|
|||||||||||
| 364 | $this->_out('endobj');
|
|||||||||||
| 365 | $this->_putjavascript(); |
|||||||||||
|
0 ignored issues
–
show
The method
_putjavascript() does not seem to exist on object<FPDF_TPL>.
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
||||||||||||
| 366 | $this->_putbookmarks(); |
|||||||||||
|
0 ignored issues
–
show
The method
_putbookmarks() does not seem to exist on object<FPDF_TPL>.
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
||||||||||||
| 367 | // encryption |
|||||||||||
| 368 | if ($this->encrypted) {
|
|||||||||||
|
0 ignored issues
–
show
The property
encrypted does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
Loading history...
|
||||||||||||
| 369 | $this->_newobj(); |
|||||||||||
| 370 | $this->enc_obj_id = $this->n; |
|||||||||||
|
0 ignored issues
–
show
The property
enc_obj_id does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
Loading history...
|
||||||||||||
| 371 | $this->_out('<<');
|
|||||||||||
| 372 | $this->_putencryption(); |
|||||||||||
|
0 ignored issues
–
show
The method
_putencryption() does not seem to exist on object<FPDF_TPL>.
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
||||||||||||
| 373 | $this->_out('>>');
|
|||||||||||
| 374 | $this->_out('endobj');
|
|||||||||||
| 375 | } |
|||||||||||
| 376 | } |
|||||||||||
| 377 | } |
|||||||||||
| 378 | ||||||||||||
| 379 | function _putxobjectdict() {
|
|||||||||||
|
0 ignored issues
–
show
|
||||||||||||
| 380 | parent::_putxobjectdict(); |
|||||||||||
| 381 | ||||||||||||
| 382 | if (count($this->tpls)) {
|
|||||||||||
| 383 | foreach($this->tpls as $tplidx => $tpl) {
|
|||||||||||
| 384 | $this->_out($this->tplprefix.$tplidx.' '.$tpl['n'].' 0 R'); |
|||||||||||
| 385 | } |
|||||||||||
| 386 | } |
|||||||||||
| 387 | } |
|||||||||||
| 388 | ||||||||||||
| 389 | /** |
|||||||||||
| 390 | * Private Method |
|||||||||||
| 391 | */ |
|||||||||||
| 392 | function _out($s) {
|
|||||||||||
|
0 ignored issues
–
show
|
||||||||||||
| 393 | if ($this->state==2 && $this->_intpl) {
|
|||||||||||
| 394 | $this->tpls[$this->tpl]['buffer'] .= $s."\n"; |
|||||||||||
| 395 | } else {
|
|||||||||||
| 396 | parent::_out($s); |
|||||||||||
| 397 | } |
|||||||||||
| 398 | } |
|||||||||||
| 399 | } |
|||||||||||
| 400 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.