Changeset 10294


Ignore:
Timestamp:
Apr 11, 2011, 2:04:35 PM (13 years ago)
Author:
flop25
Message:

better management of the config : no more notice and defaut value if empty
code a bit cleaner

Location:
extensions/music_player
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/music_player/admin/admin.php

    r6985 r10294  
    357357$conf_plugin = explode("," , $conf['mp_plugin']);
    358358
    359 ////envoi
     359// +-----------------------------------------------------------------------+
     360// |                         changement de config                          |
     361// +-----------------------------------------------------------------------+
    360362if (isset($_POST['envoi_config']) ){
    361363if ($_POST['envoi_config']=='lecteur')
    362364{
    363   if ($_POST['style']=='NULL')
     365  if (isset($_POST['style']) and $_POST['style']=='NULL')
    364366  {
    365367          $style=$conf_lecteur['9'];
     
    370372  }
    371373 
    372   if ($_POST['mp_miniature']=="true")
     374  if (isset($_POST['mp_miniature']) and $_POST['mp_miniature']=="true")
    373375  { 
    374     $conf_lecteur = array(
    375       $_POST['h_tt'],
    376       $_POST['l_tt'],
    377       $_POST['h'],
    378       $_POST['mp_miniature'],
    379       $_POST['l'],
    380       $_POST['mp_shuffle'],
    381       $_POST['mp_repeat'],
    382       $_POST['mp_autostart'],
    383       $_POST['mp_autoscroll'],
    384       $style,
    385       $_POST['various_style'],
    386     );
     376      $h = $_POST['h_tt'];
    387377  }
    388378  else
    389379  {
    390380      $h = $_POST['h_tt'] - 20;//pour un affichage correct la playlist doit faire la hauteur totale moins les 20px de la barre
    391     $conf_lecteur = array(
    392       $_POST['h_tt'],
    393       $_POST['l_tt'],
    394       $h,
    395       $_POST['mp_miniature'],
    396       '0',
    397       $_POST['mp_shuffle'],
    398       $_POST['mp_repeat'],
    399       $_POST['mp_autostart'],
    400       $_POST['mp_autoscroll'],
    401       $style,
    402       $_POST['various_style'],
    403     );
    404381  }   
    405   $newconf_lecteur = implode ("," , $conf_lecteur);
     382
     383        $newconf_lecteur = (isset($_POST['h_tt']) and !empty($_POST['h_tt'])) ? $_POST['h_tt'] : '148';
     384        $newconf_lecteur .= (isset($_POST['l_tt']) and !empty($_POST['l_tt'])) ? ','.$_POST['l_tt'] : ',300';
     385        $newconf_lecteur .= (isset($_POST['h_tt']) and !empty($_POST['h_tt'])) ? ','.$h : ',128';
     386        $newconf_lecteur .= (isset($_POST['mp_miniature'])) ? ',true' : ',false';
     387        if (!isset($_POST['l']) or empty($_POST['l']))
     388        {
     389                $newconf_lecteur .= ',128';
     390        }
     391        elseif (isset($_POST['mp_miniature']) and $_POST['mp_miniature']=="true")
     392        {
     393                $newconf_lecteur .= ','.$_POST['l'];
     394        }
     395        else
     396        {
     397                $newconf_lecteur .= ',0';
     398        }
     399        $newconf_lecteur .= (isset($_POST['mp_shuffle'])) ? ',true' : ',false';
     400        $newconf_lecteur .= (isset($_POST['mp_repeat'])) ? ',true' : ',false';
     401        $newconf_lecteur .= ','.$_POST['mp_autostart'];
     402        $newconf_lecteur .= (isset($_POST['mp_autoscroll'])) ? ',true' : ',false';
     403        $newconf_lecteur .= ','.$style;
     404        $newconf_lecteur .= (isset($_POST['various_style'])) ? ',true' : ',false';
    406405  $query = '
    407406    UPDATE '.CONFIG_TABLE.'
     
    417416if ($_POST['envoi_config']=='plugin' or isset($_POST['foot']))
    418417{
    419     $conf_plugin = array(
    420       $_POST['evidence'],
    421       $_POST['head'],
    422       $_POST['foot'],
    423       $_POST['h_pop'],
    424       $_POST['l_pop'],
    425     );
    426   $newconf_plugin = implode ("," , $conf_plugin);
     418        $newconf_plugin = (isset($_POST['evidence'])) ? 'true' : 'false';
     419        $newconf_plugin .= (isset($_POST['head'])) ? ',true' : ',false';
     420        $newconf_plugin .= (isset($_POST['foot'])) ? ',true' : ',false';
     421        $newconf_plugin .= (isset($_POST['h_pop']) and !empty($_POST['h_pop'])) ? ','.$_POST['h_pop'] : ',260';
     422        $newconf_plugin .= (isset($_POST['l_pop']) and !empty($_POST['l_pop'])) ? ','.$_POST['l_pop'] : ',400';
    427423  $query = '
    428424    UPDATE '.CONFIG_TABLE.'
     
    437433}
    438434load_conf_from_db();
    439 
     435$conf_lecteur = explode("," , $conf['mp_lecteur']);
     436$conf_plugin = explode("," , $conf['mp_plugin']);
    440437$check='checked="checked"';
    441438if ($conf_lecteur[3]=='true') { $miniature=$check; } else { $miniature=NULL; }
  • extensions/music_player/admin/admin_edit.php

    r6985 r10294  
    2626   pwg_query($query);
    2727   $page['infos'][]=l10n('mp_msg_edit1');
    28    //$mp_msgs[] = $lang['mp_msg_edit1'];
    2928
    3029}
     
    139138   $filename="./plugins/music_player/".$url;
    140139   unlink($filename);
    141    //$mp_msgs[] = $lang['mp_msg_edit5'].$url;
    142140   $page['infos'][]=l10n('mp_msg_edit5').$url;
    143141  }
     
    162160  }//while
    163161 pwg_query('DELETE FROM '.MP_MUSIC.' WHERE id IN (\''.$_POST['id'].'\')');
    164 // $mp_msgs[] = $lang['mp_msg_edit4'].$url;
    165162 $page['infos'][]=l10n('mp_msg_edit4').$url;
    166163}
     
    215212   pwg_query($query);
    216213   
    217   //$mp_msgs[] = $lang['mp_msg_edit3'];
    218214  $page['infos'][]=l10n('mp_msg_edit3');
    219215}
     
    275271;';
    276272     pwg_query($query);
    277          //$mp_msgs[] = $lang['mp_msg_admin_4'].$url;
    278273         $page['infos'][]=l10n('mp_msg_admin_4').$url;
    279274 }
     
    364359                $music['url']=addslashes($music['url']);
    365360      pwg_query('DELETE FROM '.MP_MUSIC.' WHERE url IN (\''.$music['url'].'\')');
    366           //$mp_msgs[] = $lang['mp_msg_edit4'].$url;
    367361          $page['infos'][]=l10n('mp_msg_edit4').$url;
    368362    }
     
    406400         }
    407401      fwrite($file, $_xml);
    408 
    409 //  $mp_msgs[] = $lang['mp_msg_edit2'];
    410402  $page['infos'][]=l10n('mp_msg_edit2');
    411403}
     
    479471
    480472// +-----------------------------------------------------------------------+
    481 // |               affichage des msg                                       |
    482 // +-----------------------------------------------------------------------+
    483 /*
    484 if (count($mp_msgs) > 0)
    485 {
    486   $template->append('mp_msgs',array());
    487   foreach ($mp_msgs as $mp_msg)
    488   {
    489     $template->append('mp_msgs.mp_msg',
    490                                  array('MP_MSG'=>$mp_msg));
    491   }
    492 }
    493 */
     473// |               affichage                                               |
     474// +-----------------------------------------------------------------------+
    494475$template->set_filename('plugin_admin_content', $m_p->plugin_path.'template/admin_edit.tpl');
    495476$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
  • extensions/music_player/template/admin_edit.tpl

    r3329 r10294  
    55  <h2>Music player / {$PLAYLIST}</h2>
    66</div>
    7 <!--
    8 <div class="header_msgs">
    9   <p>mp_msgs.mp_msg.MP_MSG</p>
    10 </div>
    11  -->
    127{foreach from=$edit_txt item=edit_txt}
    138<form action="" method="post" name="edit_txt">
Note: See TracChangeset for help on using the changeset viewer.