-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverysimpleimagegallery.php
746 lines (661 loc) · 32.8 KB
/
verysimpleimagegallery.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
<?php
/*
* Minimal update of the VSIG for Joomla 2.5 to work with Joomla 3 by Elin Waring @ http://officialjoomlabook.com.
*
// "Very Simple Image Gallery" Plugin for Joomla 2.5 - Version 1.6.7
// License: GNU General Public License version 2 or later; see LICENSE.txt
// Author: Andreas Berger - [email protected]
// Copyright (C) 2012 Andreas Berger - http://www.bretteleben.de. All rights reserved.
// Project page and Demo at http://www.bretteleben.de
// ***Last update: 2012-04-17***
*/
defined('_JEXEC') or die;
class plgContentVerysimpleimagegallery extends JPlugin {
//#############################################################################
//substitute article id - start
//public $myarticleid = '00';//substitute article id on frontpage
public $vsigcounter = 0;//substitute article id
//substitute article id - end
//#############################################################################
public function onContentPrepare($context, &$article, &$params, $limitstart=0)
{
// checking
$document=JFactory::getDocument();
// Only render the plugin on an html page.
if($document->getType() != 'html')
{
return;
}
// Search for the matching string
if (!isset($article->text) || !preg_match("#{vsig}(.*?){/vsig}#s", $article->text) )
{
return;
}
//paths
$path_absolute = JPATH_SITE;
$path_site = JURI :: base(true);
if(substr($path_site, -1)=="/") $path_site = substr($path_site, 0, -1);
// default image root folder //1.6
$path_imgroot = '/images/';
// button folder
$path_ctrls = '/images/vsig_buttons/';
// path to plugin folder
$path_plugin = '/plugins/content/verysimpleimagegallery/files/';
// thumbnail subfolder
$folder_thumbs = 'vsig_thumbs';
// image subfolder
$folder_images = 'vsig_images';
// import helper
JLoader::import( 'verysimpleimagegalleryhelper', dirname( __FILE__ ).'/files' );
//captions
if (preg_match_all("#{vsig_c}(.*?){/vsig_c}#s", $article->text, $matches, PREG_PATTERN_ORDER) > 0)
{ //1.6
foreach ($matches[0] as $match)
{
$_raw_cap_ = preg_replace("/{.+?}/", "", $match);
$_raw_cap_exp_ = explode("|",$_raw_cap_);
$cap1=($_raw_cap_exp_[1]&&trim($_raw_cap_exp_[1])!="")?(trim(plgContentVerysimpleimagegalleryHelper::beStrtolower($_raw_cap_exp_[1]))):("CAPDEFAULT");
$cap2=($_raw_cap_exp_[2]&&trim($_raw_cap_exp_[2])!="")?(trim($_raw_cap_exp_[2])):("");
$cap3=($_raw_cap_exp_[3]&&trim($_raw_cap_exp_[3])!="")?(trim($_raw_cap_exp_[3])):("");
$caparray="cap_ar".$_raw_cap_exp_[0];
if(!isset($$caparray)){$$caparray=array();};
${$caparray}[$cap1]=array($cap2,$cap3);
//remove the call
$article->text = plgContentVerysimpleimagegalleryHelper::beReplaceCall("{vsig_c}".$_raw_cap_."{/vsig_c}",'', $article->text);
}
}
//links
if (preg_match_all("#{vsig_l}(.*?){/vsig_l}#s", $article->text, $matches, PREG_PATTERN_ORDER) > 0) { //1.6
foreach ($matches[0] as $match) {
$_raw_link_ = preg_replace("/{.+?}/", "", $match);
$_raw_link_exp_ = explode("|",$_raw_link_);
$_link1=($_raw_link_exp_[1]&&trim($_raw_link_exp_[1])!="")?(trim(plgContentVerysimpleimagegalleryHelper::beStrtolower($_raw_link_exp_[1]))):("LINKDEFAULT");
$_link2=($_raw_link_exp_[2]&&trim($_raw_link_exp_[2])!="")?(trim($_raw_link_exp_[2])):("");
$_link3=($_raw_link_exp_[3]&&trim($_raw_link_exp_[3])!="")?(trim($_raw_link_exp_[3])):($_link2);
$_link4=($_raw_link_exp_[4]&&trim($_raw_link_exp_[4])!="")?(trim($_raw_link_exp_[4])):("_self");
$_linkarray="_linkar".$_raw_link_exp_[0];
if(!isset($$_linkarray)){$$_linkarray=array();};
${$_linkarray}[$_link1]=array($_link2,$_link3,$_link4);
//remove the call
$article->text = plgContentVerysimpleimagegalleryHelper::beReplaceCall("{vsig_l}".$_raw_link_."{/vsig_l}",'', $article->text);
}
}
//images
if (preg_match_all("#{vsig}(.*?){/vsig}#s", $article->text, $matches, PREG_PATTERN_ORDER) > 0)
{ //1.6
$sigcount = -1;
//substitute article id - start
$headerstuff = $document->getHeadData();
foreach($headerstuff['custom'] as $key => $custom){
if(stristr($custom, 'vsig_count') !== false){
$vsigcount=explode(" ", trim($custom));
$this->vsigcounter=$vsigcount[2];
unset($headerstuff['custom'][$key]);
}
}
$document->setHeadData($headerstuff);
$this->vsigcounter = $this->vsigcounter+1;
$document->addCustomTag('<!-- vsig_count '.$this->vsigcounter.' -->' );
//substitute article id - end
$_target=JRequest::getURI();
$vsig_cssadd=""; //collect css for page head
$vsig_script=""; //collect javascript for page head
foreach ($matches[0] as $match)
{
$sigcount++;
//split string and check for overrides
$vsig_code = preg_replace("/{.+?}/", "", $match);
$vsig_raw = explode ("|", $vsig_code);
$_images_dir_ = trim($vsig_raw[0]);
if(substr($_images_dir_,-1,1)!="/"&&$_images_dir_!=""){$_images_dir_=$_images_dir_."/";} //add trailing slash
if(substr($_images_dir_,0,1)=="/"&&$_images_dir_!=""){$_images_dir_=substr($_images_dir_,1,strlen($_images_dir_)-1);} //remove leading slash
//process overrides if any
unset ($vsig_overrides);
$vsig_overrides=array();
if(count($vsig_raw)>=2)
{
//there are parameteroverrides
for($i=1;$i<count($vsig_raw);$i++)
{
$overr_temp=explode("=",$vsig_raw[$i]);
if(count($overr_temp)>=2)
{
$vsig_overrides[strtolower(trim($overr_temp[0]))]=trim($overr_temp[1]);
}
}
}
unset($images);
$noimage = 0;
//read and process the param for the image root
$path_imgroot = trim($this->params->get('imagepath', $path_imgroot));
if(substr($path_imgroot, -1)!="/"){$path_imgroot=$path_imgroot."/";} //add trailing slash
if(substr($path_imgroot,0,1)!="/"){$path_imgroot="/".$path_imgroot;} //add leading slash
//check permissions and set default if possible
//jimport('joomla.filesystem.path');
//$dpcr = JPath::canChmod($path_absolute.$path_imgroot.$_images_dir_);
//if($dpcr==1){$dpcr = JPath::setPermissions($path_absolute.$path_imgroot.$_images_dir_);};
// read directory and check for images
if ($dh = @opendir($path_absolute.$path_imgroot.$_images_dir_)) {
while (($f = readdir($dh)) !== false) {
if((substr(strtolower($f),-4) == '.jpg') || (substr(strtolower($f),-4) == '.gif') || (substr(strtolower($f),-4) == '.png')) {
$noimage++;
$images[] = array('filename' => $f, 'flastmod' => filemtime($path_absolute.$path_imgroot.$_images_dir_.$f));
}
}
closedir($dh);
//damn, found the folder but it is empty
$html1="<br />Very Simple Image Gallery:<br />No images found in folder ".$path_absolute.$path_imgroot.$_images_dir_."<br />";
}
else {
//you promised me a folder - where is it?
$html1="<br />Very Simple Image Gallery:<br />Could not find folder ".$path_absolute.$path_imgroot.$_images_dir_."<br />";
}
if($noimage) {
//read in parameters and overrides
$_width_ = (array_key_exists("twidth",$vsig_overrides)&&$vsig_overrides['twidth']!="")?($vsig_overrides['twidth']):($this->params->get('th_width', 120)); //thumbs
$_height_ = (array_key_exists("theight",$vsig_overrides)&&$vsig_overrides['theight']!="")?($vsig_overrides['theight']):($this->params->get('th_height', 90)); //thumbs
$_keep_ = (array_key_exists("crop",$vsig_overrides)&&$vsig_overrides['crop']!="")?($vsig_overrides['crop']):($this->params->get('th_keep', 'keep')); //thumbs
$_imquality_ = (array_key_exists("imquality",$vsig_overrides)&&$vsig_overrides['imquality']!="")?($vsig_overrides['imquality']):($this->params->get('im_quality', 90)); //image
$_quality_ = (array_key_exists("quality",$vsig_overrides)&&$vsig_overrides['quality']!="")?($vsig_overrides['quality']):($this->params->get('th_quality', 80)); //thumbs
$_space_ = (array_key_exists("space",$vsig_overrides)&&$vsig_overrides['space']!="")?($vsig_overrides['space']):($this->params->get('th_space', 5)); //thumbs
$_imwidth_ = (array_key_exists("width",$vsig_overrides)&&$vsig_overrides['width']!="")?($vsig_overrides['width']):($this->params->get('im_width', 400)); //image
$_imheight_ = (array_key_exists("height",$vsig_overrides))?($vsig_overrides['height']):($this->params->get('im_height', '')); //image
$_im_align_ = (array_key_exists("align",$vsig_overrides)&&$vsig_overrides['align']!="")?($vsig_overrides['align']):($this->params->get('im_align', 1)); //image
$_usescript_ = (array_key_exists("script",$vsig_overrides)&&$vsig_overrides['script']!="")?($vsig_overrides['script']):($this->params->get('usescript', 1)); //javascript
$_hover_ = (array_key_exists("hover",$vsig_overrides)&&$vsig_overrides['hover']!="")?($vsig_overrides['hover']):($this->params->get('th_hover', 0)); //javascript
$_preload_ = (array_key_exists("preload",$vsig_overrides)&&$vsig_overrides['preload']!="")?($vsig_overrides['preload']):($this->params->get('preload', 0)); //javascript
$_tooltip_ = (array_key_exists("tooltip",$vsig_overrides)&&$vsig_overrides['tooltip']!="")?($vsig_overrides['tooltip']):($this->params->get('tooltip', 0)); //tooltips
$_th_right_ = (array_key_exists("right",$vsig_overrides)&&$vsig_overrides['right']!="")?($vsig_overrides['right']):($this->params->get('th_right', 2)); //layout
$_th_cols_ = (array_key_exists("cols",$vsig_overrides)&&$vsig_overrides['cols']!="")?($vsig_overrides['cols']):($this->params->get('th_cols', 1)); //layout
$_th_sort_ = (array_key_exists("sort",$vsig_overrides)&&$vsig_overrides['sort']!="")?($vsig_overrides['sort']):($this->params->get('th_sort', 0)); //thumbs
$_setid_ = (array_key_exists("folderid",$vsig_overrides)&&$vsig_overrides['folderid']!="")?($vsig_overrides['folderid']):($this->params->get('setid', 0)); //foldername
$_cap_show_ = (array_key_exists("caps",$vsig_overrides)&&$vsig_overrides['caps']!="")?($vsig_overrides['caps']):($this->params->get('cap_show', 1)); //captions
$_cap_pos_ = (array_key_exists("inout",$vsig_overrides)&&$vsig_overrides['inout']!="")?($vsig_overrides['inout']):($this->params->get('cap_pos', 1)); //captions
$_link_use_ = (array_key_exists("links",$vsig_overrides)&&$vsig_overrides['links']!="")?($vsig_overrides['links']):($this->params->get('link_use', 1)); //links
$_link_orig_ = (array_key_exists("autolink",$vsig_overrides)&&$vsig_overrides['autolink']!="")?($vsig_overrides['autolink']):($this->params->get('link_orig', 0)); //links
$_sets_use_ = (array_key_exists("sets",$vsig_overrides)&&$vsig_overrides['sets']!="")?($vsig_overrides['sets']):($this->params->get('sets_use', '')); //sets
$_sets_txt_ = (array_key_exists("setstxt",$vsig_overrides)&&$vsig_overrides['setstxt']!="")?($vsig_overrides['setstxt']):($this->params->get('sets_txt', 'Set')); //sets
$path_ctrls = trim($this->params->get('buttonpath', $path_ctrls));
//controls
$_ctrl_fwd_ = (array_key_exists("cfwd",$vsig_overrides))?($vsig_overrides['cfwd']):(trim($this->params->get('ctrl_fwd', '')));
$_ctrl_back_ = (array_key_exists("cbwd",$vsig_overrides))?($vsig_overrides['cbwd']):(trim($this->params->get('ctrl_back', '')));
$_ctrl_height_ = 24;
//check if images are used for controls and allow default buttons
$_ctrl_fwd_type = $_ctrl_back_type = "noimg";
if(is_file($path_absolute.$path_ctrls.$_ctrl_fwd_)&&((substr(strtolower($_ctrl_fwd_),-3)=='jpg')||(substr(strtolower($_ctrl_fwd_),-3)=='gif')||(substr(strtolower($_ctrl_fwd_),-3)=='png'))){$_ctrl_fwd_=$path_ctrls.$_ctrl_fwd_;$_ctrl_fwd_type="img";}
elseif($_ctrl_fwd_==""){$_ctrl_fwd_=$path_plugin.'fwd.png';$_ctrl_fwd_type="img";}
if(is_file($path_absolute.$path_ctrls.$_ctrl_back_)&&((substr(strtolower($_ctrl_back_),-3)=='jpg')||(substr(strtolower($_ctrl_back_),-3)=='gif')||(substr(strtolower($_ctrl_back_),-3)=='png'))){$_ctrl_back_=$path_ctrls.$_ctrl_back_;$_ctrl_back_type="img";}
elseif($_ctrl_back_==""){$_ctrl_back_=$path_plugin.'bwd.png';$_ctrl_back_type="img";}
//calculations
$_im_area_=$_imwidth_-10;
if($_th_right_=="1"||$_th_right_=="3"){
$_im_area_=$_imwidth_+10;
$_th_cols_=(($_im_area_-($_width_+8+$_space_)*$_th_cols_) >=($_width_+10))?($_th_cols_):(1);
$_im_area_=intval($_imwidth_-($_width_+8+$_space_)*$_th_cols_);
$_rulerspace_=intval(($_width_+8+$_space_)*$_th_cols_);
$_rulerspace_.="px";
$_im_area_=$_im_area_-10;
}
//calculate the number of sets
$_sets_number_=($_sets_use_&&$_sets_use_<=(count($images)+1))?(ceil(count($images)/$_sets_use_)):1;
//justify
if($_th_right_=="2"){
$_im_area_=$_im_area_+10;
$countthumbs=intval($_im_area_/(($_width_+8+$_space_)));
$toremove=$_im_area_-($countthumbs*($_width_+8+$_space_));
$newwidth=$_width_+intval($toremove/$countthumbs);
$_height_=intval($_height_/$_width_*$newwidth);
$_width_=$newwidth;
$_im_area_=$countthumbs*($_width_+8+$_space_)-$_space_-10;
}
//calulate the image proportions
if(trim($_imheight_)!=""){$therealimageheight=(int)($_imheight_*($_im_area_/$_imwidth_));}
else{$therealimageheight="full";}
//create a unique identifier for the current gallery
$identifier=$this->vsigcounter."_".$sigcount;
//write the styles for the gallery
if($_th_right_!="1"&&$_th_right_!="3")
{
$vsig_cssadd.=".vsig_cont".$identifier." {margin:0 ".$_space_."px ".$_space_."px 0 !important;width:".($_width_+8)."px;height:".($_height_+8)."px;}\n";
$vsig_cssadd.=".vsig_top".$identifier." {width:".$_im_area_."px;margin:0px 0px 0px 0px;}\n";
}
else
{
if($_th_right_=="1")
{
$vsig_cssadd.=".vsig_cont".$identifier." {margin:0 0 ".$_space_."px ".$_space_."px !important;width:".($_width_+8)."px;height:".($_height_+7)."px;}\n";
$vsig_cssadd.=".vsig_top".$identifier." {width:".$_im_area_."px;float:left;margin:0px 0px 0px 0px;}\n.vsig_ruler".$identifier." {float:right !important;width:".$_rulerspace_.";}\n";
}
else
{
$vsig_cssadd.=".vsig_cont".$identifier." {margin:0 ".$_space_."px ".$_space_."px 0 !important;width:".($_width_+8)."px;height:".($_height_+7)."px;}\n";
$vsig_cssadd.=".vsig_top".$identifier." {width:".$_im_area_."px;float:left;margin:0px 0px 0px 0px;}\n.vsig_ruler".$identifier." {float:left !important;width:".$_rulerspace_.";}\n";
}
}
if ($_im_align_==0)
{
$vsig_cssadd.=".vsig".$identifier." {margin:0 0 0 auto;padding:0;display:block;width:".$_imwidth_."px;}\n";
}
elseif ($_im_align_==1)
{
$vsig_cssadd.=".vsig".$identifier." {margin:auto;display:block;width:".$_imwidth_."px;}\n";
}
elseif ($_im_align_==3)
{
$vsig_cssadd.=".vsig".$identifier." {margin:10px;float:left;width:".$_imwidth_."px;}\n";
}
elseif ($_im_align_==4)
{
$vsig_cssadd.=".vsig".$identifier." {margin:10px;float:right;width:".$_imwidth_."px;}\n";
}
else {
$vsig_cssadd.=".vsig".$identifier." {width:".$_imwidth_."px;}\n";
}
$vsig_cssadd.=".vsig_ctrls_".$identifier." {display:block;width:".($_im_area_+10)."px;height:".$_ctrl_height_."px;text-align:right;";
if($_th_right_==3)
{
$vsig_cssadd.="float:right !important;";
}
else
{
$vsig_cssadd.="float:left !important;";
}
$vsig_cssadd.="}\n";
//manipulate uri
$aktimg=0;
$target[$identifier]=htmlspecialchars($_target);
$foundrequest=JRequest::getVar('vsig'.$identifier, 'FALSE');
if($foundrequest!='FALSE'){
$aktimg=(int)$foundrequest;
//if we find on of our request-params a potential random sort is changed to the default sort
if($_th_sort_==4){$_th_sort_=0;}
$target[$identifier] = preg_replace('@[&|&]?vsig'.$identifier.'=[0-9]+@', '', $target[$identifier] );
$target[$identifier] = @preg_replace('@(\?&)@', '?', $target[$identifier] );
}
$vsig_adqm = strpos($target[$identifier], '?');
$target[$identifier].=($vsig_adqm===false)?("?"):("");
$target[$identifier].=(substr($target[$identifier], -1)!="?")?("&"):("");
$target[$identifier] = @preg_replace('@(&&)@', '&', $target[$identifier] );
//current set according to main image else 1
$_sets_current_=($_sets_use_)?(intval($aktimg/$_sets_use_)+1):1;
//sort images
$images = plgContentVerysimpleimagegalleryHelper::beSortImages($images,$_th_sort_);
//set path of thumbnail directory
$thumbdir=$path_absolute.$path_imgroot.$_images_dir_.$folder_thumbs.'/';
//check_existence_of/create thumbdirectory
if(!is_dir($thumbdir))
{
plgContentVerysimpleimagegalleryHelper::beMakeFolder($thumbdir,'thumbnail');
}
//set path of image directory
$imgdir=$path_absolute.$path_imgroot.$_images_dir_.$folder_images.'/';
// Check_existence_of/create imagedirectory
if(!is_dir($imgdir))
{
plgContentVerysimpleimagegalleryHelper::beMakeFolder($imgdir,'image');
}
// Set the var for the current array of captions
$captions="cap_ar".$sigcount;
// Set the var for the current array of links
$vsiglinks = "_linkar" . $sigcount;
//start collecting html and set folder identity - if set to do so
if($_setid_)
{
$_tempstring=explode("/",$_images_dir_);
$_tempstring=$_tempstring[count($_tempstring)-2];
$html1 = "\n<a id='g_vsig".$identifier."'></a><div class='vsig vsig".$identifier."' id='".$_tempstring."'>";
}
else
{
$html1 = "\n<a id='g_vsig".$identifier."'></a><div class='vsig vsig".$identifier."'>";
}
//start collecting html for main-image-part
$html2='';
//start collecting html for thumbs-part
$html3='';
//create current javascript array
if($_usescript_){
$vsig_script.="var vsig_".$identifier."= new Array();\n";
$vsig_script.="var vsig_".$identifier."_b=new Array('".$path_site.$path_imgroot.$_images_dir_."','".$folder_thumbs."/','".$identifier."','".$target[$identifier]."vsig".$identifier."=');\n";
}
//set counter for thumbs in set to 1
$thumbs_in_set=1;
//traverse the found images#######################
for($a = 0; $a < $noimage; $a++)
{
if($images[$a]['filename'] != '') {
//prepare captions############################
$cur_cap=array("",""); //reset captions
$cur_cap_set=0; //set trigger for captions
if($_cap_show_&&isset($$captions))
{
// Are captions activated and are there captions?
if(array_key_exists(plgContentVerysimpleimagegalleryHelper::beStrtolower($images[$a]['filename']),$$captions)){ //check for specific caption
$cur_cap=array(${$captions}[plgContentVerysimpleimagegalleryHelper::beStrtolower($images[$a]['filename'])][0],${$captions}[plgContentVerysimpleimagegalleryHelper::beStrtolower($images[$a]['filename'])][1]);
$cur_cap_set=1;
}
elseif(array_key_exists("CAPDEFAULT",$$captions))
{
//check for default caption
$cur_cap=array(${$captions}["CAPDEFAULT"][0],${$captions}["CAPDEFAULT"][1]);
$cur_cap_set=1;
}
}
//create values for js
$cur_cap_js=$cur_cap;
//encode captions
$cur_cap_js[0] = plgContentVerysimpleimagegalleryHelper::beKickQuotes($cur_cap_js[0]);
$cur_cap_js[1] = plgContentVerysimpleimagegalleryHelper::beKickQuotes($cur_cap_js[1]);
//prepare links###############################
$cur_link=array("#g_vsig".$identifier,"","_self"); //reset links
//check for autolinks
if($_link_orig_)
{
$setlinks="_linkar".$sigcount;
if(!isset($$setlinks)){$$setlinks=array();}
$_link1=$images[$a]['filename'];
$_link2=$path_site.$path_imgroot.$_images_dir_.$images[$a]['filename'];
$_link3=$images[$a]['filename'];
${$setlinks}[$_link1]=array($_link2,$_link3,"_blank");
}
if($_link_use_&&isset($$vsiglinks))
{
// Are links activated and are there links?
if(array_key_exists(plgContentVerysimpleimagegalleryHelper::beStrtolower($images[$a]['filename']),$$vsiglinks)){ //check for specific links
$cur_link=${$vsiglinks}[plgContentVerysimpleimagegalleryHelper::beStrtolower($images[$a]['filename'])];
}
elseif
(array_key_exists("LINKDEFAULT",$$vsiglinks))
{
//check for default link
$cur_link=${$vsiglinks}["LINKDEFAULT"];
}
}
//create values for js
$cur_link_js=$cur_link;
//encode links
$cur_link[1] = htmlspecialchars($cur_link_js[1], ENT_QUOTES);
$cur_link_js[1] = plgContentVerysimpleimagegalleryHelper::beKickQuotes($cur_link_js[1]);
//prepare alt and title#######################
$cur_alt=($_tooltip_>=1)?(substr($images[$a]['filename'], 0, -4)):(""); //reset alt-text and title
//create values for js
$cur_alt_js=$cur_alt;
//encode alt-title from image name
$cur_alt = utf8_encode($cur_alt);
$cur_alt_js = $cur_alt;
//check captions to use instead of file name
if(isset($$captions)){ //are there captions?
if(array_key_exists(plgContentVerysimpleimagegalleryHelper::beStrtolower($images[$a]['filename']),$$captions)){ //check for specific caption
$cur_alt=${$captions}[plgContentVerysimpleimagegalleryHelper::beStrtolower($images[$a]['filename'])][0];
}
elseif(array_key_exists("CAPDEFAULT",$$captions)){ //check for default caption
$cur_alt=${$captions}["CAPDEFAULT"][0];
}
//create values for js
$cur_alt_js=$cur_alt;
//encode alt-title from captions
}
//if a specific link is set, the title overrides all
if($_link_use_&&isset($$vsiglinks)&&array_key_exists(plgContentVerysimpleimagegalleryHelper::beStrtolower($images[$a]['filename']),$$vsiglinks)&&${$vsiglinks}[plgContentVerysimpleimagegalleryHelper::beStrtolower($images[$a]['filename'])][1]!=""){
$cur_alt=${$vsiglinks}[plgContentVerysimpleimagegalleryHelper::beStrtolower($images[$a]['filename'])][1];
//encode alt-title from links
//$cur_alt=$cur_alt;
$cur_alt_js=$cur_alt;
}
//encode alt-title
$cur_alt_js = plgContentVerysimpleimagegalleryHelper::beKickQuotes($cur_alt_js);
$cur_alt = plgContentVerysimpleimagegalleryHelper::beKickQuotes($cur_alt);
//check_existence_of/create img
$theimage = plgContentVerysimpleimagegalleryHelper::beResizeImg($path_absolute.$path_imgroot.$_images_dir_.$images[$a]['filename'],$folder_images,$_im_area_,$therealimageheight,'keep','no',$_imquality_);
//prepare and encode webpath main image#######
$cur_webpath=$path_site.$path_imgroot.$_images_dir_.$folder_images."/".$theimage[1];
//top image###################################
if ($images[$a]['filename'] == $images[$aktimg]['filename'])
{
$html2 .= "\n<div class='vsig_top vsig_top".$identifier."'>";
if($_link_use_&&isset($$vsiglinks)){ //links are activated and set
$html2 .= "\n<a href='".$cur_link[0]."' title='".$cur_link[1]."' target='".$cur_link[2]."'>";
}
$html2 .= "\n<img id='topimg".$identifier."' src='".$cur_webpath."' title='".$cur_alt."' alt='".$cur_alt."'/>";
if($_link_use_&&isset($$vsiglinks))
{
//links are activated and set
$html2 .= "\n</a>";
}
if( $_cap_show_ && isset($captions))
{
//we have to show captions
$html2 .= "\n<div class='".(($_cap_pos_)?'inside':'outside')."' style='width:".$_im_area_."px;'>";
if($cur_cap_set)
{
// Captions (specific or default) are set for this image
$cur_cap[1] = preg_replace('/[\$]/', '$', $cur_cap[1]);//prevent the $ from getting executed as a variable;
$html2 .= "<span>".$cur_cap[0]."</span><span>".$cur_cap[1]."</span>";
}
$html2 .= "\n</div>".(($_cap_pos_)?"":"<br class='vsig_clr' />");
}
$html2 .= "\n</div>\n";
}
//thumbnails##################################
//check_existence_of/create thumb
$thethumb = plgContentVerysimpleimagegalleryHelper::beResizeImg($path_absolute.$path_imgroot.$_images_dir_.$images[$a]['filename'], $folder_thumbs, $_width_, $_height_, $_keep_, 'no', $_quality_);
//prepare and encode webpath thumbs#######
$cur_thumb_webpath=$path_site.$path_imgroot.$_images_dir_.$folder_thumbs.'/'.$thethumb[1];
//check if sets are used and if the current thumb belongs to the current set
if(!$_sets_use_||($a>=($_sets_use_*$_sets_current_-$_sets_use_)&&$a<=($_sets_use_*$_sets_current_-1)&&$_sets_use_>=2)){
//write html for thumbs
$html3 .= '<div id="thbvsig_'.$identifier.'_'.$thumbs_in_set.'" class="vsig_cont vsig_cont'.$identifier.'"><div class="vsig_thumb">';
$html3 .= '<a href="'.$target[$identifier].'vsig'.$identifier.'='.$a.'" rel="nofollow"';
if($_usescript_>=1){ //javascript is activated, insert the onclick event
$html3 .= ' onclick=\'switchimg(vsig_'.$identifier.'['.$a.'],vsig_'.$identifier.'_b);return false;\'';
if($_hover_>=1){ //change main image on thumbhover too
$html3 .= ' onmouseover=\'switchimg(vsig_'.$identifier.'['.$a.'],vsig_'.$identifier.'_b);return false;\'';
}
}
$html3 .= ' title="'.$cur_alt.'">';
$html3 .= '<img src="'.$cur_thumb_webpath.'" alt="'.$cur_alt.'"/>';
$html3 .= "</a></div></div>\n";
//increment counter for thumbs in set
$thumbs_in_set++;
}
//array for javascript; name: identifier+prefix
if($_usescript_){
$vsig_script.="vsig_".$identifier."[".$a."]=new Array(";
$vsig_script.="'".$theimage[1]."',"; //0-image-url
$vsig_script.="'".$cur_cap_js[0]."',"; //1-captitle
$vsig_script.="'".$cur_cap_js[1]."',"; //2-captext
$vsig_script.="'".$cur_link_js[0]."',"; //3-linkhref
$vsig_script.="'".$cur_link_js[1]."',"; //4-linktitle
$vsig_script.="'".$cur_link_js[2]."',"; //5-linktarget
$vsig_script.="'".$cur_alt_js."',"; //6-alt-txt
$vsig_script.="'".$thethumb[1]."');\n"; //7-thumb-url
}
}
}
// If the last set contains less thumbs than a full set, add dummies
if($_sets_use_&&count($images)>=($_sets_use_+1)&&$_sets_use_>=2)
{
for($b=$thumbs_in_set;$b<=$_sets_use_;$b++)
{
$html3 .= '<div id="thbvsig_'.$identifier.'_'.$thumbs_in_set.'" class="vsig_cont vsig_cont'.$identifier.'" style="visibility:hidden;"><div class="vsig_thumb">';
$html3 .= '<a href="" rel="nofollow"';
if($_usescript_>=1)
{
//javascript is activated, insert the onclick event
$html3 .= ' onclick=\'return false;\'';
if($_hover_>=1)
{
//change main image on thumbhover too
$html3 .= ' onmouseover=\'\'';
}
}
$html3 .= ' title=""><img src=""/>';
$html3 .= "</a></div></div>\n";
// Increment counter for thumbs in set
$thumbs_in_set++;
}
}
//add controls
if($_sets_use_&&$_sets_number_>=2)
{
$html4="<div class='vsig_ctrls vsig_ctrls_".$identifier."'>";
$html4.="<div class='vsig_ctrl_left'></div><div class='vsig_ctrl_right'>";
//back
if($_sets_current_>=2)
{
$html4.= '<a href="'.$target[$identifier].'vsig'.$identifier.'='.(($_sets_current_-1)*$_sets_use_-$_sets_use_).'" rel="nofollow"';
if($_usescript_>=1){ //javascript is activated, insert the onclick event
$html4.= ' id=\'bbackvsig_'.$identifier.'\'';
$html4.= ' onclick=\'switchset("vsig_'.$identifier.'",'.(($_sets_current_-1)*$_sets_use_-$_sets_use_).','.$_sets_use_.');return false;\'';
}
$html4.= '>';
}
else{
$html4.= '<a href="'.$target[$identifier].'vsig'.$identifier.'='.(($_sets_number_-1)*$_sets_use_).'" rel="nofollow"';
if($_usescript_>=1)
{
//javascript is activated, insert the onclick event
$html4.= ' id=\'bbackvsig_'.$identifier.'\'';
$html4.= ' onclick=\'switchset("vsig_'.$identifier.'",'.(($_sets_number_-1)*$_sets_use_).','.$_sets_use_.');return false;\'';
}
$html4.= '>';
}
if($_ctrl_back_type=="img")
{
$html4.="<img src='".$path_site.$_ctrl_back_."' alt='".substr($_ctrl_back_, (strrpos($_ctrl_back_, "/")+1), -4)."'/>";}
else
{
$html4.=$_ctrl_back_;
}
$html4.="</a>";
//counter
$html4.=" ".$_sets_txt_."<span id='countervsig_".$identifier."' class='vsig_counter'> ".$_sets_current_."/".$_sets_number_."</span> ";
//forward
if($_sets_current_<=$_sets_number_-1){
$html4.= '<a href="'.$target[$identifier].'vsig'.$identifier.'='.($_sets_current_*$_sets_use_).'" rel="nofollow"';
if($_usescript_>=1){ //javascript is activated, insert the onclick event
$html4.= ' id=\'bfwdvsig_'.$identifier.'\'';
$html4.= ' onclick=\'switchset("vsig_'.$identifier.'",'.($_sets_current_*$_sets_use_).','.$_sets_use_.');return false;\'';
}
$html4.= '>';
}
else{
$html4.= '<a href="'.$target[$identifier].'vsig'.$identifier.'=0" rel="nofollow"';
if($_usescript_>=1)
{ //javascript is activated, insert the onclick event
$html4.= ' id=\'bfwdvsig_'.$identifier.'\'';
$html4.= ' onclick=\'switchset("vsig_'.$identifier.'",0,'.$_sets_use_.');return false;\'';
}
$html4.= '>';
}
if($_ctrl_fwd_type=="img")
{
$html4.="<img src='".$path_site.$_ctrl_fwd_."' alt='".substr($_ctrl_fwd_, (strrpos($_ctrl_fwd_, "/")+1), -4)."'/>";}
else
{
$html4.=$_ctrl_fwd_;
}
$html4.="</a>";
$html4.="</div></div>\n";
}
//combine top image, controls and thumbs####################
if($_sets_use_&&$_sets_number_>=2) {
if($_th_right_=="1")
{
//if thumbs are right PLUS sets are used => topimage-ruler-thumbs-controls
$html1 .=$html2;
$html1 .="<div class='vsig_ruler".$identifier." vsig_ruler'>\n";
$html1 .=$html3;
$html1 .="</div>\n";
$html1 .=$html4;
}
elseif($_th_right_=="3")
{
//if thumbs are left PLUS sets are used => topimage-ruler-thumbs-controls
$html1 .="<div class='vsig_ruler".$identifier." vsig_ruler'>\n";
$html1 .=$html3;
$html1 .="</div>\n";
$html1 .=$html2;
$html1 .=$html4;
}
else
{
//if thumbs are below PLUS sets are used => topimage-controls-thumbs
$html1 .=$html2;
$html1 .=$html4;
$html1 .=$html3;
}
}
else{
if($_th_right_=="1")
{
//if thumbs are right NO sets are used => topimage-ruler-thumbs
$html1 .=$html2;
$html1 .="<div class='vsig_ruler".$identifier." vsig_ruler'>\n";
$html1 .=$html3;
$html1 .="</div>\n";
}
elseif($_th_right_=="3"){ //if thumbs are left NO sets are used => ruler-thumbs-topimage
$html1 .="<div class='vsig_ruler".$identifier." vsig_ruler'>\n";
$html1 .=$html3;
$html1 .="</div>\n";
$html1 .=$html2;
}
else{ //if thumbs are below NO sets are used => topimage-thumbs
$html1 .=$html2;
$html1 .=$html3;
}
}
$html1 .="<div class=\"vsig_clr\"></div>\n</div>\n";
if($_usescript_==1){ //javascript is activated, link the js-file
$document->addScript($path_site.$path_plugin.'vsig.js');
}
if($_preload_){
$vsig_script.="var vsig_".$identifier."_preload = vsig_daisychain('vsig_".$identifier."','vsig_".$identifier."_b');\n";
}
}
//replace the call with the gallery#################
$article->text = plgContentVerysimpleimagegalleryHelper::beReplaceCall("{vsig}".$vsig_code."{/vsig}",$html1, $article->text);
}
//add arrays with alt, caption and link
if($vsig_script!="")
{
$document->addScriptDeclaration($vsig_script);
}
//write collected CSS setting to the head of the page
if($vsig_cssadd!="")
{
$document->addCustomTag("<style type='text/css'>\n".$vsig_cssadd."</style>\n");
//remove duplicate links to stylesheet - start
$headerstuff = $document->getHeadData();
foreach($headerstuff['custom'] as $key => $custom)
{
if(stristr($custom, 'vsig.css') !== false){
unset($headerstuff['custom'][$key]);
}
}
$document->setHeadData($headerstuff);
//remove duplicate links to stylesheet - end
$document->addCustomTag('<link rel="stylesheet" href="' . $path_site.$path_plugin . 'vsig.css" type="text/css" />' );
}
}
}
public function onContentAfterDisplay($context, &$article, &$params, $limitstart = 0)
{
if (preg_match('#vsig[0-9]+_#s', $_SERVER['REQUEST_URI']) >= 1)
{
// If we aren't in a web page, stop
$document=JFactory::getDocument();
if($document->getType() != 'html')
{
return;
}
$document->setMetaData("robots", "noindex, nofollow");
}
if(isset($article->id))
{
//substitute article id on frontpage
$this->myarticleid = $article->id;
}
}
}