1 | <?php |
---|
2 | /* ----------------------------------------------------------------------------- |
---|
3 | Plugin : LMT |
---|
4 | Author : Grum |
---|
5 | email : grum@piwigo.org |
---|
6 | website : http://photos.grum.fr |
---|
7 | |
---|
8 | << May the Little SpaceFrog be with you ! >> |
---|
9 | ------------------------------------------------------------------------------ |
---|
10 | See main.inc.php for release information |
---|
11 | |
---|
12 | LMT_PIP : classe to manage plugin public pages |
---|
13 | |
---|
14 | --------------------------------------------------------------------------- */ |
---|
15 | |
---|
16 | include_once('lmt_root.class.inc.php'); |
---|
17 | include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/public_integration.class.inc.php'); |
---|
18 | |
---|
19 | class LMT_PIP extends LMT_root |
---|
20 | { |
---|
21 | protected $section_page; |
---|
22 | |
---|
23 | public function LMT_PIP($prefixeTable, $filelocation) |
---|
24 | { |
---|
25 | parent::__construct($prefixeTable, $filelocation); |
---|
26 | $this->load_config(); |
---|
27 | |
---|
28 | // don't create this object inside root classe otherwise header is modified |
---|
29 | // everywhere in admin pages |
---|
30 | $this->ajax = new Ajax(); |
---|
31 | |
---|
32 | $this->init_events(); |
---|
33 | $this->load_lang(); |
---|
34 | } |
---|
35 | |
---|
36 | /* |
---|
37 | load language file |
---|
38 | */ |
---|
39 | public function load_lang() |
---|
40 | { |
---|
41 | global $lang; |
---|
42 | |
---|
43 | load_language('plugin.lang', LMT_PATH); |
---|
44 | |
---|
45 | // ajax is managed here ; this permit to use user&language properties inside |
---|
46 | // ajax content |
---|
47 | //$this->return_ajax_content(); |
---|
48 | } |
---|
49 | |
---|
50 | /* |
---|
51 | initialize events call for the plugin |
---|
52 | */ |
---|
53 | public function init_events() |
---|
54 | { |
---|
55 | parent::init_events(); |
---|
56 | /* |
---|
57 | add_event_handler('blockmanager_apply', array(&$this, 'blockmanager_apply') ); |
---|
58 | add_event_handler('loading_lang', array(&$this, 'load_lang')); |
---|
59 | */ |
---|
60 | if($this->my_config['lmt_licence_activated']=='y') |
---|
61 | { |
---|
62 | add_event_handler('loc_end_page_header', array(&$this->css_icn, 'apply_CSS')); |
---|
63 | add_event_handler('loc_end_picture', array(&$this, 'manage_licence_element')); |
---|
64 | |
---|
65 | if($this->my_config['lmt_warning_visible']=='y') |
---|
66 | { |
---|
67 | add_event_handler('loc_end_page_tail', array(&$this, 'manage_warning_text')); |
---|
68 | } |
---|
69 | } |
---|
70 | } |
---|
71 | |
---|
72 | |
---|
73 | |
---|
74 | /* ------------------------------------------------------------------------- |
---|
75 | FUNCTIONS TO MANAGE LMT DISPLAY |
---|
76 | ------------------------------------------------------------------------- */ |
---|
77 | public function manage_licence_element() |
---|
78 | { |
---|
79 | global $template, $page, $user; |
---|
80 | |
---|
81 | $licence=$this->get_image_licence($page['image_id']); |
---|
82 | if($licence['licence']=="") |
---|
83 | { |
---|
84 | return(""); |
---|
85 | } |
---|
86 | |
---|
87 | if($this->my_config['lmt_redirect_activated']=='y') |
---|
88 | { |
---|
89 | $url=$this->my_config['lmt_redirect_url-'.strToLower($licence['licence'])][$user['language']]; |
---|
90 | if($url=='') |
---|
91 | { |
---|
92 | $url=$this->my_config['lmt_redirect_url-'.strToLower($licence['licence'])]['en_UK']; |
---|
93 | } |
---|
94 | } |
---|
95 | else |
---|
96 | { |
---|
97 | $url=""; |
---|
98 | } |
---|
99 | |
---|
100 | $style=""; |
---|
101 | $text=""; |
---|
102 | $target=($this->my_config['lmt_redirect_open_target']=="y")?" onclick='window.open(this.href); return false;'":""; |
---|
103 | switch($this->my_config['lmt_licence_logo']) |
---|
104 | { |
---|
105 | case '80x15': |
---|
106 | if($url!="") |
---|
107 | { |
---|
108 | $text = "<br/><a href='".$url."'".$target."><img class='logo80x15' src='". LMT_PATH."img/".strToLower($licence['licence'])."_80x15.png'></a>".$licence['aut_text1']." ".$licence['aut_text2']; |
---|
109 | } |
---|
110 | else |
---|
111 | { |
---|
112 | $text = "<br/><img class='logo80x15' src='". LMT_PATH."img/".strToLower($licence['licence'])."_80x15.png'>".$licence['aut_text1']." ".$licence['aut_text2']; |
---|
113 | } |
---|
114 | break; |
---|
115 | case '88x31'; |
---|
116 | $style=" style='text-align:left;'"; |
---|
117 | if($url!="") |
---|
118 | { |
---|
119 | $text = "<table style='margin:auto;'><tr><td><a href='".$url."'".$target."><img class='logo88x31' style='top:-4px;' src='". LMT_PATH."img/".strToLower($licence['licence'])."_88x31.png'></a></td><td>".$licence['aut_text1']."<br/>".$licence['aut_text2']."</td></tr></table>"; |
---|
120 | } |
---|
121 | else |
---|
122 | { |
---|
123 | $text = "<table style='margin:auto;'><tr><td><img class='logo88x31' style='top:-4px;' src='". LMT_PATH."img/".strToLower($licence['licence'])."_88x31.png'></td><td>".$licence['aut_text1']."<br/>".$licence['aut_text2']."</td></tr></table>"; |
---|
124 | } |
---|
125 | break; |
---|
126 | case 'text'; |
---|
127 | if($url!="") |
---|
128 | { |
---|
129 | $text ="<br/>".l10n("lmt_lbl_under-".strToLower($licence['licence']))." <a href='".$url."'".$target.">".l10n("lmt_lbl_cc_s-".strToLower($licence['licence']))."</a> ".$licence['aut_text1']." ".$licence['aut_text2']; |
---|
130 | } |
---|
131 | else |
---|
132 | { |
---|
133 | $text ="<br/>".l10n("lmt_lbl_under-".strToLower($licence['licence']))." ".l10n("lmt_lbl_cc_s-".strToLower($licence['licence']))." ".$licence['aut_text1']." ".$licence['aut_text2']; |
---|
134 | } |
---|
135 | break; |
---|
136 | } |
---|
137 | |
---|
138 | $template->concat('COMMENT_IMG', '<span class="licencetag" '.$style.'>'.$text.'</span>'); |
---|
139 | } |
---|
140 | |
---|
141 | public function manage_warning_text() |
---|
142 | { |
---|
143 | global $template, $user; |
---|
144 | |
---|
145 | |
---|
146 | if(isset($this->my_config['lmt_warning_texts'][$user['language']])) |
---|
147 | { |
---|
148 | $text=$this->my_config['lmt_warning_texts'][$user['language']]; |
---|
149 | } |
---|
150 | else |
---|
151 | { |
---|
152 | $text=$this->my_config['lmt_warning_texts']['en_UK']; |
---|
153 | } |
---|
154 | |
---|
155 | $patterns = array('/\[logo=80x15\]/i', '/\[logo=88x31\]/i', '/\[logo=text\]/i'); |
---|
156 | $replacements = array( |
---|
157 | "<img class='logo80x15' src='". LMT_PATH."img/".strToLower($this->my_config['lmt_licence_default'])."_80x15.png'>", |
---|
158 | "<img class='logo88x31' src='". LMT_PATH."img/".strToLower($this->my_config['lmt_licence_default'])."_88x31.png'>", |
---|
159 | l10n("lmt_lbl_cc_s-".strToLower($this->my_config['lmt_licence_default'])) |
---|
160 | ); |
---|
161 | |
---|
162 | if($this->my_config['lmt_redirect_activated']=='y') |
---|
163 | { |
---|
164 | $url=$this->my_config['lmt_redirect_url-'.strToLower($this->my_config['lmt_licence_default'])][$user['language']]; |
---|
165 | if($url=='') |
---|
166 | { |
---|
167 | $url=$this->my_config['lmt_redirect_url-'.strToLower($this->my_config['lmt_licence_default'])]['en_UK']; |
---|
168 | } |
---|
169 | if($url!="") |
---|
170 | { |
---|
171 | $target=($this->my_config['lmt_redirect_open_target']=="y")?" onclick='window.open(this.href); return false;'":""; |
---|
172 | $replacements[0]="<a href='".$url."'".$target.">".$replacements[0]."</a>"; |
---|
173 | $replacements[1]="<a href='".$url."'".$target.">".$replacements[1]."</a>"; |
---|
174 | $replacements[2]="<a href='".$url."'".$target.">".$replacements[2]."</a>"; |
---|
175 | } |
---|
176 | } |
---|
177 | |
---|
178 | $text = preg_replace($patterns, $replacements, $text); |
---|
179 | |
---|
180 | $template->append("footer_elements", "<span>".htmlspecialchars_decode($text)."</span>"); |
---|
181 | } |
---|
182 | |
---|
183 | |
---|
184 | /* --------------------------------------------------------------------------- |
---|
185 | ajax functions |
---|
186 | --------------------------------------------------------------------------- */ |
---|
187 | |
---|
188 | } //class |
---|
189 | |
---|
190 | ?> |
---|