<?php

class VideoAdminView extends Slot {

	var $SectionID = 56;
	var $ModuleID = 2;
	var $reqfield = '<img src="/i/must.gif">&nbsp;';
	var $upload_formats = array(
		'image/jpeg' => 'jpg',
		'image/pjpeg' => 'jpg',
		'image/gif' => 'gif',
		'image/png' => 'gif',
	);
	var $upload_formats_check = array(
		'image/jpeg',
		'image/pjpeg',
		'image/gif',
		'image/png',
	
	);
	var $upload_video_formats = array(
		'video/mp4' => 'mp4',
	);
	var $upload_video_formats_check = array(
		'video/mp4',
	);
	
	var $upload_settings = array(
		'prew_width' => '',
		'prew_height' => '',
		'big_width' => '315',
		'big_height' => '208',
	);
	

	function __construct($pquery) {
		parent::__construct($pquery);
	}

	function init() { 
		switch(@$this->LocalTarget[0]) {
			case 'Edit': case 'Delete':
				if(!empty($this->LocalTarget[1]) && validate(intval($this->LocalTarget[1]))) {
					$this->Action->processEvent($this->SectionID,'open_video',array('id' => $this->LocalTarget[1]),$this);
					if(!empty($this->PreparedTemplates['_error'])) header("Location: ".$this->Home.'/Registar/VideoAdmin'.$this->SID);
					else $this->Scheme = 'action';
				}
				else header("Location: ".$this->Home.'/Registar/VideoAdmin'.$this->SID);
			break;
			case 'Add': $this->Scheme = 'action'; break;
			default:                
				$request = array('conditions' => array(),'pageRecordsQty' => '20', 'sortColumn'=>'date' , 'sortType' =>'DESC');
				$request['curPageNumber'] = empty($this->LocalTarget[0]) || !validate(intval($this->LocalTarget[0]))? 1 : intval($this->LocalTarget[0]+1);
				$this->Action->processEvent($this->SectionID,'select_videos',$request,$this);
				$this->getPageControl($this->Home.'/Registar/VideoAdmin');
			break;
		}
		if(!empty($this->Request)) {
			switch($this->getRequestField('step')) {
				case 'Add': case 'Edit':
					$this->validateForm()
					and $this->Action->processEvent($this->SectionID,'save_video',$this->getRequestField('form'),$this)
					and header("Location: ".$this->Home.'/Registar/VideoAdmin'.$this->SID);
				break;
				case 'unlock':
	 					header("Location: ".$this->Home.'/Registar/VideoAdmin'.$this->SID);
				break;				
				case 'Delete':
					$this->validateForm()
					and $this->Action->processEvent($this->SectionID,'delete_video',$this->getRequestField('form'),$this)
					and header("Location: ".$this->Home.'/Registar/VideoAdmin'.$this->SID);
				break;
			}
		}
		$this->setSchemeTemplate($this->Scheme);
	}

	function saveFiles($array) { //printArray($array);exit;
		$path = $this->ImagePath.'/video/'.$array['id'];
		if($this->getRequestField('step')=='add' || !file_exists($path)) {
			umask(0002); mkdir($path,0775);
		}
		if(!empty($this->Request['form']['big'])) {
			$image = $this->Request['form']['big'];
			if(!empty($image['_tmp_name'])) {
				if(file_exists($path.'/big.jpg')) unlink($path.'/big.jpg');
				copy($image['_tmp_name'],$path.'/big.jpg');
				chmod($path.'/big.jpg',0664);
			}
		}
		
		if(!empty($this->Request['form']['video'])) {
			$video = $this->Request['form']['video'];
			if(!empty($video['_tmp_name'])) {
				if(file_exists($path.'/video.mp4')) unlink($path.'/video.mp4');
				copy($video['_tmp_name'],$path.'/video.mp4');
				chmod($path.'/big.jpg',0664);
			}
		}
		
	}
	
