protected function compile()
	{
		/** @var PageModel $objPage */
		global $objPage;

		$this->Template->poster = false;

		// Optional poster
		if ($this->posterSRC != '')
		{
			if (($objFile = FilesModel::findByUuid($this->posterSRC)) !== null)
			{
				$this->Template->poster = $objFile->path;
			}
		}

		$objFiles = $this->objFiles;

		/** @var FilesModel $objFirst */
		$objFirst = $objFiles->current();

		// Pre-sort the array by preference
		if (\in_array($objFirst->extension, array('mp4', 'm4v', 'mov', 'wmv', 'webm', 'ogv')))
		{
			$this->Template->isVideo = true;
			$arrFiles = array('mp4'=>null, 'm4v'=>null, 'mov'=>null, 'wmv'=>null, 'webm'=>null, 'ogv'=>null);
		}
		else
		{
			$this->Template->isVideo = false;
			$arrFiles = array('m4a'=>null, 'mp3'=>null, 'wma'=>null, 'mpeg'=>null, 'wav'=>null, 'ogg'=>null);
		}

		$objFiles->reset();

		// Convert the language to a locale (see #5678)
		$strLanguage = str_replace('-', '_', $objPage->language);

		// Pass File objects to the template
		while ($objFiles->next())
		{
			$arrMeta = StringUtil::deserialize($objFiles->meta);

			if (\is_array($arrMeta) && isset($arrMeta[$strLanguage]))
			{
				$strTitle = $arrMeta[$strLanguage]['title'];
			}
			else
			{
				$strTitle = $objFiles->name;
			}

			$objFile = new File($objFiles->path);
			$objFile->title = StringUtil::specialchars($strTitle);

			$arrFiles[$objFile->extension] = $objFile;
		}

		$size = StringUtil::deserialize($this->playerSize);

		if (!\is_array($size) || empty($size[0]) || empty($size[1]))
		{
			if ($this->Template->isVideo)
			{
				$this->Template->size = ' width="640" height="360"';
			}
			else
			{
				$this->Template->size = ' width="400" height="40"';
			}
		}
		else
		{
			$this->Template->size = ' width="' . $size[0] . '" height="' . $size[1] . '"';
		}

		$this->Template->files = array_values(array_filter($arrFiles));

		$attributes = array('controls' => 'controls');
		$options = StringUtil::deserialize($this->playerOptions);

		if (\is_array($options))
		{
			foreach ($options as $option)
			{
				if ($option == 'player_nocontrols')
				{
					unset($attributes['controls']);
				}
				else
				{
					$attributes[substr($option, 7)] = substr($option, 7);
				}
			}
		}

		$this->Template->attributes = $attributes;
		$this->Template->preload = $this->playerPreload;
		$this->Template->caption = $this->playerCaption;

		if ($this->playerStart || $this->playerStop)
		{
			$range = '#t=';

			if ($this->playerStart)
			{
				$range .= $this->playerStart;
			}

			if ($this->playerStop)
			{
				$range .= ',' . $this->playerStop;
			}

			$this->Template->range = $range;
		}
	}
protected function compile()
	{
		
		global $objPage;

		$this->Template->poster = false;

		
		if ($this->posterSRC != '')
		{
			if (($objFile = FilesModel::findByUuid($this->posterSRC)) !== null)
			{
				$this->Template->poster = $objFile->path;
			}
		}

		$objFiles = $this->objFiles;

		
		$objFirst = $objFiles->current();

		
		if (\in_array($objFirst->extension, array('mp4', 'm4v', 'mov', 'wmv', 'webm', 'ogv')))
		{
			$this->Template->isVideo = true;
			$arrFiles = array('mp4'=>null, 'm4v'=>null, 'mov'=>null, 'wmv'=>null, 'webm'=>null, 'ogv'=>null);
		}
		else
		{
			$this->Template->isVideo = false;
			$arrFiles = array('m4a'=>null, 'mp3'=>null, 'wma'=>null, 'mpeg'=>null, 'wav'=>null, 'ogg'=>null);
		}

		$objFiles->reset();

		
		$strLanguage = str_replace('-', '_', $objPage->language);

		
		while ($objFiles->next())
		{
			$arrMeta = StringUtil::deserialize($objFiles->meta);

			if (\is_array($arrMeta) && isset($arrMeta[$strLanguage]))
			{
				$strTitle = $arrMeta[$strLanguage]['title'];
			}
			else
			{
				$strTitle = $objFiles->name;
			}

			$objFile = new File($objFiles->path);
			$objFile->title = StringUtil::specialchars($strTitle);

			$arrFiles[$objFile->extension] = $objFile;
		}

		$size = StringUtil::deserialize($this->playerSize);

		if (!\is_array($size) || empty($size[0]) || empty($size[1]))
		{
			if ($this->Template->isVideo)
			{
				$this->Template->size = ' width="640" height="360"';
			}
			else
			{
				$this->Template->size = ' width="400" height="40"';
			}
		}
		else
		{
			$this->Template->size = ' width="' . $size[0] . '" height="' . $size[1] . '"';
		}

		$this->Template->files = array_values(array_filter($arrFiles));

		$attributes = array('controls' => 'controls');
		$options = StringUtil::deserialize($this->playerOptions);

		if (\is_array($options))
		{
			foreach ($options as $option)
			{
				if ($option == 'player_nocontrols')
				{
					unset($attributes['controls']);
				}
				else
				{
					$attributes[substr($option, 7)] = substr($option, 7);
				}
			}
		}

		$this->Template->attributes = $attributes;
		$this->Template->preload = $this->playerPreload;
		$this->Template->caption = $this->playerCaption;

		if ($this->playerStart || $this->playerStop)
		{
			$range = '

			if ($this->playerStart)
			{
				$range .= $this->playerStart;
			}

			if ($this->playerStop)
			{
				$range .= ',' . $this->playerStop;
			}

			$this->Template->range = $range;
		}
	}
