MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mhistory.class
Ir para a documentação deste ficheiro.
1<?php
2
4{
5 var $limit = 10;
6 var $name;
7 var $base = 0;
8 var $top;
9 var $stack;
10
12 {
13 global $MIOLO, $$name;
14
15 $this->name = $name;
16 $s = $MIOLO->GetSession()->getValue($name);
17 if ($s == NULL)
18 {
19 $this->top = -1;
20 $this->stack = array();
21 }
22 else
23 {
24 $this->top = count($s) - 1;
25 $this->stack = $s;
26 }
27 }
28
29 function Push($value)
30 {
31 if (++$this->top > $this->limit)
32 {
34 }
35 $this->stack[$this->top] = $value;
36 }
37
38 function Pop()
39 {
40 $value = $this->stack[$this->top];
41 if (--$this->top < $this->base)
42 {
43 $this->top = $this->base;
44 }
45 return $value;
46 }
47
48 function Top($offset = 0)
49 {
50 $n = $this->top - $offset;
51 return ($n >= $this->base) ? $this->stack[$n] : NULL;
52 }
53
54 function Count()
55 {
56 return $this->top - $this->base + 1;
57 }
58
59 function Save()
60 {
61 global $MIOLO;
62
63 $this->stack = array_slice($this->stack, $this->base, $this->Count());
64 $this->top = $this->Count() - 1;
65 $MIOLO->GetSession()->setValue($this->name, $this->stack);
66 }
67}
68
69class MHistory extends MService
70{
74
76 {
77 parent::__construct();
78 $this->context = new StdClass;
79 $this->stackContext = new MStackHistory('_stackContext');
80 $this->stackHistory = new MStackHistory('_stackAction');
81 if ($this->stackContext->Count() == 0)
82 {
83 $this->context->action = '';
84 }
85 else
86 {
87 $this->context = new MContext($this->stackContext->Top());
88 }
89 $this->Push($this->manager->GetCurrentUrl());
90 }
91
92 function Push($action)
93 {
94 $this->stackHistory->Push($action);
96 $this->stackContext->Push($context->ComposeURL($this->manager->dispatch));
97 }
98
99 function Pop($stack = NULL)
100 {
101 if (is_null($stack) || ($stack == 'action'))
102 {
103 $this->stackHistory->Pop();
104 }
105 if (is_null($stack) || ($stack == 'context'))
106 {
107 $this->stackContext->Pop();
108 }
109 }
110
111 function Top($stack = 'action')
112 {
113 if ($stack == 'action')
114 {
115 return $this->stackHistory->Top();
116 }
117 elseif ($stack == 'context')
118 {
119 return $this->stackContext->Top();
120 }
121 }
122
123 function Back($stack = 'action')
124 {
125 if ($stack == 'action')
126 {
127 return $this->stackHistory->Top(1);
128 }
129 elseif ($stack == 'context')
130 {
131 return $this->stackContext->Top(1);
132 }
133 }
134
135 function Close()
136 {
137 $this->stackContext->Save();
138 $this->stackHistory->Save();
139 }
140}
141?>
Push($action)
Definição mhistory.class:92
Top($stack='action')
Definição mhistory.class:111
Pop($stack=NULL)
Definição mhistory.class:99
Back($stack='action')
Definição mhistory.class:123
__construct($manager)
Definição mhistory.class:75
__construct($name)
Definição mhistory.class:11
Push($value)
Definição mhistory.class:29
Top($offset=0)
Definição mhistory.class:48
$action
Definição base.php:4