tpl_4ef0a6fb_form__ptHLwoxWkRiy9cfnoKv2kg.php 6.16 KB
<?php 
function tpl_4ef0a6fb_form__ptHLwoxWkRiy9cfnoKv2kg($tpl, $ctx) {
$_thistpl = $tpl ;
$_translator = $tpl->getTranslator() ;
?>
<link rel="stylesheet" href="<?php echo phptal_escape($ctx->MAIN_SOURCE_URL) ?>/tmpl/css/admin.css" type="text/css"/>
	<link rel="stylesheet" href="<?php echo phptal_escape($ctx->MAIN_SOURCE_URL) ?>/tmpl/css/default.css" type="text/css"/>
	<link rel="stylesheet" type="text/css" href="<?php echo phptal_escape($ctx->MAIN_SOURCE_URL) ?>/ext/fc_cropresizer/fc-cropresizer.css"/>
	<script src="<?php echo phptal_escape($ctx->MAIN_SOURCE_URL) ?>/tmpl/default/js/default.js"></script>
	<script src="<?php echo phptal_escape($ctx->MAIN_SOURCE_URL) ?>/ext/ajax/JsHttpRequest.js"></script>
	<script src="<?php echo phptal_escape($ctx->MAIN_SOURCE_URL) ?>/tmpl/default/js/upload.js"></script>
	<script type="text/javascript" src="<?php echo phptal_escape($ctx->MAIN_SOURCE_URL) ?>/ext/fc_cropresizer/fc-cropresizer.js"></script>

<div style="padding:10px">
	<div style="color:red;font-size:12px;text-align:center;" id="ua_error"></div>
	
	<form id="form1" enctype="multipart/form-data" onsubmit="return false" method="post">
	<input type="file" name="ua_file" id="ua_file" style="margin:0px;padding:0px;height:20px;"/>
	<input type="hidden" name="path" value="<?php echo phptal_escape($ctx->path) ?>"/>
	<input type="hidden" name="max_size" value="<?php echo phptal_escape($ctx->max_size) ?>"/>
	<input type="hidden" name="max_width" value="<?php echo phptal_escape($ctx->max_width) ?>"/>
	<input type="hidden" name="max_height" value="<?php echo phptal_escape($ctx->max_height) ?>"/>
	<div style="text-align:left;color:#808080;font-size:10px;">
		Нажав на кнопку "<b>Обзор</b>", выберите на своём компьютере изображение  размером не более 
		<b><?php echo phptal_escape($ctx->max_size_str) ?></b> в формате <b>JPG</b>,<b>GIF</b> или <b>PNG</b> для загрузки его на сайт.
	</div>
	<br/>
	<div style="color:#808080;font-size:10px;text-align:center;display:none" id="ua_status">
		<b>Подождите, идёт загрузка изображения на сайт...</b>
		<div><img src="/source/tmpl/default/img/ajax-loader.gif" style="margin:5px;"/></div>
	</div>

	<div style="text-align:right"><input type="button" id="ua_button" onclick="upload_ajax.send()" value="Загрузить" class="button_rp"/></div>
	
	</form>
</div>


<div style="display:none;padding:30px;" id="crop_form">
	
	
		<img src="?resize=2&amp;width=300&amp;height=300" id="photo1" style="
			
			
				border:1px solid black;
				
			"/> 
	<br/>
	
	
	<form class="reg_profile" method="POST" action="/?p_name=ajax_upload_img&amp;act=crop" target="_self" enctype="multipart/form-data">
		<input type="hidden" name="act" value="crop"/>
		<input type="hidden" name="image_width" id="image_width"/>
		<input type="hidden" name="image_height" id="image_height"/>
		<input type="hidden" name="image_top" id="image_top"/>
		<input type="hidden" name="image_left" id="image_left"/>
	
	
		<div style="float:left;">
		<input type="button" value="Сохранить" onclick="upload_ajax.crop()"/>
		</div>
		<div style="text-align:right">
		<input type="button" value="Удалить" onclick="upload_ajax.del()"/>
		</div>
	
	</form>
</div>
	
<script>/*<![CDATA[*/



	//	передаем из адресной строки в js скрипт
upload_ajax = {};
upload_ajax.crop_x = <?php echo strtr(phptal_tostring($ctx->crop_image_width) ,array(']]>'=>']]]]><![CDATA[>','</'=>'<\/')) ?>;
upload_ajax.crop_y = <?php echo strtr(phptal_tostring($ctx->crop_image_height) ,array(']]>'=>']]]]><![CDATA[>','</'=>'<\/')) ?>;
upload_ajax.path = '<?php echo strtr(phptal_tostring($ctx->path) ,array(']]>'=>']]]]><![CDATA[>','</'=>'<\/')) ?>';
upload_ajax.max_size = <?php echo strtr(phptal_tostring($ctx->max_size) ,array(']]>'=>']]]]><![CDATA[>','</'=>'<\/')) ?>;
upload_ajax.server = '/?p_name=admin_images';



	//	загрузка изображения на сервер
upload_ajax.send = function(){
	r = new request(  upload_ajax.server+'&act=ajax_upload' );
		//	возвращаем результат
	r.onload = function(rst){
		if ( !upload_ajax.crop_x && !upload_ajax.crop_y ){
			opener.upload_img_class.set_file(rst.img_name)	
			opener.upload_img_class.show();
			window.close();
			return false;
		}
		upload_ajax.img_name = rst.img_name;
		upload_ajax.img_id = rst.img_id;
	
		o.$('crop_form').style.display='block'
		o.$('photo1').src='/media/'+upload_ajax.path+'/'+rst.img_name+'?resize=2&width=800&height=600';
	
		
		o.$('photo1').onload = function(){
		
			cropresizer.getObject("photo1").init({
					cropWidth : upload_ajax.crop_x ,
					cropHeight : upload_ajax.crop_y,
					onUpdate : function() {
						this.stopSelection = false;
						document.getElementById("image_width").value= this.iWidth;
						document.getElementById("image_height").value= this.iHeight
						document.getElementById("image_top").value= this.cropTop - this.iTop;
						document.getElementById("image_left").value= this.cropLeft - this.iLeft
					}
			},1);
		}
	
	}
	r.error = function(e){
		o.$('ua_error').innerHTML =e; 
	}
	r.form( o.$('form1') );
	
}


upload_ajax.crop = function(){
	r = new request(  upload_ajax.server+'&act=ajax_crop' );
	r.onload = function(rst){ 
			opener.upload_img_class.set_file(rst.img_src)	
			opener.upload_img_class.show();
			window.close();
			return false;
	};
	
	r.send( 
			{
				'img_id': upload_ajax.img_id ,
				'w' : document.getElementById("image_width").value,
				'h' : document.getElementById("image_height").value,
				't' : document.getElementById("image_top").value,
				'l' : document.getElementById("image_left").value,
				'crop_w':upload_ajax.crop_x,
				'crop_h':upload_ajax.crop_y,
			} 
	)
	
}


upload_ajax.del = function(){
	r = new request(  upload_ajax.server+'&act=ajax_delete' );
	r.onload = function(rst){ 
			window.close();
			//alert('файл удалён')
			//return false;
	};
	
	r.send( {'id': upload_ajax.img_id } )
	
}



/*]]>*/</script><?php 
/* end */ ;

}

?><?php /* 
*** DO NOT EDIT THIS FILE ***

Generated by PHPTAL from /home/shasha/www/pr25_autocatalog/source/modules/admin/tmpl/control_images/form.html (edit that file instead) */; ?>