* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
class csstidy_print {
+ /**
+ * csstidy object
+ * @var object
+ */
+ public $parser;
+
/**
* Saves the input CSS string
* @var string
* @access private
*/
- var $input_css = '';
+ public $input_css = '';
/**
* Saves the formatted CSS string
* @var string
* @access public
*/
- var $output_css = '';
+ public $output_css = '';
/**
* Saves the formatted CSS string (plain text)
* @var string
* @access public
*/
- var $output_css_plain = '';
+ public $output_css_plain = '';
/**
* Constructor
* @access private
* @version 1.0
*/
- function csstidy_print(&$css) {
- $this->parser = & $css;
+ public function __construct($css) {
+ $this->parser = $css;
$this->css = & $css->css;
$this->template = & $css->template;
$this->tokens = & $css->tokens;
* @access private
* @version 1.0
*/
- function _reset() {
+ public function _reset() {
$this->output_css = '';
$this->output_css_plain = '';
}
* @access public
* @version 1.0
*/
- function plain($default_media='') {
+ public function plain($default_media='') {
$this->_print(true, $default_media);
return $this->output_css_plain;
}
* @access public
* @version 1.0
*/
- function formatted($default_media='') {
+ public function formatted($default_media='') {
$this->_print(false, $default_media);
return $this->output_css;
}
* @access public
* @version 1.4
*/
- function formatted_page($doctype='xhtml1.1', $externalcss=true, $title='', $lang='en') {
+ public function formatted_page($doctype='html5', $externalcss=true, $title='', $lang='en') {
switch ($doctype) {
- case 'xhtml1.0strict':
+ case 'html5':
+ $doctype_output = '<!DOCTYPE html>';
+ break;
+ case 'xhtml1.0strict':
$doctype_output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
break;
$output .= "\n</style>";
} else {
$output .= "\n" . ' <link rel="stylesheet" type="text/css" href="cssparsed.css" />';
-// }
}
$output .= "\n</head>\n<body><code id=\"copytext\">";
$output .= $this->formatted();
* @access private
* @version 2.0
*/
- function _print($plain = false, $default_media='') {
+ public function _print($plain = false, $default_media='') {
if ($this->output_css && $this->output_css_plain) {
return;
}
* @access private
* @version 1.0
*/
- function _seeknocomment($key, $move) {
+ public function _seeknocomment($key, $move) {
$go = ($move > 0) ? 1 : -1;
for ($i = $key + 1; abs($key - $i) - 1 < abs($move); $i += $go) {
if (!isset($this->tokens[$i])) {
* @access private
* @version 1.0
*/
- function _convert_raw_css($default_media='') {
+ public function _convert_raw_css($default_media='') {
$this->tokens = array();
$sort_selectors = $this->parser->get_cfg('sort_selectors');
$sort_properties = $this->parser->get_cfg('sort_properties');
ksort($val);
if (intval($medium) < DEFAULT_AT) {
// un medium vide (contenant @font-face ou autre @) ne produit aucun conteneur
- if (strlen(trim($medium))){
+ if (strlen(trim($medium))) {
$this->parser->_add_token(AT_START, $medium, true);
}
- }
- elseif ($default_media) {
+ } elseif ($default_media) {
$this->parser->_add_token(AT_START, $default_media, true);
}
-
+
foreach ($val as $selector => $vali) {
if ($sort_properties)
ksort($vali);
'-' => array() // IE6 hacks
);
foreach ($vali as $property => $valj) {
- if (strncmp($property,"//",2)!==0){
+ if (strncmp($property,"//",2)!==0) {
$matches = array();
if ($sort_properties && preg_match('/^(\*|_|\/|-)(?!(ms|moz|o\b|xv|atsc|wap|khtml|webkit|ah|hp|ro|rim|tc)-)/', $property, $matches)) {
$invalid[$matches[1]][$property] = $valj;
if (intval($medium) < DEFAULT_AT) {
// un medium vide (contenant @font-face ou autre @) ne produit aucun conteneur
- if (strlen(trim($medium))){
+ if (strlen(trim($medium))) {
$this->parser->_add_token(AT_END, $medium, true);
}
- }
- elseif ($default_media) {
+ } elseif ($default_media) {
$this->parser->_add_token(AT_END, $default_media, true);
}
}
* @access private
* @version 1.0
*/
- function _htmlsp($string, $plain) {
+ public function _htmlsp($string, $plain) {
if (!$plain) {
return htmlspecialchars($string, ENT_QUOTES, 'utf-8');
}
* @return float
* @version 1.2
*/
- function get_ratio() {
+ public function get_ratio() {
if (!$this->output_css_plain) {
$this->formatted();
}
* @return string
* @version 1.1
*/
- function get_diff() {
+ public function get_diff() {
if (!$this->output_css_plain) {
$this->formatted();
}
* @return integer
* @version 1.0
*/
- function size($loc = 'output') {
+ public function size($loc = 'output') {
if ($loc === 'output' && !$this->output_css) {
$this->formatted();
}