Trasformare switch in if

di il
1 risposte

Trasformare switch in if

Salve a tutti, sono in difficoltà e spero che qualcuno possa darmi una mano, siccome devo eseguire i controlli di un file più di una volta avrei bisogno , come da titolo, di trasformare una serie di switch in if, solo che evidentemente sbaglio qualcosa.. potete darmi una mano? vi posto i due codici

l'originale
<?php
$type = of_get_option('type_background');
$image = of_get_option('background_upload');
$radio_ip = of_get_option('radio_ip');
$radioplay = of_get_option('radio_autoplay');
$radioopened = of_get_option('radio_opened');
$playerar = of_get_option('player_audio_radio');
$speedslideshow = of_get_option('slider_speed_slideshow');
$speedanimation = of_get_option('slider_speed_animation');
 
echo'

<script type="text/javascript">
jQuery(document).ready(function ($){ $("#menu-item-3354,#menu-item-3419").on("click",function(){$("#jquery_jplayer_1").jPlayer("pause");});  $("#menu-item-3367,#menu-item-123,#menu-item-304,#menu-item-1048,#menu-item-2788,#menu-item-1046,#menu-item-3753,#menu-item-1045,#menu-item-1044,#menu-item-3719,#menu-item-3754,#menu-item-3755,#menu-item-3751,#menu-item-41,#menu-item-3418,#menu-item-68,#menu-item-123,#menu-item-2788").on("click",function(){$("#jquery_jplayer_1").jPlayer("play");});';

switch ($type) {
		 case "image": 
		 echo '
$.backstretch("'.$image.'");';
break;
}

switch ($playerar) {
case "player_radio":
echo'
$("#jquery_jplayer_1").jPlayer({
    ready: function () {
        $(this).jPlayer("setMedia", {
            mp3: "http://'.$radio_ip.'/;stream/1"
        })';
		
		switch ($radioplay) {
		case "radio_autoplay_on":
		echo '.jPlayer("play")';
		break;
		}
echo';	
		
    },
	swfPath: "'.get_template_directory_uri().'/swf/",
    supplied: "mp3",
	volume: 1
});';

switch ($radioopened) {
case "radio_opened_visible":  
  echo '
  $(".radio-wz-open-hidden").click(function () {
    $("#radio-wz #radio-wz-col").slideToggle({
      direction: "up"
    }, 100);
    $(this).toggleClass("clientsClose");
  });
   $("#radio-wz-col").show();
   
   function mouseHandler(e){
  if ($(this).hasClass("radio-wz-hidden-open")) {
    $(this).removeClass("radio-wz-hidden-open");
  } else {
    $(".radio-wz-hidden-open").removeClass("radio-wz-hidden-open");
    $(this).addClass("radio-wz-hidden-open");
  } 
}
function start(){
  $(".radio-wz-open-hidden").bind("click", mouseHandler);
}
$(document).ready(start);
   ';
break;
case "radio_opened_hidden": 
echo '
  $(".radio-wz-open").click(function () {
    $("#radio-wz #radio-wz-col").slideToggle({
      direction: "up"
    }, 100);
    $(this).toggleClass("clientsClose");
  });
  function mouseHandler(e){
 if ($(this).hasClass("radio-wz-open-hidden")) {
   $(this).removeClass("radio-wz-open-hidden");
  } else {
   $(".radio-wz-open-hidden").removeClass("radio-wz-open-hidden");
   $(this).addClass("radio-wz-open-hidden");
  } 
}
function start(){
   $(".radio-wz-open").bind("click", mouseHandler);
}
$(document).ready(start);
  ';
break;
}  
break;
} 

if (of_get_option('slider_active', '1') == '1') {
	if (is_front_page()){ 
echo'
		if ( jQuery(".flexslider").length && jQuery() ) {
		jQuery(".flexslider").flexslider({
			controlNav: true,
			animationLoop: true,  
			controlsContainer:"",
			pauseOnAction: false,
			pauseOnHover: true,
			smoothHeight: true,
			nextText:"&rsaquo;",
			prevText:"&lsaquo;",
			keyboardNav: false, 		
			slideshowSpeed: '.$speedslideshow.',
			animationSpeed: '.$speedanimation.',
	        start: function(slider) {
            slider.removeClass("loading");
            }
		});			
		}';
	} 
}
echo'
});
 </script>';
 
