Merge pull request #705 from DanielOaks/extend-wiki-tagcategories
Extend Wiki integration a bit
This commit is contained in:
		
						commit
						9a21716f5e
					
				| @ -37,6 +37,8 @@ and of course start organising your images :-) | |||||||
|      */ |      */ | ||||||
|     public function display_page(Page $page, array $images) |     public function display_page(Page $page, array $images) | ||||||
|     { |     { | ||||||
|  |         $this->display_shortwiki($page); | ||||||
|  | 
 | ||||||
|         $this->display_page_header($page, $images); |         $this->display_page_header($page, $images); | ||||||
| 
 | 
 | ||||||
|         $nav = $this->build_navigation($this->page_number, $this->total_pages, $this->search_terms); |         $nav = $this->build_navigation($this->page_number, $this->total_pages, $this->search_terms); | ||||||
| @ -102,6 +104,36 @@ and of course start organising your images :-) | |||||||
|         return $table; |         return $table; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     protected function display_shortwiki(Page $page) | ||||||
|  |     { | ||||||
|  |         global $config; | ||||||
|  | 
 | ||||||
|  |         if (class_exists('Wiki') && $config->get_bool(WikiConfig::TAG_SHORTWIKIS)) { | ||||||
|  |             if (count($this->search_terms) == 1) { | ||||||
|  |                 $st = Tag::implode($this->search_terms); | ||||||
|  | 
 | ||||||
|  |                 $wikiPage = Wiki::get_page($st); | ||||||
|  |                 $short_wiki_description = ''; | ||||||
|  |                 if ($wikiPage->id != -1) { | ||||||
|  |                     // only show first line of wiki
 | ||||||
|  |                     $short_wiki_description = explode("\n", $wikiPage->body, 2)[0]; | ||||||
|  | 
 | ||||||
|  |                     $tfe = new TextFormattingEvent($short_wiki_description); | ||||||
|  |                     send_event($tfe); | ||||||
|  |                     $short_wiki_description = $tfe->formatted; | ||||||
|  |                 } | ||||||
|  |                 $wikiLink = make_link("wiki/$st"); | ||||||
|  |                 if (class_exists('TagCategories')) { | ||||||
|  |                     $this->tagcategories = new TagCategories; | ||||||
|  |                     $tag_category_dict = $this->tagcategories->getKeyedDict(); | ||||||
|  |                     $st = $this->tagcategories->getTagHtml(html_escape($st), $tag_category_dict); | ||||||
|  |                 } | ||||||
|  |                 $short_wiki_description = '<h2>'.$st.' <a href="'.$wikiLink.'"><sup>ⓘ</sup></a></h2>'.$short_wiki_description; | ||||||
|  |                 $page->add_block(new Block(null, $short_wiki_description, "main", 0, "short-wiki-description")); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     /** |     /** | ||||||
|      * #param Image[] $images
 |      * #param Image[] $images
 | ||||||
|      */ |      */ | ||||||
|  | |||||||
| @ -96,11 +96,31 @@ class WikiPage | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | abstract class WikiConfig | ||||||
|  | { | ||||||
|  |     const TAG_SHORTWIKIS = "shortwikis_on_tags"; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| class Wiki extends Extension | class Wiki extends Extension | ||||||
| { | { | ||||||
|     /** @var WikiTheme */ |     /** @var WikiTheme */ | ||||||
|     protected $theme; |     protected $theme; | ||||||
| 
 | 
 | ||||||
|  |     public function onInitExt(InitExtEvent $event) | ||||||
|  |     { | ||||||
|  |         global $config; | ||||||
|  |         $config->set_default_bool(WikiConfig::TAG_SHORTWIKIS, false); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // Add a block to the Board Config / Setup
 | ||||||
|  |     public function onSetupBuilding(SetupBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         $sb = new SetupBlock("Wiki"); | ||||||
|  |         $sb->add_bool_option(WikiConfig::TAG_SHORTWIKIS, "Show shortwiki entry when searching for a single tag: "); | ||||||
|  | 
 | ||||||
|  |         $event->panel->add_block($sb); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) |     public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) | ||||||
|     { |     { | ||||||
|         global $database; |         global $database; | ||||||
|  | |||||||
| @ -25,11 +25,19 @@ class WikiTheme extends Themelet | |||||||
|             $tfe->formatted .= "<p>(<a href='".make_link("wiki/wiki:sidebar", "edit=on")."'>Edit</a>)"; |             $tfe->formatted .= "<p>(<a href='".make_link("wiki/wiki:sidebar", "edit=on")."'>Edit</a>)"; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         // see if title is a category'd tag
 | ||||||
|  |         $title_html = html_escape($wiki_page->title); | ||||||
|  |         if (class_exists('TagCategories')) { | ||||||
|  |             $this->tagcategories = new TagCategories; | ||||||
|  |             $tag_category_dict = $this->tagcategories->getKeyedDict(); | ||||||
|  |             $title_html = $this->tagcategories->getTagHtml($title_html, $tag_category_dict); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         $page->set_title(html_escape($wiki_page->title)); |         $page->set_title(html_escape($wiki_page->title)); | ||||||
|         $page->set_heading(html_escape($wiki_page->title)); |         $page->set_heading(html_escape($wiki_page->title)); | ||||||
|         $page->add_block(new NavBlock()); |         $page->add_block(new NavBlock()); | ||||||
|         $page->add_block(new Block("Wiki Index", $tfe->formatted, "left", 20)); |         $page->add_block(new Block("Wiki Index", $tfe->formatted, "left", 20)); | ||||||
|         $page->add_block(new Block(html_escape($wiki_page->title), $this->create_display_html($wiki_page))); |         $page->add_block(new Block($title_html, $this->create_display_html($wiki_page))); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public function display_page_editor(Page $page, WikiPage $wiki_page) |     public function display_page_editor(Page $page, WikiPage $wiki_page) | ||||||
|  | |||||||
| @ -7,6 +7,8 @@ class CustomIndexTheme extends IndexTheme | |||||||
|      */ |      */ | ||||||
|     public function display_page(Page $page, array $images) |     public function display_page(Page $page, array $images) | ||||||
|     { |     { | ||||||
|  |         $this->display_shortwiki($page); | ||||||
|  | 
 | ||||||
|         global $config; |         global $config; | ||||||
| 
 | 
 | ||||||
|         if (count($this->search_terms) == 0) { |         if (count($this->search_terms) == 0) { | ||||||
|  | |||||||
| @ -87,6 +87,12 @@ margin:auto; | |||||||
| text-align:center; | text-align:center; | ||||||
| width:256px; | width:256px; | ||||||
| } | } | ||||||
|  | #short-wiki-description { | ||||||
|  | padding:0 1.5em; | ||||||
|  | } | ||||||
|  | #short-wiki-description h2 { | ||||||
|  | padding-bottom:0.2em; | ||||||
|  | } | ||||||
| FOOTER { | FOOTER { | ||||||
| clear:both; | clear:both; | ||||||
| color:#CCCCCC; | color:#CCCCCC; | ||||||
|  | |||||||
| @ -7,6 +7,8 @@ class CustomIndexTheme extends IndexTheme | |||||||
|      */ |      */ | ||||||
|     public function display_page(Page $page, array $images) |     public function display_page(Page $page, array $images) | ||||||
|     { |     { | ||||||
|  |         $this->display_shortwiki($page); | ||||||
|  | 
 | ||||||
|         $this->display_page_header($page, $images); |         $this->display_page_header($page, $images); | ||||||
| 
 | 
 | ||||||
|         $nav = $this->build_navigation($this->page_number, $this->total_pages, $this->search_terms); |         $nav = $this->build_navigation($this->page_number, $this->total_pages, $this->search_terms); | ||||||
|  | |||||||
| @ -99,6 +99,13 @@ border-top:medium none; | |||||||
| text-align:center; | text-align:center; | ||||||
| font-size:0.75em; | font-size:0.75em; | ||||||
| } | } | ||||||
|  | #short-wiki-description { | ||||||
|  | padding:0 2em; | ||||||
|  | font-size:1.2em; | ||||||
|  | } | ||||||
|  | #short-wiki-description h2 { | ||||||
|  | padding-bottom:0.2em; | ||||||
|  | } | ||||||
| FOOTER { | FOOTER { | ||||||
| clear:both; | clear:both; | ||||||
| border-top:solid 1px #E7E7F7; | border-top:solid 1px #E7E7F7; | ||||||
|  | |||||||
| @ -148,6 +148,13 @@ ARTICLE TABLE { | |||||||
| *                     specific page types                        * | *                     specific page types                        * | ||||||
| * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||||||
| 
 | 
 | ||||||
|  | #short-wiki-description > .blockbody { | ||||||
|  | 	padding-bottom: 15px; | ||||||
|  | } | ||||||
|  | #short-wiki-description h2 { | ||||||
|  | 	margin: 0 0 0.4em; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| #pagelist { | #pagelist { | ||||||
| 	margin-top: 32px; | 	margin-top: 32px; | ||||||
| } | } | ||||||
|  | |||||||
| @ -84,6 +84,14 @@ TABLE.tag_list>TBODY>TR>TD:after { | |||||||
| *                     specific page types                        * | *                     specific page types                        * | ||||||
| * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||||||
| 
 | 
 | ||||||
|  | #short-wiki-description > .blockbody { | ||||||
|  | 	padding-bottom: 15px; | ||||||
|  | 	font-size: 1.1em; | ||||||
|  | } | ||||||
|  | #short-wiki-description h2 { | ||||||
|  | 	margin: 0 0 0.4em; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| .doubledash { | .doubledash { | ||||||
| 	color: #D9BFB7; | 	color: #D9BFB7; | ||||||
| 	vertical-align: top; | 	vertical-align: top; | ||||||
|  | |||||||
| @ -170,6 +170,13 @@ ARTICLE TABLE { | |||||||
| *                     specific page types                        * | *                     specific page types                        * | ||||||
| * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||||||
| 
 | 
 | ||||||
|  | #short-wiki-description > .blockbody { | ||||||
|  | 	padding-bottom: 15px; | ||||||
|  | } | ||||||
|  | #short-wiki-description h2 { | ||||||
|  | 	margin: 0 0 0.4em; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| #pagelist { | #pagelist { | ||||||
| 	margin-top: 32px; | 	margin-top: 32px; | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user