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