@@ -95,7 +95,11 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function __construct($time='now',DateTimeZone $tz=null,&$type=null) |
| 97 | 97 | { |
| 98 | - if (is_null($tz)) $tz = self::$user_timezone; // default user timezone |
|
| 98 | + if (is_null($tz)) |
|
| 99 | + { |
|
| 100 | + $tz = self::$user_timezone; |
|
| 101 | + } |
|
| 102 | + // default user timezone |
|
| 99 | 103 | |
| 100 | 104 | switch(($type = gettype($time))) |
| 101 | 105 | { |
@@ -108,7 +112,11 @@ discard block |
||
| 108 | 112 | if (!(is_numeric($time) && ($time > 21000000 || $time < 19000000))) |
| 109 | 113 | { |
| 110 | 114 | $t_str = $time; |
| 111 | - if (is_numeric($time) && strlen($time) == 8) $t_str .= 'T000000'; // 'Ymd' string used in calendar to represent a date |
|
| 115 | + if (is_numeric($time) && strlen($time) == 8) |
|
| 116 | + { |
|
| 117 | + $t_str .= 'T000000'; |
|
| 118 | + } |
|
| 119 | + // 'Ymd' string used in calendar to represent a date |
|
| 112 | 120 | // $time ending in a Z (Zulu or UTC time), is unterstood by DateTime class itself |
| 113 | 121 | try { |
| 114 | 122 | parent::__construct($t_str,$tz); |
@@ -116,7 +124,10 @@ discard block |
||
| 116 | 124 | } |
| 117 | 125 | catch(Exception $e) { |
| 118 | 126 | // if string is nummeric, ignore the exception and treat string as timestamp |
| 119 | - if (!is_numeric($time)) throw $e; |
|
| 127 | + if (!is_numeric($time)) |
|
| 128 | + { |
|
| 129 | + throw $e; |
|
| 130 | + } |
|
| 120 | 131 | } |
| 121 | 132 | } |
| 122 | 133 | $type = 'integer'; |
@@ -137,7 +148,9 @@ discard block |
||
| 137 | 148 | |
| 138 | 149 | case 'array': |
| 139 | 150 | parent::__construct('now',$tz); |
| 140 | - if (isset($time['Y'])) // array format used in eTemplate |
|
| 151 | + if (isset($time['Y'])) |
|
| 152 | + { |
|
| 153 | + // array format used in eTemplate |
|
| 141 | 154 | { |
| 142 | 155 | $time = array( |
| 143 | 156 | 'year' => $time['Y'], |
@@ -148,13 +161,17 @@ discard block |
||
| 148 | 161 | 'second' => $time['s'], |
| 149 | 162 | ); |
| 150 | 163 | } |
| 164 | + } |
|
| 151 | 165 | if (!empty($time['full']) && empty($time['year'])) |
| 152 | 166 | { |
| 153 | 167 | $time['year'] = (int)substr($time['full'],0,4); |
| 154 | 168 | $time['month'] = (int)substr($time['full'],4,2); |
| 155 | 169 | $time['day'] = (int)substr($time['full'],6,2); |
| 156 | 170 | } |
| 157 | - if (isset($time['year'])) $this->setDate((int)$time['year'],(int)$time['month'],isset($time['day']) ? (int)$time['day'] : (int)$time['mday']); |
|
| 171 | + if (isset($time['year'])) |
|
| 172 | + { |
|
| 173 | + $this->setDate((int)$time['year'],(int)$time['month'],isset($time['day']) ? (int)$time['day'] : (int)$time['mday']); |
|
| 174 | + } |
|
| 158 | 175 | $this->setTime((int)$time['hour'],(int)$time['minute'],(int)$time['second']); |
| 159 | 176 | break; |
| 160 | 177 | |
@@ -178,7 +195,10 @@ discard block |
||
| 178 | 195 | */ |
| 179 | 196 | public function add($interval) |
| 180 | 197 | { |
| 181 | - if (is_string($interval)) $interval = DateInterval::createFromDateString($interval); |
|
| 198 | + if (is_string($interval)) |
|
| 199 | + { |
|
| 200 | + $interval = DateInterval::createFromDateString($interval); |
|
| 201 | + } |
|
| 182 | 202 | |
| 183 | 203 | parent::add($interval); |
| 184 | 204 | } |
@@ -202,7 +222,10 @@ discard block |
||
| 202 | 222 | $wstart = -($wday ? $wday-1 : 6); |
| 203 | 223 | break; |
| 204 | 224 | } |
| 205 | - if ($wstart) $this->add($wstart.'days'); |
|
| 225 | + if ($wstart) |
|
| 226 | + { |
|
| 227 | + $this->add($wstart.'days'); |
|
| 228 | + } |
|
| 206 | 229 | } |
| 207 | 230 | |
| 208 | 231 | /** |
@@ -263,15 +286,27 @@ discard block |
||
| 263 | 286 | } |
| 264 | 287 | elseif ($sday || $eday) |
| 265 | 288 | { |
| 266 | - if ($sday) $start->add($sday.'days'); |
|
| 267 | - if ($eday) $end->add($eday.'days'); |
|
| 289 | + if ($sday) |
|
| 290 | + { |
|
| 291 | + $start->add($sday.'days'); |
|
| 292 | + } |
|
| 293 | + if ($eday) |
|
| 294 | + { |
|
| 295 | + $end->add($eday.'days'); |
|
| 296 | + } |
|
| 268 | 297 | } |
| 269 | 298 | elseif ($sweek || $eweek) |
| 270 | 299 | { |
| 271 | 300 | $start->setWeekstart(); |
| 272 | - if ($sweek) $start->add($sweek.'weeks'); |
|
| 301 | + if ($sweek) |
|
| 302 | + { |
|
| 303 | + $start->add($sweek.'weeks'); |
|
| 304 | + } |
|
| 273 | 305 | $end->setWeekstart(); |
| 274 | - if ($eweek) $end->add($eweek.'weeks'); |
|
| 306 | + if ($eweek) |
|
| 307 | + { |
|
| 308 | + $end->add($eweek.'weeks'); |
|
| 309 | + } |
|
| 275 | 310 | } |
| 276 | 311 | } |
| 277 | 312 | // convert start + end from user to servertime for the filter |
@@ -416,7 +451,10 @@ discard block |
||
| 416 | 451 | } |
| 417 | 452 | $time->setUser(); |
| 418 | 453 | |
| 419 | - if (is_null($type)) $type = $typeof; |
|
| 454 | + if (is_null($type)) |
|
| 455 | + { |
|
| 456 | + $type = $typeof; |
|
| 457 | + } |
|
| 420 | 458 | |
| 421 | 459 | //echo "<p>".__METHOD__."($time,$type) = ".print_r($format->format($type),true)."</p>\n"; |
| 422 | 460 | return $time->format($type); |
@@ -446,7 +484,10 @@ discard block |
||
| 446 | 484 | } |
| 447 | 485 | $time->setServer(); |
| 448 | 486 | |
| 449 | - if (is_null($type)) $type = $typeof; |
|
| 487 | + if (is_null($type)) |
|
| 488 | + { |
|
| 489 | + $type = $typeof; |
|
| 490 | + } |
|
| 450 | 491 | |
| 451 | 492 | //echo "<p>".__METHOD__."($time,$type) = ".print_r($format->format($type),true)."</p>\n"; |
| 452 | 493 | return $time->format($type); |
@@ -520,8 +561,12 @@ discard block |
||
| 520 | 561 | $time, |
| 521 | 562 | static::$user_timezone |
| 522 | 563 | ); |
| 523 | - if($date) break; |
|
| 524 | - } catch (\Exception $e) { |
|
| 564 | + if($date) |
|
| 565 | + { |
|
| 566 | + break; |
|
| 567 | + } |
|
| 568 | + } |
|
| 569 | + catch (\Exception $e) { |
|
| 525 | 570 | |
| 526 | 571 | } |
| 527 | 572 | } |
@@ -540,7 +585,10 @@ discard block |
||
| 540 | 585 | public static function setUserPrefs($tz,$dateformat='',$timeformat='') |
| 541 | 586 | { |
| 542 | 587 | //echo "<p>".__METHOD__."('$tz','$dateformat','$timeformat') ".function_backtrace()."</p>\n"; |
| 543 | - if (!empty($dateformat)) self::$user_dateformat = $dateformat; |
|
| 588 | + if (!empty($dateformat)) |
|
| 589 | + { |
|
| 590 | + self::$user_dateformat = $dateformat; |
|
| 591 | + } |
|
| 544 | 592 | |
| 545 | 593 | switch($timeformat) |
| 546 | 594 | { |
@@ -578,7 +626,10 @@ discard block |
||
| 578 | 626 | */ |
| 579 | 627 | public static function tz_offset_s($time='now') |
| 580 | 628 | { |
| 581 | - if (!($time instanceof DateTime)) $time = new DateTime($time); |
|
| 629 | + if (!($time instanceof DateTime)) |
|
| 630 | + { |
|
| 631 | + $time = new DateTime($time); |
|
| 632 | + } |
|
| 582 | 633 | |
| 583 | 634 | return self::$user_timezone->getOffset($time) - self::$server_timezone->getOffset($time); |
| 584 | 635 | } |
@@ -686,9 +737,17 @@ discard block |
||
| 686 | 737 | ); |
| 687 | 738 | foreach(DateTimeZone::listIdentifiers() as $name) |
| 688 | 739 | { |
| 689 | - if (in_array($name,$no_vtimezone)) continue; // do NOT allow to set in EGroupware, as we have not VTIMEZONE component for it |
|
| 740 | + if (in_array($name,$no_vtimezone)) |
|
| 741 | + { |
|
| 742 | + continue; |
|
| 743 | + } |
|
| 744 | + // do NOT allow to set in EGroupware, as we have not VTIMEZONE component for it |
|
| 690 | 745 | list($continent) = explode('/',$name,2); |
| 691 | - if (!isset($tzs[$continent])) continue; // old depricated timezones |
|
| 746 | + if (!isset($tzs[$continent])) |
|
| 747 | + { |
|
| 748 | + continue; |
|
| 749 | + } |
|
| 750 | + // old depricated timezones |
|
| 692 | 751 | $datetime = new DateTime('now',new DateTimeZone($name)); |
| 693 | 752 | $tzs[$continent][$name] = str_replace(array('_','/'),array(' ',' / '),$name)." ".$datetime->format(); |
| 694 | 753 | unset($datetime); |
@@ -727,10 +786,13 @@ discard block |
||
| 727 | 786 | { |
| 728 | 787 | $user_tzs = array_merge(array($tz),$user_tzs); |
| 729 | 788 | } |
| 730 | - if (!$user_tzs) // if we have no user timezones, eg. user set no pref --> use server default |
|
| 789 | + if (!$user_tzs) |
|
| 790 | + { |
|
| 791 | + // if we have no user timezones, eg. user set no pref --> use server default |
|
| 731 | 792 | { |
| 732 | 793 | $user_tzs = array($GLOBALS['egw_info']['server']['server_timezone']); |
| 733 | 794 | } |
| 795 | + } |
|
| 734 | 796 | if ($extra && !in_array($extra,$user_tzs)) |
| 735 | 797 | { |
| 736 | 798 | $user_tzs = array_merge(array($extra),$user_tzs); |
@@ -168,13 +168,19 @@ discard block |
||
| 168 | 168 | switch ($mimetype) |
| 169 | 169 | { |
| 170 | 170 | case 'application/msword': |
| 171 | - if (strtolower($extension) != '.rtf') break; |
|
| 171 | + if (strtolower($extension) != '.rtf') |
|
| 172 | + { |
|
| 173 | + break; |
|
| 174 | + } |
|
| 172 | 175 | case 'application/rtf': |
| 173 | 176 | case 'text/rtf': |
| 174 | 177 | return true; // rtf files |
| 175 | 178 | case 'application/vnd.oasis.opendocument.text': // oo text |
| 176 | 179 | case 'application/vnd.oasis.opendocument.spreadsheet': // oo spreadsheet |
| 177 | - if (!$zip_available) break; |
|
| 180 | + if (!$zip_available) |
|
| 181 | + { |
|
| 182 | + break; |
|
| 183 | + } |
|
| 178 | 184 | return true; // open office write xml files |
| 179 | 185 | case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': // ms word 2007 xml format |
| 180 | 186 | case 'application/vnd.openxmlformats-officedocument.wordprocessingml.d': // mimetypes in vfs are limited to 64 chars |
@@ -182,7 +188,10 @@ discard block |
||
| 182 | 188 | case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': // ms excel 2007 xml format |
| 183 | 189 | case 'application/vnd.openxmlformats-officedocument.spreadsheetml.shee': |
| 184 | 190 | case 'application/vnd.ms-excel.sheet.macroenabled.12': |
| 185 | - if (!$zip_available) break; |
|
| 191 | + if (!$zip_available) |
|
| 192 | + { |
|
| 193 | + break; |
|
| 194 | + } |
|
| 186 | 195 | return true; // ms word xml format |
| 187 | 196 | case 'application/xml': |
| 188 | 197 | return true; // alias for text/xml, eg. ms office 2003 word format |
@@ -217,7 +226,10 @@ discard block |
||
| 217 | 226 | { |
| 218 | 227 | $contact = $this->contacts->read($contact, $ignore_acl); |
| 219 | 228 | } |
| 220 | - if (!is_array($contact)) return array(); |
|
| 229 | + if (!is_array($contact)) |
|
| 230 | + { |
|
| 231 | + return array(); |
|
| 232 | + } |
|
| 221 | 233 | |
| 222 | 234 | $replacements = array(); |
| 223 | 235 | foreach(array_keys($this->contacts->contact_fields) as $name) |
@@ -226,7 +238,10 @@ discard block |
||
| 226 | 238 | switch($name) |
| 227 | 239 | { |
| 228 | 240 | case 'created': case 'modified': |
| 229 | - if($value) $value = Api\DateTime::to($value); |
|
| 241 | + if($value) |
|
| 242 | + { |
|
| 243 | + $value = Api\DateTime::to($value); |
|
| 244 | + } |
|
| 230 | 245 | break; |
| 231 | 246 | case 'bday': |
| 232 | 247 | if ($value) |
@@ -276,7 +291,10 @@ discard block |
||
| 276 | 291 | } |
| 277 | 292 | break; |
| 278 | 293 | } |
| 279 | - if ($name != 'photo') $replacements['$$'.($prefix ? $prefix.'/':'').$name.'$$'] = $value; |
|
| 294 | + if ($name != 'photo') |
|
| 295 | + { |
|
| 296 | + $replacements['$$'.($prefix ? $prefix.'/':'').$name.'$$'] = $value; |
|
| 297 | + } |
|
| 280 | 298 | } |
| 281 | 299 | // set custom fields, should probably go to a general method all apps can use |
| 282 | 300 | // need to load all cfs for $ignore_acl=true |
@@ -293,17 +311,23 @@ discard block |
||
| 293 | 311 | $cats = array(); |
| 294 | 312 | foreach(is_array($contact['cat_id']) ? $contact['cat_id'] : explode(',',$contact['cat_id']) as $cat_id) |
| 295 | 313 | { |
| 296 | - if(!$cat_id) continue; |
|
| 314 | + if(!$cat_id) |
|
| 315 | + { |
|
| 316 | + continue; |
|
| 317 | + } |
|
| 297 | 318 | if($GLOBALS['egw']->categories->id2name($cat_id,'main') != $cat_id) |
| 298 | 319 | { |
| 299 | 320 | $path = explode(' / ', $GLOBALS['egw']->categories->id2name($cat_id, 'path')); |
| 300 | 321 | unset($path[0]); // Drop main |
| 301 | 322 | $cats[$GLOBALS['egw']->categories->id2name($cat_id,'main')][] = implode(' / ', $path); |
| 302 | - } elseif($cat_id) { |
|
| 323 | + } |
|
| 324 | + elseif($cat_id) |
|
| 325 | + { |
|
| 303 | 326 | $cats[$cat_id] = array(); |
| 304 | 327 | } |
| 305 | 328 | } |
| 306 | - foreach($cats as $main => $cat) { |
|
| 329 | + foreach($cats as $main => $cat) |
|
| 330 | + { |
|
| 307 | 331 | $replacements['$$'.($prefix ? $prefix.'/':'').'categories$$'] .= $GLOBALS['egw']->categories->id2name($main,'name') |
| 308 | 332 | . (count($cat) > 0 ? ': ' : '') . implode(', ', $cats[$main]) . "\n"; |
| 309 | 333 | } |
@@ -338,7 +362,10 @@ discard block |
||
| 338 | 362 | 'id' => $link_info |
| 339 | 363 | ); |
| 340 | 364 | } |
| 341 | - if($exclude && in_array($link_info['id'], $exclude)) continue; |
|
| 365 | + if($exclude && in_array($link_info['id'], $exclude)) |
|
| 366 | + { |
|
| 367 | + continue; |
|
| 368 | + } |
|
| 342 | 369 | |
| 343 | 370 | $title = Api\Link::title($link_info['app'], $link_info['id']); |
| 344 | 371 | if(class_exists('EGroupware\Stylite\Vfs\Links\StreamWrapper') && $link_info['app'] != Api\Link::VFS_APPNAME) |
@@ -457,7 +484,10 @@ discard block |
||
| 457 | 484 | protected function format_datetime($time,$format=null) |
| 458 | 485 | { |
| 459 | 486 | trigger_error(__METHOD__ . ' is deprecated, use Api\DateTime::to($time, $format)', E_USER_DEPRECATED); |
| 460 | - if (is_null($format)) $format = $this->datetime_format; |
|
| 487 | + if (is_null($format)) |
|
| 488 | + { |
|
| 489 | + $format = $this->datetime_format; |
|
| 490 | + } |
|
| 461 | 491 | |
| 462 | 492 | return Api\DateTime::to($time,$format); |
| 463 | 493 | } |
@@ -499,7 +529,10 @@ discard block |
||
| 499 | 529 | public static function getExportLimit($app='common') |
| 500 | 530 | { |
| 501 | 531 | static $exportLimitStore=array(); |
| 502 | - if (empty($app)) $app='common'; |
|
| 532 | + if (empty($app)) |
|
| 533 | + { |
|
| 534 | + $app='common'; |
|
| 535 | + } |
|
| 503 | 536 | //error_log(__METHOD__.__LINE__.' called with app:'.$app); |
| 504 | 537 | if (!array_key_exists($app,$exportLimitStore)) |
| 505 | 538 | { |
@@ -508,7 +541,10 @@ discard block |
||
| 508 | 541 | if ($app !='common') |
| 509 | 542 | { |
| 510 | 543 | $app_limit = Api\Hooks::single('export_limit',$app); |
| 511 | - if ($app_limit) $exportLimitStore[$app] = $app_limit; |
|
| 544 | + if ($app_limit) |
|
| 545 | + { |
|
| 546 | + $exportLimitStore[$app] = $app_limit; |
|
| 547 | + } |
|
| 512 | 548 | } |
| 513 | 549 | //error_log(__METHOD__.__LINE__.' building cache for app:'.$app.' -> '.$exportLimitStore[$app]); |
| 514 | 550 | if (empty($exportLimitStore[$app])) |
@@ -541,10 +577,22 @@ discard block |
||
| 541 | 577 | */ |
| 542 | 578 | public static function hasExportLimit($app_limit,$checkas='AND') |
| 543 | 579 | { |
| 544 | - if (strtoupper($checkas) == 'ISALLOWED') return (empty($app_limit) || ($app_limit !='no' && $app_limit > 0) ); |
|
| 545 | - if (empty($app_limit)) return false; |
|
| 546 | - if ($app_limit == 'no') return true; |
|
| 547 | - if ($app_limit > 0) return true; |
|
| 580 | + if (strtoupper($checkas) == 'ISALLOWED') |
|
| 581 | + { |
|
| 582 | + return (empty($app_limit) || ($app_limit !='no' && $app_limit > 0) ); |
|
| 583 | + } |
|
| 584 | + if (empty($app_limit)) |
|
| 585 | + { |
|
| 586 | + return false; |
|
| 587 | + } |
|
| 588 | + if ($app_limit == 'no') |
|
| 589 | + { |
|
| 590 | + return true; |
|
| 591 | + } |
|
| 592 | + if ($app_limit > 0) |
|
| 593 | + { |
|
| 594 | + return true; |
|
| 595 | + } |
|
| 548 | 596 | } |
| 549 | 597 | |
| 550 | 598 | /** |
@@ -579,7 +627,8 @@ discard block |
||
| 579 | 627 | |
| 580 | 628 | try { |
| 581 | 629 | $content = $this->merge_string($content,$ids,$err,$mimetype,$fix); |
| 582 | - } catch (\Exception $e) { |
|
| 630 | + } |
|
| 631 | + catch (\Exception $e) { |
|
| 583 | 632 | _egw_log_exception($e); |
| 584 | 633 | $err = $e->getMessage(); |
| 585 | 634 | return false; |
@@ -671,7 +720,8 @@ discard block |
||
| 671 | 720 | $content = $xslt->transformToXml($element); |
| 672 | 721 | |
| 673 | 722 | // Word 2003 needs two declarations, add extra declaration back in |
| 674 | - if($mimetype == 'application/xml' && $mso_application_progid == 'Word.Document' && strpos($content, '<?xml') !== 0) { |
|
| 723 | + if($mimetype == 'application/xml' && $mso_application_progid == 'Word.Document' && strpos($content, '<?xml') !== 0) |
|
| 724 | + { |
|
| 675 | 725 | $content = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'.$content; |
| 676 | 726 | } |
| 677 | 727 | // Validate |
@@ -731,7 +781,10 @@ discard block |
||
| 731 | 781 | // textdocuments are simple, they do not hold start and end, but they may have content before and after the $$pagerepeat$$ tag |
| 732 | 782 | // header and footer should not hold any $$ tags; if we find $$ tags with the header, we assume it is the pagerepeatcontent |
| 733 | 783 | $nohead = false; |
| 734 | - if (stripos($contentstart,'$$') !== false) $nohead = true; |
|
| 784 | + if (stripos($contentstart,'$$') !== false) |
|
| 785 | + { |
|
| 786 | + $nohead = true; |
|
| 787 | + } |
|
| 735 | 788 | if ($nohead) |
| 736 | 789 | { |
| 737 | 790 | $contentend = $contentrepeat; |
@@ -773,13 +826,19 @@ discard block |
||
| 773 | 826 | preg_match_all('/\$\$labelplacement\$\$/',$contentrepeat,$countlables, PREG_SPLIT_NO_EMPTY); |
| 774 | 827 | $countlables = count($countlables[0]); |
| 775 | 828 | preg_replace('/\$\$labelplacement\$\$/','',$Labelrepeat,1); |
| 776 | - if ($countlables > 1) $lableprint = true; |
|
| 829 | + if ($countlables > 1) |
|
| 830 | + { |
|
| 831 | + $lableprint = true; |
|
| 832 | + } |
|
| 777 | 833 | if (count($ids) > 1 && !$contentrepeat) |
| 778 | 834 | { |
| 779 | 835 | $err = lang('for more than one contact in a document use the tag pagerepeat!'); |
| 780 | 836 | return false; |
| 781 | 837 | } |
| 782 | - if ($this->report_memory_usage) error_log(__METHOD__."(count(ids)=".count($ids).") strlen(contentrepeat)=".strlen($contentrepeat).', strlen(labelrepeat)='.strlen($Labelrepeat)); |
|
| 838 | + if ($this->report_memory_usage) |
|
| 839 | + { |
|
| 840 | + error_log(__METHOD__."(count(ids)=".count($ids).") strlen(contentrepeat)=".strlen($contentrepeat).', strlen(labelrepeat)='.strlen($Labelrepeat)); |
|
| 841 | + } |
|
| 783 | 842 | |
| 784 | 843 | if ($contentrepeat) |
| 785 | 844 | { |
@@ -814,8 +873,15 @@ discard block |
||
| 814 | 873 | } |
| 815 | 874 | foreach ((array)$ids as $n => $id) |
| 816 | 875 | { |
| 817 | - if ($contentrepeat) $content = $contentrepeat; //content to repeat |
|
| 818 | - if ($lableprint) $content = $Labelrepeat; |
|
| 876 | + if ($contentrepeat) |
|
| 877 | + { |
|
| 878 | + $content = $contentrepeat; |
|
| 879 | + } |
|
| 880 | + //content to repeat |
|
| 881 | + if ($lableprint) |
|
| 882 | + { |
|
| 883 | + $content = $Labelrepeat; |
|
| 884 | + } |
|
| 819 | 885 | |
| 820 | 886 | // generate replacements; if exeption is thrown, catch it set error message and return false |
| 821 | 887 | try |
@@ -832,7 +898,10 @@ discard block |
||
| 832 | 898 | $err = $e->getMessage(); |
| 833 | 899 | return false; |
| 834 | 900 | } |
| 835 | - if ($this->report_memory_usage) error_log(__METHOD__."() $n: $id ".Api\Vfs::hsize(memory_get_usage(true))); |
|
| 901 | + if ($this->report_memory_usage) |
|
| 902 | + { |
|
| 903 | + error_log(__METHOD__."() $n: $id ".Api\Vfs::hsize(memory_get_usage(true))); |
|
| 904 | + } |
|
| 836 | 905 | // some general replacements: current user, date and time |
| 837 | 906 | if (strpos($content,'$$user/') !== null && ($user = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))) |
| 838 | 907 | { |
@@ -890,9 +959,12 @@ discard block |
||
| 890 | 959 | { |
| 891 | 960 | $contentrepeatpages[$countpage] = preg_replace('/\$\$labelplacement\$\$/',$Label,$contentrepeatpages[$countpage],1); |
| 892 | 961 | $count=$count+1; |
| 893 | - if (($count % $countlables) == 0 && count($contentrep)>$count) //new page |
|
| 962 | + if (($count % $countlables) == 0 && count($contentrep)>$count) |
|
| 963 | + { |
|
| 964 | + //new page |
|
| 894 | 965 | { |
| 895 | 966 | $countpage = $countpage+1; |
| 967 | + } |
|
| 896 | 968 | $contentrepeatpages[$countpage] = $Labelstart.$Labeltend; |
| 897 | 969 | } |
| 898 | 970 | } |
@@ -925,7 +997,10 @@ discard block |
||
| 925 | 997 | rewind($content_stream); |
| 926 | 998 | return stream_get_contents($content_stream); |
| 927 | 999 | } |
| 928 | - if ($this->report_memory_usage) error_log(__METHOD__."() returning ".Api\Vfs::hsize(memory_get_peak_usage(true))); |
|
| 1000 | + if ($this->report_memory_usage) |
|
| 1001 | + { |
|
| 1002 | + error_log(__METHOD__."() returning ".Api\Vfs::hsize(memory_get_peak_usage(true))); |
|
| 1003 | + } |
|
| 929 | 1004 | |
| 930 | 1005 | return $content; |
| 931 | 1006 | } |
@@ -970,7 +1045,10 @@ discard block |
||
| 970 | 1045 | break; |
| 971 | 1046 | |
| 972 | 1047 | default: // div. text files --> use our export-charset, defined in addressbook prefs |
| 973 | - if (empty($charset)) $charset = $this->contacts->prefs['csv_charset']; |
|
| 1048 | + if (empty($charset)) |
|
| 1049 | + { |
|
| 1050 | + $charset = $this->contacts->prefs['csv_charset']; |
|
| 1051 | + } |
|
| 974 | 1052 | break; |
| 975 | 1053 | } |
| 976 | 1054 | //error_log(__METHOD__."('$document', ... ,$mimetype) --> $charset (egw=".Api\Translation::charset().', export='.$this->contacts->prefs['csv_charset'].')'); |
@@ -993,10 +1071,13 @@ discard block |
||
| 993 | 1071 | } |
| 994 | 1072 | } |
| 995 | 1073 | } |
| 996 | - if ($is_xml) // zip'ed xml document (eg. OO) |
|
| 1074 | + if ($is_xml) |
|
| 1075 | + { |
|
| 1076 | + // zip'ed xml document (eg. OO) |
|
| 997 | 1077 | { |
| 998 | 1078 | // Numeric fields |
| 999 | 1079 | $names = array(); |
| 1080 | + } |
|
| 1000 | 1081 | |
| 1001 | 1082 | // Tags we can replace with the target document's version |
| 1002 | 1083 | $replace_tags = array(); |
@@ -1061,7 +1142,8 @@ discard block |
||
| 1061 | 1142 | else if (is_string($value) && (strpos($value,'<') !== false)) |
| 1062 | 1143 | { |
| 1063 | 1144 | // Clean HTML, if it's being kept |
| 1064 | - if($replace_tags && extension_loaded('tidy')) { |
|
| 1145 | + if($replace_tags && extension_loaded('tidy')) |
|
| 1146 | + { |
|
| 1065 | 1147 | $tidy = new tidy(); |
| 1066 | 1148 | $cleaned = $tidy->repairString($value, self::$tidy_config); |
| 1067 | 1149 | // Found errors. Strip it all so there's some output |
@@ -1095,16 +1177,20 @@ discard block |
||
| 1095 | 1177 | // replace all control chars (C0+C1) but CR (\015), LF (\012) and TAB (\011) (eg. vertical tabulators) with space |
| 1096 | 1178 | // as they are not allowed in xml |
| 1097 | 1179 | $value = preg_replace('/[\000-\010\013\014\016-\037\177-\237]/u',' ',$value); |
| 1098 | - if(is_numeric($value) && $name != '$$user/account_id$$') // account_id causes problems with the preg_replace below |
|
| 1180 | + if(is_numeric($value) && $name != '$$user/account_id$$') |
|
| 1181 | + { |
|
| 1182 | + // account_id causes problems with the preg_replace below |
|
| 1099 | 1183 | { |
| 1100 | 1184 | $names[] = preg_quote($name,'/'); |
| 1101 | 1185 | } |
| 1186 | + } |
|
| 1102 | 1187 | } |
| 1103 | 1188 | |
| 1104 | 1189 | // Look for numbers, set their value if needed |
| 1105 | 1190 | if($this->numeric_fields || count($names)) |
| 1106 | 1191 | { |
| 1107 | - foreach((array)$this->numeric_fields as $fieldname) { |
|
| 1192 | + foreach((array)$this->numeric_fields as $fieldname) |
|
| 1193 | + { |
|
| 1108 | 1194 | $names[] = preg_quote($fieldname,'/'); |
| 1109 | 1195 | } |
| 1110 | 1196 | $this->format_spreadsheet_numbers($content, $names, $mimetype.$mso_application_progid); |
@@ -1114,7 +1200,8 @@ discard block |
||
| 1114 | 1200 | if($this->date_fields || count($names)) |
| 1115 | 1201 | { |
| 1116 | 1202 | $names = array(); |
| 1117 | - foreach((array)$this->date_fields as $fieldname) { |
|
| 1203 | + foreach((array)$this->date_fields as $fieldname) |
|
| 1204 | + { |
|
| 1118 | 1205 | $names[] = $fieldname; |
| 1119 | 1206 | } |
| 1120 | 1207 | $this->format_spreadsheet_dates($content, $names, $replacements, $mimetype.$mso_application_progid); |
@@ -1193,7 +1280,8 @@ discard block |
||
| 1193 | 1280 | */ |
| 1194 | 1281 | protected function format_spreadsheet_numbers(&$content, $names, $mimetype) |
| 1195 | 1282 | { |
| 1196 | - foreach((array)$this->numeric_fields as $fieldname) { |
|
| 1283 | + foreach((array)$this->numeric_fields as $fieldname) |
|
| 1284 | + { |
|
| 1197 | 1285 | $names[] = preg_quote($fieldname,'/'); |
| 1198 | 1286 | } |
| 1199 | 1287 | switch($mimetype) |
@@ -1222,7 +1310,11 @@ discard block |
||
| 1222 | 1310 | // try to increase/double pcre.backtrack_limit failure |
| 1223 | 1311 | while(preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR && self::increase_backtrack_limit()); |
| 1224 | 1312 | |
| 1225 | - if ($result) $content = $result; // On failure $result would be NULL |
|
| 1313 | + if ($result) |
|
| 1314 | + { |
|
| 1315 | + $content = $result; |
|
| 1316 | + } |
|
| 1317 | + // On failure $result would be NULL |
|
| 1226 | 1318 | } |
| 1227 | 1319 | } |
| 1228 | 1320 | |
@@ -1266,7 +1358,10 @@ discard block |
||
| 1266 | 1358 | 'application/vnd.oasis.opendocument.spreadsheet', // open office calc |
| 1267 | 1359 | 'application/xmlExcel.Sheet', // Excel 2003 |
| 1268 | 1360 | //'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'//Excel WTF |
| 1269 | - ))) return; |
|
| 1361 | + ))) |
|
| 1362 | + { |
|
| 1363 | + return; |
|
| 1364 | + } |
|
| 1270 | 1365 | |
| 1271 | 1366 | // Some different formats dates could be in, depending what they've been through |
| 1272 | 1367 | $formats = array( |
@@ -1287,9 +1382,12 @@ discard block |
||
| 1287 | 1382 | { |
| 1288 | 1383 | $date = Api\DateTime::createFromUserFormat($values[$key]); |
| 1289 | 1384 | if($mimetype == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || |
| 1290 | - $mimetype == 'application/vnd.ms-excel.sheet.macroenabled.12')//Excel WTF |
|
| 1385 | + $mimetype == 'application/vnd.ms-excel.sheet.macroenabled.12') |
|
| 1386 | + { |
|
| 1387 | + //Excel WTF |
|
| 1291 | 1388 | { |
| 1292 | 1389 | $interval = $date->diff(new Api\DateTime('1900-01-00 0:00')); |
| 1390 | + } |
|
| 1293 | 1391 | $values[$key] = $interval->format('%a')+1;// 1900-02-29 did not exist |
| 1294 | 1392 | // 1440 minutes in a day - fractional part |
| 1295 | 1393 | $values[$key] += ($date->format('H') * 60 + $date->format('i'))/1440; |
@@ -1332,7 +1430,11 @@ discard block |
||
| 1332 | 1430 | // try to increase/double pcre.backtrack_limit failure |
| 1333 | 1431 | while(preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR && self::increase_backtrack_limit()); |
| 1334 | 1432 | |
| 1335 | - if ($result) $content = $result; // On failure $result would be NULL |
|
| 1433 | + if ($result) |
|
| 1434 | + { |
|
| 1435 | + $content = $result; |
|
| 1436 | + } |
|
| 1437 | + // On failure $result would be NULL |
|
| 1336 | 1438 | } |
| 1337 | 1439 | } |
| 1338 | 1440 | |
@@ -1403,7 +1505,10 @@ discard block |
||
| 1403 | 1505 | } |
| 1404 | 1506 | else |
| 1405 | 1507 | { |
| 1406 | - if ($cfs[$field]['type'] == 'date' || $cfs[$field]['type'] == 'date-time') $this->date_fields[] = '#'.$field; |
|
| 1508 | + if ($cfs[$field]['type'] == 'date' || $cfs[$field]['type'] == 'date-time') |
|
| 1509 | + { |
|
| 1510 | + $this->date_fields[] = '#'.$field; |
|
| 1511 | + } |
|
| 1407 | 1512 | } |
| 1408 | 1513 | } |
| 1409 | 1514 | } |
@@ -1457,30 +1562,35 @@ discard block |
||
| 1457 | 1562 | private function process_commands($content, $replacements) |
| 1458 | 1563 | { |
| 1459 | 1564 | if (strpos($content,'$$IF') !== false) |
| 1460 | - { //Example use to use: $$IF n_prefix~Herr~Sehr geehrter~Sehr geehrte$$ |
|
| 1565 | + { |
|
| 1566 | +//Example use to use: $$IF n_prefix~Herr~Sehr geehrter~Sehr geehrte$$ |
|
| 1461 | 1567 | $this->replacements =& $replacements; |
| 1462 | 1568 | $content = preg_replace_callback('/\$\$IF ([#0-9a-z_\/-]+)~(.*)~(.*)~(.*)\$\$/imU',Array($this,'replace_callback'),$content); |
| 1463 | 1569 | unset($this->replacements); |
| 1464 | 1570 | } |
| 1465 | 1571 | if (strpos($content,'$$NELF') !== false) |
| 1466 | - { //Example: $$NEPBR org_unit$$ sets a LF and value of org_unit, only if there is a value |
|
| 1572 | + { |
|
| 1573 | +//Example: $$NEPBR org_unit$$ sets a LF and value of org_unit, only if there is a value |
|
| 1467 | 1574 | $this->replacements =& $replacements; |
| 1468 | 1575 | $content = preg_replace_callback('/\$\$NELF ([#0-9a-z_\/-]+)\$\$/imU',Array($this,'replace_callback'),$content); |
| 1469 | 1576 | unset($this->replacements); |
| 1470 | 1577 | } |
| 1471 | 1578 | if (strpos($content,'$$NENVLF') !== false) |
| 1472 | - { //Example: $$NEPBRNV org_unit$$ sets only a LF if there is a value for org_units, but did not add any value |
|
| 1579 | + { |
|
| 1580 | +//Example: $$NEPBRNV org_unit$$ sets only a LF if there is a value for org_units, but did not add any value |
|
| 1473 | 1581 | $this->replacements =& $replacements; |
| 1474 | 1582 | $content = preg_replace_callback('/\$\$NENVLF ([#0-9a-z_\/-]+)\$\$/imU',Array($this,'replace_callback'),$content); |
| 1475 | 1583 | unset($this->replacements); |
| 1476 | 1584 | } |
| 1477 | 1585 | if (strpos($content,'$$LETTERPREFIX$$') !== false) |
| 1478 | - { //Example use to use: $$LETTERPREFIX$$ |
|
| 1586 | + { |
|
| 1587 | +//Example use to use: $$LETTERPREFIX$$ |
|
| 1479 | 1588 | $LETTERPREFIXCUSTOM = '$$LETTERPREFIXCUSTOM n_prefix title n_family$$'; |
| 1480 | 1589 | $content = str_replace('$$LETTERPREFIX$$',$LETTERPREFIXCUSTOM,$content); |
| 1481 | 1590 | } |
| 1482 | 1591 | if (strpos($content,'$$LETTERPREFIXCUSTOM') !== false) |
| 1483 | - { //Example use to use for a custom Letter Prefix: $$LETTERPREFIX n_prefix title n_family$$ |
|
| 1592 | + { |
|
| 1593 | +//Example use to use for a custom Letter Prefix: $$LETTERPREFIX n_prefix title n_family$$ |
|
| 1484 | 1594 | $this->replacements =& $replacements; |
| 1485 | 1595 | $content = preg_replace_callback('/\$\$LETTERPREFIXCUSTOM ([#0-9a-z_-]+)(.*)\$\$/imU',Array($this,'replace_callback'),$content); |
| 1486 | 1596 | unset($this->replacements); |
@@ -1496,8 +1606,14 @@ discard block |
||
| 1496 | 1606 | */ |
| 1497 | 1607 | private function replace_callback($param) |
| 1498 | 1608 | { |
| 1499 | - if (array_key_exists('$$'.$param[4].'$$',$this->replacements)) $param[4] = $this->replacements['$$'.$param[4].'$$']; |
|
| 1500 | - if (array_key_exists('$$'.$param[3].'$$',$this->replacements)) $param[3] = $this->replacements['$$'.$param[3].'$$']; |
|
| 1609 | + if (array_key_exists('$$'.$param[4].'$$',$this->replacements)) |
|
| 1610 | + { |
|
| 1611 | + $param[4] = $this->replacements['$$'.$param[4].'$$']; |
|
| 1612 | + } |
|
| 1613 | + if (array_key_exists('$$'.$param[3].'$$',$this->replacements)) |
|
| 1614 | + { |
|
| 1615 | + $param[3] = $this->replacements['$$'.$param[3].'$$']; |
|
| 1616 | + } |
|
| 1501 | 1617 | |
| 1502 | 1618 | $pattern = '/'.preg_quote($param[2], '/').'/'; |
| 1503 | 1619 | if (strpos($param[0],'$$IF') === 0 && (trim($param[2]) == "EMPTY" || $param[2] === '')) |
@@ -1521,7 +1637,7 @@ discard block |
||
| 1521 | 1637 | } |
| 1522 | 1638 | |
| 1523 | 1639 | switch($this->mimetype) |
| 1524 | - { |
|
| 1640 | + { |
|
| 1525 | 1641 | case 'application/rtf': |
| 1526 | 1642 | case 'text/rtf': |
| 1527 | 1643 | $LF = '}\par \pard\plain{'; |
@@ -1550,25 +1666,38 @@ discard block |
||
| 1550 | 1666 | default: |
| 1551 | 1667 | $LF = "\n"; |
| 1552 | 1668 | } |
| 1553 | - if($is_xml) { |
|
| 1669 | + if($is_xml) |
|
| 1670 | + { |
|
| 1554 | 1671 | $this->replacements = str_replace(array('&','&amp;','<','>',"\r","\n"),array('&','&','<','>','',$LF),$this->replacements); |
| 1555 | 1672 | } |
| 1556 | 1673 | if (strpos($param[0],'$$NELF') === 0) |
| 1557 | - { //sets a Pagebreak and value, only if the field has a value |
|
| 1558 | - if ($this->replacements['$$'.$param[1].'$$'] !='') $replace = $LF.$this->replacements['$$'.$param[1].'$$']; |
|
| 1674 | + { |
|
| 1675 | +//sets a Pagebreak and value, only if the field has a value |
|
| 1676 | + if ($this->replacements['$$'.$param[1].'$$'] !='') |
|
| 1677 | + { |
|
| 1678 | + $replace = $LF.$this->replacements['$$'.$param[1].'$$']; |
|
| 1679 | + } |
|
| 1559 | 1680 | } |
| 1560 | 1681 | if (strpos($param[0],'$$NENVLF') === 0) |
| 1561 | - { //sets a Pagebreak without any value, only if the field has a value |
|
| 1562 | - if ($this->replacements['$$'.$param[1].'$$'] !='') $replace = $LF; |
|
| 1682 | + { |
|
| 1683 | +//sets a Pagebreak without any value, only if the field has a value |
|
| 1684 | + if ($this->replacements['$$'.$param[1].'$$'] !='') |
|
| 1685 | + { |
|
| 1686 | + $replace = $LF; |
|
| 1687 | + } |
|
| 1563 | 1688 | } |
| 1564 | 1689 | if (strpos($param[0],'$$LETTERPREFIXCUSTOM') === 0) |
| 1565 | - { //sets a Letterprefix |
|
| 1690 | + { |
|
| 1691 | +//sets a Letterprefix |
|
| 1566 | 1692 | $replaceprefixsort = array(); |
| 1567 | 1693 | // ToDo Stefan: $contentstart is NOT defined here!!! |
| 1568 | 1694 | $replaceprefix = explode(' ',substr($param[0],21,-2)); |
| 1569 | 1695 | foreach ($replaceprefix as $nameprefix) |
| 1570 | 1696 | { |
| 1571 | - if ($this->replacements['$$'.$nameprefix.'$$'] !='') $replaceprefixsort[] = $this->replacements['$$'.$nameprefix.'$$']; |
|
| 1697 | + if ($this->replacements['$$'.$nameprefix.'$$'] !='') |
|
| 1698 | + { |
|
| 1699 | + $replaceprefixsort[] = $this->replacements['$$'.$nameprefix.'$$']; |
|
| 1700 | + } |
|
| 1572 | 1701 | } |
| 1573 | 1702 | $replace = implode($replaceprefixsort,' '); |
| 1574 | 1703 | } |
@@ -1609,13 +1738,20 @@ discard block |
||
| 1609 | 1738 | } |
| 1610 | 1739 | //error_log(__METHOD__.__LINE__.' Message after importMessageToMergeAndSend:'.array2string($msgs)); |
| 1611 | 1740 | $retString = ''; |
| 1612 | - if (count($msgs['success'])>0) $retString .= count($msgs['success']).' '.(count($msgs['success'])+count($msgs['failed'])==1?lang('Message prepared for sending.'):lang('Message(s) send ok.'));//implode('<br />',$msgs['success']); |
|
| 1741 | + if (count($msgs['success'])>0) |
|
| 1742 | + { |
|
| 1743 | + $retString .= count($msgs['success']).' '.(count($msgs['success'])+count($msgs['failed'])==1?lang('Message prepared for sending.'):lang('Message(s) send ok.')); |
|
| 1744 | + } |
|
| 1745 | + //implode('<br />',$msgs['success']); |
|
| 1613 | 1746 | //if (strlen($retString)>0) $retString .= '<br />'; |
| 1614 | 1747 | foreach($msgs['failed'] as $c =>$e) |
| 1615 | 1748 | { |
| 1616 | 1749 | $errorString .= lang('contact').' '.lang('id').':'.$c.'->'.$e.'.'; |
| 1617 | 1750 | } |
| 1618 | - if (count($msgs['failed'])>0) $retString .= count($msgs['failed']).' '.lang('Message(s) send failed!').'=>'.$errorString; |
|
| 1751 | + if (count($msgs['failed'])>0) |
|
| 1752 | + { |
|
| 1753 | + $retString .= count($msgs['failed']).' '.lang('Message(s) send failed!').'=>'.$errorString; |
|
| 1754 | + } |
|
| 1619 | 1755 | return $retString; |
| 1620 | 1756 | case 'application/vnd.oasis.opendocument.text': |
| 1621 | 1757 | case 'application/vnd.oasis.opendocument.spreadsheet': |
@@ -1689,7 +1825,10 @@ discard block |
||
| 1689 | 1825 | return $err; |
| 1690 | 1826 | } |
| 1691 | 1827 | } |
| 1692 | - if ($this->report_memory_usage) error_log(__METHOD__."() after HTML processing ".Api\Vfs::hsize(memory_get_peak_usage(true))); |
|
| 1828 | + if ($this->report_memory_usage) |
|
| 1829 | + { |
|
| 1830 | + error_log(__METHOD__."() after HTML processing ".Api\Vfs::hsize(memory_get_peak_usage(true))); |
|
| 1831 | + } |
|
| 1693 | 1832 | } |
| 1694 | 1833 | if(!empty($name)) |
| 1695 | 1834 | { |
@@ -1709,13 +1848,25 @@ discard block |
||
| 1709 | 1848 | if ($zip->open($archive, ZipArchive::CHECKCONS) !== true) |
| 1710 | 1849 | { |
| 1711 | 1850 | error_log(__METHOD__.__LINE__." !ZipArchive::open('$archive',ZIPARCHIVE"."::CHECKCONS) failed. Trying open without validating"); |
| 1712 | - if ($zip->open($archive) !== true) throw new Api\Exception("!ZipArchive::open('$archive',|ZIPARCHIVE::CHECKCONS)"); |
|
| 1851 | + if ($zip->open($archive) !== true) |
|
| 1852 | + { |
|
| 1853 | + throw new Api\Exception("!ZipArchive::open('$archive',|ZIPARCHIVE::CHECKCONS)"); |
|
| 1854 | + } |
|
| 1855 | + } |
|
| 1856 | + if ($zip->addFromString($content_file,$merged) !== true) |
|
| 1857 | + { |
|
| 1858 | + throw new Api\Exception("!ZipArchive::addFromString('$content_file',\$merged)"); |
|
| 1859 | + } |
|
| 1860 | + if ($zip->close() !== true) |
|
| 1861 | + { |
|
| 1862 | + throw new Api\Exception("!ZipArchive::close()"); |
|
| 1713 | 1863 | } |
| 1714 | - if ($zip->addFromString($content_file,$merged) !== true) throw new Api\Exception("!ZipArchive::addFromString('$content_file',\$merged)"); |
|
| 1715 | - if ($zip->close() !== true) throw new Api\Exception("!ZipArchive::close()"); |
|
| 1716 | 1864 | unset($zip); |
| 1717 | 1865 | unset($merged); |
| 1718 | - if ($this->report_memory_usage) error_log(__METHOD__."() after ZIP processing ".Api\Vfs::hsize(memory_get_peak_usage(true))); |
|
| 1866 | + if ($this->report_memory_usage) |
|
| 1867 | + { |
|
| 1868 | + error_log(__METHOD__."() after ZIP processing ".Api\Vfs::hsize(memory_get_peak_usage(true))); |
|
| 1869 | + } |
|
| 1719 | 1870 | Api\Header\Content::type($name,$mimetype,filesize($archive)); |
| 1720 | 1871 | readfile($archive,'r'); |
| 1721 | 1872 | } |
@@ -1750,9 +1901,18 @@ discard block |
||
| 1750 | 1901 | */ |
| 1751 | 1902 | public function download_by_request() |
| 1752 | 1903 | { |
| 1753 | - if(empty($_POST['data_document_name'])) return false; |
|
| 1754 | - if(empty($_POST['data_document_dir'])) return false; |
|
| 1755 | - if(empty($_POST['data_checked'])) return false; |
|
| 1904 | + if(empty($_POST['data_document_name'])) |
|
| 1905 | + { |
|
| 1906 | + return false; |
|
| 1907 | + } |
|
| 1908 | + if(empty($_POST['data_document_dir'])) |
|
| 1909 | + { |
|
| 1910 | + return false; |
|
| 1911 | + } |
|
| 1912 | + if(empty($_POST['data_checked'])) |
|
| 1913 | + { |
|
| 1914 | + return false; |
|
| 1915 | + } |
|
| 1756 | 1916 | |
| 1757 | 1917 | return $this->download( |
| 1758 | 1918 | $_POST['data_document_name'], |
@@ -1773,7 +1933,10 @@ discard block |
||
| 1773 | 1933 | public static function get_documents($dirs, $prefix='document_', $mime_filter=null, $app='') |
| 1774 | 1934 | { |
| 1775 | 1935 | $export_limit=self::getExportLimit($app); |
| 1776 | - if (!$dirs || (!self::hasExportLimit($export_limit,'ISALLOWED') && !self::is_export_limit_excepted())) return array(); |
|
| 1936 | + if (!$dirs || (!self::hasExportLimit($export_limit,'ISALLOWED') && !self::is_export_limit_excepted())) |
|
| 1937 | + { |
|
| 1938 | + return array(); |
|
| 1939 | + } |
|
| 1777 | 1940 | |
| 1778 | 1941 | // split multiple comma or whitespace separated directories |
| 1779 | 1942 | // to still allow space or comma in dirnames, we also use the trailing slash of all pathes to split |
@@ -1781,7 +1944,11 @@ discard block |
||
| 1781 | 1944 | { |
| 1782 | 1945 | foreach($dirs as $n => &$d) |
| 1783 | 1946 | { |
| 1784 | - if ($n) $d = '/'.$d; // re-adding trailing slash removed by split |
|
| 1947 | + if ($n) |
|
| 1948 | + { |
|
| 1949 | + $d = '/'.$d; |
|
| 1950 | + } |
|
| 1951 | + // re-adding trailing slash removed by split |
|
| 1785 | 1952 | } |
| 1786 | 1953 | } |
| 1787 | 1954 | if ($mime_filter && ($negativ_filter = $mime_filter[0] === '!')) |
@@ -1804,8 +1971,14 @@ discard block |
||
| 1804 | 1971 | { |
| 1805 | 1972 | // return only the mime-types we support |
| 1806 | 1973 | $parts = explode('.',$file['name']); |
| 1807 | - if (!self::is_implemented($file['mime'],'.'.array_pop($parts))) continue; |
|
| 1808 | - if ($mime_filter && $negativ_filter === in_array($file['mime'], (array)$mime_filter)) continue; |
|
| 1974 | + if (!self::is_implemented($file['mime'],'.'.array_pop($parts))) |
|
| 1975 | + { |
|
| 1976 | + continue; |
|
| 1977 | + } |
|
| 1978 | + if ($mime_filter && $negativ_filter === in_array($file['mime'], (array)$mime_filter)) |
|
| 1979 | + { |
|
| 1980 | + continue; |
|
| 1981 | + } |
|
| 1809 | 1982 | $list[$prefix.$file['name']] = Api\Vfs::decodePath($file['name']); |
| 1810 | 1983 | } |
| 1811 | 1984 | } |
@@ -1835,12 +2008,19 @@ discard block |
||
| 1835 | 2008 | $export_limit=null) |
| 1836 | 2009 | { |
| 1837 | 2010 | $documents = array(); |
| 1838 | - if ($export_limit == null) $export_limit = self::getExportLimit(); // check if there is a globalsetting |
|
| 1839 | - if ($default_doc && ($file = Api\Vfs::stat($default_doc))) // put default document on top |
|
| 2011 | + if ($export_limit == null) |
|
| 2012 | + { |
|
| 2013 | + $export_limit = self::getExportLimit(); |
|
| 2014 | + } |
|
| 2015 | + // check if there is a globalsetting |
|
| 2016 | + if ($default_doc && ($file = Api\Vfs::stat($default_doc))) |
|
| 2017 | + { |
|
| 2018 | + // put default document on top |
|
| 1840 | 2019 | { |
| 1841 | 2020 | if(!$file['mime']) |
| 1842 | 2021 | { |
| 1843 | 2022 | $file['mime'] = Api\Vfs::mime_content_type($default_doc); |
| 2023 | + } |
|
| 1844 | 2024 | $file['path'] = $default_doc; |
| 1845 | 2025 | } |
| 1846 | 2026 | $documents['document'] = array( |
@@ -1864,7 +2044,11 @@ discard block |
||
| 1864 | 2044 | { |
| 1865 | 2045 | foreach($dirs as $n => &$d) |
| 1866 | 2046 | { |
| 1867 | - if ($n) $d = '/'.$d; // re-adding trailing slash removed by split |
|
| 2047 | + if ($n) |
|
| 2048 | + { |
|
| 2049 | + $d = '/'.$d; |
|
| 2050 | + } |
|
| 2051 | + // re-adding trailing slash removed by split |
|
| 1868 | 2052 | } |
| 1869 | 2053 | } |
| 1870 | 2054 | foreach($dirs as $dir) |
@@ -1884,10 +2068,13 @@ discard block |
||
| 1884 | 2068 | $parts = explode('.',$file['name']); |
| 1885 | 2069 | if (!self::is_implemented($file['mime'],'.'.array_pop($parts)) || |
| 1886 | 2070 | !Api\Vfs::check_access($file['path'], Api\Vfs::READABLE, $file) || // remove files not readable by user |
| 1887 | - $file['path'] === $default_doc) // default doc already added |
|
| 2071 | + $file['path'] === $default_doc) |
|
| 2072 | + { |
|
| 2073 | + // default doc already added |
|
| 1888 | 2074 | { |
| 1889 | 2075 | unset($files[$key]); |
| 1890 | 2076 | } |
| 2077 | + } |
|
| 1891 | 2078 | else |
| 1892 | 2079 | { |
| 1893 | 2080 | $dirname = Api\Vfs::dirname($file['path']); |
@@ -2046,7 +2233,11 @@ discard block |
||
| 2046 | 2233 | { |
| 2047 | 2234 | foreach($dirs as $n => $dir) |
| 2048 | 2235 | { |
| 2049 | - if ($n) $dir = '/'.$dir; // re-adding trailing slash removed by split |
|
| 2236 | + if ($n) |
|
| 2237 | + { |
|
| 2238 | + $dir = '/'.$dir; |
|
| 2239 | + } |
|
| 2240 | + // re-adding trailing slash removed by split |
|
| 2050 | 2241 | if (Api\Vfs::stat($dir.'/'.$document) && Api\Vfs::is_readable($dir.'/'.$document)) |
| 2051 | 2242 | { |
| 2052 | 2243 | $document = $dir.'/'.$document; |
@@ -2083,7 +2274,10 @@ discard block |
||
| 2083 | 2274 | */ |
| 2084 | 2275 | static public function number_format($number,$num_decimal_places=2,$_mimetype='') |
| 2085 | 2276 | { |
| 2086 | - if ((string)$number === '') return ''; |
|
| 2277 | + if ((string)$number === '') |
|
| 2278 | + { |
|
| 2279 | + return ''; |
|
| 2280 | + } |
|
| 2087 | 2281 | //error_log(__METHOD__.$_mimetype); |
| 2088 | 2282 | switch($_mimetype) |
| 2089 | 2283 | { |