示例#1
0
    /**
     * Outputs frontpage HTML
     *
     * @return       Nothing
     */
    function grabAjaxPlayer()
	{
		global $Itemid, $smartyvs, $hwdvs_selectv, $hwdvs_joinv, $mainframe, $hwdvsAjaxPlayer;

		header('Content-type: text/html; charset=utf-8');

		$c = hwd_vs_Config::get_instance();
		$db = & JFactory::getDBO();
		$my = & JFactory::getUser();
		$acl= & JFactory::getACL();
		$usersConfig = &JComponentHelper::getParams( 'com_users' );

		$video_id = JRequest::getInt( 'video_id', 0 );
		$template = JRequest::getVar( 'template', '' );
		$showdetails = JRequest::getInt( 'showdetails', '1' );
		$width = JRequest::getInt( 'width', null );
		$height = JRequest::getInt( 'height', null );
		$quality = JRequest::getWord( 'quality', 'hd' );
		$autostart = JRequest::getInt( 'autostart', null );
		$hwdvsAjaxPlayer = true;

		if (!hwd_vs_access::allowAccess( $c->gtree_plyr, $c->gtree_plyr_child, hwd_vs_access::userGID( $my->id ))) {
			if ( ($my->id < 1) && (!$usersConfig->get( 'allowUserRegistration' ) == '0' && hwd_vs_access::allowAccess( $c->gtree_upld, 'RECURSE', $acl->get_group_id('Registered','ARO') ) ) ) {
				hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_NOACCESS, _HWDVIDS_ALERT_REGISTERFORPLYR, "exclamation.png", 0, 0);
				exit;
			} else {
				hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_NOACCESS, _HWDVIDS_ALERT_PLYR_NOT_AUTHORIZED, "exclamation.png", 0, 0);
				exit;
			}
		}

        $where = ' WHERE video.id = '.$video_id;

		$query = "SELECT".$hwdvs_selectv." FROM #__hwdvidsvideos AS video ".$hwdvs_joinv." ".$where;
        $db->SetQuery($query);
        $row = $db->loadObject();

		if (!hwd_vs_tools::validateVideoAccess($row))
		{
			exit;
		}

		hwd_vs_tools::logViewing($row->id);
		require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'maintenance_recount.class.php');

		if ($showdetails == 1) {
			$smartyvs->assign("showdetails", 1);
		}

		$videoplayer = hwd_vs_tools::generateVideoDetails($row, $width, $height, null, $Itemid, null, null, $autostart);
		$smartyvs->assign("videoplayer", $videoplayer);
		hwd_vs_javascript::ajaxRate($row);

		if (empty($template) || $template == '') {
			$html = $smartyvs->fetch('plug_jomsocial_ajax.tpl');
		} else if ($template == 'playeronly') {
			$html = $videoplayer->player;
		} else {
			$html = $smartyvs->fetch($template.'.tpl');
		}

		print $html;
		exit;
	}
    /**
     *
     */
    function viewPlaylist($row)
    {
    	global $mainframe, $Itemid, $smartyvs, $Itemid;
        $c = hwd_vs_Config::get_instance();

		// load the menu name
		jimport( 'joomla.application.menu' );
		$menu   = &JMenu::getInstance('site');
		$mparams = &$menu->getParams($Itemid);
		$mparams_pt	= $mparams->get( 'page_title', '');

		jimport( 'joomla.document.document' );
		$doc = & JFactory::getDocument();

		$active = &$menu->getActive();

		if (!empty($mparams_pt)) {
			$metatitle = $mparams_pt;
		} else if (!empty($active->name)) {
			$metatitle = $active->name;
		} else {
			$metatitle = _HWDVIDS_META_DEFAULT;
		}

        // decode
        $meta_title = html_entity_decode($row->playlist_name);
        // set the page/meta title
        $doc->setTitle( $metatitle." - "._HWDVIDS_META_EPL." - ".$meta_title );
        $doc->setMetaData( 'title' , $metatitle." - "._HWDVIDS_META_EPL." - ".$meta_title );
		hwd_vs_tools::generateActiveLink(1);
		hwd_vs_javascript::confirmdelete();
		hwd_vs_tools::generateBreadcrumbs();

		$smartyvs->assign("playlist_name", stripslashes($row->playlist_name));
		$smartyvs->assign("playlist_description", stripslashes($row->playlist_description));
		$smartyvs->assign("playlist_id", $row->id);

		$hwdvids_params['playlist']		= "pl_$row->id";
		$hwdvids_params['single_id']	= 0;
		$hwdvids_params['width'] 		= 320;
		$hwdvids_params['height'] 		= 240;
		$hwdvids_params['autostart'] 	= 1;
		$hwdvids_params['extended'] 	= 1;
		$hwdvids_params['showdetails'] 	= 1;
		$hwdvids_params['novtd'] 		= 10;

		$hwdvids_params['thumb_width'] 		= 60;
		$hwdvids_params['mod_hwd_itemid'] 	= 0;
		$hwdvids_params['trunc_title'] 		= '';
		$hwdvids_params['trunc_descr'] 		= '';
		$hwdvids_params['showtt'] 		    = '0';

		if ($hwdvids_params['mod_hwd_itemid'] == 0) {
			$hwdvids_params['mod_hwd_itemid'] = hwd_vs_tools::generateValidItemid();
		}

		require_once(JPATH_SITE.DS.'components'.DS.'com_hwdvideoshare'.DS.'xml'.DS.'xmlparse.class.php');
		$parser = new HWDVS_xmlParse();
		$parsed_list = $parser->parse($hwdvids_params['playlist']);

		if (count($parsed_list) > 0)
		{
			$smartyvs->assign("vid", $parsed_list[0]['id']);

			$row->video_id = "";
			$row->video_type = "playlist";
			$row->playlist = JURI::base( true )."/components/com_hwdvideoshare/xml/xspf/".$hwdvids_params['playlist'].".xml";
			$video_player = hwd_vs_tools::generateVideoPlayer( $row, $hwdvids_params['width'], $hwdvids_params['height'], $hwdvids_params['autostart'] );

			if ($hwdvids_params['extended'] == 1)
			{
				$tooltip = 1;
				$list = hwd_vs_tools::generateVideoListFromXml($parsed_list, $hwdvids_params['thumb_width'], $hwdvids_params['mod_hwd_itemid'], $tooltip, $hwdvids_params['trunc_title'], $hwdvids_params['trunc_descr'], "hwdvs_insert_playlist_video");
				$smartyvs->assign("list", $list);
			}
		}
		else
		{
			hwd_vs_tools::infomessage(4, 0, "Empty playlist", "This playlist does not contactin any videos", "exclamation.png", 0);
			return;
		}

if ($hwdvids_params['extended'] == 1) {

	if ($hwdvids_params['showdetails'] == 1)
	{
		$showdetails = '&showdetails=1';
		$div_height = $hwdvids_params['height']+70;
	}
	else
	{
		$showdetails = '&showdetails=0';
		$div_height = $hwdvids_params['height']+70;
	}

	$showdetails.= '&width='.$hwdvids_params['width'].'&height='.$hwdvids_params['height'];

	$random = rand();
	$smartyvs->assign("print_extended", 1);
	$smartyvs->assign("random", $random);

	$hwdvs_ajax_video_js = "<script language=\"javascript\" type=\"text/javascript\">
			<!--
			//Browser Support Code
			function hwdvs_insert_playlist_video(video_id){

				var ajaxRequest;  // The variable that makes Ajax possible!

				document.getElementById('hwdvs_player_container".$random."').style.padding = \"0\";
				document.getElementById('hwdvs_player_container".$random."').style.margin = \"0\";
				document.getElementById('hwdvs_player_container".$random."').style.height = \"".$div_height."px\";
				document.getElementById('hwdvs_player_container".$random."').innerHTML = '<div style=\"padding:5px;\">Loading...<br /><img src=\"".JURI::root( true )."/plugins/community/hwdvideoshare/loading.gif\"></div>';

				try{
					// Opera 8.0+, Firefox, Safari
					ajaxRequest = new XMLHttpRequest();
				} catch (e){
					// Internet Explorer Browsers
					try{
						ajaxRequest = new ActiveXObject(\"Msxml2.XMLHTTP\");
					} catch (e) {
						try{
							ajaxRequest = new ActiveXObject(\"Microsoft.XMLHTTP\");
						} catch (e){
							// Something went wrong
							alert(\"Your browser broke!\");
							return false;
						}
					}
				}
				// Create a function that will receive data sent from the server
				ajaxRequest.onreadystatechange = function(){
					if(ajaxRequest.readyState == 4){
						document.getElementById('hwdvs_player_container".$random."').style.padding = \"0\";
						document.getElementById('hwdvs_player_container".$random."').style.margin = \"0\";
						document.getElementById('hwdvs_player_container".$random."').innerHTML = ajaxRequest.responseText;

						var theInnerHTML = ajaxRequest.responseText;
						var theID = 'hwdvs_player_container".$random."';
						setAndExecute(theID,theInnerHTML);
						var containerHeight = document.getElementById('hwdvs_player_container".$random."').offsetHeight;
						var calcHeight = containerHeight-40;
						document.getElementById('videoDetails').style.height = calcHeight+\"px\";
						document.getElementById('videoDetails').style.overflow = \"auto\";
					}
				}
				ajaxRequest.open(\"GET\", \"".JURI::root( true )."/index.php?option=com_hwdvideoshare&task=grabajaxplayer&Itemid=".$hwdvids_params['mod_hwd_itemid'].$showdetails."&template=mod_hwd_vs_video_playlist_container&tmpl=component&video_id=\" + video_id, true);
				ajaxRequest.send(null);

				function setAndExecute(divId, innerHTML)
				{
					var div = document.getElementById(divId);
					div.innerHTML = innerHTML;
					var x = div.getElementsByTagName(\"script\");
					for(var i=0;i<x.length;i++)
					{
						eval(x[i].text);
					}
				}
			}

			//-->
		 </script>";
	$doc->addCustomTag($hwdvs_ajax_video_js);
}

		$smartyvs->assign("hwdvids_params", $hwdvids_params);
		$smartyvs->assign("video_player", $video_player);
		$smartyvs->display('playlist_view.tpl');

		return;
    }
    /**
     * Generates the 'add video to group' button
     *
     * @param string $row  the group sql data
     * @return       $code
     */
	function generateAddToPlaylistButton($row)
	{
		global $smartyvs, $hwdvsItemid;
		$c = hwd_vs_Config::get_instance();
		$db = & JFactory::getDBO();
		$my = & JFactory::getUser();

		hwd_vs_javascript::ajaxaddtoplaylist($row);

		// setup ajax tags
	    if ($c->ajaxa2gmeth == 1) { $ajaxa2g = "onsubmit=\"ajaxFunctionA2PL();return false;\""; } else { $ajaxa2g = null; }

		$code = null;

		$db->SetQuery( 'SELECT count(*)'
							. ' FROM #__hwdvidsplaylists'
							. ' WHERE user_id = '.$my->id
							);
		$total = $db->loadResult();
		echo $db->getErrorMsg();

		if ($total > 0) {

			$smartyvs->assign("showAddButton", 1);
			$smartyvs->assign("print_addtoplaylist", 1);

			$query = 'SELECT * FROM #__hwdvidsplaylists WHERE user_id = '.$my->id;
			$db->SetQuery($query);
			$rows = $db->loadObjectList();

			$code.= "<form name=\"add2playlist\" ".$ajaxa2g." action=\"".JURI::root( true )."/index.php?option=com_hwdvideoshare&Itemid=".$hwdvsItemid."&task=addvideotoplaylist\" method=\"post\">";
			$code.= "<input type=\"hidden\" name=\"userid\" value=\"".$my->id."\" />";
			$code.= "<input type=\"hidden\" name=\"videoid\" value=\"".$row->id."\" />";
			$code.= "<select name=\"playlistid\" class=\"add2gselect\">";
			$code.= "<option value=\"0\">Add to playlist</option>";
				$n=count($rows);
				for ($i=0, $n=count($rows); $i < $n; $i++) {
					$row = $rows[$i];
					$code.= "<option value =\"".$row->id."\">".$row->playlist_name."</option>";
				}
			$code.= "</select>&nbsp;";
			$code.= "<input type=\"submit\" value=\""._HWDVIDS_BUTTON_ADD."\" id=\"add2groupbutton\" class=\"interactbutton\" />";
			$code.= "</form>";

		}

		return $code;
    }