1 | <?php |
---|
2 | |
---|
3 | if (!defined('_ECRIRE_INC_VERSION')) return; |
---|
4 | |
---|
5 | function mediabox_config($public=null){ |
---|
6 | include_spip("inc/filtres"); |
---|
7 | $config = @unserialize($GLOBALS['meta']['mediabox']); |
---|
8 | if (!is_array($config)) |
---|
9 | $config = array(); |
---|
10 | $config = array_merge(array( |
---|
11 | 'active' => 'oui', |
---|
12 | 'traiter_toutes_images' => 'oui', |
---|
13 | 'selecteur_galerie' => '#documents_portfolio a[type=\'image/jpeg\'],#documents_portfolio a[type=\'image/png\'],#documents_portfolio a[type=\'image/gif\']', |
---|
14 | 'selecteur_commun' => '.mediabox', |
---|
15 | 'splash_url' => '', |
---|
16 | 'skin' => 'black-striped', |
---|
17 | 'transition' => 'elastic', |
---|
18 | 'speed'=>'200', |
---|
19 | 'maxWidth'=>'90%', |
---|
20 | 'maxHeight'=>'90%', |
---|
21 | 'minWidth'=>'400px', |
---|
22 | 'minHeight'=>'', |
---|
23 | 'slideshow_speed' => '2500', |
---|
24 | 'opacite' => '0.9', |
---|
25 | ), $config); |
---|
26 | |
---|
27 | if ((is_null($public) AND test_espace_prive()) OR $public===false) { |
---|
28 | $config = array_merge($config,array( |
---|
29 | 'active' => 'oui', |
---|
30 | 'selecteur_galerie' => '#portfolios a[type^=\'image/\']', |
---|
31 | 'selecteur_commun' => '.mediabox, .iconifier a[href$=jpg],.iconifier a[href$=png],.iconifier a[href$=gif]', |
---|
32 | 'splash_url' => '', |
---|
33 | 'skin' => 'white-shadow', |
---|
34 | 'maxWidth'=>'90%', |
---|
35 | 'maxHeight'=>'95%', |
---|
36 | 'minWidth'=>'600px', |
---|
37 | 'minHeight'=>'300px', |
---|
38 | 'opacite' => '0.9', |
---|
39 | )); |
---|
40 | } |
---|
41 | |
---|
42 | // charger la config du theme uniquement dans le public |
---|
43 | if (!test_espace_prive() AND include_spip("colorbox/".$config['skin']."/mediabox_config_theme")) { |
---|
44 | $config_theme = mediabox_config_theme(); |
---|
45 | $config = array_merge($config, $config_theme); |
---|
46 | } |
---|
47 | |
---|
48 | return $config; |
---|
49 | } |
---|
50 | |
---|
51 | function mediabox_insert_head_css($flux){ |
---|
52 | $config = mediabox_config(); |
---|
53 | if ($config['active']=='oui' AND $f = find_in_path((test_espace_prive()?"prive/":"")."colorbox/".$config['skin'].'/colorbox.css')) |
---|
54 | $flux .= '<link rel="stylesheet" href="'.direction_css($f).'" type="text/css" media="all" />'; |
---|
55 | /** |
---|
56 | * Initialiser la config de la mediabox |
---|
57 | */ |
---|
58 | $flux ='<script type="text/javascript">/* <![CDATA[ */ |
---|
59 | var box_settings = {tt_img:'.($config['traiter_toutes_images'] == 'oui'?'true':'false') |
---|
60 | .',sel_g:"'.$config['selecteur_galerie'] |
---|
61 | .'",sel_c:"'.$config['selecteur_commun'] |
---|
62 | .'",trans:"'.$config['transition'] |
---|
63 | .'",speed:"'.$config['speed'] |
---|
64 | .'",ssSpeed:"'.$config['slideshow_speed'] |
---|
65 | .'",maxW:"'.$config['maxWidth'] |
---|
66 | .'",maxH:"'.$config['maxHeight'] |
---|
67 | .'",minW:"'.$config['minWidth'] |
---|
68 | .'",minH:"'.$config['minHeight'] |
---|
69 | .'",opa:"'.$config['opacite'] |
---|
70 | .'",str_ssStart:"'.unicode2charset(html2unicode(_T('mediabox:boxstr_slideshowStart'))) |
---|
71 | .'",str_ssStop:"'.unicode2charset(html2unicode(_T('mediabox:boxstr_slideshowStop'))) |
---|
72 | .'",str_cur:"'._T('mediabox:boxstr_current', array('current'=>'{current}', 'total'=>'{total}')) |
---|
73 | .'",str_prev:"'._T('mediabox:boxstr_previous') |
---|
74 | .'",str_next:"'._T('mediabox:boxstr_next') |
---|
75 | .'",str_close:"'._T('mediabox:boxstr_close') |
---|
76 | .'",splash_url:"'.$config['splash_url'] |
---|
77 | .'"}; |
---|
78 | /* ]]> */</script>'."\n" . $flux; |
---|
79 | |
---|
80 | return $flux; |
---|
81 | } |
---|
82 | |
---|
83 | |
---|
84 | function mediabox_timestamp($fichier){ |
---|
85 | if ($m = filemtime($fichier)) |
---|
86 | return "$fichier?$m"; |
---|
87 | return $fichier; |
---|
88 | } |
---|
89 | |
---|
90 | function mediabox_insert_head($flux){ |
---|
91 | $config = mediabox_config(); |
---|
92 | if ($config['active']=='oui') { |
---|
93 | |
---|
94 | $flux .=' |
---|
95 | <script src="'.mediabox_timestamp(find_in_path('javascript/jquery.colorbox.js')).'" type="text/javascript"></script> |
---|
96 | <script src="'.mediabox_timestamp(find_in_path('javascript/spip.mediabox.js')).'" type="text/javascript"></script>'; |
---|
97 | if ($config['splash_url']) |
---|
98 | $flux .='<script src="'.mediabox_timestamp(find_in_path('javascript/splash.mediabox.js')).'" type="text/javascript"></script>'; |
---|
99 | } |
---|
100 | |
---|
101 | return $flux; |
---|
102 | } |
---|
103 | |
---|
104 | function mediabox_jquery_plugins($plugins){ |
---|
105 | $config = mediabox_config(); |
---|
106 | if ($config['splash_url']) { |
---|
107 | $plugins[] = 'javascript/jquery.cookie.js'; |
---|
108 | } |
---|
109 | return $plugins; |
---|
110 | } |
---|
111 | |
---|
112 | ?> |
---|