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 | | 2.1.0 | 2010/10/28 | * Add the pageIsSection() function |
---|
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 initEvents() |
---|
30 | - (public) function setCallbackPageFunction($value) |
---|
31 | - (public) function pageIsSection() |
---|
32 | - (private) function initSection() |
---|
33 | - (private) function callPage() |
---|
34 | |
---|
35 | use initEvents() function to initialize needed triggers for updating menubar |
---|
36 | |
---|
37 | the "callback_page_function" is called everytime a specific page is displayed |
---|
38 | |
---|
39 | ----------------------------------------------------------------------------- */ |
---|
40 | |
---|
41 | class GPCPublicIntegration |
---|
42 | { |
---|
43 | private $section; //section applied to the page viewed |
---|
44 | private $callback_page_function; //called function to display page |
---|
45 | |
---|
46 | public function __construct($section) |
---|
47 | { |
---|
48 | $this->section=$section; |
---|
49 | $this->callback_page_function=''; |
---|
50 | } |
---|
51 | |
---|
52 | public function __destruct() |
---|
53 | { |
---|
54 | unset($this->section); |
---|
55 | unset($this->callback_page_function); |
---|
56 | } |
---|
57 | |
---|
58 | /** |
---|
59 | * initialize events to manage menu & page integration |
---|
60 | */ |
---|
61 | public function initEvents() |
---|
62 | { |
---|
63 | add_event_handler('loc_end_section_init', array(&$this, 'initSection')); |
---|
64 | add_event_handler('loc_end_index', array(&$this, 'callPage')); |
---|
65 | } |
---|
66 | |
---|
67 | public function setCallbackPageFunction($value) |
---|
68 | { |
---|
69 | $this->callback_page_function=$value; |
---|
70 | } |
---|
71 | |
---|
72 | /** |
---|
73 | * initialize section in piwigo |
---|
74 | */ |
---|
75 | public function initSection() |
---|
76 | { |
---|
77 | global $tokens, $page; |
---|
78 | |
---|
79 | if ($tokens[0] == $this->section) |
---|
80 | { $page['section'] = $this->section; } |
---|
81 | } |
---|
82 | |
---|
83 | /** |
---|
84 | * loads the section page |
---|
85 | */ |
---|
86 | public function callPage() |
---|
87 | { |
---|
88 | global $page, $user; |
---|
89 | |
---|
90 | if($page['section'] == $this->section) |
---|
91 | { |
---|
92 | @call_user_func($this->callback_page_function); |
---|
93 | } |
---|
94 | } |
---|
95 | |
---|
96 | /** |
---|
97 | * return true if current page is the section |
---|
98 | */ |
---|
99 | public function pageIsSection() |
---|
100 | { |
---|
101 | return($_SERVER['QUERY_STRING']=='/'.$this->section); |
---|
102 | } |
---|
103 | |
---|
104 | } //class GPCPublicIntegration |
---|
105 | |
---|
106 | |
---|
107 | ?> |
---|