Форуми / Cotonti / Support / sql queries in header.main

booka
#1 30.03.2010 03:51
Is it possible?
booka
Trustmaster
#2 30.03.2010 03:53
Why not? :)
May the Source be with you!
booka
#3 30.03.2010 04:02
dunno why, but it is not working...(((

where is mistake?

<?PHP
/* ====================
[BEGIN_SED_EXTPLUGIN]
Code=jQPlayer
Part=header
File=jQPlayer.header
Hooks=header.main
Tags=header.tpl:{HEADER_COMPOPUP}
Order=10
[END_SED_EXTPLUGIN]
==================== */

defined('SED_CODE') or die('Wrong URL');

$sql = sed_sql_query("SELECT * FROM `sed_jqplayer_playlist`");

while($row = sed_sql_fetcharray($sql))
$i=1;
{
$track .= "{name:\"".$row['track_artist']." - ".$row['track_song']."\",mp3:\"".$row['track_loc']."\"}";
	if ($i<sed_sql_numrows($sql)) { $track .= ", "; }
$i++;
}
	
$out['compopup'] .= '

<script type="text/javascript" src="js/jquery.jplayer.min.js"></script>

<script>

$(document).ready(function(){

var playItem = 0;

	var myPlayList = [ '.$track.' ];

	// Local copy of jQuery selectors, for performance.
	var jpPlayTime = $("#jplayer_play_time");
	var jpTotalTime = $("#jplayer_total_time");


   $("#jquery_jplayer").jPlayer({
		ready: function () {
			displayPlayList();
			playListInit(false); // Parameter is a boolean for autoplay.			
		},
	swfPath: "/js", nativeSupport: true, oggSupport: false,
	customCssIds: false
	})
	
	.jPlayer("onProgressChange", function(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) {
		jpPlayTime.text($.jPlayer.convertTime(playedTime));
		jpTotalTime.text($.jPlayer.convertTime(totalTime));
	})
	
	.jPlayer("onSoundComplete", function() {
		playListNext();
	});

	$("#jplayer_previous").click( function() {
		playListPrev();
		return false;
	});

	$("#jplayer_next").click( function() {
		playListNext();
		return false;
	});

	function displayPlayList() {
		for (i=0; i < myPlayList.length; i++) {
			$("#jplayer_playlist ul").append("<li id=\'jplayer_playlist_item_"+i+"\'>"+ myPlayList[i].name +"</li>");
			$("#jplayer_playlist_item_"+i).data( "index", i ).click( function() {
				var index = $(this).data("index");
				if (playItem != index) {
					playListChange( index );
				} else {
					$("#jquery_jplayer").jPlayer("play");
				}
			});
		}
	}

	function playListInit(autoplay) {
		if(autoplay) {
			playListChange( playItem );
		} else {
			playListConfig( playItem );
		}
	}

	function playListConfig( index ) {
		$("#jplayer_playlist_item_"+playItem).removeClass("jplayer_playlist_current");
		$("#jplayer_playlist_item_"+index).addClass("jplayer_playlist_current");
		playItem = index;
		$("#jquery_jplayer").jPlayer("setFile", myPlayList[playItem].mp3, myPlayList[playItem].ogg);
	}

	function playListChange( index ) {
		playListConfig( index );
		$("#jquery_jplayer").jPlayer("play");
	}

	function playListNext() {
		var index = (playItem+1 < myPlayList.length) ? playItem+1 : 0;
		playListChange( index );
	}

	function playListPrev() {
		var index = (playItem-1 >= 0) ? playItem-1 : myPlayList.length-1;
		playListChange( index );
	}


});

</script>';


$out['compopup'] .= '<link rel="stylesheet" type="text/css" href="plugins/jQPlayer/jQPlayer.css" />';

?>


Добавлено 3 Минуты спустя:

oooooooouuuuuuuuuuuuuuuhhhhhhhhhhhh... shit... I'm stupid lazy dumb ass...)))

Found and fixed
booka
pieter
#4 30.03.2010 04:13
And what was the problem?
Or the fault?
... can we help you ...
booka
#5 30.03.2010 04:52
here: )))))))))

while($row = sed_sql_fetcharray($sql))
$i=1;
{
$track .= "{name:\"".$row['track_artist']." - ".$row['track_song']."\",mp3:\"".$row['track_loc']."\"}";
    if ($i<sed_sql_numrows($sql)) { $track .= ", "; }
$i++;
}

think tomorrow I'll release it
booka
Trustmaster
#6 30.03.2010 13:47
Note: it is recommended to use variable prefixes in plugin parts that hook into modules, to ensure that no variable conflicts occur. E.g. use $jqp_sql and $jqp_row to make sure you don't destroy $sql and $row in the outer context.
May the Source be with you!
booka
#7 30.03.2010 14:00
thanks... looks like here I didn't break anything, but I'll try to review code and add prefixes...

anyway - because I'm not very skilled coder it will be a huge field for optimization )))
booka
tensh
#8 30.03.2010 17:56
Will you publish the plugin after completion? :)
booka
#9 30.03.2010 18:51
yep...

Firstly I need to solve question with scroll... Don't know why but I can't change default scroll with custom by jQuery.
And decide how I will sync playlist for cases when file is removed from PFS...
booka
musiconly
#10 30.03.2010 21:08
I have one plugin with header.main hook and I was wondering if you have problems with system messages because of that hook?

For example, the output of the plugin is shown AFTER the system message like "You're not allowed to do that! Redirecting... (and then output of the plugin that is using that header.main hook).

Live example is on my website, http://www.gitare.info
It's about that scrolling marquee. Try visiting this link http://www.gitare.info/forums.php?m=topics&s=88 as non-registered user, and you'll see how big my error message gets

Any ideas?
booka
#11 30.03.2010 21:32
Zabranjeno neregistriranim korisnicima.
Preusmjeravam...Rođen Eric Patrick Clapton( Ripley, Surrey, 30. ožujka 1945.), engleski gitarist i pjevač. Inspiriran bluesom, već više od 20 godina slovi za jednog od najboljih rock gitarista na svijetu. Svirao je u različitim sastavima, a najpoznatiji su The Yardbirds, Cream i Blind Faith.1962. Rođen MC Hammer, (Stanley Kirk Burrell), 1990 US No.1 album 'Please Hammer Don't Hurt Em', 1990 UK No.3 single 'U Can't Touch This'.1964. Rođena Tracy Chapman, singer, songwriter, (1988 UK No.5 & US No.6 single 'Fast Car', 1988 US & UK No.1 debitantski album 'Tracy Chapman').

???

Looks like it is your scroll text, right? May be you should check variables for concatenation with some system vars?
booka
musiconly
#12 30.03.2010 22:04
you were right! Body of message and body of my scroll text had same var name :) fixed that and now it's working like a charm :D thanks!