first commit

This commit is contained in:
2025-03-12 17:06:23 +01:00
commit 2241f7131f
13185 changed files with 1692479 additions and 0 deletions

View File

@@ -0,0 +1,265 @@
<?php
/**
* SOTESHOP/stTrustPlugin
*
*
* @package stTrustPlugin
* @author Bartosz Alejski <bartosz.alejski@sote.pl>
*/
class stTrustBackendActions extends autoStTrustBackendActions
{
public function executeConfig()
{
$this->config = stConfig::getInstance('stTrustBackend');
$this->config->setCulture($this->getRequestParameter('culture', stLanguage::getOptLanguage()));
if ($this->getRequest()->getMethod() == sfRequest::POST)
{
$this->updateConfigFromRequest();
$this->config->save(true);
stFastCacheManager::clearCache();
foreach (glob(sfConfig::get('sf_root_dir').'/cache/smarty_c/*') as $file)
{
unlink($file);
}
$this->setFlash('notice', 'Twoje zmiany zostały zapisane');
$this->redirect('stTrustBackend/config?culture='.$this->getRequestParameter('culture', stLanguage::getOptLanguage()));
}
$i18n = $this->getContext()->getI18N();
$this->getBreadcrumbs()->add($i18n->__('Konfiguracja'));
}
public function updateConfigFromRequest()
{
$this->config->set('field_on', $this->getRequestParameter('trust[field_on]'));
$this->config->set('field_description', $this->getRequestParameter('trust[field_description]'), true);
$this->config->set('field_1_on', $this->getRequestParameter('trust[field_1_on]'));
$this->config->set('field_label_1', $this->getRequestParameter('trust[field_label_1]'), true);
$this->config->set('field_sub_label_1', $this->getRequestParameter('trust[field_sub_label_1]'), true);
$this->config->set('field_description_1', $this->getRequestParameter('trust[field_description_1]'), true);
if ($this->getRequest()->getFileSize('trust[icon_1]'))
{
$currentFile = sfConfig::get('sf_upload_dir') . $this->config->get('icon_1', null, true);
$fileName = md5($this->getRequest()->getFileName('trust[icon_1]') . time() . rand(0, 99999));
$ext = $this->getRequest()->getFileExtension('trust[icon_1]');
if (is_file($currentFile))
{
unlink($currentFile);
}
$this->config->set('icon_1', "/picture/" . $this->getRequestParameter('culture', stLanguage::getOptLanguage()) . '/' . $fileName . $ext, true);
$this->getRequest()->moveFile('trust[icon_1]', sfConfig::get('sf_upload_dir') . $this->config->get('icon_1', null, true));
}
$this->config->set('field_2_on', $this->getRequestParameter('trust[field_2_on]'));
$this->config->set('field_label_2', $this->getRequestParameter('trust[field_label_2]'), true);
$this->config->set('field_sub_label_2', $this->getRequestParameter('trust[field_sub_label_2]'), true);
$this->config->set('field_description_2', $this->getRequestParameter('trust[field_description_2]'), true);
if ($this->getRequest()->getFileSize('trust[icon_2]'))
{
$currentFile = sfConfig::get('sf_upload_dir') . $this->config->get('icon_2', null, true);
$fileName = md5($this->getRequest()->getFileName('trust[icon_2]') . time() . rand(0, 99999));
$ext = $this->getRequest()->getFileExtension('trust[icon_2]');
if (is_file($currentFile))
{
unlink($currentFile);
}
$this->config->set('icon_2', "/picture/" . $this->getRequestParameter('culture', stLanguage::getOptLanguage()) . '/' . $fileName . $ext, true);
$this->getRequest()->moveFile('trust[icon_2]', sfConfig::get('sf_upload_dir') . $this->config->get('icon_2', null, true));
}
$this->config->set('field_3_on', $this->getRequestParameter('trust[field_3_on]'));
$this->config->set('field_label_3', $this->getRequestParameter('trust[field_label_3]'), true);
$this->config->set('field_sub_label_3', $this->getRequestParameter('trust[field_sub_label_3]'), true);
$this->config->set('field_description_3', $this->getRequestParameter('trust[field_description_3]'), true);
if ($this->getRequest()->getFileSize('trust[icon_3]'))
{
$currentFile = sfConfig::get('sf_upload_dir') . $this->config->get('icon_3', null, true);
$fileName = md5($this->getRequest()->getFileName('trust[icon_3]') . time() . rand(0, 99999));
$ext = $this->getRequest()->getFileExtension('trust[icon_3]');
if (is_file($currentFile))
{
unlink($currentFile);
}
$this->config->set('icon_3', "/picture/" . $this->getRequestParameter('culture', stLanguage::getOptLanguage()) . '/' . $fileName . $ext, true);
$this->getRequest()->moveFile('trust[icon_3]', sfConfig::get('sf_upload_dir') . $this->config->get('icon_3', null, true));
}
}
public function validateConfig()
{
$i18n = $this->getContext()->getI18N();
$data = $this->getRequestParameter('trust');
$labelValidator = new sfStringValidator();
$labelValidator->initialize($this->getContext(), array(
'max' => 13,
'max_error' => $i18n->__('Długość tekstu nie może przekraczać %max% znaków', array('%max%' => 13)),
));
if (isset($data)){
foreach (array('field_label_1', 'field_label_2', 'field_label_3', 'field_sub_label_1', 'field_sub_label_2', 'field_sub_label_3') as $name)
{
if ($data[$name] && !$labelValidator->execute($data[$name], $error))
{
$this->getRequest()->setError('trust{' . $name . '}', $error);
}
}
}
return !$this->getRequest()->hasErrors();
}
public function handleErrorConfig()
{
$this->config = stConfig::getInstance('stTrustBackend');
$this->config->setCulture($this->getRequestParameter('culture', stLanguage::getOptLanguage()));
if ($this->getRequest()->getMethod() == sfRequest::POST)
{
$this->updateConfigFromRequest();
}
$i18n = $this->getContext()->getI18N();
$this->getBreadcrumbs()->add($i18n->__('Konfiguracja'));
return sfView::SUCCESS;
}
public function executeDeleteImage()
{
$config = stConfig::getInstance('stTrustBackend');
$config->setCulture($this->getRequestParameter('culture', stLanguage::getOptLanguage()));
$image = $this->getRequestParameter('image');
if (in_array($image, array('icon_1', 'icon_2', 'icon_3')))
{
$file = sfConfig::get('sf_upload_dir') . $config->get($image, null, true);
if (is_file($file) && unlink($file))
{
unlink($file);
$i18n = $this->getContext()->getI18N();
$this->setFlash('notice', $i18n->__('Ikona została usunięta'));
$config->set($image, null, true);
$config->save(true);
}
}
else
{
$this->setFlash('warning', $i18n->__('Wystąpił bład podczas próby usuwania ikony'));
}
return $this->redirect($this->getRequest()->getReferer());
}
public function executeDeleteProductImage()
{
$i18n = $this->getContext()->getI18N();
$c = new Criteria();
$c->add(TrustPeer::PRODUCT_ID, $this->getRequestParameter('product_id'));
$trust = TrustPeer::doSelectWithI18n($c);
if($trust){
$trust = $trust[0];
}
$trust->setCulture($this->getRequestParameter('culture', stLanguage::getOptLanguage()));
// echo "<pre>";
// print_r($trust);
// echo $trust->getIconF();
//
// die();
$image = $this->getRequestParameter('image');
if (in_array($image, array('icon_f', 'icon_s', 'icon_t')))
{
if($image=="icon_f"){
$icon = $trust->getIconF();
}
if($image=="icon_s"){
$icon = $trust->getIconS();
}
if($image=="icon_t"){
$icon = $trust->getIconT();
}
$file = sfConfig::get('sf_upload_dir') . $icon;
if (is_file($file) && unlink($file))
{
unlink($file);
$i18n = $this->getContext()->getI18N();
$this->setFlash('notice', $i18n->__('Ikona została usunięta'));
if($image=="icon_f"){
$trust->setIconF(null);
}
if($image=="icon_s"){
$trust->setIconS(null);
}
if($image=="icon_t"){
$trust->setIconT(null);
}
$trust->save();
}
}
else
{
$this->setFlash('warning', $i18n->__('Wystąpił bład podczas próby usuwania ikony'));
}
return $this->redirect($this->getRequest()->getReferer());
}
protected function getBreadcrumbs()
{
if (null === $this->breadcrumbs)
{
$i18n = $this->getContext()->getI18N();
$this->breadcrumbs = parent::getBreadcrumbs();
$this->breadcrumbs->add($i18n->__('Gwarancja i zaufanie'), '@stTrustPlugin');
}
return $this->breadcrumbs;
}
}

