View file blog/templates/blog/new.html

File size: 7.01Kb
<script src="<?php echo pxp_acp_link('plugins/tinymce/tinymce.min.js'); ?>"></script>

<div class="page-margin verf-active">
	<form class="form pg_page padd pp_store_upload pp_create_blog" method="POST" id="upload_store_image">
		<h2 class="pg_in_page_title"><?php echo $context['category_name'];?></h2>
		<div class="row">
			<div class="col-lg-1"></div>
			<div class="col-lg-10">
				<div class="pg_mat_input">
					<input type="text" name="title" value="" id="title" required="true" placeholder="{{LANG title}}">
					<label for="title">{{LANG title}}</label>
				</div>
				<div class="pg_mat_input">
					<textarea name="description" rows="4" placeholder="{{LANG description}}"></textarea>
					<label for="description">{{LANG description}}</label>
				</div>
				<div class="fak_image" onclick="document.getElementById('user-photo').click(); return false">
					<div class="upload_fk_image">
						<svg id="Capa_1" enable-background="new 0 0 512 512" height="512" viewBox="0 0 512 512" width="512" xmlns="http://www.w3.org/2000/svg"><g><g><path d="m256 512c-64.349 0-129.788-2.237-194.5-6.649l-7.639-.521c-10.546-.719-19.053-8.906-20.176-19.416l-.814-7.614c-9.706-90.844-9.706-182.967 0-273.81l.814-7.614c1.123-10.51 9.63-18.697 20.176-19.416l7.639-.521c64.72-4.412 130.159-6.649 194.5-6.649 64.342 0 129.781 2.237 194.5 6.649l7.639.521c10.546.719 19.053 8.906 20.176 19.416l.814 7.613c9.707 90.844 9.707 182.967 0 273.811l-.814 7.613c-1.123 10.51-9.63 18.697-20.176 19.416l-7.639.521c-64.712 4.413-130.15 6.65-194.5 6.65z" fill="#dfeaef"/><path d="m448.402 474.512c-64.074 4.382-128.599 6.582-192.41 6.582-63.792 0-128.318-2.2-192.392-6.582-2.915-27.288-4.946-54.652-6.075-82.035-2.52-61.761-.508-123.654 6.075-185.208 64.074-4.363 128.599-6.582 192.392-6.582 26.536 0 53.185.376 79.872 1.147 37.519 1.072 75.095 2.877 112.539 5.435 2.313 21.628 4.062 43.312 5.228 64.996 1.091 19.521 1.693 39.043 1.862 58.564.376 47.957-1.994 95.914-7.091 143.683z" fill="#6bbef6"/><path d="m452.803 423.546c-1.129 17.001-2.595 34.003-4.401 50.966-64.074 4.382-128.599 6.582-192.41 6.582-63.792 0-128.318-2.2-192.392-6.582-1.034-9.667-1.956-19.333-2.746-29-1.486-17.659-2.595-35.338-3.329-53.035h.019c61.761 0 112.426-106.784 181.841-76.75 69.415 30.015 112.05 86.36 216.069 15.026l.038.075c.245 30.919-.658 61.838-2.689 92.718z" fill="#86f1a7"/><path d="m452.803 423.546c-1.129 17.001-2.595 34.003-4.401 50.966-64.074 4.382-128.599 6.582-192.41 6.582-63.792 0-128.318-2.2-192.392-6.582-1.034-9.667-1.956-19.333-2.746-29 .001 0 205.726-21.966 391.949-21.966z" fill="#66b49d"/><g><circle cx="360.366" cy="273.394" fill="#f4dd45" r="45.22"/></g></g><path d="m337.231 96.515-68.095-92.032c-4.423-5.978-13.366-5.978-17.789 0l-68.095 92.032c-5.403 7.303-.19 17.645 8.894 17.645h14.251c6.111 0 11.064 4.954 11.064 11.064v92.383c0 6.111 4.954 11.064 11.064 11.064h63.432c6.111 0 11.064-4.954 11.064-11.064v-92.383c0-6.111 4.954-11.064 11.064-11.064h14.251c9.085.001 14.298-10.342 8.895-17.645z" fill="#617881"/></g></svg>
						<p>{{LANG upload_file}}</p>
					</div>
					<div id="user_image"></div>
				</div>
				<div class="pg_mat_input">
					<select name="category" id="category">
						<option value="" selected disabled>{{LANG category}}</option>
						<?php
							$store_categories = blog_categories();
							foreach ($store_categories as $key => $category) {
								echo '<option value="'.$key.'">'.$category.'</option>';
							}
						?>
					</select>
				</div>
				<div class="pg_mat_input">
					<textarea id="content" name="content" rows="8" placeholder="{{LANG create_article_html}}"></textarea>
				</div>
				<div class="pg_mat_input">
					<textarea name="tags" rows="1" placeholder="{{LANG tags}}"></textarea>
					<label for="tags">{{LANG tags}}</label>
				</div>
				<div class="pg_page_footer">
					<button class="btn btn-large btn-main btn-mat btn-mat-raised" type="submit"><span>{{LANG save}}</span></button>
				</div>
				<input type="hidden" name="user_id" value="<?php echo($context['me']['user_id']) ?>">
				<input type="hidden" name="hash" value="<?php echo($context['csrf_token']) ?>">
				<input type="file" name="thumbnail" class="hidden" id="user-photo" accept="image/x-png,image/jpg,image/jpeg">
			</div>
			<div class="col-lg-1"></div>
		</div>
	</form>
</div>

<script>
    $(function() {
        tinymce.init({
                selector: '#content',
                height: 270,
                entity_encoding : "raw",
                paste_data_images: true,
                image_advtab: true,
                plugins: [
                    "advlist autolink lists link image charmap print preview hr anchor pagebreak",
                    "searchreplace wordcount visualblocks visualchars code fullscreen",
                    "insertdatetime media nonbreaking save table contextmenu directionality",
                    "template paste textcolor colorpicker textpattern"
                ],
            });
    });
    jQuery(document).ready(function($) {


        $("#user-photo").change(function(event) {
            $("#user_image").html("<img src='" + window.URL.createObjectURL(this.files[0]) + "' alt='Picture' width='100%'>")
        });

        var form_add_settings = $('form#upload_store_image');
        form_add_settings.ajaxForm({
            url: '<?php echo($config["site_url"]); ?>/aj/admin/add_new_blog_article',
            type: 'POST',
            dataType: 'json',
            beforeSend: function() {
                form_add_settings.find('.btn-primary').text('Please wait..');
            },
            beforeSubmit : function(arr, $form, options){
                //arr.splice(0, 1);
                tinymce.get("content").setContent(tinymce.activeEditor.getContent());
                document.getElementById("content").value=tinymce.activeEditor.getContent();
                arr.push({name:'content', value:btoa(unescape(encodeURIComponent($('#content').val())))});
                arr.push({name:'category', value:$('#category').val()})
            },
            success: function(data) {
                $("html, body").animate({ scrollTop: 0 }, "slow");
                $.toast(data.message,{
                    duration: 5000,
                    type: 'success',
                    align: 'bottom',
                    singleton: true
                });
                form_add_settings.find('button[type="submit"]').removeAttr('disabled');
                if (data.status == 200) {
                    setTimeout(function () {
                        window.location = '{{CONFIG site_url}}/blog';
                    },3000);
                }
                else if (data.status == 400) {
                    alert(data.message);
					$.toast(data.message,{
                        duration: 5000,
                        type: 'error',
                        align: 'bottom',
                        singleton: true
                    });
                }
                form_add_settings.find('.btn-primary').text('{{LANG save}}');
            }
        });

    });
</script>