/**
	* edit videos
	*/
	function editvideos($row, $cat, $usr, $favs, $flagged)
	{
		global $option, $smartyvs, $Itemid;
		$c = hwd_vs_Config::get_instance();
		jimport('joomla.user.authorization');
		$editor      =& JFactory::getEditor();
		$acl=& JFactory::getACL();

		// force no-cache so new thumbnail will display
		@header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
		@header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
		@header( 'Cache-Control: no-store, no-cache, must-revalidate' );
		@header( 'Cache-Control: post-check=0, pre-check=0', false );
		@header( 'Pragma: no-cache' );

		/** define template variables **/
		$hidden_inputs = '<input type="hidden" name="option" value="com_hwdvideoshare" />
		<input type="hidden" name="id" value="'.$row->id.'" />
		<input type="hidden" name="video_type" value="'.$row->video_type.'" />
		<input type="hidden" name="task" value="savevid" />';
		jimport('joomla.html.pane');
		$pane =& JPane::getInstance('tabs');
		$startpane = $pane->startPane( 'video-edit-pane' );
		$endtab = $pane->endPanel();
		$endpane = $pane->endPane();
		$starttab1 = $pane->startPanel( _HWDVIDS_TAB_BASIC, 'panel1' );
		$starttab2 = $pane->startPanel( _HWDVIDS_TAB_SHARING, 'panel2' );

		//echo '<script type="text/javascript" src="'.JURI::root(true).'/components/com_hwdvideoshare/js/mootools-1.2-core-yc.js"></script>';

		if ($row->public_private == "public")          { $pubsel = "selected=\"selected\""; $regsel=null; $msel=null; $wsel=null; $gsel=null; $lsel=null; }
		else if ($row->public_private == "registered") { $regsel = "selected=\"selected\""; $pubsel=null; $msel=null; $wsel=null; $gsel=null; $lsel=null; }
		else if ($row->public_private == "me")         { $msel = "selected=\"selected\""; $pubsel=null; $regsel=null; $wsel=null; $gsel=null; $lsel=null; }
		else if ($row->public_private == "password")   { $wsel = "selected=\"selected\""; $pubsel=null; $regsel=null; $msel=null; $gsel=null; $lsel=null; }
		else if ($row->public_private == "group")   { $gsel = "selected=\"selected\""; $pubsel=null; $regsel=null; $msel=null; $wsel=null; $lsel=null; }
		else if ($row->public_private == "level")   { $lsel = "selected=\"selected\""; $pubsel=null; $regsel=null; $msel=null; $wsel=null; $gsel=null; }

		$public_private = "<select name=\"public_private\" onChange=\"ShowPasswordField()\">
		                   <option value=\"public\" ".$pubsel.">"._HWDVIDS_SELECT_PUBLIC."</option>
		                   <option value=\"registered\" ".$regsel.">"._HWDVIDS_SELECT_REG."</option>
		                   <option value=\"me\" ".$msel.">"._HWDVIDS_SELECT_ME."</option>
		                   <option value=\"password\" ".$wsel.">"._HWDVIDS_SELECT_PASSWORD."</option>
		                   <option value=\"group\" ".$gsel.">"._HWDVIDS_SELECT_JACG."</option>
		                   <option value=\"level\" ".$lsel.">"._HWDVIDS_SELECT_JACL."</option>
					       </select>";

		$gtree=array();
		$gtree[] = JHTML::_('select.option', -2 , '- ' ._HWDVIDS_SELECT_EVERYONE . ' -');
		$gtree[] = JHTML::_('select.option', -1, '- ' . _HWDVIDS_SELECT_ALLREGUSER . ' -');
		$gtree = array_merge( $gtree, $acl->get_group_children_tree( null, 'USERS', false  ) );

		if ($row->public_private == "group")
		{
			$gtree_video = JHTML::_('select.genericlist', $gtree, 'gtree_video', 'size="4"', 'value', 'text', $row->password);
			$smartyvs->assign( "gtree_video", $gtree_video );
		}
		else
		{
			$gtree_video = JHTML::_('select.genericlist', $gtree, 'gtree_video', 'size="4"', 'value', 'text', '');
			$smartyvs->assign( "gtree_video", $gtree_video );
		}

		if ($row->public_private == "level")
		{
			$jacl_video = hwd_vs_tools::hwdvsMultiAccess( $row->password, 'jacl_video[]' );
			$smartyvs->assign( "jacl_video", $jacl_video );
		}
		else
		{
			$jacl_video = hwd_vs_tools::hwdvsMultiAccess( '', 'jacl_video[]' );
			$smartyvs->assign( "jacl_video", $jacl_video );
		}

		$missingfile=null;
		if ($row->video_type == "local" || $row->video_type == "mp4") {

			$location = _HWDVIDS_DETAILS_SOTS."<br />";
			if (file_exists(JPATH_SITE."/hwdvideos/uploads/".$row->video_id.".flv")) {
				$location.= "<b>"._HWDVIDS_NQFILE.":</b> ".JPATH_SITE."/hwdvideos/uploads/".$row->video_id.".flv<br />";
			}
			else
			{
				$location.= "<b>"._HWDVIDS_NQFILE.":</b> ".JPATH_SITE."/hwdvideos/uploads/".$row->video_id.".flv <b>(MISSING)</b><br />";
				$smartyvs->assign( "print_missingfile", 1 );
			}
			if (file_exists(JPATH_SITE."/hwdvideos/uploads/".$row->video_id.".mp4")) {
				$location.= "<b>"._HWDVIDS_HQFILE.":</b> ".JPATH_SITE."/hwdvideos/uploads/".$row->video_id.".mp4<br />";
			}
			else
			{
				$location.= "<b>"._HWDVIDS_HQFILE.":</b> ".JPATH_SITE."/hwdvideos/uploads/".$row->video_id.".mp4 <b>(MISSING)</b><br />";
				$smartyvs->assign( "print_missingfile", 1 );
			}
		} else if ($row->video_type == "swf") {
			$location = _HWDVIDS_DETAILS_SOTS."<br /><b>"._HWDVIDS_FNAME.":</b> ".JPATH_SITE."/hwdvideos/uploads/".$row->video_id.".swf";
			if (@!file_exists(JPATH_SITE."/hwdvideos/uploads/".$row->video_id.".swf")) {
				$missingfile = "<div style=\"color:#ff0000;font-weight:bold;\">"._HWDVIDS_ALERT_MISSINGVIDFILE."</div>";
			}
		} else if ($row->video_type == "remote") {
			$data = @explode(",", $row->video_id);
			$location = _HWDVIDS_DETAILS_REMSER." (".$row->video_type.")<br /><b>"._HWDVIDS_FURL.":</b> ".$data[0];
		} else if ($row->video_type == "seyret") {

			$data = @explode(",", $row->video_id);
			if ($data[0] == "local") {

				$data = @explode(",", $row->video_id);
				$location = _HWDVIDS_DETAILS_SOTS."<br /><b>"._HWDVIDS_NAME.":</b> ".$data[1];

			} else {

				hwd_vs_tools::getPluginDetails($data[0]);
				$flvurlfunc = preg_replace("/[^a-zA-Z0-9s_-]/", "", $data[0])."PrepareFlvURL";
				if (function_exists($flvurlfunc)) {
					$truepath = $flvurlfunc($data[1].",".$data[2], $row);
					$location = _HWDVIDS_DETAILS_REMSER." (".$data[0].")<br /><b>"._HWDVIDS_FURL.":</b><br /><textarea readonly rows=\"5\" cols=\"60\">".urldecode($truepath)."</textarea>";
				} else {
					$location = _HWDVIDS_DETAILS_REMSER." (".$data[0].")";
				}
			}

		} else {
			hwd_vs_tools::getPluginDetails($row->video_type);
			$flvurlfunc = preg_replace("/[^a-zA-Z0-9s_-]/", "", $row->video_type)."PrepareFlvURL";
			if (function_exists($flvurlfunc)) {
				$truepath = $flvurlfunc($row->video_id, $row);
				$location = _HWDVIDS_DETAILS_REMSER." (".$row->video_type.")<br /><b>"._HWDVIDS_FURL.":</b><br /><textarea readonly rows=\"5\" cols=\"60\">".urldecode($truepath)."</textarea>";
			} else {
				$location = _HWDVIDS_DETAILS_REMSER." (".$row->video_type.")";
			}
		}

		/** assign template variables **/
		$smartyvs->assign( "hidden_inputs" , $hidden_inputs );
		$smartyvs->assign( "header_title" , _HWDVIDS_SECTIONHEAD_VIDEOS );
		$smartyvs->assign( "row" , $row );
		$smartyvs->assign( "startpane", $startpane );
		$smartyvs->assign( "endtab", $endtab );
		$smartyvs->assign( "endpane", $endpane );
		$smartyvs->assign( "starttab1", $starttab1 );
		$smartyvs->assign( "starttab2", $starttab2 );
		$smartyvs->assign( "vid", $row->id);

		if ($row->approved == "deleted") {
			$smartyvs->display('admin_videos_edit_deleted.tpl');
			return;
		} else if ($row->approved == "queuedforconversion") {
			$smartyvs->display('admin_videos_edit_queuedforconversion.tpl');
			return;
		} else if ($row->approved == "queuedforthumbnail") {
			$smartyvs->display('admin_videos_edit_queuedforthumbnail.tpl');
			return;
		} else if ($row->approved == "queuedforswf") {
			$smartyvs->display('admin_videos_edit_queuedforswf.tpl');
			return;
		} else if ($row->approved == "converting") {
		    $smartyvs->display( 'admin_videos_edit_converting.tpl');
			return;
		} else if (strpos($row->approved, "converting") || strpos($row->approved, "re-calculate_duration") || strpos($row->approved, "re-generate_thumb")) {
		    $smartyvs->display( 'admin_videos_edit_queuedforconversion.tpl');
			return;
		} else if ($row->approved == "pending") {
		    $smartyvs->assign( 'print_pending', 1 );
		}

		$age_check = "<select name=\"age_check\" size=\"1\" class=\"inputbox\">";
		$age_check.= "<option value=\"-1\""; if ($row->age_check == -1) { $age_check.= " selected=\"selected\""; } $age_check.= ">Global</option>";
		$age_check.= "<option value=\"0\""; if ($row->age_check == 0) { $age_check.= " selected=\"selected\""; } $age_check.= ">Off</option>";

		for ($i=1, $n=100; $i < $n; $i++)
		{
		$age_check.= "<option value=\"$i\""; if ($row->age_check == $i) $age_check.= " selected=\"selected\""; $age_check.= ">$i</option>";
		}

		$age_check.= "</select>";

		$smartyvs->assign( "age_check" , $age_check);
		$smartyvs->assign( "categorylist" , hwd_vs_tools::categoryList(_HWDVIDS_INFO_CHOOSECAT, $row->category_id, _HWDVIDS_INFO_NOCATS, 1) );
		$smartyvs->assign( "title", str_replace('"', "&#34;", stripslashes($row->title)) );
		$smartyvs->assign( "category", hwd_vs_tools::generateCategory( $row->category_id ) );
		$smartyvs->assign( "description", $editor->display("description",stripslashes($row->description),350,250,40,20,1) );
		$smartyvs->assign( "tags", str_replace('"', "&#34;", $row->tags) );
		$smartyvs->assign( "published", hwd_vs_tools::yesnoSelectList( 'published', 'class="inputbox"', $row->published ) );
		$smartyvs->assign( "featured", hwd_vs_tools::yesnoSelectList( 'featured', 'class="inputbox"', $row->featured ) );
		$smartyvs->assign( "dateuploaded", $row->date_uploaded );
		$smartyvs->assign( "duration", $row->video_length );
		$smartyvs->assign( "thumb_snap", $row->thumb_snap );
		$smartyvs->assign( "public_private", $public_private );
		$smartyvs->assign( "allow_comments", hwd_vs_tools::yesnoSelectList( 'allow_comments', 'class="inputbox"', $row->allow_comments ) );
		$smartyvs->assign( "allow_embedding", hwd_vs_tools::yesnoSelectList( 'allow_embedding', 'class="inputbox"', $row->allow_embedding ) );
		$smartyvs->assign( "allow_ratings", hwd_vs_tools::yesnoSelectList( 'allow_ratings', 'class="inputbox"', $row->allow_ratings ) );
		$smartyvs->assign( "link_live_video", JURI::root(true)."/index.php?option=com_hwdvideoshare&task=viewvideo&Itemid=".$Itemid."&video_id=".$row->id );
		$smartyvs->assign( "status", hwd_vs_tools::generateVideoStatus($row->approved) );
		$smartyvs->assign( "videoplayer", hwd_vs_tools::generateVideoPlayer($row) );
		$smartyvs->assign( "missingfile", $missingfile );
		$smartyvs->assign( "location", $location );
		$smartyvs->assign( "thumbnail", hwd_vs_tools::generateThumbnail( $row->id, $row->video_id, $row->video_type, $row->thumbnail, null, null, null, null) );
		$smartyvs->assign( "access", hwd_vs_tools::generateVideoAccess( $row->public_private ) );
		$smartyvs->assign( "rating", hwd_vs_tools::generateExactRating($row) );
		$smartyvs->assign( "views", $row->number_of_views );
		$smartyvs->assign( "user", $usr->username );
		$smartyvs->assign( "favoured", $favs );

		if ($row->video_type == "local" || $row->video_type == "mp4")
		{
			$smartyvs->assign( "remotevideo", 0 );
		}
		else if ($row->video_type == "swf")
		{
			$smartyvs->assign( "remotevideo", 2 );
		}
		else if ($row->video_type == "seyret")
		{
			$data = @explode(",", $row->video_id);
			if ($data[0] == "local")
			{
				$smartyvs->assign( "remotevideo", 0 );
			}
			else
			{
				$smartyvs->assign( "remotevideo", 1 );
			}
		}
		else
		{
			$smartyvs->assign( "remotevideo", 1 );
		}

		$thumbnail_form_code = null;
		// generate thumbnail form
		if ($row->approved == "yes" || $row->approved == "pending") {
			$thumbnail_form_code.= '<h3>Upload Custom Thumbnail</h3>';
			$thumbnail_form_code.= '<p>Upload a custom thumbnail image from your computer.</p>';
			$thumbnail_form_code.= '<form action="index.php" method="post" enctype="multipart/form-data">
			<div style="padding:2px 0;"><input type="file" name="thumbnail_file" value="" size="30"></div>
			<div style="padding:2px 0;"><input type="submit" value="Upload"></div>
			<input type="hidden" name="option" value="'.$option.'" />
			<input type="hidden" name="cid" value="'.$row->id.'" />
			<input type="hidden" name="task" value="editvidsA" />
			<input type="hidden" name="upld_thumbnail" value="1" />
			</form>';
		}
		$smartyvs->assign( "thumbnail_form_code", $thumbnail_form_code );

		/** display template **/
		$smartyvs->display('admin_videos_edit.tpl');
		return;
	}