View File

@@ -0,0 +1,13 @@
<?php
class stTrustBackendComponents extends sfComponents
{
public function executeListMenu()
{
}
}
?>

View File

@@ -0,0 +1,57 @@
generator:
class: stAdminGenerator
param:
model_class: Trust
theme: simple
head:
package: stTrustPlugin
list:
title: Lista
display: [product_id]
actions:
_create:
object_actions:
_edit: -
_delete: -
fields:
product_id: {name: Produkt, params: size=35}
field_on: {name: Tekst, params: size=35}
field_f_on: {name: Dostawa, params: size=35}
field_s_on: {name: Gwarancja, params: size=35}
field_t_on: {name: Zwrot, params: size=35}
edit:
title: Edycja zaufania
description: Edycja zaufania.
display:
"NONE": [product_id]
"Tekst pod przyciskiem koszyka": [ field_on, field_description ]
"Dostawa": [ field_f_on, field_sub_label_f, field_sub_label_f, field_description_f ]
"Gwarancja": [ field_s_on, field_sub_label_s, field_sub_label_s, field_description_s ]
"Zwrot": [ field_t_on, field_sub_label_t, field_sub_label_t, field_description_t ]
fields:
product_id: {name: Produkt}
field_on: {name: Włącz}
field_description: {name: Opis, type: textarea_tag, params: size=75x10 rich=true tinymce_options='height:300,width:400,theme:'simple''}
field_f_on: {name: Włącz }
field_label_f: {name: Tytuł, type: input_tag, params: size=20 }
field_sub_label_f: {name: Podtytuł, type: input_tag, params: size=20 }
field_description_f: {name: Opis, type: textarea_tag, params: size=75x10 rich=true tinymce_options='height:300,width:400,theme:'simple''}
icon_f: {name: Ikona, type: input_tag, params: size=20}
field_s_on: {name: Włącz}
field_label_s: {name: Tytuł, type: input_tag, params: size=20}
field_sub_label_s: {name: Podtytuł, type: input_tag, params: size=20}
field_description_s: {name: Opis, type: textarea_tag, params: size=75x10 rich=true tinymce_options='height:300,width:400,theme:'simple''}
icon_s: {name: Ikona, type: input_tag, params: size=20}
field_t_on: {name: Włącz}
field_label_t: {name: Tytuł, type: input_tag, params: size=20}
field_sub_label_t: {name: Podtytuł, type: input_tag, params: size=20}
field_description_t: {name: Opis, type: textarea_tag, params: size=75x10 rich=true tinymce_options='height:300,width:400,theme:'simple''}
icon_t: {name: Ikona, type: input_tag, params: size=20}
actions:
_list: {name: Lista}
_save: {name: Zapisz}

