@@ -11,10 +11,10 @@ discard block |
||
11 | 11 | $from_myspace = false; |
12 | 12 | $from_link = ''; |
13 | 13 | if (isset($_GET['from']) && $_GET['from'] == 'myspace') { |
14 | - $from_link = '&from=myspace'; |
|
15 | - $this_section = SECTION_TRACKING; |
|
14 | + $from_link = '&from=myspace'; |
|
15 | + $this_section = SECTION_TRACKING; |
|
16 | 16 | } else { |
17 | - $this_section = SECTION_COURSES; |
|
17 | + $this_section = SECTION_COURSES; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | $session_id = isset($_REQUEST['id_session']) && !empty($_REQUEST['id_session']) ? intval($_REQUEST['id_session']) : api_get_session_id(); |
@@ -35,19 +35,19 @@ discard block |
||
35 | 35 | if (!api_is_platform_admin(true) && |
36 | 36 | !CourseManager :: is_course_teacher(api_get_user_id(), $courseCode) && |
37 | 37 | !Tracking :: is_allowed_to_coach_student(api_get_user_id(), $user_id) && !api_is_drh() && !api_is_course_tutor()) { |
38 | - api_not_allowed(); |
|
38 | + api_not_allowed(); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | if ($origin == 'user_course') { |
42 | - $interbreadcrumb[] = array ("url" => api_get_path(WEB_COURSE_PATH).$course_info['directory'], 'name' => $course_info['name']); |
|
43 | - $interbreadcrumb[] = array ("url" => "../user/user.php?cidReq=".$courseCode, "name" => get_lang("Users")); |
|
42 | + $interbreadcrumb[] = array ("url" => api_get_path(WEB_COURSE_PATH).$course_info['directory'], 'name' => $course_info['name']); |
|
43 | + $interbreadcrumb[] = array ("url" => "../user/user.php?cidReq=".$courseCode, "name" => get_lang("Users")); |
|
44 | 44 | } else if($origin == 'tracking_course') { |
45 | - $interbreadcrumb[] = array ("url" => "../tracking/courseLog.php?cidReq=".$courseCode.'&id_session='.$session_id, "name" => get_lang("Tracking")); |
|
45 | + $interbreadcrumb[] = array ("url" => "../tracking/courseLog.php?cidReq=".$courseCode.'&id_session='.$session_id, "name" => get_lang("Tracking")); |
|
46 | 46 | } else { |
47 | - $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace')); |
|
48 | - $interbreadcrumb[] = array ("url" => "student.php", "name" => get_lang("MyStudents")); |
|
49 | - $interbreadcrumb[] = array ("url" => "myStudents.php?student=".$user_id, "name" => get_lang("StudentDetails")); |
|
50 | - $nameTools=get_lang("DetailsStudentInCourse"); |
|
47 | + $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace')); |
|
48 | + $interbreadcrumb[] = array ("url" => "student.php", "name" => get_lang("MyStudents")); |
|
49 | + $interbreadcrumb[] = array ("url" => "myStudents.php?student=".$user_id, "name" => get_lang("StudentDetails")); |
|
50 | + $nameTools=get_lang("DetailsStudentInCourse"); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | $interbreadcrumb[] = array("url" => "myStudents.php?student=".$user_id."&course=".$courseCode."&details=true&origin=".$origin , "name" => get_lang("DetailsStudentInCourse")); |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | # |
101 | 101 | if (!function_exists('xml_parser_create')) { |
102 | 102 | $this->error( "Failed to load PHP's XML Extension. " . |
103 | - "http://www.php.net/manual/en/ref.xml.php", |
|
104 | - E_USER_ERROR ); |
|
103 | + "http://www.php.net/manual/en/ref.xml.php", |
|
104 | + E_USER_ERROR ); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | list($parser, $source) = $this->create_parser($source, |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | |
111 | 111 | if (!is_resource($parser)) { |
112 | 112 | $this->error( "Failed to create an instance of PHP's XML parser. " . |
113 | - "http://www.php.net/manual/en/ref.xml.php", |
|
114 | - E_USER_ERROR ); |
|
113 | + "http://www.php.net/manual/en/ref.xml.php", |
|
114 | + E_USER_ERROR ); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
@@ -447,9 +447,9 @@ discard block |
||
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
450 | - * return XML parser, and possibly re-encoded source |
|
451 | - * |
|
452 | - */ |
|
450 | + * return XML parser, and possibly re-encoded source |
|
451 | + * |
|
452 | + */ |
|
453 | 453 | public function create_parser($source, $out_enc, $in_enc, $detect) { |
454 | 454 | if ( substr(phpversion(),0,1) == 5) { |
455 | 455 | $parser = $this->php5_create_parser($in_enc, $detect); |
@@ -466,14 +466,14 @@ discard block |
||
466 | 466 | } |
467 | 467 | |
468 | 468 | /** |
469 | - * Instantiate an XML parser under PHP5 |
|
470 | - * |
|
471 | - * PHP5 will do a fine job of detecting input encoding |
|
472 | - * if passed an empty string as the encoding. |
|
473 | - * |
|
474 | - * All hail libxml2! |
|
475 | - * |
|
476 | - */ |
|
469 | + * Instantiate an XML parser under PHP5 |
|
470 | + * |
|
471 | + * PHP5 will do a fine job of detecting input encoding |
|
472 | + * if passed an empty string as the encoding. |
|
473 | + * |
|
474 | + * All hail libxml2! |
|
475 | + * |
|
476 | + */ |
|
477 | 477 | public function php5_create_parser($in_enc, $detect) { |
478 | 478 | // by default php5 does a fine job of detecting input encodings |
479 | 479 | if(!$detect && $in_enc) { |
@@ -485,20 +485,20 @@ discard block |
||
485 | 485 | } |
486 | 486 | |
487 | 487 | /** |
488 | - * Instaniate an XML parser under PHP4 |
|
489 | - * |
|
490 | - * Unfortunately PHP4's support for character encodings |
|
491 | - * and especially XML and character encodings sucks. As |
|
492 | - * long as the documents you parse only contain characters |
|
493 | - * from the ISO-8859-1 character set (a superset of ASCII, |
|
494 | - * and a subset of UTF-8) you're fine. However once you |
|
495 | - * step out of that comfy little world things get mad, bad, |
|
496 | - * and dangerous to know. |
|
497 | - * |
|
498 | - * The following code is based on SJM's work with FoF |
|
499 | - * @see http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss |
|
500 | - * |
|
501 | - */ |
|
488 | + * Instaniate an XML parser under PHP4 |
|
489 | + * |
|
490 | + * Unfortunately PHP4's support for character encodings |
|
491 | + * and especially XML and character encodings sucks. As |
|
492 | + * long as the documents you parse only contain characters |
|
493 | + * from the ISO-8859-1 character set (a superset of ASCII, |
|
494 | + * and a subset of UTF-8) you're fine. However once you |
|
495 | + * step out of that comfy little world things get mad, bad, |
|
496 | + * and dangerous to know. |
|
497 | + * |
|
498 | + * The following code is based on SJM's work with FoF |
|
499 | + * @see http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss |
|
500 | + * |
|
501 | + */ |
|
502 | 502 | public function php4_create_parser($source, $in_enc, $detect) { |
503 | 503 | if ( !$detect ) { |
504 | 504 | return array(xml_parser_create($in_enc), $source); |
@@ -542,8 +542,8 @@ discard block |
||
542 | 542 | |
543 | 543 | // else |
544 | 544 | $this->error("Feed is in an unsupported character encoding. ($in_enc) " . |
545 | - "You may see strange artifacts, and mangled characters.", |
|
546 | - E_USER_NOTICE); |
|
545 | + "You may see strange artifacts, and mangled characters.", |
|
546 | + E_USER_NOTICE); |
|
547 | 547 | |
548 | 548 | return array(xml_parser_create(), $source); |
549 | 549 | } |
@@ -589,17 +589,17 @@ discard block |
||
589 | 589 | // courtesy, Ryan Currie, [email protected] |
590 | 590 | |
591 | 591 | if (!function_exists('array_change_key_case')) { |
592 | - define("CASE_UPPER",1); |
|
593 | - define("CASE_LOWER",0); |
|
592 | + define("CASE_UPPER",1); |
|
593 | + define("CASE_LOWER",0); |
|
594 | 594 | |
595 | 595 | |
596 | - function array_change_key_case($array,$case=CASE_LOWER) { |
|
597 | - if ($case=CASE_LOWER) $cmd=strtolower; |
|
598 | - elseif ($case=CASE_UPPER) $cmd=strtoupper; |
|
599 | - foreach($array as $key=>$value) { |
|
600 | - $output[$cmd($key)]=$value; |
|
601 | - } |
|
602 | - return $output; |
|
603 | - } |
|
596 | + function array_change_key_case($array,$case=CASE_LOWER) { |
|
597 | + if ($case=CASE_LOWER) $cmd=strtolower; |
|
598 | + elseif ($case=CASE_UPPER) $cmd=strtoupper; |
|
599 | + foreach($array as $key=>$value) { |
|
600 | + $output[$cmd($key)]=$value; |
|
601 | + } |
|
602 | + return $output; |
|
603 | + } |
|
604 | 604 | |
605 | 605 | } |
@@ -47,199 +47,199 @@ |
||
47 | 47 | * @version $Revision: 822448 $ |
48 | 48 | * @package log4php |
49 | 49 | */ |
50 | - /* |
|
50 | + /* |
|
51 | 51 | * TODO: |
52 | 52 | * - addHierarchyEventListener($listener) not supported |
53 | 53 | * - emitNoAppenderWarning($cat) not supported |
54 | 54 | * - fireAddAppenderEvent not supported |
55 | 55 | */ |
56 | 56 | class LoggerHierarchy { |
57 | - /** Default Factory */ |
|
58 | - protected $defaultFactory; |
|
57 | + /** Default Factory */ |
|
58 | + protected $defaultFactory; |
|
59 | 59 | |
60 | - /** array hierarchy tree. saves here all loggers */ |
|
61 | - protected $ht = array(); |
|
60 | + /** array hierarchy tree. saves here all loggers */ |
|
61 | + protected $ht = array(); |
|
62 | 62 | |
63 | - /** The root Logger */ |
|
64 | - protected $root = null; |
|
63 | + /** The root Logger */ |
|
64 | + protected $root = null; |
|
65 | 65 | |
66 | - /** LoggerRendererMap */ |
|
67 | - protected $rendererMap; |
|
66 | + /** LoggerRendererMap */ |
|
67 | + protected $rendererMap; |
|
68 | 68 | |
69 | - /** LoggerLevel main level threshold */ |
|
70 | - protected $threshold; |
|
69 | + /** LoggerLevel main level threshold */ |
|
70 | + protected $threshold; |
|
71 | 71 | |
72 | - /** |
|
73 | - * Create a new logger hierarchy. |
|
74 | - * @param object $root the root logger |
|
75 | - */ |
|
76 | - public function __construct(LoggerRoot $root) { |
|
77 | - $this->root = $root; |
|
78 | - $this->setThreshold(LoggerLevel::getLevelAll()); |
|
79 | - $this->rendererMap = new LoggerRendererMap(); |
|
80 | - } |
|
72 | + /** |
|
73 | + * Create a new logger hierarchy. |
|
74 | + * @param object $root the root logger |
|
75 | + */ |
|
76 | + public function __construct(LoggerRoot $root) { |
|
77 | + $this->root = $root; |
|
78 | + $this->setThreshold(LoggerLevel::getLevelAll()); |
|
79 | + $this->rendererMap = new LoggerRendererMap(); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * This call will clear all logger definitions from the internal hashtable. |
|
84 | - */ |
|
85 | - public function clear() { |
|
86 | - $this->ht = array(); |
|
87 | - } |
|
82 | + /** |
|
83 | + * This call will clear all logger definitions from the internal hashtable. |
|
84 | + */ |
|
85 | + public function clear() { |
|
86 | + $this->ht = array(); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Check if the named logger exists in the hierarchy. |
|
91 | - * @param string $name |
|
92 | - * @return boolean |
|
93 | - */ |
|
94 | - public function exists($name) { |
|
95 | - return isset($this->ht[$name]); |
|
96 | - } |
|
89 | + /** |
|
90 | + * Check if the named logger exists in the hierarchy. |
|
91 | + * @param string $name |
|
92 | + * @return boolean |
|
93 | + */ |
|
94 | + public function exists($name) { |
|
95 | + return isset($this->ht[$name]); |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * Returns all the currently defined categories in this hierarchy as an array. |
|
100 | - * @return array |
|
101 | - */ |
|
102 | - public function getCurrentLoggers() { |
|
103 | - return array_values($this->ht); |
|
104 | - } |
|
98 | + /** |
|
99 | + * Returns all the currently defined categories in this hierarchy as an array. |
|
100 | + * @return array |
|
101 | + */ |
|
102 | + public function getCurrentLoggers() { |
|
103 | + return array_values($this->ht); |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Return a new logger instance named as the first parameter using the default factory. |
|
108 | - * |
|
109 | - * @param string $name logger name |
|
110 | - * @param LoggerFactory $factory a {@link LoggerFactory} instance or null |
|
111 | - * @return Logger |
|
112 | - */ |
|
113 | - public function getLogger($name) { |
|
114 | - if(!isset($this->ht[$name])) { |
|
115 | - $this->ht[$name] = new Logger($name);; |
|
116 | - // TODO: isn't necessary, access via singleton? |
|
117 | - // $this->ht[$name]->setHierarchy($this); |
|
118 | - $nodes = explode('.', $name); |
|
119 | - $firstNode = array_shift($nodes); |
|
106 | + /** |
|
107 | + * Return a new logger instance named as the first parameter using the default factory. |
|
108 | + * |
|
109 | + * @param string $name logger name |
|
110 | + * @param LoggerFactory $factory a {@link LoggerFactory} instance or null |
|
111 | + * @return Logger |
|
112 | + */ |
|
113 | + public function getLogger($name) { |
|
114 | + if(!isset($this->ht[$name])) { |
|
115 | + $this->ht[$name] = new Logger($name);; |
|
116 | + // TODO: isn't necessary, access via singleton? |
|
117 | + // $this->ht[$name]->setHierarchy($this); |
|
118 | + $nodes = explode('.', $name); |
|
119 | + $firstNode = array_shift($nodes); |
|
120 | 120 | |
121 | - // if name is not a first node but another first node is their |
|
122 | - if($firstNode != $name and isset($this->ht[$firstNode])) { |
|
123 | - $this->ht[$name]->setParent($this->ht[$firstNode]); |
|
124 | - } else { |
|
125 | - // if there is no father, set root logger as father |
|
126 | - $this->ht[$name]->setParent($this->root); |
|
127 | - } |
|
121 | + // if name is not a first node but another first node is their |
|
122 | + if($firstNode != $name and isset($this->ht[$firstNode])) { |
|
123 | + $this->ht[$name]->setParent($this->ht[$firstNode]); |
|
124 | + } else { |
|
125 | + // if there is no father, set root logger as father |
|
126 | + $this->ht[$name]->setParent($this->root); |
|
127 | + } |
|
128 | 128 | |
129 | - // if there are more nodes than one |
|
130 | - if(count($nodes) > 0) { |
|
131 | - // find parent node |
|
132 | - foreach($nodes as $node) { |
|
133 | - $parentNode = "$firstNode.$node"; |
|
134 | - if(isset($this->ht[$parentNode]) and $parentNode != $name) { |
|
129 | + // if there are more nodes than one |
|
130 | + if(count($nodes) > 0) { |
|
131 | + // find parent node |
|
132 | + foreach($nodes as $node) { |
|
133 | + $parentNode = "$firstNode.$node"; |
|
134 | + if(isset($this->ht[$parentNode]) and $parentNode != $name) { |
|
135 | 135 | |
136 | - $this->ht[$name]->setParent($this->ht[$parentNode]); |
|
137 | - } |
|
138 | - $firstNode .= ".$node"; |
|
139 | - } |
|
140 | - } |
|
141 | - } |
|
136 | + $this->ht[$name]->setParent($this->ht[$parentNode]); |
|
137 | + } |
|
138 | + $firstNode .= ".$node"; |
|
139 | + } |
|
140 | + } |
|
141 | + } |
|
142 | 142 | |
143 | - return $this->ht[$name]; |
|
144 | - } |
|
143 | + return $this->ht[$name]; |
|
144 | + } |
|
145 | 145 | |
146 | - /** |
|
147 | - * @return LoggerRendererMap Get the renderer map for this hierarchy. |
|
148 | - */ |
|
149 | - public function getRendererMap() { |
|
150 | - return $this->rendererMap; |
|
151 | - } |
|
146 | + /** |
|
147 | + * @return LoggerRendererMap Get the renderer map for this hierarchy. |
|
148 | + */ |
|
149 | + public function getRendererMap() { |
|
150 | + return $this->rendererMap; |
|
151 | + } |
|
152 | 152 | |
153 | - /** |
|
154 | - * @return LoggerRoot Get the root of this hierarchy. |
|
155 | - */ |
|
156 | - public function getRootLogger() { |
|
157 | - if(!isset($this->root) or $this->root == null) { |
|
158 | - $this->root = new LoggerRoot(); |
|
159 | - } |
|
160 | - return $this->root; |
|
161 | - } |
|
153 | + /** |
|
154 | + * @return LoggerRoot Get the root of this hierarchy. |
|
155 | + */ |
|
156 | + public function getRootLogger() { |
|
157 | + if(!isset($this->root) or $this->root == null) { |
|
158 | + $this->root = new LoggerRoot(); |
|
159 | + } |
|
160 | + return $this->root; |
|
161 | + } |
|
162 | 162 | |
163 | - /** |
|
164 | - * @return LoggerLevel Returns the threshold Level. |
|
165 | - */ |
|
166 | - public function getThreshold() { |
|
167 | - return $this->threshold; |
|
168 | - } |
|
163 | + /** |
|
164 | + * @return LoggerLevel Returns the threshold Level. |
|
165 | + */ |
|
166 | + public function getThreshold() { |
|
167 | + return $this->threshold; |
|
168 | + } |
|
169 | 169 | |
170 | - /** |
|
171 | - * This method will return true if this repository is disabled |
|
172 | - * for level object passed as parameter and false otherwise. |
|
173 | - * @return boolean |
|
174 | - */ |
|
175 | - public function isDisabled(LoggerLevel $level) { |
|
176 | - return ($this->threshold->toInt() > $level->toInt()); |
|
177 | - } |
|
170 | + /** |
|
171 | + * This method will return true if this repository is disabled |
|
172 | + * for level object passed as parameter and false otherwise. |
|
173 | + * @return boolean |
|
174 | + */ |
|
175 | + public function isDisabled(LoggerLevel $level) { |
|
176 | + return ($this->threshold->toInt() > $level->toInt()); |
|
177 | + } |
|
178 | 178 | |
179 | - /** |
|
180 | - * Reset all values contained in this hierarchy instance to their |
|
181 | - * default. |
|
182 | - * |
|
183 | - * This removes all appenders from all categories, sets |
|
184 | - * the level of all non-root categories to <i>null</i>, |
|
185 | - * sets their additivity flag to <i>true</i> and sets the level |
|
186 | - * of the root logger to {@link LOGGER_LEVEL_DEBUG}. Moreover, |
|
187 | - * message disabling is set its default "off" value. |
|
188 | - * |
|
189 | - * <p>Existing categories are not removed. They are just reset. |
|
190 | - * |
|
191 | - * <p>This method should be used sparingly and with care as it will |
|
192 | - * block all logging until it is completed.</p> |
|
193 | - */ |
|
194 | - public function resetConfiguration() { |
|
195 | - $root = $this->getRootLogger(); |
|
179 | + /** |
|
180 | + * Reset all values contained in this hierarchy instance to their |
|
181 | + * default. |
|
182 | + * |
|
183 | + * This removes all appenders from all categories, sets |
|
184 | + * the level of all non-root categories to <i>null</i>, |
|
185 | + * sets their additivity flag to <i>true</i> and sets the level |
|
186 | + * of the root logger to {@link LOGGER_LEVEL_DEBUG}. Moreover, |
|
187 | + * message disabling is set its default "off" value. |
|
188 | + * |
|
189 | + * <p>Existing categories are not removed. They are just reset. |
|
190 | + * |
|
191 | + * <p>This method should be used sparingly and with care as it will |
|
192 | + * block all logging until it is completed.</p> |
|
193 | + */ |
|
194 | + public function resetConfiguration() { |
|
195 | + $root = $this->getRootLogger(); |
|
196 | 196 | |
197 | - $root->setLevel(LoggerLevel::getLevelDebug()); |
|
198 | - $this->setThreshold(LoggerLevel::getLevelAll()); |
|
199 | - $this->shutDown(); |
|
200 | - $loggers = $this->getCurrentLoggers(); |
|
201 | - $enumLoggers = count($loggers); |
|
202 | - for($i = 0; $i < $enumLoggers; $i++) { |
|
203 | - $loggers[$i]->setLevel(null); |
|
204 | - $loggers[$i]->setAdditivity(true); |
|
205 | - $loggers[$i]->removeAllAppenders(); |
|
206 | - } |
|
207 | - $this->rendererMap->clear(); |
|
208 | - } |
|
197 | + $root->setLevel(LoggerLevel::getLevelDebug()); |
|
198 | + $this->setThreshold(LoggerLevel::getLevelAll()); |
|
199 | + $this->shutDown(); |
|
200 | + $loggers = $this->getCurrentLoggers(); |
|
201 | + $enumLoggers = count($loggers); |
|
202 | + for($i = 0; $i < $enumLoggers; $i++) { |
|
203 | + $loggers[$i]->setLevel(null); |
|
204 | + $loggers[$i]->setAdditivity(true); |
|
205 | + $loggers[$i]->removeAllAppenders(); |
|
206 | + } |
|
207 | + $this->rendererMap->clear(); |
|
208 | + } |
|
209 | 209 | |
210 | - /** |
|
211 | - * set a new threshold level |
|
212 | - * |
|
213 | - * @param LoggerLevel $l |
|
214 | - */ |
|
215 | - public function setThreshold(LoggerLevel $l) { |
|
216 | - if($l !== null) { |
|
217 | - $this->threshold = $l; |
|
218 | - } |
|
219 | - } |
|
210 | + /** |
|
211 | + * set a new threshold level |
|
212 | + * |
|
213 | + * @param LoggerLevel $l |
|
214 | + */ |
|
215 | + public function setThreshold(LoggerLevel $l) { |
|
216 | + if($l !== null) { |
|
217 | + $this->threshold = $l; |
|
218 | + } |
|
219 | + } |
|
220 | 220 | |
221 | - /** |
|
222 | - * Shutting down a hierarchy will <i>safely</i> close and remove |
|
223 | - * all appenders in all categories including the root logger. |
|
224 | - * |
|
225 | - * <p>Some appenders such as {@link LoggerSocketAppender} |
|
226 | - * need to be closed before the |
|
227 | - * application exists. Otherwise, pending logging events might be |
|
228 | - * lost. |
|
229 | - * |
|
230 | - * <p>The shutdown method is careful to close nested |
|
231 | - * appenders before closing regular appenders. This is allows |
|
232 | - * configurations where a regular appender is attached to a logger |
|
233 | - * and again to a nested appender. |
|
234 | - */ |
|
235 | - public function shutdown() { |
|
236 | - $this->root->removeAllAppenders(); |
|
237 | - $cats = $this->getCurrentLoggers(); |
|
238 | - $enumCats = count($cats); |
|
239 | - if($enumCats > 0) { |
|
240 | - for($i = 0; $i < $enumCats; $i++) { |
|
241 | - $cats[$i]->removeAllAppenders(); |
|
242 | - } |
|
243 | - } |
|
244 | - } |
|
221 | + /** |
|
222 | + * Shutting down a hierarchy will <i>safely</i> close and remove |
|
223 | + * all appenders in all categories including the root logger. |
|
224 | + * |
|
225 | + * <p>Some appenders such as {@link LoggerSocketAppender} |
|
226 | + * need to be closed before the |
|
227 | + * application exists. Otherwise, pending logging events might be |
|
228 | + * lost. |
|
229 | + * |
|
230 | + * <p>The shutdown method is careful to close nested |
|
231 | + * appenders before closing regular appenders. This is allows |
|
232 | + * configurations where a regular appender is attached to a logger |
|
233 | + * and again to a nested appender. |
|
234 | + */ |
|
235 | + public function shutdown() { |
|
236 | + $this->root->removeAllAppenders(); |
|
237 | + $cats = $this->getCurrentLoggers(); |
|
238 | + $enumCats = count($cats); |
|
239 | + if($enumCats > 0) { |
|
240 | + for($i = 0; $i < $enumCats; $i++) { |
|
241 | + $cats[$i]->removeAllAppenders(); |
|
242 | + } |
|
243 | + } |
|
244 | + } |
|
245 | 245 | } |
@@ -38,97 +38,97 @@ |
||
38 | 38 | */ |
39 | 39 | class LoggerConfiguratorPhp implements LoggerConfigurator { |
40 | 40 | |
41 | - public function configure(LoggerHierarchy $hierarchy, $url = '') { |
|
42 | - return $this->doConfigure($url, $hierarchy); |
|
43 | - } |
|
41 | + public function configure(LoggerHierarchy $hierarchy, $url = '') { |
|
42 | + return $this->doConfigure($url, $hierarchy); |
|
43 | + } |
|
44 | 44 | |
45 | - private function doConfigure($url, LoggerHierarchy $hierarchy) { |
|
45 | + private function doConfigure($url, LoggerHierarchy $hierarchy) { |
|
46 | 46 | |
47 | - $config = require $url; |
|
47 | + $config = require $url; |
|
48 | 48 | |
49 | - // set threshold |
|
50 | - if(isset($config['threshold'])) { |
|
51 | - $hierarchy->setThreshold(LoggerOptionConverter::toLevel($config['threshold'], LoggerLevel::getLevelAll())); |
|
52 | - } |
|
49 | + // set threshold |
|
50 | + if(isset($config['threshold'])) { |
|
51 | + $hierarchy->setThreshold(LoggerOptionConverter::toLevel($config['threshold'], LoggerLevel::getLevelAll())); |
|
52 | + } |
|
53 | 53 | |
54 | - // parse and create appenders |
|
55 | - if(isset($config['appenders'])) { |
|
54 | + // parse and create appenders |
|
55 | + if(isset($config['appenders'])) { |
|
56 | 56 | |
57 | - foreach($config['appenders'] as $appenderName => $appenderProperties) { |
|
57 | + foreach($config['appenders'] as $appenderName => $appenderProperties) { |
|
58 | 58 | |
59 | - $appender = LoggerAppenderPool::getAppenderFromPool($appenderName, $appenderProperties['class']); |
|
59 | + $appender = LoggerAppenderPool::getAppenderFromPool($appenderName, $appenderProperties['class']); |
|
60 | 60 | |
61 | - if($appender->requiresLayout()) { |
|
61 | + if($appender->requiresLayout()) { |
|
62 | 62 | |
63 | - if(isset($appenderProperties['layout'])) { |
|
63 | + if(isset($appenderProperties['layout'])) { |
|
64 | 64 | |
65 | - if(isset($appenderProperties['layout']['class']) and !empty($appenderProperties['layout']['class'])) { |
|
66 | - $layoutClass = $appenderProperties['layout']['class']; |
|
67 | - } else { |
|
68 | - $layoutClass = 'LoggerLayoutSimple'; |
|
69 | - } |
|
65 | + if(isset($appenderProperties['layout']['class']) and !empty($appenderProperties['layout']['class'])) { |
|
66 | + $layoutClass = $appenderProperties['layout']['class']; |
|
67 | + } else { |
|
68 | + $layoutClass = 'LoggerLayoutSimple'; |
|
69 | + } |
|
70 | 70 | |
71 | - $layout = LoggerReflectionUtils::createObject($layoutClass); |
|
72 | - if($layout === null) { |
|
73 | - $layout = LoggerReflectionUtils::createObject('LoggerLayoutSimple'); |
|
74 | - } |
|
71 | + $layout = LoggerReflectionUtils::createObject($layoutClass); |
|
72 | + if($layout === null) { |
|
73 | + $layout = LoggerReflectionUtils::createObject('LoggerLayoutSimple'); |
|
74 | + } |
|
75 | 75 | |
76 | - if($layout instanceof LoggerLayoutPattern) { |
|
77 | - $layout->setConversionPattern($appenderProperties['layout']['conversionPattern']); |
|
78 | - } |
|
76 | + if($layout instanceof LoggerLayoutPattern) { |
|
77 | + $layout->setConversionPattern($appenderProperties['layout']['conversionPattern']); |
|
78 | + } |
|
79 | 79 | |
80 | - $appender->setLayout($layout); |
|
80 | + $appender->setLayout($layout); |
|
81 | 81 | |
82 | - } else { |
|
83 | - // TODO: throw exception? |
|
84 | - } |
|
82 | + } else { |
|
83 | + // TODO: throw exception? |
|
84 | + } |
|
85 | 85 | |
86 | - } |
|
86 | + } |
|
87 | 87 | |
88 | - } |
|
88 | + } |
|
89 | 89 | |
90 | - } |
|
90 | + } |
|
91 | 91 | |
92 | - // parse and create root logger |
|
93 | - if(isset($config['rootLogger'])) { |
|
94 | - $rootLogger = $hierarchy->getRootLogger(); |
|
95 | - if(isset($config['rootLogger']['level'])) { |
|
96 | - $rootLogger->setLevel(LoggerOptionConverter::toLevel($config['rootLogger']['level'], LoggerLevel::getLevelDebug())); |
|
97 | - if(isset($config['rootLogger']['appenders'])) { |
|
98 | - foreach($config['rootLogger']['appenders'] as $appenderName) { |
|
99 | - $appender = LoggerAppenderPool::getAppenderFromPool($appenderName); |
|
100 | - if($appender !== null) { |
|
101 | - $rootLogger->addAppender($appender); |
|
102 | - } |
|
103 | - } |
|
104 | - } |
|
105 | - } |
|
106 | - } |
|
92 | + // parse and create root logger |
|
93 | + if(isset($config['rootLogger'])) { |
|
94 | + $rootLogger = $hierarchy->getRootLogger(); |
|
95 | + if(isset($config['rootLogger']['level'])) { |
|
96 | + $rootLogger->setLevel(LoggerOptionConverter::toLevel($config['rootLogger']['level'], LoggerLevel::getLevelDebug())); |
|
97 | + if(isset($config['rootLogger']['appenders'])) { |
|
98 | + foreach($config['rootLogger']['appenders'] as $appenderName) { |
|
99 | + $appender = LoggerAppenderPool::getAppenderFromPool($appenderName); |
|
100 | + if($appender !== null) { |
|
101 | + $rootLogger->addAppender($appender); |
|
102 | + } |
|
103 | + } |
|
104 | + } |
|
105 | + } |
|
106 | + } |
|
107 | 107 | |
108 | - // parse and create loggers |
|
109 | - if(isset($config['loggers'])) { |
|
110 | - foreach($config['loggers'] as $loggerName => $loggerProperties) { |
|
111 | - if(is_string($loggerName)) { |
|
112 | - $logger = $hierarchy->getLogger($loggerName); |
|
108 | + // parse and create loggers |
|
109 | + if(isset($config['loggers'])) { |
|
110 | + foreach($config['loggers'] as $loggerName => $loggerProperties) { |
|
111 | + if(is_string($loggerName)) { |
|
112 | + $logger = $hierarchy->getLogger($loggerName); |
|
113 | 113 | |
114 | - if(isset($loggerProperties['level'])) { |
|
115 | - $logger->setLevel(LoggerOptionConverter::toLevel($loggerProperties['level'], LoggerLevel::getLevelDebug())); |
|
116 | - if(isset($loggerProperties['appenders'])) { |
|
117 | - foreach($loggerProperties['appenders'] as $appenderName) { |
|
118 | - $appender = LoggerAppenderPool::getAppenderFromPool($appenderName); |
|
119 | - if($appender !== null) { |
|
120 | - $logger->addAppender($appender); |
|
121 | - } |
|
122 | - } |
|
123 | - } |
|
124 | - } |
|
125 | - } else { |
|
126 | - // TODO: throw exception |
|
127 | - } |
|
128 | - } |
|
129 | - } |
|
114 | + if(isset($loggerProperties['level'])) { |
|
115 | + $logger->setLevel(LoggerOptionConverter::toLevel($loggerProperties['level'], LoggerLevel::getLevelDebug())); |
|
116 | + if(isset($loggerProperties['appenders'])) { |
|
117 | + foreach($loggerProperties['appenders'] as $appenderName) { |
|
118 | + $appender = LoggerAppenderPool::getAppenderFromPool($appenderName); |
|
119 | + if($appender !== null) { |
|
120 | + $logger->addAppender($appender); |
|
121 | + } |
|
122 | + } |
|
123 | + } |
|
124 | + } |
|
125 | + } else { |
|
126 | + // TODO: throw exception |
|
127 | + } |
|
128 | + } |
|
129 | + } |
|
130 | 130 | |
131 | - return true; |
|
132 | - } |
|
131 | + return true; |
|
132 | + } |
|
133 | 133 | |
134 | 134 | } |
@@ -26,12 +26,12 @@ discard block |
||
26 | 26 | * @subpackage helpers |
27 | 27 | */ |
28 | 28 | $GLOBALS['log4php.LoggerPatternConverter.spaces'] = array( |
29 | - " ", // 1 space |
|
30 | - " ", // 2 spaces |
|
31 | - " ", // 4 spaces |
|
32 | - " ", // 8 spaces |
|
33 | - " ", // 16 spaces |
|
34 | - " " ); // 32 spaces |
|
29 | + " ", // 1 space |
|
30 | + " ", // 2 spaces |
|
31 | + " ", // 4 spaces |
|
32 | + " ", // 8 spaces |
|
33 | + " ", // 16 spaces |
|
34 | + " " ); // 32 spaces |
|
35 | 35 | |
36 | 36 | |
37 | 37 | /** |
@@ -50,89 +50,89 @@ discard block |
||
50 | 50 | */ |
51 | 51 | class LoggerPatternConverter { |
52 | 52 | |
53 | - /** |
|
54 | - * @var LoggerPatternConverter next converter in converter chain |
|
55 | - */ |
|
56 | - public $next = null; |
|
53 | + /** |
|
54 | + * @var LoggerPatternConverter next converter in converter chain |
|
55 | + */ |
|
56 | + public $next = null; |
|
57 | 57 | |
58 | - public $min = -1; |
|
59 | - public $max = 0x7FFFFFFF; |
|
60 | - public $leftAlign = false; |
|
58 | + public $min = -1; |
|
59 | + public $max = 0x7FFFFFFF; |
|
60 | + public $leftAlign = false; |
|
61 | 61 | |
62 | - /** |
|
63 | - * Constructor |
|
64 | - * |
|
65 | - * @param LoggerFormattingInfo $fi |
|
66 | - */ |
|
67 | - public function __construct($fi = null) { |
|
68 | - if($fi !== null) { |
|
69 | - $this->min = $fi->min; |
|
70 | - $this->max = $fi->max; |
|
71 | - $this->leftAlign = $fi->leftAlign; |
|
72 | - } |
|
73 | - } |
|
62 | + /** |
|
63 | + * Constructor |
|
64 | + * |
|
65 | + * @param LoggerFormattingInfo $fi |
|
66 | + */ |
|
67 | + public function __construct($fi = null) { |
|
68 | + if($fi !== null) { |
|
69 | + $this->min = $fi->min; |
|
70 | + $this->max = $fi->max; |
|
71 | + $this->leftAlign = $fi->leftAlign; |
|
72 | + } |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Derived pattern converters must override this method in order to |
|
77 | - * convert conversion specifiers in the correct way. |
|
78 | - * |
|
79 | - * @param LoggerLoggingEvent $event |
|
80 | - */ |
|
81 | - public function convert($event) {} |
|
75 | + /** |
|
76 | + * Derived pattern converters must override this method in order to |
|
77 | + * convert conversion specifiers in the correct way. |
|
78 | + * |
|
79 | + * @param LoggerLoggingEvent $event |
|
80 | + */ |
|
81 | + public function convert($event) {} |
|
82 | 82 | |
83 | - /** |
|
84 | - * A template method for formatting in a converter specific way. |
|
85 | - * |
|
86 | - * @param string &$sbuf string buffer |
|
87 | - * @param LoggerLoggingEvent $e |
|
88 | - */ |
|
89 | - public function format(&$sbuf, $e) { |
|
90 | - $s = $this->convert($e); |
|
83 | + /** |
|
84 | + * A template method for formatting in a converter specific way. |
|
85 | + * |
|
86 | + * @param string &$sbuf string buffer |
|
87 | + * @param LoggerLoggingEvent $e |
|
88 | + */ |
|
89 | + public function format(&$sbuf, $e) { |
|
90 | + $s = $this->convert($e); |
|
91 | 91 | |
92 | - if($s == null or empty($s)) { |
|
93 | - if(0 < $this->min) { |
|
94 | - $this->spacePad($sbuf, $this->min); |
|
95 | - } |
|
96 | - return; |
|
97 | - } |
|
92 | + if($s == null or empty($s)) { |
|
93 | + if(0 < $this->min) { |
|
94 | + $this->spacePad($sbuf, $this->min); |
|
95 | + } |
|
96 | + return; |
|
97 | + } |
|
98 | 98 | |
99 | - $len = strlen($s); |
|
99 | + $len = strlen($s); |
|
100 | 100 | |
101 | - if($len > $this->max) { |
|
102 | - $sbuf .= substr($s , 0, ($len - $this->max)); |
|
103 | - } else if($len < $this->min) { |
|
104 | - if($this->leftAlign) { |
|
105 | - $sbuf .= $s; |
|
106 | - $this->spacePad($sbuf, ($this->min - $len)); |
|
107 | - } else { |
|
108 | - $this->spacePad($sbuf, ($this->min - $len)); |
|
109 | - $sbuf .= $s; |
|
110 | - } |
|
111 | - } else { |
|
112 | - $sbuf .= $s; |
|
113 | - } |
|
114 | - } |
|
101 | + if($len > $this->max) { |
|
102 | + $sbuf .= substr($s , 0, ($len - $this->max)); |
|
103 | + } else if($len < $this->min) { |
|
104 | + if($this->leftAlign) { |
|
105 | + $sbuf .= $s; |
|
106 | + $this->spacePad($sbuf, ($this->min - $len)); |
|
107 | + } else { |
|
108 | + $this->spacePad($sbuf, ($this->min - $len)); |
|
109 | + $sbuf .= $s; |
|
110 | + } |
|
111 | + } else { |
|
112 | + $sbuf .= $s; |
|
113 | + } |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * Fast space padding method. |
|
118 | - * |
|
119 | - * @param string $sbuf string buffer |
|
120 | - * @param integer $length pad length |
|
121 | - * |
|
122 | - * @todo reimplement using PHP string functions |
|
123 | - */ |
|
124 | - public function spacePad($sbuf, $length) { |
|
125 | - while($length >= 32) { |
|
126 | - $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][5]; |
|
127 | - $length -= 32; |
|
128 | - } |
|
116 | + /** |
|
117 | + * Fast space padding method. |
|
118 | + * |
|
119 | + * @param string $sbuf string buffer |
|
120 | + * @param integer $length pad length |
|
121 | + * |
|
122 | + * @todo reimplement using PHP string functions |
|
123 | + */ |
|
124 | + public function spacePad($sbuf, $length) { |
|
125 | + while($length >= 32) { |
|
126 | + $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][5]; |
|
127 | + $length -= 32; |
|
128 | + } |
|
129 | 129 | |
130 | - for($i = 4; $i >= 0; $i--) { |
|
131 | - if(($length & (1<<$i)) != 0) { |
|
132 | - $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][$i]; |
|
133 | - } |
|
134 | - } |
|
130 | + for($i = 4; $i >= 0; $i--) { |
|
131 | + if(($length & (1<<$i)) != 0) { |
|
132 | + $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][$i]; |
|
133 | + } |
|
134 | + } |
|
135 | 135 | |
136 | - // $sbuf = str_pad($sbuf, $length); |
|
137 | - } |
|
136 | + // $sbuf = str_pad($sbuf, $length); |
|
137 | + } |
|
138 | 138 | } |
@@ -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: table_row_group_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,11 +46,11 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Table_Row_Group_Frame_Reflower extends Frame_Reflower { |
49 | 48 | |
50 | - function __construct($frame) { |
|
49 | + function __construct($frame) { |
|
51 | 50 | parent::__construct($frame); |
52 | - } |
|
51 | + } |
|
53 | 52 | |
54 | - function reflow() { |
|
53 | + function reflow() { |
|
55 | 54 | $page = $this->_frame->get_root(); |
56 | 55 | |
57 | 56 | $style = $this->_frame->get_style(); |
@@ -62,20 +61,20 @@ discard block |
||
62 | 61 | $cb = $this->_frame->get_containing_block(); |
63 | 62 | |
64 | 63 | foreach ( $this->_frame->get_children() as $child) { |
65 | - // Bail if the page is full |
|
66 | - if ( $page->is_full() ) |
|
64 | + // Bail if the page is full |
|
65 | + if ( $page->is_full() ) |
|
67 | 66 | return; |
68 | 67 | |
69 | - $child->set_containing_block($cb["x"], $cb["y"], $cb["w"], $cb["h"]); |
|
70 | - $child->reflow(); |
|
68 | + $child->set_containing_block($cb["x"], $cb["y"], $cb["w"], $cb["h"]); |
|
69 | + $child->reflow(); |
|
71 | 70 | |
72 | - // Check if a split has occured |
|
73 | - $page->check_page_break($child); |
|
71 | + // Check if a split has occured |
|
72 | + $page->check_page_break($child); |
|
74 | 73 | |
75 | 74 | } |
76 | 75 | |
77 | 76 | if ( $page->is_full() ) |
78 | - return; |
|
77 | + return; |
|
79 | 78 | |
80 | 79 | $cellmap = $table->get_cellmap(); |
81 | 80 | $style->width = $cellmap->get_frame_width($this->_frame); |
@@ -84,9 +83,9 @@ discard block |
||
84 | 83 | $this->_frame->set_position($cellmap->get_frame_position($this->_frame)); |
85 | 84 | |
86 | 85 | if ( $table->get_style()->border_collapse === "collapse" ) |
87 | - // Unset our borders because our cells are now using them |
|
88 | - $style->border_style = "none"; |
|
86 | + // Unset our borders because our cells are now using them |
|
87 | + $style->border_style = "none"; |
|
89 | 88 | |
90 | - } |
|
89 | + } |
|
91 | 90 | |
92 | 91 | } |
@@ -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: null_positioner.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,10 +46,10 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Null_Positioner extends Positioner { |
49 | 48 | |
50 | - function __construct(Frame_Decorator $frame) { |
|
49 | + function __construct(Frame_Decorator $frame) { |
|
51 | 50 | parent::__construct($frame); |
52 | - } |
|
51 | + } |
|
53 | 52 | |
54 | - function position() { return; } |
|
53 | + function position() { return; } |
|
55 | 54 | |
56 | 55 | } |
@@ -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: inline_renderer.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,13 +46,13 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Inline_Renderer extends Abstract_Renderer { |
49 | 48 | |
50 | - //........................................................................ |
|
49 | + //........................................................................ |
|
51 | 50 | |
52 | - function render(Frame $frame) { |
|
51 | + function render(Frame $frame) { |
|
53 | 52 | $style = $frame->get_style(); |
54 | 53 | |
55 | 54 | if ( !$frame->get_first_child() ) |
56 | - return; // No children, no service |
|
55 | + return; // No children, no service |
|
57 | 56 | |
58 | 57 | // Draw the left border if applicable |
59 | 58 | $bp = $style->get_border_properties(); |
@@ -73,10 +72,10 @@ discard block |
||
73 | 72 | $first_row = true; |
74 | 73 | |
75 | 74 | foreach ($frame->get_children() as $child) { |
76 | - list($child_x, $child_y, $child_w, $child_h) = $child->get_padding_box(); |
|
77 | - $child_h += $widths[2]; |
|
75 | + list($child_x, $child_y, $child_w, $child_h) = $child->get_padding_box(); |
|
76 | + $child_h += $widths[2]; |
|
78 | 77 | |
79 | - if ( !is_null($w) && $child_x < $x + $w ) { |
|
78 | + if ( !is_null($w) && $child_x < $x + $w ) { |
|
80 | 79 | //This branch seems to be supposed to being called on the first part |
81 | 80 | //of an inline html element, and the part after the if clause for the |
82 | 81 | //parts after a line break. |
@@ -88,37 +87,37 @@ discard block |
||
88 | 87 | |
89 | 88 | // Background: |
90 | 89 | if ( ($bg = $style->background_color) !== "transparent" ) |
91 | - $this->_canvas->filled_rectangle( $x, $y, $w, $h, $style->background_color); |
|
90 | + $this->_canvas->filled_rectangle( $x, $y, $w, $h, $style->background_color); |
|
92 | 91 | |
93 | 92 | if ( ($url = $style->background_image) && $url !== "none" ) { |
94 | - $this->_background_image($url, $x, $y, $w, $h, $style); |
|
93 | + $this->_background_image($url, $x, $y, $w, $h, $style); |
|
95 | 94 | } |
96 | 95 | |
97 | 96 | // If this is the first row, draw the left border |
98 | 97 | if ( $first_row ) { |
99 | 98 | |
100 | - if ( $bp["left"]["style"] !== "none" && $bp["left"]["width"] > 0 ) { |
|
99 | + if ( $bp["left"]["style"] !== "none" && $bp["left"]["width"] > 0 ) { |
|
101 | 100 | $method = "_border_" . $bp["left"]["style"]; |
102 | 101 | $this->$method($x, $y, $h + $widths[0] + $widths[2], $bp["left"]["color"], $widths, "left"); |
103 | - } |
|
104 | - $first_row = false; |
|
102 | + } |
|
103 | + $first_row = false; |
|
105 | 104 | } |
106 | 105 | |
107 | 106 | // Draw the top & bottom borders |
108 | 107 | if ( $bp["top"]["style"] !== "none" && $bp["top"]["width"] > 0 ) { |
109 | - $method = "_border_" . $bp["top"]["style"]; |
|
110 | - $this->$method($x, $y, $w + $widths[1] + $widths[3], $bp["top"]["color"], $widths, "top"); |
|
108 | + $method = "_border_" . $bp["top"]["style"]; |
|
109 | + $this->$method($x, $y, $w + $widths[1] + $widths[3], $bp["top"]["color"], $widths, "top"); |
|
111 | 110 | } |
112 | 111 | |
113 | 112 | if ( $bp["bottom"]["style"] !== "none" && $bp["bottom"]["width"] > 0 ) { |
114 | - $method = "_border_" . $bp["bottom"]["style"]; |
|
115 | - $this->$method($x, $y + $h + $widths[0] + $widths[2], $w + $widths[1] + $widths[3], $bp["bottom"]["color"], $widths, "bottom"); |
|
113 | + $method = "_border_" . $bp["bottom"]["style"]; |
|
114 | + $this->$method($x, $y + $h + $widths[0] + $widths[2], $w + $widths[1] + $widths[3], $bp["bottom"]["color"], $widths, "bottom"); |
|
116 | 115 | } |
117 | 116 | |
118 | 117 | // Handle anchors & links |
119 | 118 | if ( $frame->get_node()->nodeName === "a" ) { |
120 | 119 | |
121 | - if ( $href = $frame->get_node()->getAttribute("href") ) |
|
120 | + if ( $href = $frame->get_node()->getAttribute("href") ) |
|
122 | 121 | $this->_canvas->add_link($href, $x, $y, $w, $h); |
123 | 122 | |
124 | 123 | } |
@@ -128,20 +127,20 @@ discard block |
||
128 | 127 | $w = $child_w; |
129 | 128 | $h = $child_h; |
130 | 129 | continue; |
131 | - } |
|
130 | + } |
|
132 | 131 | |
133 | - if ( is_null($w) ) |
|
132 | + if ( is_null($w) ) |
|
134 | 133 | $w = $child_w; |
135 | - else |
|
134 | + else |
|
136 | 135 | $w += $child_w; |
137 | 136 | |
138 | - $h = max($h, $child_h); |
|
137 | + $h = max($h, $child_h); |
|
139 | 138 | } |
140 | 139 | |
141 | 140 | |
142 | 141 | // Handle the last child |
143 | 142 | if ( ($bg = $style->background_color) !== "transparent" ) |
144 | - $this->_canvas->filled_rectangle( $x + $widths[3], $y + $widths[0], $w, $h, $style->background_color); |
|
143 | + $this->_canvas->filled_rectangle( $x + $widths[3], $y + $widths[0], $w, $h, $style->background_color); |
|
145 | 144 | |
146 | 145 | //On continuation lines (after line break) of inline elements, the style got copied. |
147 | 146 | //But a non repeatable background image should not be repeated on the next line. |
@@ -152,7 +151,7 @@ discard block |
||
152 | 151 | // ... && (!($repeat = $style->background_repeat) || $repeat === "repeat" ... |
153 | 152 | //different position? $this->_background_image($url, $x, $y, $w, $h, $style); |
154 | 153 | if ( ($url = $style->background_image) && $url !== "none" ) |
155 | - $this->_background_image($url, $x + $widths[3], $y + $widths[0], $w, $h, $style); |
|
154 | + $this->_background_image($url, $x + $widths[3], $y + $widths[0], $w, $h, $style); |
|
156 | 155 | |
157 | 156 | // Add the border widths |
158 | 157 | $w += $widths[1] + $widths[3]; |
@@ -164,37 +163,37 @@ discard block |
||
164 | 163 | |
165 | 164 | // If this is the first row, draw the left border too |
166 | 165 | if ( $first_row && $bp["left"]["style"] !== "none" && $widths[3] > 0 ) { |
167 | - $method = "_border_" . $bp["left"]["style"]; |
|
168 | - $this->$method($x, $y, $h, $bp["left"]["color"], $widths, "left"); |
|
166 | + $method = "_border_" . $bp["left"]["style"]; |
|
167 | + $this->$method($x, $y, $h, $bp["left"]["color"], $widths, "left"); |
|
169 | 168 | } |
170 | 169 | |
171 | 170 | // Draw the top & bottom borders |
172 | 171 | if ( $bp["top"]["style"] !== "none" && $widths[0] > 0 ) { |
173 | - $method = "_border_" . $bp["top"]["style"]; |
|
174 | - $this->$method($x, $y, $w, $bp["top"]["color"], $widths, "top"); |
|
172 | + $method = "_border_" . $bp["top"]["style"]; |
|
173 | + $this->$method($x, $y, $w, $bp["top"]["color"], $widths, "top"); |
|
175 | 174 | } |
176 | 175 | |
177 | 176 | if ( $bp["bottom"]["style"] !== "none" && $widths[2] > 0 ) { |
178 | - $method = "_border_" . $bp["bottom"]["style"]; |
|
179 | - $this->$method($x, $y + $h, $w, $bp["bottom"]["color"], $widths, "bottom"); |
|
177 | + $method = "_border_" . $bp["bottom"]["style"]; |
|
178 | + $this->$method($x, $y + $h, $w, $bp["bottom"]["color"], $widths, "bottom"); |
|
180 | 179 | } |
181 | 180 | |
182 | 181 | // pre_var_dump(get_class($frame->get_next_sibling())); |
183 | 182 | // $last_row = get_class($frame->get_next_sibling()) !== 'Inline_Frame_Decorator'; |
184 | 183 | // Draw the right border if this is the last row |
185 | 184 | if ( $bp["right"]["style"] !== "none" && $widths[1] > 0 ) { |
186 | - $method = "_border_" . $bp["right"]["style"]; |
|
187 | - $this->$method($x + $w, $y, $h, $bp["right"]["color"], $widths, "right"); |
|
185 | + $method = "_border_" . $bp["right"]["style"]; |
|
186 | + $this->$method($x + $w, $y, $h, $bp["right"]["color"], $widths, "right"); |
|
188 | 187 | } |
189 | 188 | |
190 | 189 | // Handle anchors & links |
191 | 190 | if ( $frame->get_node()->nodeName === "a" ) { |
192 | 191 | |
193 | - if ( $name = $frame->get_node()->getAttribute("name") ) |
|
192 | + if ( $name = $frame->get_node()->getAttribute("name") ) |
|
194 | 193 | $this->_canvas->add_named_dest($name); |
195 | 194 | |
196 | - if ( $href = $frame->get_node()->getAttribute("href") ) |
|
195 | + if ( $href = $frame->get_node()->getAttribute("href") ) |
|
197 | 196 | $this->_canvas->add_link($href, $x, $y, $w, $h); |
198 | 197 | } |
199 | - } |
|
198 | + } |
|
200 | 199 | } |
@@ -61,25 +61,25 @@ discard block |
||
61 | 61 | */ |
62 | 62 | class Image_Cache { |
63 | 63 | |
64 | - /** |
|
65 | - * Array of downloaded images. Cached so that identical images are |
|
66 | - * not needlessly downloaded. |
|
67 | - * |
|
68 | - * @var array |
|
69 | - */ |
|
70 | - static protected $_cache = array(); |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * Resolve and fetch an image for use. |
|
75 | - * |
|
76 | - * @param string $url The url of the image |
|
77 | - * @param string $proto Default protocol if none specified in $url |
|
78 | - * @param string $host Default host if none specified in $url |
|
79 | - * @param string $base_path Default path if none specified in $url |
|
80 | - * @return array An array with two elements: The local path to the image and the image extension |
|
81 | - */ |
|
82 | - static function resolve_url($url, $proto, $host, $base_path) { |
|
64 | + /** |
|
65 | + * Array of downloaded images. Cached so that identical images are |
|
66 | + * not needlessly downloaded. |
|
67 | + * |
|
68 | + * @var array |
|
69 | + */ |
|
70 | + static protected $_cache = array(); |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * Resolve and fetch an image for use. |
|
75 | + * |
|
76 | + * @param string $url The url of the image |
|
77 | + * @param string $proto Default protocol if none specified in $url |
|
78 | + * @param string $host Default host if none specified in $url |
|
79 | + * @param string $base_path Default path if none specified in $url |
|
80 | + * @return array An array with two elements: The local path to the image and the image extension |
|
81 | + */ |
|
82 | + static function resolve_url($url, $proto, $host, $base_path) { |
|
83 | 83 | global $_dompdf_warnings; |
84 | 84 | |
85 | 85 | $parsed_url = explode_url($url); |
@@ -94,23 +94,23 @@ discard block |
||
94 | 94 | $remote = $remote || ($parsed_url['protocol'] != ""); |
95 | 95 | |
96 | 96 | if ( !DOMPDF_ENABLE_REMOTE && $remote ) { |
97 | - $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
98 | - $ext = "png"; |
|
97 | + $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
98 | + $ext = "png"; |
|
99 | 99 | |
100 | - //debugpng |
|
101 | - if ($DEBUGPNG) $full_url_dbg = '(blockedremote)'; |
|
100 | + //debugpng |
|
101 | + if ($DEBUGPNG) $full_url_dbg = '(blockedremote)'; |
|
102 | 102 | |
103 | 103 | } else if ( DOMPDF_ENABLE_REMOTE && $remote ) { |
104 | - // Download remote files to a temporary directory |
|
105 | - $full_url = build_url($proto, $host, $base_path, $url); |
|
104 | + // Download remote files to a temporary directory |
|
105 | + $full_url = build_url($proto, $host, $base_path, $url); |
|
106 | 106 | |
107 | - if ( isset(self::$_cache[$full_url]) ) { |
|
107 | + if ( isset(self::$_cache[$full_url]) ) { |
|
108 | 108 | list($resolved_url,$ext) = self::$_cache[$full_url]; |
109 | 109 | |
110 | 110 | //debugpng |
111 | 111 | if ($DEBUGPNG) $full_url_dbg = $full_url.'(cache)'; |
112 | 112 | |
113 | - } else { |
|
113 | + } else { |
|
114 | 114 | |
115 | 115 | $resolved_url = tempnam(DOMPDF_TEMP_DIR, "ca_dompdf_img_"); |
116 | 116 | //debugpng |
@@ -121,21 +121,21 @@ discard block |
||
121 | 121 | restore_error_handler(); |
122 | 122 | |
123 | 123 | if ( strlen($image) == 0 ) { |
124 | - //target image not found |
|
125 | - $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
126 | - $ext = "png"; |
|
124 | + //target image not found |
|
125 | + $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
126 | + $ext = "png"; |
|
127 | 127 | |
128 | - //debugpng |
|
129 | - if ($DEBUGPNG) $full_url_dbg = $full_url.'(missing)'; |
|
128 | + //debugpng |
|
129 | + if ($DEBUGPNG) $full_url_dbg = $full_url.'(missing)'; |
|
130 | 130 | |
131 | 131 | } else { |
132 | 132 | |
133 | 133 | file_put_contents($resolved_url, $image); |
134 | 134 | |
135 | - //e.g. fetch.php?media=url.jpg&cache=1 |
|
136 | - //- Image file name might be one of the dynamic parts of the url, don't strip off! |
|
137 | - // if ( preg_match("/.*\.(\w+)/",$url,$match) ) $ext = $match[1]; |
|
138 | - //- a remote url does not need to have a file extension at all |
|
135 | + //e.g. fetch.php?media=url.jpg&cache=1 |
|
136 | + //- Image file name might be one of the dynamic parts of the url, don't strip off! |
|
137 | + // if ( preg_match("/.*\.(\w+)/",$url,$match) ) $ext = $match[1]; |
|
138 | + //- a remote url does not need to have a file extension at all |
|
139 | 139 | //- local cached file does not have a matching file extension |
140 | 140 | //Therefore get image type from the content |
141 | 141 | |
@@ -146,33 +146,33 @@ discard block |
||
146 | 146 | $imagetypes = array('','gif','jpeg','png','swf'); |
147 | 147 | $ext = $imagetypes[$imagedim[2]]; |
148 | 148 | if ( rename($resolved_url,$resolved_url.'.'.$ext) ) { |
149 | - $resolved_url .= '.'.$ext; |
|
149 | + $resolved_url .= '.'.$ext; |
|
150 | 150 | } |
151 | 151 | |
152 | - //Don't put replacement image into cache - otherwise it will be deleted on cache cleanup. |
|
153 | - //Only execute on successfull caching of remote image. |
|
152 | + //Don't put replacement image into cache - otherwise it will be deleted on cache cleanup. |
|
153 | + //Only execute on successfull caching of remote image. |
|
154 | 154 | self::$_cache[$full_url] = array($resolved_url,$ext); |
155 | 155 | |
156 | 156 | } else { |
157 | - //target image is not valid. |
|
158 | - unlink($resolved_url); |
|
157 | + //target image is not valid. |
|
158 | + unlink($resolved_url); |
|
159 | 159 | |
160 | - $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
161 | - $ext = "png"; |
|
160 | + $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
161 | + $ext = "png"; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | - } |
|
165 | + } |
|
166 | 166 | |
167 | 167 | } else { |
168 | 168 | |
169 | - $resolved_url = build_url($proto, $host, $base_path, $url); |
|
170 | - if ($DEBUGPNG) print 'build_url('.$proto.','.$host.','.$base_path.','.$url.')('.$resolved_url.')'; |
|
169 | + $resolved_url = build_url($proto, $host, $base_path, $url); |
|
170 | + if ($DEBUGPNG) print 'build_url('.$proto.','.$host.','.$base_path.','.$url.')('.$resolved_url.')'; |
|
171 | 171 | |
172 | - if ( !preg_match("/.*\.(\w+)/",$url,$match) ) { |
|
172 | + if ( !preg_match("/.*\.(\w+)/",$url,$match) ) { |
|
173 | 173 | //debugpng |
174 | 174 | if ($DEBUGPNG) print '[resolve_url exception '.$url.']'; |
175 | - throw new DOMPDF_Exception("Unknown image type: $url."); |
|
175 | + throw new DOMPDF_Exception("Unknown image type: $url."); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | $ext = $match[1]; |
@@ -184,35 +184,35 @@ discard block |
||
184 | 184 | |
185 | 185 | if ( !is_readable($resolved_url) || !filesize($resolved_url) ) { |
186 | 186 | |
187 | - //debugpng |
|
188 | - if ($DEBUGPNG) $full_url_dbg .= '(nocache'.$resolved_url.')'; |
|
187 | + //debugpng |
|
188 | + if ($DEBUGPNG) $full_url_dbg .= '(nocache'.$resolved_url.')'; |
|
189 | 189 | |
190 | - $_dompdf_warnings[] = "File " .$resolved_url . " is not readable or is an empty file.\n"; |
|
191 | - $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
192 | - $ext = "png"; |
|
190 | + $_dompdf_warnings[] = "File " .$resolved_url . " is not readable or is an empty file.\n"; |
|
191 | + $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
192 | + $ext = "png"; |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | //debugpng |
196 | 196 | if ($DEBUGPNG) print '[resolve_url '.$url.'|'.$full_url_dbg.'|'.$resolved_url.'|'.$ext.']'; |
197 | 197 | |
198 | 198 | return array($resolved_url, $ext); |
199 | - } |
|
199 | + } |
|
200 | 200 | |
201 | - /** |
|
202 | - * Unlink all cached images (i.e. temporary images either downloaded |
|
203 | - * or converted) |
|
204 | - */ |
|
205 | - static function clear() { |
|
201 | + /** |
|
202 | + * Unlink all cached images (i.e. temporary images either downloaded |
|
203 | + * or converted) |
|
204 | + */ |
|
205 | + static function clear() { |
|
206 | 206 | if ( count(self::$_cache) ) { |
207 | - while ($entry = array_shift(self::$_cache)) { |
|
207 | + while ($entry = array_shift(self::$_cache)) { |
|
208 | 208 | list($file, $ext) = $entry; |
209 | 209 | //debugpng |
210 | 210 | if (DEBUGPNG) print '[clear unlink '.$file.']'; |
211 | 211 | if (!DEBUGKEEPTEMP) |
212 | - //XXX: Should we have some kind of fallback or warning if unlink() fails? |
|
213 | - unlink($file); |
|
214 | - } |
|
212 | + //XXX: Should we have some kind of fallback or warning if unlink() fails? |
|
213 | + unlink($file); |
|
214 | + } |
|
215 | + } |
|
215 | 216 | } |
216 | - } |
|
217 | 217 | |
218 | 218 | } |