html5-starter 0.1.3b
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +3 -0
- data/README.md +135 -0
- data/VERSION +1 -0
- data/lib/app/helpers/html5_boilerplate_helper.rb +47 -0
- data/lib/html5-boilerplate.rb +6 -0
- data/stylesheets/_html5-boilerplate.scss +15 -0
- data/stylesheets/html5-boilerplate/_fonts.scss +36 -0
- data/stylesheets/html5-boilerplate/_handheld.scss +8 -0
- data/stylesheets/html5-boilerplate/_helpers.scss +25 -0
- data/stylesheets/html5-boilerplate/_print.scss +20 -0
- data/stylesheets/html5-boilerplate/_reset.scss +50 -0
- data/stylesheets/html5-boilerplate/_styles.scss +100 -0
- data/templates/project/_flashes.html.haml +4 -0
- data/templates/project/_footer.html.haml +2 -0
- data/templates/project/_head.html.haml +32 -0
- data/templates/project/_header.html.haml +1 -0
- data/templates/project/_javascripts.html.haml +38 -0
- data/templates/project/_stylesheets.html.haml +8 -0
- data/templates/project/application.html.haml +15 -0
- data/templates/project/files/404.html +22 -0
- data/templates/project/files/apple-touch-icon.png +0 -0
- data/templates/project/files/build/build.xml +636 -0
- data/templates/project/files/build/buildinfo.properties +5 -0
- data/templates/project/files/build/config/build.properties +3 -0
- data/templates/project/files/build/config/default.properties +79 -0
- data/templates/project/files/build/config/project.properties +49 -0
- data/templates/project/files/build/createproject.sh +73 -0
- data/templates/project/files/build/tools/ant-contrib-1.0b3.jar +0 -0
- data/templates/project/files/build/tools/css-compressor/CSSCompression.php +465 -0
- data/templates/project/files/build/tools/css-compressor/changelog.txt +22 -0
- data/templates/project/files/build/tools/css-compressor/cli.php +101 -0
- data/templates/project/files/build/tools/css-compressor/helpers/hex2short-colors.json +39 -0
- data/templates/project/files/build/tools/css-compressor/helpers/hex2short-safe.json +16 -0
- data/templates/project/files/build/tools/css-compressor/helpers/long2hex-colors.json +127 -0
- data/templates/project/files/build/tools/css-compressor/lib/Cleanup.php +218 -0
- data/templates/project/files/build/tools/css-compressor/lib/Color.php +199 -0
- data/templates/project/files/build/tools/css-compressor/lib/Combine.php +191 -0
- data/templates/project/files/build/tools/css-compressor/lib/Combine/Aural.php +109 -0
- data/templates/project/files/build/tools/css-compressor/lib/Combine/Background.php +107 -0
- data/templates/project/files/build/tools/css-compressor/lib/Combine/Border.php +98 -0
- data/templates/project/files/build/tools/css-compressor/lib/Combine/BorderOutline.php +109 -0
- data/templates/project/files/build/tools/css-compressor/lib/Combine/BorderRadius.php +262 -0
- data/templates/project/files/build/tools/css-compressor/lib/Combine/Font.php +125 -0
- data/templates/project/files/build/tools/css-compressor/lib/Combine/List.php +104 -0
- data/templates/project/files/build/tools/css-compressor/lib/Combine/MarginPadding.php +190 -0
- data/templates/project/files/build/tools/css-compressor/lib/Compress.php +212 -0
- data/templates/project/files/build/tools/css-compressor/lib/Control.php +236 -0
- data/templates/project/files/build/tools/css-compressor/lib/Exception.php +32 -0
- data/templates/project/files/build/tools/css-compressor/lib/Format.php +187 -0
- data/templates/project/files/build/tools/css-compressor/lib/Individuals.php +307 -0
- data/templates/project/files/build/tools/css-compressor/lib/Numeric.php +103 -0
- data/templates/project/files/build/tools/css-compressor/lib/Option.php +133 -0
- data/templates/project/files/build/tools/css-compressor/lib/Organize.php +149 -0
- data/templates/project/files/build/tools/css-compressor/lib/Selectors.php +245 -0
- data/templates/project/files/build/tools/css-compressor/lib/Setup.php +292 -0
- data/templates/project/files/build/tools/css-compressor/lib/Trim.php +213 -0
- data/templates/project/files/build/tools/css-compressor/license.txt +21 -0
- data/templates/project/files/build/tools/htmlcompressor-0.9.8.jar +0 -0
- data/templates/project/files/build/tools/jpegtran.exe +0 -0
- data/templates/project/files/build/tools/optipng-0.6.4-exe/LICENSE.txt +21 -0
- data/templates/project/files/build/tools/optipng-0.6.4-exe/optipng.exe +0 -0
- data/templates/project/files/build/tools/yuicompressor-2.4.2.jar +0 -0
- data/templates/project/files/crossdomain.xml +25 -0
- data/templates/project/files/favicon.ico +0 -0
- data/templates/project/files/gitignore.txt +32 -0
- data/templates/project/files/gitignore_placeholder.txt +2 -0
- data/templates/project/files/google.yml +22 -0
- data/templates/project/files/htaccess +415 -0
- data/templates/project/files/humans.txt +43 -0
- data/templates/project/files/lighttpd.conf +149 -0
- data/templates/project/files/mime.types +80 -0
- data/templates/project/files/nginx.conf +108 -0
- data/templates/project/files/robots.txt +5 -0
- data/templates/project/files/web.config +207 -0
- data/templates/project/handheld.scss +8 -0
- data/templates/project/index.html +81 -0
- data/templates/project/javascripts/libs/dd_belatedpng.js +13 -0
- data/templates/project/javascripts/libs/jquery-1.4.4.js +7179 -0
- data/templates/project/javascripts/libs/jquery-1.4.4.min.js +167 -0
- data/templates/project/javascripts/libs/modernizr-1.6.min.js +30 -0
- data/templates/project/javascripts/plugins.js +13 -0
- data/templates/project/javascripts/rails.js +156 -0
- data/templates/project/javascripts/script.js +26 -0
- data/templates/project/manifest.rb +101 -0
- data/templates/project/partials/_base.scss +23 -0
- data/templates/project/style.scss +70 -0
- metadata +171 -0
@@ -0,0 +1,199 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* CSS Compressor [VERSION]
|
4
|
+
* [DATE]
|
5
|
+
* Corey Hart @ http://www.codenothing.com
|
6
|
+
*/
|
7
|
+
|
8
|
+
Class CSSCompression_Color
|
9
|
+
{
|
10
|
+
/**
|
11
|
+
* Color Patterns
|
12
|
+
*
|
13
|
+
* @class Control: Compression Controller
|
14
|
+
* @param (array) options: Reference to options array
|
15
|
+
* @param (regex) rrgb: Checks for rgb notation
|
16
|
+
* @param (regex) rhex: Checks for hex code
|
17
|
+
* @param (regex) rfullhex: Checks for full 6 character hex code
|
18
|
+
* @static (array) color2hex: Long color name to hex code conversions
|
19
|
+
* @static (array) hex2short: Hex code to short color name conversions
|
20
|
+
* @static (array) hex2short_safe: CSS Level 1 safe color names that are shorter than hex codes
|
21
|
+
* @static (array) files: List of static helpers with their class vars
|
22
|
+
*/
|
23
|
+
private $Control;
|
24
|
+
private $options = array();
|
25
|
+
private $rrgb = "/^rgb\((\d{1,3}\%?(,\d{1,3}\%?,\d{1,3}\%?)?)\)$/i";
|
26
|
+
private $rhex = "/^#([0-9a-f]{3}|[0-9a-f]{6})$/i";
|
27
|
+
private $rfullhex = "/^#([0-9a-f]{6})$/i";
|
28
|
+
private static $color2hex = array();
|
29
|
+
private static $hex2short = array();
|
30
|
+
private static $hex2short_safe = array();
|
31
|
+
private static $files = array(
|
32
|
+
'color2hex' => 'long2hex-colors.json',
|
33
|
+
'hex2short' => 'hex2short-colors.json',
|
34
|
+
'hex2short_safe' => 'hex2short-safe.json',
|
35
|
+
);
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Stash a reference to the controller on each instantiation
|
39
|
+
* and install conversion helpers
|
40
|
+
*
|
41
|
+
* @param (class) control: CSSCompression Controller
|
42
|
+
*/
|
43
|
+
public function __construct( CSSCompression_Control $control ) {
|
44
|
+
$this->Control = $control;
|
45
|
+
$this->options = &$control->Option->options;
|
46
|
+
|
47
|
+
if ( ! self::$color2hex ) {
|
48
|
+
foreach ( self::$files as $v => $file ) {
|
49
|
+
self::$$v = CSSCompression::getJSON( $file );
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
/**
|
55
|
+
* Central handler for all color conversions.
|
56
|
+
*
|
57
|
+
* @param (string) val: Color to be parsed
|
58
|
+
*/
|
59
|
+
public function color( $val ) {
|
60
|
+
// Converts rgb values to hex codes
|
61
|
+
if ( $this->options['color-rgb2hex'] ) {
|
62
|
+
$val = $this->rgb2hex( $val );
|
63
|
+
}
|
64
|
+
|
65
|
+
// Convert long color names to hex codes
|
66
|
+
if ( $this->options['color-long2hex'] ) {
|
67
|
+
$val = $this->color2hex( $val );
|
68
|
+
}
|
69
|
+
|
70
|
+
// Ensure all hex codes are lowercase
|
71
|
+
if ( preg_match( $this->rhex, $val ) ) {
|
72
|
+
$val = strtolower( $val );
|
73
|
+
}
|
74
|
+
|
75
|
+
// Convert large hex codes to small codes
|
76
|
+
if ( $this->options['color-hex2shorthex'] ) {
|
77
|
+
$val = $this->hex2short( $val );
|
78
|
+
}
|
79
|
+
|
80
|
+
// Convert 6 digit hex codes to short color names
|
81
|
+
if ( $this->options['color-hex2shortcolor'] ) {
|
82
|
+
$val = $this->hex2color( $val );
|
83
|
+
}
|
84
|
+
|
85
|
+
// Convert safe css level1 color names
|
86
|
+
if ( $this->options['color-hex2safe'] ) {
|
87
|
+
$val = $this->hex2safe( $val );
|
88
|
+
}
|
89
|
+
|
90
|
+
return $val;
|
91
|
+
}
|
92
|
+
|
93
|
+
/**
|
94
|
+
* Converts rgb values to hex codes
|
95
|
+
*
|
96
|
+
* @param (string) val: Color to be converted
|
97
|
+
*/
|
98
|
+
private function rgb2hex( $val ) {
|
99
|
+
if ( ! preg_match( $this->rrgb, $val, $match ) ) {
|
100
|
+
return $val;
|
101
|
+
}
|
102
|
+
|
103
|
+
// locals
|
104
|
+
$hex = '0123456789abcdef';
|
105
|
+
$str = explode( ',', $match[ 1 ] );
|
106
|
+
$new = '';
|
107
|
+
|
108
|
+
// Incase rgb was defined with single val
|
109
|
+
if ( ! $str ) {
|
110
|
+
$str = array( $match[ 1 ] );
|
111
|
+
}
|
112
|
+
|
113
|
+
foreach ( $str as $x ) {
|
114
|
+
$x = strpos( $x, '%' ) !== false ? intval( ( intval( $x ) / 100 ) * 255 ) : intval( $x );
|
115
|
+
|
116
|
+
if ( $x > 255 ) {
|
117
|
+
$x = 255;
|
118
|
+
}
|
119
|
+
|
120
|
+
if ( $x < 0 ) {
|
121
|
+
$x = 0;
|
122
|
+
}
|
123
|
+
|
124
|
+
$new .= $hex[ ( $x - $x % 16 ) / 16 ];
|
125
|
+
$new .= $hex[ $x % 16 ];
|
126
|
+
}
|
127
|
+
|
128
|
+
// Repeat hex code to complete 6 digit hex requirement for single definitions
|
129
|
+
if ( count( $str ) == 1 ) {
|
130
|
+
$new .= $new . $new;
|
131
|
+
}
|
132
|
+
|
133
|
+
// Replace with hex value
|
134
|
+
return "#$new";
|
135
|
+
}
|
136
|
+
|
137
|
+
/**
|
138
|
+
* Convert long color names to hex codes
|
139
|
+
*
|
140
|
+
* @param (string) val: Color to be converted
|
141
|
+
*/
|
142
|
+
private function color2hex( $val ) {
|
143
|
+
return isset( self::$color2hex[ $val ] ) ? self::$color2hex[ $val ] : $val;
|
144
|
+
}
|
145
|
+
|
146
|
+
/**
|
147
|
+
* Convert large hex codes to small codes
|
148
|
+
*
|
149
|
+
* @param (string) val: Hex to be shortened
|
150
|
+
*/
|
151
|
+
private function hex2short( $val ) {
|
152
|
+
if ( ! preg_match( $this->rfullhex, $val, $match ) ) {
|
153
|
+
return $val;
|
154
|
+
}
|
155
|
+
|
156
|
+
// See if we can convert to 3 char hex
|
157
|
+
$hex = $match[ 1 ];
|
158
|
+
if ( $hex[ 0 ] == $hex[ 1 ] && $hex[ 2 ] == $hex[ 3 ] && $hex[ 4 ] == $hex[ 5 ] ) {
|
159
|
+
$val = '#' . $hex[ 0 ] . $hex[ 2 ] . $hex[ 4 ];
|
160
|
+
}
|
161
|
+
|
162
|
+
return $val;
|
163
|
+
}
|
164
|
+
|
165
|
+
/**
|
166
|
+
* Convert large hex codes to small codes
|
167
|
+
*
|
168
|
+
* @param (string) val: Color to be converted
|
169
|
+
*/
|
170
|
+
private function hex2color( $val ) {
|
171
|
+
return isset( self::$hex2short[ $val ] ) ? self::$hex2short[ $val ] : $val;
|
172
|
+
}
|
173
|
+
|
174
|
+
/**
|
175
|
+
* Convert large hex codes to small codes
|
176
|
+
*
|
177
|
+
* @param (string) val: Color to be converted
|
178
|
+
*/
|
179
|
+
private function hex2safe( $val ) {
|
180
|
+
return isset( self::$hex2short_safe[ $val ] ) ? self::$hex2short_safe[ $val ] : $val;
|
181
|
+
}
|
182
|
+
|
183
|
+
/**
|
184
|
+
* Access to private methods for testing
|
185
|
+
*
|
186
|
+
* @param (string) method: Method to be called
|
187
|
+
* @param (array) args: Array of paramters to be passed in
|
188
|
+
*/
|
189
|
+
public function access( $method, $args ) {
|
190
|
+
if ( method_exists( $this, $method ) ) {
|
191
|
+
return call_user_func_array( array( $this, $method ), $args );
|
192
|
+
}
|
193
|
+
else {
|
194
|
+
throw new CSSCompression_Exception( "Unknown method in Color Class - " . $method );
|
195
|
+
}
|
196
|
+
}
|
197
|
+
};
|
198
|
+
|
199
|
+
?>
|
@@ -0,0 +1,191 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* CSS Compressor [VERSION]
|
4
|
+
* [DATE]
|
5
|
+
* Corey Hart @ http://www.codenothing.com
|
6
|
+
*/
|
7
|
+
|
8
|
+
Class CSSCompression_Combine
|
9
|
+
{
|
10
|
+
/**
|
11
|
+
* Combine Patterns
|
12
|
+
*
|
13
|
+
* @class Control: Compression Controller
|
14
|
+
* @param (string) token: Copy of the injection token
|
15
|
+
* @param (array) options: Reference to options
|
16
|
+
* @param (regex) rspace: Checks for space without an escape '\' character before it
|
17
|
+
* @param (regex) rslash: Checks for unescaped slash character
|
18
|
+
* @param (regex) rimportant: Checking props for uncombinables
|
19
|
+
* @param (array) methods: List of options with their corresponding class
|
20
|
+
*/
|
21
|
+
private $Control;
|
22
|
+
private $token = '';
|
23
|
+
private $options = array();
|
24
|
+
private $rspace = "/(?<!\\\)\s/";
|
25
|
+
private $rslash = "/(?<!\\\)\//";
|
26
|
+
private $rimportant = "/inherit|\!important|\!ie|(?<!\\\)\s/i";
|
27
|
+
private $methods = array(
|
28
|
+
'csw-combine' => 'BorderOutline',
|
29
|
+
'border-radius-combine' => 'BorderRadius',
|
30
|
+
'border-combine' => 'Border',
|
31
|
+
'mp-combine' => 'MarginPadding',
|
32
|
+
'background-combine' => 'Background',
|
33
|
+
'auralcp-combine' => 'Aural',
|
34
|
+
'font-combine' => 'Font',
|
35
|
+
'list-combine' => 'List',
|
36
|
+
);
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Sub Comination Classes
|
40
|
+
*
|
41
|
+
* @class BorderOutline: Handles Color/Style/With combinations of border/outline properties
|
42
|
+
* @class BorderRadius: Handles border-radius combinations
|
43
|
+
* @class Border: Handles normal border combinations
|
44
|
+
* @class MarginPadding: Handles margin/padding combinations
|
45
|
+
* @class Background: Handles background combinations
|
46
|
+
* @class Aural: Handles aural combinations
|
47
|
+
* @class Font: Handles font combinations
|
48
|
+
* @class List: Handles list combinations
|
49
|
+
* @param (array) subcombines: Array holding all subcombination classes
|
50
|
+
*/
|
51
|
+
public $BorderOutline;
|
52
|
+
public $BorderRadius;
|
53
|
+
public $Border;
|
54
|
+
public $MarginPadding;
|
55
|
+
public $Background;
|
56
|
+
public $Aural;
|
57
|
+
public $Font;
|
58
|
+
public $List;
|
59
|
+
private $subcombines = array(
|
60
|
+
'BorderOutline',
|
61
|
+
'BorderRadius',
|
62
|
+
'Border',
|
63
|
+
'MarginPadding',
|
64
|
+
'Background',
|
65
|
+
'Aural',
|
66
|
+
'Font',
|
67
|
+
'List',
|
68
|
+
);
|
69
|
+
|
70
|
+
/**
|
71
|
+
* Stash a reference to the controller on each instantiation
|
72
|
+
*
|
73
|
+
* @param (class) control: CSSCompression Controller
|
74
|
+
*/
|
75
|
+
public function __construct( CSSCompression_Control $control ) {
|
76
|
+
$this->Control = $control;
|
77
|
+
$this->token = CSSCompression::TOKEN;
|
78
|
+
$this->options = &$control->Option->options;
|
79
|
+
|
80
|
+
// Include classes if not already done so
|
81
|
+
if ( ! class_exists( "CSSCompression_Combine_Border", false ) ) {
|
82
|
+
$path = dirname(__FILE__) . '/Combine/';
|
83
|
+
foreach ( $this->subcombines as $class ) {
|
84
|
+
require( $path . $class . '.php' );
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
// Instantiate each sub combine
|
89
|
+
foreach ( $this->subcombines as $class ) {
|
90
|
+
$full = "CSSCompression_Combine_$class";
|
91
|
+
$this->$class = new $full( $control, $this );
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
/**
|
96
|
+
* Reads through each detailed package and checks for cross defn combinations
|
97
|
+
*
|
98
|
+
* @param (array) selectors: Array of selectors
|
99
|
+
* @param (array) details: Array of details
|
100
|
+
*/
|
101
|
+
public function combine( &$selectors = array(), &$details = array() ) {
|
102
|
+
foreach ( $details as $i => &$value ) {
|
103
|
+
if ( isset( $selectors[ $i ] ) && strpos( $selectors[ $i ], $this->token ) === 0 ) {
|
104
|
+
continue;
|
105
|
+
}
|
106
|
+
|
107
|
+
foreach ( $this->methods as $option => $class ) {
|
108
|
+
if ( $this->options[ $option ] ) {
|
109
|
+
$value = $this->$class->combine( $value );
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
return array( $selectors, $details );
|
115
|
+
}
|
116
|
+
|
117
|
+
/**
|
118
|
+
* Helper function to ensure flagged words don't get
|
119
|
+
* overridden
|
120
|
+
*
|
121
|
+
* @param (mixed) obj: Array/String of definitions to be checked
|
122
|
+
*/
|
123
|
+
public function checkUncombinables( $obj ) {
|
124
|
+
if ( is_array( $obj ) ) {
|
125
|
+
foreach ( $obj as $item ) {
|
126
|
+
if ( preg_match( $this->rimportant, $item ) ) {
|
127
|
+
return true;
|
128
|
+
}
|
129
|
+
}
|
130
|
+
return false;
|
131
|
+
}
|
132
|
+
else {
|
133
|
+
return preg_match( $this->rimportant, $obj );
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
/**
|
138
|
+
* Helper function to ensure all values of search array
|
139
|
+
* exist within the storage array
|
140
|
+
*
|
141
|
+
* @param (string) prop: CSS Property
|
142
|
+
* @param (array) storage: Array of definitions found
|
143
|
+
* @param (array) search: Array of definitions requred
|
144
|
+
*/
|
145
|
+
public function searchDefinitions( $prop, $storage, $search ) {
|
146
|
+
// Return if storage & search don't match
|
147
|
+
if ( count( $storage ) != count( $search ) ) {
|
148
|
+
return false;
|
149
|
+
}
|
150
|
+
|
151
|
+
$str = "$prop:";
|
152
|
+
foreach ( $search as $value ) {
|
153
|
+
if ( ! isset( $storage[ $value ] ) || $this->checkUncombinables( $storage[ $value ] ) ) {
|
154
|
+
return false;
|
155
|
+
}
|
156
|
+
$str .= $storage[ $value ] . ' ';
|
157
|
+
}
|
158
|
+
return trim( $str ) . ';';
|
159
|
+
}
|
160
|
+
|
161
|
+
/**
|
162
|
+
* Access to private methods for testing
|
163
|
+
*
|
164
|
+
* @param (string) subclass: Name of subclass to focus on
|
165
|
+
* @param (string) method: Method to be called
|
166
|
+
* @param (array) args: Array of paramters to be passed in
|
167
|
+
*/
|
168
|
+
public function access( $subclass, $method, $args ) {
|
169
|
+
if ( $subclass == 'Combine' ) {
|
170
|
+
if ( method_exists( $this, $method ) ) {
|
171
|
+
if ( $method == 'combine' ) {
|
172
|
+
return $this->combine( $args[ 0 ], $args[ 1 ] );
|
173
|
+
}
|
174
|
+
else {
|
175
|
+
return call_user_func_array( array( $this, $method ), $args );
|
176
|
+
}
|
177
|
+
}
|
178
|
+
else {
|
179
|
+
throw new CSSCompression_Exception( "Unknown method in Combine Class - " . $method );
|
180
|
+
}
|
181
|
+
}
|
182
|
+
else if ( in_array( $subclass, $this->subcombines ) ) {
|
183
|
+
return $this->$subclass->access( $method, $args );
|
184
|
+
}
|
185
|
+
else {
|
186
|
+
throw new CSSCompression_Exception( "Unknown Sub Combine Class - " . $subclass );
|
187
|
+
}
|
188
|
+
}
|
189
|
+
};
|
190
|
+
|
191
|
+
?>
|
@@ -0,0 +1,109 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* CSS Compressor [VERSION]
|
4
|
+
* [DATE]
|
5
|
+
* Corey Hart @ http://www.codenothing.com
|
6
|
+
*/
|
7
|
+
|
8
|
+
Class CSSCompression_Combine_Aural
|
9
|
+
{
|
10
|
+
/**
|
11
|
+
* Combine Patterns
|
12
|
+
*
|
13
|
+
* @class Control: Compression Controller
|
14
|
+
* @class Combine: Combine Controller
|
15
|
+
* @param (regex) raural: Aurual matching
|
16
|
+
*/
|
17
|
+
private $Control;
|
18
|
+
private $Combine;
|
19
|
+
private $raural = "/(^|(?<!\\\);)(cue|pause)-(before|after):(.*?)((?<!\\\);|$)/";
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Stash a reference to the controller & combiner
|
23
|
+
*
|
24
|
+
* @param (class) control: CSSCompression Controller
|
25
|
+
* @param (class) combine: CSSCompression Combiner
|
26
|
+
*/
|
27
|
+
public function __construct( CSSCompression_Control $control, CSSCompression_Combine $combine ) {
|
28
|
+
$this->Control = $control;
|
29
|
+
$this->Combine = $combine;
|
30
|
+
}
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Combines Aural properties (currently being depreciated in W3C Standards)
|
34
|
+
*
|
35
|
+
* @param (string) val: Rule Set
|
36
|
+
*/
|
37
|
+
public function combine( $val ) {
|
38
|
+
$storage = $this->storage( $val );
|
39
|
+
$pos = 0;
|
40
|
+
|
41
|
+
// Replace first occurance with it's prop, and remove all following occurances
|
42
|
+
while ( preg_match( $this->raural, $val, $match, PREG_OFFSET_CAPTURE, $pos ) ) {
|
43
|
+
$prop = $match[ 2 ][ 0 ];
|
44
|
+
if ( isset( $storage[ $prop ] ) ) {
|
45
|
+
$colon = strlen( $match[ 1 ][ 0 ] );
|
46
|
+
$val = substr_replace( $val, $storage[ $prop ], $match[ 0 ][ 1 ] + $colon, strlen( $match[ 0 ][ 0 ] ) - $colon );
|
47
|
+
$pos = $match[ 0 ][ 1 ] + strlen( $storage[ $prop ] ) - $colon - 1;
|
48
|
+
$storage[ $prop ] = '';
|
49
|
+
}
|
50
|
+
else {
|
51
|
+
$pos = $match[ 0 ][ 1 ] + strlen( $match[ 0 ][ 0 ] ) - 1;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
// Return converted val
|
56
|
+
return $val;
|
57
|
+
}
|
58
|
+
|
59
|
+
/**
|
60
|
+
* Builds a storage object for iteration
|
61
|
+
*
|
62
|
+
* @param (string) val: Rule Set
|
63
|
+
*/
|
64
|
+
private function storage( $val ) {
|
65
|
+
$storage = array();
|
66
|
+
|
67
|
+
// Find all possible occurences and build the replacement
|
68
|
+
$pos = 0;
|
69
|
+
while ( preg_match( $this->raural, $val, $match, PREG_OFFSET_CAPTURE, $pos ) ) {
|
70
|
+
if ( ! isset( $storage[ $match[ 2 ][ 0 ] ] ) ) {
|
71
|
+
$storage[ $match[ 2 ][ 0 ] ] = array( $match[ 3 ][ 0 ] => $match[ 4 ][ 0 ] );
|
72
|
+
}
|
73
|
+
|
74
|
+
// Override double written properties
|
75
|
+
$storage[ $match[ 2 ][ 0 ] ][ $match[ 3 ][ 0 ] ] = $match[ 4 ][ 0 ];
|
76
|
+
$pos = $match[ 0 ][ 1 ] + strlen( $match[ 0 ][ 0 ] ) - 1;
|
77
|
+
}
|
78
|
+
|
79
|
+
// Go through each tag for possible combination
|
80
|
+
foreach ( $storage as $tag => $arr ) {
|
81
|
+
// All three have to be defined
|
82
|
+
if ( count( $arr ) == 2 && ! $this->Combine->checkUncombinables( $arr ) ) {
|
83
|
+
$storage[ $tag ] = "$tag:" . $arr['before'] . ' ' . $arr['after'] . ';';
|
84
|
+
}
|
85
|
+
else {
|
86
|
+
unset( $storage[ $tag ] );
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
return $storage;
|
91
|
+
}
|
92
|
+
|
93
|
+
/**
|
94
|
+
* Access to private methods for testing
|
95
|
+
*
|
96
|
+
* @param (string) method: Method to be called
|
97
|
+
* @param (array) args: Array of paramters to be passed in
|
98
|
+
*/
|
99
|
+
public function access( $method, $args ) {
|
100
|
+
if ( method_exists( $this, $method ) ) {
|
101
|
+
return call_user_func_array( array( $this, $method ), $args );
|
102
|
+
}
|
103
|
+
else {
|
104
|
+
throw new CSSCompression_Exception( "Unknown method in Aural Class - " . $method );
|
105
|
+
}
|
106
|
+
}
|
107
|
+
};
|
108
|
+
|
109
|
+
?>
|