public function testLoadString() { $css = "body {background-color: silver; color: red;} p a.anchor {color: blue;} p a.anchor:hover {color: green;} blockquote {background-image: url('images/quote.jpg')"; $doc = SimpleCss::LoadString($css); $this->assertTrue(is_a($doc, 'SimpleCss_Document'), "SimpleCss::LoadString did not return a SimpleCss_Document object"); }
$extension = pathinfo($s, PATHINFO_EXTENSION); if ($extension == strtolower('less')) { $cur = $less->parse(file_get_contents(TYPEF_DIR . substr($s, strlen(TYPEF_WEB_DIR)))) . "\n"; $cur = SimpleCss::LoadString($cur, dirname($s))->toString(); $base .= $cur; } else { $cur = file_get_contents(TYPEF_DIR . substr($s, strlen(TYPEF_WEB_DIR))) . "\n"; $cur = SimpleCss::LoadString($cur, dirname($s))->toString(); $base .= $cur; } } $output = $base; $output = "/* SELECTOR: {$_REQUEST['selector']} */\n\n" . $output; // Find rules that affect the provided selector's content and apply them to // the editor's body. $css = SimpleCss::LoadString($base); foreach ($css->Stylerulesets() as $ruleset) { foreach ($ruleset->selectors() as $selector) { $target = $selectors; $parts = explode(' ', $selector); $cur = count($parts); $match = true; while (count($target) && count($parts)) { if ($target[0] != $parts[0]) { $match = false; if (substr($parts[0], 0, 1) == '#' || substr($parts[0], 0, 1) == '.') { if (strpos($target[0], $parts[0]) !== false) { $match = true; array_shift($parts); } }