admin for Repairs Section
This commit is contained in:
256
api/Repairs.php
Normal file
256
api/Repairs.php
Normal file
@@ -0,0 +1,256 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Simpla CMS
|
||||
*
|
||||
* @copyright 2011 Denis Pikusov
|
||||
* @link http://simplacms.ru
|
||||
* @author Denis Pikusov
|
||||
*
|
||||
* @editor 2014 Vitaly Raevsky
|
||||
* @link http://bwdesign.ru
|
||||
* @email vitaly.raevsky@gmail.com
|
||||
*
|
||||
*/
|
||||
|
||||
require_once('Simpla.php');
|
||||
|
||||
class Repairs extends Simpla
|
||||
{
|
||||
|
||||
/*
|
||||
*
|
||||
* Функция возвращает пост по его id или url
|
||||
* (в зависимости от типа аргумента, int - id, string - url)
|
||||
* @param $id id или url поста
|
||||
*
|
||||
*/
|
||||
public function get_post($id)
|
||||
{
|
||||
if(is_int($id))
|
||||
$where = $this->db->placehold(' WHERE b.id=? ', intval($id));
|
||||
else
|
||||
$where = $this->db->placehold(' WHERE b.url=? ', $id);
|
||||
|
||||
$query = $this->db->placehold("SELECT b.id, b.url, b.name, b.annotation, b.text, b.meta_title,
|
||||
b.meta_keywords, b.meta_description, b.visible, b.date, b.image
|
||||
FROM __repairs b $where LIMIT 1");
|
||||
if($this->db->query($query))
|
||||
return $this->db->result();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Функция возвращает массив постов, удовлетворяющих фильтру
|
||||
* @param $filter
|
||||
*
|
||||
*/
|
||||
public function get_posts($filter = array())
|
||||
{
|
||||
// По умолчанию
|
||||
$limit = 1000;
|
||||
$page = 1;
|
||||
$post_id_filter = '';
|
||||
$visible_filter = '';
|
||||
$keyword_filter = '';
|
||||
$posts = array();
|
||||
|
||||
if(isset($filter['limit']))
|
||||
$limit = max(1, intval($filter['limit']));
|
||||
|
||||
if(isset($filter['page']))
|
||||
$page = max(1, intval($filter['page']));
|
||||
|
||||
if(!empty($filter['id']))
|
||||
$post_id_filter = $this->db->placehold('AND b.id in(?@)', (array)$filter['id']);
|
||||
|
||||
if(isset($filter['visible']))
|
||||
$visible_filter = $this->db->placehold('AND b.visible = ?', intval($filter['visible']));
|
||||
|
||||
if(isset($filter['keyword']))
|
||||
{
|
||||
$keywords = explode(' ', $filter['keyword']);
|
||||
foreach($keywords as $keyword)
|
||||
$keyword_filter .= $this->db->placehold('AND (b.name LIKE "%'.mysql_real_escape_string(trim($keyword)).'%" OR b.meta_keywords LIKE "%'.mysql_real_escape_string(trim($keyword)).'%") ');
|
||||
}
|
||||
|
||||
$sql_limit = $this->db->placehold(' LIMIT ?, ? ', ($page-1)*$limit, $limit);
|
||||
|
||||
$query = $this->db->placehold("SELECT b.id, b.url, b.name, b.annotation, b.text,
|
||||
b.meta_title, b.meta_keywords, b.meta_description, b.visible,
|
||||
b.date, b.image
|
||||
FROM __repairs b WHERE 1 $post_id_filter $visible_filter $keyword_filter
|
||||
ORDER BY date DESC, id DESC $sql_limit");
|
||||
|
||||
$this->db->query($query);
|
||||
return $this->db->results();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Функция вычисляет количество постов, удовлетворяющих фильтру
|
||||
* @param $filter
|
||||
*
|
||||
*/
|
||||
public function count_posts($filter = array())
|
||||
{
|
||||
$post_id_filter = '';
|
||||
$visible_filter = '';
|
||||
$keyword_filter = '';
|
||||
|
||||
if(!empty($filter['id']))
|
||||
$post_id_filter = $this->db->placehold('AND b.id in(?@)', (array)$filter['id']);
|
||||
|
||||
if(isset($filter['visible']))
|
||||
$visible_filter = $this->db->placehold('AND b.visible = ?', intval($filter['visible']));
|
||||
|
||||
if(isset($filter['keyword']))
|
||||
{
|
||||
$keywords = explode(' ', $filter['keyword']);
|
||||
foreach($keywords as $keyword)
|
||||
$keyword_filter .= $this->db->placehold('AND (b.name LIKE "%'.mysql_real_escape_string(trim($keyword)).'%" OR b.meta_keywords LIKE "%'.mysql_real_escape_string(trim($keyword)).'%") ');
|
||||
}
|
||||
|
||||
$query = "SELECT COUNT(distinct b.id) as count
|
||||
FROM __repairs b WHERE 1 $post_id_filter $visible_filter $keyword_filter";
|
||||
|
||||
if($this->db->query($query))
|
||||
return $this->db->result('count');
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Создание поста
|
||||
* @param $post
|
||||
*
|
||||
*/
|
||||
public function add_post($post)
|
||||
{
|
||||
if(isset($post->date))
|
||||
{
|
||||
$date = $post->date;
|
||||
unset($post->date);
|
||||
//$date_query = $this->db->placehold(', date=STR_TO_DATE(?, ?)', $date, $this->settings->date_format);
|
||||
$date_query = ', date=NOW()';
|
||||
}else{
|
||||
$date_query = '';
|
||||
}
|
||||
$query = $this->db->placehold("INSERT INTO __repairs SET ?% $date_query", $post);
|
||||
|
||||
if(!$this->db->query($query))
|
||||
return false;
|
||||
else
|
||||
return $this->db->insert_id();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Обновить пост(ы)
|
||||
* @param $post
|
||||
*
|
||||
*/
|
||||
public function update_post($id, $post)
|
||||
{
|
||||
$query = $this->db->placehold("UPDATE __repairs SET ?% WHERE id in(?@) LIMIT ?", $post, (array)$id, count((array)$id));
|
||||
$this->db->query($query);
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Удалить пост
|
||||
* @param $id
|
||||
*
|
||||
*/
|
||||
public function delete_post($id)
|
||||
{
|
||||
if(!empty($id))
|
||||
{
|
||||
$query = $this->db->placehold("DELETE FROM __repairs WHERE id=? LIMIT 1", intval($id));
|
||||
if($this->db->query($query))
|
||||
{
|
||||
$query = $this->db->placehold("DELETE FROM __comments WHERE type='repairs' AND object_id=? LIMIT 1", intval($id));
|
||||
if($this->db->query($query))
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function delete_image($id)
|
||||
{
|
||||
$query = $this->db->placehold("SELECT image FROM __repairs WHERE id=?", intval($id));
|
||||
$this->db->query($query);
|
||||
$filename = $this->db->result('image');
|
||||
if(!empty($filename))
|
||||
{
|
||||
$query = $this->db->placehold("UPDATE __repairs SET image=NULL WHERE id=?", $id);
|
||||
$this->db->query($query);
|
||||
$query = $this->db->placehold("SELECT count(*) as count FROM __repairs WHERE image=? LIMIT 1", $filename);
|
||||
$this->db->query($query);
|
||||
$count = $this->db->result('count');
|
||||
if($count == 0)
|
||||
{
|
||||
@unlink($this->config->root_dir.$this->config->original_images_dir.$filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Следующий пост
|
||||
* @param $post
|
||||
*
|
||||
*/
|
||||
public function get_next_post($id)
|
||||
{
|
||||
$this->db->query("SELECT date FROM __repairs WHERE id=? LIMIT 1", $id);
|
||||
$date = $this->db->result('date');
|
||||
|
||||
$this->db->query("(SELECT id FROM __repairs WHERE date=? AND id>? AND visible ORDER BY id limit 1)
|
||||
UNION
|
||||
(SELECT id FROM __repairs WHERE date>? AND visible ORDER BY date, id limit 1)",
|
||||
$date, $id, $date);
|
||||
$next_id = $this->db->result('id');
|
||||
if($next_id){
|
||||
$post = $this->get_post(intval($next_id));
|
||||
$post->image = Img::get('files/originals/' . $post->image, array('width' => 200, 'height' => 200));
|
||||
return $post;
|
||||
}
|
||||
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Предыдущий пост
|
||||
* @param $post
|
||||
*
|
||||
*/
|
||||
public function get_prev_post($id)
|
||||
{
|
||||
$this->db->query("SELECT date FROM __repairs WHERE id=? LIMIT 1", $id);
|
||||
$date = $this->db->result('date');
|
||||
|
||||
$this->db->query("(SELECT id FROM __repairs WHERE date=? AND id<? AND visible ORDER BY id DESC limit 1)
|
||||
UNION
|
||||
(SELECT id FROM __repairs WHERE date<? AND visible ORDER BY date DESC, id DESC limit 1)",
|
||||
$date, $id, $date);
|
||||
$prev_id = $this->db->result('id');
|
||||
if($prev_id){
|
||||
$post = $this->get_post(intval($prev_id));
|
||||
$post->image = Img::get('files/originals/' . $post->image, array('width' => 200, 'height' => 200));
|
||||
return $post;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,7 @@ class Simpla
|
||||
'marka' => 'Marka',
|
||||
'model' => 'Model',
|
||||
'services' => 'Services',
|
||||
'repairs' => 'Repairs',
|
||||
);
|
||||
|
||||
// Созданные объекты
|
||||
|
||||
41
repairs.sql
Normal file
41
repairs.sql
Normal file
@@ -0,0 +1,41 @@
|
||||
create table s_repair_photo
|
||||
(
|
||||
id int auto_increment
|
||||
primary key,
|
||||
action_id int default 0 not null,
|
||||
img varchar(100) default '' not null,
|
||||
position int default 0 not null
|
||||
)
|
||||
engine = MyISAM
|
||||
charset = utf8;
|
||||
;
|
||||
|
||||
|
||||
create table s_repairs
|
||||
(
|
||||
id int auto_increment
|
||||
primary key,
|
||||
name text not null,
|
||||
url varchar(255) default '' not null,
|
||||
meta_title text not null,
|
||||
meta_keywords text not null,
|
||||
meta_description text not null,
|
||||
annotation text not null,
|
||||
image varchar(255) default '' not null,
|
||||
text longtext not null,
|
||||
visible tinyint(1) default 0 not null,
|
||||
date timestamp default '0000-00-00 00:00:00' not null
|
||||
)
|
||||
engine = MyISAM
|
||||
charset = utf8;
|
||||
|
||||
create index `1gb_VISIBLE_DATE_ID_AUTO`
|
||||
on s_repairs (visible, date, id);
|
||||
|
||||
create index enabled
|
||||
on s_repairs (visible);
|
||||
|
||||
create index url
|
||||
on s_repairs (url);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
admin:$apr1$5asceyrg$9bgPtSc50E9hoCmmIPk3K0:banners,products,categories,brands,features,orders,labels,users,groups,coupons,pages,blog,comments,feedbacks,import,export,backup,stats,design,settings,currency,delivery,payment,managers,license,callbacks,articles_categories,articles,marka,model
|
||||
alaev:$apr1$cmbuh3df$9VJhmckpYKDz81JPTOyzh1:banners,products,categories,brands,features,orders,labels,users,groups,coupons,pages,blog,comments,feedbacks,import,export,backup,stats,design,settings,currency,delivery,payment,managers,license,callbacks,articles_categories,articles,marka,model
|
||||
Grib:$apr1$sbaru2xk$OgkV5q93tqQ0aGihz6JgV.:products,categories,brands,features,orders,labels,users,groups,coupons,pages,blog,comments,feedbacks,import,export,backup,stats,design,settings,currency,delivery,payment,managers,license,callbacks,articles,articles_categories,marka,model
|
||||
Olga:$apr1$c6m9xwli$AN5vPxodjhlkHf1jFUgO0/:products,categories,brands,features,pages,blog,comments,feedbacks,callbacks,articles_categories,articles,marka,model
|
||||
admin:$apr1$5asceyrg$9bgPtSc50E9hoCmmIPk3K0:banners,products,categories,brands,features,orders,labels,users,groups,coupons,pages,blog,comments,feedbacks,import,export,backup,stats,design,settings,currency,delivery,payment,managers,license,callbacks,articles_categories,articles,marka,model, repairs
|
||||
alaev:$apr1$cmbuh3df$9VJhmckpYKDz81JPTOyzh1:banners,products,categories,brands,features,orders,labels,users,groups,coupons,pages,blog,comments,feedbacks,import,export,backup,stats,design,settings,currency,delivery,payment,managers,license,callbacks,articles_categories,articles,marka,model, repairs
|
||||
Grib:$apr1$sbaru2xk$OgkV5q93tqQ0aGihz6JgV.:products,categories,brands,features,orders,labels,users,groups,coupons,pages,blog,comments,feedbacks,import,export,backup,stats,design,settings,currency,delivery,payment,managers,license,callbacks,articles,articles_categories,marka,model, repairs
|
||||
Olga:$apr1$c6m9xwli$AN5vPxodjhlkHf1jFUgO0/:products,categories,brands,features,pages,blog,comments,feedbacks,callbacks,articles_categories,articles,marka,model, repairs
|
||||
@@ -71,6 +71,8 @@ class IndexAdmin extends Simpla
|
||||
'ServicesMenuAdmin' => 'pages',
|
||||
'ServicesAdmin' => 'pages',
|
||||
'ServiceAdmin' => 'pages',
|
||||
'RepairsAdmin' => 'repairs',
|
||||
'RepairsPostAdmin' => 'repairs',
|
||||
);
|
||||
|
||||
// Конструктор
|
||||
|
||||
72
simpla/RepairsAdmin.php
Normal file
72
simpla/RepairsAdmin.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @copyright 2026
|
||||
* @author Alan Shan
|
||||
*
|
||||
*/
|
||||
require_once('api/Simpla.php');
|
||||
|
||||
class RepairsAdmin extends Simpla
|
||||
{
|
||||
public function fetch()
|
||||
{
|
||||
// Обработка действий
|
||||
if($this->request->method('post'))
|
||||
{
|
||||
// Действия с выбранными
|
||||
$ids = $this->request->post('check');
|
||||
if(is_array($ids))
|
||||
switch($this->request->post('action'))
|
||||
{
|
||||
case 'disable':
|
||||
{
|
||||
$this->repairs->update_post($ids, array('visible'=>0));
|
||||
break;
|
||||
}
|
||||
case 'enable':
|
||||
{
|
||||
$this->repairs->update_post($ids, array('visible'=>1));
|
||||
break;
|
||||
}
|
||||
case 'delete':
|
||||
{
|
||||
foreach($ids as $id)
|
||||
$this->repairs->delete_post($id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$filter = array();
|
||||
$filter['page'] = max(1, $this->request->get('page', 'integer'));
|
||||
$filter['limit'] = 20;
|
||||
|
||||
// Поиск
|
||||
$keyword = $this->request->get('keyword', 'string');
|
||||
if(!empty($keyword))
|
||||
{
|
||||
$filter['keyword'] = $keyword;
|
||||
$this->design->assign('keyword', $keyword);
|
||||
}
|
||||
|
||||
$posts_count = $this->repairs->count_posts($filter);
|
||||
// Показать все страницы сразу
|
||||
if($this->request->get('page') == 'all')
|
||||
$filter['limit'] = $posts_count;
|
||||
|
||||
$posts = $this->repairs->get_posts($filter);
|
||||
$this->design->assign('posts_count', $posts_count);
|
||||
|
||||
$this->design->assign('pages_count', ceil($posts_count/$filter['limit']));
|
||||
$this->design->assign('current_page', $filter['page']);
|
||||
|
||||
$this->design->assign('posts', $posts);
|
||||
|
||||
|
||||
|
||||
|
||||
return $this->design->fetch('repairs.tpl');
|
||||
}
|
||||
}
|
||||
91
simpla/RepairsPostAdmin.php
Normal file
91
simpla/RepairsPostAdmin.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?PHP
|
||||
|
||||
require_once('api/Simpla.php');
|
||||
|
||||
class RepairsPostAdmin extends Simpla
|
||||
{
|
||||
private $allowed_image_extentions = array('png', 'gif', 'jpg', 'jpeg', 'ico');
|
||||
public function fetch()
|
||||
{
|
||||
if($this->request->method('post'))
|
||||
{
|
||||
$post->id = $this->request->post('id', 'integer');
|
||||
$post->name = $this->request->post('name');
|
||||
$post->date = date('Y-m-d', strtotime($this->request->post('date')));
|
||||
|
||||
$post->visible = $this->request->post('visible', 'boolean');
|
||||
|
||||
$post->url = $this->request->post('url', 'string');
|
||||
$post->meta_title = $this->request->post('meta_title');
|
||||
$post->meta_keywords = $this->request->post('meta_keywords');
|
||||
$post->meta_description = $this->request->post('meta_description');
|
||||
|
||||
$post->annotation = $this->request->post('annotation');
|
||||
$post->text = $this->request->post('body');
|
||||
|
||||
// Не допустить одинаковые URL разделов.
|
||||
if(($a = $this->repairs->get_post($post->url)) && $a->id!=$post->id)
|
||||
{
|
||||
$this->design->assign('message_error', 'url_exists');
|
||||
}
|
||||
else
|
||||
{
|
||||
if(empty($post->id))
|
||||
{
|
||||
$post->id = $this->repairs->add_post($post);
|
||||
$post = $this->repairs->get_post($post->id);
|
||||
$this->design->assign('message_success', 'added');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->repairs->update_post($post->id, $post);
|
||||
$post = $this->repairs->get_post($post->id);
|
||||
$this->design->assign('message_success', 'updated');
|
||||
}
|
||||
|
||||
// Удаление изображения
|
||||
if($this->request->post('delete_image'))
|
||||
{
|
||||
$this->repairs->delete_image($post->id);
|
||||
}
|
||||
// Загрузка изображения
|
||||
$image = $this->request->files('image');
|
||||
if(!empty($image['name']) && in_array(strtolower(pathinfo($image['name'], PATHINFO_EXTENSION)), $this->allowed_image_extentions))
|
||||
{
|
||||
if ($image_name = $this->image->upload_image($image['tmp_name'], $image['name']))
|
||||
{
|
||||
$this->repairs->delete_image($post->id);
|
||||
$this->repairs->update_post($post->id, array('image'=>$image_name));
|
||||
$post->image = $image_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->design->assign('error', 'error uploading image');
|
||||
}
|
||||
}
|
||||
|
||||
$post = $this->repairs->get_post(intval($post->id));
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$post->id = $this->request->get('id', 'integer');
|
||||
$post = $this->repairs->get_post(intval($post->id));
|
||||
if(!$post->id) $post->visible = 1;
|
||||
}
|
||||
|
||||
if(empty($post->date))
|
||||
$post->date = date($this->settings->date_format, time());
|
||||
|
||||
$this->design->assign('post', $post);
|
||||
|
||||
$this->db->query("SELECT * FROM __repairs_photo WHERE repair_id='" . $post->id . "' ORDER BY position, id DESC");
|
||||
$photos = $this->db->results();
|
||||
foreach($photos as $ph) $ph->img = Img::get('files/post/' . $ph->img, array('width'=>120, 'height'=>120));
|
||||
$this->design->assign('repair_photos', $photos);
|
||||
|
||||
|
||||
return $this->design->fetch('repairs_post.tpl');
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,8 @@ $(function() {
|
||||
'articles_categories' => 'Категории статей',
|
||||
|
||||
'marka' => 'Марка авто',
|
||||
'model' => 'Модель авто'
|
||||
'model' => 'Модель авто',
|
||||
'repairs' => 'Автосервис'
|
||||
]}
|
||||
|
||||
{foreach $perms as $p=>$name}
|
||||
|
||||
46
simpla/design/html/repair_photo.tpl
Normal file
46
simpla/design/html/repair_photo.tpl
Normal file
@@ -0,0 +1,46 @@
|
||||
{literal}
|
||||
|
||||
|
||||
<link href="/js/file2/file.css?v=2" media="all" rel="stylesheet" type="text/css" />
|
||||
<script src="/js/file2/uploader.js"></script>
|
||||
<script src="/js/file2/file.js?v=21"></script>
|
||||
<div class="clearfix" style="clear: both;"></div>
|
||||
<hr />
|
||||
<span class="btn fileinput-btn btn-info button_green" style="display: inline-block;" id="art-files-input"><i class="fa fa-plus"> Добавить файл</i>
|
||||
<input type="file" multiple name="file"></span>
|
||||
<div class="well2" style="margin-top: 10px;width: 90%;">
|
||||
|
||||
|
||||
<div class="sx-form-images" style="margin-top: 20px;">
|
||||
{/literal}
|
||||
{foreach from=$repair_photos item=ph}
|
||||
<div class="sx-form-preview" style="" data-id="{$ph->id}">
|
||||
<img src="{$ph->img}" style3="width: 120px">
|
||||
|
||||
<div class="sx-move-photo">
|
||||
<img src="/images/move.png">
|
||||
</div>
|
||||
|
||||
<div class="sx-remove-photo">
|
||||
<button type="button" class="btn btn-danger btn-xs sx-form-image-remove" data-id="{$ph->id}"><b>X</b></button>
|
||||
</div>
|
||||
</div>
|
||||
{/foreach}
|
||||
{literal}
|
||||
|
||||
</div>
|
||||
<div class="clearfix" style="clear:both"></div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function(){
|
||||
var sxFile = new sxFormFile();
|
||||
{/literal}
|
||||
sxFile.init({$post->id}, '/simpla/ajax/file_action.php');
|
||||
{literal}
|
||||
})
|
||||
</script>
|
||||
|
||||
{/literal}
|
||||
153
simpla/design/html/repairs.tpl
Normal file
153
simpla/design/html/repairs.tpl
Normal file
@@ -0,0 +1,153 @@
|
||||
{* Вкладки *}
|
||||
{capture name=tabs}
|
||||
|
||||
<li><a href="index.php?module=BlogAdmin">Блог</a></li>
|
||||
<li><a href="index.php?module=ArticlesAdmin">Примеры работ</a></li>
|
||||
<li><a href="index.php?module=ArticleCategoriesAdmin">Категории примеров работ</a></li>
|
||||
<li><a href="{url module=ActionsAdmin id=null page=null}">Акции</a></li>
|
||||
<li><a href="{url module=MarkasAdmin id=null page=null}">Марки и модели</a></li>
|
||||
<li class="active"><a href="{url module=RepairsAdmin id=null page=null}">Автосервис</a></li>
|
||||
{/capture}
|
||||
{* Title *}
|
||||
{$meta_title='Автосервис' scope=parent}
|
||||
|
||||
{* Поиск *}
|
||||
{if $posts || $keyword}
|
||||
<form method="get">
|
||||
<div id="search">
|
||||
<input type="hidden" name="module" value='BlogAdmin'>
|
||||
<input class="search" type="text" name="keyword" value="{$keyword|escape}" />
|
||||
<input class="search_button" type="submit" value=""/>
|
||||
</div>
|
||||
</form>
|
||||
{/if}
|
||||
|
||||
{* Заголовок *}
|
||||
<div id="header">
|
||||
{if $keyword && $posts_count}
|
||||
<h1>{$posts_count|plural:'Нашлась':'Нашлись':'Нашлись'} {$posts_count} {$posts_count|plural:'запись':'записей':'записи'}</h1>
|
||||
{elseif $posts_count}
|
||||
<h1>{$posts_count} {$posts_count|plural:'запись':'записей':'записи'} в акциях</h1>
|
||||
{else}
|
||||
<h1>Нет записей</h1>
|
||||
{/if}
|
||||
<a class="add" href="{url module=RepairsPostAdmin return=$smarty.server.REQUEST_URI}">Добавить запись</a>
|
||||
</div>
|
||||
|
||||
{if $posts}
|
||||
<div id="main_list">
|
||||
|
||||
<!-- Листалка страниц -->
|
||||
{include file='pagination.tpl'}
|
||||
<!-- Листалка страниц (The End) -->
|
||||
|
||||
<form id="form_list" method="post">
|
||||
<input type="hidden" name="session_id" value="{$smarty.session.id}">
|
||||
|
||||
<div id="list">
|
||||
{foreach $posts as $post}
|
||||
<div class="{if !$post->visible}invisible{/if} row">
|
||||
<input type="hidden" name="positions[{$post->id}]" value="{$post->position}">
|
||||
<div class="checkbox cell">
|
||||
<input type="checkbox" name="check[]" value="{$post->id}" />
|
||||
</div>
|
||||
<div class="name cell">
|
||||
<a href="{url module=RepairsPostAdmin id=$post->id return=$smarty.server.REQUEST_URI}">{$post->name|escape}</a>
|
||||
<br>
|
||||
{$post->date|date}
|
||||
</div>
|
||||
<div class="icons cell">
|
||||
<a class="preview" title="Предпросмотр в новом окне" href="../repairs/{$post->url}" target="_blank"></a>
|
||||
<a class="enable" title="Активна" href="#"></a>
|
||||
<a class="delete" title="Удалить" href="#"></a>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
|
||||
|
||||
<div id="action">
|
||||
<label id="check_all" class="dash_link">Выбрать все</label>
|
||||
|
||||
<span id="select">
|
||||
<select name="action">
|
||||
<option value="enable">Сделать видимыми</option>
|
||||
<option value="disable">Сделать невидимыми</option>
|
||||
<option value="delete">Удалить</option>
|
||||
</select>
|
||||
</span>
|
||||
|
||||
<input id="apply_action" class="button_green" type="submit" value="Применить">
|
||||
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<!-- Листалка страниц -->
|
||||
{include file='pagination.tpl'}
|
||||
<!-- Листалка страниц (The End) -->
|
||||
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{* On document load *}
|
||||
{literal}
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
|
||||
// Раскраска строк
|
||||
function colorize()
|
||||
{
|
||||
$("#list div.row:even").addClass('even');
|
||||
$("#list div.row:odd").removeClass('even');
|
||||
}
|
||||
// Раскрасить строки сразу
|
||||
colorize();
|
||||
|
||||
// Выделить все
|
||||
$("#check_all").click(function() {
|
||||
$('#list input[type="checkbox"][name*="check"]').attr('checked', 1-$('#list input[type="checkbox"][name*="check"]').attr('checked'));
|
||||
});
|
||||
|
||||
// Удалить
|
||||
$("a.delete").click(function() {
|
||||
$('#list input[type="checkbox"][name*="check"]').attr('checked', false);
|
||||
$(this).closest(".row").find('input[type="checkbox"][name*="check"]').attr('checked', true);
|
||||
$(this).closest("form").find('select[name="action"] option[value=delete]').attr('selected', true);
|
||||
$(this).closest("form").submit();
|
||||
});
|
||||
|
||||
// Скрыт/Видим
|
||||
$("a.enable").click(function() {
|
||||
var icon = $(this);
|
||||
var line = icon.closest(".row");
|
||||
var id = line.find('input[type="checkbox"][name*="check"]').val();
|
||||
var state = line.hasClass('invisible')?1:0;
|
||||
icon.addClass('loading_icon');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'ajax/update_object.php',
|
||||
data: {'object': 'repairs', 'id': id, 'values': {'visible': state}, 'session_id': '{/literal}{$smarty.session.id}{literal}'},
|
||||
success: function(data){
|
||||
icon.removeClass('loading_icon');
|
||||
if(state)
|
||||
line.removeClass('invisible');
|
||||
else
|
||||
line.addClass('invisible');
|
||||
},
|
||||
dataType: 'json'
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
// Подтверждение удаления
|
||||
$("form").submit(function() {
|
||||
if($('select[name="action"]').val()=='delete' && !confirm('Подтвердите удаление'))
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
{/literal}
|
||||
212
simpla/design/html/repairs_post.tpl
Normal file
212
simpla/design/html/repairs_post.tpl
Normal file
@@ -0,0 +1,212 @@
|
||||
{capture name=tabs}
|
||||
<li class="active"><a href="{url module=RepairsAdmin id=null page=null}">Автосервис</a></li>
|
||||
{/capture}
|
||||
|
||||
{if $post->id}
|
||||
{$meta_title = $post->name scope=parent}
|
||||
{else}
|
||||
{$meta_title = 'Новая услуга автосервиса' scope=parent}
|
||||
{/if}
|
||||
|
||||
{* Подключаем Tiny MCE *}
|
||||
{include file='tinymce_init.tpl'}
|
||||
|
||||
{* On document load *}
|
||||
{literal}
|
||||
<script src="design/js/jquery/datepicker/jquery.ui.datepicker-ru.js"></script>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
|
||||
$('input[name="date"]').datepicker({
|
||||
regional:'ru'
|
||||
});
|
||||
|
||||
// Автозаполнение мета-тегов
|
||||
meta_title_touched = true;
|
||||
meta_keywords_touched = true;
|
||||
meta_description_touched = true;
|
||||
url_touched = true;
|
||||
update = {/literal}{if $post->url}true;{else}false;{/if}{literal}
|
||||
|
||||
if($('input[name="meta_title"]').val() == generate_meta_title() || $('input[name="meta_title"]').val() == '')
|
||||
meta_title_touched = false;
|
||||
if($('input[name="meta_keywords"]').val() == generate_meta_keywords() || $('input[name="meta_keywords"]').val() == '')
|
||||
meta_keywords_touched = false;
|
||||
if($('textarea[name="meta_description"]').val() == generate_meta_description() || $('textarea[name="meta_description"]').val() == '')
|
||||
meta_description_touched = false;
|
||||
if($('input[name="url"]').val() == generate_url() || $('input[name="url"]').val() == '')
|
||||
url_touched = false;
|
||||
|
||||
$('input[name="meta_title"]').change(function() { meta_title_touched = true; });
|
||||
$('input[name="meta_keywords"]').change(function() { meta_keywords_touched = true; });
|
||||
$('textarea[name="meta_description"]').change(function() { meta_description_touched = true; });
|
||||
$('input[name="url"]').change(function() { url_touched = true; });
|
||||
|
||||
$('input[name="name"]').keyup(function() { set_meta(); });
|
||||
$('select[name="brand_id"]').change(function() { set_meta(); });
|
||||
$('select[name="categories[]"]').change(function() { set_meta(); });
|
||||
|
||||
});
|
||||
|
||||
function set_meta()
|
||||
{
|
||||
if(!meta_title_touched && !update)
|
||||
// $('input[name="meta_title"]').val(generate_meta_title());
|
||||
if(!meta_keywords_touched && !update)
|
||||
// $('input[name="meta_keywords"]').val(generate_meta_keywords());
|
||||
if(!meta_description_touched && !update)
|
||||
{
|
||||
descr = $('textarea[name="meta_description"]');
|
||||
descr.val(generate_meta_description());
|
||||
descr.scrollTop(descr.outerHeight());
|
||||
}
|
||||
if(!url_touched && !update)
|
||||
$('input[name="url"]').val(generate_url());
|
||||
}
|
||||
|
||||
function generate_meta_title()
|
||||
{
|
||||
name = $('input[name="name"]').val();
|
||||
return name;
|
||||
}
|
||||
|
||||
function generate_meta_keywords()
|
||||
{
|
||||
name = $('input[name="name"]').val();
|
||||
return name;
|
||||
}
|
||||
|
||||
function generate_meta_description()
|
||||
{
|
||||
if(typeof(tinyMCE.get("annotation")) =='object')
|
||||
{
|
||||
description = tinyMCE.get("annotation").getContent().replace(/(<([^>]+)>)/ig," ").replace(/(\ )/ig," ").replace(/^\s+|\s+$/g, '').substr(0, 512);
|
||||
return description;
|
||||
}
|
||||
else
|
||||
return $('textarea[name=annotation]').val().replace(/(<([^>]+)>)/ig," ").replace(/(\ )/ig," ").replace(/^\s+|\s+$/g, '').substr(0, 512);
|
||||
}
|
||||
|
||||
function generate_url()
|
||||
{
|
||||
url = $('input[name="name"]').val();
|
||||
url = url.replace(/[\s]+/gi, '-');
|
||||
url = translit(url);
|
||||
url = url.replace(/[^0-9a-z_\-]+/gi, '').toLowerCase();
|
||||
return url;
|
||||
}
|
||||
|
||||
function translit(str)
|
||||
{
|
||||
var ru=("А-а-Б-б-В-в-Ґ-ґ-Г-г-Д-д-Е-е-Ё-ё-Є-є-Ж-ж-З-з-И-и-І-і-Ї-ї-Й-й-К-к-Л-л-М-м-Н-н-О-о-П-п-Р-р-С-с-Т-т-У-у-Ф-ф-Х-х-Ц-ц-Ч-ч-Ш-ш-Щ-щ-Ъ-ъ-Ы-ы-Ь-ь-Э-э-Ю-ю-Я-я").split("-")
|
||||
var en=("A-a-B-b-V-v-G-g-G-g-D-d-E-e-E-e-E-e-ZH-zh-Z-z-I-i-I-i-I-i-J-j-K-k-L-l-M-m-N-n-O-o-P-p-R-r-S-s-T-t-U-u-F-f-H-h-TS-ts-CH-ch-SH-sh-SCH-sch-'-'-Y-y-'-'-E-e-YU-yu-YA-ya").split("-")
|
||||
var res = '';
|
||||
for(var i=0, l=str.length; i<l; i++)
|
||||
{
|
||||
var s = str.charAt(i), n = ru.indexOf(s);
|
||||
if(n >= 0) { res += en[n]; }
|
||||
else { res += s; }
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
</script>
|
||||
{/literal}
|
||||
|
||||
{if $message_success}
|
||||
<!-- Системное сообщение -->
|
||||
<div class="message message_success">
|
||||
<span>{if $message_success == 'added'}Запись добавлена{elseif $message_success == 'updated'}Запись обновлена{/if}</span>
|
||||
<a class="link" target="_blank" href="../blog/{$post->url}">Открыть запись на сайте</a>
|
||||
{if $smarty.get.return}
|
||||
<a class="button" href="{$smarty.get.return}">Вернуться</a>
|
||||
{/if}
|
||||
</div>
|
||||
<!-- Системное сообщение (The End)-->
|
||||
{/if}
|
||||
|
||||
{if $message_error}
|
||||
<!-- Системное сообщение -->
|
||||
<div class="message message_error">
|
||||
<span>{if $message_error == 'url_exists'}Запись с таким адресом уже существует{/if}</span>
|
||||
<a class="button" href="">Вернуться</a>
|
||||
</div>
|
||||
<!-- Системное сообщение (The End)-->
|
||||
{/if}
|
||||
|
||||
|
||||
<!-- Основная форма -->
|
||||
<form method=post id=product enctype="multipart/form-data">
|
||||
<input type=hidden name="session_id" value="{$smarty.session.id}">
|
||||
<div id="name">
|
||||
<input class="name" name=name type="text" value="{$post->name|escape}"/>
|
||||
<input name=id type="hidden" value="{$post->id|escape}"/>
|
||||
<div class="checkbox">
|
||||
<input name=visible value='1' type="checkbox" id="active_checkbox" {if $post->visible}checked{/if}/> <label for="active_checkbox">Активна</label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Левая колонка свойств товара -->
|
||||
<div id="column_left">
|
||||
|
||||
<!-- Параметры страницы -->
|
||||
<div class="block">
|
||||
<ul>
|
||||
<li><label class=property>Дата</label><input type=text name=date value='{$post->date|date}'></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="block layer">
|
||||
<!-- Параметры страницы (The End)-->
|
||||
<h2>Параметры страницы</h2>
|
||||
<!-- Параметры страницы -->
|
||||
<ul>
|
||||
<li><label class=property>Адрес</label><div class="page_url"> /repairs/</div><input name="url" class="page_url" type="text" value="{$post->url|escape}" /></li>
|
||||
<li><label class=property>Заголовок</label><input name="meta_title" type="text" value="{$post->meta_title|escape}" /></li>
|
||||
<li><label class=property>Ключевые слова</label><input name="meta_keywords" type="text" value="{$post->meta_keywords|escape}" /></li>
|
||||
<li><label class=property>Описание</label><textarea name="meta_description" />{$post->meta_description|escape}</textarea></li>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- Параметры страницы (The End)-->
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- Левая колонка свойств товара (The End)-->
|
||||
|
||||
<!-- Правая колонка свойств товара -->
|
||||
<div id="column_right">
|
||||
<!-- Изображение категории -->
|
||||
<div class="block layer images">
|
||||
<h2>Изображение</h2>
|
||||
<input class='upload_image' name=image type=file>
|
||||
<input type=hidden name="delete_image" value="">
|
||||
{if $post->image}
|
||||
<ul>
|
||||
<li>
|
||||
<a href='#' class="delete"><img src='design/images/cross-circle-frame.png'></a>
|
||||
<img src="{$post->image|resizepost:100:100}" alt="" />
|
||||
</li>
|
||||
</ul>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<!-- Правая колонка свойств товара (The End)-->
|
||||
|
||||
<!-- Описагние товара -->
|
||||
<div class="block layer">
|
||||
<h2>Краткое описание</h2>
|
||||
<textarea name="annotation" class='editor_small'>{$post->annotation|escape}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="block">
|
||||
<h2>Полное описание</h2>
|
||||
<textarea name="body" class='editor_large'>{$post->text|escape}</textarea>
|
||||
</div>
|
||||
<!-- Описание товара (The End)-->
|
||||
<input class="button_green button_save" type="submit" name="" value="Сохранить" />
|
||||
|
||||
{if $post->id}{include file="repair_photo.tpl"}{/if}
|
||||
</form>
|
||||
<!-- Основная форма (The End) -->
|
||||
Reference in New Issue
Block a user