mediabox_pipelines.php 3.7 KB

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