first commit
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<div class="list-menu">
|
||||
<ul>
|
||||
<li class="selected"><?php echo link_to(__('Konfiguracja', null, 'stAdminGeneratorPlugin'),'appFaviconBackend/index')?></li>
|
||||
<li>
|
||||
<?php if (sfContext::getInstance()->getUser()->getCulture() == 'pl_PL'): ?>
|
||||
<a href="https://www.sote.pl/favicon.html" target="_blank"><?php echo __('Dokumentacja', null, 'stAdminGeneratorPlugin'); ?></a>
|
||||
<?php else: ?>
|
||||
<a href="https://www.soteshop.com/favicon.html" target="_blank"><?php echo __('Documentation', null, 'stAdminGeneratorPlugin'); ?></a>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="clr"></div>
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
use_helper('I18N', 'stAdminGenerator');
|
||||
echo st_get_admin_head('appFaviconPlugin', __('Konfiguracja'), __('Favicon'), array('stConfigurationPlugin'));
|
||||
st_view_slot_start('application-menu');
|
||||
st_include_partial('appFaviconBackend/config_menu');
|
||||
st_view_slot_end();
|
||||
?>
|
||||
|
||||
<div id="sf_admin_content" class="admin-content-edit">
|
||||
<?php st_include_partial('stAdminGenerator/message');?>
|
||||
<?php echo form_tag('appFaviconBackend/index', array('enctype'=>'multipart/form-data', 'id' => 'admin_config_form', 'name' => 'admin_config_form', 'class' => 'admin_form'));?>
|
||||
<fieldset>
|
||||
<div class="content">
|
||||
<?php if ($favicon_exists): ?>
|
||||
<div class="row">
|
||||
<label><?php echo __('Twój favicon') ?>:</label>
|
||||
<div class="field" style="margin-top: 10px;"><img src="/favicon.ico" alt=""></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="row">
|
||||
<label>
|
||||
<?php if ($favicon_exists): echo __('Zmień favicon'); else: echo __('Dodaj favicon'); endif; ?>
|
||||
</label>
|
||||
<div class="field">
|
||||
<?php if ($sf_request->hasError('favicon')): ?>
|
||||
<div class="error_field" style="color: red;">
|
||||
<?php echo form_error('favicon', array('class' => 'form-error-msg')) ?>
|
||||
<?php echo input_file_tag('favicon', 'favicon') ?><br />
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php echo input_file_tag('favicon', 'favicon') ?><br />
|
||||
<?php endif;?>
|
||||
<div class="clr"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div id="config_actions">
|
||||
<?php echo st_get_admin_actions_head() ?>
|
||||
<?php echo st_get_admin_action('save', __('Zapisz', null, 'stAdminGeneratorPlugin'), null, array('name' => 'save')) ?>
|
||||
<?php echo st_get_admin_actions_foot() ?>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php echo st_get_admin_foot() ?>
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#config_actions').stickyBox();
|
||||
fieldsetVisibility();
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,18 @@
|
||||
fields:
|
||||
favicon:
|
||||
file: True
|
||||
sfFileValidator:
|
||||
mime_types:
|
||||
- 'image/ico'
|
||||
- 'image/icon'
|
||||
- 'image/x-icon'
|
||||
- 'text/ico'
|
||||
- 'application/ico'
|
||||
- 'application/x-ico'
|
||||
- 'application/x-win-bitmap'
|
||||
- 'image/x-win-bitmap'
|
||||
- 'application/octet-stream'
|
||||
- 'image/vnd.microsoft.icon'
|
||||
mime_types_error: "Dozwolony format ikony to .ico"
|
||||
max_size: 128000
|
||||
max_size_error: "Maksymalny rozmiar pliku to 128Kb"
|
||||
Reference in New Issue
Block a user