protected function compile ( ) { /** @var PageModel $objPage */ global $ objPage ; $ this -> Template -> poster = false ; // Optional poster if ( $ this -> posterSRC != '' ) { if ( ( $ objFile = FilesModel :: findByUuid ( $ this -> posterSRC ) ) !== null ) { $ this -> Template -> poster = $ objFile -> path ; } } $ objFiles = $ this -> objFiles ; /** @var FilesModel $objFirst */ $ objFirst = $ objFiles -> current ( ) ; // Pre-sort the array by preference if ( \ in_array ( $ objFirst -> extension , array ( 'mp4' , 'm4v' , 'mov' , 'wmv' , 'webm' , 'ogv' ) ) ) { $ this -> Template -> isVideo = true ; $ arrFiles = array ( 'mp4' => null , 'm4v' => null , 'mov' => null , 'wmv' => null , 'webm' => null , 'ogv' => null ) ; } else { $ this -> Template -> isVideo = false ; $ arrFiles = array ( 'm4a' => null , 'mp3' => null , 'wma' => null , 'mpeg' => null , 'wav' => null , 'ogg' => null ) ; } $ objFiles -> reset ( ) ; // Convert the language to a locale (see #5678) $ strLanguage = str_replace ( '-' , '_' , $ objPage -> language ) ; // Pass File objects to the template while ( $ objFiles -> next ( ) ) { $ arrMeta = StringUtil :: deserialize ( $ objFiles -> meta ) ; if ( \ is_array ( $ arrMeta ) && isset ( $ arrMeta [ $ strLanguage ] ) ) { $ strTitle = $ arrMeta [ $ strLanguage ] [ 'title' ] ; } else { $ strTitle = $ objFiles -> name ; } $ objFile = new File ( $ objFiles -> path ) ; $ objFile -> title = StringUtil :: specialchars ( $ strTitle ) ; $ arrFiles [ $ objFile -> extension ] = $ objFile ; } $ size = StringUtil :: deserialize ( $ this -> playerSize ) ; if ( ! \ is_array ( $ size ) || empty ( $ size [ 0 ] ) || empty ( $ size [ 1 ] ) ) { if ( $ this -> Template -> isVideo ) { $ this -> Template -> size = ' width="640" height="360"' ; } else { $ this -> Template -> size = ' width="400" height="40"' ; } } else { $ this -> Template -> size = ' width="' . $ size [ 0 ] . '" height="' . $ size [ 1 ] . '"' ; } $ this -> Template -> files = array_values ( array_filter ( $ arrFiles ) ) ; $ attributes = array ( 'controls' => 'controls' ) ; $ options = StringUtil :: deserialize ( $ this -> playerOptions ) ; if ( \ is_array ( $ options ) ) { foreach ( $ options as $ option ) { if ( $ option == 'player_nocontrols' ) { unset ( $ attributes [ 'controls' ] ) ; } else { $ attributes [ substr ( $ option , 7 ) ] = substr ( $ option , 7 ) ; } } } $ this -> Template -> attributes = $ attributes ; $ this -> Template -> preload = $ this -> playerPreload ; $ this -> Template -> caption = $ this -> playerCaption ; if ( $ this -> playerStart || $ this -> playerStop ) { $ range = '#t=' ; if ( $ this -> playerStart ) { $ range .= $ this -> playerStart ; } if ( $ this -> playerStop ) { $ range .= ',' . $ this -> playerStop ; } $ this -> Template -> range = $ range ; } }
Generate the module
Generate the module