Browse Source

Tag namespace tweaks

spaghetti 8 years ago
parent
commit
1dcb5f0ddb
4 changed files with 35 additions and 20 deletions
  1. 0
    2
      classes/rules.class.php
  2. 27
    9
      classes/tags.class.php
  3. 4
    1
      sections/top10/tags.php
  4. 4
    8
      sections/torrents/details.php

+ 0
- 2
classes/rules.class.php View File

@@ -67,8 +67,6 @@ class Rules {
67 67
           <li><strong>:male</strong> - Used to denote that the tag refers to a male character: <strong class="tag_male">masturbation</strong>, <strong class="tag_male">teacher</strong></li>
68 68
           <li><strong>:female</strong> - Used to denote that the tag refers to a female character: <strong class="tag_female">masturbation</strong>, <strong class="tag_female">shaved</strong></li>
69 69
         </ul>
70
-
71
-        Note: gender namespaces should <strong class="important_text">NOT</strong> be used for tags where the gender is implied, such as "<strong class="important_text_alt">lolicon</strong>" or "<strong class="important_text_alt">shotacon</strong>".
72 70
       </li>
73 71
 
74 72
       <li><strong>All uploads require a minimum of 5 tags.</strong></li>

+ 27
- 9
classes/tags.class.php View File

@@ -136,13 +136,9 @@ class Tags {
136 136
       $ArtistName = "&amp;artistname=" . urlencode($ArtistName) . "&amp;action=advanced&amp;searchsubmit=1";
137 137
     }
138 138
     foreach ($this->Tags as $Tag) {
139
-			$Name = $Tag;
140
-			$Class = "";
141
-			$Split = explode(':', $Tag);
142
-			if (count($Split) > 1 && in_array($Split[1], TAG_NAMESPACES)) {
143
-				$Name = $Split[0];
144
-				$Class = "tag_" . $Split[1];
145
-			}
139
+      $Split = self::get_name_and_class($Tag);
140
+      $Name = $Split['name'];
141
+      $Class = $Split['class'];
146 142
       if (empty($this->TagLink[$Tag])) {
147 143
         $this->TagLink[$Tag] = '<a class="' . $Class . '" href="' . $Link . $Tag . $ArtistName . '">' . $Name . '</a>';
148 144
       }
@@ -165,8 +161,12 @@ class Tags {
165 161
     if (!empty($ArtistName)) {
166 162
       $ArtistName = '&amp;artistname=' . urlencode($ArtistName) . '&amp;action=advanced&amp;searchsubmit=1';
167 163
     }
168
-    foreach (array_slice(self::sorted(), 0, $Max) as $TagName => $Total) { ?>
169
-      <li><a href="<?=$Link . display_str($TagName) . $ArtistName?>"><?=display_str($TagName)?></a> (<?=$Total?>)</li>
164
+    foreach (array_slice(self::sorted(), 0, $Max) as $Tag => $Total) {
165
+      $Split = self::get_name_and_class($Tag);
166
+      $Name = $Split['name'];
167
+      $Class = $Split['class'];
168
+    ?>
169
+      <li><a class="<?=$Class?>" href="<?=$Link . display_str($Name) . $ArtistName?>"><?=display_str($Name)?></a> (<?=$Total?>)</li>
170 170
 <?    }
171 171
   }
172 172
 
@@ -278,4 +278,22 @@ class Tags {
278 278
 
279 279
     return ['input' => $TagList, 'predicate' => implode(' ', $QueryParts)];
280 280
   }
281
+
282
+  /**
283
+   * Breaks a tag down into name and namespace class
284
+   * @param string $Tag Tag of the form 'tag' or 'tag:namespace'
285
+   * @return array Array keys name and class
286
+   *               name is the name of the tag without a namespace
287
+   *               class is the HTML class that should be applied to the tag, empty string if the tag has no namespace
288
+   */
289
+   public static function get_name_and_class($Tag) {
290
+			$Name = $Tag;
291
+			$Class = "";
292
+			$Split = explode(':', $Tag);
293
+			if (count($Split) > 1 && in_array($Split[1], TAG_NAMESPACES)) {
294
+				$Name = $Split[0];
295
+				$Class = "tag_" . $Split[1];
296
+			}
297
+      return array("name" => display_str($Name), "class" => display_str($Class));
298
+   }
281 299
 }

+ 4
- 1
sections/top10/tags.php View File

@@ -144,12 +144,15 @@ function generate_tag_table($Caption, $Tag, $Details, $Limit, $ShowVotes = true,
144 144
   $Rank = 0;
145 145
   foreach ($Details as $Detail) {
146 146
     $Rank++;
147
+    $Split = Tags::get_name_and_class($Detail['Name']);
148
+    $DisplayName = $Split['name'];
149
+    $Class = $Split['class'];
147 150
 
148 151
     // print row
149 152
 ?>
150 153
   <tr class="row">
151 154
     <td class="center"><?=$Rank?></td>
152
-    <td><a href="<?=$URLString?><?=$Detail['Name']?>"><?=$Detail['Name']?></a></td>
155
+    <td><a class="<?=$Class?>" href="<?=$URLString?><?=$Detail['Name']?>"><?=$DisplayName?></a></td>
153 156
     <td class="number_column"><?=number_format($Detail['Uses'])?></td>
154 157
 <?    if ($ShowVotes) { ?>
155 158
     <td class="number_column"><?=number_format($Detail['PosVotes'])?></td>

+ 4
- 8
sections/torrents/details.php View File

@@ -92,14 +92,10 @@ if ($TorrentTags != '') {
92 92
     $Tags[$TagKey]['score'] = ($TagPositiveVotes[$TagKey] - $TagNegativeVotes[$TagKey]);
93 93
     $Tags[$TagKey]['id'] = $TorrentTagIDs[$TagKey];
94 94
     $Tags[$TagKey]['userid'] = $TorrentTagUserIDs[$TagKey];
95
-		$Tags[$TagKey]['display'] = $TagName;
96
-		$Tags[$TagKey]['class'] = "";
97
-
98
-		$Split = explode(':', $TagName);
99
-		if (count($Split) > 1 && in_array($Split[1], TAG_NAMESPACES)) {
100
-			$Tags[$TagKey]['display'] = $Split[0];
101
-			$Tags[$TagKey]['class'] = "tag_" . $Split[1];
102
-		}
95
+
96
+    $Split = Tags::get_name_and_class($TagName);
97
+    $Tags[$TagKey]['display'] = $Split['name'];
98
+    $Tags[$TagKey]['class'] = $Split['class'];
103 99
 
104 100
   }
105 101
   uasort($Tags, 'compare');

Loading…
Cancel
Save