]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Handle relative and absolute url parameters to script() and cssLink()
authorCraig Andrews <candrews@integralblue.com>
Thu, 6 Aug 2009 00:28:46 +0000 (20:28 -0400)
committerCraig Andrews <candrews@integralblue.com>
Thu, 6 Aug 2009 00:28:46 +0000 (20:28 -0400)
lib/htmloutputter.php

index 0b4c1405a8a3e9048b6b1289262afc536333bf00..9d3244625607740799ec2f792d20a5ecc48091e0 100644 (file)
@@ -349,29 +349,38 @@ class HTMLOutputter extends XMLOutputter
      */
     function script($src, $type='text/javascript')
     {
+        $url = parse_url($src);
+        if(! ($url->scheme || $url->host || $url->query || $url->fragment))
+        {
+            $src = common_path($src) . '?version=' . LACONICA_VERSION;
+        }
         $this->element('script', array('type' => $type,
-                                               'src' => common_path($src) . '?version=' . LACONICA_VERSION),
+                                               'src' => $src),
                                ' ');
     }
 
     /**
      * output a css link
      *
-     * @param string $relative     relative path within the theme directory
+     * @param string $src     relative path within the theme directory, or an absolute path
      * @param string $theme        'theme' that contains the stylesheet
      * @param string media         'media' attribute of the tag
      *
      * @return void
      */
-    function cssLink($relative,$theme,$media)
+    function cssLink($src,$theme,$media)
     {
         if (!$theme) {
             $theme = common_config('site', 'theme');
         }
-
+        $url = parse_url($src);
+        if(! ($url->scheme || $url->host || $url->query || $url->fragment))
+        {
+            $src = theme_path($src) . '?version=' . LACONICA_VERSION;
+        }
         $this->element('link', array('rel' => 'stylesheet',
                                 'type' => 'text/css',
-                                'href' => theme_path($relative, $theme) . '?version=' . LACONICA_VERSION,
+                                'href' => $src,
                                 'media' => $media));
     }