Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
function &parse_css_property($string, &$pipeline) {
4
  $collection =& parse_css_properties($string, $pipeline);
5
  return $collection;
6
}
7
 
8
function &parse_css_properties($string, &$pipeline) {
9
  $property_collection =& new CSSPropertyCollection();
10
 
11
  while ($string != '') {
12
    $string = parse_css_properties_property($string, $code);
13
 
14
    if (preg_match('/^\s*:\s*(.*?)$/si', $string, $matches)) {
15
      $string = $matches[1];
16
    };
17
 
18
    $string = parse_css_properties_value($string, $value);
19
 
20
    if (preg_match('/^\s*;\s*(.*)$/si', $string, $matches)) {
21
      $string = $matches[1];
22
    };
23
 
24
    $property =& CSSPropertyDeclaration::create($code, $value, $pipeline);
25
    if (!is_null($property)) {
26
      $property_collection->add_property($property);
27
    };
28
  };
29
 
30
  return $property_collection;
31
}
32
 
33
function parse_css_properties_property($string, &$code) {
34
  $identifier_regexp = CSS::get_identifier_regexp();
35
 
36
  if (!preg_match(sprintf('/^\s*(%s)(.*)/si', $identifier_regexp), $string, $matches)) {
37
    $code = null;
38
    return '';
39
  };
40
 
41
  $name = strtolower(trim($matches[1]));
42
  $rest = $matches[2];
43
  $code = CSS::name2code($name);
44
  return $rest;
45
}
46
 
47
function parse_css_properties_value($string, &$value) {
48
  $string1_regexp = CSS_STRING1_REGEXP;
49
  $string2_regexp = CSS_STRING2_REGEXP;
50
 
51
  $value = '';
52
 
53
  do {
54
    $matched = false;
55
 
56
    list($new_value, $string) = CSS::parse_string($string);
57
    if (!is_null($new_value)) {
58
      $value .= $new_value;
59
      $matched = true;
60
    };
61
 
62
    if (preg_match('/^('.CSS_FUNCTION_REGEXP.CSS_IDENT_REGEXP.'\))\s*(.*)$/si', $string, $matches)) {
63
      $value .= $matches[1];
64
      $string = $matches[2];
65
      $matched = true;
66
    };
67
  } while ($matched);
68
 
69
  $value_regexp = '[^;]*?';
70
  if (preg_match(sprintf('/^(%s)(\s*;.*)/si', $value_regexp), $string, $matches)) {
71
    $value .= trim($matches[1]);
72
    $rest = $matches[2];
73
 
74
    return $rest;
75
  };
76
 
77
  $value = $value.trim($string);
78
  return '';
79
}
80
 
81
?>