Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 1
<?php
2
 
3
namespace Sabberworm\CSS\CSSList;
4
 
5
use Sabberworm\CSS\OutputFormat;
6
use Sabberworm\CSS\Property\AtRule;
7
 
8
/**
9
 * A `BlockList` constructed by an unknown at-rule. `@media` rules are rendered into `AtRuleBlockList` objects.
10
 */
11
class AtRuleBlockList extends CSSBlockList implements AtRule
12
{
13
    /**
14
     * @var string
15
     */
16
    private $sType;
17
 
18
    /**
19
     * @var string
20
     */
21
    private $sArgs;
22
 
23
    /**
24
     * @param string $sType
25
     * @param string $sArgs
26
     * @param int $iLineNo
27
     */
28
    public function __construct($sType, $sArgs = '', $iLineNo = 0)
29
    {
30
        parent::__construct($iLineNo);
31
        $this->sType = $sType;
32
        $this->sArgs = $sArgs;
33
    }
34
 
35
    /**
36
     * @return string
37
     */
38
    public function atRuleName()
39
    {
40
        return $this->sType;
41
    }
42
 
43
    /**
44
     * @return string
45
     */
46
    public function atRuleArgs()
47
    {
48
        return $this->sArgs;
49
    }
50
 
51
    /**
52
     * @return string
53
     */
54
    public function __toString()
55
    {
56
        return $this->render(new OutputFormat());
57
    }
58
 
59
    /**
60
     * @param OutputFormat|null $oOutputFormat
61
     *
62
     * @return string
63
     */
64
    public function render($oOutputFormat)
65
    {
66
        $sResult = $oOutputFormat->comments($this);
67
        $sResult .= $oOutputFormat->sBeforeAtRuleBlock;
68
        $sArgs = $this->sArgs;
69
        if ($sArgs) {
70
            $sArgs = ' ' . $sArgs;
71
        }
72
        $sResult .= "@{$this->sType}$sArgs{$oOutputFormat->spaceBeforeOpeningBrace()}{";
73
        $sResult .= $this->renderListContents($oOutputFormat);
74
        $sResult .= '}';
75
        $sResult .= $oOutputFormat->sAfterAtRuleBlock;
76
        return $sResult;
77
    }
78
 
79
    /**
80
     * @return bool
81
     */
82
    public function isRootList()
83
    {
84
        return false;
85
    }
86
}