Fix photos
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<!-- Хлебные крошки /-->
|
<!-- Хлебные крошки /-->
|
||||||
<ul class="breadcrumb">
|
<ul class="breadcrumb">
|
||||||
<li><a href="/">Главная</a></li>
|
<li><a href="/">Главная</a></li>
|
||||||
<li><a href="/repairs/">Акции</a></li>
|
<li><a href="/repairs/">Автосервис</a></li>
|
||||||
<li>{$post->name|escape}</li>
|
<li>{$post->name|escape}</li>
|
||||||
</ul>
|
</ul>
|
||||||
<!-- Хлебные крошки #End /-->
|
<!-- Хлебные крошки #End /-->
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ create table s_repair_photo
|
|||||||
(
|
(
|
||||||
id int auto_increment
|
id int auto_increment
|
||||||
primary key,
|
primary key,
|
||||||
action_id int default 0 not null,
|
repair_id int default 0 not null,
|
||||||
img varchar(100) default '' not null,
|
img varchar(100) default '' not null,
|
||||||
position int default 0 not null
|
position int default 0 not null
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class RepairsPostAdmin extends Simpla
|
|||||||
|
|
||||||
$this->design->assign('post', $post);
|
$this->design->assign('post', $post);
|
||||||
|
|
||||||
$this->db->query("SELECT * FROM __repairs_photo WHERE repair_id='" . $post->id . "' ORDER BY position, id DESC");
|
$this->db->query("SELECT * FROM __repair_photo WHERE repair_id='" . $post->id . "' ORDER BY position, id DESC");
|
||||||
$photos = $this->db->results();
|
$photos = $this->db->results();
|
||||||
foreach($photos as $ph) $ph->img = Img::get('files/post/' . $ph->img, array('width'=>120, 'height'=>120));
|
foreach($photos as $ph) $ph->img = Img::get('files/post/' . $ph->img, array('width'=>120, 'height'=>120));
|
||||||
$this->design->assign('repair_photos', $photos);
|
$this->design->assign('repair_photos', $photos);
|
||||||
|
|||||||
38
simpla/ajax/file_repair.php
Normal file
38
simpla/ajax/file_repair.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
chdir('../..');
|
||||||
|
require_once('api/Simpla.php');
|
||||||
|
$simpla = new Simpla();
|
||||||
|
|
||||||
|
|
||||||
|
if(isset($_POST['action']) && $_POST['action'] == 'remove'){
|
||||||
|
$simpla->db->query("DELETE FROM __repair_photo WHERE id=" . (int)$_POST['id']);
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_POST['action']) && $_POST['action'] == 'reorder'){
|
||||||
|
foreach($_POST['ids'] as $pos => $id){
|
||||||
|
$simpla->db->query("UPDATE __repair_photo SET position='$pos' WHERE id='" . (int)$id ."' " );
|
||||||
|
}
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$ext = mb_strtolower(substr(strrchr($_FILES['file']['name'], '.'), 1), 'UTF-8');
|
||||||
|
$name = $_POST['article_id'] . '_' . md5( uniqid( $_POST['article_id'] . rand(1, 10000), true) ) . '.' . $ext;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
move_uploaded_file($_FILES['file']['tmp_name'], $_SERVER['DOCUMENT_ROOT'] . '/files/post/' . $name);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$simpla->db->query("INSERT INTO __repair_photo SET repair_id='" . (int)$_POST['article_id'] ."', img='$name', position=999 " );
|
||||||
|
|
||||||
|
echo $simpla->db->insert_id();
|
||||||
|
|
||||||
|
//print_r($_POST); print_r($_FILES);
|
||||||
|
//echo 3;
|
||||||
|
|
||||||
|
//echo json_encode(array('id'=>44, 'img'=>'test'));
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
$(function(){
|
$(function(){
|
||||||
var sxFile = new sxFormFile();
|
var sxFile = new sxFormFile();
|
||||||
{/literal}
|
{/literal}
|
||||||
sxFile.init({$post->id}, '/simpla/ajax/file_action.php');
|
sxFile.init({$post->id}, '/simpla/ajax/file_repair.php');
|
||||||
{literal}
|
{literal}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ function translit(str)
|
|||||||
<!-- Системное сообщение -->
|
<!-- Системное сообщение -->
|
||||||
<div class="message message_success">
|
<div class="message message_success">
|
||||||
<span>{if $message_success == 'added'}Запись добавлена{elseif $message_success == 'updated'}Запись обновлена{/if}</span>
|
<span>{if $message_success == 'added'}Запись добавлена{elseif $message_success == 'updated'}Запись обновлена{/if}</span>
|
||||||
<a class="link" target="_blank" href="../blog/{$post->url}">Открыть запись на сайте</a>
|
<a class="link" target="_blank" href="../repairs/{$post->url}">Открыть запись на сайте</a>
|
||||||
{if $smarty.get.return}
|
{if $smarty.get.return}
|
||||||
<a class="button" href="{$smarty.get.return}">Вернуться</a>
|
<a class="button" href="{$smarty.get.return}">Вернуться</a>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user