892 lines
25 KiB
PHP
892 lines
25 KiB
PHP
<?php
|
|
|
|
use_helper('stUrl', 'stPartial', 'I18N');
|
|
|
|
function get_navbar_attributes($item)
|
|
{
|
|
static $version = null;
|
|
|
|
if (null === $version)
|
|
{
|
|
$version = stSoteshopVersion::getVersion();
|
|
}
|
|
|
|
$attributes = array();
|
|
|
|
$items = sfConfig::get('app_navigation_bar_items');
|
|
|
|
if (isset($items[$item]['version']) && constant('stSoteshopVersion::' . $items[$item]['version']) != $version)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (isset($items[$item]['route']))
|
|
{
|
|
$route = $items[$item]['route'];
|
|
|
|
$attributes['is_external'] = strpos($route, "://") !== false;
|
|
|
|
$attributes['route'] = $route;
|
|
}
|
|
else
|
|
{
|
|
$attributes['route'] = false;
|
|
}
|
|
|
|
|
|
if (isset($items[$item]['icon']))
|
|
{
|
|
$attributes['icon'] = $items[$item]['icon'][0] == '/' ? $items[$item]['icon'] : '/images/backend/main/icons/' . $items[$item]['icon'];
|
|
}
|
|
else
|
|
{
|
|
$attributes['icon'] = false;
|
|
}
|
|
|
|
if (isset($items[$item]['icon_path']))
|
|
{
|
|
$attributes['icon_path'] = $items[$item]['icon_path'];
|
|
}
|
|
|
|
$attributes['label'] = isset($items[$item]['label']) ? $items[$item]['label'] : $item;
|
|
|
|
$attributes['i18n'] = isset($items[$item]['i18n']) ? $items[$item]['i18n'] : 'stBackend';
|
|
|
|
return $attributes;
|
|
}
|
|
|
|
function get_gadget_source(DashboardGadget $gadget)
|
|
{
|
|
$source = $gadget->isExternal() ? $gadget->getSource() : st_url_for($gadget->getSource());
|
|
|
|
$query = strpos($source, '?') ? '&' : '?';
|
|
|
|
$params = array('culture=' . sfContext::getInstance()->getUser()->getCulture());
|
|
|
|
if (!$gadget->isExternal())
|
|
{
|
|
$params[] = 'gadget_id=' . $gadget->getId();
|
|
$params[] = 'dashboard_id=' . $gadget->getDashboardId();
|
|
|
|
if (sfConfig::get('sf_debug'))
|
|
{
|
|
$params[] = 'cache=0';
|
|
}
|
|
}
|
|
|
|
$params[] = 'refreshed_at=' . $gadget->getRefreshedAt();
|
|
|
|
$min_height = $gadget->getMinHeight() ? $gadget->getMinHeight() . 'px' : 'none';
|
|
|
|
$max_height = $gadget->getMaxHeight() ? $gadget->getMaxHeight() . 'px' : 'none';
|
|
|
|
$iframe_id = 'st_dashboard_gadget_' . $gadget->getId();
|
|
|
|
return '<iframe id="' . $iframe_id . '" src="' . $source . $query . implode('&', $params) . '" scrolling="no" frameborder="0" width="100%" style="min-height: ' . $min_height . '; max-height: ' . $max_height . '"></iframe>';
|
|
}
|
|
|
|
function get_gadget_layout(Dashboard $dashboard)
|
|
{
|
|
if ($dashboard->getIsDefault())
|
|
{
|
|
$js = "jQuery('#dashboard > .menu a[href=#default]').hide();";
|
|
}
|
|
else
|
|
{
|
|
$js = "jQuery('#dashboard > .menu a[href=#default]').show();";
|
|
}
|
|
|
|
return st_get_fast_partial('stDashboard/' . $dashboard->getLayout(), array('dashboard' => $dashboard)) . javascript_tag($js);
|
|
}
|
|
|
|
function get_gadgets(Dashboard $dashboard, $column)
|
|
{
|
|
return st_get_fast_partial('stDashboard/gadgets', array('gadgets' => $dashboard->getGadgetsByColumn($column), 'column' => $column, 'dashboard' => $dashboard));
|
|
}
|
|
|
|
function get_gadget_column_id($dashboard, $column)
|
|
{
|
|
return 'column-' . ($dashboard instanceof Dashboard ? $dashboard->getId() : $dashboard) . '-' . $column;
|
|
}
|
|
|
|
function gadget_color_tag($name, DashboardGadget $gadget)
|
|
{
|
|
$colors = sfConfig::get('app_dashboard_gadget_colors');
|
|
|
|
$html = '';
|
|
|
|
$current = $gadget->getColor();
|
|
|
|
$id = get_id_from_name($name);
|
|
|
|
foreach ($colors as $color)
|
|
{
|
|
$color = '#' . $color;
|
|
|
|
if ($color == $current)
|
|
{
|
|
$html .= '<li class="current"><a style="background-color: ' . $color . '" href="' . $color . '"></a></li>';
|
|
}
|
|
else
|
|
{
|
|
$html .= '<li><a style="background-color: ' . $color . '" href="' . $color . '"></a></li>';
|
|
}
|
|
}
|
|
|
|
$js = <<<JS
|
|
jQuery(function($) {
|
|
var colors = $('#colors-$id a');
|
|
colors.click(function(event) {
|
|
var a = $(this);
|
|
$('#$id').val(a.attr('href'));
|
|
colors.parent().removeClass('current');
|
|
a.parent().addClass('current');
|
|
event.preventDefault();
|
|
});
|
|
});
|
|
JS;
|
|
|
|
return '<div id="colors-' . $id . '" class="colors"><ul>' . $html . '</ul><div class="clr"></div>' . javascript_tag($js) . input_hidden_tag($name, $current) . '</div>';
|
|
}
|
|
|
|
function gadget_refresh_rates_tag($name, DashboardGadget $gadget)
|
|
{
|
|
$options = array();
|
|
|
|
foreach (sfConfig::get('app_dashboard_gadget_refresh_rates') as $rate => $attr)
|
|
{
|
|
$options[$rate] = __($attr['label'], null, 'stBackend');
|
|
}
|
|
|
|
return select_tag($name, options_for_select($options, $gadget->getRefreshBy()));
|
|
}
|
|
|
|
function get_dashboard_layout_tag($name, Dashboard $dashboard)
|
|
{
|
|
$layouts = sfConfig::get('app_dashboard_layouts');
|
|
|
|
$html = '';
|
|
|
|
$current = $dashboard->getLayout();
|
|
|
|
$id = get_id_from_name($name);
|
|
|
|
foreach ($layouts as $layout => $params)
|
|
{
|
|
if ($layout == $current)
|
|
{
|
|
$html .= '<li class="current"><a href="#' . $layout . '"><img src="/images/backend/beta/gadgets/layouts/' . $layout . '.png" /></a></li>';
|
|
}
|
|
else
|
|
{
|
|
$html .= '<li><a href="#' . $layout . '"><img src="/images/backend/beta/gadgets/layouts/' . $layout . '.png" /></a></li>';
|
|
}
|
|
}
|
|
|
|
$js = <<<JS
|
|
jQuery(function($) {
|
|
var layouts = $('#layouts-$id a');
|
|
layouts.click(function(event) {
|
|
var a = $(this);
|
|
$('#$id').val(a.attr('href').slice(1));
|
|
layouts.parent().removeClass('current');
|
|
a.parent().addClass('current');
|
|
event.preventDefault();
|
|
});
|
|
});
|
|
JS;
|
|
|
|
return '<div id="layouts-' . $id . '" class="layouts"><ul>' . $html . '</ul><div class="clr"></div>' . javascript_tag($js) . input_hidden_tag($name, $current) . '</div>';
|
|
}
|
|
|
|
function backend_language_picker()
|
|
{
|
|
if (stSoteshopVersion::getVersion() != stSoteshopVersion::ST_SOTESHOP_VERSION_INTERNATIONAL)
|
|
{
|
|
$langs = array(
|
|
'pl' => __('Polski'),
|
|
'en' => __('Angielski'),
|
|
);
|
|
|
|
$culture = sfContext::getInstance()->getUser()->getCulture();
|
|
|
|
if ($culture == 'pl_PL')
|
|
{
|
|
$culture = 'pl';
|
|
}
|
|
|
|
if ($culture == 'en_US')
|
|
{
|
|
$culture = 'en';
|
|
}
|
|
|
|
foreach ($langs as $lang => $label)
|
|
{
|
|
$active = $lang == $culture ? ' class="active"' : '';
|
|
|
|
echo '<a href="' . st_url_for('@stLanguagePlugin?action=changeLanguage&name=' . $lang) . '" title="' . $label . '"' . $active . '>';
|
|
echo '<img src="/images/backend/icons/flags/' . $lang . '.svg">';
|
|
echo '</a>';
|
|
}
|
|
}
|
|
}
|
|
|
|
function get_language_flag_icon($culture, array $options = array())
|
|
{
|
|
if ($culture == 'pl_PL')
|
|
{
|
|
$culture = 'pl';
|
|
}
|
|
|
|
if ($culture == 'en_US')
|
|
{
|
|
$culture = 'en';
|
|
}
|
|
|
|
$size = 20;
|
|
|
|
if (isset($options['size']))
|
|
{
|
|
$size = $options['size'];
|
|
unset($options['size']);
|
|
}
|
|
|
|
if (!isset($options['style']))
|
|
{
|
|
$options['style'] = '';
|
|
}
|
|
|
|
$options['style'] .= '; max-width: ' . $size . 'px; filter: drop-shadow(0px 0px 1px #aaa);';
|
|
$options['class'] = 'align-middle';
|
|
|
|
return image_tag('/images/backend/icons/flags/' . $culture . '.svg', $options);
|
|
}
|
|
|
|
function gadget_url_for($internal_url, $parameters = array())
|
|
{
|
|
|
|
|
|
$request = sfContext::getInstance()->getRequest();
|
|
|
|
$url_params = array(
|
|
'gadget_id=' . $request->getParameter('gadget_id'),
|
|
'dashboard_id=' . $request->getParameter('dashboard_id'),
|
|
'cache=0'
|
|
);
|
|
|
|
foreach ($parameters as $name => $value)
|
|
{
|
|
$url_params[] = $name . '=' . rawurlencode($value);
|
|
}
|
|
|
|
return st_url_for($internal_url) . '?' . implode('&', $url_params);
|
|
}
|
|
|
|
function get_backend_header_text()
|
|
{
|
|
$host = sfContext::getInstance()->getRequest()->getHost();
|
|
|
|
return sprintf('<a href="%s"><img src="/images/backend/main/icons/logo_sote_top.png" alt="home" />%s<br /><span>Sell Your Products in Poland and Europe</span></a>', st_url_for('@homepage'), $host);
|
|
}
|
|
|
|
function get_backend_version_information()
|
|
{
|
|
$cache = new stFunctionCache('stBackend');
|
|
|
|
return $cache->cacheCall('_backend_version_information', array('culture' => sfContext::getInstance()->getUser()->getCulture()));
|
|
}
|
|
|
|
function _backend_version_information()
|
|
{
|
|
$content = array();
|
|
|
|
if (stLicense::isOpen())
|
|
{
|
|
$content[] = __('Darmowy sklep internetowy SOTESHOP OPEN', null, 'stBackendMain');
|
|
}
|
|
else
|
|
{
|
|
$content[] = __('Wersja', null, 'stBackendMain') . ': ' . __('SOTESHOP', null, 'stBackendMain');
|
|
}
|
|
|
|
$content[] = stApplication::getSoteshopVersion();
|
|
|
|
return implode(' ', $content);
|
|
}
|
|
|
|
function already_called($namespace)
|
|
{
|
|
static $called = array();
|
|
|
|
if (isset($called[$namespace]))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
$called[$namespace] = true;
|
|
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Tworzy okno modane o podanym id
|
|
* Ddoatkowe parametry:
|
|
* content -
|
|
* remote_url - Adres url zdalnej zawartości jaka ma być wczytana podczas otwierania okna
|
|
* @param mixed $id Id okna
|
|
* @param mixed $title Tytuł okna
|
|
* @param array|null $params Dodatkowe parametry
|
|
*
|
|
* @return string
|
|
*/
|
|
function modal($id, $title, array $params = null)
|
|
{
|
|
$content = isset($params['content']) ? $params['content'] : '';
|
|
$remoteUrl = isset($params['remote_url']) ? $params['remote_url'] : '';
|
|
$trigger = isset($params['trigger']) ? $params['trigger'] : '';
|
|
|
|
$width = isset($params['width']) ? $params['width'] : 500;
|
|
$height = isset($params['height']) ? $params['height'] : 150;
|
|
|
|
$html = <<<HTML
|
|
<div id="{$id}" class="popup_window" data-trigger="$trigger">
|
|
<div class="close"></div>
|
|
<h2>{$title}</h2>
|
|
<div class="preloader_48x48 preloader" style="position: absolute; top: 0; left: 0; height: 100%; width: 100%; background-color: rgba(255, 255, 255, 0.7); z-index: 1; display: none"></div>
|
|
<div class="content" style="width: {$width}px; min-height: {$height}px">
|
|
{$content}
|
|
</div>
|
|
</div>
|
|
<script>
|
|
jQuery(function($) {
|
|
let remoteUrl = '{$remoteUrl}';
|
|
const modal = $('#{$id}');
|
|
const trigger = modal.data('trigger') ? $(modal.data('trigger')) : null;
|
|
const preloader = modal.find('.preloader');
|
|
const parameters = {};
|
|
|
|
const api = {
|
|
show: function() {
|
|
modal.data('overlay').load();
|
|
},
|
|
hide: function() {
|
|
modal.data('overlay').close();
|
|
},
|
|
showPreloader: function() {
|
|
preloader.show();
|
|
},
|
|
hidePreloader: function() {
|
|
preloader.hide();
|
|
},
|
|
updateContent: function(content) {
|
|
modal.find('.content').html(content);
|
|
},
|
|
updateTitle: function(title) {
|
|
modal.children('h2').first().html(title);
|
|
},
|
|
getElement: function() {
|
|
return modal;
|
|
}
|
|
};
|
|
|
|
modal.data('api', api);
|
|
|
|
modal.overlay({
|
|
closeOnClick: true,
|
|
closeOnEsc: true,
|
|
top: "10%",
|
|
speed: 0,
|
|
oneInstance: false,
|
|
load: false,
|
|
closeSpeed: 0,
|
|
mask: {
|
|
color: '#444',
|
|
loadSpeed: 0,
|
|
closeSpeed: 0,
|
|
opacity: 0.5,
|
|
zIndex: 100000
|
|
},
|
|
onLoad: function() {
|
|
const overlay = this.getOverlay();
|
|
let remoteParameters = {};
|
|
let method = "GET";
|
|
|
|
console.log('remote', remoteUrl);
|
|
|
|
if (trigger && trigger.is('a') && trigger.prop('href').indexOf('#') === -1) {
|
|
remoteUrl = trigger.prop('href');
|
|
|
|
if (trigger.data('modal-remote-parameters')) {
|
|
remoteParameters = trigger.data('modal-remote-parameters');
|
|
}
|
|
|
|
if (trigger.data('modal-remote-post')) {
|
|
method = 'POST';
|
|
}
|
|
}
|
|
|
|
console.log('after_remote', remoteUrl);
|
|
|
|
if (remoteUrl) {
|
|
preloader.show();
|
|
|
|
remoteParameters = modal.triggerHandler("remote.parameters", remoteParameters);
|
|
|
|
let customRemoteUrl = modal.triggerHandler("remote.url");
|
|
|
|
if (customRemoteUrl) {
|
|
remoteUrl = customRemoteUrl;
|
|
}
|
|
|
|
$.ajax({
|
|
url: remoteUrl,
|
|
data: remoteParameters,
|
|
success: function(response) {
|
|
overlay.find('.content').html('object' === typeof response && response.content ? response.content : response);
|
|
overlay.trigger('modal.load', api);
|
|
preloader.hide();
|
|
},
|
|
method: method.toUpperCase(),
|
|
});
|
|
}
|
|
|
|
overlay.trigger('modal.show', api);
|
|
},
|
|
onClose: function() {
|
|
this.getOverlay().trigger('modal.hide', api);
|
|
}
|
|
});
|
|
|
|
if (trigger) {
|
|
trigger.click(function() {
|
|
api.show();
|
|
return false;
|
|
});
|
|
}
|
|
|
|
modal.on('hide', function() {
|
|
api.hide();
|
|
});
|
|
|
|
modal.on('show', function() {
|
|
api.show();
|
|
});
|
|
|
|
modal.on('preloader.show', function() {
|
|
api.showPreloader();
|
|
});
|
|
|
|
modal.on('preloader.hide', function() {
|
|
api.hidePreloader();
|
|
});
|
|
});
|
|
</script>
|
|
HTML;
|
|
return $html;
|
|
}
|
|
|
|
function modal_block_start()
|
|
{
|
|
ob_start();
|
|
}
|
|
|
|
function modal_block_end($id, $title, array $params = null)
|
|
{
|
|
$content = ob_get_clean();
|
|
$params['content'] = $content;
|
|
echo modal($id, $title, $params);
|
|
}
|
|
|
|
function init_tooltip($selector = ".tooltip", $options = array())
|
|
{
|
|
static $selectors = array();
|
|
|
|
/**
|
|
* Duplicate tooltip initialization fix
|
|
*/
|
|
if (false !== strpos($selector, '.tooltip,'))
|
|
{
|
|
$selector = '.tooltip';
|
|
}
|
|
|
|
if (!isset($selectors[$selector]))
|
|
{
|
|
$selectors[$selector] = true;
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
|
|
$trigger = isset($options['trigger']) ? $options['trigger'] : 'mouseenter focus';
|
|
|
|
$hideAll = '';
|
|
|
|
$appendTo = isset($options['append_to']) ? $options['append_to'] : 'document.body';
|
|
|
|
$interactive = isset($options['interactive']) && false === $options['interactive'] ? 'false' : 'true';
|
|
|
|
if (isset($options['hideAll']) && $options['hideAll'])
|
|
{
|
|
$hideAll = "tippy.hideAll({ duration: 0 })";
|
|
}
|
|
|
|
$js = <<<JS
|
|
jQuery(function($) {
|
|
var instance = tippy('$selector', {
|
|
allowHTML: true,
|
|
interactive: $interactive,
|
|
animation: 'scale',
|
|
'trigger': '$trigger',
|
|
zIndex: 400000,
|
|
appendTo: () => $appendTo,
|
|
onShow: function(instance) {
|
|
$hideAll;
|
|
$(document).trigger('tooltip-show', instance);
|
|
return null !== instance.props.content && instance.props.content.length > 0;
|
|
},
|
|
content: function(reference) {
|
|
if (reference.getAttribute('data-tooltip-source') == 'content')
|
|
{
|
|
reference.setAttribute('data-title', reference.innerHTML);
|
|
reference.removeAttribute('data-tooltip-source');
|
|
}
|
|
else if (reference.getAttribute('title'))
|
|
{
|
|
var title = reference.getAttribute('title');
|
|
|
|
if (title) {
|
|
reference.setAttribute('data-title', title.replace(/\*([^*]+)\*/g, '<b>$1</b>'));
|
|
reference.removeAttribute('title');
|
|
}
|
|
}
|
|
|
|
return reference.getAttribute('data-title');
|
|
},
|
|
});
|
|
|
|
$(document).data('tippy{$selector}', instance);
|
|
});
|
|
JS;
|
|
|
|
echo javascript_tag($js);
|
|
}
|
|
|
|
function get_service_information()
|
|
{
|
|
$cache = new stFunctionCache('stBackend');
|
|
|
|
$cache->removeAll();
|
|
|
|
return $cache->cacheCall('_service_information', array('culture' => sfContext::getInstance()->getUser()->getCulture()));
|
|
}
|
|
|
|
function _service_information()
|
|
{
|
|
$lang = sfContext::getInstance()->getUser()->getCulture();
|
|
|
|
$licenseBlocked = stLicenseAbuse::isBlocked();
|
|
|
|
if ($licenseBlocked)
|
|
{
|
|
stNotification::getInstance()->addAlert('stUpdate', 'Wystąpił błąd podczas weryfikacji licencji. Proszę o pilny kontakt z SOTE. Sklep może zostać zablokowany.', array(
|
|
'i18n_catalogue' => 'stBackend',
|
|
'singular' => true,
|
|
'action' => 'https://www.sote.pl/page/block',
|
|
'icon' => 'refresh'
|
|
));
|
|
|
|
return content_tag('span', __('Wystąpił błąd podczas weryfikacji licencji. Proszę o pilny kontakt z SOTE. Sklep może zostać zablokowany.', null, 'stBackend'), array(
|
|
'class' => 'color-danger-dark',
|
|
));
|
|
}
|
|
|
|
$license = new stLicense();
|
|
$communication = stCommunication::getLicenseInfo(); // Pobierz informacje o licnecji z SOTE
|
|
$iwt_till = $communication['support']; // Pakiet VIP, dawniej IWT. Data ważności pakietu. Wycofane w 8.
|
|
$upgrade_exp_date = $communication['guarantee']; // Data dostpu do aktualizacji sklepu
|
|
$current_date = date("Y-m-d"); // Aktualna data
|
|
$seven = stCommunication::getIsSeven(); // Czy sklep ma dostępne aktualizacje do wersj 7
|
|
|
|
|
|
$service_has_update = 0; // Czy usługa ma aktualizacje, dotyczy werji bezterminowych
|
|
|
|
switch ($communication['type'])
|
|
{
|
|
case "MIESIĄC":
|
|
// $message_service = __("Abonament miesięczny", null, 'stBackendMain');
|
|
$message_url = "#";
|
|
break;
|
|
case "MIESIĄC+HOSTING":
|
|
// $message_service = __("Abonament miesięczny+hosting", null, 'stBackendMain');
|
|
$message_url = "#";
|
|
break;
|
|
case "ROK":
|
|
// $message_service = __("Abonament roczny", null, 'stBackendMain');
|
|
$message_url = "#";
|
|
break;
|
|
case "ROK+HOSTING":
|
|
// $message_service = __("Abonament roczny+hosting", null, 'stBackendMain');
|
|
$message_url = "#";
|
|
break;
|
|
case "BEZTERMINOWO":
|
|
$service_has_update = 1;
|
|
// $message_service = __("Licencja bezterminowa", null, 'stBackendMain');
|
|
$message_url = get_update_link();
|
|
break;
|
|
case "BEZTERMINOWO+HOSTING":
|
|
$service_has_update = 1;
|
|
// $message_service = __("Licencja bezterminowa+hosting", null, 'stBackendMain');
|
|
$message_url = get_update_link();
|
|
break;
|
|
default:
|
|
// $message_service = $communication['type'];
|
|
break;
|
|
}
|
|
|
|
if (!$service_has_update)
|
|
{
|
|
// komunikaty dla abonamentów
|
|
$message_expire_name = __("Usługa ważna do", null, 'stBackendMain');
|
|
$message_expire_service = __("Twoja usługa wygasła. Dokonaj opłaty na kolejny okres.", null, 'stBackendMain');
|
|
$message_payment = null;
|
|
}
|
|
else
|
|
{
|
|
// komunikaty dla licencji bezterminonwych
|
|
$message_expire_name = __("Aktualizacje dostępne do", null, 'stBackendMain');
|
|
$message_expire_service = __("Dostęp do pomocy i aktualizacji sklepu wygasł.", null, 'stBackendMain');
|
|
$message_payment = __("Zamów dostęp do aktualizacji", null, 'stBackendMain');
|
|
}
|
|
|
|
$message_expire = __($message_expire_name . ": %date%", array("%date%" => '<b>' . $upgrade_exp_date . '</b>'), 'stBackendMain');
|
|
|
|
|
|
// Sprawdzenie czy usługa wygasła
|
|
$message_expire_notice = '';
|
|
if ($current_date > $upgrade_exp_date)
|
|
{
|
|
// usługa wygasła, nie ma dostępu do usługi/akualizacji
|
|
$message_expire_notice = '<br /><div style="color: #E01111;">' . $message_expire_service;
|
|
if (!empty($message_payment))
|
|
{
|
|
$message_expire_notice .= ' <a href="' . $message_url . '" target="sote"><u style="color: #555555;">' . $message_payment . '</u></a></div>';
|
|
}
|
|
|
|
if (!$service_has_update)
|
|
{
|
|
stNotification::getInstance()->addAlert('stUpdate', 'Twoja usługa wygasła. Dokonaj opłaty na kolejny okres.', array(
|
|
'i18n_catalogue' => 'stBackendMain',
|
|
'singular' => true,
|
|
'icon' => 'refresh'
|
|
));
|
|
}
|
|
else
|
|
{
|
|
stNotification::getInstance()->addAlert('stUpdate', 'Dostęp do pomocy i aktualizacji sklepu wygasł. %link%', array(
|
|
'i18n_catalogue' => 'stBackendMain',
|
|
'i18n_params' => array('%link%' => 'Zamów dostęp do aktualizacji'),
|
|
'action' => get_update_link(),
|
|
'singular' => true,
|
|
'icon' => 'refresh'
|
|
));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$message_expire .= '<br />' . __("Serwis i aktualizacje aktywne.", null, 'stBackendMain');
|
|
stNotification::getInstance()->markAllAsRead('stUpdate');
|
|
}
|
|
|
|
return $message_expire . '<br />' . $message_expire_notice;
|
|
}
|
|
|
|
|
|
/**
|
|
* Link do aktualziacji z uwzględnieniem wersji jeżykowej
|
|
* @return string URL
|
|
*/
|
|
function get_update_link()
|
|
{
|
|
$lang = sfContext::getInstance()->getUser()->getCulture();
|
|
|
|
if ($lang == 'pl_PL')
|
|
{
|
|
$link_update = 'https://www.sote.pl/dostep-do-aktualizacji.html';
|
|
}
|
|
else
|
|
{
|
|
$link_update = 'https://www.soteshop.com/access-to-update.html';
|
|
}
|
|
|
|
return $link_update;
|
|
}
|
|
|
|
function get_app_icon($icon_path, $default = true)
|
|
{
|
|
$path = $icon_path;
|
|
|
|
if ($path)
|
|
{
|
|
$path = _get_app_icon_svg($path);
|
|
|
|
if (null === $path)
|
|
{
|
|
$icon_file = basename($icon_path);
|
|
$sf_web_dir = sfConfig::get('sf_web_dir');
|
|
|
|
if ($icon_file != "logo_sote_top.png")
|
|
{
|
|
if (is_file($sf_web_dir . '/images/backend/main/icons/red_new/' . $icon_file))
|
|
{
|
|
$path = '/images/backend/main/icons/red_new/' . $icon_file;
|
|
}
|
|
elseif (is_file($sf_web_dir . '/images/backend/main/icons/red/' . $icon_file))
|
|
{
|
|
$path = '/images/backend/main/icons/red/' . $icon_file;
|
|
}
|
|
elseif (is_file('/images/backend/main/icons/' . $icon_file))
|
|
{
|
|
$path = '/images/backend/main/icons/' . $icon_file;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (null === $path && $default)
|
|
{
|
|
$path = _get_app_icon_svg('stDefaultApp.svg');
|
|
}
|
|
|
|
return $path;
|
|
}
|
|
|
|
|
|
function _get_app_icon_svg($path)
|
|
{
|
|
$info = pathinfo($path);
|
|
|
|
$info['extension'] = 'svg';
|
|
|
|
$svgFilename = $info['filename'] . '.' . $info['extension'];
|
|
|
|
if (!$info['dirname'] || $info['dirname'] == '.' || 0 === strpos($info['dirname'], '/images/backend/'))
|
|
{
|
|
$info['dirname'] = '/images/backend/applications';
|
|
}
|
|
|
|
$svgPath = $info['dirname'] . '/' . $svgFilename;
|
|
|
|
if (is_file(sfConfig::get('sf_web_dir') . $svgPath))
|
|
{
|
|
return $svgPath;
|
|
}
|
|
|
|
$svgPath = '/plugins/' . $info['filename'] . '/images/backend/' . $svgFilename;
|
|
|
|
if (is_file(sfConfig::get('sf_web_dir') . $svgPath))
|
|
{
|
|
return $svgPath;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
function st_backend_get_icon_path($name, $default = true)
|
|
{
|
|
$mappings = sfConfig::get('app_icon_mapping');
|
|
|
|
if (isset($mappings[$name]))
|
|
{
|
|
$name = $mappings[$name];
|
|
}
|
|
|
|
$filename = $name . '.svg';
|
|
|
|
if (is_file(sfConfig::get('sf_web_dir') . '/images/backend/icons/svg/' . $filename))
|
|
{
|
|
return '/images/backend/icons/svg/' . $filename . '?v' . stApplication::getApplicationVersion('stBackend');
|
|
}
|
|
|
|
$pluginPaths = sfLoader::getPluginModulePaths();
|
|
$moduleName = sfContext::getInstance()->getModuleName();
|
|
|
|
if (isset($pluginPaths[$moduleName]))
|
|
{
|
|
list(,,$pluginDir) = explode('/', $pluginPaths[$moduleName]);
|
|
$iconPluginPath = '/plugins/' . $pluginDir . '/images/backend/icons/' . $filename;
|
|
|
|
if (is_file(sfConfig::get('sf_web_dir') . $iconPluginPath))
|
|
{
|
|
return $iconPluginPath. '?v' . stApplication::getApplicationVersion('stBackend');
|
|
}
|
|
}
|
|
|
|
if ($path = get_app_icon($name, $default))
|
|
{
|
|
return $path;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
function st_backend_is_left_menu_hidden()
|
|
{
|
|
$config = stAdminGeneratorUserConfiguration::getDefault(sfContext::getInstance());
|
|
|
|
return $config->getParameter('left_menu.hidden', MobileDetect::getInstance()->isMobile());
|
|
}
|
|
|
|
function st_backend_get_icon($name, array $options = array())
|
|
{
|
|
if (isset($options['size']))
|
|
{
|
|
switch ($options['size'])
|
|
{
|
|
case 'medium':
|
|
$options['size'] = 22;
|
|
break;
|
|
}
|
|
}
|
|
|
|
$icon = st_backend_get_icon_path($name, isset($options['default']) ? $options['default'] : true);
|
|
|
|
if (!$icon)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
$iconClass = $name[0] != '/' ? ' svg-icon-' . $name : '';
|
|
$size = isset($options['size']) ? "; width: {$options['size']}px; height: {$options['size']}px" : '';
|
|
$customColor = '';
|
|
$style = isset($options['style']) ? '; ' . $options['style'] : '';
|
|
|
|
if (isset($options['color']))
|
|
{
|
|
if ($options['color'][0] == '#')
|
|
{
|
|
$customColor = "; background-color: {$options['color']}";
|
|
}
|
|
else
|
|
{
|
|
$iconClass .= ' svg-icon-color-' . $options['color'];
|
|
}
|
|
}
|
|
|
|
if (isset($options['hidden']))
|
|
{
|
|
$style .= '; display: none';
|
|
}
|
|
|
|
if (isset($options['class']))
|
|
{
|
|
$iconClass .= ' ' . $options['class'];
|
|
}
|
|
|
|
return content_tag('span', '', array(
|
|
'class' => 'svg-icon' . $iconClass,
|
|
'style' => "-webkit-mask-image: url($icon); mask-image: url($icon) $size $customColor $style",
|
|
'title' => isset($options['title']) ? htmlspecialchars($options['title']) : null,
|
|
));
|
|
}
|