1 | <?php |
---|
2 | |
---|
3 | /* ----------------------------------------------------------------------------- |
---|
4 | class name: GPCPublicIntegration |
---|
5 | class version : 2.0.0 |
---|
6 | plugin version : 3.0.0 |
---|
7 | date : 2010-03-30 |
---|
8 | ------------------------------------------------------------------------------ |
---|
9 | author: grum at piwigo.org |
---|
10 | << May the Little SpaceFrog be with you >> |
---|
11 | ------------------------------------------------------------------------------ |
---|
12 | |
---|
13 | :: HISTORY |
---|
14 | |
---|
15 | | release | date | |
---|
16 | | 2.0.0 | 2010/03/30 | * Update class & function names |
---|
17 | | | | |
---|
18 | | | | |
---|
19 | | | | |
---|
20 | | | | |
---|
21 | | | | |
---|
22 | | | | |
---|
23 | ------------------------------------------------------------------------------ |
---|
24 | |
---|
25 | this class provides base functions to manage an integration into main index |
---|
26 | page |
---|
27 | |
---|
28 | - constructor GPCPublicIntegration($section) |
---|
29 | - (public) function init_events() |
---|
30 | - (public) function setCallbackPageFunction($value) |
---|
31 | - (private) function init_section() |
---|
32 | - (private) function call_page() |
---|
33 | |
---|
34 | use initEvents() function to initialize needed triggers for updating menubar |
---|
35 | |
---|
36 | the "callback_page_function" is called everytime a specific page is displayed |
---|
37 | |
---|
38 | ----------------------------------------------------------------------------- */ |
---|
39 | |
---|
40 | class GPCPublicIntegration |
---|
41 | { |
---|
42 | var $section; //section applied to the page viewed |
---|
43 | var $callback_page_function; //called function to display page |
---|
44 | |
---|
45 | public function __construct($section) |
---|
46 | { |
---|
47 | $this->section=$section; |
---|
48 | $this->callback_page_function=''; |
---|
49 | } |
---|
50 | |
---|
51 | public function __destruct() |
---|
52 | { |
---|
53 | unset($this->section); |
---|
54 | unset($this->callback_page_function); |
---|
55 | } |
---|
56 | |
---|
57 | //initialize events to manage menu & page integration |
---|
58 | public function initEvents() |
---|
59 | { |
---|
60 | add_event_handler('loc_end_section_init', array(&$this, 'initSection')); |
---|
61 | add_event_handler('loc_end_index', array(&$this, 'callPage')); |
---|
62 | } |
---|
63 | |
---|
64 | public function setCallbackPageFunction($value) |
---|
65 | { |
---|
66 | $this->callback_page_function=$value; |
---|
67 | } |
---|
68 | |
---|
69 | /* |
---|
70 | init section |
---|
71 | */ |
---|
72 | public function initSection() |
---|
73 | { |
---|
74 | global $tokens, $page; |
---|
75 | |
---|
76 | if ($tokens[0] == $this->section) |
---|
77 | { $page['section'] = $this->section; } |
---|
78 | } |
---|
79 | |
---|
80 | /* |
---|
81 | loads a page |
---|
82 | */ |
---|
83 | public function callPage() |
---|
84 | { |
---|
85 | global $page, $user; |
---|
86 | |
---|
87 | if($page['section'] == $this->section) |
---|
88 | { |
---|
89 | @call_user_func($this->callback_page_function); |
---|
90 | } |
---|
91 | } |
---|
92 | |
---|
93 | } //class GPCPublicIntegration |
---|
94 | |
---|
95 | |
---|
96 | ?> |
---|