示例#1
0
 public static function link_tags()
 {
     $args = func_get_args();
     $styles = array();
     foreach ($args as $ai => $arg) {
         if (is_array($arg)) {
             foreach ($arg as $aai => $a) {
                 $styles[] = $a;
             }
         } else {
             $styles[] = $arg;
         }
     }
     $tags = array();
     foreach ($styles as $si => $style) {
         if (self::$convert_less) {
             $style = preg_replace('/\\.less$/', '.css', $style);
         }
         if (preg_match('/\\.less$/', $style)) {
             // add revision as GET param to avoid old, cached css/less
             if ($rev = Sourcemap::revision()) {
                 $style .= '?_v=' . $rev;
             }
             $tags[] = '<link rel="stylesheet/less" href="' . $style . '" type="text/css" />';
         } else {
             // add revision as GET param to avoid old, cached css/less
             if ($rev = Sourcemap::revision()) {
                 $style .= '?_v=' . $rev;
             }
             $tags[] = '<link rel="stylesheet" href="' . $style . '" type="text/css"/>';
         }
     }
     $tags = join("\n", $tags);
     return $tags;
 }
示例#2
0
 public function __construct($url = null)
 {
     $this->url = $url;
     $this->method = self::GET;
     $this->user_agent = sprintf('Sourcemap HTTP Client (%d)', Sourcemap::revision());
     $this->parameters = array();
     $this->headers = array();
     $this->_ch = curl_init();
     curl_setopt($this->_ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($this->_ch, CURLOPT_HEADER, true);
 }
示例#3
0
 public static function script_tags()
 {
     $args = func_get_args();
     $scripts = call_user_func_array(array('self', 'scripts'), $args);
     $tags = array();
     if ($rev = Sourcemap::revision()) {
         $rev = "_v={$rev}";
     } else {
         $rev = '';
     }
     foreach ($scripts as $i => $script) {
         if ($rev && !preg_match('/^https?:\\/\\//', $script)) {
             if (strstr($script, '?')) {
                 $script .= "&{$rev}";
             } else {
                 $script .= "?{$rev}";
             }
         }
         $tags[] = HTML::script($script);
     }
     return join("\n", $tags);
 }