Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
// $Header: /cvsroot/html2ps/css.background.repeat.inc.php,v 1.8 2006/07/09 09:07:44 Konstantin Exp $
3
 
4
define('BR_REPEAT',0);
5
define('BR_REPEAT_X',1);
6
define('BR_REPEAT_Y',2);
7
define('BR_NO_REPEAT',3);
8
 
9
class CSSBackgroundRepeat extends CSSSubFieldProperty {
10
  function get_property_code() {
11
    return CSS_BACKGROUND_REPEAT;
12
  }
13
 
14
  function get_property_name() {
15
    return 'background-repeat';
16
  }
17
 
18
  function default_value() { return BR_REPEAT; }
19
 
20
  function parse($value) {
21
    if ($value === 'inherit') {
22
      return CSS_PROPERTY_INHERIT;
23
    }
24
 
25
    // Note that we cannot just compare $value with these strings for equality,
26
    // as 'parse' can be called with composite 'background' value as a parameter,
27
    // say, 'black url(picture.gif) repeat', instead of just using 'repeat'
28
 
29
    // Also, note that
30
    // 1) 'repeat-x' value will match 'repeat' term
31
    // 2) background-image 'url' values may contain these values as substrings
32
    // to avoid these problems, we'll add spaced to the beginning and to the end of value,
33
    // and will search for space-padded values, instead of raw substrings
34
    $value = " ".$value." ";
35
    if (strpos($value, ' repeat-x ')  !== false) { return BR_REPEAT_X; };
36
    if (strpos($value, ' repeat-y ')  !== false) { return BR_REPEAT_Y; };
37
    if (strpos($value, ' no-repeat ') !== false) { return BR_NO_REPEAT; };
38
    if (strpos($value, ' repeat ')    !== false) { return BR_REPEAT; };
39
    return CSSBackgroundRepeat::default_value();
40
  }
41
}
42
 
43
?>