source: extensions/music_player/class.inc.php @ 3329

Last change on this file since 3329 was 3329, checked in by flop25, 15 years ago

first commit

File size: 7.4 KB
Line 
1<?php
2
3
4class Musicplayer
5{
6  var $plugin_name, $plugin_path;
7 
8  function Musicplayer($plugin_name, $plugin_path)
9  {
10    // Args
11    $this->plugin_name = $plugin_name;
12    $this->plugin_path = $plugin_path;
13    // handler
14   // $this->initialize_event_handler();
15  }
16  /*
17  function loading_lang()
18  {
19    global $lang;
20    //include(get_language_filepath('plugin.lang.php', $this->plugin_path));
21        load_language('plugin.lang', $this->plugin_path);
22  }  */
23  function var_template()
24  {
25    global $user;
26    if ($user['template'] == 'flop_pure_design')
27    {
28      $r = 'include/var_fpd.inc.php';   
29    }
30    else
31    {
32     $r = 'include/var.inc.php';       
33    }
34   return $r;
35  }
36  /*function remove_code($tlp_handle, $str_begin, $str_end)
37  {
38      global $template;
39 
40      $template->loadfile($tlp_handle);
41 
42      $p_beg = strpos($template->uncompiled_code[$tlp_handle], $str_begin);
43      $p_end = strpos($template->uncompiled_code[$tlp_handle], $str_end) + strlen($str_end);
44      $s = substr($template->uncompiled_code[$tlp_handle], $p_beg, $p_end - $p_beg);
45 
46      $template->uncompiled_code[$tlp_handle] =
47      substr_replace($template->uncompiled_code[$tlp_handle], '', $p_beg, $p_end - $p_beg);
48 
49      return $s;
50  }
51 
52  function add_before_code($tlp_handle, $insert_before, $code)
53  {
54      global $template;
55 
56      $template->loadfile($tlp_handle);
57      $template->uncompiled_code[$tlp_handle] = str_replace($insert_before, $code.$insert_before, $template->uncompiled_code[$tlp_handle]);
58  }
59  function add_after_code($tlp_handle, $insert_after, $code)
60  {
61    global $template;
62 
63    $template->loadfile($tlp_handle);
64    $template->uncompiled_code[$tlp_handle] = str_replace($insert_after, $insert_after.$code, $template->uncompiled_code[$tlp_handle]);
65  }*/
66   function register_mp_menubar_blocks($menu_ref_arr) {
67    $menu = & $menu_ref_arr[0];
68    if ($menu->get_id() != 'menubar')
69      return;
70    $menu->register_block(new RegisteredBlock('mbMusicPlayer', 'Music player', 'MP'));
71  }
72
73
74  function placer_lien($menu_ref_arr)
75  {
76
77///////////////////////[début de l'affichage lien]////////////////////
78    //$this->loading_lang();
79       
80    global $lang, $conf, $template;
81       
82    /*$conf_plugin = explode("," , $conf['mp_plugin']);
83
84    $this->add_before_code('menubar','<!-- END quick_search -->','<ul>
85        <li><img src="plugins/'.$this->plugin_name.'/template/audio.png" /> <a name="{lang:lien_expl}" href="javascript:void(0)" onClick="window.open(\''.get_root_url().'plugins/'.$this->plugin_name.'/lecteur.php\',\'musique\',\'width='.$conf_plugin[4].',height='.$conf_plugin[3].',top=400,left=400,menubar=no,resizable=yes,toolbar=no,status=no,alwaysRaised=yes\')" >{lang:lien_titre}</a></li>
86</ul>
87        ');*/
88       
89          $menu = & $menu_ref_arr[0];
90 
91          if ( ($block = $menu->get_block('mbSpecials')) != null )
92          {
93            load_language('plugin.lang', $this->plugin_path);
94       
95            $position = count($block->data)+1;
96       
97            array_splice($block->data, $position-1, 0, array('mp' =>
98              array(
99                'URL' => 'javascript:void(0)'.'onClick="window.open(\''.get_root_url().'plugins/'.$this->plugin_name.'/lecteur.php\',\'musique\',\'width='.$conf_plugin[4].',height='.$conf_plugin[3].',top=400,left=400,menubar=no,resizable=yes,toolbar=no,status=no,alwaysRaised=yes\')" ',
100                'TITLE' => l10n('lien_expl'),
101                'NAME' => l10n('lien_titre')
102                )
103              )
104            );
105          }
106
107        /*
108/////[ si metre en evidence
109        if ($conf_plugin[0]=="true")
110        {
111          //si envoi formulaire avec "se rappeler" coché
112          if (isset($_POST['mp_remember']) and $_POST['mp_remember']=="on")
113          {
114       switch($_POST['mp_rep'])
115       {
116         /*case 'oui':setcookie( 'pwg_music_player', 'open', time()+60*60*24*10, cookie_path() );break;
117         case 'non':setcookie( 'pwg_music_player', 'closed', time()+60*60*24*10, cookie_path() );break;
118         case 'oui':setcookie( 'pwg_music_player', 'open', time()+60, cookie_path() );break;
119         case 'non':setcookie( 'pwg_music_player', 'closed', time()+60, cookie_path() );break;
120       }
121          }
122          elseif (isset($_POST['mp_rep']))
123          {
124       switch($_POST['mp_rep'])
125       {
126         case 'oui':pwg_set_session_var( 'pwg_music_player', 'open' );break;
127         case 'non':pwg_set_session_var( 'pwg_music_player', 'closed' );break;
128       }
129          }
130         
131          $mp_ses = pwg_get_session_var( 'pwg_music_player', '' );
132          //si on a cliqué oui, affiche le lecteur
133      if ( $_COOKIE['pwg_music_player'] == 'open' or $mp_ses == 'open' or $_POST['mp_rep'] == 'oui' )
134      {
135      $my_root_url = get_root_url().'plugins/'. basename(dirname(__FILE__)).'/';
136      $js =
137'<script type="text/javascript">
138var theLecteur = window.open("", "musique", "width='.$conf_plugin[4].',height='.$conf_plugin[3].',top=400,left=400,menubar=no,resizable=yes,toolbar=no,status=no,alwaysRaised=yes");
139if ( theLecteur.location.toString()=="about:blank" || !theLecteur.location.toString().match(/^(https?.*\/)lecteur\.php(\?.+)?$/))
140{
141  theLecteur.location = "'.$my_root_url.'lecteur.php";
142}
143</script>';
144
145      $template->assign_block_vars( 'head_element', array(
146          'CONTENT' => $js
147            )
148          );
149
150      }
151          //si on a cliqué non, on n'affiche pas le msg
152          //si on a pas cliqué, on affiche le msg
153      elseif ( !isset($_COOKIE['pwg_music_player']) and !isset($_POST['mp_rep']) and !isset($_SESSION['pwg_pwg_music_player']) )
154      {
155              include($this->var_template());
156          $this->add_before_code('menubar','<!-- BEGIN links -->', $msg);*/
157          /*$template->assign_block_vars( 'head_element', array(
158             'CONTENT' => '<style type="text/css">
159#mbMusic_player
160{
161        font-size: 1em;
162        padding: 0px;
163}
164</style>'
165                )
166               );*/
167      //}
168        //} /fin metre en evidence
169       
170  }//fin placer_lien
171
172  function placer_block($menu_ref_arr)
173  {
174        global $template, $user, $conf;
175        load_language('plugin.lang', $this->plugin_path);
176       
177    $conf_plugin = explode("," , $conf['mp_plugin']);
178
179    $menu = & $menu_ref_arr[0];
180        $template->assign(array(  'ATRIB' => 'name="'.l10n('lien_expl').'" href="javascript:void(0)" onClick="window.open(\''.get_root_url().'plugins/'.$this->plugin_name.'/lecteur.php\',\'musique\',\'width='.$conf_plugin[4].',height='.$conf_plugin[3].',top=400,left=400,menubar=no,resizable=yes,toolbar=no,status=no,alwaysRaised=yes\')"'  ,
181                                                          'PLG_path' => get_root_url().'plugins/'.$this->plugin_name    ));
182
183                        if (($block = $menu->get_block( 'mbMusicPlayer' )) != null) {
184               $block->set_title(l10n('lien_titre'));
185               $block->template = $this->plugin_path.'template/block.tpl';
186            }
187
188  }
189  function mp_lien_menu($menu)
190  {
191    array_push($menu, array('NAME' => 'Music Player',
192            'URL' => get_admin_plugin_menu_link(get_root_url().'plugins/'.$this->plugin_name.'/admin/admin.php')));
193    return $menu;
194  }
195 
196  function add_css()
197{
198  global $page, $template;
199  if (isset($page['body_id']) and $page['body_id']=='theAdminPage' and ($_GET['section']=='music_player/admin/admin.php' or $_GET['section']=='music_player/admin/help.php' or $_GET['section']=='music_player/admin/admin_edit.php') )
200  {
201      $template -> assign(
202        'head_element', array (
203          'CONTENT' => '<link rel="stylesheet" type="text/css" href="plugins/'.$this->plugin_name.'/template/admin.css">'
204        )
205      );
206          }
207
208
209}
210
211}//fin class
212?>
Note: See TracBrowser for help on using the repository browser.