Файл: adultscript-2.0.3-pro/files/templates/defboot/photo_edit.tpl.php
Строк: 127
<?php defined('_VALID') or die('Restricted Access!'); ?>
<div id="content" class="row">
<div class="col-xs-12 col-sm-12 col-md-10">
<div class="well well-small">
<h1><?php echo __('edit-album'); ?></h1>
<form id="edit-form" class="form-horizontal" role="form" method="post" action="<?php echo REL_URL; ?>/photo/edit/<?php echo $this->album['album_id']; ?>/">
<input name="submit-edit" type="hidden" value="<?php echo time(); ?>">
<div id="title-group" class="form-group">
<label for="title" class="col-sm-2 control-label"><?php echo __('title'); ?></label>
<div class="col-sm-10">
<input name="title" type="text" class="form-control" id="title" value="<?php echo e($this->album['title']); ?>">
<span id="title-error" class="help-block text-danger"></span>
</div>
</div>
<div id="description-group" class="form-group">
<label for="description" class="col-sm-2 control-label"><?php echo __('description'); ?></label>
<div class="col-sm-10">
<textarea name="description" class="form-control" id="description"><?php echo e($this->album['description']); ?></textarea>
</div>
</div>
<div id="categories-group" class="form-group">
<label for="categories" class="col-sm-2 control-label"><?php echo __('categories'); ?></label>
<div class="col-sm-10">
<?php foreach ($this->categories as $category): ?>
<div class="col-xs-6 col-sm-4 col-md-3 col-lg-2">
<input id="category-<?php echo $category['cat_id']; ?>" name="category[]" type="checkbox" value="<?php echo $category['cat_id']; ?>"<?php if (in_array($category['cat_id'], $this->album['category'])): echo ' checked="checked"'; endif; echo '> ',e($category['name']); ?>
</div>
<?php endforeach; ?>
<div class="clearfix"></div>
<span id="categories-error" class="help-block text-danger"></span>
</div>
</div>
<div id="tags-group" class="form-group">
<label for="tags" class="col-sm-2 control-label"><?php echo __('tags'); ?></label>
<div class="col-sm-10">
<textarea name="tags" class="form-control" id="tags"><?php echo e($this->album['tags']); ?></textarea>
<span id="tags-error" class="help-block text-danger"></span>
</div>
</div>
<div class="form-group">
<label for="type" class="col-sm-2 control-label"><?php echo __('type'); ?></label>
<div class="radio-inline"><input name="type" type="radio" id="type_public" value="public"<?php if ($this->album['type'] == 'public'): echo ' checked="checked"'; endif; echo '> ',__('public'); ?></div>
<div class="radio-inline"><input name="type" type="radio" id="type_private" value="private"<?php if ($this->album['type'] == 'private'): echo ' checked="checked"'; endif; echo '> ',__('private'); ?></div>
</div>
<?php if (VCfg::get('photo.allow_password')): ?>
<div id="password-group" class="form-group">
<label for="password" class="col-sm-2 control-label"><?php echo __('password'); ?></label>
<div class="col-sm-8">
<input name="password" type="text" class="form-control" id="password" value="">
<span class="help-block"><?php if ($this->album['password'] != ''): echo __('album-edit-passworded'); endif; echo __('album-edit-password'); ?></span>
</div>
</div>
<?php endif; ?>
<div class="form-group">
<input name="cover_id" type="hidden" value="<?php echo $this->album['cover']; ?>" />
<label for="cover" class="col-sm-2 control-label"><?php echo __('album-cover'); ?></label>
<div class="col-sm-10">
<span class="help-block"><?php echo __('edit-cover-help'); ?></span>
<ul class="photos">
<?php foreach ($this->photos as $photo): ?>
<li>
<div class="photo">
<img src="<?php echo PHOTO_URL,'/thumbs/',$photo['photo_id']; ?>.jpg" alt="<?php echo e($photo['caption']); ?>" id="photo-<?php echo $photo['photo_id']; ?>" class="img-thumbnail <?php if ($photo['photo_id'] == $this->album['cover']): echo 'bg-primary'; endif;?>" />
</div>
</li>
<?php endforeach; ?>
</ul>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="button" id="edit-button" class="btn btn-default"><?php echo __('edit-button'); ?></button>
</div>
</div>
</form>
<script type="text/javascript">
$(document).ready(function() {
$("div.photo img").click(function(e) {
e.preventDefault();
$("div.photo img").removeClass('bg-primary');
$(this).addClass('bg-primary');
$("input[name='cover_id']").val($(this).attr('id').match(/photo-(.*)/)[1]);
});
});
$("button[id='edit-button']").click(function() {
var error = false;
var title = $("input[name='title']").val();
if (title == '') {
$("#title-group").removeClass('has-success').addClass('has-error');
$("#title-error").html('<?php echo __('title-empty'); ?>');
error = true;
} else if (title.length < <?php echo VCfg::get('photo.title_min_length'); ?> || title.length > <?php echo VCfg::get('photo.title_max_length'); ?>) {
$("#title-group").removeClass('has-success').addClass('has-error');
$("#title-error").html('<?php echo __('title-length', array(VCfg::get('photo.title_min_length'), VCfg::get('photo.title_max_length'))); ?>');
error = true;
} else {
$("#title-group").removeClass('has-error').addClass('has-success');
$("#title-error").html('');
}
var checked = $(":checkbox:checked").length;
if (checked == 0 || checked > <?php echo VCfg::get('photo.max_categories'); ?>) {
$("#categories-group").removeClass('has-success').addClass('has-error');
$("#categories-error").html('<?php echo __('category-empty', array(VCfg::get('photo.max_categories'))); ?>');
error = true;
} else {
$("#categories-group").removeClass('has-error').addClass('has-success');
$("#categories-error").html('');
}
var tags = $("textarea[name='tags']").val();
if (tags == '') {
$("#tags-group").removeClass('has-success').addClass('has-error');
$("#tags-error").html('<?php echo __('tags-empty'); ?>');
error = true;
} else if (tags.length < <?php echo VCfg::get('photo.tags_min_length'); ?>) {
$("#tags-group").removeClass('has-success').addClass('has-error');
$("#tags-error").html('<?php echo __('tags-length', array(VCfg::get('photo.tags_min_length'), VCfg::get('photo.tags_max_length'))); ?>');
error = true;
} else if (tags.length > <?php echo VCfg::get('photo.tags_max_length'); ?>) {
$("#tags-group").removeClass('has-success').addClass('has-error');
$("#tags-error").html('<?php echo __('tags-length', array(VCfg::get('photo.tags_min_length'), VCfg::get('photo.tags_max_length'))); ?>');
error = true;
} else {
$("#tags-error").html('');
var tag_max_length_error = '<?php echo __('tag-length', array('#TAG#', VCfg::get('photo.tag_max_length'))); ?>';
var tag_max_words_error = '<?php echo __('tag-words', array('#TAG#', VCfg::get('photo.tag_max_words'))); ?>';
var tags_error = false;
var arr = tags.split(',');
jQuery.each(arr, function() {
if (this.length > <?php echo VCfg::get('photo.tag_max_length'); ?>) {
$("#tags-group").removeClass('has-success').addClass('has-error');
$("#tags-error").append(tag_max_length_error.replace('#TAG#', '"' + this + '"') + '<br>');
error = true;
tags_error = true;
} else if (this.split(' ').length > <?php echo VCfg::get('photo.tag_max_words'); ?>) {
$("#tags-group").removeClass('has-success').addClass('has-error');
$("#tags-error").append(tag_max_words_error.replace('#TAG#', '"' + this + '"') + '<br>');
error = true;
tags_error = true;
}
});
if (!tags_error) {
$("#tags-group").removeClass('has-error').addClass('has-success');
$("#tags-error").html('');
}
}
if (error) {
return false;
}
$("#edit-form").submit();
});
</script>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-2">
<div class="well well-small">
</div>
</div>
</div>