Commit 48680c56 authored by Яков's avatar Яков
Browse files

first

parents
<?php
require_once dirname(__FILE__).'/../lib/pageGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/pageGeneratorHelper.class.php';
/**
* page actions.
*
* @package sf
* @subpackage page
* @author Atma
* @version SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class pageActions extends autoPageActions
{
protected function buildQuery()
{
$query = parent::buildQuery();
$query->leftJoin("r.Translation t");
return $query;
}
}
generator:
class: sfDoctrineGenerator
param:
model_class: Page
theme: admin
non_verbose_templates: true
with_show: false
singular: ~
plural: ~
route_prefix: page
with_doctrine_route: true
actions_base_class: sfActions
order: 90
config:
actions: ~
fields:
id: {label: ''}
RuTitle: {label: 'Название'}
alias: {label: 'Алиас'}
title: {label: 'Название'}
created_at: {label: ''}
updated_at: {label: ''}
list:
layout: ~
title: 'Страницы'
display: [RuTitle, alias]
max_per_page: 100
object_actions:
_delete: ~
_edit: ~
search:
fields: false
export: false
filter:
class: false
form: ~
edit:
title: Редактирование страницы
new:
title: Добавление страницы
\ No newline at end of file
<?php
/**
* page module configuration.
*
* @package sf
* @subpackage page
* @author Atma
* @version SVN: $Id: configuration.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class pageGeneratorConfiguration extends BasePageGeneratorConfiguration
{
}
<?php
/**
* page module helper.
*
* @package sf
* @subpackage page
* @author Atma
* @version SVN: $Id: helper.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class pageGeneratorHelper extends BasePageGeneratorHelper
{
}
<?php use_helper('I18N', 'Date') ?>
<?php if (!$sf_request->isXmlHttpRequest()): ?>
<?php include_partial('page/assets') ?>
<span class="lui__h1"><?php echo __('Страницы', array(), 'messages') ?></span><sup
class="lui__list_count">&nbsp;<?php echo ($sf_request->getParameter('q') ? 'найдено:&nbsp;' : '');?><?php echo isset($pager) ? $pager->getNbResults() : ''; ?>&nbsp;</sup>
<?php include_partial('page/flashes') ?>
<span class="br15"></span>
<div class="batch_form__class">
<?php endif; ?>
<?php if (isset($pager)): ?>
<form id="batch_form" action="<?php echo url_for('page_collection', array('action' => 'batch')) ?>" method="post">
<div id="lui_scroller" class="lui_scroller">
<div class="lui__scroller_wrapper"><?php include_partial('page/list', array('pager' => $pager, 'sort' => $sort, 'helper' => $helper)) ?></div>
</div>
<input type="hidden" name="batch_action" id="batch_action_id"/>
<?php $form = new BaseForm(); if ($form->isCSRFProtected()): ?>
<input type="hidden" name="<?php echo $form->getCSRFFieldName() ?>" value="<?php echo $form->getCSRFToken() ?>"/>
<?php endif; ?>
</form>
<?php endif; ?>
<?php if (!$sf_request->isXmlHttpRequest()): ?>
</div>
<?php endif; ?>
<?php if (isset($replace_content) && $replace_content !== false): ?>
<?php echo htmlspecialchars_decode($replace_content); ?>
<?php endif; ?>
\ No newline at end of file
<?php
require_once dirname(__FILE__).'/../lib/partnersGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/partnersGeneratorHelper.class.php';
/**
* partners actions.
*
* @package sf
* @subpackage partners
* @author Atma
* @version SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class partnersActions extends autoPartnersActions
{
}
generator:
class: sfDoctrineGenerator
param:
model_class: Partners
theme: admin
non_verbose_templates: true
with_show: false
singular: ~
plural: ~
route_prefix: partners
with_doctrine_route: true
actions_base_class: sfActions
order: 80
hr: true
config:
actions: ~
fields:
cover: {label: Изображение}
title: {label: Название}
link: {label: Ссылка}
order_id: {label: 'Порядок сортировки'}
created_at: {label: Дата создания}
list:
layout: ~
title: 'Партнёры'
display: [title, _cover, order_id]
max_per_page: 100
sort: [order_id, ASC]
object_actions:
_delete: ~
_edit: ~
search:
fields: [title]
export: false
filter:
class: false
form: ~
edit:
title: Редактирование партнёра
new:
title: Добавление партнёра
\ No newline at end of file
<?php
/**
* partners module configuration.
*
* @package sf
* @subpackage partners
* @author Atma
* @version SVN: $Id: configuration.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class partnersGeneratorConfiguration extends BasePartnersGeneratorConfiguration
{
}
<?php
/**
* partners module helper.
*
* @package sf
* @subpackage partners
* @author Atma
* @version SVN: $Id: helper.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class partnersGeneratorHelper extends BasePartnersGeneratorHelper
{
}
<?php
include_partial('main/image', array('image' => $partners->getCover(), 'type' => 'fotorama', 'id' => $partners->getId()));
?>
<?php
require_once dirname(__FILE__) . '/../lib/productGeneratorConfiguration.class.php';
require_once dirname(__FILE__) . '/../lib/productGeneratorHelper.class.php';
/**
* product actions.
*
* @package sf
* @subpackage product
* @author Atma
* @version SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class productActions extends autoProductActions
{
public function executeUpdate(sfWebRequest $request)
{
parent::executeUpdate($request);
return sfView::NONE;
}
public function executeCreate(sfWebRequest $request)
{
parent::executeCreate($request);
return sfView::NONE;
}
public function executeDelete(sfWebRequest $request)
{
$product = $this->getRoute()->getObject();
$this->dispatcher->notify(new sfEvent($this, 'admin.delete_object', array('object' => $product)));
$offer_count = Doctrine_Query::create()
->from("Offer")
->where("product_id = ?", $product->getId())
->count();
if ($offer_count == 0) {
$product->delete();
echo 'ok';
} else {
echo 'no';
}
return sfView::NONE;
}
protected function processForm(sfWebRequest $request, sfForm $form)
{
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid()) {
try {
$product = $form->save();
$props = $request->getParameter('props');
if($props && is_array($props)){
$product_props = Doctrine_Query::create()
->select("pp.id")
->from("ProductProp pp INDEXBY pp.id")
->fetchArray();
foreach ($props as $prop_id => $prop){
if(isset($product_props[$prop_id])){
$prop_value = Doctrine::getTable("ProductPropValue")->findOneByProductIdAndPropId($product->getId(), $prop_id);
if($prop == ''){
if($prop_value){
$prop_value->delete();
}
continue;
}
if(!$prop_value){
$prop_value = new ProductPropValue();
$prop_value->setProductId($product->getId());
$prop_value->setPropId($prop_id);
}
$prop_value->setValue($prop);
$prop_value->save();
}
}
}
echo $this->getPartial('cat/struct_form', array('form' => new ProductForm($product), 'parent_id' => Cat::$parentId, 'link' => '/arm/product' . ($product ? '/' . $product->getId() : '')));
return sfView::NONE;
} catch (Doctrine_Validator_Exception $e) {
$errorStack = $form->getObject()->getErrorStack();
return sfView::SUCCESS;
}
$this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $product)));
}
echo $this->getPartial('cat/struct_form', array('form' => $form, 'parent_id' => Cat::$parentId, 'link' => '/arm/product' . ($this->product && $this->product->getId() ? '/' . $this->product->getId() : '')));
return sfView::NONE;
}
}
generator:
class: sfDoctrineGenerator
param:
model_class: Product
theme: admin
non_verbose_templates: true
with_show: false
singular: ~
plural: ~
route_prefix: product
with_doctrine_route: true
actions_base_class: sfActions
order: 10
skip: true
config:
actions: ~
fields:
title: {label: 'Название'}
title_ru: {label: 'Название RU'}
title_en: {label: 'Название EN'}
alias: {label: 'Алиас'}
created_at: {label: 'Дата создания'}
cat_products_list: {label: 'Категория'}
product_img: {label: 'Изображения'}
supplier_id: {label: 'Поставщик'}
supplier_price: {label: 'Цена поставщика'}
cat: {label: 'Категория'}
certificate: {label: 'Сертификат'}
tags_list: {label: 'Теги'}
is_detail: {label: 'Подробный просмотр'}
the_weight: {label: 'Вес ведра'}
list:
layout: ~
title: 'Товары'
display: [_title, _cat , alias, _supplier_id, created_at]
max_per_page: 100
object_actions:
_delete: ~
_edit: ~
search:
fields: false
export: false
filter:
class: false
form: ~
edit:
title: Редактирование товара
new:
title: Добавление товара
\ No newline at end of file
<?php
/**
* product module configuration.
*
* @package sf
* @subpackage product
* @author Atma
* @version SVN: $Id: configuration.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class productGeneratorConfiguration extends BaseProductGeneratorConfiguration
{
}
<?php
/**
* product module helper.
*
* @package sf
* @subpackage product
* @author Atma
* @version SVN: $Id: helper.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
class productGeneratorHelper extends BaseProductGeneratorHelper
{
}
<?php
$cat = $product->getCats()->getFirst();
$breadcrumbs = false;
if($cat){
$breadcrumbs = $cat->getBreadcrumbs();
}
echo '<nobr>';
if($breadcrumbs)
{
foreach($breadcrumbs as $crumb)
{
echo $crumb . ' > ';
}
}
echo $cat;
echo '</nobr>';
\ No newline at end of file
<?php if ($field->isPartial()): ?>
<?php include_partial('product/'.$name, array('form' => $form, 'attributes' => $attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes)) ?>
<?php elseif ($field->isComponent()): ?>
<?php include_component('product', $name, array('form' => $form, 'attributes' => $attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes)) ?>
<?php else: ?>
<div class="<?php echo $class ?><?php $form[$name]->hasError() and print ' errors' ?>">
<div>
<?php $opts = $form[$name]->getWidget()->getOptions(); ?>
<?php if (key_exists('type', $opts) && $opts['type'] == 'checkbox'): ?>
<div class="content"><label><?php echo $form[$name]->render($attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes); ?><?php echo $label; ?></label></div>
<?php else: ?>
<span class="inline-label"><?php echo $form[$name]->renderLabel($label) ?></span>
<div class="content">
<?php echo $name == 'alias' ? 'product/' : ''; ?>
<?php echo $form[$name]->render($attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes) ?>
<?php echo $name == 'alias' ? '/' : ''; ?>
<?php echo $form[$name]->renderError() ?>
<?php if ($help): ?><span class="help"><?php echo __($help, array(), 'messages') ?></span><?php elseif ($help = $form[$name]->renderHelp()): ?><span class="help"><?php echo strip_tags($help, '<a><i>') ?></span><?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<style type="text/css">
.uploader {
cursor: pointer;
}
.uploader img {
max-height: 52px !important;
max-width: 143px !important;
}
.uploaders {
display: none;
}
</style>
<?php
if ($form->isNew()) {
$obj = $form->getObject();
$value['direct_price'] = 0;
} else {
$obj = $form->getObject();
}
$tags = Doctrine::getTable('Tag')->findAll();
?>
<div class="sf_admin_form_row sf_admin_text tabbed_div">
<div>
<span class="inline-label">Цены</span>
<div class="content">
<div style="display: inline-block;padding-left: 5px;min-width: 720px;">
<label>
<i class="br5"></i>
<i class="br5"></i>
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="55%">
Цена за одну единицу
</td>
<td width="20%">
</td width="25%">
<td colspan="2" style="width:1%; padding-left: 5px">
руб
</td>
</tr>
</table>
</label>
<i class="br15"></i>
<div style="width: 100%; text-align: center"><i>или</i></div>
<i class="br15"></i>
Торговые предложения
<i class="br5"></i>
<div class="offer_group">
<?php
$offer_counter = 0;
$offers = $obj->getOffer();
if (count($offers) > 0) {
foreach ($offers as $offer) {
?>
<div class="offer custom_offer">
<div class="custom_offer_closer" onclick="$(this).parent().remove()">×</div>
<table cellspacing="0" cellpadding="0" style="width: 100%">
<tr>
<td width="55%">
<input style="width: 100%" maxlength="255"
name="product_custom[custom_offer][<?php echo $offer->getId() ?>][title_ru]"
type="text"
value="<?php echo $offer->getTranslation()->ru->title ?>">
<div class="input_label_overlay">RU</div>
<i class="br5"></i>
<input style="width: 100%" maxlength="255"
name="product_custom[custom_offer][<?php echo $offer->getId() ?>][title_en]"
type="text"
value="<?php echo $offer->getTranslation()->en->title ?>">
<div class="input_label_overlay">EN</div>
</td>
<td width="20%">
<input style="width: 100%; height: 53px" maxlength="255"
name="product_custom[custom_offer][<?php echo $offer->getId() ?>][price]"
type="number" value="<?php echo $offer->getPrice() ?>">
</td>
<td width="5%" style="padding-left: 5px">руб</td>
<td width="20%">
<input type="file" class="uploaders pseudo_button_file" name="file"
id="<?php echo $offer->getId() ?>__uploader"/>
<div class="uploader upload_img_btn">
<?php
if ($offer['img']) {
echo '<img src="/u/i/' . $offer["img"] . '">';
} else {
echo 'Загрузить изображение';
}
?>
</div>
<input type="text" class="offerImg offerImg<?php echo $offer->getId() ?>"
name="product_custom[custom_offer][<?php echo $offer->getId() ?>][img]"
value="<?php echo $offer['img'] ?>">
</td>
</tr>
</table>
</div>
<?php
$offer_counter++;
}
}
?>
</div>
<i class="br10"></i>
<div class="green_btn" style="cursor: pointer" onclick="add_offer()">Добавить предложение</div>
</div>
</div>
</div>
</div>
<i class="br10"></i>
<?php
include_partial('product/props', array('form' => $form))
?>
<script type="text/javascript">
function add_offer() {
var newId = 'new_offer_' + ($('.js_new_offer').length + 1);
var html = '<div class="offer custom_offer js_new_offer">' +
'<div class="custom_offer_closer" onclick="$(this).parent().remove()">×</div>' +
'<table cellspacing="0" cellpadding="0" style="width: 100%">' +
'<tr>' +
'<td width="55%">' +
'<input style="width: 100%" maxlength="255" name="product_custom[custom_offer][' + newId + '][title_ru]" type="text">' +
'<div class="input_label_overlay">RU</div>' +
'<i class="br5"></i>' +
'<input style="width: 100%" maxlength="255" name="product_custom[custom_offer][' + newId + '][title_en]" type="text">' +
'<div class="input_label_overlay">EN</div>' +
'</td>' +
'<td width="20%">' +
'<input style="width: 100%; height: 53px" maxlength="255" name="product_custom[custom_offer][' + newId + '][price]" type="number">' +
'</td>' +
'<td width="5%" style="padding-left: 5px">руб</td>' +
'<td width="20%">' +
'<input type="file" class="uploaders pseudo_button_file" name="file" id="' + newId + '__uploader" />' +
'<div class="uploader upload_img_btn">Загрузить изображение</div>' +
'<input type="text" class="offerImg offerImg' + newId + '" name="product_custom[custom_offer][' + newId + '][img]">' +
'</td>' +
'</tr>' +
'</table>' +
'</div>';
$('.offer_group').append(html);
$('#' + newId + '__uploader').liteUploader({
singleFileUploads: true,
script: sf_prefix + '/uploader?key=catalog'
}).on('lu:success', function (e, response) {
var obj = JSON.parse(response);
var filename = obj.filename;
//alert(filename);
$(this).next().html('<img src="/u/i/' + filename + '">').next().val(filename);
});
}
$('.uploaders').liteUploader({
singleFileUploads: true,
script: sf_prefix + '/uploader?key=catalog'
}).on('lu:success', function (e, response) {
var obj = JSON.parse(response);
var filename = obj.filename;
$(this).next().html('<img src="/u/i/' + filename + '">').next().val(filename);
});
$('body').on('change', '.uploaders', function () {
startUploader($(this));
});
$('body').on('click', '.uploader', function (e) {
$(this).prev().trigger('click');
});
function startUploader(_this) {
$(_this).data('liteUploader').startUpload();
}
$('#product_supplier_id').change(function () {
if ($('#product_supplier_id').val() == '') {
$('.sf_admin_form_field_supplier_price').css('display', 'none');
}
else {
$('.sf_admin_form_field_supplier_price').css('display', 'block');
}
}).change();
</script>
<?php
$translation = (isset($new) ? false : $prop);
echo '<input autocomplete="off" size="8" maxlength="8" name="props['. $prop["id"] .'][ru]" value="' . ($translation ? $translation->value : '') . '" id="props" type="text">';
?>
\ No newline at end of file
<span class="inline_label"><label for="props">Характеристики</label></span>
<i class="br10"></i>
<table cellpadding="0" cellspacing="0" class="adminTable">
<tr>
<td>Название</td>
<td>Значение</td>
</tr>
<?php
$values = array();
if(!$form->isNew()){
$obj = $form->getObject();
$values = Doctrine_Query::create()
->select("v.*")
->from("ProductPropValue v INDEXBY v.prop_id")
->where("v.product_id = ?", $obj->getId())
->fetchArray();
}
$props = Doctrine_Query::create()
->select("p.*, l.*, pt.*, lt.*")
->from("ProductProp p")
->leftJoin("p.ProductPropList l")
->leftJoin("p.Translation pt WITH pt.lang = 'ru'")
->leftJoin("l.Translation lt WITH lt.lang = 'ru'")
->fetchArray();
if(count($props) > 0){
foreach ($props as $prop){
echo '<tr>';
echo '<td width="150">' . $prop['Translation']['ru']['title'] . '</td>';
echo '<td>';
if($prop['isList']){
echo '<select style="width:100%;" name="props[' . $prop['id'] . ']">';
echo '<option value="">—</option>';
foreach ($prop['ProductPropList'] as $list){
echo '<option ' . (isset($values[$prop['id']]) && (int)$values[$prop['id']]['value'] == $list['id'] ? 'selected="selected"' : '') . ' value="' . $list['id'] . '">' . $list['Translation']['ru']['variant'] . '</option>';
}
echo '</select>';
}else{
echo '<input autocomplete="off" size="8" maxlength="8" name="props['. $prop["id"] .']" value="' . (isset($values[$prop['id']]) ? $values[$prop['id']]['value'] : '') . '" id="props" type="text">';
}
echo '</td>';
echo '</tr>';
}
}
?>
</table>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment