*/
/**
* Klasa rozszerzająca warstwę view dla stTheme
*
* @package stThemePlugin
* @subpackage libs
*/
class stThemeView extends sfPHPView
{
protected $theme = null;
protected $themeMode;
protected $themeCulture;
protected $themeReturnUrl;
public function initialize($context, $moduleName, $actionName, $viewName)
{
$this->themeMode = SF_ENVIRONMENT == 'theme' && $context->getUser()->isAuthenticated() && $context->getUser()->hasCredential('stThemeBackend.modification');
if (SF_ENVIRONMENT == 'theme') {
$referer = $context->getRequest()->getReferer();
if (strpos($referer, 'backend.php') !== false || strpos($referer, 'backend_dev.php') !== false) {
$context->getUser()->setAttribute('return_url', $referer, 'stThemePlugin');
}
if ($context->getRequest()->hasParameter('theme_culture')) {
$context->getUser()->setAttribute('culture', $context->getRequest()->getParameter('theme_culture'), 'stThemePlugin');
}
$this->themeReturnUrl = $context->getUser()->getAttribute('return_url', '/backend.php', 'stThemePlugin');
$this->themeCulture = $context->getUser()->getAttribute('culture', stLanguage::getOptLanguage(), 'stThemePlugin');
}
parent::initialize($context, $moduleName, $actionName, $viewName);
if (stConfig::getInstance('stThemeBackend')->get('responsive_vary')) {
$this->context->getResponse()->addVaryHttpHeader('User-Agent');
}
}
/**
* Zwraca instancję obiektu stTheme
*
* @return stTheme
*/
public function getTheme()
{
if (null === $this->theme) {
$this->theme = $this->context->getController()->getTheme();
}
return $this->theme;
}
public function hasThemeMode()
{
return $this->themeMode;
}
public function smartyIncludeStylesheets($params, &$smarty)
{
if ($this->themeMode) {
echo minify_get_stylesheets($this->context->getResponse(), isset($params['minify']) && $params['minify'] == 'true', 'cache/css/_editor');
} else {
echo minify_get_stylesheets($this->context->getResponse(), isset($params['minify']) && $params['minify'] == 'true');
}
if (SF_ENVIRONMENT == 'theme') {
echo '';
echo '';
echo '';
}
}
public function smartyIncludeJavascripts($params, &$smarty)
{
echo minify_get_javascripts($this->context->getResponse(), isset($params['minify']) && $params['minify'] == 'true');
if ($this->themeMode) {
echo '';
echo '';
echo '';
echo '';
} elseif (SF_ENVIRONMENT == 'theme') {
$i18n = $this->context->getI18N();
$i18n->setCulture($this->themeCulture);
$request = $this->context->getRequest();
$login_label = $i18n->__('Użytkownik', null, 'stThemeFrontend');
$password_label = $i18n->__('Hasło', null, 'stThemeFrontend');
$login_title = $i18n->__('Logowanie do zarządzania tematami', null, 'stThemeFrontend');
$button_label = $i18n->__('Zaloguj się', null, 'stThemeFrontend');
$error_message = $i18n->__($request->getError('theme_login'), null, 'stThemeFrontend');
$login = $request->getParameter('theme_login[login]');
$login_url = $this->context->getController()->genUrl('stSmartyFrontend/login');
$return_label = $i18n->__('Powrót', null, 'stThemeFrontend');
$i18n->setCulture($this->context->getUser()->getCulture());
if ($this->getTheme()->getVersion() < 7) {
$js = <<