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 | load_language('plugin.lang', LMT_PATH); |
---|
20 | |
---|
21 | class LMT_PIP extends LMT_root |
---|
22 | { |
---|
23 | protected $section_page; |
---|
24 | |
---|
25 | public function __construct($prefixeTable, $filelocation) |
---|
26 | { |
---|
27 | parent::__construct($prefixeTable, $filelocation); |
---|
28 | $this->loadConfig(); |
---|
29 | |
---|
30 | $this->initEvents(); |
---|
31 | } |
---|
32 | |
---|
33 | public function __destruct() |
---|
34 | { |
---|
35 | unset($section_page); |
---|
36 | parent::__destruct(); |
---|
37 | } |
---|
38 | |
---|
39 | /** |
---|
40 | * initialize events call for the plugin |
---|
41 | */ |
---|
42 | public function initEvents() |
---|
43 | { |
---|
44 | parent::initEvents(); |
---|
45 | |
---|
46 | if($this->config['lmt_licence_activated']=='y') |
---|
47 | { |
---|
48 | add_event_handler('loc_end_page_header', array(&$this->css_icn, 'applyCSS')); |
---|
49 | add_event_handler('loc_end_picture', array(&$this, 'manageLicenceElement')); |
---|
50 | |
---|
51 | if($this->config['lmt_warning_visible']=='y') |
---|
52 | { |
---|
53 | add_event_handler('loc_end_page_tail', array(&$this, 'manageWarningText')); |
---|
54 | } |
---|
55 | } |
---|
56 | } |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | /* ------------------------------------------------------------------------- |
---|
61 | FUNCTIONS TO MANAGE LMT DISPLAY |
---|
62 | ------------------------------------------------------------------------- */ |
---|
63 | public function manageLicenceElement() |
---|
64 | { |
---|
65 | global $template, $page, $user; |
---|
66 | |
---|
67 | $licence=$this->getImageLicence($page['image_id']); |
---|
68 | if($licence['licence']=="") |
---|
69 | { |
---|
70 | return(""); |
---|
71 | } |
---|
72 | |
---|
73 | if($this->config['lmt_redirect_activated']=='y') |
---|
74 | { |
---|
75 | $url=$this->config['lmt_redirect_url-'.strToLower($licence['licence'])][$user['language']]; |
---|
76 | if($url=='') |
---|
77 | { |
---|
78 | $url=$this->config['lmt_redirect_url-'.strToLower($licence['licence'])]['en_UK']; |
---|
79 | } |
---|
80 | } |
---|
81 | else |
---|
82 | { |
---|
83 | $url=""; |
---|
84 | } |
---|
85 | |
---|
86 | $alternateText=" alt='".htmlspecialchars(l10n('lmt_lbl_cc_s-'.strtolower($licence['licence'])), ENT_QUOTES)."' |
---|
87 | title='".htmlspecialchars( |
---|
88 | l10n('lmt_lbl_under-'.strtolower($licence['licence'])).' '. |
---|
89 | l10n('lmt_lbl_cc_s-'.strtolower($licence['licence'])).' : '. |
---|
90 | l10n('lmt_lbl_cc-'.strtolower($licence['licence'])),ENT_QUOTES |
---|
91 | )."' "; |
---|
92 | |
---|
93 | $style=""; |
---|
94 | $text=""; |
---|
95 | $target=($this->config['lmt_redirect_open_target']=="y")?" onclick='window.open(this.href); return false;'":""; |
---|
96 | switch($this->config['lmt_licence_logo']) |
---|
97 | { |
---|
98 | case '80x15': |
---|
99 | if($url!="") |
---|
100 | { |
---|
101 | $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']; |
---|
102 | } |
---|
103 | else |
---|
104 | { |
---|
105 | $text = "<br/><img $alternateText class='logo80x15' src='". LMT_PATH."img/".strToLower($licence['licence'])."_80x15.png'>".$licence['aut_text1']." ".$licence['aut_text2']; |
---|
106 | } |
---|
107 | break; |
---|
108 | case '88x31'; |
---|
109 | $style=" style='text-align:left;'"; |
---|
110 | if($url!="") |
---|
111 | { |
---|
112 | $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>"; |
---|
113 | } |
---|
114 | else |
---|
115 | { |
---|
116 | $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>"; |
---|
117 | } |
---|
118 | break; |
---|
119 | case 'text'; |
---|
120 | if($url!="") |
---|
121 | { |
---|
122 | $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']; |
---|
123 | } |
---|
124 | else |
---|
125 | { |
---|
126 | $text ="<br/>".l10n("lmt_lbl_under-".strToLower($licence['licence']))." ".l10n("lmt_lbl_cc_s-".strToLower($licence['licence']))." ".$licence['aut_text1']." ".$licence['aut_text2']; |
---|
127 | } |
---|
128 | break; |
---|
129 | } |
---|
130 | |
---|
131 | $template->concat('COMMENT_IMG', '<span class="licencetag" '.$style.'>'.$text.'</span>'); |
---|
132 | } |
---|
133 | |
---|
134 | public function manageWarningText() |
---|
135 | { |
---|
136 | global $template, $user; |
---|
137 | |
---|
138 | |
---|
139 | if(isset($this->config['lmt_warning_texts'][$user['language']])) |
---|
140 | { |
---|
141 | $text=$this->config['lmt_warning_texts'][$user['language']]; |
---|
142 | } |
---|
143 | else |
---|
144 | { |
---|
145 | $text=$this->config['lmt_warning_texts']['en_UK']; |
---|
146 | } |
---|
147 | |
---|
148 | $alternateText=" alt='".htmlspecialchars(l10n('lmt_lbl_cc_s-'.strtolower($this->config['lmt_licence_default'])), ENT_QUOTES)."' |
---|
149 | title='".htmlspecialchars( |
---|
150 | l10n('lmt_lbl_under-'.strtolower($this->config['lmt_licence_default'])).' '. |
---|
151 | l10n('lmt_lbl_cc_s-'.strtolower($this->config['lmt_licence_default'])).' : '. |
---|
152 | l10n('lmt_lbl_cc-'.strtolower($this->config['lmt_licence_default'])),ENT_QUOTES |
---|
153 | )."' "; |
---|
154 | |
---|
155 | $patterns = array('/\[logo=80x15\]/i', '/\[logo=88x31\]/i', '/\[logo=text\]/i'); |
---|
156 | $replacements = array( |
---|
157 | "<img $alternateText class='logo80x15' src='". LMT_PATH."img/".strToLower($this->config['lmt_licence_default'])."_80x15.png'>", |
---|
158 | "<img $alternateText class='logo88x31' src='". LMT_PATH."img/".strToLower($this->config['lmt_licence_default'])."_88x31.png'>", |
---|
159 | l10n("lmt_lbl_cc_s-".strToLower($this->config['lmt_licence_default'])) |
---|
160 | ); |
---|
161 | |
---|
162 | if($this->config['lmt_redirect_activated']=='y') |
---|
163 | { |
---|
164 | $url=$this->config['lmt_redirect_url-'.strToLower($this->config['lmt_licence_default'])][$user['language']]; |
---|
165 | if($url=='') |
---|
166 | { |
---|
167 | $url=$this->config['lmt_redirect_url-'.strToLower($this->config['lmt_licence_default'])]['en_UK']; |
---|
168 | } |
---|
169 | if($url!="") |
---|
170 | { |
---|
171 | $target=($this->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 | } //class |
---|
185 | |
---|
186 | ?> |
---|