?>
quello modificato da me ( che non funziona)
<?php
$type = of_get_option('image');
$image = of_get_option('background_upload');
$radio_ip = of_get_option('radio_ip');
$radioplay = of_get_option('radio_autoplay_on');
$radioopened = of_get_option('radio_opened');
$playerar = of_get_option('player_radio');
$speedslideshow = of_get_option('slider_speed_slideshow');
$speedanimation = of_get_option('slider_speed_animation');
 
echo'

<script type="text/javascript">
jQuery(document).ready(function ($){ $("#menu-item-3354,#menu-item-3419").on("click",function(){$("#jquery_jplayer_1").jPlayer("pause");});  $("#menu-item-3367,#menu-item-123,#menu-item-304,#menu-item-1048,#menu-item-2788,#menu-item-1046,#menu-item-3753,#menu-item-1045,#menu-item-1044,#menu-item-3719,#menu-item-3754,#menu-item-3755,#menu-item-3751,#menu-item-41,#menu-item-3418,#menu-item-68,#menu-item-123,#menu-item-2788").on("click",function(){$("#jquery_jplayer_1").jPlayer("play");});';

$type="image";
if ($type=="image") {
		
		 echo '
$.backstretch("'.$image.'");';

}
$playerar="player_radio";
if ($playerar=="player_radio") {
echo'
$("#jquery_jplayer_1").jPlayer({
    ready: function () {
        $(this).jPlayer("setMedia", {
            mp3: "http://'.$radio_ip.'/;stream/1"
        })';
		$radioplay = "radio_autoplay_on";

if($radioplay == "radio_autoplay_on")
{
    echo '.jPlayer("play")';
}
elseif($radioplay == "radio_autoplay_pause")
{
    echo '.jPlayer("pause")';
}

else
{
   echo '.jPlayer("play")';
}
		
	
echo';	
		debug($(this));
    },
	swfPath: "'.get_template_directory_uri().'/swf/",
    supplied: "mp3",
	volume: 1
});';
$radioopened="radio_opened_visible";
if ($radioopened=="radio_opened_visible") {
 
  echo '
  $(".radio-wz-open-hidden").click(function () {
    $("#radio-wz #radio-wz-col").slideToggle({
      direction: "up"
    }, 100);
    $(this).toggleClass("clientsClose");
  });
   $("#radio-wz-col").show();
   
   function mouseHandler(e){
  if ($(this).hasClass("radio-wz-hidden-open")) {
    $(this).removeClass("radio-wz-hidden-open");
  } else {
    $(".radio-wz-hidden-open").removeClass("radio-wz-hidden-open");
    $(this).addClass("radio-wz-hidden-open");
  } 
}
function start(){
  $(".radio-wz-open-hidden").bind("click", mouseHandler);
}
$(document).ready(start);
   ';

elseif( $radioopened=="radio_opened_hidden") {
echo '
  $(".radio-wz-open").click(function () {
    $("#radio-wz #radio-wz-col").slideToggle({
      direction: "up"
    }, 100);
    $(this).toggleClass("clientsClose");
  });
  function mouseHandler(e){
 if ($(this).hasClass("radio-wz-open-hidden")) {
   $(this).removeClass("radio-wz-open-hidden");
  } else {
   $(".radio-wz-open-hidden").removeClass("radio-wz-open-hidden");
   $(this).addClass("radio-wz-open-hidden");
  } 
}
function start(){
   $(".radio-wz-open").bind("click", mouseHandler);
}
$(document).ready(start);
  ';


if (of_get_option('slider_active', '1') == '1') {
	if (is_front_page()){ 
echo'
		if ( jQuery(".flexslider").length && jQuery() ) {
		jQuery(".flexslider").flexslider({
			controlNav: true,
			animationLoop: true,  
			controlsContainer:"",
			pauseOnAction: false,
			pauseOnHover: true,
			smoothHeight: true,
			nextText:"&rsaquo;",
			prevText:"&lsaquo;",
			keyboardNav: false, 		
			slideshowSpeed: '.$speedslideshow.',
			animationSpeed: '.$speedanimation.',
	        start: function(slider) {
            slider.removeClass("loading");
            }
		});			
		}';
	} 
}
echo'
});
 </script>';
 
?>
vi sono grata in anticipo per l'aiuto ( ps, sono mio malgrado dentro un sito non fatto da me per cui ho poca manovrabiltà)

1 Risposte

Devi accedere o registrarti per scrivere nel forum
1 risposte