Exemplo n.º 2
0
    /**
     * Generates a linked thumbnail for video id $video_id
     *
     * @param int    $video_id  the id of the video
     * @param string $video_code  the name of the video file (excluding ext)
     * @param string $video_type  the video type tag
     * @param int    $k  current css tag
     * @param int    $width  width of the thumbnail
     * @param int    $height  height of the thumbnail
     * @param string $class  class for thumbnail (not link)
     * @param string $target(optional)  the target for the link
     * @return       $code
     */
	function generateVideoThumbnailLink( $video_id, $video_code, $video_type, $video_thumbnail, $k, $width, $height, $class, $target="_top", $hwdvs_itemid=null, $onclick_js=null, $tooltip_data=null, $lightbox=false, $video_duration=null)
	{
		global $option, $hwdvsItemid, $mainframe, $smartyvs;
		$doc = & JFactory::getDocument();
		$c = hwd_vs_Config::get_instance();

		if ($hwdvs_itemid == null) { $hwdvs_itemid = $hwdvsItemid; }

		if (!empty($onclick_js))
		{
			$onclick_txt="onclick=\"".$onclick_js."(".$video_id.");return false;\"";
			$link="#video";
		}
		else
		{
			$onclick_txt="";
			$link=JRoute::_("index.php?option=com_hwdvideoshare&task=viewvideo&Itemid=".$hwdvs_itemid."&video_id=".$video_id);
		}

		if (!empty($lightbox)) {

			$link=JRoute::_("index.php?option=com_hwdvideoshare&task=grabajaxplayer&Itemid=".$hwdvs_itemid."&video_id=".$video_id."&template=playeronly");

			if (!defined( 'HWDVS_LB' )) {
				define( 'HWDVS_LB', 1 );
				$doc->addCustomTag('<script type="text/javascript" src="'.JURI::root(true).'/components/com_hwdvideoshare/assets/js/overlay.js"></script>');
				$doc->addCustomTag('<script type="text/javascript" src="'.JURI::root(true).'/components/com_hwdvideoshare/assets/js/multibox.js"></script>');
				$doc->addCustomTag('<link rel="stylesheet" href="'.JURI::root(true).'/components/com_hwdvideoshare/assets/css/multibox.css" media="screen,projection" type="text/css" />');

				if (substr($lightbox, 0, 2) == "mb")
				{
					$smartyvs->assign("print_mb_initialize", 1);
					$smartyvs->assign("mb_id", $lightbox);
				}
			}

			$v_width = $c->flvplay_width;
			$v_height = intval($v_width*$c->var_fb)+20;

			$code = null;
			$code.= '<a href="'.$link.'" class="'.$lightbox.'" title="" rel="width:'.$v_width.',height:'.$v_height.'">';
			$code.= hwd_vs_tools::generateThumbnail( $video_id, $video_code, $video_type, $video_thumbnail, $k, $width, $height, $class, $tooltip_data, $video_duration );
			$code.= '</a>';

  			return $code;

		}

		$code = null;
		$code.= "<a href=\"".$link."\" ".$onclick_txt.">";
		$code.= hwd_vs_tools::generateThumbnail( $video_id, $video_code, $video_type, $video_thumbnail, $k, $width, $height, $class, $tooltip_data, $video_duration );
		$code.= "</a>";

		return $code;
    }