<?php
/**
 * This file is to get xml code
 *
 * This file is having get xml code
 *
 * PHP version 5.0
 *
 * @category	Anova
 * @package     ansVideoConfigXmlCode
 * @author 		shankar_76ag08
 * @copyright 	Copyright (c) 2009 {@link http://www.agriya.com Agriya Infoway}
 * @license		http://www.agriya.com Agriya Infoway Licence
 * @since 		2008-12-19
 *
 **/
require_once('../common/configs/config.inc.php');

$CFG['lang']['include_files'][] = 'languages/%s/admin/ansVideoConfiguration.php';
$CFG['site']['is_module_page'] = $CFG['admin']['index']['anova_module'];
//compulsory
$CFG['mods']['is_include_only']['non_html_header_files'] = true;
$CFG['mods']['is_include_only']['html_header'] = false;
$CFG['html']['is_use_header'] = false;
/**
 * To include application top file
*/
require_once($CFG['site']['project_path'].'common/application_top.inc.php');

/**
 * XmlCode
 *
 * @package
 * @author sridhar_68ag07
 * @copyright Copyright (c) 2009
 * @version $Id$
 * @access public
 */
class XmlCode extends FormHandler
	{
		public $audio_details;

		/**
		 * XmlCode::populatePhotoDetails()
		 *
		 * @return
		 **/
		public function populateMusicDetails()
			{
				$sql = 'SELECT audio_id, content_id, user_id, audio_ext, audio_size,'.
						' playing_time, date_added, audio_server_url,'.
						' audio_url, audio_upload_type'.
						' FROM '.$this->CFG['db']['tbl']['ans_audio'].' WHERE'.
						' audio_id='.$this->dbObj->Param('audio_id').' AND'.
						' audio_status=\'Ok\' AND'.
						' audio_encoded_status=\'Yes\'';

				$stmt = $this->dbObj->Prepare($sql);
				$rs = $this->dbObj->Execute($stmt, array($this->fields_arr['aid']));
				    if (!$rs)
					    trigger_db_error($this->dbObj);

				if($this->audio_details = $rs->FetchRow())
					return true;
				return false;
			}

		public function chkIsValidExternalAudioUrl($audio_url, $err_tip = '')
			{
				return $this->music_url = $audio_url;
			}

		public function getXmlCode()
			{
				$fields = explode('_', $this->fields_arr['pg']);
				$this->fields_arr['pg'] = $fields[0];
				$this->fields_arr['aid'] = $fields[1];

				if(!($this->fields_arr['pg'] and $this->fields_arr['aid']))
					{
						return;
					}
				switch($this->fields_arr['pg'])
					{
						case 'music':
							$this->populateMusicDetails();
							$music_folder = $this->CFG['admin']['ans_audios']['audio_folder'];
							if($this->audio_details['audio_upload_type']=='Normal' || $this->audio_details['audio_upload_type']=='Othersite')
								$music_url = $this->audio_details['audio_server_url'].$music_folder.getImageName($this->fields_arr['aid']).'.'.$this->audio_details['audio_ext'];
							else
								$music_url = $this->chkIsValidExternalAudioUrl($this->audio_details['audio_url']);
							break;

						case 'previewmusic':
							$temp_dir = $this->CFG['site']['url'].$this->CFG['admin']['ans_audios']['temp_folder'];
							$music_url = $temp_dir.$this->fields_arr['aid'].'AUD.flv?v='.time();
							break;

						case 'smallmusic':
							break;

						case 'musicactivate':
							break;
					}
?>
<PATH>
	<SONGS>
		<SONG Path="<?php echo $music_url;?>"  Title="<?php echo $this->CFG['site']['name'].' - '.$this->LANG['common_audio_player']; ?>" Plays = "100"  BuyUrl="http://url1.com" LyricsUrl = "http://gmail1.com"  Rate="http://rateUrl.com" Comments="http://comments.h" ImageUrl="images/image1.jpg" TargetUrl = "http://google.com" Target="_blank" Type="<?php echo $this->audio_details['audio_ext'];?>" />
	</SONGS>
</PATH>
<?php
			}
	}
//<<<<<-------------- Class XmlCode begins ---------------//
//-------------------- Code begins -------------->>>>>//
$XmlCode = new XmlCode();
$XmlCode->includeAjaxHeader();

$CFG['user']['user_id'] = isset($_SESSION['user']['user_id'])?$_SESSION['user']['user_id']:'0';

$XmlCode->setPageBlockNames(array('get_code_form'));
//default form fields and values...
$XmlCode->setFormField('aid', '');
$XmlCode->setFormField('pg', '');
$XmlCode->setFormField('full', false);
$XmlCode->setPageBlockShow('get_code_form');
$XmlCode->sanitizeFormInputs($_GET);
//<<<<<-------------------- Code ends----------------------//
//-------------------- Page block templates begins -------------------->>>>>//
if ($XmlCode->isShowPageBlock('get_code_form'))
    {
		$XmlCode->getXmlCode();
	}
//<<<<<-------------------- Page block templates ends -------------------//
$XmlCode->includeAjaxFooter();
?>