View File

@@ -0,0 +1,19 @@
<div class="list-menu">
<ul>
<li class="selected">
<?php echo link_to(__('Konfiguracja'),'stTrustBackend/config')?>
</li>
<li>
<?php if (sfContext::getInstance()->getUser()->getCulture() == 'pl_PL'): ?>
<a href="https://www.sote.pl/docs/gwarancja-i-zaufanie" target="_blank"><?php echo __('Dokumentacja'); ?></a>
<?php else: ?>
<a href="https://www.soteshop.com/docs/documentation" target="_blank"><?php echo __('Documentation'); ?></a>
<?php endif; ?>
</li>
</ul>
</div>
<div class="clr"></div>

View File

@@ -0,0 +1,151 @@
<?php use_helper('I18N', 'stAdminGenerator', 'Validation');?>
<?php st_view_slot_start('application-menu') ?>
<?php st_include_component('stTrustBackend', 'listMenu') ?>
<?php st_view_slot_end() ?>
<?php echo st_get_admin_head('stTrustPlugin', __('Konfiguracja'), array('shortcuts' => array(), 'culture' => $config->getCulture(), 'route' => 'stTrustBackend/config')) ?>
<?php st_include_partial('stAdminGenerator/message', array('labels' => @$labels));?>
<?php echo form_tag('stTrustBackend/config?culture=' . $config->getCulture(), array("enctype" => "multipart/form-data", 'class' => 'admin_form')) ?>
<fieldset>
<h2><?php echo __('Tekst pod przyciskiem koszyka') ?> </h2>
<div class="content">
<?php echo st_admin_get_form_field('trust[field_on]', __('Włącz'), 1, 'checkbox_tag', array('checked' => $config->get('field_on'))) ?>
<div class="row">
<label><?php echo __('Opis') ?>:</label>
<div class="field">
<?php echo textarea_tag("trust[field_description]", $config->get('field_description', null, true), array('size' => '60x6', 'rich' => true, 'tinymce_options' => "height:80,width:'60%'")) ?>
<br class="st_clear_all">
</div>
</div>
</div>
</fieldset>
<fieldset>
<h2><?php echo __('Dostawa') ?> </h2>
<div class="content">
<?php echo st_admin_get_form_field('trust[field_1_on]', __('Włącz'), 1, 'checkbox_tag', array('checked' => $config->get('field_1_on'))) ?>
<?php echo st_admin_get_form_field('trust[field_label_1]', __('Tytuł'), $config->get('field_label_1', null, true), 'input_tag', array('size' => '12', 'maxlength' => '10', 'help' => __('max 10 znaków'))) ?>
<?php echo st_admin_get_form_field('trust[field_sub_label_1]', __('Podtytuł'), $config->get('field_sub_label_1', null, true), 'input_tag', array('size' => '12', 'maxlength' => '12', 'help' => __('max 12 znaków'))) ?>
<div class="form-row">
<label><?php echo __('Ikona') ?>:<a class="help" title="<?php echo __('Rozmiar ikonki 30x30px') ?>" href="#"></a></label>
<div class="content">
<?php echo input_file_tag("trust[icon_1]", ""); ?><br />
<?php if ($config->get('icon_1', null, true) != "") : ?>
<img src="/uploads<?php echo $config->get('icon_1', null, true); ?>" alt="" style="max-width: 100px; margin-top: 7px;"><br />
<?php echo link_to(__('Usuń ikone'), 'stTrustBackend/deleteImage?image=icon_1&culture=' . $config->getCulture()) ?>
<br class="st_clear_all">
<?php endif; ?>
</div>
</div>
<div class="form-row">
<label><?php echo __('Opis') ?>:</label>
<div class="content">
<?php echo textarea_tag("trust[field_description_1]", $config->get('field_description_1', null, true), array('size' => '60x6', 'rich' => true, 'tinymce_options' => "height:80,width:'60%'")) ?>
<br class="st_clear_all">
</div>
</div>
</div>
</fieldset>
<fieldset>
<h2><?php echo __('Gwarancja') ?> </h2>
<div class="content">
<?php echo st_admin_get_form_field('trust[field_2_on]', __('Włącz'), 1, 'checkbox_tag', array('checked' => $config->get('field_2_on'))) ?>
<?php echo st_admin_get_form_field('trust[field_label_2]', __('Tytuł'), $config->get('field_label_2', null, true), 'input_tag', array('size' => '12', 'maxlength' => '10', 'help' => __('max 10 znaków'))) ?>
<?php echo st_admin_get_form_field('trust[field_sub_label_2]', __('Podtytuł'), $config->get('field_sub_label_2', null, true), 'input_tag', array('size' => '12', 'maxlength' => '12', 'help' => __('max 12 znaków'))) ?>
<div class="form-row">
<label><?php echo __('Ikona') ?>:<a class="help" title="<?php echo __('Rozmiar ikonki 30x30px') ?>" href="#"></a></label>
<div class="content">
<?php echo input_file_tag("trust[icon_2]", ""); ?><br />
<?php if ($config->get('icon_1', null, true) != "") : ?>
<img src="/uploads<?php echo $config->get('icon_2', null, true); ?>" alt="" style="max-width: 100px; margin-top: 7px;"><br />
<?php echo link_to(__('Usuń ikone'), 'stTrustBackend/deleteImage?image=icon_2&culture=' . $config->getCulture()) ?>
<br class="st_clear_all">
<?php endif; ?>
</div>
</div>
<div class="form-row">
<label><?php echo __('Opis') ?>:</label>
<div class="content">
<?php echo textarea_tag("trust[field_description_2]", $config->get('field_description_2', null, true), array('size' => '60x6', 'rich' => true, 'tinymce_options' => "height:80,width:'60%'")) ?>
<br class="st_clear_all">
</div>
</div>
</div>
</fieldset>
<fieldset>
<h2><?php echo __('Zwrot') ?></h2>
<div class="content">
<?php echo st_admin_get_form_field('trust[field_3_on]', __('Włącz'), 1, 'checkbox_tag', array('checked' => $config->get('field_3_on'))) ?>
<?php echo st_admin_get_form_field('trust[field_label_3]', __('Tytuł'), $config->get('field_label_3', null, true), 'input_tag', array('size' => '12', 'maxlength' => '10', 'help' => __('max 10 znaków'))) ?>
<?php echo st_admin_get_form_field('trust[field_sub_label_3]', __('Podtytuł'), $config->get('field_sub_label_3', null, true), 'input_tag', array('size' => '12', 'maxlength' => '12', 'help' => __('max 12 znaków'))) ?>
<div class="form-row">
<label><?php echo __('Ikona') ?>:<a class="help" title="<?php echo __('Rozmiar ikonki 30x30px') ?>" href="#"></a></label>
<div class="content">
<?php echo input_file_tag("trust[icon_3]", ""); ?><br />
<?php if ($config->get('icon_3', null, true) != "") : ?>
<img src="/uploads<?php echo $config->get('icon_3', null, true); ?>" alt="" style="max-width: 100px; margin-top: 7px;"><br />
<?php echo link_to(__('Usuń ikone'), 'stTrustBackend/deleteImage?image=icon_3&culture=' . $config->getCulture()) ?>
<br class="st_clear_all">
<?php endif; ?>
</div>
</div>
<div class="form-row">
<label><?php echo __('Opis') ?>:</label>
<div class="content">
<?php echo textarea_tag("trust[field_description_3]", $config->get('field_description_3', null, true), array('size' => '60x6', 'rich' => true, 'tinymce_options' => "height:80,width:'60%'")) ?>
<br class="st_clear_all">
</div>
</div>
</div>
</fieldset>
<div id="edit_actions">
<?php echo st_get_admin_actions_head() ?>
<?php echo st_get_admin_action('save', __('Zapisz', null, 'stAdminGeneratorPlugin'), null, array("name" => "save",)) ?>
<?php echo st_get_admin_actions_foot() ?>
</div>
</form>
<script type="text/javascript">
jQuery(function($) {
$(document).ready(function() {
$('#edit_actions').stickyBox();
});
});
</script>
<br class="st_clear_all">
<?php echo st_get_admin_foot() ?>