	function validateForm() {
		switch($this->getRequestField('step')) {
			case 'Add':
				if(!is_FullText(stripslashes($this->Request['form']['story_langs']['0']['title']),4,255)) $this->errors['title'] = 'The Video title you entered is not a valid string';
				$this->Request['form']['sort_order'] = (int)$this->Request['form']['sort_order'];
				if ( empty($this->Request['form']['url']) && empty($this->Request['video']))  $this->errors['video'] = 'Error uploading - no video is loaded';
				
				// big image			
				$image = $this->getRequestField('image');
				if(!empty($image['name'])) {
					if(!$image['size']) $this->errors['image'] = 'Error uploading - Preview Image is empty';
						else {
								$size = GetImageSize($image['tmp_name']);
								if($size['0'] > $this->upload_settings['big_width']) $this->errors['image'] = 'Error uploading - width of Preview Image is not valid';
									else if($size['1'] > $this->upload_settings['big_height']) $this->errors['image'] = 'Error uploading - height of Preview Image is not valid';
										  else if (!in_array($size['mime'], $this->upload_formats_check)) $this->errors['image'] = 'Error uploading - type of Preview Image is not valid';
												else {
													$this->Request['form']['big']['image_type'] = $this->upload_formats[$size['mime']];
													$this->Request['form']['big']['_tmp_name'] = $image['tmp_name'];
												}
						}
				} else $this->errors['image'] = 'Error uploading - Preview Image is empty';			
				
				// video			
				$video = $this->getRequestField('video');
				if(!empty($video['name'])) {
					if(!$video['size']) $this->errors['video'] = 'Error uploading - video is empty';
						else { //printArray($this->Request);exit;
								if (!in_array($this->Request['video']['type'], $this->upload_video_formats_check)) $this->errors['video'] = 'Error uploading - type of video is not valid';
									else {
										$this->Request['form']['video']['image_type'] = $this->upload_video_formats[ $this->Request['video']['type'] ];
										$this->Request['form']['video']['_tmp_name'] = $video['tmp_name'];
									}
						}
				}			
			break;			
			case 'Edit':
				if(!is_FullText(stripslashes($this->Request['form']['story_langs']['0']['title']),4,255)) $this->errors['title'] = 'The Video title you entered is not a valid string';
				$this->Request['form']['sort_order'] = (int)$this->Request['form']['sort_order'];
				// big image			
				$image = $this->getRequestField('image');
				if(!empty($image['name'])) {
					if(!$image['size']) $this->errors['image'] = 'Error uploading - image is empty';
						else {
								$size = GetImageSize($image['tmp_name']);
								if($size['0'] > $this->upload_settings['big_width']) $this->errors['image'] = 'Error uploading - width of image is not valid';
									else if($size['1'] > $this->upload_settings['big_height']) $this->errors['image'] = 'Error uploading - height of image is not valid';
										  else if (!in_array($size['mime'], $this->upload_formats_check)) $this->errors['image'] = 'Error uploading - type of image is not valid';
												else {
													$this->Request['form']['big']['image_type'] = $this->upload_formats[$size['mime']];
													$this->Request['form']['big']['_tmp_name'] = $image['tmp_name'];
												}
						}
				}			
				
				// video			
				$video = $this->getRequestField('video');
				if(!empty($video['name'])) {
					if(!$video['size']) $this->errors['video'] = 'Error uploading - video is empty';
						else { //printArray($this->Request);exit;
								if (!in_array($this->Request['video']['type'], $this->upload_video_formats_check)) $this->errors['video'] = 'Error uploading - type of video is not valid';
									else {
										$this->Request['form']['video']['image_type'] = $this->upload_video_formats[ $this->Request['video']['type'] ];
										$this->Request['form']['video']['_tmp_name'] = $video['tmp_name'];
									}
						}
				}			
			break;
		}
//printArray($this->errors);exit;		
		if(count($this->errors) > 0) return FALSE;
		return TRUE;
	}

	function fillElements() {
		switch($this->Scheme) {
			case 'default': $this->fillList(); break;
			case 'action': $this->fillAction(); break;
		}
	}

	
	function fillList() { 
			foreach($this->PreparedTemplates['curPage'] as $key => $value) {
				$date = new DateTime($value['date']); 
				$HeaderDate = $date->format('F j, Y'); 
				$this->TempFillEls['video'][] = array(
					//'picture' => makeImage($this->ImagePath.'/news/'.$value['id'].'.jpg',$this->ImageWPath.'/news/'.$value['id'].'.jpg','','left',array(5,5), 0, array(100,100)     ),
					'title' => $value['story_langs']['0']['title'],
					//'description' => $value['story_langs']['0']['short_text'],
					'id' => $value['id'],
					'date' => $HeaderDate,
					'sort_order' => $value['sort_order'],
				);
			}
	}

	function fillAction() {
		global $PHP_SELF;
		
		switch($this->LocalTarget[0]) {
			case 'Add': {
					$this->TempFillEls['reqfield'] = $this->reqfield;
					$this->TempFillEls['sub_action'] = 'Add';
					$this->TempFillEls['id'] = '';
					$this->TempFillEls['title'] = inputTextArea('form[story_langs][0][title]',(!empty($this->Request)? stripslashes($this->Request['form']['story_langs']['0']['title']) : ''),$this->correctSize('65'),2);
					//$this->TempFillEls['short_desc'] = inputTextArea('form[story_langs][0][short_text]',(!empty($this->Request)? stripslashes($this->Request['form']['story_langs']['0']['short_text']) : ''),$this->correctSize('65'),6);
					//$this->TempFillEls['full_desc'] = inputTextArea('form[story_langs][0][text]',(!empty($this->Request)? stripslashes($this->Request['form']['story_langs']['0']['text']) : ''),$this->correctSize('65'),18);
					$this->TempFillEls['sort_order'] = inputText('form[sort_order]',(!empty($this->Request)? stripslashes($this->Request['form']['sort_order']) : ''),$this->correctSize('10'));		
					$this->TempFillEls['full_desc_name'] = 'form[story_langs][0][text]';
					$this->TempFillEls['image'] = inputFile('image');
					$this->TempFillEls['video'] = inputFile('video');
					$this->TempFillEls['url'] = inputText('form[url]',(!empty($this->Request)? stripslashes($this->Request['form']['url']) : ''),$this->correctSize('65'));																																																		  //2010-12-17 13:56:31
					$this->TempFillEls['date'] =  inputText('form[date]',     !empty($this->Request['form']['date'])?    $this->Request['form']['date']  :   date ('Y-m-d')   , 19, '" style="width: 130px;" readonly', 19);
					$this->TempFillEls['image_buttons'] = array(array());
					if(!empty($this->PreparedTemplates)) {
						$this->TempFillEls['id'] = $this->PreparedTemplates['id'];
						$this->TempFillEls['title'] = inputTextArea('form[story_langs][0][title]',(!empty($this->Request)? stripslashes($this->Request['form']['story_langs']['0']['title']) : $this->PreparedTemplates['story_langs']['0']['title']),$this->correctSize('65'),2);
						//$this->TempFillEls['short_desc'] =inputTextArea('form[story_langs][0][short_text]',(!empty($this->Request)? stripslashes($this->Request['form']['story_langs']['0']['short_text']) : $this->PreparedTemplates['story_langs']['0']['short_text']),$this->correctSize('65'),6);
						//$this->TempFillEls['full_desc'] =inputTextArea('form[story_langs][0][text]',(!empty($this->Request)? stripslashes($this->Request['form']['story_langs']['0']['text']) : $this->PreparedTemplates['story_langs']['0']['text']),$this->correctSize('65'),18);
						$this->TempFillEls['sort_order'] =inputText('form[sort_order]',(!empty($this->Request)? stripslashes($this->Request['form']['sort_order']) : ucwords($this->PreparedTemplates['sort_order'])),$this->correctSize('10'));			
						//$this->TempFillEls['picture'] = makeImage($this->ImagePath.'/news/'.$this->PreparedTemplates['id'].'.jpg',$this->ImageWPath.'/news/'.$this->PreparedTemplates['id'].'.jpg');
						$this->TempFillEls['picture'] = makeImage($this->ImagePath.'/1.gif',$this->ImageWPath.'/1.gif','','',array(),0,'','bigimg');
						$this->TempFillEls['url'] = inputText('form[url]',(!empty($this->Request)? stripslashes($this->Request['form']['url']) : ucwords($this->PreparedTemplates['url'])),$this->correctSize('65'));			
						$this->TempFillEls['date'] =  inputText('form[date]',     !empty($this->PreparedTemplates['date'])?    $this->PreparedTemplates['date']  :   date ('Y-m-d')   , 19, '" style="width: 130px;" readonly', 19);
					}
					$number_image = !empty($this->Request['image_big']) && count($this->Request['image_big']['name']) > 1? count($this->Request['image_big']['name']) : 1;
					for($i = 1; $i <= $number_image; $i++) {
						$this->TempFillEls['images'][$i] = array(
							'num' => $i,
							'big_setting' => 'Jpg, '.$this->upload_settings['big_width'].'x'.$this->upload_settings['big_height'],
							//'middle_setting' => 'jpg, '.$this->upload_settings['middle_width'].'x'.$this->upload_settings['middle_height'],
						//'small_setting' => 'jpg, '.$this->upload_settings['small_width'].'x'.$this->upload_settings['small_height'],
							'big_image' => '&nbsp;',
							//'middle_image' => '&nbsp;',
						//'small_image' => '&nbsp;',
							'image_big_upload' => inputFile('image_big['.$i.']'),
							//'image_middle_upload' => inputFile('image_middle['.$i.']'),
						//'image_small_upload' => inputFile('image_small['.$i.']'),
							'image_big_error' => !empty($this->errors['image_big'][$i])? $this->printError($this->errors['image_big'][$i]) : '',
							//'image_middle_error' => !empty($this->errors['image_middle'][$i])? $this->printError($this->errors['image_middle'][$i]) : '',
						//'image_small_error' => !empty($this->errors['image_small'][$i])? $this->printError($this->errors['image_small'][$i]) : '',
							'delete_image' => array(array('num' => $i)),
						);
					}
			break;
			}
			case 'Edit': {
					$this->PreparedTemplates = $this->Action->getTemplate($this->SectionID,'open_video');
					$path = '/video/'.$this->PreparedTemplates['id'];
					$files = array('prew' => array(),'big' => array(),'image' => array(),'3d' => array(),'hi' => array(),'ss' => array(),'ug' => array(),'middle' => array());
					foreach($this->PreparedTemplates['files'] as $key => $value) {
						switch($value['filetype']) {
						//	case 1: $files['prew'] = array('image_link' => $value['image_link'],'name' => 'prew.'.$value['imagetype']); break;
							case 2: $files['big'] = array('image_link' => $value['image_link'],'name' => 'big.'.$value['imagetype']); break;
							case 3: $files['image'][$value['number']] = array('name' => date2pg($value['number']),'ext' => $value['imagetype']); break;
						//	case 8: $files['middle'] = array('image_link' => $value['image_link'],'name' => 'middle.'.$value['imagetype']); break;
						}
					}
					$this->TempFillEls['reqfield'] = $this->reqfield;
					$this->TempFillEls['sub_action'] = 'Update';
					$this->TempFillEls['id'] = '';
					$this->TempFillEls['title'] = inputTextArea('form[story_langs][0][title]',(!empty($this->Request)? stripslashes($this->Request['form']['story_langs']['0']['title']) : ''),$this->correctSize('65'),2);
					//$this->TempFillEls['short_desc'] = inputTextArea('form[story_langs][0][short_text]',(!empty($this->Request)? stripslashes($this->Request['form']['story_langs']['0']['short_text']) : ''),$this->correctSize('65'),6);
					//$this->TempFillEls['full_desc'] = inputTextArea('form[story_langs][0][text]',(!empty($this->Request)? stripslashes($this->Request['form']['story_langs']['0']['text']) : ''),$this->correctSize('65'),18);
					$this->TempFillEls['sort_order'] = inputText('form[sort_order]',(!empty($this->Request)? stripslashes($this->Request['form']['sort_order']) : ''),$this->correctSize('10'));		
					$this->TempFillEls['full_desc_name'] = 'form[story_langs][0][text]';
					$this->TempFillEls['image'] = inputFile('image');
					$this->TempFillEls['video'] = inputFile('video');
					$this->TempFillEls['url'] = inputText('form[url',(!empty($this->Request)? stripslashes($this->Request['form']['url']) : ''),$this->correctSize('65'));																																																		  //2010-12-17 13:56:31
					$this->TempFillEls['date'] =  inputText('form[date]',     !empty($this->Request['form']['date'])?    $this->Request['form']['date']  :   date ('Y-m-d')   , 19, '" style="width: 130px;" readonly', 19);
					$this->TempFillEls['image_buttons'] = array(array());
					if(!empty($this->PreparedTemplates)) {
						$this->TempFillEls['id'] = $this->PreparedTemplates['id'];
						$this->TempFillEls['title'] = inputTextArea('form[story_langs][0][title]',(!empty($this->Request)? stripslashes($this->Request['form']['story_langs']['0']['title']) : $this->PreparedTemplates['story_langs']['0']['title']),$this->correctSize('65'),2);
						//$this->TempFillEls['short_desc'] =inputTextArea('form[story_langs][0][short_text]',(!empty($this->Request)? stripslashes($this->Request['form']['story_langs']['0']['short_text']) : $this->PreparedTemplates['story_langs']['0']['short_text']),$this->correctSize('65'),6);
						//$this->TempFillEls['full_desc'] =inputTextArea('form[story_langs][0][text]',(!empty($this->Request)? stripslashes($this->Request['form']['story_langs']['0']['text']) : $this->PreparedTemplates['story_langs']['0']['text']),$this->correctSize('65'),18);
						$this->TempFillEls['sort_order'] =inputText('form[sort_order]',(!empty($this->Request)? stripslashes($this->Request['form']['sort_order']) : ucwords($this->PreparedTemplates['sort_order'])),$this->correctSize('10'));			
						$this->TempFillEls['picture'] = makeImage($this->ImagePath.$path.'/big.jpg',$this->ImageWPath.$path.'/big.jpg'.'?'.time());
						$this->TempFillEls['url'] = inputText('form[url]',(!empty($this->Request)? stripslashes($this->Request['form']['url']) : ucwords($this->PreparedTemplates['url'])),$this->correctSize('65'));			
						$this->TempFillEls['date'] =  inputText('form[date]',     !empty($this->PreparedTemplates['date'])?    $this->PreparedTemplates['date']  :   date ('Y-m-d')   , 19, '" style="width: 130px;" readonly', 19);
					}
					$number_image = !empty($this->Request['image_big']) && count($this->Request['image_big']['name']) > 1? count($this->Request['image_big']['name']) : (!empty($files['image']) && count($files['image']) > 1? count($files['image']) : 1);
					for($i = 1; $i <= $number_image; $i++) {
//print $this->ImagePath.$path.'/images/big/'.$files['image'][$i]['name'].'.jpg                        ';						
						$this->TempFillEls['images'][$i] = array(
							'num' => $i,
							'big_setting' => 'Jpg, '.$this->upload_settings['big_width'].'x'.$this->upload_settings['big_height'],
//							'middle_setting' => 'jpg, '.$this->upload_settings['middle_width'].'x'.$this->upload_settings['middle_height'],
	//					'small_setting' => 'jpg, '.$this->upload_settings['small_width'].'x'.$this->upload_settings['small_height'],
							'big_image' => !empty($files['image'][$i])? (file_exists($this->ImagePath.$path.'/images/big/'.$files['image'][$i]['name'].'.jpg')? makeImage($this->ImagePath.$path.'/images/big/'.$files['image'][$i]['name'].'.jpg', $this->ImageWPath.$path.'/images/big/'.$files['image'][$i]['name'].'.jpg'.'?'.time(),'','',array(),0, array('0' => '280', '1' => '100' ) ,'big_image'.$i.'img') : '&nbsp;') : '&nbsp;',
		//					'middle_image' => !empty($files['image'][$i])? (file_exists($this->ImagePath.$path.'/images/middle/'.$files['image'][$i]['name'].'.jpg')? makeImage($this->ImagePath.$path.'/images/middle/'.$files['image'][$i]['name'].'.jpg',$this->ImageWPath.$path.'/images/middle/'.$files['image'][$i]['name'].'.jpg'.'?'.time(),'','',array(),0, array('0' => '280', '1' => '100' ),'middle_image'.$i.'img') : '&nbsp;') : '&nbsp;',
			//			'small_image' => !empty($files['image'][$i])? (file_exists($this->ImagePath.$path.'/images/small/'.$files['image'][$i]['name'].'.jpg')? makeImage($this->ImagePath.$path.'/images/small/'.$files['image'][$i]['name'].'.jpg',$this->ImageWPath.$path.'/images/small/'.$files['image'][$i]['name'].'.jpg'.'?'.time(),'','',array(),0, array('0' => '140', '1' => '50' ),'small_image'.$i.'img') : '&nbsp;') : '&nbsp;',
							'image_big_upload' => inputFile('image_big['.$i.']'),
			//				'image_middle_upload' => inputFile('image_middle['.$i.']'),
				//		'image_small_upload' => inputFile('image_small['.$i.']'),
							'image_big_error' => !empty($this->errors['image_big'][$i])? $this->printError($this->errors['image_big'][$i]) : '',
			//				'image_middle_error' => !empty($this->errors['image_middle'][$i])? $this->printError($this->errors['image_middle'][$i]) : '',
			//			'image_small_error' => !empty($this->errors['image_small'][$i])? $this->printError($this->errors['image_small'][$i]) : '',
							'delete_image' => array(array('num' => $i)),
						);
					}
			break;
			}
			case 'Delete': {
					$this->PreparedTemplates = $this->Action->getTemplate($this->SectionID,'open_video');
					$path = '/video/'.$this->PreparedTemplates['id'];
					$files = array('prew' => array(),'big' => array(),'image' => array(),'3d' => array(),'hi' => array(),'ss' => array(),'ug' => array(),'middle' => array());
					foreach($this->PreparedTemplates['files'] as $key => $value) {
						switch($value['filetype']) {
							case 1: $files['prew'] = array('image_link' => $value['image_link'],'name' => 'prew.'.$value['imagetype']); break;
							case 2: $files['big'] = array('image_link' => $value['image_link'],'name' => 'big.'.$value['imagetype']); break;
							//case 3: $files['image'][$value['number']] = array('name' => date2pg($value['number']),'ext' => $value['imagetype']); break;
							//case 8: $files['middle'] = array('image_link' => $value['image_link'],'name' => 'middle.'.$value['imagetype']); break;
						}
					}
					$this->TempFillEls['reqfield'] = $this->reqfield;
					$this->TempFillEls['sub_action'] = 'Delete';
					$this->TempFillEls['id'] = '';
					$this->TempFillEls['title'] = inputTextArea('form[story_langs][0][title]',(!empty($this->Request)? stripslashes($this->Request['form']['story_langs']['0']['title']) : ''),$this->correctSize('65'),2);
					//$this->TempFillEls['short_desc'] = inputTextArea('form[story_langs][0][short_text]',(!empty($this->Request)? stripslashes($this->Request['form']['story_langs']['0']['short_text']) : ''),$this->correctSize('65'),6);
					//$this->TempFillEls['full_desc'] = inputTextArea('form[story_langs][0][text]',(!empty($this->Request)? stripslashes($this->Request['form']['story_langs']['0']['text']) : ''),$this->correctSize('65'),18);
					$this->TempFillEls['sort_order'] = inputText('form[sort_order]',(!empty($this->Request)? stripslashes($this->Request['form']['sort_order']) : ''),$this->correctSize('10'));		
					$this->TempFillEls['full_desc_name'] = 'form[story_langs][0][text]';
					$this->TempFillEls['image'] = '---';
					$this->TempFillEls['video'] = '---';
					$this->TempFillEls['url'] = inputText('form[url]',(!empty($this->Request)? stripslashes($this->Request['form']['url']) : ''),$this->correctSize('65'));																																																		  //2010-12-17 13:56:31
					$this->TempFillEls['date'] =  inputText('form[date]',     !empty($this->Request['form']['date'])?    $this->Request['form']['date']  :   date ('Y-m-d')   , 19, '" style="width: 130px;" readonly', 19);
					$this->TempFillEls['image_buttons'] = array();
					if(!empty($this->PreparedTemplates)) {
						$this->TempFillEls['id'] = $this->PreparedTemplates['id'];
						$this->TempFillEls['title'] = $this->PreparedTemplates['story_langs']['0']['title'];
						//$this->TempFillEls['short_desc'] = $this->PreparedTemplates['story_langs']['0']['short_text'];
						//$this->TempFillEls['full_desc'] = $this->PreparedTemplates['story_langs']['0']['text'];
						$this->TempFillEls['sort_order'] = ucwords($this->PreparedTemplates['sort_order']);			
						$this->TempFillEls['picture'] = makeImage($this->ImagePath.$path.'/big.jpg',$this->ImageWPath.$path.'/big.jpg'.'?'.time());
						$this->TempFillEls['url'] = ucwords($this->PreparedTemplates['url']);			
						$this->TempFillEls['date'] =  inputText('form[date]',     !empty($this->PreparedTemplates['date'])?    $this->PreparedTemplates['date']  :   date ('Y-m-d')   , 19, '" style="width: 130px;" readonly', 19);
					}
					$number_image = !empty($files['image']) && count($files['image']) > 1? count($files['image']) : 1;
					for($i = 1; $i <= $number_image; $i++) {
						$this->TempFillEls['images'][$i] = array(
							'num' => $i,
							'big_setting' => 'Jpg, '.$this->upload_settings['big_width'].'x'.$this->upload_settings['big_height'],
//							'middle_setting' => 'jpg, '.$this->upload_settings['middle_width'].'x'.$this->upload_settings['middle_height'],
	//					'small_setting' => 'jpg, '.$this->upload_settings['small_width'].'x'.$this->upload_settings['small_height'],
							'big_image' => !empty($files['image'][$i][1])? (file_exists($this->ImagePath.$path.'/images/big/'.$files['image'][$i]['name'].'.jpg')? makeImage($this->ImagePath.$path.'/images/big/'.$files['image'][$i]['name'].'.jpg',$this->ImageWPath.$path.'/images/big/'.$files['image'][$i]['name'].'.jpg'.'?'.time(),'','',array(),0,'','big_image'.$i.'img') : ' --- Empty --- ') : ' --- Empty --- ',
							//'middle_image' => !empty($files['image'][$i][2])? (file_exists($this->ImagePath.$path.'/images/middle/'.$files['image'][$i]['name'].'.png')? makeImage($this->ImagePath.$path.'/images/middle/'.$files['image'][$i]['name'].'.png',$this->ImageWPath.$path.'/images/middle/'.$files['image'][$i]['name'].'.png'.'?'.time(),'','',array(),0,'','middle_image'.$i.'img') : ' --- Empty --- ') : ' --- Empty --- ',
							//'big_image' => !empty($files['image'][$i][1])? (file_exists($this->ImagePath.$path.'/images/big/'.$files['image'][$i]['name'].'.jpg')? makeImage($this->ImagePath.$path.'/images/big/'.$files['image'][$i]['name'].'.jpg',$this->ImageWPath.$path.'/images/big/'.$files['image'][$i]['name'].'.jpg'.'?'.time(),'','',array(),0, array('0' => '280', '1' => '100' ),'big_image'.$i.'img') : ' --- Empty --- ') : ' --- Empty --- ',
		//					'middle_image' => !empty($files['image'][$i][2])? (file_exists($this->ImagePath.$path.'/images/middle/'.$files['image'][$i]['name'].'.jpg')? makeImage($this->ImagePath.$path.'/images/middle/'.$files['image'][$i]['name'].'.jpg',$this->ImageWPath.$path.'/images/middle/'.$files['image'][$i]['name'].'.jpg'.'?'.time(),'','',array(),0, array('0' => '280', '1' => '100' ),'middle_image'.$i.'img') : ' --- Empty --- ') : ' --- Empty --- ',
			//			'small_image' => !empty($files['image'][$i][2])? (file_exists($this->ImagePath.$path.'/images/small/'.$files['image'][$i]['name'].'.jpg')? makeImage($this->ImagePath.$path.'/images/small/'.$files['image'][$i]['name'].'.jpg',$this->ImageWPath.$path.'/images/small/'.$files['image'][$i]['name'].'.jpg'.'?'.time(),'','',array(),0, array('0' => '140', '1' => '50' ),'small_image'.$i.'img') : ' --- Empty --- ') : ' --- Empty --- ',
						);
					}
			break;
			}
		}
		$this->TempFillEls['new_param_id_image'] = $number_image;
		$this->TempFillEls['action'] = $this->LocalTarget[0];
		$this->PreparedTemplates = $this->Action->getTemplate($this->SectionID,'save_video');
		!empty($this->PreparedTemplates['_error']) and $this->errors['model'] = $this->globalLangContent['error_model'][$this->PreparedTemplates['_error']];
		if(count($this->errors) > 0) $this->errors['header'] = 'There were some errors.<br>Please see below for details.';
		foreach($this->errors as $k => $v) $this->TempFillEls[$k.'_error'] = $k=='header'? '<strong>'.$v.'</strong><p>' : $this->printError($v);
		$this->PreparedTemplates = $this->Action->clearTemplate($this->SectionID,'save_video');
		
	}

	
	
	
}
?>