@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | * LoggerLoggingEvent are filled when actually needed. |
| 118 | 118 | * |
| 119 | 119 | * @param string $fqcn name of the caller class. |
| 120 | - * @param mixed $logger The {@link Logger} category of this event or the logger name. |
|
| 120 | + * @param Logger $logger The {@link Logger} category of this event or the logger name. |
|
| 121 | 121 | * @param LoggerLevel $priority The level of this event. |
| 122 | 122 | * @param mixed $message The message of this event. |
| 123 | 123 | * @param integer $timeStamp the timestamp of this logging event. |
@@ -249,6 +249,7 @@ discard block |
||
| 249 | 249 | /** |
| 250 | 250 | * Returns the the context corresponding to the <code>key</code> |
| 251 | 251 | * parameter. |
| 252 | + * @param string $key |
|
| 252 | 253 | * @return string |
| 253 | 254 | */ |
| 254 | 255 | public function getMDC($key) { |
@@ -304,7 +305,7 @@ discard block |
||
| 304 | 305 | |
| 305 | 306 | /** |
| 306 | 307 | * Calculates the time of this event. |
| 307 | - * @return the time after event starttime when this event has occured |
|
| 308 | + * @return string time after event starttime when this event has occured |
|
| 308 | 309 | */ |
| 309 | 310 | public function getTime() { |
| 310 | 311 | $eventTime = (float)$this->getTimeStamp(); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function __construct($fqcn, $logger, $priority, $message, $timeStamp = null) { |
| 126 | 126 | $this->fqcn = $fqcn; |
| 127 | - if($logger instanceof Logger) { |
|
| 127 | + if ($logger instanceof Logger) { |
|
| 128 | 128 | $this->logger = $logger; |
| 129 | 129 | $this->categoryName = $logger->getName(); |
| 130 | 130 | } else { |
@@ -132,10 +132,10 @@ discard block |
||
| 132 | 132 | } |
| 133 | 133 | $this->level = $priority; |
| 134 | 134 | $this->message = $message; |
| 135 | - if($timeStamp !== null && is_float($timeStamp)) { |
|
| 135 | + if ($timeStamp !== null && is_float($timeStamp)) { |
|
| 136 | 136 | $this->timeStamp = $timeStamp; |
| 137 | 137 | } else { |
| 138 | - if(function_exists('microtime')) { |
|
| 138 | + if (function_exists('microtime')) { |
|
| 139 | 139 | // get microtime as float |
| 140 | 140 | $this->timeStamp = microtime(true); |
| 141 | 141 | } else { |
@@ -154,20 +154,20 @@ discard block |
||
| 154 | 154 | * @return LoggerLocationInfo |
| 155 | 155 | */ |
| 156 | 156 | public function getLocationInformation() { |
| 157 | - if($this->locationInfo === null) { |
|
| 157 | + if ($this->locationInfo === null) { |
|
| 158 | 158 | |
| 159 | 159 | $locationInfo = array(); |
| 160 | 160 | |
| 161 | - if(function_exists('debug_backtrace')) { |
|
| 161 | + if (function_exists('debug_backtrace')) { |
|
| 162 | 162 | $trace = debug_backtrace(); |
| 163 | 163 | $prevHop = null; |
| 164 | 164 | // make a downsearch to identify the caller |
| 165 | 165 | $hop = array_pop($trace); |
| 166 | - while($hop !== null) { |
|
| 167 | - if(isset($hop['class'])) { |
|
| 166 | + while ($hop !== null) { |
|
| 167 | + if (isset($hop['class'])) { |
|
| 168 | 168 | // we are sometimes in functions = no class available: avoid php warning here |
| 169 | 169 | $className = strtolower($hop['class']); |
| 170 | - if(!empty($className) and ($className == 'logger' or $className == 'loggercategory' or |
|
| 170 | + if (!empty($className) and ($className == 'logger' or $className == 'loggercategory' or |
|
| 171 | 171 | strtolower(get_parent_class($className)) == 'logger' or |
| 172 | 172 | strtolower(get_parent_class($className)) == 'loggercategory')) { |
| 173 | 173 | $locationInfo['line'] = $hop['line']; |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | $hop = array_pop($trace); |
| 180 | 180 | } |
| 181 | 181 | $locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main'; |
| 182 | - if(isset($prevHop['function']) and |
|
| 182 | + if (isset($prevHop['function']) and |
|
| 183 | 183 | $prevHop['function'] !== 'include' and |
| 184 | 184 | $prevHop['function'] !== 'include_once' and |
| 185 | 185 | $prevHop['function'] !== 'require' and |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | * @return mixed |
| 225 | 225 | */ |
| 226 | 226 | public function getMessage() { |
| 227 | - if($this->message !== null) { |
|
| 227 | + if ($this->message !== null) { |
|
| 228 | 228 | return $this->message; |
| 229 | 229 | } else { |
| 230 | 230 | return $this->getRenderedMessage(); |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | * @return string |
| 240 | 240 | */ |
| 241 | 241 | public function getNDC() { |
| 242 | - if($this->ndcLookupRequired) { |
|
| 242 | + if ($this->ndcLookupRequired) { |
|
| 243 | 243 | $this->ndcLookupRequired = false; |
| 244 | 244 | $this->ndc = implode(' ', LoggerNDC::get()); |
| 245 | 245 | } |
@@ -260,8 +260,8 @@ discard block |
||
| 260 | 260 | * @return string |
| 261 | 261 | */ |
| 262 | 262 | public function getRenderedMessage() { |
| 263 | - if($this->renderedMessage === null and $this->message !== null) { |
|
| 264 | - if(is_string($this->message)) { |
|
| 263 | + if ($this->renderedMessage === null and $this->message !== null) { |
|
| 264 | + if (is_string($this->message)) { |
|
| 265 | 265 | $this->renderedMessage = $this->message; |
| 266 | 266 | } else { |
| 267 | 267 | // $this->logger might be null or an instance of Logger or RootLogger |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | // TODO: Logger::getHierarchy() is marked @deprecated! |
| 271 | 271 | $repository = Logger::getHierarchy(); |
| 272 | 272 | $rendererMap = $repository->getRendererMap(); |
| 273 | - $this->renderedMessage= $rendererMap->findAndRender($this->message); |
|
| 273 | + $this->renderedMessage = $rendererMap->findAndRender($this->message); |
|
| 274 | 274 | } |
| 275 | 275 | } |
| 276 | 276 | return $this->renderedMessage; |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | * @static |
| 285 | 285 | */ |
| 286 | 286 | public static function getStartTime() { |
| 287 | - if(!isset(self::$startTime)) { |
|
| 287 | + if (!isset(self::$startTime)) { |
|
| 288 | 288 | if (function_exists('microtime')) { |
| 289 | 289 | // microtime as float |
| 290 | 290 | self::$startTime = microtime(true); |
@@ -307,8 +307,8 @@ discard block |
||
| 307 | 307 | * @return the time after event starttime when this event has occured |
| 308 | 308 | */ |
| 309 | 309 | public function getTime() { |
| 310 | - $eventTime = (float)$this->getTimeStamp(); |
|
| 311 | - $eventStartTime = (float)LoggerLoggingEvent::getStartTime(); |
|
| 310 | + $eventTime = (float) $this->getTimeStamp(); |
|
| 311 | + $eventStartTime = (float) LoggerLoggingEvent::getStartTime(); |
|
| 312 | 312 | return number_format(($eventTime - $eventStartTime) * 1000, 0, '', ''); |
| 313 | 313 | } |
| 314 | 314 | |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | */ |
| 318 | 318 | public function getThreadName() { |
| 319 | 319 | if ($this->threadName === null) { |
| 320 | - $this->threadName = (string)getmypid(); |
|
| 320 | + $this->threadName = (string) getmypid(); |
|
| 321 | 321 | } |
| 322 | 322 | return $this->threadName; |
| 323 | 323 | } |
@@ -26,334 +26,334 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | class LoggerLoggingEvent { |
| 28 | 28 | |
| 29 | - private static $startTime; |
|
| 29 | + private static $startTime; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var string Fully Qualified Class Name of the calling category class. |
|
| 33 | - */ |
|
| 34 | - private $fqcn; |
|
| 31 | + /** |
|
| 32 | + * @var string Fully Qualified Class Name of the calling category class. |
|
| 33 | + */ |
|
| 34 | + private $fqcn; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var Logger reference |
|
| 38 | - */ |
|
| 39 | - private $logger = null; |
|
| 36 | + /** |
|
| 37 | + * @var Logger reference |
|
| 38 | + */ |
|
| 39 | + private $logger = null; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * The category (logger) name. |
|
| 43 | - * This field will be marked as private in future |
|
| 44 | - * releases. Please do not access it directly. |
|
| 45 | - * Use the {@link getLoggerName()} method instead. |
|
| 46 | - * @deprecated |
|
| 47 | - */ |
|
| 48 | - private $categoryName; |
|
| 41 | + /** |
|
| 42 | + * The category (logger) name. |
|
| 43 | + * This field will be marked as private in future |
|
| 44 | + * releases. Please do not access it directly. |
|
| 45 | + * Use the {@link getLoggerName()} method instead. |
|
| 46 | + * @deprecated |
|
| 47 | + */ |
|
| 48 | + private $categoryName; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Level of logging event. |
|
| 52 | - * <p> This field should not be accessed directly. You shoud use the |
|
| 53 | - * {@link getLevel()} method instead. |
|
| 54 | - * |
|
| 55 | - * @deprecated |
|
| 56 | - * @var LoggerLevel |
|
| 57 | - */ |
|
| 58 | - protected $level; |
|
| 50 | + /** |
|
| 51 | + * Level of logging event. |
|
| 52 | + * <p> This field should not be accessed directly. You shoud use the |
|
| 53 | + * {@link getLevel()} method instead. |
|
| 54 | + * |
|
| 55 | + * @deprecated |
|
| 56 | + * @var LoggerLevel |
|
| 57 | + */ |
|
| 58 | + protected $level; |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @var string The nested diagnostic context (NDC) of logging event. |
|
| 62 | - */ |
|
| 63 | - private $ndc; |
|
| 60 | + /** |
|
| 61 | + * @var string The nested diagnostic context (NDC) of logging event. |
|
| 62 | + */ |
|
| 63 | + private $ndc; |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Have we tried to do an NDC lookup? If we did, there is no need |
|
| 67 | - * to do it again. Note that its value is always false when |
|
| 68 | - * serialized. Thus, a receiving SocketNode will never use it's own |
|
| 69 | - * (incorrect) NDC. See also writeObject method. |
|
| 70 | - * @var boolean |
|
| 71 | - */ |
|
| 72 | - private $ndcLookupRequired = true; |
|
| 65 | + /** |
|
| 66 | + * Have we tried to do an NDC lookup? If we did, there is no need |
|
| 67 | + * to do it again. Note that its value is always false when |
|
| 68 | + * serialized. Thus, a receiving SocketNode will never use it's own |
|
| 69 | + * (incorrect) NDC. See also writeObject method. |
|
| 70 | + * @var boolean |
|
| 71 | + */ |
|
| 72 | + private $ndcLookupRequired = true; |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Have we tried to do an MDC lookup? If we did, there is no need |
|
| 76 | - * to do it again. Note that its value is always false when |
|
| 77 | - * serialized. See also the getMDC and getMDCCopy methods. |
|
| 78 | - * @var boolean |
|
| 79 | - */ |
|
| 80 | - private $mdcCopyLookupRequired = true; |
|
| 74 | + /** |
|
| 75 | + * Have we tried to do an MDC lookup? If we did, there is no need |
|
| 76 | + * to do it again. Note that its value is always false when |
|
| 77 | + * serialized. See also the getMDC and getMDCCopy methods. |
|
| 78 | + * @var boolean |
|
| 79 | + */ |
|
| 80 | + private $mdcCopyLookupRequired = true; |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * @var mixed The application supplied message of logging event. |
|
| 84 | - */ |
|
| 85 | - private $message; |
|
| 82 | + /** |
|
| 83 | + * @var mixed The application supplied message of logging event. |
|
| 84 | + */ |
|
| 85 | + private $message; |
|
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * The application supplied message rendered through the log4php |
|
| 89 | - * objet rendering mechanism. At present renderedMessage == message. |
|
| 90 | - * @var string |
|
| 91 | - */ |
|
| 92 | - private $renderedMessage = null; |
|
| 87 | + /** |
|
| 88 | + * The application supplied message rendered through the log4php |
|
| 89 | + * objet rendering mechanism. At present renderedMessage == message. |
|
| 90 | + * @var string |
|
| 91 | + */ |
|
| 92 | + private $renderedMessage = null; |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * The name of thread in which this logging event was generated. |
|
| 96 | - * log4php saves here the process id via {@link PHP_MANUAL#getmypid getmypid()} |
|
| 97 | - * @var mixed |
|
| 98 | - */ |
|
| 99 | - private $threadName = null; |
|
| 94 | + /** |
|
| 95 | + * The name of thread in which this logging event was generated. |
|
| 96 | + * log4php saves here the process id via {@link PHP_MANUAL#getmypid getmypid()} |
|
| 97 | + * @var mixed |
|
| 98 | + */ |
|
| 99 | + private $threadName = null; |
|
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * The number of seconds elapsed from 1/1/1970 until logging event |
|
| 103 | - * was created plus microseconds if available. |
|
| 104 | - * @var float |
|
| 105 | - */ |
|
| 106 | - public $timeStamp; |
|
| 101 | + /** |
|
| 102 | + * The number of seconds elapsed from 1/1/1970 until logging event |
|
| 103 | + * was created plus microseconds if available. |
|
| 104 | + * @var float |
|
| 105 | + */ |
|
| 106 | + public $timeStamp; |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * @var LoggerLocationInfo Location information for the caller. |
|
| 110 | - */ |
|
| 111 | - private $locationInfo = null; |
|
| 108 | + /** |
|
| 109 | + * @var LoggerLocationInfo Location information for the caller. |
|
| 110 | + */ |
|
| 111 | + private $locationInfo = null; |
|
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * Instantiate a LoggingEvent from the supplied parameters. |
|
| 115 | - * |
|
| 116 | - * <p>Except {@link $timeStamp} all the other fields of |
|
| 117 | - * LoggerLoggingEvent are filled when actually needed. |
|
| 118 | - * |
|
| 119 | - * @param string $fqcn name of the caller class. |
|
| 120 | - * @param mixed $logger The {@link Logger} category of this event or the logger name. |
|
| 121 | - * @param LoggerLevel $priority The level of this event. |
|
| 122 | - * @param mixed $message The message of this event. |
|
| 123 | - * @param integer $timeStamp the timestamp of this logging event. |
|
| 124 | - */ |
|
| 125 | - public function __construct($fqcn, $logger, $priority, $message, $timeStamp = null) { |
|
| 126 | - $this->fqcn = $fqcn; |
|
| 127 | - if($logger instanceof Logger) { |
|
| 128 | - $this->logger = $logger; |
|
| 129 | - $this->categoryName = $logger->getName(); |
|
| 130 | - } else { |
|
| 131 | - $this->categoryName = strval($logger); |
|
| 132 | - } |
|
| 133 | - $this->level = $priority; |
|
| 134 | - $this->message = $message; |
|
| 135 | - if($timeStamp !== null && is_float($timeStamp)) { |
|
| 136 | - $this->timeStamp = $timeStamp; |
|
| 137 | - } else { |
|
| 138 | - if(function_exists('microtime')) { |
|
| 139 | - // get microtime as float |
|
| 140 | - $this->timeStamp = microtime(true); |
|
| 141 | - } else { |
|
| 142 | - $this->timeStamp = floatval(time()); |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - } |
|
| 113 | + /** |
|
| 114 | + * Instantiate a LoggingEvent from the supplied parameters. |
|
| 115 | + * |
|
| 116 | + * <p>Except {@link $timeStamp} all the other fields of |
|
| 117 | + * LoggerLoggingEvent are filled when actually needed. |
|
| 118 | + * |
|
| 119 | + * @param string $fqcn name of the caller class. |
|
| 120 | + * @param mixed $logger The {@link Logger} category of this event or the logger name. |
|
| 121 | + * @param LoggerLevel $priority The level of this event. |
|
| 122 | + * @param mixed $message The message of this event. |
|
| 123 | + * @param integer $timeStamp the timestamp of this logging event. |
|
| 124 | + */ |
|
| 125 | + public function __construct($fqcn, $logger, $priority, $message, $timeStamp = null) { |
|
| 126 | + $this->fqcn = $fqcn; |
|
| 127 | + if($logger instanceof Logger) { |
|
| 128 | + $this->logger = $logger; |
|
| 129 | + $this->categoryName = $logger->getName(); |
|
| 130 | + } else { |
|
| 131 | + $this->categoryName = strval($logger); |
|
| 132 | + } |
|
| 133 | + $this->level = $priority; |
|
| 134 | + $this->message = $message; |
|
| 135 | + if($timeStamp !== null && is_float($timeStamp)) { |
|
| 136 | + $this->timeStamp = $timeStamp; |
|
| 137 | + } else { |
|
| 138 | + if(function_exists('microtime')) { |
|
| 139 | + // get microtime as float |
|
| 140 | + $this->timeStamp = microtime(true); |
|
| 141 | + } else { |
|
| 142 | + $this->timeStamp = floatval(time()); |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - /** |
|
| 148 | - * Set the location information for this logging event. The collected |
|
| 149 | - * information is cached for future use. |
|
| 150 | - * |
|
| 151 | - * <p>This method uses {@link PHP_MANUAL#debug_backtrace debug_backtrace()} function (if exists) |
|
| 152 | - * to collect informations about caller.</p> |
|
| 153 | - * <p>It only recognize informations generated by {@link Logger} and its subclasses.</p> |
|
| 154 | - * @return LoggerLocationInfo |
|
| 155 | - */ |
|
| 156 | - public function getLocationInformation() { |
|
| 157 | - if($this->locationInfo === null) { |
|
| 147 | + /** |
|
| 148 | + * Set the location information for this logging event. The collected |
|
| 149 | + * information is cached for future use. |
|
| 150 | + * |
|
| 151 | + * <p>This method uses {@link PHP_MANUAL#debug_backtrace debug_backtrace()} function (if exists) |
|
| 152 | + * to collect informations about caller.</p> |
|
| 153 | + * <p>It only recognize informations generated by {@link Logger} and its subclasses.</p> |
|
| 154 | + * @return LoggerLocationInfo |
|
| 155 | + */ |
|
| 156 | + public function getLocationInformation() { |
|
| 157 | + if($this->locationInfo === null) { |
|
| 158 | 158 | |
| 159 | - $locationInfo = array(); |
|
| 159 | + $locationInfo = array(); |
|
| 160 | 160 | |
| 161 | - if(function_exists('debug_backtrace')) { |
|
| 162 | - $trace = debug_backtrace(); |
|
| 163 | - $prevHop = null; |
|
| 164 | - // make a downsearch to identify the caller |
|
| 165 | - $hop = array_pop($trace); |
|
| 166 | - while($hop !== null) { |
|
| 167 | - if(isset($hop['class'])) { |
|
| 168 | - // we are sometimes in functions = no class available: avoid php warning here |
|
| 169 | - $className = strtolower($hop['class']); |
|
| 170 | - if(!empty($className) and ($className == 'logger' or $className == 'loggercategory' or |
|
| 171 | - strtolower(get_parent_class($className)) == 'logger' or |
|
| 172 | - strtolower(get_parent_class($className)) == 'loggercategory')) { |
|
| 173 | - $locationInfo['line'] = $hop['line']; |
|
| 174 | - $locationInfo['file'] = $hop['file']; |
|
| 175 | - break; |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - $prevHop = $hop; |
|
| 179 | - $hop = array_pop($trace); |
|
| 180 | - } |
|
| 181 | - $locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main'; |
|
| 182 | - if(isset($prevHop['function']) and |
|
| 183 | - $prevHop['function'] !== 'include' and |
|
| 184 | - $prevHop['function'] !== 'include_once' and |
|
| 185 | - $prevHop['function'] !== 'require' and |
|
| 186 | - $prevHop['function'] !== 'require_once') { |
|
| 161 | + if(function_exists('debug_backtrace')) { |
|
| 162 | + $trace = debug_backtrace(); |
|
| 163 | + $prevHop = null; |
|
| 164 | + // make a downsearch to identify the caller |
|
| 165 | + $hop = array_pop($trace); |
|
| 166 | + while($hop !== null) { |
|
| 167 | + if(isset($hop['class'])) { |
|
| 168 | + // we are sometimes in functions = no class available: avoid php warning here |
|
| 169 | + $className = strtolower($hop['class']); |
|
| 170 | + if(!empty($className) and ($className == 'logger' or $className == 'loggercategory' or |
|
| 171 | + strtolower(get_parent_class($className)) == 'logger' or |
|
| 172 | + strtolower(get_parent_class($className)) == 'loggercategory')) { |
|
| 173 | + $locationInfo['line'] = $hop['line']; |
|
| 174 | + $locationInfo['file'] = $hop['file']; |
|
| 175 | + break; |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + $prevHop = $hop; |
|
| 179 | + $hop = array_pop($trace); |
|
| 180 | + } |
|
| 181 | + $locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main'; |
|
| 182 | + if(isset($prevHop['function']) and |
|
| 183 | + $prevHop['function'] !== 'include' and |
|
| 184 | + $prevHop['function'] !== 'include_once' and |
|
| 185 | + $prevHop['function'] !== 'require' and |
|
| 186 | + $prevHop['function'] !== 'require_once') { |
|
| 187 | 187 | |
| 188 | - $locationInfo['function'] = $prevHop['function']; |
|
| 189 | - } else { |
|
| 190 | - $locationInfo['function'] = 'main'; |
|
| 191 | - } |
|
| 192 | - } |
|
| 188 | + $locationInfo['function'] = $prevHop['function']; |
|
| 189 | + } else { |
|
| 190 | + $locationInfo['function'] = 'main'; |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | - $this->locationInfo = new LoggerLocationInfo($locationInfo, $this->fqcn); |
|
| 195 | - } |
|
| 196 | - return $this->locationInfo; |
|
| 197 | - } |
|
| 194 | + $this->locationInfo = new LoggerLocationInfo($locationInfo, $this->fqcn); |
|
| 195 | + } |
|
| 196 | + return $this->locationInfo; |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - /** |
|
| 200 | - * Return the level of this event. Use this form instead of directly |
|
| 201 | - * accessing the {@link $level} field. |
|
| 202 | - * @return LoggerLevel |
|
| 203 | - */ |
|
| 204 | - public function getLevel() { |
|
| 205 | - return $this->level; |
|
| 206 | - } |
|
| 199 | + /** |
|
| 200 | + * Return the level of this event. Use this form instead of directly |
|
| 201 | + * accessing the {@link $level} field. |
|
| 202 | + * @return LoggerLevel |
|
| 203 | + */ |
|
| 204 | + public function getLevel() { |
|
| 205 | + return $this->level; |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - /** |
|
| 209 | - * Return the name of the logger. Use this form instead of directly |
|
| 210 | - * accessing the {@link $categoryName} field. |
|
| 211 | - * @return string |
|
| 212 | - */ |
|
| 213 | - public function getLoggerName() { |
|
| 214 | - return $this->categoryName; |
|
| 215 | - } |
|
| 208 | + /** |
|
| 209 | + * Return the name of the logger. Use this form instead of directly |
|
| 210 | + * accessing the {@link $categoryName} field. |
|
| 211 | + * @return string |
|
| 212 | + */ |
|
| 213 | + public function getLoggerName() { |
|
| 214 | + return $this->categoryName; |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - /** |
|
| 218 | - * Return the message for this logging event. |
|
| 219 | - * |
|
| 220 | - * <p>Before serialization, the returned object is the message |
|
| 221 | - * passed by the user to generate the logging event. After |
|
| 222 | - * serialization, the returned value equals the String form of the |
|
| 223 | - * message possibly after object rendering. |
|
| 224 | - * @return mixed |
|
| 225 | - */ |
|
| 226 | - public function getMessage() { |
|
| 227 | - if($this->message !== null) { |
|
| 228 | - return $this->message; |
|
| 229 | - } else { |
|
| 230 | - return $this->getRenderedMessage(); |
|
| 231 | - } |
|
| 232 | - } |
|
| 217 | + /** |
|
| 218 | + * Return the message for this logging event. |
|
| 219 | + * |
|
| 220 | + * <p>Before serialization, the returned object is the message |
|
| 221 | + * passed by the user to generate the logging event. After |
|
| 222 | + * serialization, the returned value equals the String form of the |
|
| 223 | + * message possibly after object rendering. |
|
| 224 | + * @return mixed |
|
| 225 | + */ |
|
| 226 | + public function getMessage() { |
|
| 227 | + if($this->message !== null) { |
|
| 228 | + return $this->message; |
|
| 229 | + } else { |
|
| 230 | + return $this->getRenderedMessage(); |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - /** |
|
| 235 | - * This method returns the NDC for this event. It will return the |
|
| 236 | - * correct content even if the event was generated in a different |
|
| 237 | - * thread or even on a different machine. The {@link LoggerNDC::get()} method |
|
| 238 | - * should <b>never</b> be called directly. |
|
| 239 | - * @return string |
|
| 240 | - */ |
|
| 241 | - public function getNDC() { |
|
| 242 | - if($this->ndcLookupRequired) { |
|
| 243 | - $this->ndcLookupRequired = false; |
|
| 244 | - $this->ndc = implode(' ', LoggerNDC::get()); |
|
| 245 | - } |
|
| 246 | - return $this->ndc; |
|
| 247 | - } |
|
| 234 | + /** |
|
| 235 | + * This method returns the NDC for this event. It will return the |
|
| 236 | + * correct content even if the event was generated in a different |
|
| 237 | + * thread or even on a different machine. The {@link LoggerNDC::get()} method |
|
| 238 | + * should <b>never</b> be called directly. |
|
| 239 | + * @return string |
|
| 240 | + */ |
|
| 241 | + public function getNDC() { |
|
| 242 | + if($this->ndcLookupRequired) { |
|
| 243 | + $this->ndcLookupRequired = false; |
|
| 244 | + $this->ndc = implode(' ', LoggerNDC::get()); |
|
| 245 | + } |
|
| 246 | + return $this->ndc; |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | - /** |
|
| 250 | - * Returns the the context corresponding to the <code>key</code> |
|
| 251 | - * parameter. |
|
| 252 | - * @return string |
|
| 253 | - */ |
|
| 254 | - public function getMDC($key) { |
|
| 255 | - return LoggerMDC::get($key); |
|
| 256 | - } |
|
| 249 | + /** |
|
| 250 | + * Returns the the context corresponding to the <code>key</code> |
|
| 251 | + * parameter. |
|
| 252 | + * @return string |
|
| 253 | + */ |
|
| 254 | + public function getMDC($key) { |
|
| 255 | + return LoggerMDC::get($key); |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | - /** |
|
| 259 | - * Render message. |
|
| 260 | - * @return string |
|
| 261 | - */ |
|
| 262 | - public function getRenderedMessage() { |
|
| 263 | - if($this->renderedMessage === null and $this->message !== null) { |
|
| 264 | - if(is_string($this->message)) { |
|
| 265 | - $this->renderedMessage = $this->message; |
|
| 266 | - } else { |
|
| 267 | - // $this->logger might be null or an instance of Logger or RootLogger |
|
| 268 | - // But in contrast to log4j, in log4php there is only have one LoggerHierarchy so there is |
|
| 269 | - // no need figure out which one is $this->logger part of. |
|
| 270 | - // TODO: Logger::getHierarchy() is marked @deprecated! |
|
| 271 | - $repository = Logger::getHierarchy(); |
|
| 272 | - $rendererMap = $repository->getRendererMap(); |
|
| 273 | - $this->renderedMessage= $rendererMap->findAndRender($this->message); |
|
| 274 | - } |
|
| 275 | - } |
|
| 276 | - return $this->renderedMessage; |
|
| 277 | - } |
|
| 258 | + /** |
|
| 259 | + * Render message. |
|
| 260 | + * @return string |
|
| 261 | + */ |
|
| 262 | + public function getRenderedMessage() { |
|
| 263 | + if($this->renderedMessage === null and $this->message !== null) { |
|
| 264 | + if(is_string($this->message)) { |
|
| 265 | + $this->renderedMessage = $this->message; |
|
| 266 | + } else { |
|
| 267 | + // $this->logger might be null or an instance of Logger or RootLogger |
|
| 268 | + // But in contrast to log4j, in log4php there is only have one LoggerHierarchy so there is |
|
| 269 | + // no need figure out which one is $this->logger part of. |
|
| 270 | + // TODO: Logger::getHierarchy() is marked @deprecated! |
|
| 271 | + $repository = Logger::getHierarchy(); |
|
| 272 | + $rendererMap = $repository->getRendererMap(); |
|
| 273 | + $this->renderedMessage= $rendererMap->findAndRender($this->message); |
|
| 274 | + } |
|
| 275 | + } |
|
| 276 | + return $this->renderedMessage; |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - /** |
|
| 280 | - * Returns the time when the application started, in seconds |
|
| 281 | - * elapsed since 01.01.1970 plus microseconds if available. |
|
| 282 | - * |
|
| 283 | - * @return float |
|
| 284 | - * @static |
|
| 285 | - */ |
|
| 286 | - public static function getStartTime() { |
|
| 287 | - if(!isset(self::$startTime)) { |
|
| 288 | - if (function_exists('microtime')) { |
|
| 289 | - // microtime as float |
|
| 290 | - self::$startTime = microtime(true); |
|
| 291 | - } else { |
|
| 292 | - self::$startTime = floatval(time()); |
|
| 293 | - } |
|
| 294 | - } |
|
| 295 | - return self::$startTime; |
|
| 296 | - } |
|
| 279 | + /** |
|
| 280 | + * Returns the time when the application started, in seconds |
|
| 281 | + * elapsed since 01.01.1970 plus microseconds if available. |
|
| 282 | + * |
|
| 283 | + * @return float |
|
| 284 | + * @static |
|
| 285 | + */ |
|
| 286 | + public static function getStartTime() { |
|
| 287 | + if(!isset(self::$startTime)) { |
|
| 288 | + if (function_exists('microtime')) { |
|
| 289 | + // microtime as float |
|
| 290 | + self::$startTime = microtime(true); |
|
| 291 | + } else { |
|
| 292 | + self::$startTime = floatval(time()); |
|
| 293 | + } |
|
| 294 | + } |
|
| 295 | + return self::$startTime; |
|
| 296 | + } |
|
| 297 | 297 | |
| 298 | - /** |
|
| 299 | - * @return float |
|
| 300 | - */ |
|
| 301 | - public function getTimeStamp() { |
|
| 302 | - return $this->timeStamp; |
|
| 303 | - } |
|
| 298 | + /** |
|
| 299 | + * @return float |
|
| 300 | + */ |
|
| 301 | + public function getTimeStamp() { |
|
| 302 | + return $this->timeStamp; |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | - /** |
|
| 306 | - * Calculates the time of this event. |
|
| 307 | - * @return the time after event starttime when this event has occured |
|
| 308 | - */ |
|
| 309 | - public function getTime() { |
|
| 305 | + /** |
|
| 306 | + * Calculates the time of this event. |
|
| 307 | + * @return the time after event starttime when this event has occured |
|
| 308 | + */ |
|
| 309 | + public function getTime() { |
|
| 310 | 310 | $eventTime = (float)$this->getTimeStamp(); |
| 311 | 311 | $eventStartTime = (float)LoggerLoggingEvent::getStartTime(); |
| 312 | 312 | return number_format(($eventTime - $eventStartTime) * 1000, 0, '', ''); |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - /** |
|
| 316 | - * @return mixed |
|
| 317 | - */ |
|
| 318 | - public function getThreadName() { |
|
| 319 | - if ($this->threadName === null) { |
|
| 320 | - $this->threadName = (string)getmypid(); |
|
| 321 | - } |
|
| 322 | - return $this->threadName; |
|
| 323 | - } |
|
| 315 | + /** |
|
| 316 | + * @return mixed |
|
| 317 | + */ |
|
| 318 | + public function getThreadName() { |
|
| 319 | + if ($this->threadName === null) { |
|
| 320 | + $this->threadName = (string)getmypid(); |
|
| 321 | + } |
|
| 322 | + return $this->threadName; |
|
| 323 | + } |
|
| 324 | 324 | |
| 325 | - /** |
|
| 326 | - * @return mixed null |
|
| 327 | - */ |
|
| 328 | - public function getThrowableInformation() { |
|
| 329 | - return null; |
|
| 330 | - } |
|
| 325 | + /** |
|
| 326 | + * @return mixed null |
|
| 327 | + */ |
|
| 328 | + public function getThrowableInformation() { |
|
| 329 | + return null; |
|
| 330 | + } |
|
| 331 | 331 | |
| 332 | - /** |
|
| 333 | - * Serialize this object |
|
| 334 | - * @return string |
|
| 335 | - */ |
|
| 336 | - public function toString() { |
|
| 337 | - serialize($this); |
|
| 338 | - } |
|
| 332 | + /** |
|
| 333 | + * Serialize this object |
|
| 334 | + * @return string |
|
| 335 | + */ |
|
| 336 | + public function toString() { |
|
| 337 | + serialize($this); |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | - /** |
|
| 341 | - * Avoid serialization of the {@link $logger} object |
|
| 342 | - */ |
|
| 343 | - public function __sleep() { |
|
| 344 | - return array( |
|
| 345 | - 'fqcn', |
|
| 346 | - 'categoryName', |
|
| 347 | - 'level', |
|
| 348 | - 'ndc', |
|
| 349 | - 'ndcLookupRequired', |
|
| 350 | - 'message', |
|
| 351 | - 'renderedMessage', |
|
| 352 | - 'threadName', |
|
| 353 | - 'timeStamp', |
|
| 354 | - 'locationInfo', |
|
| 355 | - ); |
|
| 356 | - } |
|
| 340 | + /** |
|
| 341 | + * Avoid serialization of the {@link $logger} object |
|
| 342 | + */ |
|
| 343 | + public function __sleep() { |
|
| 344 | + return array( |
|
| 345 | + 'fqcn', |
|
| 346 | + 'categoryName', |
|
| 347 | + 'level', |
|
| 348 | + 'ndc', |
|
| 349 | + 'ndcLookupRequired', |
|
| 350 | + 'message', |
|
| 351 | + 'renderedMessage', |
|
| 352 | + 'threadName', |
|
| 353 | + 'timeStamp', |
|
| 354 | + 'locationInfo', |
|
| 355 | + ); |
|
| 356 | + } |
|
| 357 | 357 | |
| 358 | 358 | } |
| 359 | 359 | |
@@ -47,6 +47,10 @@ discard block |
||
| 47 | 47 | * @static |
| 48 | 48 | */ |
| 49 | 49 | // TODO: check, if this is really useful |
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * @param string $prefix |
|
| 53 | + */ |
|
| 50 | 54 | public static function setPropertiesByObject($obj, $properties, $prefix) { |
| 51 | 55 | $pSetter = new LoggerReflectionUtils($obj); |
| 52 | 56 | return $pSetter->setProperties($properties, $prefix); |
@@ -123,7 +127,7 @@ discard block |
||
| 123 | 127 | /** |
| 124 | 128 | * Creates an instances from the given class name. |
| 125 | 129 | * |
| 126 | - * @param string $classname |
|
| 130 | + * @param string $class |
|
| 127 | 131 | * @return an object from the class with the given classname |
| 128 | 132 | */ |
| 129 | 133 | public static function createObject($class) { |
@@ -18,123 +18,123 @@ |
||
| 18 | 18 | * @package log4php |
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Provides methods for reflective use on php objects |
|
| 23 | - * @package log4php |
|
| 24 | - */ |
|
| 21 | + /** |
|
| 22 | + * Provides methods for reflective use on php objects |
|
| 23 | + * @package log4php |
|
| 24 | + */ |
|
| 25 | 25 | class LoggerReflectionUtils { |
| 26 | - /** the target object */ |
|
| 27 | - private $obj; |
|
| 26 | + /** the target object */ |
|
| 27 | + private $obj; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Create a new LoggerReflectionUtils for the specified Object. |
|
| 31 | - * This is done in prepartion for invoking {@link setProperty()} |
|
| 32 | - * one or more times. |
|
| 33 | - * @param object &$obj the object for which to set properties |
|
| 34 | - */ |
|
| 35 | - public function __construct($obj) { |
|
| 36 | - $this->obj = $obj; |
|
| 37 | - } |
|
| 29 | + /** |
|
| 30 | + * Create a new LoggerReflectionUtils for the specified Object. |
|
| 31 | + * This is done in prepartion for invoking {@link setProperty()} |
|
| 32 | + * one or more times. |
|
| 33 | + * @param object &$obj the object for which to set properties |
|
| 34 | + */ |
|
| 35 | + public function __construct($obj) { |
|
| 36 | + $this->obj = $obj; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Set the properties of an object passed as a parameter in one |
|
| 41 | - * go. The <code>properties</code> are parsed relative to a |
|
| 42 | - * <code>prefix</code>. |
|
| 43 | - * |
|
| 44 | - * @param object $obj The object to configure. |
|
| 45 | - * @param array $properties An array containing keys and values. |
|
| 46 | - * @param string $prefix Only keys having the specified prefix will be set. |
|
| 47 | - * @static |
|
| 48 | - */ |
|
| 49 | - // TODO: check, if this is really useful |
|
| 50 | - public static function setPropertiesByObject($obj, $properties, $prefix) { |
|
| 51 | - $pSetter = new LoggerReflectionUtils($obj); |
|
| 52 | - return $pSetter->setProperties($properties, $prefix); |
|
| 53 | - } |
|
| 39 | + /** |
|
| 40 | + * Set the properties of an object passed as a parameter in one |
|
| 41 | + * go. The <code>properties</code> are parsed relative to a |
|
| 42 | + * <code>prefix</code>. |
|
| 43 | + * |
|
| 44 | + * @param object $obj The object to configure. |
|
| 45 | + * @param array $properties An array containing keys and values. |
|
| 46 | + * @param string $prefix Only keys having the specified prefix will be set. |
|
| 47 | + * @static |
|
| 48 | + */ |
|
| 49 | + // TODO: check, if this is really useful |
|
| 50 | + public static function setPropertiesByObject($obj, $properties, $prefix) { |
|
| 51 | + $pSetter = new LoggerReflectionUtils($obj); |
|
| 52 | + return $pSetter->setProperties($properties, $prefix); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Set the properites for the object that match the |
|
| 58 | - * <code>prefix</code> passed as parameter. |
|
| 59 | - * |
|
| 60 | - * Example: |
|
| 61 | - * |
|
| 62 | - * $arr['xxxname'] = 'Joe'; |
|
| 63 | - * $arr['xxxmale'] = true; |
|
| 64 | - * and prefix xxx causes setName and setMale. |
|
| 65 | - * |
|
| 66 | - * @param array $properties An array containing keys and values. |
|
| 67 | - * @param string $prefix Only keys having the specified prefix will be set. |
|
| 68 | - */ |
|
| 69 | - // TODO: check, if this is really useful |
|
| 70 | - public function setProperties($properties, $prefix) { |
|
| 71 | - $len = strlen($prefix); |
|
| 72 | - while(list($key,) = each($properties)) { |
|
| 73 | - if(strpos($key, $prefix) === 0) { |
|
| 74 | - if(strpos($key, '.', ($len + 1)) > 0) { |
|
| 75 | - continue; |
|
| 76 | - } |
|
| 77 | - $value = LoggerOptionConverter::findAndSubst($key, $properties); |
|
| 78 | - $key = substr($key, $len); |
|
| 79 | - if($key == 'layout' and ($this->obj instanceof LoggerAppender)) { |
|
| 80 | - continue; |
|
| 81 | - } |
|
| 82 | - $this->setProperty($key, $value); |
|
| 83 | - } |
|
| 84 | - } |
|
| 85 | - $this->activate(); |
|
| 86 | - } |
|
| 56 | + /** |
|
| 57 | + * Set the properites for the object that match the |
|
| 58 | + * <code>prefix</code> passed as parameter. |
|
| 59 | + * |
|
| 60 | + * Example: |
|
| 61 | + * |
|
| 62 | + * $arr['xxxname'] = 'Joe'; |
|
| 63 | + * $arr['xxxmale'] = true; |
|
| 64 | + * and prefix xxx causes setName and setMale. |
|
| 65 | + * |
|
| 66 | + * @param array $properties An array containing keys and values. |
|
| 67 | + * @param string $prefix Only keys having the specified prefix will be set. |
|
| 68 | + */ |
|
| 69 | + // TODO: check, if this is really useful |
|
| 70 | + public function setProperties($properties, $prefix) { |
|
| 71 | + $len = strlen($prefix); |
|
| 72 | + while(list($key,) = each($properties)) { |
|
| 73 | + if(strpos($key, $prefix) === 0) { |
|
| 74 | + if(strpos($key, '.', ($len + 1)) > 0) { |
|
| 75 | + continue; |
|
| 76 | + } |
|
| 77 | + $value = LoggerOptionConverter::findAndSubst($key, $properties); |
|
| 78 | + $key = substr($key, $len); |
|
| 79 | + if($key == 'layout' and ($this->obj instanceof LoggerAppender)) { |
|
| 80 | + continue; |
|
| 81 | + } |
|
| 82 | + $this->setProperty($key, $value); |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | + $this->activate(); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * Set a property on this PropertySetter's Object. If successful, this |
|
| 90 | - * method will invoke a setter method on the underlying Object. The |
|
| 91 | - * setter is the one for the specified property name and the value is |
|
| 92 | - * determined partly from the setter argument type and partly from the |
|
| 93 | - * value specified in the call to this method. |
|
| 94 | - * |
|
| 95 | - * <p>If the setter expects a String no conversion is necessary. |
|
| 96 | - * If it expects an int, then an attempt is made to convert 'value' |
|
| 97 | - * to an int using new Integer(value). If the setter expects a boolean, |
|
| 98 | - * the conversion is by new Boolean(value). |
|
| 99 | - * |
|
| 100 | - * @param string $name name of the property |
|
| 101 | - * @param string $value String value of the property |
|
| 102 | - */ |
|
| 103 | - public function setProperty($name, $value) { |
|
| 104 | - if($value === null) { |
|
| 105 | - return; |
|
| 106 | - } |
|
| 88 | + /** |
|
| 89 | + * Set a property on this PropertySetter's Object. If successful, this |
|
| 90 | + * method will invoke a setter method on the underlying Object. The |
|
| 91 | + * setter is the one for the specified property name and the value is |
|
| 92 | + * determined partly from the setter argument type and partly from the |
|
| 93 | + * value specified in the call to this method. |
|
| 94 | + * |
|
| 95 | + * <p>If the setter expects a String no conversion is necessary. |
|
| 96 | + * If it expects an int, then an attempt is made to convert 'value' |
|
| 97 | + * to an int using new Integer(value). If the setter expects a boolean, |
|
| 98 | + * the conversion is by new Boolean(value). |
|
| 99 | + * |
|
| 100 | + * @param string $name name of the property |
|
| 101 | + * @param string $value String value of the property |
|
| 102 | + */ |
|
| 103 | + public function setProperty($name, $value) { |
|
| 104 | + if($value === null) { |
|
| 105 | + return; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - $method = "set" . ucfirst($name); |
|
| 108 | + $method = "set" . ucfirst($name); |
|
| 109 | 109 | |
| 110 | - if(!method_exists($this->obj, $method)) { |
|
| 111 | - throw new Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!"); |
|
| 112 | - } else { |
|
| 113 | - return call_user_func(array($this->obj, $method), $value); |
|
| 114 | - } |
|
| 115 | - } |
|
| 110 | + if(!method_exists($this->obj, $method)) { |
|
| 111 | + throw new Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!"); |
|
| 112 | + } else { |
|
| 113 | + return call_user_func(array($this->obj, $method), $value); |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - public function activate() { |
|
| 118 | - if(method_exists($this->obj, 'activateoptions')) { |
|
| 119 | - return call_user_func(array($this->obj, 'activateoptions')); |
|
| 120 | - } |
|
| 121 | - } |
|
| 117 | + public function activate() { |
|
| 118 | + if(method_exists($this->obj, 'activateoptions')) { |
|
| 119 | + return call_user_func(array($this->obj, 'activateoptions')); |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * Creates an instances from the given class name. |
|
| 125 | - * |
|
| 126 | - * @param string $classname |
|
| 127 | - * @return an object from the class with the given classname |
|
| 128 | - */ |
|
| 129 | - public static function createObject($class) { |
|
| 130 | - if(!empty($class)) { |
|
| 131 | - $class = basename($class); |
|
| 132 | - return new $class(); |
|
| 133 | - } |
|
| 134 | - return null; |
|
| 135 | - } |
|
| 123 | + /** |
|
| 124 | + * Creates an instances from the given class name. |
|
| 125 | + * |
|
| 126 | + * @param string $classname |
|
| 127 | + * @return an object from the class with the given classname |
|
| 128 | + */ |
|
| 129 | + public static function createObject($class) { |
|
| 130 | + if(!empty($class)) { |
|
| 131 | + $class = basename($class); |
|
| 132 | + return new $class(); |
|
| 133 | + } |
|
| 134 | + return null; |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - /** |
|
| 137 | + /** |
|
| 138 | 138 | * @param object $object |
| 139 | 139 | * @param string $name |
| 140 | 140 | * @param mixed $value |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | // TODO: check, if this is really useful |
| 70 | 70 | public function setProperties($properties, $prefix) { |
| 71 | 71 | $len = strlen($prefix); |
| 72 | - while(list($key,) = each($properties)) { |
|
| 73 | - if(strpos($key, $prefix) === 0) { |
|
| 74 | - if(strpos($key, '.', ($len + 1)) > 0) { |
|
| 72 | + while (list($key,) = each($properties)) { |
|
| 73 | + if (strpos($key, $prefix) === 0) { |
|
| 74 | + if (strpos($key, '.', ($len + 1)) > 0) { |
|
| 75 | 75 | continue; |
| 76 | 76 | } |
| 77 | 77 | $value = LoggerOptionConverter::findAndSubst($key, $properties); |
| 78 | 78 | $key = substr($key, $len); |
| 79 | - if($key == 'layout' and ($this->obj instanceof LoggerAppender)) { |
|
| 79 | + if ($key == 'layout' and ($this->obj instanceof LoggerAppender)) { |
|
| 80 | 80 | continue; |
| 81 | 81 | } |
| 82 | 82 | $this->setProperty($key, $value); |
@@ -101,13 +101,13 @@ discard block |
||
| 101 | 101 | * @param string $value String value of the property |
| 102 | 102 | */ |
| 103 | 103 | public function setProperty($name, $value) { |
| 104 | - if($value === null) { |
|
| 104 | + if ($value === null) { |
|
| 105 | 105 | return; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - $method = "set" . ucfirst($name); |
|
| 108 | + $method = "set".ucfirst($name); |
|
| 109 | 109 | |
| 110 | - if(!method_exists($this->obj, $method)) { |
|
| 110 | + if (!method_exists($this->obj, $method)) { |
|
| 111 | 111 | throw new Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!"); |
| 112 | 112 | } else { |
| 113 | 113 | return call_user_func(array($this->obj, $method), $value); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | public function activate() { |
| 118 | - if(method_exists($this->obj, 'activateoptions')) { |
|
| 118 | + if (method_exists($this->obj, 'activateoptions')) { |
|
| 119 | 119 | return call_user_func(array($this->obj, 'activateoptions')); |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @return an object from the class with the given classname |
| 128 | 128 | */ |
| 129 | 129 | public static function createObject($class) { |
| 130 | - if(!empty($class)) { |
|
| 130 | + if (!empty($class)) { |
|
| 131 | 131 | $class = basename($class); |
| 132 | 132 | return new $class(); |
| 133 | 133 | } |
@@ -58,7 +58,6 @@ discard block |
||
| 58 | 58 | * Add a renderer to a hierarchy passed as parameter. |
| 59 | 59 | * Note that hierarchy must implement getRendererMap() and setRenderer() methods. |
| 60 | 60 | * |
| 61 | - * @param LoggerHierarchy $repository a logger repository. |
|
| 62 | 61 | * @param string $renderedClassName |
| 63 | 62 | * @param string $renderingClassName |
| 64 | 63 | * @static |
@@ -108,7 +107,7 @@ discard block |
||
| 108 | 107 | * class of the object parameter. |
| 109 | 108 | * |
| 110 | 109 | * @param mixed $o |
| 111 | - * @return string |
|
| 110 | + * @return LoggerRendererObject |
|
| 112 | 111 | */ |
| 113 | 112 | public function getByObject($o) { |
| 114 | 113 | return ($o == null) ? null : $this->getByClassName(get_class($o)); |
@@ -1,22 +1,22 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Licensed to the Apache Software Foundation (ASF) under one or more |
|
| 4 | - * contributor license agreements. See the NOTICE file distributed with |
|
| 5 | - * this work for additional information regarding copyright ownership. |
|
| 6 | - * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
| 7 | - * (the "License"); you may not use this file except in compliance with |
|
| 8 | - * the License. You may obtain a copy of the License at |
|
| 9 | - * |
|
| 10 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 11 | - * |
|
| 12 | - * Unless required by applicable law or agreed to in writing, software |
|
| 13 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 14 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 15 | - * See the License for the specific language governing permissions and |
|
| 16 | - * limitations under the License. |
|
| 17 | - * |
|
| 18 | - * @package log4php |
|
| 19 | - */ |
|
| 3 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
|
| 4 | + * contributor license agreements. See the NOTICE file distributed with |
|
| 5 | + * this work for additional information regarding copyright ownership. |
|
| 6 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
| 7 | + * (the "License"); you may not use this file except in compliance with |
|
| 8 | + * the License. You may obtain a copy of the License at |
|
| 9 | + * |
|
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 11 | + * |
|
| 12 | + * Unless required by applicable law or agreed to in writing, software |
|
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 15 | + * See the License for the specific language governing permissions and |
|
| 16 | + * limitations under the License. |
|
| 17 | + * |
|
| 18 | + * @package log4php |
|
| 19 | + */ |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Log objects using customized renderers that implement {@link LoggerRendererObject}. |
@@ -36,114 +36,114 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | class LoggerRendererMap { |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @var array |
|
| 41 | - */ |
|
| 42 | - private $map; |
|
| 39 | + /** |
|
| 40 | + * @var array |
|
| 41 | + */ |
|
| 42 | + private $map; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @var LoggerDefaultRenderer |
|
| 46 | - */ |
|
| 47 | - private $defaultRenderer; |
|
| 44 | + /** |
|
| 45 | + * @var LoggerDefaultRenderer |
|
| 46 | + */ |
|
| 47 | + private $defaultRenderer; |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Constructor |
|
| 51 | - */ |
|
| 52 | - public function __construct() { |
|
| 53 | - $this->map = array(); |
|
| 54 | - $this->defaultRenderer = new LoggerRendererDefault(); |
|
| 55 | - } |
|
| 49 | + /** |
|
| 50 | + * Constructor |
|
| 51 | + */ |
|
| 52 | + public function __construct() { |
|
| 53 | + $this->map = array(); |
|
| 54 | + $this->defaultRenderer = new LoggerRendererDefault(); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Add a renderer to a hierarchy passed as parameter. |
|
| 59 | - * Note that hierarchy must implement getRendererMap() and setRenderer() methods. |
|
| 60 | - * |
|
| 61 | - * @param LoggerHierarchy $repository a logger repository. |
|
| 62 | - * @param string $renderedClassName |
|
| 63 | - * @param string $renderingClassName |
|
| 64 | - * @static |
|
| 65 | - */ |
|
| 66 | - public function addRenderer($renderedClassName, $renderingClassName) { |
|
| 67 | - $renderer = LoggerReflectionUtils::createObject($renderingClassName); |
|
| 68 | - if($renderer == null) { |
|
| 69 | - return; |
|
| 70 | - } else { |
|
| 71 | - $this->put($renderedClassName, $renderer); |
|
| 72 | - } |
|
| 73 | - } |
|
| 57 | + /** |
|
| 58 | + * Add a renderer to a hierarchy passed as parameter. |
|
| 59 | + * Note that hierarchy must implement getRendererMap() and setRenderer() methods. |
|
| 60 | + * |
|
| 61 | + * @param LoggerHierarchy $repository a logger repository. |
|
| 62 | + * @param string $renderedClassName |
|
| 63 | + * @param string $renderingClassName |
|
| 64 | + * @static |
|
| 65 | + */ |
|
| 66 | + public function addRenderer($renderedClassName, $renderingClassName) { |
|
| 67 | + $renderer = LoggerReflectionUtils::createObject($renderingClassName); |
|
| 68 | + if($renderer == null) { |
|
| 69 | + return; |
|
| 70 | + } else { |
|
| 71 | + $this->put($renderedClassName, $renderer); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Find the appropriate renderer for the class type of the |
|
| 78 | - * <var>o</var> parameter. |
|
| 79 | - * |
|
| 80 | - * This is accomplished by calling the {@link getByObject()} |
|
| 81 | - * method if <var>o</var> is object or using {@link LoggerRendererDefault}. |
|
| 82 | - * Once a renderer is found, it is applied on the object <var>o</var> and |
|
| 83 | - * the result is returned as a string. |
|
| 84 | - * |
|
| 85 | - * @param mixed $o |
|
| 86 | - * @return string |
|
| 87 | - */ |
|
| 88 | - public function findAndRender($o) { |
|
| 89 | - if($o == null) { |
|
| 90 | - return null; |
|
| 91 | - } else { |
|
| 92 | - if(is_object($o)) { |
|
| 93 | - $renderer = $this->getByObject($o); |
|
| 94 | - if($renderer !== null) { |
|
| 95 | - return $renderer->render($o); |
|
| 96 | - } else { |
|
| 97 | - return null; |
|
| 98 | - } |
|
| 99 | - } else { |
|
| 100 | - $renderer = $this->defaultRenderer; |
|
| 101 | - return $renderer->render($o); |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - } |
|
| 76 | + /** |
|
| 77 | + * Find the appropriate renderer for the class type of the |
|
| 78 | + * <var>o</var> parameter. |
|
| 79 | + * |
|
| 80 | + * This is accomplished by calling the {@link getByObject()} |
|
| 81 | + * method if <var>o</var> is object or using {@link LoggerRendererDefault}. |
|
| 82 | + * Once a renderer is found, it is applied on the object <var>o</var> and |
|
| 83 | + * the result is returned as a string. |
|
| 84 | + * |
|
| 85 | + * @param mixed $o |
|
| 86 | + * @return string |
|
| 87 | + */ |
|
| 88 | + public function findAndRender($o) { |
|
| 89 | + if($o == null) { |
|
| 90 | + return null; |
|
| 91 | + } else { |
|
| 92 | + if(is_object($o)) { |
|
| 93 | + $renderer = $this->getByObject($o); |
|
| 94 | + if($renderer !== null) { |
|
| 95 | + return $renderer->render($o); |
|
| 96 | + } else { |
|
| 97 | + return null; |
|
| 98 | + } |
|
| 99 | + } else { |
|
| 100 | + $renderer = $this->defaultRenderer; |
|
| 101 | + return $renderer->render($o); |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * Syntactic sugar method that calls {@link PHP_MANUAL#get_class} with the |
|
| 108 | - * class of the object parameter. |
|
| 109 | - * |
|
| 110 | - * @param mixed $o |
|
| 111 | - * @return string |
|
| 112 | - */ |
|
| 113 | - public function getByObject($o) { |
|
| 114 | - return ($o == null) ? null : $this->getByClassName(get_class($o)); |
|
| 115 | - } |
|
| 106 | + /** |
|
| 107 | + * Syntactic sugar method that calls {@link PHP_MANUAL#get_class} with the |
|
| 108 | + * class of the object parameter. |
|
| 109 | + * |
|
| 110 | + * @param mixed $o |
|
| 111 | + * @return string |
|
| 112 | + */ |
|
| 113 | + public function getByObject($o) { |
|
| 114 | + return ($o == null) ? null : $this->getByClassName(get_class($o)); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Search the parents of <var>clazz</var> for a renderer. |
|
| 120 | - * |
|
| 121 | - * The renderer closest in the hierarchy will be returned. If no |
|
| 122 | - * renderers could be found, then the default renderer is returned. |
|
| 123 | - * |
|
| 124 | - * @param string $class |
|
| 125 | - * @return LoggerRendererObject |
|
| 126 | - */ |
|
| 127 | - public function getByClassName($class) { |
|
| 128 | - $r = null; |
|
| 129 | - for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) { |
|
| 130 | - if(isset($this->map[$c])) { |
|
| 131 | - return $this->map[$c]; |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - return $this->defaultRenderer; |
|
| 135 | - } |
|
| 118 | + /** |
|
| 119 | + * Search the parents of <var>clazz</var> for a renderer. |
|
| 120 | + * |
|
| 121 | + * The renderer closest in the hierarchy will be returned. If no |
|
| 122 | + * renderers could be found, then the default renderer is returned. |
|
| 123 | + * |
|
| 124 | + * @param string $class |
|
| 125 | + * @return LoggerRendererObject |
|
| 126 | + */ |
|
| 127 | + public function getByClassName($class) { |
|
| 128 | + $r = null; |
|
| 129 | + for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) { |
|
| 130 | + if(isset($this->map[$c])) { |
|
| 131 | + return $this->map[$c]; |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + return $this->defaultRenderer; |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - public function clear() { |
|
| 138 | - $this->map = array(); |
|
| 139 | - } |
|
| 137 | + public function clear() { |
|
| 138 | + $this->map = array(); |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - /** |
|
| 142 | - * Register a {@link LoggerRendererObject} for <var>clazz</var>. |
|
| 143 | - * @param string $class |
|
| 144 | - * @param LoggerRendererObject $or |
|
| 145 | - */ |
|
| 146 | - private function put($class, $or) { |
|
| 147 | - $this->map[strtolower($class)] = $or; |
|
| 148 | - } |
|
| 141 | + /** |
|
| 142 | + * Register a {@link LoggerRendererObject} for <var>clazz</var>. |
|
| 143 | + * @param string $class |
|
| 144 | + * @param LoggerRendererObject $or |
|
| 145 | + */ |
|
| 146 | + private function put($class, $or) { |
|
| 147 | + $this->map[strtolower($class)] = $or; |
|
| 148 | + } |
|
| 149 | 149 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | public function addRenderer($renderedClassName, $renderingClassName) { |
| 67 | 67 | $renderer = LoggerReflectionUtils::createObject($renderingClassName); |
| 68 | - if($renderer == null) { |
|
| 68 | + if ($renderer == null) { |
|
| 69 | 69 | return; |
| 70 | 70 | } else { |
| 71 | 71 | $this->put($renderedClassName, $renderer); |
@@ -86,12 +86,12 @@ discard block |
||
| 86 | 86 | * @return string |
| 87 | 87 | */ |
| 88 | 88 | public function findAndRender($o) { |
| 89 | - if($o == null) { |
|
| 89 | + if ($o == null) { |
|
| 90 | 90 | return null; |
| 91 | 91 | } else { |
| 92 | - if(is_object($o)) { |
|
| 92 | + if (is_object($o)) { |
|
| 93 | 93 | $renderer = $this->getByObject($o); |
| 94 | - if($renderer !== null) { |
|
| 94 | + if ($renderer !== null) { |
|
| 95 | 95 | return $renderer->render($o); |
| 96 | 96 | } else { |
| 97 | 97 | return null; |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function getByClassName($class) { |
| 128 | 128 | $r = null; |
| 129 | - for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) { |
|
| 130 | - if(isset($this->map[$c])) { |
|
| 129 | + for ($c = strtolower($class); !empty($c); $c = get_parent_class($c)) { |
|
| 130 | + if (isset($this->map[$c])) { |
|
| 131 | 131 | return $this->map[$c]; |
| 132 | 132 | } |
| 133 | 133 | } |
@@ -98,7 +98,6 @@ |
||
| 98 | 98 | /** |
| 99 | 99 | * Render a background image over a rectangular area |
| 100 | 100 | * |
| 101 | - * @param string $img The background image to load |
|
| 102 | 101 | * @param float $x The left edge of the rectangular area |
| 103 | 102 | * @param float $y The top edge of the rectangular area |
| 104 | 103 | * @param float $width The width of the rectangular area |
@@ -299,21 +299,21 @@ discard block |
||
| 299 | 299 | |
| 300 | 300 | switch (strtolower($ext)) { |
| 301 | 301 | |
| 302 | - case "png": |
|
| 303 | - $src = imagecreatefrompng($img); |
|
| 304 | - break; |
|
| 302 | + case "png": |
|
| 303 | + $src = imagecreatefrompng($img); |
|
| 304 | + break; |
|
| 305 | 305 | |
| 306 | - case "jpg": |
|
| 307 | - case "jpeg": |
|
| 308 | - $src = imagecreatefromjpeg($img); |
|
| 309 | - break; |
|
| 306 | + case "jpg": |
|
| 307 | + case "jpeg": |
|
| 308 | + $src = imagecreatefromjpeg($img); |
|
| 309 | + break; |
|
| 310 | 310 | |
| 311 | - case "gif": |
|
| 312 | - $src = imagecreatefromgif($img); |
|
| 313 | - break; |
|
| 311 | + case "gif": |
|
| 312 | + $src = imagecreatefromgif($img); |
|
| 313 | + break; |
|
| 314 | 314 | |
| 315 | - default: |
|
| 316 | - return; // Unsupported image type |
|
| 315 | + default: |
|
| 316 | + return; // Unsupported image type |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | if ($src == null) { |
@@ -475,22 +475,22 @@ discard block |
||
| 475 | 475 | |
| 476 | 476 | switch ($side) { |
| 477 | 477 | |
| 478 | - case "top": |
|
| 479 | - $delta = $top / 2; |
|
| 480 | - case "bottom": |
|
| 481 | - $delta = isset($delta) ? $delta : -$bottom / 2; |
|
| 482 | - $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, $dash); |
|
| 483 | - break; |
|
| 484 | - |
|
| 485 | - case "left": |
|
| 486 | - $delta = $left / 2; |
|
| 487 | - case "right": |
|
| 488 | - $delta = isset($delta) ? $delta : - $right / 2; |
|
| 489 | - $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, $dash); |
|
| 490 | - break; |
|
| 491 | - |
|
| 492 | - default: |
|
| 493 | - return; |
|
| 478 | + case "top": |
|
| 479 | + $delta = $top / 2; |
|
| 480 | + case "bottom": |
|
| 481 | + $delta = isset($delta) ? $delta : -$bottom / 2; |
|
| 482 | + $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, $dash); |
|
| 483 | + break; |
|
| 484 | + |
|
| 485 | + case "left": |
|
| 486 | + $delta = $left / 2; |
|
| 487 | + case "right": |
|
| 488 | + $delta = isset($delta) ? $delta : - $right / 2; |
|
| 489 | + $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, $dash); |
|
| 490 | + break; |
|
| 491 | + |
|
| 492 | + default: |
|
| 493 | + return; |
|
| 494 | 494 | |
| 495 | 495 | } |
| 496 | 496 | } |
@@ -501,22 +501,22 @@ discard block |
||
| 501 | 501 | |
| 502 | 502 | switch ($side) { |
| 503 | 503 | |
| 504 | - case "top": |
|
| 505 | - $delta = $top / 2; |
|
| 506 | - case "bottom": |
|
| 507 | - $delta = isset($delta) ? $delta : -$bottom / 2; |
|
| 508 | - $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, array(3 * $$side)); |
|
| 509 | - break; |
|
| 510 | - |
|
| 511 | - case "left": |
|
| 512 | - $delta = $left / 2; |
|
| 513 | - case "right": |
|
| 514 | - $delta = isset($delta) ? $delta : - $right / 2; |
|
| 515 | - $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, array(3 * $$side)); |
|
| 516 | - break; |
|
| 517 | - |
|
| 518 | - default: |
|
| 519 | - return; |
|
| 504 | + case "top": |
|
| 505 | + $delta = $top / 2; |
|
| 506 | + case "bottom": |
|
| 507 | + $delta = isset($delta) ? $delta : -$bottom / 2; |
|
| 508 | + $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, array(3 * $$side)); |
|
| 509 | + break; |
|
| 510 | + |
|
| 511 | + case "left": |
|
| 512 | + $delta = $left / 2; |
|
| 513 | + case "right": |
|
| 514 | + $delta = isset($delta) ? $delta : - $right / 2; |
|
| 515 | + $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, array(3 * $$side)); |
|
| 516 | + break; |
|
| 517 | + |
|
| 518 | + default: |
|
| 519 | + return; |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | } |
@@ -528,57 +528,57 @@ discard block |
||
| 528 | 528 | // All this polygon business is for beveled corners... |
| 529 | 529 | switch ($side) { |
| 530 | 530 | |
| 531 | - case "top": |
|
| 532 | - if ( $corner_style === "bevel" ) { |
|
| 531 | + case "top": |
|
| 532 | + if ( $corner_style === "bevel" ) { |
|
| 533 | 533 | |
| 534 | - $points = array($x, $y, |
|
| 535 | - $x + $length, $y, |
|
| 536 | - $x + $length - $right, $y + $top, |
|
| 537 | - $x + $left, $y + $top); |
|
| 538 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
| 539 | - } else |
|
| 540 | - $this->_canvas->filled_rectangle($x, $y, $length, $top, $color); |
|
| 534 | + $points = array($x, $y, |
|
| 535 | + $x + $length, $y, |
|
| 536 | + $x + $length - $right, $y + $top, |
|
| 537 | + $x + $left, $y + $top); |
|
| 538 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
| 539 | + } else |
|
| 540 | + $this->_canvas->filled_rectangle($x, $y, $length, $top, $color); |
|
| 541 | 541 | |
| 542 | - break; |
|
| 542 | + break; |
|
| 543 | 543 | |
| 544 | - case "bottom": |
|
| 545 | - if ( $corner_style === "bevel" ) { |
|
| 546 | - $points = array($x, $y, |
|
| 547 | - $x + $length, $y, |
|
| 548 | - $x + $length - $right, $y - $bottom, |
|
| 549 | - $x + $left, $y - $bottom); |
|
| 550 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
| 551 | - } else |
|
| 552 | - $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color); |
|
| 544 | + case "bottom": |
|
| 545 | + if ( $corner_style === "bevel" ) { |
|
| 546 | + $points = array($x, $y, |
|
| 547 | + $x + $length, $y, |
|
| 548 | + $x + $length - $right, $y - $bottom, |
|
| 549 | + $x + $left, $y - $bottom); |
|
| 550 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
| 551 | + } else |
|
| 552 | + $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color); |
|
| 553 | 553 | |
| 554 | - break; |
|
| 554 | + break; |
|
| 555 | 555 | |
| 556 | - case "left": |
|
| 557 | - if ( $corner_style === "bevel" ) { |
|
| 558 | - $points = array($x, $y, |
|
| 559 | - $x, $y + $length, |
|
| 560 | - $x + $left, $y + $length - $bottom, |
|
| 561 | - $x + $left, $y + $top); |
|
| 562 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
| 563 | - } else |
|
| 564 | - $this->_canvas->filled_rectangle($x, $y, $left, $length, $color); |
|
| 556 | + case "left": |
|
| 557 | + if ( $corner_style === "bevel" ) { |
|
| 558 | + $points = array($x, $y, |
|
| 559 | + $x, $y + $length, |
|
| 560 | + $x + $left, $y + $length - $bottom, |
|
| 561 | + $x + $left, $y + $top); |
|
| 562 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
| 563 | + } else |
|
| 564 | + $this->_canvas->filled_rectangle($x, $y, $left, $length, $color); |
|
| 565 | 565 | |
| 566 | - break; |
|
| 566 | + break; |
|
| 567 | 567 | |
| 568 | - case "right": |
|
| 569 | - if ( $corner_style === "bevel" ) { |
|
| 570 | - $points = array($x, $y, |
|
| 571 | - $x, $y + $length, |
|
| 572 | - $x - $right, $y + $length - $bottom, |
|
| 573 | - $x - $right, $y + $top); |
|
| 574 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
| 575 | - } else |
|
| 576 | - $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color); |
|
| 577 | - |
|
| 578 | - break; |
|
| 579 | - |
|
| 580 | - default: |
|
| 581 | - return; |
|
| 568 | + case "right": |
|
| 569 | + if ( $corner_style === "bevel" ) { |
|
| 570 | + $points = array($x, $y, |
|
| 571 | + $x, $y + $length, |
|
| 572 | + $x - $right, $y + $length - $bottom, |
|
| 573 | + $x - $right, $y + $top); |
|
| 574 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
| 575 | + } else |
|
| 576 | + $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color); |
|
| 577 | + |
|
| 578 | + break; |
|
| 579 | + |
|
| 580 | + default: |
|
| 581 | + return; |
|
| 582 | 582 | |
| 583 | 583 | } |
| 584 | 584 | |
@@ -595,105 +595,105 @@ discard block |
||
| 595 | 595 | // inner bottom, inner top. |
| 596 | 596 | switch ($side) { |
| 597 | 597 | |
| 598 | - case "top": |
|
| 599 | - if ( $corner_style === "bevel" ) { |
|
| 600 | - $left_line_width = $left / 4; |
|
| 601 | - $right_line_width = $right / 4; |
|
| 598 | + case "top": |
|
| 599 | + if ( $corner_style === "bevel" ) { |
|
| 600 | + $left_line_width = $left / 4; |
|
| 601 | + $right_line_width = $right / 4; |
|
| 602 | 602 | |
| 603 | - $points = array($x, $y, |
|
| 604 | - $x + $length, $y, |
|
| 605 | - $x + $length - $right_line_width, $y + $line_width, |
|
| 606 | - $x + $left_line_width, $y + $line_width,); |
|
| 607 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
| 603 | + $points = array($x, $y, |
|
| 604 | + $x + $length, $y, |
|
| 605 | + $x + $length - $right_line_width, $y + $line_width, |
|
| 606 | + $x + $left_line_width, $y + $line_width,); |
|
| 607 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
| 608 | 608 | |
| 609 | - $points = array($x + $left - $left_line_width, $y + $top - $line_width, |
|
| 610 | - $x + $length - $right + $right_line_width, $y + $top - $line_width, |
|
| 611 | - $x + $length - $right, $y + $top, |
|
| 612 | - $x + $left, $y + $top); |
|
| 613 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
| 609 | + $points = array($x + $left - $left_line_width, $y + $top - $line_width, |
|
| 610 | + $x + $length - $right + $right_line_width, $y + $top - $line_width, |
|
| 611 | + $x + $length - $right, $y + $top, |
|
| 612 | + $x + $left, $y + $top); |
|
| 613 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
| 614 | 614 | |
| 615 | - } else { |
|
| 616 | - $this->_canvas->filled_rectangle($x, $y, $length, $line_width, $color); |
|
| 617 | - $this->_canvas->filled_rectangle($x, $y + $top - $line_width, $length, $line_width, $color); |
|
| 615 | + } else { |
|
| 616 | + $this->_canvas->filled_rectangle($x, $y, $length, $line_width, $color); |
|
| 617 | + $this->_canvas->filled_rectangle($x, $y + $top - $line_width, $length, $line_width, $color); |
|
| 618 | 618 | |
| 619 | - } |
|
| 620 | - break; |
|
| 619 | + } |
|
| 620 | + break; |
|
| 621 | 621 | |
| 622 | - case "bottom": |
|
| 623 | - if ( $corner_style === "bevel" ) { |
|
| 624 | - $left_line_width = $left / 4; |
|
| 625 | - $right_line_width = $right / 4; |
|
| 622 | + case "bottom": |
|
| 623 | + if ( $corner_style === "bevel" ) { |
|
| 624 | + $left_line_width = $left / 4; |
|
| 625 | + $right_line_width = $right / 4; |
|
| 626 | 626 | |
| 627 | - $points = array($x, $y, |
|
| 628 | - $x + $length, $y, |
|
| 629 | - $x + $length - $right_line_width, $y - $line_width, |
|
| 630 | - $x + $left_line_width, $y - $line_width); |
|
| 631 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
| 627 | + $points = array($x, $y, |
|
| 628 | + $x + $length, $y, |
|
| 629 | + $x + $length - $right_line_width, $y - $line_width, |
|
| 630 | + $x + $left_line_width, $y - $line_width); |
|
| 631 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
| 632 | 632 | |
| 633 | - $points = array($x + $left - $left_line_width, $y - $bottom + $line_width, |
|
| 634 | - $x + $length - $right + $right_line_width, $y - $bottom + $line_width, |
|
| 635 | - $x + $length - $right, $y - $bottom, |
|
| 636 | - $x + $left, $y - $bottom); |
|
| 637 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
| 633 | + $points = array($x + $left - $left_line_width, $y - $bottom + $line_width, |
|
| 634 | + $x + $length - $right + $right_line_width, $y - $bottom + $line_width, |
|
| 635 | + $x + $length - $right, $y - $bottom, |
|
| 636 | + $x + $left, $y - $bottom); |
|
| 637 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
| 638 | 638 | |
| 639 | - } else { |
|
| 640 | - $this->_canvas->filled_rectangle($x, $y - $line_width, $length, $line_width, $color); |
|
| 641 | - $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $line_width, $color); |
|
| 642 | - } |
|
| 639 | + } else { |
|
| 640 | + $this->_canvas->filled_rectangle($x, $y - $line_width, $length, $line_width, $color); |
|
| 641 | + $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $line_width, $color); |
|
| 642 | + } |
|
| 643 | 643 | |
| 644 | - break; |
|
| 644 | + break; |
|
| 645 | 645 | |
| 646 | - case "left": |
|
| 647 | - if ( $corner_style === "bevel" ) { |
|
| 648 | - $top_line_width = $top / 4; |
|
| 649 | - $bottom_line_width = $bottom / 4; |
|
| 646 | + case "left": |
|
| 647 | + if ( $corner_style === "bevel" ) { |
|
| 648 | + $top_line_width = $top / 4; |
|
| 649 | + $bottom_line_width = $bottom / 4; |
|
| 650 | 650 | |
| 651 | - $points = array($x, $y, |
|
| 652 | - $x, $y + $length, |
|
| 653 | - $x + $line_width, $y + $length - $bottom_line_width, |
|
| 654 | - $x + $line_width, $y + $top_line_width); |
|
| 655 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
| 656 | - |
|
| 657 | - $points = array($x + $left - $line_width, $y + $top - $top_line_width, |
|
| 658 | - $x + $left - $line_width, $y + $length - $bottom + $bottom_line_width, |
|
| 659 | - $x + $left, $y + $length - $bottom, |
|
| 660 | - $x + $left, $y + $top); |
|
| 661 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
| 651 | + $points = array($x, $y, |
|
| 652 | + $x, $y + $length, |
|
| 653 | + $x + $line_width, $y + $length - $bottom_line_width, |
|
| 654 | + $x + $line_width, $y + $top_line_width); |
|
| 655 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
| 656 | + |
|
| 657 | + $points = array($x + $left - $line_width, $y + $top - $top_line_width, |
|
| 658 | + $x + $left - $line_width, $y + $length - $bottom + $bottom_line_width, |
|
| 659 | + $x + $left, $y + $length - $bottom, |
|
| 660 | + $x + $left, $y + $top); |
|
| 661 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
| 662 | 662 | |
| 663 | - } else { |
|
| 664 | - $this->_canvas->filled_rectangle($x, $y, $line_width, $length, $color); |
|
| 665 | - $this->_canvas->filled_rectangle($x + $left - $line_width, $y, $line_width, $length, $color); |
|
| 666 | - } |
|
| 663 | + } else { |
|
| 664 | + $this->_canvas->filled_rectangle($x, $y, $line_width, $length, $color); |
|
| 665 | + $this->_canvas->filled_rectangle($x + $left - $line_width, $y, $line_width, $length, $color); |
|
| 666 | + } |
|
| 667 | 667 | |
| 668 | - break; |
|
| 668 | + break; |
|
| 669 | 669 | |
| 670 | - case "right": |
|
| 671 | - if ( $corner_style === "bevel" ) { |
|
| 672 | - $top_line_width = $top / 4; |
|
| 673 | - $bottom_line_width = $bottom / 4; |
|
| 670 | + case "right": |
|
| 671 | + if ( $corner_style === "bevel" ) { |
|
| 672 | + $top_line_width = $top / 4; |
|
| 673 | + $bottom_line_width = $bottom / 4; |
|
| 674 | 674 | |
| 675 | 675 | |
| 676 | - $points = array($x, $y, |
|
| 677 | - $x, $y + $length, |
|
| 678 | - $x - $line_width, $y + $length - $bottom_line_width, |
|
| 679 | - $x - $line_width, $y + $top_line_width); |
|
| 680 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
| 676 | + $points = array($x, $y, |
|
| 677 | + $x, $y + $length, |
|
| 678 | + $x - $line_width, $y + $length - $bottom_line_width, |
|
| 679 | + $x - $line_width, $y + $top_line_width); |
|
| 680 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
| 681 | 681 | |
| 682 | - $points = array($x - $right + $line_width, $y + $top - $top_line_width, |
|
| 683 | - $x - $right + $line_width, $y + $length - $bottom + $bottom_line_width, |
|
| 684 | - $x - $right, $y + $length - $bottom, |
|
| 685 | - $x - $right, $y + $top); |
|
| 686 | - $this->_canvas->polygon($points, $color, null, null, true); |
|
| 682 | + $points = array($x - $right + $line_width, $y + $top - $top_line_width, |
|
| 683 | + $x - $right + $line_width, $y + $length - $bottom + $bottom_line_width, |
|
| 684 | + $x - $right, $y + $length - $bottom, |
|
| 685 | + $x - $right, $y + $top); |
|
| 686 | + $this->_canvas->polygon($points, $color, null, null, true); |
|
| 687 | 687 | |
| 688 | - } else { |
|
| 689 | - $this->_canvas->filled_rectangle($x - $line_width, $y, $line_width, $length, $color); |
|
| 690 | - $this->_canvas->filled_rectangle($x - $right, $y, $line_width, $length, $color); |
|
| 691 | - } |
|
| 688 | + } else { |
|
| 689 | + $this->_canvas->filled_rectangle($x - $line_width, $y, $line_width, $length, $color); |
|
| 690 | + $this->_canvas->filled_rectangle($x - $right, $y, $line_width, $length, $color); |
|
| 691 | + } |
|
| 692 | 692 | |
| 693 | - break; |
|
| 693 | + break; |
|
| 694 | 694 | |
| 695 | - default: |
|
| 696 | - return; |
|
| 695 | + default: |
|
| 696 | + return; |
|
| 697 | 697 | |
| 698 | 698 | } |
| 699 | 699 | |
@@ -708,32 +708,32 @@ discard block |
||
| 708 | 708 | |
| 709 | 709 | switch ($side) { |
| 710 | 710 | |
| 711 | - case "top": |
|
| 712 | - $x += $left / 2; |
|
| 713 | - $y += $top / 2; |
|
| 714 | - $length -= $left / 2 + $right / 2; |
|
| 715 | - break; |
|
| 716 | - |
|
| 717 | - case "bottom": |
|
| 718 | - $x += $left / 2; |
|
| 719 | - $y -= $bottom / 2; |
|
| 720 | - $length -= $left / 2 + $right / 2; |
|
| 721 | - break; |
|
| 722 | - |
|
| 723 | - case "left": |
|
| 724 | - $x += $left / 2; |
|
| 725 | - $y += $top / 2; |
|
| 726 | - $length -= $top / 2 + $bottom / 2; |
|
| 727 | - break; |
|
| 728 | - |
|
| 729 | - case "right": |
|
| 730 | - $x -= $right / 2; |
|
| 731 | - $y += $top / 2; |
|
| 732 | - $length -= $top / 2 + $bottom / 2; |
|
| 733 | - break; |
|
| 734 | - |
|
| 735 | - default: |
|
| 736 | - return; |
|
| 711 | + case "top": |
|
| 712 | + $x += $left / 2; |
|
| 713 | + $y += $top / 2; |
|
| 714 | + $length -= $left / 2 + $right / 2; |
|
| 715 | + break; |
|
| 716 | + |
|
| 717 | + case "bottom": |
|
| 718 | + $x += $left / 2; |
|
| 719 | + $y -= $bottom / 2; |
|
| 720 | + $length -= $left / 2 + $right / 2; |
|
| 721 | + break; |
|
| 722 | + |
|
| 723 | + case "left": |
|
| 724 | + $x += $left / 2; |
|
| 725 | + $y += $top / 2; |
|
| 726 | + $length -= $top / 2 + $bottom / 2; |
|
| 727 | + break; |
|
| 728 | + |
|
| 729 | + case "right": |
|
| 730 | + $x -= $right / 2; |
|
| 731 | + $y += $top / 2; |
|
| 732 | + $length -= $top / 2 + $bottom / 2; |
|
| 733 | + break; |
|
| 734 | + |
|
| 735 | + default: |
|
| 736 | + return; |
|
| 737 | 737 | |
| 738 | 738 | } |
| 739 | 739 | |
@@ -750,32 +750,32 @@ discard block |
||
| 750 | 750 | |
| 751 | 751 | switch ($side) { |
| 752 | 752 | |
| 753 | - case "top": |
|
| 754 | - $x += $left / 2; |
|
| 755 | - $y += $top / 2; |
|
| 756 | - $length -= $left / 2 + $right / 2; |
|
| 757 | - break; |
|
| 758 | - |
|
| 759 | - case "bottom": |
|
| 760 | - $x += $left / 2; |
|
| 761 | - $y -= $bottom / 2; |
|
| 762 | - $length -= $left / 2 + $right / 2; |
|
| 763 | - break; |
|
| 764 | - |
|
| 765 | - case "left": |
|
| 766 | - $x += $left / 2; |
|
| 767 | - $y += $top / 2; |
|
| 768 | - $length -= $top / 2 + $bottom / 2; |
|
| 769 | - break; |
|
| 770 | - |
|
| 771 | - case "right": |
|
| 772 | - $x -= $right / 2; |
|
| 773 | - $y += $top / 2; |
|
| 774 | - $length -= $top / 2 + $bottom / 2; |
|
| 775 | - break; |
|
| 776 | - |
|
| 777 | - default: |
|
| 778 | - return; |
|
| 753 | + case "top": |
|
| 754 | + $x += $left / 2; |
|
| 755 | + $y += $top / 2; |
|
| 756 | + $length -= $left / 2 + $right / 2; |
|
| 757 | + break; |
|
| 758 | + |
|
| 759 | + case "bottom": |
|
| 760 | + $x += $left / 2; |
|
| 761 | + $y -= $bottom / 2; |
|
| 762 | + $length -= $left / 2 + $right / 2; |
|
| 763 | + break; |
|
| 764 | + |
|
| 765 | + case "left": |
|
| 766 | + $x += $left / 2; |
|
| 767 | + $y += $top / 2; |
|
| 768 | + $length -= $top / 2 + $bottom / 2; |
|
| 769 | + break; |
|
| 770 | + |
|
| 771 | + case "right": |
|
| 772 | + $x -= $right / 2; |
|
| 773 | + $y += $top / 2; |
|
| 774 | + $length -= $top / 2 + $bottom / 2; |
|
| 775 | + break; |
|
| 776 | + |
|
| 777 | + default: |
|
| 778 | + return; |
|
| 779 | 779 | |
| 780 | 780 | } |
| 781 | 781 | |
@@ -802,20 +802,20 @@ discard block |
||
| 802 | 802 | |
| 803 | 803 | switch ($side) { |
| 804 | 804 | |
| 805 | - case "top": |
|
| 806 | - case "left": |
|
| 807 | - $shade = array_map(array($this, "_shade"), $color); |
|
| 808 | - $this->_border_solid($x, $y, $length, $shade, $widths, $side); |
|
| 809 | - break; |
|
| 805 | + case "top": |
|
| 806 | + case "left": |
|
| 807 | + $shade = array_map(array($this, "_shade"), $color); |
|
| 808 | + $this->_border_solid($x, $y, $length, $shade, $widths, $side); |
|
| 809 | + break; |
|
| 810 | 810 | |
| 811 | - case "bottom": |
|
| 812 | - case "right": |
|
| 813 | - $tint = array_map(array($this, "_tint"), $color); |
|
| 814 | - $this->_border_solid($x, $y, $length, $tint, $widths, $side); |
|
| 815 | - break; |
|
| 811 | + case "bottom": |
|
| 812 | + case "right": |
|
| 813 | + $tint = array_map(array($this, "_tint"), $color); |
|
| 814 | + $this->_border_solid($x, $y, $length, $tint, $widths, $side); |
|
| 815 | + break; |
|
| 816 | 816 | |
| 817 | - default: |
|
| 818 | - return; |
|
| 817 | + default: |
|
| 818 | + return; |
|
| 819 | 819 | } |
| 820 | 820 | } |
| 821 | 821 | |
@@ -823,20 +823,20 @@ discard block |
||
| 823 | 823 | list($top, $right, $bottom, $left) = $widths; |
| 824 | 824 | |
| 825 | 825 | switch ($side) { |
| 826 | - case "top": |
|
| 827 | - case "left": |
|
| 828 | - $tint = array_map(array($this, "_tint"), $color); |
|
| 829 | - $this->_border_solid($x, $y, $length, $tint, $widths, $side); |
|
| 830 | - break; |
|
| 831 | - |
|
| 832 | - case "bottom": |
|
| 833 | - case "right": |
|
| 834 | - $shade = array_map(array($this, "_shade"), $color); |
|
| 835 | - $this->_border_solid($x, $y, $length, $shade, $widths, $side); |
|
| 836 | - break; |
|
| 837 | - |
|
| 838 | - default: |
|
| 839 | - return; |
|
| 826 | + case "top": |
|
| 827 | + case "left": |
|
| 828 | + $tint = array_map(array($this, "_tint"), $color); |
|
| 829 | + $this->_border_solid($x, $y, $length, $tint, $widths, $side); |
|
| 830 | + break; |
|
| 831 | + |
|
| 832 | + case "bottom": |
|
| 833 | + case "right": |
|
| 834 | + $shade = array_map(array($this, "_shade"), $color); |
|
| 835 | + $this->_border_solid($x, $y, $length, $shade, $widths, $side); |
|
| 836 | + break; |
|
| 837 | + |
|
| 838 | + default: |
|
| 839 | + return; |
|
| 840 | 840 | |
| 841 | 841 | } |
| 842 | 842 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | $sheet = $style->get_stylesheet(); |
| 110 | 110 | |
| 111 | 111 | // Skip degenerate cases |
| 112 | - if ( $width == 0 || $height == 0 ) |
|
| 112 | + if ($width == 0 || $height == 0) |
|
| 113 | 113 | return; |
| 114 | 114 | |
| 115 | 115 | //debugpng |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | $sheet->get_base_path()); |
| 122 | 122 | |
| 123 | 123 | // Bail if the image is no good |
| 124 | - if ( $img === DOMPDF_LIB_DIR . "/res/broken_image.png" ) |
|
| 124 | + if ($img === DOMPDF_LIB_DIR."/res/broken_image.png") |
|
| 125 | 125 | return; |
| 126 | 126 | |
| 127 | 127 | //Try to optimize away reading and composing of same background multiple times |
@@ -140,35 +140,35 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | //Increase background resolution and dependent box size according to image resolution to be placed in |
| 142 | 142 | //Then image can be copied in without resize |
| 143 | - $bg_width = round((float)($width * DOMPDF_DPI) / 72); |
|
| 144 | - $bg_height = round((float)($height * DOMPDF_DPI) / 72); |
|
| 143 | + $bg_width = round((float) ($width * DOMPDF_DPI) / 72); |
|
| 144 | + $bg_height = round((float) ($height * DOMPDF_DPI) / 72); |
|
| 145 | 145 | |
| 146 | 146 | //Need %bg_x, $bg_y as background pos, where img starts, converted to pixel |
| 147 | 147 | |
| 148 | 148 | list($bg_x, $bg_y) = $style->background_position; |
| 149 | 149 | |
| 150 | - if ( is_percent($bg_x) ) { |
|
| 150 | + if (is_percent($bg_x)) { |
|
| 151 | 151 | // The point $bg_x % from the left edge of the image is placed |
| 152 | 152 | // $bg_x % from the left edge of the background rectangle |
| 153 | - $p = ((float)$bg_x)/100.0; |
|
| 153 | + $p = ((float) $bg_x) / 100.0; |
|
| 154 | 154 | $x1 = $p * $img_w; |
| 155 | 155 | $x2 = $p * $bg_width; |
| 156 | 156 | |
| 157 | 157 | $bg_x = round($x2 - $x1); |
| 158 | 158 | } else { |
| 159 | - $bg_x = round((float)($style->length_in_pt($bg_x)*DOMPDF_DPI) / 72); |
|
| 159 | + $bg_x = round((float) ($style->length_in_pt($bg_x) * DOMPDF_DPI) / 72); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if ( is_percent($bg_y) ) { |
|
| 162 | + if (is_percent($bg_y)) { |
|
| 163 | 163 | // The point $bg_y % from the left edge of the image is placed |
| 164 | 164 | // $bg_y % from the left edge of the background rectangle |
| 165 | - $p = ((float)$bg_y)/100.0; |
|
| 165 | + $p = ((float) $bg_y) / 100.0; |
|
| 166 | 166 | $y1 = $p * $img_h; |
| 167 | 167 | $y2 = $p * $bg_height; |
| 168 | 168 | |
| 169 | 169 | $bg_y = round($y2 - $y1); |
| 170 | 170 | } else { |
| 171 | - $bg_y = round((float)($style->length_in_pt($bg_y)*DOMPDF_DPI) / 72); |
|
| 171 | + $bg_y = round((float) ($style->length_in_pt($bg_y) * DOMPDF_DPI) / 72); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | //clip background to the image area on partial repeat. Nothing to do if img off area |
@@ -176,12 +176,12 @@ discard block |
||
| 176 | 176 | //On no repeat with positive offset: move size/start to have offset==0 |
| 177 | 177 | //Handle x/y Dimensions separately |
| 178 | 178 | |
| 179 | - if ( $repeat !== "repeat" && $repeat !== "repeat-x" ) { |
|
| 179 | + if ($repeat !== "repeat" && $repeat !== "repeat-x") { |
|
| 180 | 180 | //No repeat x |
| 181 | 181 | if ($bg_x < 0) { |
| 182 | 182 | $bg_width = $img_w + $bg_x; |
| 183 | 183 | } else { |
| 184 | - $x += ($bg_x * 72)/DOMPDF_DPI; |
|
| 184 | + $x += ($bg_x * 72) / DOMPDF_DPI; |
|
| 185 | 185 | $bg_width = $bg_width - $bg_x; |
| 186 | 186 | if ($bg_width > $img_w) { |
| 187 | 187 | $bg_width = $img_w; |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | if ($bg_width <= 0) { |
| 192 | 192 | return; |
| 193 | 193 | } |
| 194 | - $width = (float)($bg_width * 72)/DOMPDF_DPI; |
|
| 194 | + $width = (float) ($bg_width * 72) / DOMPDF_DPI; |
|
| 195 | 195 | } else { |
| 196 | 196 | //repeat x |
| 197 | 197 | if ($bg_x < 0) { |
@@ -204,12 +204,12 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - if ( $repeat !== "repeat" && $repeat !== "repeat-y" ) { |
|
| 207 | + if ($repeat !== "repeat" && $repeat !== "repeat-y") { |
|
| 208 | 208 | //no repeat y |
| 209 | 209 | if ($bg_y < 0) { |
| 210 | 210 | $bg_height = $img_h + $bg_y; |
| 211 | 211 | } else { |
| 212 | - $y += ($bg_y * 72)/DOMPDF_DPI; |
|
| 212 | + $y += ($bg_y * 72) / DOMPDF_DPI; |
|
| 213 | 213 | $bg_height = $bg_height - $bg_y; |
| 214 | 214 | if ($bg_height > $img_h) { |
| 215 | 215 | $bg_height = $img_h; |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | if ($bg_height <= 0) { |
| 220 | 220 | return; |
| 221 | 221 | } |
| 222 | - $height = (float)($bg_height * 72)/DOMPDF_DPI; |
|
| 222 | + $height = (float) ($bg_height * 72) / DOMPDF_DPI; |
|
| 223 | 223 | } else { |
| 224 | 224 | //repeat y |
| 225 | 225 | if ($bg_y < 0) { |
@@ -233,14 +233,14 @@ discard block |
||
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | //Optimization, if repeat has no effect |
| 236 | - if ( $repeat === "repeat" && $bg_y <= 0 && $img_h+$bg_y >= $bg_height ) { |
|
| 236 | + if ($repeat === "repeat" && $bg_y <= 0 && $img_h + $bg_y >= $bg_height) { |
|
| 237 | 237 | $repeat = "repeat-x"; |
| 238 | 238 | } |
| 239 | - if ( $repeat === "repeat" && $bg_x <= 0 && $img_w+$bg_x >= $bg_width ) { |
|
| 239 | + if ($repeat === "repeat" && $bg_x <= 0 && $img_w + $bg_x >= $bg_width) { |
|
| 240 | 240 | $repeat = "repeat-y"; |
| 241 | 241 | } |
| 242 | - if ( ($repeat === "repeat-x" && $bg_x <= 0 && $img_w+$bg_x >= $bg_width) || |
|
| 243 | - ($repeat === "repeat-y" && $bg_y <= 0 && $img_h+$bg_y >= $bg_height) ) { |
|
| 242 | + if (($repeat === "repeat-x" && $bg_x <= 0 && $img_w + $bg_x >= $bg_width) || |
|
| 243 | + ($repeat === "repeat-y" && $bg_y <= 0 && $img_h + $bg_y >= $bg_height)) { |
|
| 244 | 244 | $repeat = "no-repeat"; |
| 245 | 245 | } |
| 246 | 246 | |
@@ -281,10 +281,10 @@ discard block |
||
| 281 | 281 | //Optimization to avoid multiple times rendering the same image. |
| 282 | 282 | //If check functions are existing and identical image already cached, |
| 283 | 283 | //then skip creation of duplicate, because it is not needed by addImagePng |
| 284 | - if ( method_exists( $this->_canvas, "get_cpdf" ) && |
|
| 285 | - method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) && |
|
| 286 | - method_exists( $this->_canvas->get_cpdf(), "image_iscached" ) && |
|
| 287 | - $this->_canvas->get_cpdf()->image_iscached($filedummy) ) { |
|
| 284 | + if (method_exists($this->_canvas, "get_cpdf") && |
|
| 285 | + method_exists($this->_canvas->get_cpdf(), "addImagePng") && |
|
| 286 | + method_exists($this->_canvas->get_cpdf(), "image_iscached") && |
|
| 287 | + $this->_canvas->get_cpdf()->image_iscached($filedummy)) { |
|
| 288 | 288 | $bg = null; |
| 289 | 289 | |
| 290 | 290 | //debugpng |
@@ -327,15 +327,15 @@ discard block |
||
| 327 | 327 | //to keep the transparency when copying over the non transparent parts of the tiles. |
| 328 | 328 | $ti = imagecolortransparent($src); |
| 329 | 329 | if ($ti >= 0) { |
| 330 | - $tc = imagecolorsforindex($src,$ti); |
|
| 331 | - $ti = imagecolorallocate($bg,$tc['red'],$tc['green'],$tc['blue']); |
|
| 332 | - imagefill($bg,0,0,$ti); |
|
| 330 | + $tc = imagecolorsforindex($src, $ti); |
|
| 331 | + $ti = imagecolorallocate($bg, $tc['red'], $tc['green'], $tc['blue']); |
|
| 332 | + imagefill($bg, 0, 0, $ti); |
|
| 333 | 333 | imagecolortransparent($bg, $ti); |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | //This has only an effect for the non repeatable dimension. |
| 337 | 337 | //compute start of src and dest coordinates of the single copy |
| 338 | - if ( $bg_x < 0 ) { |
|
| 338 | + if ($bg_x < 0) { |
|
| 339 | 339 | $dst_x = 0; |
| 340 | 340 | $src_x = -$bg_x; |
| 341 | 341 | } else { |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | $dst_x = $bg_x; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | - if ( $bg_y < 0 ) { |
|
| 346 | + if ($bg_y < 0) { |
|
| 347 | 347 | $dst_y = 0; |
| 348 | 348 | $src_y = -$bg_y; |
| 349 | 349 | } else { |
@@ -358,15 +358,15 @@ discard block |
||
| 358 | 358 | |
| 359 | 359 | // Copy regions from the source image to the background |
| 360 | 360 | |
| 361 | - if ( $repeat === "no-repeat" ) { |
|
| 361 | + if ($repeat === "no-repeat") { |
|
| 362 | 362 | |
| 363 | 363 | // Simply place the image on the background |
| 364 | 364 | imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $img_h); |
| 365 | 365 | |
| 366 | - } else if ( $repeat === "repeat-x" ) { |
|
| 366 | + } else if ($repeat === "repeat-x") { |
|
| 367 | 367 | |
| 368 | - for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) { |
|
| 369 | - if ( $bg_x < 0 ) { |
|
| 368 | + for ($bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w) { |
|
| 369 | + if ($bg_x < 0) { |
|
| 370 | 370 | $dst_x = 0; |
| 371 | 371 | $src_x = -$bg_x; |
| 372 | 372 | $w = $img_w + $bg_x; |
@@ -378,10 +378,10 @@ discard block |
||
| 378 | 378 | imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $img_h); |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - } else if ( $repeat === "repeat-y" ) { |
|
| 381 | + } else if ($repeat === "repeat-y") { |
|
| 382 | 382 | |
| 383 | - for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) { |
|
| 384 | - if ( $bg_y < 0 ) { |
|
| 383 | + for ($bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h) { |
|
| 384 | + if ($bg_y < 0) { |
|
| 385 | 385 | $dst_y = 0; |
| 386 | 386 | $src_y = -$bg_y; |
| 387 | 387 | $h = $img_h + $bg_y; |
@@ -394,12 +394,12 @@ discard block |
||
| 394 | 394 | |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - } else if ( $repeat === "repeat" ) { |
|
| 397 | + } else if ($repeat === "repeat") { |
|
| 398 | 398 | |
| 399 | - for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) { |
|
| 400 | - for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) { |
|
| 399 | + for ($bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h) { |
|
| 400 | + for ($bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w) { |
|
| 401 | 401 | |
| 402 | - if ( $bg_x < 0 ) { |
|
| 402 | + if ($bg_x < 0) { |
|
| 403 | 403 | $dst_x = 0; |
| 404 | 404 | $src_x = -$bg_x; |
| 405 | 405 | $w = $img_w + $bg_x; |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | $w = $img_w; |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - if ( $bg_y < 0 ) { |
|
| 412 | + if ($bg_y < 0) { |
|
| 413 | 413 | $dst_y = 0; |
| 414 | 414 | $src_y = -$bg_y; |
| 415 | 415 | $h = $img_h + $bg_y; |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | //$src: GD object of original image |
| 439 | 439 | //When using cpdf and optimization to direct png creation from gd object is available, |
| 440 | 440 | //don't create temp file, but place gd object directly into the pdf |
| 441 | - if ( method_exists( $this->_canvas, "get_cpdf" ) && method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) ) { |
|
| 441 | + if (method_exists($this->_canvas, "get_cpdf") && method_exists($this->_canvas->get_cpdf(), "addImagePng")) { |
|
| 442 | 442 | //Note: CPDF_Adapter image converts y position |
| 443 | 443 | $this->_canvas->get_cpdf()->addImagePng( |
| 444 | 444 | $filedummy, |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | protected function _border_dotted($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
| 468 | 468 | list($top, $right, $bottom, $left) = $widths; |
| 469 | 469 | |
| 470 | - if ( $$side < 2 ) |
|
| 470 | + if ($$side < 2) |
|
| 471 | 471 | $dash = array($$side, 2); |
| 472 | 472 | else |
| 473 | 473 | $dash = array($$side); |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | switch ($side) { |
| 530 | 530 | |
| 531 | 531 | case "top": |
| 532 | - if ( $corner_style === "bevel" ) { |
|
| 532 | + if ($corner_style === "bevel") { |
|
| 533 | 533 | |
| 534 | 534 | $points = array($x, $y, |
| 535 | 535 | $x + $length, $y, |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | break; |
| 543 | 543 | |
| 544 | 544 | case "bottom": |
| 545 | - if ( $corner_style === "bevel" ) { |
|
| 545 | + if ($corner_style === "bevel") { |
|
| 546 | 546 | $points = array($x, $y, |
| 547 | 547 | $x + $length, $y, |
| 548 | 548 | $x + $length - $right, $y - $bottom, |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | break; |
| 555 | 555 | |
| 556 | 556 | case "left": |
| 557 | - if ( $corner_style === "bevel" ) { |
|
| 557 | + if ($corner_style === "bevel") { |
|
| 558 | 558 | $points = array($x, $y, |
| 559 | 559 | $x, $y + $length, |
| 560 | 560 | $x + $left, $y + $length - $bottom, |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | break; |
| 567 | 567 | |
| 568 | 568 | case "right": |
| 569 | - if ( $corner_style === "bevel" ) { |
|
| 569 | + if ($corner_style === "bevel") { |
|
| 570 | 570 | $points = array($x, $y, |
| 571 | 571 | $x, $y + $length, |
| 572 | 572 | $x - $right, $y + $length - $bottom, |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | switch ($side) { |
| 597 | 597 | |
| 598 | 598 | case "top": |
| 599 | - if ( $corner_style === "bevel" ) { |
|
| 599 | + if ($corner_style === "bevel") { |
|
| 600 | 600 | $left_line_width = $left / 4; |
| 601 | 601 | $right_line_width = $right / 4; |
| 602 | 602 | |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | break; |
| 621 | 621 | |
| 622 | 622 | case "bottom": |
| 623 | - if ( $corner_style === "bevel" ) { |
|
| 623 | + if ($corner_style === "bevel") { |
|
| 624 | 624 | $left_line_width = $left / 4; |
| 625 | 625 | $right_line_width = $right / 4; |
| 626 | 626 | |
@@ -644,7 +644,7 @@ discard block |
||
| 644 | 644 | break; |
| 645 | 645 | |
| 646 | 646 | case "left": |
| 647 | - if ( $corner_style === "bevel" ) { |
|
| 647 | + if ($corner_style === "bevel") { |
|
| 648 | 648 | $top_line_width = $top / 4; |
| 649 | 649 | $bottom_line_width = $bottom / 4; |
| 650 | 650 | |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | break; |
| 669 | 669 | |
| 670 | 670 | case "right": |
| 671 | - if ( $corner_style === "bevel" ) { |
|
| 671 | + if ($corner_style === "bevel") { |
|
| 672 | 672 | $top_line_width = $top / 4; |
| 673 | 673 | $bottom_line_width = $bottom / 4; |
| 674 | 674 | |
@@ -784,14 +784,14 @@ discard block |
||
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | protected function _tint($c) { |
| 787 | - if ( !is_numeric($c) ) |
|
| 787 | + if (!is_numeric($c)) |
|
| 788 | 788 | return $c; |
| 789 | 789 | |
| 790 | 790 | return min(1, $c + 0.66); |
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | protected function _shade($c) { |
| 794 | - if ( !is_numeric($c) ) |
|
| 794 | + if (!is_numeric($c)) |
|
| 795 | 795 | return $c; |
| 796 | 796 | |
| 797 | 797 | return max(0, $c - 0.66); |
@@ -109,11 +109,14 @@ discard block |
||
| 109 | 109 | $sheet = $style->get_stylesheet(); |
| 110 | 110 | |
| 111 | 111 | // Skip degenerate cases |
| 112 | - if ( $width == 0 || $height == 0 ) |
|
| 113 | - return; |
|
| 112 | + if ( $width == 0 || $height == 0 ) { |
|
| 113 | + return; |
|
| 114 | + } |
|
| 114 | 115 | |
| 115 | 116 | //debugpng |
| 116 | - if (DEBUGPNG) print '[_background_image '.$url.']'; |
|
| 117 | + if (DEBUGPNG) { |
|
| 118 | + print '[_background_image '.$url.']'; |
|
| 119 | + } |
|
| 117 | 120 | |
| 118 | 121 | list($img, $ext) = Image_Cache::resolve_url($url, |
| 119 | 122 | $sheet->get_protocol(), |
@@ -121,8 +124,9 @@ discard block |
||
| 121 | 124 | $sheet->get_base_path()); |
| 122 | 125 | |
| 123 | 126 | // Bail if the image is no good |
| 124 | - if ( $img === DOMPDF_LIB_DIR . "/res/broken_image.png" ) |
|
| 125 | - return; |
|
| 127 | + if ( $img === DOMPDF_LIB_DIR . "/res/broken_image.png" ) { |
|
| 128 | + return; |
|
| 129 | + } |
|
| 126 | 130 | |
| 127 | 131 | //Try to optimize away reading and composing of same background multiple times |
| 128 | 132 | //Postponing read with imagecreatefrom ...() |
@@ -446,16 +450,21 @@ discard block |
||
| 446 | 450 | } else { |
| 447 | 451 | $tmp_file = tempnam(DOMPDF_TEMP_DIR, "bg_dompdf_img_").'.png'; |
| 448 | 452 | //debugpng |
| 449 | - if (DEBUGPNG) print '[_background_image '.$tmp_file.']'; |
|
| 453 | + if (DEBUGPNG) { |
|
| 454 | + print '[_background_image '.$tmp_file.']'; |
|
| 455 | + } |
|
| 450 | 456 | |
| 451 | 457 | imagepng($bg, $tmp_file); |
| 452 | 458 | $this->_canvas->image($tmp_file, "png", $x, $y, $width, $height); |
| 453 | 459 | |
| 454 | 460 | //debugpng |
| 455 | - if (DEBUGPNG) print '[_background_image unlink '.$tmp_file.']'; |
|
| 461 | + if (DEBUGPNG) { |
|
| 462 | + print '[_background_image unlink '.$tmp_file.']'; |
|
| 463 | + } |
|
| 456 | 464 | |
| 457 | - if (!DEBUGKEEPTEMP) |
|
| 458 | - unlink($tmp_file); |
|
| 465 | + if (!DEBUGKEEPTEMP) { |
|
| 466 | + unlink($tmp_file); |
|
| 467 | + } |
|
| 459 | 468 | } |
| 460 | 469 | } |
| 461 | 470 | |
@@ -467,10 +476,11 @@ discard block |
||
| 467 | 476 | protected function _border_dotted($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
| 468 | 477 | list($top, $right, $bottom, $left) = $widths; |
| 469 | 478 | |
| 470 | - if ( $$side < 2 ) |
|
| 471 | - $dash = array($$side, 2); |
|
| 472 | - else |
|
| 473 | - $dash = array($$side); |
|
| 479 | + if ( $$side < 2 ) { |
|
| 480 | + $dash = array($$side, 2); |
|
| 481 | + } else { |
|
| 482 | + $dash = array($$side); |
|
| 483 | + } |
|
| 474 | 484 | |
| 475 | 485 | |
| 476 | 486 | switch ($side) { |
@@ -536,8 +546,9 @@ discard block |
||
| 536 | 546 | $x + $length - $right, $y + $top, |
| 537 | 547 | $x + $left, $y + $top); |
| 538 | 548 | $this->_canvas->polygon($points, $color, null, null, true); |
| 539 | - } else |
|
| 540 | - $this->_canvas->filled_rectangle($x, $y, $length, $top, $color); |
|
| 549 | + } else { |
|
| 550 | + $this->_canvas->filled_rectangle($x, $y, $length, $top, $color); |
|
| 551 | + } |
|
| 541 | 552 | |
| 542 | 553 | break; |
| 543 | 554 | |
@@ -548,8 +559,9 @@ discard block |
||
| 548 | 559 | $x + $length - $right, $y - $bottom, |
| 549 | 560 | $x + $left, $y - $bottom); |
| 550 | 561 | $this->_canvas->polygon($points, $color, null, null, true); |
| 551 | - } else |
|
| 552 | - $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color); |
|
| 562 | + } else { |
|
| 563 | + $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color); |
|
| 564 | + } |
|
| 553 | 565 | |
| 554 | 566 | break; |
| 555 | 567 | |
@@ -560,8 +572,9 @@ discard block |
||
| 560 | 572 | $x + $left, $y + $length - $bottom, |
| 561 | 573 | $x + $left, $y + $top); |
| 562 | 574 | $this->_canvas->polygon($points, $color, null, null, true); |
| 563 | - } else |
|
| 564 | - $this->_canvas->filled_rectangle($x, $y, $left, $length, $color); |
|
| 575 | + } else { |
|
| 576 | + $this->_canvas->filled_rectangle($x, $y, $left, $length, $color); |
|
| 577 | + } |
|
| 565 | 578 | |
| 566 | 579 | break; |
| 567 | 580 | |
@@ -572,8 +585,9 @@ discard block |
||
| 572 | 585 | $x - $right, $y + $length - $bottom, |
| 573 | 586 | $x - $right, $y + $top); |
| 574 | 587 | $this->_canvas->polygon($points, $color, null, null, true); |
| 575 | - } else |
|
| 576 | - $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color); |
|
| 588 | + } else { |
|
| 589 | + $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color); |
|
| 590 | + } |
|
| 577 | 591 | |
| 578 | 592 | break; |
| 579 | 593 | |
@@ -784,15 +798,17 @@ discard block |
||
| 784 | 798 | } |
| 785 | 799 | |
| 786 | 800 | protected function _tint($c) { |
| 787 | - if ( !is_numeric($c) ) |
|
| 788 | - return $c; |
|
| 801 | + if ( !is_numeric($c) ) { |
|
| 802 | + return $c; |
|
| 803 | + } |
|
| 789 | 804 | |
| 790 | 805 | return min(1, $c + 0.66); |
| 791 | 806 | } |
| 792 | 807 | |
| 793 | 808 | protected function _shade($c) { |
| 794 | - if ( !is_numeric($c) ) |
|
| 795 | - return $c; |
|
| 809 | + if ( !is_numeric($c) ) { |
|
| 810 | + return $c; |
|
| 811 | + } |
|
| 796 | 812 | |
| 797 | 813 | return max(0, $c - 0.66); |
| 798 | 814 | } |
@@ -1,54 +1,54 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
| 4 | - * |
|
| 5 | - * File: $RCSfile: abstract_renderer.cls.php,v $ |
|
| 6 | - * Created on: 2004-06-01 |
|
| 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 | - * - On background image |
|
| 43 | - * - Clip invisible areas from background images, then merge identical |
|
| 44 | - * image/size/offset to a single image. |
|
| 45 | - * - Fix rounding of background image size. |
|
| 46 | - * - Fix background image position given as percent |
|
| 47 | - * - Check if identical image is already cached by cpdf. Then do not create |
|
| 48 | - * duplicates to save memory and CPU time |
|
| 49 | - * - Fix skipping of image repetition if area is too small |
|
| 50 | - * - Do not create temporary files, but pass gd object directly |
|
| 51 | - */ |
|
| 3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
| 4 | + * |
|
| 5 | + * File: $RCSfile: abstract_renderer.cls.php,v $ |
|
| 6 | + * Created on: 2004-06-01 |
|
| 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 | + * - On background image |
|
| 43 | + * - Clip invisible areas from background images, then merge identical |
|
| 44 | + * image/size/offset to a single image. |
|
| 45 | + * - Fix rounding of background image size. |
|
| 46 | + * - Fix background image position given as percent |
|
| 47 | + * - Check if identical image is already cached by cpdf. Then do not create |
|
| 48 | + * duplicates to save memory and CPU time |
|
| 49 | + * - Fix skipping of image repetition if area is too small |
|
| 50 | + * - Do not create temporary files, but pass gd object directly |
|
| 51 | + */ |
|
| 52 | 52 | |
| 53 | 53 | /* $Id: abstract_renderer.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
| 54 | 54 | |
@@ -60,57 +60,57 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | abstract class Abstract_Renderer { |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Rendering backend |
|
| 65 | - * |
|
| 66 | - * @var Canvas |
|
| 67 | - */ |
|
| 68 | - protected $_canvas; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Current dompdf instance |
|
| 72 | - * |
|
| 73 | - * @var DOMPDF |
|
| 74 | - */ |
|
| 75 | - protected $_dompdf; |
|
| 63 | + /** |
|
| 64 | + * Rendering backend |
|
| 65 | + * |
|
| 66 | + * @var Canvas |
|
| 67 | + */ |
|
| 68 | + protected $_canvas; |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * Current dompdf instance |
|
| 72 | + * |
|
| 73 | + * @var DOMPDF |
|
| 74 | + */ |
|
| 75 | + protected $_dompdf; |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Class constructor |
|
| 79 | - * |
|
| 80 | - * @param DOMPDF $dompdf The current dompdf instance |
|
| 81 | - */ |
|
| 82 | - function __construct(DOMPDF $dompdf) { |
|
| 77 | + /** |
|
| 78 | + * Class constructor |
|
| 79 | + * |
|
| 80 | + * @param DOMPDF $dompdf The current dompdf instance |
|
| 81 | + */ |
|
| 82 | + function __construct(DOMPDF $dompdf) { |
|
| 83 | 83 | $this->_dompdf = $dompdf; |
| 84 | 84 | $this->_canvas = $dompdf->get_canvas(); |
| 85 | - } |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * Render a frame. |
|
| 89 | - * |
|
| 90 | - * Specialized in child classes |
|
| 91 | - * |
|
| 92 | - * @param Frame $frame The frame to render |
|
| 93 | - */ |
|
| 94 | - abstract function render(Frame $frame); |
|
| 95 | - |
|
| 96 | - //........................................................................ |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * Render a background image over a rectangular area |
|
| 100 | - * |
|
| 101 | - * @param string $img The background image to load |
|
| 102 | - * @param float $x The left edge of the rectangular area |
|
| 103 | - * @param float $y The top edge of the rectangular area |
|
| 104 | - * @param float $width The width of the rectangular area |
|
| 105 | - * @param float $height The height of the rectangular area |
|
| 106 | - * @param Style $style The associated Style object |
|
| 107 | - */ |
|
| 108 | - protected function _background_image($url, $x, $y, $width, $height, $style) { |
|
| 87 | + /** |
|
| 88 | + * Render a frame. |
|
| 89 | + * |
|
| 90 | + * Specialized in child classes |
|
| 91 | + * |
|
| 92 | + * @param Frame $frame The frame to render |
|
| 93 | + */ |
|
| 94 | + abstract function render(Frame $frame); |
|
| 95 | + |
|
| 96 | + //........................................................................ |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * Render a background image over a rectangular area |
|
| 100 | + * |
|
| 101 | + * @param string $img The background image to load |
|
| 102 | + * @param float $x The left edge of the rectangular area |
|
| 103 | + * @param float $y The top edge of the rectangular area |
|
| 104 | + * @param float $width The width of the rectangular area |
|
| 105 | + * @param float $height The height of the rectangular area |
|
| 106 | + * @param Style $style The associated Style object |
|
| 107 | + */ |
|
| 108 | + protected function _background_image($url, $x, $y, $width, $height, $style) { |
|
| 109 | 109 | $sheet = $style->get_stylesheet(); |
| 110 | 110 | |
| 111 | 111 | // Skip degenerate cases |
| 112 | 112 | if ( $width == 0 || $height == 0 ) |
| 113 | - return; |
|
| 113 | + return; |
|
| 114 | 114 | |
| 115 | 115 | //debugpng |
| 116 | 116 | if (DEBUGPNG) print '[_background_image '.$url.']'; |
@@ -122,24 +122,24 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | // Bail if the image is no good |
| 124 | 124 | if ( $img === DOMPDF_LIB_DIR . "/res/broken_image.png" ) |
| 125 | - return; |
|
| 125 | + return; |
|
| 126 | 126 | |
| 127 | - //Try to optimize away reading and composing of same background multiple times |
|
| 128 | - //Postponing read with imagecreatefrom ...() |
|
| 129 | - //final composition paramters and name not known yet |
|
| 130 | - //Therefore read dimension directly from file, instead of creating gd object first. |
|
| 127 | + //Try to optimize away reading and composing of same background multiple times |
|
| 128 | + //Postponing read with imagecreatefrom ...() |
|
| 129 | + //final composition paramters and name not known yet |
|
| 130 | + //Therefore read dimension directly from file, instead of creating gd object first. |
|
| 131 | 131 | //$img_w = imagesx($src); $img_h = imagesy($src); |
| 132 | 132 | |
| 133 | 133 | list($img_w, $img_h) = getimagesize($img); |
| 134 | 134 | if (!isset($img_w) || $img_w == 0 || !isset($img_h) || $img_h == 0) { |
| 135 | - return; |
|
| 135 | + return; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | $repeat = $style->background_repeat; |
| 139 | 139 | $bg_color = $style->background_color; |
| 140 | 140 | |
| 141 | - //Increase background resolution and dependent box size according to image resolution to be placed in |
|
| 142 | - //Then image can be copied in without resize |
|
| 141 | + //Increase background resolution and dependent box size according to image resolution to be placed in |
|
| 142 | + //Then image can be copied in without resize |
|
| 143 | 143 | $bg_width = round((float)($width * DOMPDF_DPI) / 72); |
| 144 | 144 | $bg_height = round((float)($height * DOMPDF_DPI) / 72); |
| 145 | 145 | |
@@ -148,27 +148,27 @@ discard block |
||
| 148 | 148 | list($bg_x, $bg_y) = $style->background_position; |
| 149 | 149 | |
| 150 | 150 | if ( is_percent($bg_x) ) { |
| 151 | - // The point $bg_x % from the left edge of the image is placed |
|
| 152 | - // $bg_x % from the left edge of the background rectangle |
|
| 153 | - $p = ((float)$bg_x)/100.0; |
|
| 154 | - $x1 = $p * $img_w; |
|
| 155 | - $x2 = $p * $bg_width; |
|
| 151 | + // The point $bg_x % from the left edge of the image is placed |
|
| 152 | + // $bg_x % from the left edge of the background rectangle |
|
| 153 | + $p = ((float)$bg_x)/100.0; |
|
| 154 | + $x1 = $p * $img_w; |
|
| 155 | + $x2 = $p * $bg_width; |
|
| 156 | 156 | |
| 157 | - $bg_x = round($x2 - $x1); |
|
| 157 | + $bg_x = round($x2 - $x1); |
|
| 158 | 158 | } else { |
| 159 | - $bg_x = round((float)($style->length_in_pt($bg_x)*DOMPDF_DPI) / 72); |
|
| 159 | + $bg_x = round((float)($style->length_in_pt($bg_x)*DOMPDF_DPI) / 72); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | if ( is_percent($bg_y) ) { |
| 163 | - // The point $bg_y % from the left edge of the image is placed |
|
| 164 | - // $bg_y % from the left edge of the background rectangle |
|
| 165 | - $p = ((float)$bg_y)/100.0; |
|
| 166 | - $y1 = $p * $img_h; |
|
| 167 | - $y2 = $p * $bg_height; |
|
| 163 | + // The point $bg_y % from the left edge of the image is placed |
|
| 164 | + // $bg_y % from the left edge of the background rectangle |
|
| 165 | + $p = ((float)$bg_y)/100.0; |
|
| 166 | + $y1 = $p * $img_h; |
|
| 167 | + $y2 = $p * $bg_height; |
|
| 168 | 168 | |
| 169 | - $bg_y = round($y2 - $y1); |
|
| 169 | + $bg_y = round($y2 - $y1); |
|
| 170 | 170 | } else { |
| 171 | - $bg_y = round((float)($style->length_in_pt($bg_y)*DOMPDF_DPI) / 72); |
|
| 171 | + $bg_y = round((float)($style->length_in_pt($bg_y)*DOMPDF_DPI) / 72); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | //clip background to the image area on partial repeat. Nothing to do if img off area |
@@ -177,79 +177,79 @@ discard block |
||
| 177 | 177 | //Handle x/y Dimensions separately |
| 178 | 178 | |
| 179 | 179 | if ( $repeat !== "repeat" && $repeat !== "repeat-x" ) { |
| 180 | - //No repeat x |
|
| 181 | - if ($bg_x < 0) { |
|
| 180 | + //No repeat x |
|
| 181 | + if ($bg_x < 0) { |
|
| 182 | 182 | $bg_width = $img_w + $bg_x; |
| 183 | - } else { |
|
| 183 | + } else { |
|
| 184 | 184 | $x += ($bg_x * 72)/DOMPDF_DPI; |
| 185 | 185 | $bg_width = $bg_width - $bg_x; |
| 186 | 186 | if ($bg_width > $img_w) { |
| 187 | - $bg_width = $img_w; |
|
| 187 | + $bg_width = $img_w; |
|
| 188 | 188 | } |
| 189 | 189 | $bg_x = 0; |
| 190 | - } |
|
| 191 | - if ($bg_width <= 0) { |
|
| 192 | - return; |
|
| 193 | - } |
|
| 194 | - $width = (float)($bg_width * 72)/DOMPDF_DPI; |
|
| 190 | + } |
|
| 191 | + if ($bg_width <= 0) { |
|
| 192 | + return; |
|
| 193 | + } |
|
| 194 | + $width = (float)($bg_width * 72)/DOMPDF_DPI; |
|
| 195 | 195 | } else { |
| 196 | - //repeat x |
|
| 197 | - if ($bg_x < 0) { |
|
| 196 | + //repeat x |
|
| 197 | + if ($bg_x < 0) { |
|
| 198 | 198 | $bg_x = - ((-$bg_x) % $img_w); |
| 199 | - } else { |
|
| 199 | + } else { |
|
| 200 | 200 | $bg_x = $bg_x % $img_w; |
| 201 | 201 | if ($bg_x > 0) { |
| 202 | - $bg_x -= $img_w; |
|
| 202 | + $bg_x -= $img_w; |
|
| 203 | + } |
|
| 203 | 204 | } |
| 204 | - } |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | if ( $repeat !== "repeat" && $repeat !== "repeat-y" ) { |
| 208 | - //no repeat y |
|
| 209 | - if ($bg_y < 0) { |
|
| 208 | + //no repeat y |
|
| 209 | + if ($bg_y < 0) { |
|
| 210 | 210 | $bg_height = $img_h + $bg_y; |
| 211 | - } else { |
|
| 211 | + } else { |
|
| 212 | 212 | $y += ($bg_y * 72)/DOMPDF_DPI; |
| 213 | 213 | $bg_height = $bg_height - $bg_y; |
| 214 | 214 | if ($bg_height > $img_h) { |
| 215 | - $bg_height = $img_h; |
|
| 215 | + $bg_height = $img_h; |
|
| 216 | 216 | } |
| 217 | 217 | $bg_y = 0; |
| 218 | - } |
|
| 219 | - if ($bg_height <= 0) { |
|
| 220 | - return; |
|
| 221 | - } |
|
| 222 | - $height = (float)($bg_height * 72)/DOMPDF_DPI; |
|
| 218 | + } |
|
| 219 | + if ($bg_height <= 0) { |
|
| 220 | + return; |
|
| 221 | + } |
|
| 222 | + $height = (float)($bg_height * 72)/DOMPDF_DPI; |
|
| 223 | 223 | } else { |
| 224 | - //repeat y |
|
| 225 | - if ($bg_y < 0) { |
|
| 224 | + //repeat y |
|
| 225 | + if ($bg_y < 0) { |
|
| 226 | 226 | $bg_y = - ((-$bg_y) % $img_h); |
| 227 | - } else { |
|
| 227 | + } else { |
|
| 228 | 228 | $bg_y = $bg_y % $img_h; |
| 229 | 229 | if ($bg_y > 0) { |
| 230 | - $bg_y -= $img_h; |
|
| 230 | + $bg_y -= $img_h; |
|
| 231 | + } |
|
| 231 | 232 | } |
| 232 | - } |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | //Optimization, if repeat has no effect |
| 236 | 236 | if ( $repeat === "repeat" && $bg_y <= 0 && $img_h+$bg_y >= $bg_height ) { |
| 237 | - $repeat = "repeat-x"; |
|
| 237 | + $repeat = "repeat-x"; |
|
| 238 | 238 | } |
| 239 | 239 | if ( $repeat === "repeat" && $bg_x <= 0 && $img_w+$bg_x >= $bg_width ) { |
| 240 | - $repeat = "repeat-y"; |
|
| 240 | + $repeat = "repeat-y"; |
|
| 241 | 241 | } |
| 242 | 242 | if ( ($repeat === "repeat-x" && $bg_x <= 0 && $img_w+$bg_x >= $bg_width) || |
| 243 | 243 | ($repeat === "repeat-y" && $bg_y <= 0 && $img_h+$bg_y >= $bg_height) ) { |
| 244 | - $repeat = "no-repeat"; |
|
| 244 | + $repeat = "no-repeat"; |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - //Use filename as indicator only |
|
| 248 | - //different names for different variants to have different copies in the pdf |
|
| 249 | - //This is not dependent of background color of box! .'_'.(is_array($bg_color) ? $bg_color["hex"] : $bg_color) |
|
| 250 | - //Note: Here, bg_* are the start values, not end values after going through the tile loops! |
|
| 247 | + //Use filename as indicator only |
|
| 248 | + //different names for different variants to have different copies in the pdf |
|
| 249 | + //This is not dependent of background color of box! .'_'.(is_array($bg_color) ? $bg_color["hex"] : $bg_color) |
|
| 250 | + //Note: Here, bg_* are the start values, not end values after going through the tile loops! |
|
| 251 | 251 | |
| 252 | - $filedummy = $img; |
|
| 252 | + $filedummy = $img; |
|
| 253 | 253 | |
| 254 | 254 | /* |
| 255 | 255 | //Make shorter strings with limited characters for cache associative array index - needed? |
@@ -274,50 +274,50 @@ discard block |
||
| 274 | 274 | } |
| 275 | 275 | */ |
| 276 | 276 | |
| 277 | - $filedummy .= '_'.$bg_width.'_'.$bg_height.'_'.$bg_x.'_'.$bg_y.'_'.$repeat; |
|
| 277 | + $filedummy .= '_'.$bg_width.'_'.$bg_height.'_'.$bg_x.'_'.$bg_y.'_'.$repeat; |
|
| 278 | 278 | //debugpng |
| 279 | 279 | //if (DEBUGPNG) print '<pre>[_background_image name '.$filedummy.']</pre>'; |
| 280 | 280 | |
| 281 | 281 | //Optimization to avoid multiple times rendering the same image. |
| 282 | 282 | //If check functions are existing and identical image already cached, |
| 283 | 283 | //then skip creation of duplicate, because it is not needed by addImagePng |
| 284 | - if ( method_exists( $this->_canvas, "get_cpdf" ) && |
|
| 285 | - method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) && |
|
| 286 | - method_exists( $this->_canvas->get_cpdf(), "image_iscached" ) && |
|
| 287 | - $this->_canvas->get_cpdf()->image_iscached($filedummy) ) { |
|
| 288 | - $bg = null; |
|
| 284 | + if ( method_exists( $this->_canvas, "get_cpdf" ) && |
|
| 285 | + method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) && |
|
| 286 | + method_exists( $this->_canvas->get_cpdf(), "image_iscached" ) && |
|
| 287 | + $this->_canvas->get_cpdf()->image_iscached($filedummy) ) { |
|
| 288 | + $bg = null; |
|
| 289 | 289 | |
| 290 | - //debugpng |
|
| 291 | - //if (DEBUGPNG) print '[_background_image skip]'; |
|
| 290 | + //debugpng |
|
| 291 | + //if (DEBUGPNG) print '[_background_image skip]'; |
|
| 292 | 292 | |
| 293 | - } else { |
|
| 293 | + } else { |
|
| 294 | 294 | |
| 295 | 295 | // Create a new image to fit over the background rectangle |
| 296 | 296 | $bg = imagecreatetruecolor($bg_width, $bg_height); |
| 297 | 297 | //anyway default |
| 298 | - //imagealphablending($img, true); |
|
| 298 | + //imagealphablending($img, true); |
|
| 299 | 299 | |
| 300 | 300 | switch (strtolower($ext)) { |
| 301 | 301 | |
| 302 | 302 | case "png": |
| 303 | 303 | $src = imagecreatefrompng($img); |
| 304 | - break; |
|
| 304 | + break; |
|
| 305 | 305 | |
| 306 | 306 | case "jpg": |
| 307 | 307 | case "jpeg": |
| 308 | 308 | $src = imagecreatefromjpeg($img); |
| 309 | - break; |
|
| 309 | + break; |
|
| 310 | 310 | |
| 311 | 311 | case "gif": |
| 312 | 312 | $src = imagecreatefromgif($img); |
| 313 | - break; |
|
| 313 | + break; |
|
| 314 | 314 | |
| 315 | 315 | default: |
| 316 | 316 | return; // Unsupported image type |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | if ($src == null) { |
| 320 | - return; |
|
| 320 | + return; |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | //Background color if box is not relevant here |
@@ -325,34 +325,34 @@ discard block |
||
| 325 | 325 | //Transparent image: The image controls the transparency and lets shine through whatever background. |
| 326 | 326 | //However on transparent imaage preset the composed image with the transparency color, |
| 327 | 327 | //to keep the transparency when copying over the non transparent parts of the tiles. |
| 328 | - $ti = imagecolortransparent($src); |
|
| 329 | - if ($ti >= 0) { |
|
| 330 | - $tc = imagecolorsforindex($src,$ti); |
|
| 331 | - $ti = imagecolorallocate($bg,$tc['red'],$tc['green'],$tc['blue']); |
|
| 332 | - imagefill($bg,0,0,$ti); |
|
| 333 | - imagecolortransparent($bg, $ti); |
|
| 328 | + $ti = imagecolortransparent($src); |
|
| 329 | + if ($ti >= 0) { |
|
| 330 | + $tc = imagecolorsforindex($src,$ti); |
|
| 331 | + $ti = imagecolorallocate($bg,$tc['red'],$tc['green'],$tc['blue']); |
|
| 332 | + imagefill($bg,0,0,$ti); |
|
| 333 | + imagecolortransparent($bg, $ti); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | //This has only an effect for the non repeatable dimension. |
| 337 | 337 | //compute start of src and dest coordinates of the single copy |
| 338 | 338 | if ( $bg_x < 0 ) { |
| 339 | - $dst_x = 0; |
|
| 340 | - $src_x = -$bg_x; |
|
| 339 | + $dst_x = 0; |
|
| 340 | + $src_x = -$bg_x; |
|
| 341 | 341 | } else { |
| 342 | - $src_x = 0; |
|
| 343 | - $dst_x = $bg_x; |
|
| 342 | + $src_x = 0; |
|
| 343 | + $dst_x = $bg_x; |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | if ( $bg_y < 0 ) { |
| 347 | - $dst_y = 0; |
|
| 348 | - $src_y = -$bg_y; |
|
| 347 | + $dst_y = 0; |
|
| 348 | + $src_y = -$bg_y; |
|
| 349 | 349 | } else { |
| 350 | - $src_y = 0; |
|
| 351 | - $dst_y = $bg_y; |
|
| 350 | + $src_y = 0; |
|
| 351 | + $dst_y = $bg_y; |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - //For historical reasons exchange meanings of variables: |
|
| 355 | - //start_* will be the start values, while bg_* will be the temporary start values in the loops |
|
| 354 | + //For historical reasons exchange meanings of variables: |
|
| 355 | + //start_* will be the start values, while bg_* will be the temporary start values in the loops |
|
| 356 | 356 | $start_x = $bg_x; |
| 357 | 357 | $start_y = $bg_y; |
| 358 | 358 | |
@@ -360,117 +360,117 @@ discard block |
||
| 360 | 360 | |
| 361 | 361 | if ( $repeat === "no-repeat" ) { |
| 362 | 362 | |
| 363 | - // Simply place the image on the background |
|
| 364 | - imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $img_h); |
|
| 363 | + // Simply place the image on the background |
|
| 364 | + imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $img_h); |
|
| 365 | 365 | |
| 366 | 366 | } else if ( $repeat === "repeat-x" ) { |
| 367 | 367 | |
| 368 | - for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) { |
|
| 368 | + for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) { |
|
| 369 | 369 | if ( $bg_x < 0 ) { |
| 370 | - $dst_x = 0; |
|
| 371 | - $src_x = -$bg_x; |
|
| 372 | - $w = $img_w + $bg_x; |
|
| 370 | + $dst_x = 0; |
|
| 371 | + $src_x = -$bg_x; |
|
| 372 | + $w = $img_w + $bg_x; |
|
| 373 | 373 | } else { |
| 374 | - $dst_x = $bg_x; |
|
| 375 | - $src_x = 0; |
|
| 376 | - $w = $img_w; |
|
| 374 | + $dst_x = $bg_x; |
|
| 375 | + $src_x = 0; |
|
| 376 | + $w = $img_w; |
|
| 377 | 377 | } |
| 378 | 378 | imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $img_h); |
| 379 | - } |
|
| 379 | + } |
|
| 380 | 380 | |
| 381 | 381 | } else if ( $repeat === "repeat-y" ) { |
| 382 | 382 | |
| 383 | - for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) { |
|
| 383 | + for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) { |
|
| 384 | 384 | if ( $bg_y < 0 ) { |
| 385 | - $dst_y = 0; |
|
| 386 | - $src_y = -$bg_y; |
|
| 387 | - $h = $img_h + $bg_y; |
|
| 385 | + $dst_y = 0; |
|
| 386 | + $src_y = -$bg_y; |
|
| 387 | + $h = $img_h + $bg_y; |
|
| 388 | 388 | } else { |
| 389 | - $dst_y = $bg_y; |
|
| 390 | - $src_y = 0; |
|
| 391 | - $h = $img_h; |
|
| 389 | + $dst_y = $bg_y; |
|
| 390 | + $src_y = 0; |
|
| 391 | + $h = $img_h; |
|
| 392 | 392 | } |
| 393 | 393 | imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $h); |
| 394 | 394 | |
| 395 | - } |
|
| 395 | + } |
|
| 396 | 396 | |
| 397 | 397 | } else if ( $repeat === "repeat" ) { |
| 398 | 398 | |
| 399 | - for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) { |
|
| 399 | + for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) { |
|
| 400 | 400 | for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) { |
| 401 | 401 | |
| 402 | - if ( $bg_x < 0 ) { |
|
| 402 | + if ( $bg_x < 0 ) { |
|
| 403 | 403 | $dst_x = 0; |
| 404 | 404 | $src_x = -$bg_x; |
| 405 | 405 | $w = $img_w + $bg_x; |
| 406 | - } else { |
|
| 406 | + } else { |
|
| 407 | 407 | $dst_x = $bg_x; |
| 408 | 408 | $src_x = 0; |
| 409 | 409 | $w = $img_w; |
| 410 | - } |
|
| 410 | + } |
|
| 411 | 411 | |
| 412 | - if ( $bg_y < 0 ) { |
|
| 412 | + if ( $bg_y < 0 ) { |
|
| 413 | 413 | $dst_y = 0; |
| 414 | 414 | $src_y = -$bg_y; |
| 415 | 415 | $h = $img_h + $bg_y; |
| 416 | - } else { |
|
| 416 | + } else { |
|
| 417 | 417 | $dst_y = $bg_y; |
| 418 | 418 | $src_y = 0; |
| 419 | 419 | $h = $img_h; |
| 420 | - } |
|
| 421 | - imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $h); |
|
| 420 | + } |
|
| 421 | + imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $h); |
|
| 422 | + } |
|
| 422 | 423 | } |
| 423 | - } |
|
| 424 | 424 | } else { |
| 425 | - print 'Unknown repeat!'; |
|
| 425 | + print 'Unknown repeat!'; |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | } /* End optimize away creation of duplicates */ |
| 429 | 429 | |
| 430 | 430 | //img: image url string |
| 431 | - //img_w, img_h: original image size in px |
|
| 432 | - //width, height: box size in pt |
|
| 433 | - //bg_width, bg_height: box size in px |
|
| 434 | - //x, y: left/top edge of box on page in pt |
|
| 435 | - //start_x, start_y: placement of image relativ to pattern |
|
| 436 | - //$repeat: repeat mode |
|
| 437 | - //$bg: GD object of result image |
|
| 438 | - //$src: GD object of original image |
|
| 431 | + //img_w, img_h: original image size in px |
|
| 432 | + //width, height: box size in pt |
|
| 433 | + //bg_width, bg_height: box size in px |
|
| 434 | + //x, y: left/top edge of box on page in pt |
|
| 435 | + //start_x, start_y: placement of image relativ to pattern |
|
| 436 | + //$repeat: repeat mode |
|
| 437 | + //$bg: GD object of result image |
|
| 438 | + //$src: GD object of original image |
|
| 439 | 439 | //When using cpdf and optimization to direct png creation from gd object is available, |
| 440 | 440 | //don't create temp file, but place gd object directly into the pdf |
| 441 | - if ( method_exists( $this->_canvas, "get_cpdf" ) && method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) ) { |
|
| 442 | - //Note: CPDF_Adapter image converts y position |
|
| 443 | - $this->_canvas->get_cpdf()->addImagePng( |
|
| 444 | - $filedummy, |
|
| 445 | - $x, $this->_canvas->get_height() - $y - $height, $width, $height, $bg); |
|
| 446 | - } else { |
|
| 447 | - $tmp_file = tempnam(DOMPDF_TEMP_DIR, "bg_dompdf_img_").'.png'; |
|
| 448 | - //debugpng |
|
| 449 | - if (DEBUGPNG) print '[_background_image '.$tmp_file.']'; |
|
| 441 | + if ( method_exists( $this->_canvas, "get_cpdf" ) && method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) ) { |
|
| 442 | + //Note: CPDF_Adapter image converts y position |
|
| 443 | + $this->_canvas->get_cpdf()->addImagePng( |
|
| 444 | + $filedummy, |
|
| 445 | + $x, $this->_canvas->get_height() - $y - $height, $width, $height, $bg); |
|
| 446 | + } else { |
|
| 447 | + $tmp_file = tempnam(DOMPDF_TEMP_DIR, "bg_dompdf_img_").'.png'; |
|
| 448 | + //debugpng |
|
| 449 | + if (DEBUGPNG) print '[_background_image '.$tmp_file.']'; |
|
| 450 | 450 | |
| 451 | - imagepng($bg, $tmp_file); |
|
| 452 | - $this->_canvas->image($tmp_file, "png", $x, $y, $width, $height); |
|
| 451 | + imagepng($bg, $tmp_file); |
|
| 452 | + $this->_canvas->image($tmp_file, "png", $x, $y, $width, $height); |
|
| 453 | 453 | |
| 454 | - //debugpng |
|
| 455 | - if (DEBUGPNG) print '[_background_image unlink '.$tmp_file.']'; |
|
| 454 | + //debugpng |
|
| 455 | + if (DEBUGPNG) print '[_background_image unlink '.$tmp_file.']'; |
|
| 456 | 456 | |
| 457 | - if (!DEBUGKEEPTEMP) |
|
| 457 | + if (!DEBUGKEEPTEMP) |
|
| 458 | 458 | unlink($tmp_file); |
| 459 | 459 | } |
| 460 | - } |
|
| 460 | + } |
|
| 461 | 461 | |
| 462 | - protected function _border_none($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
| 462 | + protected function _border_none($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
| 463 | 463 | return; |
| 464 | - } |
|
| 464 | + } |
|
| 465 | 465 | |
| 466 | - // Border rendering functions |
|
| 467 | - protected function _border_dotted($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
| 466 | + // Border rendering functions |
|
| 467 | + protected function _border_dotted($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
| 468 | 468 | list($top, $right, $bottom, $left) = $widths; |
| 469 | 469 | |
| 470 | 470 | if ( $$side < 2 ) |
| 471 | - $dash = array($$side, 2); |
|
| 471 | + $dash = array($$side, 2); |
|
| 472 | 472 | else |
| 473 | - $dash = array($$side); |
|
| 473 | + $dash = array($$side); |
|
| 474 | 474 | |
| 475 | 475 | |
| 476 | 476 | switch ($side) { |
@@ -479,24 +479,24 @@ discard block |
||
| 479 | 479 | $delta = $top / 2; |
| 480 | 480 | case "bottom": |
| 481 | 481 | $delta = isset($delta) ? $delta : -$bottom / 2; |
| 482 | - $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, $dash); |
|
| 483 | - break; |
|
| 482 | + $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, $dash); |
|
| 483 | + break; |
|
| 484 | 484 | |
| 485 | 485 | case "left": |
| 486 | 486 | $delta = $left / 2; |
| 487 | 487 | case "right": |
| 488 | 488 | $delta = isset($delta) ? $delta : - $right / 2; |
| 489 | - $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, $dash); |
|
| 490 | - break; |
|
| 489 | + $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, $dash); |
|
| 490 | + break; |
|
| 491 | 491 | |
| 492 | 492 | default: |
| 493 | 493 | return; |
| 494 | 494 | |
| 495 | 495 | } |
| 496 | - } |
|
| 496 | + } |
|
| 497 | 497 | |
| 498 | 498 | |
| 499 | - protected function _border_dashed($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
| 499 | + protected function _border_dashed($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
| 500 | 500 | list($top, $right, $bottom, $left) = $widths; |
| 501 | 501 | |
| 502 | 502 | switch ($side) { |
@@ -505,24 +505,24 @@ discard block |
||
| 505 | 505 | $delta = $top / 2; |
| 506 | 506 | case "bottom": |
| 507 | 507 | $delta = isset($delta) ? $delta : -$bottom / 2; |
| 508 | - $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, array(3 * $$side)); |
|
| 509 | - break; |
|
| 508 | + $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, array(3 * $$side)); |
|
| 509 | + break; |
|
| 510 | 510 | |
| 511 | 511 | case "left": |
| 512 | 512 | $delta = $left / 2; |
| 513 | 513 | case "right": |
| 514 | 514 | $delta = isset($delta) ? $delta : - $right / 2; |
| 515 | - $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, array(3 * $$side)); |
|
| 516 | - break; |
|
| 515 | + $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, array(3 * $$side)); |
|
| 516 | + break; |
|
| 517 | 517 | |
| 518 | 518 | default: |
| 519 | 519 | return; |
| 520 | 520 | } |
| 521 | 521 | |
| 522 | - } |
|
| 522 | + } |
|
| 523 | 523 | |
| 524 | 524 | |
| 525 | - protected function _border_solid($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
| 525 | + protected function _border_solid($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
| 526 | 526 | list($top, $right, $bottom, $left) = $widths; |
| 527 | 527 | |
| 528 | 528 | // All this polygon business is for beveled corners... |
@@ -536,10 +536,10 @@ discard block |
||
| 536 | 536 | $x + $length - $right, $y + $top, |
| 537 | 537 | $x + $left, $y + $top); |
| 538 | 538 | $this->_canvas->polygon($points, $color, null, null, true); |
| 539 | - } else |
|
| 539 | + } else |
|
| 540 | 540 | $this->_canvas->filled_rectangle($x, $y, $length, $top, $color); |
| 541 | 541 | |
| 542 | - break; |
|
| 542 | + break; |
|
| 543 | 543 | |
| 544 | 544 | case "bottom": |
| 545 | 545 | if ( $corner_style === "bevel" ) { |
@@ -548,10 +548,10 @@ discard block |
||
| 548 | 548 | $x + $length - $right, $y - $bottom, |
| 549 | 549 | $x + $left, $y - $bottom); |
| 550 | 550 | $this->_canvas->polygon($points, $color, null, null, true); |
| 551 | - } else |
|
| 551 | + } else |
|
| 552 | 552 | $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color); |
| 553 | 553 | |
| 554 | - break; |
|
| 554 | + break; |
|
| 555 | 555 | |
| 556 | 556 | case "left": |
| 557 | 557 | if ( $corner_style === "bevel" ) { |
@@ -560,10 +560,10 @@ discard block |
||
| 560 | 560 | $x + $left, $y + $length - $bottom, |
| 561 | 561 | $x + $left, $y + $top); |
| 562 | 562 | $this->_canvas->polygon($points, $color, null, null, true); |
| 563 | - } else |
|
| 563 | + } else |
|
| 564 | 564 | $this->_canvas->filled_rectangle($x, $y, $left, $length, $color); |
| 565 | 565 | |
| 566 | - break; |
|
| 566 | + break; |
|
| 567 | 567 | |
| 568 | 568 | case "right": |
| 569 | 569 | if ( $corner_style === "bevel" ) { |
@@ -572,20 +572,20 @@ discard block |
||
| 572 | 572 | $x - $right, $y + $length - $bottom, |
| 573 | 573 | $x - $right, $y + $top); |
| 574 | 574 | $this->_canvas->polygon($points, $color, null, null, true); |
| 575 | - } else |
|
| 575 | + } else |
|
| 576 | 576 | $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color); |
| 577 | 577 | |
| 578 | - break; |
|
| 578 | + break; |
|
| 579 | 579 | |
| 580 | 580 | default: |
| 581 | 581 | return; |
| 582 | 582 | |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | - } |
|
| 585 | + } |
|
| 586 | 586 | |
| 587 | 587 | |
| 588 | - protected function _border_double($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
| 588 | + protected function _border_double($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
| 589 | 589 | list($top, $right, $bottom, $left) = $widths; |
| 590 | 590 | |
| 591 | 591 | $line_width = $$side / 4; |
@@ -612,12 +612,12 @@ discard block |
||
| 612 | 612 | $x + $left, $y + $top); |
| 613 | 613 | $this->_canvas->polygon($points, $color, null, null, true); |
| 614 | 614 | |
| 615 | - } else { |
|
| 615 | + } else { |
|
| 616 | 616 | $this->_canvas->filled_rectangle($x, $y, $length, $line_width, $color); |
| 617 | 617 | $this->_canvas->filled_rectangle($x, $y + $top - $line_width, $length, $line_width, $color); |
| 618 | 618 | |
| 619 | - } |
|
| 620 | - break; |
|
| 619 | + } |
|
| 620 | + break; |
|
| 621 | 621 | |
| 622 | 622 | case "bottom": |
| 623 | 623 | if ( $corner_style === "bevel" ) { |
@@ -636,12 +636,12 @@ discard block |
||
| 636 | 636 | $x + $left, $y - $bottom); |
| 637 | 637 | $this->_canvas->polygon($points, $color, null, null, true); |
| 638 | 638 | |
| 639 | - } else { |
|
| 639 | + } else { |
|
| 640 | 640 | $this->_canvas->filled_rectangle($x, $y - $line_width, $length, $line_width, $color); |
| 641 | 641 | $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $line_width, $color); |
| 642 | - } |
|
| 642 | + } |
|
| 643 | 643 | |
| 644 | - break; |
|
| 644 | + break; |
|
| 645 | 645 | |
| 646 | 646 | case "left": |
| 647 | 647 | if ( $corner_style === "bevel" ) { |
@@ -660,12 +660,12 @@ discard block |
||
| 660 | 660 | $x + $left, $y + $top); |
| 661 | 661 | $this->_canvas->polygon($points, $color, null, null, true); |
| 662 | 662 | |
| 663 | - } else { |
|
| 663 | + } else { |
|
| 664 | 664 | $this->_canvas->filled_rectangle($x, $y, $line_width, $length, $color); |
| 665 | 665 | $this->_canvas->filled_rectangle($x + $left - $line_width, $y, $line_width, $length, $color); |
| 666 | - } |
|
| 666 | + } |
|
| 667 | 667 | |
| 668 | - break; |
|
| 668 | + break; |
|
| 669 | 669 | |
| 670 | 670 | case "right": |
| 671 | 671 | if ( $corner_style === "bevel" ) { |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | |
| 675 | 675 | |
| 676 | 676 | $points = array($x, $y, |
| 677 | - $x, $y + $length, |
|
| 677 | + $x, $y + $length, |
|
| 678 | 678 | $x - $line_width, $y + $length - $bottom_line_width, |
| 679 | 679 | $x - $line_width, $y + $top_line_width); |
| 680 | 680 | $this->_canvas->polygon($points, $color, null, null, true); |
@@ -685,21 +685,21 @@ discard block |
||
| 685 | 685 | $x - $right, $y + $top); |
| 686 | 686 | $this->_canvas->polygon($points, $color, null, null, true); |
| 687 | 687 | |
| 688 | - } else { |
|
| 688 | + } else { |
|
| 689 | 689 | $this->_canvas->filled_rectangle($x - $line_width, $y, $line_width, $length, $color); |
| 690 | 690 | $this->_canvas->filled_rectangle($x - $right, $y, $line_width, $length, $color); |
| 691 | - } |
|
| 691 | + } |
|
| 692 | 692 | |
| 693 | - break; |
|
| 693 | + break; |
|
| 694 | 694 | |
| 695 | 695 | default: |
| 696 | 696 | return; |
| 697 | 697 | |
| 698 | 698 | } |
| 699 | 699 | |
| 700 | - } |
|
| 700 | + } |
|
| 701 | 701 | |
| 702 | - protected function _border_groove($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
| 702 | + protected function _border_groove($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
| 703 | 703 | list($top, $right, $bottom, $left) = $widths; |
| 704 | 704 | |
| 705 | 705 | $half_widths = array($top / 2, $right / 2, $bottom / 2, $left / 2); |
@@ -710,27 +710,27 @@ discard block |
||
| 710 | 710 | |
| 711 | 711 | case "top": |
| 712 | 712 | $x += $left / 2; |
| 713 | - $y += $top / 2; |
|
| 714 | - $length -= $left / 2 + $right / 2; |
|
| 715 | - break; |
|
| 713 | + $y += $top / 2; |
|
| 714 | + $length -= $left / 2 + $right / 2; |
|
| 715 | + break; |
|
| 716 | 716 | |
| 717 | 717 | case "bottom": |
| 718 | 718 | $x += $left / 2; |
| 719 | - $y -= $bottom / 2; |
|
| 720 | - $length -= $left / 2 + $right / 2; |
|
| 721 | - break; |
|
| 719 | + $y -= $bottom / 2; |
|
| 720 | + $length -= $left / 2 + $right / 2; |
|
| 721 | + break; |
|
| 722 | 722 | |
| 723 | 723 | case "left": |
| 724 | 724 | $x += $left / 2; |
| 725 | - $y += $top / 2; |
|
| 726 | - $length -= $top / 2 + $bottom / 2; |
|
| 727 | - break; |
|
| 725 | + $y += $top / 2; |
|
| 726 | + $length -= $top / 2 + $bottom / 2; |
|
| 727 | + break; |
|
| 728 | 728 | |
| 729 | 729 | case "right": |
| 730 | 730 | $x -= $right / 2; |
| 731 | - $y += $top / 2; |
|
| 732 | - $length -= $top / 2 + $bottom / 2; |
|
| 733 | - break; |
|
| 731 | + $y += $top / 2; |
|
| 732 | + $length -= $top / 2 + $bottom / 2; |
|
| 733 | + break; |
|
| 734 | 734 | |
| 735 | 735 | default: |
| 736 | 736 | return; |
@@ -739,9 +739,9 @@ discard block |
||
| 739 | 739 | |
| 740 | 740 | $this->_border_outset($x, $y, $length, $color, $half_widths, $side); |
| 741 | 741 | |
| 742 | - } |
|
| 742 | + } |
|
| 743 | 743 | |
| 744 | - protected function _border_ridge($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
| 744 | + protected function _border_ridge($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
| 745 | 745 | list($top, $right, $bottom, $left) = $widths; |
| 746 | 746 | |
| 747 | 747 | $half_widths = array($top / 2, $right / 2, $bottom / 2, $left / 2); |
@@ -752,27 +752,27 @@ discard block |
||
| 752 | 752 | |
| 753 | 753 | case "top": |
| 754 | 754 | $x += $left / 2; |
| 755 | - $y += $top / 2; |
|
| 756 | - $length -= $left / 2 + $right / 2; |
|
| 757 | - break; |
|
| 755 | + $y += $top / 2; |
|
| 756 | + $length -= $left / 2 + $right / 2; |
|
| 757 | + break; |
|
| 758 | 758 | |
| 759 | 759 | case "bottom": |
| 760 | 760 | $x += $left / 2; |
| 761 | - $y -= $bottom / 2; |
|
| 762 | - $length -= $left / 2 + $right / 2; |
|
| 763 | - break; |
|
| 761 | + $y -= $bottom / 2; |
|
| 762 | + $length -= $left / 2 + $right / 2; |
|
| 763 | + break; |
|
| 764 | 764 | |
| 765 | 765 | case "left": |
| 766 | 766 | $x += $left / 2; |
| 767 | - $y += $top / 2; |
|
| 768 | - $length -= $top / 2 + $bottom / 2; |
|
| 769 | - break; |
|
| 767 | + $y += $top / 2; |
|
| 768 | + $length -= $top / 2 + $bottom / 2; |
|
| 769 | + break; |
|
| 770 | 770 | |
| 771 | 771 | case "right": |
| 772 | 772 | $x -= $right / 2; |
| 773 | - $y += $top / 2; |
|
| 774 | - $length -= $top / 2 + $bottom / 2; |
|
| 775 | - break; |
|
| 773 | + $y += $top / 2; |
|
| 774 | + $length -= $top / 2 + $bottom / 2; |
|
| 775 | + break; |
|
| 776 | 776 | |
| 777 | 777 | default: |
| 778 | 778 | return; |
@@ -781,23 +781,23 @@ discard block |
||
| 781 | 781 | |
| 782 | 782 | $this->_border_inset($x, $y, $length, $color, $half_widths, $side); |
| 783 | 783 | |
| 784 | - } |
|
| 784 | + } |
|
| 785 | 785 | |
| 786 | - protected function _tint($c) { |
|
| 786 | + protected function _tint($c) { |
|
| 787 | 787 | if ( !is_numeric($c) ) |
| 788 | - return $c; |
|
| 788 | + return $c; |
|
| 789 | 789 | |
| 790 | 790 | return min(1, $c + 0.66); |
| 791 | - } |
|
| 791 | + } |
|
| 792 | 792 | |
| 793 | - protected function _shade($c) { |
|
| 793 | + protected function _shade($c) { |
|
| 794 | 794 | if ( !is_numeric($c) ) |
| 795 | - return $c; |
|
| 795 | + return $c; |
|
| 796 | 796 | |
| 797 | 797 | return max(0, $c - 0.66); |
| 798 | - } |
|
| 798 | + } |
|
| 799 | 799 | |
| 800 | - protected function _border_inset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
| 800 | + protected function _border_inset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
| 801 | 801 | list($top, $right, $bottom, $left) = $widths; |
| 802 | 802 | |
| 803 | 803 | switch ($side) { |
@@ -805,43 +805,43 @@ discard block |
||
| 805 | 805 | case "top": |
| 806 | 806 | case "left": |
| 807 | 807 | $shade = array_map(array($this, "_shade"), $color); |
| 808 | - $this->_border_solid($x, $y, $length, $shade, $widths, $side); |
|
| 809 | - break; |
|
| 808 | + $this->_border_solid($x, $y, $length, $shade, $widths, $side); |
|
| 809 | + break; |
|
| 810 | 810 | |
| 811 | 811 | case "bottom": |
| 812 | 812 | case "right": |
| 813 | 813 | $tint = array_map(array($this, "_tint"), $color); |
| 814 | - $this->_border_solid($x, $y, $length, $tint, $widths, $side); |
|
| 815 | - break; |
|
| 814 | + $this->_border_solid($x, $y, $length, $tint, $widths, $side); |
|
| 815 | + break; |
|
| 816 | 816 | |
| 817 | 817 | default: |
| 818 | 818 | return; |
| 819 | 819 | } |
| 820 | - } |
|
| 820 | + } |
|
| 821 | 821 | |
| 822 | - protected function _border_outset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
| 822 | + protected function _border_outset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
|
| 823 | 823 | list($top, $right, $bottom, $left) = $widths; |
| 824 | 824 | |
| 825 | 825 | switch ($side) { |
| 826 | 826 | case "top": |
| 827 | 827 | case "left": |
| 828 | 828 | $tint = array_map(array($this, "_tint"), $color); |
| 829 | - $this->_border_solid($x, $y, $length, $tint, $widths, $side); |
|
| 830 | - break; |
|
| 829 | + $this->_border_solid($x, $y, $length, $tint, $widths, $side); |
|
| 830 | + break; |
|
| 831 | 831 | |
| 832 | 832 | case "bottom": |
| 833 | 833 | case "right": |
| 834 | 834 | $shade = array_map(array($this, "_shade"), $color); |
| 835 | - $this->_border_solid($x, $y, $length, $shade, $widths, $side); |
|
| 836 | - break; |
|
| 835 | + $this->_border_solid($x, $y, $length, $shade, $widths, $side); |
|
| 836 | + break; |
|
| 837 | 837 | |
| 838 | 838 | default: |
| 839 | 839 | return; |
| 840 | 840 | |
| 841 | 841 | } |
| 842 | - } |
|
| 842 | + } |
|
| 843 | 843 | |
| 844 | - //........................................................................ |
|
| 844 | + //........................................................................ |
|
| 845 | 845 | |
| 846 | 846 | |
| 847 | 847 | } |
@@ -106,6 +106,9 @@ |
||
| 106 | 106 | unset($this->_lines[$i]); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | + /** |
|
| 110 | + * @param integer $lineno |
|
| 111 | + */ |
|
| 109 | 112 | function set_line($lineno, $y = null, $w = null, $h = null) { |
| 110 | 113 | |
| 111 | 114 | if ( is_array($y) ) |
@@ -266,32 +266,32 @@ |
||
| 266 | 266 | |
| 267 | 267 | switch ($type) { |
| 268 | 268 | |
| 269 | - default: |
|
| 270 | - case "decimal": |
|
| 271 | - return $this->_counters[$id]; |
|
| 269 | + default: |
|
| 270 | + case "decimal": |
|
| 271 | + return $this->_counters[$id]; |
|
| 272 | 272 | |
| 273 | - case "decimal-leading-zero": |
|
| 274 | - return str_pad($this->_counters[$id], 2, "0"); |
|
| 273 | + case "decimal-leading-zero": |
|
| 274 | + return str_pad($this->_counters[$id], 2, "0"); |
|
| 275 | 275 | |
| 276 | - case "lower-roman": |
|
| 277 | - return dec2roman($this->_counters[$id]); |
|
| 276 | + case "lower-roman": |
|
| 277 | + return dec2roman($this->_counters[$id]); |
|
| 278 | 278 | |
| 279 | - case "upper-roman": |
|
| 280 | - return mb_strtoupper(dec2roman($this->_counters[$id])); |
|
| 279 | + case "upper-roman": |
|
| 280 | + return mb_strtoupper(dec2roman($this->_counters[$id])); |
|
| 281 | 281 | |
| 282 | - case "lower-latin": |
|
| 283 | - case "lower-alpha": |
|
| 284 | - return chr( ($this->_counters[$id] % 26) + ord('a') - 1); |
|
| 282 | + case "lower-latin": |
|
| 283 | + case "lower-alpha": |
|
| 284 | + return chr( ($this->_counters[$id] % 26) + ord('a') - 1); |
|
| 285 | 285 | |
| 286 | - case "upper-latin": |
|
| 287 | - case "upper-alpha": |
|
| 288 | - return chr( ($this->_counters[$id] % 26) + ord('A') - 1); |
|
| 286 | + case "upper-latin": |
|
| 287 | + case "upper-alpha": |
|
| 288 | + return chr( ($this->_counters[$id] % 26) + ord('A') - 1); |
|
| 289 | 289 | |
| 290 | - case "lower-greek": |
|
| 291 | - return chr($this->_counters[$id] + 944); |
|
| 290 | + case "lower-greek": |
|
| 291 | + return chr($this->_counters[$id] + 944); |
|
| 292 | 292 | |
| 293 | - case "upper-greek": |
|
| 294 | - return chr($this->_counters[$id] + 912); |
|
| 293 | + case "upper-greek": |
|
| 294 | + return chr($this->_counters[$id] + 912); |
|
| 295 | 295 | } |
| 296 | 296 | } |
| 297 | 297 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | protected $_lines; // array( [num] => array([frames] => array(<frame list>), |
| 53 | 53 | // y, w, h) ) |
| 54 | 54 | protected $_counters; // array([id] => counter_value) (for generated content) |
| 55 | - protected $_cl; // current line index |
|
| 55 | + protected $_cl; // current line index |
|
| 56 | 56 | |
| 57 | 57 | //........................................................................ |
| 58 | 58 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | function get_current_line($i = null) { |
| 89 | 89 | $cl = $this->_lines[$this->_cl]; |
| 90 | - if ( isset($i) ) |
|
| 90 | + if (isset($i)) |
|
| 91 | 91 | return $cl[$i]; |
| 92 | 92 | return $cl; |
| 93 | 93 | } |
@@ -102,13 +102,13 @@ discard block |
||
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | function clear_line($i) { |
| 105 | - if ( isset($this->_lines[$i]) ) |
|
| 105 | + if (isset($this->_lines[$i])) |
|
| 106 | 106 | unset($this->_lines[$i]); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | function set_line($lineno, $y = null, $w = null, $h = null) { |
| 110 | 110 | |
| 111 | - if ( is_array($y) ) |
|
| 111 | + if (is_array($y)) |
|
| 112 | 112 | extract($y); |
| 113 | 113 | |
| 114 | 114 | if (is_numeric($y)) |
@@ -126,37 +126,37 @@ discard block |
||
| 126 | 126 | function add_frame_to_line(Frame $frame) { |
| 127 | 127 | |
| 128 | 128 | // Handle inline frames (which are effectively wrappers) |
| 129 | - if ( $frame instanceof Inline_Frame_Decorator ) { |
|
| 129 | + if ($frame instanceof Inline_Frame_Decorator) { |
|
| 130 | 130 | |
| 131 | 131 | // Handle line breaks |
| 132 | - if ( $frame->get_node()->nodeName === "br" ) { |
|
| 133 | - $this->maximize_line_height( $frame->get_style()->length_in_pt($frame->get_style()->line_height) ); |
|
| 132 | + if ($frame->get_node()->nodeName === "br") { |
|
| 133 | + $this->maximize_line_height($frame->get_style()->length_in_pt($frame->get_style()->line_height)); |
|
| 134 | 134 | $this->add_line(); |
| 135 | 135 | return; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | // Add each child of the inline frame to the line individually |
| 139 | 139 | foreach ($frame->get_children() as $child) |
| 140 | - $this->add_frame_to_line( $child ); |
|
| 140 | + $this->add_frame_to_line($child); |
|
| 141 | 141 | |
| 142 | 142 | return; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | // Trim leading text if this is an empty line. Kinda a hack to put it here, |
| 146 | 146 | // but what can you do... |
| 147 | - if ( $this->_lines[$this->_cl]["w"] == 0 && |
|
| 147 | + if ($this->_lines[$this->_cl]["w"] == 0 && |
|
| 148 | 148 | $frame->get_node()->nodeName === "#text" && |
| 149 | 149 | ($frame->get_style()->white_space !== "pre" || |
| 150 | - $frame->get_style()->white_space !== "pre-wrap") ) { |
|
| 150 | + $frame->get_style()->white_space !== "pre-wrap")) { |
|
| 151 | 151 | |
| 152 | - $frame->set_text( ltrim($frame->get_text()) ); |
|
| 152 | + $frame->set_text(ltrim($frame->get_text())); |
|
| 153 | 153 | $frame->recalculate_width(); |
| 154 | 154 | |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | $w = $frame->get_margin_width(); |
| 158 | 158 | |
| 159 | - if ( $w == 0 ) |
|
| 159 | + if ($w == 0) |
|
| 160 | 160 | return; |
| 161 | 161 | |
| 162 | 162 | // Debugging code: |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | $this->_lines[$this->_cl]["frames"][] = $frame; |
| 186 | 186 | |
| 187 | - if ( $frame->get_node()->nodeName === "#text") |
|
| 187 | + if ($frame->get_node()->nodeName === "#text") |
|
| 188 | 188 | $this->_lines[$this->_cl]["wc"] += count(preg_split("/\s+/", $frame->get_text())); |
| 189 | 189 | |
| 190 | 190 | $this->_lines[$this->_cl]["w"] += $w; |
@@ -197,12 +197,12 @@ discard block |
||
| 197 | 197 | $i = $this->_cl; |
| 198 | 198 | |
| 199 | 199 | while ($i >= 0) { |
| 200 | - if ( ($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false ) |
|
| 200 | + if (($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false) |
|
| 201 | 201 | break; |
| 202 | 202 | $i--; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - if ( $j === false ) |
|
| 205 | + if ($j === false) |
|
| 206 | 206 | return; |
| 207 | 207 | |
| 208 | 208 | // Remove $frame and all frames that follow |
@@ -215,22 +215,22 @@ discard block |
||
| 215 | 215 | // Recalculate the height of the line |
| 216 | 216 | $h = 0; |
| 217 | 217 | foreach ($this->_lines[$i]["frames"] as $f) |
| 218 | - $h = max( $h, $f->get_margin_height() ); |
|
| 218 | + $h = max($h, $f->get_margin_height()); |
|
| 219 | 219 | |
| 220 | 220 | $this->_lines[$i]["h"] = $h; |
| 221 | 221 | |
| 222 | 222 | // Remove all lines that follow |
| 223 | 223 | while ($this->_cl > $i) |
| 224 | - unset($this->_lines[ $this->_cl-- ]); |
|
| 224 | + unset($this->_lines[$this->_cl--]); |
|
| 225 | 225 | |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | function increase_line_width($w) { |
| 229 | - $this->_lines[ $this->_cl ]["w"] += $w; |
|
| 229 | + $this->_lines[$this->_cl]["w"] += $w; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | function maximize_line_height($val) { |
| 233 | - $this->_lines[ $this->_cl ]["h"] = max($this->_lines[ $this->_cl ]["h"], $val); |
|
| 233 | + $this->_lines[$this->_cl]["h"] = max($this->_lines[$this->_cl]["h"], $val); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | function add_line() { |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | $y = $this->_lines[$this->_cl]["y"] + $this->_lines[$this->_cl]["h"]; |
| 242 | 242 | |
| 243 | - $this->_lines[ ++$this->_cl ] = array("frames" => array(), |
|
| 243 | + $this->_lines[ ++$this->_cl] = array("frames" => array(), |
|
| 244 | 244 | "wc" => 0, |
| 245 | 245 | "y" => $y, "w" => 0, "h" => 0); |
| 246 | 246 | } |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | function increment_counter($id = self::DEFAULT_COUNTER, $increment = 1) { |
| 255 | - if ( !isset($this->_counters[$id]) ) |
|
| 255 | + if (!isset($this->_counters[$id])) |
|
| 256 | 256 | $this->_counters[$id] = $increment; |
| 257 | 257 | else |
| 258 | 258 | $this->_counters[$id] += $increment; |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | function counter_value($id = self::DEFAULT_COUNTER, $type = "decimal") { |
| 263 | 263 | $type = mb_strtolower($type); |
| 264 | - if ( !isset($this->_counters[$id]) ) |
|
| 264 | + if (!isset($this->_counters[$id])) |
|
| 265 | 265 | $this->_counters[$id] = 0; |
| 266 | 266 | |
| 267 | 267 | switch ($type) { |
@@ -281,11 +281,11 @@ discard block |
||
| 281 | 281 | |
| 282 | 282 | case "lower-latin": |
| 283 | 283 | case "lower-alpha": |
| 284 | - return chr( ($this->_counters[$id] % 26) + ord('a') - 1); |
|
| 284 | + return chr(($this->_counters[$id] % 26) + ord('a') - 1); |
|
| 285 | 285 | |
| 286 | 286 | case "upper-latin": |
| 287 | 287 | case "upper-alpha": |
| 288 | - return chr( ($this->_counters[$id] % 26) + ord('A') - 1); |
|
| 288 | + return chr(($this->_counters[$id] % 26) + ord('A') - 1); |
|
| 289 | 289 | |
| 290 | 290 | case "lower-greek": |
| 291 | 291 | return chr($this->_counters[$id] + 944); |
@@ -87,8 +87,9 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | function get_current_line($i = null) { |
| 89 | 89 | $cl = $this->_lines[$this->_cl]; |
| 90 | - if ( isset($i) ) |
|
| 91 | - return $cl[$i]; |
|
| 90 | + if ( isset($i) ) { |
|
| 91 | + return $cl[$i]; |
|
| 92 | + } |
|
| 92 | 93 | return $cl; |
| 93 | 94 | } |
| 94 | 95 | |
@@ -102,23 +103,28 @@ discard block |
||
| 102 | 103 | } |
| 103 | 104 | |
| 104 | 105 | function clear_line($i) { |
| 105 | - if ( isset($this->_lines[$i]) ) |
|
| 106 | - unset($this->_lines[$i]); |
|
| 106 | + if ( isset($this->_lines[$i]) ) { |
|
| 107 | + unset($this->_lines[$i]); |
|
| 108 | + } |
|
| 107 | 109 | } |
| 108 | 110 | |
| 109 | 111 | function set_line($lineno, $y = null, $w = null, $h = null) { |
| 110 | 112 | |
| 111 | - if ( is_array($y) ) |
|
| 112 | - extract($y); |
|
| 113 | + if ( is_array($y) ) { |
|
| 114 | + extract($y); |
|
| 115 | + } |
|
| 113 | 116 | |
| 114 | - if (is_numeric($y)) |
|
| 115 | - $this->_lines[$lineno]["y"] = $y; |
|
| 117 | + if (is_numeric($y)) { |
|
| 118 | + $this->_lines[$lineno]["y"] = $y; |
|
| 119 | + } |
|
| 116 | 120 | |
| 117 | - if (is_numeric($w)) |
|
| 118 | - $this->_lines[$lineno]["w"] = $w; |
|
| 121 | + if (is_numeric($w)) { |
|
| 122 | + $this->_lines[$lineno]["w"] = $w; |
|
| 123 | + } |
|
| 119 | 124 | |
| 120 | - if (is_numeric($h)) |
|
| 121 | - $this->_lines[$lineno]["h"] = $h; |
|
| 125 | + if (is_numeric($h)) { |
|
| 126 | + $this->_lines[$lineno]["h"] = $h; |
|
| 127 | + } |
|
| 122 | 128 | |
| 123 | 129 | } |
| 124 | 130 | |
@@ -136,8 +142,9 @@ discard block |
||
| 136 | 142 | } |
| 137 | 143 | |
| 138 | 144 | // Add each child of the inline frame to the line individually |
| 139 | - foreach ($frame->get_children() as $child) |
|
| 140 | - $this->add_frame_to_line( $child ); |
|
| 145 | + foreach ($frame->get_children() as $child) { |
|
| 146 | + $this->add_frame_to_line( $child ); |
|
| 147 | + } |
|
| 141 | 148 | |
| 142 | 149 | return; |
| 143 | 150 | } |
@@ -156,8 +163,9 @@ discard block |
||
| 156 | 163 | |
| 157 | 164 | $w = $frame->get_margin_width(); |
| 158 | 165 | |
| 159 | - if ( $w == 0 ) |
|
| 160 | - return; |
|
| 166 | + if ( $w == 0 ) { |
|
| 167 | + return; |
|
| 168 | + } |
|
| 161 | 169 | |
| 162 | 170 | // Debugging code: |
| 163 | 171 | /* |
@@ -176,16 +184,18 @@ discard block |
||
| 176 | 184 | */ |
| 177 | 185 | // End debugging |
| 178 | 186 | |
| 179 | - if ($this->_lines[$this->_cl]["w"] + $w > $this->get_containing_block("w")) |
|
| 180 | - $this->add_line(); |
|
| 187 | + if ($this->_lines[$this->_cl]["w"] + $w > $this->get_containing_block("w")) { |
|
| 188 | + $this->add_line(); |
|
| 189 | + } |
|
| 181 | 190 | |
| 182 | 191 | $frame->position(); |
| 183 | 192 | |
| 184 | 193 | |
| 185 | 194 | $this->_lines[$this->_cl]["frames"][] = $frame; |
| 186 | 195 | |
| 187 | - if ( $frame->get_node()->nodeName === "#text") |
|
| 188 | - $this->_lines[$this->_cl]["wc"] += count(preg_split("/\s+/", $frame->get_text())); |
|
| 196 | + if ( $frame->get_node()->nodeName === "#text") { |
|
| 197 | + $this->_lines[$this->_cl]["wc"] += count(preg_split("/\s+/", $frame->get_text())); |
|
| 198 | + } |
|
| 189 | 199 | |
| 190 | 200 | $this->_lines[$this->_cl]["w"] += $w; |
| 191 | 201 | $this->_lines[$this->_cl]["h"] = max($this->_lines[$this->_cl]["h"], $frame->get_margin_height()); |
@@ -197,13 +207,15 @@ discard block |
||
| 197 | 207 | $i = $this->_cl; |
| 198 | 208 | |
| 199 | 209 | while ($i >= 0) { |
| 200 | - if ( ($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false ) |
|
| 201 | - break; |
|
| 210 | + if ( ($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false ) { |
|
| 211 | + break; |
|
| 212 | + } |
|
| 202 | 213 | $i--; |
| 203 | 214 | } |
| 204 | 215 | |
| 205 | - if ( $j === false ) |
|
| 206 | - return; |
|
| 216 | + if ( $j === false ) { |
|
| 217 | + return; |
|
| 218 | + } |
|
| 207 | 219 | |
| 208 | 220 | // Remove $frame and all frames that follow |
| 209 | 221 | while ($j < count($this->_lines[$i]["frames"])) { |
@@ -214,14 +226,16 @@ discard block |
||
| 214 | 226 | |
| 215 | 227 | // Recalculate the height of the line |
| 216 | 228 | $h = 0; |
| 217 | - foreach ($this->_lines[$i]["frames"] as $f) |
|
| 218 | - $h = max( $h, $f->get_margin_height() ); |
|
| 229 | + foreach ($this->_lines[$i]["frames"] as $f) { |
|
| 230 | + $h = max( $h, $f->get_margin_height() ); |
|
| 231 | + } |
|
| 219 | 232 | |
| 220 | 233 | $this->_lines[$i]["h"] = $h; |
| 221 | 234 | |
| 222 | 235 | // Remove all lines that follow |
| 223 | - while ($this->_cl > $i) |
|
| 224 | - unset($this->_lines[ $this->_cl-- ]); |
|
| 236 | + while ($this->_cl > $i) { |
|
| 237 | + unset($this->_lines[ $this->_cl-- ]); |
|
| 238 | + } |
|
| 225 | 239 | |
| 226 | 240 | } |
| 227 | 241 | |
@@ -252,17 +266,19 @@ discard block |
||
| 252 | 266 | } |
| 253 | 267 | |
| 254 | 268 | function increment_counter($id = self::DEFAULT_COUNTER, $increment = 1) { |
| 255 | - if ( !isset($this->_counters[$id]) ) |
|
| 256 | - $this->_counters[$id] = $increment; |
|
| 257 | - else |
|
| 258 | - $this->_counters[$id] += $increment; |
|
| 269 | + if ( !isset($this->_counters[$id]) ) { |
|
| 270 | + $this->_counters[$id] = $increment; |
|
| 271 | + } else { |
|
| 272 | + $this->_counters[$id] += $increment; |
|
| 273 | + } |
|
| 259 | 274 | |
| 260 | 275 | } |
| 261 | 276 | |
| 262 | 277 | function counter_value($id = self::DEFAULT_COUNTER, $type = "decimal") { |
| 263 | 278 | $type = mb_strtolower($type); |
| 264 | - if ( !isset($this->_counters[$id]) ) |
|
| 265 | - $this->_counters[$id] = 0; |
|
| 279 | + if ( !isset($this->_counters[$id]) ) { |
|
| 280 | + $this->_counters[$id] = 0; |
|
| 281 | + } |
|
| 266 | 282 | |
| 267 | 283 | switch ($type) { |
| 268 | 284 | |
@@ -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: block_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,16 +46,16 @@ discard block |
||
| 47 | 46 | */ |
| 48 | 47 | class Block_Frame_Decorator extends Frame_Decorator { |
| 49 | 48 | |
| 50 | - const DEFAULT_COUNTER = "-dompdf-default-counter"; |
|
| 49 | + const DEFAULT_COUNTER = "-dompdf-default-counter"; |
|
| 51 | 50 | |
| 52 | - protected $_lines; // array( [num] => array([frames] => array(<frame list>), |
|
| 53 | - // y, w, h) ) |
|
| 54 | - protected $_counters; // array([id] => counter_value) (for generated content) |
|
| 55 | - protected $_cl; // current line index |
|
| 51 | + protected $_lines; // array( [num] => array([frames] => array(<frame list>), |
|
| 52 | + // y, w, h) ) |
|
| 53 | + protected $_counters; // array([id] => counter_value) (for generated content) |
|
| 54 | + protected $_cl; // current line index |
|
| 56 | 55 | |
| 57 | - //........................................................................ |
|
| 56 | + //........................................................................ |
|
| 58 | 57 | |
| 59 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
| 58 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
| 60 | 59 | parent::__construct($frame, $dompdf); |
| 61 | 60 | $this->_lines = array(array("frames" => array(), |
| 62 | 61 | "wc" => 0, |
@@ -66,11 +65,11 @@ discard block |
||
| 66 | 65 | $this->_counters = array(self::DEFAULT_COUNTER => 0); |
| 67 | 66 | $this->_cl = 0; |
| 68 | 67 | |
| 69 | - } |
|
| 68 | + } |
|
| 70 | 69 | |
| 71 | - //........................................................................ |
|
| 70 | + //........................................................................ |
|
| 72 | 71 | |
| 73 | - function reset() { |
|
| 72 | + function reset() { |
|
| 74 | 73 | parent::reset(); |
| 75 | 74 | $this->_lines = array(array("frames" => array(), |
| 76 | 75 | "wc" => 0, |
@@ -79,67 +78,67 @@ discard block |
||
| 79 | 78 | "h" => 0)); |
| 80 | 79 | $this->_counters = array(self::DEFAULT_COUNTER => 0); |
| 81 | 80 | $this->_cl = 0; |
| 82 | - } |
|
| 81 | + } |
|
| 83 | 82 | |
| 84 | - //........................................................................ |
|
| 83 | + //........................................................................ |
|
| 85 | 84 | |
| 86 | - // Accessor methods |
|
| 85 | + // Accessor methods |
|
| 87 | 86 | |
| 88 | - function get_current_line($i = null) { |
|
| 87 | + function get_current_line($i = null) { |
|
| 89 | 88 | $cl = $this->_lines[$this->_cl]; |
| 90 | 89 | if ( isset($i) ) |
| 91 | - return $cl[$i]; |
|
| 90 | + return $cl[$i]; |
|
| 92 | 91 | return $cl; |
| 93 | - } |
|
| 92 | + } |
|
| 94 | 93 | |
| 95 | - function get_lines() { return $this->_lines; } |
|
| 94 | + function get_lines() { return $this->_lines; } |
|
| 96 | 95 | |
| 97 | - //........................................................................ |
|
| 96 | + //........................................................................ |
|
| 98 | 97 | |
| 99 | - // Set methods |
|
| 100 | - function set_current_line($y = null, $w = null, $h = null) { |
|
| 98 | + // Set methods |
|
| 99 | + function set_current_line($y = null, $w = null, $h = null) { |
|
| 101 | 100 | $this->set_line($this->_cl, $y, $w, $h); |
| 102 | - } |
|
| 101 | + } |
|
| 103 | 102 | |
| 104 | - function clear_line($i) { |
|
| 103 | + function clear_line($i) { |
|
| 105 | 104 | if ( isset($this->_lines[$i]) ) |
| 106 | - unset($this->_lines[$i]); |
|
| 107 | - } |
|
| 105 | + unset($this->_lines[$i]); |
|
| 106 | + } |
|
| 108 | 107 | |
| 109 | - function set_line($lineno, $y = null, $w = null, $h = null) { |
|
| 108 | + function set_line($lineno, $y = null, $w = null, $h = null) { |
|
| 110 | 109 | |
| 111 | 110 | if ( is_array($y) ) |
| 112 | - extract($y); |
|
| 111 | + extract($y); |
|
| 113 | 112 | |
| 114 | 113 | if (is_numeric($y)) |
| 115 | - $this->_lines[$lineno]["y"] = $y; |
|
| 114 | + $this->_lines[$lineno]["y"] = $y; |
|
| 116 | 115 | |
| 117 | 116 | if (is_numeric($w)) |
| 118 | - $this->_lines[$lineno]["w"] = $w; |
|
| 117 | + $this->_lines[$lineno]["w"] = $w; |
|
| 119 | 118 | |
| 120 | 119 | if (is_numeric($h)) |
| 121 | - $this->_lines[$lineno]["h"] = $h; |
|
| 120 | + $this->_lines[$lineno]["h"] = $h; |
|
| 122 | 121 | |
| 123 | - } |
|
| 122 | + } |
|
| 124 | 123 | |
| 125 | 124 | |
| 126 | - function add_frame_to_line(Frame $frame) { |
|
| 125 | + function add_frame_to_line(Frame $frame) { |
|
| 127 | 126 | |
| 128 | 127 | // Handle inline frames (which are effectively wrappers) |
| 129 | 128 | if ( $frame instanceof Inline_Frame_Decorator ) { |
| 130 | 129 | |
| 131 | - // Handle line breaks |
|
| 132 | - if ( $frame->get_node()->nodeName === "br" ) { |
|
| 130 | + // Handle line breaks |
|
| 131 | + if ( $frame->get_node()->nodeName === "br" ) { |
|
| 133 | 132 | $this->maximize_line_height( $frame->get_style()->length_in_pt($frame->get_style()->line_height) ); |
| 134 | 133 | $this->add_line(); |
| 135 | 134 | return; |
| 136 | - } |
|
| 135 | + } |
|
| 137 | 136 | |
| 138 | - // Add each child of the inline frame to the line individually |
|
| 139 | - foreach ($frame->get_children() as $child) |
|
| 137 | + // Add each child of the inline frame to the line individually |
|
| 138 | + foreach ($frame->get_children() as $child) |
|
| 140 | 139 | $this->add_frame_to_line( $child ); |
| 141 | 140 | |
| 142 | - return; |
|
| 141 | + return; |
|
| 143 | 142 | } |
| 144 | 143 | |
| 145 | 144 | // Trim leading text if this is an empty line. Kinda a hack to put it here, |
@@ -149,15 +148,15 @@ discard block |
||
| 149 | 148 | ($frame->get_style()->white_space !== "pre" || |
| 150 | 149 | $frame->get_style()->white_space !== "pre-wrap") ) { |
| 151 | 150 | |
| 152 | - $frame->set_text( ltrim($frame->get_text()) ); |
|
| 153 | - $frame->recalculate_width(); |
|
| 151 | + $frame->set_text( ltrim($frame->get_text()) ); |
|
| 152 | + $frame->recalculate_width(); |
|
| 154 | 153 | |
| 155 | 154 | } |
| 156 | 155 | |
| 157 | 156 | $w = $frame->get_margin_width(); |
| 158 | 157 | |
| 159 | 158 | if ( $w == 0 ) |
| 160 | - return; |
|
| 159 | + return; |
|
| 161 | 160 | |
| 162 | 161 | // Debugging code: |
| 163 | 162 | /* |
@@ -177,7 +176,7 @@ discard block |
||
| 177 | 176 | // End debugging |
| 178 | 177 | |
| 179 | 178 | if ($this->_lines[$this->_cl]["w"] + $w > $this->get_containing_block("w")) |
| 180 | - $this->add_line(); |
|
| 179 | + $this->add_line(); |
|
| 181 | 180 | |
| 182 | 181 | $frame->position(); |
| 183 | 182 | |
@@ -185,55 +184,55 @@ discard block |
||
| 185 | 184 | $this->_lines[$this->_cl]["frames"][] = $frame; |
| 186 | 185 | |
| 187 | 186 | if ( $frame->get_node()->nodeName === "#text") |
| 188 | - $this->_lines[$this->_cl]["wc"] += count(preg_split("/\s+/", $frame->get_text())); |
|
| 187 | + $this->_lines[$this->_cl]["wc"] += count(preg_split("/\s+/", $frame->get_text())); |
|
| 189 | 188 | |
| 190 | 189 | $this->_lines[$this->_cl]["w"] += $w; |
| 191 | 190 | $this->_lines[$this->_cl]["h"] = max($this->_lines[$this->_cl]["h"], $frame->get_margin_height()); |
| 192 | 191 | |
| 193 | - } |
|
| 192 | + } |
|
| 194 | 193 | |
| 195 | - function remove_frames_from_line(Frame $frame) { |
|
| 194 | + function remove_frames_from_line(Frame $frame) { |
|
| 196 | 195 | // Search backwards through the lines for $frame |
| 197 | 196 | $i = $this->_cl; |
| 198 | 197 | |
| 199 | 198 | while ($i >= 0) { |
| 200 | - if ( ($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false ) |
|
| 199 | + if ( ($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false ) |
|
| 201 | 200 | break; |
| 202 | - $i--; |
|
| 201 | + $i--; |
|
| 203 | 202 | } |
| 204 | 203 | |
| 205 | 204 | if ( $j === false ) |
| 206 | - return; |
|
| 205 | + return; |
|
| 207 | 206 | |
| 208 | 207 | // Remove $frame and all frames that follow |
| 209 | 208 | while ($j < count($this->_lines[$i]["frames"])) { |
| 210 | - $f = $this->_lines[$i]["frames"][$j]; |
|
| 211 | - unset($this->_lines[$i]["frames"][$j++]); |
|
| 212 | - $this->_lines[$i]["w"] -= $f->get_margin_width(); |
|
| 209 | + $f = $this->_lines[$i]["frames"][$j]; |
|
| 210 | + unset($this->_lines[$i]["frames"][$j++]); |
|
| 211 | + $this->_lines[$i]["w"] -= $f->get_margin_width(); |
|
| 213 | 212 | } |
| 214 | 213 | |
| 215 | 214 | // Recalculate the height of the line |
| 216 | 215 | $h = 0; |
| 217 | 216 | foreach ($this->_lines[$i]["frames"] as $f) |
| 218 | - $h = max( $h, $f->get_margin_height() ); |
|
| 217 | + $h = max( $h, $f->get_margin_height() ); |
|
| 219 | 218 | |
| 220 | 219 | $this->_lines[$i]["h"] = $h; |
| 221 | 220 | |
| 222 | 221 | // Remove all lines that follow |
| 223 | 222 | while ($this->_cl > $i) |
| 224 | - unset($this->_lines[ $this->_cl-- ]); |
|
| 223 | + unset($this->_lines[ $this->_cl-- ]); |
|
| 225 | 224 | |
| 226 | - } |
|
| 225 | + } |
|
| 227 | 226 | |
| 228 | - function increase_line_width($w) { |
|
| 227 | + function increase_line_width($w) { |
|
| 229 | 228 | $this->_lines[ $this->_cl ]["w"] += $w; |
| 230 | - } |
|
| 229 | + } |
|
| 231 | 230 | |
| 232 | - function maximize_line_height($val) { |
|
| 231 | + function maximize_line_height($val) { |
|
| 233 | 232 | $this->_lines[ $this->_cl ]["h"] = max($this->_lines[ $this->_cl ]["h"], $val); |
| 234 | - } |
|
| 233 | + } |
|
| 235 | 234 | |
| 236 | - function add_line() { |
|
| 235 | + function add_line() { |
|
| 237 | 236 | |
| 238 | 237 | // if ( $this->_lines[$this->_cl]["h"] == 0 ) //count($this->_lines[$i]["frames"]) == 0 || |
| 239 | 238 | // return; |
@@ -241,28 +240,28 @@ discard block |
||
| 241 | 240 | $y = $this->_lines[$this->_cl]["y"] + $this->_lines[$this->_cl]["h"]; |
| 242 | 241 | |
| 243 | 242 | $this->_lines[ ++$this->_cl ] = array("frames" => array(), |
| 244 | - "wc" => 0, |
|
| 245 | - "y" => $y, "w" => 0, "h" => 0); |
|
| 246 | - } |
|
| 243 | + "wc" => 0, |
|
| 244 | + "y" => $y, "w" => 0, "h" => 0); |
|
| 245 | + } |
|
| 247 | 246 | |
| 248 | - //........................................................................ |
|
| 247 | + //........................................................................ |
|
| 249 | 248 | |
| 250 | - function reset_counter($id = self::DEFAULT_COUNTER, $value = 0) { |
|
| 249 | + function reset_counter($id = self::DEFAULT_COUNTER, $value = 0) { |
|
| 251 | 250 | $this->_counters[$id] = $value; |
| 252 | - } |
|
| 251 | + } |
|
| 253 | 252 | |
| 254 | - function increment_counter($id = self::DEFAULT_COUNTER, $increment = 1) { |
|
| 253 | + function increment_counter($id = self::DEFAULT_COUNTER, $increment = 1) { |
|
| 255 | 254 | if ( !isset($this->_counters[$id]) ) |
| 256 | - $this->_counters[$id] = $increment; |
|
| 255 | + $this->_counters[$id] = $increment; |
|
| 257 | 256 | else |
| 258 | - $this->_counters[$id] += $increment; |
|
| 257 | + $this->_counters[$id] += $increment; |
|
| 259 | 258 | |
| 260 | - } |
|
| 259 | + } |
|
| 261 | 260 | |
| 262 | - function counter_value($id = self::DEFAULT_COUNTER, $type = "decimal") { |
|
| 261 | + function counter_value($id = self::DEFAULT_COUNTER, $type = "decimal") { |
|
| 263 | 262 | $type = mb_strtolower($type); |
| 264 | 263 | if ( !isset($this->_counters[$id]) ) |
| 265 | - $this->_counters[$id] = 0; |
|
| 264 | + $this->_counters[$id] = 0; |
|
| 266 | 265 | |
| 267 | 266 | switch ($type) { |
| 268 | 267 | |
@@ -293,5 +292,5 @@ discard block |
||
| 293 | 292 | case "upper-greek": |
| 294 | 293 | return chr($this->_counters[$id] + 912); |
| 295 | 294 | } |
| 296 | - } |
|
| 295 | + } |
|
| 297 | 296 | } |
@@ -54,6 +54,10 @@ |
||
| 54 | 54 | */ |
| 55 | 55 | private function __construct() { } |
| 56 | 56 | |
| 57 | + /** |
|
| 58 | + * @param string $paper |
|
| 59 | + * @param string $orientation |
|
| 60 | + */ |
|
| 57 | 61 | static function get_instance($paper = null, $orientation = null, $class = null) { |
| 58 | 62 | |
| 59 | 63 | $backend = strtolower(DOMPDF_PDF_BACKEND); |
@@ -1,41 +1,40 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
| 4 | - * |
|
| 5 | - * File: $RCSfile: canvas_factory.cls.php,v $ |
|
| 6 | - * Created on: 2004-06-02 |
|
| 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: canvas_factory.cls.php,v $ |
|
| 6 | + * Created on: 2004-06-02 |
|
| 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: canvas_factory.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
| 41 | 40 | |
@@ -49,35 +48,35 @@ discard block |
||
| 49 | 48 | */ |
| 50 | 49 | class Canvas_Factory { |
| 51 | 50 | |
| 52 | - /** |
|
| 53 | - * Constructor is private: this is a static class |
|
| 54 | - */ |
|
| 55 | - private function __construct() { } |
|
| 51 | + /** |
|
| 52 | + * Constructor is private: this is a static class |
|
| 53 | + */ |
|
| 54 | + private function __construct() { } |
|
| 56 | 55 | |
| 57 | - static function get_instance($paper = null, $orientation = null, $class = null) { |
|
| 56 | + static function get_instance($paper = null, $orientation = null, $class = null) { |
|
| 58 | 57 | |
| 59 | 58 | $backend = strtolower(DOMPDF_PDF_BACKEND); |
| 60 | 59 | |
| 61 | 60 | if ( isset($class) && class_exists($class, false) ) |
| 62 | - $class .= "_Adapter"; |
|
| 61 | + $class .= "_Adapter"; |
|
| 63 | 62 | |
| 64 | 63 | else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "pdflib" ) && |
| 65 | 64 | class_exists("PDFLib", false) ) |
| 66 | - $class = "PDFLib_Adapter"; |
|
| 65 | + $class = "PDFLib_Adapter"; |
|
| 67 | 66 | |
| 68 | 67 | else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "cpdf") ) |
| 69 | - $class = "CPDF_Adapter"; |
|
| 68 | + $class = "CPDF_Adapter"; |
|
| 70 | 69 | |
| 71 | 70 | else if ( ( $backend === "tcpdf") ) |
| 72 | - $class = "TCPDF_Adapter"; |
|
| 71 | + $class = "TCPDF_Adapter"; |
|
| 73 | 72 | |
| 74 | 73 | else if ( $backend === "gd" ) |
| 75 | - $class = "GD_Adapter"; |
|
| 74 | + $class = "GD_Adapter"; |
|
| 76 | 75 | |
| 77 | 76 | else |
| 78 | - $class = "CPDF_Adapter"; |
|
| 77 | + $class = "CPDF_Adapter"; |
|
| 79 | 78 | |
| 80 | 79 | return new $class($paper, $orientation); |
| 81 | 80 | |
| 82 | - } |
|
| 81 | + } |
|
| 83 | 82 | } |
@@ -54,24 +54,24 @@ |
||
| 54 | 54 | */ |
| 55 | 55 | private function __construct() { } |
| 56 | 56 | |
| 57 | - static function get_instance($paper = null, $orientation = null, $class = null) { |
|
| 57 | + static function get_instance($paper = null, $orientation = null, $class = null) { |
|
| 58 | 58 | |
| 59 | 59 | $backend = strtolower(DOMPDF_PDF_BACKEND); |
| 60 | 60 | |
| 61 | - if ( isset($class) && class_exists($class, false) ) |
|
| 61 | + if (isset($class) && class_exists($class, false)) |
|
| 62 | 62 | $class .= "_Adapter"; |
| 63 | 63 | |
| 64 | - else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "pdflib" ) && |
|
| 65 | - class_exists("PDFLib", false) ) |
|
| 64 | + else if ((DOMPDF_PDF_BACKEND === "auto" || $backend === "pdflib") && |
|
| 65 | + class_exists("PDFLib", false)) |
|
| 66 | 66 | $class = "PDFLib_Adapter"; |
| 67 | 67 | |
| 68 | - else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "cpdf") ) |
|
| 68 | + else if ((DOMPDF_PDF_BACKEND === "auto" || $backend === "cpdf")) |
|
| 69 | 69 | $class = "CPDF_Adapter"; |
| 70 | 70 | |
| 71 | - else if ( ( $backend === "tcpdf") ) |
|
| 71 | + else if (($backend === "tcpdf")) |
|
| 72 | 72 | $class = "TCPDF_Adapter"; |
| 73 | 73 | |
| 74 | - else if ( $backend === "gd" ) |
|
| 74 | + else if ($backend === "gd") |
|
| 75 | 75 | $class = "GD_Adapter"; |
| 76 | 76 | |
| 77 | 77 | else |
@@ -58,24 +58,20 @@ |
||
| 58 | 58 | |
| 59 | 59 | $backend = strtolower(DOMPDF_PDF_BACKEND); |
| 60 | 60 | |
| 61 | - if ( isset($class) && class_exists($class, false) ) |
|
| 62 | - $class .= "_Adapter"; |
|
| 63 | - |
|
| 64 | - else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "pdflib" ) && |
|
| 65 | - class_exists("PDFLib", false) ) |
|
| 66 | - $class = "PDFLib_Adapter"; |
|
| 67 | - |
|
| 68 | - else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "cpdf") ) |
|
| 69 | - $class = "CPDF_Adapter"; |
|
| 70 | - |
|
| 71 | - else if ( ( $backend === "tcpdf") ) |
|
| 72 | - $class = "TCPDF_Adapter"; |
|
| 73 | - |
|
| 74 | - else if ( $backend === "gd" ) |
|
| 75 | - $class = "GD_Adapter"; |
|
| 76 | - |
|
| 77 | - else |
|
| 78 | - $class = "CPDF_Adapter"; |
|
| 61 | + if ( isset($class) && class_exists($class, false) ) { |
|
| 62 | + $class .= "_Adapter"; |
|
| 63 | + } else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "pdflib" ) && |
|
| 64 | + class_exists("PDFLib", false) ) { |
|
| 65 | + $class = "PDFLib_Adapter"; |
|
| 66 | + } else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "cpdf") ) { |
|
| 67 | + $class = "CPDF_Adapter"; |
|
| 68 | + } else if ( ( $backend === "tcpdf") ) { |
|
| 69 | + $class = "TCPDF_Adapter"; |
|
| 70 | + } else if ( $backend === "gd" ) { |
|
| 71 | + $class = "GD_Adapter"; |
|
| 72 | + } else { |
|
| 73 | + $class = "CPDF_Adapter"; |
|
| 74 | + } |
|
| 79 | 75 | |
| 80 | 76 | return new $class($paper, $orientation); |
| 81 | 77 | |
@@ -194,6 +194,9 @@ discard block |
||
| 194 | 194 | return $this->_rows[$j]; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | + /** |
|
| 198 | + * @param string $h_v |
|
| 199 | + */ |
|
| 197 | 200 | function get_border($i, $j, $h_v, $prop = null) { |
| 198 | 201 | if ( !isset($this->_borders[$i][$j][$h_v]) ) |
| 199 | 202 | $this->_borders[$i][$j][$h_v] = array("width" => 0, |
@@ -318,6 +321,11 @@ discard block |
||
| 318 | 321 | //........................................................................ |
| 319 | 322 | |
| 320 | 323 | |
| 324 | + /** |
|
| 325 | + * @param integer $i |
|
| 326 | + * @param integer $j |
|
| 327 | + * @param string $h_v |
|
| 328 | + */ |
|
| 321 | 329 | protected function _resolve_border($i, $j, $h_v, $border_spec) { |
| 322 | 330 | $n_width = $border_spec["width"]; |
| 323 | 331 | $n_style = $border_spec["style"]; |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | function &get_column($i) { |
| 173 | - if ( !isset($this->_columns[$i]) ) |
|
| 173 | + if (!isset($this->_columns[$i])) |
|
| 174 | 174 | $this->_columns[$i] = array("x" => 0, |
| 175 | 175 | "min-width" => 0, |
| 176 | 176 | "max-width" => 0, |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | function &get_row($j) { |
| 190 | - if ( !isset($this->_rows[$j]) ) |
|
| 190 | + if (!isset($this->_rows[$j])) |
|
| 191 | 191 | $this->_rows[$j] = array("y" => 0, |
| 192 | 192 | "first-column" => 0, |
| 193 | 193 | "height" => null); |
@@ -195,11 +195,11 @@ discard block |
||
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | function get_border($i, $j, $h_v, $prop = null) { |
| 198 | - if ( !isset($this->_borders[$i][$j][$h_v]) ) |
|
| 198 | + if (!isset($this->_borders[$i][$j][$h_v])) |
|
| 199 | 199 | $this->_borders[$i][$j][$h_v] = array("width" => 0, |
| 200 | 200 | "style" => "solid", |
| 201 | 201 | "color" => "black"); |
| 202 | - if ( isset($prop) ) |
|
| 202 | + if (isset($prop)) |
|
| 203 | 203 | return $this->_borders[$i][$j][$h_v][$prop]; |
| 204 | 204 | |
| 205 | 205 | return $this->_borders[$i][$j][$h_v]; |
@@ -208,9 +208,9 @@ discard block |
||
| 208 | 208 | function get_border_properties($i, $j) { |
| 209 | 209 | |
| 210 | 210 | $left = $this->get_border($i, $j, "vertical"); |
| 211 | - $right = $this->get_border($i, $j+1, "vertical"); |
|
| 211 | + $right = $this->get_border($i, $j + 1, "vertical"); |
|
| 212 | 212 | $top = $this->get_border($i, $j, "horizontal"); |
| 213 | - $bottom = $this->get_border($i+1, $j, "horizontal"); |
|
| 213 | + $bottom = $this->get_border($i + 1, $j, "horizontal"); |
|
| 214 | 214 | |
| 215 | 215 | return compact("top", "bottom", "left", "right"); |
| 216 | 216 | } |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | function get_spanned_cells($frame) { |
| 221 | 221 | $key = $frame->get_id(); |
| 222 | 222 | |
| 223 | - if ( !isset($this->_frames[$key]) ) { |
|
| 223 | + if (!isset($this->_frames[$key])) { |
|
| 224 | 224 | throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
| 225 | 225 | } |
| 226 | 226 | |
@@ -238,20 +238,20 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | $key = $frame->get_id(); |
| 240 | 240 | |
| 241 | - if ( !isset($this->_frames[$key]) ) { |
|
| 241 | + if (!isset($this->_frames[$key])) { |
|
| 242 | 242 | throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | $col = $this->_frames[$key]["columns"][0]; |
| 246 | 246 | $row = $this->_frames[$key]["rows"][0]; |
| 247 | 247 | |
| 248 | - if ( !isset($this->_columns[$col])) { |
|
| 248 | + if (!isset($this->_columns[$col])) { |
|
| 249 | 249 | $_dompdf_warnings[] = "Frame not found in columns array. Check your table layout for missing or extra TDs."; |
| 250 | 250 | $x = 0; |
| 251 | 251 | } else |
| 252 | 252 | $x = $this->_columns[$col]["x"]; |
| 253 | 253 | |
| 254 | - if ( !isset($this->_rows[$row])) { |
|
| 254 | + if (!isset($this->_rows[$row])) { |
|
| 255 | 255 | $_dompdf_warnings[] = "Frame not found in row array. Check your table layout for missing or extra TDs."; |
| 256 | 256 | $y = 0; |
| 257 | 257 | } else |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | function get_frame_width($frame) { |
| 264 | 264 | $key = $frame->get_id(); |
| 265 | 265 | |
| 266 | - if ( !isset($this->_frames[$key]) ) { |
|
| 266 | + if (!isset($this->_frames[$key])) { |
|
| 267 | 267 | throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
| 268 | 268 | } |
| 269 | 269 | |
@@ -279,13 +279,13 @@ discard block |
||
| 279 | 279 | function get_frame_height($frame) { |
| 280 | 280 | $key = $frame->get_id(); |
| 281 | 281 | |
| 282 | - if ( !isset($this->_frames[$key]) ) |
|
| 282 | + if (!isset($this->_frames[$key])) |
|
| 283 | 283 | throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
| 284 | 284 | |
| 285 | 285 | $rows = $this->_frames[$key]["rows"]; |
| 286 | 286 | $h = 0; |
| 287 | 287 | foreach ($rows as $i) { |
| 288 | - if ( !isset($this->_rows[$i]) ) { |
|
| 288 | + if (!isset($this->_rows[$i])) { |
|
| 289 | 289 | throw new Exception("foo"); |
| 290 | 290 | } |
| 291 | 291 | $h += $this->_rows[$i]["height"]; |
@@ -298,19 +298,19 @@ discard block |
||
| 298 | 298 | //........................................................................ |
| 299 | 299 | |
| 300 | 300 | function set_column_width($j, $width) { |
| 301 | - $col =& $this->get_column($j); |
|
| 301 | + $col = & $this->get_column($j); |
|
| 302 | 302 | $col["used-width"] = $width; |
| 303 | - $next_col =& $this->get_column($j+1); |
|
| 303 | + $next_col = & $this->get_column($j + 1); |
|
| 304 | 304 | $next_col["x"] = $next_col["x"] + $width; |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | function set_row_height($i, $height) { |
| 308 | - $row =& $this->get_row($i); |
|
| 309 | - if ( $height <= $row["height"] ) |
|
| 308 | + $row = & $this->get_row($i); |
|
| 309 | + if ($height <= $row["height"]) |
|
| 310 | 310 | return; |
| 311 | 311 | |
| 312 | 312 | $row["height"] = $height; |
| 313 | - $next_row =& $this->get_row($i+1); |
|
| 313 | + $next_row = & $this->get_row($i + 1); |
|
| 314 | 314 | $next_row["y"] = $row["y"] + $height; |
| 315 | 315 | |
| 316 | 316 | } |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | $n_style = $border_spec["style"]; |
| 324 | 324 | $n_color = $border_spec["color"]; |
| 325 | 325 | |
| 326 | - if ( !isset($this->_borders[$i][$j][$h_v]) ) { |
|
| 326 | + if (!isset($this->_borders[$i][$j][$h_v])) { |
|
| 327 | 327 | $this->_borders[$i][$j][$h_v] = $border_spec; |
| 328 | 328 | return $this->_borders[$i][$j][$h_v]["width"]; |
| 329 | 329 | } |
@@ -332,15 +332,15 @@ discard block |
||
| 332 | 332 | $o_style = $this->_borders[$i][$j][$h_v]["style"]; |
| 333 | 333 | $o_color = $this->_borders[$i][$j][$h_v]["color"]; |
| 334 | 334 | |
| 335 | - if ( ($n_style === "hidden" || |
|
| 336 | - $n_width > $o_width || |
|
| 335 | + if (($n_style === "hidden" || |
|
| 336 | + $n_width > $o_width || |
|
| 337 | 337 | $o_style === "none") |
| 338 | 338 | |
| 339 | 339 | or |
| 340 | 340 | |
| 341 | 341 | ($o_width == $n_width && |
| 342 | 342 | in_array($n_style, self::$_BORDER_STYLE_SCORE) && |
| 343 | - self::$_BORDER_STYLE_SCORE[ $n_style ] > self::$_BORDER_STYLE_SCORE[ $o_style ]) ) |
|
| 343 | + self::$_BORDER_STYLE_SCORE[$n_style] > self::$_BORDER_STYLE_SCORE[$o_style])) |
|
| 344 | 344 | $this->_borders[$i][$j][$h_v] = $border_spec; |
| 345 | 345 | |
| 346 | 346 | return $this->_borders[$i][$j][$h_v]["width"]; |
@@ -356,37 +356,37 @@ discard block |
||
| 356 | 356 | $collapse = $this->_table->get_style()->border_collapse == "collapse"; |
| 357 | 357 | |
| 358 | 358 | // Recursively add the frames within tables, table-row-groups and table-rows |
| 359 | - if ( $display == "table-row" || |
|
| 359 | + if ($display == "table-row" || |
|
| 360 | 360 | $display == "table" || |
| 361 | 361 | $display == "inline-table" || |
| 362 | - in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) { |
|
| 362 | + in_array($display, Table_Frame_Decorator::$ROW_GROUPS)) { |
|
| 363 | 363 | |
| 364 | 364 | $start_row = $this->__row; |
| 365 | - foreach ( $frame->get_children() as $child ) |
|
| 366 | - $this->add_frame( $child ); |
|
| 365 | + foreach ($frame->get_children() as $child) |
|
| 366 | + $this->add_frame($child); |
|
| 367 | 367 | |
| 368 | - if ( $display == "table-row" ) |
|
| 368 | + if ($display == "table-row") |
|
| 369 | 369 | $this->add_row(); |
| 370 | 370 | |
| 371 | 371 | $num_rows = $this->__row - $start_row - 1; |
| 372 | 372 | $key = $frame->get_id(); |
| 373 | 373 | |
| 374 | 374 | // Row groups always span across the entire table |
| 375 | - $this->_frames[ $key ]["columns"] = range(0,max(0,$this->_num_cols-1)); |
|
| 376 | - $this->_frames[ $key ]["rows"] = range($start_row, max(0, $this->__row - 1)); |
|
| 377 | - $this->_frames[ $key ]["frame"] = $frame; |
|
| 375 | + $this->_frames[$key]["columns"] = range(0, max(0, $this->_num_cols - 1)); |
|
| 376 | + $this->_frames[$key]["rows"] = range($start_row, max(0, $this->__row - 1)); |
|
| 377 | + $this->_frames[$key]["frame"] = $frame; |
|
| 378 | 378 | |
| 379 | - if ( $display != "table-row" && $collapse ) { |
|
| 379 | + if ($display != "table-row" && $collapse) { |
|
| 380 | 380 | |
| 381 | 381 | $bp = $style->get_border_properties(); |
| 382 | 382 | |
| 383 | 383 | // Resolve the borders |
| 384 | - for ( $i = 0; $i < $num_rows+1; $i++) { |
|
| 384 | + for ($i = 0; $i < $num_rows + 1; $i++) { |
|
| 385 | 385 | $this->_resolve_border($start_row + $i, 0, "vertical", $bp["left"]); |
| 386 | 386 | $this->_resolve_border($start_row + $i, $this->_num_cols, "vertical", $bp["right"]); |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - for ( $j = 0; $j < $this->_num_cols; $j++) { |
|
| 389 | + for ($j = 0; $j < $this->_num_cols; $j++) { |
|
| 390 | 390 | $this->_resolve_border($start_row, $j, "horizontal", $bp["top"]); |
| 391 | 391 | $this->_resolve_border($this->__row, $j, "horizontal", $bp["bottom"]); |
| 392 | 392 | } |
@@ -400,14 +400,14 @@ discard block |
||
| 400 | 400 | $colspan = $frame->get_node()->getAttribute("colspan"); |
| 401 | 401 | $rowspan = $frame->get_node()->getAttribute("rowspan"); |
| 402 | 402 | |
| 403 | - if ( !$colspan ) { |
|
| 403 | + if (!$colspan) { |
|
| 404 | 404 | $colspan = 1; |
| 405 | - $frame->get_node()->setAttribute("colspan",1); |
|
| 405 | + $frame->get_node()->setAttribute("colspan", 1); |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - if ( !$rowspan ) { |
|
| 408 | + if (!$rowspan) { |
|
| 409 | 409 | $rowspan = 1; |
| 410 | - $frame->get_node()->setAttribute("rowspan",1); |
|
| 410 | + $frame->get_node()->setAttribute("rowspan", 1); |
|
| 411 | 411 | } |
| 412 | 412 | $key = $frame->get_id(); |
| 413 | 413 | |
@@ -419,20 +419,20 @@ discard block |
||
| 419 | 419 | |
| 420 | 420 | // Find the next available column (fix by Ciro Mondueri) |
| 421 | 421 | $ac = $this->__col; |
| 422 | - while ( isset($this->_cells[$this->__row][$ac]) ) |
|
| 422 | + while (isset($this->_cells[$this->__row][$ac])) |
|
| 423 | 423 | $ac++; |
| 424 | 424 | $this->__col = $ac; |
| 425 | 425 | |
| 426 | 426 | // Rows: |
| 427 | - for ( $i = 0; $i < $rowspan; $i++ ) { |
|
| 427 | + for ($i = 0; $i < $rowspan; $i++) { |
|
| 428 | 428 | $row = $this->__row + $i; |
| 429 | 429 | |
| 430 | - $this->_frames[ $key ]["rows"][] = $row; |
|
| 430 | + $this->_frames[$key]["rows"][] = $row; |
|
| 431 | 431 | |
| 432 | - for ( $j = 0; $j < $colspan; $j++) |
|
| 432 | + for ($j = 0; $j < $colspan; $j++) |
|
| 433 | 433 | $this->_cells[$row][$this->__col + $j] = $frame; |
| 434 | 434 | |
| 435 | - if ( $collapse ) { |
|
| 435 | + if ($collapse) { |
|
| 436 | 436 | // Resolve vertical borders |
| 437 | 437 | $max_left = max($max_left, $this->_resolve_border($row, $this->__col, "vertical", $bp["left"])); |
| 438 | 438 | $max_right = max($max_right, $this->_resolve_border($row, $this->__col + $colspan, "vertical", $bp["right"])); |
@@ -442,21 +442,21 @@ discard block |
||
| 442 | 442 | $max_top = $max_bottom = 0; |
| 443 | 443 | |
| 444 | 444 | // Columns: |
| 445 | - for ( $j = 0; $j < $colspan; $j++ ) { |
|
| 445 | + for ($j = 0; $j < $colspan; $j++) { |
|
| 446 | 446 | $col = $this->__col + $j; |
| 447 | - $this->_frames[ $key ]["columns"][] = $col; |
|
| 447 | + $this->_frames[$key]["columns"][] = $col; |
|
| 448 | 448 | |
| 449 | - if ( $collapse ) { |
|
| 449 | + if ($collapse) { |
|
| 450 | 450 | // Resolve horizontal borders |
| 451 | 451 | $max_top = max($max_top, $this->_resolve_border($this->__row, $col, "horizontal", $bp["top"])); |
| 452 | 452 | $max_bottom = max($max_bottom, $this->_resolve_border($this->__row + $rowspan, $col, "horizontal", $bp["bottom"])); |
| 453 | 453 | } |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - $this->_frames[ $key ]["frame"] = $frame; |
|
| 456 | + $this->_frames[$key]["frame"] = $frame; |
|
| 457 | 457 | |
| 458 | 458 | // Handle seperated border model |
| 459 | - if ( !$collapse ) { |
|
| 459 | + if (!$collapse) { |
|
| 460 | 460 | list($h, $v) = $this->_table->get_style()->border_spacing; |
| 461 | 461 | |
| 462 | 462 | // Border spacing is effectively a margin between cells |
@@ -481,26 +481,26 @@ discard block |
||
| 481 | 481 | |
| 482 | 482 | $width = $style->width; |
| 483 | 483 | |
| 484 | - if ( is_percent($width) ) { |
|
| 484 | + if (is_percent($width)) { |
|
| 485 | 485 | $var = "percent"; |
| 486 | - $val = (float)rtrim($width, "% ") / $colspan; |
|
| 486 | + $val = (float) rtrim($width, "% ") / $colspan; |
|
| 487 | 487 | |
| 488 | - } else if ( $width !== "auto" ) { |
|
| 488 | + } else if ($width !== "auto") { |
|
| 489 | 489 | $var = "absolute"; |
| 490 | 490 | $val = $style->length_in_pt($frame_min) / $colspan; |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | $min = 0; |
| 494 | 494 | $max = 0; |
| 495 | - for ( $cs = 0; $cs < $colspan; $cs++ ) { |
|
| 495 | + for ($cs = 0; $cs < $colspan; $cs++) { |
|
| 496 | 496 | |
| 497 | 497 | // Resolve the frame's width(s) with other cells |
| 498 | - $col =& $this->get_column( $this->__col + $cs ); |
|
| 498 | + $col = & $this->get_column($this->__col + $cs); |
|
| 499 | 499 | |
| 500 | 500 | // Note: $var is either 'percent' or 'absolute'. We compare the |
| 501 | 501 | // requested percentage or absolute values with the existing widths |
| 502 | 502 | // and adjust accordingly. |
| 503 | - if ( isset($var) && $val > $col[$var] ) { |
|
| 503 | + if (isset($var) && $val > $col[$var]) { |
|
| 504 | 504 | $col[$var] = $val; |
| 505 | 505 | $col["auto"] = false; |
| 506 | 506 | } |
@@ -510,25 +510,25 @@ discard block |
||
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | |
| 513 | - if ( $frame_min > $min ) { |
|
| 513 | + if ($frame_min > $min) { |
|
| 514 | 514 | // The frame needs more space. Expand each sub-column |
| 515 | 515 | $inc = ($frame_min - $min) / $colspan; |
| 516 | 516 | for ($c = 0; $c < $colspan; $c++) { |
| 517 | - $col =& $this->get_column($this->__col + $c); |
|
| 517 | + $col = & $this->get_column($this->__col + $c); |
|
| 518 | 518 | $col["min-width"] += $inc; |
| 519 | 519 | } |
| 520 | 520 | } |
| 521 | 521 | |
| 522 | - if ( $frame_max > $max ) { |
|
| 522 | + if ($frame_max > $max) { |
|
| 523 | 523 | $inc = ($frame_max - $max) / $colspan; |
| 524 | 524 | for ($c = 0; $c < $colspan; $c++) { |
| 525 | - $col =& $this->get_column($this->__col + $c); |
|
| 525 | + $col = & $this->get_column($this->__col + $c); |
|
| 526 | 526 | $col["max-width"] += $inc; |
| 527 | 527 | } |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | $this->__col += $colspan; |
| 531 | - if ( $this->__col > $this->_num_cols ) |
|
| 531 | + if ($this->__col > $this->_num_cols) |
|
| 532 | 532 | $this->_num_cols = $this->__col; |
| 533 | 533 | |
| 534 | 534 | } |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | |
| 543 | 543 | // Find the next available column |
| 544 | 544 | $i = 0; |
| 545 | - while ( isset($this->_cells[$this->__row][$i]) ) |
|
| 545 | + while (isset($this->_cells[$this->__row][$i])) |
|
| 546 | 546 | $i++; |
| 547 | 547 | |
| 548 | 548 | $this->__col = $i; |
@@ -559,8 +559,8 @@ discard block |
||
| 559 | 559 | function remove_row(Frame $row) { |
| 560 | 560 | |
| 561 | 561 | $key = $row->get_id(); |
| 562 | - if ( !isset($this->_frames[$key]) ) |
|
| 563 | - return; // Presumably this row has alredy been removed |
|
| 562 | + if (!isset($this->_frames[$key])) |
|
| 563 | + return; // Presumably this row has alredy been removed |
|
| 564 | 564 | |
| 565 | 565 | $this->_row = $this->_num_rows--; |
| 566 | 566 | |
@@ -568,11 +568,11 @@ discard block |
||
| 568 | 568 | $columns = $this->_frames[$key]["columns"]; |
| 569 | 569 | |
| 570 | 570 | // Remove all frames from this row |
| 571 | - foreach ( $rows as $r ) { |
|
| 572 | - foreach ( $columns as $c ) { |
|
| 573 | - if ( isset($this->_cells[$r][$c]) ) { |
|
| 571 | + foreach ($rows as $r) { |
|
| 572 | + foreach ($columns as $c) { |
|
| 573 | + if (isset($this->_cells[$r][$c])) { |
|
| 574 | 574 | $frame = $this->_cells[$r][$c]; |
| 575 | - unset($this->_frames[ $frame->get_id() ]); |
|
| 575 | + unset($this->_frames[$frame->get_id()]); |
|
| 576 | 576 | unset($this->_cells[$r][$c]); |
| 577 | 577 | } |
| 578 | 578 | } |
@@ -591,8 +591,8 @@ discard block |
||
| 591 | 591 | function remove_row_group(Frame $group) { |
| 592 | 592 | |
| 593 | 593 | $key = $group->get_id(); |
| 594 | - if ( !isset($this->_frames[$key]) ) |
|
| 595 | - return; // Presumably this row has alredy been removed |
|
| 594 | + if (!isset($this->_frames[$key])) |
|
| 595 | + return; // Presumably this row has alredy been removed |
|
| 596 | 596 | |
| 597 | 597 | $iter = $group->get_first_child(); |
| 598 | 598 | while ($iter) { |
@@ -615,7 +615,7 @@ discard block |
||
| 615 | 615 | $r_key = $last_row->get_id(); |
| 616 | 616 | |
| 617 | 617 | $r_rows = $this->_frames[$r_key]["rows"]; |
| 618 | - $this->_frames[$g_key]["rows"] = range( $this->_frames[$g_key]["rows"][0], end($r_rows) ); |
|
| 618 | + $this->_frames[$g_key]["rows"] = range($this->_frames[$g_key]["rows"][0], end($r_rows)); |
|
| 619 | 619 | |
| 620 | 620 | } |
| 621 | 621 | |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | // column[0]["x"] must be set. |
| 627 | 627 | |
| 628 | 628 | $x = $this->_columns[0]["x"]; |
| 629 | - foreach ( array_keys($this->_columns) as $j ) { |
|
| 629 | + foreach (array_keys($this->_columns) as $j) { |
|
| 630 | 630 | $this->_columns[$j]["x"] = $x; |
| 631 | 631 | $x += $this->_columns[$j]["used-width"]; |
| 632 | 632 | |
@@ -638,18 +638,18 @@ discard block |
||
| 638 | 638 | // Pre-condition: widths and heights of each column & row must be |
| 639 | 639 | // calcluated |
| 640 | 640 | |
| 641 | - foreach ( $this->_frames as $arr ) { |
|
| 641 | + foreach ($this->_frames as $arr) { |
|
| 642 | 642 | $frame = $arr["frame"]; |
| 643 | 643 | |
| 644 | 644 | $h = 0; |
| 645 | - foreach( $arr["rows"] as $row ) { |
|
| 646 | - if ( !isset($this->_rows[$row]) ) |
|
| 645 | + foreach ($arr["rows"] as $row) { |
|
| 646 | + if (!isset($this->_rows[$row])) |
|
| 647 | 647 | // The row has been removed because of a page split, so skip it. |
| 648 | 648 | continue; |
| 649 | 649 | $h += $this->_rows[$row]["height"]; |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
| 652 | + if ($frame instanceof Table_Cell_Frame_Decorator) |
|
| 653 | 653 | $frame->set_cell_height($h); |
| 654 | 654 | else |
| 655 | 655 | $frame->get_style()->height = $h; |
@@ -666,12 +666,12 @@ discard block |
||
| 666 | 666 | |
| 667 | 667 | |
| 668 | 668 | // Distribute the increased height proportionally amongst each row |
| 669 | - foreach ( $this->_frames as $arr ) { |
|
| 669 | + foreach ($this->_frames as $arr) { |
|
| 670 | 670 | $frame = $arr["frame"]; |
| 671 | 671 | |
| 672 | 672 | $h = 0; |
| 673 | - foreach ($arr["rows"] as $row ) { |
|
| 674 | - if ( !isset($this->_rows[$row]) ) |
|
| 673 | + foreach ($arr["rows"] as $row) { |
|
| 674 | + if (!isset($this->_rows[$row])) |
|
| 675 | 675 | continue; |
| 676 | 676 | |
| 677 | 677 | $h += $this->_rows[$row]["height"]; |
@@ -679,7 +679,7 @@ discard block |
||
| 679 | 679 | |
| 680 | 680 | $new_height = ($h / $content_height) * $table_height; |
| 681 | 681 | |
| 682 | - if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
| 682 | + if ($frame instanceof Table_Cell_Frame_Decorator) |
|
| 683 | 683 | $frame->set_cell_height($new_height); |
| 684 | 684 | else |
| 685 | 685 | $frame->get_style()->height = $new_height; |
@@ -694,19 +694,19 @@ discard block |
||
| 694 | 694 | $str = ""; |
| 695 | 695 | $str .= "Columns:<br/>"; |
| 696 | 696 | $str .= pre_r($this->_columns, true); |
| 697 | - $str .= "Rows:<br/>"; |
|
| 697 | + $str .= "Rows:<br/>"; |
|
| 698 | 698 | $str .= pre_r($this->_rows, true); |
| 699 | 699 | |
| 700 | - $str .= "Frames:<br/>"; |
|
| 700 | + $str .= "Frames:<br/>"; |
|
| 701 | 701 | $arr = array(); |
| 702 | - foreach ( $this->_frames as $key => $val ) |
|
| 702 | + foreach ($this->_frames as $key => $val) |
|
| 703 | 703 | $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]); |
| 704 | 704 | |
| 705 | 705 | $str .= pre_r($arr, true); |
| 706 | 706 | |
| 707 | - if ( php_sapi_name() == "cli" ) |
|
| 708 | - $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
| 709 | - array("\n",chr(27)."[01;33m", chr(27)."[0m"), |
|
| 707 | + if (php_sapi_name() == "cli") |
|
| 708 | + $str = strip_tags(str_replace(array("<br/>", "<b>", "</b>"), |
|
| 709 | + array("\n", chr(27)."[01;33m", chr(27)."[0m"), |
|
| 710 | 710 | $str)); |
| 711 | 711 | return $str; |
| 712 | 712 | } |
@@ -170,14 +170,15 @@ discard block |
||
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | function &get_column($i) { |
| 173 | - if ( !isset($this->_columns[$i]) ) |
|
| 174 | - $this->_columns[$i] = array("x" => 0, |
|
| 173 | + if ( !isset($this->_columns[$i]) ) { |
|
| 174 | + $this->_columns[$i] = array("x" => 0, |
|
| 175 | 175 | "min-width" => 0, |
| 176 | 176 | "max-width" => 0, |
| 177 | 177 | "used-width" => null, |
| 178 | 178 | "absolute" => 0, |
| 179 | 179 | "percent" => 0, |
| 180 | 180 | "auto" => true); |
| 181 | + } |
|
| 181 | 182 | |
| 182 | 183 | return $this->_columns[$i]; |
| 183 | 184 | } |
@@ -187,20 +188,23 @@ discard block |
||
| 187 | 188 | } |
| 188 | 189 | |
| 189 | 190 | function &get_row($j) { |
| 190 | - if ( !isset($this->_rows[$j]) ) |
|
| 191 | - $this->_rows[$j] = array("y" => 0, |
|
| 191 | + if ( !isset($this->_rows[$j]) ) { |
|
| 192 | + $this->_rows[$j] = array("y" => 0, |
|
| 192 | 193 | "first-column" => 0, |
| 193 | 194 | "height" => null); |
| 195 | + } |
|
| 194 | 196 | return $this->_rows[$j]; |
| 195 | 197 | } |
| 196 | 198 | |
| 197 | 199 | function get_border($i, $j, $h_v, $prop = null) { |
| 198 | - if ( !isset($this->_borders[$i][$j][$h_v]) ) |
|
| 199 | - $this->_borders[$i][$j][$h_v] = array("width" => 0, |
|
| 200 | + if ( !isset($this->_borders[$i][$j][$h_v]) ) { |
|
| 201 | + $this->_borders[$i][$j][$h_v] = array("width" => 0, |
|
| 200 | 202 | "style" => "solid", |
| 201 | 203 | "color" => "black"); |
| 202 | - if ( isset($prop) ) |
|
| 203 | - return $this->_borders[$i][$j][$h_v][$prop]; |
|
| 204 | + } |
|
| 205 | + if ( isset($prop) ) { |
|
| 206 | + return $this->_borders[$i][$j][$h_v][$prop]; |
|
| 207 | + } |
|
| 204 | 208 | |
| 205 | 209 | return $this->_borders[$i][$j][$h_v]; |
| 206 | 210 | } |
@@ -248,14 +252,16 @@ discard block |
||
| 248 | 252 | if ( !isset($this->_columns[$col])) { |
| 249 | 253 | $_dompdf_warnings[] = "Frame not found in columns array. Check your table layout for missing or extra TDs."; |
| 250 | 254 | $x = 0; |
| 251 | - } else |
|
| 252 | - $x = $this->_columns[$col]["x"]; |
|
| 255 | + } else { |
|
| 256 | + $x = $this->_columns[$col]["x"]; |
|
| 257 | + } |
|
| 253 | 258 | |
| 254 | 259 | if ( !isset($this->_rows[$row])) { |
| 255 | 260 | $_dompdf_warnings[] = "Frame not found in row array. Check your table layout for missing or extra TDs."; |
| 256 | 261 | $y = 0; |
| 257 | - } else |
|
| 258 | - $y = $this->_rows[$row]["y"]; |
|
| 262 | + } else { |
|
| 263 | + $y = $this->_rows[$row]["y"]; |
|
| 264 | + } |
|
| 259 | 265 | |
| 260 | 266 | return array($x, $y, "x" => $x, "y" => $y); |
| 261 | 267 | } |
@@ -269,8 +275,9 @@ discard block |
||
| 269 | 275 | |
| 270 | 276 | $cols = $this->_frames[$key]["columns"]; |
| 271 | 277 | $w = 0; |
| 272 | - foreach ($cols as $i) |
|
| 273 | - $w += $this->_columns[$i]["used-width"]; |
|
| 278 | + foreach ($cols as $i) { |
|
| 279 | + $w += $this->_columns[$i]["used-width"]; |
|
| 280 | + } |
|
| 274 | 281 | |
| 275 | 282 | return $w; |
| 276 | 283 | |
@@ -279,8 +286,9 @@ discard block |
||
| 279 | 286 | function get_frame_height($frame) { |
| 280 | 287 | $key = $frame->get_id(); |
| 281 | 288 | |
| 282 | - if ( !isset($this->_frames[$key]) ) |
|
| 283 | - throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
| 289 | + if ( !isset($this->_frames[$key]) ) { |
|
| 290 | + throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
| 291 | + } |
|
| 284 | 292 | |
| 285 | 293 | $rows = $this->_frames[$key]["rows"]; |
| 286 | 294 | $h = 0; |
@@ -306,8 +314,9 @@ discard block |
||
| 306 | 314 | |
| 307 | 315 | function set_row_height($i, $height) { |
| 308 | 316 | $row =& $this->get_row($i); |
| 309 | - if ( $height <= $row["height"] ) |
|
| 310 | - return; |
|
| 317 | + if ( $height <= $row["height"] ) { |
|
| 318 | + return; |
|
| 319 | + } |
|
| 311 | 320 | |
| 312 | 321 | $row["height"] = $height; |
| 313 | 322 | $next_row =& $this->get_row($i+1); |
@@ -340,8 +349,9 @@ discard block |
||
| 340 | 349 | |
| 341 | 350 | ($o_width == $n_width && |
| 342 | 351 | in_array($n_style, self::$_BORDER_STYLE_SCORE) && |
| 343 | - self::$_BORDER_STYLE_SCORE[ $n_style ] > self::$_BORDER_STYLE_SCORE[ $o_style ]) ) |
|
| 344 | - $this->_borders[$i][$j][$h_v] = $border_spec; |
|
| 352 | + self::$_BORDER_STYLE_SCORE[ $n_style ] > self::$_BORDER_STYLE_SCORE[ $o_style ]) ) { |
|
| 353 | + $this->_borders[$i][$j][$h_v] = $border_spec; |
|
| 354 | + } |
|
| 345 | 355 | |
| 346 | 356 | return $this->_borders[$i][$j][$h_v]["width"]; |
| 347 | 357 | } |
@@ -362,11 +372,13 @@ discard block |
||
| 362 | 372 | in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) { |
| 363 | 373 | |
| 364 | 374 | $start_row = $this->__row; |
| 365 | - foreach ( $frame->get_children() as $child ) |
|
| 366 | - $this->add_frame( $child ); |
|
| 375 | + foreach ( $frame->get_children() as $child ) { |
|
| 376 | + $this->add_frame( $child ); |
|
| 377 | + } |
|
| 367 | 378 | |
| 368 | - if ( $display == "table-row" ) |
|
| 369 | - $this->add_row(); |
|
| 379 | + if ( $display == "table-row" ) { |
|
| 380 | + $this->add_row(); |
|
| 381 | + } |
|
| 370 | 382 | |
| 371 | 383 | $num_rows = $this->__row - $start_row - 1; |
| 372 | 384 | $key = $frame->get_id(); |
@@ -419,8 +431,9 @@ discard block |
||
| 419 | 431 | |
| 420 | 432 | // Find the next available column (fix by Ciro Mondueri) |
| 421 | 433 | $ac = $this->__col; |
| 422 | - while ( isset($this->_cells[$this->__row][$ac]) ) |
|
| 423 | - $ac++; |
|
| 434 | + while ( isset($this->_cells[$this->__row][$ac]) ) { |
|
| 435 | + $ac++; |
|
| 436 | + } |
|
| 424 | 437 | $this->__col = $ac; |
| 425 | 438 | |
| 426 | 439 | // Rows: |
@@ -429,8 +442,9 @@ discard block |
||
| 429 | 442 | |
| 430 | 443 | $this->_frames[ $key ]["rows"][] = $row; |
| 431 | 444 | |
| 432 | - for ( $j = 0; $j < $colspan; $j++) |
|
| 433 | - $this->_cells[$row][$this->__col + $j] = $frame; |
|
| 445 | + for ( $j = 0; $j < $colspan; $j++) { |
|
| 446 | + $this->_cells[$row][$this->__col + $j] = $frame; |
|
| 447 | + } |
|
| 434 | 448 | |
| 435 | 449 | if ( $collapse ) { |
| 436 | 450 | // Resolve vertical borders |
@@ -528,8 +542,9 @@ discard block |
||
| 528 | 542 | } |
| 529 | 543 | |
| 530 | 544 | $this->__col += $colspan; |
| 531 | - if ( $this->__col > $this->_num_cols ) |
|
| 532 | - $this->_num_cols = $this->__col; |
|
| 545 | + if ( $this->__col > $this->_num_cols ) { |
|
| 546 | + $this->_num_cols = $this->__col; |
|
| 547 | + } |
|
| 533 | 548 | |
| 534 | 549 | } |
| 535 | 550 | |
@@ -542,8 +557,9 @@ discard block |
||
| 542 | 557 | |
| 543 | 558 | // Find the next available column |
| 544 | 559 | $i = 0; |
| 545 | - while ( isset($this->_cells[$this->__row][$i]) ) |
|
| 546 | - $i++; |
|
| 560 | + while ( isset($this->_cells[$this->__row][$i]) ) { |
|
| 561 | + $i++; |
|
| 562 | + } |
|
| 547 | 563 | |
| 548 | 564 | $this->__col = $i; |
| 549 | 565 | |
@@ -559,8 +575,10 @@ discard block |
||
| 559 | 575 | function remove_row(Frame $row) { |
| 560 | 576 | |
| 561 | 577 | $key = $row->get_id(); |
| 562 | - if ( !isset($this->_frames[$key]) ) |
|
| 563 | - return; // Presumably this row has alredy been removed |
|
| 578 | + if ( !isset($this->_frames[$key]) ) { |
|
| 579 | + return; |
|
| 580 | + } |
|
| 581 | + // Presumably this row has alredy been removed |
|
| 564 | 582 | |
| 565 | 583 | $this->_row = $this->_num_rows--; |
| 566 | 584 | |
@@ -591,8 +609,10 @@ discard block |
||
| 591 | 609 | function remove_row_group(Frame $group) { |
| 592 | 610 | |
| 593 | 611 | $key = $group->get_id(); |
| 594 | - if ( !isset($this->_frames[$key]) ) |
|
| 595 | - return; // Presumably this row has alredy been removed |
|
| 612 | + if ( !isset($this->_frames[$key]) ) { |
|
| 613 | + return; |
|
| 614 | + } |
|
| 615 | + // Presumably this row has alredy been removed |
|
| 596 | 616 | |
| 597 | 617 | $iter = $group->get_first_child(); |
| 598 | 618 | while ($iter) { |
@@ -643,16 +663,18 @@ discard block |
||
| 643 | 663 | |
| 644 | 664 | $h = 0; |
| 645 | 665 | foreach( $arr["rows"] as $row ) { |
| 646 | - if ( !isset($this->_rows[$row]) ) |
|
| 647 | - // The row has been removed because of a page split, so skip it. |
|
| 666 | + if ( !isset($this->_rows[$row]) ) { |
|
| 667 | + // The row has been removed because of a page split, so skip it. |
|
| 648 | 668 | continue; |
| 669 | + } |
|
| 649 | 670 | $h += $this->_rows[$row]["height"]; |
| 650 | 671 | } |
| 651 | 672 | |
| 652 | - if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
| 653 | - $frame->set_cell_height($h); |
|
| 654 | - else |
|
| 655 | - $frame->get_style()->height = $h; |
|
| 673 | + if ( $frame instanceof Table_Cell_Frame_Decorator ) { |
|
| 674 | + $frame->set_cell_height($h); |
|
| 675 | + } else { |
|
| 676 | + $frame->get_style()->height = $h; |
|
| 677 | + } |
|
| 656 | 678 | } |
| 657 | 679 | |
| 658 | 680 | } |
@@ -671,18 +693,20 @@ discard block |
||
| 671 | 693 | |
| 672 | 694 | $h = 0; |
| 673 | 695 | foreach ($arr["rows"] as $row ) { |
| 674 | - if ( !isset($this->_rows[$row]) ) |
|
| 675 | - continue; |
|
| 696 | + if ( !isset($this->_rows[$row]) ) { |
|
| 697 | + continue; |
|
| 698 | + } |
|
| 676 | 699 | |
| 677 | 700 | $h += $this->_rows[$row]["height"]; |
| 678 | 701 | } |
| 679 | 702 | |
| 680 | 703 | $new_height = ($h / $content_height) * $table_height; |
| 681 | 704 | |
| 682 | - if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
| 683 | - $frame->set_cell_height($new_height); |
|
| 684 | - else |
|
| 685 | - $frame->get_style()->height = $new_height; |
|
| 705 | + if ( $frame instanceof Table_Cell_Frame_Decorator ) { |
|
| 706 | + $frame->set_cell_height($new_height); |
|
| 707 | + } else { |
|
| 708 | + $frame->get_style()->height = $new_height; |
|
| 709 | + } |
|
| 686 | 710 | } |
| 687 | 711 | |
| 688 | 712 | } |
@@ -699,15 +723,17 @@ discard block |
||
| 699 | 723 | |
| 700 | 724 | $str .= "Frames:<br/>"; |
| 701 | 725 | $arr = array(); |
| 702 | - foreach ( $this->_frames as $key => $val ) |
|
| 703 | - $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]); |
|
| 726 | + foreach ( $this->_frames as $key => $val ) { |
|
| 727 | + $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]); |
|
| 728 | + } |
|
| 704 | 729 | |
| 705 | 730 | $str .= pre_r($arr, true); |
| 706 | 731 | |
| 707 | - if ( php_sapi_name() == "cli" ) |
|
| 708 | - $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
| 732 | + if ( php_sapi_name() == "cli" ) { |
|
| 733 | + $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
| 709 | 734 | array("\n",chr(27)."[01;33m", chr(27)."[0m"), |
| 710 | 735 | $str)); |
| 736 | + } |
|
| 711 | 737 | return $str; |
| 712 | 738 | } |
| 713 | 739 | } |
@@ -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: cellmap.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -50,12 +49,12 @@ discard block |
||
| 50 | 49 | */ |
| 51 | 50 | class Cellmap { |
| 52 | 51 | |
| 53 | - /** |
|
| 54 | - * Border style weight lookup for collapsed border resolution. |
|
| 55 | - * |
|
| 56 | - * @var array |
|
| 57 | - */ |
|
| 58 | - static protected $_BORDER_STYLE_SCORE = array("inset" => 1, |
|
| 52 | + /** |
|
| 53 | + * Border style weight lookup for collapsed border resolution. |
|
| 54 | + * |
|
| 55 | + * @var array |
|
| 56 | + */ |
|
| 57 | + static protected $_BORDER_STYLE_SCORE = array("inset" => 1, |
|
| 59 | 58 | "groove" => 2, |
| 60 | 59 | "outset" => 3, |
| 61 | 60 | "ridge" => 4, |
@@ -65,87 +64,87 @@ discard block |
||
| 65 | 64 | "double" => 8, |
| 66 | 65 | "none" => 0); |
| 67 | 66 | |
| 68 | - /** |
|
| 69 | - * The table object this cellmap is attached to. |
|
| 70 | - * |
|
| 71 | - * @var Table_Frame_Decorator |
|
| 72 | - */ |
|
| 73 | - protected $_table; |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * The total number of rows in the table |
|
| 77 | - * |
|
| 78 | - * @var int |
|
| 79 | - */ |
|
| 80 | - protected $_num_rows; |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * The total number of columns in the table |
|
| 84 | - * |
|
| 85 | - * @var int |
|
| 86 | - */ |
|
| 87 | - protected $_num_cols; |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * 2D array mapping <row,column> to frames |
|
| 91 | - * |
|
| 92 | - * @var array |
|
| 93 | - */ |
|
| 94 | - protected $_cells; |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * 1D array of column dimensions |
|
| 98 | - * |
|
| 99 | - * @var array |
|
| 100 | - */ |
|
| 101 | - protected $_columns; |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * 1D array of row dimensions |
|
| 105 | - * |
|
| 106 | - * @var array |
|
| 107 | - */ |
|
| 108 | - protected $_rows; |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * 2D array of border specs |
|
| 112 | - * |
|
| 113 | - * @var array |
|
| 114 | - */ |
|
| 115 | - protected $_borders; |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * 1D Array mapping frames to (multiple) <row, col> pairs, keyed on |
|
| 119 | - * frame_id. |
|
| 120 | - * |
|
| 121 | - * @var array |
|
| 122 | - */ |
|
| 123 | - protected $_frames; |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * Current column when adding cells, 0-based |
|
| 127 | - * |
|
| 128 | - * @var int |
|
| 129 | - */ |
|
| 130 | - private $__col; |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * Current row when adding cells, 0-based |
|
| 134 | - * |
|
| 135 | - * @var int |
|
| 136 | - */ |
|
| 137 | - private $__row; |
|
| 138 | - |
|
| 139 | - //........................................................................ |
|
| 140 | - |
|
| 141 | - function __construct(Table_Frame_Decorator $table) { |
|
| 67 | + /** |
|
| 68 | + * The table object this cellmap is attached to. |
|
| 69 | + * |
|
| 70 | + * @var Table_Frame_Decorator |
|
| 71 | + */ |
|
| 72 | + protected $_table; |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * The total number of rows in the table |
|
| 76 | + * |
|
| 77 | + * @var int |
|
| 78 | + */ |
|
| 79 | + protected $_num_rows; |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * The total number of columns in the table |
|
| 83 | + * |
|
| 84 | + * @var int |
|
| 85 | + */ |
|
| 86 | + protected $_num_cols; |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * 2D array mapping <row,column> to frames |
|
| 90 | + * |
|
| 91 | + * @var array |
|
| 92 | + */ |
|
| 93 | + protected $_cells; |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * 1D array of column dimensions |
|
| 97 | + * |
|
| 98 | + * @var array |
|
| 99 | + */ |
|
| 100 | + protected $_columns; |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * 1D array of row dimensions |
|
| 104 | + * |
|
| 105 | + * @var array |
|
| 106 | + */ |
|
| 107 | + protected $_rows; |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * 2D array of border specs |
|
| 111 | + * |
|
| 112 | + * @var array |
|
| 113 | + */ |
|
| 114 | + protected $_borders; |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * 1D Array mapping frames to (multiple) <row, col> pairs, keyed on |
|
| 118 | + * frame_id. |
|
| 119 | + * |
|
| 120 | + * @var array |
|
| 121 | + */ |
|
| 122 | + protected $_frames; |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Current column when adding cells, 0-based |
|
| 126 | + * |
|
| 127 | + * @var int |
|
| 128 | + */ |
|
| 129 | + private $__col; |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Current row when adding cells, 0-based |
|
| 133 | + * |
|
| 134 | + * @var int |
|
| 135 | + */ |
|
| 136 | + private $__row; |
|
| 137 | + |
|
| 138 | + //........................................................................ |
|
| 139 | + |
|
| 140 | + function __construct(Table_Frame_Decorator $table) { |
|
| 142 | 141 | $this->_table = $table; |
| 143 | 142 | $this->reset(); |
| 144 | - } |
|
| 143 | + } |
|
| 145 | 144 | |
| 146 | - //........................................................................ |
|
| 145 | + //........................................................................ |
|
| 147 | 146 | |
| 148 | - function reset() { |
|
| 147 | + function reset() { |
|
| 149 | 148 | $this->_num_rows = 0; |
| 150 | 149 | $this->_num_cols = 0; |
| 151 | 150 | |
@@ -158,54 +157,54 @@ discard block |
||
| 158 | 157 | $this->_borders = array(); |
| 159 | 158 | |
| 160 | 159 | $this->__col = $this->__row = 0; |
| 161 | - } |
|
| 160 | + } |
|
| 162 | 161 | |
| 163 | - //........................................................................ |
|
| 162 | + //........................................................................ |
|
| 164 | 163 | |
| 165 | - function get_num_rows() { return $this->_num_rows; } |
|
| 166 | - function get_num_cols() { return $this->_num_cols; } |
|
| 164 | + function get_num_rows() { return $this->_num_rows; } |
|
| 165 | + function get_num_cols() { return $this->_num_cols; } |
|
| 167 | 166 | |
| 168 | - function &get_columns() { |
|
| 167 | + function &get_columns() { |
|
| 169 | 168 | return $this->_columns; |
| 170 | - } |
|
| 169 | + } |
|
| 171 | 170 | |
| 172 | - function &get_column($i) { |
|
| 171 | + function &get_column($i) { |
|
| 173 | 172 | if ( !isset($this->_columns[$i]) ) |
| 174 | - $this->_columns[$i] = array("x" => 0, |
|
| 175 | - "min-width" => 0, |
|
| 176 | - "max-width" => 0, |
|
| 177 | - "used-width" => null, |
|
| 178 | - "absolute" => 0, |
|
| 179 | - "percent" => 0, |
|
| 180 | - "auto" => true); |
|
| 173 | + $this->_columns[$i] = array("x" => 0, |
|
| 174 | + "min-width" => 0, |
|
| 175 | + "max-width" => 0, |
|
| 176 | + "used-width" => null, |
|
| 177 | + "absolute" => 0, |
|
| 178 | + "percent" => 0, |
|
| 179 | + "auto" => true); |
|
| 181 | 180 | |
| 182 | 181 | return $this->_columns[$i]; |
| 183 | - } |
|
| 182 | + } |
|
| 184 | 183 | |
| 185 | - function &get_rows() { |
|
| 184 | + function &get_rows() { |
|
| 186 | 185 | return $this->_rows; |
| 187 | - } |
|
| 186 | + } |
|
| 188 | 187 | |
| 189 | - function &get_row($j) { |
|
| 188 | + function &get_row($j) { |
|
| 190 | 189 | if ( !isset($this->_rows[$j]) ) |
| 191 | - $this->_rows[$j] = array("y" => 0, |
|
| 192 | - "first-column" => 0, |
|
| 193 | - "height" => null); |
|
| 190 | + $this->_rows[$j] = array("y" => 0, |
|
| 191 | + "first-column" => 0, |
|
| 192 | + "height" => null); |
|
| 194 | 193 | return $this->_rows[$j]; |
| 195 | - } |
|
| 194 | + } |
|
| 196 | 195 | |
| 197 | - function get_border($i, $j, $h_v, $prop = null) { |
|
| 196 | + function get_border($i, $j, $h_v, $prop = null) { |
|
| 198 | 197 | if ( !isset($this->_borders[$i][$j][$h_v]) ) |
| 199 | - $this->_borders[$i][$j][$h_v] = array("width" => 0, |
|
| 200 | - "style" => "solid", |
|
| 201 | - "color" => "black"); |
|
| 198 | + $this->_borders[$i][$j][$h_v] = array("width" => 0, |
|
| 199 | + "style" => "solid", |
|
| 200 | + "color" => "black"); |
|
| 202 | 201 | if ( isset($prop) ) |
| 203 | - return $this->_borders[$i][$j][$h_v][$prop]; |
|
| 202 | + return $this->_borders[$i][$j][$h_v][$prop]; |
|
| 204 | 203 | |
| 205 | 204 | return $this->_borders[$i][$j][$h_v]; |
| 206 | - } |
|
| 205 | + } |
|
| 207 | 206 | |
| 208 | - function get_border_properties($i, $j) { |
|
| 207 | + function get_border_properties($i, $j) { |
|
| 209 | 208 | |
| 210 | 209 | $left = $this->get_border($i, $j, "vertical"); |
| 211 | 210 | $right = $this->get_border($i, $j+1, "vertical"); |
@@ -213,119 +212,119 @@ discard block |
||
| 213 | 212 | $bottom = $this->get_border($i+1, $j, "horizontal"); |
| 214 | 213 | |
| 215 | 214 | return compact("top", "bottom", "left", "right"); |
| 216 | - } |
|
| 215 | + } |
|
| 217 | 216 | |
| 218 | - //........................................................................ |
|
| 217 | + //........................................................................ |
|
| 219 | 218 | |
| 220 | - function get_spanned_cells($frame) { |
|
| 219 | + function get_spanned_cells($frame) { |
|
| 221 | 220 | $key = $frame->get_id(); |
| 222 | 221 | |
| 223 | 222 | if ( !isset($this->_frames[$key]) ) { |
| 224 | - throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
| 223 | + throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
| 225 | 224 | } |
| 226 | 225 | |
| 227 | 226 | return $this->_frames[$key]; |
| 228 | 227 | |
| 229 | - } |
|
| 228 | + } |
|
| 230 | 229 | |
| 231 | - function frame_exists_in_cellmap($frame) { |
|
| 230 | + function frame_exists_in_cellmap($frame) { |
|
| 232 | 231 | $key = $frame->get_id(); |
| 233 | 232 | return isset($this->_frames[$key]); |
| 234 | - } |
|
| 233 | + } |
|
| 235 | 234 | |
| 236 | - function get_frame_position($frame) { |
|
| 235 | + function get_frame_position($frame) { |
|
| 237 | 236 | global $_dompdf_warnings; |
| 238 | 237 | |
| 239 | 238 | $key = $frame->get_id(); |
| 240 | 239 | |
| 241 | 240 | if ( !isset($this->_frames[$key]) ) { |
| 242 | - throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
| 241 | + throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
| 243 | 242 | } |
| 244 | 243 | |
| 245 | 244 | $col = $this->_frames[$key]["columns"][0]; |
| 246 | 245 | $row = $this->_frames[$key]["rows"][0]; |
| 247 | 246 | |
| 248 | 247 | if ( !isset($this->_columns[$col])) { |
| 249 | - $_dompdf_warnings[] = "Frame not found in columns array. Check your table layout for missing or extra TDs."; |
|
| 250 | - $x = 0; |
|
| 248 | + $_dompdf_warnings[] = "Frame not found in columns array. Check your table layout for missing or extra TDs."; |
|
| 249 | + $x = 0; |
|
| 251 | 250 | } else |
| 252 | - $x = $this->_columns[$col]["x"]; |
|
| 251 | + $x = $this->_columns[$col]["x"]; |
|
| 253 | 252 | |
| 254 | 253 | if ( !isset($this->_rows[$row])) { |
| 255 | - $_dompdf_warnings[] = "Frame not found in row array. Check your table layout for missing or extra TDs."; |
|
| 256 | - $y = 0; |
|
| 254 | + $_dompdf_warnings[] = "Frame not found in row array. Check your table layout for missing or extra TDs."; |
|
| 255 | + $y = 0; |
|
| 257 | 256 | } else |
| 258 | - $y = $this->_rows[$row]["y"]; |
|
| 257 | + $y = $this->_rows[$row]["y"]; |
|
| 259 | 258 | |
| 260 | 259 | return array($x, $y, "x" => $x, "y" => $y); |
| 261 | - } |
|
| 260 | + } |
|
| 262 | 261 | |
| 263 | - function get_frame_width($frame) { |
|
| 262 | + function get_frame_width($frame) { |
|
| 264 | 263 | $key = $frame->get_id(); |
| 265 | 264 | |
| 266 | 265 | if ( !isset($this->_frames[$key]) ) { |
| 267 | - throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
| 266 | + throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
| 268 | 267 | } |
| 269 | 268 | |
| 270 | 269 | $cols = $this->_frames[$key]["columns"]; |
| 271 | 270 | $w = 0; |
| 272 | 271 | foreach ($cols as $i) |
| 273 | - $w += $this->_columns[$i]["used-width"]; |
|
| 272 | + $w += $this->_columns[$i]["used-width"]; |
|
| 274 | 273 | |
| 275 | 274 | return $w; |
| 276 | 275 | |
| 277 | - } |
|
| 276 | + } |
|
| 278 | 277 | |
| 279 | - function get_frame_height($frame) { |
|
| 278 | + function get_frame_height($frame) { |
|
| 280 | 279 | $key = $frame->get_id(); |
| 281 | 280 | |
| 282 | 281 | if ( !isset($this->_frames[$key]) ) |
| 283 | - throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
| 282 | + throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
| 284 | 283 | |
| 285 | 284 | $rows = $this->_frames[$key]["rows"]; |
| 286 | 285 | $h = 0; |
| 287 | 286 | foreach ($rows as $i) { |
| 288 | - if ( !isset($this->_rows[$i]) ) { |
|
| 287 | + if ( !isset($this->_rows[$i]) ) { |
|
| 289 | 288 | throw new Exception("foo"); |
| 290 | - } |
|
| 291 | - $h += $this->_rows[$i]["height"]; |
|
| 289 | + } |
|
| 290 | + $h += $this->_rows[$i]["height"]; |
|
| 292 | 291 | } |
| 293 | 292 | return $h; |
| 294 | 293 | |
| 295 | - } |
|
| 294 | + } |
|
| 296 | 295 | |
| 297 | 296 | |
| 298 | - //........................................................................ |
|
| 297 | + //........................................................................ |
|
| 299 | 298 | |
| 300 | - function set_column_width($j, $width) { |
|
| 299 | + function set_column_width($j, $width) { |
|
| 301 | 300 | $col =& $this->get_column($j); |
| 302 | 301 | $col["used-width"] = $width; |
| 303 | 302 | $next_col =& $this->get_column($j+1); |
| 304 | 303 | $next_col["x"] = $next_col["x"] + $width; |
| 305 | - } |
|
| 304 | + } |
|
| 306 | 305 | |
| 307 | - function set_row_height($i, $height) { |
|
| 306 | + function set_row_height($i, $height) { |
|
| 308 | 307 | $row =& $this->get_row($i); |
| 309 | 308 | if ( $height <= $row["height"] ) |
| 310 | - return; |
|
| 309 | + return; |
|
| 311 | 310 | |
| 312 | 311 | $row["height"] = $height; |
| 313 | 312 | $next_row =& $this->get_row($i+1); |
| 314 | 313 | $next_row["y"] = $row["y"] + $height; |
| 315 | 314 | |
| 316 | - } |
|
| 315 | + } |
|
| 317 | 316 | |
| 318 | - //........................................................................ |
|
| 317 | + //........................................................................ |
|
| 319 | 318 | |
| 320 | 319 | |
| 321 | - protected function _resolve_border($i, $j, $h_v, $border_spec) { |
|
| 320 | + protected function _resolve_border($i, $j, $h_v, $border_spec) { |
|
| 322 | 321 | $n_width = $border_spec["width"]; |
| 323 | 322 | $n_style = $border_spec["style"]; |
| 324 | 323 | $n_color = $border_spec["color"]; |
| 325 | 324 | |
| 326 | 325 | if ( !isset($this->_borders[$i][$j][$h_v]) ) { |
| 327 | - $this->_borders[$i][$j][$h_v] = $border_spec; |
|
| 328 | - return $this->_borders[$i][$j][$h_v]["width"]; |
|
| 326 | + $this->_borders[$i][$j][$h_v] = $border_spec; |
|
| 327 | + return $this->_borders[$i][$j][$h_v]["width"]; |
|
| 329 | 328 | } |
| 330 | 329 | |
| 331 | 330 | $o_width = $this->_borders[$i][$j][$h_v]["width"]; |
@@ -341,14 +340,14 @@ discard block |
||
| 341 | 340 | ($o_width == $n_width && |
| 342 | 341 | in_array($n_style, self::$_BORDER_STYLE_SCORE) && |
| 343 | 342 | self::$_BORDER_STYLE_SCORE[ $n_style ] > self::$_BORDER_STYLE_SCORE[ $o_style ]) ) |
| 344 | - $this->_borders[$i][$j][$h_v] = $border_spec; |
|
| 343 | + $this->_borders[$i][$j][$h_v] = $border_spec; |
|
| 345 | 344 | |
| 346 | 345 | return $this->_borders[$i][$j][$h_v]["width"]; |
| 347 | - } |
|
| 346 | + } |
|
| 348 | 347 | |
| 349 | - //........................................................................ |
|
| 348 | + //........................................................................ |
|
| 350 | 349 | |
| 351 | - function add_frame(Frame $frame) { |
|
| 350 | + function add_frame(Frame $frame) { |
|
| 352 | 351 | |
| 353 | 352 | $style = $frame->get_style(); |
| 354 | 353 | $display = $style->display; |
@@ -361,39 +360,39 @@ discard block |
||
| 361 | 360 | $display == "inline-table" || |
| 362 | 361 | in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) { |
| 363 | 362 | |
| 364 | - $start_row = $this->__row; |
|
| 365 | - foreach ( $frame->get_children() as $child ) |
|
| 363 | + $start_row = $this->__row; |
|
| 364 | + foreach ( $frame->get_children() as $child ) |
|
| 366 | 365 | $this->add_frame( $child ); |
| 367 | 366 | |
| 368 | - if ( $display == "table-row" ) |
|
| 367 | + if ( $display == "table-row" ) |
|
| 369 | 368 | $this->add_row(); |
| 370 | 369 | |
| 371 | - $num_rows = $this->__row - $start_row - 1; |
|
| 372 | - $key = $frame->get_id(); |
|
| 370 | + $num_rows = $this->__row - $start_row - 1; |
|
| 371 | + $key = $frame->get_id(); |
|
| 373 | 372 | |
| 374 | - // Row groups always span across the entire table |
|
| 375 | - $this->_frames[ $key ]["columns"] = range(0,max(0,$this->_num_cols-1)); |
|
| 376 | - $this->_frames[ $key ]["rows"] = range($start_row, max(0, $this->__row - 1)); |
|
| 377 | - $this->_frames[ $key ]["frame"] = $frame; |
|
| 373 | + // Row groups always span across the entire table |
|
| 374 | + $this->_frames[ $key ]["columns"] = range(0,max(0,$this->_num_cols-1)); |
|
| 375 | + $this->_frames[ $key ]["rows"] = range($start_row, max(0, $this->__row - 1)); |
|
| 376 | + $this->_frames[ $key ]["frame"] = $frame; |
|
| 378 | 377 | |
| 379 | - if ( $display != "table-row" && $collapse ) { |
|
| 378 | + if ( $display != "table-row" && $collapse ) { |
|
| 380 | 379 | |
| 381 | 380 | $bp = $style->get_border_properties(); |
| 382 | 381 | |
| 383 | 382 | // Resolve the borders |
| 384 | 383 | for ( $i = 0; $i < $num_rows+1; $i++) { |
| 385 | - $this->_resolve_border($start_row + $i, 0, "vertical", $bp["left"]); |
|
| 386 | - $this->_resolve_border($start_row + $i, $this->_num_cols, "vertical", $bp["right"]); |
|
| 384 | + $this->_resolve_border($start_row + $i, 0, "vertical", $bp["left"]); |
|
| 385 | + $this->_resolve_border($start_row + $i, $this->_num_cols, "vertical", $bp["right"]); |
|
| 387 | 386 | } |
| 388 | 387 | |
| 389 | 388 | for ( $j = 0; $j < $this->_num_cols; $j++) { |
| 390 | - $this->_resolve_border($start_row, $j, "horizontal", $bp["top"]); |
|
| 391 | - $this->_resolve_border($this->__row, $j, "horizontal", $bp["bottom"]); |
|
| 389 | + $this->_resolve_border($start_row, $j, "horizontal", $bp["top"]); |
|
| 390 | + $this->_resolve_border($this->__row, $j, "horizontal", $bp["bottom"]); |
|
| 391 | + } |
|
| 392 | 392 | } |
| 393 | - } |
|
| 394 | 393 | |
| 395 | 394 | |
| 396 | - return; |
|
| 395 | + return; |
|
| 397 | 396 | } |
| 398 | 397 | |
| 399 | 398 | // Determine where this cell is going |
@@ -401,13 +400,13 @@ discard block |
||
| 401 | 400 | $rowspan = $frame->get_node()->getAttribute("rowspan"); |
| 402 | 401 | |
| 403 | 402 | if ( !$colspan ) { |
| 404 | - $colspan = 1; |
|
| 405 | - $frame->get_node()->setAttribute("colspan",1); |
|
| 403 | + $colspan = 1; |
|
| 404 | + $frame->get_node()->setAttribute("colspan",1); |
|
| 406 | 405 | } |
| 407 | 406 | |
| 408 | 407 | if ( !$rowspan ) { |
| 409 | - $rowspan = 1; |
|
| 410 | - $frame->get_node()->setAttribute("rowspan",1); |
|
| 408 | + $rowspan = 1; |
|
| 409 | + $frame->get_node()->setAttribute("rowspan",1); |
|
| 411 | 410 | } |
| 412 | 411 | $key = $frame->get_id(); |
| 413 | 412 | |
@@ -420,60 +419,60 @@ discard block |
||
| 420 | 419 | // Find the next available column (fix by Ciro Mondueri) |
| 421 | 420 | $ac = $this->__col; |
| 422 | 421 | while ( isset($this->_cells[$this->__row][$ac]) ) |
| 423 | - $ac++; |
|
| 422 | + $ac++; |
|
| 424 | 423 | $this->__col = $ac; |
| 425 | 424 | |
| 426 | 425 | // Rows: |
| 427 | 426 | for ( $i = 0; $i < $rowspan; $i++ ) { |
| 428 | - $row = $this->__row + $i; |
|
| 427 | + $row = $this->__row + $i; |
|
| 429 | 428 | |
| 430 | - $this->_frames[ $key ]["rows"][] = $row; |
|
| 429 | + $this->_frames[ $key ]["rows"][] = $row; |
|
| 431 | 430 | |
| 432 | - for ( $j = 0; $j < $colspan; $j++) |
|
| 431 | + for ( $j = 0; $j < $colspan; $j++) |
|
| 433 | 432 | $this->_cells[$row][$this->__col + $j] = $frame; |
| 434 | 433 | |
| 435 | - if ( $collapse ) { |
|
| 434 | + if ( $collapse ) { |
|
| 436 | 435 | // Resolve vertical borders |
| 437 | 436 | $max_left = max($max_left, $this->_resolve_border($row, $this->__col, "vertical", $bp["left"])); |
| 438 | 437 | $max_right = max($max_right, $this->_resolve_border($row, $this->__col + $colspan, "vertical", $bp["right"])); |
| 439 | - } |
|
| 438 | + } |
|
| 440 | 439 | } |
| 441 | 440 | |
| 442 | 441 | $max_top = $max_bottom = 0; |
| 443 | 442 | |
| 444 | 443 | // Columns: |
| 445 | 444 | for ( $j = 0; $j < $colspan; $j++ ) { |
| 446 | - $col = $this->__col + $j; |
|
| 447 | - $this->_frames[ $key ]["columns"][] = $col; |
|
| 445 | + $col = $this->__col + $j; |
|
| 446 | + $this->_frames[ $key ]["columns"][] = $col; |
|
| 448 | 447 | |
| 449 | - if ( $collapse ) { |
|
| 448 | + if ( $collapse ) { |
|
| 450 | 449 | // Resolve horizontal borders |
| 451 | 450 | $max_top = max($max_top, $this->_resolve_border($this->__row, $col, "horizontal", $bp["top"])); |
| 452 | 451 | $max_bottom = max($max_bottom, $this->_resolve_border($this->__row + $rowspan, $col, "horizontal", $bp["bottom"])); |
| 453 | - } |
|
| 452 | + } |
|
| 454 | 453 | } |
| 455 | 454 | |
| 456 | 455 | $this->_frames[ $key ]["frame"] = $frame; |
| 457 | 456 | |
| 458 | 457 | // Handle seperated border model |
| 459 | 458 | if ( !$collapse ) { |
| 460 | - list($h, $v) = $this->_table->get_style()->border_spacing; |
|
| 459 | + list($h, $v) = $this->_table->get_style()->border_spacing; |
|
| 461 | 460 | |
| 462 | - // Border spacing is effectively a margin between cells |
|
| 463 | - $v = $style->length_in_pt($v) / 2; |
|
| 464 | - $h = $style->length_in_pt($h) / 2; |
|
| 465 | - $style->margin = "$v $h"; |
|
| 461 | + // Border spacing is effectively a margin between cells |
|
| 462 | + $v = $style->length_in_pt($v) / 2; |
|
| 463 | + $h = $style->length_in_pt($h) / 2; |
|
| 464 | + $style->margin = "$v $h"; |
|
| 466 | 465 | |
| 467 | - // The additional 1/2 width gets added to the table proper |
|
| 466 | + // The additional 1/2 width gets added to the table proper |
|
| 468 | 467 | |
| 469 | 468 | } else { |
| 470 | 469 | |
| 471 | - // Drop the frame's actual border |
|
| 472 | - $style->border_left_width = $max_left / 2; |
|
| 473 | - $style->border_right_width = $max_right / 2; |
|
| 474 | - $style->border_top_width = $max_top / 2; |
|
| 475 | - $style->border_bottom_width = $max_bottom / 2; |
|
| 476 | - $style->margin = "none"; |
|
| 470 | + // Drop the frame's actual border |
|
| 471 | + $style->border_left_width = $max_left / 2; |
|
| 472 | + $style->border_right_width = $max_right / 2; |
|
| 473 | + $style->border_top_width = $max_top / 2; |
|
| 474 | + $style->border_bottom_width = $max_bottom / 2; |
|
| 475 | + $style->margin = "none"; |
|
| 477 | 476 | } |
| 478 | 477 | |
| 479 | 478 | // Resolve the frame's width |
@@ -482,60 +481,60 @@ discard block |
||
| 482 | 481 | $width = $style->width; |
| 483 | 482 | |
| 484 | 483 | if ( is_percent($width) ) { |
| 485 | - $var = "percent"; |
|
| 486 | - $val = (float)rtrim($width, "% ") / $colspan; |
|
| 484 | + $var = "percent"; |
|
| 485 | + $val = (float)rtrim($width, "% ") / $colspan; |
|
| 487 | 486 | |
| 488 | 487 | } else if ( $width !== "auto" ) { |
| 489 | - $var = "absolute"; |
|
| 490 | - $val = $style->length_in_pt($frame_min) / $colspan; |
|
| 488 | + $var = "absolute"; |
|
| 489 | + $val = $style->length_in_pt($frame_min) / $colspan; |
|
| 491 | 490 | } |
| 492 | 491 | |
| 493 | 492 | $min = 0; |
| 494 | 493 | $max = 0; |
| 495 | 494 | for ( $cs = 0; $cs < $colspan; $cs++ ) { |
| 496 | 495 | |
| 497 | - // Resolve the frame's width(s) with other cells |
|
| 498 | - $col =& $this->get_column( $this->__col + $cs ); |
|
| 496 | + // Resolve the frame's width(s) with other cells |
|
| 497 | + $col =& $this->get_column( $this->__col + $cs ); |
|
| 499 | 498 | |
| 500 | - // Note: $var is either 'percent' or 'absolute'. We compare the |
|
| 501 | - // requested percentage or absolute values with the existing widths |
|
| 502 | - // and adjust accordingly. |
|
| 503 | - if ( isset($var) && $val > $col[$var] ) { |
|
| 499 | + // Note: $var is either 'percent' or 'absolute'. We compare the |
|
| 500 | + // requested percentage or absolute values with the existing widths |
|
| 501 | + // and adjust accordingly. |
|
| 502 | + if ( isset($var) && $val > $col[$var] ) { |
|
| 504 | 503 | $col[$var] = $val; |
| 505 | 504 | $col["auto"] = false; |
| 506 | - } |
|
| 505 | + } |
|
| 507 | 506 | |
| 508 | - $min += $col["min-width"]; |
|
| 509 | - $max += $col["max-width"]; |
|
| 507 | + $min += $col["min-width"]; |
|
| 508 | + $max += $col["max-width"]; |
|
| 510 | 509 | } |
| 511 | 510 | |
| 512 | 511 | |
| 513 | 512 | if ( $frame_min > $min ) { |
| 514 | - // The frame needs more space. Expand each sub-column |
|
| 515 | - $inc = ($frame_min - $min) / $colspan; |
|
| 516 | - for ($c = 0; $c < $colspan; $c++) { |
|
| 513 | + // The frame needs more space. Expand each sub-column |
|
| 514 | + $inc = ($frame_min - $min) / $colspan; |
|
| 515 | + for ($c = 0; $c < $colspan; $c++) { |
|
| 517 | 516 | $col =& $this->get_column($this->__col + $c); |
| 518 | 517 | $col["min-width"] += $inc; |
| 519 | - } |
|
| 518 | + } |
|
| 520 | 519 | } |
| 521 | 520 | |
| 522 | 521 | if ( $frame_max > $max ) { |
| 523 | - $inc = ($frame_max - $max) / $colspan; |
|
| 524 | - for ($c = 0; $c < $colspan; $c++) { |
|
| 522 | + $inc = ($frame_max - $max) / $colspan; |
|
| 523 | + for ($c = 0; $c < $colspan; $c++) { |
|
| 525 | 524 | $col =& $this->get_column($this->__col + $c); |
| 526 | 525 | $col["max-width"] += $inc; |
| 527 | - } |
|
| 526 | + } |
|
| 528 | 527 | } |
| 529 | 528 | |
| 530 | 529 | $this->__col += $colspan; |
| 531 | 530 | if ( $this->__col > $this->_num_cols ) |
| 532 | - $this->_num_cols = $this->__col; |
|
| 531 | + $this->_num_cols = $this->__col; |
|
| 533 | 532 | |
| 534 | - } |
|
| 533 | + } |
|
| 535 | 534 | |
| 536 | - //........................................................................ |
|
| 535 | + //........................................................................ |
|
| 537 | 536 | |
| 538 | - function add_row() { |
|
| 537 | + function add_row() { |
|
| 539 | 538 | |
| 540 | 539 | $this->__row++; |
| 541 | 540 | $this->_num_rows++; |
@@ -543,24 +542,24 @@ discard block |
||
| 543 | 542 | // Find the next available column |
| 544 | 543 | $i = 0; |
| 545 | 544 | while ( isset($this->_cells[$this->__row][$i]) ) |
| 546 | - $i++; |
|
| 545 | + $i++; |
|
| 547 | 546 | |
| 548 | 547 | $this->__col = $i; |
| 549 | 548 | |
| 550 | - } |
|
| 549 | + } |
|
| 551 | 550 | |
| 552 | - //........................................................................ |
|
| 551 | + //........................................................................ |
|
| 553 | 552 | |
| 554 | - /** |
|
| 555 | - * Remove a row from the cellmap. |
|
| 556 | - * |
|
| 557 | - * @param Frame |
|
| 558 | - */ |
|
| 559 | - function remove_row(Frame $row) { |
|
| 553 | + /** |
|
| 554 | + * Remove a row from the cellmap. |
|
| 555 | + * |
|
| 556 | + * @param Frame |
|
| 557 | + */ |
|
| 558 | + function remove_row(Frame $row) { |
|
| 560 | 559 | |
| 561 | 560 | $key = $row->get_id(); |
| 562 | 561 | if ( !isset($this->_frames[$key]) ) |
| 563 | - return; // Presumably this row has alredy been removed |
|
| 562 | + return; // Presumably this row has alredy been removed |
|
| 564 | 563 | |
| 565 | 564 | $this->_row = $this->_num_rows--; |
| 566 | 565 | |
@@ -569,47 +568,47 @@ discard block |
||
| 569 | 568 | |
| 570 | 569 | // Remove all frames from this row |
| 571 | 570 | foreach ( $rows as $r ) { |
| 572 | - foreach ( $columns as $c ) { |
|
| 571 | + foreach ( $columns as $c ) { |
|
| 573 | 572 | if ( isset($this->_cells[$r][$c]) ) { |
| 574 | - $frame = $this->_cells[$r][$c]; |
|
| 575 | - unset($this->_frames[ $frame->get_id() ]); |
|
| 576 | - unset($this->_cells[$r][$c]); |
|
| 573 | + $frame = $this->_cells[$r][$c]; |
|
| 574 | + unset($this->_frames[ $frame->get_id() ]); |
|
| 575 | + unset($this->_cells[$r][$c]); |
|
| 576 | + } |
|
| 577 | 577 | } |
| 578 | - } |
|
| 579 | - unset($this->_rows[$r]); |
|
| 578 | + unset($this->_rows[$r]); |
|
| 580 | 579 | } |
| 581 | 580 | |
| 582 | 581 | unset($this->_frames[$key]); |
| 583 | 582 | |
| 584 | - } |
|
| 583 | + } |
|
| 585 | 584 | |
| 586 | - /** |
|
| 587 | - * Remove a row group from the cellmap. |
|
| 588 | - * |
|
| 589 | - * @param Frame $group The group to remove |
|
| 590 | - */ |
|
| 591 | - function remove_row_group(Frame $group) { |
|
| 585 | + /** |
|
| 586 | + * Remove a row group from the cellmap. |
|
| 587 | + * |
|
| 588 | + * @param Frame $group The group to remove |
|
| 589 | + */ |
|
| 590 | + function remove_row_group(Frame $group) { |
|
| 592 | 591 | |
| 593 | 592 | $key = $group->get_id(); |
| 594 | 593 | if ( !isset($this->_frames[$key]) ) |
| 595 | - return; // Presumably this row has alredy been removed |
|
| 594 | + return; // Presumably this row has alredy been removed |
|
| 596 | 595 | |
| 597 | 596 | $iter = $group->get_first_child(); |
| 598 | 597 | while ($iter) { |
| 599 | - $this->remove_row($iter); |
|
| 600 | - $iter = $iter->get_next_sibling(); |
|
| 598 | + $this->remove_row($iter); |
|
| 599 | + $iter = $iter->get_next_sibling(); |
|
| 601 | 600 | } |
| 602 | 601 | |
| 603 | 602 | unset($this->_frames[$key]); |
| 604 | - } |
|
| 603 | + } |
|
| 605 | 604 | |
| 606 | - /** |
|
| 607 | - * Update a row group after rows have been removed |
|
| 608 | - * |
|
| 609 | - * @param Frame $group The group to update |
|
| 610 | - * @param Frame $last_row The last row in the row group |
|
| 611 | - */ |
|
| 612 | - function update_row_group(Frame $group, Frame $last_row) { |
|
| 605 | + /** |
|
| 606 | + * Update a row group after rows have been removed |
|
| 607 | + * |
|
| 608 | + * @param Frame $group The group to update |
|
| 609 | + * @param Frame $last_row The last row in the row group |
|
| 610 | + */ |
|
| 611 | + function update_row_group(Frame $group, Frame $last_row) { |
|
| 613 | 612 | |
| 614 | 613 | $g_key = $group->get_id(); |
| 615 | 614 | $r_key = $last_row->get_id(); |
@@ -617,80 +616,80 @@ discard block |
||
| 617 | 616 | $r_rows = $this->_frames[$r_key]["rows"]; |
| 618 | 617 | $this->_frames[$g_key]["rows"] = range( $this->_frames[$g_key]["rows"][0], end($r_rows) ); |
| 619 | 618 | |
| 620 | - } |
|
| 619 | + } |
|
| 621 | 620 | |
| 622 | - //........................................................................ |
|
| 621 | + //........................................................................ |
|
| 623 | 622 | |
| 624 | - function assign_x_positions() { |
|
| 623 | + function assign_x_positions() { |
|
| 625 | 624 | // Pre-condition: widths must be resolved and assigned to columns and |
| 626 | 625 | // column[0]["x"] must be set. |
| 627 | 626 | |
| 628 | 627 | $x = $this->_columns[0]["x"]; |
| 629 | 628 | foreach ( array_keys($this->_columns) as $j ) { |
| 630 | - $this->_columns[$j]["x"] = $x; |
|
| 631 | - $x += $this->_columns[$j]["used-width"]; |
|
| 629 | + $this->_columns[$j]["x"] = $x; |
|
| 630 | + $x += $this->_columns[$j]["used-width"]; |
|
| 632 | 631 | |
| 633 | 632 | } |
| 634 | 633 | |
| 635 | - } |
|
| 634 | + } |
|
| 636 | 635 | |
| 637 | - function assign_frame_heights() { |
|
| 636 | + function assign_frame_heights() { |
|
| 638 | 637 | // Pre-condition: widths and heights of each column & row must be |
| 639 | 638 | // calcluated |
| 640 | 639 | |
| 641 | 640 | foreach ( $this->_frames as $arr ) { |
| 642 | - $frame = $arr["frame"]; |
|
| 641 | + $frame = $arr["frame"]; |
|
| 643 | 642 | |
| 644 | - $h = 0; |
|
| 645 | - foreach( $arr["rows"] as $row ) { |
|
| 643 | + $h = 0; |
|
| 644 | + foreach( $arr["rows"] as $row ) { |
|
| 646 | 645 | if ( !isset($this->_rows[$row]) ) |
| 647 | - // The row has been removed because of a page split, so skip it. |
|
| 648 | - continue; |
|
| 646 | + // The row has been removed because of a page split, so skip it. |
|
| 647 | + continue; |
|
| 649 | 648 | $h += $this->_rows[$row]["height"]; |
| 650 | - } |
|
| 649 | + } |
|
| 651 | 650 | |
| 652 | - if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
| 651 | + if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
| 653 | 652 | $frame->set_cell_height($h); |
| 654 | - else |
|
| 653 | + else |
|
| 655 | 654 | $frame->get_style()->height = $h; |
| 656 | 655 | } |
| 657 | 656 | |
| 658 | - } |
|
| 657 | + } |
|
| 659 | 658 | |
| 660 | - //........................................................................ |
|
| 659 | + //........................................................................ |
|
| 661 | 660 | |
| 662 | - /** |
|
| 663 | - * Re-adjust frame height if the table height is larger than its content |
|
| 664 | - */ |
|
| 665 | - function set_frame_heights($table_height, $content_height) { |
|
| 661 | + /** |
|
| 662 | + * Re-adjust frame height if the table height is larger than its content |
|
| 663 | + */ |
|
| 664 | + function set_frame_heights($table_height, $content_height) { |
|
| 666 | 665 | |
| 667 | 666 | |
| 668 | 667 | // Distribute the increased height proportionally amongst each row |
| 669 | 668 | foreach ( $this->_frames as $arr ) { |
| 670 | - $frame = $arr["frame"]; |
|
| 669 | + $frame = $arr["frame"]; |
|
| 671 | 670 | |
| 672 | - $h = 0; |
|
| 673 | - foreach ($arr["rows"] as $row ) { |
|
| 671 | + $h = 0; |
|
| 672 | + foreach ($arr["rows"] as $row ) { |
|
| 674 | 673 | if ( !isset($this->_rows[$row]) ) |
| 675 | - continue; |
|
| 674 | + continue; |
|
| 676 | 675 | |
| 677 | 676 | $h += $this->_rows[$row]["height"]; |
| 678 | - } |
|
| 677 | + } |
|
| 679 | 678 | |
| 680 | - $new_height = ($h / $content_height) * $table_height; |
|
| 679 | + $new_height = ($h / $content_height) * $table_height; |
|
| 681 | 680 | |
| 682 | - if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
| 681 | + if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
| 683 | 682 | $frame->set_cell_height($new_height); |
| 684 | - else |
|
| 683 | + else |
|
| 685 | 684 | $frame->get_style()->height = $new_height; |
| 686 | 685 | } |
| 687 | 686 | |
| 688 | - } |
|
| 687 | + } |
|
| 689 | 688 | |
| 690 | - //........................................................................ |
|
| 689 | + //........................................................................ |
|
| 691 | 690 | |
| 692 | - // Used for debugging: |
|
| 693 | - function __toString() { |
|
| 691 | + // Used for debugging: |
|
| 692 | + function __toString() { |
|
| 694 | 693 | $str = ""; |
| 695 | 694 | $str .= "Columns:<br/>"; |
| 696 | 695 | $str .= pre_r($this->_columns, true); |
@@ -700,14 +699,14 @@ discard block |
||
| 700 | 699 | $str .= "Frames:<br/>"; |
| 701 | 700 | $arr = array(); |
| 702 | 701 | foreach ( $this->_frames as $key => $val ) |
| 703 | - $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]); |
|
| 702 | + $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]); |
|
| 704 | 703 | |
| 705 | 704 | $str .= pre_r($arr, true); |
| 706 | 705 | |
| 707 | 706 | if ( php_sapi_name() == "cli" ) |
| 708 | - $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
| 707 | + $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
| 709 | 708 | array("\n",chr(27)."[01;33m", chr(27)."[0m"), |
| 710 | 709 | $str)); |
| 711 | 710 | return $str; |
| 712 | - } |
|
| 711 | + } |
|
| 713 | 712 | } |
@@ -461,6 +461,8 @@ discard block |
||
| 461 | 461 | * @param string cap |
| 462 | 462 | * @param string join |
| 463 | 463 | * @param array dash |
| 464 | + * @param string $cap |
|
| 465 | + * @param string $join |
|
| 464 | 466 | */ |
| 465 | 467 | protected function _set_line_style($width, $cap, $join, $dash) { |
| 466 | 468 | $this->_pdf->setLineStyle($width, $cap, $join, $dash); |
@@ -496,6 +498,7 @@ discard block |
||
| 496 | 498 | /** |
| 497 | 499 | * Convert a GIF image to a PNG image |
| 498 | 500 | * |
| 501 | + * @param string $image_url |
|
| 499 | 502 | * @return string The url of the newly converted image |
| 500 | 503 | */ |
| 501 | 504 | protected function _convert_gif_to_png($image_url) { |
@@ -775,8 +778,8 @@ discard block |
||
| 775 | 778 | * @param string $font the font file to use |
| 776 | 779 | * @param float $size the font size, in points |
| 777 | 780 | * @param array $color |
| 778 | - * @param float $adjust word spacing adjustment |
|
| 779 | - * @param float $angle angle to write the text at, measured CW starting from the x-axis |
|
| 781 | + * @param integer $adjust word spacing adjustment |
|
| 782 | + * @param integer $angle angle to write the text at, measured CW starting from the x-axis |
|
| 780 | 783 | */ |
| 781 | 784 | function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), |
| 782 | 785 | $adjust = 0, $angle = 0) { |
@@ -595,56 +595,56 @@ discard block |
||
| 595 | 595 | $img_type = mb_strtolower($img_type); |
| 596 | 596 | |
| 597 | 597 | switch ($img_type) { |
| 598 | - case "jpeg": |
|
| 599 | - case "jpg": |
|
| 600 | - //debugpng |
|
| 601 | - if (DEBUGPNG) print '!!!jpg!!!'; |
|
| 598 | + case "jpeg": |
|
| 599 | + case "jpg": |
|
| 600 | + //debugpng |
|
| 601 | + if (DEBUGPNG) print '!!!jpg!!!'; |
|
| 602 | 602 | |
| 603 | - $this->_pdf->addJpegFromFile($img_url, $x, $this->y($y) - $h, $w, $h); |
|
| 604 | - break; |
|
| 603 | + $this->_pdf->addJpegFromFile($img_url, $x, $this->y($y) - $h, $w, $h); |
|
| 604 | + break; |
|
| 605 | 605 | |
| 606 | - case "png": |
|
| 607 | - //debugpng |
|
| 608 | - if (DEBUGPNG) print '!!!png!!!'; |
|
| 609 | - |
|
| 610 | - $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h); |
|
| 611 | - break; |
|
| 612 | - |
|
| 613 | - case "gif": |
|
| 614 | - // Convert gifs to pngs |
|
| 615 | - //DEBUG_IMG_TEMP |
|
| 616 | - //if (0) { |
|
| 617 | - if ( method_exists( $this->_pdf, "addImagePng" ) ) { |
|
| 618 | - //debugpng |
|
| 619 | - if (DEBUGPNG) print '!!!gif addImagePng!!!'; |
|
| 620 | - |
|
| 621 | - //If optimization to direct png creation from gd object is available, |
|
| 622 | - //don't create temp file, but place gd object directly into the pdf |
|
| 623 | - if ( method_exists( $this->_pdf, "image_iscached" ) && |
|
| 624 | - $this->_pdf->image_iscached($img_url) ) { |
|
| 625 | - //If same image has occured already before, no need to load because |
|
| 626 | - //duplicate will anyway be eliminated. |
|
| 627 | - $img = null; |
|
| 628 | - } else { |
|
| 629 | - $img = @imagecreatefromgif($img_url); |
|
| 630 | - if (!$img) { |
|
| 631 | - return; |
|
| 632 | - } |
|
| 633 | - imageinterlace($img, 0); |
|
| 634 | - } |
|
| 635 | - $this->_pdf->addImagePng($img_url, $x, $this->y($y) - $h, $w, $h, $img); |
|
| 636 | - } else { |
|
| 637 | - //debugpng |
|
| 638 | - if (DEBUGPNG) print '!!!gif addPngFromFile!!!'; |
|
| 639 | - $img_url = $this->_convert_gif_to_png($img_url); |
|
| 640 | - $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h); |
|
| 641 | - } |
|
| 642 | - break; |
|
| 606 | + case "png": |
|
| 607 | + //debugpng |
|
| 608 | + if (DEBUGPNG) print '!!!png!!!'; |
|
| 643 | 609 | |
| 644 | - default: |
|
| 645 | - //debugpng |
|
| 646 | - if (DEBUGPNG) print '!!!unknown!!!'; |
|
| 647 | - break; |
|
| 610 | + $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h); |
|
| 611 | + break; |
|
| 612 | + |
|
| 613 | + case "gif": |
|
| 614 | + // Convert gifs to pngs |
|
| 615 | + //DEBUG_IMG_TEMP |
|
| 616 | + //if (0) { |
|
| 617 | + if ( method_exists( $this->_pdf, "addImagePng" ) ) { |
|
| 618 | + //debugpng |
|
| 619 | + if (DEBUGPNG) print '!!!gif addImagePng!!!'; |
|
| 620 | + |
|
| 621 | + //If optimization to direct png creation from gd object is available, |
|
| 622 | + //don't create temp file, but place gd object directly into the pdf |
|
| 623 | + if ( method_exists( $this->_pdf, "image_iscached" ) && |
|
| 624 | + $this->_pdf->image_iscached($img_url) ) { |
|
| 625 | + //If same image has occured already before, no need to load because |
|
| 626 | + //duplicate will anyway be eliminated. |
|
| 627 | + $img = null; |
|
| 628 | + } else { |
|
| 629 | + $img = @imagecreatefromgif($img_url); |
|
| 630 | + if (!$img) { |
|
| 631 | + return; |
|
| 632 | + } |
|
| 633 | + imageinterlace($img, 0); |
|
| 634 | + } |
|
| 635 | + $this->_pdf->addImagePng($img_url, $x, $this->y($y) - $h, $w, $h, $img); |
|
| 636 | + } else { |
|
| 637 | + //debugpng |
|
| 638 | + if (DEBUGPNG) print '!!!gif addPngFromFile!!!'; |
|
| 639 | + $img_url = $this->_convert_gif_to_png($img_url); |
|
| 640 | + $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h); |
|
| 641 | + } |
|
| 642 | + break; |
|
| 643 | + |
|
| 644 | + default: |
|
| 645 | + //debugpng |
|
| 646 | + if (DEBUGPNG) print '!!!unknown!!!'; |
|
| 647 | + break; |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | return; |
@@ -833,18 +833,18 @@ discard block |
||
| 833 | 833 | |
| 834 | 834 | switch ($_t) { |
| 835 | 835 | |
| 836 | - case "text": |
|
| 837 | - $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"), |
|
| 838 | - array($page_number, $this->_page_count), $text); |
|
| 839 | - $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
|
| 840 | - break; |
|
| 836 | + case "text": |
|
| 837 | + $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"), |
|
| 838 | + array($page_number, $this->_page_count), $text); |
|
| 839 | + $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
|
| 840 | + break; |
|
| 841 | 841 | |
| 842 | - case "script": |
|
| 843 | - if (!$eval) { |
|
| 844 | - $eval = new PHP_Evaluator($this); |
|
| 845 | - } |
|
| 846 | - $eval->evaluate($code, array('PAGE_NUM' => $page_number, 'PAGE_COUNT' => $this->_page_count)); |
|
| 847 | - break; |
|
| 842 | + case "script": |
|
| 843 | + if (!$eval) { |
|
| 844 | + $eval = new PHP_Evaluator($this); |
|
| 845 | + } |
|
| 846 | + $eval->evaluate($code, array('PAGE_NUM' => $page_number, 'PAGE_COUNT' => $this->_page_count)); |
|
| 847 | + break; |
|
| 848 | 848 | } |
| 849 | 849 | } |
| 850 | 850 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | /* $Id: cpdf_adapter.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */ |
| 56 | 56 | |
| 57 | 57 | // FIXME: Need to sanity check inputs to this class |
| 58 | -require_once(DOMPDF_LIB_DIR . "/class.pdf.php"); |
|
| 58 | +require_once(DOMPDF_LIB_DIR."/class.pdf.php"); |
|
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * PDF rendering interface |
@@ -79,62 +79,62 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @var array; |
| 81 | 81 | */ |
| 82 | - static $PAPER_SIZES = array("4a0" => array(0,0,4767.87,6740.79), |
|
| 83 | - "2a0" => array(0,0,3370.39,4767.87), |
|
| 84 | - "a0" => array(0,0,2383.94,3370.39), |
|
| 85 | - "a1" => array(0,0,1683.78,2383.94), |
|
| 86 | - "a2" => array(0,0,1190.55,1683.78), |
|
| 87 | - "a3" => array(0,0,841.89,1190.55), |
|
| 88 | - "a4" => array(0,0,595.28,841.89), |
|
| 89 | - "a5" => array(0,0,419.53,595.28), |
|
| 90 | - "a6" => array(0,0,297.64,419.53), |
|
| 91 | - "a7" => array(0,0,209.76,297.64), |
|
| 92 | - "a8" => array(0,0,147.40,209.76), |
|
| 93 | - "a9" => array(0,0,104.88,147.40), |
|
| 94 | - "a10" => array(0,0,73.70,104.88), |
|
| 95 | - "b0" => array(0,0,2834.65,4008.19), |
|
| 96 | - "b1" => array(0,0,2004.09,2834.65), |
|
| 97 | - "b2" => array(0,0,1417.32,2004.09), |
|
| 98 | - "b3" => array(0,0,1000.63,1417.32), |
|
| 99 | - "b4" => array(0,0,708.66,1000.63), |
|
| 100 | - "b5" => array(0,0,498.90,708.66), |
|
| 101 | - "b6" => array(0,0,354.33,498.90), |
|
| 102 | - "b7" => array(0,0,249.45,354.33), |
|
| 103 | - "b8" => array(0,0,175.75,249.45), |
|
| 104 | - "b9" => array(0,0,124.72,175.75), |
|
| 105 | - "b10" => array(0,0,87.87,124.72), |
|
| 106 | - "c0" => array(0,0,2599.37,3676.54), |
|
| 107 | - "c1" => array(0,0,1836.85,2599.37), |
|
| 108 | - "c2" => array(0,0,1298.27,1836.85), |
|
| 109 | - "c3" => array(0,0,918.43,1298.27), |
|
| 110 | - "c4" => array(0,0,649.13,918.43), |
|
| 111 | - "c5" => array(0,0,459.21,649.13), |
|
| 112 | - "c6" => array(0,0,323.15,459.21), |
|
| 113 | - "c7" => array(0,0,229.61,323.15), |
|
| 114 | - "c8" => array(0,0,161.57,229.61), |
|
| 115 | - "c9" => array(0,0,113.39,161.57), |
|
| 116 | - "c10" => array(0,0,79.37,113.39), |
|
| 117 | - "ra0" => array(0,0,2437.80,3458.27), |
|
| 118 | - "ra1" => array(0,0,1729.13,2437.80), |
|
| 119 | - "ra2" => array(0,0,1218.90,1729.13), |
|
| 120 | - "ra3" => array(0,0,864.57,1218.90), |
|
| 121 | - "ra4" => array(0,0,609.45,864.57), |
|
| 122 | - "sra0" => array(0,0,2551.18,3628.35), |
|
| 123 | - "sra1" => array(0,0,1814.17,2551.18), |
|
| 124 | - "sra2" => array(0,0,1275.59,1814.17), |
|
| 125 | - "sra3" => array(0,0,907.09,1275.59), |
|
| 126 | - "sra4" => array(0,0,637.80,907.09), |
|
| 127 | - "letter" => array(0,0,612.00,792.00), |
|
| 128 | - "legal" => array(0,0,612.00,1008.00), |
|
| 129 | - "ledger" => array(0,0,1224.00, 792.00), |
|
| 130 | - "tabloid" => array(0,0,792.00, 1224.00), |
|
| 131 | - "executive" => array(0,0,521.86,756.00), |
|
| 132 | - "folio" => array(0,0,612.00,936.00), |
|
| 133 | - "commerical #10 envelope" => array(0,0,684,297), |
|
| 134 | - "catalog #10 1/2 envelope" => array(0,0,648,864), |
|
| 135 | - "8.5x11" => array(0,0,612.00,792.00), |
|
| 136 | - "8.5x14" => array(0,0,612.00,1008.0), |
|
| 137 | - "11x17" => array(0,0,792.00, 1224.00)); |
|
| 82 | + static $PAPER_SIZES = array("4a0" => array(0, 0, 4767.87, 6740.79), |
|
| 83 | + "2a0" => array(0, 0, 3370.39, 4767.87), |
|
| 84 | + "a0" => array(0, 0, 2383.94, 3370.39), |
|
| 85 | + "a1" => array(0, 0, 1683.78, 2383.94), |
|
| 86 | + "a2" => array(0, 0, 1190.55, 1683.78), |
|
| 87 | + "a3" => array(0, 0, 841.89, 1190.55), |
|
| 88 | + "a4" => array(0, 0, 595.28, 841.89), |
|
| 89 | + "a5" => array(0, 0, 419.53, 595.28), |
|
| 90 | + "a6" => array(0, 0, 297.64, 419.53), |
|
| 91 | + "a7" => array(0, 0, 209.76, 297.64), |
|
| 92 | + "a8" => array(0, 0, 147.40, 209.76), |
|
| 93 | + "a9" => array(0, 0, 104.88, 147.40), |
|
| 94 | + "a10" => array(0, 0, 73.70, 104.88), |
|
| 95 | + "b0" => array(0, 0, 2834.65, 4008.19), |
|
| 96 | + "b1" => array(0, 0, 2004.09, 2834.65), |
|
| 97 | + "b2" => array(0, 0, 1417.32, 2004.09), |
|
| 98 | + "b3" => array(0, 0, 1000.63, 1417.32), |
|
| 99 | + "b4" => array(0, 0, 708.66, 1000.63), |
|
| 100 | + "b5" => array(0, 0, 498.90, 708.66), |
|
| 101 | + "b6" => array(0, 0, 354.33, 498.90), |
|
| 102 | + "b7" => array(0, 0, 249.45, 354.33), |
|
| 103 | + "b8" => array(0, 0, 175.75, 249.45), |
|
| 104 | + "b9" => array(0, 0, 124.72, 175.75), |
|
| 105 | + "b10" => array(0, 0, 87.87, 124.72), |
|
| 106 | + "c0" => array(0, 0, 2599.37, 3676.54), |
|
| 107 | + "c1" => array(0, 0, 1836.85, 2599.37), |
|
| 108 | + "c2" => array(0, 0, 1298.27, 1836.85), |
|
| 109 | + "c3" => array(0, 0, 918.43, 1298.27), |
|
| 110 | + "c4" => array(0, 0, 649.13, 918.43), |
|
| 111 | + "c5" => array(0, 0, 459.21, 649.13), |
|
| 112 | + "c6" => array(0, 0, 323.15, 459.21), |
|
| 113 | + "c7" => array(0, 0, 229.61, 323.15), |
|
| 114 | + "c8" => array(0, 0, 161.57, 229.61), |
|
| 115 | + "c9" => array(0, 0, 113.39, 161.57), |
|
| 116 | + "c10" => array(0, 0, 79.37, 113.39), |
|
| 117 | + "ra0" => array(0, 0, 2437.80, 3458.27), |
|
| 118 | + "ra1" => array(0, 0, 1729.13, 2437.80), |
|
| 119 | + "ra2" => array(0, 0, 1218.90, 1729.13), |
|
| 120 | + "ra3" => array(0, 0, 864.57, 1218.90), |
|
| 121 | + "ra4" => array(0, 0, 609.45, 864.57), |
|
| 122 | + "sra0" => array(0, 0, 2551.18, 3628.35), |
|
| 123 | + "sra1" => array(0, 0, 1814.17, 2551.18), |
|
| 124 | + "sra2" => array(0, 0, 1275.59, 1814.17), |
|
| 125 | + "sra3" => array(0, 0, 907.09, 1275.59), |
|
| 126 | + "sra4" => array(0, 0, 637.80, 907.09), |
|
| 127 | + "letter" => array(0, 0, 612.00, 792.00), |
|
| 128 | + "legal" => array(0, 0, 612.00, 1008.00), |
|
| 129 | + "ledger" => array(0, 0, 1224.00, 792.00), |
|
| 130 | + "tabloid" => array(0, 0, 792.00, 1224.00), |
|
| 131 | + "executive" => array(0, 0, 521.86, 756.00), |
|
| 132 | + "folio" => array(0, 0, 612.00, 936.00), |
|
| 133 | + "commerical #10 envelope" => array(0, 0, 684, 297), |
|
| 134 | + "catalog #10 1/2 envelope" => array(0, 0, 648, 864), |
|
| 135 | + "8.5x11" => array(0, 0, 612.00, 792.00), |
|
| 136 | + "8.5x14" => array(0, 0, 612.00, 1008.0), |
|
| 137 | + "11x17" => array(0, 0, 792.00, 1224.00)); |
|
| 138 | 138 | |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -201,14 +201,14 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | function __construct($paper = "letter", $orientation = "portrait") { |
| 203 | 203 | |
| 204 | - if ( is_array($paper) ) |
|
| 204 | + if (is_array($paper)) |
|
| 205 | 205 | $size = $paper; |
| 206 | - else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) |
|
| 206 | + else if (isset(self::$PAPER_SIZES[mb_strtolower($paper)])) |
|
| 207 | 207 | $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
| 208 | 208 | else |
| 209 | 209 | $size = self::$PAPER_SIZES["letter"]; |
| 210 | 210 | |
| 211 | - if ( mb_strtolower($orientation) === "landscape" ) { |
|
| 211 | + if (mb_strtolower($orientation) === "landscape") { |
|
| 212 | 212 | $a = $size[3]; |
| 213 | 213 | $size[3] = $size[2]; |
| 214 | 214 | $size[2] = $a; |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | |
| 226 | 226 | $this->_width = $size[2] - $size[0]; |
| 227 | - $this->_height= $size[3] - $size[1]; |
|
| 227 | + $this->_height = $size[3] - $size[1]; |
|
| 228 | 228 | $this->_pdf->openHere('Fit'); |
| 229 | 229 | |
| 230 | 230 | $this->_page_number = $this->_page_count = 1; |
@@ -500,14 +500,14 @@ discard block |
||
| 500 | 500 | */ |
| 501 | 501 | protected function _convert_gif_to_png($image_url) { |
| 502 | 502 | |
| 503 | - if ( !function_exists("imagecreatefromgif") ) { |
|
| 503 | + if (!function_exists("imagecreatefromgif")) { |
|
| 504 | 504 | throw new DOMPDF_Exception("Function imagecreatefromgif() not found. Cannot convert gif image: $image_url. Please install the image PHP extension."); |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | $old_err = set_error_handler("record_warnings"); |
| 508 | 508 | $im = imagecreatefromgif($image_url); |
| 509 | 509 | |
| 510 | - if ( $im ) { |
|
| 510 | + if ($im) { |
|
| 511 | 511 | imageinterlace($im, 0); |
| 512 | 512 | |
| 513 | 513 | $filename = tempnam(DOMPDF_TEMP_DIR, "gifdompdf_img_").'.png'; |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | imagepng($im, $filename); |
| 517 | 517 | |
| 518 | 518 | } else { |
| 519 | - $filename = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
| 519 | + $filename = DOMPDF_LIB_DIR."/res/broken_image.png"; |
|
| 520 | 520 | |
| 521 | 521 | } |
| 522 | 522 | |
@@ -559,11 +559,11 @@ discard block |
||
| 559 | 559 | $this->_set_line_transparency($blend, $opacity); |
| 560 | 560 | $this->_set_fill_transparency($blend, $opacity); |
| 561 | 561 | |
| 562 | - if ( !$fill && isset($width) ) |
|
| 562 | + if (!$fill && isset($width)) |
|
| 563 | 563 | $this->_set_line_style($width, "square", "miter", $style); |
| 564 | 564 | |
| 565 | 565 | // Adjust y values |
| 566 | - for ( $i = 1; $i < count($points); $i += 2) |
|
| 566 | + for ($i = 1; $i < count($points); $i += 2) |
|
| 567 | 567 | $points[$i] = $this->y($points[$i]); |
| 568 | 568 | |
| 569 | 569 | $this->_pdf->polygon($points, count($points) / 2, $fill); |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | $this->_set_line_transparency($blend, $opacity); |
| 581 | 581 | $this->_set_fill_transparency($blend, $opacity); |
| 582 | 582 | |
| 583 | - if ( !$fill && isset($width) ) |
|
| 583 | + if (!$fill && isset($width)) |
|
| 584 | 584 | $this->_set_line_style($width, "round", "round", $style); |
| 585 | 585 | |
| 586 | 586 | $this->_pdf->ellipse($x, $this->y($y), $r1, 0, 0, 8, 0, 360, 1, $fill); |
@@ -614,14 +614,14 @@ discard block |
||
| 614 | 614 | // Convert gifs to pngs |
| 615 | 615 | //DEBUG_IMG_TEMP |
| 616 | 616 | //if (0) { |
| 617 | - if ( method_exists( $this->_pdf, "addImagePng" ) ) { |
|
| 617 | + if (method_exists($this->_pdf, "addImagePng")) { |
|
| 618 | 618 | //debugpng |
| 619 | 619 | if (DEBUGPNG) print '!!!gif addImagePng!!!'; |
| 620 | 620 | |
| 621 | 621 | //If optimization to direct png creation from gd object is available, |
| 622 | 622 | //don't create temp file, but place gd object directly into the pdf |
| 623 | - if ( method_exists( $this->_pdf, "image_iscached" ) && |
|
| 624 | - $this->_pdf->image_iscached($img_url) ) { |
|
| 623 | + if (method_exists($this->_pdf, "image_iscached") && |
|
| 624 | + $this->_pdf->image_iscached($img_url)) { |
|
| 625 | 625 | //If same image has occured already before, no need to load because |
| 626 | 626 | //duplicate will anyway be eliminated. |
| 627 | 627 | $img = null; |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | |
| 653 | 653 | //........................................................................ |
| 654 | 654 | |
| 655 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), |
|
| 655 | + function text($x, $y, $text, $font, $size, $color = array(0, 0, 0), |
|
| 656 | 656 | $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0) { |
| 657 | 657 | |
| 658 | 658 | list($r, $g, $b) = $color; |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | //$this->_pdf->addText($x, $this->y($y) - Font_Metrics::get_font_height($font, $size), $size, $text, $angle, $adjust); |
| 696 | 696 | //$this->_pdf->addText($x, $this->y($y) - $size, $size, $text, $angle, $adjust); |
| 697 | 697 | //$this->_pdf->addText($x, $this->y($y) - $this->_pdf->getFontHeight($size)-$this->_pdf->getFontDescender($size), $size, $text, $angle, $adjust); |
| 698 | - $this->_pdf->addText($x, $this->y($y) - ($this->_pdf->fonts[$this->_pdf->currentFont]['FontBBox'][3]*$size)/1000, $size, $text, $angle, $adjust); |
|
| 698 | + $this->_pdf->addText($x, $this->y($y) - ($this->_pdf->fonts[$this->_pdf->currentFont]['FontBBox'][3] * $size) / 1000, $size, $text, $angle, $adjust); |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | //........................................................................ |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | * @param string $anchorname The name of the named destination |
| 713 | 713 | */ |
| 714 | 714 | function add_named_dest($anchorname) { |
| 715 | - $this->_pdf->addDestination($anchorname,"Fit"); |
|
| 715 | + $this->_pdf->addDestination($anchorname, "Fit"); |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | //........................................................................ |
@@ -730,10 +730,10 @@ discard block |
||
| 730 | 730 | |
| 731 | 731 | $y = $this->y($y) - $height; |
| 732 | 732 | |
| 733 | - if ( strpos($url, '#') === 0 ) { |
|
| 733 | + if (strpos($url, '#') === 0) { |
|
| 734 | 734 | // Local link |
| 735 | - $name = substr($url,1); |
|
| 736 | - if ( $name ) |
|
| 735 | + $name = substr($url, 1); |
|
| 736 | + if ($name) |
|
| 737 | 737 | $this->_pdf->addInternalLink($name, $x, $y, $x + $width, $y + $height); |
| 738 | 738 | |
| 739 | 739 | } else { |
@@ -778,7 +778,7 @@ discard block |
||
| 778 | 778 | * @param float $adjust word spacing adjustment |
| 779 | 779 | * @param float $angle angle to write the text at, measured CW starting from the x-axis |
| 780 | 780 | */ |
| 781 | - function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), |
|
| 781 | + function page_text($x, $y, $text, $font, $size, $color = array(0, 0, 0), |
|
| 782 | 782 | $adjust = 0, $angle = 0) { |
| 783 | 783 | $_t = "text"; |
| 784 | 784 | $this->_page_text[] = compact("_t", "x", "y", "text", "font", "size", "color", "adjust", "angle"); |
@@ -819,7 +819,7 @@ discard block |
||
| 819 | 819 | */ |
| 820 | 820 | protected function _add_page_text() { |
| 821 | 821 | |
| 822 | - if ( !count($this->_page_text) ) |
|
| 822 | + if (!count($this->_page_text)) |
|
| 823 | 823 | return; |
| 824 | 824 | |
| 825 | 825 | $page_number = 1; |
@@ -834,7 +834,7 @@ discard block |
||
| 834 | 834 | switch ($_t) { |
| 835 | 835 | |
| 836 | 836 | case "text": |
| 837 | - $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"), |
|
| 837 | + $text = str_replace(array("{PAGE_NUM}", "{PAGE_COUNT}"), |
|
| 838 | 838 | array($page_number, $this->_page_count), $text); |
| 839 | 839 | $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
| 840 | 840 | break; |
@@ -878,7 +878,7 @@ discard block |
||
| 878 | 878 | // Add page text |
| 879 | 879 | $this->_add_page_text(); |
| 880 | 880 | |
| 881 | - if ( isset($options["compress"]) && $options["compress"] != 1 ) |
|
| 881 | + if (isset($options["compress"]) && $options["compress"] != 1) |
|
| 882 | 882 | $debug = 1; |
| 883 | 883 | else |
| 884 | 884 | $debug = 0; |
@@ -201,12 +201,13 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | function __construct($paper = "letter", $orientation = "portrait") { |
| 203 | 203 | |
| 204 | - if ( is_array($paper) ) |
|
| 205 | - $size = $paper; |
|
| 206 | - else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) |
|
| 207 | - $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
|
| 208 | - else |
|
| 209 | - $size = self::$PAPER_SIZES["letter"]; |
|
| 204 | + if ( is_array($paper) ) { |
|
| 205 | + $size = $paper; |
|
| 206 | + } else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) { |
|
| 207 | + $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
|
| 208 | + } else { |
|
| 209 | + $size = self::$PAPER_SIZES["letter"]; |
|
| 210 | + } |
|
| 210 | 211 | |
| 211 | 212 | if ( mb_strtolower($orientation) === "landscape" ) { |
| 212 | 213 | $a = $size[3]; |
@@ -243,9 +244,12 @@ discard block |
||
| 243 | 244 | function __destruct() { |
| 244 | 245 | foreach ($this->_image_cache as $img) { |
| 245 | 246 | //debugpng |
| 246 | - if (DEBUGPNG) print '[__destruct unlink '.$img.']'; |
|
| 247 | - if (!DEBUGKEEPTEMP) |
|
| 248 | - unlink($img); |
|
| 247 | + if (DEBUGPNG) { |
|
| 248 | + print '[__destruct unlink '.$img.']'; |
|
| 249 | + } |
|
| 250 | + if (!DEBUGKEEPTEMP) { |
|
| 251 | + unlink($img); |
|
| 252 | + } |
|
| 249 | 253 | } |
| 250 | 254 | } |
| 251 | 255 | |
@@ -559,12 +563,14 @@ discard block |
||
| 559 | 563 | $this->_set_line_transparency($blend, $opacity); |
| 560 | 564 | $this->_set_fill_transparency($blend, $opacity); |
| 561 | 565 | |
| 562 | - if ( !$fill && isset($width) ) |
|
| 563 | - $this->_set_line_style($width, "square", "miter", $style); |
|
| 566 | + if ( !$fill && isset($width) ) { |
|
| 567 | + $this->_set_line_style($width, "square", "miter", $style); |
|
| 568 | + } |
|
| 564 | 569 | |
| 565 | 570 | // Adjust y values |
| 566 | - for ( $i = 1; $i < count($points); $i += 2) |
|
| 567 | - $points[$i] = $this->y($points[$i]); |
|
| 571 | + for ( $i = 1; $i < count($points); $i += 2) { |
|
| 572 | + $points[$i] = $this->y($points[$i]); |
|
| 573 | + } |
|
| 568 | 574 | |
| 569 | 575 | $this->_pdf->polygon($points, count($points) / 2, $fill); |
| 570 | 576 | } |
@@ -580,8 +586,9 @@ discard block |
||
| 580 | 586 | $this->_set_line_transparency($blend, $opacity); |
| 581 | 587 | $this->_set_fill_transparency($blend, $opacity); |
| 582 | 588 | |
| 583 | - if ( !$fill && isset($width) ) |
|
| 584 | - $this->_set_line_style($width, "round", "round", $style); |
|
| 589 | + if ( !$fill && isset($width) ) { |
|
| 590 | + $this->_set_line_style($width, "round", "round", $style); |
|
| 591 | + } |
|
| 585 | 592 | |
| 586 | 593 | $this->_pdf->ellipse($x, $this->y($y), $r1, 0, 0, 8, 0, 360, 1, $fill); |
| 587 | 594 | } |
@@ -590,7 +597,9 @@ discard block |
||
| 590 | 597 | |
| 591 | 598 | function image($img_url, $img_type, $x, $y, $w, $h) { |
| 592 | 599 | //debugpng |
| 593 | - if (DEBUGPNG) print '[image:'.$img_url.'|'.$img_type.']'; |
|
| 600 | + if (DEBUGPNG) { |
|
| 601 | + print '[image:'.$img_url.'|'.$img_type.']'; |
|
| 602 | + } |
|
| 594 | 603 | |
| 595 | 604 | $img_type = mb_strtolower($img_type); |
| 596 | 605 | |
@@ -598,14 +607,18 @@ discard block |
||
| 598 | 607 | case "jpeg": |
| 599 | 608 | case "jpg": |
| 600 | 609 | //debugpng |
| 601 | - if (DEBUGPNG) print '!!!jpg!!!'; |
|
| 610 | + if (DEBUGPNG) { |
|
| 611 | + print '!!!jpg!!!'; |
|
| 612 | + } |
|
| 602 | 613 | |
| 603 | 614 | $this->_pdf->addJpegFromFile($img_url, $x, $this->y($y) - $h, $w, $h); |
| 604 | 615 | break; |
| 605 | 616 | |
| 606 | 617 | case "png": |
| 607 | 618 | //debugpng |
| 608 | - if (DEBUGPNG) print '!!!png!!!'; |
|
| 619 | + if (DEBUGPNG) { |
|
| 620 | + print '!!!png!!!'; |
|
| 621 | + } |
|
| 609 | 622 | |
| 610 | 623 | $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h); |
| 611 | 624 | break; |
@@ -616,7 +629,9 @@ discard block |
||
| 616 | 629 | //if (0) { |
| 617 | 630 | if ( method_exists( $this->_pdf, "addImagePng" ) ) { |
| 618 | 631 | //debugpng |
| 619 | - if (DEBUGPNG) print '!!!gif addImagePng!!!'; |
|
| 632 | + if (DEBUGPNG) { |
|
| 633 | + print '!!!gif addImagePng!!!'; |
|
| 634 | + } |
|
| 620 | 635 | |
| 621 | 636 | //If optimization to direct png creation from gd object is available, |
| 622 | 637 | //don't create temp file, but place gd object directly into the pdf |
@@ -635,7 +650,9 @@ discard block |
||
| 635 | 650 | $this->_pdf->addImagePng($img_url, $x, $this->y($y) - $h, $w, $h, $img); |
| 636 | 651 | } else { |
| 637 | 652 | //debugpng |
| 638 | - if (DEBUGPNG) print '!!!gif addPngFromFile!!!'; |
|
| 653 | + if (DEBUGPNG) { |
|
| 654 | + print '!!!gif addPngFromFile!!!'; |
|
| 655 | + } |
|
| 639 | 656 | $img_url = $this->_convert_gif_to_png($img_url); |
| 640 | 657 | $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h); |
| 641 | 658 | } |
@@ -643,7 +660,9 @@ discard block |
||
| 643 | 660 | |
| 644 | 661 | default: |
| 645 | 662 | //debugpng |
| 646 | - if (DEBUGPNG) print '!!!unknown!!!'; |
|
| 663 | + if (DEBUGPNG) { |
|
| 664 | + print '!!!unknown!!!'; |
|
| 665 | + } |
|
| 647 | 666 | break; |
| 648 | 667 | } |
| 649 | 668 | |
@@ -733,8 +752,9 @@ discard block |
||
| 733 | 752 | if ( strpos($url, '#') === 0 ) { |
| 734 | 753 | // Local link |
| 735 | 754 | $name = substr($url,1); |
| 736 | - if ( $name ) |
|
| 737 | - $this->_pdf->addInternalLink($name, $x, $y, $x + $width, $y + $height); |
|
| 755 | + if ( $name ) { |
|
| 756 | + $this->_pdf->addInternalLink($name, $x, $y, $x + $width, $y + $height); |
|
| 757 | + } |
|
| 738 | 758 | |
| 739 | 759 | } else { |
| 740 | 760 | $this->_pdf->addLink(rawurldecode($url), $x, $y, $x + $width, $y + $height); |
@@ -819,8 +839,9 @@ discard block |
||
| 819 | 839 | */ |
| 820 | 840 | protected function _add_page_text() { |
| 821 | 841 | |
| 822 | - if ( !count($this->_page_text) ) |
|
| 823 | - return; |
|
| 842 | + if ( !count($this->_page_text) ) { |
|
| 843 | + return; |
|
| 844 | + } |
|
| 824 | 845 | |
| 825 | 846 | $page_number = 1; |
| 826 | 847 | $eval = null; |
@@ -878,10 +899,11 @@ discard block |
||
| 878 | 899 | // Add page text |
| 879 | 900 | $this->_add_page_text(); |
| 880 | 901 | |
| 881 | - if ( isset($options["compress"]) && $options["compress"] != 1 ) |
|
| 882 | - $debug = 1; |
|
| 883 | - else |
|
| 884 | - $debug = 0; |
|
| 902 | + if ( isset($options["compress"]) && $options["compress"] != 1 ) { |
|
| 903 | + $debug = 1; |
|
| 904 | + } else { |
|
| 905 | + $debug = 0; |
|
| 906 | + } |
|
| 885 | 907 | |
| 886 | 908 | return $this->_pdf->output($debug); |
| 887 | 909 | |
@@ -1,56 +1,56 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
| 4 | - * |
|
| 5 | - * File: $RCSfile: cpdf_adapter.cls.php,v $ |
|
| 6 | - * Created on: 2004-08-04 |
|
| 7 | - * Modified on: 2008-01-05 |
|
| 8 | - * |
|
| 9 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
| 10 | - * Portions copyright (c) 2008 - Orion Richardson <[email protected]> |
|
| 11 | - * |
|
| 12 | - * This library is free software; you can redistribute it and/or |
|
| 13 | - * modify it under the terms of the GNU Lesser General Public |
|
| 14 | - * License as published by the Free Software Foundation; either |
|
| 15 | - * version 2.1 of the License, or (at your option) any later version. |
|
| 16 | - * |
|
| 17 | - * This library is distributed in the hope that it will be useful, |
|
| 18 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
| 20 | - * Lesser General Public License for more details. |
|
| 21 | - * |
|
| 22 | - * You should have received a copy of the GNU Lesser General Public License |
|
| 23 | - * along with this library in the file LICENSE.LGPL; if not, write to the |
|
| 24 | - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
| 25 | - * 02111-1307 USA |
|
| 26 | - * |
|
| 27 | - * Alternatively, you may distribute this software under the terms of the |
|
| 28 | - * PHP License, version 3.0 or later. A copy of this license should have |
|
| 29 | - * been distributed with this file in the file LICENSE.PHP . If this is not |
|
| 30 | - * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
| 31 | - * |
|
| 32 | - * The latest version of DOMPDF might be available at: |
|
| 33 | - * http://www.dompdf.com/ |
|
| 34 | - * |
|
| 35 | - * @link http://www.dompdf.com/ |
|
| 36 | - * @copyright 2004 Benj Carson |
|
| 37 | - * @author Benj Carson <[email protected]> |
|
| 38 | - * @contributor Orion Richardson <[email protected]> |
|
| 39 | - * @contributor Helmut Tischer <[email protected]> |
|
| 40 | - * @package dompdf |
|
| 41 | - * |
|
| 42 | - * Changes |
|
| 43 | - * @contributor Helmut Tischer <[email protected]> |
|
| 44 | - * @version 0.5.1.htischer.20090507 |
|
| 45 | - * - On gif to png conversion tmp file creation, clarify tmp name and add to tmp deletion list only on success |
|
| 46 | - * - On gif to png conversion, when available add direct from gd without tmp file, skip image load if already cached. |
|
| 47 | - * to safe CPU time and memory |
|
| 48 | - * @contributor Helmut Tischer <[email protected]> |
|
| 49 | - * @version dompdf_trunk_with_helmut_mods.20090524 |
|
| 50 | - * - Pass temp and fontcache folders to Cpdf, to making Cpdf independent from dompdf |
|
| 51 | - * @version dompdf_trunk_with_helmut_mods.20090528 |
|
| 52 | - * - fix text position according to glyph baseline to match background rectangle |
|
| 53 | - */ |
|
| 3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
| 4 | + * |
|
| 5 | + * File: $RCSfile: cpdf_adapter.cls.php,v $ |
|
| 6 | + * Created on: 2004-08-04 |
|
| 7 | + * Modified on: 2008-01-05 |
|
| 8 | + * |
|
| 9 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
| 10 | + * Portions copyright (c) 2008 - Orion Richardson <[email protected]> |
|
| 11 | + * |
|
| 12 | + * This library is free software; you can redistribute it and/or |
|
| 13 | + * modify it under the terms of the GNU Lesser General Public |
|
| 14 | + * License as published by the Free Software Foundation; either |
|
| 15 | + * version 2.1 of the License, or (at your option) any later version. |
|
| 16 | + * |
|
| 17 | + * This library is distributed in the hope that it will be useful, |
|
| 18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
| 20 | + * Lesser General Public License for more details. |
|
| 21 | + * |
|
| 22 | + * You should have received a copy of the GNU Lesser General Public License |
|
| 23 | + * along with this library in the file LICENSE.LGPL; if not, write to the |
|
| 24 | + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
| 25 | + * 02111-1307 USA |
|
| 26 | + * |
|
| 27 | + * Alternatively, you may distribute this software under the terms of the |
|
| 28 | + * PHP License, version 3.0 or later. A copy of this license should have |
|
| 29 | + * been distributed with this file in the file LICENSE.PHP . If this is not |
|
| 30 | + * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
| 31 | + * |
|
| 32 | + * The latest version of DOMPDF might be available at: |
|
| 33 | + * http://www.dompdf.com/ |
|
| 34 | + * |
|
| 35 | + * @link http://www.dompdf.com/ |
|
| 36 | + * @copyright 2004 Benj Carson |
|
| 37 | + * @author Benj Carson <[email protected]> |
|
| 38 | + * @contributor Orion Richardson <[email protected]> |
|
| 39 | + * @contributor Helmut Tischer <[email protected]> |
|
| 40 | + * @package dompdf |
|
| 41 | + * |
|
| 42 | + * Changes |
|
| 43 | + * @contributor Helmut Tischer <[email protected]> |
|
| 44 | + * @version 0.5.1.htischer.20090507 |
|
| 45 | + * - On gif to png conversion tmp file creation, clarify tmp name and add to tmp deletion list only on success |
|
| 46 | + * - On gif to png conversion, when available add direct from gd without tmp file, skip image load if already cached. |
|
| 47 | + * to safe CPU time and memory |
|
| 48 | + * @contributor Helmut Tischer <[email protected]> |
|
| 49 | + * @version dompdf_trunk_with_helmut_mods.20090524 |
|
| 50 | + * - Pass temp and fontcache folders to Cpdf, to making Cpdf independent from dompdf |
|
| 51 | + * @version dompdf_trunk_with_helmut_mods.20090528 |
|
| 52 | + * - fix text position according to glyph baseline to match background rectangle |
|
| 53 | + */ |
|
| 54 | 54 | |
| 55 | 55 | /* $Id: cpdf_adapter.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */ |
| 56 | 56 | |
@@ -74,144 +74,144 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | class CPDF_Adapter implements Canvas { |
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Dimensions of paper sizes in points |
|
| 79 | - * |
|
| 80 | - * @var array; |
|
| 81 | - */ |
|
| 82 | - static $PAPER_SIZES = array("4a0" => array(0,0,4767.87,6740.79), |
|
| 83 | - "2a0" => array(0,0,3370.39,4767.87), |
|
| 84 | - "a0" => array(0,0,2383.94,3370.39), |
|
| 85 | - "a1" => array(0,0,1683.78,2383.94), |
|
| 86 | - "a2" => array(0,0,1190.55,1683.78), |
|
| 87 | - "a3" => array(0,0,841.89,1190.55), |
|
| 88 | - "a4" => array(0,0,595.28,841.89), |
|
| 89 | - "a5" => array(0,0,419.53,595.28), |
|
| 90 | - "a6" => array(0,0,297.64,419.53), |
|
| 91 | - "a7" => array(0,0,209.76,297.64), |
|
| 92 | - "a8" => array(0,0,147.40,209.76), |
|
| 93 | - "a9" => array(0,0,104.88,147.40), |
|
| 94 | - "a10" => array(0,0,73.70,104.88), |
|
| 95 | - "b0" => array(0,0,2834.65,4008.19), |
|
| 96 | - "b1" => array(0,0,2004.09,2834.65), |
|
| 97 | - "b2" => array(0,0,1417.32,2004.09), |
|
| 98 | - "b3" => array(0,0,1000.63,1417.32), |
|
| 99 | - "b4" => array(0,0,708.66,1000.63), |
|
| 100 | - "b5" => array(0,0,498.90,708.66), |
|
| 101 | - "b6" => array(0,0,354.33,498.90), |
|
| 102 | - "b7" => array(0,0,249.45,354.33), |
|
| 103 | - "b8" => array(0,0,175.75,249.45), |
|
| 104 | - "b9" => array(0,0,124.72,175.75), |
|
| 105 | - "b10" => array(0,0,87.87,124.72), |
|
| 106 | - "c0" => array(0,0,2599.37,3676.54), |
|
| 107 | - "c1" => array(0,0,1836.85,2599.37), |
|
| 108 | - "c2" => array(0,0,1298.27,1836.85), |
|
| 109 | - "c3" => array(0,0,918.43,1298.27), |
|
| 110 | - "c4" => array(0,0,649.13,918.43), |
|
| 111 | - "c5" => array(0,0,459.21,649.13), |
|
| 112 | - "c6" => array(0,0,323.15,459.21), |
|
| 113 | - "c7" => array(0,0,229.61,323.15), |
|
| 114 | - "c8" => array(0,0,161.57,229.61), |
|
| 115 | - "c9" => array(0,0,113.39,161.57), |
|
| 116 | - "c10" => array(0,0,79.37,113.39), |
|
| 117 | - "ra0" => array(0,0,2437.80,3458.27), |
|
| 118 | - "ra1" => array(0,0,1729.13,2437.80), |
|
| 119 | - "ra2" => array(0,0,1218.90,1729.13), |
|
| 120 | - "ra3" => array(0,0,864.57,1218.90), |
|
| 121 | - "ra4" => array(0,0,609.45,864.57), |
|
| 122 | - "sra0" => array(0,0,2551.18,3628.35), |
|
| 123 | - "sra1" => array(0,0,1814.17,2551.18), |
|
| 124 | - "sra2" => array(0,0,1275.59,1814.17), |
|
| 125 | - "sra3" => array(0,0,907.09,1275.59), |
|
| 126 | - "sra4" => array(0,0,637.80,907.09), |
|
| 127 | - "letter" => array(0,0,612.00,792.00), |
|
| 128 | - "legal" => array(0,0,612.00,1008.00), |
|
| 129 | - "ledger" => array(0,0,1224.00, 792.00), |
|
| 130 | - "tabloid" => array(0,0,792.00, 1224.00), |
|
| 131 | - "executive" => array(0,0,521.86,756.00), |
|
| 132 | - "folio" => array(0,0,612.00,936.00), |
|
| 133 | - "commerical #10 envelope" => array(0,0,684,297), |
|
| 134 | - "catalog #10 1/2 envelope" => array(0,0,648,864), |
|
| 135 | - "8.5x11" => array(0,0,612.00,792.00), |
|
| 136 | - "8.5x14" => array(0,0,612.00,1008.0), |
|
| 137 | - "11x17" => array(0,0,792.00, 1224.00)); |
|
| 138 | - |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * Instance of Cpdf class |
|
| 142 | - * |
|
| 143 | - * @var Cpdf |
|
| 144 | - */ |
|
| 145 | - private $_pdf; |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * PDF width, in points |
|
| 149 | - * |
|
| 150 | - * @var float |
|
| 151 | - */ |
|
| 152 | - private $_width; |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * PDF height, in points |
|
| 156 | - * |
|
| 157 | - * @var float; |
|
| 158 | - */ |
|
| 159 | - private $_height; |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * Current page number |
|
| 163 | - * |
|
| 164 | - * @var int |
|
| 165 | - */ |
|
| 166 | - private $_page_number; |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * Total number of pages |
|
| 170 | - * |
|
| 171 | - * @var int |
|
| 172 | - */ |
|
| 173 | - private $_page_count; |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * Text to display on every page |
|
| 177 | - * |
|
| 178 | - * @var array |
|
| 179 | - */ |
|
| 180 | - private $_page_text; |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * Array of pages for accesing after rendering is initially complete |
|
| 184 | - * |
|
| 185 | - * @var array |
|
| 186 | - */ |
|
| 187 | - private $_pages; |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * Array of temporary cached images to be deleted when processing is complete |
|
| 191 | - * |
|
| 192 | - * @var array |
|
| 193 | - */ |
|
| 194 | - private $_image_cache; |
|
| 77 | + /** |
|
| 78 | + * Dimensions of paper sizes in points |
|
| 79 | + * |
|
| 80 | + * @var array; |
|
| 81 | + */ |
|
| 82 | + static $PAPER_SIZES = array("4a0" => array(0,0,4767.87,6740.79), |
|
| 83 | + "2a0" => array(0,0,3370.39,4767.87), |
|
| 84 | + "a0" => array(0,0,2383.94,3370.39), |
|
| 85 | + "a1" => array(0,0,1683.78,2383.94), |
|
| 86 | + "a2" => array(0,0,1190.55,1683.78), |
|
| 87 | + "a3" => array(0,0,841.89,1190.55), |
|
| 88 | + "a4" => array(0,0,595.28,841.89), |
|
| 89 | + "a5" => array(0,0,419.53,595.28), |
|
| 90 | + "a6" => array(0,0,297.64,419.53), |
|
| 91 | + "a7" => array(0,0,209.76,297.64), |
|
| 92 | + "a8" => array(0,0,147.40,209.76), |
|
| 93 | + "a9" => array(0,0,104.88,147.40), |
|
| 94 | + "a10" => array(0,0,73.70,104.88), |
|
| 95 | + "b0" => array(0,0,2834.65,4008.19), |
|
| 96 | + "b1" => array(0,0,2004.09,2834.65), |
|
| 97 | + "b2" => array(0,0,1417.32,2004.09), |
|
| 98 | + "b3" => array(0,0,1000.63,1417.32), |
|
| 99 | + "b4" => array(0,0,708.66,1000.63), |
|
| 100 | + "b5" => array(0,0,498.90,708.66), |
|
| 101 | + "b6" => array(0,0,354.33,498.90), |
|
| 102 | + "b7" => array(0,0,249.45,354.33), |
|
| 103 | + "b8" => array(0,0,175.75,249.45), |
|
| 104 | + "b9" => array(0,0,124.72,175.75), |
|
| 105 | + "b10" => array(0,0,87.87,124.72), |
|
| 106 | + "c0" => array(0,0,2599.37,3676.54), |
|
| 107 | + "c1" => array(0,0,1836.85,2599.37), |
|
| 108 | + "c2" => array(0,0,1298.27,1836.85), |
|
| 109 | + "c3" => array(0,0,918.43,1298.27), |
|
| 110 | + "c4" => array(0,0,649.13,918.43), |
|
| 111 | + "c5" => array(0,0,459.21,649.13), |
|
| 112 | + "c6" => array(0,0,323.15,459.21), |
|
| 113 | + "c7" => array(0,0,229.61,323.15), |
|
| 114 | + "c8" => array(0,0,161.57,229.61), |
|
| 115 | + "c9" => array(0,0,113.39,161.57), |
|
| 116 | + "c10" => array(0,0,79.37,113.39), |
|
| 117 | + "ra0" => array(0,0,2437.80,3458.27), |
|
| 118 | + "ra1" => array(0,0,1729.13,2437.80), |
|
| 119 | + "ra2" => array(0,0,1218.90,1729.13), |
|
| 120 | + "ra3" => array(0,0,864.57,1218.90), |
|
| 121 | + "ra4" => array(0,0,609.45,864.57), |
|
| 122 | + "sra0" => array(0,0,2551.18,3628.35), |
|
| 123 | + "sra1" => array(0,0,1814.17,2551.18), |
|
| 124 | + "sra2" => array(0,0,1275.59,1814.17), |
|
| 125 | + "sra3" => array(0,0,907.09,1275.59), |
|
| 126 | + "sra4" => array(0,0,637.80,907.09), |
|
| 127 | + "letter" => array(0,0,612.00,792.00), |
|
| 128 | + "legal" => array(0,0,612.00,1008.00), |
|
| 129 | + "ledger" => array(0,0,1224.00, 792.00), |
|
| 130 | + "tabloid" => array(0,0,792.00, 1224.00), |
|
| 131 | + "executive" => array(0,0,521.86,756.00), |
|
| 132 | + "folio" => array(0,0,612.00,936.00), |
|
| 133 | + "commerical #10 envelope" => array(0,0,684,297), |
|
| 134 | + "catalog #10 1/2 envelope" => array(0,0,648,864), |
|
| 135 | + "8.5x11" => array(0,0,612.00,792.00), |
|
| 136 | + "8.5x14" => array(0,0,612.00,1008.0), |
|
| 137 | + "11x17" => array(0,0,792.00, 1224.00)); |
|
| 138 | + |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * Instance of Cpdf class |
|
| 142 | + * |
|
| 143 | + * @var Cpdf |
|
| 144 | + */ |
|
| 145 | + private $_pdf; |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * PDF width, in points |
|
| 149 | + * |
|
| 150 | + * @var float |
|
| 151 | + */ |
|
| 152 | + private $_width; |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * PDF height, in points |
|
| 156 | + * |
|
| 157 | + * @var float; |
|
| 158 | + */ |
|
| 159 | + private $_height; |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * Current page number |
|
| 163 | + * |
|
| 164 | + * @var int |
|
| 165 | + */ |
|
| 166 | + private $_page_number; |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * Total number of pages |
|
| 170 | + * |
|
| 171 | + * @var int |
|
| 172 | + */ |
|
| 173 | + private $_page_count; |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * Text to display on every page |
|
| 177 | + * |
|
| 178 | + * @var array |
|
| 179 | + */ |
|
| 180 | + private $_page_text; |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * Array of pages for accesing after rendering is initially complete |
|
| 184 | + * |
|
| 185 | + * @var array |
|
| 186 | + */ |
|
| 187 | + private $_pages; |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * Array of temporary cached images to be deleted when processing is complete |
|
| 191 | + * |
|
| 192 | + * @var array |
|
| 193 | + */ |
|
| 194 | + private $_image_cache; |
|
| 195 | 195 | |
| 196 | - /** |
|
| 197 | - * Class constructor |
|
| 198 | - * |
|
| 199 | - * @param mixed $paper The size of paper to use in this PDF ({@link CPDF_Adapter::$PAPER_SIZES}) |
|
| 200 | - * @param string $orientation The orienation of the document (either 'landscape' or 'portrait') |
|
| 201 | - */ |
|
| 202 | - function __construct($paper = "letter", $orientation = "portrait") { |
|
| 196 | + /** |
|
| 197 | + * Class constructor |
|
| 198 | + * |
|
| 199 | + * @param mixed $paper The size of paper to use in this PDF ({@link CPDF_Adapter::$PAPER_SIZES}) |
|
| 200 | + * @param string $orientation The orienation of the document (either 'landscape' or 'portrait') |
|
| 201 | + */ |
|
| 202 | + function __construct($paper = "letter", $orientation = "portrait") { |
|
| 203 | 203 | |
| 204 | 204 | if ( is_array($paper) ) |
| 205 | - $size = $paper; |
|
| 205 | + $size = $paper; |
|
| 206 | 206 | else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) |
| 207 | - $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
|
| 207 | + $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
|
| 208 | 208 | else |
| 209 | - $size = self::$PAPER_SIZES["letter"]; |
|
| 209 | + $size = self::$PAPER_SIZES["letter"]; |
|
| 210 | 210 | |
| 211 | 211 | if ( mb_strtolower($orientation) === "landscape" ) { |
| 212 | - $a = $size[3]; |
|
| 213 | - $size[3] = $size[2]; |
|
| 214 | - $size[2] = $a; |
|
| 212 | + $a = $size[3]; |
|
| 213 | + $size[3] = $size[2]; |
|
| 214 | + $size[2] = $a; |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | $this->_pdf = new Cpdf($size, DOMPDF_UNICODE_ENABLED, DOMPDF_FONT_CACHE, DOMPDF_TEMP_DIR); |
@@ -219,8 +219,8 @@ discard block |
||
| 219 | 219 | |
| 220 | 220 | // Silence pedantic warnings about missing TZ settings |
| 221 | 221 | $time = substr_replace(date('YmdHisO'), '\'', (0 - 2), 0).'\''; |
| 222 | - $this->_pdf->addInfo("CreationDate", "D:".$time); |
|
| 223 | - $this->_pdf->addInfo("ModDate", "D:".$time); |
|
| 222 | + $this->_pdf->addInfo("CreationDate", "D:".$time); |
|
| 223 | + $this->_pdf->addInfo("ModDate", "D:".$time); |
|
| 224 | 224 | |
| 225 | 225 | |
| 226 | 226 | $this->_width = $size[2] - $size[0]; |
@@ -233,253 +233,253 @@ discard block |
||
| 233 | 233 | $this->_pages = array($this->_pdf->getFirstPageId()); |
| 234 | 234 | |
| 235 | 235 | $this->_image_cache = array(); |
| 236 | - } |
|
| 237 | - |
|
| 238 | - /** |
|
| 239 | - * Class destructor |
|
| 240 | - * |
|
| 241 | - * Deletes all temporary image files |
|
| 242 | - */ |
|
| 243 | - function __destruct() { |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + /** |
|
| 239 | + * Class destructor |
|
| 240 | + * |
|
| 241 | + * Deletes all temporary image files |
|
| 242 | + */ |
|
| 243 | + function __destruct() { |
|
| 244 | 244 | foreach ($this->_image_cache as $img) { |
| 245 | - //debugpng |
|
| 246 | - if (DEBUGPNG) print '[__destruct unlink '.$img.']'; |
|
| 247 | - if (!DEBUGKEEPTEMP) |
|
| 245 | + //debugpng |
|
| 246 | + if (DEBUGPNG) print '[__destruct unlink '.$img.']'; |
|
| 247 | + if (!DEBUGKEEPTEMP) |
|
| 248 | 248 | unlink($img); |
| 249 | 249 | } |
| 250 | - } |
|
| 250 | + } |
|
| 251 | 251 | |
| 252 | - /** |
|
| 253 | - * Returns the Cpdf instance |
|
| 254 | - * |
|
| 255 | - * @return Cpdf |
|
| 256 | - */ |
|
| 257 | - function get_cpdf() { return $this->_pdf; } |
|
| 258 | - |
|
| 259 | - /** |
|
| 260 | - * Add meta information to the PDF |
|
| 261 | - * |
|
| 262 | - * @param string $label label of the value (Creator, Producter, etc.) |
|
| 263 | - * @param string $value the text to set |
|
| 264 | - */ |
|
| 265 | - function add_info($label, $value) { |
|
| 252 | + /** |
|
| 253 | + * Returns the Cpdf instance |
|
| 254 | + * |
|
| 255 | + * @return Cpdf |
|
| 256 | + */ |
|
| 257 | + function get_cpdf() { return $this->_pdf; } |
|
| 258 | + |
|
| 259 | + /** |
|
| 260 | + * Add meta information to the PDF |
|
| 261 | + * |
|
| 262 | + * @param string $label label of the value (Creator, Producter, etc.) |
|
| 263 | + * @param string $value the text to set |
|
| 264 | + */ |
|
| 265 | + function add_info($label, $value) { |
|
| 266 | 266 | $this->_pdf->addInfo($label, $value); |
| 267 | - } |
|
| 268 | - |
|
| 269 | - /** |
|
| 270 | - * Opens a new 'object' |
|
| 271 | - * |
|
| 272 | - * While an object is open, all drawing actions are recored in the object, |
|
| 273 | - * as opposed to being drawn on the current page. Objects can be added |
|
| 274 | - * later to a specific page or to several pages. |
|
| 275 | - * |
|
| 276 | - * The return value is an integer ID for the new object. |
|
| 277 | - * |
|
| 278 | - * @see CPDF_Adapter::close_object() |
|
| 279 | - * @see CPDF_Adapter::add_object() |
|
| 280 | - * |
|
| 281 | - * @return int |
|
| 282 | - */ |
|
| 283 | - function open_object() { |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + /** |
|
| 270 | + * Opens a new 'object' |
|
| 271 | + * |
|
| 272 | + * While an object is open, all drawing actions are recored in the object, |
|
| 273 | + * as opposed to being drawn on the current page. Objects can be added |
|
| 274 | + * later to a specific page or to several pages. |
|
| 275 | + * |
|
| 276 | + * The return value is an integer ID for the new object. |
|
| 277 | + * |
|
| 278 | + * @see CPDF_Adapter::close_object() |
|
| 279 | + * @see CPDF_Adapter::add_object() |
|
| 280 | + * |
|
| 281 | + * @return int |
|
| 282 | + */ |
|
| 283 | + function open_object() { |
|
| 284 | 284 | $ret = $this->_pdf->openObject(); |
| 285 | 285 | $this->_pdf->saveState(); |
| 286 | 286 | return $ret; |
| 287 | - } |
|
| 288 | - |
|
| 289 | - /** |
|
| 290 | - * Reopens an existing 'object' |
|
| 291 | - * |
|
| 292 | - * @see CPDF_Adapter::open_object() |
|
| 293 | - * @param int $object the ID of a previously opened object |
|
| 294 | - */ |
|
| 295 | - function reopen_object($object) { |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + /** |
|
| 290 | + * Reopens an existing 'object' |
|
| 291 | + * |
|
| 292 | + * @see CPDF_Adapter::open_object() |
|
| 293 | + * @param int $object the ID of a previously opened object |
|
| 294 | + */ |
|
| 295 | + function reopen_object($object) { |
|
| 296 | 296 | $this->_pdf->reopenObject($object); |
| 297 | 297 | $this->_pdf->saveState(); |
| 298 | - } |
|
| 299 | - |
|
| 300 | - /** |
|
| 301 | - * Closes the current 'object' |
|
| 302 | - * |
|
| 303 | - * @see CPDF_Adapter::open_object() |
|
| 304 | - */ |
|
| 305 | - function close_object() { |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + /** |
|
| 301 | + * Closes the current 'object' |
|
| 302 | + * |
|
| 303 | + * @see CPDF_Adapter::open_object() |
|
| 304 | + */ |
|
| 305 | + function close_object() { |
|
| 306 | 306 | $this->_pdf->restoreState(); |
| 307 | 307 | $this->_pdf->closeObject(); |
| 308 | - } |
|
| 309 | - |
|
| 310 | - /** |
|
| 311 | - * Adds a specified 'object' to the document |
|
| 312 | - * |
|
| 313 | - * $object int specifying an object created with {@link |
|
| 314 | - * CPDF_Adapter::open_object()}. $where can be one of: |
|
| 315 | - * - 'add' add to current page only |
|
| 316 | - * - 'all' add to every page from the current one onwards |
|
| 317 | - * - 'odd' add to all odd numbered pages from now on |
|
| 318 | - * - 'even' add to all even numbered pages from now on |
|
| 319 | - * - 'next' add the object to the next page only |
|
| 320 | - * - 'nextodd' add to all odd numbered pages from the next one |
|
| 321 | - * - 'nexteven' add to all even numbered pages from the next one |
|
| 322 | - * |
|
| 323 | - * @see Cpdf::addObject() |
|
| 324 | - * |
|
| 325 | - * @param int $object |
|
| 326 | - * @param string $where |
|
| 327 | - */ |
|
| 328 | - function add_object($object, $where = 'all') { |
|
| 308 | + } |
|
| 309 | + |
|
| 310 | + /** |
|
| 311 | + * Adds a specified 'object' to the document |
|
| 312 | + * |
|
| 313 | + * $object int specifying an object created with {@link |
|
| 314 | + * CPDF_Adapter::open_object()}. $where can be one of: |
|
| 315 | + * - 'add' add to current page only |
|
| 316 | + * - 'all' add to every page from the current one onwards |
|
| 317 | + * - 'odd' add to all odd numbered pages from now on |
|
| 318 | + * - 'even' add to all even numbered pages from now on |
|
| 319 | + * - 'next' add the object to the next page only |
|
| 320 | + * - 'nextodd' add to all odd numbered pages from the next one |
|
| 321 | + * - 'nexteven' add to all even numbered pages from the next one |
|
| 322 | + * |
|
| 323 | + * @see Cpdf::addObject() |
|
| 324 | + * |
|
| 325 | + * @param int $object |
|
| 326 | + * @param string $where |
|
| 327 | + */ |
|
| 328 | + function add_object($object, $where = 'all') { |
|
| 329 | 329 | $this->_pdf->addObject($object, $where); |
| 330 | - } |
|
| 331 | - |
|
| 332 | - /** |
|
| 333 | - * Stops the specified 'object' from appearing in the document. |
|
| 334 | - * |
|
| 335 | - * The object will stop being displayed on the page following the current |
|
| 336 | - * one. |
|
| 337 | - * |
|
| 338 | - * @param int $object |
|
| 339 | - */ |
|
| 340 | - function stop_object($object) { |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + /** |
|
| 333 | + * Stops the specified 'object' from appearing in the document. |
|
| 334 | + * |
|
| 335 | + * The object will stop being displayed on the page following the current |
|
| 336 | + * one. |
|
| 337 | + * |
|
| 338 | + * @param int $object |
|
| 339 | + */ |
|
| 340 | + function stop_object($object) { |
|
| 341 | 341 | $this->_pdf->stopObject($object); |
| 342 | - } |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | - /** |
|
| 345 | - * @access private |
|
| 346 | - */ |
|
| 347 | - function serialize_object($id) { |
|
| 344 | + /** |
|
| 345 | + * @access private |
|
| 346 | + */ |
|
| 347 | + function serialize_object($id) { |
|
| 348 | 348 | // Serialize the pdf object's current state for retrieval later |
| 349 | 349 | return $this->_pdf->serializeObject($id); |
| 350 | - } |
|
| 350 | + } |
|
| 351 | 351 | |
| 352 | - /** |
|
| 353 | - * @access private |
|
| 354 | - */ |
|
| 355 | - function reopen_serialized_object($obj) { |
|
| 352 | + /** |
|
| 353 | + * @access private |
|
| 354 | + */ |
|
| 355 | + function reopen_serialized_object($obj) { |
|
| 356 | 356 | return $this->_pdf->restoreSerializedObject($obj); |
| 357 | - } |
|
| 357 | + } |
|
| 358 | 358 | |
| 359 | - //........................................................................ |
|
| 360 | - |
|
| 361 | - /** |
|
| 362 | - * Returns the PDF's width in points |
|
| 363 | - * @return float |
|
| 364 | - */ |
|
| 365 | - function get_width() { return $this->_width; } |
|
| 366 | - |
|
| 367 | - /** |
|
| 368 | - * Returns the PDF's height in points |
|
| 369 | - * @return float |
|
| 370 | - */ |
|
| 371 | - function get_height() { return $this->_height; } |
|
| 372 | - |
|
| 373 | - /** |
|
| 374 | - * Returns the current page number |
|
| 375 | - * @return int |
|
| 376 | - */ |
|
| 377 | - function get_page_number() { return $this->_page_number; } |
|
| 378 | - |
|
| 379 | - /** |
|
| 380 | - * Returns the total number of pages in the document |
|
| 381 | - * @return int |
|
| 382 | - */ |
|
| 383 | - function get_page_count() { return $this->_page_count; } |
|
| 384 | - |
|
| 385 | - /** |
|
| 386 | - * Sets the current page number |
|
| 387 | - * |
|
| 388 | - * @param int $num |
|
| 389 | - */ |
|
| 390 | - function set_page_number($num) { $this->_page_number = $num; } |
|
| 391 | - |
|
| 392 | - /** |
|
| 393 | - * Sets the page count |
|
| 394 | - * |
|
| 395 | - * @param int $count |
|
| 396 | - */ |
|
| 397 | - function set_page_count($count) { $this->_page_count = $count; } |
|
| 359 | + //........................................................................ |
|
| 360 | + |
|
| 361 | + /** |
|
| 362 | + * Returns the PDF's width in points |
|
| 363 | + * @return float |
|
| 364 | + */ |
|
| 365 | + function get_width() { return $this->_width; } |
|
| 366 | + |
|
| 367 | + /** |
|
| 368 | + * Returns the PDF's height in points |
|
| 369 | + * @return float |
|
| 370 | + */ |
|
| 371 | + function get_height() { return $this->_height; } |
|
| 372 | + |
|
| 373 | + /** |
|
| 374 | + * Returns the current page number |
|
| 375 | + * @return int |
|
| 376 | + */ |
|
| 377 | + function get_page_number() { return $this->_page_number; } |
|
| 378 | + |
|
| 379 | + /** |
|
| 380 | + * Returns the total number of pages in the document |
|
| 381 | + * @return int |
|
| 382 | + */ |
|
| 383 | + function get_page_count() { return $this->_page_count; } |
|
| 384 | + |
|
| 385 | + /** |
|
| 386 | + * Sets the current page number |
|
| 387 | + * |
|
| 388 | + * @param int $num |
|
| 389 | + */ |
|
| 390 | + function set_page_number($num) { $this->_page_number = $num; } |
|
| 391 | + |
|
| 392 | + /** |
|
| 393 | + * Sets the page count |
|
| 394 | + * |
|
| 395 | + * @param int $count |
|
| 396 | + */ |
|
| 397 | + function set_page_count($count) { $this->_page_count = $count; } |
|
| 398 | 398 | |
| 399 | - /** |
|
| 400 | - * Sets the stroke colour |
|
| 401 | - * |
|
| 402 | - * See {@link Style::set_colour()} for the format of the color array. |
|
| 403 | - * @param array $color |
|
| 404 | - */ |
|
| 405 | - protected function _set_stroke_color($color) { |
|
| 399 | + /** |
|
| 400 | + * Sets the stroke colour |
|
| 401 | + * |
|
| 402 | + * See {@link Style::set_colour()} for the format of the color array. |
|
| 403 | + * @param array $color |
|
| 404 | + */ |
|
| 405 | + protected function _set_stroke_color($color) { |
|
| 406 | 406 | list($r, $g, $b) = $color; |
| 407 | 407 | $this->_pdf->setStrokeColor($r, $g, $b); |
| 408 | - } |
|
| 408 | + } |
|
| 409 | 409 | |
| 410 | - /** |
|
| 411 | - * Sets the fill colour |
|
| 412 | - * |
|
| 413 | - * See {@link Style::set_colour()} for the format of the colour array. |
|
| 414 | - * @param array $color |
|
| 415 | - */ |
|
| 416 | - protected function _set_fill_color($color) { |
|
| 410 | + /** |
|
| 411 | + * Sets the fill colour |
|
| 412 | + * |
|
| 413 | + * See {@link Style::set_colour()} for the format of the colour array. |
|
| 414 | + * @param array $color |
|
| 415 | + */ |
|
| 416 | + protected function _set_fill_color($color) { |
|
| 417 | 417 | list($r, $g, $b) = $color; |
| 418 | 418 | $this->_pdf->setColor($r, $g, $b); |
| 419 | - } |
|
| 420 | - |
|
| 421 | - /** |
|
| 422 | - * Sets line transparency |
|
| 423 | - * @see Cpdf::setLineTransparency() |
|
| 424 | - * |
|
| 425 | - * Valid blend modes are (case-sensitive): |
|
| 426 | - * |
|
| 427 | - * Normal, Multiply, Screen, Overlay, Darken, Lighten, |
|
| 428 | - * ColorDodge, ColorBurn, HardLight, SoftLight, Difference, |
|
| 429 | - * Exclusion |
|
| 430 | - * |
|
| 431 | - * @param string $mode the blending mode to use |
|
| 432 | - * @param float $opacity 0.0 fully transparent, 1.0 fully opaque |
|
| 433 | - */ |
|
| 434 | - protected function _set_line_transparency($mode, $opacity) { |
|
| 419 | + } |
|
| 420 | + |
|
| 421 | + /** |
|
| 422 | + * Sets line transparency |
|
| 423 | + * @see Cpdf::setLineTransparency() |
|
| 424 | + * |
|
| 425 | + * Valid blend modes are (case-sensitive): |
|
| 426 | + * |
|
| 427 | + * Normal, Multiply, Screen, Overlay, Darken, Lighten, |
|
| 428 | + * ColorDodge, ColorBurn, HardLight, SoftLight, Difference, |
|
| 429 | + * Exclusion |
|
| 430 | + * |
|
| 431 | + * @param string $mode the blending mode to use |
|
| 432 | + * @param float $opacity 0.0 fully transparent, 1.0 fully opaque |
|
| 433 | + */ |
|
| 434 | + protected function _set_line_transparency($mode, $opacity) { |
|
| 435 | 435 | $this->_pdf->setLineTransparency($mode, $opacity); |
| 436 | - } |
|
| 436 | + } |
|
| 437 | 437 | |
| 438 | - /** |
|
| 439 | - * Sets fill transparency |
|
| 440 | - * @see Cpdf::setFillTransparency() |
|
| 441 | - * |
|
| 442 | - * Valid blend modes are (case-sensitive): |
|
| 443 | - * |
|
| 444 | - * Normal, Multiply, Screen, Overlay, Darken, Lighten, |
|
| 445 | - * ColorDogde, ColorBurn, HardLight, SoftLight, Difference, |
|
| 446 | - * Exclusion |
|
| 447 | - * |
|
| 448 | - * @param string $mode the blending mode to use |
|
| 449 | - * @param float $opacity 0.0 fully transparent, 1.0 fully opaque |
|
| 450 | - */ |
|
| 451 | - protected function _set_fill_transparency($mode, $opacity) { |
|
| 438 | + /** |
|
| 439 | + * Sets fill transparency |
|
| 440 | + * @see Cpdf::setFillTransparency() |
|
| 441 | + * |
|
| 442 | + * Valid blend modes are (case-sensitive): |
|
| 443 | + * |
|
| 444 | + * Normal, Multiply, Screen, Overlay, Darken, Lighten, |
|
| 445 | + * ColorDogde, ColorBurn, HardLight, SoftLight, Difference, |
|
| 446 | + * Exclusion |
|
| 447 | + * |
|
| 448 | + * @param string $mode the blending mode to use |
|
| 449 | + * @param float $opacity 0.0 fully transparent, 1.0 fully opaque |
|
| 450 | + */ |
|
| 451 | + protected function _set_fill_transparency($mode, $opacity) { |
|
| 452 | 452 | $this->_pdf->setFillTransparency($mode, $opacity); |
| 453 | - } |
|
| 454 | - |
|
| 455 | - /** |
|
| 456 | - * Sets the line style |
|
| 457 | - * |
|
| 458 | - * @see Cpdf::setLineStyle() |
|
| 459 | - * |
|
| 460 | - * @param float width |
|
| 461 | - * @param string cap |
|
| 462 | - * @param string join |
|
| 463 | - * @param array dash |
|
| 464 | - */ |
|
| 465 | - protected function _set_line_style($width, $cap, $join, $dash) { |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + /** |
|
| 456 | + * Sets the line style |
|
| 457 | + * |
|
| 458 | + * @see Cpdf::setLineStyle() |
|
| 459 | + * |
|
| 460 | + * @param float width |
|
| 461 | + * @param string cap |
|
| 462 | + * @param string join |
|
| 463 | + * @param array dash |
|
| 464 | + */ |
|
| 465 | + protected function _set_line_style($width, $cap, $join, $dash) { |
|
| 466 | 466 | $this->_pdf->setLineStyle($width, $cap, $join, $dash); |
| 467 | - } |
|
| 467 | + } |
|
| 468 | 468 | |
| 469 | - //........................................................................ |
|
| 469 | + //........................................................................ |
|
| 470 | 470 | |
| 471 | 471 | |
| 472 | - /** |
|
| 473 | - * Remaps y coords from 4th to 1st quadrant |
|
| 474 | - * |
|
| 475 | - * @param float $y |
|
| 476 | - * @return float |
|
| 477 | - */ |
|
| 478 | - protected function y($y) { return $this->_height - $y; } |
|
| 472 | + /** |
|
| 473 | + * Remaps y coords from 4th to 1st quadrant |
|
| 474 | + * |
|
| 475 | + * @param float $y |
|
| 476 | + * @return float |
|
| 477 | + */ |
|
| 478 | + protected function y($y) { return $this->_height - $y; } |
|
| 479 | 479 | |
| 480 | - // Canvas implementation |
|
| 480 | + // Canvas implementation |
|
| 481 | 481 | |
| 482 | - function line($x1, $y1, $x2, $y2, $color, $width, $style = array(), |
|
| 482 | + function line($x1, $y1, $x2, $y2, $color, $width, $style = array(), |
|
| 483 | 483 | $blend = "Normal", $opacity = 1.0) { |
| 484 | 484 | //pre_r(compact("x1", "y1", "x2", "y2", "color", "width", "style")); |
| 485 | 485 | |
@@ -488,35 +488,35 @@ discard block |
||
| 488 | 488 | $this->_set_line_transparency($blend, $opacity); |
| 489 | 489 | |
| 490 | 490 | $this->_pdf->line($x1, $this->y($y1), |
| 491 | - $x2, $this->y($y2)); |
|
| 492 | - } |
|
| 491 | + $x2, $this->y($y2)); |
|
| 492 | + } |
|
| 493 | 493 | |
| 494 | - //........................................................................ |
|
| 495 | - |
|
| 496 | - /** |
|
| 497 | - * Convert a GIF image to a PNG image |
|
| 498 | - * |
|
| 499 | - * @return string The url of the newly converted image |
|
| 500 | - */ |
|
| 501 | - protected function _convert_gif_to_png($image_url) { |
|
| 494 | + //........................................................................ |
|
| 495 | + |
|
| 496 | + /** |
|
| 497 | + * Convert a GIF image to a PNG image |
|
| 498 | + * |
|
| 499 | + * @return string The url of the newly converted image |
|
| 500 | + */ |
|
| 501 | + protected function _convert_gif_to_png($image_url) { |
|
| 502 | 502 | |
| 503 | 503 | if ( !function_exists("imagecreatefromgif") ) { |
| 504 | - throw new DOMPDF_Exception("Function imagecreatefromgif() not found. Cannot convert gif image: $image_url. Please install the image PHP extension."); |
|
| 504 | + throw new DOMPDF_Exception("Function imagecreatefromgif() not found. Cannot convert gif image: $image_url. Please install the image PHP extension."); |
|
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | $old_err = set_error_handler("record_warnings"); |
| 508 | 508 | $im = imagecreatefromgif($image_url); |
| 509 | 509 | |
| 510 | 510 | if ( $im ) { |
| 511 | - imageinterlace($im, 0); |
|
| 511 | + imageinterlace($im, 0); |
|
| 512 | 512 | |
| 513 | - $filename = tempnam(DOMPDF_TEMP_DIR, "gifdompdf_img_").'.png'; |
|
| 514 | - $this->_image_cache[] = $filename; |
|
| 513 | + $filename = tempnam(DOMPDF_TEMP_DIR, "gifdompdf_img_").'.png'; |
|
| 514 | + $this->_image_cache[] = $filename; |
|
| 515 | 515 | |
| 516 | - imagepng($im, $filename); |
|
| 516 | + imagepng($im, $filename); |
|
| 517 | 517 | |
| 518 | 518 | } else { |
| 519 | - $filename = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
| 519 | + $filename = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
| 520 | 520 | |
| 521 | 521 | } |
| 522 | 522 | |
@@ -524,21 +524,21 @@ discard block |
||
| 524 | 524 | |
| 525 | 525 | return $filename; |
| 526 | 526 | |
| 527 | - } |
|
| 527 | + } |
|
| 528 | 528 | |
| 529 | - function rectangle($x1, $y1, $w, $h, $color, $width, $style = array(), |
|
| 530 | - $blend = "Normal", $opacity = 1.0) { |
|
| 529 | + function rectangle($x1, $y1, $w, $h, $color, $width, $style = array(), |
|
| 530 | + $blend = "Normal", $opacity = 1.0) { |
|
| 531 | 531 | |
| 532 | 532 | $this->_set_stroke_color($color); |
| 533 | 533 | $this->_set_line_style($width, "square", "miter", $style); |
| 534 | 534 | $this->_set_line_transparency($blend, $opacity); |
| 535 | 535 | |
| 536 | 536 | $this->_pdf->rectangle($x1, $this->y($y1) - $h, $w, $h); |
| 537 | - } |
|
| 537 | + } |
|
| 538 | 538 | |
| 539 | - //........................................................................ |
|
| 539 | + //........................................................................ |
|
| 540 | 540 | |
| 541 | - function filled_rectangle($x1, $y1, $w, $h, $color, $blend = "Normal", $opacity = 1.0) { |
|
| 541 | + function filled_rectangle($x1, $y1, $w, $h, $color, $blend = "Normal", $opacity = 1.0) { |
|
| 542 | 542 | |
| 543 | 543 | $this->_set_fill_color($color); |
| 544 | 544 | $this->_set_line_style(1, "square", "miter", array()); |
@@ -546,12 +546,12 @@ discard block |
||
| 546 | 546 | $this->_set_fill_transparency($blend, $opacity); |
| 547 | 547 | |
| 548 | 548 | $this->_pdf->filledRectangle($x1, $this->y($y1) - $h, $w, $h); |
| 549 | - } |
|
| 549 | + } |
|
| 550 | 550 | |
| 551 | - //........................................................................ |
|
| 551 | + //........................................................................ |
|
| 552 | 552 | |
| 553 | - function polygon($points, $color, $width = null, $style = array(), |
|
| 554 | - $fill = false, $blend = "Normal", $opacity = 1.0) { |
|
| 553 | + function polygon($points, $color, $width = null, $style = array(), |
|
| 554 | + $fill = false, $blend = "Normal", $opacity = 1.0) { |
|
| 555 | 555 | |
| 556 | 556 | $this->_set_fill_color($color); |
| 557 | 557 | $this->_set_stroke_color($color); |
@@ -560,19 +560,19 @@ discard block |
||
| 560 | 560 | $this->_set_fill_transparency($blend, $opacity); |
| 561 | 561 | |
| 562 | 562 | if ( !$fill && isset($width) ) |
| 563 | - $this->_set_line_style($width, "square", "miter", $style); |
|
| 563 | + $this->_set_line_style($width, "square", "miter", $style); |
|
| 564 | 564 | |
| 565 | 565 | // Adjust y values |
| 566 | 566 | for ( $i = 1; $i < count($points); $i += 2) |
| 567 | - $points[$i] = $this->y($points[$i]); |
|
| 567 | + $points[$i] = $this->y($points[$i]); |
|
| 568 | 568 | |
| 569 | 569 | $this->_pdf->polygon($points, count($points) / 2, $fill); |
| 570 | - } |
|
| 570 | + } |
|
| 571 | 571 | |
| 572 | - //........................................................................ |
|
| 572 | + //........................................................................ |
|
| 573 | 573 | |
| 574 | - function circle($x, $y, $r1, $color, $width = null, $style = null, |
|
| 575 | - $fill = false, $blend = "Normal", $opacity = 1.0) { |
|
| 574 | + function circle($x, $y, $r1, $color, $width = null, $style = null, |
|
| 575 | + $fill = false, $blend = "Normal", $opacity = 1.0) { |
|
| 576 | 576 | |
| 577 | 577 | $this->_set_fill_color($color); |
| 578 | 578 | $this->_set_stroke_color($color); |
@@ -581,14 +581,14 @@ discard block |
||
| 581 | 581 | $this->_set_fill_transparency($blend, $opacity); |
| 582 | 582 | |
| 583 | 583 | if ( !$fill && isset($width) ) |
| 584 | - $this->_set_line_style($width, "round", "round", $style); |
|
| 584 | + $this->_set_line_style($width, "round", "round", $style); |
|
| 585 | 585 | |
| 586 | 586 | $this->_pdf->ellipse($x, $this->y($y), $r1, 0, 0, 8, 0, 360, 1, $fill); |
| 587 | - } |
|
| 587 | + } |
|
| 588 | 588 | |
| 589 | - //........................................................................ |
|
| 589 | + //........................................................................ |
|
| 590 | 590 | |
| 591 | - function image($img_url, $img_type, $x, $y, $w, $h) { |
|
| 591 | + function image($img_url, $img_type, $x, $y, $w, $h) { |
|
| 592 | 592 | //debugpng |
| 593 | 593 | if (DEBUGPNG) print '[image:'.$img_url.'|'.$img_type.']'; |
| 594 | 594 | |
@@ -600,15 +600,15 @@ discard block |
||
| 600 | 600 | //debugpng |
| 601 | 601 | if (DEBUGPNG) print '!!!jpg!!!'; |
| 602 | 602 | |
| 603 | - $this->_pdf->addJpegFromFile($img_url, $x, $this->y($y) - $h, $w, $h); |
|
| 604 | - break; |
|
| 603 | + $this->_pdf->addJpegFromFile($img_url, $x, $this->y($y) - $h, $w, $h); |
|
| 604 | + break; |
|
| 605 | 605 | |
| 606 | 606 | case "png": |
| 607 | 607 | //debugpng |
| 608 | 608 | if (DEBUGPNG) print '!!!png!!!'; |
| 609 | 609 | |
| 610 | - $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h); |
|
| 611 | - break; |
|
| 610 | + $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h); |
|
| 611 | + break; |
|
| 612 | 612 | |
| 613 | 613 | case "gif": |
| 614 | 614 | // Convert gifs to pngs |
@@ -618,41 +618,41 @@ discard block |
||
| 618 | 618 | //debugpng |
| 619 | 619 | if (DEBUGPNG) print '!!!gif addImagePng!!!'; |
| 620 | 620 | |
| 621 | - //If optimization to direct png creation from gd object is available, |
|
| 621 | + //If optimization to direct png creation from gd object is available, |
|
| 622 | 622 | //don't create temp file, but place gd object directly into the pdf |
| 623 | - if ( method_exists( $this->_pdf, "image_iscached" ) && |
|
| 624 | - $this->_pdf->image_iscached($img_url) ) { |
|
| 625 | - //If same image has occured already before, no need to load because |
|
| 626 | - //duplicate will anyway be eliminated. |
|
| 627 | - $img = null; |
|
| 628 | - } else { |
|
| 629 | - $img = @imagecreatefromgif($img_url); |
|
| 630 | - if (!$img) { |
|
| 631 | - return; |
|
| 632 | - } |
|
| 633 | - imageinterlace($img, 0); |
|
| 634 | - } |
|
| 635 | - $this->_pdf->addImagePng($img_url, $x, $this->y($y) - $h, $w, $h, $img); |
|
| 636 | - } else { |
|
| 623 | + if ( method_exists( $this->_pdf, "image_iscached" ) && |
|
| 624 | + $this->_pdf->image_iscached($img_url) ) { |
|
| 625 | + //If same image has occured already before, no need to load because |
|
| 626 | + //duplicate will anyway be eliminated. |
|
| 627 | + $img = null; |
|
| 628 | + } else { |
|
| 629 | + $img = @imagecreatefromgif($img_url); |
|
| 630 | + if (!$img) { |
|
| 631 | + return; |
|
| 632 | + } |
|
| 633 | + imageinterlace($img, 0); |
|
| 634 | + } |
|
| 635 | + $this->_pdf->addImagePng($img_url, $x, $this->y($y) - $h, $w, $h, $img); |
|
| 636 | + } else { |
|
| 637 | 637 | //debugpng |
| 638 | 638 | if (DEBUGPNG) print '!!!gif addPngFromFile!!!'; |
| 639 | 639 | $img_url = $this->_convert_gif_to_png($img_url); |
| 640 | 640 | $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h); |
| 641 | - } |
|
| 642 | - break; |
|
| 641 | + } |
|
| 642 | + break; |
|
| 643 | 643 | |
| 644 | 644 | default: |
| 645 | 645 | //debugpng |
| 646 | 646 | if (DEBUGPNG) print '!!!unknown!!!'; |
| 647 | - break; |
|
| 647 | + break; |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | return; |
| 651 | - } |
|
| 651 | + } |
|
| 652 | 652 | |
| 653 | - //........................................................................ |
|
| 653 | + //........................................................................ |
|
| 654 | 654 | |
| 655 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), |
|
| 655 | + function text($x, $y, $text, $font, $size, $color = array(0,0,0), |
|
| 656 | 656 | $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0) { |
| 657 | 657 | |
| 658 | 658 | list($r, $g, $b) = $color; |
@@ -693,142 +693,142 @@ discard block |
||
| 693 | 693 | //print '<pre>['.$font.','.$size.','.$this->_pdf->getFontHeight($size).','.$this->_pdf->getFontDescender($size).','.$this->_pdf->fonts[$this->_pdf->currentFont]['FontBBox'][3].','.$this->_pdf->fonts[$this->_pdf->currentFont]['FontBBox'][1].','.$this->_pdf->fonts[$this->_pdf->currentFont]['FontHeightOffset'].','.$this->_pdf->fonts[$this->_pdf->currentFont]['Ascender'].','.$this->_pdf->fonts[$this->_pdf->currentFont]['Descender'].']</pre>'; |
| 694 | 694 | // |
| 695 | 695 | //$this->_pdf->addText($x, $this->y($y) - Font_Metrics::get_font_height($font, $size), $size, $text, $angle, $adjust); |
| 696 | - //$this->_pdf->addText($x, $this->y($y) - $size, $size, $text, $angle, $adjust); |
|
| 697 | - //$this->_pdf->addText($x, $this->y($y) - $this->_pdf->getFontHeight($size)-$this->_pdf->getFontDescender($size), $size, $text, $angle, $adjust); |
|
| 698 | - $this->_pdf->addText($x, $this->y($y) - ($this->_pdf->fonts[$this->_pdf->currentFont]['FontBBox'][3]*$size)/1000, $size, $text, $angle, $adjust); |
|
| 699 | - } |
|
| 696 | + //$this->_pdf->addText($x, $this->y($y) - $size, $size, $text, $angle, $adjust); |
|
| 697 | + //$this->_pdf->addText($x, $this->y($y) - $this->_pdf->getFontHeight($size)-$this->_pdf->getFontDescender($size), $size, $text, $angle, $adjust); |
|
| 698 | + $this->_pdf->addText($x, $this->y($y) - ($this->_pdf->fonts[$this->_pdf->currentFont]['FontBBox'][3]*$size)/1000, $size, $text, $angle, $adjust); |
|
| 699 | + } |
|
| 700 | 700 | |
| 701 | - //........................................................................ |
|
| 701 | + //........................................................................ |
|
| 702 | 702 | |
| 703 | - function javascript($code) { |
|
| 703 | + function javascript($code) { |
|
| 704 | 704 | $this->_pdf->addJavascript($code); |
| 705 | - } |
|
| 705 | + } |
|
| 706 | 706 | |
| 707 | - //........................................................................ |
|
| 707 | + //........................................................................ |
|
| 708 | 708 | |
| 709 | - /** |
|
| 710 | - * Add a named destination (similar to <a name="foo">...</a> in html) |
|
| 711 | - * |
|
| 712 | - * @param string $anchorname The name of the named destination |
|
| 713 | - */ |
|
| 714 | - function add_named_dest($anchorname) { |
|
| 709 | + /** |
|
| 710 | + * Add a named destination (similar to <a name="foo">...</a> in html) |
|
| 711 | + * |
|
| 712 | + * @param string $anchorname The name of the named destination |
|
| 713 | + */ |
|
| 714 | + function add_named_dest($anchorname) { |
|
| 715 | 715 | $this->_pdf->addDestination($anchorname,"Fit"); |
| 716 | - } |
|
| 716 | + } |
|
| 717 | 717 | |
| 718 | - //........................................................................ |
|
| 718 | + //........................................................................ |
|
| 719 | 719 | |
| 720 | - /** |
|
| 721 | - * Add a link to the pdf |
|
| 722 | - * |
|
| 723 | - * @param string $url The url to link to |
|
| 724 | - * @param float $x The x position of the link |
|
| 725 | - * @param float $y The y position of the link |
|
| 726 | - * @param float $width The width of the link |
|
| 727 | - * @param float $height The height of the link |
|
| 728 | - */ |
|
| 729 | - function add_link($url, $x, $y, $width, $height) { |
|
| 720 | + /** |
|
| 721 | + * Add a link to the pdf |
|
| 722 | + * |
|
| 723 | + * @param string $url The url to link to |
|
| 724 | + * @param float $x The x position of the link |
|
| 725 | + * @param float $y The y position of the link |
|
| 726 | + * @param float $width The width of the link |
|
| 727 | + * @param float $height The height of the link |
|
| 728 | + */ |
|
| 729 | + function add_link($url, $x, $y, $width, $height) { |
|
| 730 | 730 | |
| 731 | 731 | $y = $this->y($y) - $height; |
| 732 | 732 | |
| 733 | 733 | if ( strpos($url, '#') === 0 ) { |
| 734 | - // Local link |
|
| 735 | - $name = substr($url,1); |
|
| 736 | - if ( $name ) |
|
| 734 | + // Local link |
|
| 735 | + $name = substr($url,1); |
|
| 736 | + if ( $name ) |
|
| 737 | 737 | $this->_pdf->addInternalLink($name, $x, $y, $x + $width, $y + $height); |
| 738 | 738 | |
| 739 | 739 | } else { |
| 740 | - $this->_pdf->addLink(rawurldecode($url), $x, $y, $x + $width, $y + $height); |
|
| 740 | + $this->_pdf->addLink(rawurldecode($url), $x, $y, $x + $width, $y + $height); |
|
| 741 | 741 | } |
| 742 | 742 | |
| 743 | - } |
|
| 743 | + } |
|
| 744 | 744 | |
| 745 | - //........................................................................ |
|
| 745 | + //........................................................................ |
|
| 746 | 746 | |
| 747 | - function get_text_width($text, $font, $size, $spacing = 0) { |
|
| 747 | + function get_text_width($text, $font, $size, $spacing = 0) { |
|
| 748 | 748 | $this->_pdf->selectFont($font); |
| 749 | 749 | if (!DOMPDF_UNICODE_ENABLED) { |
| 750 | - $text = mb_convert_encoding($text, 'Windows-1252', 'UTF-8'); |
|
| 750 | + $text = mb_convert_encoding($text, 'Windows-1252', 'UTF-8'); |
|
| 751 | 751 | } |
| 752 | 752 | return $this->_pdf->getTextWidth($size, $text, $spacing); |
| 753 | - } |
|
| 753 | + } |
|
| 754 | 754 | |
| 755 | - //........................................................................ |
|
| 755 | + //........................................................................ |
|
| 756 | 756 | |
| 757 | - function get_font_height($font, $size) { |
|
| 757 | + function get_font_height($font, $size) { |
|
| 758 | 758 | $this->_pdf->selectFont($font); |
| 759 | 759 | return $this->_pdf->getFontHeight($size); |
| 760 | - } |
|
| 760 | + } |
|
| 761 | 761 | |
| 762 | - //........................................................................ |
|
| 762 | + //........................................................................ |
|
| 763 | 763 | |
| 764 | - /** |
|
| 765 | - * Writes text at the specified x and y coordinates on every page |
|
| 766 | - * |
|
| 767 | - * The strings '{PAGE_NUM}' and '{PAGE_COUNT}' are automatically replaced |
|
| 768 | - * with their current values. |
|
| 769 | - * |
|
| 770 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
| 771 | - * |
|
| 772 | - * @param float $x |
|
| 773 | - * @param float $y |
|
| 774 | - * @param string $text the text to write |
|
| 775 | - * @param string $font the font file to use |
|
| 776 | - * @param float $size the font size, in points |
|
| 777 | - * @param array $color |
|
| 778 | - * @param float $adjust word spacing adjustment |
|
| 779 | - * @param float $angle angle to write the text at, measured CW starting from the x-axis |
|
| 780 | - */ |
|
| 781 | - function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), |
|
| 782 | - $adjust = 0, $angle = 0) { |
|
| 764 | + /** |
|
| 765 | + * Writes text at the specified x and y coordinates on every page |
|
| 766 | + * |
|
| 767 | + * The strings '{PAGE_NUM}' and '{PAGE_COUNT}' are automatically replaced |
|
| 768 | + * with their current values. |
|
| 769 | + * |
|
| 770 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
| 771 | + * |
|
| 772 | + * @param float $x |
|
| 773 | + * @param float $y |
|
| 774 | + * @param string $text the text to write |
|
| 775 | + * @param string $font the font file to use |
|
| 776 | + * @param float $size the font size, in points |
|
| 777 | + * @param array $color |
|
| 778 | + * @param float $adjust word spacing adjustment |
|
| 779 | + * @param float $angle angle to write the text at, measured CW starting from the x-axis |
|
| 780 | + */ |
|
| 781 | + function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), |
|
| 782 | + $adjust = 0, $angle = 0) { |
|
| 783 | 783 | $_t = "text"; |
| 784 | 784 | $this->_page_text[] = compact("_t", "x", "y", "text", "font", "size", "color", "adjust", "angle"); |
| 785 | - } |
|
| 785 | + } |
|
| 786 | 786 | |
| 787 | - //........................................................................ |
|
| 787 | + //........................................................................ |
|
| 788 | 788 | |
| 789 | - /** |
|
| 790 | - * Processes a script on every page |
|
| 791 | - * |
|
| 792 | - * The variables $pdf, $PAGE_NUM, and $PAGE_COUNT are available. |
|
| 793 | - * |
|
| 794 | - * This function can be used to add page numbers to all pages |
|
| 795 | - * after the first one, for example. |
|
| 796 | - * |
|
| 797 | - * @param string $code the script code |
|
| 798 | - * @param string $type the language type for script |
|
| 799 | - */ |
|
| 800 | - function page_script($code, $type = "text/php") { |
|
| 789 | + /** |
|
| 790 | + * Processes a script on every page |
|
| 791 | + * |
|
| 792 | + * The variables $pdf, $PAGE_NUM, and $PAGE_COUNT are available. |
|
| 793 | + * |
|
| 794 | + * This function can be used to add page numbers to all pages |
|
| 795 | + * after the first one, for example. |
|
| 796 | + * |
|
| 797 | + * @param string $code the script code |
|
| 798 | + * @param string $type the language type for script |
|
| 799 | + */ |
|
| 800 | + function page_script($code, $type = "text/php") { |
|
| 801 | 801 | $_t = "script"; |
| 802 | 802 | $this->_page_text[] = compact("_t", "code", "type"); |
| 803 | - } |
|
| 803 | + } |
|
| 804 | 804 | |
| 805 | - //........................................................................ |
|
| 805 | + //........................................................................ |
|
| 806 | 806 | |
| 807 | - function new_page() { |
|
| 807 | + function new_page() { |
|
| 808 | 808 | $this->_page_count++; |
| 809 | 809 | |
| 810 | 810 | $ret = $this->_pdf->newPage(); |
| 811 | 811 | $this->_pages[] = $ret; |
| 812 | 812 | return $ret; |
| 813 | - } |
|
| 813 | + } |
|
| 814 | 814 | |
| 815 | - //........................................................................ |
|
| 815 | + //........................................................................ |
|
| 816 | 816 | |
| 817 | - /** |
|
| 818 | - * Add text to each page after rendering is complete |
|
| 819 | - */ |
|
| 820 | - protected function _add_page_text() { |
|
| 817 | + /** |
|
| 818 | + * Add text to each page after rendering is complete |
|
| 819 | + */ |
|
| 820 | + protected function _add_page_text() { |
|
| 821 | 821 | |
| 822 | 822 | if ( !count($this->_page_text) ) |
| 823 | - return; |
|
| 823 | + return; |
|
| 824 | 824 | |
| 825 | 825 | $page_number = 1; |
| 826 | 826 | $eval = null; |
| 827 | 827 | |
| 828 | 828 | foreach ($this->_pages as $pid) { |
| 829 | - $this->reopen_object($pid); |
|
| 829 | + $this->reopen_object($pid); |
|
| 830 | 830 | |
| 831 | - foreach ($this->_page_text as $pt) { |
|
| 831 | + foreach ($this->_page_text as $pt) { |
|
| 832 | 832 | extract($pt); |
| 833 | 833 | |
| 834 | 834 | switch ($_t) { |
@@ -837,63 +837,63 @@ discard block |
||
| 837 | 837 | $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"), |
| 838 | 838 | array($page_number, $this->_page_count), $text); |
| 839 | 839 | $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
| 840 | - break; |
|
| 840 | + break; |
|
| 841 | 841 | |
| 842 | 842 | case "script": |
| 843 | 843 | if (!$eval) { |
| 844 | 844 | $eval = new PHP_Evaluator($this); |
| 845 | - } |
|
| 846 | - $eval->evaluate($code, array('PAGE_NUM' => $page_number, 'PAGE_COUNT' => $this->_page_count)); |
|
| 847 | - break; |
|
| 845 | + } |
|
| 846 | + $eval->evaluate($code, array('PAGE_NUM' => $page_number, 'PAGE_COUNT' => $this->_page_count)); |
|
| 847 | + break; |
|
| 848 | + } |
|
| 848 | 849 | } |
| 849 | - } |
|
| 850 | 850 | |
| 851 | - $this->close_object(); |
|
| 852 | - $page_number++; |
|
| 851 | + $this->close_object(); |
|
| 852 | + $page_number++; |
|
| 853 | + } |
|
| 853 | 854 | } |
| 854 | - } |
|
| 855 | 855 | |
| 856 | - /** |
|
| 857 | - * Streams the PDF directly to the browser |
|
| 858 | - * |
|
| 859 | - * @param string $filename the name of the PDF file |
|
| 860 | - * @param array $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0 |
|
| 861 | - */ |
|
| 862 | - function stream($filename, $options = null) { |
|
| 856 | + /** |
|
| 857 | + * Streams the PDF directly to the browser |
|
| 858 | + * |
|
| 859 | + * @param string $filename the name of the PDF file |
|
| 860 | + * @param array $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0 |
|
| 861 | + */ |
|
| 862 | + function stream($filename, $options = null) { |
|
| 863 | 863 | // Add page text |
| 864 | 864 | $this->_add_page_text(); |
| 865 | 865 | |
| 866 | 866 | $options["Content-Disposition"] = $filename; |
| 867 | 867 | $this->_pdf->stream($options); |
| 868 | - } |
|
| 868 | + } |
|
| 869 | 869 | |
| 870 | - //........................................................................ |
|
| 870 | + //........................................................................ |
|
| 871 | 871 | |
| 872 | - /** |
|
| 873 | - * Returns the PDF as a string |
|
| 874 | - * |
|
| 875 | - * @return string |
|
| 876 | - */ |
|
| 877 | - function output($options = null) { |
|
| 872 | + /** |
|
| 873 | + * Returns the PDF as a string |
|
| 874 | + * |
|
| 875 | + * @return string |
|
| 876 | + */ |
|
| 877 | + function output($options = null) { |
|
| 878 | 878 | // Add page text |
| 879 | 879 | $this->_add_page_text(); |
| 880 | 880 | |
| 881 | 881 | if ( isset($options["compress"]) && $options["compress"] != 1 ) |
| 882 | - $debug = 1; |
|
| 882 | + $debug = 1; |
|
| 883 | 883 | else |
| 884 | - $debug = 0; |
|
| 884 | + $debug = 0; |
|
| 885 | 885 | |
| 886 | 886 | return $this->_pdf->output($debug); |
| 887 | 887 | |
| 888 | - } |
|
| 888 | + } |
|
| 889 | 889 | |
| 890 | - //........................................................................ |
|
| 891 | - |
|
| 892 | - /** |
|
| 893 | - * Returns logging messages generated by the Cpdf class |
|
| 894 | - * |
|
| 895 | - * @return string |
|
| 896 | - */ |
|
| 897 | - function get_messages() { return $this->_pdf->messages; } |
|
| 890 | + //........................................................................ |
|
| 891 | + |
|
| 892 | + /** |
|
| 893 | + * Returns logging messages generated by the Cpdf class |
|
| 894 | + * |
|
| 895 | + * @return string |
|
| 896 | + */ |
|
| 897 | + function get_messages() { return $this->_pdf->messages; } |
|
| 898 | 898 | |
| 899 | 899 | } |
@@ -190,6 +190,9 @@ |
||
| 190 | 190 | "yellowgreen" => "9ACD32", |
| 191 | 191 | ); |
| 192 | 192 | |
| 193 | + /** |
|
| 194 | + * @param string $colour |
|
| 195 | + */ |
|
| 193 | 196 | static function parse($colour) {
|
| 194 | 197 | if ( is_array($colour) ) |
| 195 | 198 | // Assume the array has the right format... |