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.'GrumPluginClasses/classes/GPCPublicIntegration.class.inc.php'); |
---|
18 | |
---|
19 | class LMT_PIP extends LMT_root |
---|
20 | { |
---|
21 | protected $section_page; |
---|
22 | |
---|
23 | public function __construct($prefixeTable, $filelocation) |
---|
24 | { |
---|
25 | parent::__construct($prefixeTable, $filelocation); |
---|
26 | $this->loadConfig(); |
---|
27 | |
---|
28 | $this->initEvents(); |
---|
29 | $this->load_lang(); |
---|
30 | } |
---|
31 | |
---|
32 | public function __destruct() |
---|
33 | { |
---|
34 | unset($section_page); |
---|
35 | parent::__destruct(); |
---|
36 | } |
---|
37 | |
---|
38 | /* |
---|
39 | load language file |
---|
40 | */ |
---|
41 | public function load_lang() |
---|
42 | { |
---|
43 | global $lang; |
---|
44 | |
---|
45 | load_language('plugin.lang', LMT_PATH); |
---|
46 | |
---|
47 | // ajax is managed here ; this permit to use user&language properties inside |
---|
48 | // ajax content |
---|
49 | //$this->return_ajax_content(); |
---|
50 | } |
---|
51 | |
---|
52 | /* |
---|
53 | initialize events call for the plugin |
---|
54 | */ |
---|
55 | public function initEvents() |
---|
56 | { |
---|
57 | parent::initEvents(); |
---|
58 | /* |
---|
59 | add_event_handler('blockmanager_apply', array(&$this, 'blockmanager_apply') ); |
---|
60 | add_event_handler('loading_lang', array(&$this, 'load_lang')); |
---|
61 | */ |
---|
62 | if($this->config['lmt_licence_activated']=='y') |
---|
63 | { |
---|
64 | add_event_handler('loc_end_page_header', array(&$this->css_icn, 'applyCSS')); |
---|
65 | add_event_handler('loc_end_picture', array(&$this, 'manage_licence_element')); |
---|
66 | |
---|
67 | if($this->config['lmt_warning_visible']=='y') |
---|
68 | { |
---|
69 | add_event_handler('loc_end_page_tail', array(&$this, 'manage_warning_text')); |
---|
70 | } |
---|
71 | } |
---|
72 | } |
---|
73 | |
---|
74 | |
---|
75 | |
---|
76 | /* ------------------------------------------------------------------------- |
---|
77 | FUNCTIONS TO MANAGE LMT DISPLAY |
---|
78 | ------------------------------------------------------------------------- */ |
---|
79 | public function manage_licence_element() |
---|
80 | { |
---|
81 | global $template, $page, $user; |
---|
82 | |
---|
83 | $licence=$this->get_image_licence($page['image_id']); |
---|
84 | if($licence['licence']=="") |
---|
85 | { |
---|
86 | return(""); |
---|
87 | } |
---|
88 | |
---|
89 | if($this->config['lmt_redirect_activated']=='y') |
---|
90 | { |
---|
91 | $url=$this->config['lmt_redirect_url-'.strToLower($licence['licence'])][$user['language']]; |
---|
92 | if($url=='') |
---|
93 | { |
---|
94 | $url=$this->config['lmt_redirect_url-'.strToLower($licence['licence'])]['en_UK']; |
---|
95 | } |
---|
96 | } |
---|
97 | else |
---|
98 | { |
---|
99 | $url=""; |
---|
100 | } |
---|
101 | |
---|
102 | $alternateText=" alt='".htmlspecialchars(l10n('lmt_lbl_cc_s-'.strtolower($licence['licence'])), ENT_QUOTES)."' |
---|
103 | title='".htmlspecialchars( |
---|
104 | l10n('lmt_lbl_under-'.strtolower($licence['licence'])).' '. |
---|
105 | l10n('lmt_lbl_cc_s-'.strtolower($licence['licence'])).' : '. |
---|
106 | l10n('lmt_lbl_cc-'.strtolower($licence['licence'])),ENT_QUOTES |
---|
107 | )."' "; |
---|
108 | |
---|
109 | $style=""; |
---|
110 | $text=""; |
---|
111 | $target=($this->config['lmt_redirect_open_target']=="y")?" onclick='window.open(this.href); return false;'":""; |
---|
112 | switch($this->config['lmt_licence_logo']) |
---|
113 | { |
---|
114 | case '80x15': |
---|
115 | if($url!="") |
---|
116 | { |
---|
117 | $text = "<br/><a href='".$url."'".$target."><img $alternateText class='logo80x15' src='". LMT_PATH."img/".strToLower($licence['licence'])."_80x15.png'></a>".$licence['aut_text1']." ".$licence['aut_text2']; |
---|
118 | } |
---|
119 | else |
---|
120 | { |
---|
121 | $text = "<br/><img $alternateText class='logo80x15' src='". LMT_PATH."img/".strToLower($licence['licence'])."_80x15.png'>".$licence['aut_text1']." ".$licence['aut_text2']; |
---|
122 | } |
---|
123 | break; |
---|
124 | case '88x31'; |
---|
125 | $style=" style='text-align:left;'"; |
---|
126 | if($url!="") |
---|
127 | { |
---|
128 | $text = "<table style='margin:auto;'><tr><td><a href='".$url."'".$target."><img $alternateText 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>"; |
---|
129 | } |
---|
130 | else |
---|
131 | { |
---|
132 | $text = "<table style='margin:auto;'><tr><td><img $alternateText 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>"; |
---|
133 | } |
---|
134 | break; |
---|
135 | case 'text'; |
---|
136 | if($url!="") |
---|
137 | { |
---|
138 | $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']; |
---|
139 | } |
---|
140 | else |
---|
141 | { |
---|
142 | $text ="<br/>".l10n("lmt_lbl_under-".strToLower($licence['licence']))." ".l10n("lmt_lbl_cc_s-".strToLower($licence['licence']))." ".$licence['aut_text1']." ".$licence['aut_text2']; |
---|
143 | } |
---|
144 | break; |
---|
145 | } |
---|
146 | |
---|
147 | $template->concat('COMMENT_IMG', '<span class="licencetag" '.$style.'>'.$text.'</span>'); |
---|
148 | } |
---|
149 | |
---|
150 | public function manage_warning_text() |
---|
151 | { |
---|
152 | global $template, $user; |
---|
153 | |
---|
154 | |
---|
155 | if(isset($this->config['lmt_warning_texts'][$user['language']])) |
---|
156 | { |
---|
157 | $text=$this->config['lmt_warning_texts'][$user['language']]; |
---|
158 | } |
---|
159 | else |
---|
160 | { |
---|
161 | $text=$this->config['lmt_warning_texts']['en_UK']; |
---|
162 | } |
---|
163 | |
---|
164 | $alternateText=" alt='".htmlspecialchars(l10n('lmt_lbl_cc_s-'.strtolower($this->config['lmt_licence_default'])), ENT_QUOTES)."' |
---|
165 | title='".htmlspecialchars( |
---|
166 | l10n('lmt_lbl_under-'.strtolower($this->config['lmt_licence_default'])).' '. |
---|
167 | l10n('lmt_lbl_cc_s-'.strtolower($this->config['lmt_licence_default'])).' : '. |
---|
168 | l10n('lmt_lbl_cc-'.strtolower($this->config['lmt_licence_default'])),ENT_QUOTES |
---|
169 | )."' "; |
---|
170 | |
---|
171 | $patterns = array('/\[logo=80x15\]/i', '/\[logo=88x31\]/i', '/\[logo=text\]/i'); |
---|
172 | $replacements = array( |
---|
173 | "<img $alternateText class='logo80x15' src='". LMT_PATH."img/".strToLower($this->config['lmt_licence_default'])."_80x15.png'>", |
---|
174 | "<img $alternateText class='logo88x31' src='". LMT_PATH."img/".strToLower($this->config['lmt_licence_default'])."_88x31.png'>", |
---|
175 | l10n("lmt_lbl_cc_s-".strToLower($this->config['lmt_licence_default'])) |
---|
176 | ); |
---|
177 | |
---|
178 | if($this->config['lmt_redirect_activated']=='y') |
---|
179 | { |
---|
180 | $url=$this->config['lmt_redirect_url-'.strToLower($this->config['lmt_licence_default'])][$user['language']]; |
---|
181 | if($url=='') |
---|
182 | { |
---|
183 | $url=$this->config['lmt_redirect_url-'.strToLower($this->config['lmt_licence_default'])]['en_UK']; |
---|
184 | } |
---|
185 | if($url!="") |
---|
186 | { |
---|
187 | $target=($this->config['lmt_redirect_open_target']=="y")?" onclick='window.open(this.href); return false;'":""; |
---|
188 | $replacements[0]="<a href='".$url."'".$target.">".$replacements[0]."</a>"; |
---|
189 | $replacements[1]="<a href='".$url."'".$target.">".$replacements[1]."</a>"; |
---|
190 | $replacements[2]="<a href='".$url."'".$target.">".$replacements[2]."</a>"; |
---|
191 | } |
---|
192 | } |
---|
193 | |
---|
194 | $text = preg_replace($patterns, $replacements, $text); |
---|
195 | |
---|
196 | $template->append("footer_elements", "<span>".htmlspecialchars_decode($text)."</span>"); |
---|
197 | } |
---|
198 | |
---|
199 | |
---|
200 | /* --------------------------------------------------------------------------- |
---|
201 | ajax functions |
---|
202 | --------------------------------------------------------------------------- */ |
---|
203 | |
---|
204 | } //class |
---|
205 | |
---|
206 | ?> |
---|