public function EventExec() { $sFile = ''; $sSourceFile = implode('/', $this->GetParams()); $sSourceFile = str_replace('[skin]', HelperPlugin::GetTemplatePath(), $sSourceFile); $sSourceFile = str_replace('[admin_skin]', HelperPlugin::GetPluginPath('aceadminpanel') . '/templates/skin/' . $this->Admin_GetAdminSkin(), $sSourceFile); if (isset($_SERVER['QUERY_STRING']) and $_SERVER['QUERY_STRING']) { $sSourceFile .= '?' . $_SERVER['QUERY_STRING']; } $sCachePath = Config::Get('path.smarty.cache') . '/' . $this->Admin_GetAdminSkin(); $aFileParts = ACE::PathInfo($sSourceFile); if (strtolower($aFileParts['extension']) == 'css' and getRequest('from', '', 'get') == 'less') { $sSourceFile = $aFileParts['dirname'] . '/' . $aFileParts['filename'] . '.less'; $sFileType = 'less'; } elseif (strtolower($aFileParts['extension']) == 'less') { $sFileType = 'less'; } else { $sFileType = 'other'; } if ($sFileType == 'less') { $sCachePath .= '/css/'; if (!is_dir($sCachePath)) { ACE::MakeDir($sCachePath); } $aLessParams = array('file' => $sSourceFile, 'config' => array('formatter' => 'compressed'), 'variables' => array('gridColumns' => 16, 'gridColumnWidth' => '65px', 'gridGutterWidth' => '12px', 'baseFontSize' => '12px', 'baseLineHeight' => '18px')); // определяем целевой CSS-файл $sFile = ACE::FilePath($sCachePath . '/' . md5(serialize($aLessParams)) . '.css'); // если целевого файла нет - компилируем его из исходного LESS-файла if (!is_file($sFile)) { $oLess = $this->PluginAceadminpanel_Aceless_GetLessCompiler(); $oLess->setVariables($aLessParams['variables'], true); $oLess->setFormatter('compressed'); $oLess->checkedCompile($sSourceFile, $sFile); $this->aFiles[] = array('source' => $sSourceFile, 'target' => $sFile); } $sContentType = 'text/css'; } else { $sCachePath .= '/' . basename($aFileParts['dirname']) . '/'; if (!is_dir($sCachePath)) { ACE::MakeDir($sCachePath); } $sFile = $sCachePath . $aFileParts['basename']; copy($sSourceFile, $sFile); $sContentType = 'image/' . strtolower($aFileParts['extension']); } if ($sFile and is_file($sFile)) { $sCssContent = file_get_contents($sFile); header('Content-type: ' . $sContentType); echo $sCssContent; } /* */ exit; }
protected static function _makeTmpDir($sTmpPath, $sDirKey, $sConfigKey) { if ($sDir = self::_getVal($sDirKey)) { if (is_dir($sPath = $sTmpPath . '/' . $sDir) or ACE::MakeDir($sPath, 0777, true)) { Config::Set($sConfigKey, $sPath); return true; } } }