libs/plugins/function.counter.php Quellcode

function.counter.php
gehe zur Dokumentation dieser Datei
1 <?php
24 function smarty_function_counter($params, $template)
25 {
26  static $counters = array();
27 
28  $name = (isset($params['name'])) ? $params['name'] : 'default';
29  if (!isset($counters[$name])) {
30  $counters[$name] = array(
31  'start' => 1,
32  'skip' => 1,
33  'direction' => 'up',
34  'count' => 1
35  );
36  }
37  $counter =& $counters[$name];
38 
39  if (isset($params['start'])) {
40  $counter['start'] = $counter['count'] = (int) $params['start'];
41  }
42 
43  if (!empty($params['assign'])) {
44  $counter['assign'] = $params['assign'];
45  }
46 
47  if (isset($counter['assign'])) {
48  $template->assign($counter['assign'], $counter['count']);
49  }
50 
51  if (isset($params['print'])) {
52  $print = (bool) $params['print'];
53  } else {
54  $print = empty($counter['assign']);
55  }
56 
57  if ($print) {
58  $retval = $counter['count'];
59  } else {
60  $retval = null;
61  }
62 
63  if (isset($params['skip'])) {
64  $counter['skip'] = $params['skip'];
65  }
66 
67  if (isset($params['direction'])) {
68  $counter['direction'] = $params['direction'];
69  }
70 
71  if ($counter['direction'] == "down") {
72  $counter['count'] -= $counter['skip'];
73  } else {
74  $counter['count'] += $counter['skip'];
75  }
76 
77  return $retval;
78 }




Korrekturen, Hinweise und Ergänzungen

Bitte scheuen Sie sich nicht und melden Sie, was auf dieser Seite sachlich falsch oder irreführend ist, was ergänzt werden sollte, was fehlt usw. Dazu bitte oben aus dem Menü Seite den Eintrag Support Forum wählen. Es ist eine kostenlose Anmeldung erforderlich, um Anmerkungen zu posten. Unpassende Postings, Spam usw. werden kommentarlos entfernt.