1
0
Sunny 2 rokov pred
rodič
commit
386a5c8e31
2 zmenil súbory, kde vykonal 15 pridanie a 17 odobranie
  1. 4 6
      pages/artist.php
  2. 11 11
      pages/search.php

+ 4 - 6
pages/artist.php

@@ -17,10 +17,7 @@
     $title = preg_split("/\n[\n\s]+/", trim($release->find(".title")->text()));
 
     $image = $release->find("img");
-    if ($image->hasAttr("data-original"))
-      $image = $image->attr("data-original");
-    else
-      $image = $image->attr("src");
+    $image = $image->hasAttr("data-original") ? $image->attr("data-original") : $image->attr("src");
     $image = "image.php?file=" . basename($image);
 
     $link = $release->find("a")->attr("href");
@@ -33,20 +30,21 @@
     echo "<img src=\"" . $image . "\">";
     echo "<p>";
     echo htmlspecialchars($title[0]);
+
     if (isset($title[1])) {
       echo "<br>";
       echo "<small>";
       echo "by " . htmlspecialchars($title[1]);
       echo "</small>";
     };
+
     echo "</p>";
     echo "</div>";
     echo "</a>";
   };
 
-  if (!$releases->length) {
+  if (!$releases->length)
     echo "<div>No results.</div>";
-  };
 
   echo "</div>";
 ?>

+ 11 - 11
pages/search.php

@@ -27,7 +27,7 @@
         $domain = explode(".", parse_url($result->item_url_root, PHP_URL_HOST));
         if (end($domain) === "com" && prev($domain) === "bandcamp")
           /* TODO: Some artists and labels use custom domains for their pages.
-                   Blindly sending requests to these could be a security risk.
+                   Blindly sending requests to them could be a security risk.
                    Is there a good way to support these? */
           $link = "artist.php?name=" . prev($domain);
         break;
@@ -39,30 +39,30 @@
     echo "<p>";
     echo htmlspecialchars($result->name);
 
+    unset($text);
+
     switch ($result->type) {
       case "a":
-        echo "<br>";
-        echo "<small>by " . htmlspecialchars($result->band_name) . "</small>";
+        $text = "by " . htmlspecialchars($result->band_name);
         break;
 
       case "t":
-        echo "<br>";
-        echo "<small>";
-        echo "by " . htmlspecialchars($result->band_name);
-        echo "<br>";
-        echo "on " . htmlspecialchars($result->album_name ?? $result->name);
-        echo "</small>";
+        $text = "by " . htmlspecialchars($result->band_name);
+        $text .= "<br>";
+        $text .= "on " . htmlspecialchars($result->album_name ?? $result->name);
         break;
     };
 
+    if ($text)
+      echo "<br><small>" . $text . "</small>";
+
     echo "</p>";
     echo "</div>";
     echo "</a>";
   };
 
-  if (empty($results)) {
+  if (empty($results))
     echo "<div>No results.</div>";
-  };
 
   echo "</div>";
 ?>