]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/htmloutputter.php
Fix logic that determines if a URL is relative or absolute in script() and cssLink()
[quix0rs-gnu-social.git] / lib / htmloutputter.php
index 0b4c1405a8a3e9048b6b1289262afc536333bf00..6045971161d5e933437d5c1be6d02e61e870f802 100644 (file)
@@ -349,29 +349,39 @@ class HTMLOutputter extends XMLOutputter
      */
     function script($src, $type='text/javascript')
     {
+        $url = parse_url($src);
+        if( empty($url->scheme) && empty($url->host) && empty($url->query) && empty($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=null,$media=null)
     {
-        if (!$theme) {
-            $theme = common_config('site', 'theme');
+        $url = parse_url($src);
+        if( empty($url->scheme) && empty($url->host) && empty($url->query) && empty($url->fragment))
+        {
+            if(file_exists(theme_file($src,$theme))){
+               $src = theme_path($src, $theme) . '?version=' . LACONICA_VERSION;
+            }else{
+               $src = common_path($src);
+            }
         }
-
         $this->element('link', array('rel' => 'stylesheet',
                                 'type' => 'text/css',
-                                'href' => theme_path($relative, $theme) . '?version=' . LACONICA_VERSION,
+                                'href' => $src,
                                 'media' => $media));
     }