private function addResource($type, $file_names, $single = false)
 {
     if ($single) {
         if (count($file_names) > 1) {
             $file_names = array($file_names[0]);
         }
         $Resource = new Resource();
         $type == 'file' ? $Resource->setFile($file_names[0]) : $Resource->setString($file_names[0]);
         /*$Resource->setDriver($this->driver);*/
         $this->resources[] = $Resource;
         $Resource->collection = $this;
         return $Resource;
     } else {
         $class = __CLASS__;
         $Collection = new $class();
         $Collection->collection = $this;
         $this->resources[] = $Collection;
         foreach ($file_names as $data) {
             if (is_string($data)) {
                 $type == 'file' ? $Collection->addSingleFile($data) : $Collection->addSingleString($data);
             } else {
                 $type == 'file' ? $Collection->addFile($data) : $Collection->addString($data);
             }
         }
         return $Collection;
     }
 }
						([;|}])
			/ixs', '$1$2; $1hand$3'), 'opacity' => array('/
						(opacity\\s*:\\s*)
						(\\d*(?:\\.\\d*)?)
						([;|}])
			/ixs', function ($matches) {
        return $matches[1] . $matches[2] . '; ' . 'filter: alpha(opacity=' . round(floatval($matches[2]) * 100) . ');' . '-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=' . round(floatval($matches[2]) * 100) . ')"' . $matches[3];
    }, true));
    foreach ($replace_pairs as $rule) {
        if (!empty($rule[2])) {
            $string = preg_replace_callback($rule[0], $rule[1], $string);
        } else {
            $string = preg_replace($rule[0], $rule[1], $string);
        }
    }
    return $string;
};
$CSS = new Resource('CSS');
$CSS->setFile('css/w3-correct.css')->handler($handleBorderRadius)->inline()->handler(function ($string) {
    return '/* Author: Anton Ruban */' . "\r\n" . $string;
})->flush();
$JS = new Resource();
$JS->driver('JavaScript')->setFile('js/example.js')->handler(function ($string) {
    $packer = new JavaScriptPacker($string);
    return $packer->pack();
})->inline()->file('tmp/example.js')->flush();
?>
<div id="foobar" style="border: 1px solid #D0D0D0; padding: 20px; width: 300px;">Hello, world</div>
</body>
</html>
Beispiel #3
0
<?php

include 'init.php';
$JS = new Resource(new DriverJavaScript(array('base-uri' => '/')));
$JS->setFile('js/example.js');
$JS->flush();