28e8a35989a53608ae652de39340a15686f50ebb
2 /********************************************************************************
3 * include/spool.inc.php : spool subroutines
4 * -----------------------
6 * This file is part of the banana distribution
7 * Copyright: See COPYING files that comes with this distribution
8 ********************************************************************************/
10 require_once dirname(__FILE__
) . '/banana.inc.php';
12 define('BANANA_SPOOL_VERSION', '0.5.7');
15 * class used in thread overviews
19 /** date (timestamp) */
27 /** reference of parent */
28 public $parent = null
;
29 /** paren is direct */
30 public $parent_direct;
31 /** array of children */
32 public $children = Array();
33 /** true if post is read */
35 /** number of posts deeper in this branch of tree */
37 /** same as desc, but counts only unread posts */
41 public $storage = array();
44 * @param $_date INTEGER timestamp of post
45 * @param $_subject STRING subject of post
46 * @param $_from STRING author of post
47 * @param $_desc INTEGER desc value (1 for a new post)
48 * @param $_read BOOLEAN true if read
49 * @param $_descunread INTEGER descunread value (0 for a new post)
51 public function __construct(array &$message)
53 $this->date
= $message['date'];
54 $this->subject
= $message['subject'];
55 $this->from
= $message['from'];
56 $this->color
= sprintf('#%06x', abs(crc32($this->from
) %
0xffffff));
59 $this->descunread
= 0;
60 if (preg_match("/^([^ ]+@[^ ]+) \((.*)\)$/", $this->from
, $regs)) {
61 $this->name
= $regs[2];
63 if (preg_match("/^\"?([^<>\"]+)\"? +<(.+@.+)>$/", $this->from
, $regs)) {
64 $this->name
= preg_replace("/^'(.*)'$/", '\1', $regs[1]);
65 $this->name
= stripslashes($this->name
);
68 $this->name
= preg_replace("/\\\(\(|\))/","\\1", $this->name
);
69 } else if (preg_match("/([^< ]+)@([^> ]+)/", $this->from
, $regs)) {
70 $this->name
= $regs[1];
72 $this->name
= 'Anonymous';
87 /** array msgid => msgnum */
91 /** thread trees (one tree per root node) */
92 public $trees = array();
94 /** protocole specific data */
95 public $storage = array();
97 private $unreadnb = 0;
100 * @param $_group STRING group name
101 * @param $_display INTEGER 1 => all posts, 2 => only threads with new posts
102 * @param $_since INTEGER time stamp (used for read/unread)
104 protected function __construct($group)
106 $this->version
= BANANA_SPOOL_VERSION
;
107 $this->mode
= Banana
::SPOOL_ALL
;
108 $this->group
= $group;
111 public static function &getSpool($group, $since = 0, $clean = false
)
113 if (!is_null(Banana
::$spool) && Banana
::$spool->group
== $group) {
114 $spool =& Banana
::$spool;
116 $spool =& BananaSpool
::readFromFile($group);
118 if (is_null($spool)) {
119 $spool = new BananaSpool($group);
121 Banana
::$spool =& $spool;
124 $spool->markAllAsRead();
126 $spool->updateUnread($since);
130 private static function spoolFilename($group)
132 $file = Banana
::$spool_root . '/' . Banana
::$protocole->name() . '/';
133 if (!is_dir($file)) {
136 return $file . Banana
::$protocole->filename();
139 private static function &readFromFile($group)
142 $file = BananaSpool
::spoolFilename($group);
143 if (!file_exists($file)) {
146 $spool = unserialize(file_get_contents($file));
147 if ($spool->version
!= BANANA_SPOOL_VERSION ||
$spool->mode
!= Banana
::SPOOL_ALL
) {
151 $spool->markAllAsRead();
155 private function compare($a, $b)
157 return ($this->overview
[$b]->date
>= $this->overview
[$a]->date
);
160 private function saveToFile()
162 $file = BananaSpool
::spoolFilename($this->group
);
164 $this->roots
= Array();
165 foreach($this->overview
as $id=>&$msg) {
166 if (is_null($msg->parent
)) {
167 $this->roots
[] = $id;
170 usort($this->roots
, array($this, 'compare'));
172 if ($this->mode
== Banana
::SPOOL_ALL
) {
173 file_put_contents($file, serialize($this));
177 private function build()
181 // Compute the range of indexes
182 list($msgnum, $first, $last) = Banana
::$protocole->getIndexes();
183 if ($last < $first) {
184 $threshold = $first +
$msgnum - $last;
185 $threshold = (int)(log($threshold)/log(2));
186 $threshold = (2 ^
($threshold +
1)) - 1;
188 if (Banana
::$spool_max && Banana
::$spool_max < $msgnum) {
189 $first = $last - Banana
::$spool_max;
191 $first +
= $threshold;
194 $clean = $this->clean($first, $last, $msgnum);
195 $update = $this->update($first, $last, $msgnum);
197 if ($clean ||
$update) {
202 private function clean(&$first, &$last, $msgnum)
205 if (is_array($this->overview
)) {
206 $mids = array_keys($this->overview
);
207 foreach ($mids as $id) {
208 if (($first <= $last && ($id < $first ||
$id > $last))
209 ||
($first > $last && $id < $first && $id > $last)) {
210 $this->delid($id, false
);
214 if (!empty($this->overview
)) {
215 $first = max(array_keys($this->overview
))+
1;
221 private function update(&$first, &$last, $msgnum)
223 if ($first > $last ||
!$msgnum) {
227 $messages =& Banana
::$protocole->getMessageHeaders($first, $last,
228 array('Date', 'Subject', 'From', 'Message-ID', 'References', 'In-Reply-To'));
230 if (!is_array($this->ids
)) {
231 $this->ids
= array();
233 foreach ($messages as $id=>&$message) {
234 $this->ids
[$message['message-id']] = $id;
237 if (!is_array($this->overview
)) {
238 $this->overview
= array();
240 $updateTrees = array();
241 foreach ($messages as $id=>&$message) {
242 if (!isset($this->overview
[$id])) {
243 $this->overview
[$id] = new BananaSpoolHead($message);
245 $msg =& $this->overview
[$id];
246 $msgrefs = BananaMessage
::formatReferences($message);
247 $parents = preg_grep('/^\d+$/', $msgrefs);
248 $msg->parent
= array_pop($parents);
249 $msg->parent_direct
= preg_match('/^\d+$/', array_pop($msgrefs));
251 if (!is_null($p = $msg->parent
)) {
252 if (empty($this->overview
[$p])) {
253 $this->overview
[$p] = new BananaSpoolHead($messages[$p]);
255 $this->overview
[$p]->children
[] = $id;
256 while (!is_null($p)) {
257 $this->overview
[$p]->desc +
= $msg->desc
;
259 if ($p != $this->overview
[$p]->parent
) {
260 $p = $this->overview
[$p]->parent
;
265 $updateTrees[$prev] = true
;
270 foreach ($updateTrees as $root=>$t) {
271 $this->trees
[$root] = $this->buildTree($root, true
);
273 Banana
::$protocole->updateSpool($messages);
277 public function updateUnread($since)
283 $newpostsids = Banana
::$protocole->getNewIndexes($since);
285 if (empty($newpostsids)) {
289 if (!is_array($this->ids
)) {
290 $this->ids
= array();
292 $newpostsids = array_intersect($newpostsids, array_keys($this->ids
));
293 foreach ($newpostsids as $mid) {
294 $id = $this->ids
[$mid];
295 if ($this->overview
[$id]->isread
) {
296 $this->overview
[$id]->isread
= false
;
299 $this->overview
[$id]->descunread++
;
300 $id = $this->overview
[$id]->parent
;
306 public function setMode($mode)
310 case Banana
::SPOOL_UNREAD
:
311 $num = max(array_keys($this->overview
));
312 if ($this->overview
[$num]->isread
) {
315 foreach ($this->roots
as $k=>$i) {
316 if ($this->overview
[$i]->descunread
== 0) {
318 unset($this->roots
[$k]);
325 /** Mark the given id as read
326 * @param id MSGNUM of post
328 public function markAsRead($id)
330 if (!$this->overview
[$id]->isread
) {
331 $this->overview
[$id]->isread
= true
;
334 $this->overview
[$id]->descunread
--;
335 $id = $this->overview
[$id]->parent
;
340 /** Mark all unread messages as read
342 public function markAllAsRead(array &$array = null
)
344 if (!$this->unreadnb
) {
347 if (is_null($array) && is_array($this->roots
)) {
348 $array =& $this->roots
;
349 } elseif (is_null($array)) {
352 foreach ($array as $id) {
353 if (!$this->overview
[$id]->isread
) {
354 $this->markAsRead($id);
355 if (!$this->unreadnb
) {
359 if ($this->overview
[$id]->descunread
) {
360 $this->markAllAsRead($this->overview
[$id]->children
);
365 /** kill post and childrens
366 * @param $_id MSGNUM of post
368 private function killdesc($_id)
370 if (sizeof($this->overview
[$_id]->children
)) {
371 foreach ($this->overview
[$_id]->children
as $c) {
375 unset($this->overview
[$_id]);
376 if (($msgid = array_search($_id, $this->ids
)) !== false
) {
377 unset($this->ids
[$msgid]);
381 /** delete a post from overview
382 * @param $_id MSGNUM of post
384 public function delid($_id, $write = true
)
386 if (isset($this->overview
[$_id])) {
387 $overview =& $this->overview
[$_id];
388 if (!$overview->isread
) {
389 $this->markAsRead($_id);
391 if ($overview->parent
) {
392 $p = $overview->parent
;
393 $parent =& $this->overview
[$p];
394 $parent->children
= array_diff($parent->children
, array($_id));
395 if (sizeof($overview->children
)) {
396 $parent->children
= array_merge($parent->children
, $overview->children
);
397 foreach ($overview->children
as $c) {
398 $this->overview
[$c]->parent
= $p;
399 $this->overview
[$c]->parent_direct
= false
;
403 $this->overview
[$p]->desc
--;
404 $p = $this->overview
[$p]->parent
;
406 } elseif ($overview->children
) {
407 foreach ($overview->children
as $c) {
408 $this->overview
[$c]->parent
= null
;
412 unset($this->overview
[$_id]);
413 unset($this->trees
[$_id]);
414 $msgid = array_search($_id, $this->ids
);
415 if ($msgid !== false
) {
416 unset($this->ids
[$msgid]);
418 $msgid = array_search($_id, $this->roots
);
419 if ($msgid !== false
) {
420 unset($this->roots
[$msgid]);
429 public function formatDate($stamp)
431 $today = intval(time() / (24*3600));
432 $dday = intval($stamp / (24*3600));
434 if ($today == $dday) {
436 } elseif ($today == 1 +
$dday) {
437 $format = _b_('hier')." %H:%M";
438 } elseif ($today < 7 +
$dday) {
439 $format = '%a %H:%M';
440 } elseif ($today < 90 +
$dday) {
441 $format = '%a %e %b';
443 $format = '%a %e %b %Y';
445 return strftime($format, $stamp);
448 public function formatSubject($id, $subject)
450 $subject = banana_html_entity_decode($subject);
452 if (function_exists('hook_formatDisplayHeader')) {
453 list($subject, $link) = hook_formatDisplayHeader('subject', $subject, true
);
455 $subject = banana_catchFormats(banana_entities(stripslashes($subject)));
458 if (empty($subject)) {
459 $subject = _b_('(pas de sujet)');
461 if ($id != Banana
::$artid) {
462 $subject = Banana
::$page->makeLink(Array('group' => $this->group
, 'artid' => $id,
463 'text' => $subject, 'popup' => $popup));
465 return $subject . $link;
468 public function formatFrom($from)
470 $from = banana_html_entity_decode($from);
471 return BananaMessage
::formatFrom($from);
474 public function start()
476 if (Banana
::$first) {
477 return Banana
::$first;
479 $first = array_search(Banana
::$artid, $this->roots
);
480 return max(0, $first - Banana
::$spool_tbefore);
484 public function context()
486 return Banana
::$first ? Banana
::$spool_tmax : Banana
::$spool_tcontext;
489 /** displays children tree of a post
490 * @param $_id INTEGER MSGNUM of post
491 * @param $_index INTEGER linear number of post in the tree
492 * @param $_first INTEGER linear number of first post displayed
493 * @param $_last INTEGER linear number of last post displayed
494 * @param $_ref STRING MSGNUM of current post
495 * @param $_pfx_node STRING prefix used for current node
496 * @param $_pfx_end STRING prefix used for children of current node
497 * @param $_head BOOLEAN true if first post in thread
499 * If you want to analyse subject, you can define the function hook_formatDisplayHeader
501 private function _to_html($_id, $_index, $_first=0, $_last=0, $_ref="", $_pfx_node="", $_pfx_end="", $_head=true
, $_pfx_id="")
503 static $spfx_f, $spfx_n, $spfx_Tnd, $spfx_Lnd, $spfx_snd, $spfx_T, $spfx_L, $spfx_s, $spfx_e, $spfx_I;
504 if (!isset($spfx_f)) {
505 $spfx_f = Banana
::$page->makeImg(Array('img' => 'k1', 'alt' => 'o', 'height' => 21, 'width' => 9));
506 $spfx_n = Banana
::$page->makeImg(Array('img' => 'k2', 'alt' => '*', 'height' => 21, 'width' => 9));
507 $spfx_Tnd = Banana
::$page->makeImg(Array('img' => 'T-direct', 'alt' => '+', 'height' => 21, 'width' => 12));
508 $spfx_Lnd = Banana
::$page->makeImg(Array('img' => 'L-direct', 'alt' => '`', 'height' => 21, 'width' => 12));
509 $spfx_snd = Banana
::$page->makeImg(Array('img' => 's-direct', 'alt' => '-', 'height' => 21, 'width' => 5));
510 $spfx_T = Banana
::$page->makeImg(Array('img' => 'T', 'alt' => '+', 'height' => 21, 'width' => 12));
511 $spfx_L = Banana
::$page->makeImg(Array('img' => 'L', 'alt' => '`', 'height' => 21, 'width' => 12));
512 $spfx_s = Banana
::$page->makeImg(Array('img' => 's', 'alt' => '-', 'height' => 21, 'width' => 5));
513 $spfx_e = Banana
::$page->makeImg(Array('img' => 'e', 'alt' => ' ', 'height' => 21, 'width' => 12));
514 $spfx_I = Banana
::$page->makeImg(Array('img' => 'I', 'alt' => '|', 'height' => 21, 'width' => 12));
517 $overview =& $this->overview
[$_id];
518 if ($_index +
$overview->desc
< $_first ||
$_index > $_last) {
523 if ($_index >= $_first) {
524 $hc = empty($overview->children
);
526 $res .= '<tr id="'.$_pfx_id.$_id.'" class="' . ($_index%2 ?
'pair' : 'impair') . ($overview->isread ?
'' : ' new') . "\">\n";
527 $res .= '<td class="date">' . $this->formatDate($overview->date
) . " </td>\n";
528 $res .= '<td class="subj' . ($_index == $_ref ?
' cur' : '') . '"><div class="tree">'
529 . $_pfx_node .($hc ?
($_head ?
$spfx_f : ($overview->parent_direct ?
$spfx_s : $spfx_snd)) : $spfx_n)
531 $popup = $subject = $overview->subject
;
532 if (function_exists('hook_formatDisplayHeader')) {
533 list($subject, $link) = hook_formatDisplayHeader('subject', $subject, true
);
535 $subject = banana_catchFormats(banana_entities(stripslashes($subject)));
538 if (empty($subject)) {
539 $subject = _b_('(pas de sujet)');
541 if ($_index != $_ref) {
542 $subject = Banana
::$page->makeLink(Array('group' => $this->group
, 'artid' => $_id,
543 'text' => $subject, 'popup' => $popup));
545 $res .= ' ' . $subject . $link;
546 $res .= "</td>\n<td class='from'>" . BananaMessage
::formatFrom($overview->from
) . "</td>\n</tr>";
554 $children = $overview->children
;
555 while ($child = array_shift($children)) {
556 $overview =& $this->overview
[$child];
557 if ($_index > $_last) {
560 if ($_index +
$overview->desc
>= $_first) {
561 if (sizeof($children)) {
562 $res .= $this->_to_html($child, $_index, $_first, $_last, $_ref,
563 $_pfx_end . ($overview->parent_direct ?
$spfx_T : $spfx_Tnd),
564 $_pfx_end . $spfx_I, false
,$_id.'_');
566 $res .= $this->_to_html($child, $_index, $_first, $_last, $_ref,
567 $_pfx_end . ($overview->parent_direct ?
$spfx_L : $spfx_Lnd),
568 $_pfx_end . $spfx_e, false
,$_id.'_');
571 $_index +
= $overview->desc
;
577 /** Displays overview
578 * @param $_first INTEGER MSGNUM of first post
579 * @param $_last INTEGER MSGNUM of last post
580 * @param $_ref STRING MSGNUM of current/selectionned post
582 public function toHtml($first = 0, $overview = false
)
584 $res = Banana
::$page->makeJs('jquery');
585 $res .= Banana
::$page->makeJs('spool_toggle');
589 $_last = $first + Banana
::$spool_tmax - 1;
592 $_ref = $this->getNdx($first);
593 $_last = $_ref + Banana
::$spool_tafter;
594 $_first = $_ref - Banana
::$spool_tbefore;
600 foreach ($this->roots
as $id) {
601 $res .= $this->_to_html($id, $index, $_first, $_last, $_ref);
602 $index +
= $this->overview
[$id]->desc
;
603 if ($index > $_last) {
611 public function _buildTree($id, BananaSpoolHead
&$head, $current) {
612 static $t_e, $u_h, $u_ht, $u_vt, $u_l, $u_f, $r_h, $r_ht, $r_vt, $r_l, $r_f;
613 if (!isset($spfx_f)) {
614 $t_e = Banana
::$page->makeImg(Array('img' => 'e', 'alt' => ' ', 'height' => 18, 'width' => 14));
615 $u_h = Banana
::$page->makeImg(Array('img' => 'h2', 'alt' => '-', 'height' => 18, 'width' => 14));
616 $u_ht = Banana
::$page->makeImg(Array('img' => 'T2', 'alt' => '+', 'height' => 18, 'width' => 14));
617 $u_vt = Banana
::$page->makeImg(Array('img' => 't2', 'alt' => '`', 'height' => 18, 'width' => 14));
618 $u_l = Banana
::$page->makeImg(Array('img' => 'l2', 'alt' => '|', 'height' => 18, 'width' => 14));
619 $u_f = Banana
::$page->makeImg(Array('img' => 'f2', 'alt' => 't', 'height' => 18, 'width' => 14));
620 $r_h = Banana
::$page->makeImg(Array('img' => 'h2r', 'alt' => '-', 'height' => 18, 'width' => 14));
621 $r_ht = Banana
::$page->makeImg(Array('img' => 'T2r', 'alt' => '+', 'height' => 18, 'width' => 14));
622 $r_vt = Banana
::$page->makeImg(Array('img' => 't2r', 'alt' => '`', 'height' => 18, 'width' => 14));
623 $r_l = Banana
::$page->makeImg(Array('img' => 'l2r', 'alt' => '|', 'height' => 18, 'width' => 14));
624 $r_f = Banana
::$page->makeImg(Array('img' => 'f2r', 'alt' => 't', 'height' => 18, 'width' => 14));
626 $style = 'background-color:' . $head->color
. '; text-decoration: none';
628 $text = '<span style="' . $style . '" title="' . banana_entities($head->name
. ', ' . $this->formatDate($head->date
)) . '">' .
629 '<input type="radio" name="banana_tree" '. ($id == $current ?
'checked="checked" ' : ' ' ) .
630 (Banana
::$msgshow_javascript ?
'onchange="window.location=\'' .
631 banana_entities(Banana
::$page->makeURL(array('group' => $this->group
, 'artid' => $id))) . '\'"'
632 : ' disabled="disabled"')
635 $array = array($text);
636 foreach ($head->children
as $key=>&$child) {
637 $msg =& $this->overview
[$child];
638 list($tpr, $tree) = $this->_buildTree($child, $msg, $current);
639 $last = $key == count($head->children
) - 1;
640 foreach ($tree as $kt=>&$line) {
641 if ($kt == 0 && $key == 0 && !$last) {
642 $array[0] .= ($msg->isread ?
$r_ht : $u_ht) . $line;
643 } else if($kt == 0 && $key == 0) {
644 $array[0] .= ($msg->isread ?
$r_h : $u_h) . $line;
645 } else if ($kt == 0 && $last) {
646 $array[] = $t_e . ($msg->isread ?
$r_vt : $u_vt) . $line;
647 } else if ($kt == 0) {
648 $array[] = $t_e . ($msg->isread ?
$r_f : $u_f) . $line;
650 $array[] = $t_e . $t_e . $line;
652 $array[] = $t_e . ($msg->isread ?
$r_l : $u_l) . $line;
660 return array($prof, $array);
663 /** build the spool tree associated with the given message
665 public function buildTree($id, $force = false
) {
667 $overview =& $this->overview
[$id];
668 while (!is_null($overview->parent
)) {
669 $pos = $overview->parent
;
670 $overview =& $this->overview
[$pos];
672 if (!$force && isset($this->trees
[$pos])) {
673 return $this->trees
[$pos];
675 list(, $tree) = $this->_buildTree($pos, $overview, $force ?
-1 : $id);
676 return '<div style="height:18px">' . implode("</div>\n<div style=\"height:18px\">", $tree) . '</div>';
680 /** computes linear post index
681 * @param $_id INTEGER MSGNUM of post
682 * @return INTEGER linear index of post
684 public function getNdX($_id)
689 $id_parent = $this->overview
[$id_cur]->parent
;
690 if (is_null($id_parent)) break;
691 $pos = array_search($id_cur, $this->overview
[$id_parent]->children
);
693 for ($i = 0; $i < $pos ; $i++
) {
694 $ndx +
= $this->overview
[$this->overview
[$id_parent]->children
[$i]]->desc
;
698 $id_cur = $id_parent;
701 foreach ($this->roots
as $i) {
705 $ndx +
= $this->overview
[$i]->desc
;
710 /** Return root message of the given thread
711 * @param id INTEGER id of a message
713 public function root($id)
717 $id_parent = $this->overview
[$id_cur]->parent
;
718 if (is_null($id_parent)) break;
719 $id_cur = $id_parent;
724 /** Return the last post id with the given subject
727 public function getPostId($subject)
729 $subject = trim($subject);
730 $id = max(array_keys($this->overview
));
731 while (isset($this->overview
[$id])) {
732 $test = $this->overview
[$id]->subject
;
733 if (function_exists('hook_formatDisplayHeader')) {
734 $val = hook_formatDisplayHeader('subject', $test, true
);
735 if (is_array($val)) {
736 $test = banana_html_entity_decode($val[0]);
738 $test = banana_html_entity_decode($val);
742 if ($test == $subject) {
750 /** Returns previous thread root index
751 * @param id INTEGER message number
753 public function prevThread($id)
755 $root = $this->root($id);
757 foreach ($this->roots
as $i) {
766 /** Returns next thread root index
767 * @param id INTEGER message number
769 public function nextThread($id)
771 $root = $this->root($id);
773 foreach ($this->roots
as $i) {
784 /** Return prev post in the thread
785 * @param id INTEGER message number
787 public function prevPost($id)
789 $parent = $this->overview
[$id]->parent
;
790 if (is_null($parent)) {
794 foreach ($this->overview
[$parent]->children
as $child) {
803 /** Return next post in the thread
804 * @param id INTEGER message number
806 public function nextPost($id)
808 if (count($this->overview
[$id]->children
) != 0) {
809 return $this->overview
[$id]->children
[0];
814 $parent = $this->overview
[$cur]->parent
;
815 if (is_null($parent)) {
819 foreach ($this->overview
[$parent]->children
as $child) {
823 if ($child == $cur) {
832 /** Look for an unread message in the thread rooted by the message
833 * @param id INTEGER message number
835 private function _nextUnread($id)
837 if (!$this->overview
[$id]->isread
) {
840 foreach ($this->overview
[$id]->children
as $child) {
841 $unread = $this->_nextUnread($child);
842 if (!is_null($unread)) {
849 /** Find next unread message
850 * @param id INTEGER message number
852 public function nextUnread($id = null
)
854 if (!$this->unreadnb
) {
859 // Look in message children
860 foreach ($this->overview
[$id]->children
as $child) {
861 $next = $this->_nextUnread($child);
862 if (!is_null($next)) {
868 // Look in current thread
871 $parent = is_null($cur) ? null
: $this->overview
[$cur]->parent
;
872 $ok = is_null($cur) ? true
: false
;
873 if (!is_null($parent)) {
874 $array = &$this->overview
[$parent]->children
;
876 $array = &$this->roots
;
878 foreach ($array as $child) {
880 $next = $this->_nextUnread($child);
881 if (!is_null($next)) {
885 if ($child == $cur) {
890 } while(!is_null($cur));
895 // vim:set et sw=4 sts=4 ts=4 enc=utf-8: