Merhabalar,

Yazmış olduğum araçta stil dosyalarınızı sıkıştırabiliyor ve dizinleri kolaylıkla belirtebiliyorsunuz.

ilgili sınıf dosyamız;

class compressor
{
protected $basePath;
protected $fileContentArray;
protected $fileClearedContentArray;

public function __construct()
{
header('content-type:text/css;charset=utf-8');
$this->fileContentArray = array();
$this->_createBasePath();
// stil dosyalarınızı buraya ekleyiniz.
// örnek ; $this->_read('benimstilim.css');
// şeklinde ekleyiniz.
$this->_read('reset.css');
$this->_read('style.css');
$this->_compress();
$this->_print();
}

protected function _read($path)
{
if( is_readable($path) )
{
array_push($this->fileContentArray,file_get_contents($path));
return true;
}
}

protected function _compress()
{
if( is_null($this->fileContentArray) ) return false;
foreach($this->fileContentArray as $key => $value)
{
$tmp = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $value);
$tmp = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $tmp);
$tmp = str_replace(array(', ',' {','} ','{ ',' }',': ','; '), array(',','{','}','{','}',':',';'), $tmp);
$tmp = str_replace('__BASEPATH__', $this->basePath, $tmp);
$this->fileClearedContentArray[$key] = $tmp;
}
}

protected function _print()
{
foreach($this->fileClearedContentArray as $key => $value)
{
echo $value;
}
}

protected function _createBasePath()
{
$this->basePath = __DIR__;
$this->basePath = str_replace(dirname($this->basePath), '', $this->basePath);
$this->basePath = str_replace(DIRECTORY_SEPARATOR, '/', $this->basePath);
$this->basePath = 'http://'.$_SERVER['HTTP_HOST'].$this->basePath;
}
}
new compressor;
?>


ve bir yeni özellik olarak stil dosyalarınızda script ana klasör yolu belirtebiliyorsunuz.

Örneğin;


body
{
background:#FFF url('__BASEPATH__/images/background.png');
}


__BASEPATH__ değişkeninin kullanıyoruz.

Sorunları başlık altından bildirin lütfen iyi forumlar