source: extensions/charlies_content/main.inc.php @ 9885

Last change on this file since 9885 was 6360, checked in by vdigital, 14 years ago

Admin page design review mainly for the "clear" theme
Code review

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 5.8 KB
Line 
1<?php /*
2Plugin Name: Charlies content
3Version: 2.1.b
4Description: Charlies content is a global solution for none picture files.
5Plugin URI: http://piwigo.org/ext/extension_view.php?eid=119
6Author: VDigital, rvelices (Piwigo team)
7Author URI: http://piwigo.org/
8*/
9/* Synopsis
101 - Based on file extension...
112 - A template is used in state of the default content
12
13Dependencies:
14http://getid3.sourceforge.net/
15http://flv-player.net/players/maxi/documentation/
16
17/**
18 * All media file have to be broadcasted via an embedded player
19 * so link its extention to a player name as to be define
20 * the same player can be used for several extentions
21 */
22  global $conf, $charlie;
23
24if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
25define('CHARLIES_DIR' , basename(dirname(__FILE__)));
26define('CHARLIES_PATH' , PHPWG_PLUGINS_PATH . CHARLIES_DIR . '/');
27define('CHARLIES_VER' , '2.1.b');
28$x = @file_get_contents( $conf['local_data_dir'].'/plugins/'.basename(dirname(__FILE__)).'.dat');
29if ($x!==false) $charlie = unserialize($x);
30
31if ( isset($_POST['reset']) and defined('IN_ADMIN')
32    and isset($_GET['section']) and $_GET['section']=='charlies_content/charlies_config.php' ) {
33                unset( $charlie );
34                if (!isset($infos)) $infos = array();
35                array_push($infos, l10n('Your configuration configuration has been reset.'));
36}
37if (!isset($charlie['version']) or  $charlie['version'] != CHARLIES_VER) 
38{
39        $default = array(
40                        'autoload'                      => 1,
41                        'autoplay'                      => 1,
42                        'loop'                                  => 1,
43                        'full'                                  => 1,
44                        'forced_width'                  => '',
45                        'forced_height'                 => '',
46                        'video_default_width'   =>  320,
47                        'video_default_height'  =>  240,
48                        'volume'                                => 150,
49                        'onclick'                               => 'playpause',
50                        'onclicktarget'                 => 0,
51                        'ondoubleclick'                 => 'fullscreen',
52                        'ondoubleclicktarget'   => 0,
53                        'buffer'                                => 10,
54                        'buffermessage'                 => 'Buffering _n_',
55                        'buffershowbg'                  => 0,
56                        'config'                                => 0,
57                        'configxml'                     => 0,
58                        'margin'                                => 8,
59                        'skin'                                  => '', /* './plugins/charlies_content/skin.jpg', */
60                        'title'                                 => '/n/n/nCharlies\' content ',
61                        'titlesize'                     => 26,
62                        'start_image'                   => './plugins/charlies_content/city-lights.jpg',
63                        'showtitleandstartimage'=> 0,
64                        'showiconplay'                  => 0,
65                        'iconplaybgalpha'               => 20,
66                        'showplayer'                    => 1,
67                        'showloading'                   => 1,
68                        'showmouse'                     => 1,
69                        'showtime'                      => 2,
70                        'srt'                                   => 0,
71                        'playeralpha'                   => 20,
72                        'playertimeout'                 => 1500,
73                        'showstop'                      => 1,
74                        'showvolume'                    => 1,
75                        'showswitchsubtitles'   => 0,
76                        'loadonstop'                    => 0,
77                        'shortcut'                      => 1,
78                        'phpstream'                     => 1,
79                        'curtain'                               => 'none',
80                        'start_image'                   =>  CHARLIES_PATH . 'background.jpg',
81                        'color0'                                => '#111111',
82                        'color1'                                => '#ff7700',
83                        'color2'                                => '#444444',
84                        'color3'                                => '#ff3333',
85                        'color4'                                => '#ff3363',
86                        'color5'                                => '#ff7700',
87                        'color6'                                => '#111111',
88                        'color7'                                => '#ff3333',
89                        'color8'                                => '#ff3363',
90                        'color9'                                => '#111111',
91                        'color10'                               => '#444444',
92                        'color11'                               => '#ff3333',
93                        'color12'                               => '#ff3363',
94                        'color13'                               => '#ff7700',
95                        'color14'                               => '#444444',
96                        'color15'                               => '#ff3333',
97                        'color16'                               => '#111111',
98                );
99        if (!isset($charlie['version'])) $charlie = $default;
100        else $charlie = array_merge( $default, $charlie );
101        if (!isset($charlie['FlvStreamer']))    $charlie['FlvStreamer'] = array('flv',); 
102        if (!isset($charlie['Flash']))                  $charlie['Flash'] = array('swf',); 
103        if (!isset($charlie['Music']))                  $charlie['Music'] = array('pls','m3u','wav','mid','au','aif',); 
104        if (!isset($charlie['mp3Player']))              $charlie['mp3Player'] = array('mp3',); 
105        if (!isset($charlie['Acrobat']))                $charlie['Acrobat'] = array('pdf',); 
106        if (!isset($charlie['WMplayer']))               $charlie['WMplayer'] = array('asf','wmv','divx','xvid',); 
107        if (!isset($charlie['QuickTime']))              $charlie['QuickTime'] = 
108        array('aiff','aac','bmp','gsm','mov','mpg','mpeg','mp4','m4a','psd','qt','qtif','qif','qti','snd','tif','tiff','3g2','3pg');
109        if (!isset($charlie['Archive']))                $charlie['Archive'] = array('zip','rar',); 
110        if (!isset($charlie['GPS']))                    $charlie['GPS'] = array('gpx',); 
111        $charlie['version'] = CHARLIES_VER;
112
113        $dir = $conf['local_data_dir'].'/plugins/';
114        @mkdir($dir);
115        $file = fopen( $dir.basename(dirname(__FILE__)).'.dat', 'w' );
116        fwrite($file, serialize($charlie));
117        fclose( $file );
118}
119  /* Note: Uppercase extensions are not requested */
120  /**
121   * That means you must have a tpl file for each... player
122   * like for Flash => ./plugings/charlies_content/flash_content.tpl
123   *
124   * Player name is in lower-case followed by _content.tpl
125   */
126
127$all = array();
128foreach ($charlie as $ext) { 
129  if ( is_array($ext) ) { $all = array_merge ($all, $ext); }
130}
131$conf['file_ext'] = array_merge (
132    $conf['file_ext'], $all, array_map('strtoupper', $all) );
133
134# $charlie['all'] = $all;
135add_event_handler('render_element_content', 'render_Charlie_element_content', 40, 2 );
136add_event_handler('get_admin_plugin_menu_links', 'Charlie_plugin_admin_menu');
137
138function Charlie_plugin_admin_menu($menu)
139{
140        array_push($menu, array(
141                                'NAME' => 'Charlies\'', 
142                                'URL' => get_admin_plugin_menu_link(dirname(__FILE__).'/charlies_config.php'), 
143                        ));
144        return $menu;
145} 
146
147/**
148 * Only if picture.php is active
149 */
150function render_Charlie_element_content($content, $picture)
151{
152  global $template, $charlie, $page, $conf;
153  if ( isset($page['slideshow']) and $page['slideshow'] ) return $content;
154  if ( @$picture['is_picture'] ) return $content;
155  $all = array();
156  foreach ($charlie as $ext) { 
157        if (is_array($ext)) $all = array_merge ($all, $ext); 
158  }
159  $extension = strtolower(get_extension($picture['file']));
160  if (!in_array($extension, $all))
161  { // in fact nothing to do (Lucky Charlies)
162    return $content; }
163  include_once(CHARLIES_PATH.'charlies.inc.php');
164  return Charlies_content($picture);
165}
166?>
Note: See TracBrowser for help on using the repository browser.