118 lines
4.1 KiB
PHP
118 lines
4.1 KiB
PHP
<?php
|
|
/**
|
|
* SOTESHOP/appFacebookRemarketingPlugin
|
|
*
|
|
*
|
|
* @package appFacebookRemarketingPlugin
|
|
* @author Pawel Byszewski <pawel@apes-apps.com>
|
|
*/
|
|
class appFacebookRemarketingBackendActions extends stAdminGeneratorActions
|
|
{
|
|
|
|
public function initializeParameters()
|
|
{
|
|
|
|
$this->webRequest = new stWebRequest();
|
|
$this->config = stConfig::getInstance('appFacebookRemarketingBackend');
|
|
|
|
if ($this->config->get('code_fbremarketing', $this->getRequestParameter('fbremarketing[code_fbremarketing]'), true) == '') {
|
|
$notice = '<a href="https://pl-pl.facebook.com/ads/manager/pixel/custom_audience_pixel/" target="_blank">'.$this->getContext()->getI18n()->__('Utwórz piksel').'</a>'." ".$this->getContext()->getI18n()->__(' w menedżerze reklam Facebook.');
|
|
|
|
$this->setFlash("info", $notice, false);
|
|
|
|
$this->configuration_check = true;
|
|
|
|
} else {
|
|
|
|
$this->configuration_check = false;
|
|
|
|
}
|
|
|
|
$i18n = $this->getContext()->getI18n();
|
|
$this->labels = array(
|
|
'fbremarketing{code_fbremarketing}' => $i18n->__('Podaj indentyfikator piksela Facebooka'),
|
|
);
|
|
}
|
|
|
|
|
|
public function executeIndex()
|
|
{
|
|
$this->initializeParameters();
|
|
$i18n = $this->getContext()->getI18N();
|
|
|
|
$this->config = stConfig::getInstance('appFacebookRemarketingBackend');
|
|
|
|
$this->config->setCulture($this->getRequestParameter('culture', stLanguage::getOptLanguage()));
|
|
|
|
if ($this->getRequest()->getMethod() == sfRequest::POST)
|
|
{
|
|
|
|
$this->config->set('enable_fbremarketing', $this->getRequestParameter('fbremarketing[enable_fbremarketing]'));
|
|
|
|
$this->config->set('content_id', $this->getRequestParameter('fbremarketing[content_id]'));
|
|
|
|
$this->config->set('code_fbremarketing', $this->getRequestParameter('fbremarketing[code_fbremarketing]'), true);
|
|
|
|
$this->config->set('product_card', $this->getRequestParameter('fbremarketing[product_card]'));
|
|
|
|
$this->config->set('cart', $this->getRequestParameter('fbremarketing[cart]'));
|
|
|
|
$this->config->set('basket', $this->getRequestParameter('fbremarketing[basket]'));
|
|
|
|
$this->config->set('order', $this->getRequestParameter('fbremarketing[order]'));
|
|
|
|
if ($this->config->get('enable_fbremarketing') && $this->config->get('code_fbremarketing', null, true))
|
|
{
|
|
stAppStats::activate('Piksel Facebooka');
|
|
}
|
|
else
|
|
{
|
|
stAppStats::deactivate('Piksel Facebooka');
|
|
}
|
|
|
|
$this->config->save();
|
|
|
|
stFastCacheManager::clearCache();
|
|
|
|
$this->setFlash('notice', $i18n->__('Twoje zmiany zostały zapisane', null, 'stAdminGeneratorPlugin'));
|
|
|
|
$this->redirect('appFacebookRemarketingBackend/index?culture=' . $this->getRequestParameter('culture', stLanguage::getOptLanguage()));
|
|
}
|
|
|
|
|
|
|
|
$this->config->load();
|
|
|
|
$this->getBreadcrumbs()->add($i18n->__('Konfiguracja', null, 'stAdminGeneratorPlugin'));
|
|
|
|
}
|
|
|
|
public function validateIndex()
|
|
{
|
|
if ($this->getRequest()->getMethod() == sfRequest::POST)
|
|
stAuthUsersListener::checkModificationCredentials($this, $this->getRequest(), $this->getModuleName());
|
|
return true;
|
|
}
|
|
|
|
public function handleErrorIndex()
|
|
{
|
|
|
|
$this->initializeParameters();
|
|
$i18n = $this->getContext()->getI18N();
|
|
$this->getBreadcrumbs()->add($i18n->__('Konfiguracja', null, 'stAdminGeneratorPlugin'));
|
|
return sfView::SUCCESS;
|
|
}
|
|
|
|
|
|
protected function getBreadcrumbs(){
|
|
|
|
if (null === $this->breadcrumbs){
|
|
$i18n = $this->getContext()->getI18N();
|
|
$this->breadcrumbs = parent::getBreadcrumbs();
|
|
$this->breadcrumbs->add($i18n->__('Piksel Facebooka'), '@appFacebookRemarketingPlugin');
|
|
}
|
|
|
|
return $this->breadcrumbs;
|
|
}
|
|
|
|
} |