Skip to content

Instantly share code, notes, and snippets.

@tadeubdev
Created August 3, 2016 22:47
Show Gist options
  • Save tadeubdev/ae80da0e7ef45b2ed6cf59d7b935ffe6 to your computer and use it in GitHub Desktop.
Save tadeubdev/ae80da0e7ef45b2ed6cf59d7b935ffe6 to your computer and use it in GitHub Desktop.
<?php
/**
* -------------------------------------------
* A class to compile teedcss into projects
* -------------------------------------------
* Creator: Tadeu Barbosa
* Inits in: > August.03.2016 - 06:30h PM <
*
**/
class TeedCss
{
# Path of your project: configurated 'mysite.dev/', this is setted by `Startup` function
protected $InitialPath = "";
# Name of file in your project to receive data with your project config: default 'mysite.dev/teedcss.conf'
protected $ConfigFileName = "teedcss.conf";
# Object receives Data of configuration file `ConfigFileName`
protected $ConfiData = new objClass;
#
protected $RegexToGet = array(
# link
"/(?<dad>[^s])\:(?<function>visited|hover|active) (?<child>.*)/",
"/(?<element>html|body|a|div|span|small|p|section|article|frameset|iframe|form|label|button|input|h1|h2|h3|h4|h5)/",
"/(?<element>\#.*|\..*)/",
);
/**
* Inits a class and config file data
**/
public static function Startup($_InitialPath)
{
self::$InitalPath = $_InitialPath;
#
self::$ConfigFileName = "{self::$InitialPath}{self::$ConfigFileName}";
# Create a file if not exists and write a data default
if( !file_exists(self::$ConfigFileName)) self::CreateAFileConfig();
}
private static function CreateAFileConfig()
{
$File = fopen(self::$ConfigFileName, "w+");
$DataToInsert = "Output=Compressed",
"SaveVersion=True",
"CssFiles='www\teedcss\'",
"CssOutput='www\css\'";
fwrite($DataToInsert, $File);
fclose($File);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment