first commit
This commit is contained in:
31
apps/backend/lib/helper/stAlertHelper.php
Normal file
31
apps/backend/lib/helper/stAlertHelper.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stBackend
|
||||
*
|
||||
* Ten plik należy do aplikacji stBackend opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stBackend
|
||||
* @subpackage helpers
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
|
||||
* @version $Id: stAlertHelper.php 9 2009-08-24 09:31:16Z michal $
|
||||
* @author Łukasz Andrzejak <lukasz.andrzejak@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ładujemy komunikaty widoczne na głównej stronie, wedle modułu
|
||||
*
|
||||
* @param string $module
|
||||
* @return string
|
||||
*/
|
||||
function stAlert($module)
|
||||
{
|
||||
if (empty($module)) return;
|
||||
include(sfConfig::get('sf_app_module_dir').'/'.$module.'/lib/'.$module.'MainFunctions.class.php');
|
||||
if(class_exists($module.'MainFunctions')) {
|
||||
return call_user_func($module.'MainFunctions::alertMessage');
|
||||
} else return;
|
||||
}
|
||||
891
apps/backend/lib/helper/stBackendHelper.php
Normal file
891
apps/backend/lib/helper/stBackendHelper.php
Normal file
@@ -0,0 +1,891 @@
|
||||
<?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,
|
||||
));
|
||||
}
|
||||
23
apps/backend/lib/helper/stGadgetHelper.php
Normal file
23
apps/backend/lib/helper/stGadgetHelper.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
function st_gadget_filters($action, array $fields, array $values = array())
|
||||
{
|
||||
return st_get_component('stAdminGenerator', 'filters', array(
|
||||
'fields' => $fields,
|
||||
'values' => $values,
|
||||
'action' => gadget_url_for($action)
|
||||
));
|
||||
}
|
||||
|
||||
function st_gadget_date_select_tag($name, $value)
|
||||
{
|
||||
return select_tag($name, options_for_select(array(
|
||||
'today' => __('dzisiaj', null, 'stBackend'),
|
||||
'yesterday' => __('wczoraj', null, 'stBackend'),
|
||||
'7' => __('7 dni', null, 'stBackend'),
|
||||
'14' => __('14 dni'),
|
||||
'30' => __('30 dni', null, 'stBackend'),
|
||||
'this_month' => __('ten miesiąc', null, 'stBackend'),
|
||||
'prev_month' => __('poprzedni miesiąc', null, 'stBackend'),
|
||||
), $value));
|
||||
}
|
||||
26
apps/backend/lib/helper/stWidgetsHelper.php
Normal file
26
apps/backend/lib/helper/stWidgetsHelper.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Desktop widget components helper
|
||||
*/
|
||||
|
||||
|
||||
function st_open_widget($name,$title)
|
||||
{
|
||||
$name=preg_replace("/[\s]*/",'_',$name);
|
||||
|
||||
return
|
||||
'
|
||||
<div class="qpanel_list_main st_round_box" id="widget-'.$name.'">
|
||||
<div class="st_round_box_header">'.$title.'</div>
|
||||
<div class="st_round_box_content">
|
||||
';
|
||||
}
|
||||
|
||||
function st_close_widget()
|
||||
{
|
||||
return
|
||||
'
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
26
apps/backend/lib/myUser.class.php
Normal file
26
apps/backend/lib/myUser.class.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stAuthUsers
|
||||
*
|
||||
* Ten plik należy do aplikacji stAuthUsers opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stAuthUsers
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
|
||||
* @version $Id: myUser.class.php 251 2009-03-30 11:35:06Z marek $
|
||||
* @author Michal Prochowski <michal.prochowski@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa myUser
|
||||
*
|
||||
* @package stAuthUsers
|
||||
* @subpackage libs
|
||||
*/
|
||||
class myUser extends sfGuardSecurityUser
|
||||
{
|
||||
}
|
||||
139
apps/backend/lib/stBackendDesktopModules.class.php
Normal file
139
apps/backend/lib/stBackendDesktopModules.class.php
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
class stBackendDesktopModule
|
||||
{
|
||||
protected
|
||||
$route = null,
|
||||
$name = null,
|
||||
$icon = null,
|
||||
$valid = true,
|
||||
$label = null;
|
||||
|
||||
public function __construct($routing, $params)
|
||||
{
|
||||
static $packages = null;
|
||||
|
||||
if (is_array($params))
|
||||
{
|
||||
$this->route = $params['route'];
|
||||
|
||||
$this->label = $params['label'];
|
||||
|
||||
|
||||
if (isset($params['icon']) && $params['icon'])
|
||||
{
|
||||
$tmp = pathinfo($params['icon']);
|
||||
|
||||
$this->icon = !isset($tmp['extension']) || !$tmp['extension'] ? $params['icon'].'.png' : $params['icon'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->icon = 'stDefaultApp.png';
|
||||
}
|
||||
|
||||
if (isset($params['name']))
|
||||
{
|
||||
|
||||
$this->name = $params['name'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (null === $packages)
|
||||
{
|
||||
$packages = stApplication::getApps();
|
||||
}
|
||||
|
||||
if ($routing->hasRouteName($params))
|
||||
{
|
||||
$this->route = '@'.$params;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->route = '@'.$params.'Default';
|
||||
}
|
||||
|
||||
|
||||
$this->icon = $params.'.png';
|
||||
|
||||
if (isset($packages[$params]))
|
||||
{
|
||||
$this->label = $packages[$params];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->label = $params;
|
||||
|
||||
$this->valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (null === $this->name)
|
||||
{
|
||||
if ($this->route[0] == '@')
|
||||
{
|
||||
list($name) = explode('?', $this->route);
|
||||
$route = $routing->getRouteByName($name);
|
||||
|
||||
$this->name = $route[4]['module'];
|
||||
}
|
||||
else
|
||||
{
|
||||
list($this->name) = explode('/', $this->route);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(sfConfigurationException $e)
|
||||
{
|
||||
$this->valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function isValid()
|
||||
{
|
||||
return $this->valid;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getRoute()
|
||||
{
|
||||
return $this->route;
|
||||
}
|
||||
|
||||
public function getLabel()
|
||||
{
|
||||
return sfI18N::getInstance()->__($this->label, null, $this->name);
|
||||
}
|
||||
|
||||
public function getIcon()
|
||||
{
|
||||
return $this->icon;
|
||||
}
|
||||
|
||||
public function getIconPath()
|
||||
{
|
||||
if ($this->icon[0] == '/')
|
||||
{
|
||||
$icon_path = $this->icon;
|
||||
}
|
||||
else
|
||||
{
|
||||
$icon_path = 'backend/main/icons/'.$this->icon;
|
||||
}
|
||||
|
||||
$extension = pathinfo($icon_path, PATHINFO_EXTENSION);
|
||||
|
||||
if (!in_array($extension, array('jpg', 'png', 'gif', 'jpeg')))
|
||||
{
|
||||
return $icon_path . '.png';
|
||||
}
|
||||
|
||||
return $icon_path;
|
||||
}
|
||||
}
|
||||
58
apps/backend/lib/stFastCache.class.php
Normal file
58
apps/backend/lib/stFastCache.class.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Marek Jakubowicz <marek.jakubowicz@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* stfastCache progress bar
|
||||
*/
|
||||
class stFastCache
|
||||
{
|
||||
protected $msg = '';
|
||||
|
||||
public static $pages=array(
|
||||
|
||||
"STANDARD" => array(
|
||||
"/stMixerFrontend/index",
|
||||
),
|
||||
|
||||
"DEFAULT" => array(
|
||||
"/",
|
||||
"/lang/en",
|
||||
"/lang/pl",
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
/**
|
||||
* Number of steps. Number of cached pages.
|
||||
*/
|
||||
public static function getSteps()
|
||||
{
|
||||
return sizeof(stFastCache::$pages['STANDARD']);
|
||||
}
|
||||
|
||||
public function step($step)
|
||||
{
|
||||
$hostname=sfContext::getInstance()->getRequest()->getHost();
|
||||
$page="http://".$hostname.'/'.stFastCache::$pages['STANDARD'][$step].'/hash/'.$this->getHash();
|
||||
$b = new sfWebBrowser(array(), null, array('ssl_verify' => false, 'ssl_verify_host' => false));
|
||||
$b->get($page,array());
|
||||
// $res = $b->getResponseText();
|
||||
|
||||
return $step+1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash for fast cache saving URI
|
||||
*/
|
||||
public function getHash()
|
||||
{
|
||||
return '123456';
|
||||
}
|
||||
|
||||
public function getMessage()
|
||||
{
|
||||
return $this->msg;
|
||||
}
|
||||
}
|
||||
35
apps/backend/lib/stFastCacheDefault.class.php
Normal file
35
apps/backend/lib/stFastCacheDefault.class.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Marek Jakubowicz <marek.jakubowicz@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* stfastCache progress bar
|
||||
*/
|
||||
class stFastCacheDefault extends stFastCache
|
||||
{
|
||||
|
||||
public static function getSteps()
|
||||
{
|
||||
return sizeof(stFastCache::$pages['DEFAULT']);
|
||||
}
|
||||
|
||||
public function step($step)
|
||||
{
|
||||
$hostname=sfContext::getInstance()->getRequest()->getHost();
|
||||
$page="http://".$hostname.'/'.stFastCache::$pages['DEFAULT'][$step];
|
||||
|
||||
// Caching pages in default mode
|
||||
$b = new sfWebBrowser();
|
||||
$b->get($page,array('hash'=>$this->getHash(),'default'=>1));
|
||||
|
||||
// Caching the same pages without default mode
|
||||
$c = new sfWebBrowser();
|
||||
$c->get($page,array('hash'=>$this->getHash()));
|
||||
|
||||
// $res = $b->getResponseText();
|
||||
|
||||
return $step+1;
|
||||
}
|
||||
|
||||
}
|
||||
285
apps/backend/lib/stFastCacheSEO.php
Normal file
285
apps/backend/lib/stFastCacheSEO.php
Normal file
@@ -0,0 +1,285 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Marek Jakubowicz <marek.jakubowicz@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* stfastCache progress bar
|
||||
*/
|
||||
class stFastCacheSEO extends stFastCache
|
||||
{
|
||||
protected static $methods = array();
|
||||
|
||||
protected static $steps = 0;
|
||||
|
||||
protected static $max_skip = 100;
|
||||
|
||||
public static function registerFastCacheLink($name, $class, $method, $steps)
|
||||
{
|
||||
if ($steps > 0 )
|
||||
{
|
||||
self::$methods[] = array('class'=>$class,
|
||||
'method'=>$method,
|
||||
'steps'=>$steps,
|
||||
'name'=>$name,
|
||||
'limit'=>self::$steps+$steps,
|
||||
'start'=>self::$steps
|
||||
);
|
||||
self::$steps += $steps;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getMethod($step)
|
||||
{
|
||||
foreach (self::$methods as $method)
|
||||
{
|
||||
if ($step < $method['limit']){
|
||||
return $method;
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
public static function getSteps()
|
||||
{
|
||||
self::Init();
|
||||
return self::$steps;
|
||||
}
|
||||
|
||||
public static function Init()
|
||||
{
|
||||
self::registerFastCacheLink('main_page', 'stFastCacheSEO', 'mainPageLink', 1);
|
||||
|
||||
//$config = stConfig::getInstance(sfContext::getInstance(), array( 'show_without_price' => stConfig::BOOL),'stProduct' );
|
||||
//$c = new Criteria();
|
||||
//$c->add(ProductPeer::ACTIVE,1);
|
||||
//if ($config->get('show_without_price')) $c->add(ProductPeer::PRICE,0,Criteria::GREATER_THAN);
|
||||
|
||||
//self::registerFastCacheLink('group', 'stFastCacheSEO', 'productLink', ProductPeer::doCount($c));
|
||||
|
||||
// rejestracja linkow webpage
|
||||
$c = new Criteria();
|
||||
$c->add(WebpagePeer::ACTIVE, 1);
|
||||
self::registerFastCacheLink('webpage', 'stFastCacheSEO', 'webPageLink', WebpagePeer::doCount($c));
|
||||
self::registerFastCacheLink('category', 'stFastCacheSEO', 'categoryLink', CategoryPeer::doCount(new Criteria()));
|
||||
self::registerFastCacheLink('group', 'stFastCacheSEO', 'productGroupLink', ProductGroupPeer::doCount(new Criteria()));
|
||||
|
||||
}
|
||||
|
||||
public function generateCache($step)
|
||||
{
|
||||
$method = stFastCacheSEO::getMethod($step);
|
||||
if (is_callable($method['class'].'::'.$method['method'])) {
|
||||
|
||||
return call_user_func($method['class'].'::'.$method['method'], $step-$method['start'],$this->getHash());
|
||||
}
|
||||
}
|
||||
|
||||
public function step($step)
|
||||
{
|
||||
// usuwanie plikow cache
|
||||
if ($step == 0 && sfContext::getInstance()->getRequest()->hasParameter('del'))
|
||||
{
|
||||
stFastCacheManager::clearCache();
|
||||
}
|
||||
|
||||
sfLoader::loadHelpers('Helper');
|
||||
sfLoader::loadHelpers('Tag');
|
||||
sfLoader::loadHelpers('stUrl');
|
||||
|
||||
stFastCacheSEO::Init();
|
||||
$old_conf = sfConfig::get('sf_no_script_name');
|
||||
sfConfig::set('sf_no_script_name',1);
|
||||
$this->addRouting();
|
||||
$skipped = $processed = 0;
|
||||
|
||||
while ($processed==0 && $skipped < self::$max_skip && $step<=self::$steps)
|
||||
{
|
||||
if ($this->generateCache($step)!=0) $processed++;
|
||||
else $skipped++;
|
||||
$step++;
|
||||
}
|
||||
if ($step>self::$steps) $step = self::$steps;
|
||||
|
||||
sfConfig::set('sf_no_script_name',$old_conf);
|
||||
|
||||
$resume_file = sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.'fastcache'.DIRECTORY_SEPARATOR.'db'.DIRECTORY_SEPARATOR.'fast_cache_running';
|
||||
$data = array('step'=>$step+1);
|
||||
file_put_contents($resume_file, sfYaml::dump($data));
|
||||
|
||||
return $step;
|
||||
}
|
||||
|
||||
protected function addRouting() {
|
||||
stPluginHelper::addRouting('stBackendProductUrlLang', '/:lang/:url.html', 'stProduct', 'show', 'backend', array(), array('lang' => '[a-z]{2,4}'));
|
||||
stPluginHelper::addRouting('stBackendProductUrl', '/:url.html', 'stProduct', 'show', 'backend');
|
||||
stPluginHelper::addRouting('stBackendProductCategoryUrlLang3', '/category/:lang/:url', 'stProduct', 'list', 'backend', array(), array('lang' => '[a-z]{2,4}'));
|
||||
stPluginHelper::addRouting('stBackendProductCategoryUrl3', '/category/:url', 'stProduct', 'list', 'backend');
|
||||
stPluginHelper::addRouting('stBackendWebpageUrlLang', '/webpage/:lang/:url.html', 'stWebpageFrontend', 'index', 'backend');
|
||||
stPluginHelper::addRouting('stBackendWebpageUrl', '/webpage/:url.html', 'stWebpageFrontend', 'index', 'backend');
|
||||
stPluginHelper::addRouting('stBackendProductGroupUrlLang4', '/group/:lang/:url', 'stProduct', 'groupList', 'backend', array(), array('lang' => '[a-z]{2,4}'));
|
||||
stPluginHelper::addRouting('stBackendProductGroupUrl4', '/group/:url', 'stProduct', 'groupList', 'backend');
|
||||
stPluginHelper::addRouting('stFrontendMain', '/', 'stFrontendMain', 'index', 'backend');
|
||||
stPluginHelper::addRouting('stFrontendMainLang', '/lang/:lang', 'stFrontendMain', 'index', 'backend');
|
||||
}
|
||||
|
||||
public static function webPageLink($offset, $hash)
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->add(WebpagePeer::ACTIVE, 1);
|
||||
$c->setLimit(1);
|
||||
$c->setOffset($offset);
|
||||
$webpage = WebPagePeer::doSelectOne($c);
|
||||
$processed = 0;
|
||||
if (is_object($webpage))
|
||||
{
|
||||
$language = stLanguage::getInstance(sfContext::getInstance());
|
||||
foreach (LanguagePeer::doSelect(new Criteria()) as $lang)
|
||||
{
|
||||
$host = $language->hasLangParameterInUrl($lang->getShortcut())?sfContext::getInstance()->getRequest()->getHost():$language->hasLangParameterInUrl($lang->getShortcut(),true);
|
||||
$webpage->setCulture($lang->getOriginalLanguage());
|
||||
if (stFastCacheSEO::writeCache(st_url_for(
|
||||
"stWebpageFrontend/index?url=".$webpage->getFriendlyUrl(),
|
||||
true,
|
||||
'frontend',
|
||||
$host,
|
||||
$lang->getShortcut()),
|
||||
$hash, $host)) $processed=1;
|
||||
}
|
||||
}
|
||||
return $processed;
|
||||
}
|
||||
|
||||
public static function categoryLink($offset, $hash)
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->setLimit(1);
|
||||
$c->setOffset($offset);
|
||||
$category = CategoryPeer::doSelectOne($c);
|
||||
$processed = 0;
|
||||
if (is_object($category))
|
||||
{
|
||||
$language = stLanguage::getInstance(sfContext::getInstance());
|
||||
foreach (LanguagePeer::doSelect(new Criteria()) as $lang)
|
||||
{
|
||||
$host = $language->hasLangParameterInUrl($lang->getShortcut())?sfContext::getInstance()->getRequest()->getHost():$language->hasLangParameterInUrl($lang->getShortcut(),true);
|
||||
$category->setCulture($lang->getOriginalLanguage());
|
||||
if (stFastCacheSEO::writeCache(st_url_for(
|
||||
"stProduct/list?url=".$category->getFriendlyUrl(),
|
||||
true,
|
||||
'frontend',
|
||||
$host,
|
||||
$lang->getShortcut()),
|
||||
$hash, $host)) $processed=1;
|
||||
}
|
||||
}
|
||||
return $processed;
|
||||
}
|
||||
|
||||
public static function productGroupLink($offset, $hash)
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->setLimit(1);
|
||||
$c->setOffset($offset);
|
||||
$productGroup = ProductGroupPeer::doSelectOne($c);
|
||||
$processed = 0;
|
||||
if (is_object($productGroup))
|
||||
{
|
||||
$language = stLanguage::getInstance(sfContext::getInstance());
|
||||
foreach (LanguagePeer::doSelect(new Criteria()) as $lang)
|
||||
{
|
||||
$host = $language->hasLangParameterInUrl($lang->getShortcut())?sfContext::getInstance()->getRequest()->getHost():$language->hasLangParameterInUrl($lang->getShortcut(),true);
|
||||
$productGroup->setCulture($lang->getOriginalLanguage());
|
||||
if (stFastCacheSEO::writeCache(st_url_for(
|
||||
"stProduct/groupList?url=".$productGroup->getFriendlyUrl(),
|
||||
true,
|
||||
'frontend',
|
||||
$host,
|
||||
$lang->getShortcut()),
|
||||
$hash, $host)) $processed=1;
|
||||
}
|
||||
}
|
||||
return $processed;
|
||||
}
|
||||
|
||||
public static function productLink($offset, $hash)
|
||||
{
|
||||
$config = stConfig::getInstance(sfContext::getInstance(), array( 'show_without_price' => stConfig::BOOL),'stProduct' );
|
||||
$c = new Criteria();
|
||||
$c->add(ProductPeer::ACTIVE,1);
|
||||
if ($config->get('show_without_price')) $c->add(ProductPeer::PRICE,0,Criteria::GREATER_THAN);
|
||||
$c->setLimit(1);
|
||||
$c->setOffset($offset);
|
||||
$product = ProductPeer::doSelectOne($c);
|
||||
$processed = 0;
|
||||
if (is_object($product))
|
||||
{
|
||||
|
||||
$language = stLanguage::getInstance(sfContext::getInstance());
|
||||
foreach (LanguagePeer::doSelect(new Criteria()) as $lang)
|
||||
{
|
||||
$product->setCulture($lang->getOriginalLanguage());
|
||||
$host = $language->hasLangParameterInUrl($lang->getShortcut())?sfContext::getInstance()->getRequest()->getHost():$language->hasLangParameterInUrl($lang->getShortcut(),true);
|
||||
if (stFastCacheSEO::writeCache(st_url_for(
|
||||
"stProduct/show?url=".$product->getFriendlyUrl(),
|
||||
true,
|
||||
'frontend',
|
||||
$host,
|
||||
$lang->getShortcut()),
|
||||
$hash, $host)) $processed=1;
|
||||
}
|
||||
}
|
||||
return $processed;
|
||||
}
|
||||
|
||||
public static function mainPageLink($offset, $hash)
|
||||
{
|
||||
$language = stLanguage::getInstance(sfContext::getInstance());
|
||||
$processed = 0;
|
||||
foreach (LanguagePeer::doSelect(new Criteria()) as $lang)
|
||||
{
|
||||
$host = $language->hasLangParameterInUrl($lang->getShortcut())?sfContext::getInstance()->getRequest()->getHost():$language->hasLangParameterInUrl($lang->getShortcut(),true);
|
||||
|
||||
if (stFastCacheSEO::writeCache(st_url_for(
|
||||
"stFrontendMain/index",
|
||||
true,
|
||||
'frontend',
|
||||
$host,
|
||||
$lang->getShortcut()),
|
||||
$hash, $host, array('default'=>1))) $processed=1;
|
||||
|
||||
if (stFastCacheSEO::writeCache(st_url_for(
|
||||
"stFrontendMain/index",
|
||||
true,
|
||||
'frontend',
|
||||
$host,
|
||||
$lang->getShortcut()),
|
||||
$hash, $host)) $processed=1;
|
||||
|
||||
}
|
||||
return $processed;
|
||||
}
|
||||
|
||||
|
||||
public function close()
|
||||
{
|
||||
$resume_file = sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.'fastcache'.DIRECTORY_SEPARATOR.'db'.DIRECTORY_SEPARATOR.'fast_cache_running';
|
||||
$enabled_file = sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.'fastcache'.DIRECTORY_SEPARATOR.'db'.DIRECTORY_SEPARATOR.'fast_cache_enabled';
|
||||
unlink($resume_file);
|
||||
unlink($enabled_file);
|
||||
touch($enabled_file);
|
||||
}
|
||||
|
||||
public static function writeCache($link, $hash, $host, $params = array())
|
||||
{
|
||||
$file = str_replace('http://'.$host, '',$link);
|
||||
$params = array_merge($params, array('hash'=>md5($file)));
|
||||
if (!sfSuperCacheFilter::hasEntry($host,$file,null))
|
||||
{
|
||||
$b = new sfWebBrowser();
|
||||
$b->get($link,$params);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
191
apps/backend/lib/stPake.php
Normal file
191
apps/backend/lib/stPake.php
Normal file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Wykonywanie task'ów przez WWW
|
||||
*
|
||||
* Dane wejsciowe jako zmienne globalne: argv, sf_root_dir
|
||||
* Skrypt zbudowany na podstwie symfony.php
|
||||
*
|
||||
*/
|
||||
|
||||
error_reporting(E_ALL);
|
||||
|
||||
if (ini_get('zend.ze1_compatibility_mode'))
|
||||
{
|
||||
die("symfony cannot run with zend.ze1_compatibility_mode enabled.\nPlease turn zend.ze1_compatibility_mode to Off in your php.ini.\n");
|
||||
}
|
||||
|
||||
// set magic_quotes_runtime to off
|
||||
ini_set('magic_quotes_runtime', 'Off');
|
||||
|
||||
/*
|
||||
// force populating $argc and $argv in the case PHP does not automatically create them (fixes #2943)
|
||||
if (empty($argv)) $argv = $_SERVER['argv'];
|
||||
$argc = $_SERVER['argc'];
|
||||
|
||||
echo "<form>command:<input type=text size=80 name=task><input type=submit value=execute></form>";
|
||||
$task=@$_REQUEST['task'];
|
||||
if (! empty($task)) {
|
||||
$argv=array();$argv=array('/usr/bin/symfony');
|
||||
$command=explode(' ',$task,1000);
|
||||
$argv=array_merge($argv,$command);
|
||||
}
|
||||
*/
|
||||
|
||||
// zaladuj konfiguracje
|
||||
if (empty($sf_root_dir)) $sf_root_dir=dirname(dirname(__FILE__).DIRECTORY_SEPARATOR); // +sote
|
||||
require_once ("config/config.php");
|
||||
define("STDOUT",1);
|
||||
$stderr=fopen($sf_root_dir.DIRECTORY_SEPARATOR.'log'.DIRECTORY_SEPARATOR.'webinstaller.log','a+'); // w tym pliku zapisywane sa Exceptions jako text
|
||||
define("STDERR",$stderr);
|
||||
// end
|
||||
|
||||
require_once($sf_symfony_lib_dir.'/vendor/pake/pakeFunction.php');
|
||||
require_once($sf_symfony_lib_dir.'/vendor/pake/pakeGetopt.class.php');
|
||||
|
||||
// autoloading for pake tasks
|
||||
class simpleAutoloader
|
||||
{
|
||||
static public
|
||||
$class_paths = array(),
|
||||
$autoload_callables = array();
|
||||
|
||||
static public function initialize($sf_symfony_lib_dir)
|
||||
{
|
||||
self::$class_paths = array();
|
||||
|
||||
self::register($sf_symfony_lib_dir, '.class.php');
|
||||
self::register($sf_symfony_lib_dir.'/vendor/propel', '.php');
|
||||
self::register($sf_symfony_lib_dir.'/vendor/creole', '.php');
|
||||
self::register('lib/model', '.php');
|
||||
// self::register('plugins', '.php'); // - sote
|
||||
self::register('../plugins', '.php'); // + sote
|
||||
}
|
||||
|
||||
static public function __autoload($class)
|
||||
{
|
||||
if (!isset(self::$class_paths[$class]))
|
||||
{
|
||||
foreach ((array) self::$autoload_callables as $callable)
|
||||
{
|
||||
if (call_user_func($callable, $class))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
require_once(self::$class_paths[$class]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static public function register($dir, $ext)
|
||||
{
|
||||
if (!is_dir($dir))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (pakeFinder::type('file')->name('*'.$ext)->ignore_version_control()->follow_link()->in($dir) as $file)
|
||||
{
|
||||
self::$class_paths[str_replace($ext, '', str_replace('.class', '', basename($file, $ext)))] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
static public function add($class, $file)
|
||||
{
|
||||
if (!is_file($file))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
self::$class_paths[$class] = $file;
|
||||
}
|
||||
|
||||
static public function registerCallable($callable)
|
||||
{
|
||||
if (!is_callable($callable))
|
||||
{
|
||||
throw new Exception('Autoload callable does not exist');
|
||||
}
|
||||
|
||||
self::$autoload_callables[] = $callable;
|
||||
}
|
||||
}
|
||||
|
||||
function __autoload($class)
|
||||
{
|
||||
static $initialized = false;
|
||||
|
||||
if (!$initialized)
|
||||
{
|
||||
simpleAutoloader::initialize(sfConfig::get('sf_symfony_lib_dir'));
|
||||
$initialized = true;
|
||||
}
|
||||
|
||||
return simpleAutoloader::__autoload($class);
|
||||
}
|
||||
|
||||
// trap -V before pake
|
||||
if (in_array('-V', $argv) || in_array('--version', $argv))
|
||||
{
|
||||
printf("symfony version %s\n", trim(file_get_contents($sf_symfony_lib_dir.'/VERSION'), 'INFO'));
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (count($argv) <= 1)
|
||||
{
|
||||
$argv[] = '-T';
|
||||
}
|
||||
|
||||
// @todo przeciazyc ta klase zmienic odczytywanie konfigow
|
||||
require_once($sf_symfony_lib_dir.'/config/sfConfig.class.php');
|
||||
|
||||
sfConfig::add(array(
|
||||
'sf_root_dir' => $sf_root_dir, // +- sote
|
||||
'sf_symfony_lib_dir' => $sf_symfony_lib_dir,
|
||||
'sf_symfony_data_dir' => $sf_symfony_data_dir,
|
||||
));
|
||||
|
||||
// directory layout
|
||||
// @todo dodac przeciazenie tego wywolania
|
||||
include($sf_symfony_data_dir.'/config/constants.php');
|
||||
#include(sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'stInstallerWebPlugin'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'constants.php');
|
||||
|
||||
|
||||
// include path
|
||||
set_include_path(
|
||||
sfConfig::get('sf_lib_dir').PATH_SEPARATOR.
|
||||
sfConfig::get('sf_app_lib_dir').PATH_SEPARATOR.
|
||||
sfConfig::get('sf_model_dir').PATH_SEPARATOR.
|
||||
sfConfig::get('sf_symfony_lib_dir').DIRECTORY_SEPARATOR.'vendor'.PATH_SEPARATOR.
|
||||
get_include_path()
|
||||
);
|
||||
|
||||
|
||||
// register tasks
|
||||
$dirs = array(
|
||||
sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.'tasks' => 'myPake*.php', // project tasks
|
||||
sfConfig::get('sf_symfony_data_dir').DIRECTORY_SEPARATOR.'tasks' => 'sfPake*.php', // symfony tasks
|
||||
sfConfig::get('sf_root_dir').'/plugins/*/data/tasks' => '*.php', // plugin tasks // +- sote
|
||||
);
|
||||
|
||||
|
||||
foreach ($dirs as $globDir => $name)
|
||||
{
|
||||
if ($dirs = glob($globDir))
|
||||
{
|
||||
$tasks = pakeFinder::type('file')->ignore_version_control()->name($name)->in($dirs);
|
||||
foreach ($tasks as $task)
|
||||
{
|
||||
// echo "inclue task: $task \n";
|
||||
include_once($task);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// run task
|
||||
// pakeApp::get_instance()->run(null, null, false);
|
||||
91
apps/backend/lib/stPakeWeb.class.php
Normal file
91
apps/backend/lib/stPakeWeb.class.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stInstallerWebPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stInstallerWebPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stInstallerWebPlugin
|
||||
* @subpackage libs
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: stPakeWeb.class.php 9276 2010-11-18 12:06:42Z marek $
|
||||
* @author Marek Jakubowicz <marek.jakubowicz@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Uruchamianie tasków przez WWW.
|
||||
*
|
||||
* @author Marek Jakubowicz <marek.jakubowicz@sote.pl>
|
||||
*
|
||||
* @package stInstallerWebPlugin
|
||||
* @subpackage libs
|
||||
*/
|
||||
class stPakeWeb
|
||||
{
|
||||
/**
|
||||
* @var string $content wynik zwrócony przez TASK
|
||||
*/
|
||||
var $content='';
|
||||
|
||||
/**
|
||||
* @var string $error komunikat blędu jeśli wystąpił wyjątek
|
||||
*/
|
||||
var $error='';
|
||||
|
||||
/**
|
||||
* @var string wartość niewykorzytywana, wymagana do uruchomienia task'a
|
||||
*/
|
||||
var $symfony='/usr/bin/symfony';
|
||||
|
||||
/**
|
||||
* Wykonaj Task
|
||||
*
|
||||
* @param string np. propel-build-model, cc
|
||||
* @return bool
|
||||
*/
|
||||
public function run($webtask)
|
||||
{
|
||||
if (empty($webtask)) {
|
||||
$this->error='Empty parameter task';
|
||||
return false;
|
||||
}
|
||||
|
||||
// clean Fast Cache
|
||||
if ($webtask=='cc')
|
||||
{
|
||||
stFastCacheManager::clearCache();
|
||||
}
|
||||
|
||||
// symfony directories
|
||||
$sf_symfony_lib_dir = sfConfig::get('sf_symfony_lib_dir');
|
||||
$sf_symfony_data_dir = sfConfig::get('sf_symfony_data_dir');
|
||||
|
||||
$sf_root_dir=sfConfig::get('sf_root_dir');
|
||||
chdir($sf_root_dir);
|
||||
|
||||
// force populating $argc and $argv in the case PHP does not automatically create them (fixes #2943)
|
||||
$argc=array();
|
||||
$argv=array($this->symfony,$webtask);
|
||||
|
||||
$pakelib=$sf_root_dir.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.'backend'.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'stPake.php';
|
||||
require_once($pakelib);
|
||||
|
||||
$pake = pakeApp::get_instance();
|
||||
try
|
||||
{
|
||||
ob_start();
|
||||
$ret = $pake->run(null, $webtask, false); // wykonaj task
|
||||
$content = ob_get_clean();
|
||||
$this->content = $content;
|
||||
return true;
|
||||
}
|
||||
catch (Exception $ret)
|
||||
{
|
||||
$this->error = $ret->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user