Merge pull request #703 from DanielOaks/more_tag_category_integration
More tag category integration
This commit is contained in:
commit
1d6ad6cb09
@ -127,6 +127,27 @@ class TagCategories extends Extension
|
|||||||
return $tc_keyed_dict;
|
return $tc_keyed_dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTagHtml(string $h_tag, $tag_category_dict, string $extra_text = '')
|
||||||
|
{
|
||||||
|
$h_tag_no_underscores = str_replace("_", " ", $h_tag);
|
||||||
|
|
||||||
|
// we found a tag, see if it's valid!
|
||||||
|
$h_tag_split = explode(':', $h_tag, 2);
|
||||||
|
if ((count($h_tag_split) > 1) and array_key_exists($h_tag_split[0], $tag_category_dict)) {
|
||||||
|
$category = $h_tag_split[0];
|
||||||
|
$h_tag = $h_tag_split[1];
|
||||||
|
$tag_category_css = ' tag_category_'.$category;
|
||||||
|
$tag_category_style = 'style="color:'.html_escape($tag_category_dict[$category]['color']).';" ';
|
||||||
|
$h_tag_no_underscores = str_replace("_", " ", $h_tag);
|
||||||
|
|
||||||
|
$h_tag_no_underscores = '<span class="'.$tag_category_css.'" '.$tag_category_style.'>'.$h_tag_no_underscores.$extra_text.'</span>';
|
||||||
|
} else {
|
||||||
|
$h_tag_no_underscores .= $extra_text;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $h_tag_no_underscores;
|
||||||
|
}
|
||||||
|
|
||||||
public function page_update()
|
public function page_update()
|
||||||
{
|
{
|
||||||
global $user, $database;
|
global $user, $database;
|
||||||
|
@ -288,6 +288,10 @@ class TagList extends Extension
|
|||||||
if ($config->get_bool(TagListConfig::PAGES)) {
|
if ($config->get_bool(TagListConfig::PAGES)) {
|
||||||
$html .= $this->build_az();
|
$html .= $this->build_az();
|
||||||
}
|
}
|
||||||
|
if (class_exists('TagCategories')) {
|
||||||
|
$this->tagcategories = new TagCategories;
|
||||||
|
$tag_category_dict = $this->tagcategories->getKeyedDict();
|
||||||
|
}
|
||||||
foreach ($tag_data as $row) {
|
foreach ($tag_data as $row) {
|
||||||
$h_tag = html_escape($row['tag']);
|
$h_tag = html_escape($row['tag']);
|
||||||
$size = sprintf("%.2f", (float)$row['scaled']);
|
$size = sprintf("%.2f", (float)$row['scaled']);
|
||||||
@ -296,6 +300,9 @@ class TagList extends Extension
|
|||||||
$size = 0.5;
|
$size = 0.5;
|
||||||
}
|
}
|
||||||
$h_tag_no_underscores = str_replace("_", " ", $h_tag);
|
$h_tag_no_underscores = str_replace("_", " ", $h_tag);
|
||||||
|
if (class_exists('TagCategories')) {
|
||||||
|
$h_tag_no_underscores = $this->tagcategories->getTagHtml($h_tag, $tag_category_dict);
|
||||||
|
}
|
||||||
$html .= " <a style='font-size: ${size}em' href='$link'>$h_tag_no_underscores</a> \n";
|
$html .= " <a style='font-size: ${size}em' href='$link'>$h_tag_no_underscores</a> \n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,6 +354,11 @@ class TagList extends Extension
|
|||||||
*/
|
*/
|
||||||
mb_internal_encoding('UTF-8');
|
mb_internal_encoding('UTF-8');
|
||||||
|
|
||||||
|
if (class_exists('TagCategories')) {
|
||||||
|
$this->tagcategories = new TagCategories;
|
||||||
|
$tag_category_dict = $this->tagcategories->getKeyedDict();
|
||||||
|
}
|
||||||
|
|
||||||
$lastLetter = "";
|
$lastLetter = "";
|
||||||
# postres utf8 string sort ignores punctuation, so we get "aza, a-zb, azc"
|
# postres utf8 string sort ignores punctuation, so we get "aza, a-zb, azc"
|
||||||
# which breaks down into "az, a-, az" :(
|
# which breaks down into "az, a-, az" :(
|
||||||
@ -361,7 +373,10 @@ class TagList extends Extension
|
|||||||
}
|
}
|
||||||
$link = $this->theme->tag_link($tag);
|
$link = $this->theme->tag_link($tag);
|
||||||
$h_tag = html_escape($tag);
|
$h_tag = html_escape($tag);
|
||||||
$html .= "<a href='$link'>$h_tag ($count)</a>\n";
|
if (class_exists('TagCategories')) {
|
||||||
|
$h_tag = $this->tagcategories->getTagHtml($h_tag, $tag_category_dict, " ($count)");
|
||||||
|
}
|
||||||
|
$html .= "<a href='$link'>$h_tag</a>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SPEED_HAX) {
|
if (SPEED_HAX) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user