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_picture', array(&$this, 'manageLicenceElement')); |
---|
49 | |
---|
50 | if($this->config['lmt_warning_visible']=='y') |
---|
51 | { |
---|
52 | add_event_handler('loc_end_page_tail', array(&$this, 'manageWarningText')); |
---|
53 | } |
---|
54 | } |
---|
55 | } |
---|
56 | |
---|
57 | public function loadCSS() |
---|
58 | { |
---|
59 | //parent::loadCSS(); -- don't call the ancestor! |
---|
60 | GPCCore::addHeaderCSS('lmt_icn.css', 'plugins/'.$this->getDirectory().'/'.$this->getPluginNameFiles()."_icn.css"); |
---|
61 | } |
---|
62 | |
---|
63 | /* ------------------------------------------------------------------------- |
---|
64 | FUNCTIONS TO MANAGE LMT DISPLAY |
---|
65 | ------------------------------------------------------------------------- */ |
---|
66 | public function manageLicenceElement() |
---|
67 | { |
---|
68 | global $template, $page, $user; |
---|
69 | |
---|
70 | $licence=$this->getImageLicence($page['image_id']); |
---|
71 | if($licence['licence']=="") |
---|
72 | { |
---|
73 | return(""); |
---|
74 | } |
---|
75 | |
---|
76 | if($this->config['lmt_redirect_activated']=='y') |
---|
77 | { |
---|
78 | $url=$this->config['lmt_redirect_url-'.strToLower($licence['licence'])][$user['language']]; |
---|
79 | if($url=='') |
---|
80 | { |
---|
81 | $url=$this->config['lmt_redirect_url-'.strToLower($licence['licence'])]['en_UK']; |
---|
82 | } |
---|
83 | } |
---|
84 | else |
---|
85 | { |
---|
86 | $url=""; |
---|
87 | } |
---|
88 | |
---|
89 | $alternateText=" alt='".htmlspecialchars(l10n('lmt_lbl_cc_s-'.strtolower($licence['licence'])), ENT_QUOTES)."' |
---|
90 | title='".htmlspecialchars( |
---|
91 | l10n('lmt_lbl_under-'.strtolower($licence['licence'])).' '. |
---|
92 | l10n('lmt_lbl_cc_s-'.strtolower($licence['licence'])).' : '. |
---|
93 | l10n('lmt_lbl_cc-'.strtolower($licence['licence'])),ENT_QUOTES |
---|
94 | )."' "; |
---|
95 | |
---|
96 | $style=""; |
---|
97 | $text=""; |
---|
98 | $target=($this->config['lmt_redirect_open_target']=="y")?" onclick='window.open(this.href); return false;'":""; |
---|
99 | switch($this->config['lmt_licence_logo']) |
---|
100 | { |
---|
101 | case '80x15': |
---|
102 | if($url!="") |
---|
103 | { |
---|
104 | $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']; |
---|
105 | } |
---|
106 | else |
---|
107 | { |
---|
108 | $text = "<br/><img $alternateText class='logo80x15' src='". LMT_PATH."img/".strToLower($licence['licence'])."_80x15.png'>".$licence['aut_text1']." ".$licence['aut_text2']; |
---|
109 | } |
---|
110 | break; |
---|
111 | case '88x31'; |
---|
112 | $style=" style='text-align:left;'"; |
---|
113 | if($url!="") |
---|
114 | { |
---|
115 | $text = "<table style='margin:auto;'><tr><td><a href='".$url."'".$target."><img $alternateText class='logo88x31' src='". LMT_PATH."img/".strToLower($licence['licence'])."_88x31.png'></a></td><td>".$licence['aut_text1']."<br/>".$licence['aut_text2']."</td></tr></table>"; |
---|
116 | } |
---|
117 | else |
---|
118 | { |
---|
119 | $text = "<table style='margin:auto;'><tr><td><img $alternateText class='logo88x31' src='". LMT_PATH."img/".strToLower($licence['licence'])."_88x31.png'></td><td>".$licence['aut_text1']."<br/>".$licence['aut_text2']."</td></tr></table>"; |
---|
120 | } |
---|
121 | break; |
---|
122 | case 'text'; |
---|
123 | if($url!="") |
---|
124 | { |
---|
125 | $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']; |
---|
126 | } |
---|
127 | else |
---|
128 | { |
---|
129 | $text ="<br/>".l10n("lmt_lbl_under-".strToLower($licence['licence']))." ".l10n("lmt_lbl_cc_s-".strToLower($licence['licence']))." ".$licence['aut_text1']." ".$licence['aut_text2']; |
---|
130 | } |
---|
131 | break; |
---|
132 | } |
---|
133 | |
---|
134 | $template->concat('COMMENT_IMG', '<span class="licencetag" '.$style.'>'.$text.'</span>'); |
---|
135 | } |
---|
136 | |
---|
137 | public function manageWarningText() |
---|
138 | { |
---|
139 | global $template, $user; |
---|
140 | |
---|
141 | |
---|
142 | if(isset($this->config['lmt_warning_texts'][$user['language']])) |
---|
143 | { |
---|
144 | $text=$this->config['lmt_warning_texts'][$user['language']]; |
---|
145 | } |
---|
146 | else |
---|
147 | { |
---|
148 | $text=$this->config['lmt_warning_texts']['en_UK']; |
---|
149 | } |
---|
150 | |
---|
151 | $alternateText=" alt='".htmlspecialchars(l10n('lmt_lbl_cc_s-'.strtolower($this->config['lmt_licence_default'])), ENT_QUOTES)."' |
---|
152 | title='".htmlspecialchars( |
---|
153 | l10n('lmt_lbl_under-'.strtolower($this->config['lmt_licence_default'])).' '. |
---|
154 | l10n('lmt_lbl_cc_s-'.strtolower($this->config['lmt_licence_default'])).' : '. |
---|
155 | l10n('lmt_lbl_cc-'.strtolower($this->config['lmt_licence_default'])),ENT_QUOTES |
---|
156 | )."' "; |
---|
157 | |
---|
158 | $patterns = array('/\[logo=80x15\]/i', '/\[logo=88x31\]/i', '/\[logo=text\]/i'); |
---|
159 | $replacements = array( |
---|
160 | "<img $alternateText class='logo80x15' src='". LMT_PATH."img/".strToLower($this->config['lmt_licence_default'])."_80x15.png'>", |
---|
161 | "<img $alternateText class='logo88x31' src='". LMT_PATH."img/".strToLower($this->config['lmt_licence_default'])."_88x31.png'>", |
---|
162 | l10n("lmt_lbl_cc_s-".strToLower($this->config['lmt_licence_default'])) |
---|
163 | ); |
---|
164 | |
---|
165 | if($this->config['lmt_redirect_activated']=='y') |
---|
166 | { |
---|
167 | $url=$this->config['lmt_redirect_url-'.strToLower($this->config['lmt_licence_default'])][$user['language']]; |
---|
168 | if($url=='') |
---|
169 | { |
---|
170 | $url=$this->config['lmt_redirect_url-'.strToLower($this->config['lmt_licence_default'])]['en_UK']; |
---|
171 | } |
---|
172 | if($url!="") |
---|
173 | { |
---|
174 | $target=($this->config['lmt_redirect_open_target']=="y")?" onclick='window.open(this.href); return false;'":""; |
---|
175 | $replacements[0]="<a href='".$url."'".$target.">".$replacements[0]."</a>"; |
---|
176 | $replacements[1]="<a href='".$url."'".$target.">".$replacements[1]."</a>"; |
---|
177 | $replacements[2]="<a href='".$url."'".$target.">".$replacements[2]."</a>"; |
---|
178 | } |
---|
179 | } |
---|
180 | |
---|
181 | $text = preg_replace($patterns, $replacements, $text); |
---|
182 | |
---|
183 | $template->append("footer_elements", "<span>".htmlspecialchars_decode($text)."</span>"); |
---|
184 | } |
---|
185 | |
---|
186 | |
---|
187 | } //class |
---|
188 | |
---|
189 | ?> |
---|