Merge branch 'tag-tables' of git://github.com/im-mi/shimmie2 into im-mi-tag-tables

This commit is contained in:
Shish 2016-10-10 14:19:57 +01:00
commit e43b1b3aed
8 changed files with 166 additions and 47 deletions

View file

@ -35,6 +35,29 @@ class TagListTheme extends Themelet {
// ======================================================================= // =======================================================================
protected function get_tag_list_preamble() {
global $config;
$tag_info_link_is_visible = !is_null($config->get_string('info_link'));
$tag_count_is_visible = $config->get_bool("tag_list_numbers");
return '
<table class="tag_list sortable">
<colgroup>' .
($tag_info_link_is_visible ? '<col class="tag_info_link_column">' : '') .
('<col class="tag_name_column">') .
($tag_count_is_visible ? '<col class="tag_count_column">' : '') . '
</colgroup>
<thead>
<tr>' .
($tag_info_link_is_visible ? '<th class="tag_info_link_cell"></th>' : '') .
('<th class="tag_name_cell">Tag</th>') .
($tag_count_is_visible ? '<th class="tag_count_cell">#</th>' : '') . '
</tr>
</thead>
<tbody>';
}
/* /*
* $tag_infos = array( * $tag_infos = array(
* array('tag' => $tag, 'count' => $number_of_uses), * array('tag' => $tag, 'count' => $number_of_uses),
@ -61,9 +84,9 @@ class TagListTheme extends Themelet {
$category = $split[0]; $category = $split[0];
$tag_html = $split[1]; $tag_html = $split[1];
if(!isset($tag_categories_html[$category])) { if(!isset($tag_categories_html[$category])) {
$tag_categories_html[$category] = ''; $tag_categories_html[$category] = $this->get_tag_list_preamble();
} }
$tag_categories_html[$category] .= $tag_html . '<br />'; $tag_categories_html[$category] .= "<tr>$tag_html</tr>";
if(!isset($tag_categories_count[$category])) { if(!isset($tag_categories_count[$category])) {
$tag_categories_count[$category] = 0; $tag_categories_count[$category] = 0;
@ -71,6 +94,10 @@ class TagListTheme extends Themelet {
$tag_categories_count[$category] += 1; $tag_categories_count[$category] += 1;
} }
foreach(array_keys($tag_categories_html) as $category) {
$tag_categories_html[$category] .= '</tbody></table>';
}
asort($tag_categories_html); asort($tag_categories_html);
if(isset($tag_categories_html[' '])) $main_html = $tag_categories_html[' ']; else $main_html = null; if(isset($tag_categories_html[' '])) $main_html = $tag_categories_html[' ']; else $main_html = null;
unset($tag_categories_html[' ']); unset($tag_categories_html[' ']);
@ -99,10 +126,8 @@ class TagListTheme extends Themelet {
* ... * ...
* ) * )
*/ */
public function display_related_block(Page $page, $tag_infos) { private function get_tag_list_html($tag_infos, $sort) {
global $config; if($sort == 'alphabetical') asort($tag_infos);
if($config->get_string('tag_list_related_sort') == 'alphabetical') asort($tag_infos);
if(class_exists('TagCategories')) { if(class_exists('TagCategories')) {
$this->tagcategories = new TagCategories; $this->tagcategories = new TagCategories;
@ -111,15 +136,32 @@ class TagListTheme extends Themelet {
else { else {
$tag_category_dict = array(); $tag_category_dict = array();
} }
$main_html = ''; $main_html = $this->get_tag_list_preamble();
foreach($tag_infos as $row) { foreach($tag_infos as $row) {
$split = $this->return_tag($row, $tag_category_dict); $split = $this->return_tag($row, $tag_category_dict);
//$category = $split[0]; //$category = $split[0];
$tag_html = $split[1]; $tag_html = $split[1];
$main_html .= $tag_html . '<br />'; $main_html .= "<tr>$tag_html</tr>";
} }
$main_html .= '</tbody></table>';
return $main_html;
}
/*
* $tag_infos = array(
* array('tag' => $tag, 'count' => $number_of_uses),
* ...
* )
*/
public function display_related_block(Page $page, $tag_infos) {
global $config;
$main_html = $this->get_tag_list_html(
$tag_infos, $config->get_string('tag_list_related_sort'));
if($config->get_string('tag_list_image_type')=="tags") { if($config->get_string('tag_list_image_type')=="tags") {
$page->add_block(new Block("Tags", $main_html, "left", 10)); $page->add_block(new Block("Tags", $main_html, "left", 10));
} }
@ -138,25 +180,10 @@ class TagListTheme extends Themelet {
public function display_popular_block(Page $page, $tag_infos) { public function display_popular_block(Page $page, $tag_infos) {
global $config; global $config;
if($config->get_string('tag_list_popular_sort') == 'alphabetical') asort($tag_infos); $main_html = $this->get_tag_list_html(
$tag_infos, $config->get_string('tag_list_popular_sort'));
if(class_exists('TagCategories')) {
$this->tagcategories = new TagCategories;
$tag_category_dict = $this->tagcategories->getKeyedDict();
}
else {
$tag_category_dict = array();
}
$main_html = '';
foreach($tag_infos as $row) {
$split = self::return_tag($row, $tag_category_dict);
//$category = $split[0];
$tag_html = $split[1];
$main_html .= $tag_html . '<br />';
}
$main_html .= "&nbsp;<br><a class='more' href='".make_link("tags")."'>Full List</a>\n"; $main_html .= "&nbsp;<br><a class='more' href='".make_link("tags")."'>Full List</a>\n";
$page->add_block(new Block("Popular Tags", $main_html, "left", 60)); $page->add_block(new Block("Popular Tags", $main_html, "left", 60));
} }
@ -170,25 +197,10 @@ class TagListTheme extends Themelet {
public function display_refine_block(Page $page, $tag_infos, $search) { public function display_refine_block(Page $page, $tag_infos, $search) {
global $config; global $config;
if($config->get_string('tag_list_popular_sort') == 'alphabetical') asort($tag_infos); $main_html = $this->get_tag_list_html(
$tag_infos, $config->get_string('tag_list_popular_sort'));
if(class_exists('TagCategories')) {
$this->tagcategories = new TagCategories;
$tag_category_dict = $this->tagcategories->getKeyedDict();
}
else {
$tag_category_dict = array();
}
$main_html = '';
foreach($tag_infos as $row) {
$split = self::return_tag($row, $tag_category_dict);
//$category = $split[0];
$tag_html = $split[1];
$main_html .= $tag_html . '<br />';
}
$main_html .= "&nbsp;<br><a class='more' href='".make_link("tags")."'>Full List</a>\n"; $main_html .= "&nbsp;<br><a class='more' href='".make_link("tags")."'>Full List</a>\n";
$page->add_block(new Block("refine Search", $main_html, "left", 60)); $page->add_block(new Block("refine Search", $main_html, "left", 60));
} }
@ -217,13 +229,13 @@ class TagListTheme extends Themelet {
// if($n++) $display_html .= "\n<br/>"; // if($n++) $display_html .= "\n<br/>";
if(!is_null($config->get_string('info_link'))) { if(!is_null($config->get_string('info_link'))) {
$link = html_escape(str_replace('$tag', url_escape($tag), $config->get_string('info_link'))); $link = html_escape(str_replace('$tag', url_escape($tag), $config->get_string('info_link')));
$display_html .= ' <a class="tag_info_link'.$tag_category_css.'" '.$tag_category_style.'href="'.$link.'">?</a>'; $display_html .= '<td class="tag_info_link_cell"> <a class="tag_info_link'.$tag_category_css.'" '.$tag_category_style.'href="'.$link.'">?</a></td>';
} }
$link = $this->tag_link($row['tag']); $link = $this->tag_link($row['tag']);
$display_html .= ' <a class="tag_name'.$tag_category_css.'" '.$tag_category_style.'href="'.$link.'">'.$h_tag_no_underscores.'</a>'; $display_html .= '<td class="tag_name_cell"> <a class="tag_name'.$tag_category_css.'" '.$tag_category_style.'href="'.$link.'">'.$h_tag_no_underscores.'</a></td>';
if($config->get_bool("tag_list_numbers")) { if($config->get_bool("tag_list_numbers")) {
$display_html .= " <span class='tag_count'>$count</span>"; $display_html .= "<td class='tag_count_cell'> <span class='tag_count'>$count</span></td>";
} }
return array($category, $display_html); return array($category, $display_html);

View file

@ -132,6 +132,20 @@ overflow:hidden;
text-align:left; text-align:left;
width:150px; width:150px;
} }
TABLE.tag_list {
border-collapse: collapse;
}
TABLE.tag_list>THEAD {
display: none;
}
TABLE.tag_list>TBODY>TR>TD {
display: inline;
padding: 0;
line-height: 1em;
}
TABLE.tag_list>TBODY>TR>TD:after {
content: " ";
}
.tag_count { .tag_count {
color:#AAAAAA; color:#AAAAAA;
} }

View file

@ -152,6 +152,21 @@ max-width:150px;
width:15rem; width:15rem;
text-align:left; text-align:left;
} }
TABLE.tag_list {
width: auto;
border-collapse: collapse;
}
TABLE.tag_list>THEAD {
display: none;
}
TABLE.tag_list>TBODY>TR>TD {
display: inline;
padding: 0;
line-height: 1em;
}
TABLE.tag_list>TBODY>TR>TD:after {
content: " ";
}
.tag_count { .tag_count {
display:inline-block; display:inline-block;
margin-left:0.4rem; margin-left:0.4rem;

View file

@ -96,6 +96,20 @@ NAV SELECT {
padding: 0px; padding: 0px;
} }
TABLE.tag_list {
border-collapse: collapse;
}
TABLE.tag_list>THEAD {
display: none;
}
TABLE.tag_list>TBODY>TR>TD {
display: inline;
padding: 0;
}
TABLE.tag_list>TBODY>TR>TD:after {
content: " ";
}
.more:after { .more:after {
content: " >>>"; content: " >>>";
} }

View file

@ -61,6 +61,25 @@ TD {
vertical-align: top; vertical-align: top;
} }
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* the navigation bar, and all its blocks *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
TABLE.tag_list {
border-collapse: collapse;
}
TABLE.tag_list>THEAD {
display: none;
}
TABLE.tag_list>TBODY>TR>TD {
display: inline;
padding: 0;
line-height: 1em;
}
TABLE.tag_list>TBODY>TR>TD:after {
content: " ";
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* specific page types * * specific page types *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

View file

@ -218,6 +218,21 @@ NAV SELECT {
text-align: left; text-align: left;
} }
TABLE.tag_list {
border-collapse: collapse;
}
TABLE.tag_list>THEAD {
display: none;
}
TABLE.tag_list>TBODY>TR>TD {
display: inline;
padding: 0;
line-height: 1em;
}
TABLE.tag_list>TBODY>TR>TD:after {
content: " ";
}
.more:after { .more:after {
content: " >>>"; content: " >>>";
} }

View file

@ -1,3 +1,17 @@
.nav-card{ .nav-card{
min-height: 3em; min-height: 3em;
} }
TABLE.tag_list {
border-collapse: collapse;
}
TABLE.tag_list>THEAD {
display: none;
}
TABLE.tag_list>TBODY>TR>TD {
display: inline;
padding: 0;
line-height: 1em;
}
TABLE.tag_list>TBODY>TR>TD:after {
content: " ";
}

View file

@ -117,6 +117,22 @@ NAV SELECT {
padding: 0px; padding: 0px;
} }
TABLE.tag_list {
width: 100%;
border-collapse: collapse;
}
TABLE.tag_list>THEAD {
display: none;
}
TABLE.tag_list>TBODY>TR>TD {
display: inline;
padding: 0;
line-height: 1em;
}
TABLE.tag_list>TBODY>TR>TD:after {
content: " ";
}
.more:after { .more:after {
content: " >>>"; content: " >>>";
} }