first commit
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
class stHtaccessBackendActions extends stActions {
|
||||
|
||||
public function executeIndex() {
|
||||
|
||||
$this->labels = array('config{error}' => ' ');
|
||||
|
||||
$this->config = stConfig::getInstance('stHtaccessBackend');
|
||||
if ($this->getRequest()->getMethod() == sfRequest::POST) {
|
||||
$c = $this->getRequestParameter('config');
|
||||
|
||||
stHtaccess::rebuild(null, array('top' => $c['top'], 'middle' => $c['middle'], 'bottom' => $c['bottom']));
|
||||
|
||||
$testFilename = 'test_'.time().'.php';
|
||||
file_put_contents(sfConfig::get('sf_web_dir').'/'.$testFilename, '<?php echo "'.$testFilename.'";');
|
||||
|
||||
$b = new sfWebBrowser(array(), 'sfCurlAdapter', array('ssl_verify' => false));
|
||||
$b->get($this->getRequest()->getUriPrefix().'/'.$testFilename);
|
||||
|
||||
unlink(sfConfig::get('sf_web_dir').'/'.$testFilename);
|
||||
|
||||
if ($b->getResponseText() == $testFilename) {
|
||||
$this->config->setFromRequest('config');
|
||||
$this->config->save();
|
||||
$this->setFlash('notice', $this->getContext()->getI18n()->__('Twoje zmiany zostały zapisane', null, 'stAdminGeneratorPlugin'));
|
||||
} else {
|
||||
stHtaccess::rebuild(null, array('top' => $this->config->get('top'), 'middle' => $this->config->get('middle'), 'bottom' => $this->config->get('bottom')));
|
||||
$this->getRequest()->setError('config{error}', 'Sprawdź poprawność wprowadzonych danych.');
|
||||
}
|
||||
}
|
||||
|
||||
$this->config->load();
|
||||
}
|
||||
|
||||
public function validateIndex() {
|
||||
if ($this->getRequest()->getMethod() == sfRequest::POST) {
|
||||
stAuthUsersListener::checkModificationCredentials($this, $this->getRequest(), $this->getModuleName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
class stHtaccessBackendComponents extends sfComponents
|
||||
{
|
||||
|
||||
public function executeListMenu()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,19 @@
|
||||
<div class="list-menu">
|
||||
<ul>
|
||||
|
||||
<li class="selected">
|
||||
<?php echo link_to(__('Konfiguracja'),'stHtaccessBackend/index')?>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<?php if (sfContext::getInstance()->getUser()->getCulture() == 'pl_PL'): ?>
|
||||
<a href="https://www.sote.pl/docs/edycja-pliku-htaccess" target="_blank"><?php echo __('Dokumentacja'); ?></a>
|
||||
<?php else: ?>
|
||||
<a href="https://www.soteshop.com/docs/htaccess_file_editing" target="_blank"><?php echo __('Documentation'); ?></a>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="clr"></div>
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php use_helper('I18N', 'stAdminGenerator');?>
|
||||
<?php echo st_get_admin_head('stHtaccessPlugin', __('Konfiguracja'), null, array());?>
|
||||
<?php st_view_slot_start('application-menu') ?>
|
||||
<?php st_include_component('stHtaccessBackend', 'listMenu') ?>
|
||||
<?php st_view_slot_end() ?>
|
||||
|
||||
<?php echo form_tag('htaccess/index', array('id' => 'sf_admin_config_form', 'name' => 'sf_admin_config_form'));?>
|
||||
<div id="sf_admin_content" style="margin-bottom: 15px;">
|
||||
<?php if ($sf_request->hasErrors()):?>
|
||||
<div class="form-errors">
|
||||
<h2><span class="svg-icon svg-icon-error" style="-webkit-mask-image: url(/images/backend/icons/svg/error.svg?v=2); mask-image: url(/images/backend/icons/svg/error.svg?v=2); " title=""></span><?php echo __('Błąd podczas walidacji danych.') ?></h2>
|
||||
<?php if (isset($labels)):?>
|
||||
|
||||
<dl>
|
||||
<?php foreach ($sf_request->getErrorNames() as $name):?>
|
||||
<dt><?php echo __($labels[$name])?></dt>
|
||||
<dd><?php echo $sf_request->getError($name)?></dd>
|
||||
<?php endforeach;?>
|
||||
</dl>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
<?php elseif ($sf_flash->has('notice')):?>
|
||||
<div class="save-ok">
|
||||
<h2><?php echo __($sf_flash->get('notice'));?></h2>
|
||||
</div>
|
||||
<?php elseif ($sf_flash->has('warning')):?>
|
||||
<div class="form-errors">
|
||||
<h2><?php echo __($sf_flash->get('warning'));?></h2>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
<fieldset style="border: none;">
|
||||
<div style="padding: 30px;">
|
||||
<div class="row <?php if($sf_request->hasError('config{error}')):?> form-error<?php endif;?>" style="margin-bottom: 15px;">
|
||||
<label for="config[top]" style="float: left; padding-right: 10px; text-align: right; width: 300px;"><?php echo __('Początek pliku') ?></label>
|
||||
<?php if($sf_request->hasErrors()):?>
|
||||
<div class="field"><?php echo textarea_tag('config[top]', $sf_params->get('config[top]'), array('size' => '100x5'));?></div>
|
||||
<?php else:?>
|
||||
<div class="field"><?php echo textarea_tag('config[top]', $config->get('top'), array('size' => '100x5'));?></div>
|
||||
<?php endif;?>
|
||||
<div class="clr"></div>
|
||||
</div>
|
||||
<div class="row <?php if($sf_request->hasError('config{error}')):?> form-error<?php endif;?>" style="margin-bottom: 15px;">
|
||||
<label for="config[middle]" style="float: left; padding-right: 10px; text-align: right; width: 300px;"><?php echo __('Środek pliku');?></label>
|
||||
<?php if($sf_request->hasErrors()):?>
|
||||
<div class="field"><?php echo textarea_tag('config[middle]', $sf_params->get('config[middle]'), array('size' => '100x5'));?></div>
|
||||
<?php else:?>
|
||||
<div class="field"><?php echo textarea_tag('config[middle]', $config->get('middle'), array('size' => '100x5'));?></div>
|
||||
<?php endif;?>
|
||||
<div class="clr"></div>
|
||||
</div>
|
||||
<div class="row <?php if($sf_request->hasError('config{error}')):?> form-error<?php endif;?>">
|
||||
<label for="config[bottom]" style="float: left; padding-right: 10px; text-align: right; width: 300px;"><?php echo __('Koniec pliku');?></label>
|
||||
<?php if($sf_request->hasErrors()):?>
|
||||
<div class="field"><?php echo textarea_tag('config[bottom]', $sf_params->get('config[bottom]'), array('size' => '100x5'));?></div>
|
||||
<?php else:?>
|
||||
<div class="field"><?php echo textarea_tag('config[bottom]', $config->get('bottom'), array('size' => '100x5'));?></div>
|
||||
<?php endif;?>
|
||||
<div class="clr"></div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div id="config_actions">
|
||||
<?php echo st_get_admin_actions_head('style="margin-top: 10px; float: right"');?>
|
||||
<?php echo st_get_admin_action('save', __('Zapisz', null, 'stAdminGeneratorPlugin'), null, array('name' => 'save'));?>
|
||||
<?php echo st_get_admin_actions_foot();?>
|
||||
</div>
|
||||
</form>
|
||||
<br class="st_clear_all" />
|
||||
<?php echo st_get_admin_foot();?>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
$(document).ready(function() {
|
||||
$('#config_actions').stickyBox();
|
||||
fieldsetVisibility();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user