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,233 @@
<?php
/**
* SOTESHOP/appWishesPlugin
*
*
* @package appWishesPlugin
* @author Bartosz Alejski <whiteface@whiteface.pl>
*/
class appWishesBackendActions extends sfActions{
public function executeResponsiveConfig(){
$this->forward_parameters = $this->getUser()->getAttributeHolder()->getAll('sf_admin/appWishesResponsiveConfigBackend/site_forward_parameters');
$this->config = stConfig::getInstance($this->getContext(), 'appWishesResponsiveConfigBackend');
$this->config->setCulture($this->getRequestParameter('culture', stLanguage::getOptLanguage()));
$video_array = unserialize($this->config->get('wishes_responsive_video'));
$images_array = unserialize($this->config->get('wishes_responsive_images'));
$number_of_elements = count($images_array);
$number_of_elements_video = count($video_array);
if ($this->getRequest()->getMethod() == sfRequest::POST){
$this->config->set('wishes_responsive_on', $this->getRequestParameter('wishes[wishes_responsive_on]'));
$this->config->set('wishes_responsive_description', $this->getRequestParameter('wishes[wishes_responsive_description]'), true);
$this->config->set('wishes_responsive_link_on', $this->getRequestParameter('wishes[wishes_responsive_link_on]'));
$this->config->set('wishes_responsive_music_on', $this->getRequestParameter('wishes[wishes_responsive_music_on]'));
$this->config->set('wishes_responsive_music_autoplay', $this->getRequestParameter('wishes[wishes_responsive_music_autoplay]'));
$this->config->set('wishes_responsive_song_number', $this->getRequestParameter('wishes[wishes_responsive_song_number]'));
// ustawienie aktywnego zdjęcia
if ($this->getRequestParameter('wishes[image_radio]') || $this->getRequestParameter('wishes[video_radio]') ){
// zerowanie tabel
for ($i = 0; $i <= $number_of_elements-1; $i++){
$images_array[$i]['active'] = 0;
}
for ($i = 0; $i <= $number_of_elements_video-1; $i++){
$video_array[$i]['active'] = 0;
}
if ($this->getRequestParameter('wishes[image_radio]')){
foreach ($images_array as $key => $image){
if($image['name'] == $this->getRequestParameter('wishes[image_radio]')){
$new_active = $key;
}
}
$images_array[$new_active]['active'] = 1;
$fileName = $this->getRequestParameter('wishes[image_radio]');
}elseif($this->getRequestParameter('wishes[video_radio]')){
foreach ($video_array as $key => $video){
if($video['name'] == $this->getRequestParameter('wishes[video_radio]')){
$new_active = $key;
}
}
$video_array[$new_active]['active'] = 1;
$fileName = $this->getRequestParameter('wishes[video_radio]');
}
}
// załadowanie nowego zdjęcia
if ($this->getRequest()->getFileSize('wishes[image]')){
$fileName = $this->getRequest()->getFileName('wishes[image]');
$ext = $this->getRequest()->getFileExtension('wishes[image]');
if($ext=='.jpg' || $ext=='.gif' || $ext=='.png' || $ext=='.jpeg'){
$this->getRequest()->moveFile('wishes[image]', sfConfig::get('sf_upload_dir') . '/wishes_picture/' . $fileName);
for ($i = 0; $i <= $number_of_elements-1; $i++){
$images_array[$i]['active'] = 0;
}
for ($i = 0; $i <= $number_of_elements_video-1; $i++){
$video_array[$i]['active'] = 0;
}
$images_array[$number_of_elements]['name'] = $fileName;
$images_array[$number_of_elements]['active'] = 1;
}elseif($ext == '.bin'){
$this->getRequest()->moveFile('wishes[image]', sfConfig::get('sf_upload_dir') . '/wishes_picture/' . $fileName);
for ($i = 0; $i <= $number_of_elements-1; $i++){
$images_array[$i]['active'] = 0;
}
for ($i = 0; $i <= $number_of_elements_video-1; $i++){
$video_array[$i]['active'] = 0;
}
$video_array[$number_of_elements_video]['name'] = $fileName;
$video_array[$number_of_elements_video]['active'] = 1;
}
}
$this->config->set('wishes_responsive_images', serialize($images_array));
$this->config->set('wishes_responsive_video', serialize($video_array));
$this->config->set('wishes_responsive_active_image', $fileName);
$this->config->save();
stFastCacheManager::clearCache();
$this->setFlash('notice', 'Twoje zmiany zostały zapisane');
$this->redirect('appWishesBackend/responsiveConfig?culture='.$this->getRequestParameter('culture', stLanguage::getOptLanguage()));
}
$this->images_array = $images_array;
$this->video_array = $video_array;
}
public function executeDelete(){
$fileName = $this->getRequestParameter('name');
$this->config = stConfig::getInstance($this->getContext(), 'appWishesResponsiveConfigBackend');
$images_array = unserialize($this->config->get('wishes_responsive_images'));
$this->config->setCulture($this->getRequestParameter('culture', stLanguage::getOptLanguage()));
$i = 0;
$set_default = 0;
foreach ($images_array as $key=>$image){
if($image['name'] == $fileName){
$new_active = $key;
if($image['active']==1){
$set_default = 1;
}
}
$i++;
}
unset($images_array[$new_active]);
if($set_default==1){
$images_array[3]['active'] = 1;
}
$this->config->set('wishes_responsive_images', serialize($images_array));
if($set_default==1){
$this->config->set('wishes_responsive_active_image', 'responsive1.jpg');
}
$this->config->save();
stFastCacheManager::clearCache();
$this->redirect('appWishesBackend/responsiveConfig?culture='.$this->getRequestParameter('culture', stLanguage::getOptLanguage()));
}
public function executeDeleteVideo(){
$fileName = $this->getRequestParameter('name');
$this->config = stConfig::getInstance($this->getContext(), 'appWishesResponsiveConfigBackend');
$video_array = unserialize($this->config->get('wishes_responsive_video'));
$this->config->setCulture($this->getRequestParameter('culture', stLanguage::getOptLanguage()));
$i = 0;
$set_default = 0;
foreach ($video_array as $key=>$video){
if($video['name'] == $fileName){
$new_active = $key;
if($image['active']==1){
$set_default = 1;
}
}
$i++;
}
unset($video_array[$new_active]);
if($set_default==1){
$video_array[1]['active'] = 1;
}
$this->config->set('wishes_responsive_video', serialize($video_array));
if($set_default==1){
$this->config->set('wishes_responsive_active_image', 'chistmas-video1.mp4');
}
$this->config->save();
stFastCacheManager::clearCache();
$this->redirect('appWishesBackend/responsiveConfig?culture='.$this->getRequestParameter('culture', stLanguage::getOptLanguage()));
}
}

