@@ -305,6 +305,10 @@ discard block |
||
| 305 | 305 | */ |
| 306 | 306 | |
| 307 | 307 | if ( !function_exists("mb_convert_encoding") ) { |
| 308 | + |
|
| 309 | + /** |
|
| 310 | + * @param string|null $to_encoding |
|
| 311 | + */ |
|
| 308 | 312 | function mb_convert_encoding($data, $to_encoding, $from_encoding='UTF-8') { |
| 309 | 313 | if (str_replace('-', '', strtolower($to_encoding)) == 'utf8') { |
| 310 | 314 | return utf8_encode($data); |
@@ -327,6 +331,10 @@ discard block |
||
| 327 | 331 | } |
| 328 | 332 | |
| 329 | 333 | if ( !function_exists("mb_internal_encoding") ) { |
| 334 | + |
|
| 335 | + /** |
|
| 336 | + * @param string $encoding |
|
| 337 | + */ |
|
| 330 | 338 | function mb_internal_encoding($encoding=NULL) { |
| 331 | 339 | if (isset($encoding)) { |
| 332 | 340 | return true; |
@@ -365,6 +373,10 @@ discard block |
||
| 365 | 373 | } |
| 366 | 374 | |
| 367 | 375 | if ( !function_exists("mb_strtoupper") ) { |
| 376 | + |
|
| 377 | + /** |
|
| 378 | + * @param string $str |
|
| 379 | + */ |
|
| 368 | 380 | function mb_strtoupper($str) { |
| 369 | 381 | return strtoupper($str); |
| 370 | 382 | } |
@@ -380,6 +392,10 @@ discard block |
||
| 380 | 392 | } |
| 381 | 393 | |
| 382 | 394 | if ( !function_exists("mb_substr_count") ) { |
| 395 | + |
|
| 396 | + /** |
|
| 397 | + * @param string $needle |
|
| 398 | + */ |
|
| 383 | 399 | function mb_substr_count($haystack, $needle) { |
| 384 | 400 | return substr_count($haystack, $needle); |
| 385 | 401 | } |
@@ -442,6 +458,7 @@ discard block |
||
| 442 | 458 | * Print debug messages |
| 443 | 459 | * |
| 444 | 460 | * @param string $type The type of debug messages to print |
| 461 | + * @param string $msg |
|
| 445 | 462 | */ |
| 446 | 463 | function dompdf_debug($type, $msg) { |
| 447 | 464 | global $_DOMPDF_DEBUG_TYPES; |
@@ -63,18 +63,18 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | if ( !function_exists("pre_r") ) { |
| 65 | 65 | function pre_r($mixed, $return = false) { |
| 66 | - if ($return) |
|
| 66 | + if ($return) |
|
| 67 | 67 | return "<pre>" . print_r($mixed, true) . "</pre>"; |
| 68 | 68 | |
| 69 | - if ( php_sapi_name() !== "cli") |
|
| 69 | + if ( php_sapi_name() !== "cli") |
|
| 70 | 70 | echo ("<pre>"); |
| 71 | - print_r($mixed); |
|
| 71 | + print_r($mixed); |
|
| 72 | 72 | |
| 73 | - if ( php_sapi_name() !== "cli") |
|
| 73 | + if ( php_sapi_name() !== "cli") |
|
| 74 | 74 | echo("</pre>"); |
| 75 | - else |
|
| 75 | + else |
|
| 76 | 76 | echo ("\n"); |
| 77 | - flush(); |
|
| 77 | + flush(); |
|
| 78 | 78 | |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | if ( !function_exists("pre_var_dump") ) { |
| 91 | 91 | function pre_var_dump($mixed) { |
| 92 | - if ( php_sapi_name() !== "cli") |
|
| 92 | + if ( php_sapi_name() !== "cli") |
|
| 93 | 93 | echo("<pre>"); |
| 94 | - var_dump($mixed); |
|
| 95 | - if ( php_sapi_name() !== "cli") |
|
| 94 | + var_dump($mixed); |
|
| 95 | + if ( php_sapi_name() !== "cli") |
|
| 96 | 96 | echo("</pre>"); |
| 97 | 97 | } |
| 98 | 98 | } |
@@ -115,41 +115,41 @@ discard block |
||
| 115 | 115 | * is appended (o.k. also for Windows) |
| 116 | 116 | */ |
| 117 | 117 | function build_url($protocol, $host, $base_path, $url) { |
| 118 | - if ( mb_strlen($url) == 0 ) { |
|
| 118 | + if ( mb_strlen($url) == 0 ) { |
|
| 119 | 119 | //return $protocol . $host . rtrim($base_path, "/\\") . "/"; |
| 120 | 120 | return $protocol . $host . $base_path; |
| 121 | - } |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - // Is the url already fully qualified? |
|
| 124 | - if ( mb_strpos($url, "://") !== false ) |
|
| 123 | + // Is the url already fully qualified? |
|
| 124 | + if ( mb_strpos($url, "://") !== false ) |
|
| 125 | 125 | return $url; |
| 126 | 126 | |
| 127 | - $ret = $protocol; |
|
| 127 | + $ret = $protocol; |
|
| 128 | 128 | |
| 129 | - if (!in_array(mb_strtolower($protocol), array("http://", "https://", "ftp://", "ftps://"))) { |
|
| 129 | + if (!in_array(mb_strtolower($protocol), array("http://", "https://", "ftp://", "ftps://"))) { |
|
| 130 | 130 | //On Windows local file, an abs path can begin also with a '\' or a drive letter and colon |
| 131 | 131 | //drive: followed by a relative path would be a drive specific default folder. |
| 132 | 132 | //not known in php app code, treat as abs path |
| 133 | 133 | //($url[1] !== ':' || ($url[2]!=='\\' && $url[2]!=='/')) |
| 134 | 134 | if ($url[0] !== '/' && (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' || ($url[0] !== '\\' && $url[1] !== ':'))) { |
| 135 | - // For rel path and local acess we ignore the host, and run the path through realpath() |
|
| 136 | - $ret .= realpath($base_path).'/'; |
|
| 135 | + // For rel path and local acess we ignore the host, and run the path through realpath() |
|
| 136 | + $ret .= realpath($base_path).'/'; |
|
| 137 | 137 | } |
| 138 | 138 | $ret .= $url; |
| 139 | 139 | return $ret; |
| 140 | - } |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - //remote urls with backslash in html/css are not really correct, but lets be genereous |
|
| 143 | - if ( $url[0] === '/' || $url[0] === '\\' ) { |
|
| 142 | + //remote urls with backslash in html/css are not really correct, but lets be genereous |
|
| 143 | + if ( $url[0] === '/' || $url[0] === '\\' ) { |
|
| 144 | 144 | // Absolute path |
| 145 | 145 | $ret .= $host . $url; |
| 146 | - } else { |
|
| 146 | + } else { |
|
| 147 | 147 | // Relative path |
| 148 | 148 | //$base_path = $base_path !== "" ? rtrim($base_path, "/\\") . "/" : ""; |
| 149 | 149 | $ret .= $host . $base_path . $url; |
| 150 | - } |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - return $ret; |
|
| 152 | + return $ret; |
|
| 153 | 153 | |
| 154 | 154 | } |
| 155 | 155 | |
@@ -161,56 +161,56 @@ discard block |
||
| 161 | 161 | * @return array |
| 162 | 162 | */ |
| 163 | 163 | function explode_url($url) { |
| 164 | - $protocol = ""; |
|
| 165 | - $host = ""; |
|
| 166 | - $path = ""; |
|
| 167 | - $file = ""; |
|
| 164 | + $protocol = ""; |
|
| 165 | + $host = ""; |
|
| 166 | + $path = ""; |
|
| 167 | + $file = ""; |
|
| 168 | 168 | |
| 169 | - $arr = parse_url($url); |
|
| 169 | + $arr = parse_url($url); |
|
| 170 | 170 | |
| 171 | - if ( isset($arr["scheme"]) && |
|
| 171 | + if ( isset($arr["scheme"]) && |
|
| 172 | 172 | $arr["scheme"] !== "file" && |
| 173 | 173 | mb_strlen($arr["scheme"]) > 1 ) // Exclude windows drive letters... |
| 174 | 174 | { |
| 175 | 175 | $protocol = $arr["scheme"] . "://"; |
| 176 | 176 | |
| 177 | 177 | if ( isset($arr["user"]) ) { |
| 178 | - $host .= $arr["user"]; |
|
| 178 | + $host .= $arr["user"]; |
|
| 179 | 179 | |
| 180 | - if ( isset($arr["pass"]) ) |
|
| 180 | + if ( isset($arr["pass"]) ) |
|
| 181 | 181 | $host .= "@" . $arr["pass"]; |
| 182 | 182 | |
| 183 | - $host .= ":"; |
|
| 183 | + $host .= ":"; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | if ( isset($arr["host"]) ) |
| 187 | - $host .= $arr["host"]; |
|
| 187 | + $host .= $arr["host"]; |
|
| 188 | 188 | |
| 189 | 189 | if ( isset($arr["port"]) ) |
| 190 | - $host .= ":" . $arr["port"]; |
|
| 190 | + $host .= ":" . $arr["port"]; |
|
| 191 | 191 | |
| 192 | 192 | if ( isset($arr["path"]) && $arr["path"] !== "" ) { |
| 193 | - // Do we have a trailing slash? |
|
| 194 | - if ( $arr["path"]{ mb_strlen($arr["path"]) - 1 } === "/" ) { |
|
| 193 | + // Do we have a trailing slash? |
|
| 194 | + if ( $arr["path"]{ mb_strlen($arr["path"]) - 1 } === "/" ) { |
|
| 195 | 195 | $path = $arr["path"]; |
| 196 | 196 | $file = ""; |
| 197 | - } else { |
|
| 197 | + } else { |
|
| 198 | 198 | $path = dirname($arr["path"]) . "/"; |
| 199 | 199 | $file = basename($arr["path"]); |
| 200 | - } |
|
| 200 | + } |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | if ( isset($arr["query"]) ) |
| 204 | - $file .= "?" . $arr["query"]; |
|
| 204 | + $file .= "?" . $arr["query"]; |
|
| 205 | 205 | |
| 206 | 206 | if ( isset($arr["fragment"]) ) |
| 207 | - $file .= "#" . $arr["fragment"]; |
|
| 207 | + $file .= "#" . $arr["fragment"]; |
|
| 208 | 208 | |
| 209 | - } else { |
|
| 209 | + } else { |
|
| 210 | 210 | |
| 211 | 211 | $i = mb_strpos($url, "file://"); |
| 212 | 212 | if ( $i !== false) |
| 213 | - $url = mb_substr($url, $i + 7); |
|
| 213 | + $url = mb_substr($url, $i + 7); |
|
| 214 | 214 | |
| 215 | 215 | $protocol = ""; // "file://"; ? why doesn't this work... It's because of |
| 216 | 216 | // network filenames like //COMPU/SHARENAME |
@@ -222,28 +222,28 @@ discard block |
||
| 222 | 222 | |
| 223 | 223 | // Check that the path exists |
| 224 | 224 | if ( $path !== false ) { |
| 225 | - $path .= '/'; |
|
| 225 | + $path .= '/'; |
|
| 226 | 226 | |
| 227 | 227 | } else { |
| 228 | - // generate a url to access the file if no real path found. |
|
| 229 | - $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://'; |
|
| 228 | + // generate a url to access the file if no real path found. |
|
| 229 | + $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://'; |
|
| 230 | 230 | |
| 231 | - $host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : php_uname("n"); |
|
| 231 | + $host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : php_uname("n"); |
|
| 232 | 232 | |
| 233 | - if ( substr($arr["path"], 0, 1) === '/' ) { |
|
| 233 | + if ( substr($arr["path"], 0, 1) === '/' ) { |
|
| 234 | 234 | $path = dirname($arr["path"]); |
| 235 | - } else { |
|
| 235 | + } else { |
|
| 236 | 236 | $path = '/' . rtrim(dirname($_SERVER["SCRIPT_NAME"]), '/') . '/' . $arr["path"]; |
| 237 | - } |
|
| 237 | + } |
|
| 238 | + } |
|
| 238 | 239 | } |
| 239 | - } |
|
| 240 | - |
|
| 241 | - $ret = array($protocol, $host, $path, $file, |
|
| 242 | - "protocol" => $protocol, |
|
| 243 | - "host" => $host, |
|
| 244 | - "path" => $path, |
|
| 245 | - "file" => $file); |
|
| 246 | - return $ret; |
|
| 240 | + |
|
| 241 | + $ret = array($protocol, $host, $path, $file, |
|
| 242 | + "protocol" => $protocol, |
|
| 243 | + "host" => $host, |
|
| 244 | + "path" => $path, |
|
| 245 | + "file" => $file); |
|
| 246 | + return $ret; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -254,41 +254,41 @@ discard block |
||
| 254 | 254 | */ |
| 255 | 255 | function dec2roman($num) { |
| 256 | 256 | |
| 257 | - static $ones = array("", "i", "ii", "iii", "iv", "v", |
|
| 258 | - "vi", "vii", "viii", "ix"); |
|
| 259 | - static $tens = array("", "x", "xx", "xxx", "xl", "l", |
|
| 260 | - "lx", "lxx", "lxxx", "xc"); |
|
| 261 | - static $hund = array("", "c", "cc", "ccc", "cd", "d", |
|
| 262 | - "dc", "dcc", "dccc", "cm"); |
|
| 263 | - static $thou = array("", "m", "mm", "mmm"); |
|
| 257 | + static $ones = array("", "i", "ii", "iii", "iv", "v", |
|
| 258 | + "vi", "vii", "viii", "ix"); |
|
| 259 | + static $tens = array("", "x", "xx", "xxx", "xl", "l", |
|
| 260 | + "lx", "lxx", "lxxx", "xc"); |
|
| 261 | + static $hund = array("", "c", "cc", "ccc", "cd", "d", |
|
| 262 | + "dc", "dcc", "dccc", "cm"); |
|
| 263 | + static $thou = array("", "m", "mm", "mmm"); |
|
| 264 | 264 | |
| 265 | - if ( !is_numeric($num) ) |
|
| 265 | + if ( !is_numeric($num) ) |
|
| 266 | 266 | throw new DOMPDF_Exception("dec2roman() requires a numeric argument."); |
| 267 | 267 | |
| 268 | - if ( $num > 4000 || $num < 0 ) |
|
| 268 | + if ( $num > 4000 || $num < 0 ) |
|
| 269 | 269 | return "(out of range)"; |
| 270 | 270 | |
| 271 | - $num = strrev((string)$num); |
|
| 271 | + $num = strrev((string)$num); |
|
| 272 | 272 | |
| 273 | - $ret = ""; |
|
| 274 | - switch (mb_strlen($num)) { |
|
| 273 | + $ret = ""; |
|
| 274 | + switch (mb_strlen($num)) { |
|
| 275 | 275 | |
| 276 | - case 4: |
|
| 276 | + case 4: |
|
| 277 | 277 | $ret .= $thou[$num[3]]; |
| 278 | 278 | |
| 279 | - case 3: |
|
| 279 | + case 3: |
|
| 280 | 280 | $ret .= $hund[$num[2]]; |
| 281 | 281 | |
| 282 | - case 2: |
|
| 282 | + case 2: |
|
| 283 | 283 | $ret .= $tens[$num[1]]; |
| 284 | 284 | |
| 285 | - case 1: |
|
| 285 | + case 1: |
|
| 286 | 286 | $ret .= $ones[$num[0]]; |
| 287 | 287 | |
| 288 | - default: |
|
| 288 | + default: |
|
| 289 | 289 | break; |
| 290 | - } |
|
| 291 | - return $ret; |
|
| 290 | + } |
|
| 291 | + return $ret; |
|
| 292 | 292 | |
| 293 | 293 | } |
| 294 | 294 | |
@@ -305,84 +305,84 @@ discard block |
||
| 305 | 305 | */ |
| 306 | 306 | |
| 307 | 307 | if ( !function_exists("mb_convert_encoding") ) { |
| 308 | - function mb_convert_encoding($data, $to_encoding, $from_encoding='UTF-8') { |
|
| 308 | + function mb_convert_encoding($data, $to_encoding, $from_encoding='UTF-8') { |
|
| 309 | 309 | if (str_replace('-', '', strtolower($to_encoding)) == 'utf8') { |
| 310 | - return utf8_encode($data); |
|
| 310 | + return utf8_encode($data); |
|
| 311 | 311 | } else { |
| 312 | - return utf8_decode($data); |
|
| 312 | + return utf8_decode($data); |
|
| 313 | + } |
|
| 313 | 314 | } |
| 314 | - } |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | if ( !function_exists("mb_detect_encoding") ) { |
| 318 | - function mb_detect_encoding($data, $encoding_list=array('iso-8859-1'), $strict=false) { |
|
| 318 | + function mb_detect_encoding($data, $encoding_list=array('iso-8859-1'), $strict=false) { |
|
| 319 | 319 | return 'iso-8859-1'; |
| 320 | - } |
|
| 320 | + } |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | if ( !function_exists("mb_detect_order") ) { |
| 324 | - function mb_detect_order($encoding_list=array('iso-8859-1')) { |
|
| 324 | + function mb_detect_order($encoding_list=array('iso-8859-1')) { |
|
| 325 | 325 | return 'iso-8859-1'; |
| 326 | - } |
|
| 326 | + } |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | if ( !function_exists("mb_internal_encoding") ) { |
| 330 | - function mb_internal_encoding($encoding=NULL) { |
|
| 330 | + function mb_internal_encoding($encoding=NULL) { |
|
| 331 | 331 | if (isset($encoding)) { |
| 332 | - return true; |
|
| 332 | + return true; |
|
| 333 | 333 | } else { |
| 334 | - return 'iso-8859-1'; |
|
| 334 | + return 'iso-8859-1'; |
|
| 335 | + } |
|
| 335 | 336 | } |
| 336 | - } |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | if ( !function_exists("mb_strlen") ) { |
| 340 | - function mb_strlen($str, $encoding='iso-8859-1') { |
|
| 340 | + function mb_strlen($str, $encoding='iso-8859-1') { |
|
| 341 | 341 | if (str_replace('-', '', strtolower($encoding)) == 'utf8') { |
| 342 | - return strlen(utf8_encode($data)); |
|
| 342 | + return strlen(utf8_encode($data)); |
|
| 343 | 343 | } else { |
| 344 | - return strlen(utf8_decode($data)); |
|
| 344 | + return strlen(utf8_decode($data)); |
|
| 345 | + } |
|
| 345 | 346 | } |
| 346 | - } |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | if ( !function_exists("mb_strpos") ) { |
| 350 | - function mb_strpos($haystack, $needle, $offset = 0) { |
|
| 350 | + function mb_strpos($haystack, $needle, $offset = 0) { |
|
| 351 | 351 | return strpos($haystack, $needle, $offset); |
| 352 | - } |
|
| 352 | + } |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | if ( !function_exists("mb_strrpos") ) { |
| 356 | - function mb_strrpos($haystack, $needle, $offset = 0) { |
|
| 356 | + function mb_strrpos($haystack, $needle, $offset = 0) { |
|
| 357 | 357 | return strrpos($haystack, $needle, $offset); |
| 358 | - } |
|
| 358 | + } |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | if ( !function_exists("mb_strtolower") ) { |
| 362 | - function mb_strtolower($str) { |
|
| 362 | + function mb_strtolower($str) { |
|
| 363 | 363 | return strtolower($str); |
| 364 | - } |
|
| 364 | + } |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | if ( !function_exists("mb_strtoupper") ) { |
| 368 | - function mb_strtoupper($str) { |
|
| 368 | + function mb_strtoupper($str) { |
|
| 369 | 369 | return strtoupper($str); |
| 370 | - } |
|
| 370 | + } |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | if ( !function_exists("mb_substr") ) { |
| 374 | - function mb_substr($str, $start, $length=null, $encoding='iso-8859-1') { |
|
| 374 | + function mb_substr($str, $start, $length=null, $encoding='iso-8859-1') { |
|
| 375 | 375 | if ( is_null($length) ) |
| 376 | - return substr($str, $start); |
|
| 376 | + return substr($str, $start); |
|
| 377 | 377 | else |
| 378 | - return substr($str, $start, $length); |
|
| 379 | - } |
|
| 378 | + return substr($str, $start, $length); |
|
| 379 | + } |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | if ( !function_exists("mb_substr_count") ) { |
| 383 | - function mb_substr_count($haystack, $needle) { |
|
| 383 | + function mb_substr_count($haystack, $needle) { |
|
| 384 | 384 | return substr_count($haystack, $needle); |
| 385 | - } |
|
| 385 | + } |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
@@ -402,40 +402,40 @@ discard block |
||
| 402 | 402 | */ |
| 403 | 403 | function record_warnings($errno, $errstr, $errfile, $errline) { |
| 404 | 404 | |
| 405 | - if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) // Not a warning or notice |
|
| 405 | + if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) // Not a warning or notice |
|
| 406 | 406 | throw new DOMPDF_Exception($errstr . " $errno"); |
| 407 | 407 | |
| 408 | - global $_dompdf_warnings; |
|
| 409 | - global $_dompdf_show_warnings; |
|
| 408 | + global $_dompdf_warnings; |
|
| 409 | + global $_dompdf_show_warnings; |
|
| 410 | 410 | |
| 411 | - if ( $_dompdf_show_warnings ) |
|
| 411 | + if ( $_dompdf_show_warnings ) |
|
| 412 | 412 | echo $errstr . "\n"; |
| 413 | 413 | |
| 414 | - $_dompdf_warnings[] = $errstr; |
|
| 414 | + $_dompdf_warnings[] = $errstr; |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | /** |
| 418 | 418 | * Print a useful backtrace |
| 419 | 419 | */ |
| 420 | 420 | function bt() { |
| 421 | - $bt = debug_backtrace(); |
|
| 421 | + $bt = debug_backtrace(); |
|
| 422 | 422 | |
| 423 | - array_shift($bt); // remove actual bt() call |
|
| 424 | - echo "\n"; |
|
| 423 | + array_shift($bt); // remove actual bt() call |
|
| 424 | + echo "\n"; |
|
| 425 | 425 | |
| 426 | - $i = 0; |
|
| 427 | - foreach ($bt as $call) { |
|
| 426 | + $i = 0; |
|
| 427 | + foreach ($bt as $call) { |
|
| 428 | 428 | $file = basename($call["file"]) . " (" . $call["line"] . ")"; |
| 429 | 429 | if ( isset($call["class"]) ) { |
| 430 | - $func = $call["class"] . "->" . $call["function"] . "()"; |
|
| 430 | + $func = $call["class"] . "->" . $call["function"] . "()"; |
|
| 431 | 431 | } else { |
| 432 | - $func = $call["function"] . "()"; |
|
| 432 | + $func = $call["function"] . "()"; |
|
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | echo "#" . str_pad($i, 2, " ", STR_PAD_RIGHT) . ": " . str_pad($file.":", 42) . " $func\n"; |
| 436 | 436 | $i++; |
| 437 | - } |
|
| 438 | - echo "\n"; |
|
| 437 | + } |
|
| 438 | + echo "\n"; |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | /** |
@@ -444,15 +444,15 @@ discard block |
||
| 444 | 444 | * @param string $type The type of debug messages to print |
| 445 | 445 | */ |
| 446 | 446 | function dompdf_debug($type, $msg) { |
| 447 | - global $_DOMPDF_DEBUG_TYPES; |
|
| 448 | - global $_dompdf_show_warnings; |
|
| 449 | - global $_dompdf_debug; |
|
| 450 | - if ( isset($_DOMPDF_DEBUG_TYPES[$type]) && ($_dompdf_show_warnings || $_dompdf_debug) ) { |
|
| 447 | + global $_DOMPDF_DEBUG_TYPES; |
|
| 448 | + global $_dompdf_show_warnings; |
|
| 449 | + global $_dompdf_debug; |
|
| 450 | + if ( isset($_DOMPDF_DEBUG_TYPES[$type]) && ($_dompdf_show_warnings || $_dompdf_debug) ) { |
|
| 451 | 451 | $arr = debug_backtrace(); |
| 452 | 452 | |
| 453 | 453 | echo basename($arr[0]["file"]) . " (" . $arr[0]["line"] ."): " . $arr[1]["function"] . ": "; |
| 454 | 454 | pre_r($msg); |
| 455 | - } |
|
| 455 | + } |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | /** |
@@ -460,20 +460,20 @@ discard block |
||
| 460 | 460 | */ |
| 461 | 461 | if ( !function_exists("print_memusage") ) { |
| 462 | 462 | function print_memusage() { |
| 463 | - global $memusage; |
|
| 464 | - echo ("Memory Usage\n"); |
|
| 465 | - $prev = 0; |
|
| 466 | - $initial = reset($memusage); |
|
| 467 | - echo (str_pad("Initial:", 40) . $initial . "\n\n"); |
|
| 463 | + global $memusage; |
|
| 464 | + echo ("Memory Usage\n"); |
|
| 465 | + $prev = 0; |
|
| 466 | + $initial = reset($memusage); |
|
| 467 | + echo (str_pad("Initial:", 40) . $initial . "\n\n"); |
|
| 468 | 468 | |
| 469 | - foreach ($memusage as $key=>$mem) { |
|
| 469 | + foreach ($memusage as $key=>$mem) { |
|
| 470 | 470 | $mem -= $initial; |
| 471 | 471 | echo (str_pad("$key:" , 40)); |
| 472 | 472 | echo (str_pad("$mem", 12) . "(diff: " . ($mem - $prev) . ")\n"); |
| 473 | 473 | $prev = $mem; |
| 474 | - } |
|
| 474 | + } |
|
| 475 | 475 | |
| 476 | - echo ("\n" . str_pad("Total:", 40) . memory_get_usage()) . "\n"; |
|
| 476 | + echo ("\n" . str_pad("Total:", 40) . memory_get_usage()) . "\n"; |
|
| 477 | 477 | } |
| 478 | 478 | } |
| 479 | 479 | |
@@ -495,8 +495,8 @@ discard block |
||
| 495 | 495 | */ |
| 496 | 496 | if ( !function_exists("mark_memusage") ) { |
| 497 | 497 | function mark_memusage($location) { |
| 498 | - global $memusage; |
|
| 499 | - if ( isset($memusage) ) |
|
| 498 | + global $memusage; |
|
| 499 | + if ( isset($memusage) ) |
|
| 500 | 500 | $memusage[$location] = memory_get_usage(); |
| 501 | 501 | } |
| 502 | 502 | } |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | * @link http://us.php.net/manual/en/function.sys-get-temp-dir.php#85261 |
| 508 | 508 | */ |
| 509 | 509 | if ( !function_exists('sys_get_temp_dir')) { |
| 510 | - function sys_get_temp_dir() { |
|
| 510 | + function sys_get_temp_dir() { |
|
| 511 | 511 | if (!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); } |
| 512 | 512 | if (!empty($_ENV['TMPDIR'])) { return realpath( $_ENV['TMPDIR']); } |
| 513 | 513 | if (!empty($_ENV['TEMP'])) { return realpath( $_ENV['TEMP']); } |
@@ -516,5 +516,5 @@ discard block |
||
| 516 | 516 | unlink($tempfile); |
| 517 | 517 | return realpath(dirname($tempfile)); |
| 518 | 518 | } |
| 519 | - } |
|
| 519 | + } |
|
| 520 | 520 | } |
@@ -273,20 +273,20 @@ |
||
| 273 | 273 | $ret = ""; |
| 274 | 274 | switch (mb_strlen($num)) { |
| 275 | 275 | |
| 276 | - case 4: |
|
| 277 | - $ret .= $thou[$num[3]]; |
|
| 276 | + case 4: |
|
| 277 | + $ret .= $thou[$num[3]]; |
|
| 278 | 278 | |
| 279 | - case 3: |
|
| 280 | - $ret .= $hund[$num[2]]; |
|
| 279 | + case 3: |
|
| 280 | + $ret .= $hund[$num[2]]; |
|
| 281 | 281 | |
| 282 | - case 2: |
|
| 283 | - $ret .= $tens[$num[1]]; |
|
| 282 | + case 2: |
|
| 283 | + $ret .= $tens[$num[1]]; |
|
| 284 | 284 | |
| 285 | - case 1: |
|
| 286 | - $ret .= $ones[$num[0]]; |
|
| 285 | + case 1: |
|
| 286 | + $ret .= $ones[$num[0]]; |
|
| 287 | 287 | |
| 288 | - default: |
|
| 289 | - break; |
|
| 288 | + default: |
|
| 289 | + break; |
|
| 290 | 290 | } |
| 291 | 291 | return $ret; |
| 292 | 292 | |
@@ -61,16 +61,16 @@ discard block |
||
| 61 | 61 | * @param bool $return |
| 62 | 62 | * |
| 63 | 63 | */ |
| 64 | -if ( !function_exists("pre_r") ) { |
|
| 64 | +if (!function_exists("pre_r")) { |
|
| 65 | 65 | function pre_r($mixed, $return = false) { |
| 66 | 66 | if ($return) |
| 67 | - return "<pre>" . print_r($mixed, true) . "</pre>"; |
|
| 67 | + return "<pre>".print_r($mixed, true)."</pre>"; |
|
| 68 | 68 | |
| 69 | - if ( php_sapi_name() !== "cli") |
|
| 69 | + if (php_sapi_name() !== "cli") |
|
| 70 | 70 | echo ("<pre>"); |
| 71 | 71 | print_r($mixed); |
| 72 | 72 | |
| 73 | - if ( php_sapi_name() !== "cli") |
|
| 73 | + if (php_sapi_name() !== "cli") |
|
| 74 | 74 | echo("</pre>"); |
| 75 | 75 | else |
| 76 | 76 | echo ("\n"); |
@@ -87,12 +87,12 @@ discard block |
||
| 87 | 87 | * |
| 88 | 88 | * @param mixed $mixed variable or expression to display. |
| 89 | 89 | */ |
| 90 | -if ( !function_exists("pre_var_dump") ) { |
|
| 90 | +if (!function_exists("pre_var_dump")) { |
|
| 91 | 91 | function pre_var_dump($mixed) { |
| 92 | - if ( php_sapi_name() !== "cli") |
|
| 92 | + if (php_sapi_name() !== "cli") |
|
| 93 | 93 | echo("<pre>"); |
| 94 | 94 | var_dump($mixed); |
| 95 | - if ( php_sapi_name() !== "cli") |
|
| 95 | + if (php_sapi_name() !== "cli") |
|
| 96 | 96 | echo("</pre>"); |
| 97 | 97 | } |
| 98 | 98 | } |
@@ -115,13 +115,13 @@ discard block |
||
| 115 | 115 | * is appended (o.k. also for Windows) |
| 116 | 116 | */ |
| 117 | 117 | function build_url($protocol, $host, $base_path, $url) { |
| 118 | - if ( mb_strlen($url) == 0 ) { |
|
| 118 | + if (mb_strlen($url) == 0) { |
|
| 119 | 119 | //return $protocol . $host . rtrim($base_path, "/\\") . "/"; |
| 120 | - return $protocol . $host . $base_path; |
|
| 120 | + return $protocol.$host.$base_path; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // Is the url already fully qualified? |
| 124 | - if ( mb_strpos($url, "://") !== false ) |
|
| 124 | + if (mb_strpos($url, "://") !== false) |
|
| 125 | 125 | return $url; |
| 126 | 126 | |
| 127 | 127 | $ret = $protocol; |
@@ -140,13 +140,13 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | //remote urls with backslash in html/css are not really correct, but lets be genereous |
| 143 | - if ( $url[0] === '/' || $url[0] === '\\' ) { |
|
| 143 | + if ($url[0] === '/' || $url[0] === '\\') { |
|
| 144 | 144 | // Absolute path |
| 145 | - $ret .= $host . $url; |
|
| 145 | + $ret .= $host.$url; |
|
| 146 | 146 | } else { |
| 147 | 147 | // Relative path |
| 148 | 148 | //$base_path = $base_path !== "" ? rtrim($base_path, "/\\") . "/" : ""; |
| 149 | - $ret .= $host . $base_path . $url; |
|
| 149 | + $ret .= $host.$base_path.$url; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | return $ret; |
@@ -168,48 +168,48 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | $arr = parse_url($url); |
| 170 | 170 | |
| 171 | - if ( isset($arr["scheme"]) && |
|
| 171 | + if (isset($arr["scheme"]) && |
|
| 172 | 172 | $arr["scheme"] !== "file" && |
| 173 | - mb_strlen($arr["scheme"]) > 1 ) // Exclude windows drive letters... |
|
| 173 | + mb_strlen($arr["scheme"]) > 1) // Exclude windows drive letters... |
|
| 174 | 174 | { |
| 175 | - $protocol = $arr["scheme"] . "://"; |
|
| 175 | + $protocol = $arr["scheme"]."://"; |
|
| 176 | 176 | |
| 177 | - if ( isset($arr["user"]) ) { |
|
| 177 | + if (isset($arr["user"])) { |
|
| 178 | 178 | $host .= $arr["user"]; |
| 179 | 179 | |
| 180 | - if ( isset($arr["pass"]) ) |
|
| 181 | - $host .= "@" . $arr["pass"]; |
|
| 180 | + if (isset($arr["pass"])) |
|
| 181 | + $host .= "@".$arr["pass"]; |
|
| 182 | 182 | |
| 183 | 183 | $host .= ":"; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - if ( isset($arr["host"]) ) |
|
| 186 | + if (isset($arr["host"])) |
|
| 187 | 187 | $host .= $arr["host"]; |
| 188 | 188 | |
| 189 | - if ( isset($arr["port"]) ) |
|
| 190 | - $host .= ":" . $arr["port"]; |
|
| 189 | + if (isset($arr["port"])) |
|
| 190 | + $host .= ":".$arr["port"]; |
|
| 191 | 191 | |
| 192 | - if ( isset($arr["path"]) && $arr["path"] !== "" ) { |
|
| 192 | + if (isset($arr["path"]) && $arr["path"] !== "") { |
|
| 193 | 193 | // Do we have a trailing slash? |
| 194 | - if ( $arr["path"]{ mb_strlen($arr["path"]) - 1 } === "/" ) { |
|
| 194 | + if ($arr["path"]{ mb_strlen($arr["path"]) - 1 } === "/") { |
|
| 195 | 195 | $path = $arr["path"]; |
| 196 | 196 | $file = ""; |
| 197 | 197 | } else { |
| 198 | - $path = dirname($arr["path"]) . "/"; |
|
| 198 | + $path = dirname($arr["path"])."/"; |
|
| 199 | 199 | $file = basename($arr["path"]); |
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - if ( isset($arr["query"]) ) |
|
| 204 | - $file .= "?" . $arr["query"]; |
|
| 203 | + if (isset($arr["query"])) |
|
| 204 | + $file .= "?".$arr["query"]; |
|
| 205 | 205 | |
| 206 | - if ( isset($arr["fragment"]) ) |
|
| 207 | - $file .= "#" . $arr["fragment"]; |
|
| 206 | + if (isset($arr["fragment"])) |
|
| 207 | + $file .= "#".$arr["fragment"]; |
|
| 208 | 208 | |
| 209 | 209 | } else { |
| 210 | 210 | |
| 211 | 211 | $i = mb_strpos($url, "file://"); |
| 212 | - if ( $i !== false) |
|
| 212 | + if ($i !== false) |
|
| 213 | 213 | $url = mb_substr($url, $i + 7); |
| 214 | 214 | |
| 215 | 215 | $protocol = ""; // "file://"; ? why doesn't this work... It's because of |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | $path = dirname($url); |
| 222 | 222 | |
| 223 | 223 | // Check that the path exists |
| 224 | - if ( $path !== false ) { |
|
| 224 | + if ($path !== false) { |
|
| 225 | 225 | $path .= '/'; |
| 226 | 226 | |
| 227 | 227 | } else { |
@@ -230,10 +230,10 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | $host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : php_uname("n"); |
| 232 | 232 | |
| 233 | - if ( substr($arr["path"], 0, 1) === '/' ) { |
|
| 233 | + if (substr($arr["path"], 0, 1) === '/') { |
|
| 234 | 234 | $path = dirname($arr["path"]); |
| 235 | 235 | } else { |
| 236 | - $path = '/' . rtrim(dirname($_SERVER["SCRIPT_NAME"]), '/') . '/' . $arr["path"]; |
|
| 236 | + $path = '/'.rtrim(dirname($_SERVER["SCRIPT_NAME"]), '/').'/'.$arr["path"]; |
|
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | } |
@@ -262,13 +262,13 @@ discard block |
||
| 262 | 262 | "dc", "dcc", "dccc", "cm"); |
| 263 | 263 | static $thou = array("", "m", "mm", "mmm"); |
| 264 | 264 | |
| 265 | - if ( !is_numeric($num) ) |
|
| 265 | + if (!is_numeric($num)) |
|
| 266 | 266 | throw new DOMPDF_Exception("dec2roman() requires a numeric argument."); |
| 267 | 267 | |
| 268 | - if ( $num > 4000 || $num < 0 ) |
|
| 268 | + if ($num > 4000 || $num < 0) |
|
| 269 | 269 | return "(out of range)"; |
| 270 | 270 | |
| 271 | - $num = strrev((string)$num); |
|
| 271 | + $num = strrev((string) $num); |
|
| 272 | 272 | |
| 273 | 273 | $ret = ""; |
| 274 | 274 | switch (mb_strlen($num)) { |
@@ -304,8 +304,8 @@ discard block |
||
| 304 | 304 | * mb_string compatibility |
| 305 | 305 | */ |
| 306 | 306 | |
| 307 | -if ( !function_exists("mb_convert_encoding") ) { |
|
| 308 | - function mb_convert_encoding($data, $to_encoding, $from_encoding='UTF-8') { |
|
| 307 | +if (!function_exists("mb_convert_encoding")) { |
|
| 308 | + function mb_convert_encoding($data, $to_encoding, $from_encoding = 'UTF-8') { |
|
| 309 | 309 | if (str_replace('-', '', strtolower($to_encoding)) == 'utf8') { |
| 310 | 310 | return utf8_encode($data); |
| 311 | 311 | } else { |
@@ -314,20 +314,20 @@ discard block |
||
| 314 | 314 | } |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | -if ( !function_exists("mb_detect_encoding") ) { |
|
| 318 | - function mb_detect_encoding($data, $encoding_list=array('iso-8859-1'), $strict=false) { |
|
| 317 | +if (!function_exists("mb_detect_encoding")) { |
|
| 318 | + function mb_detect_encoding($data, $encoding_list = array('iso-8859-1'), $strict = false) { |
|
| 319 | 319 | return 'iso-8859-1'; |
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | -if ( !function_exists("mb_detect_order") ) { |
|
| 324 | - function mb_detect_order($encoding_list=array('iso-8859-1')) { |
|
| 323 | +if (!function_exists("mb_detect_order")) { |
|
| 324 | + function mb_detect_order($encoding_list = array('iso-8859-1')) { |
|
| 325 | 325 | return 'iso-8859-1'; |
| 326 | 326 | } |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | -if ( !function_exists("mb_internal_encoding") ) { |
|
| 330 | - function mb_internal_encoding($encoding=NULL) { |
|
| 329 | +if (!function_exists("mb_internal_encoding")) { |
|
| 330 | + function mb_internal_encoding($encoding = NULL) { |
|
| 331 | 331 | if (isset($encoding)) { |
| 332 | 332 | return true; |
| 333 | 333 | } else { |
@@ -336,8 +336,8 @@ discard block |
||
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | -if ( !function_exists("mb_strlen") ) { |
|
| 340 | - function mb_strlen($str, $encoding='iso-8859-1') { |
|
| 339 | +if (!function_exists("mb_strlen")) { |
|
| 340 | + function mb_strlen($str, $encoding = 'iso-8859-1') { |
|
| 341 | 341 | if (str_replace('-', '', strtolower($encoding)) == 'utf8') { |
| 342 | 342 | return strlen(utf8_encode($data)); |
| 343 | 343 | } else { |
@@ -346,40 +346,40 @@ discard block |
||
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | -if ( !function_exists("mb_strpos") ) { |
|
| 349 | +if (!function_exists("mb_strpos")) { |
|
| 350 | 350 | function mb_strpos($haystack, $needle, $offset = 0) { |
| 351 | 351 | return strpos($haystack, $needle, $offset); |
| 352 | 352 | } |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | -if ( !function_exists("mb_strrpos") ) { |
|
| 355 | +if (!function_exists("mb_strrpos")) { |
|
| 356 | 356 | function mb_strrpos($haystack, $needle, $offset = 0) { |
| 357 | 357 | return strrpos($haystack, $needle, $offset); |
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | -if ( !function_exists("mb_strtolower") ) { |
|
| 361 | +if (!function_exists("mb_strtolower")) { |
|
| 362 | 362 | function mb_strtolower($str) { |
| 363 | 363 | return strtolower($str); |
| 364 | 364 | } |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | -if ( !function_exists("mb_strtoupper") ) { |
|
| 367 | +if (!function_exists("mb_strtoupper")) { |
|
| 368 | 368 | function mb_strtoupper($str) { |
| 369 | 369 | return strtoupper($str); |
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | -if ( !function_exists("mb_substr") ) { |
|
| 374 | - function mb_substr($str, $start, $length=null, $encoding='iso-8859-1') { |
|
| 375 | - if ( is_null($length) ) |
|
| 373 | +if (!function_exists("mb_substr")) { |
|
| 374 | + function mb_substr($str, $start, $length = null, $encoding = 'iso-8859-1') { |
|
| 375 | + if (is_null($length)) |
|
| 376 | 376 | return substr($str, $start); |
| 377 | 377 | else |
| 378 | 378 | return substr($str, $start, $length); |
| 379 | 379 | } |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | -if ( !function_exists("mb_substr_count") ) { |
|
| 382 | +if (!function_exists("mb_substr_count")) { |
|
| 383 | 383 | function mb_substr_count($haystack, $needle) { |
| 384 | 384 | return substr_count($haystack, $needle); |
| 385 | 385 | } |
@@ -402,14 +402,14 @@ discard block |
||
| 402 | 402 | */ |
| 403 | 403 | function record_warnings($errno, $errstr, $errfile, $errline) { |
| 404 | 404 | |
| 405 | - if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) // Not a warning or notice |
|
| 406 | - throw new DOMPDF_Exception($errstr . " $errno"); |
|
| 405 | + if (!($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING))) // Not a warning or notice |
|
| 406 | + throw new DOMPDF_Exception($errstr." $errno"); |
|
| 407 | 407 | |
| 408 | 408 | global $_dompdf_warnings; |
| 409 | 409 | global $_dompdf_show_warnings; |
| 410 | 410 | |
| 411 | - if ( $_dompdf_show_warnings ) |
|
| 412 | - echo $errstr . "\n"; |
|
| 411 | + if ($_dompdf_show_warnings) |
|
| 412 | + echo $errstr."\n"; |
|
| 413 | 413 | |
| 414 | 414 | $_dompdf_warnings[] = $errstr; |
| 415 | 415 | } |
@@ -425,14 +425,14 @@ discard block |
||
| 425 | 425 | |
| 426 | 426 | $i = 0; |
| 427 | 427 | foreach ($bt as $call) { |
| 428 | - $file = basename($call["file"]) . " (" . $call["line"] . ")"; |
|
| 429 | - if ( isset($call["class"]) ) { |
|
| 430 | - $func = $call["class"] . "->" . $call["function"] . "()"; |
|
| 428 | + $file = basename($call["file"])." (".$call["line"].")"; |
|
| 429 | + if (isset($call["class"])) { |
|
| 430 | + $func = $call["class"]."->".$call["function"]."()"; |
|
| 431 | 431 | } else { |
| 432 | - $func = $call["function"] . "()"; |
|
| 432 | + $func = $call["function"]."()"; |
|
| 433 | 433 | } |
| 434 | 434 | |
| 435 | - echo "#" . str_pad($i, 2, " ", STR_PAD_RIGHT) . ": " . str_pad($file.":", 42) . " $func\n"; |
|
| 435 | + echo "#".str_pad($i, 2, " ", STR_PAD_RIGHT).": ".str_pad($file.":", 42)." $func\n"; |
|
| 436 | 436 | $i++; |
| 437 | 437 | } |
| 438 | 438 | echo "\n"; |
@@ -447,10 +447,10 @@ discard block |
||
| 447 | 447 | global $_DOMPDF_DEBUG_TYPES; |
| 448 | 448 | global $_dompdf_show_warnings; |
| 449 | 449 | global $_dompdf_debug; |
| 450 | - if ( isset($_DOMPDF_DEBUG_TYPES[$type]) && ($_dompdf_show_warnings || $_dompdf_debug) ) { |
|
| 450 | + if (isset($_DOMPDF_DEBUG_TYPES[$type]) && ($_dompdf_show_warnings || $_dompdf_debug)) { |
|
| 451 | 451 | $arr = debug_backtrace(); |
| 452 | 452 | |
| 453 | - echo basename($arr[0]["file"]) . " (" . $arr[0]["line"] ."): " . $arr[1]["function"] . ": "; |
|
| 453 | + echo basename($arr[0]["file"])." (".$arr[0]["line"]."): ".$arr[1]["function"].": "; |
|
| 454 | 454 | pre_r($msg); |
| 455 | 455 | } |
| 456 | 456 | } |
@@ -458,29 +458,29 @@ discard block |
||
| 458 | 458 | /** |
| 459 | 459 | * Dump memory usage |
| 460 | 460 | */ |
| 461 | -if ( !function_exists("print_memusage") ) { |
|
| 461 | +if (!function_exists("print_memusage")) { |
|
| 462 | 462 | function print_memusage() { |
| 463 | 463 | global $memusage; |
| 464 | 464 | echo ("Memory Usage\n"); |
| 465 | 465 | $prev = 0; |
| 466 | 466 | $initial = reset($memusage); |
| 467 | - echo (str_pad("Initial:", 40) . $initial . "\n\n"); |
|
| 467 | + echo (str_pad("Initial:", 40).$initial."\n\n"); |
|
| 468 | 468 | |
| 469 | 469 | foreach ($memusage as $key=>$mem) { |
| 470 | 470 | $mem -= $initial; |
| 471 | - echo (str_pad("$key:" , 40)); |
|
| 472 | - echo (str_pad("$mem", 12) . "(diff: " . ($mem - $prev) . ")\n"); |
|
| 471 | + echo (str_pad("$key:", 40)); |
|
| 472 | + echo (str_pad("$mem", 12)."(diff: ".($mem - $prev).")\n"); |
|
| 473 | 473 | $prev = $mem; |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | - echo ("\n" . str_pad("Total:", 40) . memory_get_usage()) . "\n"; |
|
| 476 | + echo ("\n".str_pad("Total:", 40).memory_get_usage())."\n"; |
|
| 477 | 477 | } |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | /** |
| 481 | 481 | * Initialize memory profiling code |
| 482 | 482 | */ |
| 483 | -if ( !function_exists("enable_mem_profile") ) { |
|
| 483 | +if (!function_exists("enable_mem_profile")) { |
|
| 484 | 484 | function enable_mem_profile() { |
| 485 | 485 | global $memusage; |
| 486 | 486 | $memusage = array("Startup" => memory_get_usage()); |
@@ -493,10 +493,10 @@ discard block |
||
| 493 | 493 | * |
| 494 | 494 | * @param string $location a meaningful location |
| 495 | 495 | */ |
| 496 | -if ( !function_exists("mark_memusage") ) { |
|
| 496 | +if (!function_exists("mark_memusage")) { |
|
| 497 | 497 | function mark_memusage($location) { |
| 498 | 498 | global $memusage; |
| 499 | - if ( isset($memusage) ) |
|
| 499 | + if (isset($memusage)) |
|
| 500 | 500 | $memusage[$location] = memory_get_usage(); |
| 501 | 501 | } |
| 502 | 502 | } |
@@ -506,12 +506,12 @@ discard block |
||
| 506 | 506 | * |
| 507 | 507 | * @link http://us.php.net/manual/en/function.sys-get-temp-dir.php#85261 |
| 508 | 508 | */ |
| 509 | -if ( !function_exists('sys_get_temp_dir')) { |
|
| 509 | +if (!function_exists('sys_get_temp_dir')) { |
|
| 510 | 510 | function sys_get_temp_dir() { |
| 511 | 511 | if (!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); } |
| 512 | - if (!empty($_ENV['TMPDIR'])) { return realpath( $_ENV['TMPDIR']); } |
|
| 513 | - if (!empty($_ENV['TEMP'])) { return realpath( $_ENV['TEMP']); } |
|
| 514 | - $tempfile=tempnam(uniqid(rand(),TRUE),''); |
|
| 512 | + if (!empty($_ENV['TMPDIR'])) { return realpath($_ENV['TMPDIR']); } |
|
| 513 | + if (!empty($_ENV['TEMP'])) { return realpath($_ENV['TEMP']); } |
|
| 514 | + $tempfile = tempnam(uniqid(rand(), TRUE), ''); |
|
| 515 | 515 | if (file_exists($tempfile)) { |
| 516 | 516 | unlink($tempfile); |
| 517 | 517 | return realpath(dirname($tempfile)); |
@@ -63,17 +63,20 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | if ( !function_exists("pre_r") ) { |
| 65 | 65 | function pre_r($mixed, $return = false) { |
| 66 | - if ($return) |
|
| 67 | - return "<pre>" . print_r($mixed, true) . "</pre>"; |
|
| 66 | + if ($return) { |
|
| 67 | + return "<pre>" . print_r($mixed, true) . "</pre>"; |
|
| 68 | + } |
|
| 68 | 69 | |
| 69 | - if ( php_sapi_name() !== "cli") |
|
| 70 | - echo ("<pre>"); |
|
| 70 | + if ( php_sapi_name() !== "cli") { |
|
| 71 | + echo ("<pre>"); |
|
| 72 | + } |
|
| 71 | 73 | print_r($mixed); |
| 72 | 74 | |
| 73 | - if ( php_sapi_name() !== "cli") |
|
| 74 | - echo("</pre>"); |
|
| 75 | - else |
|
| 76 | - echo ("\n"); |
|
| 75 | + if ( php_sapi_name() !== "cli") { |
|
| 76 | + echo("</pre>"); |
|
| 77 | + } else { |
|
| 78 | + echo ("\n"); |
|
| 79 | + } |
|
| 77 | 80 | flush(); |
| 78 | 81 | |
| 79 | 82 | } |
@@ -89,12 +92,14 @@ discard block |
||
| 89 | 92 | */ |
| 90 | 93 | if ( !function_exists("pre_var_dump") ) { |
| 91 | 94 | function pre_var_dump($mixed) { |
| 92 | - if ( php_sapi_name() !== "cli") |
|
| 93 | - echo("<pre>"); |
|
| 95 | + if ( php_sapi_name() !== "cli") { |
|
| 96 | + echo("<pre>"); |
|
| 97 | + } |
|
| 94 | 98 | var_dump($mixed); |
| 95 | - if ( php_sapi_name() !== "cli") |
|
| 96 | - echo("</pre>"); |
|
| 97 | -} |
|
| 99 | + if ( php_sapi_name() !== "cli") { |
|
| 100 | + echo("</pre>"); |
|
| 101 | + } |
|
| 102 | + } |
|
| 98 | 103 | } |
| 99 | 104 | |
| 100 | 105 | /** |
@@ -121,8 +126,9 @@ discard block |
||
| 121 | 126 | } |
| 122 | 127 | |
| 123 | 128 | // Is the url already fully qualified? |
| 124 | - if ( mb_strpos($url, "://") !== false ) |
|
| 125 | - return $url; |
|
| 129 | + if ( mb_strpos($url, "://") !== false ) { |
|
| 130 | + return $url; |
|
| 131 | + } |
|
| 126 | 132 | |
| 127 | 133 | $ret = $protocol; |
| 128 | 134 | |
@@ -170,24 +176,29 @@ discard block |
||
| 170 | 176 | |
| 171 | 177 | if ( isset($arr["scheme"]) && |
| 172 | 178 | $arr["scheme"] !== "file" && |
| 173 | - mb_strlen($arr["scheme"]) > 1 ) // Exclude windows drive letters... |
|
| 179 | + mb_strlen($arr["scheme"]) > 1 ) { |
|
| 180 | + // Exclude windows drive letters... |
|
| 174 | 181 | { |
| 175 | 182 | $protocol = $arr["scheme"] . "://"; |
| 183 | + } |
|
| 176 | 184 | |
| 177 | 185 | if ( isset($arr["user"]) ) { |
| 178 | 186 | $host .= $arr["user"]; |
| 179 | 187 | |
| 180 | - if ( isset($arr["pass"]) ) |
|
| 181 | - $host .= "@" . $arr["pass"]; |
|
| 188 | + if ( isset($arr["pass"]) ) { |
|
| 189 | + $host .= "@" . $arr["pass"]; |
|
| 190 | + } |
|
| 182 | 191 | |
| 183 | 192 | $host .= ":"; |
| 184 | 193 | } |
| 185 | 194 | |
| 186 | - if ( isset($arr["host"]) ) |
|
| 187 | - $host .= $arr["host"]; |
|
| 195 | + if ( isset($arr["host"]) ) { |
|
| 196 | + $host .= $arr["host"]; |
|
| 197 | + } |
|
| 188 | 198 | |
| 189 | - if ( isset($arr["port"]) ) |
|
| 190 | - $host .= ":" . $arr["port"]; |
|
| 199 | + if ( isset($arr["port"]) ) { |
|
| 200 | + $host .= ":" . $arr["port"]; |
|
| 201 | + } |
|
| 191 | 202 | |
| 192 | 203 | if ( isset($arr["path"]) && $arr["path"] !== "" ) { |
| 193 | 204 | // Do we have a trailing slash? |
@@ -200,17 +211,20 @@ discard block |
||
| 200 | 211 | } |
| 201 | 212 | } |
| 202 | 213 | |
| 203 | - if ( isset($arr["query"]) ) |
|
| 204 | - $file .= "?" . $arr["query"]; |
|
| 214 | + if ( isset($arr["query"]) ) { |
|
| 215 | + $file .= "?" . $arr["query"]; |
|
| 216 | + } |
|
| 205 | 217 | |
| 206 | - if ( isset($arr["fragment"]) ) |
|
| 207 | - $file .= "#" . $arr["fragment"]; |
|
| 218 | + if ( isset($arr["fragment"]) ) { |
|
| 219 | + $file .= "#" . $arr["fragment"]; |
|
| 220 | + } |
|
| 208 | 221 | |
| 209 | 222 | } else { |
| 210 | 223 | |
| 211 | 224 | $i = mb_strpos($url, "file://"); |
| 212 | - if ( $i !== false) |
|
| 213 | - $url = mb_substr($url, $i + 7); |
|
| 225 | + if ( $i !== false) { |
|
| 226 | + $url = mb_substr($url, $i + 7); |
|
| 227 | + } |
|
| 214 | 228 | |
| 215 | 229 | $protocol = ""; // "file://"; ? why doesn't this work... It's because of |
| 216 | 230 | // network filenames like //COMPU/SHARENAME |
@@ -262,11 +276,13 @@ discard block |
||
| 262 | 276 | "dc", "dcc", "dccc", "cm"); |
| 263 | 277 | static $thou = array("", "m", "mm", "mmm"); |
| 264 | 278 | |
| 265 | - if ( !is_numeric($num) ) |
|
| 266 | - throw new DOMPDF_Exception("dec2roman() requires a numeric argument."); |
|
| 279 | + if ( !is_numeric($num) ) { |
|
| 280 | + throw new DOMPDF_Exception("dec2roman() requires a numeric argument."); |
|
| 281 | + } |
|
| 267 | 282 | |
| 268 | - if ( $num > 4000 || $num < 0 ) |
|
| 269 | - return "(out of range)"; |
|
| 283 | + if ( $num > 4000 || $num < 0 ) { |
|
| 284 | + return "(out of range)"; |
|
| 285 | + } |
|
| 270 | 286 | |
| 271 | 287 | $num = strrev((string)$num); |
| 272 | 288 | |
@@ -372,10 +388,11 @@ discard block |
||
| 372 | 388 | |
| 373 | 389 | if ( !function_exists("mb_substr") ) { |
| 374 | 390 | function mb_substr($str, $start, $length=null, $encoding='iso-8859-1') { |
| 375 | - if ( is_null($length) ) |
|
| 376 | - return substr($str, $start); |
|
| 377 | - else |
|
| 378 | - return substr($str, $start, $length); |
|
| 391 | + if ( is_null($length) ) { |
|
| 392 | + return substr($str, $start); |
|
| 393 | + } else { |
|
| 394 | + return substr($str, $start, $length); |
|
| 395 | + } |
|
| 379 | 396 | } |
| 380 | 397 | } |
| 381 | 398 | |
@@ -402,14 +419,17 @@ discard block |
||
| 402 | 419 | */ |
| 403 | 420 | function record_warnings($errno, $errstr, $errfile, $errline) { |
| 404 | 421 | |
| 405 | - if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) // Not a warning or notice |
|
| 422 | + if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) { |
|
| 423 | + // Not a warning or notice |
|
| 406 | 424 | throw new DOMPDF_Exception($errstr . " $errno"); |
| 425 | + } |
|
| 407 | 426 | |
| 408 | 427 | global $_dompdf_warnings; |
| 409 | 428 | global $_dompdf_show_warnings; |
| 410 | 429 | |
| 411 | - if ( $_dompdf_show_warnings ) |
|
| 412 | - echo $errstr . "\n"; |
|
| 430 | + if ( $_dompdf_show_warnings ) { |
|
| 431 | + echo $errstr . "\n"; |
|
| 432 | + } |
|
| 413 | 433 | |
| 414 | 434 | $_dompdf_warnings[] = $errstr; |
| 415 | 435 | } |
@@ -496,9 +516,10 @@ discard block |
||
| 496 | 516 | if ( !function_exists("mark_memusage") ) { |
| 497 | 517 | function mark_memusage($location) { |
| 498 | 518 | global $memusage; |
| 499 | - if ( isset($memusage) ) |
|
| 500 | - $memusage[$location] = memory_get_usage(); |
|
| 501 | -} |
|
| 519 | + if ( isset($memusage) ) { |
|
| 520 | + $memusage[$location] = memory_get_usage(); |
|
| 521 | + } |
|
| 522 | + } |
|
| 502 | 523 | } |
| 503 | 524 | |
| 504 | 525 | /** |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * |
| 97 | 97 | * @param mixed $size The size of image to create: array(x1,y1,x2,y2) or "letter", "legal", etc. |
| 98 | 98 | * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
| 99 | - * @param float $aa_factor Anti-aliasing factor, 1 for no AA |
|
| 99 | + * @param integer $aa_factor Anti-aliasing factor, 1 for no AA |
|
| 100 | 100 | * @param array $bg_color Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1 |
| 101 | 101 | */ |
| 102 | 102 | function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1,1,1,0) ) { |
@@ -536,8 +536,8 @@ discard block |
||
| 536 | 536 | * @param string $font the font file to use |
| 537 | 537 | * @param float $size the font size, in points |
| 538 | 538 | * @param array $color |
| 539 | - * @param float $adjust word spacing adjustment |
|
| 540 | - * @param float $angle Text angle |
|
| 539 | + * @param integer $adjust word spacing adjustment |
|
| 540 | + * @param integer $angle Text angle |
|
| 541 | 541 | */ |
| 542 | 542 | function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
| 543 | 543 | |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | * @param string $text the text to be sized |
| 591 | 591 | * @param string $font the desired font |
| 592 | 592 | * @param float $size the desired font size |
| 593 | - * @param float $spacing word spacing, if any |
|
| 593 | + * @param integer $spacing word spacing, if any |
|
| 594 | 594 | * @return float |
| 595 | 595 | */ |
| 596 | 596 | function get_text_width($text, $font, $size, $spacing = 0) { |
@@ -489,21 +489,21 @@ discard block |
||
| 489 | 489 | function image($img_url, $img_type, $x, $y, $w, $h) { |
| 490 | 490 | |
| 491 | 491 | switch ($img_type) { |
| 492 | - case "png": |
|
| 493 | - $src = @imagecreatefrompng($img_url); |
|
| 494 | - break; |
|
| 492 | + case "png": |
|
| 493 | + $src = @imagecreatefrompng($img_url); |
|
| 494 | + break; |
|
| 495 | 495 | |
| 496 | - case "gif": |
|
| 497 | - $src = @imagecreatefromgif($img_url); |
|
| 498 | - break; |
|
| 496 | + case "gif": |
|
| 497 | + $src = @imagecreatefromgif($img_url); |
|
| 498 | + break; |
|
| 499 | 499 | |
| 500 | - case "jpg": |
|
| 501 | - case "jpeg": |
|
| 502 | - $src = @imagecreatefromjpeg($img_url); |
|
| 503 | - break; |
|
| 500 | + case "jpg": |
|
| 501 | + case "jpeg": |
|
| 502 | + $src = @imagecreatefromjpeg($img_url); |
|
| 503 | + break; |
|
| 504 | 504 | |
| 505 | - default: |
|
| 506 | - break; |
|
| 505 | + default: |
|
| 506 | + break; |
|
| 507 | 507 | |
| 508 | 508 | } |
| 509 | 509 | |
@@ -658,20 +658,20 @@ discard block |
||
| 658 | 658 | |
| 659 | 659 | switch ($type) { |
| 660 | 660 | |
| 661 | - case "jpg": |
|
| 662 | - case "jpeg": |
|
| 663 | - if ( !isset($options["quality"]) ) |
|
| 664 | - $options["quality"] = 75; |
|
| 661 | + case "jpg": |
|
| 662 | + case "jpeg": |
|
| 663 | + if ( !isset($options["quality"]) ) |
|
| 664 | + $options["quality"] = 75; |
|
| 665 | 665 | |
| 666 | - header("Content-type: image/jpeg"); |
|
| 667 | - imagejpeg($dst, '', $options["quality"]); |
|
| 668 | - break; |
|
| 669 | - |
|
| 670 | - case "png": |
|
| 671 | - default: |
|
| 672 | - header("Content-type: image/png"); |
|
| 673 | - imagepng($dst); |
|
| 674 | - break; |
|
| 666 | + header("Content-type: image/jpeg"); |
|
| 667 | + imagejpeg($dst, '', $options["quality"]); |
|
| 668 | + break; |
|
| 669 | + |
|
| 670 | + case "png": |
|
| 671 | + default: |
|
| 672 | + header("Content-type: image/png"); |
|
| 673 | + imagepng($dst); |
|
| 674 | + break; |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | if ( $this->_aa_factor != 1 ) |
@@ -706,18 +706,18 @@ discard block |
||
| 706 | 706 | |
| 707 | 707 | switch ($type) { |
| 708 | 708 | |
| 709 | - case "jpg": |
|
| 710 | - case "jpeg": |
|
| 711 | - if ( !isset($options["quality"]) ) |
|
| 712 | - $options["quality"] = 75; |
|
| 709 | + case "jpg": |
|
| 710 | + case "jpeg": |
|
| 711 | + if ( !isset($options["quality"]) ) |
|
| 712 | + $options["quality"] = 75; |
|
| 713 | 713 | |
| 714 | - imagejpeg($dst, '', $options["quality"]); |
|
| 715 | - break; |
|
| 714 | + imagejpeg($dst, '', $options["quality"]); |
|
| 715 | + break; |
|
| 716 | 716 | |
| 717 | - case "png": |
|
| 718 | - default: |
|
| 719 | - imagepng($dst); |
|
| 720 | - break; |
|
| 717 | + case "png": |
|
| 718 | + default: |
|
| 719 | + imagepng($dst); |
|
| 720 | + break; |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | $image = ob_get_contents(); |
@@ -99,22 +99,22 @@ discard block |
||
| 99 | 99 | * @param float $aa_factor Anti-aliasing factor, 1 for no AA |
| 100 | 100 | * @param array $bg_color Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1 |
| 101 | 101 | */ |
| 102 | - function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1,1,1,0) ) { |
|
| 102 | + function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1, 1, 1, 0)) { |
|
| 103 | 103 | |
| 104 | - if ( !is_array($size) ) { |
|
| 104 | + if (!is_array($size)) { |
|
| 105 | 105 | |
| 106 | - if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) |
|
| 106 | + if (isset(CPDF_Adapter::$PAPER_SIZES[strtolower($size)])) |
|
| 107 | 107 | $size = CPDF_Adapter::$PAPER_SIZES[$size]; |
| 108 | 108 | else |
| 109 | 109 | $size = CPDF_Adapter::$PAPER_SIZES["letter"]; |
| 110 | 110 | |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if ( strtolower($orientation) === "landscape" ) { |
|
| 114 | - list($size[2],$size[3]) = array($size[3],$size[2]); |
|
| 113 | + if (strtolower($orientation) === "landscape") { |
|
| 114 | + list($size[2], $size[3]) = array($size[3], $size[2]); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - if ( $aa_factor < 1 ) |
|
| 117 | + if ($aa_factor < 1) |
|
| 118 | 118 | $aa_factor = 1; |
| 119 | 119 | |
| 120 | 120 | $this->_aa_factor = $aa_factor; |
@@ -127,9 +127,9 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | $this->_img = imagecreatetruecolor($this->_width, $this->_height); |
| 129 | 129 | |
| 130 | - if ( is_null($bg_color) || !is_array($bg_color) ) { |
|
| 130 | + if (is_null($bg_color) || !is_array($bg_color)) { |
|
| 131 | 131 | // Pure white bg |
| 132 | - $bg_color = array(1,1,1,0); |
|
| 132 | + $bg_color = array(1, 1, 1, 0); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | $this->_bg_color = $this->_allocate_color($bg_color); |
@@ -197,10 +197,10 @@ discard block |
||
| 197 | 197 | private function _allocate_color($color) { |
| 198 | 198 | |
| 199 | 199 | // Full opacity if no alpha set |
| 200 | - if ( !isset($color[3]) ) |
|
| 200 | + if (!isset($color[3])) |
|
| 201 | 201 | $color[3] = 0; |
| 202 | 202 | |
| 203 | - list($r,$g,$b,$a) = $color; |
|
| 203 | + list($r, $g, $b, $a) = $color; |
|
| 204 | 204 | |
| 205 | 205 | $r *= 255; |
| 206 | 206 | $g *= 255; |
@@ -220,10 +220,10 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | $key = sprintf("#%02X%02X%02X%02X", $r, $g, $b, $a); |
| 222 | 222 | |
| 223 | - if ( isset($this->_colors[$key]) ) |
|
| 223 | + if (isset($this->_colors[$key])) |
|
| 224 | 224 | return $this->_colors[$key]; |
| 225 | 225 | |
| 226 | - if ( $a != 0 ) |
|
| 226 | + if ($a != 0) |
|
| 227 | 227 | $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a); |
| 228 | 228 | else |
| 229 | 229 | $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b); |
@@ -259,10 +259,10 @@ discard block |
||
| 259 | 259 | $c = $this->_allocate_color($color); |
| 260 | 260 | |
| 261 | 261 | // Convert the style array if required |
| 262 | - if ( !is_null($style) ) { |
|
| 262 | + if (!is_null($style)) { |
|
| 263 | 263 | $gd_style = array(); |
| 264 | 264 | |
| 265 | - if ( count($style) == 1 ) { |
|
| 265 | + if (count($style) == 1) { |
|
| 266 | 266 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) { |
| 267 | 267 | $gd_style[] = $c; |
| 268 | 268 | } |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | $i = 0; |
| 277 | 277 | foreach ($style as $length) { |
| 278 | 278 | |
| 279 | - if ( $i % 2 == 0 ) { |
|
| 279 | + if ($i % 2 == 0) { |
|
| 280 | 280 | // 'On' pattern |
| 281 | 281 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) |
| 282 | 282 | $gd_style[] = $c; |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | $c = $this->_allocate_color($color); |
| 328 | 328 | |
| 329 | 329 | // Convert the style array if required |
| 330 | - if ( !is_null($style) ) { |
|
| 330 | + if (!is_null($style)) { |
|
| 331 | 331 | $gd_style = array(); |
| 332 | 332 | |
| 333 | 333 | foreach ($style as $length) { |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | $c = $this->_allocate_color($color); |
| 405 | 405 | |
| 406 | 406 | // Convert the style array if required |
| 407 | - if ( !is_null($style) && !$fill ) { |
|
| 407 | + if (!is_null($style) && !$fill) { |
|
| 408 | 408 | $gd_style = array(); |
| 409 | 409 | |
| 410 | 410 | foreach ($style as $length) { |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | |
| 420 | 420 | imagesetthickness($this->_img, $width); |
| 421 | 421 | |
| 422 | - if ( $fill ) |
|
| 422 | + if ($fill) |
|
| 423 | 423 | imagefilledpolygon($this->_img, $points, count($points) / 2, $c); |
| 424 | 424 | else |
| 425 | 425 | imagepolygon($this->_img, $points, count($points) / 2, $c); |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | $c = $this->_allocate_color($color); |
| 452 | 452 | |
| 453 | 453 | // Convert the style array if required |
| 454 | - if ( !is_null($style) && !$fill ) { |
|
| 454 | + if (!is_null($style) && !$fill) { |
|
| 455 | 455 | $gd_style = array(); |
| 456 | 456 | |
| 457 | 457 | foreach ($style as $length) { |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | |
| 467 | 467 | imagesetthickness($this->_img, $width); |
| 468 | 468 | |
| 469 | - if ( $fill ) |
|
| 469 | + if ($fill) |
|
| 470 | 470 | imagefilledellipse($this->_img, $x, $y, $r, $r, $c); |
| 471 | 471 | else |
| 472 | 472 | imageellipse($this->_img, $x, $y, $r, $r, $c); |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | - if ( !$src ) |
|
| 510 | + if (!$src) |
|
| 511 | 511 | return; // Probably should add to $_dompdf_errors or whatever here |
| 512 | 512 | |
| 513 | 513 | // Scale by the AA factor |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | * @param float $adjust word spacing adjustment |
| 540 | 540 | * @param float $angle Text angle |
| 541 | 541 | */ |
| 542 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
| 542 | + function text($x, $y, $text, $font, $size, $color = array(0, 0, 0), $adjust = 0, $angle = 0) { |
|
| 543 | 543 | |
| 544 | 544 | // Scale by the AA factor |
| 545 | 545 | $x *= $this->_aa_factor; |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | |
| 551 | 551 | $c = $this->_allocate_color($color); |
| 552 | 552 | |
| 553 | - if ( strpos($font, '.ttf') === false ) |
|
| 553 | + if (strpos($font, '.ttf') === false) |
|
| 554 | 554 | $font .= ".ttf"; |
| 555 | 555 | |
| 556 | 556 | // FIXME: word spacing |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | */ |
| 596 | 596 | function get_text_width($text, $font, $size, $spacing = 0) { |
| 597 | 597 | |
| 598 | - if ( strpos($font, '.ttf') === false ) |
|
| 598 | + if (strpos($font, '.ttf') === false) |
|
| 599 | 599 | $font .= ".ttf"; |
| 600 | 600 | |
| 601 | 601 | // FIXME: word spacing |
@@ -611,11 +611,11 @@ discard block |
||
| 611 | 611 | * @return float |
| 612 | 612 | */ |
| 613 | 613 | function get_font_height($font, $size) { |
| 614 | - if ( strpos($font, '.ttf') === false ) |
|
| 614 | + if (strpos($font, '.ttf') === false) |
|
| 615 | 615 | $font .= ".ttf"; |
| 616 | 616 | |
| 617 | 617 | // FIXME: word spacing |
| 618 | - list(,$y2,,,,$y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl"); // Test string with ascenders, descenders and caps |
|
| 618 | + list(,$y2,,,,$y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl"); // Test string with ascenders, descenders and caps |
|
| 619 | 619 | return $y2 - $y1; |
| 620 | 620 | } |
| 621 | 621 | |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | function stream($filename, $options = null) { |
| 639 | 639 | |
| 640 | 640 | // Perform any antialiasing |
| 641 | - if ( $this->_aa_factor != 1 ) { |
|
| 641 | + if ($this->_aa_factor != 1) { |
|
| 642 | 642 | $dst_w = $this->_width / $this->_aa_factor; |
| 643 | 643 | $dst_h = $this->_height / $this->_aa_factor; |
| 644 | 644 | $dst = imagecreatetruecolor($dst_w, $dst_h); |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | $dst = $this->_img; |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - if ( !isset($options["type"]) ) |
|
| 652 | + if (!isset($options["type"])) |
|
| 653 | 653 | $options["type"] = "png"; |
| 654 | 654 | |
| 655 | 655 | $type = strtolower($options["type"]); |
@@ -660,7 +660,7 @@ discard block |
||
| 660 | 660 | |
| 661 | 661 | case "jpg": |
| 662 | 662 | case "jpeg": |
| 663 | - if ( !isset($options["quality"]) ) |
|
| 663 | + if (!isset($options["quality"])) |
|
| 664 | 664 | $options["quality"] = 75; |
| 665 | 665 | |
| 666 | 666 | header("Content-type: image/jpeg"); |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | break; |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | - if ( $this->_aa_factor != 1 ) |
|
| 677 | + if ($this->_aa_factor != 1) |
|
| 678 | 678 | imagedestroy($dst); |
| 679 | 679 | } |
| 680 | 680 | |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | */ |
| 687 | 687 | function output($options = null) { |
| 688 | 688 | |
| 689 | - if ( $this->_aa_factor != 1 ) { |
|
| 689 | + if ($this->_aa_factor != 1) { |
|
| 690 | 690 | $dst_w = $this->_width / $this->_aa_factor; |
| 691 | 691 | $dst_h = $this->_height / $this->_aa_factor; |
| 692 | 692 | $dst = imagecreatetruecolor($dst_w, $dst_h); |
@@ -697,7 +697,7 @@ discard block |
||
| 697 | 697 | $dst = $this->_img; |
| 698 | 698 | } |
| 699 | 699 | |
| 700 | - if ( !isset($options["type"]) ) |
|
| 700 | + if (!isset($options["type"])) |
|
| 701 | 701 | $options["type"] = "png"; |
| 702 | 702 | |
| 703 | 703 | $type = $options["type"]; |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | |
| 709 | 709 | case "jpg": |
| 710 | 710 | case "jpeg": |
| 711 | - if ( !isset($options["quality"]) ) |
|
| 711 | + if (!isset($options["quality"])) |
|
| 712 | 712 | $options["quality"] = 75; |
| 713 | 713 | |
| 714 | 714 | imagejpeg($dst, '', $options["quality"]); |
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | $image = ob_get_contents(); |
| 724 | 724 | ob_end_clean(); |
| 725 | 725 | |
| 726 | - if ( $this->_aa_factor != 1 ) |
|
| 726 | + if ($this->_aa_factor != 1) |
|
| 727 | 727 | imagedestroy($dst); |
| 728 | 728 | |
| 729 | 729 | return $image; |
@@ -103,10 +103,11 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | if ( !is_array($size) ) { |
| 105 | 105 | |
| 106 | - if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) |
|
| 107 | - $size = CPDF_Adapter::$PAPER_SIZES[$size]; |
|
| 108 | - else |
|
| 109 | - $size = CPDF_Adapter::$PAPER_SIZES["letter"]; |
|
| 106 | + if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) { |
|
| 107 | + $size = CPDF_Adapter::$PAPER_SIZES[$size]; |
|
| 108 | + } else { |
|
| 109 | + $size = CPDF_Adapter::$PAPER_SIZES["letter"]; |
|
| 110 | + } |
|
| 110 | 111 | |
| 111 | 112 | } |
| 112 | 113 | |
@@ -114,8 +115,9 @@ discard block |
||
| 114 | 115 | list($size[2],$size[3]) = array($size[3],$size[2]); |
| 115 | 116 | } |
| 116 | 117 | |
| 117 | - if ( $aa_factor < 1 ) |
|
| 118 | - $aa_factor = 1; |
|
| 118 | + if ( $aa_factor < 1 ) { |
|
| 119 | + $aa_factor = 1; |
|
| 120 | + } |
|
| 119 | 121 | |
| 120 | 122 | $this->_aa_factor = $aa_factor; |
| 121 | 123 | |
@@ -197,8 +199,9 @@ discard block |
||
| 197 | 199 | private function _allocate_color($color) { |
| 198 | 200 | |
| 199 | 201 | // Full opacity if no alpha set |
| 200 | - if ( !isset($color[3]) ) |
|
| 201 | - $color[3] = 0; |
|
| 202 | + if ( !isset($color[3]) ) { |
|
| 203 | + $color[3] = 0; |
|
| 204 | + } |
|
| 202 | 205 | |
| 203 | 206 | list($r,$g,$b,$a) = $color; |
| 204 | 207 | |
@@ -220,13 +223,15 @@ discard block |
||
| 220 | 223 | |
| 221 | 224 | $key = sprintf("#%02X%02X%02X%02X", $r, $g, $b, $a); |
| 222 | 225 | |
| 223 | - if ( isset($this->_colors[$key]) ) |
|
| 224 | - return $this->_colors[$key]; |
|
| 226 | + if ( isset($this->_colors[$key]) ) { |
|
| 227 | + return $this->_colors[$key]; |
|
| 228 | + } |
|
| 225 | 229 | |
| 226 | - if ( $a != 0 ) |
|
| 227 | - $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a); |
|
| 228 | - else |
|
| 229 | - $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b); |
|
| 230 | + if ( $a != 0 ) { |
|
| 231 | + $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a); |
|
| 232 | + } else { |
|
| 233 | + $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b); |
|
| 234 | + } |
|
| 230 | 235 | |
| 231 | 236 | return $this->_colors[$key]; |
| 232 | 237 | |
@@ -278,13 +283,15 @@ discard block |
||
| 278 | 283 | |
| 279 | 284 | if ( $i % 2 == 0 ) { |
| 280 | 285 | // 'On' pattern |
| 281 | - for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) |
|
| 282 | - $gd_style[] = $c; |
|
| 286 | + for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) { |
|
| 287 | + $gd_style[] = $c; |
|
| 288 | + } |
|
| 283 | 289 | |
| 284 | 290 | } else { |
| 285 | 291 | // Off pattern |
| 286 | - for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) |
|
| 287 | - $gd_style[] = $this->_bg_color; |
|
| 292 | + for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) { |
|
| 293 | + $gd_style[] = $this->_bg_color; |
|
| 294 | + } |
|
| 288 | 295 | |
| 289 | 296 | } |
| 290 | 297 | $i++; |
@@ -398,8 +405,9 @@ discard block |
||
| 398 | 405 | function polygon($points, $color, $width = null, $style = null, $fill = false) { |
| 399 | 406 | |
| 400 | 407 | // Scale each point by the AA factor |
| 401 | - foreach (array_keys($points) as $i) |
|
| 402 | - $points[$i] *= $this->_aa_factor; |
|
| 408 | + foreach (array_keys($points) as $i) { |
|
| 409 | + $points[$i] *= $this->_aa_factor; |
|
| 410 | + } |
|
| 403 | 411 | |
| 404 | 412 | $c = $this->_allocate_color($color); |
| 405 | 413 | |
@@ -419,10 +427,11 @@ discard block |
||
| 419 | 427 | |
| 420 | 428 | imagesetthickness($this->_img, $width); |
| 421 | 429 | |
| 422 | - if ( $fill ) |
|
| 423 | - imagefilledpolygon($this->_img, $points, count($points) / 2, $c); |
|
| 424 | - else |
|
| 425 | - imagepolygon($this->_img, $points, count($points) / 2, $c); |
|
| 430 | + if ( $fill ) { |
|
| 431 | + imagefilledpolygon($this->_img, $points, count($points) / 2, $c); |
|
| 432 | + } else { |
|
| 433 | + imagepolygon($this->_img, $points, count($points) / 2, $c); |
|
| 434 | + } |
|
| 426 | 435 | |
| 427 | 436 | } |
| 428 | 437 | |
@@ -466,10 +475,11 @@ discard block |
||
| 466 | 475 | |
| 467 | 476 | imagesetthickness($this->_img, $width); |
| 468 | 477 | |
| 469 | - if ( $fill ) |
|
| 470 | - imagefilledellipse($this->_img, $x, $y, $r, $r, $c); |
|
| 471 | - else |
|
| 472 | - imageellipse($this->_img, $x, $y, $r, $r, $c); |
|
| 478 | + if ( $fill ) { |
|
| 479 | + imagefilledellipse($this->_img, $x, $y, $r, $r, $c); |
|
| 480 | + } else { |
|
| 481 | + imageellipse($this->_img, $x, $y, $r, $r, $c); |
|
| 482 | + } |
|
| 473 | 483 | |
| 474 | 484 | } |
| 475 | 485 | |
@@ -507,8 +517,10 @@ discard block |
||
| 507 | 517 | |
| 508 | 518 | } |
| 509 | 519 | |
| 510 | - if ( !$src ) |
|
| 511 | - return; // Probably should add to $_dompdf_errors or whatever here |
|
| 520 | + if ( !$src ) { |
|
| 521 | + return; |
|
| 522 | + } |
|
| 523 | + // Probably should add to $_dompdf_errors or whatever here |
|
| 512 | 524 | |
| 513 | 525 | // Scale by the AA factor |
| 514 | 526 | $x *= $this->_aa_factor; |
@@ -550,8 +562,9 @@ discard block |
||
| 550 | 562 | |
| 551 | 563 | $c = $this->_allocate_color($color); |
| 552 | 564 | |
| 553 | - if ( strpos($font, '.ttf') === false ) |
|
| 554 | - $font .= ".ttf"; |
|
| 565 | + if ( strpos($font, '.ttf') === false ) { |
|
| 566 | + $font .= ".ttf"; |
|
| 567 | + } |
|
| 555 | 568 | |
| 556 | 569 | // FIXME: word spacing |
| 557 | 570 | imagettftext($this->_img, $size, $angle, $x, $y + $h, $c, $font, $text); |
@@ -595,8 +608,9 @@ discard block |
||
| 595 | 608 | */ |
| 596 | 609 | function get_text_width($text, $font, $size, $spacing = 0) { |
| 597 | 610 | |
| 598 | - if ( strpos($font, '.ttf') === false ) |
|
| 599 | - $font .= ".ttf"; |
|
| 611 | + if ( strpos($font, '.ttf') === false ) { |
|
| 612 | + $font .= ".ttf"; |
|
| 613 | + } |
|
| 600 | 614 | |
| 601 | 615 | // FIXME: word spacing |
| 602 | 616 | list($x1,,$x2) = imagettfbbox($size, 0, $font, $text); |
@@ -611,8 +625,9 @@ discard block |
||
| 611 | 625 | * @return float |
| 612 | 626 | */ |
| 613 | 627 | function get_font_height($font, $size) { |
| 614 | - if ( strpos($font, '.ttf') === false ) |
|
| 615 | - $font .= ".ttf"; |
|
| 628 | + if ( strpos($font, '.ttf') === false ) { |
|
| 629 | + $font .= ".ttf"; |
|
| 630 | + } |
|
| 616 | 631 | |
| 617 | 632 | // FIXME: word spacing |
| 618 | 633 | list(,$y2,,,,$y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl"); // Test string with ascenders, descenders and caps |
@@ -649,8 +664,9 @@ discard block |
||
| 649 | 664 | $dst = $this->_img; |
| 650 | 665 | } |
| 651 | 666 | |
| 652 | - if ( !isset($options["type"]) ) |
|
| 653 | - $options["type"] = "png"; |
|
| 667 | + if ( !isset($options["type"]) ) { |
|
| 668 | + $options["type"] = "png"; |
|
| 669 | + } |
|
| 654 | 670 | |
| 655 | 671 | $type = strtolower($options["type"]); |
| 656 | 672 | |
@@ -660,8 +676,9 @@ discard block |
||
| 660 | 676 | |
| 661 | 677 | case "jpg": |
| 662 | 678 | case "jpeg": |
| 663 | - if ( !isset($options["quality"]) ) |
|
| 664 | - $options["quality"] = 75; |
|
| 679 | + if ( !isset($options["quality"]) ) { |
|
| 680 | + $options["quality"] = 75; |
|
| 681 | + } |
|
| 665 | 682 | |
| 666 | 683 | header("Content-type: image/jpeg"); |
| 667 | 684 | imagejpeg($dst, '', $options["quality"]); |
@@ -674,8 +691,9 @@ discard block |
||
| 674 | 691 | break; |
| 675 | 692 | } |
| 676 | 693 | |
| 677 | - if ( $this->_aa_factor != 1 ) |
|
| 678 | - imagedestroy($dst); |
|
| 694 | + if ( $this->_aa_factor != 1 ) { |
|
| 695 | + imagedestroy($dst); |
|
| 696 | + } |
|
| 679 | 697 | } |
| 680 | 698 | |
| 681 | 699 | /** |
@@ -697,8 +715,9 @@ discard block |
||
| 697 | 715 | $dst = $this->_img; |
| 698 | 716 | } |
| 699 | 717 | |
| 700 | - if ( !isset($options["type"]) ) |
|
| 701 | - $options["type"] = "png"; |
|
| 718 | + if ( !isset($options["type"]) ) { |
|
| 719 | + $options["type"] = "png"; |
|
| 720 | + } |
|
| 702 | 721 | |
| 703 | 722 | $type = $options["type"]; |
| 704 | 723 | |
@@ -708,8 +727,9 @@ discard block |
||
| 708 | 727 | |
| 709 | 728 | case "jpg": |
| 710 | 729 | case "jpeg": |
| 711 | - if ( !isset($options["quality"]) ) |
|
| 712 | - $options["quality"] = 75; |
|
| 730 | + if ( !isset($options["quality"]) ) { |
|
| 731 | + $options["quality"] = 75; |
|
| 732 | + } |
|
| 713 | 733 | |
| 714 | 734 | imagejpeg($dst, '', $options["quality"]); |
| 715 | 735 | break; |
@@ -723,8 +743,9 @@ discard block |
||
| 723 | 743 | $image = ob_get_contents(); |
| 724 | 744 | ob_end_clean(); |
| 725 | 745 | |
| 726 | - if ( $this->_aa_factor != 1 ) |
|
| 727 | - imagedestroy($dst); |
|
| 746 | + if ( $this->_aa_factor != 1 ) { |
|
| 747 | + imagedestroy($dst); |
|
| 748 | + } |
|
| 728 | 749 | |
| 729 | 750 | return $image; |
| 730 | 751 | } |
@@ -1,41 +1,40 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
| 4 | - * |
|
| 5 | - * File: $RCSfile: gd_adapter.cls.php,v $ |
|
| 6 | - * Created on: 2004-06-06 |
|
| 7 | - * |
|
| 8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
| 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.dompdf.com/ |
|
| 32 | - * |
|
| 33 | - * @link http://www.dompdf.com/ |
|
| 34 | - * @copyright 2004 Benj Carson |
|
| 35 | - * @author Benj Carson <[email protected]> |
|
| 36 | - * @package dompdf |
|
| 37 | - |
|
| 38 | - */ |
|
| 3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
| 4 | + * |
|
| 5 | + * File: $RCSfile: gd_adapter.cls.php,v $ |
|
| 6 | + * Created on: 2004-06-06 |
|
| 7 | + * |
|
| 8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
| 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.dompdf.com/ |
|
| 32 | + * |
|
| 33 | + * @link http://www.dompdf.com/ |
|
| 34 | + * @copyright 2004 Benj Carson |
|
| 35 | + * @author Benj Carson <[email protected]> |
|
| 36 | + * @package dompdf |
|
| 37 | + */ |
|
| 39 | 38 | |
| 40 | 39 | /* $Id: gd_adapter.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */ |
| 41 | 40 | |
@@ -49,73 +48,73 @@ discard block |
||
| 49 | 48 | */ |
| 50 | 49 | class GD_Adapter implements Canvas { |
| 51 | 50 | |
| 52 | - /** |
|
| 53 | - * Resoure handle for the image |
|
| 54 | - * |
|
| 55 | - * @var resource |
|
| 56 | - */ |
|
| 57 | - private $_img; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * Image width in pixels |
|
| 61 | - * |
|
| 62 | - * @var int |
|
| 63 | - */ |
|
| 64 | - private $_width; |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * Image height in pixels |
|
| 68 | - * |
|
| 69 | - * @var int |
|
| 70 | - */ |
|
| 71 | - private $_height; |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * Image antialias factor |
|
| 75 | - * |
|
| 76 | - * @var float |
|
| 77 | - */ |
|
| 78 | - private $_aa_factor; |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * Allocated colors |
|
| 82 | - * |
|
| 83 | - * @var array |
|
| 84 | - */ |
|
| 85 | - private $_colors; |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Background color |
|
| 89 | - * |
|
| 90 | - * @var int |
|
| 91 | - */ |
|
| 92 | - private $_bg_color; |
|
| 51 | + /** |
|
| 52 | + * Resoure handle for the image |
|
| 53 | + * |
|
| 54 | + * @var resource |
|
| 55 | + */ |
|
| 56 | + private $_img; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Image width in pixels |
|
| 60 | + * |
|
| 61 | + * @var int |
|
| 62 | + */ |
|
| 63 | + private $_width; |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Image height in pixels |
|
| 67 | + * |
|
| 68 | + * @var int |
|
| 69 | + */ |
|
| 70 | + private $_height; |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Image antialias factor |
|
| 74 | + * |
|
| 75 | + * @var float |
|
| 76 | + */ |
|
| 77 | + private $_aa_factor; |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Allocated colors |
|
| 81 | + * |
|
| 82 | + * @var array |
|
| 83 | + */ |
|
| 84 | + private $_colors; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * Background color |
|
| 88 | + * |
|
| 89 | + * @var int |
|
| 90 | + */ |
|
| 91 | + private $_bg_color; |
|
| 93 | 92 | |
| 94 | - /** |
|
| 95 | - * Class constructor |
|
| 96 | - * |
|
| 97 | - * @param mixed $size The size of image to create: array(x1,y1,x2,y2) or "letter", "legal", etc. |
|
| 98 | - * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
|
| 99 | - * @param float $aa_factor Anti-aliasing factor, 1 for no AA |
|
| 100 | - * @param array $bg_color Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1 |
|
| 101 | - */ |
|
| 102 | - function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1,1,1,0) ) { |
|
| 93 | + /** |
|
| 94 | + * Class constructor |
|
| 95 | + * |
|
| 96 | + * @param mixed $size The size of image to create: array(x1,y1,x2,y2) or "letter", "legal", etc. |
|
| 97 | + * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
|
| 98 | + * @param float $aa_factor Anti-aliasing factor, 1 for no AA |
|
| 99 | + * @param array $bg_color Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1 |
|
| 100 | + */ |
|
| 101 | + function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1,1,1,0) ) { |
|
| 103 | 102 | |
| 104 | 103 | if ( !is_array($size) ) { |
| 105 | 104 | |
| 106 | - if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) |
|
| 105 | + if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) |
|
| 107 | 106 | $size = CPDF_Adapter::$PAPER_SIZES[$size]; |
| 108 | - else |
|
| 107 | + else |
|
| 109 | 108 | $size = CPDF_Adapter::$PAPER_SIZES["letter"]; |
| 110 | 109 | |
| 111 | 110 | } |
| 112 | 111 | |
| 113 | 112 | if ( strtolower($orientation) === "landscape" ) { |
| 114 | - list($size[2],$size[3]) = array($size[3],$size[2]); |
|
| 113 | + list($size[2],$size[3]) = array($size[3],$size[2]); |
|
| 115 | 114 | } |
| 116 | 115 | |
| 117 | 116 | if ( $aa_factor < 1 ) |
| 118 | - $aa_factor = 1; |
|
| 117 | + $aa_factor = 1; |
|
| 119 | 118 | |
| 120 | 119 | $this->_aa_factor = $aa_factor; |
| 121 | 120 | |
@@ -128,8 +127,8 @@ discard block |
||
| 128 | 127 | $this->_img = imagecreatetruecolor($this->_width, $this->_height); |
| 129 | 128 | |
| 130 | 129 | if ( is_null($bg_color) || !is_array($bg_color) ) { |
| 131 | - // Pure white bg |
|
| 132 | - $bg_color = array(1,1,1,0); |
|
| 130 | + // Pure white bg |
|
| 131 | + $bg_color = array(1,1,1,0); |
|
| 133 | 132 | } |
| 134 | 133 | |
| 135 | 134 | $this->_bg_color = $this->_allocate_color($bg_color); |
@@ -137,68 +136,68 @@ discard block |
||
| 137 | 136 | imagesavealpha($this->_img, true); |
| 138 | 137 | imagefill($this->_img, 0, 0, $this->_bg_color); |
| 139 | 138 | |
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * Return the GF image resource |
|
| 144 | - * |
|
| 145 | - * @return resource |
|
| 146 | - */ |
|
| 147 | - function get_image() { return $this->_img; } |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * Return the image's width in pixels |
|
| 151 | - * |
|
| 152 | - * @return float |
|
| 153 | - */ |
|
| 154 | - function get_width() { return $this->_width / $this->_aa_factor; } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * Return the image's height in pixels |
|
| 158 | - * |
|
| 159 | - * @return float |
|
| 160 | - */ |
|
| 161 | - function get_height() { return $this->_height / $this->_aa_factor; } |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Return the GF image resource |
|
| 143 | + * |
|
| 144 | + * @return resource |
|
| 145 | + */ |
|
| 146 | + function get_image() { return $this->_img; } |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * Return the image's width in pixels |
|
| 150 | + * |
|
| 151 | + * @return float |
|
| 152 | + */ |
|
| 153 | + function get_width() { return $this->_width / $this->_aa_factor; } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Return the image's height in pixels |
|
| 157 | + * |
|
| 158 | + * @return float |
|
| 159 | + */ |
|
| 160 | + function get_height() { return $this->_height / $this->_aa_factor; } |
|
| 162 | 161 | |
| 163 | - /** |
|
| 164 | - * Returns the current page number |
|
| 165 | - * |
|
| 166 | - * @return int |
|
| 167 | - */ |
|
| 168 | - function get_page_number() { |
|
| 162 | + /** |
|
| 163 | + * Returns the current page number |
|
| 164 | + * |
|
| 165 | + * @return int |
|
| 166 | + */ |
|
| 167 | + function get_page_number() { |
|
| 169 | 168 | // FIXME |
| 170 | - } |
|
| 169 | + } |
|
| 171 | 170 | |
| 172 | - /** |
|
| 173 | - * Returns the total number of pages |
|
| 174 | - * |
|
| 175 | - * @return int |
|
| 176 | - */ |
|
| 177 | - function get_page_count() { |
|
| 171 | + /** |
|
| 172 | + * Returns the total number of pages |
|
| 173 | + * |
|
| 174 | + * @return int |
|
| 175 | + */ |
|
| 176 | + function get_page_count() { |
|
| 178 | 177 | // FIXME |
| 179 | - } |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * Sets the total number of pages |
|
| 183 | - * |
|
| 184 | - * @param int $count |
|
| 185 | - */ |
|
| 186 | - function set_page_count($count) { |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + /** |
|
| 181 | + * Sets the total number of pages |
|
| 182 | + * |
|
| 183 | + * @param int $count |
|
| 184 | + */ |
|
| 185 | + function set_page_count($count) { |
|
| 187 | 186 | // FIXME |
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * Allocate a new color. Allocate with GD as needed and store |
|
| 192 | - * previously allocated colors in $this->_colors. |
|
| 193 | - * |
|
| 194 | - * @param array $color The new current color |
|
| 195 | - * @return int The allocated color |
|
| 196 | - */ |
|
| 197 | - private function _allocate_color($color) { |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * Allocate a new color. Allocate with GD as needed and store |
|
| 191 | + * previously allocated colors in $this->_colors. |
|
| 192 | + * |
|
| 193 | + * @param array $color The new current color |
|
| 194 | + * @return int The allocated color |
|
| 195 | + */ |
|
| 196 | + private function _allocate_color($color) { |
|
| 198 | 197 | |
| 199 | 198 | // Full opacity if no alpha set |
| 200 | 199 | if ( !isset($color[3]) ) |
| 201 | - $color[3] = 0; |
|
| 200 | + $color[3] = 0; |
|
| 202 | 201 | |
| 203 | 202 | list($r,$g,$b,$a) = $color; |
| 204 | 203 | |
@@ -221,33 +220,33 @@ discard block |
||
| 221 | 220 | $key = sprintf("#%02X%02X%02X%02X", $r, $g, $b, $a); |
| 222 | 221 | |
| 223 | 222 | if ( isset($this->_colors[$key]) ) |
| 224 | - return $this->_colors[$key]; |
|
| 223 | + return $this->_colors[$key]; |
|
| 225 | 224 | |
| 226 | 225 | if ( $a != 0 ) |
| 227 | - $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a); |
|
| 226 | + $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a); |
|
| 228 | 227 | else |
| 229 | - $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b); |
|
| 228 | + $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b); |
|
| 230 | 229 | |
| 231 | 230 | return $this->_colors[$key]; |
| 232 | 231 | |
| 233 | - } |
|
| 232 | + } |
|
| 234 | 233 | |
| 235 | - /** |
|
| 236 | - * Draws a line from x1,y1 to x2,y2 |
|
| 237 | - * |
|
| 238 | - * See {@link Style::munge_color()} for the format of the color array. |
|
| 239 | - * See {@link Cpdf::setLineStyle()} for a description of the format of the |
|
| 240 | - * $style parameter (aka dash). |
|
| 241 | - * |
|
| 242 | - * @param float $x1 |
|
| 243 | - * @param float $y1 |
|
| 244 | - * @param float $x2 |
|
| 245 | - * @param float $y2 |
|
| 246 | - * @param array $color |
|
| 247 | - * @param float $width |
|
| 248 | - * @param array $style |
|
| 249 | - */ |
|
| 250 | - function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
|
| 234 | + /** |
|
| 235 | + * Draws a line from x1,y1 to x2,y2 |
|
| 236 | + * |
|
| 237 | + * See {@link Style::munge_color()} for the format of the color array. |
|
| 238 | + * See {@link Cpdf::setLineStyle()} for a description of the format of the |
|
| 239 | + * $style parameter (aka dash). |
|
| 240 | + * |
|
| 241 | + * @param float $x1 |
|
| 242 | + * @param float $y1 |
|
| 243 | + * @param float $x2 |
|
| 244 | + * @param float $y2 |
|
| 245 | + * @param array $color |
|
| 246 | + * @param float $width |
|
| 247 | + * @param array $style |
|
| 248 | + */ |
|
| 249 | + function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
|
| 251 | 250 | |
| 252 | 251 | // Scale by the AA factor |
| 253 | 252 | $x1 *= $this->_aa_factor; |
@@ -260,63 +259,63 @@ discard block |
||
| 260 | 259 | |
| 261 | 260 | // Convert the style array if required |
| 262 | 261 | if ( !is_null($style) ) { |
| 263 | - $gd_style = array(); |
|
| 262 | + $gd_style = array(); |
|
| 264 | 263 | |
| 265 | - if ( count($style) == 1 ) { |
|
| 264 | + if ( count($style) == 1 ) { |
|
| 266 | 265 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) { |
| 267 | - $gd_style[] = $c; |
|
| 266 | + $gd_style[] = $c; |
|
| 268 | 267 | } |
| 269 | 268 | |
| 270 | 269 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) { |
| 271 | - $gd_style[] = $this->_bg_color; |
|
| 270 | + $gd_style[] = $this->_bg_color; |
|
| 272 | 271 | } |
| 273 | 272 | |
| 274 | - } else { |
|
| 273 | + } else { |
|
| 275 | 274 | |
| 276 | 275 | $i = 0; |
| 277 | 276 | foreach ($style as $length) { |
| 278 | 277 | |
| 279 | - if ( $i % 2 == 0 ) { |
|
| 278 | + if ( $i % 2 == 0 ) { |
|
| 280 | 279 | // 'On' pattern |
| 281 | 280 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) |
| 282 | - $gd_style[] = $c; |
|
| 281 | + $gd_style[] = $c; |
|
| 283 | 282 | |
| 284 | - } else { |
|
| 283 | + } else { |
|
| 285 | 284 | // Off pattern |
| 286 | 285 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) |
| 287 | - $gd_style[] = $this->_bg_color; |
|
| 286 | + $gd_style[] = $this->_bg_color; |
|
| 288 | 287 | |
| 289 | - } |
|
| 290 | - $i++; |
|
| 288 | + } |
|
| 289 | + $i++; |
|
| 290 | + } |
|
| 291 | 291 | } |
| 292 | - } |
|
| 293 | 292 | |
| 294 | - imagesetstyle($this->_img, $gd_style); |
|
| 295 | - $c = IMG_COLOR_STYLED; |
|
| 293 | + imagesetstyle($this->_img, $gd_style); |
|
| 294 | + $c = IMG_COLOR_STYLED; |
|
| 296 | 295 | } |
| 297 | 296 | |
| 298 | 297 | imagesetthickness($this->_img, $width); |
| 299 | 298 | |
| 300 | 299 | imageline($this->_img, $x1, $y1, $x2, $y2, $c); |
| 301 | 300 | |
| 302 | - } |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * Draws a rectangle at x1,y1 with width w and height h |
|
| 306 | - * |
|
| 307 | - * See {@link Style::munge_color()} for the format of the color array. |
|
| 308 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
| 309 | - * parameter (aka dash) |
|
| 310 | - * |
|
| 311 | - * @param float $x1 |
|
| 312 | - * @param float $y1 |
|
| 313 | - * @param float $w |
|
| 314 | - * @param float $h |
|
| 315 | - * @param array $color |
|
| 316 | - * @param float $width |
|
| 317 | - * @param array $style |
|
| 318 | - */ |
|
| 319 | - function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * Draws a rectangle at x1,y1 with width w and height h |
|
| 305 | + * |
|
| 306 | + * See {@link Style::munge_color()} for the format of the color array. |
|
| 307 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
| 308 | + * parameter (aka dash) |
|
| 309 | + * |
|
| 310 | + * @param float $x1 |
|
| 311 | + * @param float $y1 |
|
| 312 | + * @param float $w |
|
| 313 | + * @param float $h |
|
| 314 | + * @param array $color |
|
| 315 | + * @param float $width |
|
| 316 | + * @param array $style |
|
| 317 | + */ |
|
| 318 | + function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
|
| 320 | 319 | |
| 321 | 320 | // Scale by the AA factor |
| 322 | 321 | $x1 *= $this->_aa_factor; |
@@ -328,36 +327,36 @@ discard block |
||
| 328 | 327 | |
| 329 | 328 | // Convert the style array if required |
| 330 | 329 | if ( !is_null($style) ) { |
| 331 | - $gd_style = array(); |
|
| 330 | + $gd_style = array(); |
|
| 332 | 331 | |
| 333 | - foreach ($style as $length) { |
|
| 332 | + foreach ($style as $length) { |
|
| 334 | 333 | for ($i = 0; $i < $length; $i++) { |
| 335 | - $gd_style[] = $c; |
|
| 334 | + $gd_style[] = $c; |
|
| 335 | + } |
|
| 336 | 336 | } |
| 337 | - } |
|
| 338 | 337 | |
| 339 | - imagesetstyle($this->_img, $gd_style); |
|
| 340 | - $c = IMG_COLOR_STYLED; |
|
| 338 | + imagesetstyle($this->_img, $gd_style); |
|
| 339 | + $c = IMG_COLOR_STYLED; |
|
| 341 | 340 | } |
| 342 | 341 | |
| 343 | 342 | imagesetthickness($this->_img, $width); |
| 344 | 343 | |
| 345 | 344 | imagerectangle($this->_img, $x1, $y1, $x1 + $w, $y1 + $h, $c); |
| 346 | 345 | |
| 347 | - } |
|
| 348 | - |
|
| 349 | - /** |
|
| 350 | - * Draws a filled rectangle at x1,y1 with width w and height h |
|
| 351 | - * |
|
| 352 | - * See {@link Style::munge_color()} for the format of the color array. |
|
| 353 | - * |
|
| 354 | - * @param float $x1 |
|
| 355 | - * @param float $y1 |
|
| 356 | - * @param float $w |
|
| 357 | - * @param float $h |
|
| 358 | - * @param array $color |
|
| 359 | - */ |
|
| 360 | - function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + /** |
|
| 349 | + * Draws a filled rectangle at x1,y1 with width w and height h |
|
| 350 | + * |
|
| 351 | + * See {@link Style::munge_color()} for the format of the color array. |
|
| 352 | + * |
|
| 353 | + * @param float $x1 |
|
| 354 | + * @param float $y1 |
|
| 355 | + * @param float $w |
|
| 356 | + * @param float $h |
|
| 357 | + * @param array $color |
|
| 358 | + */ |
|
| 359 | + function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
| 361 | 360 | |
| 362 | 361 | // Scale by the AA factor |
| 363 | 362 | $x1 *= $this->_aa_factor; |
@@ -369,79 +368,79 @@ discard block |
||
| 369 | 368 | |
| 370 | 369 | imagefilledrectangle($this->_img, $x1, $y1, $x1 + $w, $y1 + $h, $c); |
| 371 | 370 | |
| 372 | - } |
|
| 373 | - |
|
| 374 | - /** |
|
| 375 | - * Draws a polygon |
|
| 376 | - * |
|
| 377 | - * The polygon is formed by joining all the points stored in the $points |
|
| 378 | - * array. $points has the following structure: |
|
| 379 | - * <code> |
|
| 380 | - * array(0 => x1, |
|
| 381 | - * 1 => y1, |
|
| 382 | - * 2 => x2, |
|
| 383 | - * 3 => y2, |
|
| 384 | - * ... |
|
| 385 | - * ); |
|
| 386 | - * </code> |
|
| 387 | - * |
|
| 388 | - * See {@link Style::munge_color()} for the format of the color array. |
|
| 389 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
| 390 | - * parameter (aka dash) |
|
| 391 | - * |
|
| 392 | - * @param array $points |
|
| 393 | - * @param array $color |
|
| 394 | - * @param float $width |
|
| 395 | - * @param array $style |
|
| 396 | - * @param bool $fill Fills the polygon if true |
|
| 397 | - */ |
|
| 398 | - function polygon($points, $color, $width = null, $style = null, $fill = false) { |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + /** |
|
| 374 | + * Draws a polygon |
|
| 375 | + * |
|
| 376 | + * The polygon is formed by joining all the points stored in the $points |
|
| 377 | + * array. $points has the following structure: |
|
| 378 | + * <code> |
|
| 379 | + * array(0 => x1, |
|
| 380 | + * 1 => y1, |
|
| 381 | + * 2 => x2, |
|
| 382 | + * 3 => y2, |
|
| 383 | + * ... |
|
| 384 | + * ); |
|
| 385 | + * </code> |
|
| 386 | + * |
|
| 387 | + * See {@link Style::munge_color()} for the format of the color array. |
|
| 388 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
| 389 | + * parameter (aka dash) |
|
| 390 | + * |
|
| 391 | + * @param array $points |
|
| 392 | + * @param array $color |
|
| 393 | + * @param float $width |
|
| 394 | + * @param array $style |
|
| 395 | + * @param bool $fill Fills the polygon if true |
|
| 396 | + */ |
|
| 397 | + function polygon($points, $color, $width = null, $style = null, $fill = false) { |
|
| 399 | 398 | |
| 400 | 399 | // Scale each point by the AA factor |
| 401 | 400 | foreach (array_keys($points) as $i) |
| 402 | - $points[$i] *= $this->_aa_factor; |
|
| 401 | + $points[$i] *= $this->_aa_factor; |
|
| 403 | 402 | |
| 404 | 403 | $c = $this->_allocate_color($color); |
| 405 | 404 | |
| 406 | 405 | // Convert the style array if required |
| 407 | 406 | if ( !is_null($style) && !$fill ) { |
| 408 | - $gd_style = array(); |
|
| 407 | + $gd_style = array(); |
|
| 409 | 408 | |
| 410 | - foreach ($style as $length) { |
|
| 409 | + foreach ($style as $length) { |
|
| 411 | 410 | for ($i = 0; $i < $length; $i++) { |
| 412 | - $gd_style[] = $c; |
|
| 411 | + $gd_style[] = $c; |
|
| 412 | + } |
|
| 413 | 413 | } |
| 414 | - } |
|
| 415 | 414 | |
| 416 | - imagesetstyle($this->_img, $gd_style); |
|
| 417 | - $c = IMG_COLOR_STYLED; |
|
| 415 | + imagesetstyle($this->_img, $gd_style); |
|
| 416 | + $c = IMG_COLOR_STYLED; |
|
| 418 | 417 | } |
| 419 | 418 | |
| 420 | 419 | imagesetthickness($this->_img, $width); |
| 421 | 420 | |
| 422 | 421 | if ( $fill ) |
| 423 | - imagefilledpolygon($this->_img, $points, count($points) / 2, $c); |
|
| 422 | + imagefilledpolygon($this->_img, $points, count($points) / 2, $c); |
|
| 424 | 423 | else |
| 425 | - imagepolygon($this->_img, $points, count($points) / 2, $c); |
|
| 424 | + imagepolygon($this->_img, $points, count($points) / 2, $c); |
|
| 426 | 425 | |
| 427 | - } |
|
| 428 | - |
|
| 429 | - /** |
|
| 430 | - * Draws a circle at $x,$y with radius $r |
|
| 431 | - * |
|
| 432 | - * See {@link Style::munge_color()} for the format of the color array. |
|
| 433 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
| 434 | - * parameter (aka dash) |
|
| 435 | - * |
|
| 436 | - * @param float $x |
|
| 437 | - * @param float $y |
|
| 438 | - * @param float $r |
|
| 439 | - * @param array $color |
|
| 440 | - * @param float $width |
|
| 441 | - * @param array $style |
|
| 442 | - * @param bool $fill Fills the circle if true |
|
| 443 | - */ |
|
| 444 | - function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) { |
|
| 426 | + } |
|
| 427 | + |
|
| 428 | + /** |
|
| 429 | + * Draws a circle at $x,$y with radius $r |
|
| 430 | + * |
|
| 431 | + * See {@link Style::munge_color()} for the format of the color array. |
|
| 432 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
| 433 | + * parameter (aka dash) |
|
| 434 | + * |
|
| 435 | + * @param float $x |
|
| 436 | + * @param float $y |
|
| 437 | + * @param float $r |
|
| 438 | + * @param array $color |
|
| 439 | + * @param float $width |
|
| 440 | + * @param array $style |
|
| 441 | + * @param bool $fill Fills the circle if true |
|
| 442 | + */ |
|
| 443 | + function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) { |
|
| 445 | 444 | |
| 446 | 445 | // Scale by the AA factor |
| 447 | 446 | $x *= $this->_aa_factor; |
@@ -452,55 +451,55 @@ discard block |
||
| 452 | 451 | |
| 453 | 452 | // Convert the style array if required |
| 454 | 453 | if ( !is_null($style) && !$fill ) { |
| 455 | - $gd_style = array(); |
|
| 454 | + $gd_style = array(); |
|
| 456 | 455 | |
| 457 | - foreach ($style as $length) { |
|
| 456 | + foreach ($style as $length) { |
|
| 458 | 457 | for ($i = 0; $i < $length; $i++) { |
| 459 | - $gd_style[] = $c; |
|
| 458 | + $gd_style[] = $c; |
|
| 459 | + } |
|
| 460 | 460 | } |
| 461 | - } |
|
| 462 | 461 | |
| 463 | - imagesetstyle($this->_img, $gd_style); |
|
| 464 | - $c = IMG_COLOR_STYLED; |
|
| 462 | + imagesetstyle($this->_img, $gd_style); |
|
| 463 | + $c = IMG_COLOR_STYLED; |
|
| 465 | 464 | } |
| 466 | 465 | |
| 467 | 466 | imagesetthickness($this->_img, $width); |
| 468 | 467 | |
| 469 | 468 | if ( $fill ) |
| 470 | - imagefilledellipse($this->_img, $x, $y, $r, $r, $c); |
|
| 469 | + imagefilledellipse($this->_img, $x, $y, $r, $r, $c); |
|
| 471 | 470 | else |
| 472 | - imageellipse($this->_img, $x, $y, $r, $r, $c); |
|
| 471 | + imageellipse($this->_img, $x, $y, $r, $r, $c); |
|
| 473 | 472 | |
| 474 | - } |
|
| 475 | - |
|
| 476 | - /** |
|
| 477 | - * Add an image to the pdf. |
|
| 478 | - * |
|
| 479 | - * The image is placed at the specified x and y coordinates with the |
|
| 480 | - * given width and height. |
|
| 481 | - * |
|
| 482 | - * @param string $img_url the path to the image |
|
| 483 | - * @param string $img_type the type (e.g. extension) of the image |
|
| 484 | - * @param float $x x position |
|
| 485 | - * @param float $y y position |
|
| 486 | - * @param int $w width (in pixels) |
|
| 487 | - * @param int $h height (in pixels) |
|
| 488 | - */ |
|
| 489 | - function image($img_url, $img_type, $x, $y, $w, $h) { |
|
| 473 | + } |
|
| 474 | + |
|
| 475 | + /** |
|
| 476 | + * Add an image to the pdf. |
|
| 477 | + * |
|
| 478 | + * The image is placed at the specified x and y coordinates with the |
|
| 479 | + * given width and height. |
|
| 480 | + * |
|
| 481 | + * @param string $img_url the path to the image |
|
| 482 | + * @param string $img_type the type (e.g. extension) of the image |
|
| 483 | + * @param float $x x position |
|
| 484 | + * @param float $y y position |
|
| 485 | + * @param int $w width (in pixels) |
|
| 486 | + * @param int $h height (in pixels) |
|
| 487 | + */ |
|
| 488 | + function image($img_url, $img_type, $x, $y, $w, $h) { |
|
| 490 | 489 | |
| 491 | 490 | switch ($img_type) { |
| 492 | 491 | case "png": |
| 493 | 492 | $src = @imagecreatefrompng($img_url); |
| 494 | - break; |
|
| 493 | + break; |
|
| 495 | 494 | |
| 496 | 495 | case "gif": |
| 497 | 496 | $src = @imagecreatefromgif($img_url); |
| 498 | - break; |
|
| 497 | + break; |
|
| 499 | 498 | |
| 500 | 499 | case "jpg": |
| 501 | 500 | case "jpeg": |
| 502 | 501 | $src = @imagecreatefromjpeg($img_url); |
| 503 | - break; |
|
| 502 | + break; |
|
| 504 | 503 | |
| 505 | 504 | default: |
| 506 | 505 | break; |
@@ -508,7 +507,7 @@ discard block |
||
| 508 | 507 | } |
| 509 | 508 | |
| 510 | 509 | if ( !$src ) |
| 511 | - return; // Probably should add to $_dompdf_errors or whatever here |
|
| 510 | + return; // Probably should add to $_dompdf_errors or whatever here |
|
| 512 | 511 | |
| 513 | 512 | // Scale by the AA factor |
| 514 | 513 | $x *= $this->_aa_factor; |
@@ -523,23 +522,23 @@ discard block |
||
| 523 | 522 | |
| 524 | 523 | imagecopyresampled($this->_img, $src, $x, $y, 0, 0, $w, $h, $img_w, $img_h); |
| 525 | 524 | |
| 526 | - } |
|
| 527 | - |
|
| 528 | - /** |
|
| 529 | - * Writes text at the specified x and y coordinates |
|
| 530 | - * |
|
| 531 | - * See {@link Style::munge_color()} for the format of the color array. |
|
| 532 | - * |
|
| 533 | - * @param float $x |
|
| 534 | - * @param float $y |
|
| 535 | - * @param string $text the text to write |
|
| 536 | - * @param string $font the font file to use |
|
| 537 | - * @param float $size the font size, in points |
|
| 538 | - * @param array $color |
|
| 539 | - * @param float $adjust word spacing adjustment |
|
| 540 | - * @param float $angle Text angle |
|
| 541 | - */ |
|
| 542 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
| 525 | + } |
|
| 526 | + |
|
| 527 | + /** |
|
| 528 | + * Writes text at the specified x and y coordinates |
|
| 529 | + * |
|
| 530 | + * See {@link Style::munge_color()} for the format of the color array. |
|
| 531 | + * |
|
| 532 | + * @param float $x |
|
| 533 | + * @param float $y |
|
| 534 | + * @param string $text the text to write |
|
| 535 | + * @param string $font the font file to use |
|
| 536 | + * @param float $size the font size, in points |
|
| 537 | + * @param array $color |
|
| 538 | + * @param float $adjust word spacing adjustment |
|
| 539 | + * @param float $angle Text angle |
|
| 540 | + */ |
|
| 541 | + function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
| 543 | 542 | |
| 544 | 543 | // Scale by the AA factor |
| 545 | 544 | $x *= $this->_aa_factor; |
@@ -551,106 +550,106 @@ discard block |
||
| 551 | 550 | $c = $this->_allocate_color($color); |
| 552 | 551 | |
| 553 | 552 | if ( strpos($font, '.ttf') === false ) |
| 554 | - $font .= ".ttf"; |
|
| 553 | + $font .= ".ttf"; |
|
| 555 | 554 | |
| 556 | 555 | // FIXME: word spacing |
| 557 | 556 | imagettftext($this->_img, $size, $angle, $x, $y + $h, $c, $font, $text); |
| 558 | 557 | |
| 559 | - } |
|
| 558 | + } |
|
| 560 | 559 | |
| 561 | - function javascript($code) { |
|
| 560 | + function javascript($code) { |
|
| 562 | 561 | // Not implemented |
| 563 | - } |
|
| 564 | - |
|
| 565 | - /** |
|
| 566 | - * Add a named destination (similar to <a name="foo">...</a> in html) |
|
| 567 | - * |
|
| 568 | - * @param string $anchorname The name of the named destination |
|
| 569 | - */ |
|
| 570 | - function add_named_dest($anchorname) { |
|
| 562 | + } |
|
| 563 | + |
|
| 564 | + /** |
|
| 565 | + * Add a named destination (similar to <a name="foo">...</a> in html) |
|
| 566 | + * |
|
| 567 | + * @param string $anchorname The name of the named destination |
|
| 568 | + */ |
|
| 569 | + function add_named_dest($anchorname) { |
|
| 571 | 570 | // Not implemented |
| 572 | - } |
|
| 573 | - |
|
| 574 | - /** |
|
| 575 | - * Add a link to the pdf |
|
| 576 | - * |
|
| 577 | - * @param string $url The url to link to |
|
| 578 | - * @param float $x The x position of the link |
|
| 579 | - * @param float $y The y position of the link |
|
| 580 | - * @param float $width The width of the link |
|
| 581 | - * @param float $height The height of the link |
|
| 582 | - */ |
|
| 583 | - function add_link($url, $x, $y, $width, $height) { |
|
| 571 | + } |
|
| 572 | + |
|
| 573 | + /** |
|
| 574 | + * Add a link to the pdf |
|
| 575 | + * |
|
| 576 | + * @param string $url The url to link to |
|
| 577 | + * @param float $x The x position of the link |
|
| 578 | + * @param float $y The y position of the link |
|
| 579 | + * @param float $width The width of the link |
|
| 580 | + * @param float $height The height of the link |
|
| 581 | + */ |
|
| 582 | + function add_link($url, $x, $y, $width, $height) { |
|
| 584 | 583 | // Not implemented |
| 585 | - } |
|
| 586 | - |
|
| 587 | - /** |
|
| 588 | - * Calculates text size, in points |
|
| 589 | - * |
|
| 590 | - * @param string $text the text to be sized |
|
| 591 | - * @param string $font the desired font |
|
| 592 | - * @param float $size the desired font size |
|
| 593 | - * @param float $spacing word spacing, if any |
|
| 594 | - * @return float |
|
| 595 | - */ |
|
| 596 | - function get_text_width($text, $font, $size, $spacing = 0) { |
|
| 584 | + } |
|
| 585 | + |
|
| 586 | + /** |
|
| 587 | + * Calculates text size, in points |
|
| 588 | + * |
|
| 589 | + * @param string $text the text to be sized |
|
| 590 | + * @param string $font the desired font |
|
| 591 | + * @param float $size the desired font size |
|
| 592 | + * @param float $spacing word spacing, if any |
|
| 593 | + * @return float |
|
| 594 | + */ |
|
| 595 | + function get_text_width($text, $font, $size, $spacing = 0) { |
|
| 597 | 596 | |
| 598 | 597 | if ( strpos($font, '.ttf') === false ) |
| 599 | - $font .= ".ttf"; |
|
| 598 | + $font .= ".ttf"; |
|
| 600 | 599 | |
| 601 | 600 | // FIXME: word spacing |
| 602 | 601 | list($x1,,$x2) = imagettfbbox($size, 0, $font, $text); |
| 603 | 602 | return $x2 - $x1; |
| 604 | - } |
|
| 605 | - |
|
| 606 | - /** |
|
| 607 | - * Calculates font height, in points |
|
| 608 | - * |
|
| 609 | - * @param string $font |
|
| 610 | - * @param float $size |
|
| 611 | - * @return float |
|
| 612 | - */ |
|
| 613 | - function get_font_height($font, $size) { |
|
| 603 | + } |
|
| 604 | + |
|
| 605 | + /** |
|
| 606 | + * Calculates font height, in points |
|
| 607 | + * |
|
| 608 | + * @param string $font |
|
| 609 | + * @param float $size |
|
| 610 | + * @return float |
|
| 611 | + */ |
|
| 612 | + function get_font_height($font, $size) { |
|
| 614 | 613 | if ( strpos($font, '.ttf') === false ) |
| 615 | - $font .= ".ttf"; |
|
| 614 | + $font .= ".ttf"; |
|
| 616 | 615 | |
| 617 | 616 | // FIXME: word spacing |
| 618 | 617 | list(,$y2,,,,$y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl"); // Test string with ascenders, descenders and caps |
| 619 | 618 | return $y2 - $y1; |
| 620 | - } |
|
| 619 | + } |
|
| 621 | 620 | |
| 622 | 621 | |
| 623 | - /** |
|
| 624 | - * Starts a new page |
|
| 625 | - * |
|
| 626 | - * Subsequent drawing operations will appear on the new page. |
|
| 627 | - */ |
|
| 628 | - function new_page() { |
|
| 622 | + /** |
|
| 623 | + * Starts a new page |
|
| 624 | + * |
|
| 625 | + * Subsequent drawing operations will appear on the new page. |
|
| 626 | + */ |
|
| 627 | + function new_page() { |
|
| 629 | 628 | // FIXME |
| 630 | - } |
|
| 629 | + } |
|
| 631 | 630 | |
| 632 | - /** |
|
| 633 | - * Streams the image directly to the browser |
|
| 634 | - * |
|
| 635 | - * @param string $filename the name of the image file (ignored) |
|
| 636 | - * @param array $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only) |
|
| 637 | - */ |
|
| 638 | - function stream($filename, $options = null) { |
|
| 631 | + /** |
|
| 632 | + * Streams the image directly to the browser |
|
| 633 | + * |
|
| 634 | + * @param string $filename the name of the image file (ignored) |
|
| 635 | + * @param array $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only) |
|
| 636 | + */ |
|
| 637 | + function stream($filename, $options = null) { |
|
| 639 | 638 | |
| 640 | 639 | // Perform any antialiasing |
| 641 | 640 | if ( $this->_aa_factor != 1 ) { |
| 642 | - $dst_w = $this->_width / $this->_aa_factor; |
|
| 643 | - $dst_h = $this->_height / $this->_aa_factor; |
|
| 644 | - $dst = imagecreatetruecolor($dst_w, $dst_h); |
|
| 645 | - imagecopyresampled($dst, $this->_img, 0, 0, 0, 0, |
|
| 646 | - $dst_w, $dst_h, |
|
| 647 | - $this->_width, $this->_height); |
|
| 641 | + $dst_w = $this->_width / $this->_aa_factor; |
|
| 642 | + $dst_h = $this->_height / $this->_aa_factor; |
|
| 643 | + $dst = imagecreatetruecolor($dst_w, $dst_h); |
|
| 644 | + imagecopyresampled($dst, $this->_img, 0, 0, 0, 0, |
|
| 645 | + $dst_w, $dst_h, |
|
| 646 | + $this->_width, $this->_height); |
|
| 648 | 647 | } else { |
| 649 | - $dst = $this->_img; |
|
| 648 | + $dst = $this->_img; |
|
| 650 | 649 | } |
| 651 | 650 | |
| 652 | 651 | if ( !isset($options["type"]) ) |
| 653 | - $options["type"] = "png"; |
|
| 652 | + $options["type"] = "png"; |
|
| 654 | 653 | |
| 655 | 654 | $type = strtolower($options["type"]); |
| 656 | 655 | |
@@ -663,42 +662,42 @@ discard block |
||
| 663 | 662 | if ( !isset($options["quality"]) ) |
| 664 | 663 | $options["quality"] = 75; |
| 665 | 664 | |
| 666 | - header("Content-type: image/jpeg"); |
|
| 667 | - imagejpeg($dst, '', $options["quality"]); |
|
| 668 | - break; |
|
| 665 | + header("Content-type: image/jpeg"); |
|
| 666 | + imagejpeg($dst, '', $options["quality"]); |
|
| 667 | + break; |
|
| 669 | 668 | |
| 670 | 669 | case "png": |
| 671 | 670 | default: |
| 672 | 671 | header("Content-type: image/png"); |
| 673 | - imagepng($dst); |
|
| 674 | - break; |
|
| 672 | + imagepng($dst); |
|
| 673 | + break; |
|
| 675 | 674 | } |
| 676 | 675 | |
| 677 | 676 | if ( $this->_aa_factor != 1 ) |
| 678 | - imagedestroy($dst); |
|
| 679 | - } |
|
| 677 | + imagedestroy($dst); |
|
| 678 | + } |
|
| 680 | 679 | |
| 681 | - /** |
|
| 682 | - * Returns the PNG as a string |
|
| 683 | - * |
|
| 684 | - * @param array $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only) |
|
| 685 | - * @return string |
|
| 686 | - */ |
|
| 687 | - function output($options = null) { |
|
| 680 | + /** |
|
| 681 | + * Returns the PNG as a string |
|
| 682 | + * |
|
| 683 | + * @param array $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only) |
|
| 684 | + * @return string |
|
| 685 | + */ |
|
| 686 | + function output($options = null) { |
|
| 688 | 687 | |
| 689 | 688 | if ( $this->_aa_factor != 1 ) { |
| 690 | - $dst_w = $this->_width / $this->_aa_factor; |
|
| 691 | - $dst_h = $this->_height / $this->_aa_factor; |
|
| 692 | - $dst = imagecreatetruecolor($dst_w, $dst_h); |
|
| 693 | - imagecopyresampled($dst, $this->_img, 0, 0, 0, 0, |
|
| 694 | - $dst_w, $dst_h, |
|
| 695 | - $this->_width, $this->_height); |
|
| 689 | + $dst_w = $this->_width / $this->_aa_factor; |
|
| 690 | + $dst_h = $this->_height / $this->_aa_factor; |
|
| 691 | + $dst = imagecreatetruecolor($dst_w, $dst_h); |
|
| 692 | + imagecopyresampled($dst, $this->_img, 0, 0, 0, 0, |
|
| 693 | + $dst_w, $dst_h, |
|
| 694 | + $this->_width, $this->_height); |
|
| 696 | 695 | } else { |
| 697 | - $dst = $this->_img; |
|
| 696 | + $dst = $this->_img; |
|
| 698 | 697 | } |
| 699 | 698 | |
| 700 | 699 | if ( !isset($options["type"]) ) |
| 701 | - $options["type"] = "png"; |
|
| 700 | + $options["type"] = "png"; |
|
| 702 | 701 | |
| 703 | 702 | $type = $options["type"]; |
| 704 | 703 | |
@@ -711,23 +710,23 @@ discard block |
||
| 711 | 710 | if ( !isset($options["quality"]) ) |
| 712 | 711 | $options["quality"] = 75; |
| 713 | 712 | |
| 714 | - imagejpeg($dst, '', $options["quality"]); |
|
| 715 | - break; |
|
| 713 | + imagejpeg($dst, '', $options["quality"]); |
|
| 714 | + break; |
|
| 716 | 715 | |
| 717 | 716 | case "png": |
| 718 | 717 | default: |
| 719 | 718 | imagepng($dst); |
| 720 | - break; |
|
| 719 | + break; |
|
| 721 | 720 | } |
| 722 | 721 | |
| 723 | 722 | $image = ob_get_contents(); |
| 724 | 723 | ob_end_clean(); |
| 725 | 724 | |
| 726 | 725 | if ( $this->_aa_factor != 1 ) |
| 727 | - imagedestroy($dst); |
|
| 726 | + imagedestroy($dst); |
|
| 728 | 727 | |
| 729 | 728 | return $image; |
| 730 | - } |
|
| 729 | + } |
|
| 731 | 730 | |
| 732 | 731 | |
| 733 | 732 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | /** |
| 110 | 110 | * Return the bullet's width |
| 111 | 111 | * |
| 112 | - * @return int |
|
| 112 | + * @return double |
|
| 113 | 113 | */ |
| 114 | 114 | function get_width() { |
| 115 | 115 | //ignore image width, use same width as on predefined bullet List_Bullet_Frame_Decorator |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | /** |
| 160 | 160 | * Override get_margin_height() |
| 161 | 161 | * |
| 162 | - * @return int |
|
| 162 | + * @return double |
|
| 163 | 163 | */ |
| 164 | 164 | function get_margin_height() { |
| 165 | 165 | //Hits only on "inset" lists items, to increase height of box |
@@ -52,34 +52,34 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | class List_Bullet_Image_Frame_Decorator extends Frame_Decorator { |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * The underlying image frame |
|
| 57 | - * |
|
| 58 | - * @var Image_Frame_Decorator |
|
| 59 | - */ |
|
| 60 | - protected $_img; |
|
| 55 | + /** |
|
| 56 | + * The underlying image frame |
|
| 57 | + * |
|
| 58 | + * @var Image_Frame_Decorator |
|
| 59 | + */ |
|
| 60 | + protected $_img; |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * The image's width in pixels |
|
| 64 | - * |
|
| 65 | - * @var int |
|
| 66 | - */ |
|
| 67 | - protected $_width; |
|
| 62 | + /** |
|
| 63 | + * The image's width in pixels |
|
| 64 | + * |
|
| 65 | + * @var int |
|
| 66 | + */ |
|
| 67 | + protected $_width; |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * The image's height in pixels |
|
| 71 | - * |
|
| 72 | - * @var int |
|
| 73 | - */ |
|
| 74 | - protected $_height; |
|
| 69 | + /** |
|
| 70 | + * The image's height in pixels |
|
| 71 | + * |
|
| 72 | + * @var int |
|
| 73 | + */ |
|
| 74 | + protected $_height; |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Class constructor |
|
| 78 | - * |
|
| 79 | - * @param Frame $frame the bullet frame to decorate |
|
| 80 | - * @param DOMPDF $dompdf the document's dompdf object |
|
| 81 | - */ |
|
| 82 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
| 76 | + /** |
|
| 77 | + * Class constructor |
|
| 78 | + * |
|
| 79 | + * @param Frame $frame the bullet frame to decorate |
|
| 80 | + * @param DOMPDF $dompdf the document's dompdf object |
|
| 81 | + */ |
|
| 82 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
| 83 | 83 | $style = $frame->get_style(); |
| 84 | 84 | $url = $style->list_style_image; |
| 85 | 85 | $frame->get_node()->setAttribute("src", $url); |
@@ -104,38 +104,38 @@ discard block |
||
| 104 | 104 | // $style->min_height = $this->_height; |
| 105 | 105 | //} |
| 106 | 106 | //$style->height = "auto"; |
| 107 | - } |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Return the bullet's width |
|
| 111 | - * |
|
| 112 | - * @return int |
|
| 113 | - */ |
|
| 114 | - function get_width() { |
|
| 109 | + /** |
|
| 110 | + * Return the bullet's width |
|
| 111 | + * |
|
| 112 | + * @return int |
|
| 113 | + */ |
|
| 114 | + function get_width() { |
|
| 115 | 115 | //ignore image width, use same width as on predefined bullet List_Bullet_Frame_Decorator |
| 116 | 116 | //for proper alignment of bullet image and text. Allow image to not fitting on left border. |
| 117 | 117 | //This controls the distance between bullet image and text |
| 118 | 118 | //return $this->_width; |
| 119 | 119 | return $this->_frame->get_style()->get_font_size()*List_Bullet_Frame_Decorator::BULLET_SIZE + |
| 120 | 120 | 2 * List_Bullet_Frame_Decorator::BULLET_PADDING; |
| 121 | - } |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * Return the bullet's height |
|
| 125 | - * |
|
| 126 | - * @return int |
|
| 127 | - */ |
|
| 128 | - function get_height() { |
|
| 123 | + /** |
|
| 124 | + * Return the bullet's height |
|
| 125 | + * |
|
| 126 | + * @return int |
|
| 127 | + */ |
|
| 128 | + function get_height() { |
|
| 129 | 129 | //based on image height |
| 130 | 130 | return $this->_height; |
| 131 | - } |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - /** |
|
| 134 | - * Override get_margin_width |
|
| 135 | - * |
|
| 136 | - * @return int |
|
| 137 | - */ |
|
| 138 | - function get_margin_width() { |
|
| 133 | + /** |
|
| 134 | + * Override get_margin_width |
|
| 135 | + * |
|
| 136 | + * @return int |
|
| 137 | + */ |
|
| 138 | + function get_margin_width() { |
|
| 139 | 139 | //ignore image width, use same width as on predefined bullet List_Bullet_Frame_Decorator |
| 140 | 140 | //for proper alignment of bullet image and text. Allow image to not fitting on left border. |
| 141 | 141 | //This controls the extra indentation of text to make room for the bullet image. |
@@ -147,42 +147,42 @@ discard block |
||
| 147 | 147 | // Image Might not exist, then position like on list_bullet_frame_decorator fallback to none. |
| 148 | 148 | if ( $this->_frame->get_style()->list_style_position === "outside" || |
| 149 | 149 | $this->_width == 0) |
| 150 | - return 0; |
|
| 150 | + return 0; |
|
| 151 | 151 | //This aligns the "inside" image position with the text. |
| 152 | 152 | //The text starts to the right of the image. |
| 153 | 153 | //Between the image and the text there is an added margin of image width. |
| 154 | 154 | //Where this comes from is unknown. |
| 155 | 155 | //The corresponding List_Bullet_Frame_Decorator sets a smaller margin. bullet size? |
| 156 | 156 | return $this->_width + 2 * List_Bullet_Frame_Decorator::BULLET_PADDING; |
| 157 | - } |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - /** |
|
| 160 | - * Override get_margin_height() |
|
| 161 | - * |
|
| 162 | - * @return int |
|
| 163 | - */ |
|
| 164 | - function get_margin_height() { |
|
| 159 | + /** |
|
| 160 | + * Override get_margin_height() |
|
| 161 | + * |
|
| 162 | + * @return int |
|
| 163 | + */ |
|
| 164 | + function get_margin_height() { |
|
| 165 | 165 | //Hits only on "inset" lists items, to increase height of box |
| 166 | 166 | //based on image height |
| 167 | 167 | return $this->_height + 2 * List_Bullet_Frame_Decorator::BULLET_PADDING; |
| 168 | - } |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | - /** |
|
| 171 | - * Return image url |
|
| 172 | - * |
|
| 173 | - * @return string |
|
| 174 | - */ |
|
| 175 | - function get_image_url() { |
|
| 170 | + /** |
|
| 171 | + * Return image url |
|
| 172 | + * |
|
| 173 | + * @return string |
|
| 174 | + */ |
|
| 175 | + function get_image_url() { |
|
| 176 | 176 | return $this->_img->get_image_url(); |
| 177 | - } |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - /** |
|
| 180 | - * Return the image extension |
|
| 181 | - * |
|
| 182 | - * @return string |
|
| 183 | - */ |
|
| 184 | - function get_image_ext() { |
|
| 179 | + /** |
|
| 180 | + * Return the image extension |
|
| 181 | + * |
|
| 182 | + * @return string |
|
| 183 | + */ |
|
| 184 | + function get_image_ext() { |
|
| 185 | 185 | return $this->_img->get_image_ext(); |
| 186 | - } |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | 188 | } |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | // Resample the bullet image to be consistent with 'auto' sized images |
| 91 | 91 | // See also Image_Frame_Reflower::get_min_max_width |
| 92 | 92 | // Tested php ver: value measured in px, suffix "px" not in value: rtrim unnecessary. |
| 93 | - $this->_width = (((float)rtrim($width, "px")) * 72) / DOMPDF_DPI; |
|
| 94 | - $this->_height = (((float)rtrim($height, "px")) * 72) / DOMPDF_DPI; |
|
| 93 | + $this->_width = (((float) rtrim($width, "px")) * 72) / DOMPDF_DPI; |
|
| 94 | + $this->_height = (((float) rtrim($height, "px")) * 72) / DOMPDF_DPI; |
|
| 95 | 95 | |
| 96 | 96 | //If an image is taller as the containing block/box, the box should be extended. |
| 97 | 97 | //Neighbour elements are overwriting the overlapping image areas. |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | //for proper alignment of bullet image and text. Allow image to not fitting on left border. |
| 117 | 117 | //This controls the distance between bullet image and text |
| 118 | 118 | //return $this->_width; |
| 119 | - return $this->_frame->get_style()->get_font_size()*List_Bullet_Frame_Decorator::BULLET_SIZE + |
|
| 119 | + return $this->_frame->get_style()->get_font_size() * List_Bullet_Frame_Decorator::BULLET_SIZE + |
|
| 120 | 120 | 2 * List_Bullet_Frame_Decorator::BULLET_PADDING; |
| 121 | 121 | } |
| 122 | 122 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | // Small hack to prevent indenting of list text |
| 147 | 147 | // Image Might not exist, then position like on list_bullet_frame_decorator fallback to none. |
| 148 | - if ( $this->_frame->get_style()->list_style_position === "outside" || |
|
| 148 | + if ($this->_frame->get_style()->list_style_position === "outside" || |
|
| 149 | 149 | $this->_width == 0) |
| 150 | 150 | return 0; |
| 151 | 151 | //This aligns the "inside" image position with the text. |
@@ -146,8 +146,9 @@ |
||
| 146 | 146 | // Small hack to prevent indenting of list text |
| 147 | 147 | // Image Might not exist, then position like on list_bullet_frame_decorator fallback to none. |
| 148 | 148 | if ( $this->_frame->get_style()->list_style_position === "outside" || |
| 149 | - $this->_width == 0) |
|
| 150 | - return 0; |
|
| 149 | + $this->_width == 0) { |
|
| 150 | + return 0; |
|
| 151 | + } |
|
| 151 | 152 | //This aligns the "inside" image position with the text. |
| 152 | 153 | //The text starts to the right of the image. |
| 153 | 154 | //Between the image and the text there is an added margin of image width. |
@@ -70,12 +70,19 @@ |
||
| 70 | 70 | |
| 71 | 71 | function __construct() { throw new Exception("Can not create instance of Page_Class. Class is static."); } |
| 72 | 72 | |
| 73 | + /** |
|
| 74 | + * @param string $sql |
|
| 75 | + */ |
|
| 73 | 76 | private static function __query($sql) { |
| 74 | 77 | if ( !($res = pg_query(self::$__connection, $sql)) ) |
| 75 | 78 | throw new Exception(pg_last_error(self::$__connection)); |
| 76 | 79 | return $res; |
| 77 | 80 | } |
| 78 | 81 | |
| 82 | + /** |
|
| 83 | + * @param integer $page_num |
|
| 84 | + * @param string|null $data |
|
| 85 | + */ |
|
| 79 | 86 | static function store_page($id, $page_num, $data) { |
| 80 | 87 | $where = "WHERE id='" . pg_escape_string($id) . "' AND ". |
| 81 | 88 | "page_num=". pg_escape_string($page_num); |
@@ -1,41 +1,40 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
| 4 | - * |
|
| 5 | - * File: $RCSfile: page_cache.cls.php,v $ |
|
| 6 | - * Created on: 2004-07-23 |
|
| 7 | - * |
|
| 8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
| 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.dompdf.com/ |
|
| 32 | - * |
|
| 33 | - * @link http://www.dompdf.com/ |
|
| 34 | - * @copyright 2004 Benj Carson |
|
| 35 | - * @author Benj Carson <[email protected]> |
|
| 36 | - * @package dompdf |
|
| 37 | - |
|
| 38 | - */ |
|
| 3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
| 4 | + * |
|
| 5 | + * File: $RCSfile: page_cache.cls.php,v $ |
|
| 6 | + * Created on: 2004-07-23 |
|
| 7 | + * |
|
| 8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
| 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.dompdf.com/ |
|
| 32 | + * |
|
| 33 | + * @link http://www.dompdf.com/ |
|
| 34 | + * @copyright 2004 Benj Carson |
|
| 35 | + * @author Benj Carson <[email protected]> |
|
| 36 | + * @package dompdf |
|
| 37 | + */ |
|
| 39 | 38 | |
| 40 | 39 | /* $Id: page_cache.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
| 41 | 40 | |
@@ -50,59 +49,59 @@ discard block |
||
| 50 | 49 | */ |
| 51 | 50 | class Page_Cache { |
| 52 | 51 | |
| 53 | - const DB_USER = "dompdf_page_cache"; |
|
| 54 | - const DB_PASS = "some meaningful password"; |
|
| 55 | - const DB_NAME = "dompdf_page_cache"; |
|
| 52 | + const DB_USER = "dompdf_page_cache"; |
|
| 53 | + const DB_PASS = "some meaningful password"; |
|
| 54 | + const DB_NAME = "dompdf_page_cache"; |
|
| 56 | 55 | |
| 57 | - static private $__connection = null; |
|
| 56 | + static private $__connection = null; |
|
| 58 | 57 | |
| 59 | - function init() { |
|
| 58 | + function init() { |
|
| 60 | 59 | if ( is_null(self::$__connection) ) { |
| 61 | - $con_str = "host=" . DB_HOST . |
|
| 60 | + $con_str = "host=" . DB_HOST . |
|
| 62 | 61 | " dbname=" . self::DB_NAME . |
| 63 | 62 | " user=" . self::DB_USER . |
| 64 | 63 | " password=" . self::DB_PASS; |
| 65 | 64 | |
| 66 | - if ( !self::$__connection = pg_connect($con_str) ) |
|
| 65 | + if ( !self::$__connection = pg_connect($con_str) ) |
|
| 67 | 66 | throw new Exception("Database connection failed."); |
| 68 | 67 | } |
| 69 | - } |
|
| 68 | + } |
|
| 70 | 69 | |
| 71 | - function __construct() { throw new Exception("Can not create instance of Page_Class. Class is static."); } |
|
| 70 | + function __construct() { throw new Exception("Can not create instance of Page_Class. Class is static."); } |
|
| 72 | 71 | |
| 73 | - private static function __query($sql) { |
|
| 72 | + private static function __query($sql) { |
|
| 74 | 73 | if ( !($res = pg_query(self::$__connection, $sql)) ) |
| 75 | - throw new Exception(pg_last_error(self::$__connection)); |
|
| 74 | + throw new Exception(pg_last_error(self::$__connection)); |
|
| 76 | 75 | return $res; |
| 77 | - } |
|
| 76 | + } |
|
| 78 | 77 | |
| 79 | - static function store_page($id, $page_num, $data) { |
|
| 78 | + static function store_page($id, $page_num, $data) { |
|
| 80 | 79 | $where = "WHERE id='" . pg_escape_string($id) . "' AND ". |
| 81 | - "page_num=". pg_escape_string($page_num); |
|
| 80 | + "page_num=". pg_escape_string($page_num); |
|
| 82 | 81 | |
| 83 | 82 | $res = self::__query("SELECT timestamp FROM page_cache ". $where); |
| 84 | 83 | |
| 85 | 84 | $row = pg_fetch_assoc($res); |
| 86 | 85 | |
| 87 | 86 | if ( $row ) |
| 88 | - self::__query("UPDATE page_cache SET data='" . pg_escape_string($data) . "' " . $where); |
|
| 87 | + self::__query("UPDATE page_cache SET data='" . pg_escape_string($data) . "' " . $where); |
|
| 89 | 88 | else |
| 90 | - self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('" . pg_escape_string($id) . "', ". |
|
| 91 | - pg_escape_string($page_num) . ", ". |
|
| 92 | - "'". pg_escape_string($data) . "')"); |
|
| 89 | + self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('" . pg_escape_string($id) . "', ". |
|
| 90 | + pg_escape_string($page_num) . ", ". |
|
| 91 | + "'". pg_escape_string($data) . "')"); |
|
| 93 | 92 | |
| 94 | - } |
|
| 93 | + } |
|
| 95 | 94 | |
| 96 | - static function store_fonts($id, $fonts) { |
|
| 95 | + static function store_fonts($id, $fonts) { |
|
| 97 | 96 | self::__query("BEGIN"); |
| 98 | 97 | // Update the font information |
| 99 | 98 | self::__query("DELETE FROM page_fonts WHERE id='" . pg_escape_string($id) . "'"); |
| 100 | 99 | |
| 101 | 100 | foreach (array_keys($fonts) as $font) |
| 102 | - self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('" . |
|
| 101 | + self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('" . |
|
| 103 | 102 | pg_escape_string($id) . "', '" . pg_escape_string($font) . "')"); |
| 104 | 103 | self::__query("COMMIT"); |
| 105 | - } |
|
| 104 | + } |
|
| 106 | 105 | |
| 107 | 106 | // static function retrieve_page($id, $page_num) { |
| 108 | 107 | |
@@ -115,45 +114,45 @@ discard block |
||
| 115 | 114 | |
| 116 | 115 | // } |
| 117 | 116 | |
| 118 | - static function get_page_timestamp($id, $page_num) { |
|
| 117 | + static function get_page_timestamp($id, $page_num) { |
|
| 119 | 118 | $res = self::__query("SELECT timestamp FROM page_cache WHERE id='" . pg_escape_string($id) . "' AND ". |
| 120 | - "page_num=". pg_escape_string($page_num)); |
|
| 119 | + "page_num=". pg_escape_string($page_num)); |
|
| 121 | 120 | |
| 122 | 121 | $row = pg_fetch_assoc($res); |
| 123 | 122 | |
| 124 | 123 | return $row["timestamp"]; |
| 125 | 124 | |
| 126 | - } |
|
| 125 | + } |
|
| 127 | 126 | |
| 128 | - // Adds the cached document referenced by $id to the provided pdf |
|
| 129 | - static function insert_cached_document(CPDF_Adapter $pdf, $id, $new_page = true) { |
|
| 127 | + // Adds the cached document referenced by $id to the provided pdf |
|
| 128 | + static function insert_cached_document(CPDF_Adapter $pdf, $id, $new_page = true) { |
|
| 130 | 129 | $res = self::__query("SELECT font_name FROM page_fonts WHERE id='" . pg_escape_string($id) . "'"); |
| 131 | 130 | |
| 132 | 131 | // Ensure that the fonts needed by the cached document are loaded into |
| 133 | 132 | // the pdf |
| 134 | 133 | while ($row = pg_fetch_assoc($res)) |
| 135 | - $pdf->get_cpdf()->selectFont($row["font_name"]); |
|
| 134 | + $pdf->get_cpdf()->selectFont($row["font_name"]); |
|
| 136 | 135 | |
| 137 | 136 | $res = self::__query("SELECT data FROM page_cache WHERE id='" . pg_escape_string($id) . "'"); |
| 138 | 137 | |
| 139 | 138 | if ( $new_page ) |
| 140 | - $pdf->new_page(); |
|
| 139 | + $pdf->new_page(); |
|
| 141 | 140 | |
| 142 | 141 | $first = true; |
| 143 | 142 | while ($row = pg_fetch_assoc($res)) { |
| 144 | 143 | |
| 145 | - if ( !$first ) |
|
| 144 | + if ( !$first ) |
|
| 146 | 145 | $pdf->new_page(); |
| 147 | - else |
|
| 146 | + else |
|
| 148 | 147 | $first = false; |
| 149 | 148 | |
| 150 | - $page = $pdf->reopen_serialized_object($row["data"]); |
|
| 151 | - //$pdf->close_object(); |
|
| 152 | - $pdf->add_object($page, "add"); |
|
| 149 | + $page = $pdf->reopen_serialized_object($row["data"]); |
|
| 150 | + //$pdf->close_object(); |
|
| 151 | + $pdf->add_object($page, "add"); |
|
| 153 | 152 | |
| 154 | 153 | } |
| 155 | 154 | |
| 156 | - } |
|
| 155 | + } |
|
| 157 | 156 | } |
| 158 | 157 | |
| 159 | 158 | Page_Cache::init(); |
@@ -57,13 +57,13 @@ discard block |
||
| 57 | 57 | static private $__connection = null; |
| 58 | 58 | |
| 59 | 59 | function init() { |
| 60 | - if ( is_null(self::$__connection) ) { |
|
| 61 | - $con_str = "host=" . DB_HOST . |
|
| 62 | - " dbname=" . self::DB_NAME . |
|
| 63 | - " user=" . self::DB_USER . |
|
| 64 | - " password=" . self::DB_PASS; |
|
| 60 | + if (is_null(self::$__connection)) { |
|
| 61 | + $con_str = "host=".DB_HOST. |
|
| 62 | + " dbname=".self::DB_NAME. |
|
| 63 | + " user=".self::DB_USER. |
|
| 64 | + " password=".self::DB_PASS; |
|
| 65 | 65 | |
| 66 | - if ( !self::$__connection = pg_connect($con_str) ) |
|
| 66 | + if (!self::$__connection = pg_connect($con_str)) |
|
| 67 | 67 | throw new Exception("Database connection failed."); |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -71,36 +71,36 @@ discard block |
||
| 71 | 71 | function __construct() { throw new Exception("Can not create instance of Page_Class. Class is static."); } |
| 72 | 72 | |
| 73 | 73 | private static function __query($sql) { |
| 74 | - if ( !($res = pg_query(self::$__connection, $sql)) ) |
|
| 74 | + if (!($res = pg_query(self::$__connection, $sql))) |
|
| 75 | 75 | throw new Exception(pg_last_error(self::$__connection)); |
| 76 | 76 | return $res; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | static function store_page($id, $page_num, $data) { |
| 80 | - $where = "WHERE id='" . pg_escape_string($id) . "' AND ". |
|
| 81 | - "page_num=". pg_escape_string($page_num); |
|
| 80 | + $where = "WHERE id='".pg_escape_string($id)."' AND ". |
|
| 81 | + "page_num=".pg_escape_string($page_num); |
|
| 82 | 82 | |
| 83 | - $res = self::__query("SELECT timestamp FROM page_cache ". $where); |
|
| 83 | + $res = self::__query("SELECT timestamp FROM page_cache ".$where); |
|
| 84 | 84 | |
| 85 | 85 | $row = pg_fetch_assoc($res); |
| 86 | 86 | |
| 87 | - if ( $row ) |
|
| 88 | - self::__query("UPDATE page_cache SET data='" . pg_escape_string($data) . "' " . $where); |
|
| 87 | + if ($row) |
|
| 88 | + self::__query("UPDATE page_cache SET data='".pg_escape_string($data)."' ".$where); |
|
| 89 | 89 | else |
| 90 | - self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('" . pg_escape_string($id) . "', ". |
|
| 91 | - pg_escape_string($page_num) . ", ". |
|
| 92 | - "'". pg_escape_string($data) . "')"); |
|
| 90 | + self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('".pg_escape_string($id)."', ". |
|
| 91 | + pg_escape_string($page_num).", ". |
|
| 92 | + "'".pg_escape_string($data)."')"); |
|
| 93 | 93 | |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | static function store_fonts($id, $fonts) { |
| 97 | 97 | self::__query("BEGIN"); |
| 98 | 98 | // Update the font information |
| 99 | - self::__query("DELETE FROM page_fonts WHERE id='" . pg_escape_string($id) . "'"); |
|
| 99 | + self::__query("DELETE FROM page_fonts WHERE id='".pg_escape_string($id)."'"); |
|
| 100 | 100 | |
| 101 | 101 | foreach (array_keys($fonts) as $font) |
| 102 | - self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('" . |
|
| 103 | - pg_escape_string($id) . "', '" . pg_escape_string($font) . "')"); |
|
| 102 | + self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('". |
|
| 103 | + pg_escape_string($id)."', '".pg_escape_string($font)."')"); |
|
| 104 | 104 | self::__query("COMMIT"); |
| 105 | 105 | } |
| 106 | 106 | |
@@ -116,8 +116,8 @@ discard block |
||
| 116 | 116 | // } |
| 117 | 117 | |
| 118 | 118 | static function get_page_timestamp($id, $page_num) { |
| 119 | - $res = self::__query("SELECT timestamp FROM page_cache WHERE id='" . pg_escape_string($id) . "' AND ". |
|
| 120 | - "page_num=". pg_escape_string($page_num)); |
|
| 119 | + $res = self::__query("SELECT timestamp FROM page_cache WHERE id='".pg_escape_string($id)."' AND ". |
|
| 120 | + "page_num=".pg_escape_string($page_num)); |
|
| 121 | 121 | |
| 122 | 122 | $row = pg_fetch_assoc($res); |
| 123 | 123 | |
@@ -127,22 +127,22 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | // Adds the cached document referenced by $id to the provided pdf |
| 129 | 129 | static function insert_cached_document(CPDF_Adapter $pdf, $id, $new_page = true) { |
| 130 | - $res = self::__query("SELECT font_name FROM page_fonts WHERE id='" . pg_escape_string($id) . "'"); |
|
| 130 | + $res = self::__query("SELECT font_name FROM page_fonts WHERE id='".pg_escape_string($id)."'"); |
|
| 131 | 131 | |
| 132 | 132 | // Ensure that the fonts needed by the cached document are loaded into |
| 133 | 133 | // the pdf |
| 134 | 134 | while ($row = pg_fetch_assoc($res)) |
| 135 | 135 | $pdf->get_cpdf()->selectFont($row["font_name"]); |
| 136 | 136 | |
| 137 | - $res = self::__query("SELECT data FROM page_cache WHERE id='" . pg_escape_string($id) . "'"); |
|
| 137 | + $res = self::__query("SELECT data FROM page_cache WHERE id='".pg_escape_string($id)."'"); |
|
| 138 | 138 | |
| 139 | - if ( $new_page ) |
|
| 139 | + if ($new_page) |
|
| 140 | 140 | $pdf->new_page(); |
| 141 | 141 | |
| 142 | 142 | $first = true; |
| 143 | 143 | while ($row = pg_fetch_assoc($res)) { |
| 144 | 144 | |
| 145 | - if ( !$first ) |
|
| 145 | + if (!$first) |
|
| 146 | 146 | $pdf->new_page(); |
| 147 | 147 | else |
| 148 | 148 | $first = false; |
@@ -63,16 +63,18 @@ discard block |
||
| 63 | 63 | " user=" . self::DB_USER . |
| 64 | 64 | " password=" . self::DB_PASS; |
| 65 | 65 | |
| 66 | - if ( !self::$__connection = pg_connect($con_str) ) |
|
| 67 | - throw new Exception("Database connection failed."); |
|
| 66 | + if ( !self::$__connection = pg_connect($con_str) ) { |
|
| 67 | + throw new Exception("Database connection failed."); |
|
| 68 | + } |
|
| 68 | 69 | } |
| 69 | 70 | } |
| 70 | 71 | |
| 71 | 72 | function __construct() { throw new Exception("Can not create instance of Page_Class. Class is static."); } |
| 72 | 73 | |
| 73 | 74 | private static function __query($sql) { |
| 74 | - if ( !($res = pg_query(self::$__connection, $sql)) ) |
|
| 75 | - throw new Exception(pg_last_error(self::$__connection)); |
|
| 75 | + if ( !($res = pg_query(self::$__connection, $sql)) ) { |
|
| 76 | + throw new Exception(pg_last_error(self::$__connection)); |
|
| 77 | + } |
|
| 76 | 78 | return $res; |
| 77 | 79 | } |
| 78 | 80 | |
@@ -84,12 +86,13 @@ discard block |
||
| 84 | 86 | |
| 85 | 87 | $row = pg_fetch_assoc($res); |
| 86 | 88 | |
| 87 | - if ( $row ) |
|
| 88 | - self::__query("UPDATE page_cache SET data='" . pg_escape_string($data) . "' " . $where); |
|
| 89 | - else |
|
| 90 | - self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('" . pg_escape_string($id) . "', ". |
|
| 89 | + if ( $row ) { |
|
| 90 | + self::__query("UPDATE page_cache SET data='" . pg_escape_string($data) . "' " . $where); |
|
| 91 | + } else { |
|
| 92 | + self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('" . pg_escape_string($id) . "', ". |
|
| 91 | 93 | pg_escape_string($page_num) . ", ". |
| 92 | 94 | "'". pg_escape_string($data) . "')"); |
| 95 | + } |
|
| 93 | 96 | |
| 94 | 97 | } |
| 95 | 98 | |
@@ -98,9 +101,10 @@ discard block |
||
| 98 | 101 | // Update the font information |
| 99 | 102 | self::__query("DELETE FROM page_fonts WHERE id='" . pg_escape_string($id) . "'"); |
| 100 | 103 | |
| 101 | - foreach (array_keys($fonts) as $font) |
|
| 102 | - self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('" . |
|
| 104 | + foreach (array_keys($fonts) as $font) { |
|
| 105 | + self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('" . |
|
| 103 | 106 | pg_escape_string($id) . "', '" . pg_escape_string($font) . "')"); |
| 107 | + } |
|
| 104 | 108 | self::__query("COMMIT"); |
| 105 | 109 | } |
| 106 | 110 | |
@@ -131,21 +135,24 @@ discard block |
||
| 131 | 135 | |
| 132 | 136 | // Ensure that the fonts needed by the cached document are loaded into |
| 133 | 137 | // the pdf |
| 134 | - while ($row = pg_fetch_assoc($res)) |
|
| 135 | - $pdf->get_cpdf()->selectFont($row["font_name"]); |
|
| 138 | + while ($row = pg_fetch_assoc($res)) { |
|
| 139 | + $pdf->get_cpdf()->selectFont($row["font_name"]); |
|
| 140 | + } |
|
| 136 | 141 | |
| 137 | 142 | $res = self::__query("SELECT data FROM page_cache WHERE id='" . pg_escape_string($id) . "'"); |
| 138 | 143 | |
| 139 | - if ( $new_page ) |
|
| 140 | - $pdf->new_page(); |
|
| 144 | + if ( $new_page ) { |
|
| 145 | + $pdf->new_page(); |
|
| 146 | + } |
|
| 141 | 147 | |
| 142 | 148 | $first = true; |
| 143 | 149 | while ($row = pg_fetch_assoc($res)) { |
| 144 | 150 | |
| 145 | - if ( !$first ) |
|
| 146 | - $pdf->new_page(); |
|
| 147 | - else |
|
| 148 | - $first = false; |
|
| 151 | + if ( !$first ) { |
|
| 152 | + $pdf->new_page(); |
|
| 153 | + } else { |
|
| 154 | + $first = false; |
|
| 155 | + } |
|
| 149 | 156 | |
| 150 | 157 | $page = $pdf->reopen_serialized_object($row["data"]); |
| 151 | 158 | //$pdf->close_object(); |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * @link http://www.w3.org/TR/CSS21/page.html#forced |
| 172 | 172 | * |
| 173 | 173 | * @param Frame $frame the frame to check |
| 174 | - * @return bool true if a page break occured |
|
| 174 | + * @return null|boolean true if a page break occured |
|
| 175 | 175 | */ |
| 176 | 176 | function check_forced_page_break(Frame $frame) { |
| 177 | 177 | |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | * correct location. |
| 427 | 427 | * |
| 428 | 428 | * @param Frame $frame the frame to check |
| 429 | - * @return Frame the frame following the page break |
|
| 429 | + * @return boolean the frame following the page break |
|
| 430 | 430 | */ |
| 431 | 431 | function check_page_break(Frame $frame) { |
| 432 | 432 | // Do not split if we have already |
@@ -1,41 +1,40 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
| 4 | - * |
|
| 5 | - * File: $RCSfile: page_frame_decorator.cls.php,v $ |
|
| 6 | - * Created on: 2004-06-15 |
|
| 7 | - * |
|
| 8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
| 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.dompdf.com/ |
|
| 32 | - * |
|
| 33 | - * @link http://www.dompdf.com/ |
|
| 34 | - * @copyright 2004 Benj Carson |
|
| 35 | - * @author Benj Carson <[email protected]> |
|
| 36 | - * @package dompdf |
|
| 37 | - |
|
| 38 | - */ |
|
| 3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
| 4 | + * |
|
| 5 | + * File: $RCSfile: page_frame_decorator.cls.php,v $ |
|
| 6 | + * Created on: 2004-06-15 |
|
| 7 | + * |
|
| 8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
| 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.dompdf.com/ |
|
| 32 | + * |
|
| 33 | + * @link http://www.dompdf.com/ |
|
| 34 | + * @copyright 2004 Benj Carson |
|
| 35 | + * @author Benj Carson <[email protected]> |
|
| 36 | + * @package dompdf |
|
| 37 | + */ |
|
| 39 | 38 | |
| 40 | 39 | /* $Id: page_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
| 41 | 40 | |
@@ -47,137 +46,137 @@ discard block |
||
| 47 | 46 | */ |
| 48 | 47 | class Page_Frame_Decorator extends Frame_Decorator { |
| 49 | 48 | |
| 50 | - /** |
|
| 51 | - * y value of bottom page margin |
|
| 52 | - * |
|
| 53 | - * @var float |
|
| 54 | - */ |
|
| 55 | - protected $_bottom_page_margin; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Flag indicating page is full. |
|
| 59 | - * |
|
| 60 | - * @var bool |
|
| 61 | - */ |
|
| 62 | - protected $_page_full; |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Number of tables currently being reflowed |
|
| 66 | - * |
|
| 67 | - * @var int |
|
| 68 | - */ |
|
| 69 | - protected $_in_table; |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * The pdf renderer |
|
| 73 | - * |
|
| 74 | - * @var Renderer |
|
| 75 | - */ |
|
| 76 | - protected $_renderer; |
|
| 77 | - |
|
| 78 | - //........................................................................ |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * Class constructor |
|
| 82 | - * |
|
| 83 | - * @param Frame $frame the frame to decorate |
|
| 84 | - */ |
|
| 85 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
| 49 | + /** |
|
| 50 | + * y value of bottom page margin |
|
| 51 | + * |
|
| 52 | + * @var float |
|
| 53 | + */ |
|
| 54 | + protected $_bottom_page_margin; |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * Flag indicating page is full. |
|
| 58 | + * |
|
| 59 | + * @var bool |
|
| 60 | + */ |
|
| 61 | + protected $_page_full; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Number of tables currently being reflowed |
|
| 65 | + * |
|
| 66 | + * @var int |
|
| 67 | + */ |
|
| 68 | + protected $_in_table; |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * The pdf renderer |
|
| 72 | + * |
|
| 73 | + * @var Renderer |
|
| 74 | + */ |
|
| 75 | + protected $_renderer; |
|
| 76 | + |
|
| 77 | + //........................................................................ |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Class constructor |
|
| 81 | + * |
|
| 82 | + * @param Frame $frame the frame to decorate |
|
| 83 | + */ |
|
| 84 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
| 86 | 85 | parent::__construct($frame, $dompdf); |
| 87 | 86 | $this->_page_full = false; |
| 88 | 87 | $this->_in_table = 0; |
| 89 | 88 | $this->_bottom_page_margin = null; |
| 90 | - } |
|
| 89 | + } |
|
| 91 | 90 | |
| 92 | 91 | |
| 93 | - /** |
|
| 94 | - * Set the renderer used for this pdf |
|
| 95 | - * |
|
| 96 | - * @param Renderer $renderer the renderer to use |
|
| 97 | - */ |
|
| 98 | - function set_renderer($renderer) { |
|
| 92 | + /** |
|
| 93 | + * Set the renderer used for this pdf |
|
| 94 | + * |
|
| 95 | + * @param Renderer $renderer the renderer to use |
|
| 96 | + */ |
|
| 97 | + function set_renderer($renderer) { |
|
| 99 | 98 | $this->_renderer = $renderer; |
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Return the renderer used for this pdf |
|
| 104 | - * |
|
| 105 | - * @return Renderer |
|
| 106 | - */ |
|
| 107 | - function get_renderer() { |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * Return the renderer used for this pdf |
|
| 103 | + * |
|
| 104 | + * @return Renderer |
|
| 105 | + */ |
|
| 106 | + function get_renderer() { |
|
| 108 | 107 | return $this->_renderer; |
| 109 | - } |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * Set the frame's containing block. Overridden to set $this->_bottom_page_margin. |
|
| 113 | - * |
|
| 114 | - * @param float $x |
|
| 115 | - * @param float $y |
|
| 116 | - * @param float $w |
|
| 117 | - * @param float $h |
|
| 118 | - */ |
|
| 119 | - function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * Set the frame's containing block. Overridden to set $this->_bottom_page_margin. |
|
| 112 | + * |
|
| 113 | + * @param float $x |
|
| 114 | + * @param float $y |
|
| 115 | + * @param float $w |
|
| 116 | + * @param float $h |
|
| 117 | + */ |
|
| 118 | + function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
|
| 120 | 119 | parent::set_containing_block($x,$y,$w,$h); |
| 121 | 120 | $w = $this->get_containing_block("w"); |
| 122 | 121 | if ( isset($h) ) |
| 123 | - $this->_bottom_page_margin = $h; // - $this->_frame->get_style()->length_in_pt($this->_frame->get_style()->margin_bottom, $w); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * Returns true if the page is full and is no longer accepting frames. |
|
| 128 | - * |
|
| 129 | - * @return bool |
|
| 130 | - */ |
|
| 131 | - function is_full() { |
|
| 122 | + $this->_bottom_page_margin = $h; // - $this->_frame->get_style()->length_in_pt($this->_frame->get_style()->margin_bottom, $w); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * Returns true if the page is full and is no longer accepting frames. |
|
| 127 | + * |
|
| 128 | + * @return bool |
|
| 129 | + */ |
|
| 130 | + function is_full() { |
|
| 132 | 131 | return $this->_page_full; |
| 133 | - } |
|
| 132 | + } |
|
| 134 | 133 | |
| 135 | - /** |
|
| 136 | - * Start a new page by resetting the full flag. |
|
| 137 | - */ |
|
| 138 | - function next_page() { |
|
| 134 | + /** |
|
| 135 | + * Start a new page by resetting the full flag. |
|
| 136 | + */ |
|
| 137 | + function next_page() { |
|
| 139 | 138 | $this->_renderer->new_page(); |
| 140 | 139 | $this->_page_full = false; |
| 141 | - } |
|
| 140 | + } |
|
| 142 | 141 | |
| 143 | - /** |
|
| 144 | - * Indicate to the page that a table is currently being reflowed. |
|
| 145 | - */ |
|
| 146 | - function table_reflow_start() { |
|
| 142 | + /** |
|
| 143 | + * Indicate to the page that a table is currently being reflowed. |
|
| 144 | + */ |
|
| 145 | + function table_reflow_start() { |
|
| 147 | 146 | $this->_in_table++; |
| 148 | - } |
|
| 147 | + } |
|
| 149 | 148 | |
| 150 | - /** |
|
| 151 | - * Indicate to the page that table reflow is finished. |
|
| 152 | - */ |
|
| 153 | - function table_reflow_end() { |
|
| 149 | + /** |
|
| 150 | + * Indicate to the page that table reflow is finished. |
|
| 151 | + */ |
|
| 152 | + function table_reflow_end() { |
|
| 154 | 153 | $this->_in_table--; |
| 155 | - } |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * Return whether we are currently in a nested table or not |
|
| 159 | - * |
|
| 160 | - * @return bool |
|
| 161 | - */ |
|
| 162 | - function in_nested_table() { |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * Return whether we are currently in a nested table or not |
|
| 158 | + * |
|
| 159 | + * @return bool |
|
| 160 | + */ |
|
| 161 | + function in_nested_table() { |
|
| 163 | 162 | return $this->_in_table > 1; |
| 164 | - } |
|
| 163 | + } |
|
| 165 | 164 | |
| 166 | - /** |
|
| 167 | - * Check if a forced page break is required before $frame. This uses the |
|
| 168 | - * frame's page_break_before property as well as the preceeding frame's |
|
| 169 | - * page_break_after property. |
|
| 170 | - * |
|
| 171 | - * @link http://www.w3.org/TR/CSS21/page.html#forced |
|
| 172 | - * |
|
| 173 | - * @param Frame $frame the frame to check |
|
| 174 | - * @return bool true if a page break occured |
|
| 175 | - */ |
|
| 176 | - function check_forced_page_break(Frame $frame) { |
|
| 165 | + /** |
|
| 166 | + * Check if a forced page break is required before $frame. This uses the |
|
| 167 | + * frame's page_break_before property as well as the preceeding frame's |
|
| 168 | + * page_break_after property. |
|
| 169 | + * |
|
| 170 | + * @link http://www.w3.org/TR/CSS21/page.html#forced |
|
| 171 | + * |
|
| 172 | + * @param Frame $frame the frame to check |
|
| 173 | + * @return bool true if a page break occured |
|
| 174 | + */ |
|
| 175 | + function check_forced_page_break(Frame $frame) { |
|
| 177 | 176 | |
| 178 | 177 | // Skip check if page is already split |
| 179 | 178 | if ( $this->_page_full ) |
| 180 | - return; |
|
| 179 | + return; |
|
| 181 | 180 | |
| 182 | 181 | $block_types = array("block", "list-item", "table"); |
| 183 | 182 | $page_breaks = array("always", "left", "right"); |
@@ -185,42 +184,42 @@ discard block |
||
| 185 | 184 | $style = $frame->get_style(); |
| 186 | 185 | |
| 187 | 186 | if ( !in_array($style->display, $block_types) ) |
| 188 | - return false; |
|
| 187 | + return false; |
|
| 189 | 188 | |
| 190 | 189 | // Find the previous block-level sibling |
| 191 | 190 | $prev = $frame->get_prev_sibling(); |
| 192 | 191 | while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
| 193 | - $prev = $prev->get_prev_sibling(); |
|
| 192 | + $prev = $prev->get_prev_sibling(); |
|
| 194 | 193 | |
| 195 | 194 | if ( in_array($style->page_break_before, $page_breaks) ) { |
| 196 | 195 | |
| 197 | - // Prevent cascading splits |
|
| 198 | - $frame->split(); |
|
| 199 | - // We have to grab the style again here because split() resets |
|
| 200 | - // $frame->style to the frame's orignal style. |
|
| 201 | - $frame->get_style()->page_break_before = "auto"; |
|
| 202 | - $this->_page_full = true; |
|
| 203 | - return true; |
|
| 196 | + // Prevent cascading splits |
|
| 197 | + $frame->split(); |
|
| 198 | + // We have to grab the style again here because split() resets |
|
| 199 | + // $frame->style to the frame's orignal style. |
|
| 200 | + $frame->get_style()->page_break_before = "auto"; |
|
| 201 | + $this->_page_full = true; |
|
| 202 | + return true; |
|
| 204 | 203 | } |
| 205 | 204 | |
| 206 | 205 | if ( ($prev && in_array($prev->get_style()->page_break_after, $page_breaks)) ) { |
| 207 | - // Prevent cascading splits |
|
| 208 | - $frame->split(); |
|
| 209 | - $prev->get_style()->page_break_after = "auto"; |
|
| 210 | - $this->_page_full = true; |
|
| 211 | - return true; |
|
| 206 | + // Prevent cascading splits |
|
| 207 | + $frame->split(); |
|
| 208 | + $prev->get_style()->page_break_after = "auto"; |
|
| 209 | + $this->_page_full = true; |
|
| 210 | + return true; |
|
| 212 | 211 | } |
| 213 | 212 | |
| 214 | 213 | return false; |
| 215 | - } |
|
| 216 | - |
|
| 217 | - /** |
|
| 218 | - * Determine if a page break is allowed before $frame |
|
| 219 | - * |
|
| 220 | - * @param Frame $frame the frame to check |
|
| 221 | - * @return bool true if a break is allowed, false otherwise |
|
| 222 | - */ |
|
| 223 | - protected function _page_break_allowed(Frame $frame) { |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + /** |
|
| 217 | + * Determine if a page break is allowed before $frame |
|
| 218 | + * |
|
| 219 | + * @param Frame $frame the frame to check |
|
| 220 | + * @return bool true if a break is allowed, false otherwise |
|
| 221 | + */ |
|
| 222 | + protected function _page_break_allowed(Frame $frame) { |
|
| 224 | 223 | /** |
| 225 | 224 | * |
| 226 | 225 | * http://www.w3.org/TR/CSS21/page.html#allowed-page-breaks |
@@ -276,162 +275,162 @@ discard block |
||
| 276 | 275 | // Block Frames (1): |
| 277 | 276 | if ( in_array($display, $block_types) ) { |
| 278 | 277 | |
| 279 | - // Avoid breaks within table-cells |
|
| 280 | - if ( $this->_in_table ) { |
|
| 278 | + // Avoid breaks within table-cells |
|
| 279 | + if ( $this->_in_table ) { |
|
| 281 | 280 | dompdf_debug("page-break", "In table: " . $this->_in_table); |
| 282 | 281 | return false; |
| 283 | - } |
|
| 282 | + } |
|
| 284 | 283 | |
| 285 | - // Rules A & B |
|
| 284 | + // Rules A & B |
|
| 286 | 285 | |
| 287 | - if ( $frame->get_style()->page_break_before === "avoid" ) { |
|
| 286 | + if ( $frame->get_style()->page_break_before === "avoid" ) { |
|
| 288 | 287 | dompdf_debug("page-break", "before: avoid"); |
| 289 | 288 | return false; |
| 290 | - } |
|
| 289 | + } |
|
| 291 | 290 | |
| 292 | - // Find the preceeding block-level sibling |
|
| 293 | - $prev = $frame->get_prev_sibling(); |
|
| 294 | - while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
|
| 291 | + // Find the preceeding block-level sibling |
|
| 292 | + $prev = $frame->get_prev_sibling(); |
|
| 293 | + while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
|
| 295 | 294 | $prev = $prev->get_prev_sibling(); |
| 296 | 295 | |
| 297 | - // Does the previous element allow a page break after? |
|
| 298 | - if ( $prev && $prev->get_style()->page_break_after === "avoid" ) { |
|
| 296 | + // Does the previous element allow a page break after? |
|
| 297 | + if ( $prev && $prev->get_style()->page_break_after === "avoid" ) { |
|
| 299 | 298 | dompdf_debug("page-break", "after: avoid"); |
| 300 | 299 | return false; |
| 301 | - } |
|
| 300 | + } |
|
| 302 | 301 | |
| 303 | - // If both $prev & $frame have the same parent, check the parent's |
|
| 304 | - // page_break_inside property. |
|
| 305 | - $parent = $frame->get_parent(); |
|
| 306 | - if ( $prev && $parent && $parent->get_style()->page_break_inside === "avoid" ) { |
|
| 307 | - dompdf_debug("page-break", "parent inside: avoid"); |
|
| 302 | + // If both $prev & $frame have the same parent, check the parent's |
|
| 303 | + // page_break_inside property. |
|
| 304 | + $parent = $frame->get_parent(); |
|
| 305 | + if ( $prev && $parent && $parent->get_style()->page_break_inside === "avoid" ) { |
|
| 306 | + dompdf_debug("page-break", "parent inside: avoid"); |
|
| 308 | 307 | return false; |
| 309 | - } |
|
| 308 | + } |
|
| 310 | 309 | |
| 311 | - // To prevent cascading page breaks when a top-level element has |
|
| 312 | - // page-break-inside: avoid, ensure that at least one frame is |
|
| 313 | - // on the page before splitting. |
|
| 314 | - if ( $parent->get_node()->nodeName === "body" && !$prev ) { |
|
| 310 | + // To prevent cascading page breaks when a top-level element has |
|
| 311 | + // page-break-inside: avoid, ensure that at least one frame is |
|
| 312 | + // on the page before splitting. |
|
| 313 | + if ( $parent->get_node()->nodeName === "body" && !$prev ) { |
|
| 315 | 314 | // We are the body's first child |
| 316 | - dompdf_debug("page-break", "Body's first child."); |
|
| 315 | + dompdf_debug("page-break", "Body's first child."); |
|
| 317 | 316 | return false; |
| 318 | - } |
|
| 317 | + } |
|
| 319 | 318 | |
| 320 | - // If the frame is the first block-level frame, use the value from |
|
| 321 | - // $frame's parent instead. |
|
| 322 | - if ( !$prev && $parent ) |
|
| 319 | + // If the frame is the first block-level frame, use the value from |
|
| 320 | + // $frame's parent instead. |
|
| 321 | + if ( !$prev && $parent ) |
|
| 323 | 322 | return $this->_page_break_allowed( $parent ); |
| 324 | 323 | |
| 325 | - dompdf_debug("page-break", "block: break allowed"); |
|
| 326 | - return true; |
|
| 324 | + dompdf_debug("page-break", "block: break allowed"); |
|
| 325 | + return true; |
|
| 327 | 326 | |
| 328 | 327 | } |
| 329 | 328 | |
| 330 | 329 | // Inline frames (2): |
| 331 | 330 | else if ( in_array($display, Style::$INLINE_TYPES) ) { |
| 332 | 331 | |
| 333 | - // Avoid breaks within table-cells |
|
| 334 | - if ( $this->_in_table ) { |
|
| 335 | - dompdf_debug("page-break", "In table: " . $this->_in_table); |
|
| 332 | + // Avoid breaks within table-cells |
|
| 333 | + if ( $this->_in_table ) { |
|
| 334 | + dompdf_debug("page-break", "In table: " . $this->_in_table); |
|
| 336 | 335 | return false; |
| 337 | - } |
|
| 336 | + } |
|
| 338 | 337 | |
| 339 | - // Rule C |
|
| 340 | - $block_parent = $frame->find_block_parent(); |
|
| 341 | - if ( count($block_parent->get_lines() ) < $frame->get_style()->orphans ) { |
|
| 342 | - dompdf_debug("page-break", "orphans"); |
|
| 338 | + // Rule C |
|
| 339 | + $block_parent = $frame->find_block_parent(); |
|
| 340 | + if ( count($block_parent->get_lines() ) < $frame->get_style()->orphans ) { |
|
| 341 | + dompdf_debug("page-break", "orphans"); |
|
| 343 | 342 | return false; |
| 344 | - } |
|
| 343 | + } |
|
| 345 | 344 | |
| 346 | - // FIXME: Checking widows is tricky without having laid out the |
|
| 347 | - // remaining line boxes. Just ignore it for now... |
|
| 345 | + // FIXME: Checking widows is tricky without having laid out the |
|
| 346 | + // remaining line boxes. Just ignore it for now... |
|
| 348 | 347 | |
| 349 | - // Rule D |
|
| 350 | - $p = $block_parent; |
|
| 351 | - while ($p) { |
|
| 348 | + // Rule D |
|
| 349 | + $p = $block_parent; |
|
| 350 | + while ($p) { |
|
| 352 | 351 | if ( $p->get_style()->page_break_inside === "avoid" ) { |
| 353 | - dompdf_debug("page-break", "parent->inside: avoid"); |
|
| 354 | - return false; |
|
| 352 | + dompdf_debug("page-break", "parent->inside: avoid"); |
|
| 353 | + return false; |
|
| 355 | 354 | } |
| 356 | 355 | $p = $p->find_block_parent(); |
| 357 | - } |
|
| 356 | + } |
|
| 358 | 357 | |
| 359 | - // To prevent cascading page breaks when a top-level element has |
|
| 360 | - // page-break-inside: avoid, ensure that at least one frame with |
|
| 361 | - // some content is on the page before splitting. |
|
| 362 | - $prev = $frame->get_prev_sibling(); |
|
| 363 | - while ( $prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "") ) |
|
| 358 | + // To prevent cascading page breaks when a top-level element has |
|
| 359 | + // page-break-inside: avoid, ensure that at least one frame with |
|
| 360 | + // some content is on the page before splitting. |
|
| 361 | + $prev = $frame->get_prev_sibling(); |
|
| 362 | + while ( $prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "") ) |
|
| 364 | 363 | $prev = $prev->get_prev_sibling(); |
| 365 | 364 | |
| 366 | - if ( $block_parent->get_node()->nodeName === "body" && !$prev ) { |
|
| 365 | + if ( $block_parent->get_node()->nodeName === "body" && !$prev ) { |
|
| 367 | 366 | // We are the body's first child |
| 368 | - dompdf_debug("page-break", "Body's first child."); |
|
| 367 | + dompdf_debug("page-break", "Body's first child."); |
|
| 369 | 368 | return false; |
| 370 | - } |
|
| 369 | + } |
|
| 371 | 370 | |
| 372 | - // Skip breaks on empty text nodes |
|
| 373 | - if ( $frame->get_node()->nodeName === "#text" && |
|
| 371 | + // Skip breaks on empty text nodes |
|
| 372 | + if ( $frame->get_node()->nodeName === "#text" && |
|
| 374 | 373 | $frame->get_node()->nodeValue == "" ) |
| 375 | 374 | return false; |
| 376 | 375 | |
| 377 | - dompdf_debug("page-break", "inline: break allowed"); |
|
| 378 | - return true; |
|
| 376 | + dompdf_debug("page-break", "inline: break allowed"); |
|
| 377 | + return true; |
|
| 379 | 378 | |
| 380 | 379 | // Table-rows |
| 381 | 380 | } else if ( $display === "table-row" ) { |
| 382 | 381 | |
| 383 | - // Simply check if the parent table's page_break_inside property is |
|
| 384 | - // not 'avoid' |
|
| 385 | - $p = Table_Frame_Decorator::find_parent_table($frame); |
|
| 382 | + // Simply check if the parent table's page_break_inside property is |
|
| 383 | + // not 'avoid' |
|
| 384 | + $p = Table_Frame_Decorator::find_parent_table($frame); |
|
| 386 | 385 | |
| 387 | - while ($p) { |
|
| 386 | + while ($p) { |
|
| 388 | 387 | if ( $p->get_style()->page_break_inside === "avoid" ) { |
| 389 | - dompdf_debug("page-break", "parent->inside: avoid"); |
|
| 390 | - return false; |
|
| 388 | + dompdf_debug("page-break", "parent->inside: avoid"); |
|
| 389 | + return false; |
|
| 391 | 390 | } |
| 392 | 391 | $p = $p->find_block_parent(); |
| 393 | - } |
|
| 392 | + } |
|
| 394 | 393 | |
| 395 | - // Avoid breaking after the first row of a table |
|
| 396 | - if ( $p && $p->get_first_child() === $frame) { |
|
| 397 | - dompdf_debug("page-break", "table: first-row"); |
|
| 394 | + // Avoid breaking after the first row of a table |
|
| 395 | + if ( $p && $p->get_first_child() === $frame) { |
|
| 396 | + dompdf_debug("page-break", "table: first-row"); |
|
| 398 | 397 | return false; |
| 399 | - } |
|
| 398 | + } |
|
| 400 | 399 | |
| 401 | - // If this is a nested table, prevent the page from breaking |
|
| 402 | - if ( $this->_in_table > 1 ) { |
|
| 400 | + // If this is a nested table, prevent the page from breaking |
|
| 401 | + if ( $this->_in_table > 1 ) { |
|
| 403 | 402 | dompdf_debug("page-break", "table: nested table"); |
| 404 | 403 | return false; |
| 405 | - } |
|
| 404 | + } |
|
| 406 | 405 | |
| 407 | - dompdf_debug("page-break","table-row/row-groups: break allowed"); |
|
| 408 | - return true; |
|
| 406 | + dompdf_debug("page-break","table-row/row-groups: break allowed"); |
|
| 407 | + return true; |
|
| 409 | 408 | |
| 410 | 409 | } else if ( in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) { |
| 411 | 410 | |
| 412 | - // Disallow breaks at row-groups: only split at row boundaries |
|
| 413 | - return false; |
|
| 411 | + // Disallow breaks at row-groups: only split at row boundaries |
|
| 412 | + return false; |
|
| 414 | 413 | |
| 415 | 414 | } else { |
| 416 | 415 | |
| 417 | - dompdf_debug("page-break", "? " . $frame->get_style()->display . ""); |
|
| 418 | - return false; |
|
| 416 | + dompdf_debug("page-break", "? " . $frame->get_style()->display . ""); |
|
| 417 | + return false; |
|
| 418 | + } |
|
| 419 | + |
|
| 419 | 420 | } |
| 420 | 421 | |
| 421 | - } |
|
| 422 | - |
|
| 423 | - /** |
|
| 424 | - * Check if $frame will fit on the page. If the frame does not fit, |
|
| 425 | - * the frame tree is modified so that a page break occurs in the |
|
| 426 | - * correct location. |
|
| 427 | - * |
|
| 428 | - * @param Frame $frame the frame to check |
|
| 429 | - * @return Frame the frame following the page break |
|
| 430 | - */ |
|
| 431 | - function check_page_break(Frame $frame) { |
|
| 422 | + /** |
|
| 423 | + * Check if $frame will fit on the page. If the frame does not fit, |
|
| 424 | + * the frame tree is modified so that a page break occurs in the |
|
| 425 | + * correct location. |
|
| 426 | + * |
|
| 427 | + * @param Frame $frame the frame to check |
|
| 428 | + * @return Frame the frame following the page break |
|
| 429 | + */ |
|
| 430 | + function check_page_break(Frame $frame) { |
|
| 432 | 431 | // Do not split if we have already |
| 433 | 432 | if ( $this->_page_full ) |
| 434 | - return false; |
|
| 433 | + return false; |
|
| 435 | 434 | |
| 436 | 435 | // Determine the frame's maximum y value |
| 437 | 436 | $max_y = $frame->get_position("y") + $frame->get_margin_height(); |
@@ -440,18 +439,18 @@ discard block |
||
| 440 | 439 | // parents of $frame must fit on the page as well: |
| 441 | 440 | $p = $frame->get_parent(); |
| 442 | 441 | while ( $p ) { |
| 443 | - $style = $p->get_style(); |
|
| 444 | - $max_y += $style->length_in_pt(array($style->margin_bottom, |
|
| 445 | - $style->padding_bottom, |
|
| 446 | - $style->border_bottom_width)); |
|
| 447 | - $p = $p->get_parent(); |
|
| 442 | + $style = $p->get_style(); |
|
| 443 | + $max_y += $style->length_in_pt(array($style->margin_bottom, |
|
| 444 | + $style->padding_bottom, |
|
| 445 | + $style->border_bottom_width)); |
|
| 446 | + $p = $p->get_parent(); |
|
| 448 | 447 | } |
| 449 | 448 | |
| 450 | 449 | |
| 451 | 450 | // Check if $frame flows off the page |
| 452 | 451 | if ( $max_y <= $this->_bottom_page_margin ) |
| 453 | - // no: do nothing |
|
| 454 | - return false; |
|
| 452 | + // no: do nothing |
|
| 453 | + return false; |
|
| 455 | 454 | |
| 456 | 455 | dompdf_debug("page-break", "check_page_break"); |
| 457 | 456 | dompdf_debug("page-break", "in_table: " . $this->_in_table); |
@@ -466,58 +465,58 @@ discard block |
||
| 466 | 465 | dompdf_debug("page-break","Starting search"); |
| 467 | 466 | while ( $iter ) { |
| 468 | 467 | // echo "\nbacktrack: " .$iter->get_node()->nodeName ." ".spl_object_hash($iter->get_node()). ""; |
| 469 | - if ( $iter === $this ) { |
|
| 470 | - dompdf_debug("page-break", "reached root."); |
|
| 468 | + if ( $iter === $this ) { |
|
| 469 | + dompdf_debug("page-break", "reached root."); |
|
| 471 | 470 | // We've reached the root in our search. Just split at $frame. |
| 472 | 471 | break; |
| 473 | - } |
|
| 472 | + } |
|
| 474 | 473 | |
| 475 | - if ( $this->_page_break_allowed($iter) ) { |
|
| 474 | + if ( $this->_page_break_allowed($iter) ) { |
|
| 476 | 475 | dompdf_debug("page-break","break allowed, splitting."); |
| 477 | 476 | $iter->split(); |
| 478 | 477 | $this->_page_full = true; |
| 479 | 478 | $this->_in_table = $in_table; |
| 480 | 479 | return true; |
| 481 | - } |
|
| 480 | + } |
|
| 482 | 481 | |
| 483 | - if ( !$flg && $next = $iter->get_last_child() ) { |
|
| 484 | - dompdf_debug("page-break", "following last child."); |
|
| 482 | + if ( !$flg && $next = $iter->get_last_child() ) { |
|
| 483 | + dompdf_debug("page-break", "following last child."); |
|
| 485 | 484 | |
| 486 | 485 | if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) ) |
| 487 | - $this->_in_table++; |
|
| 486 | + $this->_in_table++; |
|
| 488 | 487 | |
| 489 | 488 | $iter = $next; |
| 490 | 489 | continue; |
| 491 | - } |
|
| 490 | + } |
|
| 492 | 491 | |
| 493 | - if ( $next = $iter->get_prev_sibling() ) { |
|
| 494 | - dompdf_debug("page-break", "following prev sibling."); |
|
| 492 | + if ( $next = $iter->get_prev_sibling() ) { |
|
| 493 | + dompdf_debug("page-break", "following prev sibling."); |
|
| 495 | 494 | |
| 496 | 495 | if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
| 497 | 496 | !in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
| 498 | - $this->_in_table++; |
|
| 497 | + $this->_in_table++; |
|
| 499 | 498 | |
| 500 | 499 | else if ( !in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
| 501 | 500 | in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
| 502 | - $this->_in_table--; |
|
| 501 | + $this->_in_table--; |
|
| 503 | 502 | |
| 504 | 503 | $iter = $next; |
| 505 | 504 | $flg = false; |
| 506 | 505 | continue; |
| 507 | - } |
|
| 506 | + } |
|
| 508 | 507 | |
| 509 | - if ( $next = $iter->get_parent() ) { |
|
| 510 | - dompdf_debug("page-break", "following parent."); |
|
| 508 | + if ( $next = $iter->get_parent() ) { |
|
| 509 | + dompdf_debug("page-break", "following parent."); |
|
| 511 | 510 | |
| 512 | 511 | if ( in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
| 513 | - $this->_in_table--; |
|
| 512 | + $this->_in_table--; |
|
| 514 | 513 | |
| 515 | 514 | $iter = $next; |
| 516 | 515 | $flg = true; |
| 517 | 516 | continue; |
| 518 | - } |
|
| 517 | + } |
|
| 519 | 518 | |
| 520 | - break; |
|
| 519 | + break; |
|
| 521 | 520 | |
| 522 | 521 | } |
| 523 | 522 | |
@@ -528,33 +527,33 @@ discard block |
||
| 528 | 527 | |
| 529 | 528 | // If we are in a table, backtrack to the nearest top-level table row |
| 530 | 529 | if ( $this->_in_table ) { |
| 531 | - $num_tables = $this->_in_table - 1; |
|
| 530 | + $num_tables = $this->_in_table - 1; |
|
| 532 | 531 | |
| 533 | - $iter = $frame; |
|
| 534 | - while ( $iter && $num_tables && $iter->get_style->display !== "table" ) { |
|
| 532 | + $iter = $frame; |
|
| 533 | + while ( $iter && $num_tables && $iter->get_style->display !== "table" ) { |
|
| 535 | 534 | $iter = $iter->get_parent(); |
| 536 | 535 | $num_tables--; |
| 537 | - } |
|
| 536 | + } |
|
| 538 | 537 | |
| 539 | - $iter = $frame; |
|
| 540 | - while ($iter && $iter->get_style()->display !== "table-row" ) |
|
| 538 | + $iter = $frame; |
|
| 539 | + while ($iter && $iter->get_style()->display !== "table-row" ) |
|
| 541 | 540 | $iter = $iter->get_parent(); |
| 542 | 541 | |
| 543 | - $iter->split(); |
|
| 544 | - $this->_page_full = true; |
|
| 545 | - return true; |
|
| 542 | + $iter->split(); |
|
| 543 | + $this->_page_full = true; |
|
| 544 | + return true; |
|
| 546 | 545 | } |
| 547 | 546 | |
| 548 | 547 | $frame->split(); |
| 549 | 548 | $this->_page_full = true; |
| 550 | 549 | return true; |
| 551 | 550 | |
| 552 | - } |
|
| 551 | + } |
|
| 553 | 552 | |
| 554 | - //........................................................................ |
|
| 553 | + //........................................................................ |
|
| 555 | 554 | |
| 556 | - function split($frame = null) { |
|
| 555 | + function split($frame = null) { |
|
| 557 | 556 | // Do nothing |
| 558 | - } |
|
| 557 | + } |
|
| 559 | 558 | |
| 560 | 559 | } |
@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | * @param float $h |
| 118 | 118 | */ |
| 119 | 119 | function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
| 120 | - parent::set_containing_block($x,$y,$w,$h); |
|
| 120 | + parent::set_containing_block($x, $y, $w, $h); |
|
| 121 | 121 | $w = $this->get_containing_block("w"); |
| 122 | - if ( isset($h) ) |
|
| 122 | + if (isset($h)) |
|
| 123 | 123 | $this->_bottom_page_margin = $h; // - $this->_frame->get_style()->length_in_pt($this->_frame->get_style()->margin_bottom, $w); |
| 124 | 124 | } |
| 125 | 125 | |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | function check_forced_page_break(Frame $frame) { |
| 177 | 177 | |
| 178 | 178 | // Skip check if page is already split |
| 179 | - if ( $this->_page_full ) |
|
| 179 | + if ($this->_page_full) |
|
| 180 | 180 | return; |
| 181 | 181 | |
| 182 | 182 | $block_types = array("block", "list-item", "table"); |
@@ -184,15 +184,15 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | $style = $frame->get_style(); |
| 186 | 186 | |
| 187 | - if ( !in_array($style->display, $block_types) ) |
|
| 187 | + if (!in_array($style->display, $block_types)) |
|
| 188 | 188 | return false; |
| 189 | 189 | |
| 190 | 190 | // Find the previous block-level sibling |
| 191 | 191 | $prev = $frame->get_prev_sibling(); |
| 192 | - while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
|
| 192 | + while ($prev && !in_array($prev->get_style()->display, $block_types)) |
|
| 193 | 193 | $prev = $prev->get_prev_sibling(); |
| 194 | 194 | |
| 195 | - if ( in_array($style->page_break_before, $page_breaks) ) { |
|
| 195 | + if (in_array($style->page_break_before, $page_breaks)) { |
|
| 196 | 196 | |
| 197 | 197 | // Prevent cascading splits |
| 198 | 198 | $frame->split(); |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | return true; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - if ( ($prev && in_array($prev->get_style()->page_break_after, $page_breaks)) ) { |
|
| 206 | + if (($prev && in_array($prev->get_style()->page_break_after, $page_breaks))) { |
|
| 207 | 207 | // Prevent cascading splits |
| 208 | 208 | $frame->split(); |
| 209 | 209 | $prev->get_style()->page_break_after = "auto"; |
@@ -270,32 +270,32 @@ discard block |
||
| 270 | 270 | */ |
| 271 | 271 | |
| 272 | 272 | $block_types = array("block", "list-item", "table"); |
| 273 | - dompdf_debug("page-break", "_page_break_allowed(" . $frame->get_node()->nodeName. ")"); |
|
| 273 | + dompdf_debug("page-break", "_page_break_allowed(".$frame->get_node()->nodeName.")"); |
|
| 274 | 274 | $display = $frame->get_style()->display; |
| 275 | 275 | |
| 276 | 276 | // Block Frames (1): |
| 277 | - if ( in_array($display, $block_types) ) { |
|
| 277 | + if (in_array($display, $block_types)) { |
|
| 278 | 278 | |
| 279 | 279 | // Avoid breaks within table-cells |
| 280 | - if ( $this->_in_table ) { |
|
| 281 | - dompdf_debug("page-break", "In table: " . $this->_in_table); |
|
| 280 | + if ($this->_in_table) { |
|
| 281 | + dompdf_debug("page-break", "In table: ".$this->_in_table); |
|
| 282 | 282 | return false; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | // Rules A & B |
| 286 | 286 | |
| 287 | - if ( $frame->get_style()->page_break_before === "avoid" ) { |
|
| 287 | + if ($frame->get_style()->page_break_before === "avoid") { |
|
| 288 | 288 | dompdf_debug("page-break", "before: avoid"); |
| 289 | 289 | return false; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | // Find the preceeding block-level sibling |
| 293 | 293 | $prev = $frame->get_prev_sibling(); |
| 294 | - while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
|
| 294 | + while ($prev && !in_array($prev->get_style()->display, $block_types)) |
|
| 295 | 295 | $prev = $prev->get_prev_sibling(); |
| 296 | 296 | |
| 297 | 297 | // Does the previous element allow a page break after? |
| 298 | - if ( $prev && $prev->get_style()->page_break_after === "avoid" ) { |
|
| 298 | + if ($prev && $prev->get_style()->page_break_after === "avoid") { |
|
| 299 | 299 | dompdf_debug("page-break", "after: avoid"); |
| 300 | 300 | return false; |
| 301 | 301 | } |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | // If both $prev & $frame have the same parent, check the parent's |
| 304 | 304 | // page_break_inside property. |
| 305 | 305 | $parent = $frame->get_parent(); |
| 306 | - if ( $prev && $parent && $parent->get_style()->page_break_inside === "avoid" ) { |
|
| 306 | + if ($prev && $parent && $parent->get_style()->page_break_inside === "avoid") { |
|
| 307 | 307 | dompdf_debug("page-break", "parent inside: avoid"); |
| 308 | 308 | return false; |
| 309 | 309 | } |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | // To prevent cascading page breaks when a top-level element has |
| 312 | 312 | // page-break-inside: avoid, ensure that at least one frame is |
| 313 | 313 | // on the page before splitting. |
| 314 | - if ( $parent->get_node()->nodeName === "body" && !$prev ) { |
|
| 314 | + if ($parent->get_node()->nodeName === "body" && !$prev) { |
|
| 315 | 315 | // We are the body's first child |
| 316 | 316 | dompdf_debug("page-break", "Body's first child."); |
| 317 | 317 | return false; |
@@ -319,8 +319,8 @@ discard block |
||
| 319 | 319 | |
| 320 | 320 | // If the frame is the first block-level frame, use the value from |
| 321 | 321 | // $frame's parent instead. |
| 322 | - if ( !$prev && $parent ) |
|
| 323 | - return $this->_page_break_allowed( $parent ); |
|
| 322 | + if (!$prev && $parent) |
|
| 323 | + return $this->_page_break_allowed($parent); |
|
| 324 | 324 | |
| 325 | 325 | dompdf_debug("page-break", "block: break allowed"); |
| 326 | 326 | return true; |
@@ -328,17 +328,17 @@ discard block |
||
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | // Inline frames (2): |
| 331 | - else if ( in_array($display, Style::$INLINE_TYPES) ) { |
|
| 331 | + else if (in_array($display, Style::$INLINE_TYPES)) { |
|
| 332 | 332 | |
| 333 | 333 | // Avoid breaks within table-cells |
| 334 | - if ( $this->_in_table ) { |
|
| 335 | - dompdf_debug("page-break", "In table: " . $this->_in_table); |
|
| 334 | + if ($this->_in_table) { |
|
| 335 | + dompdf_debug("page-break", "In table: ".$this->_in_table); |
|
| 336 | 336 | return false; |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | // Rule C |
| 340 | 340 | $block_parent = $frame->find_block_parent(); |
| 341 | - if ( count($block_parent->get_lines() ) < $frame->get_style()->orphans ) { |
|
| 341 | + if (count($block_parent->get_lines()) < $frame->get_style()->orphans) { |
|
| 342 | 342 | dompdf_debug("page-break", "orphans"); |
| 343 | 343 | return false; |
| 344 | 344 | } |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | // Rule D |
| 350 | 350 | $p = $block_parent; |
| 351 | 351 | while ($p) { |
| 352 | - if ( $p->get_style()->page_break_inside === "avoid" ) { |
|
| 352 | + if ($p->get_style()->page_break_inside === "avoid") { |
|
| 353 | 353 | dompdf_debug("page-break", "parent->inside: avoid"); |
| 354 | 354 | return false; |
| 355 | 355 | } |
@@ -360,32 +360,32 @@ discard block |
||
| 360 | 360 | // page-break-inside: avoid, ensure that at least one frame with |
| 361 | 361 | // some content is on the page before splitting. |
| 362 | 362 | $prev = $frame->get_prev_sibling(); |
| 363 | - while ( $prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "") ) |
|
| 363 | + while ($prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "")) |
|
| 364 | 364 | $prev = $prev->get_prev_sibling(); |
| 365 | 365 | |
| 366 | - if ( $block_parent->get_node()->nodeName === "body" && !$prev ) { |
|
| 366 | + if ($block_parent->get_node()->nodeName === "body" && !$prev) { |
|
| 367 | 367 | // We are the body's first child |
| 368 | 368 | dompdf_debug("page-break", "Body's first child."); |
| 369 | 369 | return false; |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | // Skip breaks on empty text nodes |
| 373 | - if ( $frame->get_node()->nodeName === "#text" && |
|
| 374 | - $frame->get_node()->nodeValue == "" ) |
|
| 373 | + if ($frame->get_node()->nodeName === "#text" && |
|
| 374 | + $frame->get_node()->nodeValue == "") |
|
| 375 | 375 | return false; |
| 376 | 376 | |
| 377 | 377 | dompdf_debug("page-break", "inline: break allowed"); |
| 378 | 378 | return true; |
| 379 | 379 | |
| 380 | 380 | // Table-rows |
| 381 | - } else if ( $display === "table-row" ) { |
|
| 381 | + } else if ($display === "table-row") { |
|
| 382 | 382 | |
| 383 | 383 | // Simply check if the parent table's page_break_inside property is |
| 384 | 384 | // not 'avoid' |
| 385 | 385 | $p = Table_Frame_Decorator::find_parent_table($frame); |
| 386 | 386 | |
| 387 | 387 | while ($p) { |
| 388 | - if ( $p->get_style()->page_break_inside === "avoid" ) { |
|
| 388 | + if ($p->get_style()->page_break_inside === "avoid") { |
|
| 389 | 389 | dompdf_debug("page-break", "parent->inside: avoid"); |
| 390 | 390 | return false; |
| 391 | 391 | } |
@@ -393,28 +393,28 @@ discard block |
||
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | // Avoid breaking after the first row of a table |
| 396 | - if ( $p && $p->get_first_child() === $frame) { |
|
| 396 | + if ($p && $p->get_first_child() === $frame) { |
|
| 397 | 397 | dompdf_debug("page-break", "table: first-row"); |
| 398 | 398 | return false; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | // If this is a nested table, prevent the page from breaking |
| 402 | - if ( $this->_in_table > 1 ) { |
|
| 402 | + if ($this->_in_table > 1) { |
|
| 403 | 403 | dompdf_debug("page-break", "table: nested table"); |
| 404 | 404 | return false; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - dompdf_debug("page-break","table-row/row-groups: break allowed"); |
|
| 407 | + dompdf_debug("page-break", "table-row/row-groups: break allowed"); |
|
| 408 | 408 | return true; |
| 409 | 409 | |
| 410 | - } else if ( in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) { |
|
| 410 | + } else if (in_array($display, Table_Frame_Decorator::$ROW_GROUPS)) { |
|
| 411 | 411 | |
| 412 | 412 | // Disallow breaks at row-groups: only split at row boundaries |
| 413 | 413 | return false; |
| 414 | 414 | |
| 415 | 415 | } else { |
| 416 | 416 | |
| 417 | - dompdf_debug("page-break", "? " . $frame->get_style()->display . ""); |
|
| 417 | + dompdf_debug("page-break", "? ".$frame->get_style()->display.""); |
|
| 418 | 418 | return false; |
| 419 | 419 | } |
| 420 | 420 | |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | */ |
| 431 | 431 | function check_page_break(Frame $frame) { |
| 432 | 432 | // Do not split if we have already |
| 433 | - if ( $this->_page_full ) |
|
| 433 | + if ($this->_page_full) |
|
| 434 | 434 | return false; |
| 435 | 435 | |
| 436 | 436 | // Determine the frame's maximum y value |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | // If a split is to occur here, then the bottom margins & paddings of all |
| 440 | 440 | // parents of $frame must fit on the page as well: |
| 441 | 441 | $p = $frame->get_parent(); |
| 442 | - while ( $p ) { |
|
| 442 | + while ($p) { |
|
| 443 | 443 | $style = $p->get_style(); |
| 444 | 444 | $max_y += $style->length_in_pt(array($style->margin_bottom, |
| 445 | 445 | $style->padding_bottom, |
@@ -449,12 +449,12 @@ discard block |
||
| 449 | 449 | |
| 450 | 450 | |
| 451 | 451 | // Check if $frame flows off the page |
| 452 | - if ( $max_y <= $this->_bottom_page_margin ) |
|
| 452 | + if ($max_y <= $this->_bottom_page_margin) |
|
| 453 | 453 | // no: do nothing |
| 454 | 454 | return false; |
| 455 | 455 | |
| 456 | 456 | dompdf_debug("page-break", "check_page_break"); |
| 457 | - dompdf_debug("page-break", "in_table: " . $this->_in_table); |
|
| 457 | + dompdf_debug("page-break", "in_table: ".$this->_in_table); |
|
| 458 | 458 | |
| 459 | 459 | |
| 460 | 460 | // yes: determine page break location |
@@ -463,42 +463,42 @@ discard block |
||
| 463 | 463 | |
| 464 | 464 | $in_table = $this->_in_table; |
| 465 | 465 | |
| 466 | - dompdf_debug("page-break","Starting search"); |
|
| 467 | - while ( $iter ) { |
|
| 466 | + dompdf_debug("page-break", "Starting search"); |
|
| 467 | + while ($iter) { |
|
| 468 | 468 | // echo "\nbacktrack: " .$iter->get_node()->nodeName ." ".spl_object_hash($iter->get_node()). ""; |
| 469 | - if ( $iter === $this ) { |
|
| 469 | + if ($iter === $this) { |
|
| 470 | 470 | dompdf_debug("page-break", "reached root."); |
| 471 | 471 | // We've reached the root in our search. Just split at $frame. |
| 472 | 472 | break; |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | - if ( $this->_page_break_allowed($iter) ) { |
|
| 476 | - dompdf_debug("page-break","break allowed, splitting."); |
|
| 475 | + if ($this->_page_break_allowed($iter)) { |
|
| 476 | + dompdf_debug("page-break", "break allowed, splitting."); |
|
| 477 | 477 | $iter->split(); |
| 478 | 478 | $this->_page_full = true; |
| 479 | 479 | $this->_in_table = $in_table; |
| 480 | 480 | return true; |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | - if ( !$flg && $next = $iter->get_last_child() ) { |
|
| 483 | + if (!$flg && $next = $iter->get_last_child()) { |
|
| 484 | 484 | dompdf_debug("page-break", "following last child."); |
| 485 | 485 | |
| 486 | - if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) ) |
|
| 486 | + if (in_array($next->get_style()->display, Style::$TABLE_TYPES)) |
|
| 487 | 487 | $this->_in_table++; |
| 488 | 488 | |
| 489 | 489 | $iter = $next; |
| 490 | 490 | continue; |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | - if ( $next = $iter->get_prev_sibling() ) { |
|
| 493 | + if ($next = $iter->get_prev_sibling()) { |
|
| 494 | 494 | dompdf_debug("page-break", "following prev sibling."); |
| 495 | 495 | |
| 496 | - if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
|
| 497 | - !in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
|
| 496 | + if (in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
|
| 497 | + !in_array($iter->get_style()->display, Style::$TABLE_TYPES)) |
|
| 498 | 498 | $this->_in_table++; |
| 499 | 499 | |
| 500 | - else if ( !in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
|
| 501 | - in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
|
| 500 | + else if (!in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
|
| 501 | + in_array($iter->get_style()->display, Style::$TABLE_TYPES)) |
|
| 502 | 502 | $this->_in_table--; |
| 503 | 503 | |
| 504 | 504 | $iter = $next; |
@@ -506,10 +506,10 @@ discard block |
||
| 506 | 506 | continue; |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | - if ( $next = $iter->get_parent() ) { |
|
| 509 | + if ($next = $iter->get_parent()) { |
|
| 510 | 510 | dompdf_debug("page-break", "following parent."); |
| 511 | 511 | |
| 512 | - if ( in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
|
| 512 | + if (in_array($iter->get_style()->display, Style::$TABLE_TYPES)) |
|
| 513 | 513 | $this->_in_table--; |
| 514 | 514 | |
| 515 | 515 | $iter = $next; |
@@ -527,17 +527,17 @@ discard block |
||
| 527 | 527 | dompdf_debug("page-break", "no valid break found, just splitting."); |
| 528 | 528 | |
| 529 | 529 | // If we are in a table, backtrack to the nearest top-level table row |
| 530 | - if ( $this->_in_table ) { |
|
| 530 | + if ($this->_in_table) { |
|
| 531 | 531 | $num_tables = $this->_in_table - 1; |
| 532 | 532 | |
| 533 | 533 | $iter = $frame; |
| 534 | - while ( $iter && $num_tables && $iter->get_style->display !== "table" ) { |
|
| 534 | + while ($iter && $num_tables && $iter->get_style->display !== "table") { |
|
| 535 | 535 | $iter = $iter->get_parent(); |
| 536 | 536 | $num_tables--; |
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | $iter = $frame; |
| 540 | - while ($iter && $iter->get_style()->display !== "table-row" ) |
|
| 540 | + while ($iter && $iter->get_style()->display !== "table-row") |
|
| 541 | 541 | $iter = $iter->get_parent(); |
| 542 | 542 | |
| 543 | 543 | $iter->split(); |
@@ -119,8 +119,10 @@ discard block |
||
| 119 | 119 | function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
| 120 | 120 | parent::set_containing_block($x,$y,$w,$h); |
| 121 | 121 | $w = $this->get_containing_block("w"); |
| 122 | - if ( isset($h) ) |
|
| 123 | - $this->_bottom_page_margin = $h; // - $this->_frame->get_style()->length_in_pt($this->_frame->get_style()->margin_bottom, $w); |
|
| 122 | + if ( isset($h) ) { |
|
| 123 | + $this->_bottom_page_margin = $h; |
|
| 124 | + } |
|
| 125 | + // - $this->_frame->get_style()->length_in_pt($this->_frame->get_style()->margin_bottom, $w); |
|
| 124 | 126 | } |
| 125 | 127 | |
| 126 | 128 | /** |
@@ -176,21 +178,24 @@ discard block |
||
| 176 | 178 | function check_forced_page_break(Frame $frame) { |
| 177 | 179 | |
| 178 | 180 | // Skip check if page is already split |
| 179 | - if ( $this->_page_full ) |
|
| 180 | - return; |
|
| 181 | + if ( $this->_page_full ) { |
|
| 182 | + return; |
|
| 183 | + } |
|
| 181 | 184 | |
| 182 | 185 | $block_types = array("block", "list-item", "table"); |
| 183 | 186 | $page_breaks = array("always", "left", "right"); |
| 184 | 187 | |
| 185 | 188 | $style = $frame->get_style(); |
| 186 | 189 | |
| 187 | - if ( !in_array($style->display, $block_types) ) |
|
| 188 | - return false; |
|
| 190 | + if ( !in_array($style->display, $block_types) ) { |
|
| 191 | + return false; |
|
| 192 | + } |
|
| 189 | 193 | |
| 190 | 194 | // Find the previous block-level sibling |
| 191 | 195 | $prev = $frame->get_prev_sibling(); |
| 192 | - while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
|
| 193 | - $prev = $prev->get_prev_sibling(); |
|
| 196 | + while ( $prev && !in_array($prev->get_style()->display, $block_types) ) { |
|
| 197 | + $prev = $prev->get_prev_sibling(); |
|
| 198 | + } |
|
| 194 | 199 | |
| 195 | 200 | if ( in_array($style->page_break_before, $page_breaks) ) { |
| 196 | 201 | |
@@ -291,8 +296,9 @@ discard block |
||
| 291 | 296 | |
| 292 | 297 | // Find the preceeding block-level sibling |
| 293 | 298 | $prev = $frame->get_prev_sibling(); |
| 294 | - while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
|
| 295 | - $prev = $prev->get_prev_sibling(); |
|
| 299 | + while ( $prev && !in_array($prev->get_style()->display, $block_types) ) { |
|
| 300 | + $prev = $prev->get_prev_sibling(); |
|
| 301 | + } |
|
| 296 | 302 | |
| 297 | 303 | // Does the previous element allow a page break after? |
| 298 | 304 | if ( $prev && $prev->get_style()->page_break_after === "avoid" ) { |
@@ -319,8 +325,9 @@ discard block |
||
| 319 | 325 | |
| 320 | 326 | // If the frame is the first block-level frame, use the value from |
| 321 | 327 | // $frame's parent instead. |
| 322 | - if ( !$prev && $parent ) |
|
| 323 | - return $this->_page_break_allowed( $parent ); |
|
| 328 | + if ( !$prev && $parent ) { |
|
| 329 | + return $this->_page_break_allowed( $parent ); |
|
| 330 | + } |
|
| 324 | 331 | |
| 325 | 332 | dompdf_debug("page-break", "block: break allowed"); |
| 326 | 333 | return true; |
@@ -360,8 +367,9 @@ discard block |
||
| 360 | 367 | // page-break-inside: avoid, ensure that at least one frame with |
| 361 | 368 | // some content is on the page before splitting. |
| 362 | 369 | $prev = $frame->get_prev_sibling(); |
| 363 | - while ( $prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "") ) |
|
| 364 | - $prev = $prev->get_prev_sibling(); |
|
| 370 | + while ( $prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "") ) { |
|
| 371 | + $prev = $prev->get_prev_sibling(); |
|
| 372 | + } |
|
| 365 | 373 | |
| 366 | 374 | if ( $block_parent->get_node()->nodeName === "body" && !$prev ) { |
| 367 | 375 | // We are the body's first child |
@@ -371,8 +379,9 @@ discard block |
||
| 371 | 379 | |
| 372 | 380 | // Skip breaks on empty text nodes |
| 373 | 381 | if ( $frame->get_node()->nodeName === "#text" && |
| 374 | - $frame->get_node()->nodeValue == "" ) |
|
| 375 | - return false; |
|
| 382 | + $frame->get_node()->nodeValue == "" ) { |
|
| 383 | + return false; |
|
| 384 | + } |
|
| 376 | 385 | |
| 377 | 386 | dompdf_debug("page-break", "inline: break allowed"); |
| 378 | 387 | return true; |
@@ -430,8 +439,9 @@ discard block |
||
| 430 | 439 | */ |
| 431 | 440 | function check_page_break(Frame $frame) { |
| 432 | 441 | // Do not split if we have already |
| 433 | - if ( $this->_page_full ) |
|
| 434 | - return false; |
|
| 442 | + if ( $this->_page_full ) { |
|
| 443 | + return false; |
|
| 444 | + } |
|
| 435 | 445 | |
| 436 | 446 | // Determine the frame's maximum y value |
| 437 | 447 | $max_y = $frame->get_position("y") + $frame->get_margin_height(); |
@@ -449,9 +459,10 @@ discard block |
||
| 449 | 459 | |
| 450 | 460 | |
| 451 | 461 | // Check if $frame flows off the page |
| 452 | - if ( $max_y <= $this->_bottom_page_margin ) |
|
| 453 | - // no: do nothing |
|
| 462 | + if ( $max_y <= $this->_bottom_page_margin ) { |
|
| 463 | + // no: do nothing |
|
| 454 | 464 | return false; |
| 465 | + } |
|
| 455 | 466 | |
| 456 | 467 | dompdf_debug("page-break", "check_page_break"); |
| 457 | 468 | dompdf_debug("page-break", "in_table: " . $this->_in_table); |
@@ -483,8 +494,9 @@ discard block |
||
| 483 | 494 | if ( !$flg && $next = $iter->get_last_child() ) { |
| 484 | 495 | dompdf_debug("page-break", "following last child."); |
| 485 | 496 | |
| 486 | - if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) ) |
|
| 487 | - $this->_in_table++; |
|
| 497 | + if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) ) { |
|
| 498 | + $this->_in_table++; |
|
| 499 | + } |
|
| 488 | 500 | |
| 489 | 501 | $iter = $next; |
| 490 | 502 | continue; |
@@ -494,12 +506,12 @@ discard block |
||
| 494 | 506 | dompdf_debug("page-break", "following prev sibling."); |
| 495 | 507 | |
| 496 | 508 | if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
| 497 | - !in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
|
| 498 | - $this->_in_table++; |
|
| 499 | - |
|
| 500 | - else if ( !in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
|
| 501 | - in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
|
| 502 | - $this->_in_table--; |
|
| 509 | + !in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) { |
|
| 510 | + $this->_in_table++; |
|
| 511 | + } else if ( !in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
|
| 512 | + in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) { |
|
| 513 | + $this->_in_table--; |
|
| 514 | + } |
|
| 503 | 515 | |
| 504 | 516 | $iter = $next; |
| 505 | 517 | $flg = false; |
@@ -509,8 +521,9 @@ discard block |
||
| 509 | 521 | if ( $next = $iter->get_parent() ) { |
| 510 | 522 | dompdf_debug("page-break", "following parent."); |
| 511 | 523 | |
| 512 | - if ( in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
|
| 513 | - $this->_in_table--; |
|
| 524 | + if ( in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) { |
|
| 525 | + $this->_in_table--; |
|
| 526 | + } |
|
| 514 | 527 | |
| 515 | 528 | $iter = $next; |
| 516 | 529 | $flg = true; |
@@ -537,8 +550,9 @@ discard block |
||
| 537 | 550 | } |
| 538 | 551 | |
| 539 | 552 | $iter = $frame; |
| 540 | - while ($iter && $iter->get_style()->display !== "table-row" ) |
|
| 541 | - $iter = $iter->get_parent(); |
|
| 553 | + while ($iter && $iter->get_style()->display !== "table-row" ) { |
|
| 554 | + $iter = $iter->get_parent(); |
|
| 555 | + } |
|
| 542 | 556 | |
| 543 | 557 | $iter->split(); |
| 544 | 558 | $this->_page_full = true; |
@@ -442,6 +442,9 @@ discard block |
||
| 442 | 442 | * @param string corner |
| 443 | 443 | * @param string join |
| 444 | 444 | * @param array dash |
| 445 | + * @param double $width |
|
| 446 | + * @param string $cap |
|
| 447 | + * @param string $join |
|
| 445 | 448 | */ |
| 446 | 449 | protected function _set_line_style($width, $cap, $join, $dash) { |
| 447 | 450 | |
@@ -795,8 +798,8 @@ discard block |
||
| 795 | 798 | * @param string $font the font file to use |
| 796 | 799 | * @param float $size the font size, in points |
| 797 | 800 | * @param array $color |
| 798 | - * @param float $adjust word spacing adjustment |
|
| 799 | - * @param float $angle angle to write the text at, measured CW starting from the x-axis |
|
| 801 | + * @param integer $adjust word spacing adjustment |
|
| 802 | + * @param integer $angle angle to write the text at, measured CW starting from the x-axis |
|
| 800 | 803 | */ |
| 801 | 804 | function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), |
| 802 | 805 | $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0) { |
@@ -1,46 +1,46 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
| 4 | - * |
|
| 5 | - * File: $RCSfile: pdflib_adapter.cls.php,v $ |
|
| 6 | - * Created on: 2005-02-28 |
|
| 7 | - * |
|
| 8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
| 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.dompdf.com/ |
|
| 32 | - * |
|
| 33 | - * @link http://www.dompdf.com/ |
|
| 34 | - * @copyright 2004 Benj Carson |
|
| 35 | - * @author Benj Carson <[email protected]> |
|
| 36 | - * @contributor Helmut Tischer <[email protected]> |
|
| 37 | - * @package dompdf |
|
| 38 | - * |
|
| 39 | - * Changes |
|
| 40 | - * @contributor Helmut Tischer <[email protected]> |
|
| 41 | - * @version 0.5.1.htischer.20090507 |
|
| 42 | - * - Clarify temp file name, optional debug output for temp file tracking |
|
| 43 | - */ |
|
| 3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
| 4 | + * |
|
| 5 | + * File: $RCSfile: pdflib_adapter.cls.php,v $ |
|
| 6 | + * Created on: 2005-02-28 |
|
| 7 | + * |
|
| 8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
| 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.dompdf.com/ |
|
| 32 | + * |
|
| 33 | + * @link http://www.dompdf.com/ |
|
| 34 | + * @copyright 2004 Benj Carson |
|
| 35 | + * @author Benj Carson <[email protected]> |
|
| 36 | + * @contributor Helmut Tischer <[email protected]> |
|
| 37 | + * @package dompdf |
|
| 38 | + * |
|
| 39 | + * Changes |
|
| 40 | + * @contributor Helmut Tischer <[email protected]> |
|
| 41 | + * @version 0.5.1.htischer.20090507 |
|
| 42 | + * - Clarify temp file name, optional debug output for temp file tracking |
|
| 43 | + */ |
|
| 44 | 44 | |
| 45 | 45 | /* $Id: pdflib_adapter.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */ |
| 46 | 46 | |
@@ -61,170 +61,170 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | class PDFLib_Adapter implements Canvas { |
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Dimensions of paper sizes in points |
|
| 66 | - * |
|
| 67 | - * @var array; |
|
| 68 | - */ |
|
| 69 | - static public $PAPER_SIZES = array(); // Set to |
|
| 64 | + /** |
|
| 65 | + * Dimensions of paper sizes in points |
|
| 66 | + * |
|
| 67 | + * @var array; |
|
| 68 | + */ |
|
| 69 | + static public $PAPER_SIZES = array(); // Set to |
|
| 70 | 70 | // CPDF_Adapter::$PAPER_SIZES below. |
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Fudge factor to adjust reported font heights |
|
| 74 | - * |
|
| 75 | - * CPDF reports larger font heights than PDFLib. This factor |
|
| 76 | - * adjusts the height reported by get_font_height(). |
|
| 77 | - * |
|
| 78 | - * @var float |
|
| 79 | - */ |
|
| 80 | - const FONT_HEIGHT_SCALE = 1.2; |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * Whether to create PDFs in memory or on disk |
|
| 84 | - * |
|
| 85 | - * @var bool |
|
| 86 | - */ |
|
| 87 | - static $IN_MEMORY = true; |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * Instance of PDFLib class |
|
| 91 | - * |
|
| 92 | - * @var PDFlib |
|
| 93 | - */ |
|
| 94 | - private $_pdf; |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * Name of temporary file used for PDFs created on disk |
|
| 98 | - * |
|
| 99 | - * @var string |
|
| 100 | - */ |
|
| 101 | - private $_file; |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * PDF width, in points |
|
| 105 | - * |
|
| 106 | - * @var float |
|
| 107 | - */ |
|
| 108 | - private $_width; |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * PDF height, in points |
|
| 112 | - * |
|
| 113 | - * @var height |
|
| 114 | - */ |
|
| 115 | - private $_height; |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * Last fill colour used |
|
| 119 | - * |
|
| 120 | - * @var array |
|
| 121 | - */ |
|
| 122 | - private $_last_fill_color; |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * Last stroke colour used |
|
| 126 | - * |
|
| 127 | - * @var array |
|
| 128 | - */ |
|
| 129 | - private $_last_stroke_color; |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * Cache of image handles |
|
| 133 | - * |
|
| 134 | - * @var array |
|
| 135 | - */ |
|
| 136 | - private $_imgs; |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * Cache of font handles |
|
| 140 | - * |
|
| 141 | - * @var array |
|
| 142 | - */ |
|
| 143 | - private $_fonts; |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * List of objects (templates) to add to multiple pages |
|
| 147 | - * |
|
| 148 | - * @var array |
|
| 149 | - */ |
|
| 150 | - private $_objs; |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * Current page number |
|
| 154 | - * |
|
| 155 | - * @var int |
|
| 156 | - */ |
|
| 157 | - private $_page_number; |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * Total number of pages |
|
| 161 | - * |
|
| 162 | - * @var int |
|
| 163 | - */ |
|
| 164 | - private $_page_count; |
|
| 165 | - |
|
| 166 | - /** |
|
| 167 | - * Text to display on every page |
|
| 168 | - * |
|
| 169 | - * @var array |
|
| 170 | - */ |
|
| 171 | - private $_page_text; |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * Array of pages for accesing after rendering is initially complete |
|
| 175 | - * |
|
| 176 | - * @var array |
|
| 177 | - */ |
|
| 178 | - private $_pages; |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * Class constructor |
|
| 182 | - * |
|
| 183 | - * @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or |
|
| 184 | - * an array(xmin,ymin,xmax,ymax) |
|
| 185 | - * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
|
| 186 | - */ |
|
| 187 | - function __construct($paper = "letter", $orientation = "portrait") { |
|
| 72 | + /** |
|
| 73 | + * Fudge factor to adjust reported font heights |
|
| 74 | + * |
|
| 75 | + * CPDF reports larger font heights than PDFLib. This factor |
|
| 76 | + * adjusts the height reported by get_font_height(). |
|
| 77 | + * |
|
| 78 | + * @var float |
|
| 79 | + */ |
|
| 80 | + const FONT_HEIGHT_SCALE = 1.2; |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * Whether to create PDFs in memory or on disk |
|
| 84 | + * |
|
| 85 | + * @var bool |
|
| 86 | + */ |
|
| 87 | + static $IN_MEMORY = true; |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * Instance of PDFLib class |
|
| 91 | + * |
|
| 92 | + * @var PDFlib |
|
| 93 | + */ |
|
| 94 | + private $_pdf; |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * Name of temporary file used for PDFs created on disk |
|
| 98 | + * |
|
| 99 | + * @var string |
|
| 100 | + */ |
|
| 101 | + private $_file; |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * PDF width, in points |
|
| 105 | + * |
|
| 106 | + * @var float |
|
| 107 | + */ |
|
| 108 | + private $_width; |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * PDF height, in points |
|
| 112 | + * |
|
| 113 | + * @var height |
|
| 114 | + */ |
|
| 115 | + private $_height; |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * Last fill colour used |
|
| 119 | + * |
|
| 120 | + * @var array |
|
| 121 | + */ |
|
| 122 | + private $_last_fill_color; |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Last stroke colour used |
|
| 126 | + * |
|
| 127 | + * @var array |
|
| 128 | + */ |
|
| 129 | + private $_last_stroke_color; |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Cache of image handles |
|
| 133 | + * |
|
| 134 | + * @var array |
|
| 135 | + */ |
|
| 136 | + private $_imgs; |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * Cache of font handles |
|
| 140 | + * |
|
| 141 | + * @var array |
|
| 142 | + */ |
|
| 143 | + private $_fonts; |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * List of objects (templates) to add to multiple pages |
|
| 147 | + * |
|
| 148 | + * @var array |
|
| 149 | + */ |
|
| 150 | + private $_objs; |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * Current page number |
|
| 154 | + * |
|
| 155 | + * @var int |
|
| 156 | + */ |
|
| 157 | + private $_page_number; |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * Total number of pages |
|
| 161 | + * |
|
| 162 | + * @var int |
|
| 163 | + */ |
|
| 164 | + private $_page_count; |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | + * Text to display on every page |
|
| 168 | + * |
|
| 169 | + * @var array |
|
| 170 | + */ |
|
| 171 | + private $_page_text; |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * Array of pages for accesing after rendering is initially complete |
|
| 175 | + * |
|
| 176 | + * @var array |
|
| 177 | + */ |
|
| 178 | + private $_pages; |
|
| 179 | + |
|
| 180 | + /** |
|
| 181 | + * Class constructor |
|
| 182 | + * |
|
| 183 | + * @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or |
|
| 184 | + * an array(xmin,ymin,xmax,ymax) |
|
| 185 | + * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
|
| 186 | + */ |
|
| 187 | + function __construct($paper = "letter", $orientation = "portrait") { |
|
| 188 | 188 | if ( is_array($paper) ) |
| 189 | - $size = $paper; |
|
| 189 | + $size = $paper; |
|
| 190 | 190 | else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) |
| 191 | - $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
|
| 191 | + $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
|
| 192 | 192 | else |
| 193 | - $size = self::$PAPER_SIZES["letter"]; |
|
| 193 | + $size = self::$PAPER_SIZES["letter"]; |
|
| 194 | 194 | |
| 195 | 195 | if ( mb_strtolower($orientation) === "landscape" ) { |
| 196 | - $a = $size[3]; |
|
| 197 | - $size[3] = $size[2]; |
|
| 198 | - $size[2] = $a; |
|
| 196 | + $a = $size[3]; |
|
| 197 | + $size[3] = $size[2]; |
|
| 198 | + $size[2] = $a; |
|
| 199 | 199 | } |
| 200 | 200 | $this->_width = $size[2] - $size[0]; |
| 201 | 201 | $this->_height= $size[3] - $size[1]; |
| 202 | 202 | |
| 203 | 203 | $this->_pdf = new PDFLib(); |
| 204 | 204 | |
| 205 | - if ( defined("DOMPDF_PDFLIB_LICENSE") ) |
|
| 206 | - $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE); |
|
| 205 | + if ( defined("DOMPDF_PDFLIB_LICENSE") ) |
|
| 206 | + $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE); |
|
| 207 | 207 | |
| 208 | - $this->_pdf->set_parameter("textformat", "utf8"); |
|
| 208 | + $this->_pdf->set_parameter("textformat", "utf8"); |
|
| 209 | 209 | $this->_pdf->set_parameter("fontwarning", "false"); |
| 210 | 210 | |
| 211 | 211 | $this->_pdf->set_info("Creator", "DOMPDF Converter"); |
| 212 | 212 | |
| 213 | 213 | // Silence pedantic warnings about missing TZ settings |
| 214 | 214 | if ( function_exists("date_default_timezone_get") ) { |
| 215 | - $tz = @date_default_timezone_get(); |
|
| 216 | - date_default_timezone_set("UTC"); |
|
| 217 | - $this->_pdf->set_info("Date", date("Y-m-d")); |
|
| 218 | - date_default_timezone_set($tz); |
|
| 215 | + $tz = @date_default_timezone_get(); |
|
| 216 | + date_default_timezone_set("UTC"); |
|
| 217 | + $this->_pdf->set_info("Date", date("Y-m-d")); |
|
| 218 | + date_default_timezone_set($tz); |
|
| 219 | 219 | } else { |
| 220 | - $this->_pdf->set_info("Date", date("Y-m-d")); |
|
| 220 | + $this->_pdf->set_info("Date", date("Y-m-d")); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | if ( self::$IN_MEMORY ) |
| 224 | - $this->_pdf->begin_document("",""); |
|
| 224 | + $this->_pdf->begin_document("",""); |
|
| 225 | 225 | else { |
| 226 | - $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf'; |
|
| 227 | - $this->_pdf->begin_document($this->_file,""); |
|
| 226 | + $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf'; |
|
| 227 | + $this->_pdf->begin_document($this->_file,""); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | $this->_pdf->begin_page_ext($this->_width, $this->_height, ""); |
@@ -239,155 +239,155 @@ discard block |
||
| 239 | 239 | // Set up font paths |
| 240 | 240 | $families = Font_Metrics::get_font_families(); |
| 241 | 241 | foreach ($families as $family => $files) { |
| 242 | - foreach ($files as $style => $file) { |
|
| 242 | + foreach ($files as $style => $file) { |
|
| 243 | 243 | $face = basename($file); |
| 244 | 244 | |
| 245 | 245 | // Prefer ttfs to afms |
| 246 | 246 | if ( file_exists($file.".ttf") ) { |
| 247 | - $outline = "$file.ttf"; |
|
| 248 | - $afm = null; |
|
| 247 | + $outline = "$file.ttf"; |
|
| 248 | + $afm = null; |
|
| 249 | 249 | |
| 250 | 250 | } else if ( file_exists($file .".TTF") ) { |
| 251 | - $outline = "$file.TTF"; |
|
| 252 | - $afm = null; |
|
| 251 | + $outline = "$file.TTF"; |
|
| 252 | + $afm = null; |
|
| 253 | 253 | |
| 254 | 254 | } else if ( file_exists($file . ".pfb") ) { |
| 255 | - $outline = "$file.pfb"; |
|
| 255 | + $outline = "$file.pfb"; |
|
| 256 | 256 | |
| 257 | - if ( file_exists($file . ".afm") ) |
|
| 257 | + if ( file_exists($file . ".afm") ) |
|
| 258 | 258 | $afm = "$file.afm"; |
| 259 | 259 | |
| 260 | 260 | } else if ( file_exists($file . ".PFB") ) { |
| 261 | - $outline = "$file.PFB"; |
|
| 262 | - if ( file_exists($file . ".AFM") ) |
|
| 261 | + $outline = "$file.PFB"; |
|
| 262 | + if ( file_exists($file . ".AFM") ) |
|
| 263 | 263 | $afm = "$file.AFM"; |
| 264 | 264 | } else |
| 265 | - continue; |
|
| 265 | + continue; |
|
| 266 | 266 | |
| 267 | 267 | $this->_pdf->set_parameter("FontOutline", "\{$face\}=\{$outline\}"); |
| 268 | 268 | if ( !is_null($afm) ) |
| 269 | - $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}"); |
|
| 270 | - } |
|
| 269 | + $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}"); |
|
| 270 | + } |
|
| 271 | + } |
|
| 271 | 272 | } |
| 272 | - } |
|
| 273 | 273 | |
| 274 | - /** |
|
| 275 | - * Close the pdf |
|
| 276 | - */ |
|
| 277 | - protected function _close() { |
|
| 274 | + /** |
|
| 275 | + * Close the pdf |
|
| 276 | + */ |
|
| 277 | + protected function _close() { |
|
| 278 | 278 | $this->_place_objects(); |
| 279 | 279 | |
| 280 | 280 | // Close all pages |
| 281 | 281 | $this->_pdf->suspend_page(""); |
| 282 | 282 | for ($p = 1; $p <= $this->_page_count; $p++) { |
| 283 | - $this->_pdf->resume_page("pagenumber=$p"); |
|
| 284 | - $this->_pdf->end_page_ext(""); |
|
| 283 | + $this->_pdf->resume_page("pagenumber=$p"); |
|
| 284 | + $this->_pdf->end_page_ext(""); |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | $this->_pdf->end_document(""); |
| 288 | - } |
|
| 289 | - |
|
| 290 | - |
|
| 291 | - /** |
|
| 292 | - * Returns the PDFLib instance |
|
| 293 | - * |
|
| 294 | - * @return PDFLib |
|
| 295 | - */ |
|
| 296 | - function get_pdflib() { return $this->_pdf; } |
|
| 297 | - |
|
| 298 | - /** |
|
| 299 | - * Add meta information to the PDF |
|
| 300 | - * |
|
| 301 | - * @param string $label label of the value (Creator, Producter, etc.) |
|
| 302 | - * @param string $value the text to set |
|
| 303 | - */ |
|
| 304 | - function add_info($label, $value) { |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + |
|
| 291 | + /** |
|
| 292 | + * Returns the PDFLib instance |
|
| 293 | + * |
|
| 294 | + * @return PDFLib |
|
| 295 | + */ |
|
| 296 | + function get_pdflib() { return $this->_pdf; } |
|
| 297 | + |
|
| 298 | + /** |
|
| 299 | + * Add meta information to the PDF |
|
| 300 | + * |
|
| 301 | + * @param string $label label of the value (Creator, Producter, etc.) |
|
| 302 | + * @param string $value the text to set |
|
| 303 | + */ |
|
| 304 | + function add_info($label, $value) { |
|
| 305 | 305 | $this->_pdf->set_info($label, $value); |
| 306 | - } |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | - /** |
|
| 309 | - * Opens a new 'object' (template in PDFLib-speak) |
|
| 310 | - * |
|
| 311 | - * While an object is open, all drawing actions are recorded to the |
|
| 312 | - * object instead of being drawn on the current page. Objects can |
|
| 313 | - * be added later to a specific page or to several pages. |
|
| 314 | - * |
|
| 315 | - * The return value is an integer ID for the new object. |
|
| 316 | - * |
|
| 317 | - * @see PDFLib_Adapter::close_object() |
|
| 318 | - * @see PDFLib_Adapter::add_object() |
|
| 319 | - * |
|
| 320 | - * @return int |
|
| 321 | - */ |
|
| 322 | - function open_object() { |
|
| 308 | + /** |
|
| 309 | + * Opens a new 'object' (template in PDFLib-speak) |
|
| 310 | + * |
|
| 311 | + * While an object is open, all drawing actions are recorded to the |
|
| 312 | + * object instead of being drawn on the current page. Objects can |
|
| 313 | + * be added later to a specific page or to several pages. |
|
| 314 | + * |
|
| 315 | + * The return value is an integer ID for the new object. |
|
| 316 | + * |
|
| 317 | + * @see PDFLib_Adapter::close_object() |
|
| 318 | + * @see PDFLib_Adapter::add_object() |
|
| 319 | + * |
|
| 320 | + * @return int |
|
| 321 | + */ |
|
| 322 | + function open_object() { |
|
| 323 | 323 | $this->_pdf->suspend_page(""); |
| 324 | 324 | $ret = $this->_pdf->begin_template($this->_width, $this->_height); |
| 325 | 325 | $this->_pdf->save(); |
| 326 | 326 | $this->_objs[$ret] = array("start_page" => $this->_page_number); |
| 327 | 327 | return $ret; |
| 328 | - } |
|
| 329 | - |
|
| 330 | - /** |
|
| 331 | - * Reopen an existing object (NOT IMPLEMENTED) |
|
| 332 | - * |
|
| 333 | - * PDFLib does not seem to support reopening templates. |
|
| 334 | - * |
|
| 335 | - * @param int $object the ID of a previously opened object |
|
| 336 | - */ |
|
| 337 | - function reopen_object($object) { |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + /** |
|
| 331 | + * Reopen an existing object (NOT IMPLEMENTED) |
|
| 332 | + * |
|
| 333 | + * PDFLib does not seem to support reopening templates. |
|
| 334 | + * |
|
| 335 | + * @param int $object the ID of a previously opened object |
|
| 336 | + */ |
|
| 337 | + function reopen_object($object) { |
|
| 338 | 338 | throw new DOMPDF_Exception("PDFLib does not support reopening objects."); |
| 339 | - } |
|
| 340 | - |
|
| 341 | - /** |
|
| 342 | - * Close the current template |
|
| 343 | - * |
|
| 344 | - * @see PDFLib_Adapter::open_object() |
|
| 345 | - */ |
|
| 346 | - function close_object() { |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + /** |
|
| 342 | + * Close the current template |
|
| 343 | + * |
|
| 344 | + * @see PDFLib_Adapter::open_object() |
|
| 345 | + */ |
|
| 346 | + function close_object() { |
|
| 347 | 347 | $this->_pdf->restore(); |
| 348 | 348 | $this->_pdf->end_template(); |
| 349 | 349 | $this->_pdf->resume_page("pagenumber=".$this->_page_number); |
| 350 | - } |
|
| 351 | - |
|
| 352 | - /** |
|
| 353 | - * Adds the specified object to the document |
|
| 354 | - * |
|
| 355 | - * $where can be one of: |
|
| 356 | - * - 'add' add to current page only |
|
| 357 | - * - 'all' add to every page from the current one onwards |
|
| 358 | - * - 'odd' add to all odd numbered pages from now on |
|
| 359 | - * - 'even' add to all even numbered pages from now on |
|
| 360 | - * - 'next' add the object to the next page only |
|
| 361 | - * - 'nextodd' add to all odd numbered pages from the next one |
|
| 362 | - * - 'nexteven' add to all even numbered pages from the next one |
|
| 363 | - * |
|
| 364 | - * @param int $object the object handle returned by open_object() |
|
| 365 | - * @param string $where |
|
| 366 | - */ |
|
| 367 | - function add_object($object, $where = 'all') { |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + /** |
|
| 353 | + * Adds the specified object to the document |
|
| 354 | + * |
|
| 355 | + * $where can be one of: |
|
| 356 | + * - 'add' add to current page only |
|
| 357 | + * - 'all' add to every page from the current one onwards |
|
| 358 | + * - 'odd' add to all odd numbered pages from now on |
|
| 359 | + * - 'even' add to all even numbered pages from now on |
|
| 360 | + * - 'next' add the object to the next page only |
|
| 361 | + * - 'nextodd' add to all odd numbered pages from the next one |
|
| 362 | + * - 'nexteven' add to all even numbered pages from the next one |
|
| 363 | + * |
|
| 364 | + * @param int $object the object handle returned by open_object() |
|
| 365 | + * @param string $where |
|
| 366 | + */ |
|
| 367 | + function add_object($object, $where = 'all') { |
|
| 368 | 368 | |
| 369 | 369 | if ( mb_strpos($where, "next") !== false ) { |
| 370 | - $this->_objs[$object]["start_page"]++; |
|
| 371 | - $where = str_replace("next", "", $where); |
|
| 372 | - if ( $where == "" ) |
|
| 370 | + $this->_objs[$object]["start_page"]++; |
|
| 371 | + $where = str_replace("next", "", $where); |
|
| 372 | + if ( $where == "" ) |
|
| 373 | 373 | $where = "add"; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | $this->_objs[$object]["where"] = $where; |
| 377 | - } |
|
| 378 | - |
|
| 379 | - /** |
|
| 380 | - * Stops the specified template from appearing in the document. |
|
| 381 | - * |
|
| 382 | - * The object will stop being displayed on the page following the |
|
| 383 | - * current one. |
|
| 384 | - * |
|
| 385 | - * @param int $object |
|
| 386 | - */ |
|
| 387 | - function stop_object($object) { |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + /** |
|
| 380 | + * Stops the specified template from appearing in the document. |
|
| 381 | + * |
|
| 382 | + * The object will stop being displayed on the page following the |
|
| 383 | + * current one. |
|
| 384 | + * |
|
| 385 | + * @param int $object |
|
| 386 | + */ |
|
| 387 | + function stop_object($object) { |
|
| 388 | 388 | |
| 389 | 389 | if ( !isset($this->_objs[$object]) ) |
| 390 | - return; |
|
| 390 | + return; |
|
| 391 | 391 | |
| 392 | 392 | $start = $this->_objs[$object]["start_page"]; |
| 393 | 393 | $where = $this->_objs[$object]["where"]; |
@@ -397,74 +397,74 @@ discard block |
||
| 397 | 397 | (($this->_page_number % 2 == 0 && $where === "even") || |
| 398 | 398 | ($this->_page_number % 2 == 1 && $where === "odd") || |
| 399 | 399 | ($where === "all")) ) |
| 400 | - $this->_pdf->fit_image($object,0,0,""); |
|
| 400 | + $this->_pdf->fit_image($object,0,0,""); |
|
| 401 | 401 | |
| 402 | 402 | unset($this->_objs[$object]); |
| 403 | - } |
|
| 403 | + } |
|
| 404 | 404 | |
| 405 | - /** |
|
| 406 | - * Add all active objects to the current page |
|
| 407 | - */ |
|
| 408 | - protected function _place_objects() { |
|
| 405 | + /** |
|
| 406 | + * Add all active objects to the current page |
|
| 407 | + */ |
|
| 408 | + protected function _place_objects() { |
|
| 409 | 409 | |
| 410 | 410 | foreach ( $this->_objs as $obj => $props ) { |
| 411 | - $start = $props["start_page"]; |
|
| 412 | - $where = $props["where"]; |
|
| 411 | + $start = $props["start_page"]; |
|
| 412 | + $where = $props["where"]; |
|
| 413 | 413 | |
| 414 | - // Place the object on this page if required |
|
| 415 | - if ( $this->_page_number >= $start && |
|
| 414 | + // Place the object on this page if required |
|
| 415 | + if ( $this->_page_number >= $start && |
|
| 416 | 416 | (($this->_page_number % 2 == 0 && $where === "even") || |
| 417 | 417 | ($this->_page_number % 2 == 1 && $where === "odd") || |
| 418 | 418 | ($where === "all")) ) { |
| 419 | 419 | $this->_pdf->fit_image($obj,0,0,""); |
| 420 | - } |
|
| 420 | + } |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - } |
|
| 423 | + } |
|
| 424 | 424 | |
| 425 | - function get_width() { return $this->_width; } |
|
| 425 | + function get_width() { return $this->_width; } |
|
| 426 | 426 | |
| 427 | - function get_height() { return $this->_height; } |
|
| 427 | + function get_height() { return $this->_height; } |
|
| 428 | 428 | |
| 429 | - function get_page_number() { return $this->_page_number; } |
|
| 429 | + function get_page_number() { return $this->_page_number; } |
|
| 430 | 430 | |
| 431 | - function get_page_count() { return $this->_page_count; } |
|
| 431 | + function get_page_count() { return $this->_page_count; } |
|
| 432 | 432 | |
| 433 | - function set_page_number($num) { $this->_page_number = (int)$num; } |
|
| 433 | + function set_page_number($num) { $this->_page_number = (int)$num; } |
|
| 434 | 434 | |
| 435 | - function set_page_count($count) { $this->_page_count = (int)$count; } |
|
| 435 | + function set_page_count($count) { $this->_page_count = (int)$count; } |
|
| 436 | 436 | |
| 437 | 437 | |
| 438 | - /** |
|
| 439 | - * Sets the line style |
|
| 440 | - * |
|
| 441 | - * @param float width |
|
| 442 | - * @param string corner |
|
| 443 | - * @param string join |
|
| 444 | - * @param array dash |
|
| 445 | - */ |
|
| 446 | - protected function _set_line_style($width, $cap, $join, $dash) { |
|
| 438 | + /** |
|
| 439 | + * Sets the line style |
|
| 440 | + * |
|
| 441 | + * @param float width |
|
| 442 | + * @param string corner |
|
| 443 | + * @param string join |
|
| 444 | + * @param array dash |
|
| 445 | + */ |
|
| 446 | + protected function _set_line_style($width, $cap, $join, $dash) { |
|
| 447 | 447 | |
| 448 | 448 | if ( count($dash) == 1 ) |
| 449 | - $dash[] = $dash[0]; |
|
| 449 | + $dash[] = $dash[0]; |
|
| 450 | 450 | |
| 451 | 451 | if ( count($dash) > 1 ) |
| 452 | - $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}"); |
|
| 452 | + $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}"); |
|
| 453 | 453 | else |
| 454 | - $this->_pdf->setdash(0,0); |
|
| 454 | + $this->_pdf->setdash(0,0); |
|
| 455 | 455 | |
| 456 | 456 | switch ( $join ) { |
| 457 | 457 | case "miter": |
| 458 | 458 | $this->_pdf->setlinejoin(0); |
| 459 | - break; |
|
| 459 | + break; |
|
| 460 | 460 | |
| 461 | 461 | case "round": |
| 462 | 462 | $this->_pdf->setlinejoin(1); |
| 463 | - break; |
|
| 463 | + break; |
|
| 464 | 464 | |
| 465 | 465 | case "bevel": |
| 466 | 466 | $this->_pdf->setlinejoin(2); |
| 467 | - break; |
|
| 467 | + break; |
|
| 468 | 468 | |
| 469 | 469 | default: |
| 470 | 470 | break; |
@@ -473,15 +473,15 @@ discard block |
||
| 473 | 473 | switch ( $cap ) { |
| 474 | 474 | case "butt": |
| 475 | 475 | $this->_pdf->setlinecap(0); |
| 476 | - break; |
|
| 476 | + break; |
|
| 477 | 477 | |
| 478 | 478 | case "round": |
| 479 | 479 | $this->_pdf->setlinecap(1); |
| 480 | - break; |
|
| 480 | + break; |
|
| 481 | 481 | |
| 482 | 482 | case "square": |
| 483 | 483 | $this->_pdf->setlinecap(2); |
| 484 | - break; |
|
| 484 | + break; |
|
| 485 | 485 | |
| 486 | 486 | default: |
| 487 | 487 | break; |
@@ -489,69 +489,69 @@ discard block |
||
| 489 | 489 | |
| 490 | 490 | $this->_pdf->setlinewidth($width); |
| 491 | 491 | |
| 492 | - } |
|
| 492 | + } |
|
| 493 | 493 | |
| 494 | - /** |
|
| 495 | - * Sets the line color |
|
| 496 | - * |
|
| 497 | - * @param array $color array(r,g,b) |
|
| 498 | - */ |
|
| 499 | - protected function _set_stroke_color($color) { |
|
| 494 | + /** |
|
| 495 | + * Sets the line color |
|
| 496 | + * |
|
| 497 | + * @param array $color array(r,g,b) |
|
| 498 | + */ |
|
| 499 | + protected function _set_stroke_color($color) { |
|
| 500 | 500 | if($this->_last_stroke_color == $color) |
| 501 | - return; |
|
| 501 | + return; |
|
| 502 | 502 | |
| 503 | 503 | $this->_last_stroke_color = $color; |
| 504 | 504 | |
| 505 | 505 | list($r,$g,$b) = $color; |
| 506 | 506 | $this->_pdf->setcolor("stroke", "rgb", $r, $g, $b, 0); |
| 507 | - } |
|
| 508 | - |
|
| 509 | - /** |
|
| 510 | - * Sets the fill color |
|
| 511 | - * |
|
| 512 | - * @param array $color array(r,g,b) |
|
| 513 | - */ |
|
| 514 | - protected function _set_fill_color($color) { |
|
| 507 | + } |
|
| 508 | + |
|
| 509 | + /** |
|
| 510 | + * Sets the fill color |
|
| 511 | + * |
|
| 512 | + * @param array $color array(r,g,b) |
|
| 513 | + */ |
|
| 514 | + protected function _set_fill_color($color) { |
|
| 515 | 515 | if($this->_last_fill_color == $color) |
| 516 | - return; |
|
| 516 | + return; |
|
| 517 | 517 | |
| 518 | 518 | $this->_last_fill_color = $color; |
| 519 | 519 | |
| 520 | 520 | list($r,$g,$b) = $color; |
| 521 | 521 | $this->_pdf->setcolor("fill", "rgb", $r, $g, $b, 0); |
| 522 | - } |
|
| 522 | + } |
|
| 523 | 523 | |
| 524 | - /** |
|
| 525 | - * Loads a specific font and stores the corresponding descriptor. |
|
| 526 | - * |
|
| 527 | - * @param string $font |
|
| 528 | - * @return int the font descriptor for the font |
|
| 529 | - */ |
|
| 530 | - protected function _load_font($font, $encoding = null, $options = "") { |
|
| 524 | + /** |
|
| 525 | + * Loads a specific font and stores the corresponding descriptor. |
|
| 526 | + * |
|
| 527 | + * @param string $font |
|
| 528 | + * @return int the font descriptor for the font |
|
| 529 | + */ |
|
| 530 | + protected function _load_font($font, $encoding = null, $options = "") { |
|
| 531 | 531 | |
| 532 | 532 | // Check if the font is a native PDF font |
| 533 | 533 | // Embed non-native fonts |
| 534 | 534 | $native_fonts = array("courier", "courier-bold", "courier-oblique", "courier-boldoblique", |
| 535 | - "helvetica", "helvetica-bold", "helvetica-oblique", "helvetica-boldoblique", |
|
| 536 | - "times-roman", "times-bold", "times-italic", "times-bolditalic", |
|
| 537 | - "symbol", "zapfdinbats"); |
|
| 535 | + "helvetica", "helvetica-bold", "helvetica-oblique", "helvetica-boldoblique", |
|
| 536 | + "times-roman", "times-bold", "times-italic", "times-bolditalic", |
|
| 537 | + "symbol", "zapfdinbats"); |
|
| 538 | 538 | |
| 539 | 539 | $test = strtolower(basename($font)); |
| 540 | 540 | if ( in_array($test, $native_fonts) ) { |
| 541 | - $font = basename($font); |
|
| 541 | + $font = basename($font); |
|
| 542 | 542 | |
| 543 | 543 | } else { |
| 544 | - // Embed non-native fonts |
|
| 545 | - $options .= " embedding=true"; |
|
| 544 | + // Embed non-native fonts |
|
| 545 | + $options .= " embedding=true"; |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | if ( is_null($encoding) ) { |
| 549 | 549 | |
| 550 | - // Unicode encoding is only available for the commerical |
|
| 551 | - // version of PDFlib and not PDFlib-Lite |
|
| 552 | - if ( defined("DOMPDF_PDFLIB_LICENSE") ) |
|
| 550 | + // Unicode encoding is only available for the commerical |
|
| 551 | + // version of PDFlib and not PDFlib-Lite |
|
| 552 | + if ( defined("DOMPDF_PDFLIB_LICENSE") ) |
|
| 553 | 553 | $encoding = "unicode"; |
| 554 | - else |
|
| 554 | + else |
|
| 555 | 555 | $encoding = "auto"; |
| 556 | 556 | |
| 557 | 557 | } |
@@ -559,28 +559,28 @@ discard block |
||
| 559 | 559 | $key = $font .":". $encoding .":". $options; |
| 560 | 560 | |
| 561 | 561 | if ( isset($this->_fonts[$key]) ) |
| 562 | - return $this->_fonts[$key]; |
|
| 562 | + return $this->_fonts[$key]; |
|
| 563 | 563 | |
| 564 | 564 | else { |
| 565 | 565 | |
| 566 | - $this->_fonts[$key] = $this->_pdf->load_font($font, $encoding, $options); |
|
| 567 | - return $this->_fonts[$key]; |
|
| 566 | + $this->_fonts[$key] = $this->_pdf->load_font($font, $encoding, $options); |
|
| 567 | + return $this->_fonts[$key]; |
|
| 568 | 568 | |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | - } |
|
| 571 | + } |
|
| 572 | 572 | |
| 573 | - /** |
|
| 574 | - * Remaps y coords from 4th to 1st quadrant |
|
| 575 | - * |
|
| 576 | - * @param float $y |
|
| 577 | - * @return float |
|
| 578 | - */ |
|
| 579 | - protected function y($y) { return $this->_height - $y; } |
|
| 573 | + /** |
|
| 574 | + * Remaps y coords from 4th to 1st quadrant |
|
| 575 | + * |
|
| 576 | + * @param float $y |
|
| 577 | + * @return float |
|
| 578 | + */ |
|
| 579 | + protected function y($y) { return $this->_height - $y; } |
|
| 580 | 580 | |
| 581 | - //........................................................................ |
|
| 581 | + //........................................................................ |
|
| 582 | 582 | |
| 583 | - function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
|
| 583 | + function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
|
| 584 | 584 | $this->_set_line_style($width, "butt", "", $style); |
| 585 | 585 | $this->_set_stroke_color($color); |
| 586 | 586 | |
@@ -590,11 +590,11 @@ discard block |
||
| 590 | 590 | $this->_pdf->moveto($x1,$y1); |
| 591 | 591 | $this->_pdf->lineto($x2, $y2); |
| 592 | 592 | $this->_pdf->stroke(); |
| 593 | - } |
|
| 593 | + } |
|
| 594 | 594 | |
| 595 | - //........................................................................ |
|
| 595 | + //........................................................................ |
|
| 596 | 596 | |
| 597 | - function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
|
| 597 | + function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
|
| 598 | 598 | $this->_set_stroke_color($color); |
| 599 | 599 | $this->_set_line_style($width, "square", "miter", $style); |
| 600 | 600 | |
@@ -602,93 +602,93 @@ discard block |
||
| 602 | 602 | |
| 603 | 603 | $this->_pdf->rect($x1, $y1, $w, $h); |
| 604 | 604 | $this->_pdf->stroke(); |
| 605 | - } |
|
| 605 | + } |
|
| 606 | 606 | |
| 607 | - //........................................................................ |
|
| 607 | + //........................................................................ |
|
| 608 | 608 | |
| 609 | - function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
| 609 | + function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
| 610 | 610 | $this->_set_fill_color($color); |
| 611 | 611 | |
| 612 | 612 | $y1 = $this->y($y1) - $h; |
| 613 | 613 | |
| 614 | 614 | $this->_pdf->rect($x1, $y1, $w, $h); |
| 615 | 615 | $this->_pdf->fill(); |
| 616 | - } |
|
| 616 | + } |
|
| 617 | 617 | |
| 618 | - //........................................................................ |
|
| 618 | + //........................................................................ |
|
| 619 | 619 | |
| 620 | - function polygon($points, $color, $width = null, $style = null, $fill = false) { |
|
| 620 | + function polygon($points, $color, $width = null, $style = null, $fill = false) { |
|
| 621 | 621 | |
| 622 | 622 | $this->_set_fill_color($color); |
| 623 | 623 | $this->_set_stroke_color($color); |
| 624 | 624 | |
| 625 | 625 | if ( !$fill && isset($width) ) |
| 626 | - $this->_set_line_style($width, "square", "miter", $style); |
|
| 626 | + $this->_set_line_style($width, "square", "miter", $style); |
|
| 627 | 627 | |
| 628 | 628 | $y = $this->y(array_pop($points)); |
| 629 | 629 | $x = array_pop($points); |
| 630 | 630 | $this->_pdf->moveto($x,$y); |
| 631 | 631 | |
| 632 | 632 | while (count($points) > 1) { |
| 633 | - $y = $this->y(array_pop($points)); |
|
| 634 | - $x = array_pop($points); |
|
| 635 | - $this->_pdf->lineto($x,$y); |
|
| 633 | + $y = $this->y(array_pop($points)); |
|
| 634 | + $x = array_pop($points); |
|
| 635 | + $this->_pdf->lineto($x,$y); |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | if ( $fill ) |
| 639 | - $this->_pdf->fill(); |
|
| 639 | + $this->_pdf->fill(); |
|
| 640 | 640 | else |
| 641 | - $this->_pdf->closepath_stroke(); |
|
| 642 | - } |
|
| 641 | + $this->_pdf->closepath_stroke(); |
|
| 642 | + } |
|
| 643 | 643 | |
| 644 | - //........................................................................ |
|
| 644 | + //........................................................................ |
|
| 645 | 645 | |
| 646 | - function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) { |
|
| 646 | + function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) { |
|
| 647 | 647 | |
| 648 | 648 | $this->_set_fill_color($color); |
| 649 | 649 | $this->_set_stroke_color($color); |
| 650 | 650 | |
| 651 | 651 | if ( !$fill && isset($width) ) |
| 652 | - $this->_set_line_style($width, "round", "round", $style); |
|
| 652 | + $this->_set_line_style($width, "round", "round", $style); |
|
| 653 | 653 | |
| 654 | 654 | $y = $this->y($y); |
| 655 | 655 | |
| 656 | 656 | $this->_pdf->circle($x, $y, $r); |
| 657 | 657 | |
| 658 | 658 | if ( $fill ) |
| 659 | - $this->_pdf->fill(); |
|
| 659 | + $this->_pdf->fill(); |
|
| 660 | 660 | else |
| 661 | - $this->_pdf->stroke(); |
|
| 661 | + $this->_pdf->stroke(); |
|
| 662 | 662 | |
| 663 | - } |
|
| 663 | + } |
|
| 664 | 664 | |
| 665 | - //........................................................................ |
|
| 665 | + //........................................................................ |
|
| 666 | 666 | |
| 667 | - function image($img_url, $img_type, $x, $y, $w, $h) { |
|
| 667 | + function image($img_url, $img_type, $x, $y, $w, $h) { |
|
| 668 | 668 | $w = (int)$w; |
| 669 | 669 | $h = (int)$h; |
| 670 | 670 | |
| 671 | 671 | $img_type = strtolower($img_type); |
| 672 | 672 | |
| 673 | 673 | if ( $img_type === "jpg" ) |
| 674 | - $img_type = "jpeg"; |
|
| 674 | + $img_type = "jpeg"; |
|
| 675 | 675 | |
| 676 | 676 | if ( isset($this->_imgs[$img_url]) ) |
| 677 | - $img = $this->_imgs[$img_url]; |
|
| 677 | + $img = $this->_imgs[$img_url]; |
|
| 678 | 678 | |
| 679 | 679 | else { |
| 680 | 680 | |
| 681 | - $img = $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, ""); |
|
| 681 | + $img = $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, ""); |
|
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | $y = $this->y($y) - $h; |
| 685 | 685 | $this->_pdf->fit_image($img, $x, $y, 'boxsize={'. "$w $h" .'} fitmethod=entire'); |
| 686 | 686 | |
| 687 | - } |
|
| 687 | + } |
|
| 688 | 688 | |
| 689 | - //........................................................................ |
|
| 689 | + //........................................................................ |
|
| 690 | 690 | |
| 691 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
| 691 | + function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
| 692 | 692 | $fh = $this->_load_font($font); |
| 693 | 693 | |
| 694 | 694 | $this->_pdf->setfont($fh, $size); |
@@ -701,72 +701,72 @@ discard block |
||
| 701 | 701 | |
| 702 | 702 | $this->_pdf->fit_textline($text, $x, $y, "rotate=$angle wordspacing=$adjust"); |
| 703 | 703 | |
| 704 | - } |
|
| 704 | + } |
|
| 705 | 705 | |
| 706 | - //........................................................................ |
|
| 706 | + //........................................................................ |
|
| 707 | 707 | |
| 708 | - function javascript($code) { |
|
| 708 | + function javascript($code) { |
|
| 709 | 709 | // Not implemented |
| 710 | - } |
|
| 710 | + } |
|
| 711 | 711 | |
| 712 | - //........................................................................ |
|
| 712 | + //........................................................................ |
|
| 713 | 713 | |
| 714 | - /** |
|
| 715 | - * Add a named destination (similar to <a name="foo">...</a> in html) |
|
| 716 | - * |
|
| 717 | - * @param string $anchorname The name of the named destination |
|
| 718 | - */ |
|
| 719 | - function add_named_dest($anchorname) { |
|
| 714 | + /** |
|
| 715 | + * Add a named destination (similar to <a name="foo">...</a> in html) |
|
| 716 | + * |
|
| 717 | + * @param string $anchorname The name of the named destination |
|
| 718 | + */ |
|
| 719 | + function add_named_dest($anchorname) { |
|
| 720 | 720 | $this->_pdf->add_nameddest($anchorname,""); |
| 721 | - } |
|
| 721 | + } |
|
| 722 | 722 | |
| 723 | - //........................................................................ |
|
| 723 | + //........................................................................ |
|
| 724 | 724 | |
| 725 | - /** |
|
| 726 | - * Add a link to the pdf |
|
| 727 | - * |
|
| 728 | - * @param string $url The url to link to |
|
| 729 | - * @param float $x The x position of the link |
|
| 730 | - * @param float $y The y position of the link |
|
| 731 | - * @param float $width The width of the link |
|
| 732 | - * @param float $height The height of the link |
|
| 733 | - */ |
|
| 734 | - function add_link($url, $x, $y, $width, $height) { |
|
| 725 | + /** |
|
| 726 | + * Add a link to the pdf |
|
| 727 | + * |
|
| 728 | + * @param string $url The url to link to |
|
| 729 | + * @param float $x The x position of the link |
|
| 730 | + * @param float $y The y position of the link |
|
| 731 | + * @param float $width The width of the link |
|
| 732 | + * @param float $height The height of the link |
|
| 733 | + */ |
|
| 734 | + function add_link($url, $x, $y, $width, $height) { |
|
| 735 | 735 | |
| 736 | 736 | $y = $this->y($y) - $height; |
| 737 | 737 | if ( strpos($url, '#') === 0 ) { |
| 738 | - // Local link |
|
| 739 | - $name = substr($url,1); |
|
| 740 | - if ( $name ) |
|
| 738 | + // Local link |
|
| 739 | + $name = substr($url,1); |
|
| 740 | + if ( $name ) |
|
| 741 | 741 | $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=". substr($url,1) . " linewidth=0"); |
| 742 | 742 | } else { |
| 743 | 743 | |
| 744 | - list($proto, $host, $path, $file) = explode_url($url); |
|
| 744 | + list($proto, $host, $path, $file) = explode_url($url); |
|
| 745 | 745 | |
| 746 | - if ( $proto == "" || $proto === "file://" ) |
|
| 746 | + if ( $proto == "" || $proto === "file://" ) |
|
| 747 | 747 | return; // Local links are not allowed |
| 748 | - $url = build_url($proto, $host, $path, $file); |
|
| 749 | - $url = '{' . rawurldecode($url) . '}'; |
|
| 748 | + $url = build_url($proto, $host, $path, $file); |
|
| 749 | + $url = '{' . rawurldecode($url) . '}'; |
|
| 750 | 750 | |
| 751 | - $action = $this->_pdf->create_action("URI", "url=" . $url); |
|
| 752 | - $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} action={activate=$action} linewidth=0"); |
|
| 751 | + $action = $this->_pdf->create_action("URI", "url=" . $url); |
|
| 752 | + $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} action={activate=$action} linewidth=0"); |
|
| 753 | + } |
|
| 753 | 754 | } |
| 754 | - } |
|
| 755 | 755 | |
| 756 | - //........................................................................ |
|
| 756 | + //........................................................................ |
|
| 757 | 757 | |
| 758 | - function get_text_width($text, $font, $size, $spacing = 0) { |
|
| 758 | + function get_text_width($text, $font, $size, $spacing = 0) { |
|
| 759 | 759 | $fh = $this->_load_font($font); |
| 760 | 760 | |
| 761 | 761 | // Determine the additional width due to extra spacing |
| 762 | 762 | $num_spaces = mb_substr_count($text," "); |
| 763 | 763 | $delta = $spacing * $num_spaces; |
| 764 | 764 | return $this->_pdf->stringwidth($text, $fh, $size) + $delta; |
| 765 | - } |
|
| 765 | + } |
|
| 766 | 766 | |
| 767 | - //........................................................................ |
|
| 767 | + //........................................................................ |
|
| 768 | 768 | |
| 769 | - function get_font_height($font, $size) { |
|
| 769 | + function get_font_height($font, $size) { |
|
| 770 | 770 | |
| 771 | 771 | $fh = $this->_load_font($font); |
| 772 | 772 | |
@@ -777,54 +777,54 @@ discard block |
||
| 777 | 777 | |
| 778 | 778 | // $desc is usually < 0, |
| 779 | 779 | return self::FONT_HEIGHT_SCALE * $size * ($asc - $desc); |
| 780 | - } |
|
| 781 | - |
|
| 782 | - //........................................................................ |
|
| 783 | - |
|
| 784 | - /** |
|
| 785 | - * Writes text at the specified x and y coordinates on every page |
|
| 786 | - * |
|
| 787 | - * The strings '{PAGE_NUM}' and '{PAGE_COUNT}' are automatically replaced |
|
| 788 | - * with their current values. |
|
| 789 | - * |
|
| 790 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
| 791 | - * |
|
| 792 | - * @param float $x |
|
| 793 | - * @param float $y |
|
| 794 | - * @param string $text the text to write |
|
| 795 | - * @param string $font the font file to use |
|
| 796 | - * @param float $size the font size, in points |
|
| 797 | - * @param array $color |
|
| 798 | - * @param float $adjust word spacing adjustment |
|
| 799 | - * @param float $angle angle to write the text at, measured CW starting from the x-axis |
|
| 800 | - */ |
|
| 801 | - function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), |
|
| 802 | - $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0) { |
|
| 780 | + } |
|
| 781 | + |
|
| 782 | + //........................................................................ |
|
| 783 | + |
|
| 784 | + /** |
|
| 785 | + * Writes text at the specified x and y coordinates on every page |
|
| 786 | + * |
|
| 787 | + * The strings '{PAGE_NUM}' and '{PAGE_COUNT}' are automatically replaced |
|
| 788 | + * with their current values. |
|
| 789 | + * |
|
| 790 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
| 791 | + * |
|
| 792 | + * @param float $x |
|
| 793 | + * @param float $y |
|
| 794 | + * @param string $text the text to write |
|
| 795 | + * @param string $font the font file to use |
|
| 796 | + * @param float $size the font size, in points |
|
| 797 | + * @param array $color |
|
| 798 | + * @param float $adjust word spacing adjustment |
|
| 799 | + * @param float $angle angle to write the text at, measured CW starting from the x-axis |
|
| 800 | + */ |
|
| 801 | + function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), |
|
| 802 | + $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0) { |
|
| 803 | 803 | $_t = "text"; |
| 804 | 804 | $this->_page_text[] = compact("_t", "x", "y", "text", "font", "size", "color", "adjust", "angle"); |
| 805 | - } |
|
| 806 | - |
|
| 807 | - //........................................................................ |
|
| 808 | - |
|
| 809 | - /** |
|
| 810 | - * Processes a script on every page |
|
| 811 | - * |
|
| 812 | - * The variables $pdf, $PAGE_NUM, and $PAGE_COUNT are available. |
|
| 813 | - * |
|
| 814 | - * This function can be used to add page numbers to all pages |
|
| 815 | - * after the first one, for example. |
|
| 816 | - * |
|
| 817 | - * @param string $code the script code |
|
| 818 | - * @param string $type the language type for script |
|
| 819 | - */ |
|
| 820 | - function page_script($code, $type = "text/php") { |
|
| 805 | + } |
|
| 806 | + |
|
| 807 | + //........................................................................ |
|
| 808 | + |
|
| 809 | + /** |
|
| 810 | + * Processes a script on every page |
|
| 811 | + * |
|
| 812 | + * The variables $pdf, $PAGE_NUM, and $PAGE_COUNT are available. |
|
| 813 | + * |
|
| 814 | + * This function can be used to add page numbers to all pages |
|
| 815 | + * after the first one, for example. |
|
| 816 | + * |
|
| 817 | + * @param string $code the script code |
|
| 818 | + * @param string $type the language type for script |
|
| 819 | + */ |
|
| 820 | + function page_script($code, $type = "text/php") { |
|
| 821 | 821 | $_t = "script"; |
| 822 | 822 | $this->_page_text[] = compact("_t", "code", "type"); |
| 823 | - } |
|
| 823 | + } |
|
| 824 | 824 | |
| 825 | - //........................................................................ |
|
| 825 | + //........................................................................ |
|
| 826 | 826 | |
| 827 | - function new_page() { |
|
| 827 | + function new_page() { |
|
| 828 | 828 | |
| 829 | 829 | // Add objects to the current page |
| 830 | 830 | $this->_place_objects(); |
@@ -833,69 +833,69 @@ discard block |
||
| 833 | 833 | $this->_pdf->begin_page_ext($this->_width, $this->_height, ""); |
| 834 | 834 | $this->_page_number = ++$this->_page_count; |
| 835 | 835 | |
| 836 | - } |
|
| 836 | + } |
|
| 837 | 837 | |
| 838 | - //........................................................................ |
|
| 838 | + //........................................................................ |
|
| 839 | 839 | |
| 840 | - /** |
|
| 841 | - * Add text to each page after rendering is complete |
|
| 842 | - */ |
|
| 843 | - protected function _add_page_text() { |
|
| 840 | + /** |
|
| 841 | + * Add text to each page after rendering is complete |
|
| 842 | + */ |
|
| 843 | + protected function _add_page_text() { |
|
| 844 | 844 | |
| 845 | 845 | if ( !count($this->_page_text) ) |
| 846 | - return; |
|
| 846 | + return; |
|
| 847 | 847 | |
| 848 | 848 | $this->_pdf->suspend_page(""); |
| 849 | 849 | |
| 850 | 850 | for ($p = 1; $p <= $this->_page_count; $p++) { |
| 851 | - $this->_pdf->resume_page("pagenumber=$p"); |
|
| 851 | + $this->_pdf->resume_page("pagenumber=$p"); |
|
| 852 | 852 | |
| 853 | - foreach ($this->_page_text as $pt) { |
|
| 853 | + foreach ($this->_page_text as $pt) { |
|
| 854 | 854 | extract($pt); |
| 855 | 855 | |
| 856 | 856 | switch ($_t) { |
| 857 | 857 | |
| 858 | 858 | case "text": |
| 859 | 859 | $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"), |
| 860 | - array($p, $this->_page_count), $text); |
|
| 861 | - $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
|
| 862 | - break; |
|
| 860 | + array($p, $this->_page_count), $text); |
|
| 861 | + $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
|
| 862 | + break; |
|
| 863 | 863 | |
| 864 | 864 | case "script": |
| 865 | 865 | if (!$eval) { |
| 866 | 866 | $eval = new PHP_Evaluator($this); |
| 867 | - } |
|
| 868 | - $eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count)); |
|
| 869 | - break; |
|
| 867 | + } |
|
| 868 | + $eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count)); |
|
| 869 | + break; |
|
| 870 | + } |
|
| 870 | 871 | } |
| 871 | - } |
|
| 872 | 872 | |
| 873 | - $this->_pdf->suspend_page(""); |
|
| 873 | + $this->_pdf->suspend_page(""); |
|
| 874 | 874 | } |
| 875 | 875 | |
| 876 | 876 | $this->_pdf->resume_page("pagenumber=".$this->_page_number); |
| 877 | - } |
|
| 877 | + } |
|
| 878 | 878 | |
| 879 | - //........................................................................ |
|
| 879 | + //........................................................................ |
|
| 880 | 880 | |
| 881 | - function stream($filename, $options = null) { |
|
| 881 | + function stream($filename, $options = null) { |
|
| 882 | 882 | |
| 883 | 883 | // Add page text |
| 884 | 884 | $this->_add_page_text(); |
| 885 | 885 | |
| 886 | 886 | if ( isset($options["compress"]) && $options["compress"] != 1 ) |
| 887 | - $this->_pdf->set_value("compress", 0); |
|
| 887 | + $this->_pdf->set_value("compress", 0); |
|
| 888 | 888 | else |
| 889 | - $this->_pdf->set_value("compress", 6); |
|
| 889 | + $this->_pdf->set_value("compress", 6); |
|
| 890 | 890 | |
| 891 | 891 | $this->_close(); |
| 892 | 892 | |
| 893 | 893 | if ( self::$IN_MEMORY ) { |
| 894 | - $data = $this->_pdf->get_buffer(); |
|
| 895 | - $size = strlen($data); |
|
| 894 | + $data = $this->_pdf->get_buffer(); |
|
| 895 | + $size = strlen($data); |
|
| 896 | 896 | |
| 897 | 897 | } else |
| 898 | - $size = filesize($this->_file); |
|
| 898 | + $size = filesize($this->_file); |
|
| 899 | 899 | |
| 900 | 900 | |
| 901 | 901 | $filename = str_replace(array("\n","'"),"", $filename); |
@@ -908,63 +908,63 @@ discard block |
||
| 908 | 908 | //header("Content-length: " . $size); |
| 909 | 909 | |
| 910 | 910 | if ( self::$IN_MEMORY ) |
| 911 | - echo $data; |
|
| 911 | + echo $data; |
|
| 912 | 912 | |
| 913 | 913 | else { |
| 914 | 914 | |
| 915 | - // Chunked readfile() |
|
| 916 | - $chunk = (1 << 21); // 2 MB |
|
| 917 | - $fh = fopen($this->_file, "rb"); |
|
| 918 | - if ( !$fh ) |
|
| 915 | + // Chunked readfile() |
|
| 916 | + $chunk = (1 << 21); // 2 MB |
|
| 917 | + $fh = fopen($this->_file, "rb"); |
|
| 918 | + if ( !$fh ) |
|
| 919 | 919 | throw new DOMPDF_Exception("Unable to load temporary PDF file: " . $this->_file); |
| 920 | 920 | |
| 921 | - while ( !feof($fh) ) |
|
| 921 | + while ( !feof($fh) ) |
|
| 922 | 922 | echo fread($fh,$chunk); |
| 923 | - fclose($fh); |
|
| 923 | + fclose($fh); |
|
| 924 | 924 | |
| 925 | - //debugpng |
|
| 926 | - if (DEBUGPNG) print '[pdflib stream unlink '.$this->_file.']'; |
|
| 927 | - if (!DEBUGKEEPTEMP) |
|
| 925 | + //debugpng |
|
| 926 | + if (DEBUGPNG) print '[pdflib stream unlink '.$this->_file.']'; |
|
| 927 | + if (!DEBUGKEEPTEMP) |
|
| 928 | 928 | |
| 929 | - unlink($this->_file); |
|
| 930 | - $this->_file = null; |
|
| 929 | + unlink($this->_file); |
|
| 930 | + $this->_file = null; |
|
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | flush(); |
| 934 | 934 | |
| 935 | 935 | |
| 936 | - } |
|
| 936 | + } |
|
| 937 | 937 | |
| 938 | - //........................................................................ |
|
| 938 | + //........................................................................ |
|
| 939 | 939 | |
| 940 | - function output($options = null) { |
|
| 940 | + function output($options = null) { |
|
| 941 | 941 | |
| 942 | 942 | // Add page text |
| 943 | 943 | $this->_add_page_text(); |
| 944 | 944 | |
| 945 | 945 | if ( isset($options["compress"]) && $options["compress"] != 1 ) |
| 946 | - $this->_pdf->set_value("compress", 0); |
|
| 946 | + $this->_pdf->set_value("compress", 0); |
|
| 947 | 947 | else |
| 948 | - $this->_pdf->set_value("compress", 6); |
|
| 948 | + $this->_pdf->set_value("compress", 6); |
|
| 949 | 949 | |
| 950 | 950 | $this->_close(); |
| 951 | 951 | |
| 952 | 952 | if ( self::$IN_MEMORY ) |
| 953 | - $data = $this->_pdf->get_buffer(); |
|
| 953 | + $data = $this->_pdf->get_buffer(); |
|
| 954 | 954 | |
| 955 | 955 | else { |
| 956 | - $data = file_get_contents($this->_file); |
|
| 956 | + $data = file_get_contents($this->_file); |
|
| 957 | 957 | |
| 958 | - //debugpng |
|
| 959 | - if (DEBUGPNG) print '[pdflib output unlink '.$this->_file.']'; |
|
| 960 | - if (!DEBUGKEEPTEMP) |
|
| 958 | + //debugpng |
|
| 959 | + if (DEBUGPNG) print '[pdflib output unlink '.$this->_file.']'; |
|
| 960 | + if (!DEBUGKEEPTEMP) |
|
| 961 | 961 | |
| 962 | - unlink($this->_file); |
|
| 963 | - $this->_file = null; |
|
| 962 | + unlink($this->_file); |
|
| 963 | + $this->_file = null; |
|
| 964 | 964 | } |
| 965 | 965 | |
| 966 | 966 | return $data; |
| 967 | - } |
|
| 967 | + } |
|
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | // Workaround for idiotic limitation on statics... |
@@ -454,37 +454,37 @@ discard block |
||
| 454 | 454 | $this->_pdf->setdash(0,0); |
| 455 | 455 | |
| 456 | 456 | switch ( $join ) { |
| 457 | - case "miter": |
|
| 458 | - $this->_pdf->setlinejoin(0); |
|
| 459 | - break; |
|
| 457 | + case "miter": |
|
| 458 | + $this->_pdf->setlinejoin(0); |
|
| 459 | + break; |
|
| 460 | 460 | |
| 461 | - case "round": |
|
| 462 | - $this->_pdf->setlinejoin(1); |
|
| 463 | - break; |
|
| 461 | + case "round": |
|
| 462 | + $this->_pdf->setlinejoin(1); |
|
| 463 | + break; |
|
| 464 | 464 | |
| 465 | - case "bevel": |
|
| 466 | - $this->_pdf->setlinejoin(2); |
|
| 467 | - break; |
|
| 465 | + case "bevel": |
|
| 466 | + $this->_pdf->setlinejoin(2); |
|
| 467 | + break; |
|
| 468 | 468 | |
| 469 | - default: |
|
| 470 | - break; |
|
| 469 | + default: |
|
| 470 | + break; |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | switch ( $cap ) { |
| 474 | - case "butt": |
|
| 475 | - $this->_pdf->setlinecap(0); |
|
| 476 | - break; |
|
| 474 | + case "butt": |
|
| 475 | + $this->_pdf->setlinecap(0); |
|
| 476 | + break; |
|
| 477 | 477 | |
| 478 | - case "round": |
|
| 479 | - $this->_pdf->setlinecap(1); |
|
| 480 | - break; |
|
| 478 | + case "round": |
|
| 479 | + $this->_pdf->setlinecap(1); |
|
| 480 | + break; |
|
| 481 | 481 | |
| 482 | - case "square": |
|
| 483 | - $this->_pdf->setlinecap(2); |
|
| 484 | - break; |
|
| 482 | + case "square": |
|
| 483 | + $this->_pdf->setlinecap(2); |
|
| 484 | + break; |
|
| 485 | 485 | |
| 486 | - default: |
|
| 487 | - break; |
|
| 486 | + default: |
|
| 487 | + break; |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | $this->_pdf->setlinewidth($width); |
@@ -855,18 +855,18 @@ discard block |
||
| 855 | 855 | |
| 856 | 856 | switch ($_t) { |
| 857 | 857 | |
| 858 | - case "text": |
|
| 859 | - $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"), |
|
| 860 | - array($p, $this->_page_count), $text); |
|
| 861 | - $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
|
| 862 | - break; |
|
| 863 | - |
|
| 864 | - case "script": |
|
| 865 | - if (!$eval) { |
|
| 866 | - $eval = new PHP_Evaluator($this); |
|
| 867 | - } |
|
| 868 | - $eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count)); |
|
| 869 | - break; |
|
| 858 | + case "text": |
|
| 859 | + $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"), |
|
| 860 | + array($p, $this->_page_count), $text); |
|
| 861 | + $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
|
| 862 | + break; |
|
| 863 | + |
|
| 864 | + case "script": |
|
| 865 | + if (!$eval) { |
|
| 866 | + $eval = new PHP_Evaluator($this); |
|
| 867 | + } |
|
| 868 | + $eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count)); |
|
| 869 | + break; |
|
| 870 | 870 | } |
| 871 | 871 | } |
| 872 | 872 | |
@@ -185,25 +185,25 @@ discard block |
||
| 185 | 185 | * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
| 186 | 186 | */ |
| 187 | 187 | function __construct($paper = "letter", $orientation = "portrait") { |
| 188 | - if ( is_array($paper) ) |
|
| 188 | + if (is_array($paper)) |
|
| 189 | 189 | $size = $paper; |
| 190 | - else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) |
|
| 190 | + else if (isset(self::$PAPER_SIZES[mb_strtolower($paper)])) |
|
| 191 | 191 | $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
| 192 | 192 | else |
| 193 | 193 | $size = self::$PAPER_SIZES["letter"]; |
| 194 | 194 | |
| 195 | - if ( mb_strtolower($orientation) === "landscape" ) { |
|
| 195 | + if (mb_strtolower($orientation) === "landscape") { |
|
| 196 | 196 | $a = $size[3]; |
| 197 | 197 | $size[3] = $size[2]; |
| 198 | 198 | $size[2] = $a; |
| 199 | 199 | } |
| 200 | 200 | $this->_width = $size[2] - $size[0]; |
| 201 | - $this->_height= $size[3] - $size[1]; |
|
| 201 | + $this->_height = $size[3] - $size[1]; |
|
| 202 | 202 | |
| 203 | 203 | $this->_pdf = new PDFLib(); |
| 204 | 204 | |
| 205 | - if ( defined("DOMPDF_PDFLIB_LICENSE") ) |
|
| 206 | - $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE); |
|
| 205 | + if (defined("DOMPDF_PDFLIB_LICENSE")) |
|
| 206 | + $this->_pdf->set_parameter("license", DOMPDF_PDFLIB_LICENSE); |
|
| 207 | 207 | |
| 208 | 208 | $this->_pdf->set_parameter("textformat", "utf8"); |
| 209 | 209 | $this->_pdf->set_parameter("fontwarning", "false"); |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | $this->_pdf->set_info("Creator", "DOMPDF Converter"); |
| 212 | 212 | |
| 213 | 213 | // Silence pedantic warnings about missing TZ settings |
| 214 | - if ( function_exists("date_default_timezone_get") ) { |
|
| 214 | + if (function_exists("date_default_timezone_get")) { |
|
| 215 | 215 | $tz = @date_default_timezone_get(); |
| 216 | 216 | date_default_timezone_set("UTC"); |
| 217 | 217 | $this->_pdf->set_info("Date", date("Y-m-d")); |
@@ -220,11 +220,11 @@ discard block |
||
| 220 | 220 | $this->_pdf->set_info("Date", date("Y-m-d")); |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - if ( self::$IN_MEMORY ) |
|
| 224 | - $this->_pdf->begin_document("",""); |
|
| 223 | + if (self::$IN_MEMORY) |
|
| 224 | + $this->_pdf->begin_document("", ""); |
|
| 225 | 225 | else { |
| 226 | 226 | $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf'; |
| 227 | - $this->_pdf->begin_document($this->_file,""); |
|
| 227 | + $this->_pdf->begin_document($this->_file, ""); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | $this->_pdf->begin_page_ext($this->_width, $this->_height, ""); |
@@ -243,29 +243,29 @@ discard block |
||
| 243 | 243 | $face = basename($file); |
| 244 | 244 | |
| 245 | 245 | // Prefer ttfs to afms |
| 246 | - if ( file_exists($file.".ttf") ) { |
|
| 246 | + if (file_exists($file.".ttf")) { |
|
| 247 | 247 | $outline = "$file.ttf"; |
| 248 | 248 | $afm = null; |
| 249 | 249 | |
| 250 | - } else if ( file_exists($file .".TTF") ) { |
|
| 250 | + } else if (file_exists($file.".TTF")) { |
|
| 251 | 251 | $outline = "$file.TTF"; |
| 252 | 252 | $afm = null; |
| 253 | 253 | |
| 254 | - } else if ( file_exists($file . ".pfb") ) { |
|
| 254 | + } else if (file_exists($file.".pfb")) { |
|
| 255 | 255 | $outline = "$file.pfb"; |
| 256 | 256 | |
| 257 | - if ( file_exists($file . ".afm") ) |
|
| 257 | + if (file_exists($file.".afm")) |
|
| 258 | 258 | $afm = "$file.afm"; |
| 259 | 259 | |
| 260 | - } else if ( file_exists($file . ".PFB") ) { |
|
| 260 | + } else if (file_exists($file.".PFB")) { |
|
| 261 | 261 | $outline = "$file.PFB"; |
| 262 | - if ( file_exists($file . ".AFM") ) |
|
| 262 | + if (file_exists($file.".AFM")) |
|
| 263 | 263 | $afm = "$file.AFM"; |
| 264 | 264 | } else |
| 265 | 265 | continue; |
| 266 | 266 | |
| 267 | 267 | $this->_pdf->set_parameter("FontOutline", "\{$face\}=\{$outline\}"); |
| 268 | - if ( !is_null($afm) ) |
|
| 268 | + if (!is_null($afm)) |
|
| 269 | 269 | $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}"); |
| 270 | 270 | } |
| 271 | 271 | } |
@@ -366,10 +366,10 @@ discard block |
||
| 366 | 366 | */ |
| 367 | 367 | function add_object($object, $where = 'all') { |
| 368 | 368 | |
| 369 | - if ( mb_strpos($where, "next") !== false ) { |
|
| 369 | + if (mb_strpos($where, "next") !== false) { |
|
| 370 | 370 | $this->_objs[$object]["start_page"]++; |
| 371 | 371 | $where = str_replace("next", "", $where); |
| 372 | - if ( $where == "" ) |
|
| 372 | + if ($where == "") |
|
| 373 | 373 | $where = "add"; |
| 374 | 374 | } |
| 375 | 375 | |
@@ -386,18 +386,18 @@ discard block |
||
| 386 | 386 | */ |
| 387 | 387 | function stop_object($object) { |
| 388 | 388 | |
| 389 | - if ( !isset($this->_objs[$object]) ) |
|
| 389 | + if (!isset($this->_objs[$object])) |
|
| 390 | 390 | return; |
| 391 | 391 | |
| 392 | 392 | $start = $this->_objs[$object]["start_page"]; |
| 393 | 393 | $where = $this->_objs[$object]["where"]; |
| 394 | 394 | |
| 395 | 395 | // Place the object on this page if required |
| 396 | - if ( $this->_page_number >= $start && |
|
| 396 | + if ($this->_page_number >= $start && |
|
| 397 | 397 | (($this->_page_number % 2 == 0 && $where === "even") || |
| 398 | 398 | ($this->_page_number % 2 == 1 && $where === "odd") || |
| 399 | - ($where === "all")) ) |
|
| 400 | - $this->_pdf->fit_image($object,0,0,""); |
|
| 399 | + ($where === "all"))) |
|
| 400 | + $this->_pdf->fit_image($object, 0, 0, ""); |
|
| 401 | 401 | |
| 402 | 402 | unset($this->_objs[$object]); |
| 403 | 403 | } |
@@ -407,16 +407,16 @@ discard block |
||
| 407 | 407 | */ |
| 408 | 408 | protected function _place_objects() { |
| 409 | 409 | |
| 410 | - foreach ( $this->_objs as $obj => $props ) { |
|
| 410 | + foreach ($this->_objs as $obj => $props) { |
|
| 411 | 411 | $start = $props["start_page"]; |
| 412 | 412 | $where = $props["where"]; |
| 413 | 413 | |
| 414 | 414 | // Place the object on this page if required |
| 415 | - if ( $this->_page_number >= $start && |
|
| 415 | + if ($this->_page_number >= $start && |
|
| 416 | 416 | (($this->_page_number % 2 == 0 && $where === "even") || |
| 417 | 417 | ($this->_page_number % 2 == 1 && $where === "odd") || |
| 418 | - ($where === "all")) ) { |
|
| 419 | - $this->_pdf->fit_image($obj,0,0,""); |
|
| 418 | + ($where === "all"))) { |
|
| 419 | + $this->_pdf->fit_image($obj, 0, 0, ""); |
|
| 420 | 420 | } |
| 421 | 421 | } |
| 422 | 422 | |
@@ -430,9 +430,9 @@ discard block |
||
| 430 | 430 | |
| 431 | 431 | function get_page_count() { return $this->_page_count; } |
| 432 | 432 | |
| 433 | - function set_page_number($num) { $this->_page_number = (int)$num; } |
|
| 433 | + function set_page_number($num) { $this->_page_number = (int) $num; } |
|
| 434 | 434 | |
| 435 | - function set_page_count($count) { $this->_page_count = (int)$count; } |
|
| 435 | + function set_page_count($count) { $this->_page_count = (int) $count; } |
|
| 436 | 436 | |
| 437 | 437 | |
| 438 | 438 | /** |
@@ -445,15 +445,15 @@ discard block |
||
| 445 | 445 | */ |
| 446 | 446 | protected function _set_line_style($width, $cap, $join, $dash) { |
| 447 | 447 | |
| 448 | - if ( count($dash) == 1 ) |
|
| 448 | + if (count($dash) == 1) |
|
| 449 | 449 | $dash[] = $dash[0]; |
| 450 | 450 | |
| 451 | - if ( count($dash) > 1 ) |
|
| 452 | - $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}"); |
|
| 451 | + if (count($dash) > 1) |
|
| 452 | + $this->_pdf->setdashpattern("dasharray={".join(" ", $dash)."}"); |
|
| 453 | 453 | else |
| 454 | - $this->_pdf->setdash(0,0); |
|
| 454 | + $this->_pdf->setdash(0, 0); |
|
| 455 | 455 | |
| 456 | - switch ( $join ) { |
|
| 456 | + switch ($join) { |
|
| 457 | 457 | case "miter": |
| 458 | 458 | $this->_pdf->setlinejoin(0); |
| 459 | 459 | break; |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | break; |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - switch ( $cap ) { |
|
| 473 | + switch ($cap) { |
|
| 474 | 474 | case "butt": |
| 475 | 475 | $this->_pdf->setlinecap(0); |
| 476 | 476 | break; |
@@ -497,12 +497,12 @@ discard block |
||
| 497 | 497 | * @param array $color array(r,g,b) |
| 498 | 498 | */ |
| 499 | 499 | protected function _set_stroke_color($color) { |
| 500 | - if($this->_last_stroke_color == $color) |
|
| 500 | + if ($this->_last_stroke_color == $color) |
|
| 501 | 501 | return; |
| 502 | 502 | |
| 503 | 503 | $this->_last_stroke_color = $color; |
| 504 | 504 | |
| 505 | - list($r,$g,$b) = $color; |
|
| 505 | + list($r, $g, $b) = $color; |
|
| 506 | 506 | $this->_pdf->setcolor("stroke", "rgb", $r, $g, $b, 0); |
| 507 | 507 | } |
| 508 | 508 | |
@@ -512,12 +512,12 @@ discard block |
||
| 512 | 512 | * @param array $color array(r,g,b) |
| 513 | 513 | */ |
| 514 | 514 | protected function _set_fill_color($color) { |
| 515 | - if($this->_last_fill_color == $color) |
|
| 515 | + if ($this->_last_fill_color == $color) |
|
| 516 | 516 | return; |
| 517 | 517 | |
| 518 | 518 | $this->_last_fill_color = $color; |
| 519 | 519 | |
| 520 | - list($r,$g,$b) = $color; |
|
| 520 | + list($r, $g, $b) = $color; |
|
| 521 | 521 | $this->_pdf->setcolor("fill", "rgb", $r, $g, $b, 0); |
| 522 | 522 | } |
| 523 | 523 | |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | "symbol", "zapfdinbats"); |
| 538 | 538 | |
| 539 | 539 | $test = strtolower(basename($font)); |
| 540 | - if ( in_array($test, $native_fonts) ) { |
|
| 540 | + if (in_array($test, $native_fonts)) { |
|
| 541 | 541 | $font = basename($font); |
| 542 | 542 | |
| 543 | 543 | } else { |
@@ -545,20 +545,20 @@ discard block |
||
| 545 | 545 | $options .= " embedding=true"; |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | - if ( is_null($encoding) ) { |
|
| 548 | + if (is_null($encoding)) { |
|
| 549 | 549 | |
| 550 | 550 | // Unicode encoding is only available for the commerical |
| 551 | 551 | // version of PDFlib and not PDFlib-Lite |
| 552 | - if ( defined("DOMPDF_PDFLIB_LICENSE") ) |
|
| 552 | + if (defined("DOMPDF_PDFLIB_LICENSE")) |
|
| 553 | 553 | $encoding = "unicode"; |
| 554 | 554 | else |
| 555 | 555 | $encoding = "auto"; |
| 556 | 556 | |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | - $key = $font .":". $encoding .":". $options; |
|
| 559 | + $key = $font.":".$encoding.":".$options; |
|
| 560 | 560 | |
| 561 | - if ( isset($this->_fonts[$key]) ) |
|
| 561 | + if (isset($this->_fonts[$key])) |
|
| 562 | 562 | return $this->_fonts[$key]; |
| 563 | 563 | |
| 564 | 564 | else { |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | $y1 = $this->y($y1); |
| 588 | 588 | $y2 = $this->y($y2); |
| 589 | 589 | |
| 590 | - $this->_pdf->moveto($x1,$y1); |
|
| 590 | + $this->_pdf->moveto($x1, $y1); |
|
| 591 | 591 | $this->_pdf->lineto($x2, $y2); |
| 592 | 592 | $this->_pdf->stroke(); |
| 593 | 593 | } |
@@ -622,20 +622,20 @@ discard block |
||
| 622 | 622 | $this->_set_fill_color($color); |
| 623 | 623 | $this->_set_stroke_color($color); |
| 624 | 624 | |
| 625 | - if ( !$fill && isset($width) ) |
|
| 625 | + if (!$fill && isset($width)) |
|
| 626 | 626 | $this->_set_line_style($width, "square", "miter", $style); |
| 627 | 627 | |
| 628 | 628 | $y = $this->y(array_pop($points)); |
| 629 | 629 | $x = array_pop($points); |
| 630 | - $this->_pdf->moveto($x,$y); |
|
| 630 | + $this->_pdf->moveto($x, $y); |
|
| 631 | 631 | |
| 632 | 632 | while (count($points) > 1) { |
| 633 | 633 | $y = $this->y(array_pop($points)); |
| 634 | 634 | $x = array_pop($points); |
| 635 | - $this->_pdf->lineto($x,$y); |
|
| 635 | + $this->_pdf->lineto($x, $y); |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | - if ( $fill ) |
|
| 638 | + if ($fill) |
|
| 639 | 639 | $this->_pdf->fill(); |
| 640 | 640 | else |
| 641 | 641 | $this->_pdf->closepath_stroke(); |
@@ -648,14 +648,14 @@ discard block |
||
| 648 | 648 | $this->_set_fill_color($color); |
| 649 | 649 | $this->_set_stroke_color($color); |
| 650 | 650 | |
| 651 | - if ( !$fill && isset($width) ) |
|
| 651 | + if (!$fill && isset($width)) |
|
| 652 | 652 | $this->_set_line_style($width, "round", "round", $style); |
| 653 | 653 | |
| 654 | 654 | $y = $this->y($y); |
| 655 | 655 | |
| 656 | 656 | $this->_pdf->circle($x, $y, $r); |
| 657 | 657 | |
| 658 | - if ( $fill ) |
|
| 658 | + if ($fill) |
|
| 659 | 659 | $this->_pdf->fill(); |
| 660 | 660 | else |
| 661 | 661 | $this->_pdf->stroke(); |
@@ -665,15 +665,15 @@ discard block |
||
| 665 | 665 | //........................................................................ |
| 666 | 666 | |
| 667 | 667 | function image($img_url, $img_type, $x, $y, $w, $h) { |
| 668 | - $w = (int)$w; |
|
| 669 | - $h = (int)$h; |
|
| 668 | + $w = (int) $w; |
|
| 669 | + $h = (int) $h; |
|
| 670 | 670 | |
| 671 | 671 | $img_type = strtolower($img_type); |
| 672 | 672 | |
| 673 | - if ( $img_type === "jpg" ) |
|
| 673 | + if ($img_type === "jpg") |
|
| 674 | 674 | $img_type = "jpeg"; |
| 675 | 675 | |
| 676 | - if ( isset($this->_imgs[$img_url]) ) |
|
| 676 | + if (isset($this->_imgs[$img_url])) |
|
| 677 | 677 | $img = $this->_imgs[$img_url]; |
| 678 | 678 | |
| 679 | 679 | else { |
@@ -682,13 +682,13 @@ discard block |
||
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | $y = $this->y($y) - $h; |
| 685 | - $this->_pdf->fit_image($img, $x, $y, 'boxsize={'. "$w $h" .'} fitmethod=entire'); |
|
| 685 | + $this->_pdf->fit_image($img, $x, $y, 'boxsize={'."$w $h".'} fitmethod=entire'); |
|
| 686 | 686 | |
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | //........................................................................ |
| 690 | 690 | |
| 691 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
| 691 | + function text($x, $y, $text, $font, $size, $color = array(0, 0, 0), $adjust = 0, $angle = 0) { |
|
| 692 | 692 | $fh = $this->_load_font($font); |
| 693 | 693 | |
| 694 | 694 | $this->_pdf->setfont($fh, $size); |
@@ -696,8 +696,8 @@ discard block |
||
| 696 | 696 | |
| 697 | 697 | $y = $this->y($y) - Font_Metrics::get_font_height($font, $size); |
| 698 | 698 | |
| 699 | - $adjust = (float)$adjust; |
|
| 700 | - $angle = -(float)$angle; |
|
| 699 | + $adjust = (float) $adjust; |
|
| 700 | + $angle = -(float) $angle; |
|
| 701 | 701 | |
| 702 | 702 | $this->_pdf->fit_textline($text, $x, $y, "rotate=$angle wordspacing=$adjust"); |
| 703 | 703 | |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | * @param string $anchorname The name of the named destination |
| 718 | 718 | */ |
| 719 | 719 | function add_named_dest($anchorname) { |
| 720 | - $this->_pdf->add_nameddest($anchorname,""); |
|
| 720 | + $this->_pdf->add_nameddest($anchorname, ""); |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | //........................................................................ |
@@ -734,21 +734,21 @@ discard block |
||
| 734 | 734 | function add_link($url, $x, $y, $width, $height) { |
| 735 | 735 | |
| 736 | 736 | $y = $this->y($y) - $height; |
| 737 | - if ( strpos($url, '#') === 0 ) { |
|
| 737 | + if (strpos($url, '#') === 0) { |
|
| 738 | 738 | // Local link |
| 739 | - $name = substr($url,1); |
|
| 740 | - if ( $name ) |
|
| 741 | - $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=". substr($url,1) . " linewidth=0"); |
|
| 739 | + $name = substr($url, 1); |
|
| 740 | + if ($name) |
|
| 741 | + $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=".substr($url, 1)." linewidth=0"); |
|
| 742 | 742 | } else { |
| 743 | 743 | |
| 744 | 744 | list($proto, $host, $path, $file) = explode_url($url); |
| 745 | 745 | |
| 746 | - if ( $proto == "" || $proto === "file://" ) |
|
| 746 | + if ($proto == "" || $proto === "file://") |
|
| 747 | 747 | return; // Local links are not allowed |
| 748 | 748 | $url = build_url($proto, $host, $path, $file); |
| 749 | - $url = '{' . rawurldecode($url) . '}'; |
|
| 749 | + $url = '{'.rawurldecode($url).'}'; |
|
| 750 | 750 | |
| 751 | - $action = $this->_pdf->create_action("URI", "url=" . $url); |
|
| 751 | + $action = $this->_pdf->create_action("URI", "url=".$url); |
|
| 752 | 752 | $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} action={activate=$action} linewidth=0"); |
| 753 | 753 | } |
| 754 | 754 | } |
@@ -759,7 +759,7 @@ discard block |
||
| 759 | 759 | $fh = $this->_load_font($font); |
| 760 | 760 | |
| 761 | 761 | // Determine the additional width due to extra spacing |
| 762 | - $num_spaces = mb_substr_count($text," "); |
|
| 762 | + $num_spaces = mb_substr_count($text, " "); |
|
| 763 | 763 | $delta = $spacing * $num_spaces; |
| 764 | 764 | return $this->_pdf->stringwidth($text, $fh, $size) + $delta; |
| 765 | 765 | } |
@@ -798,8 +798,8 @@ discard block |
||
| 798 | 798 | * @param float $adjust word spacing adjustment |
| 799 | 799 | * @param float $angle angle to write the text at, measured CW starting from the x-axis |
| 800 | 800 | */ |
| 801 | - function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), |
|
| 802 | - $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0) { |
|
| 801 | + function page_text($x, $y, $text, $font, $size, $color = array(0, 0, 0), |
|
| 802 | + $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0) { |
|
| 803 | 803 | $_t = "text"; |
| 804 | 804 | $this->_page_text[] = compact("_t", "x", "y", "text", "font", "size", "color", "adjust", "angle"); |
| 805 | 805 | } |
@@ -842,7 +842,7 @@ discard block |
||
| 842 | 842 | */ |
| 843 | 843 | protected function _add_page_text() { |
| 844 | 844 | |
| 845 | - if ( !count($this->_page_text) ) |
|
| 845 | + if (!count($this->_page_text)) |
|
| 846 | 846 | return; |
| 847 | 847 | |
| 848 | 848 | $this->_pdf->suspend_page(""); |
@@ -856,7 +856,7 @@ discard block |
||
| 856 | 856 | switch ($_t) { |
| 857 | 857 | |
| 858 | 858 | case "text": |
| 859 | - $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"), |
|
| 859 | + $text = str_replace(array("{PAGE_NUM}", "{PAGE_COUNT}"), |
|
| 860 | 860 | array($p, $this->_page_count), $text); |
| 861 | 861 | $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
| 862 | 862 | break; |
@@ -883,14 +883,14 @@ discard block |
||
| 883 | 883 | // Add page text |
| 884 | 884 | $this->_add_page_text(); |
| 885 | 885 | |
| 886 | - if ( isset($options["compress"]) && $options["compress"] != 1 ) |
|
| 886 | + if (isset($options["compress"]) && $options["compress"] != 1) |
|
| 887 | 887 | $this->_pdf->set_value("compress", 0); |
| 888 | 888 | else |
| 889 | 889 | $this->_pdf->set_value("compress", 6); |
| 890 | 890 | |
| 891 | 891 | $this->_close(); |
| 892 | 892 | |
| 893 | - if ( self::$IN_MEMORY ) { |
|
| 893 | + if (self::$IN_MEMORY) { |
|
| 894 | 894 | $data = $this->_pdf->get_buffer(); |
| 895 | 895 | $size = strlen($data); |
| 896 | 896 | |
@@ -898,7 +898,7 @@ discard block |
||
| 898 | 898 | $size = filesize($this->_file); |
| 899 | 899 | |
| 900 | 900 | |
| 901 | - $filename = str_replace(array("\n","'"),"", $filename); |
|
| 901 | + $filename = str_replace(array("\n", "'"), "", $filename); |
|
| 902 | 902 | $attach = (isset($options["Attachment"]) && $options["Attachment"]) ? "attachment" : "inline"; |
| 903 | 903 | |
| 904 | 904 | header("Cache-Control: private"); |
@@ -907,7 +907,7 @@ discard block |
||
| 907 | 907 | |
| 908 | 908 | //header("Content-length: " . $size); |
| 909 | 909 | |
| 910 | - if ( self::$IN_MEMORY ) |
|
| 910 | + if (self::$IN_MEMORY) |
|
| 911 | 911 | echo $data; |
| 912 | 912 | |
| 913 | 913 | else { |
@@ -915,11 +915,11 @@ discard block |
||
| 915 | 915 | // Chunked readfile() |
| 916 | 916 | $chunk = (1 << 21); // 2 MB |
| 917 | 917 | $fh = fopen($this->_file, "rb"); |
| 918 | - if ( !$fh ) |
|
| 919 | - throw new DOMPDF_Exception("Unable to load temporary PDF file: " . $this->_file); |
|
| 918 | + if (!$fh) |
|
| 919 | + throw new DOMPDF_Exception("Unable to load temporary PDF file: ".$this->_file); |
|
| 920 | 920 | |
| 921 | - while ( !feof($fh) ) |
|
| 922 | - echo fread($fh,$chunk); |
|
| 921 | + while (!feof($fh)) |
|
| 922 | + echo fread($fh, $chunk); |
|
| 923 | 923 | fclose($fh); |
| 924 | 924 | |
| 925 | 925 | //debugpng |
@@ -942,14 +942,14 @@ discard block |
||
| 942 | 942 | // Add page text |
| 943 | 943 | $this->_add_page_text(); |
| 944 | 944 | |
| 945 | - if ( isset($options["compress"]) && $options["compress"] != 1 ) |
|
| 945 | + if (isset($options["compress"]) && $options["compress"] != 1) |
|
| 946 | 946 | $this->_pdf->set_value("compress", 0); |
| 947 | 947 | else |
| 948 | 948 | $this->_pdf->set_value("compress", 6); |
| 949 | 949 | |
| 950 | 950 | $this->_close(); |
| 951 | 951 | |
| 952 | - if ( self::$IN_MEMORY ) |
|
| 952 | + if (self::$IN_MEMORY) |
|
| 953 | 953 | $data = $this->_pdf->get_buffer(); |
| 954 | 954 | |
| 955 | 955 | else { |
@@ -185,12 +185,13 @@ discard block |
||
| 185 | 185 | * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
| 186 | 186 | */ |
| 187 | 187 | function __construct($paper = "letter", $orientation = "portrait") { |
| 188 | - if ( is_array($paper) ) |
|
| 189 | - $size = $paper; |
|
| 190 | - else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) |
|
| 191 | - $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
|
| 192 | - else |
|
| 193 | - $size = self::$PAPER_SIZES["letter"]; |
|
| 188 | + if ( is_array($paper) ) { |
|
| 189 | + $size = $paper; |
|
| 190 | + } else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) { |
|
| 191 | + $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
|
| 192 | + } else { |
|
| 193 | + $size = self::$PAPER_SIZES["letter"]; |
|
| 194 | + } |
|
| 194 | 195 | |
| 195 | 196 | if ( mb_strtolower($orientation) === "landscape" ) { |
| 196 | 197 | $a = $size[3]; |
@@ -202,8 +203,9 @@ discard block |
||
| 202 | 203 | |
| 203 | 204 | $this->_pdf = new PDFLib(); |
| 204 | 205 | |
| 205 | - if ( defined("DOMPDF_PDFLIB_LICENSE") ) |
|
| 206 | - $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE); |
|
| 206 | + if ( defined("DOMPDF_PDFLIB_LICENSE") ) { |
|
| 207 | + $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE); |
|
| 208 | + } |
|
| 207 | 209 | |
| 208 | 210 | $this->_pdf->set_parameter("textformat", "utf8"); |
| 209 | 211 | $this->_pdf->set_parameter("fontwarning", "false"); |
@@ -220,9 +222,9 @@ discard block |
||
| 220 | 222 | $this->_pdf->set_info("Date", date("Y-m-d")); |
| 221 | 223 | } |
| 222 | 224 | |
| 223 | - if ( self::$IN_MEMORY ) |
|
| 224 | - $this->_pdf->begin_document("",""); |
|
| 225 | - else { |
|
| 225 | + if ( self::$IN_MEMORY ) { |
|
| 226 | + $this->_pdf->begin_document("",""); |
|
| 227 | + } else { |
|
| 226 | 228 | $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf'; |
| 227 | 229 | $this->_pdf->begin_document($this->_file,""); |
| 228 | 230 | } |
@@ -254,19 +256,23 @@ discard block |
||
| 254 | 256 | } else if ( file_exists($file . ".pfb") ) { |
| 255 | 257 | $outline = "$file.pfb"; |
| 256 | 258 | |
| 257 | - if ( file_exists($file . ".afm") ) |
|
| 258 | - $afm = "$file.afm"; |
|
| 259 | + if ( file_exists($file . ".afm") ) { |
|
| 260 | + $afm = "$file.afm"; |
|
| 261 | + } |
|
| 259 | 262 | |
| 260 | 263 | } else if ( file_exists($file . ".PFB") ) { |
| 261 | 264 | $outline = "$file.PFB"; |
| 262 | - if ( file_exists($file . ".AFM") ) |
|
| 263 | - $afm = "$file.AFM"; |
|
| 264 | - } else |
|
| 265 | - continue; |
|
| 265 | + if ( file_exists($file . ".AFM") ) { |
|
| 266 | + $afm = "$file.AFM"; |
|
| 267 | + } |
|
| 268 | + } else { |
|
| 269 | + continue; |
|
| 270 | + } |
|
| 266 | 271 | |
| 267 | 272 | $this->_pdf->set_parameter("FontOutline", "\{$face\}=\{$outline\}"); |
| 268 | - if ( !is_null($afm) ) |
|
| 269 | - $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}"); |
|
| 273 | + if ( !is_null($afm) ) { |
|
| 274 | + $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}"); |
|
| 275 | + } |
|
| 270 | 276 | } |
| 271 | 277 | } |
| 272 | 278 | } |
@@ -369,8 +375,9 @@ discard block |
||
| 369 | 375 | if ( mb_strpos($where, "next") !== false ) { |
| 370 | 376 | $this->_objs[$object]["start_page"]++; |
| 371 | 377 | $where = str_replace("next", "", $where); |
| 372 | - if ( $where == "" ) |
|
| 373 | - $where = "add"; |
|
| 378 | + if ( $where == "" ) { |
|
| 379 | + $where = "add"; |
|
| 380 | + } |
|
| 374 | 381 | } |
| 375 | 382 | |
| 376 | 383 | $this->_objs[$object]["where"] = $where; |
@@ -386,8 +393,9 @@ discard block |
||
| 386 | 393 | */ |
| 387 | 394 | function stop_object($object) { |
| 388 | 395 | |
| 389 | - if ( !isset($this->_objs[$object]) ) |
|
| 390 | - return; |
|
| 396 | + if ( !isset($this->_objs[$object]) ) { |
|
| 397 | + return; |
|
| 398 | + } |
|
| 391 | 399 | |
| 392 | 400 | $start = $this->_objs[$object]["start_page"]; |
| 393 | 401 | $where = $this->_objs[$object]["where"]; |
@@ -396,8 +404,9 @@ discard block |
||
| 396 | 404 | if ( $this->_page_number >= $start && |
| 397 | 405 | (($this->_page_number % 2 == 0 && $where === "even") || |
| 398 | 406 | ($this->_page_number % 2 == 1 && $where === "odd") || |
| 399 | - ($where === "all")) ) |
|
| 400 | - $this->_pdf->fit_image($object,0,0,""); |
|
| 407 | + ($where === "all")) ) { |
|
| 408 | + $this->_pdf->fit_image($object,0,0,""); |
|
| 409 | + } |
|
| 401 | 410 | |
| 402 | 411 | unset($this->_objs[$object]); |
| 403 | 412 | } |
@@ -445,13 +454,15 @@ discard block |
||
| 445 | 454 | */ |
| 446 | 455 | protected function _set_line_style($width, $cap, $join, $dash) { |
| 447 | 456 | |
| 448 | - if ( count($dash) == 1 ) |
|
| 449 | - $dash[] = $dash[0]; |
|
| 457 | + if ( count($dash) == 1 ) { |
|
| 458 | + $dash[] = $dash[0]; |
|
| 459 | + } |
|
| 450 | 460 | |
| 451 | - if ( count($dash) > 1 ) |
|
| 452 | - $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}"); |
|
| 453 | - else |
|
| 454 | - $this->_pdf->setdash(0,0); |
|
| 461 | + if ( count($dash) > 1 ) { |
|
| 462 | + $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}"); |
|
| 463 | + } else { |
|
| 464 | + $this->_pdf->setdash(0,0); |
|
| 465 | + } |
|
| 455 | 466 | |
| 456 | 467 | switch ( $join ) { |
| 457 | 468 | case "miter": |
@@ -497,8 +508,9 @@ discard block |
||
| 497 | 508 | * @param array $color array(r,g,b) |
| 498 | 509 | */ |
| 499 | 510 | protected function _set_stroke_color($color) { |
| 500 | - if($this->_last_stroke_color == $color) |
|
| 501 | - return; |
|
| 511 | + if($this->_last_stroke_color == $color) { |
|
| 512 | + return; |
|
| 513 | + } |
|
| 502 | 514 | |
| 503 | 515 | $this->_last_stroke_color = $color; |
| 504 | 516 | |
@@ -512,8 +524,9 @@ discard block |
||
| 512 | 524 | * @param array $color array(r,g,b) |
| 513 | 525 | */ |
| 514 | 526 | protected function _set_fill_color($color) { |
| 515 | - if($this->_last_fill_color == $color) |
|
| 516 | - return; |
|
| 527 | + if($this->_last_fill_color == $color) { |
|
| 528 | + return; |
|
| 529 | + } |
|
| 517 | 530 | |
| 518 | 531 | $this->_last_fill_color = $color; |
| 519 | 532 | |
@@ -549,19 +562,19 @@ discard block |
||
| 549 | 562 | |
| 550 | 563 | // Unicode encoding is only available for the commerical |
| 551 | 564 | // version of PDFlib and not PDFlib-Lite |
| 552 | - if ( defined("DOMPDF_PDFLIB_LICENSE") ) |
|
| 553 | - $encoding = "unicode"; |
|
| 554 | - else |
|
| 555 | - $encoding = "auto"; |
|
| 565 | + if ( defined("DOMPDF_PDFLIB_LICENSE") ) { |
|
| 566 | + $encoding = "unicode"; |
|
| 567 | + } else { |
|
| 568 | + $encoding = "auto"; |
|
| 569 | + } |
|
| 556 | 570 | |
| 557 | 571 | } |
| 558 | 572 | |
| 559 | 573 | $key = $font .":". $encoding .":". $options; |
| 560 | 574 | |
| 561 | - if ( isset($this->_fonts[$key]) ) |
|
| 562 | - return $this->_fonts[$key]; |
|
| 563 | - |
|
| 564 | - else { |
|
| 575 | + if ( isset($this->_fonts[$key]) ) { |
|
| 576 | + return $this->_fonts[$key]; |
|
| 577 | + } else { |
|
| 565 | 578 | |
| 566 | 579 | $this->_fonts[$key] = $this->_pdf->load_font($font, $encoding, $options); |
| 567 | 580 | return $this->_fonts[$key]; |
@@ -622,8 +635,9 @@ discard block |
||
| 622 | 635 | $this->_set_fill_color($color); |
| 623 | 636 | $this->_set_stroke_color($color); |
| 624 | 637 | |
| 625 | - if ( !$fill && isset($width) ) |
|
| 626 | - $this->_set_line_style($width, "square", "miter", $style); |
|
| 638 | + if ( !$fill && isset($width) ) { |
|
| 639 | + $this->_set_line_style($width, "square", "miter", $style); |
|
| 640 | + } |
|
| 627 | 641 | |
| 628 | 642 | $y = $this->y(array_pop($points)); |
| 629 | 643 | $x = array_pop($points); |
@@ -635,10 +649,11 @@ discard block |
||
| 635 | 649 | $this->_pdf->lineto($x,$y); |
| 636 | 650 | } |
| 637 | 651 | |
| 638 | - if ( $fill ) |
|
| 639 | - $this->_pdf->fill(); |
|
| 640 | - else |
|
| 641 | - $this->_pdf->closepath_stroke(); |
|
| 652 | + if ( $fill ) { |
|
| 653 | + $this->_pdf->fill(); |
|
| 654 | + } else { |
|
| 655 | + $this->_pdf->closepath_stroke(); |
|
| 656 | + } |
|
| 642 | 657 | } |
| 643 | 658 | |
| 644 | 659 | //........................................................................ |
@@ -648,17 +663,19 @@ discard block |
||
| 648 | 663 | $this->_set_fill_color($color); |
| 649 | 664 | $this->_set_stroke_color($color); |
| 650 | 665 | |
| 651 | - if ( !$fill && isset($width) ) |
|
| 652 | - $this->_set_line_style($width, "round", "round", $style); |
|
| 666 | + if ( !$fill && isset($width) ) { |
|
| 667 | + $this->_set_line_style($width, "round", "round", $style); |
|
| 668 | + } |
|
| 653 | 669 | |
| 654 | 670 | $y = $this->y($y); |
| 655 | 671 | |
| 656 | 672 | $this->_pdf->circle($x, $y, $r); |
| 657 | 673 | |
| 658 | - if ( $fill ) |
|
| 659 | - $this->_pdf->fill(); |
|
| 660 | - else |
|
| 661 | - $this->_pdf->stroke(); |
|
| 674 | + if ( $fill ) { |
|
| 675 | + $this->_pdf->fill(); |
|
| 676 | + } else { |
|
| 677 | + $this->_pdf->stroke(); |
|
| 678 | + } |
|
| 662 | 679 | |
| 663 | 680 | } |
| 664 | 681 | |
@@ -670,13 +687,13 @@ discard block |
||
| 670 | 687 | |
| 671 | 688 | $img_type = strtolower($img_type); |
| 672 | 689 | |
| 673 | - if ( $img_type === "jpg" ) |
|
| 674 | - $img_type = "jpeg"; |
|
| 675 | - |
|
| 676 | - if ( isset($this->_imgs[$img_url]) ) |
|
| 677 | - $img = $this->_imgs[$img_url]; |
|
| 690 | + if ( $img_type === "jpg" ) { |
|
| 691 | + $img_type = "jpeg"; |
|
| 692 | + } |
|
| 678 | 693 | |
| 679 | - else { |
|
| 694 | + if ( isset($this->_imgs[$img_url]) ) { |
|
| 695 | + $img = $this->_imgs[$img_url]; |
|
| 696 | + } else { |
|
| 680 | 697 | |
| 681 | 698 | $img = $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, ""); |
| 682 | 699 | } |
@@ -737,14 +754,17 @@ discard block |
||
| 737 | 754 | if ( strpos($url, '#') === 0 ) { |
| 738 | 755 | // Local link |
| 739 | 756 | $name = substr($url,1); |
| 740 | - if ( $name ) |
|
| 741 | - $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=". substr($url,1) . " linewidth=0"); |
|
| 757 | + if ( $name ) { |
|
| 758 | + $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=". substr($url,1) . " linewidth=0"); |
|
| 759 | + } |
|
| 742 | 760 | } else { |
| 743 | 761 | |
| 744 | 762 | list($proto, $host, $path, $file) = explode_url($url); |
| 745 | 763 | |
| 746 | - if ( $proto == "" || $proto === "file://" ) |
|
| 747 | - return; // Local links are not allowed |
|
| 764 | + if ( $proto == "" || $proto === "file://" ) { |
|
| 765 | + return; |
|
| 766 | + } |
|
| 767 | + // Local links are not allowed |
|
| 748 | 768 | $url = build_url($proto, $host, $path, $file); |
| 749 | 769 | $url = '{' . rawurldecode($url) . '}'; |
| 750 | 770 | |
@@ -842,8 +862,9 @@ discard block |
||
| 842 | 862 | */ |
| 843 | 863 | protected function _add_page_text() { |
| 844 | 864 | |
| 845 | - if ( !count($this->_page_text) ) |
|
| 846 | - return; |
|
| 865 | + if ( !count($this->_page_text) ) { |
|
| 866 | + return; |
|
| 867 | + } |
|
| 847 | 868 | |
| 848 | 869 | $this->_pdf->suspend_page(""); |
| 849 | 870 | |
@@ -883,10 +904,11 @@ discard block |
||
| 883 | 904 | // Add page text |
| 884 | 905 | $this->_add_page_text(); |
| 885 | 906 | |
| 886 | - if ( isset($options["compress"]) && $options["compress"] != 1 ) |
|
| 887 | - $this->_pdf->set_value("compress", 0); |
|
| 888 | - else |
|
| 889 | - $this->_pdf->set_value("compress", 6); |
|
| 907 | + if ( isset($options["compress"]) && $options["compress"] != 1 ) { |
|
| 908 | + $this->_pdf->set_value("compress", 0); |
|
| 909 | + } else { |
|
| 910 | + $this->_pdf->set_value("compress", 6); |
|
| 911 | + } |
|
| 890 | 912 | |
| 891 | 913 | $this->_close(); |
| 892 | 914 | |
@@ -894,8 +916,9 @@ discard block |
||
| 894 | 916 | $data = $this->_pdf->get_buffer(); |
| 895 | 917 | $size = strlen($data); |
| 896 | 918 | |
| 897 | - } else |
|
| 898 | - $size = filesize($this->_file); |
|
| 919 | + } else { |
|
| 920 | + $size = filesize($this->_file); |
|
| 921 | + } |
|
| 899 | 922 | |
| 900 | 923 | |
| 901 | 924 | $filename = str_replace(array("\n","'"),"", $filename); |
@@ -907,26 +930,30 @@ discard block |
||
| 907 | 930 | |
| 908 | 931 | //header("Content-length: " . $size); |
| 909 | 932 | |
| 910 | - if ( self::$IN_MEMORY ) |
|
| 911 | - echo $data; |
|
| 912 | - |
|
| 913 | - else { |
|
| 933 | + if ( self::$IN_MEMORY ) { |
|
| 934 | + echo $data; |
|
| 935 | + } else { |
|
| 914 | 936 | |
| 915 | 937 | // Chunked readfile() |
| 916 | 938 | $chunk = (1 << 21); // 2 MB |
| 917 | 939 | $fh = fopen($this->_file, "rb"); |
| 918 | - if ( !$fh ) |
|
| 919 | - throw new DOMPDF_Exception("Unable to load temporary PDF file: " . $this->_file); |
|
| 940 | + if ( !$fh ) { |
|
| 941 | + throw new DOMPDF_Exception("Unable to load temporary PDF file: " . $this->_file); |
|
| 942 | + } |
|
| 920 | 943 | |
| 921 | - while ( !feof($fh) ) |
|
| 922 | - echo fread($fh,$chunk); |
|
| 944 | + while ( !feof($fh) ) { |
|
| 945 | + echo fread($fh,$chunk); |
|
| 946 | + } |
|
| 923 | 947 | fclose($fh); |
| 924 | 948 | |
| 925 | 949 | //debugpng |
| 926 | - if (DEBUGPNG) print '[pdflib stream unlink '.$this->_file.']'; |
|
| 927 | - if (!DEBUGKEEPTEMP) |
|
| 928 | - |
|
| 950 | + if (DEBUGPNG) { |
|
| 951 | + print '[pdflib stream unlink '.$this->_file.']'; |
|
| 952 | + } |
|
| 953 | + if (!DEBUGKEEPTEMP) { |
|
| 954 | + |
|
| 929 | 955 | unlink($this->_file); |
| 956 | + } |
|
| 930 | 957 | $this->_file = null; |
| 931 | 958 | } |
| 932 | 959 | |
@@ -942,24 +969,27 @@ discard block |
||
| 942 | 969 | // Add page text |
| 943 | 970 | $this->_add_page_text(); |
| 944 | 971 | |
| 945 | - if ( isset($options["compress"]) && $options["compress"] != 1 ) |
|
| 946 | - $this->_pdf->set_value("compress", 0); |
|
| 947 | - else |
|
| 948 | - $this->_pdf->set_value("compress", 6); |
|
| 972 | + if ( isset($options["compress"]) && $options["compress"] != 1 ) { |
|
| 973 | + $this->_pdf->set_value("compress", 0); |
|
| 974 | + } else { |
|
| 975 | + $this->_pdf->set_value("compress", 6); |
|
| 976 | + } |
|
| 949 | 977 | |
| 950 | 978 | $this->_close(); |
| 951 | 979 | |
| 952 | - if ( self::$IN_MEMORY ) |
|
| 953 | - $data = $this->_pdf->get_buffer(); |
|
| 954 | - |
|
| 955 | - else { |
|
| 980 | + if ( self::$IN_MEMORY ) { |
|
| 981 | + $data = $this->_pdf->get_buffer(); |
|
| 982 | + } else { |
|
| 956 | 983 | $data = file_get_contents($this->_file); |
| 957 | 984 | |
| 958 | 985 | //debugpng |
| 959 | - if (DEBUGPNG) print '[pdflib output unlink '.$this->_file.']'; |
|
| 960 | - if (!DEBUGKEEPTEMP) |
|
| 961 | - |
|
| 986 | + if (DEBUGPNG) { |
|
| 987 | + print '[pdflib output unlink '.$this->_file.']'; |
|
| 988 | + } |
|
| 989 | + if (!DEBUGKEEPTEMP) { |
|
| 990 | + |
|
| 962 | 991 | unlink($this->_file); |
| 992 | + } |
|
| 963 | 993 | $this->_file = null; |
| 964 | 994 | } |
| 965 | 995 | |
@@ -742,6 +742,10 @@ discard block |
||
| 742 | 742 | * Assume that __set will be also called when this is called, so do not check validity again. |
| 743 | 743 | * Only created, if !important exists -> always set true. |
| 744 | 744 | */ |
| 745 | + |
|
| 746 | + /** |
|
| 747 | + * @param string $prop |
|
| 748 | + */ |
|
| 745 | 749 | function important_set($prop) { |
| 746 | 750 | $prop = str_replace("-", "_", $prop); |
| 747 | 751 | $this->_important_props[$prop] = true; |
@@ -1276,7 +1280,8 @@ discard block |
||
| 1276 | 1280 | /** |
| 1277 | 1281 | * Return a single border property |
| 1278 | 1282 | * |
| 1279 | - * @return mixed |
|
| 1283 | + * @param string $side |
|
| 1284 | + * @return string |
|
| 1280 | 1285 | */ |
| 1281 | 1286 | protected function _get_border($side) { |
| 1282 | 1287 | $color = $this->__get("border_" . $side . "_color"); |
@@ -1363,6 +1368,10 @@ discard block |
||
| 1363 | 1368 | * Applicable for background, border, padding, margin, font, list_style |
| 1364 | 1369 | * Note: $type has a leading underscore (or is empty), the others not. |
| 1365 | 1370 | */ |
| 1371 | + |
|
| 1372 | + /** |
|
| 1373 | + * @param string $side |
|
| 1374 | + */ |
|
| 1366 | 1375 | protected function _set_style_side_type($style,$side,$type,$val,$important) { |
| 1367 | 1376 | if ( !isset($this->_important_props[$style.'_'.$side.$type]) || $important) { |
| 1368 | 1377 | //see __set and __get, on all assignments clear cache! |
@@ -1381,6 +1390,9 @@ discard block |
||
| 1381 | 1390 | $this->_set_style_side_type($style,'left',$type,$left,$important); |
| 1382 | 1391 | } |
| 1383 | 1392 | |
| 1393 | + /** |
|
| 1394 | + * @param boolean $important |
|
| 1395 | + */ |
|
| 1384 | 1396 | protected function _set_style_type($style,$type,$val,$important) { |
| 1385 | 1397 | $arr = explode(" ", $val); |
| 1386 | 1398 | switch (count($arr)) { |
@@ -1404,6 +1416,10 @@ discard block |
||
| 1404 | 1416 | $this->_props[$style.$type] = $val; |
| 1405 | 1417 | } |
| 1406 | 1418 | |
| 1419 | + /** |
|
| 1420 | + * @param string $style |
|
| 1421 | + * @param string $type |
|
| 1422 | + */ |
|
| 1407 | 1423 | protected function _set_style_type_important($style,$type,$val) { |
| 1408 | 1424 | $this->_set_style_type($style,$type,$val,isset($this->_important_props[$style.$type])); |
| 1409 | 1425 | } |
@@ -1411,12 +1427,21 @@ discard block |
||
| 1411 | 1427 | /* Anyway only called if _important matches and is assigned |
| 1412 | 1428 | * E.g. _set_style_side_type($style,$side,'',str_replace("none", "0px", $val),isset($this->_important_props[$style.'_'.$side])); |
| 1413 | 1429 | */ |
| 1430 | + |
|
| 1431 | + /** |
|
| 1432 | + * @param string $style |
|
| 1433 | + * @param string $side |
|
| 1434 | + */ |
|
| 1414 | 1435 | protected function _set_style_side_width_important($style,$side,$val) { |
| 1415 | 1436 | //see __set and __get, on all assignments clear cache! |
| 1416 | 1437 | $this->_prop_cache[$style.'_'.$side] = null; |
| 1417 | 1438 | $this->_props[$style.'_'.$side] = str_replace("none", "0px", $val); |
| 1418 | 1439 | } |
| 1419 | 1440 | |
| 1441 | + /** |
|
| 1442 | + * @param string $style |
|
| 1443 | + * @param boolean $important |
|
| 1444 | + */ |
|
| 1420 | 1445 | protected function _set_style($style,$val,$important) { |
| 1421 | 1446 | if ( !isset($this->_important_props[$style]) || $important) { |
| 1422 | 1447 | if ($important) { |
@@ -1505,7 +1530,6 @@ discard block |
||
| 1505 | 1530 | * Set the background image url |
| 1506 | 1531 | * |
| 1507 | 1532 | * @link http://www.w3.org/TR/CSS21/colors.html#background-properties |
| 1508 | - * @param string $url |
|
| 1509 | 1533 | */ |
| 1510 | 1534 | function set_background_image($val) { |
| 1511 | 1535 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
@@ -1769,6 +1793,7 @@ discard block |
||
| 1769 | 1793 | * |
| 1770 | 1794 | * @param string $side |
| 1771 | 1795 | * @param string $border_spec ([width] [style] [color]) |
| 1796 | + * @param boolean $important |
|
| 1772 | 1797 | */ |
| 1773 | 1798 | protected function _set_border($side, $border_spec, $important) { |
| 1774 | 1799 | $border_spec = str_replace(",", " ", $border_spec); |
@@ -592,130 +592,130 @@ discard block |
||
| 592 | 592 | // Handle colour names |
| 593 | 593 | switch ($colour) { |
| 594 | 594 | |
| 595 | - case "maroon": |
|
| 596 | - $r = 0x80; |
|
| 597 | - break; |
|
| 598 | - |
|
| 599 | - case "red": |
|
| 600 | - $r = 0xff; |
|
| 601 | - break; |
|
| 602 | - |
|
| 603 | - case "orange": |
|
| 604 | - $r = 0xff; |
|
| 605 | - $g = 0xa5; |
|
| 606 | - break; |
|
| 607 | - |
|
| 608 | - case "yellow": |
|
| 609 | - $r = 0xff; |
|
| 610 | - $g = 0xff; |
|
| 611 | - break; |
|
| 612 | - |
|
| 613 | - case "olive": |
|
| 614 | - $r = 0x80; |
|
| 615 | - $g = 0x80; |
|
| 616 | - break; |
|
| 617 | - |
|
| 618 | - case "purple": |
|
| 619 | - $r = 0x80; |
|
| 620 | - $b = 0x80; |
|
| 621 | - break; |
|
| 622 | - |
|
| 623 | - case "fuchsia": |
|
| 624 | - $r = 0xff; |
|
| 625 | - $b = 0xff; |
|
| 626 | - break; |
|
| 627 | - |
|
| 628 | - case "white": |
|
| 629 | - $r = $g = $b = 0xff; |
|
| 630 | - break; |
|
| 631 | - |
|
| 632 | - case "lime": |
|
| 633 | - $g = 0xff; |
|
| 634 | - break; |
|
| 635 | - |
|
| 636 | - case "green": |
|
| 637 | - $g = 0x80; |
|
| 638 | - break; |
|
| 639 | - |
|
| 640 | - case "navy": |
|
| 641 | - $b = 0x80; |
|
| 642 | - break; |
|
| 643 | - |
|
| 644 | - case "blue": |
|
| 645 | - $b = 0xff; |
|
| 646 | - break; |
|
| 647 | - |
|
| 648 | - case "aqua": |
|
| 649 | - $g = 0xff; |
|
| 650 | - $b = 0xff; |
|
| 651 | - break; |
|
| 652 | - |
|
| 653 | - case "teal": |
|
| 654 | - $g = 0x80; |
|
| 655 | - $b = 0x80; |
|
| 656 | - break; |
|
| 657 | - |
|
| 658 | - case "black": |
|
| 659 | - break; |
|
| 660 | - |
|
| 661 | - case "sliver": |
|
| 662 | - $r = $g = $b = 0xc0; |
|
| 663 | - break; |
|
| 664 | - |
|
| 665 | - case "gray": |
|
| 666 | - case "grey": |
|
| 667 | - $r = $g = $b = 0x80; |
|
| 668 | - break; |
|
| 669 | - |
|
| 670 | - case "transparent": |
|
| 671 | - return "transparent"; |
|
| 595 | + case "maroon": |
|
| 596 | + $r = 0x80; |
|
| 597 | + break; |
|
| 598 | + |
|
| 599 | + case "red": |
|
| 600 | + $r = 0xff; |
|
| 601 | + break; |
|
| 602 | + |
|
| 603 | + case "orange": |
|
| 604 | + $r = 0xff; |
|
| 605 | + $g = 0xa5; |
|
| 606 | + break; |
|
| 607 | + |
|
| 608 | + case "yellow": |
|
| 609 | + $r = 0xff; |
|
| 610 | + $g = 0xff; |
|
| 611 | + break; |
|
| 612 | + |
|
| 613 | + case "olive": |
|
| 614 | + $r = 0x80; |
|
| 615 | + $g = 0x80; |
|
| 616 | + break; |
|
| 617 | + |
|
| 618 | + case "purple": |
|
| 619 | + $r = 0x80; |
|
| 620 | + $b = 0x80; |
|
| 621 | + break; |
|
| 622 | + |
|
| 623 | + case "fuchsia": |
|
| 624 | + $r = 0xff; |
|
| 625 | + $b = 0xff; |
|
| 626 | + break; |
|
| 627 | + |
|
| 628 | + case "white": |
|
| 629 | + $r = $g = $b = 0xff; |
|
| 630 | + break; |
|
| 631 | + |
|
| 632 | + case "lime": |
|
| 633 | + $g = 0xff; |
|
| 634 | + break; |
|
| 635 | + |
|
| 636 | + case "green": |
|
| 637 | + $g = 0x80; |
|
| 638 | + break; |
|
| 639 | + |
|
| 640 | + case "navy": |
|
| 641 | + $b = 0x80; |
|
| 642 | + break; |
|
| 643 | + |
|
| 644 | + case "blue": |
|
| 645 | + $b = 0xff; |
|
| 646 | + break; |
|
| 647 | + |
|
| 648 | + case "aqua": |
|
| 649 | + $g = 0xff; |
|
| 650 | + $b = 0xff; |
|
| 651 | + break; |
|
| 652 | + |
|
| 653 | + case "teal": |
|
| 654 | + $g = 0x80; |
|
| 655 | + $b = 0x80; |
|
| 656 | + break; |
|
| 657 | + |
|
| 658 | + case "black": |
|
| 659 | + break; |
|
| 660 | + |
|
| 661 | + case "sliver": |
|
| 662 | + $r = $g = $b = 0xc0; |
|
| 663 | + break; |
|
| 664 | + |
|
| 665 | + case "gray": |
|
| 666 | + case "grey": |
|
| 667 | + $r = $g = $b = 0x80; |
|
| 668 | + break; |
|
| 669 | + |
|
| 670 | + case "transparent": |
|
| 671 | + return "transparent"; |
|
| 672 | 672 | |
| 673 | - default: |
|
| 674 | - if ( mb_strlen($colour) == 4 && $colour[0] === "#" ) { |
|
| 675 | - // #rgb format |
|
| 676 | - $r = hexdec($colour[1] . $colour[1]); |
|
| 677 | - $g = hexdec($colour[2] . $colour[2]); |
|
| 678 | - $b = hexdec($colour[3] . $colour[3]); |
|
| 679 | - |
|
| 680 | - } else if ( mb_strlen($colour) == 7 && $colour[0] === "#" ) { |
|
| 681 | - // #rrggbb format |
|
| 682 | - $r = hexdec(mb_substr($colour, 1, 2)); |
|
| 683 | - $g = hexdec(mb_substr($colour, 3, 2)); |
|
| 684 | - $b = hexdec(mb_substr($colour, 5, 2)); |
|
| 685 | - |
|
| 686 | - } else if ( mb_strpos($colour, "rgb") !== false ) { |
|
| 687 | - // rgb( r,g,b ) format |
|
| 688 | - $i = mb_strpos($colour, "("); |
|
| 689 | - $j = mb_strpos($colour, ")"); |
|
| 673 | + default: |
|
| 674 | + if ( mb_strlen($colour) == 4 && $colour[0] === "#" ) { |
|
| 675 | + // #rgb format |
|
| 676 | + $r = hexdec($colour[1] . $colour[1]); |
|
| 677 | + $g = hexdec($colour[2] . $colour[2]); |
|
| 678 | + $b = hexdec($colour[3] . $colour[3]); |
|
| 679 | + |
|
| 680 | + } else if ( mb_strlen($colour) == 7 && $colour[0] === "#" ) { |
|
| 681 | + // #rrggbb format |
|
| 682 | + $r = hexdec(mb_substr($colour, 1, 2)); |
|
| 683 | + $g = hexdec(mb_substr($colour, 3, 2)); |
|
| 684 | + $b = hexdec(mb_substr($colour, 5, 2)); |
|
| 685 | + |
|
| 686 | + } else if ( mb_strpos($colour, "rgb") !== false ) { |
|
| 687 | + // rgb( r,g,b ) format |
|
| 688 | + $i = mb_strpos($colour, "("); |
|
| 689 | + $j = mb_strpos($colour, ")"); |
|
| 690 | 690 | |
| 691 | - // Bad colour value |
|
| 692 | - if ($i === false || $j === false) |
|
| 693 | - return null; |
|
| 691 | + // Bad colour value |
|
| 692 | + if ($i === false || $j === false) |
|
| 693 | + return null; |
|
| 694 | 694 | |
| 695 | - $triplet = explode(",", mb_substr($colour, $i+1, $j-$i-1)); |
|
| 695 | + $triplet = explode(",", mb_substr($colour, $i+1, $j-$i-1)); |
|
| 696 | 696 | |
| 697 | - if (count($triplet) != 3) |
|
| 698 | - return null; |
|
| 697 | + if (count($triplet) != 3) |
|
| 698 | + return null; |
|
| 699 | 699 | |
| 700 | - foreach (array_keys($triplet) as $c) { |
|
| 701 | - $triplet[$c] = trim($triplet[$c]); |
|
| 700 | + foreach (array_keys($triplet) as $c) { |
|
| 701 | + $triplet[$c] = trim($triplet[$c]); |
|
| 702 | 702 | |
| 703 | - if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%" ) |
|
| 704 | - $triplet[$c] = round($triplet[$c] * 0.255); |
|
| 705 | - } |
|
| 703 | + if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%" ) |
|
| 704 | + $triplet[$c] = round($triplet[$c] * 0.255); |
|
| 705 | + } |
|
| 706 | 706 | |
| 707 | - list($r, $g, $b) = $triplet; |
|
| 707 | + list($r, $g, $b) = $triplet; |
|
| 708 | 708 | |
| 709 | - } else { |
|
| 710 | - // Who knows? |
|
| 711 | - return null; |
|
| 712 | - } |
|
| 709 | + } else { |
|
| 710 | + // Who knows? |
|
| 711 | + return null; |
|
| 712 | + } |
|
| 713 | 713 | |
| 714 | - // Clip to 0 - 1 |
|
| 715 | - $r = $r < 0 ? 0 : ($r > 255 ? 255 : $r); |
|
| 716 | - $g = $g < 0 ? 0 : ($g > 255 ? 255 : $g); |
|
| 717 | - $b = $b < 0 ? 0 : ($b > 255 ? 255 : $b); |
|
| 718 | - break; |
|
| 714 | + // Clip to 0 - 1 |
|
| 715 | + $r = $r < 0 ? 0 : ($r > 255 ? 255 : $r); |
|
| 716 | + $g = $g < 0 ? 0 : ($g > 255 ? 255 : $g); |
|
| 717 | + $b = $b < 0 ? 0 : ($b > 255 ? 255 : $b); |
|
| 718 | + break; |
|
| 719 | 719 | |
| 720 | 720 | } |
| 721 | 721 | |
@@ -941,38 +941,38 @@ discard block |
||
| 941 | 941 | |
| 942 | 942 | switch ($fs) { |
| 943 | 943 | |
| 944 | - case "xx-small": |
|
| 945 | - $fs = 3/5 * $this->_parent_font_size; |
|
| 946 | - break; |
|
| 947 | - |
|
| 948 | - case "x-small": |
|
| 949 | - $fs = 3/4 * $this->_parent_font_size; |
|
| 950 | - break; |
|
| 951 | - |
|
| 952 | - case "smaller": |
|
| 953 | - case "small": |
|
| 954 | - $fs = 8/9 * $this->_parent_font_size; |
|
| 955 | - break; |
|
| 956 | - |
|
| 957 | - case "medium": |
|
| 958 | - $fs = $this->_parent_font_size; |
|
| 959 | - break; |
|
| 960 | - |
|
| 961 | - case "larger": |
|
| 962 | - case "large": |
|
| 963 | - $fs = 6/5 * $this->_parent_font_size; |
|
| 964 | - break; |
|
| 965 | - |
|
| 966 | - case "x-large": |
|
| 967 | - $fs = 3/2 * $this->_parent_font_size; |
|
| 968 | - break; |
|
| 969 | - |
|
| 970 | - case "xx-large": |
|
| 971 | - $fs = 2/1 * $this->_parent_font_size; |
|
| 972 | - break; |
|
| 973 | - |
|
| 974 | - default: |
|
| 975 | - break; |
|
| 944 | + case "xx-small": |
|
| 945 | + $fs = 3/5 * $this->_parent_font_size; |
|
| 946 | + break; |
|
| 947 | + |
|
| 948 | + case "x-small": |
|
| 949 | + $fs = 3/4 * $this->_parent_font_size; |
|
| 950 | + break; |
|
| 951 | + |
|
| 952 | + case "smaller": |
|
| 953 | + case "small": |
|
| 954 | + $fs = 8/9 * $this->_parent_font_size; |
|
| 955 | + break; |
|
| 956 | + |
|
| 957 | + case "medium": |
|
| 958 | + $fs = $this->_parent_font_size; |
|
| 959 | + break; |
|
| 960 | + |
|
| 961 | + case "larger": |
|
| 962 | + case "large": |
|
| 963 | + $fs = 6/5 * $this->_parent_font_size; |
|
| 964 | + break; |
|
| 965 | + |
|
| 966 | + case "x-large": |
|
| 967 | + $fs = 3/2 * $this->_parent_font_size; |
|
| 968 | + break; |
|
| 969 | + |
|
| 970 | + case "xx-large": |
|
| 971 | + $fs = 2/1 * $this->_parent_font_size; |
|
| 972 | + break; |
|
| 973 | + |
|
| 974 | + default: |
|
| 975 | + break; |
|
| 976 | 976 | } |
| 977 | 977 | |
| 978 | 978 | // Ensure relative sizes resolve to something |
@@ -1058,61 +1058,61 @@ discard block |
||
| 1058 | 1058 | |
| 1059 | 1059 | switch ($tmp[0]) { |
| 1060 | 1060 | |
| 1061 | - case "left": |
|
| 1062 | - $x = "0%"; |
|
| 1063 | - break; |
|
| 1061 | + case "left": |
|
| 1062 | + $x = "0%"; |
|
| 1063 | + break; |
|
| 1064 | 1064 | |
| 1065 | - case "right": |
|
| 1066 | - $x = "100%"; |
|
| 1067 | - break; |
|
| 1065 | + case "right": |
|
| 1066 | + $x = "100%"; |
|
| 1067 | + break; |
|
| 1068 | 1068 | |
| 1069 | - case "top": |
|
| 1070 | - $y = "0%"; |
|
| 1071 | - break; |
|
| 1069 | + case "top": |
|
| 1070 | + $y = "0%"; |
|
| 1071 | + break; |
|
| 1072 | 1072 | |
| 1073 | - case "bottom": |
|
| 1074 | - $y = "100%"; |
|
| 1075 | - break; |
|
| 1073 | + case "bottom": |
|
| 1074 | + $y = "100%"; |
|
| 1075 | + break; |
|
| 1076 | 1076 | |
| 1077 | - case "center": |
|
| 1078 | - $x = "50%"; |
|
| 1079 | - $y = "50%"; |
|
| 1080 | - break; |
|
| 1077 | + case "center": |
|
| 1078 | + $x = "50%"; |
|
| 1079 | + $y = "50%"; |
|
| 1080 | + break; |
|
| 1081 | 1081 | |
| 1082 | - default: |
|
| 1083 | - $x = $tmp[0]; |
|
| 1084 | - break; |
|
| 1082 | + default: |
|
| 1083 | + $x = $tmp[0]; |
|
| 1084 | + break; |
|
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | 1087 | if ( isset($tmp[1]) ) { |
| 1088 | 1088 | |
| 1089 | 1089 | switch ($tmp[1]) { |
| 1090 | - case "left": |
|
| 1091 | - $x = "0%"; |
|
| 1092 | - break; |
|
| 1090 | + case "left": |
|
| 1091 | + $x = "0%"; |
|
| 1092 | + break; |
|
| 1093 | 1093 | |
| 1094 | - case "right": |
|
| 1095 | - $x = "100%"; |
|
| 1096 | - break; |
|
| 1094 | + case "right": |
|
| 1095 | + $x = "100%"; |
|
| 1096 | + break; |
|
| 1097 | 1097 | |
| 1098 | - case "top": |
|
| 1099 | - $y = "0%"; |
|
| 1100 | - break; |
|
| 1098 | + case "top": |
|
| 1099 | + $y = "0%"; |
|
| 1100 | + break; |
|
| 1101 | 1101 | |
| 1102 | - case "bottom": |
|
| 1103 | - $y = "100%"; |
|
| 1104 | - break; |
|
| 1102 | + case "bottom": |
|
| 1103 | + $y = "100%"; |
|
| 1104 | + break; |
|
| 1105 | 1105 | |
| 1106 | - case "center": |
|
| 1107 | - if ( $tmp[0] === "left" || $tmp[0] === "right" || $tmp[0] === "center" ) |
|
| 1108 | - $y = "50%"; |
|
| 1109 | - else |
|
| 1110 | - $x = "50%"; |
|
| 1111 | - break; |
|
| 1106 | + case "center": |
|
| 1107 | + if ( $tmp[0] === "left" || $tmp[0] === "right" || $tmp[0] === "center" ) |
|
| 1108 | + $y = "50%"; |
|
| 1109 | + else |
|
| 1110 | + $x = "50%"; |
|
| 1111 | + break; |
|
| 1112 | 1112 | |
| 1113 | - default: |
|
| 1114 | - $y = $tmp[1]; |
|
| 1115 | - break; |
|
| 1113 | + default: |
|
| 1114 | + $y = $tmp[1]; |
|
| 1115 | + break; |
|
| 1116 | 1116 | } |
| 1117 | 1117 | |
| 1118 | 1118 | } else { |
@@ -1384,20 +1384,20 @@ discard block |
||
| 1384 | 1384 | protected function _set_style_type($style,$type,$val,$important) { |
| 1385 | 1385 | $arr = explode(" ", $val); |
| 1386 | 1386 | switch (count($arr)) { |
| 1387 | - case 1: |
|
| 1388 | - $this->_set_style_sides_type($style,$arr[0],$arr[0],$arr[0],$arr[0],$type,$important); |
|
| 1389 | - break; |
|
| 1390 | - case 2: |
|
| 1391 | - $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[0],$arr[1],$type,$important); |
|
| 1392 | - break; |
|
| 1393 | - case 3: |
|
| 1394 | - $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[1],$arr[2],$type,$important); |
|
| 1395 | - break; |
|
| 1396 | - case 4: |
|
| 1397 | - $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[2],$arr[3],$type,$important); |
|
| 1398 | - break; |
|
| 1399 | - default: |
|
| 1400 | - break; |
|
| 1387 | + case 1: |
|
| 1388 | + $this->_set_style_sides_type($style,$arr[0],$arr[0],$arr[0],$arr[0],$type,$important); |
|
| 1389 | + break; |
|
| 1390 | + case 2: |
|
| 1391 | + $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[0],$arr[1],$type,$important); |
|
| 1392 | + break; |
|
| 1393 | + case 3: |
|
| 1394 | + $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[1],$arr[2],$type,$important); |
|
| 1395 | + break; |
|
| 1396 | + case 4: |
|
| 1397 | + $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[2],$arr[3],$type,$important); |
|
| 1398 | + break; |
|
| 1399 | + default: |
|
| 1400 | + break; |
|
| 1401 | 1401 | } |
| 1402 | 1402 | //see __set and __get, on all assignments clear cache! |
| 1403 | 1403 | $this->_prop_cache[$style.$type] = null; |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * |
| 112 | 112 | * @var array |
| 113 | 113 | */ |
| 114 | - static $BLOCK_TYPES = array("block","inline-block", "table-cell", "list-item"); |
|
| 114 | + static $BLOCK_TYPES = array("block", "inline-block", "table-cell", "list-item"); |
|
| 115 | 115 | |
| 116 | 116 | /** |
| 117 | 117 | * List of all table types. Should really be a constant. |
@@ -199,10 +199,10 @@ discard block |
||
| 199 | 199 | $this->_parent_font_size = null; |
| 200 | 200 | $this->__font_size_calculated = false; |
| 201 | 201 | |
| 202 | - if ( !isset(self::$_defaults) ) { |
|
| 202 | + if (!isset(self::$_defaults)) { |
|
| 203 | 203 | |
| 204 | 204 | // Shorthand |
| 205 | - $d =& self::$_defaults; |
|
| 205 | + $d = & self::$_defaults; |
|
| 206 | 206 | |
| 207 | 207 | // All CSS 2.1 properties, and their default values |
| 208 | 208 | $d["azimuth"] = "center"; |
@@ -398,90 +398,90 @@ discard block |
||
| 398 | 398 | */ |
| 399 | 399 | function length_in_pt($length, $ref_size = null) { |
| 400 | 400 | |
| 401 | - if ( !is_array($length) ) |
|
| 401 | + if (!is_array($length)) |
|
| 402 | 402 | $length = array($length); |
| 403 | 403 | |
| 404 | - if ( !isset($ref_size) ) |
|
| 404 | + if (!isset($ref_size)) |
|
| 405 | 405 | $ref_size = self::$default_font_size; |
| 406 | 406 | |
| 407 | 407 | $ret = 0; |
| 408 | 408 | foreach ($length as $l) { |
| 409 | 409 | |
| 410 | - if ( $l === "auto" ) |
|
| 410 | + if ($l === "auto") |
|
| 411 | 411 | return "auto"; |
| 412 | 412 | |
| 413 | - if ( $l === "none" ) |
|
| 413 | + if ($l === "none") |
|
| 414 | 414 | return "none"; |
| 415 | 415 | |
| 416 | 416 | // Assume numeric values are already in points |
| 417 | - if ( is_numeric($l) ) { |
|
| 417 | + if (is_numeric($l)) { |
|
| 418 | 418 | $ret += $l; |
| 419 | 419 | continue; |
| 420 | 420 | } |
| 421 | 421 | |
| 422 | - if ( $l === "normal" ) { |
|
| 422 | + if ($l === "normal") { |
|
| 423 | 423 | $ret += $ref_size; |
| 424 | 424 | continue; |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | // Border lengths |
| 428 | - if ( $l === "thin" ) { |
|
| 428 | + if ($l === "thin") { |
|
| 429 | 429 | $ret += 0.5; |
| 430 | 430 | continue; |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - if ( $l === "medium" ) { |
|
| 433 | + if ($l === "medium") { |
|
| 434 | 434 | $ret += 1.5; |
| 435 | 435 | continue; |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - if ( $l === "thick" ) { |
|
| 438 | + if ($l === "thick") { |
|
| 439 | 439 | $ret += 2.5; |
| 440 | 440 | continue; |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | - if ( ($i = mb_strpos($l, "pt")) !== false ) { |
|
| 443 | + if (($i = mb_strpos($l, "pt")) !== false) { |
|
| 444 | 444 | $ret += mb_substr($l, 0, $i); |
| 445 | 445 | continue; |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - if ( ($i = mb_strpos($l, "px")) !== false ) { |
|
| 449 | - $ret += ( mb_substr($l, 0, $i) * 72 ) / DOMPDF_DPI; |
|
| 448 | + if (($i = mb_strpos($l, "px")) !== false) { |
|
| 449 | + $ret += (mb_substr($l, 0, $i) * 72) / DOMPDF_DPI; |
|
| 450 | 450 | continue; |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | - if ( ($i = mb_strpos($l, "em")) !== false ) { |
|
| 453 | + if (($i = mb_strpos($l, "em")) !== false) { |
|
| 454 | 454 | $ret += mb_substr($l, 0, $i) * $this->__get("font_size"); |
| 455 | 455 | continue; |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | // FIXME: em:ex ratio? |
| 459 | - if ( ($i = mb_strpos($l, "ex")) !== false ) { |
|
| 459 | + if (($i = mb_strpos($l, "ex")) !== false) { |
|
| 460 | 460 | $ret += mb_substr($l, 0, $i) * $this->__get("font_size"); |
| 461 | 461 | continue; |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - if ( ($i = mb_strpos($l, "%")) !== false ) { |
|
| 465 | - $ret += mb_substr($l, 0, $i)/100 * $ref_size; |
|
| 464 | + if (($i = mb_strpos($l, "%")) !== false) { |
|
| 465 | + $ret += mb_substr($l, 0, $i) / 100 * $ref_size; |
|
| 466 | 466 | continue; |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | - if ( ($i = mb_strpos($l, "in")) !== false ) { |
|
| 469 | + if (($i = mb_strpos($l, "in")) !== false) { |
|
| 470 | 470 | $ret += mb_substr($l, 0, $i) * 72; |
| 471 | 471 | continue; |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | - if ( ($i = mb_strpos($l, "cm")) !== false ) { |
|
| 474 | + if (($i = mb_strpos($l, "cm")) !== false) { |
|
| 475 | 475 | $ret += mb_substr($l, 0, $i) * 72 / 2.54; |
| 476 | 476 | continue; |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | - if ( ($i = mb_strpos($l, "mm")) !== false ) { |
|
| 479 | + if (($i = mb_strpos($l, "mm")) !== false) { |
|
| 480 | 480 | $ret += mb_substr($l, 0, $i) * 72 / 25.4; |
| 481 | 481 | continue; |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | - if ( ($i = mb_strpos($l, "pc")) !== false ) { |
|
| 484 | + if (($i = mb_strpos($l, "pc")) !== false) { |
|
| 485 | 485 | $ret += mb_substr($l, 0, $i) / 12; |
| 486 | 486 | continue; |
| 487 | 487 | } |
@@ -507,12 +507,12 @@ discard block |
||
| 507 | 507 | foreach (self::$_inherited as $prop) { |
| 508 | 508 | //inherit the !important property also. |
| 509 | 509 | //if local property is also !important, don't inherit. |
| 510 | - if ( isset($parent->_props[$prop]) && |
|
| 511 | - ( !isset($this->_props[$prop]) || |
|
| 512 | - ( isset($parent->_important_props[$prop]) && !isset($this->_important_props[$prop]) ) |
|
| 510 | + if (isset($parent->_props[$prop]) && |
|
| 511 | + (!isset($this->_props[$prop]) || |
|
| 512 | + (isset($parent->_important_props[$prop]) && !isset($this->_important_props[$prop])) |
|
| 513 | 513 | ) |
| 514 | 514 | ) { |
| 515 | - if ( isset($parent->_important_props[$prop]) ) { |
|
| 515 | + if (isset($parent->_important_props[$prop])) { |
|
| 516 | 516 | $this->_important_props[$prop] = true; |
| 517 | 517 | } |
| 518 | 518 | //see __set and __get, on all assignments clear cache! |
@@ -522,8 +522,8 @@ discard block |
||
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | foreach (array_keys($this->_props) as $prop) { |
| 525 | - if ( $this->_props[$prop] === "inherit" ) { |
|
| 526 | - if ( isset($parent->_important_props[$prop]) ) { |
|
| 525 | + if ($this->_props[$prop] === "inherit") { |
|
| 526 | + if (isset($parent->_important_props[$prop])) { |
|
| 527 | 527 | $this->_important_props[$prop] = true; |
| 528 | 528 | } |
| 529 | 529 | //do not assign direct, but |
@@ -554,20 +554,20 @@ discard block |
||
| 554 | 554 | //treat the !important attribute |
| 555 | 555 | //if old rule has !important attribute, override with new rule only if |
| 556 | 556 | //the new rule is also !important |
| 557 | - foreach($style->_props as $prop => $val ) { |
|
| 557 | + foreach ($style->_props as $prop => $val) { |
|
| 558 | 558 | if (isset($style->_important_props[$prop])) { |
| 559 | 559 | $this->_important_props[$prop] = true; |
| 560 | 560 | //see __set and __get, on all assignments clear cache! |
| 561 | 561 | $this->_prop_cache[$prop] = null; |
| 562 | 562 | $this->_props[$prop] = $val; |
| 563 | - } else if ( !isset($this->_important_props[$prop]) ) { |
|
| 563 | + } else if (!isset($this->_important_props[$prop])) { |
|
| 564 | 564 | //see __set and __get, on all assignments clear cache! |
| 565 | 565 | $this->_prop_cache[$prop] = null; |
| 566 | 566 | $this->_props[$prop] = $val; |
| 567 | 567 | } |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | - if ( isset($style->_props["font_size"]) ) |
|
| 570 | + if (isset($style->_props["font_size"])) |
|
| 571 | 571 | $this->__font_size_calculated = false; |
| 572 | 572 | } |
| 573 | 573 | |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | * @return array |
| 581 | 581 | */ |
| 582 | 582 | function munge_colour($colour) { |
| 583 | - if ( is_array($colour) ) |
|
| 583 | + if (is_array($colour)) |
|
| 584 | 584 | // Assume the array has the right format... |
| 585 | 585 | // FIXME: should/could verify this. |
| 586 | 586 | return $colour; |
@@ -671,19 +671,19 @@ discard block |
||
| 671 | 671 | return "transparent"; |
| 672 | 672 | |
| 673 | 673 | default: |
| 674 | - if ( mb_strlen($colour) == 4 && $colour[0] === "#" ) { |
|
| 674 | + if (mb_strlen($colour) == 4 && $colour[0] === "#") { |
|
| 675 | 675 | // #rgb format |
| 676 | - $r = hexdec($colour[1] . $colour[1]); |
|
| 677 | - $g = hexdec($colour[2] . $colour[2]); |
|
| 678 | - $b = hexdec($colour[3] . $colour[3]); |
|
| 676 | + $r = hexdec($colour[1].$colour[1]); |
|
| 677 | + $g = hexdec($colour[2].$colour[2]); |
|
| 678 | + $b = hexdec($colour[3].$colour[3]); |
|
| 679 | 679 | |
| 680 | - } else if ( mb_strlen($colour) == 7 && $colour[0] === "#" ) { |
|
| 680 | + } else if (mb_strlen($colour) == 7 && $colour[0] === "#") { |
|
| 681 | 681 | // #rrggbb format |
| 682 | 682 | $r = hexdec(mb_substr($colour, 1, 2)); |
| 683 | 683 | $g = hexdec(mb_substr($colour, 3, 2)); |
| 684 | 684 | $b = hexdec(mb_substr($colour, 5, 2)); |
| 685 | 685 | |
| 686 | - } else if ( mb_strpos($colour, "rgb") !== false ) { |
|
| 686 | + } else if (mb_strpos($colour, "rgb") !== false) { |
|
| 687 | 687 | // rgb( r,g,b ) format |
| 688 | 688 | $i = mb_strpos($colour, "("); |
| 689 | 689 | $j = mb_strpos($colour, ")"); |
@@ -692,7 +692,7 @@ discard block |
||
| 692 | 692 | if ($i === false || $j === false) |
| 693 | 693 | return null; |
| 694 | 694 | |
| 695 | - $triplet = explode(",", mb_substr($colour, $i+1, $j-$i-1)); |
|
| 695 | + $triplet = explode(",", mb_substr($colour, $i + 1, $j - $i - 1)); |
|
| 696 | 696 | |
| 697 | 697 | if (count($triplet) != 3) |
| 698 | 698 | return null; |
@@ -700,7 +700,7 @@ discard block |
||
| 700 | 700 | foreach (array_keys($triplet) as $c) { |
| 701 | 701 | $triplet[$c] = trim($triplet[$c]); |
| 702 | 702 | |
| 703 | - if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%" ) |
|
| 703 | + if ($triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%") |
|
| 704 | 704 | $triplet[$c] = round($triplet[$c] * 0.255); |
| 705 | 705 | } |
| 706 | 706 | |
@@ -784,19 +784,19 @@ discard block |
||
| 784 | 784 | $prop = str_replace("-", "_", $prop); |
| 785 | 785 | $this->_prop_cache[$prop] = null; |
| 786 | 786 | |
| 787 | - if ( !isset(self::$_defaults[$prop]) ) { |
|
| 787 | + if (!isset(self::$_defaults[$prop])) { |
|
| 788 | 788 | $_dompdf_warnings[] = "'$prop' is not a valid CSS2 property."; |
| 789 | 789 | return; |
| 790 | 790 | } |
| 791 | 791 | |
| 792 | - if ( $prop !== "content" && is_string($val) && mb_strpos($val, "url") === false ) { |
|
| 792 | + if ($prop !== "content" && is_string($val) && mb_strpos($val, "url") === false) { |
|
| 793 | 793 | $val = mb_strtolower(trim(str_replace(array("\n", "\t"), array(" "), $val))); |
| 794 | 794 | $val = preg_replace("/([0-9]+) (pt|px|pc|em|ex|in|cm|mm|%)/S", "\\1\\2", $val); |
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | $method = "set_$prop"; |
| 798 | 798 | |
| 799 | - if ( method_exists($this, $method) ) |
|
| 799 | + if (method_exists($this, $method)) |
|
| 800 | 800 | $this->$method($val); |
| 801 | 801 | else |
| 802 | 802 | $this->_props[$prop] = $val; |
@@ -818,19 +818,19 @@ discard block |
||
| 818 | 818 | */ |
| 819 | 819 | function __get($prop) { |
| 820 | 820 | |
| 821 | - if ( !isset(self::$_defaults[$prop]) ) |
|
| 821 | + if (!isset(self::$_defaults[$prop])) |
|
| 822 | 822 | throw new DOMPDF_Exception("'$prop' is not a valid CSS2 property."); |
| 823 | 823 | |
| 824 | - if ( isset($this->_prop_cache[$prop]) && $this->_prop_cache[$prop] != null) |
|
| 824 | + if (isset($this->_prop_cache[$prop]) && $this->_prop_cache[$prop] != null) |
|
| 825 | 825 | return $this->_prop_cache[$prop]; |
| 826 | 826 | |
| 827 | 827 | $method = "get_$prop"; |
| 828 | 828 | |
| 829 | 829 | // Fall back on defaults if property is not set |
| 830 | - if ( !isset($this->_props[$prop]) ) |
|
| 830 | + if (!isset($this->_props[$prop])) |
|
| 831 | 831 | $this->_props[$prop] = self::$_defaults[$prop]; |
| 832 | 832 | |
| 833 | - if ( method_exists($this, $method) ) |
|
| 833 | + if (method_exists($this, $method)) |
|
| 834 | 834 | return $this->_prop_cache[$prop] = $this->$method(); |
| 835 | 835 | |
| 836 | 836 | |
@@ -849,7 +849,7 @@ discard block |
||
| 849 | 849 | */ |
| 850 | 850 | function get_font_family() { |
| 851 | 851 | |
| 852 | - $DEBUGCSS=DEBUGCSS; //=DEBUGCSS; Allow override of global setting for ad hoc debug |
|
| 852 | + $DEBUGCSS = DEBUGCSS; //=DEBUGCSS; Allow override of global setting for ad hoc debug |
|
| 853 | 853 | |
| 854 | 854 | // Select the appropriate font. First determine the subtype, then check |
| 855 | 855 | // the specified font-families for a candidate. |
@@ -857,14 +857,14 @@ discard block |
||
| 857 | 857 | // Resolve font-weight |
| 858 | 858 | $weight = $this->__get("font_weight"); |
| 859 | 859 | |
| 860 | - if ( is_numeric($weight) ) { |
|
| 860 | + if (is_numeric($weight)) { |
|
| 861 | 861 | |
| 862 | - if ( $weight < 600 ) |
|
| 862 | + if ($weight < 600) |
|
| 863 | 863 | $weight = "normal"; |
| 864 | 864 | else |
| 865 | 865 | $weight = "bold"; |
| 866 | 866 | |
| 867 | - } else if ( $weight === "bold" || $weight === "bolder" ) { |
|
| 867 | + } else if ($weight === "bold" || $weight === "bolder") { |
|
| 868 | 868 | $weight = "bold"; |
| 869 | 869 | |
| 870 | 870 | } else { |
@@ -875,11 +875,11 @@ discard block |
||
| 875 | 875 | // Resolve font-style |
| 876 | 876 | $font_style = $this->__get("font_style"); |
| 877 | 877 | |
| 878 | - if ( $weight === "bold" && ($font_style === "italic" || $font_style === "oblique") ) |
|
| 878 | + if ($weight === "bold" && ($font_style === "italic" || $font_style === "oblique")) |
|
| 879 | 879 | $subtype = "bold_italic"; |
| 880 | - else if ( $weight === "bold" && $font_style !== "italic" && $font_style !== "oblique" ) |
|
| 880 | + else if ($weight === "bold" && $font_style !== "italic" && $font_style !== "oblique") |
|
| 881 | 881 | $subtype = "bold"; |
| 882 | - else if ( $weight !== "bold" && ($font_style === "italic" || $font_style === "oblique") ) |
|
| 882 | + else if ($weight !== "bold" && ($font_style === "italic" || $font_style === "oblique")) |
|
| 883 | 883 | $subtype = "italic"; |
| 884 | 884 | else |
| 885 | 885 | $subtype = "normal"; |
@@ -890,19 +890,19 @@ discard block |
||
| 890 | 890 | print '('.$this->_props["font_family"].'.'.$font_style.'.'.$this->__get("font_weight").'.'.$weight.'.'.$subtype.')'; |
| 891 | 891 | } |
| 892 | 892 | $families = explode(",", $this->_props["font_family"]); |
| 893 | - $families = array_map('trim',$families); |
|
| 893 | + $families = array_map('trim', $families); |
|
| 894 | 894 | reset($families); |
| 895 | 895 | |
| 896 | 896 | $font = null; |
| 897 | - while ( current($families) ) { |
|
| 897 | + while (current($families)) { |
|
| 898 | 898 | list(,$family) = each($families); |
| 899 | 899 | //remove leading and trailing string delimiters, e.g. on font names with spaces; |
| 900 | 900 | //remove leading and trailing whitespace |
| 901 | - $family=trim($family," \t\n\r\x0B\"'"); |
|
| 901 | + $family = trim($family, " \t\n\r\x0B\"'"); |
|
| 902 | 902 | if ($DEBUGCSS) print '('.$family.')'; |
| 903 | 903 | $font = Font_Metrics::get_font($family, $subtype); |
| 904 | 904 | |
| 905 | - if ( $font ) { |
|
| 905 | + if ($font) { |
|
| 906 | 906 | if ($DEBUGCSS) print '('.$font.")get_font_family]\n</pre>"; |
| 907 | 907 | return $font; |
| 908 | 908 | } |
@@ -912,11 +912,11 @@ discard block |
||
| 912 | 912 | if ($DEBUGCSS) print '(default)'; |
| 913 | 913 | $font = Font_Metrics::get_font($family, $subtype); |
| 914 | 914 | |
| 915 | - if ( $font ) { |
|
| 915 | + if ($font) { |
|
| 916 | 916 | if ($DEBUGCSS) print '('.$font.")get_font_family]\n</pre>"; |
| 917 | 917 | return $font; |
| 918 | 918 | } |
| 919 | - throw new DOMPDF_Exception("Unable to find a suitable font replacement for: '" . $this->_props["font_family"] ."'"); |
|
| 919 | + throw new DOMPDF_Exception("Unable to find a suitable font replacement for: '".$this->_props["font_family"]."'"); |
|
| 920 | 920 | |
| 921 | 921 | } |
| 922 | 922 | |
@@ -928,30 +928,30 @@ discard block |
||
| 928 | 928 | */ |
| 929 | 929 | function get_font_size() { |
| 930 | 930 | |
| 931 | - if ( $this->__font_size_calculated ) |
|
| 931 | + if ($this->__font_size_calculated) |
|
| 932 | 932 | return $this->_props["font_size"]; |
| 933 | 933 | |
| 934 | - if ( !isset($this->_props["font_size"]) ) |
|
| 934 | + if (!isset($this->_props["font_size"])) |
|
| 935 | 935 | $fs = self::$_defaults["font_size"]; |
| 936 | 936 | else |
| 937 | 937 | $fs = $this->_props["font_size"]; |
| 938 | 938 | |
| 939 | - if ( !isset($this->_parent_font_size) ) |
|
| 939 | + if (!isset($this->_parent_font_size)) |
|
| 940 | 940 | $this->_parent_font_size = self::$default_font_size; |
| 941 | 941 | |
| 942 | 942 | switch ($fs) { |
| 943 | 943 | |
| 944 | 944 | case "xx-small": |
| 945 | - $fs = 3/5 * $this->_parent_font_size; |
|
| 945 | + $fs = 3 / 5 * $this->_parent_font_size; |
|
| 946 | 946 | break; |
| 947 | 947 | |
| 948 | 948 | case "x-small": |
| 949 | - $fs = 3/4 * $this->_parent_font_size; |
|
| 949 | + $fs = 3 / 4 * $this->_parent_font_size; |
|
| 950 | 950 | break; |
| 951 | 951 | |
| 952 | 952 | case "smaller": |
| 953 | 953 | case "small": |
| 954 | - $fs = 8/9 * $this->_parent_font_size; |
|
| 954 | + $fs = 8 / 9 * $this->_parent_font_size; |
|
| 955 | 955 | break; |
| 956 | 956 | |
| 957 | 957 | case "medium": |
@@ -960,15 +960,15 @@ discard block |
||
| 960 | 960 | |
| 961 | 961 | case "larger": |
| 962 | 962 | case "large": |
| 963 | - $fs = 6/5 * $this->_parent_font_size; |
|
| 963 | + $fs = 6 / 5 * $this->_parent_font_size; |
|
| 964 | 964 | break; |
| 965 | 965 | |
| 966 | 966 | case "x-large": |
| 967 | - $fs = 3/2 * $this->_parent_font_size; |
|
| 967 | + $fs = 3 / 2 * $this->_parent_font_size; |
|
| 968 | 968 | break; |
| 969 | 969 | |
| 970 | 970 | case "xx-large": |
| 971 | - $fs = 2/1 * $this->_parent_font_size; |
|
| 971 | + $fs = 2 / 1 * $this->_parent_font_size; |
|
| 972 | 972 | break; |
| 973 | 973 | |
| 974 | 974 | default: |
@@ -976,10 +976,10 @@ discard block |
||
| 976 | 976 | } |
| 977 | 977 | |
| 978 | 978 | // Ensure relative sizes resolve to something |
| 979 | - if ( ($i = mb_strpos($fs, "em")) !== false ) |
|
| 979 | + if (($i = mb_strpos($fs, "em")) !== false) |
|
| 980 | 980 | $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size; |
| 981 | 981 | |
| 982 | - else if ( ($i = mb_strpos($fs, "ex")) !== false ) |
|
| 982 | + else if (($i = mb_strpos($fs, "ex")) !== false) |
|
| 983 | 983 | $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size; |
| 984 | 984 | |
| 985 | 985 | else |
@@ -998,7 +998,7 @@ discard block |
||
| 998 | 998 | * @return float |
| 999 | 999 | */ |
| 1000 | 1000 | function get_word_spacing() { |
| 1001 | - if ( $this->_props["word_spacing"] === "normal" ) |
|
| 1001 | + if ($this->_props["word_spacing"] === "normal") |
|
| 1002 | 1002 | return 0; |
| 1003 | 1003 | |
| 1004 | 1004 | return $this->_props["word_spacing"]; |
@@ -1009,13 +1009,13 @@ discard block |
||
| 1009 | 1009 | * @return float |
| 1010 | 1010 | */ |
| 1011 | 1011 | function get_line_height() { |
| 1012 | - if ( $this->_props["line_height"] === "normal" ) |
|
| 1012 | + if ($this->_props["line_height"] === "normal") |
|
| 1013 | 1013 | return self::$default_line_height * $this->get_font_size(); |
| 1014 | 1014 | |
| 1015 | - if ( is_numeric($this->_props["line_height"]) ) |
|
| 1016 | - return $this->length_in_pt( $this->_props["line_height"] . "%", $this->get_font_size()); |
|
| 1015 | + if (is_numeric($this->_props["line_height"])) |
|
| 1016 | + return $this->length_in_pt($this->_props["line_height"]."%", $this->get_font_size()); |
|
| 1017 | 1017 | |
| 1018 | - return $this->length_in_pt( $this->_props["line_height"], $this->get_font_size() ); |
|
| 1018 | + return $this->length_in_pt($this->_props["line_height"], $this->get_font_size()); |
|
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | 1021 | /** |
@@ -1028,7 +1028,7 @@ discard block |
||
| 1028 | 1028 | * @return array |
| 1029 | 1029 | */ |
| 1030 | 1030 | function get_color() { |
| 1031 | - return $this->munge_color( $this->_props["color"] ); |
|
| 1031 | + return $this->munge_color($this->_props["color"]); |
|
| 1032 | 1032 | } |
| 1033 | 1033 | |
| 1034 | 1034 | /** |
@@ -1040,7 +1040,7 @@ discard block |
||
| 1040 | 1040 | * @return array |
| 1041 | 1041 | */ |
| 1042 | 1042 | function get_background_color() { |
| 1043 | - return $this->munge_color( $this->_props["background_color"] ); |
|
| 1043 | + return $this->munge_color($this->_props["background_color"]); |
|
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | 1046 | /** |
@@ -1084,7 +1084,7 @@ discard block |
||
| 1084 | 1084 | break; |
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | - if ( isset($tmp[1]) ) { |
|
| 1087 | + if (isset($tmp[1])) { |
|
| 1088 | 1088 | |
| 1089 | 1089 | switch ($tmp[1]) { |
| 1090 | 1090 | case "left": |
@@ -1104,7 +1104,7 @@ discard block |
||
| 1104 | 1104 | break; |
| 1105 | 1105 | |
| 1106 | 1106 | case "center": |
| 1107 | - if ( $tmp[0] === "left" || $tmp[0] === "right" || $tmp[0] === "center" ) |
|
| 1107 | + if ($tmp[0] === "left" || $tmp[0] === "right" || $tmp[0] === "center") |
|
| 1108 | 1108 | $y = "50%"; |
| 1109 | 1109 | else |
| 1110 | 1110 | $x = "50%"; |
@@ -1119,14 +1119,14 @@ discard block |
||
| 1119 | 1119 | $y = "50%"; |
| 1120 | 1120 | } |
| 1121 | 1121 | |
| 1122 | - if ( !isset($x) ) |
|
| 1122 | + if (!isset($x)) |
|
| 1123 | 1123 | $x = "0%"; |
| 1124 | 1124 | |
| 1125 | - if ( !isset($y) ) |
|
| 1125 | + if (!isset($y)) |
|
| 1126 | 1126 | $y = "0%"; |
| 1127 | 1127 | |
| 1128 | - return array( 0 => $x, "x" => $x, |
|
| 1129 | - 1 => $y, "y" => $y ); |
|
| 1128 | + return array(0 => $x, "x" => $x, |
|
| 1129 | + 1 => $y, "y" => $y); |
|
| 1130 | 1130 | } |
| 1131 | 1131 | |
| 1132 | 1132 | |
@@ -1181,7 +1181,7 @@ discard block |
||
| 1181 | 1181 | * @return array |
| 1182 | 1182 | */ |
| 1183 | 1183 | function get_border_top_color() { |
| 1184 | - if ( $this->_props["border_top_color"] === "" ) { |
|
| 1184 | + if ($this->_props["border_top_color"] === "") { |
|
| 1185 | 1185 | //see __set and __get, on all assignments clear cache! |
| 1186 | 1186 | $this->_prop_cache["border_top_color"] = null; |
| 1187 | 1187 | $this->_props["border_top_color"] = $this->__get("color"); |
@@ -1190,7 +1190,7 @@ discard block |
||
| 1190 | 1190 | } |
| 1191 | 1191 | |
| 1192 | 1192 | function get_border_right_color() { |
| 1193 | - if ( $this->_props["border_right_color"] === "" ) { |
|
| 1193 | + if ($this->_props["border_right_color"] === "") { |
|
| 1194 | 1194 | //see __set and __get, on all assignments clear cache! |
| 1195 | 1195 | $this->_prop_cache["border_right_color"] = null; |
| 1196 | 1196 | $this->_props["border_right_color"] = $this->__get("color"); |
@@ -1199,16 +1199,16 @@ discard block |
||
| 1199 | 1199 | } |
| 1200 | 1200 | |
| 1201 | 1201 | function get_border_bottom_color() { |
| 1202 | - if ( $this->_props["border_bottom_color"] === "" ) { |
|
| 1202 | + if ($this->_props["border_bottom_color"] === "") { |
|
| 1203 | 1203 | //see __set and __get, on all assignments clear cache! |
| 1204 | 1204 | $this->_prop_cache["border_bottom_color"] = null; |
| 1205 | 1205 | $this->_props["border_bottom_color"] = $this->__get("color"); |
| 1206 | 1206 | } |
| 1207 | - return $this->munge_color($this->_props["border_bottom_color"]);; |
|
| 1207 | + return $this->munge_color($this->_props["border_bottom_color"]); ; |
|
| 1208 | 1208 | } |
| 1209 | 1209 | |
| 1210 | 1210 | function get_border_left_color() { |
| 1211 | - if ( $this->_props["border_left_color"] === "" ) { |
|
| 1211 | + if ($this->_props["border_left_color"] === "") { |
|
| 1212 | 1212 | //see __set and __get, on all assignments clear cache! |
| 1213 | 1213 | $this->_prop_cache["border_left_color"] = null; |
| 1214 | 1214 | $this->_props["border_left_color"] = $this->__get("color"); |
@@ -1279,10 +1279,10 @@ discard block |
||
| 1279 | 1279 | * @return mixed |
| 1280 | 1280 | */ |
| 1281 | 1281 | protected function _get_border($side) { |
| 1282 | - $color = $this->__get("border_" . $side . "_color"); |
|
| 1282 | + $color = $this->__get("border_".$side."_color"); |
|
| 1283 | 1283 | |
| 1284 | - return $this->__get("border_" . $side . "_width") . " " . |
|
| 1285 | - $this->__get("border_" . $side . "_style") . " " . $color["hex"]; |
|
| 1284 | + return $this->__get("border_".$side."_width")." ". |
|
| 1285 | + $this->__get("border_".$side."_style")." ".$color["hex"]; |
|
| 1286 | 1286 | } |
| 1287 | 1287 | |
| 1288 | 1288 | /**#@+ |
@@ -1363,8 +1363,8 @@ discard block |
||
| 1363 | 1363 | * Applicable for background, border, padding, margin, font, list_style |
| 1364 | 1364 | * Note: $type has a leading underscore (or is empty), the others not. |
| 1365 | 1365 | */ |
| 1366 | - protected function _set_style_side_type($style,$side,$type,$val,$important) { |
|
| 1367 | - if ( !isset($this->_important_props[$style.'_'.$side.$type]) || $important) { |
|
| 1366 | + protected function _set_style_side_type($style, $side, $type, $val, $important) { |
|
| 1367 | + if (!isset($this->_important_props[$style.'_'.$side.$type]) || $important) { |
|
| 1368 | 1368 | //see __set and __get, on all assignments clear cache! |
| 1369 | 1369 | $this->_prop_cache[$style.'_'.$side.$type] = null; |
| 1370 | 1370 | if ($important) { |
@@ -1374,27 +1374,27 @@ discard block |
||
| 1374 | 1374 | } |
| 1375 | 1375 | } |
| 1376 | 1376 | |
| 1377 | - protected function _set_style_sides_type($style,$top,$right,$bottom,$left,$type,$important) { |
|
| 1378 | - $this->_set_style_side_type($style,'top',$type,$top,$important); |
|
| 1379 | - $this->_set_style_side_type($style,'right',$type,$right,$important); |
|
| 1380 | - $this->_set_style_side_type($style,'bottom',$type,$bottom,$important); |
|
| 1381 | - $this->_set_style_side_type($style,'left',$type,$left,$important); |
|
| 1377 | + protected function _set_style_sides_type($style, $top, $right, $bottom, $left, $type, $important) { |
|
| 1378 | + $this->_set_style_side_type($style, 'top', $type, $top, $important); |
|
| 1379 | + $this->_set_style_side_type($style, 'right', $type, $right, $important); |
|
| 1380 | + $this->_set_style_side_type($style, 'bottom', $type, $bottom, $important); |
|
| 1381 | + $this->_set_style_side_type($style, 'left', $type, $left, $important); |
|
| 1382 | 1382 | } |
| 1383 | 1383 | |
| 1384 | - protected function _set_style_type($style,$type,$val,$important) { |
|
| 1384 | + protected function _set_style_type($style, $type, $val, $important) { |
|
| 1385 | 1385 | $arr = explode(" ", $val); |
| 1386 | 1386 | switch (count($arr)) { |
| 1387 | 1387 | case 1: |
| 1388 | - $this->_set_style_sides_type($style,$arr[0],$arr[0],$arr[0],$arr[0],$type,$important); |
|
| 1388 | + $this->_set_style_sides_type($style, $arr[0], $arr[0], $arr[0], $arr[0], $type, $important); |
|
| 1389 | 1389 | break; |
| 1390 | 1390 | case 2: |
| 1391 | - $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[0],$arr[1],$type,$important); |
|
| 1391 | + $this->_set_style_sides_type($style, $arr[0], $arr[1], $arr[0], $arr[1], $type, $important); |
|
| 1392 | 1392 | break; |
| 1393 | 1393 | case 3: |
| 1394 | - $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[1],$arr[2],$type,$important); |
|
| 1394 | + $this->_set_style_sides_type($style, $arr[0], $arr[1], $arr[1], $arr[2], $type, $important); |
|
| 1395 | 1395 | break; |
| 1396 | 1396 | case 4: |
| 1397 | - $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[2],$arr[3],$type,$important); |
|
| 1397 | + $this->_set_style_sides_type($style, $arr[0], $arr[1], $arr[2], $arr[3], $type, $important); |
|
| 1398 | 1398 | break; |
| 1399 | 1399 | default: |
| 1400 | 1400 | break; |
@@ -1404,21 +1404,21 @@ discard block |
||
| 1404 | 1404 | $this->_props[$style.$type] = $val; |
| 1405 | 1405 | } |
| 1406 | 1406 | |
| 1407 | - protected function _set_style_type_important($style,$type,$val) { |
|
| 1408 | - $this->_set_style_type($style,$type,$val,isset($this->_important_props[$style.$type])); |
|
| 1407 | + protected function _set_style_type_important($style, $type, $val) { |
|
| 1408 | + $this->_set_style_type($style, $type, $val, isset($this->_important_props[$style.$type])); |
|
| 1409 | 1409 | } |
| 1410 | 1410 | |
| 1411 | 1411 | /* Anyway only called if _important matches and is assigned |
| 1412 | 1412 | * E.g. _set_style_side_type($style,$side,'',str_replace("none", "0px", $val),isset($this->_important_props[$style.'_'.$side])); |
| 1413 | 1413 | */ |
| 1414 | - protected function _set_style_side_width_important($style,$side,$val) { |
|
| 1414 | + protected function _set_style_side_width_important($style, $side, $val) { |
|
| 1415 | 1415 | //see __set and __get, on all assignments clear cache! |
| 1416 | 1416 | $this->_prop_cache[$style.'_'.$side] = null; |
| 1417 | 1417 | $this->_props[$style.'_'.$side] = str_replace("none", "0px", $val); |
| 1418 | 1418 | } |
| 1419 | 1419 | |
| 1420 | - protected function _set_style($style,$val,$important) { |
|
| 1421 | - if ( !isset($this->_important_props[$style]) || $important) { |
|
| 1420 | + protected function _set_style($style, $val, $important) { |
|
| 1421 | + if (!isset($this->_important_props[$style]) || $important) { |
|
| 1422 | 1422 | if ($important) { |
| 1423 | 1423 | $this->_important_props[$style] = true; |
| 1424 | 1424 | } |
@@ -1429,22 +1429,22 @@ discard block |
||
| 1429 | 1429 | } |
| 1430 | 1430 | |
| 1431 | 1431 | protected function _image($val) { |
| 1432 | - $DEBUGCSS=DEBUGCSS; |
|
| 1432 | + $DEBUGCSS = DEBUGCSS; |
|
| 1433 | 1433 | |
| 1434 | - if ( mb_strpos($val, "url") === false ) { |
|
| 1434 | + if (mb_strpos($val, "url") === false) { |
|
| 1435 | 1435 | $path = "none"; //Don't resolve no image -> otherwise would prefix path and no longer recognize as none |
| 1436 | 1436 | } else { |
| 1437 | - $val = preg_replace("/url\(['\"]?([^'\")]+)['\"]?\)/","\\1", trim($val)); |
|
| 1437 | + $val = preg_replace("/url\(['\"]?([^'\")]+)['\"]?\)/", "\\1", trim($val)); |
|
| 1438 | 1438 | |
| 1439 | 1439 | // Resolve the url now in the context of the current stylesheet |
| 1440 | 1440 | $parsed_url = explode_url($val); |
| 1441 | - if ( $parsed_url["protocol"] == "" && $this->_stylesheet->get_protocol() == "" ) { |
|
| 1442 | - if ($parsed_url["path"]{0} === '/' || $parsed_url["path"]{0} === '\\' ) { |
|
| 1441 | + if ($parsed_url["protocol"] == "" && $this->_stylesheet->get_protocol() == "") { |
|
| 1442 | + if ($parsed_url["path"]{0} === '/' || $parsed_url["path"]{0} === '\\') { |
|
| 1443 | 1443 | $path = $_SERVER["DOCUMENT_ROOT"].'/'; |
| 1444 | 1444 | } else { |
| 1445 | 1445 | $path = $this->_stylesheet->get_base_path(); |
| 1446 | 1446 | } |
| 1447 | - $path .= $parsed_url["path"] . $parsed_url["file"]; |
|
| 1447 | + $path .= $parsed_url["path"].$parsed_url["file"]; |
|
| 1448 | 1448 | $path = realpath($path); |
| 1449 | 1449 | // If realpath returns FALSE then specifically state that there is no background image |
| 1450 | 1450 | if (!$path) { $path = 'none'; } |
@@ -1459,7 +1459,7 @@ discard block |
||
| 1459 | 1459 | print "<pre>[_image\n"; |
| 1460 | 1460 | print_r($parsed_url); |
| 1461 | 1461 | print $this->_stylesheet->get_protocol()."\n".$this->_stylesheet->get_base_path()."\n".$path."\n"; |
| 1462 | - print "_image]</pre>";; |
|
| 1462 | + print "_image]</pre>"; ; |
|
| 1463 | 1463 | } |
| 1464 | 1464 | return $path; |
| 1465 | 1465 | } |
@@ -1477,7 +1477,7 @@ discard block |
||
| 1477 | 1477 | function set_color($colour) { |
| 1478 | 1478 | $col = $this->munge_colour($colour); |
| 1479 | 1479 | |
| 1480 | - if ( is_null($col) ) |
|
| 1480 | + if (is_null($col)) |
|
| 1481 | 1481 | $col = self::$_defaults["color"]; |
| 1482 | 1482 | |
| 1483 | 1483 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
@@ -1493,7 +1493,7 @@ discard block |
||
| 1493 | 1493 | */ |
| 1494 | 1494 | function set_background_color($colour) { |
| 1495 | 1495 | $col = $this->munge_colour($colour); |
| 1496 | - if ( is_null($col) ) |
|
| 1496 | + if (is_null($col)) |
|
| 1497 | 1497 | $col = self::$_defaults["background_color"]; |
| 1498 | 1498 | |
| 1499 | 1499 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
@@ -1520,7 +1520,7 @@ discard block |
||
| 1520 | 1520 | * @param string $val |
| 1521 | 1521 | */ |
| 1522 | 1522 | function set_background_repeat($val) { |
| 1523 | - if ( is_null($val) ) |
|
| 1523 | + if (is_null($val)) |
|
| 1524 | 1524 | $val = self::$_defaults["background_repeat"]; |
| 1525 | 1525 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1526 | 1526 | $this->_prop_cache["background_repeat"] = null; |
@@ -1534,7 +1534,7 @@ discard block |
||
| 1534 | 1534 | * @param string $val |
| 1535 | 1535 | */ |
| 1536 | 1536 | function set_background_attachment($val) { |
| 1537 | - if ( is_null($val) ) |
|
| 1537 | + if (is_null($val)) |
|
| 1538 | 1538 | $val = self::$_defaults["background_attachment"]; |
| 1539 | 1539 | |
| 1540 | 1540 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
@@ -1549,7 +1549,7 @@ discard block |
||
| 1549 | 1549 | * @param string $val |
| 1550 | 1550 | */ |
| 1551 | 1551 | function set_background_position($val) { |
| 1552 | - if ( is_null($val) ) |
|
| 1552 | + if (is_null($val)) |
|
| 1553 | 1553 | $val = self::$_defaults["background_position"]; |
| 1554 | 1554 | |
| 1555 | 1555 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
@@ -1568,21 +1568,21 @@ discard block |
||
| 1568 | 1568 | $pos = array(); |
| 1569 | 1569 | $tmp = explode(" ", $val); |
| 1570 | 1570 | $important = isset($this->_important_props["background"]); |
| 1571 | - foreach($tmp as $attr) { |
|
| 1571 | + foreach ($tmp as $attr) { |
|
| 1572 | 1572 | if (mb_substr($attr, 0, 3) === "url" || $attr === "none") { |
| 1573 | 1573 | $this->_set_style("background_image", $this->_image($attr), $important); |
| 1574 | 1574 | } else if ($attr === "fixed" || $attr === "scroll") { |
| 1575 | 1575 | $this->_set_style("background_attachment", $attr, $important); |
| 1576 | 1576 | } else if ($attr === "repeat" || $attr === "repeat-x" || $attr === "repeat-y" || $attr === "no-repeat") { |
| 1577 | 1577 | $this->_set_style("background_repeat", $attr, $important); |
| 1578 | - } else if (($col = $this->munge_color($attr)) != null ) { |
|
| 1578 | + } else if (($col = $this->munge_color($attr)) != null) { |
|
| 1579 | 1579 | $this->_set_style("background_color", is_array($col) ? $col["hex"] : $col, $important); |
| 1580 | 1580 | } else { |
| 1581 | 1581 | $pos[] = $attr; |
| 1582 | 1582 | } |
| 1583 | 1583 | } |
| 1584 | 1584 | if (count($pos)) { |
| 1585 | - $this->_set_style("background_position",implode(' ',$pos), $important); |
|
| 1585 | + $this->_set_style("background_position", implode(' ', $pos), $important); |
|
| 1586 | 1586 | } |
| 1587 | 1587 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1588 | 1588 | $this->_prop_cache["background"] = null; |
@@ -1636,14 +1636,14 @@ discard block |
||
| 1636 | 1636 | |
| 1637 | 1637 | $important = isset($this->_important_props["font"]); |
| 1638 | 1638 | |
| 1639 | - if ( preg_match("/^(italic|oblique|normal)\s*(.*)$/i",$val,$match) ) { |
|
| 1639 | + if (preg_match("/^(italic|oblique|normal)\s*(.*)$/i", $val, $match)) { |
|
| 1640 | 1640 | $this->_set_style("font_style", $match[1], $important); |
| 1641 | 1641 | $val = $match[2]; |
| 1642 | 1642 | } else { |
| 1643 | 1643 | $this->_set_style("font_style", self::$_defaults["font_style"], $important); |
| 1644 | 1644 | } |
| 1645 | 1645 | |
| 1646 | - if ( preg_match("/^(small-caps|normal)\s*(.*)$/i",$val,$match) ) { |
|
| 1646 | + if (preg_match("/^(small-caps|normal)\s*(.*)$/i", $val, $match)) { |
|
| 1647 | 1647 | $this->_set_style("font_variant", $match[1], $important); |
| 1648 | 1648 | $val = $match[2]; |
| 1649 | 1649 | } else { |
@@ -1651,8 +1651,8 @@ discard block |
||
| 1651 | 1651 | } |
| 1652 | 1652 | |
| 1653 | 1653 | //matching numeric value followed by unit -> this is indeed a subsequent font size. Skip! |
| 1654 | - if ( preg_match("/^(bold|bolder|lighter|100|200|300|400|500|600|700|800|900|normal)\s*(.*)$/i",$val,$match) && |
|
| 1655 | - !preg_match("/^(?:pt|px|pc|em|ex|in|cm|mm|%)/",$match[2]) |
|
| 1654 | + if (preg_match("/^(bold|bolder|lighter|100|200|300|400|500|600|700|800|900|normal)\s*(.*)$/i", $val, $match) && |
|
| 1655 | + !preg_match("/^(?:pt|px|pc|em|ex|in|cm|mm|%)/", $match[2]) |
|
| 1656 | 1656 | ) { |
| 1657 | 1657 | $this->_set_style("font_weight", $match[1], $important); |
| 1658 | 1658 | $val = $match[2]; |
@@ -1660,10 +1660,10 @@ discard block |
||
| 1660 | 1660 | $this->_set_style("font_weight", self::$_defaults["font_weight"], $important); |
| 1661 | 1661 | } |
| 1662 | 1662 | |
| 1663 | - if ( preg_match("/^(xx-small|x-small|small|medium|large|x-large|xx-large|smaller|larger|\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i",$val,$match) ) { |
|
| 1663 | + if (preg_match("/^(xx-small|x-small|small|medium|large|x-large|xx-large|smaller|larger|\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i", $val, $match)) { |
|
| 1664 | 1664 | $this->_set_style("font_size", $match[1], $important); |
| 1665 | 1665 | $val = $match[2]; |
| 1666 | - if (preg_match("/^\/\s*(\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i",$val,$match) ) { |
|
| 1666 | + if (preg_match("/^\/\s*(\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i", $val, $match)) { |
|
| 1667 | 1667 | $this->_set_style("line_height", $match[1], $important); |
| 1668 | 1668 | $val = $match[2]; |
| 1669 | 1669 | } else { |
@@ -1674,7 +1674,7 @@ discard block |
||
| 1674 | 1674 | $this->_set_style("line_height", self::$_defaults["line_height"], $important); |
| 1675 | 1675 | } |
| 1676 | 1676 | |
| 1677 | - if(strlen($val) != 0) { |
|
| 1677 | + if (strlen($val) != 0) { |
|
| 1678 | 1678 | $this->_set_style("font_family", $val, $important); |
| 1679 | 1679 | } else { |
| 1680 | 1680 | $this->_set_style("font_family", self::$_defaults["font_family"], $important); |
@@ -1715,24 +1715,24 @@ discard block |
||
| 1715 | 1715 | * @param $val |
| 1716 | 1716 | */ |
| 1717 | 1717 | function set_margin_top($val) { |
| 1718 | - $this->_set_style_side_width_important('margin','top',$val); |
|
| 1718 | + $this->_set_style_side_width_important('margin', 'top', $val); |
|
| 1719 | 1719 | } |
| 1720 | 1720 | |
| 1721 | 1721 | function set_margin_right($val) { |
| 1722 | - $this->_set_style_side_width_important('margin','right',$val); |
|
| 1722 | + $this->_set_style_side_width_important('margin', 'right', $val); |
|
| 1723 | 1723 | } |
| 1724 | 1724 | |
| 1725 | 1725 | function set_margin_bottom($val) { |
| 1726 | - $this->_set_style_side_width_important('margin','bottom',$val); |
|
| 1726 | + $this->_set_style_side_width_important('margin', 'bottom', $val); |
|
| 1727 | 1727 | } |
| 1728 | 1728 | |
| 1729 | 1729 | function set_margin_left($val) { |
| 1730 | - $this->_set_style_side_width_important('margin','left',$val); |
|
| 1730 | + $this->_set_style_side_width_important('margin', 'left', $val); |
|
| 1731 | 1731 | } |
| 1732 | 1732 | |
| 1733 | 1733 | function set_margin($val) { |
| 1734 | 1734 | $val = str_replace("none", "0px", $val); |
| 1735 | - $this->_set_style_type_important('margin','',$val); |
|
| 1735 | + $this->_set_style_type_important('margin', '', $val); |
|
| 1736 | 1736 | } |
| 1737 | 1737 | /**#@-*/ |
| 1738 | 1738 | |
@@ -1743,24 +1743,24 @@ discard block |
||
| 1743 | 1743 | * @param $val |
| 1744 | 1744 | */ |
| 1745 | 1745 | function set_padding_top($val) { |
| 1746 | - $this->_set_style_side_width_important('padding','top',$val); |
|
| 1746 | + $this->_set_style_side_width_important('padding', 'top', $val); |
|
| 1747 | 1747 | } |
| 1748 | 1748 | |
| 1749 | 1749 | function set_padding_right($val) { |
| 1750 | - $this->_set_style_side_width_important('padding','right',$val); |
|
| 1750 | + $this->_set_style_side_width_important('padding', 'right', $val); |
|
| 1751 | 1751 | } |
| 1752 | 1752 | |
| 1753 | 1753 | function set_padding_bottom($val) { |
| 1754 | - $this->_set_style_side_width_important('padding','bottom',$val); |
|
| 1754 | + $this->_set_style_side_width_important('padding', 'bottom', $val); |
|
| 1755 | 1755 | } |
| 1756 | 1756 | |
| 1757 | 1757 | function set_padding_left($val) { |
| 1758 | - $this->_set_style_side_width_important('padding','left',$val); |
|
| 1758 | + $this->_set_style_side_width_important('padding', 'left', $val); |
|
| 1759 | 1759 | } |
| 1760 | 1760 | |
| 1761 | 1761 | function set_padding($val) { |
| 1762 | 1762 | $val = str_replace("none", "0px", $val); |
| 1763 | - $this->_set_style_type_important('padding','',$val); |
|
| 1763 | + $this->_set_style_type_important('padding', '', $val); |
|
| 1764 | 1764 | } |
| 1765 | 1765 | /**#@-*/ |
| 1766 | 1766 | |
@@ -1778,21 +1778,21 @@ discard block |
||
| 1778 | 1778 | |
| 1779 | 1779 | //For consistency of individal and combined properties, and with ie8 and firefox3 |
| 1780 | 1780 | //reset all attributes, even if only partially given |
| 1781 | - $this->_set_style_side_type('border',$side,'_style',self::$_defaults['border_'.$side.'_style'],$important); |
|
| 1782 | - $this->_set_style_side_type('border',$side,'_width',self::$_defaults['border_'.$side.'_width'],$important); |
|
| 1783 | - $this->_set_style_side_type('border',$side,'_color',self::$_defaults['border_'.$side.'_color'],$important); |
|
| 1781 | + $this->_set_style_side_type('border', $side, '_style', self::$_defaults['border_'.$side.'_style'], $important); |
|
| 1782 | + $this->_set_style_side_type('border', $side, '_width', self::$_defaults['border_'.$side.'_width'], $important); |
|
| 1783 | + $this->_set_style_side_type('border', $side, '_color', self::$_defaults['border_'.$side.'_color'], $important); |
|
| 1784 | 1784 | |
| 1785 | 1785 | foreach ($arr as $value) { |
| 1786 | 1786 | $value = trim($value); |
| 1787 | - if ( in_array($value, self::$BORDER_STYLES) ) { |
|
| 1788 | - $this->_set_style_side_type('border',$side,'_style',$value,$important); |
|
| 1787 | + if (in_array($value, self::$BORDER_STYLES)) { |
|
| 1788 | + $this->_set_style_side_type('border', $side, '_style', $value, $important); |
|
| 1789 | 1789 | |
| 1790 | - } else if ( preg_match("/[.0-9]+(?:px|pt|pc|em|ex|%|in|mm|cm)|(?:thin|medium|thick)/", $value ) ) { |
|
| 1791 | - $this->_set_style_side_type('border',$side,'_width',$value,$important); |
|
| 1790 | + } else if (preg_match("/[.0-9]+(?:px|pt|pc|em|ex|%|in|mm|cm)|(?:thin|medium|thick)/", $value)) { |
|
| 1791 | + $this->_set_style_side_type('border', $side, '_width', $value, $important); |
|
| 1792 | 1792 | |
| 1793 | 1793 | } else { |
| 1794 | 1794 | // must be colour |
| 1795 | - $this->_set_style_side_type('border',$side,'_color',$value,$important); |
|
| 1795 | + $this->_set_style_side_type('border', $side, '_color', $value, $important); |
|
| 1796 | 1796 | } |
| 1797 | 1797 | } |
| 1798 | 1798 | |
@@ -1824,15 +1824,15 @@ discard block |
||
| 1824 | 1824 | } |
| 1825 | 1825 | |
| 1826 | 1826 | function set_border_width($val) { |
| 1827 | - $this->_set_style_type_important('border','_width',$val); |
|
| 1827 | + $this->_set_style_type_important('border', '_width', $val); |
|
| 1828 | 1828 | } |
| 1829 | 1829 | |
| 1830 | 1830 | function set_border_color($val) { |
| 1831 | - $this->_set_style_type_important('border','_color',$val); |
|
| 1831 | + $this->_set_style_type_important('border', '_color', $val); |
|
| 1832 | 1832 | } |
| 1833 | 1833 | |
| 1834 | 1834 | function set_border_style($val) { |
| 1835 | - $this->_set_style_type_important('border','_style',$val); |
|
| 1835 | + $this->_set_style_type_important('border', '_style', $val); |
|
| 1836 | 1836 | } |
| 1837 | 1837 | /**#@-*/ |
| 1838 | 1838 | |
@@ -1847,12 +1847,12 @@ discard block |
||
| 1847 | 1847 | |
| 1848 | 1848 | $arr = explode(" ", $val); |
| 1849 | 1849 | |
| 1850 | - if ( count($arr) == 1 ) |
|
| 1850 | + if (count($arr) == 1) |
|
| 1851 | 1851 | $arr[1] = $arr[0]; |
| 1852 | 1852 | |
| 1853 | 1853 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1854 | 1854 | $this->_prop_cache["border_spacing"] = null; |
| 1855 | - $this->_props["border_spacing"] = $arr[0] . " " . $arr[1]; |
|
| 1855 | + $this->_props["border_spacing"] = $arr[0]." ".$arr[1]; |
|
| 1856 | 1856 | } |
| 1857 | 1857 | |
| 1858 | 1858 | /** |
@@ -1907,9 +1907,9 @@ discard block |
||
| 1907 | 1907 | continue; |
| 1908 | 1908 | } |
| 1909 | 1909 | |
| 1910 | - if ( in_array($value, $types) ) { |
|
| 1910 | + if (in_array($value, $types)) { |
|
| 1911 | 1911 | $this->_set_style("list_style_type", $value, $important); |
| 1912 | - } else if ( in_array($value, $positions) ) { |
|
| 1912 | + } else if (in_array($value, $positions)) { |
|
| 1913 | 1913 | $this->_set_style("list_style_position", $value, $important); |
| 1914 | 1914 | } |
| 1915 | 1915 | } |
@@ -1935,8 +1935,8 @@ discard block |
||
| 1935 | 1935 | |
| 1936 | 1936 | /*DEBUGCSS*/ function debug_print() |
| 1937 | 1937 | /*DEBUGCSS*/ { |
| 1938 | -/*DEBUGCSS*/ print "parent_font_size:".$this->_parent_font_size . ";\n"; |
|
| 1939 | -/*DEBUGCSS*/ foreach($this->_props as $prop => $val ) { |
|
| 1938 | +/*DEBUGCSS*/ print "parent_font_size:".$this->_parent_font_size.";\n"; |
|
| 1939 | +/*DEBUGCSS*/ foreach ($this->_props as $prop => $val) { |
|
| 1940 | 1940 | /*DEBUGCSS*/ print $prop.':'.$val; |
| 1941 | 1941 | /*DEBUGCSS*/ if (isset($this->_important_props[$prop])) { |
| 1942 | 1942 | /*DEBUGCSS*/ print '!important'; |
@@ -398,20 +398,24 @@ discard block |
||
| 398 | 398 | */ |
| 399 | 399 | function length_in_pt($length, $ref_size = null) { |
| 400 | 400 | |
| 401 | - if ( !is_array($length) ) |
|
| 402 | - $length = array($length); |
|
| 401 | + if ( !is_array($length) ) { |
|
| 402 | + $length = array($length); |
|
| 403 | + } |
|
| 403 | 404 | |
| 404 | - if ( !isset($ref_size) ) |
|
| 405 | - $ref_size = self::$default_font_size; |
|
| 405 | + if ( !isset($ref_size) ) { |
|
| 406 | + $ref_size = self::$default_font_size; |
|
| 407 | + } |
|
| 406 | 408 | |
| 407 | 409 | $ret = 0; |
| 408 | 410 | foreach ($length as $l) { |
| 409 | 411 | |
| 410 | - if ( $l === "auto" ) |
|
| 411 | - return "auto"; |
|
| 412 | + if ( $l === "auto" ) { |
|
| 413 | + return "auto"; |
|
| 414 | + } |
|
| 412 | 415 | |
| 413 | - if ( $l === "none" ) |
|
| 414 | - return "none"; |
|
| 416 | + if ( $l === "none" ) { |
|
| 417 | + return "none"; |
|
| 418 | + } |
|
| 415 | 419 | |
| 416 | 420 | // Assume numeric values are already in points |
| 417 | 421 | if ( is_numeric($l) ) { |
@@ -567,8 +571,9 @@ discard block |
||
| 567 | 571 | } |
| 568 | 572 | } |
| 569 | 573 | |
| 570 | - if ( isset($style->_props["font_size"]) ) |
|
| 571 | - $this->__font_size_calculated = false; |
|
| 574 | + if ( isset($style->_props["font_size"]) ) { |
|
| 575 | + $this->__font_size_calculated = false; |
|
| 576 | + } |
|
| 572 | 577 | } |
| 573 | 578 | |
| 574 | 579 | |
@@ -580,10 +585,11 @@ discard block |
||
| 580 | 585 | * @return array |
| 581 | 586 | */ |
| 582 | 587 | function munge_colour($colour) { |
| 583 | - if ( is_array($colour) ) |
|
| 584 | - // Assume the array has the right format... |
|
| 588 | + if ( is_array($colour) ) { |
|
| 589 | + // Assume the array has the right format... |
|
| 585 | 590 | // FIXME: should/could verify this. |
| 586 | 591 | return $colour; |
| 592 | + } |
|
| 587 | 593 | |
| 588 | 594 | $r = 0; |
| 589 | 595 | $g = 0; |
@@ -689,19 +695,22 @@ discard block |
||
| 689 | 695 | $j = mb_strpos($colour, ")"); |
| 690 | 696 | |
| 691 | 697 | // Bad colour value |
| 692 | - if ($i === false || $j === false) |
|
| 693 | - return null; |
|
| 698 | + if ($i === false || $j === false) { |
|
| 699 | + return null; |
|
| 700 | + } |
|
| 694 | 701 | |
| 695 | 702 | $triplet = explode(",", mb_substr($colour, $i+1, $j-$i-1)); |
| 696 | 703 | |
| 697 | - if (count($triplet) != 3) |
|
| 698 | - return null; |
|
| 704 | + if (count($triplet) != 3) { |
|
| 705 | + return null; |
|
| 706 | + } |
|
| 699 | 707 | |
| 700 | 708 | foreach (array_keys($triplet) as $c) { |
| 701 | 709 | $triplet[$c] = trim($triplet[$c]); |
| 702 | 710 | |
| 703 | - if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%" ) |
|
| 704 | - $triplet[$c] = round($triplet[$c] * 0.255); |
|
| 711 | + if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%" ) { |
|
| 712 | + $triplet[$c] = round($triplet[$c] * 0.255); |
|
| 713 | + } |
|
| 705 | 714 | } |
| 706 | 715 | |
| 707 | 716 | list($r, $g, $b) = $triplet; |
@@ -796,10 +805,11 @@ discard block |
||
| 796 | 805 | |
| 797 | 806 | $method = "set_$prop"; |
| 798 | 807 | |
| 799 | - if ( method_exists($this, $method) ) |
|
| 800 | - $this->$method($val); |
|
| 801 | - else |
|
| 802 | - $this->_props[$prop] = $val; |
|
| 808 | + if ( method_exists($this, $method) ) { |
|
| 809 | + $this->$method($val); |
|
| 810 | + } else { |
|
| 811 | + $this->_props[$prop] = $val; |
|
| 812 | + } |
|
| 803 | 813 | |
| 804 | 814 | } |
| 805 | 815 | |
@@ -818,20 +828,24 @@ discard block |
||
| 818 | 828 | */ |
| 819 | 829 | function __get($prop) { |
| 820 | 830 | |
| 821 | - if ( !isset(self::$_defaults[$prop]) ) |
|
| 822 | - throw new DOMPDF_Exception("'$prop' is not a valid CSS2 property."); |
|
| 831 | + if ( !isset(self::$_defaults[$prop]) ) { |
|
| 832 | + throw new DOMPDF_Exception("'$prop' is not a valid CSS2 property."); |
|
| 833 | + } |
|
| 823 | 834 | |
| 824 | - if ( isset($this->_prop_cache[$prop]) && $this->_prop_cache[$prop] != null) |
|
| 825 | - return $this->_prop_cache[$prop]; |
|
| 835 | + if ( isset($this->_prop_cache[$prop]) && $this->_prop_cache[$prop] != null) { |
|
| 836 | + return $this->_prop_cache[$prop]; |
|
| 837 | + } |
|
| 826 | 838 | |
| 827 | 839 | $method = "get_$prop"; |
| 828 | 840 | |
| 829 | 841 | // Fall back on defaults if property is not set |
| 830 | - if ( !isset($this->_props[$prop]) ) |
|
| 831 | - $this->_props[$prop] = self::$_defaults[$prop]; |
|
| 842 | + if ( !isset($this->_props[$prop]) ) { |
|
| 843 | + $this->_props[$prop] = self::$_defaults[$prop]; |
|
| 844 | + } |
|
| 832 | 845 | |
| 833 | - if ( method_exists($this, $method) ) |
|
| 834 | - return $this->_prop_cache[$prop] = $this->$method(); |
|
| 846 | + if ( method_exists($this, $method) ) { |
|
| 847 | + return $this->_prop_cache[$prop] = $this->$method(); |
|
| 848 | + } |
|
| 835 | 849 | |
| 836 | 850 | |
| 837 | 851 | return $this->_prop_cache[$prop] = $this->_props[$prop]; |
@@ -859,10 +873,11 @@ discard block |
||
| 859 | 873 | |
| 860 | 874 | if ( is_numeric($weight) ) { |
| 861 | 875 | |
| 862 | - if ( $weight < 600 ) |
|
| 863 | - $weight = "normal"; |
|
| 864 | - else |
|
| 865 | - $weight = "bold"; |
|
| 876 | + if ( $weight < 600 ) { |
|
| 877 | + $weight = "normal"; |
|
| 878 | + } else { |
|
| 879 | + $weight = "bold"; |
|
| 880 | + } |
|
| 866 | 881 | |
| 867 | 882 | } else if ( $weight === "bold" || $weight === "bolder" ) { |
| 868 | 883 | $weight = "bold"; |
@@ -875,14 +890,15 @@ discard block |
||
| 875 | 890 | // Resolve font-style |
| 876 | 891 | $font_style = $this->__get("font_style"); |
| 877 | 892 | |
| 878 | - if ( $weight === "bold" && ($font_style === "italic" || $font_style === "oblique") ) |
|
| 879 | - $subtype = "bold_italic"; |
|
| 880 | - else if ( $weight === "bold" && $font_style !== "italic" && $font_style !== "oblique" ) |
|
| 881 | - $subtype = "bold"; |
|
| 882 | - else if ( $weight !== "bold" && ($font_style === "italic" || $font_style === "oblique") ) |
|
| 883 | - $subtype = "italic"; |
|
| 884 | - else |
|
| 885 | - $subtype = "normal"; |
|
| 893 | + if ( $weight === "bold" && ($font_style === "italic" || $font_style === "oblique") ) { |
|
| 894 | + $subtype = "bold_italic"; |
|
| 895 | + } else if ( $weight === "bold" && $font_style !== "italic" && $font_style !== "oblique" ) { |
|
| 896 | + $subtype = "bold"; |
|
| 897 | + } else if ( $weight !== "bold" && ($font_style === "italic" || $font_style === "oblique") ) { |
|
| 898 | + $subtype = "italic"; |
|
| 899 | + } else { |
|
| 900 | + $subtype = "normal"; |
|
| 901 | + } |
|
| 886 | 902 | |
| 887 | 903 | // Resolve the font family |
| 888 | 904 | if ($DEBUGCSS) { |
@@ -899,21 +915,29 @@ discard block |
||
| 899 | 915 | //remove leading and trailing string delimiters, e.g. on font names with spaces; |
| 900 | 916 | //remove leading and trailing whitespace |
| 901 | 917 | $family=trim($family," \t\n\r\x0B\"'"); |
| 902 | - if ($DEBUGCSS) print '('.$family.')'; |
|
| 918 | + if ($DEBUGCSS) { |
|
| 919 | + print '('.$family.')'; |
|
| 920 | + } |
|
| 903 | 921 | $font = Font_Metrics::get_font($family, $subtype); |
| 904 | 922 | |
| 905 | 923 | if ( $font ) { |
| 906 | - if ($DEBUGCSS) print '('.$font.")get_font_family]\n</pre>"; |
|
| 924 | + if ($DEBUGCSS) { |
|
| 925 | + print '('.$font.")get_font_family]\n</pre>"; |
|
| 926 | + } |
|
| 907 | 927 | return $font; |
| 908 | 928 | } |
| 909 | 929 | } |
| 910 | 930 | |
| 911 | 931 | $family = null; |
| 912 | - if ($DEBUGCSS) print '(default)'; |
|
| 932 | + if ($DEBUGCSS) { |
|
| 933 | + print '(default)'; |
|
| 934 | + } |
|
| 913 | 935 | $font = Font_Metrics::get_font($family, $subtype); |
| 914 | 936 | |
| 915 | 937 | if ( $font ) { |
| 916 | - if ($DEBUGCSS) print '('.$font.")get_font_family]\n</pre>"; |
|
| 938 | + if ($DEBUGCSS) { |
|
| 939 | + print '('.$font.")get_font_family]\n</pre>"; |
|
| 940 | + } |
|
| 917 | 941 | return $font; |
| 918 | 942 | } |
| 919 | 943 | throw new DOMPDF_Exception("Unable to find a suitable font replacement for: '" . $this->_props["font_family"] ."'"); |
@@ -928,16 +952,19 @@ discard block |
||
| 928 | 952 | */ |
| 929 | 953 | function get_font_size() { |
| 930 | 954 | |
| 931 | - if ( $this->__font_size_calculated ) |
|
| 932 | - return $this->_props["font_size"]; |
|
| 955 | + if ( $this->__font_size_calculated ) { |
|
| 956 | + return $this->_props["font_size"]; |
|
| 957 | + } |
|
| 933 | 958 | |
| 934 | - if ( !isset($this->_props["font_size"]) ) |
|
| 935 | - $fs = self::$_defaults["font_size"]; |
|
| 936 | - else |
|
| 937 | - $fs = $this->_props["font_size"]; |
|
| 959 | + if ( !isset($this->_props["font_size"]) ) { |
|
| 960 | + $fs = self::$_defaults["font_size"]; |
|
| 961 | + } else { |
|
| 962 | + $fs = $this->_props["font_size"]; |
|
| 963 | + } |
|
| 938 | 964 | |
| 939 | - if ( !isset($this->_parent_font_size) ) |
|
| 940 | - $this->_parent_font_size = self::$default_font_size; |
|
| 965 | + if ( !isset($this->_parent_font_size) ) { |
|
| 966 | + $this->_parent_font_size = self::$default_font_size; |
|
| 967 | + } |
|
| 941 | 968 | |
| 942 | 969 | switch ($fs) { |
| 943 | 970 | |
@@ -976,14 +1003,13 @@ discard block |
||
| 976 | 1003 | } |
| 977 | 1004 | |
| 978 | 1005 | // Ensure relative sizes resolve to something |
| 979 | - if ( ($i = mb_strpos($fs, "em")) !== false ) |
|
| 980 | - $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size; |
|
| 981 | - |
|
| 982 | - else if ( ($i = mb_strpos($fs, "ex")) !== false ) |
|
| 983 | - $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size; |
|
| 984 | - |
|
| 985 | - else |
|
| 986 | - $fs = $this->length_in_pt($fs); |
|
| 1006 | + if ( ($i = mb_strpos($fs, "em")) !== false ) { |
|
| 1007 | + $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size; |
|
| 1008 | + } else if ( ($i = mb_strpos($fs, "ex")) !== false ) { |
|
| 1009 | + $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size; |
|
| 1010 | + } else { |
|
| 1011 | + $fs = $this->length_in_pt($fs); |
|
| 1012 | + } |
|
| 987 | 1013 | |
| 988 | 1014 | //see __set and __get, on all assignments clear cache! |
| 989 | 1015 | $this->_prop_cache["font_size"] = null; |
@@ -998,8 +1024,9 @@ discard block |
||
| 998 | 1024 | * @return float |
| 999 | 1025 | */ |
| 1000 | 1026 | function get_word_spacing() { |
| 1001 | - if ( $this->_props["word_spacing"] === "normal" ) |
|
| 1002 | - return 0; |
|
| 1027 | + if ( $this->_props["word_spacing"] === "normal" ) { |
|
| 1028 | + return 0; |
|
| 1029 | + } |
|
| 1003 | 1030 | |
| 1004 | 1031 | return $this->_props["word_spacing"]; |
| 1005 | 1032 | } |
@@ -1009,11 +1036,13 @@ discard block |
||
| 1009 | 1036 | * @return float |
| 1010 | 1037 | */ |
| 1011 | 1038 | function get_line_height() { |
| 1012 | - if ( $this->_props["line_height"] === "normal" ) |
|
| 1013 | - return self::$default_line_height * $this->get_font_size(); |
|
| 1039 | + if ( $this->_props["line_height"] === "normal" ) { |
|
| 1040 | + return self::$default_line_height * $this->get_font_size(); |
|
| 1041 | + } |
|
| 1014 | 1042 | |
| 1015 | - if ( is_numeric($this->_props["line_height"]) ) |
|
| 1016 | - return $this->length_in_pt( $this->_props["line_height"] . "%", $this->get_font_size()); |
|
| 1043 | + if ( is_numeric($this->_props["line_height"]) ) { |
|
| 1044 | + return $this->length_in_pt( $this->_props["line_height"] . "%", $this->get_font_size()); |
|
| 1045 | + } |
|
| 1017 | 1046 | |
| 1018 | 1047 | return $this->length_in_pt( $this->_props["line_height"], $this->get_font_size() ); |
| 1019 | 1048 | } |
@@ -1104,10 +1133,11 @@ discard block |
||
| 1104 | 1133 | break; |
| 1105 | 1134 | |
| 1106 | 1135 | case "center": |
| 1107 | - if ( $tmp[0] === "left" || $tmp[0] === "right" || $tmp[0] === "center" ) |
|
| 1108 | - $y = "50%"; |
|
| 1109 | - else |
|
| 1110 | - $x = "50%"; |
|
| 1136 | + if ( $tmp[0] === "left" || $tmp[0] === "right" || $tmp[0] === "center" ) { |
|
| 1137 | + $y = "50%"; |
|
| 1138 | + } else { |
|
| 1139 | + $x = "50%"; |
|
| 1140 | + } |
|
| 1111 | 1141 | break; |
| 1112 | 1142 | |
| 1113 | 1143 | default: |
@@ -1119,11 +1149,13 @@ discard block |
||
| 1119 | 1149 | $y = "50%"; |
| 1120 | 1150 | } |
| 1121 | 1151 | |
| 1122 | - if ( !isset($x) ) |
|
| 1123 | - $x = "0%"; |
|
| 1152 | + if ( !isset($x) ) { |
|
| 1153 | + $x = "0%"; |
|
| 1154 | + } |
|
| 1124 | 1155 | |
| 1125 | - if ( !isset($y) ) |
|
| 1126 | - $y = "0%"; |
|
| 1156 | + if ( !isset($y) ) { |
|
| 1157 | + $y = "0%"; |
|
| 1158 | + } |
|
| 1127 | 1159 | |
| 1128 | 1160 | return array( 0 => $x, "x" => $x, |
| 1129 | 1161 | 1 => $y, "y" => $y ); |
@@ -1477,8 +1509,9 @@ discard block |
||
| 1477 | 1509 | function set_color($colour) { |
| 1478 | 1510 | $col = $this->munge_colour($colour); |
| 1479 | 1511 | |
| 1480 | - if ( is_null($col) ) |
|
| 1481 | - $col = self::$_defaults["color"]; |
|
| 1512 | + if ( is_null($col) ) { |
|
| 1513 | + $col = self::$_defaults["color"]; |
|
| 1514 | + } |
|
| 1482 | 1515 | |
| 1483 | 1516 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1484 | 1517 | $this->_prop_cache["color"] = null; |
@@ -1493,8 +1526,9 @@ discard block |
||
| 1493 | 1526 | */ |
| 1494 | 1527 | function set_background_color($colour) { |
| 1495 | 1528 | $col = $this->munge_colour($colour); |
| 1496 | - if ( is_null($col) ) |
|
| 1497 | - $col = self::$_defaults["background_color"]; |
|
| 1529 | + if ( is_null($col) ) { |
|
| 1530 | + $col = self::$_defaults["background_color"]; |
|
| 1531 | + } |
|
| 1498 | 1532 | |
| 1499 | 1533 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1500 | 1534 | $this->_prop_cache["background_color"] = null; |
@@ -1520,8 +1554,9 @@ discard block |
||
| 1520 | 1554 | * @param string $val |
| 1521 | 1555 | */ |
| 1522 | 1556 | function set_background_repeat($val) { |
| 1523 | - if ( is_null($val) ) |
|
| 1524 | - $val = self::$_defaults["background_repeat"]; |
|
| 1557 | + if ( is_null($val) ) { |
|
| 1558 | + $val = self::$_defaults["background_repeat"]; |
|
| 1559 | + } |
|
| 1525 | 1560 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1526 | 1561 | $this->_prop_cache["background_repeat"] = null; |
| 1527 | 1562 | $this->_props["background_repeat"] = $val; |
@@ -1534,8 +1569,9 @@ discard block |
||
| 1534 | 1569 | * @param string $val |
| 1535 | 1570 | */ |
| 1536 | 1571 | function set_background_attachment($val) { |
| 1537 | - if ( is_null($val) ) |
|
| 1538 | - $val = self::$_defaults["background_attachment"]; |
|
| 1572 | + if ( is_null($val) ) { |
|
| 1573 | + $val = self::$_defaults["background_attachment"]; |
|
| 1574 | + } |
|
| 1539 | 1575 | |
| 1540 | 1576 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1541 | 1577 | $this->_prop_cache["background_attachment"] = null; |
@@ -1549,8 +1585,9 @@ discard block |
||
| 1549 | 1585 | * @param string $val |
| 1550 | 1586 | */ |
| 1551 | 1587 | function set_background_position($val) { |
| 1552 | - if ( is_null($val) ) |
|
| 1553 | - $val = self::$_defaults["background_position"]; |
|
| 1588 | + if ( is_null($val) ) { |
|
| 1589 | + $val = self::$_defaults["background_position"]; |
|
| 1590 | + } |
|
| 1554 | 1591 | |
| 1555 | 1592 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1556 | 1593 | $this->_prop_cache["background_position"] = null; |
@@ -1688,8 +1725,9 @@ discard block |
||
| 1688 | 1725 | * @param string $break |
| 1689 | 1726 | */ |
| 1690 | 1727 | function set_page_break_before($break) { |
| 1691 | - if ($break === "left" || $break === "right") |
|
| 1692 | - $break = "always"; |
|
| 1728 | + if ($break === "left" || $break === "right") { |
|
| 1729 | + $break = "always"; |
|
| 1730 | + } |
|
| 1693 | 1731 | |
| 1694 | 1732 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1695 | 1733 | $this->_prop_cache["page_break_before"] = null; |
@@ -1697,8 +1735,9 @@ discard block |
||
| 1697 | 1735 | } |
| 1698 | 1736 | |
| 1699 | 1737 | function set_page_break_after($break) { |
| 1700 | - if ($break === "left" || $break === "right") |
|
| 1701 | - $break = "always"; |
|
| 1738 | + if ($break === "left" || $break === "right") { |
|
| 1739 | + $break = "always"; |
|
| 1740 | + } |
|
| 1702 | 1741 | |
| 1703 | 1742 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1704 | 1743 | $this->_prop_cache["page_break_after"] = null; |
@@ -1847,8 +1886,9 @@ discard block |
||
| 1847 | 1886 | |
| 1848 | 1887 | $arr = explode(" ", $val); |
| 1849 | 1888 | |
| 1850 | - if ( count($arr) == 1 ) |
|
| 1851 | - $arr[1] = $arr[0]; |
|
| 1889 | + if ( count($arr) == 1 ) { |
|
| 1890 | + $arr[1] = $arr[0]; |
|
| 1891 | + } |
|
| 1852 | 1892 | |
| 1853 | 1893 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1854 | 1894 | $this->_prop_cache["border_spacing"] = null; |
@@ -85,114 +85,114 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | class Style { |
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * Default font size, in points. |
|
| 90 | - * |
|
| 91 | - * @var float |
|
| 92 | - */ |
|
| 93 | - static $default_font_size = 12; |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * Default line height, as a fraction of the font size. |
|
| 97 | - * |
|
| 98 | - * @var float |
|
| 99 | - */ |
|
| 100 | - static $default_line_height = 1.2; |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * List of all inline types. Should really be a constant. |
|
| 104 | - * |
|
| 105 | - * @var array |
|
| 106 | - */ |
|
| 107 | - static $INLINE_TYPES = array("inline"); |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * List of all block types. Should really be a constant. |
|
| 111 | - * |
|
| 112 | - * @var array |
|
| 113 | - */ |
|
| 114 | - static $BLOCK_TYPES = array("block","inline-block", "table-cell", "list-item"); |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * List of all table types. Should really be a constant. |
|
| 118 | - * |
|
| 119 | - * @var array; |
|
| 120 | - */ |
|
| 121 | - static $TABLE_TYPES = array("table", "inline-table"); |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * List of valid border styles. Should also really be a constant. |
|
| 125 | - * |
|
| 126 | - * @var array |
|
| 127 | - */ |
|
| 128 | - static $BORDER_STYLES = array("none", "hidden", "dotted", "dashed", "solid", |
|
| 88 | + /** |
|
| 89 | + * Default font size, in points. |
|
| 90 | + * |
|
| 91 | + * @var float |
|
| 92 | + */ |
|
| 93 | + static $default_font_size = 12; |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Default line height, as a fraction of the font size. |
|
| 97 | + * |
|
| 98 | + * @var float |
|
| 99 | + */ |
|
| 100 | + static $default_line_height = 1.2; |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * List of all inline types. Should really be a constant. |
|
| 104 | + * |
|
| 105 | + * @var array |
|
| 106 | + */ |
|
| 107 | + static $INLINE_TYPES = array("inline"); |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * List of all block types. Should really be a constant. |
|
| 111 | + * |
|
| 112 | + * @var array |
|
| 113 | + */ |
|
| 114 | + static $BLOCK_TYPES = array("block","inline-block", "table-cell", "list-item"); |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * List of all table types. Should really be a constant. |
|
| 118 | + * |
|
| 119 | + * @var array; |
|
| 120 | + */ |
|
| 121 | + static $TABLE_TYPES = array("table", "inline-table"); |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * List of valid border styles. Should also really be a constant. |
|
| 125 | + * |
|
| 126 | + * @var array |
|
| 127 | + */ |
|
| 128 | + static $BORDER_STYLES = array("none", "hidden", "dotted", "dashed", "solid", |
|
| 129 | 129 | "double", "groove", "ridge", "inset", "outset"); |
| 130 | 130 | |
| 131 | - /** |
|
| 132 | - * Default style values. |
|
| 133 | - * |
|
| 134 | - * @link http://www.w3.org/TR/CSS21/propidx.html |
|
| 135 | - * |
|
| 136 | - * @var array |
|
| 137 | - */ |
|
| 138 | - static protected $_defaults = null; |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * List of inherited properties |
|
| 142 | - * |
|
| 143 | - * @link http://www.w3.org/TR/CSS21/propidx.html |
|
| 144 | - * |
|
| 145 | - * @var array |
|
| 146 | - */ |
|
| 147 | - static protected $_inherited = null; |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * The stylesheet this style belongs to |
|
| 151 | - * |
|
| 152 | - * @see Stylesheet |
|
| 153 | - * @var Stylesheet |
|
| 154 | - */ |
|
| 155 | - protected $_stylesheet; // stylesheet this style is attached to |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * Main array of all CSS properties & values |
|
| 159 | - * |
|
| 160 | - * @var array |
|
| 161 | - */ |
|
| 162 | - protected $_props; |
|
| 163 | - |
|
| 164 | - /* var instead of protected would allow access outside of class */ |
|
| 165 | - protected $_important_props; |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * Cached property values |
|
| 169 | - * |
|
| 170 | - * @var array |
|
| 171 | - */ |
|
| 172 | - protected $_prop_cache; |
|
| 131 | + /** |
|
| 132 | + * Default style values. |
|
| 133 | + * |
|
| 134 | + * @link http://www.w3.org/TR/CSS21/propidx.html |
|
| 135 | + * |
|
| 136 | + * @var array |
|
| 137 | + */ |
|
| 138 | + static protected $_defaults = null; |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * List of inherited properties |
|
| 142 | + * |
|
| 143 | + * @link http://www.w3.org/TR/CSS21/propidx.html |
|
| 144 | + * |
|
| 145 | + * @var array |
|
| 146 | + */ |
|
| 147 | + static protected $_inherited = null; |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * The stylesheet this style belongs to |
|
| 151 | + * |
|
| 152 | + * @see Stylesheet |
|
| 153 | + * @var Stylesheet |
|
| 154 | + */ |
|
| 155 | + protected $_stylesheet; // stylesheet this style is attached to |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * Main array of all CSS properties & values |
|
| 159 | + * |
|
| 160 | + * @var array |
|
| 161 | + */ |
|
| 162 | + protected $_props; |
|
| 163 | + |
|
| 164 | + /* var instead of protected would allow access outside of class */ |
|
| 165 | + protected $_important_props; |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * Cached property values |
|
| 169 | + * |
|
| 170 | + * @var array |
|
| 171 | + */ |
|
| 172 | + protected $_prop_cache; |
|
| 173 | 173 | |
| 174 | - /** |
|
| 175 | - * Font size of parent element in document tree. Used for relative font |
|
| 176 | - * size resolution. |
|
| 177 | - * |
|
| 178 | - * @var float |
|
| 179 | - */ |
|
| 180 | - protected $_parent_font_size; // Font size of parent element |
|
| 174 | + /** |
|
| 175 | + * Font size of parent element in document tree. Used for relative font |
|
| 176 | + * size resolution. |
|
| 177 | + * |
|
| 178 | + * @var float |
|
| 179 | + */ |
|
| 180 | + protected $_parent_font_size; // Font size of parent element |
|
| 181 | 181 | |
| 182 | - // private members |
|
| 183 | - /** |
|
| 184 | - * True once the font size is resolved absolutely |
|
| 185 | - * |
|
| 186 | - * @var bool |
|
| 187 | - */ |
|
| 188 | - private $__font_size_calculated; // Cache flag |
|
| 182 | + // private members |
|
| 183 | + /** |
|
| 184 | + * True once the font size is resolved absolutely |
|
| 185 | + * |
|
| 186 | + * @var bool |
|
| 187 | + */ |
|
| 188 | + private $__font_size_calculated; // Cache flag |
|
| 189 | 189 | |
| 190 | - /** |
|
| 191 | - * Class constructor |
|
| 192 | - * |
|
| 193 | - * @param Stylesheet $stylesheet the stylesheet this Style is associated with. |
|
| 194 | - */ |
|
| 195 | - function __construct(Stylesheet $stylesheet) { |
|
| 190 | + /** |
|
| 191 | + * Class constructor |
|
| 192 | + * |
|
| 193 | + * @param Stylesheet $stylesheet the stylesheet this Style is associated with. |
|
| 194 | + */ |
|
| 195 | + function __construct(Stylesheet $stylesheet) { |
|
| 196 | 196 | $this->_props = array(); |
| 197 | 197 | $this->_important_props = array(); |
| 198 | 198 | $this->_stylesheet = $stylesheet; |
@@ -201,330 +201,330 @@ discard block |
||
| 201 | 201 | |
| 202 | 202 | if ( !isset(self::$_defaults) ) { |
| 203 | 203 | |
| 204 | - // Shorthand |
|
| 205 | - $d =& self::$_defaults; |
|
| 204 | + // Shorthand |
|
| 205 | + $d =& self::$_defaults; |
|
| 206 | 206 | |
| 207 | - // All CSS 2.1 properties, and their default values |
|
| 208 | - $d["azimuth"] = "center"; |
|
| 209 | - $d["background_attachment"] = "scroll"; |
|
| 210 | - $d["background_color"] = "transparent"; |
|
| 211 | - $d["background_image"] = "none"; |
|
| 212 | - $d["background_position"] = "0% 0%"; |
|
| 213 | - $d["background_repeat"] = "repeat"; |
|
| 214 | - $d["background"] = ""; |
|
| 215 | - $d["border_collapse"] = "separate"; |
|
| 216 | - $d["border_color"] = ""; |
|
| 217 | - $d["border_spacing"] = "0"; |
|
| 218 | - $d["border_style"] = ""; |
|
| 219 | - $d["border_top"] = ""; |
|
| 220 | - $d["border_right"] = ""; |
|
| 221 | - $d["border_bottom"] = ""; |
|
| 222 | - $d["border_left"] = ""; |
|
| 223 | - $d["border_top_color"] = ""; |
|
| 224 | - $d["border_right_color"] = ""; |
|
| 225 | - $d["border_bottom_color"] = ""; |
|
| 226 | - $d["border_left_color"] = ""; |
|
| 227 | - $d["border_top_style"] = "none"; |
|
| 228 | - $d["border_right_style"] = "none"; |
|
| 229 | - $d["border_bottom_style"] = "none"; |
|
| 230 | - $d["border_left_style"] = "none"; |
|
| 231 | - $d["border_top_width"] = "medium"; |
|
| 232 | - $d["border_right_width"] = "medium"; |
|
| 233 | - $d["border_bottom_width"] = "medium"; |
|
| 234 | - $d["border_left_width"] = "medium"; |
|
| 235 | - $d["border_width"] = "medium"; |
|
| 236 | - $d["border"] = ""; |
|
| 237 | - $d["bottom"] = "auto"; |
|
| 238 | - $d["caption_side"] = "top"; |
|
| 239 | - $d["clear"] = "none"; |
|
| 240 | - $d["clip"] = "auto"; |
|
| 241 | - $d["color"] = "#000000"; |
|
| 242 | - $d["content"] = "normal"; |
|
| 243 | - $d["counter_increment"] = "none"; |
|
| 244 | - $d["counter_reset"] = "none"; |
|
| 245 | - $d["cue_after"] = "none"; |
|
| 246 | - $d["cue_before"] = "none"; |
|
| 247 | - $d["cue"] = ""; |
|
| 248 | - $d["cursor"] = "auto"; |
|
| 249 | - $d["direction"] = "ltr"; |
|
| 250 | - $d["display"] = "inline"; |
|
| 251 | - $d["elevation"] = "level"; |
|
| 252 | - $d["empty_cells"] = "show"; |
|
| 253 | - $d["float"] = "none"; |
|
| 254 | - $d["font_family"] = "serif"; |
|
| 255 | - $d["font_size"] = "medium"; |
|
| 256 | - $d["font_style"] = "normal"; |
|
| 257 | - $d["font_variant"] = "normal"; |
|
| 258 | - $d["font_weight"] = "normal"; |
|
| 259 | - $d["font"] = ""; |
|
| 260 | - $d["height"] = "auto"; |
|
| 261 | - $d["left"] = "auto"; |
|
| 262 | - $d["letter_spacing"] = "normal"; |
|
| 263 | - $d["line_height"] = "normal"; |
|
| 264 | - $d["list_style_image"] = "none"; |
|
| 265 | - $d["list_style_position"] = "outside"; |
|
| 266 | - $d["list_style_type"] = "disc"; |
|
| 267 | - $d["list_style"] = ""; |
|
| 268 | - $d["margin_right"] = "0"; |
|
| 269 | - $d["margin_left"] = "0"; |
|
| 270 | - $d["margin_top"] = "0"; |
|
| 271 | - $d["margin_bottom"] = "0"; |
|
| 272 | - $d["margin"] = ""; |
|
| 273 | - $d["max_height"] = "none"; |
|
| 274 | - $d["max_width"] = "none"; |
|
| 275 | - $d["min_height"] = "0"; |
|
| 276 | - $d["min_width"] = "0"; |
|
| 277 | - $d["orphans"] = "2"; |
|
| 278 | - $d["outline_color"] = "invert"; |
|
| 279 | - $d["outline_style"] = "none"; |
|
| 280 | - $d["outline_width"] = "medium"; |
|
| 281 | - $d["outline"] = ""; |
|
| 282 | - $d["overflow"] = "visible"; |
|
| 283 | - $d["padding_top"] = "0"; |
|
| 284 | - $d["padding_right"] = "0"; |
|
| 285 | - $d["padding_bottom"] = "0"; |
|
| 286 | - $d["padding_left"] = "0"; |
|
| 287 | - $d["padding"] = ""; |
|
| 288 | - $d["page_break_after"] = "auto"; |
|
| 289 | - $d["page_break_before"] = "auto"; |
|
| 290 | - $d["page_break_inside"] = "auto"; |
|
| 291 | - $d["pause_after"] = "0"; |
|
| 292 | - $d["pause_before"] = "0"; |
|
| 293 | - $d["pause"] = ""; |
|
| 294 | - $d["pitch_range"] = "50"; |
|
| 295 | - $d["pitch"] = "medium"; |
|
| 296 | - $d["play_during"] = "auto"; |
|
| 297 | - $d["position"] = "static"; |
|
| 298 | - $d["quotes"] = ""; |
|
| 299 | - $d["richness"] = "50"; |
|
| 300 | - $d["right"] = "auto"; |
|
| 301 | - $d["speak_header"] = "once"; |
|
| 302 | - $d["speak_numeral"] = "continuous"; |
|
| 303 | - $d["speak_punctuation"] = "none"; |
|
| 304 | - $d["speak"] = "normal"; |
|
| 305 | - $d["speech_rate"] = "medium"; |
|
| 306 | - $d["stress"] = "50"; |
|
| 307 | - $d["table_layout"] = "auto"; |
|
| 308 | - $d["text_align"] = "left"; |
|
| 309 | - $d["text_decoration"] = "none"; |
|
| 310 | - $d["text_indent"] = "0"; |
|
| 311 | - $d["text_transform"] = "none"; |
|
| 312 | - $d["top"] = "auto"; |
|
| 313 | - $d["unicode_bidi"] = "normal"; |
|
| 314 | - $d["vertical_align"] = "baseline"; |
|
| 315 | - $d["visibility"] = "visible"; |
|
| 316 | - $d["voice_family"] = ""; |
|
| 317 | - $d["volume"] = "medium"; |
|
| 318 | - $d["white_space"] = "normal"; |
|
| 319 | - $d["widows"] = "2"; |
|
| 320 | - $d["width"] = "auto"; |
|
| 321 | - $d["word_spacing"] = "normal"; |
|
| 322 | - $d["z_index"] = "auto"; |
|
| 323 | - |
|
| 324 | - // Properties that inherit by default |
|
| 325 | - self::$_inherited = array("azimuth", |
|
| 326 | - "border_collapse", |
|
| 327 | - "border_spacing", |
|
| 328 | - "caption_side", |
|
| 329 | - "color", |
|
| 330 | - "cursor", |
|
| 331 | - "direction", |
|
| 332 | - "elevation", |
|
| 333 | - "empty_cells", |
|
| 334 | - "font_family", |
|
| 335 | - "font_size", |
|
| 336 | - "font_style", |
|
| 337 | - "font_variant", |
|
| 338 | - "font_weight", |
|
| 339 | - "font", |
|
| 340 | - "letter_spacing", |
|
| 341 | - "line_height", |
|
| 342 | - "list_style_image", |
|
| 343 | - "list_style_position", |
|
| 344 | - "list_style_type", |
|
| 345 | - "list_style", |
|
| 346 | - "orphans", |
|
| 347 | - "page_break_inside", |
|
| 348 | - "pitch_range", |
|
| 349 | - "pitch", |
|
| 350 | - "quotes", |
|
| 351 | - "richness", |
|
| 352 | - "speak_header", |
|
| 353 | - "speak_numeral", |
|
| 354 | - "speak_punctuation", |
|
| 355 | - "speak", |
|
| 356 | - "speech_rate", |
|
| 357 | - "stress", |
|
| 358 | - "text_align", |
|
| 359 | - "text_indent", |
|
| 360 | - "text_transform", |
|
| 361 | - "visibility", |
|
| 362 | - "voice_family", |
|
| 363 | - "volume", |
|
| 364 | - "white_space", |
|
| 365 | - "widows", |
|
| 366 | - "word_spacing"); |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - /** |
|
| 372 | - * "Destructor": forcibly free all references held by this object |
|
| 373 | - */ |
|
| 374 | - function dispose() { |
|
| 207 | + // All CSS 2.1 properties, and their default values |
|
| 208 | + $d["azimuth"] = "center"; |
|
| 209 | + $d["background_attachment"] = "scroll"; |
|
| 210 | + $d["background_color"] = "transparent"; |
|
| 211 | + $d["background_image"] = "none"; |
|
| 212 | + $d["background_position"] = "0% 0%"; |
|
| 213 | + $d["background_repeat"] = "repeat"; |
|
| 214 | + $d["background"] = ""; |
|
| 215 | + $d["border_collapse"] = "separate"; |
|
| 216 | + $d["border_color"] = ""; |
|
| 217 | + $d["border_spacing"] = "0"; |
|
| 218 | + $d["border_style"] = ""; |
|
| 219 | + $d["border_top"] = ""; |
|
| 220 | + $d["border_right"] = ""; |
|
| 221 | + $d["border_bottom"] = ""; |
|
| 222 | + $d["border_left"] = ""; |
|
| 223 | + $d["border_top_color"] = ""; |
|
| 224 | + $d["border_right_color"] = ""; |
|
| 225 | + $d["border_bottom_color"] = ""; |
|
| 226 | + $d["border_left_color"] = ""; |
|
| 227 | + $d["border_top_style"] = "none"; |
|
| 228 | + $d["border_right_style"] = "none"; |
|
| 229 | + $d["border_bottom_style"] = "none"; |
|
| 230 | + $d["border_left_style"] = "none"; |
|
| 231 | + $d["border_top_width"] = "medium"; |
|
| 232 | + $d["border_right_width"] = "medium"; |
|
| 233 | + $d["border_bottom_width"] = "medium"; |
|
| 234 | + $d["border_left_width"] = "medium"; |
|
| 235 | + $d["border_width"] = "medium"; |
|
| 236 | + $d["border"] = ""; |
|
| 237 | + $d["bottom"] = "auto"; |
|
| 238 | + $d["caption_side"] = "top"; |
|
| 239 | + $d["clear"] = "none"; |
|
| 240 | + $d["clip"] = "auto"; |
|
| 241 | + $d["color"] = "#000000"; |
|
| 242 | + $d["content"] = "normal"; |
|
| 243 | + $d["counter_increment"] = "none"; |
|
| 244 | + $d["counter_reset"] = "none"; |
|
| 245 | + $d["cue_after"] = "none"; |
|
| 246 | + $d["cue_before"] = "none"; |
|
| 247 | + $d["cue"] = ""; |
|
| 248 | + $d["cursor"] = "auto"; |
|
| 249 | + $d["direction"] = "ltr"; |
|
| 250 | + $d["display"] = "inline"; |
|
| 251 | + $d["elevation"] = "level"; |
|
| 252 | + $d["empty_cells"] = "show"; |
|
| 253 | + $d["float"] = "none"; |
|
| 254 | + $d["font_family"] = "serif"; |
|
| 255 | + $d["font_size"] = "medium"; |
|
| 256 | + $d["font_style"] = "normal"; |
|
| 257 | + $d["font_variant"] = "normal"; |
|
| 258 | + $d["font_weight"] = "normal"; |
|
| 259 | + $d["font"] = ""; |
|
| 260 | + $d["height"] = "auto"; |
|
| 261 | + $d["left"] = "auto"; |
|
| 262 | + $d["letter_spacing"] = "normal"; |
|
| 263 | + $d["line_height"] = "normal"; |
|
| 264 | + $d["list_style_image"] = "none"; |
|
| 265 | + $d["list_style_position"] = "outside"; |
|
| 266 | + $d["list_style_type"] = "disc"; |
|
| 267 | + $d["list_style"] = ""; |
|
| 268 | + $d["margin_right"] = "0"; |
|
| 269 | + $d["margin_left"] = "0"; |
|
| 270 | + $d["margin_top"] = "0"; |
|
| 271 | + $d["margin_bottom"] = "0"; |
|
| 272 | + $d["margin"] = ""; |
|
| 273 | + $d["max_height"] = "none"; |
|
| 274 | + $d["max_width"] = "none"; |
|
| 275 | + $d["min_height"] = "0"; |
|
| 276 | + $d["min_width"] = "0"; |
|
| 277 | + $d["orphans"] = "2"; |
|
| 278 | + $d["outline_color"] = "invert"; |
|
| 279 | + $d["outline_style"] = "none"; |
|
| 280 | + $d["outline_width"] = "medium"; |
|
| 281 | + $d["outline"] = ""; |
|
| 282 | + $d["overflow"] = "visible"; |
|
| 283 | + $d["padding_top"] = "0"; |
|
| 284 | + $d["padding_right"] = "0"; |
|
| 285 | + $d["padding_bottom"] = "0"; |
|
| 286 | + $d["padding_left"] = "0"; |
|
| 287 | + $d["padding"] = ""; |
|
| 288 | + $d["page_break_after"] = "auto"; |
|
| 289 | + $d["page_break_before"] = "auto"; |
|
| 290 | + $d["page_break_inside"] = "auto"; |
|
| 291 | + $d["pause_after"] = "0"; |
|
| 292 | + $d["pause_before"] = "0"; |
|
| 293 | + $d["pause"] = ""; |
|
| 294 | + $d["pitch_range"] = "50"; |
|
| 295 | + $d["pitch"] = "medium"; |
|
| 296 | + $d["play_during"] = "auto"; |
|
| 297 | + $d["position"] = "static"; |
|
| 298 | + $d["quotes"] = ""; |
|
| 299 | + $d["richness"] = "50"; |
|
| 300 | + $d["right"] = "auto"; |
|
| 301 | + $d["speak_header"] = "once"; |
|
| 302 | + $d["speak_numeral"] = "continuous"; |
|
| 303 | + $d["speak_punctuation"] = "none"; |
|
| 304 | + $d["speak"] = "normal"; |
|
| 305 | + $d["speech_rate"] = "medium"; |
|
| 306 | + $d["stress"] = "50"; |
|
| 307 | + $d["table_layout"] = "auto"; |
|
| 308 | + $d["text_align"] = "left"; |
|
| 309 | + $d["text_decoration"] = "none"; |
|
| 310 | + $d["text_indent"] = "0"; |
|
| 311 | + $d["text_transform"] = "none"; |
|
| 312 | + $d["top"] = "auto"; |
|
| 313 | + $d["unicode_bidi"] = "normal"; |
|
| 314 | + $d["vertical_align"] = "baseline"; |
|
| 315 | + $d["visibility"] = "visible"; |
|
| 316 | + $d["voice_family"] = ""; |
|
| 317 | + $d["volume"] = "medium"; |
|
| 318 | + $d["white_space"] = "normal"; |
|
| 319 | + $d["widows"] = "2"; |
|
| 320 | + $d["width"] = "auto"; |
|
| 321 | + $d["word_spacing"] = "normal"; |
|
| 322 | + $d["z_index"] = "auto"; |
|
| 323 | + |
|
| 324 | + // Properties that inherit by default |
|
| 325 | + self::$_inherited = array("azimuth", |
|
| 326 | + "border_collapse", |
|
| 327 | + "border_spacing", |
|
| 328 | + "caption_side", |
|
| 329 | + "color", |
|
| 330 | + "cursor", |
|
| 331 | + "direction", |
|
| 332 | + "elevation", |
|
| 333 | + "empty_cells", |
|
| 334 | + "font_family", |
|
| 335 | + "font_size", |
|
| 336 | + "font_style", |
|
| 337 | + "font_variant", |
|
| 338 | + "font_weight", |
|
| 339 | + "font", |
|
| 340 | + "letter_spacing", |
|
| 341 | + "line_height", |
|
| 342 | + "list_style_image", |
|
| 343 | + "list_style_position", |
|
| 344 | + "list_style_type", |
|
| 345 | + "list_style", |
|
| 346 | + "orphans", |
|
| 347 | + "page_break_inside", |
|
| 348 | + "pitch_range", |
|
| 349 | + "pitch", |
|
| 350 | + "quotes", |
|
| 351 | + "richness", |
|
| 352 | + "speak_header", |
|
| 353 | + "speak_numeral", |
|
| 354 | + "speak_punctuation", |
|
| 355 | + "speak", |
|
| 356 | + "speech_rate", |
|
| 357 | + "stress", |
|
| 358 | + "text_align", |
|
| 359 | + "text_indent", |
|
| 360 | + "text_transform", |
|
| 361 | + "visibility", |
|
| 362 | + "voice_family", |
|
| 363 | + "volume", |
|
| 364 | + "white_space", |
|
| 365 | + "widows", |
|
| 366 | + "word_spacing"); |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + /** |
|
| 372 | + * "Destructor": forcibly free all references held by this object |
|
| 373 | + */ |
|
| 374 | + function dispose() { |
|
| 375 | 375 | unset($this->_stylesheet); |
| 376 | - } |
|
| 376 | + } |
|
| 377 | 377 | |
| 378 | - /** |
|
| 379 | - * returns the {@link Stylesheet} this Style is associated with. |
|
| 380 | - * |
|
| 381 | - * @return Stylesheet |
|
| 382 | - */ |
|
| 383 | - function get_stylesheet() { return $this->_stylesheet; } |
|
| 378 | + /** |
|
| 379 | + * returns the {@link Stylesheet} this Style is associated with. |
|
| 380 | + * |
|
| 381 | + * @return Stylesheet |
|
| 382 | + */ |
|
| 383 | + function get_stylesheet() { return $this->_stylesheet; } |
|
| 384 | 384 | |
| 385 | - /** |
|
| 386 | - * Converts any CSS length value into an absolute length in points. |
|
| 387 | - * |
|
| 388 | - * length_in_pt() takes a single length (e.g. '1em') or an array of |
|
| 389 | - * lengths and returns an absolute length. If an array is passed, then |
|
| 390 | - * the return value is the sum of all elements. |
|
| 391 | - * |
|
| 392 | - * If a reference size is not provided, the default font size is used |
|
| 393 | - * ({@link Style::$default_font_size}). |
|
| 394 | - * |
|
| 395 | - * @param float|array $length the length or array of lengths to resolve |
|
| 396 | - * @param float $ref_size an absolute reference size to resolve percentage lengths |
|
| 397 | - * @return float |
|
| 398 | - */ |
|
| 399 | - function length_in_pt($length, $ref_size = null) { |
|
| 385 | + /** |
|
| 386 | + * Converts any CSS length value into an absolute length in points. |
|
| 387 | + * |
|
| 388 | + * length_in_pt() takes a single length (e.g. '1em') or an array of |
|
| 389 | + * lengths and returns an absolute length. If an array is passed, then |
|
| 390 | + * the return value is the sum of all elements. |
|
| 391 | + * |
|
| 392 | + * If a reference size is not provided, the default font size is used |
|
| 393 | + * ({@link Style::$default_font_size}). |
|
| 394 | + * |
|
| 395 | + * @param float|array $length the length or array of lengths to resolve |
|
| 396 | + * @param float $ref_size an absolute reference size to resolve percentage lengths |
|
| 397 | + * @return float |
|
| 398 | + */ |
|
| 399 | + function length_in_pt($length, $ref_size = null) { |
|
| 400 | 400 | |
| 401 | 401 | if ( !is_array($length) ) |
| 402 | - $length = array($length); |
|
| 402 | + $length = array($length); |
|
| 403 | 403 | |
| 404 | 404 | if ( !isset($ref_size) ) |
| 405 | - $ref_size = self::$default_font_size; |
|
| 405 | + $ref_size = self::$default_font_size; |
|
| 406 | 406 | |
| 407 | 407 | $ret = 0; |
| 408 | 408 | foreach ($length as $l) { |
| 409 | 409 | |
| 410 | - if ( $l === "auto" ) |
|
| 410 | + if ( $l === "auto" ) |
|
| 411 | 411 | return "auto"; |
| 412 | 412 | |
| 413 | - if ( $l === "none" ) |
|
| 413 | + if ( $l === "none" ) |
|
| 414 | 414 | return "none"; |
| 415 | 415 | |
| 416 | - // Assume numeric values are already in points |
|
| 417 | - if ( is_numeric($l) ) { |
|
| 416 | + // Assume numeric values are already in points |
|
| 417 | + if ( is_numeric($l) ) { |
|
| 418 | 418 | $ret += $l; |
| 419 | 419 | continue; |
| 420 | - } |
|
| 420 | + } |
|
| 421 | 421 | |
| 422 | - if ( $l === "normal" ) { |
|
| 422 | + if ( $l === "normal" ) { |
|
| 423 | 423 | $ret += $ref_size; |
| 424 | 424 | continue; |
| 425 | - } |
|
| 425 | + } |
|
| 426 | 426 | |
| 427 | - // Border lengths |
|
| 428 | - if ( $l === "thin" ) { |
|
| 427 | + // Border lengths |
|
| 428 | + if ( $l === "thin" ) { |
|
| 429 | 429 | $ret += 0.5; |
| 430 | 430 | continue; |
| 431 | - } |
|
| 431 | + } |
|
| 432 | 432 | |
| 433 | - if ( $l === "medium" ) { |
|
| 433 | + if ( $l === "medium" ) { |
|
| 434 | 434 | $ret += 1.5; |
| 435 | 435 | continue; |
| 436 | - } |
|
| 436 | + } |
|
| 437 | 437 | |
| 438 | - if ( $l === "thick" ) { |
|
| 438 | + if ( $l === "thick" ) { |
|
| 439 | 439 | $ret += 2.5; |
| 440 | 440 | continue; |
| 441 | - } |
|
| 441 | + } |
|
| 442 | 442 | |
| 443 | - if ( ($i = mb_strpos($l, "pt")) !== false ) { |
|
| 443 | + if ( ($i = mb_strpos($l, "pt")) !== false ) { |
|
| 444 | 444 | $ret += mb_substr($l, 0, $i); |
| 445 | 445 | continue; |
| 446 | - } |
|
| 446 | + } |
|
| 447 | 447 | |
| 448 | - if ( ($i = mb_strpos($l, "px")) !== false ) { |
|
| 448 | + if ( ($i = mb_strpos($l, "px")) !== false ) { |
|
| 449 | 449 | $ret += ( mb_substr($l, 0, $i) * 72 ) / DOMPDF_DPI; |
| 450 | 450 | continue; |
| 451 | - } |
|
| 451 | + } |
|
| 452 | 452 | |
| 453 | - if ( ($i = mb_strpos($l, "em")) !== false ) { |
|
| 453 | + if ( ($i = mb_strpos($l, "em")) !== false ) { |
|
| 454 | 454 | $ret += mb_substr($l, 0, $i) * $this->__get("font_size"); |
| 455 | 455 | continue; |
| 456 | - } |
|
| 456 | + } |
|
| 457 | 457 | |
| 458 | - // FIXME: em:ex ratio? |
|
| 459 | - if ( ($i = mb_strpos($l, "ex")) !== false ) { |
|
| 458 | + // FIXME: em:ex ratio? |
|
| 459 | + if ( ($i = mb_strpos($l, "ex")) !== false ) { |
|
| 460 | 460 | $ret += mb_substr($l, 0, $i) * $this->__get("font_size"); |
| 461 | 461 | continue; |
| 462 | - } |
|
| 462 | + } |
|
| 463 | 463 | |
| 464 | - if ( ($i = mb_strpos($l, "%")) !== false ) { |
|
| 464 | + if ( ($i = mb_strpos($l, "%")) !== false ) { |
|
| 465 | 465 | $ret += mb_substr($l, 0, $i)/100 * $ref_size; |
| 466 | 466 | continue; |
| 467 | - } |
|
| 467 | + } |
|
| 468 | 468 | |
| 469 | - if ( ($i = mb_strpos($l, "in")) !== false ) { |
|
| 469 | + if ( ($i = mb_strpos($l, "in")) !== false ) { |
|
| 470 | 470 | $ret += mb_substr($l, 0, $i) * 72; |
| 471 | 471 | continue; |
| 472 | - } |
|
| 472 | + } |
|
| 473 | 473 | |
| 474 | - if ( ($i = mb_strpos($l, "cm")) !== false ) { |
|
| 474 | + if ( ($i = mb_strpos($l, "cm")) !== false ) { |
|
| 475 | 475 | $ret += mb_substr($l, 0, $i) * 72 / 2.54; |
| 476 | 476 | continue; |
| 477 | - } |
|
| 477 | + } |
|
| 478 | 478 | |
| 479 | - if ( ($i = mb_strpos($l, "mm")) !== false ) { |
|
| 479 | + if ( ($i = mb_strpos($l, "mm")) !== false ) { |
|
| 480 | 480 | $ret += mb_substr($l, 0, $i) * 72 / 25.4; |
| 481 | 481 | continue; |
| 482 | - } |
|
| 482 | + } |
|
| 483 | 483 | |
| 484 | - if ( ($i = mb_strpos($l, "pc")) !== false ) { |
|
| 484 | + if ( ($i = mb_strpos($l, "pc")) !== false ) { |
|
| 485 | 485 | $ret += mb_substr($l, 0, $i) / 12; |
| 486 | 486 | continue; |
| 487 | - } |
|
| 487 | + } |
|
| 488 | 488 | |
| 489 | - // Bogus value |
|
| 490 | - $ret += $ref_size; |
|
| 489 | + // Bogus value |
|
| 490 | + $ret += $ref_size; |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | return $ret; |
| 494 | - } |
|
| 494 | + } |
|
| 495 | 495 | |
| 496 | 496 | |
| 497 | - /** |
|
| 498 | - * Set inherited properties in this style using values in $parent |
|
| 499 | - * |
|
| 500 | - * @param Style $parent |
|
| 501 | - */ |
|
| 502 | - function inherit(Style $parent) { |
|
| 497 | + /** |
|
| 498 | + * Set inherited properties in this style using values in $parent |
|
| 499 | + * |
|
| 500 | + * @param Style $parent |
|
| 501 | + */ |
|
| 502 | + function inherit(Style $parent) { |
|
| 503 | 503 | |
| 504 | 504 | // Set parent font size |
| 505 | 505 | $this->_parent_font_size = $parent->get_font_size(); |
| 506 | 506 | |
| 507 | 507 | foreach (self::$_inherited as $prop) { |
| 508 | - //inherit the !important property also. |
|
| 509 | - //if local property is also !important, don't inherit. |
|
| 510 | - if ( isset($parent->_props[$prop]) && |
|
| 508 | + //inherit the !important property also. |
|
| 509 | + //if local property is also !important, don't inherit. |
|
| 510 | + if ( isset($parent->_props[$prop]) && |
|
| 511 | 511 | ( !isset($this->_props[$prop]) || |
| 512 | 512 | ( isset($parent->_important_props[$prop]) && !isset($this->_important_props[$prop]) ) |
| 513 | - ) |
|
| 514 | - ) { |
|
| 513 | + ) |
|
| 514 | + ) { |
|
| 515 | 515 | if ( isset($parent->_important_props[$prop]) ) { |
| 516 | - $this->_important_props[$prop] = true; |
|
| 516 | + $this->_important_props[$prop] = true; |
|
| 517 | 517 | } |
| 518 | 518 | //see __set and __get, on all assignments clear cache! |
| 519 | - $this->_prop_cache[$prop] = null; |
|
| 520 | - $this->_props[$prop] = $parent->_props[$prop]; |
|
| 521 | - } |
|
| 519 | + $this->_prop_cache[$prop] = null; |
|
| 520 | + $this->_props[$prop] = $parent->_props[$prop]; |
|
| 521 | + } |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | foreach (array_keys($this->_props) as $prop) { |
| 525 | - if ( $this->_props[$prop] === "inherit" ) { |
|
| 525 | + if ( $this->_props[$prop] === "inherit" ) { |
|
| 526 | 526 | if ( isset($parent->_important_props[$prop]) ) { |
| 527 | - $this->_important_props[$prop] = true; |
|
| 527 | + $this->_important_props[$prop] = true; |
|
| 528 | 528 | } |
| 529 | 529 | //do not assign direct, but |
| 530 | 530 | //implicite assignment through __set, redirect to specialized, get value with __get |
@@ -532,58 +532,58 @@ discard block |
||
| 532 | 532 | //Therefore do not directly assign the value without __set |
| 533 | 533 | //set _important_props before that to be able to propagate. |
| 534 | 534 | //see __set and __get, on all assignments clear cache! |
| 535 | - //$this->_prop_cache[$prop] = null; |
|
| 536 | - //$this->_props[$prop] = $parent->_props[$prop]; |
|
| 535 | + //$this->_prop_cache[$prop] = null; |
|
| 536 | + //$this->_props[$prop] = $parent->_props[$prop]; |
|
| 537 | 537 | //props_set for more obvious explicite assignment not implemented, because |
| 538 | 538 | //too many implicite uses. |
| 539 | 539 | // $this->props_set($prop, $parent->$prop); |
| 540 | 540 | $this->$prop = $parent->$prop; |
| 541 | - } |
|
| 541 | + } |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | return $this; |
| 545 | - } |
|
| 545 | + } |
|
| 546 | 546 | |
| 547 | 547 | |
| 548 | - /** |
|
| 549 | - * Override properties in this style with those in $style |
|
| 550 | - * |
|
| 551 | - * @param Style $style |
|
| 552 | - */ |
|
| 553 | - function merge(Style $style) { |
|
| 548 | + /** |
|
| 549 | + * Override properties in this style with those in $style |
|
| 550 | + * |
|
| 551 | + * @param Style $style |
|
| 552 | + */ |
|
| 553 | + function merge(Style $style) { |
|
| 554 | 554 | //treat the !important attribute |
| 555 | 555 | //if old rule has !important attribute, override with new rule only if |
| 556 | 556 | //the new rule is also !important |
| 557 | 557 | foreach($style->_props as $prop => $val ) { |
| 558 | - if (isset($style->_important_props[$prop])) { |
|
| 559 | - $this->_important_props[$prop] = true; |
|
| 558 | + if (isset($style->_important_props[$prop])) { |
|
| 559 | + $this->_important_props[$prop] = true; |
|
| 560 | 560 | //see __set and __get, on all assignments clear cache! |
| 561 | - $this->_prop_cache[$prop] = null; |
|
| 562 | - $this->_props[$prop] = $val; |
|
| 563 | - } else if ( !isset($this->_important_props[$prop]) ) { |
|
| 561 | + $this->_prop_cache[$prop] = null; |
|
| 562 | + $this->_props[$prop] = $val; |
|
| 563 | + } else if ( !isset($this->_important_props[$prop]) ) { |
|
| 564 | 564 | //see __set and __get, on all assignments clear cache! |
| 565 | - $this->_prop_cache[$prop] = null; |
|
| 566 | - $this->_props[$prop] = $val; |
|
| 567 | - } |
|
| 568 | - } |
|
| 565 | + $this->_prop_cache[$prop] = null; |
|
| 566 | + $this->_props[$prop] = $val; |
|
| 567 | + } |
|
| 568 | + } |
|
| 569 | 569 | |
| 570 | 570 | if ( isset($style->_props["font_size"]) ) |
| 571 | - $this->__font_size_calculated = false; |
|
| 572 | - } |
|
| 571 | + $this->__font_size_calculated = false; |
|
| 572 | + } |
|
| 573 | 573 | |
| 574 | 574 | |
| 575 | - /** |
|
| 576 | - * Returns an array(r, g, b, "r"=> r, "g"=>g, "b"=>b, "hex"=>"#rrggbb") |
|
| 577 | - * based on the provided CSS colour value. |
|
| 578 | - * |
|
| 579 | - * @param string $colour |
|
| 580 | - * @return array |
|
| 581 | - */ |
|
| 582 | - function munge_colour($colour) { |
|
| 575 | + /** |
|
| 576 | + * Returns an array(r, g, b, "r"=> r, "g"=>g, "b"=>b, "hex"=>"#rrggbb") |
|
| 577 | + * based on the provided CSS colour value. |
|
| 578 | + * |
|
| 579 | + * @param string $colour |
|
| 580 | + * @return array |
|
| 581 | + */ |
|
| 582 | + function munge_colour($colour) { |
|
| 583 | 583 | if ( is_array($colour) ) |
| 584 | - // Assume the array has the right format... |
|
| 585 | - // FIXME: should/could verify this. |
|
| 586 | - return $colour; |
|
| 584 | + // Assume the array has the right format... |
|
| 585 | + // FIXME: should/could verify this. |
|
| 586 | + return $colour; |
|
| 587 | 587 | |
| 588 | 588 | $r = 0; |
| 589 | 589 | $g = 0; |
@@ -594,78 +594,78 @@ discard block |
||
| 594 | 594 | |
| 595 | 595 | case "maroon": |
| 596 | 596 | $r = 0x80; |
| 597 | - break; |
|
| 597 | + break; |
|
| 598 | 598 | |
| 599 | 599 | case "red": |
| 600 | 600 | $r = 0xff; |
| 601 | - break; |
|
| 601 | + break; |
|
| 602 | 602 | |
| 603 | 603 | case "orange": |
| 604 | 604 | $r = 0xff; |
| 605 | - $g = 0xa5; |
|
| 606 | - break; |
|
| 605 | + $g = 0xa5; |
|
| 606 | + break; |
|
| 607 | 607 | |
| 608 | 608 | case "yellow": |
| 609 | 609 | $r = 0xff; |
| 610 | - $g = 0xff; |
|
| 611 | - break; |
|
| 610 | + $g = 0xff; |
|
| 611 | + break; |
|
| 612 | 612 | |
| 613 | 613 | case "olive": |
| 614 | 614 | $r = 0x80; |
| 615 | - $g = 0x80; |
|
| 616 | - break; |
|
| 615 | + $g = 0x80; |
|
| 616 | + break; |
|
| 617 | 617 | |
| 618 | 618 | case "purple": |
| 619 | 619 | $r = 0x80; |
| 620 | - $b = 0x80; |
|
| 621 | - break; |
|
| 620 | + $b = 0x80; |
|
| 621 | + break; |
|
| 622 | 622 | |
| 623 | 623 | case "fuchsia": |
| 624 | 624 | $r = 0xff; |
| 625 | - $b = 0xff; |
|
| 626 | - break; |
|
| 625 | + $b = 0xff; |
|
| 626 | + break; |
|
| 627 | 627 | |
| 628 | 628 | case "white": |
| 629 | 629 | $r = $g = $b = 0xff; |
| 630 | - break; |
|
| 630 | + break; |
|
| 631 | 631 | |
| 632 | 632 | case "lime": |
| 633 | 633 | $g = 0xff; |
| 634 | - break; |
|
| 634 | + break; |
|
| 635 | 635 | |
| 636 | 636 | case "green": |
| 637 | 637 | $g = 0x80; |
| 638 | - break; |
|
| 638 | + break; |
|
| 639 | 639 | |
| 640 | 640 | case "navy": |
| 641 | 641 | $b = 0x80; |
| 642 | - break; |
|
| 642 | + break; |
|
| 643 | 643 | |
| 644 | 644 | case "blue": |
| 645 | 645 | $b = 0xff; |
| 646 | - break; |
|
| 646 | + break; |
|
| 647 | 647 | |
| 648 | 648 | case "aqua": |
| 649 | 649 | $g = 0xff; |
| 650 | - $b = 0xff; |
|
| 651 | - break; |
|
| 650 | + $b = 0xff; |
|
| 651 | + break; |
|
| 652 | 652 | |
| 653 | 653 | case "teal": |
| 654 | 654 | $g = 0x80; |
| 655 | - $b = 0x80; |
|
| 656 | - break; |
|
| 655 | + $b = 0x80; |
|
| 656 | + break; |
|
| 657 | 657 | |
| 658 | 658 | case "black": |
| 659 | 659 | break; |
| 660 | 660 | |
| 661 | 661 | case "sliver": |
| 662 | 662 | $r = $g = $b = 0xc0; |
| 663 | - break; |
|
| 663 | + break; |
|
| 664 | 664 | |
| 665 | 665 | case "gray": |
| 666 | 666 | case "grey": |
| 667 | 667 | $r = $g = $b = 0x80; |
| 668 | - break; |
|
| 668 | + break; |
|
| 669 | 669 | |
| 670 | 670 | case "transparent": |
| 671 | 671 | return "transparent"; |
@@ -677,177 +677,177 @@ discard block |
||
| 677 | 677 | $g = hexdec($colour[2] . $colour[2]); |
| 678 | 678 | $b = hexdec($colour[3] . $colour[3]); |
| 679 | 679 | |
| 680 | - } else if ( mb_strlen($colour) == 7 && $colour[0] === "#" ) { |
|
| 680 | + } else if ( mb_strlen($colour) == 7 && $colour[0] === "#" ) { |
|
| 681 | 681 | // #rrggbb format |
| 682 | 682 | $r = hexdec(mb_substr($colour, 1, 2)); |
| 683 | 683 | $g = hexdec(mb_substr($colour, 3, 2)); |
| 684 | 684 | $b = hexdec(mb_substr($colour, 5, 2)); |
| 685 | 685 | |
| 686 | - } else if ( mb_strpos($colour, "rgb") !== false ) { |
|
| 686 | + } else if ( mb_strpos($colour, "rgb") !== false ) { |
|
| 687 | 687 | // rgb( r,g,b ) format |
| 688 | 688 | $i = mb_strpos($colour, "("); |
| 689 | 689 | $j = mb_strpos($colour, ")"); |
| 690 | 690 | |
| 691 | 691 | // Bad colour value |
| 692 | 692 | if ($i === false || $j === false) |
| 693 | - return null; |
|
| 693 | + return null; |
|
| 694 | 694 | |
| 695 | 695 | $triplet = explode(",", mb_substr($colour, $i+1, $j-$i-1)); |
| 696 | 696 | |
| 697 | 697 | if (count($triplet) != 3) |
| 698 | - return null; |
|
| 698 | + return null; |
|
| 699 | 699 | |
| 700 | 700 | foreach (array_keys($triplet) as $c) { |
| 701 | - $triplet[$c] = trim($triplet[$c]); |
|
| 701 | + $triplet[$c] = trim($triplet[$c]); |
|
| 702 | 702 | |
| 703 | - if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%" ) |
|
| 703 | + if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%" ) |
|
| 704 | 704 | $triplet[$c] = round($triplet[$c] * 0.255); |
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | list($r, $g, $b) = $triplet; |
| 708 | 708 | |
| 709 | - } else { |
|
| 709 | + } else { |
|
| 710 | 710 | // Who knows? |
| 711 | 711 | return null; |
| 712 | - } |
|
| 712 | + } |
|
| 713 | 713 | |
| 714 | - // Clip to 0 - 1 |
|
| 715 | - $r = $r < 0 ? 0 : ($r > 255 ? 255 : $r); |
|
| 716 | - $g = $g < 0 ? 0 : ($g > 255 ? 255 : $g); |
|
| 717 | - $b = $b < 0 ? 0 : ($b > 255 ? 255 : $b); |
|
| 718 | - break; |
|
| 714 | + // Clip to 0 - 1 |
|
| 715 | + $r = $r < 0 ? 0 : ($r > 255 ? 255 : $r); |
|
| 716 | + $g = $g < 0 ? 0 : ($g > 255 ? 255 : $g); |
|
| 717 | + $b = $b < 0 ? 0 : ($b > 255 ? 255 : $b); |
|
| 718 | + break; |
|
| 719 | 719 | |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | // Form array |
| 723 | 723 | $arr = array(0 => $r / 0xff, 1 => $g / 0xff, 2 => $b / 0xff, |
| 724 | - "r"=>$r / 0xff, "g"=>$g / 0xff, "b"=>$b / 0xff, |
|
| 725 | - "hex" => sprintf("#%02X%02X%02X", $r, $g, $b)); |
|
| 724 | + "r"=>$r / 0xff, "g"=>$g / 0xff, "b"=>$b / 0xff, |
|
| 725 | + "hex" => sprintf("#%02X%02X%02X", $r, $g, $b)); |
|
| 726 | 726 | return $arr; |
| 727 | 727 | |
| 728 | - } |
|
| 728 | + } |
|
| 729 | 729 | |
| 730 | 730 | |
| 731 | - /** |
|
| 732 | - * Alias for {@link Style::munge_colour()} |
|
| 733 | - * |
|
| 734 | - * @param string $color |
|
| 735 | - * @return array |
|
| 736 | - */ |
|
| 737 | - function munge_color($color) { return CSS_Color::parse($color); } |
|
| 738 | - |
|
| 739 | - /* direct access to _important_props array from outside would work only when declared as |
|
| 731 | + /** |
|
| 732 | + * Alias for {@link Style::munge_colour()} |
|
| 733 | + * |
|
| 734 | + * @param string $color |
|
| 735 | + * @return array |
|
| 736 | + */ |
|
| 737 | + function munge_color($color) { return CSS_Color::parse($color); } |
|
| 738 | + |
|
| 739 | + /* direct access to _important_props array from outside would work only when declared as |
|
| 740 | 740 | * 'var $_important_props;' instead of 'protected $_important_props;' |
| 741 | 741 | * Don't call _set/__get on missing attribute. Therefore need a special access. |
| 742 | 742 | * Assume that __set will be also called when this is called, so do not check validity again. |
| 743 | 743 | * Only created, if !important exists -> always set true. |
| 744 | 744 | */ |
| 745 | - function important_set($prop) { |
|
| 746 | - $prop = str_replace("-", "_", $prop); |
|
| 747 | - $this->_important_props[$prop] = true; |
|
| 748 | - } |
|
| 745 | + function important_set($prop) { |
|
| 746 | + $prop = str_replace("-", "_", $prop); |
|
| 747 | + $this->_important_props[$prop] = true; |
|
| 748 | + } |
|
| 749 | 749 | |
| 750 | - function important_get($prop) { |
|
| 751 | - isset($this->_important_props[$prop]); |
|
| 752 | - } |
|
| 750 | + function important_get($prop) { |
|
| 751 | + isset($this->_important_props[$prop]); |
|
| 752 | + } |
|
| 753 | 753 | |
| 754 | - /** |
|
| 755 | - * PHP5 overloaded setter |
|
| 756 | - * |
|
| 757 | - * This function along with {@link Style::__get()} permit a user of the |
|
| 758 | - * Style class to access any (CSS) property using the following syntax: |
|
| 759 | - * <code> |
|
| 760 | - * Style->margin_top = "1em"; |
|
| 761 | - * echo (Style->margin_top); |
|
| 762 | - * </code> |
|
| 763 | - * |
|
| 764 | - * __set() automatically calls the provided set function, if one exists, |
|
| 765 | - * otherwise it sets the property directly. Typically, __set() is not |
|
| 766 | - * called directly from outside of this class. |
|
| 767 | - * |
|
| 768 | - * On each modification clear cache to return accurate setting. |
|
| 769 | - * Also affects direct settings not using __set |
|
| 770 | - * For easier finding all assignments, attempted to allowing only explicite assignment: |
|
| 771 | - * Very many uses, e.g. frame_reflower.cls.php -> for now leave as it is |
|
| 772 | - * function __set($prop, $val) { |
|
| 773 | - * throw new DOMPDF_Exception("Implicite replacement of assignment by __set. Not good."); |
|
| 774 | - * } |
|
| 775 | - * function props_set($prop, $val) { ... } |
|
| 776 | - * |
|
| 777 | - * @param string $prop the property to set |
|
| 778 | - * @param mixed $val the value of the property |
|
| 779 | - * |
|
| 780 | - */ |
|
| 781 | - function __set($prop, $val) { |
|
| 754 | + /** |
|
| 755 | + * PHP5 overloaded setter |
|
| 756 | + * |
|
| 757 | + * This function along with {@link Style::__get()} permit a user of the |
|
| 758 | + * Style class to access any (CSS) property using the following syntax: |
|
| 759 | + * <code> |
|
| 760 | + * Style->margin_top = "1em"; |
|
| 761 | + * echo (Style->margin_top); |
|
| 762 | + * </code> |
|
| 763 | + * |
|
| 764 | + * __set() automatically calls the provided set function, if one exists, |
|
| 765 | + * otherwise it sets the property directly. Typically, __set() is not |
|
| 766 | + * called directly from outside of this class. |
|
| 767 | + * |
|
| 768 | + * On each modification clear cache to return accurate setting. |
|
| 769 | + * Also affects direct settings not using __set |
|
| 770 | + * For easier finding all assignments, attempted to allowing only explicite assignment: |
|
| 771 | + * Very many uses, e.g. frame_reflower.cls.php -> for now leave as it is |
|
| 772 | + * function __set($prop, $val) { |
|
| 773 | + * throw new DOMPDF_Exception("Implicite replacement of assignment by __set. Not good."); |
|
| 774 | + * } |
|
| 775 | + * function props_set($prop, $val) { ... } |
|
| 776 | + * |
|
| 777 | + * @param string $prop the property to set |
|
| 778 | + * @param mixed $val the value of the property |
|
| 779 | + * |
|
| 780 | + */ |
|
| 781 | + function __set($prop, $val) { |
|
| 782 | 782 | global $_dompdf_warnings; |
| 783 | 783 | |
| 784 | 784 | $prop = str_replace("-", "_", $prop); |
| 785 | 785 | $this->_prop_cache[$prop] = null; |
| 786 | 786 | |
| 787 | 787 | if ( !isset(self::$_defaults[$prop]) ) { |
| 788 | - $_dompdf_warnings[] = "'$prop' is not a valid CSS2 property."; |
|
| 789 | - return; |
|
| 788 | + $_dompdf_warnings[] = "'$prop' is not a valid CSS2 property."; |
|
| 789 | + return; |
|
| 790 | 790 | } |
| 791 | 791 | |
| 792 | 792 | if ( $prop !== "content" && is_string($val) && mb_strpos($val, "url") === false ) { |
| 793 | - $val = mb_strtolower(trim(str_replace(array("\n", "\t"), array(" "), $val))); |
|
| 794 | - $val = preg_replace("/([0-9]+) (pt|px|pc|em|ex|in|cm|mm|%)/S", "\\1\\2", $val); |
|
| 793 | + $val = mb_strtolower(trim(str_replace(array("\n", "\t"), array(" "), $val))); |
|
| 794 | + $val = preg_replace("/([0-9]+) (pt|px|pc|em|ex|in|cm|mm|%)/S", "\\1\\2", $val); |
|
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | $method = "set_$prop"; |
| 798 | 798 | |
| 799 | 799 | if ( method_exists($this, $method) ) |
| 800 | - $this->$method($val); |
|
| 800 | + $this->$method($val); |
|
| 801 | 801 | else |
| 802 | - $this->_props[$prop] = $val; |
|
| 802 | + $this->_props[$prop] = $val; |
|
| 803 | 803 | |
| 804 | - } |
|
| 804 | + } |
|
| 805 | 805 | |
| 806 | - /** |
|
| 807 | - * PHP5 overloaded getter |
|
| 808 | - * |
|
| 809 | - * Along with {@link Style::__set()} __get() provides access to all CSS |
|
| 810 | - * properties directly. Typically __get() is not called directly outside |
|
| 811 | - * of this class. |
|
| 812 | - * |
|
| 813 | - * On each modification clear cache to return accurate setting. |
|
| 814 | - * Also affects direct settings not using __set |
|
| 815 | - * |
|
| 816 | - * @param string $prop |
|
| 817 | - * @return mixed |
|
| 818 | - */ |
|
| 819 | - function __get($prop) { |
|
| 806 | + /** |
|
| 807 | + * PHP5 overloaded getter |
|
| 808 | + * |
|
| 809 | + * Along with {@link Style::__set()} __get() provides access to all CSS |
|
| 810 | + * properties directly. Typically __get() is not called directly outside |
|
| 811 | + * of this class. |
|
| 812 | + * |
|
| 813 | + * On each modification clear cache to return accurate setting. |
|
| 814 | + * Also affects direct settings not using __set |
|
| 815 | + * |
|
| 816 | + * @param string $prop |
|
| 817 | + * @return mixed |
|
| 818 | + */ |
|
| 819 | + function __get($prop) { |
|
| 820 | 820 | |
| 821 | 821 | if ( !isset(self::$_defaults[$prop]) ) |
| 822 | - throw new DOMPDF_Exception("'$prop' is not a valid CSS2 property."); |
|
| 822 | + throw new DOMPDF_Exception("'$prop' is not a valid CSS2 property."); |
|
| 823 | 823 | |
| 824 | 824 | if ( isset($this->_prop_cache[$prop]) && $this->_prop_cache[$prop] != null) |
| 825 | - return $this->_prop_cache[$prop]; |
|
| 825 | + return $this->_prop_cache[$prop]; |
|
| 826 | 826 | |
| 827 | 827 | $method = "get_$prop"; |
| 828 | 828 | |
| 829 | 829 | // Fall back on defaults if property is not set |
| 830 | 830 | if ( !isset($this->_props[$prop]) ) |
| 831 | - $this->_props[$prop] = self::$_defaults[$prop]; |
|
| 831 | + $this->_props[$prop] = self::$_defaults[$prop]; |
|
| 832 | 832 | |
| 833 | 833 | if ( method_exists($this, $method) ) |
| 834 | - return $this->_prop_cache[$prop] = $this->$method(); |
|
| 834 | + return $this->_prop_cache[$prop] = $this->$method(); |
|
| 835 | 835 | |
| 836 | 836 | |
| 837 | 837 | return $this->_prop_cache[$prop] = $this->_props[$prop]; |
| 838 | - } |
|
| 838 | + } |
|
| 839 | 839 | |
| 840 | 840 | |
| 841 | - /** |
|
| 842 | - * Getter for the 'font-family' CSS property. |
|
| 843 | - * |
|
| 844 | - * Uses the {@link Font_Metrics} class to resolve the font family into an |
|
| 845 | - * actual font file. |
|
| 846 | - * |
|
| 847 | - * @link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-family |
|
| 848 | - * @return string |
|
| 849 | - */ |
|
| 850 | - function get_font_family() { |
|
| 841 | + /** |
|
| 842 | + * Getter for the 'font-family' CSS property. |
|
| 843 | + * |
|
| 844 | + * Uses the {@link Font_Metrics} class to resolve the font family into an |
|
| 845 | + * actual font file. |
|
| 846 | + * |
|
| 847 | + * @link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-family |
|
| 848 | + * @return string |
|
| 849 | + */ |
|
| 850 | + function get_font_family() { |
|
| 851 | 851 | |
| 852 | 852 | $DEBUGCSS=DEBUGCSS; //=DEBUGCSS; Allow override of global setting for ad hoc debug |
| 853 | 853 | |
@@ -859,16 +859,16 @@ discard block |
||
| 859 | 859 | |
| 860 | 860 | if ( is_numeric($weight) ) { |
| 861 | 861 | |
| 862 | - if ( $weight < 600 ) |
|
| 862 | + if ( $weight < 600 ) |
|
| 863 | 863 | $weight = "normal"; |
| 864 | - else |
|
| 864 | + else |
|
| 865 | 865 | $weight = "bold"; |
| 866 | 866 | |
| 867 | 867 | } else if ( $weight === "bold" || $weight === "bolder" ) { |
| 868 | - $weight = "bold"; |
|
| 868 | + $weight = "bold"; |
|
| 869 | 869 | |
| 870 | 870 | } else { |
| 871 | - $weight = "normal"; |
|
| 871 | + $weight = "normal"; |
|
| 872 | 872 | |
| 873 | 873 | } |
| 874 | 874 | |
@@ -876,18 +876,18 @@ discard block |
||
| 876 | 876 | $font_style = $this->__get("font_style"); |
| 877 | 877 | |
| 878 | 878 | if ( $weight === "bold" && ($font_style === "italic" || $font_style === "oblique") ) |
| 879 | - $subtype = "bold_italic"; |
|
| 879 | + $subtype = "bold_italic"; |
|
| 880 | 880 | else if ( $weight === "bold" && $font_style !== "italic" && $font_style !== "oblique" ) |
| 881 | - $subtype = "bold"; |
|
| 881 | + $subtype = "bold"; |
|
| 882 | 882 | else if ( $weight !== "bold" && ($font_style === "italic" || $font_style === "oblique") ) |
| 883 | - $subtype = "italic"; |
|
| 883 | + $subtype = "italic"; |
|
| 884 | 884 | else |
| 885 | - $subtype = "normal"; |
|
| 885 | + $subtype = "normal"; |
|
| 886 | 886 | |
| 887 | 887 | // Resolve the font family |
| 888 | 888 | if ($DEBUGCSS) { |
| 889 | - print "<pre>[get_font_family:"; |
|
| 890 | - print '('.$this->_props["font_family"].'.'.$font_style.'.'.$this->__get("font_weight").'.'.$weight.'.'.$subtype.')'; |
|
| 889 | + print "<pre>[get_font_family:"; |
|
| 890 | + print '('.$this->_props["font_family"].'.'.$font_style.'.'.$this->__get("font_weight").'.'.$weight.'.'.$subtype.')'; |
|
| 891 | 891 | } |
| 892 | 892 | $families = explode(",", $this->_props["font_family"]); |
| 893 | 893 | $families = array_map('trim',$families); |
@@ -895,17 +895,17 @@ discard block |
||
| 895 | 895 | |
| 896 | 896 | $font = null; |
| 897 | 897 | while ( current($families) ) { |
| 898 | - list(,$family) = each($families); |
|
| 899 | - //remove leading and trailing string delimiters, e.g. on font names with spaces; |
|
| 900 | - //remove leading and trailing whitespace |
|
| 901 | - $family=trim($family," \t\n\r\x0B\"'"); |
|
| 902 | - if ($DEBUGCSS) print '('.$family.')'; |
|
| 903 | - $font = Font_Metrics::get_font($family, $subtype); |
|
| 904 | - |
|
| 905 | - if ( $font ) { |
|
| 898 | + list(,$family) = each($families); |
|
| 899 | + //remove leading and trailing string delimiters, e.g. on font names with spaces; |
|
| 900 | + //remove leading and trailing whitespace |
|
| 901 | + $family=trim($family," \t\n\r\x0B\"'"); |
|
| 902 | + if ($DEBUGCSS) print '('.$family.')'; |
|
| 903 | + $font = Font_Metrics::get_font($family, $subtype); |
|
| 904 | + |
|
| 905 | + if ( $font ) { |
|
| 906 | 906 | if ($DEBUGCSS) print '('.$font.")get_font_family]\n</pre>"; |
| 907 | 907 | return $font; |
| 908 | - } |
|
| 908 | + } |
|
| 909 | 909 | } |
| 910 | 910 | |
| 911 | 911 | $family = null; |
@@ -913,63 +913,63 @@ discard block |
||
| 913 | 913 | $font = Font_Metrics::get_font($family, $subtype); |
| 914 | 914 | |
| 915 | 915 | if ( $font ) { |
| 916 | - if ($DEBUGCSS) print '('.$font.")get_font_family]\n</pre>"; |
|
| 917 | - return $font; |
|
| 916 | + if ($DEBUGCSS) print '('.$font.")get_font_family]\n</pre>"; |
|
| 917 | + return $font; |
|
| 918 | 918 | } |
| 919 | 919 | throw new DOMPDF_Exception("Unable to find a suitable font replacement for: '" . $this->_props["font_family"] ."'"); |
| 920 | 920 | |
| 921 | - } |
|
| 921 | + } |
|
| 922 | 922 | |
| 923 | - /** |
|
| 924 | - * Returns the resolved font size, in points |
|
| 925 | - * |
|
| 926 | - * @link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-size |
|
| 927 | - * @return float |
|
| 928 | - */ |
|
| 929 | - function get_font_size() { |
|
| 923 | + /** |
|
| 924 | + * Returns the resolved font size, in points |
|
| 925 | + * |
|
| 926 | + * @link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-size |
|
| 927 | + * @return float |
|
| 928 | + */ |
|
| 929 | + function get_font_size() { |
|
| 930 | 930 | |
| 931 | 931 | if ( $this->__font_size_calculated ) |
| 932 | - return $this->_props["font_size"]; |
|
| 932 | + return $this->_props["font_size"]; |
|
| 933 | 933 | |
| 934 | 934 | if ( !isset($this->_props["font_size"]) ) |
| 935 | - $fs = self::$_defaults["font_size"]; |
|
| 935 | + $fs = self::$_defaults["font_size"]; |
|
| 936 | 936 | else |
| 937 | - $fs = $this->_props["font_size"]; |
|
| 937 | + $fs = $this->_props["font_size"]; |
|
| 938 | 938 | |
| 939 | 939 | if ( !isset($this->_parent_font_size) ) |
| 940 | - $this->_parent_font_size = self::$default_font_size; |
|
| 940 | + $this->_parent_font_size = self::$default_font_size; |
|
| 941 | 941 | |
| 942 | 942 | switch ($fs) { |
| 943 | 943 | |
| 944 | 944 | case "xx-small": |
| 945 | 945 | $fs = 3/5 * $this->_parent_font_size; |
| 946 | - break; |
|
| 946 | + break; |
|
| 947 | 947 | |
| 948 | 948 | case "x-small": |
| 949 | 949 | $fs = 3/4 * $this->_parent_font_size; |
| 950 | - break; |
|
| 950 | + break; |
|
| 951 | 951 | |
| 952 | 952 | case "smaller": |
| 953 | 953 | case "small": |
| 954 | 954 | $fs = 8/9 * $this->_parent_font_size; |
| 955 | - break; |
|
| 955 | + break; |
|
| 956 | 956 | |
| 957 | 957 | case "medium": |
| 958 | 958 | $fs = $this->_parent_font_size; |
| 959 | - break; |
|
| 959 | + break; |
|
| 960 | 960 | |
| 961 | 961 | case "larger": |
| 962 | 962 | case "large": |
| 963 | 963 | $fs = 6/5 * $this->_parent_font_size; |
| 964 | - break; |
|
| 964 | + break; |
|
| 965 | 965 | |
| 966 | 966 | case "x-large": |
| 967 | 967 | $fs = 3/2 * $this->_parent_font_size; |
| 968 | - break; |
|
| 968 | + break; |
|
| 969 | 969 | |
| 970 | 970 | case "xx-large": |
| 971 | 971 | $fs = 2/1 * $this->_parent_font_size; |
| 972 | - break; |
|
| 972 | + break; |
|
| 973 | 973 | |
| 974 | 974 | default: |
| 975 | 975 | break; |
@@ -977,82 +977,82 @@ discard block |
||
| 977 | 977 | |
| 978 | 978 | // Ensure relative sizes resolve to something |
| 979 | 979 | if ( ($i = mb_strpos($fs, "em")) !== false ) |
| 980 | - $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size; |
|
| 980 | + $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size; |
|
| 981 | 981 | |
| 982 | 982 | else if ( ($i = mb_strpos($fs, "ex")) !== false ) |
| 983 | - $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size; |
|
| 983 | + $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size; |
|
| 984 | 984 | |
| 985 | 985 | else |
| 986 | - $fs = $this->length_in_pt($fs); |
|
| 986 | + $fs = $this->length_in_pt($fs); |
|
| 987 | 987 | |
| 988 | 988 | //see __set and __get, on all assignments clear cache! |
| 989 | - $this->_prop_cache["font_size"] = null; |
|
| 989 | + $this->_prop_cache["font_size"] = null; |
|
| 990 | 990 | $this->_props["font_size"] = $fs; |
| 991 | 991 | $this->__font_size_calculated = true; |
| 992 | 992 | return $this->_props["font_size"]; |
| 993 | 993 | |
| 994 | - } |
|
| 994 | + } |
|
| 995 | 995 | |
| 996 | - /** |
|
| 997 | - * @link http://www.w3.org/TR/CSS21/text.html#propdef-word-spacing |
|
| 998 | - * @return float |
|
| 999 | - */ |
|
| 1000 | - function get_word_spacing() { |
|
| 996 | + /** |
|
| 997 | + * @link http://www.w3.org/TR/CSS21/text.html#propdef-word-spacing |
|
| 998 | + * @return float |
|
| 999 | + */ |
|
| 1000 | + function get_word_spacing() { |
|
| 1001 | 1001 | if ( $this->_props["word_spacing"] === "normal" ) |
| 1002 | - return 0; |
|
| 1002 | + return 0; |
|
| 1003 | 1003 | |
| 1004 | 1004 | return $this->_props["word_spacing"]; |
| 1005 | - } |
|
| 1005 | + } |
|
| 1006 | 1006 | |
| 1007 | - /** |
|
| 1008 | - * @link http://www.w3.org/TR/CSS21/visudet.html#propdef-line-height |
|
| 1009 | - * @return float |
|
| 1010 | - */ |
|
| 1011 | - function get_line_height() { |
|
| 1007 | + /** |
|
| 1008 | + * @link http://www.w3.org/TR/CSS21/visudet.html#propdef-line-height |
|
| 1009 | + * @return float |
|
| 1010 | + */ |
|
| 1011 | + function get_line_height() { |
|
| 1012 | 1012 | if ( $this->_props["line_height"] === "normal" ) |
| 1013 | - return self::$default_line_height * $this->get_font_size(); |
|
| 1013 | + return self::$default_line_height * $this->get_font_size(); |
|
| 1014 | 1014 | |
| 1015 | 1015 | if ( is_numeric($this->_props["line_height"]) ) |
| 1016 | - return $this->length_in_pt( $this->_props["line_height"] . "%", $this->get_font_size()); |
|
| 1016 | + return $this->length_in_pt( $this->_props["line_height"] . "%", $this->get_font_size()); |
|
| 1017 | 1017 | |
| 1018 | 1018 | return $this->length_in_pt( $this->_props["line_height"], $this->get_font_size() ); |
| 1019 | - } |
|
| 1019 | + } |
|
| 1020 | 1020 | |
| 1021 | - /** |
|
| 1022 | - * Returns the colour as an array |
|
| 1023 | - * |
|
| 1024 | - * The array has the following format: |
|
| 1025 | - * <code>array(r,g,b, "r" => r, "g" => g, "b" => b, "hex" => "#rrggbb")</code> |
|
| 1026 | - * |
|
| 1027 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-color |
|
| 1028 | - * @return array |
|
| 1029 | - */ |
|
| 1030 | - function get_color() { |
|
| 1021 | + /** |
|
| 1022 | + * Returns the colour as an array |
|
| 1023 | + * |
|
| 1024 | + * The array has the following format: |
|
| 1025 | + * <code>array(r,g,b, "r" => r, "g" => g, "b" => b, "hex" => "#rrggbb")</code> |
|
| 1026 | + * |
|
| 1027 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-color |
|
| 1028 | + * @return array |
|
| 1029 | + */ |
|
| 1030 | + function get_color() { |
|
| 1031 | 1031 | return $this->munge_color( $this->_props["color"] ); |
| 1032 | - } |
|
| 1032 | + } |
|
| 1033 | 1033 | |
| 1034 | - /** |
|
| 1035 | - * Returns the background colour as an array |
|
| 1036 | - * |
|
| 1037 | - * The returned array has the same format as {@link Style::get_color()} |
|
| 1038 | - * |
|
| 1039 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-color |
|
| 1040 | - * @return array |
|
| 1041 | - */ |
|
| 1042 | - function get_background_color() { |
|
| 1034 | + /** |
|
| 1035 | + * Returns the background colour as an array |
|
| 1036 | + * |
|
| 1037 | + * The returned array has the same format as {@link Style::get_color()} |
|
| 1038 | + * |
|
| 1039 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-color |
|
| 1040 | + * @return array |
|
| 1041 | + */ |
|
| 1042 | + function get_background_color() { |
|
| 1043 | 1043 | return $this->munge_color( $this->_props["background_color"] ); |
| 1044 | - } |
|
| 1044 | + } |
|
| 1045 | 1045 | |
| 1046 | - /** |
|
| 1047 | - * Returns the background position as an array |
|
| 1048 | - * |
|
| 1049 | - * The returned array has the following format: |
|
| 1050 | - * <code>array(x,y, "x" => x, "y" => y)</code> |
|
| 1051 | - * |
|
| 1052 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-position |
|
| 1053 | - * @return array |
|
| 1054 | - */ |
|
| 1055 | - function get_background_position() { |
|
| 1046 | + /** |
|
| 1047 | + * Returns the background position as an array |
|
| 1048 | + * |
|
| 1049 | + * The returned array has the following format: |
|
| 1050 | + * <code>array(x,y, "x" => x, "y" => y)</code> |
|
| 1051 | + * |
|
| 1052 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-position |
|
| 1053 | + * @return array |
|
| 1054 | + */ |
|
| 1055 | + function get_background_position() { |
|
| 1056 | 1056 | |
| 1057 | 1057 | $tmp = explode(" ", $this->_props["background_position"]); |
| 1058 | 1058 | |
@@ -1060,119 +1060,119 @@ discard block |
||
| 1060 | 1060 | |
| 1061 | 1061 | case "left": |
| 1062 | 1062 | $x = "0%"; |
| 1063 | - break; |
|
| 1063 | + break; |
|
| 1064 | 1064 | |
| 1065 | 1065 | case "right": |
| 1066 | 1066 | $x = "100%"; |
| 1067 | - break; |
|
| 1067 | + break; |
|
| 1068 | 1068 | |
| 1069 | 1069 | case "top": |
| 1070 | 1070 | $y = "0%"; |
| 1071 | - break; |
|
| 1071 | + break; |
|
| 1072 | 1072 | |
| 1073 | 1073 | case "bottom": |
| 1074 | 1074 | $y = "100%"; |
| 1075 | - break; |
|
| 1075 | + break; |
|
| 1076 | 1076 | |
| 1077 | 1077 | case "center": |
| 1078 | 1078 | $x = "50%"; |
| 1079 | - $y = "50%"; |
|
| 1080 | - break; |
|
| 1079 | + $y = "50%"; |
|
| 1080 | + break; |
|
| 1081 | 1081 | |
| 1082 | 1082 | default: |
| 1083 | 1083 | $x = $tmp[0]; |
| 1084 | - break; |
|
| 1084 | + break; |
|
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | 1087 | if ( isset($tmp[1]) ) { |
| 1088 | 1088 | |
| 1089 | - switch ($tmp[1]) { |
|
| 1090 | - case "left": |
|
| 1089 | + switch ($tmp[1]) { |
|
| 1090 | + case "left": |
|
| 1091 | 1091 | $x = "0%"; |
| 1092 | 1092 | break; |
| 1093 | 1093 | |
| 1094 | - case "right": |
|
| 1094 | + case "right": |
|
| 1095 | 1095 | $x = "100%"; |
| 1096 | 1096 | break; |
| 1097 | 1097 | |
| 1098 | - case "top": |
|
| 1098 | + case "top": |
|
| 1099 | 1099 | $y = "0%"; |
| 1100 | 1100 | break; |
| 1101 | 1101 | |
| 1102 | - case "bottom": |
|
| 1102 | + case "bottom": |
|
| 1103 | 1103 | $y = "100%"; |
| 1104 | 1104 | break; |
| 1105 | 1105 | |
| 1106 | - case "center": |
|
| 1106 | + case "center": |
|
| 1107 | 1107 | if ( $tmp[0] === "left" || $tmp[0] === "right" || $tmp[0] === "center" ) |
| 1108 | - $y = "50%"; |
|
| 1108 | + $y = "50%"; |
|
| 1109 | 1109 | else |
| 1110 | - $x = "50%"; |
|
| 1110 | + $x = "50%"; |
|
| 1111 | 1111 | break; |
| 1112 | 1112 | |
| 1113 | - default: |
|
| 1113 | + default: |
|
| 1114 | 1114 | $y = $tmp[1]; |
| 1115 | 1115 | break; |
| 1116 | - } |
|
| 1116 | + } |
|
| 1117 | 1117 | |
| 1118 | 1118 | } else { |
| 1119 | - $y = "50%"; |
|
| 1119 | + $y = "50%"; |
|
| 1120 | 1120 | } |
| 1121 | 1121 | |
| 1122 | 1122 | if ( !isset($x) ) |
| 1123 | - $x = "0%"; |
|
| 1123 | + $x = "0%"; |
|
| 1124 | 1124 | |
| 1125 | 1125 | if ( !isset($y) ) |
| 1126 | - $y = "0%"; |
|
| 1126 | + $y = "0%"; |
|
| 1127 | 1127 | |
| 1128 | 1128 | return array( 0 => $x, "x" => $x, |
| 1129 | - 1 => $y, "y" => $y ); |
|
| 1130 | - } |
|
| 1129 | + 1 => $y, "y" => $y ); |
|
| 1130 | + } |
|
| 1131 | 1131 | |
| 1132 | 1132 | |
| 1133 | - /** |
|
| 1134 | - * Returns the background as it is currently stored |
|
| 1135 | - * |
|
| 1136 | - * (currently anyway only for completeness. |
|
| 1137 | - * not used for further processing) |
|
| 1138 | - * |
|
| 1139 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-attachment |
|
| 1140 | - * @return string |
|
| 1141 | - */ |
|
| 1142 | - function get_background_attachment() { |
|
| 1133 | + /** |
|
| 1134 | + * Returns the background as it is currently stored |
|
| 1135 | + * |
|
| 1136 | + * (currently anyway only for completeness. |
|
| 1137 | + * not used for further processing) |
|
| 1138 | + * |
|
| 1139 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-attachment |
|
| 1140 | + * @return string |
|
| 1141 | + */ |
|
| 1142 | + function get_background_attachment() { |
|
| 1143 | 1143 | return $this->_props["background_attachment"]; |
| 1144 | - } |
|
| 1144 | + } |
|
| 1145 | 1145 | |
| 1146 | 1146 | |
| 1147 | - /** |
|
| 1148 | - * Returns the background_repeat as it is currently stored |
|
| 1149 | - * |
|
| 1150 | - * (currently anyway only for completeness. |
|
| 1151 | - * not used for further processing) |
|
| 1152 | - * |
|
| 1153 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-repeat |
|
| 1154 | - * @return string |
|
| 1155 | - */ |
|
| 1156 | - function get_background_repeat() { |
|
| 1147 | + /** |
|
| 1148 | + * Returns the background_repeat as it is currently stored |
|
| 1149 | + * |
|
| 1150 | + * (currently anyway only for completeness. |
|
| 1151 | + * not used for further processing) |
|
| 1152 | + * |
|
| 1153 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-repeat |
|
| 1154 | + * @return string |
|
| 1155 | + */ |
|
| 1156 | + function get_background_repeat() { |
|
| 1157 | 1157 | return $this->_props["background_repeat"]; |
| 1158 | - } |
|
| 1158 | + } |
|
| 1159 | 1159 | |
| 1160 | 1160 | |
| 1161 | - /** |
|
| 1162 | - * Returns the background as it is currently stored |
|
| 1163 | - * |
|
| 1164 | - * (currently anyway only for completeness. |
|
| 1165 | - * not used for further processing, but the individual get_background_xxx) |
|
| 1166 | - * |
|
| 1167 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background |
|
| 1168 | - * @return string |
|
| 1169 | - */ |
|
| 1170 | - function get_background() { |
|
| 1161 | + /** |
|
| 1162 | + * Returns the background as it is currently stored |
|
| 1163 | + * |
|
| 1164 | + * (currently anyway only for completeness. |
|
| 1165 | + * not used for further processing, but the individual get_background_xxx) |
|
| 1166 | + * |
|
| 1167 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background |
|
| 1168 | + * @return string |
|
| 1169 | + */ |
|
| 1170 | + function get_background() { |
|
| 1171 | 1171 | return $this->_props["background"]; |
| 1172 | - } |
|
| 1172 | + } |
|
| 1173 | 1173 | |
| 1174 | 1174 | |
| 1175 | - /**#@+ |
|
| 1175 | + /**#@+ |
|
| 1176 | 1176 | * Returns the border colour as an array |
| 1177 | 1177 | * |
| 1178 | 1178 | * See {@link Style::get_color()} |
@@ -1180,112 +1180,112 @@ discard block |
||
| 1180 | 1180 | * @link http://www.w3.org/TR/CSS21/box.html#border-color-properties |
| 1181 | 1181 | * @return array |
| 1182 | 1182 | */ |
| 1183 | - function get_border_top_color() { |
|
| 1183 | + function get_border_top_color() { |
|
| 1184 | 1184 | if ( $this->_props["border_top_color"] === "" ) { |
| 1185 | - //see __set and __get, on all assignments clear cache! |
|
| 1186 | - $this->_prop_cache["border_top_color"] = null; |
|
| 1187 | - $this->_props["border_top_color"] = $this->__get("color"); |
|
| 1185 | + //see __set and __get, on all assignments clear cache! |
|
| 1186 | + $this->_prop_cache["border_top_color"] = null; |
|
| 1187 | + $this->_props["border_top_color"] = $this->__get("color"); |
|
| 1188 | 1188 | } |
| 1189 | 1189 | return $this->munge_color($this->_props["border_top_color"]); |
| 1190 | - } |
|
| 1190 | + } |
|
| 1191 | 1191 | |
| 1192 | - function get_border_right_color() { |
|
| 1192 | + function get_border_right_color() { |
|
| 1193 | 1193 | if ( $this->_props["border_right_color"] === "" ) { |
| 1194 | - //see __set and __get, on all assignments clear cache! |
|
| 1195 | - $this->_prop_cache["border_right_color"] = null; |
|
| 1196 | - $this->_props["border_right_color"] = $this->__get("color"); |
|
| 1194 | + //see __set and __get, on all assignments clear cache! |
|
| 1195 | + $this->_prop_cache["border_right_color"] = null; |
|
| 1196 | + $this->_props["border_right_color"] = $this->__get("color"); |
|
| 1197 | 1197 | } |
| 1198 | 1198 | return $this->munge_color($this->_props["border_right_color"]); |
| 1199 | - } |
|
| 1199 | + } |
|
| 1200 | 1200 | |
| 1201 | - function get_border_bottom_color() { |
|
| 1201 | + function get_border_bottom_color() { |
|
| 1202 | 1202 | if ( $this->_props["border_bottom_color"] === "" ) { |
| 1203 | - //see __set and __get, on all assignments clear cache! |
|
| 1204 | - $this->_prop_cache["border_bottom_color"] = null; |
|
| 1205 | - $this->_props["border_bottom_color"] = $this->__get("color"); |
|
| 1203 | + //see __set and __get, on all assignments clear cache! |
|
| 1204 | + $this->_prop_cache["border_bottom_color"] = null; |
|
| 1205 | + $this->_props["border_bottom_color"] = $this->__get("color"); |
|
| 1206 | 1206 | } |
| 1207 | 1207 | return $this->munge_color($this->_props["border_bottom_color"]);; |
| 1208 | - } |
|
| 1208 | + } |
|
| 1209 | 1209 | |
| 1210 | - function get_border_left_color() { |
|
| 1210 | + function get_border_left_color() { |
|
| 1211 | 1211 | if ( $this->_props["border_left_color"] === "" ) { |
| 1212 | - //see __set and __get, on all assignments clear cache! |
|
| 1213 | - $this->_prop_cache["border_left_color"] = null; |
|
| 1214 | - $this->_props["border_left_color"] = $this->__get("color"); |
|
| 1212 | + //see __set and __get, on all assignments clear cache! |
|
| 1213 | + $this->_prop_cache["border_left_color"] = null; |
|
| 1214 | + $this->_props["border_left_color"] = $this->__get("color"); |
|
| 1215 | 1215 | } |
| 1216 | 1216 | return $this->munge_color($this->_props["border_left_color"]); |
| 1217 | - } |
|
| 1217 | + } |
|
| 1218 | 1218 | |
| 1219 | - /**#@-*/ |
|
| 1219 | + /**#@-*/ |
|
| 1220 | 1220 | |
| 1221 | - /**#@+ |
|
| 1221 | + /**#@+ |
|
| 1222 | 1222 | * Returns the border width, as it is currently stored |
| 1223 | 1223 | * |
| 1224 | 1224 | * @link http://www.w3.org/TR/CSS21/box.html#border-width-properties |
| 1225 | 1225 | * @return float|string |
| 1226 | 1226 | */ |
| 1227 | - function get_border_top_width() { |
|
| 1227 | + function get_border_top_width() { |
|
| 1228 | 1228 | $style = $this->__get("border_top_style"); |
| 1229 | 1229 | return $style !== "none" && $style !== "hidden" ? $this->length_in_pt($this->_props["border_top_width"]) : 0; |
| 1230 | - } |
|
| 1230 | + } |
|
| 1231 | 1231 | |
| 1232 | - function get_border_right_width() { |
|
| 1232 | + function get_border_right_width() { |
|
| 1233 | 1233 | $style = $this->__get("border_right_style"); |
| 1234 | 1234 | return $style !== "none" && $style !== "hidden" ? $this->length_in_pt($this->_props["border_right_width"]) : 0; |
| 1235 | - } |
|
| 1235 | + } |
|
| 1236 | 1236 | |
| 1237 | - function get_border_bottom_width() { |
|
| 1237 | + function get_border_bottom_width() { |
|
| 1238 | 1238 | $style = $this->__get("border_bottom_style"); |
| 1239 | 1239 | return $style !== "none" && $style !== "hidden" ? $this->length_in_pt($this->_props["border_bottom_width"]) : 0; |
| 1240 | - } |
|
| 1240 | + } |
|
| 1241 | 1241 | |
| 1242 | - function get_border_left_width() { |
|
| 1242 | + function get_border_left_width() { |
|
| 1243 | 1243 | $style = $this->__get("border_left_style"); |
| 1244 | 1244 | return $style !== "none" && $style !== "hidden" ? $this->length_in_pt($this->_props["border_left_width"]) : 0; |
| 1245 | - } |
|
| 1246 | - /**#@-*/ |
|
| 1247 | - |
|
| 1248 | - /** |
|
| 1249 | - * Return an array of all border properties. |
|
| 1250 | - * |
|
| 1251 | - * The returned array has the following structure: |
|
| 1252 | - * <code> |
|
| 1253 | - * array("top" => array("width" => [border-width], |
|
| 1254 | - * "style" => [border-style], |
|
| 1255 | - * "color" => [border-color (array)]), |
|
| 1256 | - * "bottom" ... ) |
|
| 1257 | - * </code> |
|
| 1258 | - * |
|
| 1259 | - * @return array |
|
| 1260 | - */ |
|
| 1261 | - function get_border_properties() { |
|
| 1245 | + } |
|
| 1246 | + /**#@-*/ |
|
| 1247 | + |
|
| 1248 | + /** |
|
| 1249 | + * Return an array of all border properties. |
|
| 1250 | + * |
|
| 1251 | + * The returned array has the following structure: |
|
| 1252 | + * <code> |
|
| 1253 | + * array("top" => array("width" => [border-width], |
|
| 1254 | + * "style" => [border-style], |
|
| 1255 | + * "color" => [border-color (array)]), |
|
| 1256 | + * "bottom" ... ) |
|
| 1257 | + * </code> |
|
| 1258 | + * |
|
| 1259 | + * @return array |
|
| 1260 | + */ |
|
| 1261 | + function get_border_properties() { |
|
| 1262 | 1262 | return array("top" => array("width" => $this->__get("border_top_width"), |
| 1263 | 1263 | "style" => $this->__get("border_top_style"), |
| 1264 | 1264 | "color" => $this->__get("border_top_color")), |
| 1265 | - "bottom" => array("width" => $this->__get("border_bottom_width"), |
|
| 1266 | - "style" => $this->__get("border_bottom_style"), |
|
| 1267 | - "color" => $this->__get("border_bottom_color")), |
|
| 1268 | - "right" => array("width" => $this->__get("border_right_width"), |
|
| 1269 | - "style" => $this->__get("border_right_style"), |
|
| 1270 | - "color" => $this->__get("border_right_color")), |
|
| 1271 | - "left" => array("width" => $this->__get("border_left_width"), |
|
| 1272 | - "style" => $this->__get("border_left_style"), |
|
| 1273 | - "color" => $this->__get("border_left_color"))); |
|
| 1274 | - } |
|
| 1275 | - |
|
| 1276 | - /** |
|
| 1277 | - * Return a single border property |
|
| 1278 | - * |
|
| 1279 | - * @return mixed |
|
| 1280 | - */ |
|
| 1281 | - protected function _get_border($side) { |
|
| 1265 | + "bottom" => array("width" => $this->__get("border_bottom_width"), |
|
| 1266 | + "style" => $this->__get("border_bottom_style"), |
|
| 1267 | + "color" => $this->__get("border_bottom_color")), |
|
| 1268 | + "right" => array("width" => $this->__get("border_right_width"), |
|
| 1269 | + "style" => $this->__get("border_right_style"), |
|
| 1270 | + "color" => $this->__get("border_right_color")), |
|
| 1271 | + "left" => array("width" => $this->__get("border_left_width"), |
|
| 1272 | + "style" => $this->__get("border_left_style"), |
|
| 1273 | + "color" => $this->__get("border_left_color"))); |
|
| 1274 | + } |
|
| 1275 | + |
|
| 1276 | + /** |
|
| 1277 | + * Return a single border property |
|
| 1278 | + * |
|
| 1279 | + * @return mixed |
|
| 1280 | + */ |
|
| 1281 | + protected function _get_border($side) { |
|
| 1282 | 1282 | $color = $this->__get("border_" . $side . "_color"); |
| 1283 | 1283 | |
| 1284 | 1284 | return $this->__get("border_" . $side . "_width") . " " . |
| 1285 | - $this->__get("border_" . $side . "_style") . " " . $color["hex"]; |
|
| 1286 | - } |
|
| 1285 | + $this->__get("border_" . $side . "_style") . " " . $color["hex"]; |
|
| 1286 | + } |
|
| 1287 | 1287 | |
| 1288 | - /**#@+ |
|
| 1288 | + /**#@+ |
|
| 1289 | 1289 | * Return full border properties as a string |
| 1290 | 1290 | * |
| 1291 | 1291 | * Border properties are returned just as specified in CSS: |
@@ -1295,28 +1295,28 @@ discard block |
||
| 1295 | 1295 | * @link http://www.w3.org/TR/CSS21/box.html#border-shorthand-properties |
| 1296 | 1296 | * @return string |
| 1297 | 1297 | */ |
| 1298 | - function get_border_top() { return $this->_get_border("top"); } |
|
| 1299 | - function get_border_right() { return $this->_get_border("right"); } |
|
| 1300 | - function get_border_bottom() { return $this->_get_border("bottom"); } |
|
| 1301 | - function get_border_left() { return $this->_get_border("left"); } |
|
| 1302 | - /**#@-*/ |
|
| 1303 | - |
|
| 1304 | - |
|
| 1305 | - /** |
|
| 1306 | - * Returns border spacing as an array |
|
| 1307 | - * |
|
| 1308 | - * The array has the format (h_space,v_space) |
|
| 1309 | - * |
|
| 1310 | - * @link http://www.w3.org/TR/CSS21/tables.html#propdef-border-spacing |
|
| 1311 | - * @return array |
|
| 1312 | - */ |
|
| 1313 | - function get_border_spacing() { |
|
| 1298 | + function get_border_top() { return $this->_get_border("top"); } |
|
| 1299 | + function get_border_right() { return $this->_get_border("right"); } |
|
| 1300 | + function get_border_bottom() { return $this->_get_border("bottom"); } |
|
| 1301 | + function get_border_left() { return $this->_get_border("left"); } |
|
| 1302 | + /**#@-*/ |
|
| 1303 | + |
|
| 1304 | + |
|
| 1305 | + /** |
|
| 1306 | + * Returns border spacing as an array |
|
| 1307 | + * |
|
| 1308 | + * The array has the format (h_space,v_space) |
|
| 1309 | + * |
|
| 1310 | + * @link http://www.w3.org/TR/CSS21/tables.html#propdef-border-spacing |
|
| 1311 | + * @return array |
|
| 1312 | + */ |
|
| 1313 | + function get_border_spacing() { |
|
| 1314 | 1314 | return explode(" ", $this->_props["border_spacing"]); |
| 1315 | - } |
|
| 1315 | + } |
|
| 1316 | 1316 | |
| 1317 | 1317 | /*==============================*/ |
| 1318 | 1318 | |
| 1319 | - /* |
|
| 1319 | + /* |
|
| 1320 | 1320 | !important attribute |
| 1321 | 1321 | For basic functionality of the !important attribute with overloading |
| 1322 | 1322 | of several styles of an element, changes in inherit(), merge() and _parse_properties() |
@@ -1358,419 +1358,419 @@ discard block |
||
| 1358 | 1358 | Related functionality for background, padding, margin, font, list_style |
| 1359 | 1359 | */ |
| 1360 | 1360 | |
| 1361 | - /* Generalized set function for individual attribute of combined style. |
|
| 1361 | + /* Generalized set function for individual attribute of combined style. |
|
| 1362 | 1362 | * With check for !important |
| 1363 | 1363 | * Applicable for background, border, padding, margin, font, list_style |
| 1364 | 1364 | * Note: $type has a leading underscore (or is empty), the others not. |
| 1365 | 1365 | */ |
| 1366 | - protected function _set_style_side_type($style,$side,$type,$val,$important) { |
|
| 1366 | + protected function _set_style_side_type($style,$side,$type,$val,$important) { |
|
| 1367 | 1367 | if ( !isset($this->_important_props[$style.'_'.$side.$type]) || $important) { |
| 1368 | - //see __set and __get, on all assignments clear cache! |
|
| 1369 | - $this->_prop_cache[$style.'_'.$side.$type] = null; |
|
| 1370 | - if ($important) { |
|
| 1368 | + //see __set and __get, on all assignments clear cache! |
|
| 1369 | + $this->_prop_cache[$style.'_'.$side.$type] = null; |
|
| 1370 | + if ($important) { |
|
| 1371 | 1371 | $this->_important_props[$style.'_'.$side.$type] = true; |
| 1372 | - } |
|
| 1373 | - $this->_props[$style.'_'.$side.$type] = $val; |
|
| 1372 | + } |
|
| 1373 | + $this->_props[$style.'_'.$side.$type] = $val; |
|
| 1374 | + } |
|
| 1374 | 1375 | } |
| 1375 | - } |
|
| 1376 | 1376 | |
| 1377 | - protected function _set_style_sides_type($style,$top,$right,$bottom,$left,$type,$important) { |
|
| 1378 | - $this->_set_style_side_type($style,'top',$type,$top,$important); |
|
| 1379 | - $this->_set_style_side_type($style,'right',$type,$right,$important); |
|
| 1380 | - $this->_set_style_side_type($style,'bottom',$type,$bottom,$important); |
|
| 1381 | - $this->_set_style_side_type($style,'left',$type,$left,$important); |
|
| 1382 | - } |
|
| 1377 | + protected function _set_style_sides_type($style,$top,$right,$bottom,$left,$type,$important) { |
|
| 1378 | + $this->_set_style_side_type($style,'top',$type,$top,$important); |
|
| 1379 | + $this->_set_style_side_type($style,'right',$type,$right,$important); |
|
| 1380 | + $this->_set_style_side_type($style,'bottom',$type,$bottom,$important); |
|
| 1381 | + $this->_set_style_side_type($style,'left',$type,$left,$important); |
|
| 1382 | + } |
|
| 1383 | 1383 | |
| 1384 | - protected function _set_style_type($style,$type,$val,$important) { |
|
| 1384 | + protected function _set_style_type($style,$type,$val,$important) { |
|
| 1385 | 1385 | $arr = explode(" ", $val); |
| 1386 | 1386 | switch (count($arr)) { |
| 1387 | 1387 | case 1: |
| 1388 | 1388 | $this->_set_style_sides_type($style,$arr[0],$arr[0],$arr[0],$arr[0],$type,$important); |
| 1389 | - break; |
|
| 1389 | + break; |
|
| 1390 | 1390 | case 2: |
| 1391 | 1391 | $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[0],$arr[1],$type,$important); |
| 1392 | - break; |
|
| 1392 | + break; |
|
| 1393 | 1393 | case 3: |
| 1394 | 1394 | $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[1],$arr[2],$type,$important); |
| 1395 | - break; |
|
| 1395 | + break; |
|
| 1396 | 1396 | case 4: |
| 1397 | 1397 | $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[2],$arr[3],$type,$important); |
| 1398 | - break; |
|
| 1398 | + break; |
|
| 1399 | 1399 | default: |
| 1400 | 1400 | break; |
| 1401 | 1401 | } |
| 1402 | 1402 | //see __set and __get, on all assignments clear cache! |
| 1403 | - $this->_prop_cache[$style.$type] = null; |
|
| 1403 | + $this->_prop_cache[$style.$type] = null; |
|
| 1404 | 1404 | $this->_props[$style.$type] = $val; |
| 1405 | - } |
|
| 1405 | + } |
|
| 1406 | 1406 | |
| 1407 | - protected function _set_style_type_important($style,$type,$val) { |
|
| 1407 | + protected function _set_style_type_important($style,$type,$val) { |
|
| 1408 | 1408 | $this->_set_style_type($style,$type,$val,isset($this->_important_props[$style.$type])); |
| 1409 | - } |
|
| 1409 | + } |
|
| 1410 | 1410 | |
| 1411 | - /* Anyway only called if _important matches and is assigned |
|
| 1411 | + /* Anyway only called if _important matches and is assigned |
|
| 1412 | 1412 | * E.g. _set_style_side_type($style,$side,'',str_replace("none", "0px", $val),isset($this->_important_props[$style.'_'.$side])); |
| 1413 | 1413 | */ |
| 1414 | - protected function _set_style_side_width_important($style,$side,$val) { |
|
| 1414 | + protected function _set_style_side_width_important($style,$side,$val) { |
|
| 1415 | 1415 | //see __set and __get, on all assignments clear cache! |
| 1416 | 1416 | $this->_prop_cache[$style.'_'.$side] = null; |
| 1417 | 1417 | $this->_props[$style.'_'.$side] = str_replace("none", "0px", $val); |
| 1418 | - } |
|
| 1418 | + } |
|
| 1419 | 1419 | |
| 1420 | - protected function _set_style($style,$val,$important) { |
|
| 1420 | + protected function _set_style($style,$val,$important) { |
|
| 1421 | 1421 | if ( !isset($this->_important_props[$style]) || $important) { |
| 1422 | - if ($important) { |
|
| 1422 | + if ($important) { |
|
| 1423 | 1423 | $this->_important_props[$style] = true; |
| 1424 | - } |
|
| 1425 | - //see __set and __get, on all assignments clear cache! |
|
| 1426 | - $this->_prop_cache[$style] = null; |
|
| 1427 | - $this->_props[$style] = $val; |
|
| 1424 | + } |
|
| 1425 | + //see __set and __get, on all assignments clear cache! |
|
| 1426 | + $this->_prop_cache[$style] = null; |
|
| 1427 | + $this->_props[$style] = $val; |
|
| 1428 | + } |
|
| 1428 | 1429 | } |
| 1429 | - } |
|
| 1430 | 1430 | |
| 1431 | - protected function _image($val) { |
|
| 1431 | + protected function _image($val) { |
|
| 1432 | 1432 | $DEBUGCSS=DEBUGCSS; |
| 1433 | 1433 | |
| 1434 | 1434 | if ( mb_strpos($val, "url") === false ) { |
| 1435 | - $path = "none"; //Don't resolve no image -> otherwise would prefix path and no longer recognize as none |
|
| 1435 | + $path = "none"; //Don't resolve no image -> otherwise would prefix path and no longer recognize as none |
|
| 1436 | 1436 | } else { |
| 1437 | - $val = preg_replace("/url\(['\"]?([^'\")]+)['\"]?\)/","\\1", trim($val)); |
|
| 1437 | + $val = preg_replace("/url\(['\"]?([^'\")]+)['\"]?\)/","\\1", trim($val)); |
|
| 1438 | 1438 | |
| 1439 | - // Resolve the url now in the context of the current stylesheet |
|
| 1440 | - $parsed_url = explode_url($val); |
|
| 1441 | - if ( $parsed_url["protocol"] == "" && $this->_stylesheet->get_protocol() == "" ) { |
|
| 1439 | + // Resolve the url now in the context of the current stylesheet |
|
| 1440 | + $parsed_url = explode_url($val); |
|
| 1441 | + if ( $parsed_url["protocol"] == "" && $this->_stylesheet->get_protocol() == "" ) { |
|
| 1442 | 1442 | if ($parsed_url["path"]{0} === '/' || $parsed_url["path"]{0} === '\\' ) { |
| 1443 | - $path = $_SERVER["DOCUMENT_ROOT"].'/'; |
|
| 1443 | + $path = $_SERVER["DOCUMENT_ROOT"].'/'; |
|
| 1444 | 1444 | } else { |
| 1445 | - $path = $this->_stylesheet->get_base_path(); |
|
| 1445 | + $path = $this->_stylesheet->get_base_path(); |
|
| 1446 | 1446 | } |
| 1447 | 1447 | $path .= $parsed_url["path"] . $parsed_url["file"]; |
| 1448 | 1448 | $path = realpath($path); |
| 1449 | 1449 | // If realpath returns FALSE then specifically state that there is no background image |
| 1450 | 1450 | if (!$path) { $path = 'none'; } |
| 1451 | - } else { |
|
| 1451 | + } else { |
|
| 1452 | 1452 | $path = build_url($this->_stylesheet->get_protocol(), |
| 1453 | - $this->_stylesheet->get_host(), |
|
| 1454 | - $this->_stylesheet->get_base_path(), |
|
| 1455 | - $val); |
|
| 1456 | - } |
|
| 1453 | + $this->_stylesheet->get_host(), |
|
| 1454 | + $this->_stylesheet->get_base_path(), |
|
| 1455 | + $val); |
|
| 1456 | + } |
|
| 1457 | 1457 | } |
| 1458 | 1458 | if ($DEBUGCSS) { |
| 1459 | - print "<pre>[_image\n"; |
|
| 1460 | - print_r($parsed_url); |
|
| 1461 | - print $this->_stylesheet->get_protocol()."\n".$this->_stylesheet->get_base_path()."\n".$path."\n"; |
|
| 1462 | - print "_image]</pre>";; |
|
| 1459 | + print "<pre>[_image\n"; |
|
| 1460 | + print_r($parsed_url); |
|
| 1461 | + print $this->_stylesheet->get_protocol()."\n".$this->_stylesheet->get_base_path()."\n".$path."\n"; |
|
| 1462 | + print "_image]</pre>";; |
|
| 1463 | 1463 | } |
| 1464 | 1464 | return $path; |
| 1465 | - } |
|
| 1465 | + } |
|
| 1466 | 1466 | |
| 1467 | 1467 | /*======================*/ |
| 1468 | 1468 | |
| 1469 | - /** |
|
| 1470 | - * Sets colour |
|
| 1471 | - * |
|
| 1472 | - * The colour parameter can be any valid CSS colour value |
|
| 1473 | - * |
|
| 1474 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-color |
|
| 1475 | - * @param string $colour |
|
| 1476 | - */ |
|
| 1477 | - function set_color($colour) { |
|
| 1469 | + /** |
|
| 1470 | + * Sets colour |
|
| 1471 | + * |
|
| 1472 | + * The colour parameter can be any valid CSS colour value |
|
| 1473 | + * |
|
| 1474 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-color |
|
| 1475 | + * @param string $colour |
|
| 1476 | + */ |
|
| 1477 | + function set_color($colour) { |
|
| 1478 | 1478 | $col = $this->munge_colour($colour); |
| 1479 | 1479 | |
| 1480 | 1480 | if ( is_null($col) ) |
| 1481 | - $col = self::$_defaults["color"]; |
|
| 1481 | + $col = self::$_defaults["color"]; |
|
| 1482 | 1482 | |
| 1483 | 1483 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1484 | - $this->_prop_cache["color"] = null; |
|
| 1484 | + $this->_prop_cache["color"] = null; |
|
| 1485 | 1485 | $this->_props["color"] = $col["hex"]; |
| 1486 | - } |
|
| 1486 | + } |
|
| 1487 | 1487 | |
| 1488 | - /** |
|
| 1489 | - * Sets the background colour |
|
| 1490 | - * |
|
| 1491 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-color |
|
| 1492 | - * @param string $colour |
|
| 1493 | - */ |
|
| 1494 | - function set_background_color($colour) { |
|
| 1488 | + /** |
|
| 1489 | + * Sets the background colour |
|
| 1490 | + * |
|
| 1491 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-color |
|
| 1492 | + * @param string $colour |
|
| 1493 | + */ |
|
| 1494 | + function set_background_color($colour) { |
|
| 1495 | 1495 | $col = $this->munge_colour($colour); |
| 1496 | 1496 | if ( is_null($col) ) |
| 1497 | - $col = self::$_defaults["background_color"]; |
|
| 1497 | + $col = self::$_defaults["background_color"]; |
|
| 1498 | 1498 | |
| 1499 | 1499 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1500 | - $this->_prop_cache["background_color"] = null; |
|
| 1500 | + $this->_prop_cache["background_color"] = null; |
|
| 1501 | 1501 | $this->_props["background_color"] = is_array($col) ? $col["hex"] : $col; |
| 1502 | - } |
|
| 1502 | + } |
|
| 1503 | 1503 | |
| 1504 | - /** |
|
| 1505 | - * Set the background image url |
|
| 1506 | - * |
|
| 1507 | - * @link http://www.w3.org/TR/CSS21/colors.html#background-properties |
|
| 1508 | - * @param string $url |
|
| 1509 | - */ |
|
| 1510 | - function set_background_image($val) { |
|
| 1504 | + /** |
|
| 1505 | + * Set the background image url |
|
| 1506 | + * |
|
| 1507 | + * @link http://www.w3.org/TR/CSS21/colors.html#background-properties |
|
| 1508 | + * @param string $url |
|
| 1509 | + */ |
|
| 1510 | + function set_background_image($val) { |
|
| 1511 | 1511 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1512 | - $this->_prop_cache["background_image"] = null; |
|
| 1512 | + $this->_prop_cache["background_image"] = null; |
|
| 1513 | 1513 | $this->_props["background_image"] = $this->_image($val); |
| 1514 | - } |
|
| 1514 | + } |
|
| 1515 | 1515 | |
| 1516 | - /** |
|
| 1517 | - * Sets the background repeat |
|
| 1518 | - * |
|
| 1519 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-repeat |
|
| 1520 | - * @param string $val |
|
| 1521 | - */ |
|
| 1522 | - function set_background_repeat($val) { |
|
| 1516 | + /** |
|
| 1517 | + * Sets the background repeat |
|
| 1518 | + * |
|
| 1519 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-repeat |
|
| 1520 | + * @param string $val |
|
| 1521 | + */ |
|
| 1522 | + function set_background_repeat($val) { |
|
| 1523 | 1523 | if ( is_null($val) ) |
| 1524 | - $val = self::$_defaults["background_repeat"]; |
|
| 1524 | + $val = self::$_defaults["background_repeat"]; |
|
| 1525 | 1525 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1526 | 1526 | $this->_prop_cache["background_repeat"] = null; |
| 1527 | 1527 | $this->_props["background_repeat"] = $val; |
| 1528 | - } |
|
| 1528 | + } |
|
| 1529 | 1529 | |
| 1530 | - /** |
|
| 1531 | - * Sets the background attachment |
|
| 1532 | - * |
|
| 1533 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-attachment |
|
| 1534 | - * @param string $val |
|
| 1535 | - */ |
|
| 1536 | - function set_background_attachment($val) { |
|
| 1530 | + /** |
|
| 1531 | + * Sets the background attachment |
|
| 1532 | + * |
|
| 1533 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-attachment |
|
| 1534 | + * @param string $val |
|
| 1535 | + */ |
|
| 1536 | + function set_background_attachment($val) { |
|
| 1537 | 1537 | if ( is_null($val) ) |
| 1538 | - $val = self::$_defaults["background_attachment"]; |
|
| 1538 | + $val = self::$_defaults["background_attachment"]; |
|
| 1539 | 1539 | |
| 1540 | 1540 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1541 | - $this->_prop_cache["background_attachment"] = null; |
|
| 1541 | + $this->_prop_cache["background_attachment"] = null; |
|
| 1542 | 1542 | $this->_props["background_attachment"] = $val; |
| 1543 | - } |
|
| 1543 | + } |
|
| 1544 | 1544 | |
| 1545 | - /** |
|
| 1546 | - * Sets the background position |
|
| 1547 | - * |
|
| 1548 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-position |
|
| 1549 | - * @param string $val |
|
| 1550 | - */ |
|
| 1551 | - function set_background_position($val) { |
|
| 1545 | + /** |
|
| 1546 | + * Sets the background position |
|
| 1547 | + * |
|
| 1548 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-position |
|
| 1549 | + * @param string $val |
|
| 1550 | + */ |
|
| 1551 | + function set_background_position($val) { |
|
| 1552 | 1552 | if ( is_null($val) ) |
| 1553 | - $val = self::$_defaults["background_position"]; |
|
| 1553 | + $val = self::$_defaults["background_position"]; |
|
| 1554 | 1554 | |
| 1555 | 1555 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1556 | - $this->_prop_cache["background_position"] = null; |
|
| 1556 | + $this->_prop_cache["background_position"] = null; |
|
| 1557 | 1557 | $this->_props["background_position"] = $val; |
| 1558 | - } |
|
| 1558 | + } |
|
| 1559 | 1559 | |
| 1560 | - /** |
|
| 1561 | - * Sets the background - combined options |
|
| 1562 | - * |
|
| 1563 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background |
|
| 1564 | - * @param string $val |
|
| 1565 | - */ |
|
| 1566 | - function set_background($val) { |
|
| 1560 | + /** |
|
| 1561 | + * Sets the background - combined options |
|
| 1562 | + * |
|
| 1563 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background |
|
| 1564 | + * @param string $val |
|
| 1565 | + */ |
|
| 1566 | + function set_background($val) { |
|
| 1567 | 1567 | $col = null; |
| 1568 | 1568 | $pos = array(); |
| 1569 | 1569 | $tmp = explode(" ", $val); |
| 1570 | 1570 | $important = isset($this->_important_props["background"]); |
| 1571 | 1571 | foreach($tmp as $attr) { |
| 1572 | - if (mb_substr($attr, 0, 3) === "url" || $attr === "none") { |
|
| 1573 | - $this->_set_style("background_image", $this->_image($attr), $important); |
|
| 1574 | - } else if ($attr === "fixed" || $attr === "scroll") { |
|
| 1575 | - $this->_set_style("background_attachment", $attr, $important); |
|
| 1576 | - } else if ($attr === "repeat" || $attr === "repeat-x" || $attr === "repeat-y" || $attr === "no-repeat") { |
|
| 1577 | - $this->_set_style("background_repeat", $attr, $important); |
|
| 1578 | - } else if (($col = $this->munge_color($attr)) != null ) { |
|
| 1579 | - $this->_set_style("background_color", is_array($col) ? $col["hex"] : $col, $important); |
|
| 1580 | - } else { |
|
| 1581 | - $pos[] = $attr; |
|
| 1582 | - } |
|
| 1583 | - } |
|
| 1584 | - if (count($pos)) { |
|
| 1585 | - $this->_set_style("background_position",implode(' ',$pos), $important); |
|
| 1586 | - } |
|
| 1572 | + if (mb_substr($attr, 0, 3) === "url" || $attr === "none") { |
|
| 1573 | + $this->_set_style("background_image", $this->_image($attr), $important); |
|
| 1574 | + } else if ($attr === "fixed" || $attr === "scroll") { |
|
| 1575 | + $this->_set_style("background_attachment", $attr, $important); |
|
| 1576 | + } else if ($attr === "repeat" || $attr === "repeat-x" || $attr === "repeat-y" || $attr === "no-repeat") { |
|
| 1577 | + $this->_set_style("background_repeat", $attr, $important); |
|
| 1578 | + } else if (($col = $this->munge_color($attr)) != null ) { |
|
| 1579 | + $this->_set_style("background_color", is_array($col) ? $col["hex"] : $col, $important); |
|
| 1580 | + } else { |
|
| 1581 | + $pos[] = $attr; |
|
| 1582 | + } |
|
| 1583 | + } |
|
| 1584 | + if (count($pos)) { |
|
| 1585 | + $this->_set_style("background_position",implode(' ',$pos), $important); |
|
| 1586 | + } |
|
| 1587 | 1587 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1588 | - $this->_prop_cache["background"] = null; |
|
| 1589 | - $this->_props["background"] = $val; |
|
| 1590 | - } |
|
| 1588 | + $this->_prop_cache["background"] = null; |
|
| 1589 | + $this->_props["background"] = $val; |
|
| 1590 | + } |
|
| 1591 | 1591 | |
| 1592 | - /** |
|
| 1593 | - * Sets the font size |
|
| 1594 | - * |
|
| 1595 | - * $size can be any acceptable CSS size |
|
| 1596 | - * |
|
| 1597 | - * @link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-size |
|
| 1598 | - * @param string|float $size |
|
| 1599 | - */ |
|
| 1600 | - function set_font_size($size) { |
|
| 1592 | + /** |
|
| 1593 | + * Sets the font size |
|
| 1594 | + * |
|
| 1595 | + * $size can be any acceptable CSS size |
|
| 1596 | + * |
|
| 1597 | + * @link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-size |
|
| 1598 | + * @param string|float $size |
|
| 1599 | + */ |
|
| 1600 | + function set_font_size($size) { |
|
| 1601 | 1601 | $this->__font_size_calculated = false; |
| 1602 | 1602 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1603 | - $this->_prop_cache["font_size"] = null; |
|
| 1603 | + $this->_prop_cache["font_size"] = null; |
|
| 1604 | 1604 | $this->_props["font_size"] = $size; |
| 1605 | - } |
|
| 1605 | + } |
|
| 1606 | 1606 | |
| 1607 | - /** |
|
| 1608 | - * Sets the font style |
|
| 1609 | - * |
|
| 1610 | - * combined attributes |
|
| 1611 | - * set individual attributes also, respecting !important mark |
|
| 1612 | - * exactly this order, separate by space. Multiple fonts separated by comma: |
|
| 1613 | - * font-style, font-variant, font-weight, font-size, line-height, font-family |
|
| 1614 | - * |
|
| 1615 | - * Other than with border and list, existing partial attributes should |
|
| 1616 | - * reset when starting here, even when not mentioned. |
|
| 1617 | - * If individual attribute is !important and explicite or implicite replacement is not, |
|
| 1618 | - * keep individual attribute |
|
| 1619 | - * |
|
| 1620 | - * require whitespace as delimiters for single value attributes |
|
| 1621 | - * On delimiter "/" treat first as font height, second as line height |
|
| 1622 | - * treat all remaining at the end of line as font |
|
| 1623 | - * font-style, font-variant, font-weight, font-size, line-height, font-family |
|
| 1624 | - * |
|
| 1625 | - * missing font-size and font-family might be not allowed, but accept it here and |
|
| 1626 | - * use default (medium size, enpty font name) |
|
| 1627 | - * |
|
| 1628 | - * @link http://www.w3.org/TR/CSS21/generate.html#propdef-list-style |
|
| 1629 | - * @param $val |
|
| 1630 | - */ |
|
| 1631 | - function set_font($val) { |
|
| 1607 | + /** |
|
| 1608 | + * Sets the font style |
|
| 1609 | + * |
|
| 1610 | + * combined attributes |
|
| 1611 | + * set individual attributes also, respecting !important mark |
|
| 1612 | + * exactly this order, separate by space. Multiple fonts separated by comma: |
|
| 1613 | + * font-style, font-variant, font-weight, font-size, line-height, font-family |
|
| 1614 | + * |
|
| 1615 | + * Other than with border and list, existing partial attributes should |
|
| 1616 | + * reset when starting here, even when not mentioned. |
|
| 1617 | + * If individual attribute is !important and explicite or implicite replacement is not, |
|
| 1618 | + * keep individual attribute |
|
| 1619 | + * |
|
| 1620 | + * require whitespace as delimiters for single value attributes |
|
| 1621 | + * On delimiter "/" treat first as font height, second as line height |
|
| 1622 | + * treat all remaining at the end of line as font |
|
| 1623 | + * font-style, font-variant, font-weight, font-size, line-height, font-family |
|
| 1624 | + * |
|
| 1625 | + * missing font-size and font-family might be not allowed, but accept it here and |
|
| 1626 | + * use default (medium size, enpty font name) |
|
| 1627 | + * |
|
| 1628 | + * @link http://www.w3.org/TR/CSS21/generate.html#propdef-list-style |
|
| 1629 | + * @param $val |
|
| 1630 | + */ |
|
| 1631 | + function set_font($val) { |
|
| 1632 | 1632 | $this->__font_size_calculated = false; |
| 1633 | 1633 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1634 | - $this->_prop_cache["font"] = null; |
|
| 1635 | - $this->_props["font"] = $val; |
|
| 1634 | + $this->_prop_cache["font"] = null; |
|
| 1635 | + $this->_props["font"] = $val; |
|
| 1636 | 1636 | |
| 1637 | 1637 | $important = isset($this->_important_props["font"]); |
| 1638 | 1638 | |
| 1639 | - if ( preg_match("/^(italic|oblique|normal)\s*(.*)$/i",$val,$match) ) { |
|
| 1640 | - $this->_set_style("font_style", $match[1], $important); |
|
| 1641 | - $val = $match[2]; |
|
| 1642 | - } else { |
|
| 1643 | - $this->_set_style("font_style", self::$_defaults["font_style"], $important); |
|
| 1644 | - } |
|
| 1639 | + if ( preg_match("/^(italic|oblique|normal)\s*(.*)$/i",$val,$match) ) { |
|
| 1640 | + $this->_set_style("font_style", $match[1], $important); |
|
| 1641 | + $val = $match[2]; |
|
| 1642 | + } else { |
|
| 1643 | + $this->_set_style("font_style", self::$_defaults["font_style"], $important); |
|
| 1644 | + } |
|
| 1645 | 1645 | |
| 1646 | - if ( preg_match("/^(small-caps|normal)\s*(.*)$/i",$val,$match) ) { |
|
| 1647 | - $this->_set_style("font_variant", $match[1], $important); |
|
| 1648 | - $val = $match[2]; |
|
| 1649 | - } else { |
|
| 1650 | - $this->_set_style("font_variant", self::$_defaults["font_variant"], $important); |
|
| 1651 | - } |
|
| 1646 | + if ( preg_match("/^(small-caps|normal)\s*(.*)$/i",$val,$match) ) { |
|
| 1647 | + $this->_set_style("font_variant", $match[1], $important); |
|
| 1648 | + $val = $match[2]; |
|
| 1649 | + } else { |
|
| 1650 | + $this->_set_style("font_variant", self::$_defaults["font_variant"], $important); |
|
| 1651 | + } |
|
| 1652 | 1652 | |
| 1653 | 1653 | //matching numeric value followed by unit -> this is indeed a subsequent font size. Skip! |
| 1654 | - if ( preg_match("/^(bold|bolder|lighter|100|200|300|400|500|600|700|800|900|normal)\s*(.*)$/i",$val,$match) && |
|
| 1654 | + if ( preg_match("/^(bold|bolder|lighter|100|200|300|400|500|600|700|800|900|normal)\s*(.*)$/i",$val,$match) && |
|
| 1655 | 1655 | !preg_match("/^(?:pt|px|pc|em|ex|in|cm|mm|%)/",$match[2]) |
| 1656 | - ) { |
|
| 1657 | - $this->_set_style("font_weight", $match[1], $important); |
|
| 1658 | - $val = $match[2]; |
|
| 1659 | - } else { |
|
| 1660 | - $this->_set_style("font_weight", self::$_defaults["font_weight"], $important); |
|
| 1661 | - } |
|
| 1662 | - |
|
| 1663 | - if ( preg_match("/^(xx-small|x-small|small|medium|large|x-large|xx-large|smaller|larger|\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i",$val,$match) ) { |
|
| 1664 | - $this->_set_style("font_size", $match[1], $important); |
|
| 1665 | - $val = $match[2]; |
|
| 1656 | + ) { |
|
| 1657 | + $this->_set_style("font_weight", $match[1], $important); |
|
| 1658 | + $val = $match[2]; |
|
| 1659 | + } else { |
|
| 1660 | + $this->_set_style("font_weight", self::$_defaults["font_weight"], $important); |
|
| 1661 | + } |
|
| 1662 | + |
|
| 1663 | + if ( preg_match("/^(xx-small|x-small|small|medium|large|x-large|xx-large|smaller|larger|\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i",$val,$match) ) { |
|
| 1664 | + $this->_set_style("font_size", $match[1], $important); |
|
| 1665 | + $val = $match[2]; |
|
| 1666 | 1666 | if (preg_match("/^\/\s*(\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i",$val,$match) ) { |
| 1667 | - $this->_set_style("line_height", $match[1], $important); |
|
| 1668 | - $val = $match[2]; |
|
| 1667 | + $this->_set_style("line_height", $match[1], $important); |
|
| 1668 | + $val = $match[2]; |
|
| 1669 | 1669 | } else { |
| 1670 | - $this->_set_style("line_height", self::$_defaults["line_height"], $important); |
|
| 1670 | + $this->_set_style("line_height", self::$_defaults["line_height"], $important); |
|
| 1671 | 1671 | } |
| 1672 | - } else { |
|
| 1673 | - $this->_set_style("font_size", self::$_defaults["font_size"], $important); |
|
| 1674 | - $this->_set_style("line_height", self::$_defaults["line_height"], $important); |
|
| 1675 | - } |
|
| 1676 | - |
|
| 1677 | - if(strlen($val) != 0) { |
|
| 1678 | - $this->_set_style("font_family", $val, $important); |
|
| 1679 | - } else { |
|
| 1680 | - $this->_set_style("font_family", self::$_defaults["font_family"], $important); |
|
| 1681 | - } |
|
| 1682 | - } |
|
| 1683 | - |
|
| 1684 | - /**#@+ |
|
| 1672 | + } else { |
|
| 1673 | + $this->_set_style("font_size", self::$_defaults["font_size"], $important); |
|
| 1674 | + $this->_set_style("line_height", self::$_defaults["line_height"], $important); |
|
| 1675 | + } |
|
| 1676 | + |
|
| 1677 | + if(strlen($val) != 0) { |
|
| 1678 | + $this->_set_style("font_family", $val, $important); |
|
| 1679 | + } else { |
|
| 1680 | + $this->_set_style("font_family", self::$_defaults["font_family"], $important); |
|
| 1681 | + } |
|
| 1682 | + } |
|
| 1683 | + |
|
| 1684 | + /**#@+ |
|
| 1685 | 1685 | * Sets page break properties |
| 1686 | 1686 | * |
| 1687 | 1687 | * @link http://www.w3.org/TR/CSS21/page.html#page-breaks |
| 1688 | 1688 | * @param string $break |
| 1689 | 1689 | */ |
| 1690 | - function set_page_break_before($break) { |
|
| 1690 | + function set_page_break_before($break) { |
|
| 1691 | 1691 | if ($break === "left" || $break === "right") |
| 1692 | - $break = "always"; |
|
| 1692 | + $break = "always"; |
|
| 1693 | 1693 | |
| 1694 | 1694 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1695 | - $this->_prop_cache["page_break_before"] = null; |
|
| 1695 | + $this->_prop_cache["page_break_before"] = null; |
|
| 1696 | 1696 | $this->_props["page_break_before"] = $break; |
| 1697 | - } |
|
| 1697 | + } |
|
| 1698 | 1698 | |
| 1699 | - function set_page_break_after($break) { |
|
| 1699 | + function set_page_break_after($break) { |
|
| 1700 | 1700 | if ($break === "left" || $break === "right") |
| 1701 | - $break = "always"; |
|
| 1701 | + $break = "always"; |
|
| 1702 | 1702 | |
| 1703 | 1703 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1704 | - $this->_prop_cache["page_break_after"] = null; |
|
| 1704 | + $this->_prop_cache["page_break_after"] = null; |
|
| 1705 | 1705 | $this->_props["page_break_after"] = $break; |
| 1706 | - } |
|
| 1707 | - /**#@-*/ |
|
| 1706 | + } |
|
| 1707 | + /**#@-*/ |
|
| 1708 | 1708 | |
| 1709 | - //........................................................................ |
|
| 1709 | + //........................................................................ |
|
| 1710 | 1710 | |
| 1711 | - /**#@+ |
|
| 1711 | + /**#@+ |
|
| 1712 | 1712 | * Sets the margin size |
| 1713 | 1713 | * |
| 1714 | 1714 | * @link http://www.w3.org/TR/CSS21/box.html#margin-properties |
| 1715 | 1715 | * @param $val |
| 1716 | 1716 | */ |
| 1717 | - function set_margin_top($val) { |
|
| 1717 | + function set_margin_top($val) { |
|
| 1718 | 1718 | $this->_set_style_side_width_important('margin','top',$val); |
| 1719 | - } |
|
| 1719 | + } |
|
| 1720 | 1720 | |
| 1721 | - function set_margin_right($val) { |
|
| 1721 | + function set_margin_right($val) { |
|
| 1722 | 1722 | $this->_set_style_side_width_important('margin','right',$val); |
| 1723 | - } |
|
| 1723 | + } |
|
| 1724 | 1724 | |
| 1725 | - function set_margin_bottom($val) { |
|
| 1725 | + function set_margin_bottom($val) { |
|
| 1726 | 1726 | $this->_set_style_side_width_important('margin','bottom',$val); |
| 1727 | - } |
|
| 1727 | + } |
|
| 1728 | 1728 | |
| 1729 | - function set_margin_left($val) { |
|
| 1729 | + function set_margin_left($val) { |
|
| 1730 | 1730 | $this->_set_style_side_width_important('margin','left',$val); |
| 1731 | - } |
|
| 1731 | + } |
|
| 1732 | 1732 | |
| 1733 | - function set_margin($val) { |
|
| 1733 | + function set_margin($val) { |
|
| 1734 | 1734 | $val = str_replace("none", "0px", $val); |
| 1735 | 1735 | $this->_set_style_type_important('margin','',$val); |
| 1736 | - } |
|
| 1737 | - /**#@-*/ |
|
| 1736 | + } |
|
| 1737 | + /**#@-*/ |
|
| 1738 | 1738 | |
| 1739 | - /**#@+ |
|
| 1739 | + /**#@+ |
|
| 1740 | 1740 | * Sets the padding size |
| 1741 | 1741 | * |
| 1742 | 1742 | * @link http://www.w3.org/TR/CSS21/box.html#padding-properties |
| 1743 | 1743 | * @param $val |
| 1744 | 1744 | */ |
| 1745 | - function set_padding_top($val) { |
|
| 1745 | + function set_padding_top($val) { |
|
| 1746 | 1746 | $this->_set_style_side_width_important('padding','top',$val); |
| 1747 | - } |
|
| 1747 | + } |
|
| 1748 | 1748 | |
| 1749 | - function set_padding_right($val) { |
|
| 1749 | + function set_padding_right($val) { |
|
| 1750 | 1750 | $this->_set_style_side_width_important('padding','right',$val); |
| 1751 | - } |
|
| 1751 | + } |
|
| 1752 | 1752 | |
| 1753 | - function set_padding_bottom($val) { |
|
| 1753 | + function set_padding_bottom($val) { |
|
| 1754 | 1754 | $this->_set_style_side_width_important('padding','bottom',$val); |
| 1755 | - } |
|
| 1755 | + } |
|
| 1756 | 1756 | |
| 1757 | - function set_padding_left($val) { |
|
| 1757 | + function set_padding_left($val) { |
|
| 1758 | 1758 | $this->_set_style_side_width_important('padding','left',$val); |
| 1759 | - } |
|
| 1759 | + } |
|
| 1760 | 1760 | |
| 1761 | - function set_padding($val) { |
|
| 1761 | + function set_padding($val) { |
|
| 1762 | 1762 | $val = str_replace("none", "0px", $val); |
| 1763 | 1763 | $this->_set_style_type_important('padding','',$val); |
| 1764 | - } |
|
| 1765 | - /**#@-*/ |
|
| 1766 | - |
|
| 1767 | - /** |
|
| 1768 | - * Sets a single border |
|
| 1769 | - * |
|
| 1770 | - * @param string $side |
|
| 1771 | - * @param string $border_spec ([width] [style] [color]) |
|
| 1772 | - */ |
|
| 1773 | - protected function _set_border($side, $border_spec, $important) { |
|
| 1764 | + } |
|
| 1765 | + /**#@-*/ |
|
| 1766 | + |
|
| 1767 | + /** |
|
| 1768 | + * Sets a single border |
|
| 1769 | + * |
|
| 1770 | + * @param string $side |
|
| 1771 | + * @param string $border_spec ([width] [style] [color]) |
|
| 1772 | + */ |
|
| 1773 | + protected function _set_border($side, $border_spec, $important) { |
|
| 1774 | 1774 | $border_spec = str_replace(",", " ", $border_spec); |
| 1775 | 1775 | $arr = explode(" ", $border_spec); |
| 1776 | 1776 | |
@@ -1783,155 +1783,155 @@ discard block |
||
| 1783 | 1783 | $this->_set_style_side_type('border',$side,'_color',self::$_defaults['border_'.$side.'_color'],$important); |
| 1784 | 1784 | |
| 1785 | 1785 | foreach ($arr as $value) { |
| 1786 | - $value = trim($value); |
|
| 1787 | - if ( in_array($value, self::$BORDER_STYLES) ) { |
|
| 1786 | + $value = trim($value); |
|
| 1787 | + if ( in_array($value, self::$BORDER_STYLES) ) { |
|
| 1788 | 1788 | $this->_set_style_side_type('border',$side,'_style',$value,$important); |
| 1789 | 1789 | |
| 1790 | - } else if ( preg_match("/[.0-9]+(?:px|pt|pc|em|ex|%|in|mm|cm)|(?:thin|medium|thick)/", $value ) ) { |
|
| 1790 | + } else if ( preg_match("/[.0-9]+(?:px|pt|pc|em|ex|%|in|mm|cm)|(?:thin|medium|thick)/", $value ) ) { |
|
| 1791 | 1791 | $this->_set_style_side_type('border',$side,'_width',$value,$important); |
| 1792 | 1792 | |
| 1793 | - } else { |
|
| 1793 | + } else { |
|
| 1794 | 1794 | // must be colour |
| 1795 | 1795 | $this->_set_style_side_type('border',$side,'_color',$value,$important); |
| 1796 | - } |
|
| 1796 | + } |
|
| 1797 | 1797 | } |
| 1798 | 1798 | |
| 1799 | 1799 | //see __set and __get, on all assignments clear cache! |
| 1800 | - $this->_prop_cache['border_'.$side] = null; |
|
| 1800 | + $this->_prop_cache['border_'.$side] = null; |
|
| 1801 | 1801 | $this->_props['border_'.$side] = $border_spec; |
| 1802 | - } |
|
| 1802 | + } |
|
| 1803 | 1803 | |
| 1804 | - /**#@+ |
|
| 1804 | + /**#@+ |
|
| 1805 | 1805 | * Sets the border styles |
| 1806 | 1806 | * |
| 1807 | 1807 | * @link http://www.w3.org/TR/CSS21/box.html#border-properties |
| 1808 | 1808 | * @param string $val |
| 1809 | 1809 | */ |
| 1810 | - function set_border_top($val) { $this->_set_border("top", $val, isset($this->_important_props['border_top'])); } |
|
| 1811 | - function set_border_right($val) { $this->_set_border("right", $val, isset($this->_important_props['border_right'])); } |
|
| 1812 | - function set_border_bottom($val) { $this->_set_border("bottom", $val, isset($this->_important_props['border_bottom'])); } |
|
| 1813 | - function set_border_left($val) { $this->_set_border("left", $val, isset($this->_important_props['border_left'])); } |
|
| 1810 | + function set_border_top($val) { $this->_set_border("top", $val, isset($this->_important_props['border_top'])); } |
|
| 1811 | + function set_border_right($val) { $this->_set_border("right", $val, isset($this->_important_props['border_right'])); } |
|
| 1812 | + function set_border_bottom($val) { $this->_set_border("bottom", $val, isset($this->_important_props['border_bottom'])); } |
|
| 1813 | + function set_border_left($val) { $this->_set_border("left", $val, isset($this->_important_props['border_left'])); } |
|
| 1814 | 1814 | |
| 1815 | - function set_border($val) { |
|
| 1815 | + function set_border($val) { |
|
| 1816 | 1816 | $important = isset($this->_important_props["border"]); |
| 1817 | 1817 | $this->_set_border("top", $val, $important); |
| 1818 | 1818 | $this->_set_border("right", $val, $important); |
| 1819 | 1819 | $this->_set_border("bottom", $val, $important); |
| 1820 | 1820 | $this->_set_border("left", $val, $important); |
| 1821 | 1821 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1822 | - $this->_prop_cache["border"] = null; |
|
| 1822 | + $this->_prop_cache["border"] = null; |
|
| 1823 | 1823 | $this->_props["border"] = $val; |
| 1824 | - } |
|
| 1824 | + } |
|
| 1825 | 1825 | |
| 1826 | - function set_border_width($val) { |
|
| 1826 | + function set_border_width($val) { |
|
| 1827 | 1827 | $this->_set_style_type_important('border','_width',$val); |
| 1828 | - } |
|
| 1828 | + } |
|
| 1829 | 1829 | |
| 1830 | - function set_border_color($val) { |
|
| 1830 | + function set_border_color($val) { |
|
| 1831 | 1831 | $this->_set_style_type_important('border','_color',$val); |
| 1832 | - } |
|
| 1832 | + } |
|
| 1833 | 1833 | |
| 1834 | - function set_border_style($val) { |
|
| 1834 | + function set_border_style($val) { |
|
| 1835 | 1835 | $this->_set_style_type_important('border','_style',$val); |
| 1836 | - } |
|
| 1837 | - /**#@-*/ |
|
| 1836 | + } |
|
| 1837 | + /**#@-*/ |
|
| 1838 | 1838 | |
| 1839 | 1839 | |
| 1840 | - /** |
|
| 1841 | - * Sets the border spacing |
|
| 1842 | - * |
|
| 1843 | - * @link http://www.w3.org/TR/CSS21/box.html#border-properties |
|
| 1844 | - * @param float $val |
|
| 1845 | - */ |
|
| 1846 | - function set_border_spacing($val) { |
|
| 1840 | + /** |
|
| 1841 | + * Sets the border spacing |
|
| 1842 | + * |
|
| 1843 | + * @link http://www.w3.org/TR/CSS21/box.html#border-properties |
|
| 1844 | + * @param float $val |
|
| 1845 | + */ |
|
| 1846 | + function set_border_spacing($val) { |
|
| 1847 | 1847 | |
| 1848 | 1848 | $arr = explode(" ", $val); |
| 1849 | 1849 | |
| 1850 | 1850 | if ( count($arr) == 1 ) |
| 1851 | - $arr[1] = $arr[0]; |
|
| 1851 | + $arr[1] = $arr[0]; |
|
| 1852 | 1852 | |
| 1853 | 1853 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1854 | - $this->_prop_cache["border_spacing"] = null; |
|
| 1854 | + $this->_prop_cache["border_spacing"] = null; |
|
| 1855 | 1855 | $this->_props["border_spacing"] = $arr[0] . " " . $arr[1]; |
| 1856 | - } |
|
| 1856 | + } |
|
| 1857 | 1857 | |
| 1858 | - /** |
|
| 1859 | - * Sets the list style image |
|
| 1860 | - * |
|
| 1861 | - * @link http://www.w3.org/TR/CSS21/generate.html#propdef-list-style-image |
|
| 1862 | - * @param $val |
|
| 1863 | - */ |
|
| 1864 | - function set_list_style_image($val) { |
|
| 1858 | + /** |
|
| 1859 | + * Sets the list style image |
|
| 1860 | + * |
|
| 1861 | + * @link http://www.w3.org/TR/CSS21/generate.html#propdef-list-style-image |
|
| 1862 | + * @param $val |
|
| 1863 | + */ |
|
| 1864 | + function set_list_style_image($val) { |
|
| 1865 | 1865 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1866 | - $this->_prop_cache["list_style_image"] = null; |
|
| 1866 | + $this->_prop_cache["list_style_image"] = null; |
|
| 1867 | 1867 | $this->_props["list_style_image"] = $this->_image($val); |
| 1868 | - } |
|
| 1868 | + } |
|
| 1869 | 1869 | |
| 1870 | - /** |
|
| 1871 | - * Sets the list style |
|
| 1872 | - * |
|
| 1873 | - * @link http://www.w3.org/TR/CSS21/generate.html#propdef-list-style |
|
| 1874 | - * @param $val |
|
| 1875 | - */ |
|
| 1876 | - function set_list_style($val) { |
|
| 1870 | + /** |
|
| 1871 | + * Sets the list style |
|
| 1872 | + * |
|
| 1873 | + * @link http://www.w3.org/TR/CSS21/generate.html#propdef-list-style |
|
| 1874 | + * @param $val |
|
| 1875 | + */ |
|
| 1876 | + function set_list_style($val) { |
|
| 1877 | 1877 | $important = isset($this->_important_props["list_style"]); |
| 1878 | 1878 | $arr = explode(" ", str_replace(",", " ", $val)); |
| 1879 | 1879 | |
| 1880 | 1880 | static $types = array("disc", "circle", "square", "decimal", |
| 1881 | - "decimal-leading-zero", "lower-roman", |
|
| 1882 | - "upper-roman", "lower-greek", "lower-latin", |
|
| 1883 | - "upper-latin", "armenian", "georgian", |
|
| 1884 | - "lower-alpha", "upper-alpha", "hebrew", |
|
| 1885 | - "cjk-ideographic", "hiragana", "katakana", |
|
| 1886 | - "hiragana-iroha", "katakana-iroha", "none"); |
|
| 1881 | + "decimal-leading-zero", "lower-roman", |
|
| 1882 | + "upper-roman", "lower-greek", "lower-latin", |
|
| 1883 | + "upper-latin", "armenian", "georgian", |
|
| 1884 | + "lower-alpha", "upper-alpha", "hebrew", |
|
| 1885 | + "cjk-ideographic", "hiragana", "katakana", |
|
| 1886 | + "hiragana-iroha", "katakana-iroha", "none"); |
|
| 1887 | 1887 | |
| 1888 | 1888 | static $positions = array("inside", "outside"); |
| 1889 | 1889 | |
| 1890 | 1890 | foreach ($arr as $value) { |
| 1891 | - /* http://www.w3.org/TR/CSS21/generate.html#list-style |
|
| 1891 | + /* http://www.w3.org/TR/CSS21/generate.html#list-style |
|
| 1892 | 1892 | * A value of 'none' for the 'list-style' property sets both 'list-style-type' and 'list-style-image' to 'none' |
| 1893 | 1893 | */ |
| 1894 | - if ($value === "none") { |
|
| 1895 | - $this->_set_style("list_style_type", $value, $important); |
|
| 1896 | - $this->_set_style("list_style_image", $value, $important); |
|
| 1894 | + if ($value === "none") { |
|
| 1895 | + $this->_set_style("list_style_type", $value, $important); |
|
| 1896 | + $this->_set_style("list_style_image", $value, $important); |
|
| 1897 | 1897 | continue; |
| 1898 | - } |
|
| 1898 | + } |
|
| 1899 | 1899 | |
| 1900 | - //On setting or merging or inheriting list_style_image as well as list_style_type, |
|
| 1901 | - //and url exists, then url has precedence, otherwise fall back to list_style_type |
|
| 1902 | - //Firefox is wrong here (list_style_image gets overwritten on explicite list_style_type) |
|
| 1903 | - //Internet Explorer 7/8 and dompdf is right. |
|
| 1900 | + //On setting or merging or inheriting list_style_image as well as list_style_type, |
|
| 1901 | + //and url exists, then url has precedence, otherwise fall back to list_style_type |
|
| 1902 | + //Firefox is wrong here (list_style_image gets overwritten on explicite list_style_type) |
|
| 1903 | + //Internet Explorer 7/8 and dompdf is right. |
|
| 1904 | 1904 | |
| 1905 | - if (mb_substr($value, 0, 3) === "url") { |
|
| 1906 | - $this->_set_style("list_style_image", $this->_image($value), $important); |
|
| 1905 | + if (mb_substr($value, 0, 3) === "url") { |
|
| 1906 | + $this->_set_style("list_style_image", $this->_image($value), $important); |
|
| 1907 | 1907 | continue; |
| 1908 | - } |
|
| 1908 | + } |
|
| 1909 | 1909 | |
| 1910 | - if ( in_array($value, $types) ) { |
|
| 1911 | - $this->_set_style("list_style_type", $value, $important); |
|
| 1912 | - } else if ( in_array($value, $positions) ) { |
|
| 1913 | - $this->_set_style("list_style_position", $value, $important); |
|
| 1914 | - } |
|
| 1910 | + if ( in_array($value, $types) ) { |
|
| 1911 | + $this->_set_style("list_style_type", $value, $important); |
|
| 1912 | + } else if ( in_array($value, $positions) ) { |
|
| 1913 | + $this->_set_style("list_style_position", $value, $important); |
|
| 1914 | + } |
|
| 1915 | 1915 | } |
| 1916 | 1916 | |
| 1917 | 1917 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
| 1918 | - $this->_prop_cache["list_style"] = null; |
|
| 1919 | - $this->_props["list_style"] = $val; |
|
| 1920 | - } |
|
| 1918 | + $this->_prop_cache["list_style"] = null; |
|
| 1919 | + $this->_props["list_style"] = $val; |
|
| 1920 | + } |
|
| 1921 | 1921 | |
| 1922 | - /** |
|
| 1923 | - * Generate a string representation of the Style |
|
| 1924 | - * |
|
| 1925 | - * This dumps the entire property array into a string via print_r. Useful |
|
| 1926 | - * for debugging. |
|
| 1927 | - * |
|
| 1928 | - * @return string |
|
| 1929 | - */ |
|
| 1930 | - /*DEBUGCSS print: see below additional debugging util*/ |
|
| 1931 | - function __toString() { |
|
| 1922 | + /** |
|
| 1923 | + * Generate a string representation of the Style |
|
| 1924 | + * |
|
| 1925 | + * This dumps the entire property array into a string via print_r. Useful |
|
| 1926 | + * for debugging. |
|
| 1927 | + * |
|
| 1928 | + * @return string |
|
| 1929 | + */ |
|
| 1930 | + /*DEBUGCSS print: see below additional debugging util*/ |
|
| 1931 | + function __toString() { |
|
| 1932 | 1932 | return print_r(array_merge(array("parent_font_size" => $this->_parent_font_size), |
| 1933 | - $this->_props), true); |
|
| 1934 | - } |
|
| 1933 | + $this->_props), true); |
|
| 1934 | + } |
|
| 1935 | 1935 | |
| 1936 | 1936 | /*DEBUGCSS*/ function debug_print() |
| 1937 | 1937 | /*DEBUGCSS*/ { |
@@ -129,7 +129,6 @@ |
||
| 129 | 129 | * added to the clone. This method is overidden in order to remove |
| 130 | 130 | * frames from the cellmap properly. |
| 131 | 131 | * |
| 132 | - * @param Frame $row |
|
| 133 | 132 | */ |
| 134 | 133 | function split($child = null) { |
| 135 | 134 | |
@@ -133,15 +133,15 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | function split($child = null) { |
| 135 | 135 | |
| 136 | - if ( is_null($child) ) { |
|
| 136 | + if (is_null($child)) { |
|
| 137 | 137 | parent::split(); |
| 138 | 138 | return; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | // If $child is a header or if it is the first non-header row, do |
| 142 | 142 | // not duplicate headers, simply move the table to the next page. |
| 143 | - if ( count($this->_headers) && !in_array($child, $this->_headers, true) && |
|
| 144 | - !in_array($child->get_prev_sibling(), $this->_headers, true) ) { |
|
| 143 | + if (count($this->_headers) && !in_array($child, $this->_headers, true) && |
|
| 144 | + !in_array($child->get_prev_sibling(), $this->_headers, true)) { |
|
| 145 | 145 | |
| 146 | 146 | $first_header = null; |
| 147 | 147 | |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | $new_header = $header->deep_copy(); |
| 152 | 152 | |
| 153 | - if ( is_null($first_header) ) |
|
| 153 | + if (is_null($first_header)) |
|
| 154 | 154 | $first_header = $new_header; |
| 155 | 155 | |
| 156 | 156 | $this->insert_child_before($new_header, $child); |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | parent::split($first_header); |
| 160 | 160 | |
| 161 | - } else if ( in_array($child->get_style()->display, self::$ROW_GROUPS) ) { |
|
| 161 | + } else if (in_array($child->get_style()->display, self::$ROW_GROUPS)) { |
|
| 162 | 162 | |
| 163 | 163 | // Individual rows should have already been handled |
| 164 | 164 | parent::split($child); |
@@ -184,8 +184,8 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | static function find_parent_table(Frame $frame) { |
| 186 | 186 | |
| 187 | - while ( $frame = $frame->get_parent() ) |
|
| 188 | - if ( in_array($frame->get_style()->display, Style::$TABLE_TYPES) ) |
|
| 187 | + while ($frame = $frame->get_parent()) |
|
| 188 | + if (in_array($frame->get_style()->display, Style::$TABLE_TYPES)) |
|
| 189 | 189 | break; |
| 190 | 190 | |
| 191 | 191 | return $frame; |
@@ -237,15 +237,15 @@ discard block |
||
| 237 | 237 | $erroneous_frames = array(); |
| 238 | 238 | $anon_row = false; |
| 239 | 239 | $iter = $this->get_first_child(); |
| 240 | - while ( $iter ) { |
|
| 240 | + while ($iter) { |
|
| 241 | 241 | $child = $iter; |
| 242 | 242 | $iter = $iter->get_next_sibling(); |
| 243 | 243 | |
| 244 | 244 | $display = $child->get_style()->display; |
| 245 | 245 | |
| 246 | - if ( $anon_row ) { |
|
| 246 | + if ($anon_row) { |
|
| 247 | 247 | |
| 248 | - if ( $display === "table-row" ) { |
|
| 248 | + if ($display === "table-row") { |
|
| 249 | 249 | // Add the previous anonymous row |
| 250 | 250 | $this->insert_child_before($table_row, $child); |
| 251 | 251 | |
@@ -261,12 +261,12 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | } else { |
| 263 | 263 | |
| 264 | - if ( $display === "table-row" ) { |
|
| 264 | + if ($display === "table-row") { |
|
| 265 | 265 | $child->normalise(); |
| 266 | 266 | continue; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - if ( $display === "table-cell") { |
|
| 269 | + if ($display === "table-cell") { |
|
| 270 | 270 | // Create an anonymous table row |
| 271 | 271 | $tr = $this->get_node()->ownerDocument->createElement("tr"); |
| 272 | 272 | |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | // Lookup styles for tr tags. If the user wants styles to work |
| 280 | 280 | // better, they should make the tr explicit... I'm not going to |
| 281 | 281 | // try to guess what they intended. |
| 282 | - if ( $tr_style = $css->lookup("tr") ) |
|
| 282 | + if ($tr_style = $css->lookup("tr")) |
|
| 283 | 283 | $style->merge($tr_style); |
| 284 | 284 | |
| 285 | 285 | // Okay, I have absolutely no idea why I need this clone here, but |
@@ -295,27 +295,27 @@ discard block |
||
| 295 | 295 | continue; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - if ( !in_array($display, self::$VALID_CHILDREN) ) { |
|
| 298 | + if (!in_array($display, self::$VALID_CHILDREN)) { |
|
| 299 | 299 | $erroneous_frames[] = $child; |
| 300 | 300 | continue; |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | // Normalise other table parts (i.e. row groups) |
| 304 | 304 | foreach ($child->get_children() as $grandchild) { |
| 305 | - if ( $grandchild->get_style()->display === "table-row" ) |
|
| 305 | + if ($grandchild->get_style()->display === "table-row") |
|
| 306 | 306 | $grandchild->normalise(); |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | // Add headers and footers |
| 310 | - if ( $display === "table-header-group" ) |
|
| 310 | + if ($display === "table-header-group") |
|
| 311 | 311 | $this->_headers[] = $child; |
| 312 | 312 | |
| 313 | - else if ( $display === "table-footer-group" ) |
|
| 313 | + else if ($display === "table-footer-group") |
|
| 314 | 314 | $this->_footers[] = $child; |
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - if ( $anon_row ) { |
|
| 318 | + if ($anon_row) { |
|
| 319 | 319 | // Add the row to the table |
| 320 | 320 | $this->_frame->append_child($table_row); |
| 321 | 321 | $table_row->normalise(); |
@@ -150,8 +150,9 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | $new_header = $header->deep_copy(); |
| 152 | 152 | |
| 153 | - if ( is_null($first_header) ) |
|
| 154 | - $first_header = $new_header; |
|
| 153 | + if ( is_null($first_header) ) { |
|
| 154 | + $first_header = $new_header; |
|
| 155 | + } |
|
| 155 | 156 | |
| 156 | 157 | $this->insert_child_before($new_header, $child); |
| 157 | 158 | } |
@@ -184,9 +185,10 @@ discard block |
||
| 184 | 185 | */ |
| 185 | 186 | static function find_parent_table(Frame $frame) { |
| 186 | 187 | |
| 187 | - while ( $frame = $frame->get_parent() ) |
|
| 188 | - if ( in_array($frame->get_style()->display, Style::$TABLE_TYPES) ) |
|
| 188 | + while ( $frame = $frame->get_parent() ) { |
|
| 189 | + if ( in_array($frame->get_style()->display, Style::$TABLE_TYPES) ) |
|
| 189 | 190 | break; |
| 191 | + } |
|
| 190 | 192 | |
| 191 | 193 | return $frame; |
| 192 | 194 | } |
@@ -279,8 +281,9 @@ discard block |
||
| 279 | 281 | // Lookup styles for tr tags. If the user wants styles to work |
| 280 | 282 | // better, they should make the tr explicit... I'm not going to |
| 281 | 283 | // try to guess what they intended. |
| 282 | - if ( $tr_style = $css->lookup("tr") ) |
|
| 283 | - $style->merge($tr_style); |
|
| 284 | + if ( $tr_style = $css->lookup("tr") ) { |
|
| 285 | + $style->merge($tr_style); |
|
| 286 | + } |
|
| 284 | 287 | |
| 285 | 288 | // Okay, I have absolutely no idea why I need this clone here, but |
| 286 | 289 | // if it's omitted, php (as of 2004-07-28) segfaults. |
@@ -302,16 +305,17 @@ discard block |
||
| 302 | 305 | |
| 303 | 306 | // Normalise other table parts (i.e. row groups) |
| 304 | 307 | foreach ($child->get_children() as $grandchild) { |
| 305 | - if ( $grandchild->get_style()->display === "table-row" ) |
|
| 306 | - $grandchild->normalise(); |
|
| 308 | + if ( $grandchild->get_style()->display === "table-row" ) { |
|
| 309 | + $grandchild->normalise(); |
|
| 310 | + } |
|
| 307 | 311 | } |
| 308 | 312 | |
| 309 | 313 | // Add headers and footers |
| 310 | - if ( $display === "table-header-group" ) |
|
| 311 | - $this->_headers[] = $child; |
|
| 312 | - |
|
| 313 | - else if ( $display === "table-footer-group" ) |
|
| 314 | - $this->_footers[] = $child; |
|
| 314 | + if ( $display === "table-header-group" ) { |
|
| 315 | + $this->_headers[] = $child; |
|
| 316 | + } else if ( $display === "table-footer-group" ) { |
|
| 317 | + $this->_footers[] = $child; |
|
| 318 | + } |
|
| 315 | 319 | } |
| 316 | 320 | } |
| 317 | 321 | |
@@ -322,8 +326,9 @@ discard block |
||
| 322 | 326 | $this->_cellmap->add_row(); |
| 323 | 327 | } |
| 324 | 328 | |
| 325 | - foreach ($erroneous_frames as $frame) |
|
| 326 | - $this->move_after($frame); |
|
| 329 | + foreach ($erroneous_frames as $frame) { |
|
| 330 | + $this->move_after($frame); |
|
| 331 | + } |
|
| 327 | 332 | |
| 328 | 333 | } |
| 329 | 334 | |
@@ -1,41 +1,40 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
| 4 | - * |
|
| 5 | - * File: $RCSfile: table_frame_decorator.cls.php,v $ |
|
| 6 | - * Created on: 2004-06-04 |
|
| 7 | - * |
|
| 8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
| 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.dompdf.com/ |
|
| 32 | - * |
|
| 33 | - * @link http://www.dompdf.com/ |
|
| 34 | - * @copyright 2004 Benj Carson |
|
| 35 | - * @author Benj Carson <[email protected]> |
|
| 36 | - * @package dompdf |
|
| 37 | - |
|
| 38 | - */ |
|
| 3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
| 4 | + * |
|
| 5 | + * File: $RCSfile: table_frame_decorator.cls.php,v $ |
|
| 6 | + * Created on: 2004-06-04 |
|
| 7 | + * |
|
| 8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
| 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.dompdf.com/ |
|
| 32 | + * |
|
| 33 | + * @link http://www.dompdf.com/ |
|
| 34 | + * @copyright 2004 Benj Carson |
|
| 35 | + * @author Benj Carson <[email protected]> |
|
| 36 | + * @package dompdf |
|
| 37 | + */ |
|
| 39 | 38 | |
| 40 | 39 | /* $Id: table_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
| 41 | 40 | |
@@ -46,73 +45,73 @@ discard block |
||
| 46 | 45 | * @package dompdf |
| 47 | 46 | */ |
| 48 | 47 | class Table_Frame_Decorator extends Frame_Decorator { |
| 49 | - static $VALID_CHILDREN = array("table-row-group", |
|
| 50 | - "table-row", |
|
| 51 | - "table-header-group", |
|
| 52 | - "table-footer-group", |
|
| 53 | - "table-column", |
|
| 54 | - "table-column-group", |
|
| 55 | - "table-caption", |
|
| 56 | - "table-cell"); |
|
| 57 | - |
|
| 58 | - static $ROW_GROUPS = array('table-row-group', |
|
| 59 | - 'table-header-group', |
|
| 60 | - 'table-footer-group'); |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * The Cellmap object for this table. The cellmap maps table cells |
|
| 64 | - * to rows and columns, and aids in calculating column widths. |
|
| 65 | - * |
|
| 66 | - * @var Cellmap |
|
| 67 | - */ |
|
| 68 | - protected $_cellmap; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * The minimum width of the table, in pt |
|
| 72 | - * |
|
| 73 | - * @var float |
|
| 74 | - */ |
|
| 75 | - protected $_min_width; |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * The maximum width of the table, in pt |
|
| 79 | - * |
|
| 80 | - * @var float |
|
| 81 | - */ |
|
| 82 | - protected $_max_width; |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * Table header rows. Each table header is duplicated when a table |
|
| 86 | - * spans pages. |
|
| 87 | - * |
|
| 88 | - * @var array |
|
| 89 | - */ |
|
| 90 | - protected $_headers; |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * Table footer rows. Each table footer is duplicated when a table |
|
| 94 | - * spans pages. |
|
| 95 | - * |
|
| 96 | - * @var array |
|
| 97 | - */ |
|
| 98 | - protected $_footers; |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * Class constructor |
|
| 102 | - * |
|
| 103 | - * @param Frame $frame the frame to decorate |
|
| 104 | - */ |
|
| 105 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
| 48 | + static $VALID_CHILDREN = array("table-row-group", |
|
| 49 | + "table-row", |
|
| 50 | + "table-header-group", |
|
| 51 | + "table-footer-group", |
|
| 52 | + "table-column", |
|
| 53 | + "table-column-group", |
|
| 54 | + "table-caption", |
|
| 55 | + "table-cell"); |
|
| 56 | + |
|
| 57 | + static $ROW_GROUPS = array('table-row-group', |
|
| 58 | + 'table-header-group', |
|
| 59 | + 'table-footer-group'); |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * The Cellmap object for this table. The cellmap maps table cells |
|
| 63 | + * to rows and columns, and aids in calculating column widths. |
|
| 64 | + * |
|
| 65 | + * @var Cellmap |
|
| 66 | + */ |
|
| 67 | + protected $_cellmap; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * The minimum width of the table, in pt |
|
| 71 | + * |
|
| 72 | + * @var float |
|
| 73 | + */ |
|
| 74 | + protected $_min_width; |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * The maximum width of the table, in pt |
|
| 78 | + * |
|
| 79 | + * @var float |
|
| 80 | + */ |
|
| 81 | + protected $_max_width; |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * Table header rows. Each table header is duplicated when a table |
|
| 85 | + * spans pages. |
|
| 86 | + * |
|
| 87 | + * @var array |
|
| 88 | + */ |
|
| 89 | + protected $_headers; |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * Table footer rows. Each table footer is duplicated when a table |
|
| 93 | + * spans pages. |
|
| 94 | + * |
|
| 95 | + * @var array |
|
| 96 | + */ |
|
| 97 | + protected $_footers; |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * Class constructor |
|
| 101 | + * |
|
| 102 | + * @param Frame $frame the frame to decorate |
|
| 103 | + */ |
|
| 104 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
| 106 | 105 | parent::__construct($frame, $dompdf); |
| 107 | 106 | $this->_cellmap = new Cellmap($this); |
| 108 | 107 | $this->_min_width = null; |
| 109 | 108 | $this->_max_width = null; |
| 110 | 109 | $this->_headers = array(); |
| 111 | 110 | $this->_footers = array(); |
| 112 | - } |
|
| 111 | + } |
|
| 113 | 112 | |
| 114 | 113 | |
| 115 | - function reset() { |
|
| 114 | + function reset() { |
|
| 116 | 115 | parent::reset(); |
| 117 | 116 | $this->_cellmap->reset(); |
| 118 | 117 | $this->_min_width = null; |
@@ -120,22 +119,22 @@ discard block |
||
| 120 | 119 | $this->_headers = array(); |
| 121 | 120 | $this->_footers = array(); |
| 122 | 121 | $this->_reflower->reset(); |
| 123 | - } |
|
| 122 | + } |
|
| 124 | 123 | |
| 125 | - //........................................................................ |
|
| 124 | + //........................................................................ |
|
| 126 | 125 | |
| 127 | - /** |
|
| 128 | - * split the table at $row. $row and all subsequent rows will be |
|
| 129 | - * added to the clone. This method is overidden in order to remove |
|
| 130 | - * frames from the cellmap properly. |
|
| 131 | - * |
|
| 132 | - * @param Frame $row |
|
| 133 | - */ |
|
| 134 | - function split($child = null) { |
|
| 126 | + /** |
|
| 127 | + * split the table at $row. $row and all subsequent rows will be |
|
| 128 | + * added to the clone. This method is overidden in order to remove |
|
| 129 | + * frames from the cellmap properly. |
|
| 130 | + * |
|
| 131 | + * @param Frame $row |
|
| 132 | + */ |
|
| 133 | + function split($child = null) { |
|
| 135 | 134 | |
| 136 | 135 | if ( is_null($child) ) { |
| 137 | - parent::split(); |
|
| 138 | - return; |
|
| 136 | + parent::split(); |
|
| 137 | + return; |
|
| 139 | 138 | } |
| 140 | 139 | |
| 141 | 140 | // If $child is a header or if it is the first non-header row, do |
@@ -143,200 +142,200 @@ discard block |
||
| 143 | 142 | if ( count($this->_headers) && !in_array($child, $this->_headers, true) && |
| 144 | 143 | !in_array($child->get_prev_sibling(), $this->_headers, true) ) { |
| 145 | 144 | |
| 146 | - $first_header = null; |
|
| 145 | + $first_header = null; |
|
| 147 | 146 | |
| 148 | - // Insert copies of the table headers before $child |
|
| 149 | - foreach ($this->_headers as $header) { |
|
| 147 | + // Insert copies of the table headers before $child |
|
| 148 | + foreach ($this->_headers as $header) { |
|
| 150 | 149 | |
| 151 | 150 | $new_header = $header->deep_copy(); |
| 152 | 151 | |
| 153 | 152 | if ( is_null($first_header) ) |
| 154 | - $first_header = $new_header; |
|
| 153 | + $first_header = $new_header; |
|
| 155 | 154 | |
| 156 | 155 | $this->insert_child_before($new_header, $child); |
| 157 | - } |
|
| 156 | + } |
|
| 158 | 157 | |
| 159 | - parent::split($first_header); |
|
| 158 | + parent::split($first_header); |
|
| 160 | 159 | |
| 161 | 160 | } else if ( in_array($child->get_style()->display, self::$ROW_GROUPS) ) { |
| 162 | 161 | |
| 163 | - // Individual rows should have already been handled |
|
| 164 | - parent::split($child); |
|
| 162 | + // Individual rows should have already been handled |
|
| 163 | + parent::split($child); |
|
| 165 | 164 | |
| 166 | 165 | } else { |
| 167 | 166 | |
| 168 | - $iter = $child; |
|
| 167 | + $iter = $child; |
|
| 169 | 168 | |
| 170 | - while ($iter) { |
|
| 169 | + while ($iter) { |
|
| 171 | 170 | $this->_cellmap->remove_row($iter); |
| 172 | 171 | $iter = $iter->get_next_sibling(); |
| 173 | - } |
|
| 172 | + } |
|
| 174 | 173 | |
| 175 | - parent::split($child); |
|
| 174 | + parent::split($child); |
|
| 175 | + } |
|
| 176 | 176 | } |
| 177 | - } |
|
| 178 | 177 | |
| 179 | - /** |
|
| 180 | - * Static function to locate the parent table of a frame |
|
| 181 | - * |
|
| 182 | - * @param Frame $frame |
|
| 183 | - * @return Frame the table that is an ancestor of $frame |
|
| 184 | - */ |
|
| 185 | - static function find_parent_table(Frame $frame) { |
|
| 178 | + /** |
|
| 179 | + * Static function to locate the parent table of a frame |
|
| 180 | + * |
|
| 181 | + * @param Frame $frame |
|
| 182 | + * @return Frame the table that is an ancestor of $frame |
|
| 183 | + */ |
|
| 184 | + static function find_parent_table(Frame $frame) { |
|
| 186 | 185 | |
| 187 | 186 | while ( $frame = $frame->get_parent() ) |
| 188 | - if ( in_array($frame->get_style()->display, Style::$TABLE_TYPES) ) |
|
| 187 | + if ( in_array($frame->get_style()->display, Style::$TABLE_TYPES) ) |
|
| 189 | 188 | break; |
| 190 | 189 | |
| 191 | 190 | return $frame; |
| 192 | - } |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * Return this table's Cellmap |
|
| 196 | - * |
|
| 197 | - * @return Cellmap |
|
| 198 | - */ |
|
| 199 | - function get_cellmap() { return $this->_cellmap; } |
|
| 200 | - |
|
| 201 | - /** |
|
| 202 | - * Return the minimum width of this table |
|
| 203 | - * |
|
| 204 | - * @return float |
|
| 205 | - */ |
|
| 206 | - function get_min_width() { return $this->_min_width; } |
|
| 207 | - |
|
| 208 | - /** |
|
| 209 | - * Return the maximum width of this table |
|
| 210 | - * |
|
| 211 | - * @return float |
|
| 212 | - */ |
|
| 213 | - function get_max_width() { return $this->_max_width; } |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * Set the minimum width of the table |
|
| 217 | - * |
|
| 218 | - * @param float $width the new minimum width |
|
| 219 | - */ |
|
| 220 | - function set_min_width($width) { $this->_min_width = $width; } |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * Set the maximum width of the table |
|
| 224 | - * |
|
| 225 | - * @param float $width the new maximum width |
|
| 226 | - */ |
|
| 227 | - function set_max_width($width) { $this->_max_width = $width; } |
|
| 228 | - |
|
| 229 | - /** |
|
| 230 | - * Restructure tree so that the table has the correct structure. |
|
| 231 | - * Invalid children (i.e. all non-table-rows) are moved below the |
|
| 232 | - * table. |
|
| 233 | - */ |
|
| 234 | - function normalise() { |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + /** |
|
| 194 | + * Return this table's Cellmap |
|
| 195 | + * |
|
| 196 | + * @return Cellmap |
|
| 197 | + */ |
|
| 198 | + function get_cellmap() { return $this->_cellmap; } |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * Return the minimum width of this table |
|
| 202 | + * |
|
| 203 | + * @return float |
|
| 204 | + */ |
|
| 205 | + function get_min_width() { return $this->_min_width; } |
|
| 206 | + |
|
| 207 | + /** |
|
| 208 | + * Return the maximum width of this table |
|
| 209 | + * |
|
| 210 | + * @return float |
|
| 211 | + */ |
|
| 212 | + function get_max_width() { return $this->_max_width; } |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * Set the minimum width of the table |
|
| 216 | + * |
|
| 217 | + * @param float $width the new minimum width |
|
| 218 | + */ |
|
| 219 | + function set_min_width($width) { $this->_min_width = $width; } |
|
| 220 | + |
|
| 221 | + /** |
|
| 222 | + * Set the maximum width of the table |
|
| 223 | + * |
|
| 224 | + * @param float $width the new maximum width |
|
| 225 | + */ |
|
| 226 | + function set_max_width($width) { $this->_max_width = $width; } |
|
| 227 | + |
|
| 228 | + /** |
|
| 229 | + * Restructure tree so that the table has the correct structure. |
|
| 230 | + * Invalid children (i.e. all non-table-rows) are moved below the |
|
| 231 | + * table. |
|
| 232 | + */ |
|
| 233 | + function normalise() { |
|
| 235 | 234 | |
| 236 | 235 | // Store frames generated by invalid tags and move them outside the table |
| 237 | 236 | $erroneous_frames = array(); |
| 238 | 237 | $anon_row = false; |
| 239 | 238 | $iter = $this->get_first_child(); |
| 240 | 239 | while ( $iter ) { |
| 241 | - $child = $iter; |
|
| 242 | - $iter = $iter->get_next_sibling(); |
|
| 240 | + $child = $iter; |
|
| 241 | + $iter = $iter->get_next_sibling(); |
|
| 243 | 242 | |
| 244 | - $display = $child->get_style()->display; |
|
| 243 | + $display = $child->get_style()->display; |
|
| 245 | 244 | |
| 246 | - if ( $anon_row ) { |
|
| 245 | + if ( $anon_row ) { |
|
| 247 | 246 | |
| 248 | 247 | if ( $display === "table-row" ) { |
| 249 | - // Add the previous anonymous row |
|
| 250 | - $this->insert_child_before($table_row, $child); |
|
| 248 | + // Add the previous anonymous row |
|
| 249 | + $this->insert_child_before($table_row, $child); |
|
| 251 | 250 | |
| 252 | - $table_row->normalise(); |
|
| 253 | - $child->normalise(); |
|
| 254 | - $anon_row = false; |
|
| 255 | - continue; |
|
| 251 | + $table_row->normalise(); |
|
| 252 | + $child->normalise(); |
|
| 253 | + $anon_row = false; |
|
| 254 | + continue; |
|
| 256 | 255 | } |
| 257 | 256 | |
| 258 | 257 | // add the child to the anonymous row |
| 259 | 258 | $table_row->append_child($child); |
| 260 | 259 | continue; |
| 261 | 260 | |
| 262 | - } else { |
|
| 261 | + } else { |
|
| 263 | 262 | |
| 264 | 263 | if ( $display === "table-row" ) { |
| 265 | - $child->normalise(); |
|
| 266 | - continue; |
|
| 264 | + $child->normalise(); |
|
| 265 | + continue; |
|
| 267 | 266 | } |
| 268 | 267 | |
| 269 | 268 | if ( $display === "table-cell") { |
| 270 | - // Create an anonymous table row |
|
| 271 | - $tr = $this->get_node()->ownerDocument->createElement("tr"); |
|
| 269 | + // Create an anonymous table row |
|
| 270 | + $tr = $this->get_node()->ownerDocument->createElement("tr"); |
|
| 272 | 271 | |
| 273 | - $frame = new Frame($tr); |
|
| 272 | + $frame = new Frame($tr); |
|
| 274 | 273 | |
| 275 | - $css = $this->get_style()->get_stylesheet(); |
|
| 276 | - $style = $css->create_style(); |
|
| 277 | - $style->inherit($this->get_style()); |
|
| 274 | + $css = $this->get_style()->get_stylesheet(); |
|
| 275 | + $style = $css->create_style(); |
|
| 276 | + $style->inherit($this->get_style()); |
|
| 278 | 277 | |
| 279 | - // Lookup styles for tr tags. If the user wants styles to work |
|
| 280 | - // better, they should make the tr explicit... I'm not going to |
|
| 281 | - // try to guess what they intended. |
|
| 282 | - if ( $tr_style = $css->lookup("tr") ) |
|
| 278 | + // Lookup styles for tr tags. If the user wants styles to work |
|
| 279 | + // better, they should make the tr explicit... I'm not going to |
|
| 280 | + // try to guess what they intended. |
|
| 281 | + if ( $tr_style = $css->lookup("tr") ) |
|
| 283 | 282 | $style->merge($tr_style); |
| 284 | 283 | |
| 285 | - // Okay, I have absolutely no idea why I need this clone here, but |
|
| 286 | - // if it's omitted, php (as of 2004-07-28) segfaults. |
|
| 287 | - $frame->set_style(clone $style); |
|
| 288 | - $table_row = Frame_Factory::decorate_frame($frame, $this->_dompdf); |
|
| 289 | - $table_row->set_root($this->_root); |
|
| 284 | + // Okay, I have absolutely no idea why I need this clone here, but |
|
| 285 | + // if it's omitted, php (as of 2004-07-28) segfaults. |
|
| 286 | + $frame->set_style(clone $style); |
|
| 287 | + $table_row = Frame_Factory::decorate_frame($frame, $this->_dompdf); |
|
| 288 | + $table_row->set_root($this->_root); |
|
| 290 | 289 | |
| 291 | - // Add the cell to the row |
|
| 292 | - $table_row->append_child($child); |
|
| 290 | + // Add the cell to the row |
|
| 291 | + $table_row->append_child($child); |
|
| 293 | 292 | |
| 294 | - $anon_row = true; |
|
| 295 | - continue; |
|
| 293 | + $anon_row = true; |
|
| 294 | + continue; |
|
| 296 | 295 | } |
| 297 | 296 | |
| 298 | 297 | if ( !in_array($display, self::$VALID_CHILDREN) ) { |
| 299 | - $erroneous_frames[] = $child; |
|
| 300 | - continue; |
|
| 298 | + $erroneous_frames[] = $child; |
|
| 299 | + continue; |
|
| 301 | 300 | } |
| 302 | 301 | |
| 303 | 302 | // Normalise other table parts (i.e. row groups) |
| 304 | 303 | foreach ($child->get_children() as $grandchild) { |
| 305 | - if ( $grandchild->get_style()->display === "table-row" ) |
|
| 304 | + if ( $grandchild->get_style()->display === "table-row" ) |
|
| 306 | 305 | $grandchild->normalise(); |
| 307 | 306 | } |
| 308 | 307 | |
| 309 | 308 | // Add headers and footers |
| 310 | 309 | if ( $display === "table-header-group" ) |
| 311 | - $this->_headers[] = $child; |
|
| 310 | + $this->_headers[] = $child; |
|
| 312 | 311 | |
| 313 | 312 | else if ( $display === "table-footer-group" ) |
| 314 | - $this->_footers[] = $child; |
|
| 315 | - } |
|
| 313 | + $this->_footers[] = $child; |
|
| 314 | + } |
|
| 316 | 315 | } |
| 317 | 316 | |
| 318 | 317 | if ( $anon_row ) { |
| 319 | - // Add the row to the table |
|
| 320 | - $this->_frame->append_child($table_row); |
|
| 321 | - $table_row->normalise(); |
|
| 322 | - $this->_cellmap->add_row(); |
|
| 318 | + // Add the row to the table |
|
| 319 | + $this->_frame->append_child($table_row); |
|
| 320 | + $table_row->normalise(); |
|
| 321 | + $this->_cellmap->add_row(); |
|
| 323 | 322 | } |
| 324 | 323 | |
| 325 | 324 | foreach ($erroneous_frames as $frame) |
| 326 | - $this->move_after($frame); |
|
| 325 | + $this->move_after($frame); |
|
| 327 | 326 | |
| 328 | - } |
|
| 327 | + } |
|
| 329 | 328 | |
| 330 | - //........................................................................ |
|
| 329 | + //........................................................................ |
|
| 331 | 330 | |
| 332 | - /** |
|
| 333 | - * Moves the specified frame and it's corresponding node outside of |
|
| 334 | - * the table. |
|
| 335 | - * |
|
| 336 | - * @param Frame $frame the frame to move |
|
| 337 | - */ |
|
| 338 | - function move_after(Frame $frame) { |
|
| 331 | + /** |
|
| 332 | + * Moves the specified frame and it's corresponding node outside of |
|
| 333 | + * the table. |
|
| 334 | + * |
|
| 335 | + * @param Frame $frame the frame to move |
|
| 336 | + */ |
|
| 337 | + function move_after(Frame $frame) { |
|
| 339 | 338 | $this->get_parent()->insert_child_after($frame, $this); |
| 340 | - } |
|
| 339 | + } |
|
| 341 | 340 | |
| 342 | 341 | } |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | /** |
| 180 | 180 | * Sets the stroke colour |
| 181 | 181 | * |
| 182 | - * @param array $color |
|
| 182 | + * @param array $colour |
|
| 183 | 183 | */ |
| 184 | 184 | protected function _set_stroke_colour($colour) { |
| 185 | 185 | $colour[0] = round(255 * $colour[0]); |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | /** |
| 197 | 197 | * Sets the fill colour |
| 198 | 198 | * |
| 199 | - * @param array $color |
|
| 199 | + * @param array $colour |
|
| 200 | 200 | */ |
| 201 | 201 | protected function _set_fill_colour($colour) { |
| 202 | 202 | $colour[0] = round(255 * $colour[0]); |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | * @param string $font the font file to use |
| 392 | 392 | * @param float $size the font size, in points |
| 393 | 393 | * @param array $color |
| 394 | - * @param float $adjust word spacing adjustment |
|
| 394 | + * @param integer $adjust word spacing adjustment |
|
| 395 | 395 | */ |
| 396 | 396 | function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0){} |
| 397 | 397 | |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | * @param string $text the text to be sized |
| 422 | 422 | * @param string $font the desired font |
| 423 | 423 | * @param float $size the desired font size |
| 424 | - * @param float $spacing word spacing, if any |
|
| 424 | + * @param integer $spacing word spacing, if any |
|
| 425 | 425 | * @return float |
| 426 | 426 | */ |
| 427 | 427 | function get_text_width($text, $font, $size, $spacing = 0){} |
@@ -34,7 +34,6 @@ discard block |
||
| 34 | 34 | * @copyright 2004 Benj Carson |
| 35 | 35 | * @author Benj Carson <[email protected]> |
| 36 | 36 | * @package dompdf |
| 37 | - |
|
| 38 | 37 | */ |
| 39 | 38 | |
| 40 | 39 | /* $Id: tcpdf_adapter.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */ |
@@ -57,98 +56,98 @@ discard block |
||
| 57 | 56 | */ |
| 58 | 57 | class TCPDF_Adapter implements Canvas { |
| 59 | 58 | |
| 60 | - /** |
|
| 61 | - * Dimensions of paper sizes in points |
|
| 62 | - * |
|
| 63 | - * @var array; |
|
| 64 | - */ |
|
| 65 | - static public $PAPER_SIZES = array(); // Set to |
|
| 59 | + /** |
|
| 60 | + * Dimensions of paper sizes in points |
|
| 61 | + * |
|
| 62 | + * @var array; |
|
| 63 | + */ |
|
| 64 | + static public $PAPER_SIZES = array(); // Set to |
|
| 66 | 65 | // CPDF_Adapter::$PAPER_SIZES below. |
| 67 | 66 | |
| 68 | 67 | |
| 69 | - /** |
|
| 70 | - * Instance of the TCPDF class |
|
| 71 | - * |
|
| 72 | - * @var TCPDF |
|
| 73 | - */ |
|
| 74 | - private $_pdf; |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * PDF width in points |
|
| 78 | - * |
|
| 79 | - * @var float |
|
| 80 | - */ |
|
| 81 | - private $_width; |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * PDF height in points |
|
| 85 | - * |
|
| 86 | - * @var float |
|
| 87 | - */ |
|
| 88 | - private $_height; |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * Last fill colour used |
|
| 92 | - * |
|
| 93 | - * @var array |
|
| 94 | - */ |
|
| 95 | - private $_last_fill_color; |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * Last stroke colour used |
|
| 99 | - * |
|
| 100 | - * @var array |
|
| 101 | - */ |
|
| 102 | - private $_last_stroke_color; |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * Last line width used |
|
| 106 | - * |
|
| 107 | - * @var float |
|
| 108 | - */ |
|
| 109 | - private $_last_line_width; |
|
| 68 | + /** |
|
| 69 | + * Instance of the TCPDF class |
|
| 70 | + * |
|
| 71 | + * @var TCPDF |
|
| 72 | + */ |
|
| 73 | + private $_pdf; |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * PDF width in points |
|
| 77 | + * |
|
| 78 | + * @var float |
|
| 79 | + */ |
|
| 80 | + private $_width; |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * PDF height in points |
|
| 84 | + * |
|
| 85 | + * @var float |
|
| 86 | + */ |
|
| 87 | + private $_height; |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * Last fill colour used |
|
| 91 | + * |
|
| 92 | + * @var array |
|
| 93 | + */ |
|
| 94 | + private $_last_fill_color; |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * Last stroke colour used |
|
| 98 | + * |
|
| 99 | + * @var array |
|
| 100 | + */ |
|
| 101 | + private $_last_stroke_color; |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Last line width used |
|
| 105 | + * |
|
| 106 | + * @var float |
|
| 107 | + */ |
|
| 108 | + private $_last_line_width; |
|
| 110 | 109 | |
| 111 | - /** |
|
| 112 | - * Total number of pages |
|
| 113 | - * |
|
| 114 | - * @var int |
|
| 115 | - */ |
|
| 116 | - private $_page_count; |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * Text to display on every page |
|
| 120 | - * |
|
| 121 | - * @var array |
|
| 122 | - */ |
|
| 123 | - private $_page_text; |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * Array of pages for accessing after initial rendering is complete |
|
| 127 | - * |
|
| 128 | - * @var array |
|
| 129 | - */ |
|
| 130 | - private $_pages; |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * Class constructor |
|
| 134 | - * |
|
| 135 | - * @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or |
|
| 136 | - * an array(xmin,ymin,xmax,ymax) |
|
| 137 | - * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
|
| 138 | - */ |
|
| 139 | - function __construct($paper = "letter", $orientation = "portrait") { |
|
| 110 | + /** |
|
| 111 | + * Total number of pages |
|
| 112 | + * |
|
| 113 | + * @var int |
|
| 114 | + */ |
|
| 115 | + private $_page_count; |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * Text to display on every page |
|
| 119 | + * |
|
| 120 | + * @var array |
|
| 121 | + */ |
|
| 122 | + private $_page_text; |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Array of pages for accessing after initial rendering is complete |
|
| 126 | + * |
|
| 127 | + * @var array |
|
| 128 | + */ |
|
| 129 | + private $_pages; |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Class constructor |
|
| 133 | + * |
|
| 134 | + * @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or |
|
| 135 | + * an array(xmin,ymin,xmax,ymax) |
|
| 136 | + * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
|
| 137 | + */ |
|
| 138 | + function __construct($paper = "letter", $orientation = "portrait") { |
|
| 140 | 139 | |
| 141 | 140 | if ( is_array($paper) ) |
| 142 | - $size = $paper; |
|
| 141 | + $size = $paper; |
|
| 143 | 142 | else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) |
| 144 | - $size = self::$PAPER_SIZE[$paper]; |
|
| 143 | + $size = self::$PAPER_SIZE[$paper]; |
|
| 145 | 144 | else |
| 146 | - $size = self::$PAPER_SIZE["letter"]; |
|
| 145 | + $size = self::$PAPER_SIZE["letter"]; |
|
| 147 | 146 | |
| 148 | 147 | if ( mb_strtolower($orientation) === "landscape" ) { |
| 149 | - $a = $size[3]; |
|
| 150 | - $size[3] = $size[2]; |
|
| 151 | - $size[2] = $a; |
|
| 148 | + $a = $size[3]; |
|
| 149 | + $size[3] = $size[2]; |
|
| 150 | + $size[2] = $a; |
|
| 152 | 151 | } |
| 153 | 152 | |
| 154 | 153 | $this->_width = $size[2] - $size[0]; |
@@ -163,135 +162,135 @@ discard block |
||
| 163 | 162 | $this->_page_text = array(); |
| 164 | 163 | |
| 165 | 164 | $this->_last_fill_color = |
| 166 | - $this->_last_stroke_color = |
|
| 167 | - $this->_last_line_width = null; |
|
| 165 | + $this->_last_stroke_color = |
|
| 166 | + $this->_last_line_width = null; |
|
| 168 | 167 | |
| 169 | - } |
|
| 168 | + } |
|
| 170 | 169 | |
| 171 | - /** |
|
| 172 | - * Remaps y coords from 4th to 1st quadrant |
|
| 173 | - * |
|
| 174 | - * @param float $y |
|
| 175 | - * @return float |
|
| 176 | - */ |
|
| 177 | - protected function y($y) { return $this->_height - $y; } |
|
| 178 | - |
|
| 179 | - /** |
|
| 180 | - * Sets the stroke colour |
|
| 181 | - * |
|
| 182 | - * @param array $color |
|
| 183 | - */ |
|
| 184 | - protected function _set_stroke_colour($colour) { |
|
| 170 | + /** |
|
| 171 | + * Remaps y coords from 4th to 1st quadrant |
|
| 172 | + * |
|
| 173 | + * @param float $y |
|
| 174 | + * @return float |
|
| 175 | + */ |
|
| 176 | + protected function y($y) { return $this->_height - $y; } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * Sets the stroke colour |
|
| 180 | + * |
|
| 181 | + * @param array $color |
|
| 182 | + */ |
|
| 183 | + protected function _set_stroke_colour($colour) { |
|
| 185 | 184 | $colour[0] = round(255 * $colour[0]); |
| 186 | 185 | $colour[1] = round(255 * $colour[1]); |
| 187 | 186 | $colour[2] = round(255 * $colour[2]); |
| 188 | 187 | |
| 189 | 188 | if ( is_null($this->_last_stroke_color) || $color != $this->_last_stroke_color ) { |
| 190 | - $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]); |
|
| 191 | - $this->_last_stroke_color = $color; |
|
| 189 | + $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]); |
|
| 190 | + $this->_last_stroke_color = $color; |
|
| 192 | 191 | } |
| 193 | 192 | |
| 194 | - } |
|
| 193 | + } |
|
| 195 | 194 | |
| 196 | - /** |
|
| 197 | - * Sets the fill colour |
|
| 198 | - * |
|
| 199 | - * @param array $color |
|
| 200 | - */ |
|
| 201 | - protected function _set_fill_colour($colour) { |
|
| 195 | + /** |
|
| 196 | + * Sets the fill colour |
|
| 197 | + * |
|
| 198 | + * @param array $color |
|
| 199 | + */ |
|
| 200 | + protected function _set_fill_colour($colour) { |
|
| 202 | 201 | $colour[0] = round(255 * $colour[0]); |
| 203 | 202 | $colour[1] = round(255 * $colour[1]); |
| 204 | 203 | $colour[2] = round(255 * $colour[2]); |
| 205 | 204 | |
| 206 | 205 | if ( is_null($this->_last_fill_color) || $color != $this->_last_fill_color ) { |
| 207 | - $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]); |
|
| 208 | - $this->_last_fill_color = $color; |
|
| 206 | + $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]); |
|
| 207 | + $this->_last_fill_color = $color; |
|
| 209 | 208 | } |
| 210 | 209 | |
| 211 | - } |
|
| 210 | + } |
|
| 212 | 211 | |
| 213 | - /** |
|
| 214 | - * Return the TCPDF instance |
|
| 215 | - * |
|
| 216 | - * @return TCPDF |
|
| 217 | - */ |
|
| 218 | - function get_tcpdf() { return $this->_pdf; } |
|
| 212 | + /** |
|
| 213 | + * Return the TCPDF instance |
|
| 214 | + * |
|
| 215 | + * @return TCPDF |
|
| 216 | + */ |
|
| 217 | + function get_tcpdf() { return $this->_pdf; } |
|
| 219 | 218 | |
| 220 | - /** |
|
| 221 | - * Returns the current page number |
|
| 222 | - * |
|
| 223 | - * @return int |
|
| 224 | - */ |
|
| 225 | - function get_page_number() { |
|
| 219 | + /** |
|
| 220 | + * Returns the current page number |
|
| 221 | + * |
|
| 222 | + * @return int |
|
| 223 | + */ |
|
| 224 | + function get_page_number() { |
|
| 226 | 225 | return $this->_page_number; |
| 227 | - } |
|
| 228 | - |
|
| 229 | - /** |
|
| 230 | - * Returns the total number of pages |
|
| 231 | - * |
|
| 232 | - * @return int |
|
| 233 | - */ |
|
| 234 | - function get_page_count() { |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + /** |
|
| 229 | + * Returns the total number of pages |
|
| 230 | + * |
|
| 231 | + * @return int |
|
| 232 | + */ |
|
| 233 | + function get_page_count() { |
|
| 235 | 234 | return $this->_page_count; |
| 236 | - } |
|
| 237 | - |
|
| 238 | - /** |
|
| 239 | - * Sets the total number of pages |
|
| 240 | - * |
|
| 241 | - * @param int $count |
|
| 242 | - */ |
|
| 243 | - function set_page_count($count) { |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + /** |
|
| 238 | + * Sets the total number of pages |
|
| 239 | + * |
|
| 240 | + * @param int $count |
|
| 241 | + */ |
|
| 242 | + function set_page_count($count) { |
|
| 244 | 243 | $this->_page_count = (int)$count; |
| 245 | - } |
|
| 246 | - |
|
| 247 | - /** |
|
| 248 | - * Draws a line from x1,y1 to x2,y2 |
|
| 249 | - * |
|
| 250 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
| 251 | - * See {@link Cpdf::setLineStyle()} for a description of the format of the |
|
| 252 | - * $style parameter (aka dash). |
|
| 253 | - * |
|
| 254 | - * @param float $x1 |
|
| 255 | - * @param float $y1 |
|
| 256 | - * @param float $x2 |
|
| 257 | - * @param float $y2 |
|
| 258 | - * @param array $color |
|
| 259 | - * @param float $width |
|
| 260 | - * @param array $style |
|
| 261 | - */ |
|
| 262 | - function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + /** |
|
| 247 | + * Draws a line from x1,y1 to x2,y2 |
|
| 248 | + * |
|
| 249 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
| 250 | + * See {@link Cpdf::setLineStyle()} for a description of the format of the |
|
| 251 | + * $style parameter (aka dash). |
|
| 252 | + * |
|
| 253 | + * @param float $x1 |
|
| 254 | + * @param float $y1 |
|
| 255 | + * @param float $x2 |
|
| 256 | + * @param float $y2 |
|
| 257 | + * @param array $color |
|
| 258 | + * @param float $width |
|
| 259 | + * @param array $style |
|
| 260 | + */ |
|
| 261 | + function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
|
| 263 | 262 | |
| 264 | 263 | if ( is_null($this->_last_line_width) || $width != $this->_last_line_width ) { |
| 265 | - $this->_pdf->SetLineWidth($width); |
|
| 266 | - $this->_last_line_width = $width; |
|
| 264 | + $this->_pdf->SetLineWidth($width); |
|
| 265 | + $this->_last_line_width = $width; |
|
| 267 | 266 | } |
| 268 | 267 | |
| 269 | 268 | $this->_set_stroke_colour($color); |
| 270 | 269 | |
| 271 | 270 | // FIXME: ugh, need to handle different styles here |
| 272 | 271 | $this->_pdf->line($x1, $y1, $x2, $y2); |
| 273 | - } |
|
| 274 | - |
|
| 275 | - /** |
|
| 276 | - * Draws a rectangle at x1,y1 with width w and height h |
|
| 277 | - * |
|
| 278 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
| 279 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
| 280 | - * parameter (aka dash) |
|
| 281 | - * |
|
| 282 | - * @param float $x1 |
|
| 283 | - * @param float $y1 |
|
| 284 | - * @param float $w |
|
| 285 | - * @param float $h |
|
| 286 | - * @param array $color |
|
| 287 | - * @param float $width |
|
| 288 | - * @param array $style |
|
| 289 | - */ |
|
| 290 | - function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + /** |
|
| 275 | + * Draws a rectangle at x1,y1 with width w and height h |
|
| 276 | + * |
|
| 277 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
| 278 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
| 279 | + * parameter (aka dash) |
|
| 280 | + * |
|
| 281 | + * @param float $x1 |
|
| 282 | + * @param float $y1 |
|
| 283 | + * @param float $w |
|
| 284 | + * @param float $h |
|
| 285 | + * @param array $color |
|
| 286 | + * @param float $width |
|
| 287 | + * @param array $style |
|
| 288 | + */ |
|
| 289 | + function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
|
| 291 | 290 | |
| 292 | 291 | if ( is_null($this->_last_line_width) || $width != $this->_last_line_width ) { |
| 293 | - $this->_pdf->SetLineWidth($width); |
|
| 294 | - $this->_last_line_width = $width; |
|
| 292 | + $this->_pdf->SetLineWidth($width); |
|
| 293 | + $this->_last_line_width = $width; |
|
| 295 | 294 | } |
| 296 | 295 | |
| 297 | 296 | $this->_set_stroke_colour($color); |
@@ -299,165 +298,165 @@ discard block |
||
| 299 | 298 | // FIXME: ugh, need to handle styles here |
| 300 | 299 | $this->_pdf->rect($x1, $y1, $w, $h); |
| 301 | 300 | |
| 302 | - } |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * Draws a filled rectangle at x1,y1 with width w and height h |
|
| 306 | - * |
|
| 307 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
| 308 | - * |
|
| 309 | - * @param float $x1 |
|
| 310 | - * @param float $y1 |
|
| 311 | - * @param float $w |
|
| 312 | - * @param float $h |
|
| 313 | - * @param array $color |
|
| 314 | - */ |
|
| 315 | - function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * Draws a filled rectangle at x1,y1 with width w and height h |
|
| 305 | + * |
|
| 306 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
| 307 | + * |
|
| 308 | + * @param float $x1 |
|
| 309 | + * @param float $y1 |
|
| 310 | + * @param float $w |
|
| 311 | + * @param float $h |
|
| 312 | + * @param array $color |
|
| 313 | + */ |
|
| 314 | + function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
| 316 | 315 | |
| 317 | 316 | $this->_set_fill_colour($color); |
| 318 | 317 | |
| 319 | 318 | // FIXME: ugh, need to handle styles here |
| 320 | 319 | $this->_pdf->rect($x1, $y1, $w, $h, "F"); |
| 321 | - } |
|
| 322 | - |
|
| 323 | - /** |
|
| 324 | - * Draws a polygon |
|
| 325 | - * |
|
| 326 | - * The polygon is formed by joining all the points stored in the $points |
|
| 327 | - * array. $points has the following structure: |
|
| 328 | - * <code> |
|
| 329 | - * array(0 => x1, |
|
| 330 | - * 1 => y1, |
|
| 331 | - * 2 => x2, |
|
| 332 | - * 3 => y2, |
|
| 333 | - * ... |
|
| 334 | - * ); |
|
| 335 | - * </code> |
|
| 336 | - * |
|
| 337 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
| 338 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
| 339 | - * parameter (aka dash) |
|
| 340 | - * |
|
| 341 | - * @param array $points |
|
| 342 | - * @param array $color |
|
| 343 | - * @param float $width |
|
| 344 | - * @param array $style |
|
| 345 | - * @param bool $fill Fills the polygon if true |
|
| 346 | - */ |
|
| 347 | - function polygon($points, $color, $width = null, $style = null, $fill = false) { |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + /** |
|
| 323 | + * Draws a polygon |
|
| 324 | + * |
|
| 325 | + * The polygon is formed by joining all the points stored in the $points |
|
| 326 | + * array. $points has the following structure: |
|
| 327 | + * <code> |
|
| 328 | + * array(0 => x1, |
|
| 329 | + * 1 => y1, |
|
| 330 | + * 2 => x2, |
|
| 331 | + * 3 => y2, |
|
| 332 | + * ... |
|
| 333 | + * ); |
|
| 334 | + * </code> |
|
| 335 | + * |
|
| 336 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
| 337 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
| 338 | + * parameter (aka dash) |
|
| 339 | + * |
|
| 340 | + * @param array $points |
|
| 341 | + * @param array $color |
|
| 342 | + * @param float $width |
|
| 343 | + * @param array $style |
|
| 344 | + * @param bool $fill Fills the polygon if true |
|
| 345 | + */ |
|
| 346 | + function polygon($points, $color, $width = null, $style = null, $fill = false) { |
|
| 348 | 347 | // FIXME: FPDF sucks |
| 349 | - } |
|
| 350 | - |
|
| 351 | - /** |
|
| 352 | - * Draws a circle at $x,$y with radius $r |
|
| 353 | - * |
|
| 354 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
| 355 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
| 356 | - * parameter (aka dash) |
|
| 357 | - * |
|
| 358 | - * @param float $x |
|
| 359 | - * @param float $y |
|
| 360 | - * @param float $r |
|
| 361 | - * @param array $color |
|
| 362 | - * @param float $width |
|
| 363 | - * @param array $style |
|
| 364 | - * @param bool $fill Fills the circle if true |
|
| 365 | - */ |
|
| 366 | - function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false){} |
|
| 367 | - |
|
| 368 | - /** |
|
| 369 | - * Add an image to the pdf. |
|
| 370 | - * |
|
| 371 | - * The image is placed at the specified x and y coordinates with the |
|
| 372 | - * given width and height. |
|
| 373 | - * |
|
| 374 | - * @param string $img_url the path to the image |
|
| 375 | - * @param string $img_type the type (e.g. extension) of the image |
|
| 376 | - * @param float $x x position |
|
| 377 | - * @param float $y y position |
|
| 378 | - * @param int $w width (in pixels) |
|
| 379 | - * @param int $h height (in pixels) |
|
| 380 | - */ |
|
| 381 | - function image($img_url, $img_type, $x, $y, $w, $h){} |
|
| 382 | - |
|
| 383 | - /** |
|
| 384 | - * Writes text at the specified x and y coordinates |
|
| 385 | - * |
|
| 386 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
| 387 | - * |
|
| 388 | - * @param float $x |
|
| 389 | - * @param float $y |
|
| 390 | - * @param string $text the text to write |
|
| 391 | - * @param string $font the font file to use |
|
| 392 | - * @param float $size the font size, in points |
|
| 393 | - * @param array $color |
|
| 394 | - * @param float $adjust word spacing adjustment |
|
| 395 | - */ |
|
| 396 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0){} |
|
| 397 | - |
|
| 398 | - function javascript($code){} |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + /** |
|
| 351 | + * Draws a circle at $x,$y with radius $r |
|
| 352 | + * |
|
| 353 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
| 354 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
| 355 | + * parameter (aka dash) |
|
| 356 | + * |
|
| 357 | + * @param float $x |
|
| 358 | + * @param float $y |
|
| 359 | + * @param float $r |
|
| 360 | + * @param array $color |
|
| 361 | + * @param float $width |
|
| 362 | + * @param array $style |
|
| 363 | + * @param bool $fill Fills the circle if true |
|
| 364 | + */ |
|
| 365 | + function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false){} |
|
| 366 | + |
|
| 367 | + /** |
|
| 368 | + * Add an image to the pdf. |
|
| 369 | + * |
|
| 370 | + * The image is placed at the specified x and y coordinates with the |
|
| 371 | + * given width and height. |
|
| 372 | + * |
|
| 373 | + * @param string $img_url the path to the image |
|
| 374 | + * @param string $img_type the type (e.g. extension) of the image |
|
| 375 | + * @param float $x x position |
|
| 376 | + * @param float $y y position |
|
| 377 | + * @param int $w width (in pixels) |
|
| 378 | + * @param int $h height (in pixels) |
|
| 379 | + */ |
|
| 380 | + function image($img_url, $img_type, $x, $y, $w, $h){} |
|
| 381 | + |
|
| 382 | + /** |
|
| 383 | + * Writes text at the specified x and y coordinates |
|
| 384 | + * |
|
| 385 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
| 386 | + * |
|
| 387 | + * @param float $x |
|
| 388 | + * @param float $y |
|
| 389 | + * @param string $text the text to write |
|
| 390 | + * @param string $font the font file to use |
|
| 391 | + * @param float $size the font size, in points |
|
| 392 | + * @param array $color |
|
| 393 | + * @param float $adjust word spacing adjustment |
|
| 394 | + */ |
|
| 395 | + function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0){} |
|
| 396 | + |
|
| 397 | + function javascript($code){} |
|
| 399 | 398 | |
| 400 | - /** |
|
| 401 | - * Add a named destination (similar to <a name="foo">...</a> in html) |
|
| 402 | - * |
|
| 403 | - * @param string $anchorname The name of the named destination |
|
| 404 | - */ |
|
| 405 | - function add_named_dest($anchorname){} |
|
| 406 | - |
|
| 407 | - /** |
|
| 408 | - * Add a link to the pdf |
|
| 409 | - * |
|
| 410 | - * @param string $url The url to link to |
|
| 411 | - * @param float $x The x position of the link |
|
| 412 | - * @param float $y The y position of the link |
|
| 413 | - * @param float $width The width of the link |
|
| 414 | - * @param float $height The height of the link |
|
| 415 | - */ |
|
| 416 | - function add_link($url, $x, $y, $width, $height){} |
|
| 399 | + /** |
|
| 400 | + * Add a named destination (similar to <a name="foo">...</a> in html) |
|
| 401 | + * |
|
| 402 | + * @param string $anchorname The name of the named destination |
|
| 403 | + */ |
|
| 404 | + function add_named_dest($anchorname){} |
|
| 405 | + |
|
| 406 | + /** |
|
| 407 | + * Add a link to the pdf |
|
| 408 | + * |
|
| 409 | + * @param string $url The url to link to |
|
| 410 | + * @param float $x The x position of the link |
|
| 411 | + * @param float $y The y position of the link |
|
| 412 | + * @param float $width The width of the link |
|
| 413 | + * @param float $height The height of the link |
|
| 414 | + */ |
|
| 415 | + function add_link($url, $x, $y, $width, $height){} |
|
| 417 | 416 | |
| 418 | - /** |
|
| 419 | - * Calculates text size, in points |
|
| 420 | - * |
|
| 421 | - * @param string $text the text to be sized |
|
| 422 | - * @param string $font the desired font |
|
| 423 | - * @param float $size the desired font size |
|
| 424 | - * @param float $spacing word spacing, if any |
|
| 425 | - * @return float |
|
| 426 | - */ |
|
| 427 | - function get_text_width($text, $font, $size, $spacing = 0){} |
|
| 428 | - |
|
| 429 | - /** |
|
| 430 | - * Calculates font height, in points |
|
| 431 | - * |
|
| 432 | - * @param string $font |
|
| 433 | - * @param float $size |
|
| 434 | - * @return float |
|
| 435 | - */ |
|
| 436 | - function get_font_height($font, $size){} |
|
| 417 | + /** |
|
| 418 | + * Calculates text size, in points |
|
| 419 | + * |
|
| 420 | + * @param string $text the text to be sized |
|
| 421 | + * @param string $font the desired font |
|
| 422 | + * @param float $size the desired font size |
|
| 423 | + * @param float $spacing word spacing, if any |
|
| 424 | + * @return float |
|
| 425 | + */ |
|
| 426 | + function get_text_width($text, $font, $size, $spacing = 0){} |
|
| 427 | + |
|
| 428 | + /** |
|
| 429 | + * Calculates font height, in points |
|
| 430 | + * |
|
| 431 | + * @param string $font |
|
| 432 | + * @param float $size |
|
| 433 | + * @return float |
|
| 434 | + */ |
|
| 435 | + function get_font_height($font, $size){} |
|
| 437 | 436 | |
| 438 | 437 | |
| 439 | - /** |
|
| 440 | - * Starts a new page |
|
| 441 | - * |
|
| 442 | - * Subsequent drawing operations will appear on the new page. |
|
| 443 | - */ |
|
| 444 | - function new_page(){} |
|
| 445 | - |
|
| 446 | - /** |
|
| 447 | - * Streams the PDF directly to the browser |
|
| 448 | - * |
|
| 449 | - * @param string $filename the name of the PDF file |
|
| 450 | - * @param array $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0 |
|
| 451 | - */ |
|
| 452 | - function stream($filename, $options = null){} |
|
| 453 | - |
|
| 454 | - /** |
|
| 455 | - * Returns the PDF as a string |
|
| 456 | - * |
|
| 457 | - * @param array $options associative array: 'compress' => 1 or 0 |
|
| 458 | - * @return string |
|
| 459 | - */ |
|
| 460 | - function output($options = null){} |
|
| 438 | + /** |
|
| 439 | + * Starts a new page |
|
| 440 | + * |
|
| 441 | + * Subsequent drawing operations will appear on the new page. |
|
| 442 | + */ |
|
| 443 | + function new_page(){} |
|
| 444 | + |
|
| 445 | + /** |
|
| 446 | + * Streams the PDF directly to the browser |
|
| 447 | + * |
|
| 448 | + * @param string $filename the name of the PDF file |
|
| 449 | + * @param array $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0 |
|
| 450 | + */ |
|
| 451 | + function stream($filename, $options = null){} |
|
| 452 | + |
|
| 453 | + /** |
|
| 454 | + * Returns the PDF as a string |
|
| 455 | + * |
|
| 456 | + * @param array $options associative array: 'compress' => 1 or 0 |
|
| 457 | + * @return string |
|
| 458 | + */ |
|
| 459 | + function output($options = null){} |
|
| 461 | 460 | |
| 462 | 461 | } |
| 463 | 462 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | /* $Id: tcpdf_adapter.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */ |
| 41 | 41 | |
| 42 | -require_once(DOMPDF_LIB_DIR . '/tcpdf/tcpdf.php'); |
|
| 42 | +require_once(DOMPDF_LIB_DIR.'/tcpdf/tcpdf.php'); |
|
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * TCPDF PDF Rendering interface |
@@ -138,14 +138,14 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | function __construct($paper = "letter", $orientation = "portrait") { |
| 140 | 140 | |
| 141 | - if ( is_array($paper) ) |
|
| 141 | + if (is_array($paper)) |
|
| 142 | 142 | $size = $paper; |
| 143 | - else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) |
|
| 143 | + else if (isset(self::$PAPER_SIZES[mb_strtolower($paper)])) |
|
| 144 | 144 | $size = self::$PAPER_SIZE[$paper]; |
| 145 | 145 | else |
| 146 | 146 | $size = self::$PAPER_SIZE["letter"]; |
| 147 | 147 | |
| 148 | - if ( mb_strtolower($orientation) === "landscape" ) { |
|
| 148 | + if (mb_strtolower($orientation) === "landscape") { |
|
| 149 | 149 | $a = $size[3]; |
| 150 | 150 | $size[3] = $size[2]; |
| 151 | 151 | $size[2] = $a; |
@@ -186,8 +186,8 @@ discard block |
||
| 186 | 186 | $colour[1] = round(255 * $colour[1]); |
| 187 | 187 | $colour[2] = round(255 * $colour[2]); |
| 188 | 188 | |
| 189 | - if ( is_null($this->_last_stroke_color) || $color != $this->_last_stroke_color ) { |
|
| 190 | - $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]); |
|
| 189 | + if (is_null($this->_last_stroke_color) || $color != $this->_last_stroke_color) { |
|
| 190 | + $this->_pdf->SetDrawColor($color[0], $color[1], $color[2]); |
|
| 191 | 191 | $this->_last_stroke_color = $color; |
| 192 | 192 | } |
| 193 | 193 | |
@@ -203,8 +203,8 @@ discard block |
||
| 203 | 203 | $colour[1] = round(255 * $colour[1]); |
| 204 | 204 | $colour[2] = round(255 * $colour[2]); |
| 205 | 205 | |
| 206 | - if ( is_null($this->_last_fill_color) || $color != $this->_last_fill_color ) { |
|
| 207 | - $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]); |
|
| 206 | + if (is_null($this->_last_fill_color) || $color != $this->_last_fill_color) { |
|
| 207 | + $this->_pdf->SetDrawColor($color[0], $color[1], $color[2]); |
|
| 208 | 208 | $this->_last_fill_color = $color; |
| 209 | 209 | } |
| 210 | 210 | |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * @param int $count |
| 242 | 242 | */ |
| 243 | 243 | function set_page_count($count) { |
| 244 | - $this->_page_count = (int)$count; |
|
| 244 | + $this->_page_count = (int) $count; |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | */ |
| 262 | 262 | function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
| 263 | 263 | |
| 264 | - if ( is_null($this->_last_line_width) || $width != $this->_last_line_width ) { |
|
| 264 | + if (is_null($this->_last_line_width) || $width != $this->_last_line_width) { |
|
| 265 | 265 | $this->_pdf->SetLineWidth($width); |
| 266 | 266 | $this->_last_line_width = $width; |
| 267 | 267 | } |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | */ |
| 290 | 290 | function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
| 291 | 291 | |
| 292 | - if ( is_null($this->_last_line_width) || $width != $this->_last_line_width ) { |
|
| 292 | + if (is_null($this->_last_line_width) || $width != $this->_last_line_width) { |
|
| 293 | 293 | $this->_pdf->SetLineWidth($width); |
| 294 | 294 | $this->_last_line_width = $width; |
| 295 | 295 | } |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | * @param array $style |
| 364 | 364 | * @param bool $fill Fills the circle if true |
| 365 | 365 | */ |
| 366 | - function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false){} |
|
| 366 | + function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) {} |
|
| 367 | 367 | |
| 368 | 368 | /** |
| 369 | 369 | * Add an image to the pdf. |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | * @param int $w width (in pixels) |
| 379 | 379 | * @param int $h height (in pixels) |
| 380 | 380 | */ |
| 381 | - function image($img_url, $img_type, $x, $y, $w, $h){} |
|
| 381 | + function image($img_url, $img_type, $x, $y, $w, $h) {} |
|
| 382 | 382 | |
| 383 | 383 | /** |
| 384 | 384 | * Writes text at the specified x and y coordinates |
@@ -393,16 +393,16 @@ discard block |
||
| 393 | 393 | * @param array $color |
| 394 | 394 | * @param float $adjust word spacing adjustment |
| 395 | 395 | */ |
| 396 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0){} |
|
| 396 | + function text($x, $y, $text, $font, $size, $color = array(0, 0, 0), $adjust = 0) {} |
|
| 397 | 397 | |
| 398 | - function javascript($code){} |
|
| 398 | + function javascript($code) {} |
|
| 399 | 399 | |
| 400 | 400 | /** |
| 401 | 401 | * Add a named destination (similar to <a name="foo">...</a> in html) |
| 402 | 402 | * |
| 403 | 403 | * @param string $anchorname The name of the named destination |
| 404 | 404 | */ |
| 405 | - function add_named_dest($anchorname){} |
|
| 405 | + function add_named_dest($anchorname) {} |
|
| 406 | 406 | |
| 407 | 407 | /** |
| 408 | 408 | * Add a link to the pdf |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | * @param float $width The width of the link |
| 414 | 414 | * @param float $height The height of the link |
| 415 | 415 | */ |
| 416 | - function add_link($url, $x, $y, $width, $height){} |
|
| 416 | + function add_link($url, $x, $y, $width, $height) {} |
|
| 417 | 417 | |
| 418 | 418 | /** |
| 419 | 419 | * Calculates text size, in points |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | * @param float $spacing word spacing, if any |
| 425 | 425 | * @return float |
| 426 | 426 | */ |
| 427 | - function get_text_width($text, $font, $size, $spacing = 0){} |
|
| 427 | + function get_text_width($text, $font, $size, $spacing = 0) {} |
|
| 428 | 428 | |
| 429 | 429 | /** |
| 430 | 430 | * Calculates font height, in points |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | * @param float $size |
| 434 | 434 | * @return float |
| 435 | 435 | */ |
| 436 | - function get_font_height($font, $size){} |
|
| 436 | + function get_font_height($font, $size) {} |
|
| 437 | 437 | |
| 438 | 438 | |
| 439 | 439 | /** |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | * |
| 442 | 442 | * Subsequent drawing operations will appear on the new page. |
| 443 | 443 | */ |
| 444 | - function new_page(){} |
|
| 444 | + function new_page() {} |
|
| 445 | 445 | |
| 446 | 446 | /** |
| 447 | 447 | * Streams the PDF directly to the browser |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | * @param string $filename the name of the PDF file |
| 450 | 450 | * @param array $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0 |
| 451 | 451 | */ |
| 452 | - function stream($filename, $options = null){} |
|
| 452 | + function stream($filename, $options = null) {} |
|
| 453 | 453 | |
| 454 | 454 | /** |
| 455 | 455 | * Returns the PDF as a string |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | * @param array $options associative array: 'compress' => 1 or 0 |
| 458 | 458 | * @return string |
| 459 | 459 | */ |
| 460 | - function output($options = null){} |
|
| 460 | + function output($options = null) {} |
|
| 461 | 461 | |
| 462 | 462 | } |
| 463 | 463 | |
@@ -138,12 +138,13 @@ |
||
| 138 | 138 | */ |
| 139 | 139 | function __construct($paper = "letter", $orientation = "portrait") { |
| 140 | 140 | |
| 141 | - if ( is_array($paper) ) |
|
| 142 | - $size = $paper; |
|
| 143 | - else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) |
|
| 144 | - $size = self::$PAPER_SIZE[$paper]; |
|
| 145 | - else |
|
| 146 | - $size = self::$PAPER_SIZE["letter"]; |
|
| 141 | + if ( is_array($paper) ) { |
|
| 142 | + $size = $paper; |
|
| 143 | + } else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) { |
|
| 144 | + $size = self::$PAPER_SIZE[$paper]; |
|
| 145 | + } else { |
|
| 146 | + $size = self::$PAPER_SIZE["letter"]; |
|
| 147 | + } |
|
| 147 | 148 | |
| 148 | 149 | if ( mb_strtolower($orientation) === "landscape" ) { |
| 149 | 150 | $a = $size[3]; |