*/ /** * Klasa stOptimizationBackendActions * * @package stOptimizationPlugin * @subpackage actions */ class stOptimizationBackendActions extends stActions { /** * Wyświetla konfigurację modułu */ public function executeIndex() { stAuthUsersListener::checkModificationCredentials($this, $this->getRequest(), $this->getModuleName()); /** * @var stConfig $config */ $config = stConfig::getInstance('stOptimizationBackend'); $i18n = $this->getContext()->getI18N(); if ($this->getRequest()->getMethod() == sfRequest::POST) { $data = $this->getRequestParameter('config'); $config->set('enable_compression', isset($data['enable_compression'])); $config->set('optimize_js', isset($data['optimize_js'])); $updateImages = $config->get('optimize_img') != isset($data['optimize_img']); $config->set('optimize_img', isset($data['optimize_img'])); $config->save(); if ($updateImages) { stConfig::getInstance('stAsset')->save(true); } stHtaccess::rebuild(); stPartialCache::clearAll('frontend'); stFastCacheManager::clearCache(); $this->setFlash('notice', $i18n->__('Twoje zmiany zostały zapisane', null, 'stAdminGeneratorPlugin')); } sfLoader::loadHelpers(array('Helper', 'Asset')); $headers = array(); $ch = curl_init($this->getRequest()->getSiteUrl().'/bootstrap/css/bootstrap.css'); curl_setopt($ch, CURLOPT_ENCODING , ''); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 2); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($ch, CURLOPT_HEADERFUNCTION, function($curl, $header) use (&$headers) { $len = strlen($header); $header = explode(':', $header, 2); if (count($header) < 2) { return $len; } $headers[strtolower(trim($header[0]))][] = trim($header[1]); return $len; }); curl_exec($ch); $this->compressionEnabled = isset($headers['content-encoding']) && in_array($headers['content-encoding'][0], array('gzip', 'defalte', 'br')); $this->config = $config; } /** * Wykonywanie taska clean-cache */ public function executeCleanCache() { stAuthUsersListener::checkModificationCredentials($this, $this->getRequest(), $this->getModuleName()); $pakeweb = new stPakeWeb(); $i18n = $this->getContext()->getI18N(); if ($pakeweb->run('cc')) { $flash_text = $i18n->__('Pamięć podręczna została wyczyszczona'); $this->setFlash('notice', $flash_text); } sleep(2); return $this->redirect('stOptimizationBackend/index'); } }