View File

@@ -0,0 +1,6 @@
<?php
class appWishesBackendComponents extends sfComponents{
public function executeListMenu(){
}
}

View File

@@ -0,0 +1,19 @@
<div class="list-menu">
<ul>
<li class="selected">
<?php echo link_to(__('Konfiguracja'),'appWishesBackend/responsiveConfig') ?>
</li>
<li>
<?php if (sfContext::getInstance()->getUser()->getCulture() == 'pl_PL'): ?>
<a href="https://www.sote.pl/wishes.html" target="_blank"><?php echo __('Dokumentacja'); ?></a>
<?php else: ?>
<a href="https://www.sote.pl/wishes.html" target="_blank"><?php echo __('Documentation'); ?></a>
<?php endif; ?>
</li>
</ul>
</div>
<div class="clr"></div>

View File

@@ -0,0 +1,247 @@
<style type="text/css">
.radio-img label {
display: inline-block;
cursor: pointer;
padding: 0 !important;
width: 100px !important;
height: 60px !important;
margin: 1px 10px 10px 1px;
border: 2px solid #ececec;
text-align: center !important;
}
.radio-img label.video{
display: inline-block;
cursor: pointer;
padding: 0 !important;
width: 194px !important;
height: 60px !important;
margin: 1px 10px 10px 1px;
border: 2px solid #ececec;
text-align: center !important;
}
.radio-img label img{
max-width: 100%;
max-height: 100%;
}
.radio-img input[type=radio]{
display: none;
}
.radio-img input[type=radio]:checked + label{
border-color: #e10000;
border-width: 3px;
margin: 0px 9px 9px 0px;
}
.delete_img{
position: absolute;
top: -4px;
right: 3px;
background: #fff;
border-radius: 50%;
}
</style>
<?php
use_helper('Object', 'Validation', 'ObjectAdmin', 'I18N', 'Date', 'VisualEffect', 'stAdminGenerator');
$culture = $config->getCulture();
$route ='appWishesBackend/responsiveConfig';
echo st_get_admin_head(array('@appWishesPlugin', __('Świateczne dodatki do sklepu'), '/images/backend/main/icons/red/appWishesPlugin.png'), __('Konfiguracja'), array(
'shortcuts' => array(),
'culture' => isset($culture) ? $culture : null, 'route' => isset($route) ? $route : null)); ?>
<?php st_view_slot_start('application-menu') ?>
<?php st_include_component('appWishesBackend', 'listMenu') ?>
<?php st_view_slot_end() ?>
<?php st_include_partial('stAdminGenerator/message', array('i18n_catalogue' => 'appWishesBackend')); ?>
<?php echo form_tag('appWishesBackend/responsiveConfig?culture='.$config->getCulture(), array(
'id' => 'sf_admin_edit_form',
'name' => 'sf_admin_edit_form',
'multipart' => true,
'class' => 'admin_form'
)) ?>
<fieldset>
<div class="content">
<div class="row">
<?php echo st_admin_get_form_field('wishes[wishes_responsive_on]', __('Włącz baner'), 1, 'checkbox_tag', array('checked' => $config->get('wishes_responsive_on'))) ?>
<br class="st_clear_all">
</div>
<div class="form-row">
<label><?php echo __('Życzenia') ?></label>
<div class="content">
<?php echo textarea_tag("wishes[wishes_responsive_description]", $config->get('wishes_responsive_description', null, true), array('size' => '90x20', 'rich' => true, 'tinymce_options' => "width: 600, height: 250"))?>
<br class="st_clear_all">
</div>
</div>
<div class="form-row">
<label><?php echo __('Obrazek') ?></label>
<div class="content radio-img">
<?php $i = 1; ?>
<?php foreach ($images_array as $image): ?>
<div style="float:left; position: relative;">
<input id="responsive_<?php echo $i ?>" <?php if($image['active']==1) { echo "checked"; }; ?> type="radio" name="wishes[image_radio]" value="<?php echo $image['name']; ?>" class="image_radio">
<label for="responsive_<?php echo $i ?>"><img src="/uploads/wishes_picture/<?php echo $image['name']; ?>" /></label>
<?php if($image['name']!="responsive1.png" && $image['name']!="responsive2.png" && $image['name']!="responsive3.png" && $image['name']!="responsive4.png" && $image['name']!="responsive5.png" && $image['name']!="responsive6.png" && $image['name']!="responsive7.png" && $image['name']!="responsive8.png" && $image['name']!="responsive9.png" && $image['name']!="responsive10.png" && $image['name']!="responsive11.png" && $image['name']!="responsive12.png" && $image['name']!="responsive13.png" && $image['name']!="responsive14.png" && $image['name']!="responsive15.png") : ?>
<a class="delete_img" href="/backend.php/appWishesBackend/delete?name=<?php echo $image['name']; ?>" onclick="if (confirm('<?php echo __('Jesteś pewien?') ?>')) { f = document.createElement('form'); document.body.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit(); };return false;"><img src="/images/backend/icons/delete.gif" title="delete" alt="delete"></a>
<?php endif; ?>
</div>
<?php $i++; ?>
<?php endforeach; ?>
<br class="st_clear_all">
</div>
</div>
<div class="form-row">
<label><?php echo __('Video') ?></label>
<div class="content radio-img">
<?php $i = 1; ?>
<?php foreach ($video_array as $video): ?>
<div style="float:left; position: relative;">
<input id="responsive_video_<?php echo $i ?>" <?php if($video['active']==1) { echo "checked"; }; ?> type="radio" name="wishes[video_radio]" value="<?php echo $video['name']; ?>" class="video_radio">
<label for="responsive_video_<?php echo $i ?>" class="video">
<video loop="" muted="" style="width: 194px; height: 60px;">
<source src="/uploads/wishes_picture/<?php echo $video['name']; ?>" type="video/mp4">
</video>
</label>
<?php if($video['name']!="christmas-video1.mp4" && $video['name']!="christmas-video2.mp4" && $video['name']!="christmas-video3.mp4" && $video['name']!="christmas-video4.mp4" && $video['name']!="christmas-video5.mp4" && $video['name']!="christmas-video6.mp4"): ?>
<a class="delete_img" href="/backend.php/appWishesBackend/deleteVideo?name=<?php echo $video['name']; ?>" onclick="if (confirm('<?php echo __('Jesteś pewien?') ?>')) { f = document.createElement('form'); document.body.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit(); };return false;"><img src="/images/backend/icons/delete.gif" title="delete" alt="delete"></a>
<?php endif; ?>
</div>
<?php $i++; ?>
<?php endforeach; ?>
<br class="st_clear_all">
</div>
</div>
<div class="form-row">
<label><?php echo __('Dodaj obrazek / video (mp4)') ?> <a href="#" class="help" title="<?php echo htmlspecialchars(__('Zalecany rozmiar zdjęcia 470 × 288 px Zalecany rozmiar video 1290 x 400 px', null, 'appWishesBackend')) ?>"></a></label>
<div class="content">
<input type="file" value="" id="wishes_image" name="wishes[image]">
<br class="st_clear_all">
</div>
</div>
<div class="row">
<?php echo st_admin_get_form_field('wishes[wishes_responsive_music_on]', __('Włącz kolęde'), 1, 'checkbox_tag', array('checked' => $config->get('wishes_responsive_music_on'))) ?>
<br class="st_clear_all">
</div>
<div class="row">
<label><?php echo __('Wybierz kolęde') ?>:</label>
<div class="field">
<select style="float: left;" id="wishes_wishes_responsive_song_number" name="wishes[wishes_responsive_song_number]">
<option <?php if($config->get('wishes_responsive_song_number')=="1") : ?> selected="selected" <?php endif; ?> value="1">Mizerna Cicha</option>
<option <?php if($config->get('wishes_responsive_song_number')=="3") : ?> selected="selected" <?php endif; ?> value="3">Jezus Malusieńki</option>
<option <?php if($config->get('wishes_responsive_song_number')=="6") : ?> selected="selected" <?php endif; ?> value="6">Oj Maluski, Maluski</option>
</select>
<div id="song_1" class="cloud" style="float:left; margin: 2px;">
<!-- Mizerna cicha -->
<iframe width="100%" height="20" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/178863854&amp;color=ff5500&amp;inverse=false&amp;auto_play=false&amp;show_user=true"></iframe>
</div>
<div id="song_3" class="cloud" style="float:left; margin: 2px;">
<!-- Jezus malusienki -->
<iframe width="100%" height="20" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/178863856&amp;color=ff5500&amp;inverse=false&amp;auto_play=false&amp;show_user=true"></iframe>
</div>
<div id="song_6" class="cloud" style="float:left; margin: 2px;">
<!-- Oj Maluski, Maluski -->
<iframe width="100%" height="20" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/178863855&amp;color=ff5500&amp;inverse=false&amp;auto_play=false&amp;show_user=true"></iframe>
</div>
<div class="clr"></div>
</div>
</div>
</div>
</fieldset>
<div id="wishes_save">
<?php echo st_get_admin_actions_head() ?>
<?php echo st_get_admin_action('save', __('Zapisz', null, 'stAdminGeneratorPlugin')) ?>
<?php echo st_get_admin_actions_foot() ?>
</div>
</form>
<?php echo st_get_admin_foot() ?>
<script type="text/javascript">
jQuery(function($) {
$('#wishes_save').stickyBox();
});
</script>
<script type="text/javascript">
jQuery(function($) {
$(document).ready(function() {
$(".image_radio").change(function () {
$(".video_radio").each(function(i) {
this.checked = false;
});
});
$(".video_radio").change(function () {
$(".image_radio").each(function(i) {
this.checked = false;
});
});
checkvisible();
$('#wishes_wishes_responsive_song_number').on("change", function() {
checkvisible();
});
});
function checkvisible() {
$('.cloud').hide();
$('#song_'+$("#wishes_wishes_responsive_song_number").val()).show();
}
});
</script>