[3396] | 1 | <?php |
---|
| 2 | /* ----------------------------------------------------------------------------- |
---|
| 3 | Plugin : LMT |
---|
| 4 | Author : Grum |
---|
| 5 | email : grum@piwigo.org |
---|
[4396] | 6 | website : http://photos.grum.fr |
---|
[3396] | 7 | |
---|
| 8 | << May the Little SpaceFrog be with you ! >> |
---|
| 9 | ------------------------------------------------------------------------------ |
---|
| 10 | See main.inc.php for release information |
---|
| 11 | |
---|
| 12 | LMT_root : common classe for admin and public classes |
---|
| 13 | |
---|
[4396] | 14 | --------------------------------------------------------------------------- */ |
---|
[5548] | 15 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'); |
---|
| 16 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCss.class.inc.php'); |
---|
| 17 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCAjax.class.inc.php'); |
---|
[3396] | 18 | |
---|
[5548] | 19 | class LMT_root extends CommonPlugin |
---|
[3396] | 20 | { |
---|
| 21 | protected $css; //the css object |
---|
| 22 | protected $css_icn; //the css object |
---|
| 23 | |
---|
| 24 | protected $licences=array('BY', 'BY-ND', 'BY-NC', 'BY-NC-ND', 'BY-NC-SA', 'BY-SA', 'CRIGHT', 'CLEFT', 'DEFAULT'); |
---|
| 25 | |
---|
[5548] | 26 | public function __construct($prefixeTable, $filelocation) |
---|
[3396] | 27 | { |
---|
[5548] | 28 | $this->setPluginName('LMT'); |
---|
| 29 | $this->setPluginNameFiles("lmt"); |
---|
| 30 | parent::__construct($prefixeTable, $filelocation); |
---|
| 31 | $this->section_name=$this->getPluginNameFiles(); |
---|
[3396] | 32 | |
---|
[5548] | 33 | $this->setTablesList(array('images', 'licence_author')); |
---|
[3396] | 34 | |
---|
| 35 | |
---|
[5548] | 36 | $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().".css"); |
---|
| 37 | $this->css_icn = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles()."_icn.css"); |
---|
[3396] | 38 | } |
---|
| 39 | |
---|
[5548] | 40 | public function __destruct() |
---|
[3396] | 41 | { |
---|
[5548] | 42 | unset($this->css); |
---|
| 43 | unset($this->css_icn); |
---|
| 44 | unset($this->licences); |
---|
| 45 | parent::__destruct(); |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | public function initEvents() |
---|
| 49 | { |
---|
[3396] | 50 | add_event_handler('blockmanager_register_blocks', array(&$this, 'register_blocks') ); |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | /* |
---|
| 54 | menu block management |
---|
| 55 | */ |
---|
| 56 | public function register_blocks() |
---|
| 57 | { |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | /* |
---|
[5548] | 63 | surchage of CommonPlugin->saveConfig function |
---|
[3396] | 64 | */ |
---|
[5548] | 65 | public function saveConfig() |
---|
[3396] | 66 | { |
---|
[5548] | 67 | if(parent::saveConfig()) |
---|
[3396] | 68 | { |
---|
[5548] | 69 | $this->css->makeCSS($this->generate_CSS()); |
---|
| 70 | $this->css_icn->makeCSS($this->generate_CSS2()); |
---|
[3396] | 71 | return(true); |
---|
| 72 | } |
---|
| 73 | return(false); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | /* |
---|
[5548] | 77 | surchage of CommonPlugin->saveConfig function |
---|
[3396] | 78 | */ |
---|
[5548] | 79 | public function loadConfig() |
---|
[3396] | 80 | { |
---|
[5548] | 81 | parent::loadConfig(); |
---|
| 82 | if(!$this->css->fileExists()) |
---|
[3396] | 83 | { |
---|
[5548] | 84 | $this->css->makeCSS($this->generate_CSS()); |
---|
[3396] | 85 | } |
---|
[5548] | 86 | if(!$this->css_icn->fileExists()) |
---|
[3396] | 87 | { |
---|
[5548] | 88 | $this->css_icn->makeCSS($this->generate_CSS2()); |
---|
[3396] | 89 | } |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | /* |
---|
[4396] | 93 | intialize default values |
---|
[3396] | 94 | */ |
---|
[5548] | 95 | public function initConfig() |
---|
[3396] | 96 | { |
---|
| 97 | //global $user; |
---|
[5548] | 98 | $this->config=array( |
---|
[3396] | 99 | 'lmt_mouseovercolor' => '303030', /**/ |
---|
| 100 | 'lmt_list_maxheight' => '650', |
---|
| 101 | 'lmt_list_maxitems' => '0', /* limit number of item displayed ; 0 : no limit */ |
---|
[4396] | 102 | 'lmt_licence_default' => 'BY', |
---|
| 103 | 'lmt_licence_default_author' => 0, |
---|
[3396] | 104 | 'lmt_licence_activated' => 'n', |
---|
| 105 | 'lmt_licence_visible' => 'n', /* y:always visible, n:only if needed */ |
---|
| 106 | 'lmt_licence_logo' => '80x15', /* 80x15, 88x31, text */ |
---|
[4396] | 107 | 'lmt_warning_visible' => 'y', /* y: display a text at the bottom of each page */ |
---|
[3396] | 108 | 'lmt_warning_texts' => array(), /* text displayed - multi lang */ |
---|
[4396] | 109 | 'lmt_redirect_activated' => 'y', /* y: the text is an url to a warning page */ |
---|
| 110 | 'lmt_redirect_open_target' => 'n', /* y: url are openned in a new page/tab */ |
---|
| 111 | 'lmt_redirect_url-by' => array(), |
---|
| 112 | 'lmt_redirect_url-by-nd' => array(), |
---|
| 113 | 'lmt_redirect_url-by-nc' => array(), |
---|
| 114 | 'lmt_redirect_url-by-nc-nd' => array(), |
---|
| 115 | 'lmt_redirect_url-by-nc-sa' => array(), |
---|
| 116 | 'lmt_redirect_url-by-sa' => array(), |
---|
| 117 | 'lmt_redirect_url-cright' => array(), |
---|
| 118 | 'lmt_redirect_url-cleft' => array(), |
---|
[3396] | 119 | ); |
---|
| 120 | |
---|
| 121 | $languages=get_languages(); |
---|
| 122 | foreach($languages as $key => $val) |
---|
| 123 | { |
---|
| 124 | $lang=substr($key,0,2)."/"; |
---|
| 125 | if($lang=="en/") { $lang=""; } |
---|
[5548] | 126 | $this->config['lmt_warning_texts'][$key]=''; |
---|
| 127 | $this->config['lmt_redirect_url-by'][$key]='http://creativecommons.org/licenses/by/2.0/'.$lang; |
---|
| 128 | $this->config['lmt_redirect_url-by-nd'][$key]='http://creativecommons.org/licenses/by-nd/2.0/'.$lang; |
---|
| 129 | $this->config['lmt_redirect_url-by-nc'][$key]='http://creativecommons.org/licenses/by-nc/2.0/'.$lang; |
---|
| 130 | $this->config['lmt_redirect_url-by-nc-nd'][$key]='http://creativecommons.org/licenses/by-nc-nd/2.0/'.$lang; |
---|
| 131 | $this->config['lmt_redirect_url-by-nc-sa'][$key]='http://creativecommons.org/licenses/by-nc-sa/2.0/'.$lang; |
---|
| 132 | $this->config['lmt_redirect_url-by-sa'][$key]='http://creativecommons.org/licenses/by-sa/2.0/'.$lang; |
---|
| 133 | $this->config['lmt_redirect_url-cright'][$key]=''; |
---|
| 134 | $this->config['lmt_redirect_url-cleft'][$key]=''; |
---|
[3396] | 135 | } |
---|
| 136 | |
---|
| 137 | } |
---|
| 138 | |
---|
| 139 | /* |
---|
| 140 | generate the css code |
---|
| 141 | */ |
---|
| 142 | protected function generate_CSS() |
---|
| 143 | { |
---|
| 144 | $text = " |
---|
| 145 | .TableRow:hover |
---|
| 146 | { |
---|
[5548] | 147 | background-color:#".$this->config['lmt_mouseovercolor']."; |
---|
[3396] | 148 | } |
---|
| 149 | |
---|
| 150 | .formtable |
---|
| 151 | { |
---|
| 152 | text-align:justify; |
---|
| 153 | display:block; |
---|
| 154 | margin-top:0px; |
---|
| 155 | margin-bottom:0px; |
---|
| 156 | width:100%; |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | .formtable tr { |
---|
| 160 | vertical-align:top; |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | .littlefont { font-size:90%; } |
---|
| 164 | table.littlefont th { text-align:center; padding:3px;padding-left:9px;padding-right:9px; } |
---|
| 165 | table.littlefont td { text-align:left; padding:0px;padding-left:3px;padding-right:3px; } |
---|
| 166 | |
---|
| 167 | .lmt_page |
---|
| 168 | { |
---|
| 169 | text-align:justify; |
---|
| 170 | margin:8px; |
---|
| 171 | } |
---|
| 172 | |
---|
| 173 | .lmt { |
---|
[4396] | 174 | text-align:justify; |
---|
[3396] | 175 | } |
---|
| 176 | |
---|
| 177 | #list { |
---|
| 178 | width:100%; |
---|
| 179 | overflow-y:scroll; |
---|
| 180 | min-height:250px; |
---|
| 181 | max-height:650px; |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | #ullist li { |
---|
| 185 | width:300px; |
---|
[4396] | 186 | display:block; |
---|
[3396] | 187 | float:left; |
---|
| 188 | text-align:left; |
---|
| 189 | } |
---|
| 190 | |
---|
| 191 | #ullist label { |
---|
| 192 | float:left; |
---|
| 193 | } |
---|
| 194 | |
---|
| 195 | #ullist li table { |
---|
| 196 | margin:0px; |
---|
| 197 | text-align:left; |
---|
| 198 | width:300px; |
---|
| 199 | font-size:80%; |
---|
| 200 | } |
---|
| 201 | |
---|
| 202 | #ullist li tr { |
---|
| 203 | vertical-align:top; |
---|
| 204 | } |
---|
| 205 | |
---|
| 206 | .content ul.thumbnails span.extendwrap1 { |
---|
| 207 | margin:0px; |
---|
| 208 | cursor:pointer; |
---|
| 209 | } |
---|
| 210 | |
---|
| 211 | .is_on, .is_off { |
---|
| 212 | z-index:20; |
---|
| 213 | width:12px; |
---|
| 214 | height:12px; |
---|
| 215 | display:block; |
---|
| 216 | cursor:pointer; |
---|
| 217 | } |
---|
| 218 | |
---|
| 219 | .is_on { |
---|
| 220 | background:url(./img/cb_on.png); |
---|
| 221 | } |
---|
| 222 | .is_off { |
---|
| 223 | background:url(./img/cb_off.png); |
---|
| 224 | } |
---|
| 225 | |
---|
| 226 | .icnhelp { |
---|
| 227 | weight:bold; |
---|
| 228 | text-decoration:none; |
---|
| 229 | cursor:help; |
---|
| 230 | } |
---|
| 231 | |
---|
| 232 | .hinthlp { |
---|
| 233 | position:absolute; |
---|
| 234 | max-width:400px; |
---|
| 235 | border:1px solid #000000; |
---|
| 236 | background:#ffffa0; |
---|
| 237 | color:#000000; |
---|
| 238 | top:0px; |
---|
[4396] | 239 | left:-450px; |
---|
[3396] | 240 | padding:2px; |
---|
| 241 | text-align:justify; |
---|
| 242 | } |
---|
| 243 | |
---|
| 244 | "; |
---|
| 245 | return($text); |
---|
| 246 | } |
---|
| 247 | |
---|
| 248 | /* |
---|
[4396] | 249 | generate the css code |
---|
[3396] | 250 | */ |
---|
| 251 | protected function generate_CSS2() |
---|
| 252 | { |
---|
| 253 | $text = " |
---|
| 254 | .logo80x15 { |
---|
| 255 | position:relative; |
---|
| 256 | top:4px; |
---|
| 257 | margin-right:4px; |
---|
| 258 | border:0px none; |
---|
| 259 | } |
---|
| 260 | |
---|
| 261 | .logo88x31 { |
---|
| 262 | position:relative; |
---|
| 263 | margin-right:4px; |
---|
| 264 | border:0px none; |
---|
| 265 | } |
---|
| 266 | |
---|
| 267 | #theImage img.logo80x15, #theImage img.logo88x31 { |
---|
| 268 | border:0px none; |
---|
[4396] | 269 | padding:0px; |
---|
[3396] | 270 | } |
---|
| 271 | |
---|
| 272 | .licencetag { |
---|
| 273 | display:block; |
---|
| 274 | padding-top:10px; |
---|
| 275 | font-size:80%; |
---|
| 276 | } |
---|
| 277 | "; |
---|
| 278 | return($text); |
---|
| 279 | } |
---|
| 280 | |
---|
| 281 | |
---|
| 282 | |
---|
| 283 | |
---|
| 284 | /* ------------------------------------------------------------------------- |
---|
| 285 | return the licence type for an image |
---|
| 286 | $default = 'y' => if no licence for the picture, return de default licence |
---|
| 287 | 'n' => if no licence for the picture, return empty values |
---|
| 288 | ------------------------------------------------------------------------- */ |
---|
| 289 | public function get_image_licence($image_id) |
---|
| 290 | { |
---|
| 291 | |
---|
| 292 | $return=array( |
---|
| 293 | "default" => "", |
---|
| 294 | "licence" => "", |
---|
| 295 | "aut_text1" => "", |
---|
| 296 | "aut_text2" => "" |
---|
| 297 | ); |
---|
[4396] | 298 | $sql="SELECT lmti.licence_type, lmta.text1, lmta.text2 |
---|
[3396] | 299 | FROM ".$this->tables['images']." lmti |
---|
| 300 | LEFT OUTER JOIN ".$this->tables['licence_author']." lmta ON lmti.author_id = lmta.id |
---|
| 301 | WHERE lmti.image_id = '".$image_id."'"; |
---|
| 302 | $result=pwg_query($sql); |
---|
| 303 | if($result) |
---|
| 304 | { |
---|
[5431] | 305 | while($row=pwg_db_fetch_assoc($result)) |
---|
[3396] | 306 | { |
---|
| 307 | $return=array( |
---|
| 308 | "defaut" => "n", |
---|
| 309 | "licence" => $row['licence_type'], |
---|
| 310 | "aut_text1" => $row['text1'], |
---|
| 311 | "aut_text2" => $row['text2'] |
---|
| 312 | ); |
---|
| 313 | } |
---|
| 314 | } |
---|
| 315 | |
---|
[5548] | 316 | if(($return["licence"]=="")&&($this->config["lmt_licence_visible"]=="y")) |
---|
[3396] | 317 | { |
---|
| 318 | $return=array( |
---|
| 319 | "defaut" => "y", |
---|
[5548] | 320 | "licence" => $this->config["lmt_licence_default"], |
---|
[3396] | 321 | "aut_text1" => "", |
---|
| 322 | "aut_text2" => "" |
---|
| 323 | ); |
---|
| 324 | |
---|
[4396] | 325 | $sql="SELECT * FROM ".$this->tables['licence_author']." |
---|
[5548] | 326 | WHERE id = '".$this->config["lmt_licence_default_author"]."'"; |
---|
[3396] | 327 | $result=pwg_query($sql); |
---|
[4396] | 328 | if($result) |
---|
[3396] | 329 | { |
---|
[5431] | 330 | while($row=pwg_db_fetch_assoc($result)) |
---|
[3396] | 331 | { |
---|
| 332 | $return["aut_text1"]=$row['text1']; |
---|
| 333 | $return["aut_text2"]=$row['text2']; |
---|
| 334 | } |
---|
| 335 | } |
---|
| 336 | } |
---|
| 337 | |
---|
[4396] | 338 | return($return); |
---|
[3396] | 339 | } |
---|
| 340 | |
---|
| 341 | |
---|
| 342 | /* ------------------------------------------------------------------------- |
---|
| 343 | returns an array of image id with the licence type |
---|
| 344 | if $licence = "" => return all picture with a specific licences |
---|
| 345 | ------------------------------------------------------------------------- */ |
---|
| 346 | public function get_images_licences($licence) |
---|
| 347 | { |
---|
| 348 | $sql="".$this->tables['lmt']; |
---|
| 349 | |
---|
| 350 | $result=pwg_query($sql.$sql_where.$sql_order); |
---|
| 351 | if($result) |
---|
| 352 | { |
---|
| 353 | $returned=array(); |
---|
[5431] | 354 | while($row=pwg_db_fetch_assoc($result)) |
---|
[3396] | 355 | { |
---|
| 356 | array_push($returned, $row); |
---|
| 357 | } |
---|
| 358 | return($returned); |
---|
[4396] | 359 | } |
---|
| 360 | return(false); |
---|
[3396] | 361 | } |
---|
| 362 | |
---|
[5548] | 363 | protected function displayResult($action_msg, $result) |
---|
[3396] | 364 | { |
---|
| 365 | global $page; |
---|
| 366 | |
---|
| 367 | if($result) |
---|
| 368 | { |
---|
| 369 | array_push($page['infos'], $action_msg); |
---|
| 370 | } |
---|
| 371 | else |
---|
| 372 | { |
---|
| 373 | array_push($page['errors'], $action_msg); |
---|
| 374 | } |
---|
| 375 | } |
---|
| 376 | |
---|
| 377 | |
---|
| 378 | /* --------------------------------------------------------------------------- |
---|
| 379 | ajax functions |
---|
| 380 | --------------------------------------------------------------------------- */ |
---|
| 381 | |
---|
| 382 | |
---|
| 383 | } //class |
---|
| 384 | |
---|
| 385 | ?> |
---|