Ejemplo n.º 1
0
Archivo: unit.php Proyecto: ssrsfs/blg
 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");
 }
Ejemplo n.º 2
0
<?php

$file = isset($_REQUEST['file']) ? $_REQUEST['file'] : '';
if ($file && file_exists(TYPEF_DIR . $file) && is_file(TYPEF_DIR . $file)) {
    header('Content-type: text/css');
    $dir = dirname($file);
    $md5 = md5($file) . '.css';
    $dst = TYPEF_DIR . '/files/cache/lessphp/' . $md5;
    lessc::ccompile(TYPEF_DIR . $file, $dst);
    $css = SimpleCss::LoadFile($dst, TYPEF_WEB_DIR . $dir);
    $code = $css->toString();
    preg_match_all('/url\\(\\"([\\w\\W\\s\\S]*?)"\\)/', $code, $matches);
    if (isset($matches[1])) {
        foreach ($matches[1] as $url) {
            $url = Typeframe_Attribute_Url::ConvertShortUrlToExpression($url);
            $url = Typeframe::Pagemill()->data()->parseVariables($url);
            $code = str_replace($matches[1], $url, $code);
        }
    }
    echo $code;
    exit;
} else {
    http_response_code(404);
    Typeframe::SetPageTemplate('/404.html');
    Typeframe::CurrentPage()->stop();
}
Ejemplo n.º 3
0
Archivo: style.php Proyecto: ssrsfs/blg
     $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);
                     }
                 }