Files
2025-03-12 17:06:23 +01:00

133 lines
3.2 KiB
PHP

<?php
/**
* SOTESHOP/appFaviconPlugin
*
*/
class appFaviconBackendActions extends stAdminGeneratorActions
{
public function executeIndex()
{
$i18n = $this->getContext()->getI18N();
$this->labels = $this->getLabels();
$current = sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.sfConfig::get('sf_web_dir_name');
$filename = $current.'/favicon.ico';
if (file_exists($filename))
{
$this->favicon_exists = true;
} else {
$this->favicon_exists = false;
}
if ($this->favicon_exists == false){
$notice = '<a href="http://www.favicon.cc/" target="_blank">'.$i18n->__('Wejdź na stronę')."</a> ".$i18n->__(' i utwórz swoją ikonę favicon..').'</a>';
$this->setFlash("info", $notice, false);
}
if ($this->getRequest()->getMethod() == sfRequest::POST)
{
$favicon = $this->getRequest()->getFileName('favicon');
if (!empty($favicon)) {
$this->getRequest()->moveFile('favicon', $filename);
stFastCacheManager::clearCache();
$this->setFlash('notice', $i18n->__('Twoje zmiany zostały zapisane', null, 'stAdminGeneratorPlugin'));
}
$this->redirect('appFaviconBackend/index');
}
$this->getBreadcrumbs()->add($i18n->__('Konfiguracja', null, 'stAdminGeneratorPlugin'));
}
public function validateIndex()
{
$i18n = $this->getContext()->getI18N();
$this->labels = $this->getLabels();
$request = $this->getRequest();
if ($request->getMethod() == sfRequest::POST)
{
return true;
}
return!$request->hasErrors();
}
public function handleErrorIndex()
{
$current = sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.sfConfig::get('sf_web_dir_name');
$filename = $current.'/favicon.ico';
if (file_exists($filename))
{
$this->favicon_exists = 1;
}
return sfView::SUCCESS;
}
protected function getLabels()
{
$current = sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.sfConfig::get('sf_web_dir_name');
$filename = $current.'/favicon.ico';
if (file_exists($filename))
{
return array(
'favicon' => 'Zmień favicon',
);
} else {
return array(
'favicon' => 'Dodaj favicon',
);
}
}
protected function getBreadcrumbs(){
if (null === $this->breadcrumbs){
$i18n = $this->getContext()->getI18N();
$this->breadcrumbs = parent::getBreadcrumbs();
$this->breadcrumbs->add($i18n->__('Favicon'), '@appFaviconPlugin');
}
return $this->breadcrumbs;
}
}