@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @param \Fisharebest\Webtrees\Controller\IndividualController $ctrlIndividual_in The Individual Controller to extend |
35 | 35 | */ |
36 | - public function __construct(fw\Controller\IndividualController $ctrlIndividual_in){ |
|
36 | + public function __construct(fw\Controller\IndividualController $ctrlIndividual_in) { |
|
37 | 37 | $this->ctrlIndividual = $ctrlIndividual_in; |
38 | 38 | $this->dindi = new mw\Individual($this->ctrlIndividual->getSignificantIndividual()); |
39 | 39 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @uses \MyArtJaub\Webtrees\Hook\Hook |
46 | 46 | */ |
47 | - public function printHeaderExtensions(){ |
|
47 | + public function printHeaderExtensions() { |
|
48 | 48 | $hook_extend_indi_header_left = new mw\Hook\Hook('hExtendIndiHeaderLeft'); |
49 | 49 | $hook_extend_indi_header_right = new mw\Hook\Hook('hExtendIndiHeaderRight'); |
50 | 50 | $hook_extend_indi_header_left = $hook_extend_indi_header_left->execute($this->ctrlIndividual); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | echo '<div id="indi_perso_header">', |
54 | 54 | '<div id="indi_perso_header_left">'; |
55 | 55 | foreach ($hook_extend_indi_header_left as $div) { |
56 | - if(count($div)==2){ |
|
56 | + if (count($div) == 2) { |
|
57 | 57 | echo '<div id="', $div[0], '" class="indi_perso_header_left_div">', |
58 | 58 | $div[1], '</div>'; |
59 | 59 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | echo '</div>', |
62 | 62 | '<div id="indi_perso_header_right">'; |
63 | 63 | foreach ($hook_extend_indi_header_right as $div) { |
64 | - if(count($div)==2){ |
|
64 | + if (count($div) == 2) { |
|
65 | 65 | echo '<div id="', $div[0], '" class="indi_perso_header_right_div">', |
66 | 66 | $div[1], '</div>'; |
67 | 67 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @uses \MyArtJaub\Webtrees\Hook\Hook |
78 | 78 | */ |
79 | - public function printHeaderExtraIcons(){ |
|
79 | + public function printHeaderExtraIcons() { |
|
80 | 80 | $hook_extend_indi_header_icons = new Hook('hExtendIndiHeaderIcons'); |
81 | 81 | $hook_extend_indi_header_icons = $hook_extend_indi_header_icons->execute($this->ctrlIndividual); |
82 | 82 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param \Fisharebest\Webtrees\Fact $fact_in The Fact to extend |
40 | 40 | */ |
41 | - public function __construct(\Fisharebest\Webtrees\Fact $fact_in){ |
|
41 | + public function __construct(\Fisharebest\Webtrees\Fact $fact_in) { |
|
42 | 42 | $this->fact = $fact_in; |
43 | 43 | } |
44 | 44 | |
@@ -54,22 +54,22 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return int Level of sources |
56 | 56 | */ |
57 | - public function isSourced(){ |
|
58 | - $isSourced=0; |
|
57 | + public function isSourced() { |
|
58 | + $isSourced = 0; |
|
59 | 59 | $date = $this->fact->getDate(false); |
60 | - if($date->isOK()) { |
|
61 | - $isSourced=-1; |
|
62 | - if($date->qual1=='' && $date->minimumJulianDay() == $date->maximumJulianDay()){ |
|
63 | - $isSourced=-2; |
|
60 | + if ($date->isOK()) { |
|
61 | + $isSourced = -1; |
|
62 | + if ($date->qual1 == '' && $date->minimumJulianDay() == $date->maximumJulianDay()) { |
|
63 | + $isSourced = -2; |
|
64 | 64 | $citations = $this->fact->getCitations(); |
65 | - foreach($citations as $citation){ |
|
66 | - $isSourced=max($isSourced, 1); |
|
67 | - if(preg_match('/3 _ACT (.*)/', $citation) ){ |
|
68 | - $isSourced=max($isSourced, 2); |
|
65 | + foreach ($citations as $citation) { |
|
66 | + $isSourced = max($isSourced, 1); |
|
67 | + if (preg_match('/3 _ACT (.*)/', $citation)) { |
|
68 | + $isSourced = max($isSourced, 2); |
|
69 | 69 | preg_match_all("/4 DATE (.*)/", $citation, $datessource, PREG_SET_ORDER); |
70 | - foreach($datessource as $daterec){ |
|
70 | + foreach ($datessource as $daterec) { |
|
71 | 71 | $datesource = new Date($daterec[1]); |
72 | - if(abs($datesource->julianDay() - $date->julianDay()) < self::DATE_PRECISION_MARGIN){ |
|
72 | + if (abs($datesource->julianDay() - $date->julianDay()) < self::DATE_PRECISION_MARGIN) { |
|
73 | 73 | $isSourced = max($isSourced, 3); //If this level increases, do not forget to change the constant MAX_IS_SOURCED_LEVEL |
74 | 74 | } |
75 | 75 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @param \Fisharebest\Webtrees\Place $place_in The Place to extend |
30 | 30 | */ |
31 | - public function __construct(\Fisharebest\Webtrees\Place $place){ |
|
31 | + public function __construct(\Fisharebest\Webtrees\Place $place) { |
|
32 | 32 | $this->_place = $place; |
33 | 33 | } |
34 | 34 | |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | * @param \Fisharebest\Webtrees\Tree $tree |
41 | 41 | * @return \MyArtJaub\Webtrees\Place|null Instance of \MyArtJaub\Webtrees\Place, if relevant |
42 | 42 | */ |
43 | - public static function getIntance($place_str, Tree $tree){ |
|
43 | + public static function getIntance($place_str, Tree $tree) { |
|
44 | 44 | $dplace = null; |
45 | - if(is_string($place_str) && strlen($place_str) > 0){ |
|
45 | + if (is_string($place_str) && strlen($place_str) > 0) { |
|
46 | 46 | $dplace = new Place(new \Fisharebest\Webtrees\Place($place_str, $tree)); |
47 | 47 | } |
48 | 48 | return $dplace; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @return \Fisharebest\Webtrees\Place Embedded place record |
55 | 55 | */ |
56 | - public function getDerivedPlace(){ |
|
56 | + public function getDerivedPlace() { |
|
57 | 57 | return $this->_place; |
58 | 58 | } |
59 | 59 | |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | * @param bool $anchor Option to print a link to placelist |
67 | 67 | * @return string HTML code for formatted place |
68 | 68 | */ |
69 | - public function htmlFormattedName($format, $anchor = false){ |
|
70 | - $html=''; |
|
69 | + public function htmlFormattedName($format, $anchor = false) { |
|
70 | + $html = ''; |
|
71 | 71 | |
72 | 72 | $levels = array_map('trim', explode(',', $this->_place->getGedcomName())); |
73 | 73 | $nbLevels = count($levels); |
@@ -75,15 +75,15 @@ discard block |
||
75 | 75 | preg_match_all('/%[^%]/', $displayPlace, $matches); |
76 | 76 | foreach ($matches[0] as $match2) { |
77 | 77 | $index = str_replace('%', '', $match2); |
78 | - if(is_numeric($index) && $index >0 && $index <= $nbLevels){ |
|
79 | - $displayPlace = str_replace($match2, $levels[$index-1] , $displayPlace); |
|
78 | + if (is_numeric($index) && $index > 0 && $index <= $nbLevels) { |
|
79 | + $displayPlace = str_replace($match2, $levels[$index - 1], $displayPlace); |
|
80 | 80 | } |
81 | - else{ |
|
82 | - $displayPlace = str_replace($match2, '' , $displayPlace); |
|
81 | + else { |
|
82 | + $displayPlace = str_replace($match2, '', $displayPlace); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | if ($anchor && !Auth::isSearchEngine()) { |
86 | - $html .='<a href="' . $this->_place->getURL() . '">' . $displayPlace . '</a>'; |
|
86 | + $html .= '<a href="'.$this->_place->getURL().'">'.$displayPlace.'</a>'; |
|
87 | 87 | } else { |
88 | 88 | $html .= $displayPlace; |
89 | 89 | } |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | public function handle(fw\Module\AbstractModule $module, $request) { |
51 | 51 | |
52 | 52 | $fq_modclass_name = get_class($module); |
53 | - $ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')) . '\\'; |
|
53 | + $ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')).'\\'; |
|
54 | 54 | |
55 | - $args = explode( '@', $request, 2); |
|
56 | - switch(count($args)) { |
|
55 | + $args = explode('@', $request, 2); |
|
56 | + switch (count($args)) { |
|
57 | 57 | case 1: |
58 | 58 | $ctrl_name = $args[0]; |
59 | 59 | $method = 'index'; |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | break; |
66 | 66 | } |
67 | 67 | |
68 | - $ctrl_class = $ctrl_namespace . $ctrl_name . 'Controller'; |
|
69 | - if(class_exists($ctrl_class) |
|
68 | + $ctrl_class = $ctrl_namespace.$ctrl_name.'Controller'; |
|
69 | + if (class_exists($ctrl_class) |
|
70 | 70 | && is_subclass_of($ctrl_class, '\\MyArtJaub\\Webtrees\\Mvc\\Controller\\MvcController') |
71 | - && $ctrl = new $ctrl_class($module) ) { |
|
72 | - if(method_exists($ctrl, $method)) { |
|
71 | + && $ctrl = new $ctrl_class($module)) { |
|
72 | + if (method_exists($ctrl, $method)) { |
|
73 | 73 | call_user_func_array(array($ctrl, $method), array()); |
74 | 74 | } |
75 | 75 | else { |
@@ -53,13 +53,13 @@ |
||
53 | 53 | */ |
54 | 54 | public function makeView($view_name, MvcController $mvc_ctrl, BaseController $ctrl, ViewBag $data) |
55 | 55 | { |
56 | - if(!$mvc_ctrl) throw new \Exception('Mvc Controller not defined'); |
|
57 | - if(!$ctrl) throw new \Exception('Base Controller not defined'); |
|
58 | - if(!$view_name) throw new \Exception('View not defined'); |
|
56 | + if (!$mvc_ctrl) throw new \Exception('Mvc Controller not defined'); |
|
57 | + if (!$ctrl) throw new \Exception('Base Controller not defined'); |
|
58 | + if (!$view_name) throw new \Exception('View not defined'); |
|
59 | 59 | |
60 | 60 | $mvc_ctrl_refl = new \ReflectionObject($mvc_ctrl); |
61 | - $view_class = $mvc_ctrl_refl->getNamespaceName() . '\\Views\\' . $view_name . 'View'; |
|
62 | - if(!class_exists($view_class)) throw new \Exception('View does not exist'); |
|
61 | + $view_class = $mvc_ctrl_refl->getNamespaceName().'\\Views\\'.$view_name.'View'; |
|
62 | + if (!class_exists($view_class)) throw new \Exception('View does not exist'); |
|
63 | 63 | |
64 | 64 | return new $view_class($ctrl, $data); |
65 | 65 | } |
@@ -45,7 +45,7 @@ |
||
45 | 45 | public function render() { |
46 | 46 | global $controller; |
47 | 47 | |
48 | - if(!$this->ctrl) throw new \Exception('Controller not initialised'); |
|
48 | + if (!$this->ctrl) throw new \Exception('Controller not initialised'); |
|
49 | 49 | |
50 | 50 | $controller = $this->ctrl; |
51 | 51 | $this->ctrl->pageHeader(); |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | * @param bool $override |
74 | 74 | */ |
75 | 75 | public function set($key, $value, $override = true) { |
76 | - if(is_null($key)) return; |
|
77 | - if(!$override && array_key_exists($key, $this->data)) return; |
|
76 | + if (is_null($key)) return; |
|
77 | + if (!$override && array_key_exists($key, $this->data)) return; |
|
78 | 78 | $this->data[$key] = $value; |
79 | 79 | } |
80 | 80 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @param string $key |
108 | 108 | */ |
109 | 109 | public function __unset($key) { |
110 | - unset($this->data[$key]);; |
|
110 | + unset($this->data[$key]); ; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | } |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @param string $text Text to display |
42 | 42 | */ |
43 | - static public function promptAlert($text){ |
|
43 | + static public function promptAlert($text) { |
|
44 | 44 | echo '<script>'; |
45 | - echo 'alert("',fw\Filter::escapeHtml($text),'")'; |
|
45 | + echo 'alert("', fw\Filter::escapeHtml($text), '")'; |
|
46 | 46 | echo '</script>'; |
47 | 47 | } |
48 | 48 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @return float Result of the safe division |
56 | 56 | */ |
57 | 57 | public static function safeDivision($num, $denom, $default = 0) { |
58 | - if($denom && $denom!=0){ |
|
58 | + if ($denom && $denom != 0) { |
|
59 | 59 | return $num / $denom; |
60 | 60 | } |
61 | 61 | return $default; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param float $default Default value if denominator null or 0 |
70 | 70 | * @return float Percentage |
71 | 71 | */ |
72 | - public static function getPercentage($num, $denom, $default = 0){ |
|
72 | + public static function getPercentage($num, $denom, $default = 0) { |
|
73 | 73 | return 100 * self::safeDivision($num, $denom, $default); |
74 | 74 | } |
75 | 75 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param int $target The final max width/height |
81 | 81 | * @return array array of ($width, $height). One of them must be $target |
82 | 82 | */ |
83 | - static public function getResizedImageSize($file, $target=25){ |
|
83 | + static public function getResizedImageSize($file, $target = 25) { |
|
84 | 84 | list($width, $height, $type, $attr) = getimagesize($file); |
85 | 85 | $max = max($width, $height); |
86 | 86 | $rapp = $target / $max; |
@@ -111,21 +111,21 @@ discard block |
||
111 | 111 | * @param int $length Length of the token, default to 32 |
112 | 112 | * @return string Random token |
113 | 113 | */ |
114 | - public static function generateRandomToken($length=32) { |
|
114 | + public static function generateRandomToken($length = 32) { |
|
115 | 115 | $chars = str_split('abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'); |
116 | 116 | $len_chars = count($chars); |
117 | 117 | $token = ''; |
118 | 118 | |
119 | 119 | for ($i = 0; $i < $length; $i++) |
120 | - $token .= $chars[ mt_rand(0, $len_chars - 1) ]; |
|
120 | + $token .= $chars[mt_rand(0, $len_chars - 1)]; |
|
121 | 121 | |
122 | 122 | # Number of 32 char chunks |
123 | - $chunks = ceil( strlen($token) / 32 ); |
|
123 | + $chunks = ceil(strlen($token) / 32); |
|
124 | 124 | $md5token = ''; |
125 | 125 | |
126 | 126 | # Run each chunk through md5 |
127 | - for ( $i=1; $i<=$chunks; $i++ ) |
|
128 | - $md5token .= md5( substr($token, $i * 32 - 32, 32) ); |
|
127 | + for ($i = 1; $i <= $chunks; $i++) |
|
128 | + $md5token .= md5(substr($token, $i * 32 - 32, 32)); |
|
129 | 129 | |
130 | 130 | # Trim the token |
131 | 131 | return substr($md5token, 0, $length); |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | * @param string $data Text to encrypt |
139 | 139 | * @return string Encrypted and encoded text |
140 | 140 | */ |
141 | - public static function encryptToSafeBase64($data){ |
|
141 | + public static function encryptToSafeBase64($data) { |
|
142 | 142 | $key = 'STANDARDKEYIFNOSERVER'; |
143 | - if($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) |
|
143 | + if ($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) |
|
144 | 144 | $key = md5($_SERVER['SERVER_NAME'].$_SERVER['SERVER_SOFTWARE']); |
145 | 145 | $iv = mcrypt_create_iv(self::ENCRYPTION_IV_SIZE, MCRYPT_RAND); |
146 | - $id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC,$iv); |
|
146 | + $id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, $iv); |
|
147 | 147 | $encrypted = base64_encode($iv.$id); |
148 | 148 | // +, / and = are not URL-compatible |
149 | 149 | $encrypted = str_replace('+', '-', $encrypted); |
@@ -158,22 +158,22 @@ discard block |
||
158 | 158 | * @param string $encrypted Text to decrypt |
159 | 159 | * @return string Decrypted text |
160 | 160 | */ |
161 | - public static function decryptFromSafeBase64($encrypted){ |
|
161 | + public static function decryptFromSafeBase64($encrypted) { |
|
162 | 162 | $key = 'STANDARDKEYIFNOSERVER'; |
163 | - if($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) |
|
163 | + if ($_SERVER['SERVER_NAME'] && $_SERVER['SERVER_SOFTWARE']) |
|
164 | 164 | $key = md5($_SERVER['SERVER_NAME'].$_SERVER['SERVER_SOFTWARE']); |
165 | 165 | $encrypted = str_replace('-', '+', $encrypted); |
166 | 166 | $encrypted = str_replace('_', '/', $encrypted); |
167 | 167 | $encrypted = str_replace('*', '=', $encrypted); |
168 | 168 | $encrypted = base64_decode($encrypted); |
169 | - if(!$encrypted) |
|
169 | + if (!$encrypted) |
|
170 | 170 | throw new InvalidArgumentException('The encrypted value is not in correct base64 format.'); |
171 | - if(strlen($encrypted) < self::ENCRYPTION_IV_SIZE) |
|
171 | + if (strlen($encrypted) < self::ENCRYPTION_IV_SIZE) |
|
172 | 172 | throw new InvalidArgumentException('The encrypted value does not contain enough characters for the key.'); |
173 | 173 | $iv_dec = substr($encrypted, 0, self::ENCRYPTION_IV_SIZE); |
174 | 174 | $encrypted = substr($encrypted, self::ENCRYPTION_IV_SIZE); |
175 | 175 | $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $encrypted, MCRYPT_MODE_CBC, $iv_dec); |
176 | - return preg_replace('~(?:\\000+)$~','',$decrypted); |
|
176 | + return preg_replace('~(?:\\000+)$~', '', $decrypted); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | * @param string $string Filesystem encoded string to encode |
183 | 183 | * @return string UTF-8 encoded string |
184 | 184 | */ |
185 | - public static function encodeFileSystemToUtf8($string){ |
|
185 | + public static function encodeFileSystemToUtf8($string) { |
|
186 | 186 | if (strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') { |
187 | - return iconv('cp1252', 'utf-8//IGNORE',$string); |
|
187 | + return iconv('cp1252', 'utf-8//IGNORE', $string); |
|
188 | 188 | } |
189 | 189 | return $string; |
190 | 190 | } |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | * @param string $string UTF-8 encoded string to encode |
196 | 196 | * @return string Filesystem encoded string |
197 | 197 | */ |
198 | - public static function encodeUtf8ToFileSystem($string){ |
|
198 | + public static function encodeUtf8ToFileSystem($string) { |
|
199 | 199 | if (preg_match('//u', $string) && strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') { |
200 | - return iconv('utf-8', 'cp1252//IGNORE' , $string); |
|
200 | + return iconv('utf-8', 'cp1252//IGNORE', $string); |
|
201 | 201 | } |
202 | 202 | return $string; |
203 | 203 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @return boolean True if path valid |
211 | 211 | */ |
212 | 212 | public static function isValidPath($filename, $acceptfolder = FALSE) { |
213 | - if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
213 | + if (strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
214 | 214 | return false; |
215 | 215 | } |
216 | 216 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @return array Array of month short names |
223 | 223 | */ |
224 | 224 | public static function getCalendarShortMonths($calendarId = 0) { |
225 | - if(!isset(self::$calendarShortMonths[$calendarId])) { |
|
225 | + if (!isset(self::$calendarShortMonths[$calendarId])) { |
|
226 | 226 | $calendar_info = cal_info($calendarId); |
227 | 227 | self::$calendarShortMonths[$calendarId] = $calendar_info['abbrevmonths']; |
228 | 228 | } |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | * @param int $sosa Sosa number |
236 | 236 | * @return number |
237 | 237 | */ |
238 | - public static function getGeneration($sosa){ |
|
239 | - return(int)log($sosa, 2)+1; |
|
238 | + public static function getGeneration($sosa) { |
|
239 | + return(int)log($sosa, 2) + 1; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @param Media|null $media Reference media object |
64 | 64 | */ |
65 | - public function __construct(Media $media = null){ |
|
65 | + public function __construct(Media $media = null) { |
|
66 | 66 | $this->media = $media; |
67 | 67 | $this->use_ttf = function_exists('imagettftext'); |
68 | 68 | $this->expire_offset = 3600 * 24; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @return ImageBuilder |
88 | 88 | */ |
89 | 89 | public function setExpireOffset($expireOffset) { |
90 | - if($expireOffset) $this->expire_offset = $expireOffset; |
|
90 | + if ($expireOffset) $this->expire_offset = $expireOffset; |
|
91 | 91 | return $this; |
92 | 92 | } |
93 | 93 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @return ImageBuilder |
108 | 108 | */ |
109 | 109 | public function setShowWatermark($show_watermark) { |
110 | - if(!is_null($show_watermark)) $this->show_watermark = $show_watermark; |
|
110 | + if (!is_null($show_watermark)) $this->show_watermark = $show_watermark; |
|
111 | 111 | return $this; |
112 | 112 | } |
113 | 113 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @return ImageBuilder |
119 | 119 | */ |
120 | 120 | public function setFontMaxSize($font_max_size) { |
121 | - if($font_max_size) $this->font_max_size = $font_max_size; |
|
121 | + if ($font_max_size) $this->font_max_size = $font_max_size; |
|
122 | 122 | return $this; |
123 | 123 | } |
124 | 124 | |
@@ -129,32 +129,32 @@ discard block |
||
129 | 129 | * @return ImageBuilder |
130 | 130 | */ |
131 | 131 | public function setFontColor($font_color) { |
132 | - if($font_color) $this->font_color = $font_color; |
|
132 | + if ($font_color) $this->font_color = $font_color; |
|
133 | 133 | return $this; |
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
137 | 137 | * Render the image to the output. |
138 | 138 | */ |
139 | - public function render(){ |
|
139 | + public function render() { |
|
140 | 140 | |
141 | 141 | if (!$this->media || !$this->media->canShow()) { |
142 | - Log::addMediaLog('Image Builder error: >' . I18N::translate('Missing or private media object.')); |
|
142 | + Log::addMediaLog('Image Builder error: >'.I18N::translate('Missing or private media object.')); |
|
143 | 143 | $this->renderError(); |
144 | 144 | } |
145 | 145 | |
146 | 146 | $serverFilename = $this->media->getServerFilename(); |
147 | 147 | |
148 | 148 | if (!file_exists($serverFilename)) { |
149 | - Log::addMediaLog('Image Builder error: >'. I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<'); |
|
149 | + Log::addMediaLog('Image Builder error: >'.I18N::translate('The media object does not exist.').'< for path >'.$serverFilename.'<'); |
|
150 | 150 | $this->renderError(); |
151 | 151 | } |
152 | 152 | |
153 | 153 | $mimetype = $this->media->mimeType(); |
154 | 154 | $imgsize = $this->media->getImageAttributes(); |
155 | 155 | $filetime = $this->media->getFiletime(); |
156 | - $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime) . ' GMT'; |
|
157 | - $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $this->getExpireOffset()) . ' GMT'; |
|
156 | + $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime).' GMT'; |
|
157 | + $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $this->getExpireOffset()).' GMT'; |
|
158 | 158 | |
159 | 159 | $type = Functions::isImageTypeSupported($imgsize['ext']); |
160 | 160 | $usewatermark = false; |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | } |
187 | 187 | |
188 | 188 | // add caching headers. allow browser to cache file, but not proxy |
189 | - header('Last-Modified: ' . $filetimeHeader); |
|
190 | - header('ETag: "' . $etag . '"'); |
|
191 | - header('Expires: ' . $expireHeader); |
|
192 | - header('Cache-Control: max-age=' . $this->getExpireOffset() . ', s-maxage=0, proxy-revalidate'); |
|
189 | + header('Last-Modified: '.$filetimeHeader); |
|
190 | + header('ETag: "'.$etag.'"'); |
|
191 | + header('Expires: '.$expireHeader); |
|
192 | + header('Cache-Control: max-age='.$this->getExpireOffset().', s-maxage=0, proxy-revalidate'); |
|
193 | 193 | |
194 | 194 | // if this file is already in the user’s cache, don’t resend it |
195 | 195 | // first check if the if_modified_since param matches |
@@ -203,13 +203,13 @@ discard block |
||
203 | 203 | } |
204 | 204 | |
205 | 205 | // send headers for the image |
206 | - header('Content-Type: ' . $mimetype); |
|
207 | - header('Content-Disposition: filename="' . addslashes(basename($this->media->getFilename())) . '"'); |
|
206 | + header('Content-Type: '.$mimetype); |
|
207 | + header('Content-Disposition: filename="'.addslashes(basename($this->media->getFilename())).'"'); |
|
208 | 208 | |
209 | 209 | if ($usewatermark) { |
210 | 210 | // generate the watermarked image |
211 | - $imCreateFunc = 'imagecreatefrom' . $type; |
|
212 | - $imSendFunc = 'image' . $type; |
|
211 | + $imCreateFunc = 'imagecreatefrom'.$type; |
|
212 | + $imSendFunc = 'image'.$type; |
|
213 | 213 | |
214 | 214 | if (function_exists($imCreateFunc) && function_exists($imSendFunc)) { |
215 | 215 | $im = $imCreateFunc($serverFilename); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | return; |
223 | 223 | } else { |
224 | 224 | // this image is defective. log it |
225 | - Log::addMediaLog('Image Builder error: >' . I18N::translate('This media file is broken and cannot be watermarked.') . '< in file >' . $serverFilename . '< memory used: ' . memory_get_usage()); |
|
225 | + Log::addMediaLog('Image Builder error: >'.I18N::translate('This media file is broken and cannot be watermarked.').'< in file >'.$serverFilename.'< memory used: '.memory_get_usage()); |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $filesize = filesize($serverFilename); |
231 | 231 | |
232 | 232 | // set content-length header, send file |
233 | - header('Content-Length: ' . $filesize); |
|
233 | + header('Content-Length: '.$filesize); |
|
234 | 234 | |
235 | 235 | // Some servers disable fpassthru() and readfile() |
236 | 236 | if (function_exists('readfile')) { |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | $bgc = imagecolorallocate($im, 255, 255, 255); /* set background color */ |
261 | 261 | imagefilledrectangle($im, 2, 2, $width - 4, $height - 4, $bgc); /* create a rectangle, leaving 2 px border */ |
262 | 262 | |
263 | - $this->embedText($im, $error, 100, '255, 0, 0', WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, 'top', 'left'); |
|
263 | + $this->embedText($im, $error, 100, '255, 0, 0', WT_ROOT.Config::FONT_DEJAVU_SANS_TTF, 'top', 'left'); |
|
264 | 264 | |
265 | 265 | http_response_code(404); |
266 | 266 | header('Content-Type: image/png'); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | protected function applyWatermark($im) { |
279 | 279 | |
280 | 280 | // text to watermark with |
281 | - if(method_exists($this->media, 'getWatermarkText')) { |
|
281 | + if (method_exists($this->media, 'getWatermarkText')) { |
|
282 | 282 | $word1_text = $this->media->getWatermarkText(); |
283 | 283 | } |
284 | 284 | else { |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | $word1_text, |
291 | 291 | $this->font_max_size, |
292 | 292 | $this->font_color, |
293 | - WT_ROOT . Config::FONT_DEJAVU_SANS_TTF, |
|
293 | + WT_ROOT.Config::FONT_DEJAVU_SANS_TTF, |
|
294 | 294 | 'top', |
295 | 295 | 'left' |
296 | 296 | ); |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | * @param string $hexstr |
410 | 410 | * @return int[] |
411 | 411 | */ |
412 | - protected function hexrgb ($hexstr) |
|
412 | + protected function hexrgb($hexstr) |
|
413 | 413 | { |
414 | 414 | $int = hexdec($hexstr); |
415 | 415 | |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | */ |
452 | 452 | function imageTtfTextErrorHandler($errno, $errstr) { |
453 | 453 | // log the error |
454 | - Log::addErrorLog('Image Builder error: >' . $errno . '/' . $errstr . '< while processing file >' . $this->media->getServerFilename() . '<'); |
|
454 | + Log::addErrorLog('Image Builder error: >'.$errno.'/'.$errstr.'< while processing file >'.$this->media->getServerFilename().'<'); |
|
455 | 455 | |
456 | 456 | // change value of useTTF to false so the fallback watermarking can be used. |
457 | 457 | $this->use_ttf = false; |