Implemented a nav link generating system so that extension power what shows up in the menus rather than being hard-coded in the themes.
This commit is contained in:
		
							parent
							
								
									972b68bdd3
								
							
						
					
					
						commit
						00464d2579
					
				
							
								
								
									
										144
									
								
								core/page.php
									
									
									
									
									
								
							
							
						
						
									
										144
									
								
								core/page.php
									
									
									
									
									
								
							| @ -299,9 +299,55 @@ class Page | |||||||
|                     $this->add_cookie("flash_message", "", -1, "/"); |                     $this->add_cookie("flash_message", "", -1, "/"); | ||||||
|                 } |                 } | ||||||
|                 usort($this->blocks, "blockcmp"); |                 usort($this->blocks, "blockcmp"); | ||||||
|  |                 $pnbe = new PageNavBuildingEvent(); | ||||||
|  |                 send_event($pnbe); | ||||||
|  | 
 | ||||||
|  |                 $nav_links = $pnbe->links; | ||||||
|  | 
 | ||||||
|  |                 $active_link = null; | ||||||
|  |                 // To save on event calls, we check if one of the top-level links has already been marked as active
 | ||||||
|  |                 foreach ($nav_links as $link) { | ||||||
|  |                     if($link->active===true) { | ||||||
|  |                         $active_link = $link; | ||||||
|  |                         break; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |                 $sub_links = null; | ||||||
|  |                 // If one is, we just query for sub-menu options under that one tab
 | ||||||
|  |                 if($active_link!==null) { | ||||||
|  |                     $psnbe = new PageSubNavBuildingEvent($active_link->name); | ||||||
|  |                     send_event($psnbe); | ||||||
|  |                     $sub_links = $psnbe->links; | ||||||
|  |                 } else { | ||||||
|  |                     // Otherwise we query for the sub-items under each of the tabs
 | ||||||
|  |                     foreach ($nav_links as $link) { | ||||||
|  |                         $psnbe = new PageSubNavBuildingEvent($link->name); | ||||||
|  |                         send_event($psnbe); | ||||||
|  | 
 | ||||||
|  |                         // Now we check for a current link so we can identify the sub-links to show
 | ||||||
|  |                         foreach ($psnbe->links as $sub_link) { | ||||||
|  |                             if($sub_link->active===true) { | ||||||
|  |                                 $sub_links = $psnbe->links; | ||||||
|  |                                 break; | ||||||
|  |                             } | ||||||
|  |                         } | ||||||
|  |                         // If the active link has been detected, we break out
 | ||||||
|  |                         if($sub_links!==null) { | ||||||
|  |                             $link->active = true; | ||||||
|  |                             break; | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |                 $sub_links = $sub_links??[]; | ||||||
|  |                 usort($nav_links, "sort_nav_links"); | ||||||
|  |                 usort($sub_links, "sort_nav_links"); | ||||||
|  | 
 | ||||||
|                 $this->add_auto_html_headers(); |                 $this->add_auto_html_headers(); | ||||||
|                 $layout = new Layout(); |                 $layout = new Layout(); | ||||||
|                 $layout->display_page($page); |                 $layout->display_page($page, $nav_links, $sub_links); | ||||||
|                 break; |                 break; | ||||||
|             case PageMode::DATA: |             case PageMode::DATA: | ||||||
|                 header("Content-Length: " . strlen($this->data)); |                 header("Content-Length: " . strlen($this->data)); | ||||||
| @ -471,3 +517,99 @@ class Page | |||||||
|         $this->add_html_header("<script src='$data_href/$js_cache_file' type='text/javascript'></script>", 44); |         $this->add_html_header("<script src='$data_href/$js_cache_file' type='text/javascript'></script>", 44); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | class PageNavBuildingEvent extends Event | ||||||
|  | { | ||||||
|  |     public $links = []; | ||||||
|  | 
 | ||||||
|  |     public function add_nav_link(string $name, Link $link, string $desc, ?bool $active = null, int $order = 50) | ||||||
|  |     { | ||||||
|  |         $this->links[]  = new NavLink($name, $link, $desc, $active, $order); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | class PageSubNavBuildingEvent extends Event | ||||||
|  | { | ||||||
|  |     public $parent; | ||||||
|  | 
 | ||||||
|  |     public $links = []; | ||||||
|  | 
 | ||||||
|  |     public function __construct(string $parent) | ||||||
|  |     { | ||||||
|  |         $this->parent= $parent; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public function add_nav_link(string $name, Link $link, string $desc, ?bool $active = null, int $order = 50) | ||||||
|  |     { | ||||||
|  |         $this->links[]  = new NavLink($name, $link, $desc, $active,$order); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | class NavLink | ||||||
|  | { | ||||||
|  |     public $name; | ||||||
|  |     public $link; | ||||||
|  |     public $description; | ||||||
|  |     public $order; | ||||||
|  |     public $active = false; | ||||||
|  | 
 | ||||||
|  |     public function  __construct(String $name, Link $link, String $description, ?bool $active = null, int $order = 50) | ||||||
|  |     { | ||||||
|  |         global $config; | ||||||
|  | 
 | ||||||
|  |         $this->name = $name; | ||||||
|  |         $this->link = $link; | ||||||
|  |         $this->description = $description; | ||||||
|  |         $this->order = $order; | ||||||
|  |         if($active==null) { | ||||||
|  |             $query = ltrim(_get_query(), "/"); | ||||||
|  |             if ($query === "") { | ||||||
|  |                 // This indicates the front page, so we check what's set as the front page
 | ||||||
|  |                 $front_page = trim($config->get_string(SetupConfig::FRONT_PAGE), "/"); | ||||||
|  | 
 | ||||||
|  |                 if ($front_page === $link->page) { | ||||||
|  |                     $this->active = true; | ||||||
|  |                 } else { | ||||||
|  |                     $this->active = self::is_active([$link->page], $front_page); | ||||||
|  |                 } | ||||||
|  |             } elseif($query===$link->page) { | ||||||
|  |                 $this->active = true; | ||||||
|  |             }else { | ||||||
|  |                 $this->active = self::is_active([$link->page]); | ||||||
|  |             } | ||||||
|  |         } else { | ||||||
|  |             $this->active = $active; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public static function is_active(array $pages_matched, string $url = null): bool | ||||||
|  |     { | ||||||
|  |         /** | ||||||
|  |          * Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.) | ||||||
|  |          */ | ||||||
|  |         $url = $url??ltrim(_get_query(), "/"); | ||||||
|  | 
 | ||||||
|  |         $re1='.*?'; | ||||||
|  |         $re2='((?:[a-z][a-z_]+))'; | ||||||
|  | 
 | ||||||
|  |         if (preg_match_all("/".$re1.$re2."/is", $url, $matches)) { | ||||||
|  |             $url=$matches[1][0]; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         $count_pages_matched = count($pages_matched); | ||||||
|  | 
 | ||||||
|  |         for ($i=0; $i < $count_pages_matched; $i++) { | ||||||
|  |             if ($url == $pages_matched[$i]) { | ||||||
|  |                 return true; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function sort_nav_links(NavLink $a, NavLink $b) | ||||||
|  | { | ||||||
|  |     return $a->order - $b->order; | ||||||
|  | } | ||||||
|  | |||||||
| @ -40,7 +40,7 @@ _d("SEARCH_ACCEL", false);   // boolean  use search accelerator | |||||||
| _d("WH_SPLITS", 1);          // int      how many levels of subfolders to put in the warehouse
 | _d("WH_SPLITS", 1);          // int      how many levels of subfolders to put in the warehouse
 | ||||||
| _d("VERSION", '2.7-beta');   // string   shimmie version
 | _d("VERSION", '2.7-beta');   // string   shimmie version
 | ||||||
| _d("TIMEZONE", null);        // string   timezone
 | _d("TIMEZONE", null);        // string   timezone
 | ||||||
| _d("CORE_EXTS", "bbcode,user,mail,upload,image,view,handle_pixel,ext_manager,setup,upgrade,handle_404,handle_static,comment,tag_list,index,tag_edit,alias_editor,media"); // extensions to always enable
 | _d("CORE_EXTS", "bbcode,user,mail,upload,image,view,handle_pixel,ext_manager,setup,upgrade,handle_404,handle_static,comment,tag_list,index,tag_edit,alias_editor,media,system"); // extensions to always enable
 | ||||||
| _d("EXTRA_EXTS", "");        // string   optional extra extensions
 | _d("EXTRA_EXTS", "");        // string   optional extra extensions
 | ||||||
| _d("BASE_URL", null);        // string   force a specific base URL (default is auto-detect)
 | _d("BASE_URL", null);        // string   force a specific base URL (default is auto-detect)
 | ||||||
| _d("MIN_PHP_VERSION", '7.1');// string   minimum supported PHP version
 | _d("MIN_PHP_VERSION", '7.1');// string   minimum supported PHP version
 | ||||||
|  | |||||||
| @ -3,6 +3,23 @@ | |||||||
| * HTML Generation                                                           * | * HTML Generation                                                           * | ||||||
| \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||||||
| 
 | 
 | ||||||
|  | class Link | ||||||
|  | { | ||||||
|  |     public $page; | ||||||
|  |     public $query; | ||||||
|  | 
 | ||||||
|  |     public function __construct(?string $page=null, ?string $query=null) | ||||||
|  |     { | ||||||
|  |         $this->page = $page; | ||||||
|  |         $this->query = $query; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public function make_link(): string | ||||||
|  |     { | ||||||
|  |         return make_link($this->page, $this->query); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /** | /** | ||||||
|  * Figure out the correct way to link to a page, taking into account |  * Figure out the correct way to link to a page, taking into account | ||||||
|  * things like the nice URLs setting. |  * things like the nice URLs setting. | ||||||
|  | |||||||
| @ -108,6 +108,16 @@ class AdminPage extends Extension | |||||||
|         $this->theme->display_form(); |         $this->theme->display_form(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         global $user; | ||||||
|  |         if($event->parent==="system") { | ||||||
|  |             if ($user->can(Permissions::MANAGE_ADMINTOOLS)) { | ||||||
|  |                 $event->add_nav_link("admin", new Link('admin'), "Board Admin"); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public function onUserBlockBuilding(UserBlockBuildingEvent $event) |     public function onUserBlockBuilding(UserBlockBuildingEvent $event) | ||||||
|     { |     { | ||||||
|         global $user; |         global $user; | ||||||
|  | |||||||
| @ -117,6 +117,13 @@ class AliasEditor extends Extension | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         if($event->parent=="tags") { | ||||||
|  |             $event->add_nav_link("aliases", new Link('alias/list'), "Aliases", NavLink::is_active(["alias"])); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public function onUserBlockBuilding(UserBlockBuildingEvent $event) |     public function onUserBlockBuilding(UserBlockBuildingEvent $event) | ||||||
|     { |     { | ||||||
|         global $user; |         global $user; | ||||||
|  | |||||||
| @ -26,6 +26,16 @@ class Blocks extends Extension | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         global $user; | ||||||
|  |         if($event->parent==="system") { | ||||||
|  |             if ($user->can(Permissions::MANAGE_BLOCKS)) { | ||||||
|  |                 $event->add_nav_link("blocks", new Link('blocks/list'), "Blocks Editor"); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public function onUserBlockBuilding(UserBlockBuildingEvent $event) |     public function onUserBlockBuilding(UserBlockBuildingEvent $event) | ||||||
|     { |     { | ||||||
|         global $user; |         global $user; | ||||||
|  | |||||||
| @ -56,6 +56,17 @@ class Blotter extends Extension | |||||||
|         $event->panel->add_block($sb); |         $event->panel->add_block($sb); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         global $user; | ||||||
|  |         if($event->parent==="system") { | ||||||
|  |             if ($user->is_admin()) { | ||||||
|  |                 $event->add_nav_link("blotter", new Link('blotter/editor'), "Blotter Editor"); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|     public function onUserBlockBuilding(UserBlockBuildingEvent $event) |     public function onUserBlockBuilding(UserBlockBuildingEvent $event) | ||||||
|     { |     { | ||||||
|         global $user; |         global $user; | ||||||
|  | |||||||
| @ -157,6 +157,21 @@ class CommentList extends Extension | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  |     public function onPageNavBuilding(PageNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         $event->add_nav_link("comment", new Link('comment/list'), "Comments"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         if($event->parent=="comment") { | ||||||
|  |             $event->add_nav_link("comment_list", new Link('comment/list'), "All"); | ||||||
|  |             $event->add_nav_link("comment_help", new Link('ext_doc/comment'), "Help"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public function onPageRequest(PageRequestEvent $event) |     public function onPageRequest(PageRequestEvent $event) | ||||||
|     { |     { | ||||||
|         if ($event->page_matches("comment")) { |         if ($event->page_matches("comment")) { | ||||||
|  | |||||||
| @ -24,6 +24,18 @@ class ET extends Extension | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         global $user; | ||||||
|  |         if($event->parent==="system") { | ||||||
|  |             if ($user->can(Permissions::VIEW_SYSINTO)) { | ||||||
|  |                 $event->add_nav_link("system_info", new Link('system_info'), "System Info", null, 10); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|     public function onUserBlockBuilding(UserBlockBuildingEvent $event) |     public function onUserBlockBuilding(UserBlockBuildingEvent $event) | ||||||
|     { |     { | ||||||
|         global $user; |         global $user; | ||||||
|  | |||||||
| @ -162,6 +162,17 @@ class ExtManager extends Extension | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         global $user; | ||||||
|  |         if($event->parent==="system") { | ||||||
|  |             if ($user->can(Permissions::MANAGE_EXTENSION_LIST)) { | ||||||
|  |                 $event->add_nav_link("ext_manager", new Link('ext_manager'), "Extension Manager"); | ||||||
|  |             } else { | ||||||
|  |                 $event->add_nav_link("ext_doc", new Link('ext_doc'), "Board Help"); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     public function onUserBlockBuilding(UserBlockBuildingEvent $event) |     public function onUserBlockBuilding(UserBlockBuildingEvent $event) | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -155,6 +155,20 @@ class Favorites extends Extension | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         global $user; | ||||||
|  |         if($event->parent=="posts") { | ||||||
|  |             $event->add_nav_link("posts_favorites", new Link("post/list/favorited_by={$user->name}/1"), "My Favorites"); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if($event->parent==="user") { | ||||||
|  |             if ($user->can(Permissions::MANAGE_ADMINTOOLS)) { | ||||||
|  |                 $username = url_escape($user->name); | ||||||
|  |                 $event->add_nav_link("favorites", new Link("post/list/favorited_by=$username/1"), "My Favorites"); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     private function install() |     private function install() | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -103,6 +103,17 @@ class ImageBan extends Extension | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         global $user; | ||||||
|  |         if($event->parent==="system") { | ||||||
|  |             if ($user->can(Permissions::BAN_IMAGE)) { | ||||||
|  |                 $event->add_nav_link("image_bans", new Link('image_hash_ban/list/1'), "Image Bans", NavLink::is_active(["image_hash_ban"])); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|     public function onUserBlockBuilding(UserBlockBuildingEvent $event) |     public function onUserBlockBuilding(UserBlockBuildingEvent $event) | ||||||
|     { |     { | ||||||
|         global $user; |         global $user; | ||||||
|  | |||||||
| @ -332,6 +332,18 @@ class Index extends Extension | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function onPageNavBuilding(PageNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         $event->add_nav_link("posts", new Link('post/list'), "Posts", NavLink::is_active(["post","view"]),20); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         if($event->parent=="posts") { | ||||||
|  |             $event->add_nav_link("posts_all", new Link('post/list'), "All"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public function onSearchTermParse(SearchTermParseEvent $event) |     public function onSearchTermParse(SearchTermParseEvent $event) | ||||||
|     { |     { | ||||||
|         $matches = []; |         $matches = []; | ||||||
|  | |||||||
| @ -105,6 +105,16 @@ class IPBan extends Extension | |||||||
|         $event->panel->add_block($sb); |         $event->panel->add_block($sb); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         global $user; | ||||||
|  |         if($event->parent==="system") { | ||||||
|  |             if ($user->can(Permissions::BAN_IP)) { | ||||||
|  |                 $event->add_nav_link("ip_bans", new Link('ip_ban/list'), "IP Bans", NavLink::is_active(["ip_ban"])); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public function onUserBlockBuilding(UserBlockBuildingEvent $event) |     public function onUserBlockBuilding(UserBlockBuildingEvent $event) | ||||||
|     { |     { | ||||||
|         global $user; |         global $user; | ||||||
|  | |||||||
| @ -120,6 +120,16 @@ class LogDatabase extends Extension | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         global $user; | ||||||
|  |         if($event->parent==="system") { | ||||||
|  |             if ($user->can(Permissions::VIEW_EVENTLOG)) { | ||||||
|  |                 $event->add_nav_link("event_log", new Link('log/view'), "Event Log"); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public function onUserBlockBuilding(UserBlockBuildingEvent $event) |     public function onUserBlockBuilding(UserBlockBuildingEvent $event) | ||||||
|     { |     { | ||||||
|         global $user; |         global $user; | ||||||
|  | |||||||
| @ -58,6 +58,16 @@ class NotATag extends Extension | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         global $user; | ||||||
|  |         if($event->parent==="tags") { | ||||||
|  |             if ($user->can(Permissions::BAN_IMAGE)) { | ||||||
|  |                 $event->add_nav_link("untags", new Link('untag/list/1'), "UnTags"); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public function onUserBlockBuilding(UserBlockBuildingEvent $event) |     public function onUserBlockBuilding(UserBlockBuildingEvent $event) | ||||||
|     { |     { | ||||||
|         global $user; |         global $user; | ||||||
|  | |||||||
| @ -294,6 +294,16 @@ class NumericScore extends Extension | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         if($event->parent=="posts") { | ||||||
|  |             $event->add_nav_link("numeric_score_day", new Link('popular_by_day'), "Popular by Day"); | ||||||
|  |             $event->add_nav_link("numeric_score_month", new Link('popular_by_month'), "Popular by Month"); | ||||||
|  |             $event->add_nav_link("numeric_score_year", new Link('popular_by_year'), "Popular by Year"); | ||||||
|  | 
 | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     private function install() |     private function install() | ||||||
|     { |     { | ||||||
|         global $database; |         global $database; | ||||||
|  | |||||||
| @ -93,6 +93,19 @@ class PrivMsg extends Extension | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         global $user; | ||||||
|  |         if($event->parent==="user") { | ||||||
|  |             if (!$user->is_anonymous()) { | ||||||
|  |                 $count = $this->count_pms($user); | ||||||
|  |                 $h_count = $count > 0 ? " <span class='unread'>($count)</span>" : ""; | ||||||
|  |                 $event->add_nav_link("pm", new Link('user#private-messages'), "Private Messages$h_count"); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|     public function onUserBlockBuilding(UserBlockBuildingEvent $event) |     public function onUserBlockBuilding(UserBlockBuildingEvent $event) | ||||||
|     { |     { | ||||||
|         global $user; |         global $user; | ||||||
|  | |||||||
| @ -145,6 +145,23 @@ class Pools extends Extension | |||||||
|         $event->panel->add_block($sb); |         $event->panel->add_block($sb); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function onPageNavBuilding(PageNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         $event->add_nav_link("pool", new Link('pool/list'), "Pools"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         if($event->parent=="pool") { | ||||||
|  |             $event->add_nav_link("pool_list", new Link('pool/list'), "List"); | ||||||
|  |             $event->add_nav_link("pool_new", new Link('pool/new'), "Create"); | ||||||
|  |             $event->add_nav_link("pool_updated", new Link('pool/updated'), "Changes"); | ||||||
|  |             $event->add_nav_link("pool_help", new Link('ext_doc/pools'), "Help"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|     public function onPageRequest(PageRequestEvent $event) |     public function onPageRequest(PageRequestEvent $event) | ||||||
|     { |     { | ||||||
|         global $page, $user, $database; |         global $page, $user, $database; | ||||||
|  | |||||||
| @ -75,4 +75,11 @@ class RandomImage extends Extension | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         if($event->parent=="posts") { | ||||||
|  |             $event->add_nav_link("posts_random", new Link('random_image/view'), "Random Image"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -74,4 +74,11 @@ class RandomList extends Extension | |||||||
| 
 | 
 | ||||||
|         $event->panel->add_block($sb); |         $event->panel->add_block($sb); | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         if($event->parent=="posts") { | ||||||
|  |             $event->add_nav_link("posts_random", new Link('random'), "Shuffle"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -132,6 +132,20 @@ class ReportImage extends Extension | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         global $user; | ||||||
|  |         if($event->parent==="system") { | ||||||
|  |             if ($user->can(Permissions::VIEW_IMAGE_REPORT)) { | ||||||
|  |                 $count = $this->count_reported_images(); | ||||||
|  |                 $h_count = $count > 0 ? " ($count)" : ""; | ||||||
|  | 
 | ||||||
|  |                 $event->add_nav_link("image_report", new Link('image_report/list'), "Reported Images$h_count"); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public function onUserBlockBuilding(UserBlockBuildingEvent $event) |     public function onUserBlockBuilding(UserBlockBuildingEvent $event) | ||||||
|     { |     { | ||||||
|         global $user; |         global $user; | ||||||
|  | |||||||
| @ -79,4 +79,12 @@ EOD; | |||||||
|             $page->set_data($xml); |             $page->set_data($xml); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         if($event->parent=="comment") { | ||||||
|  |             $event->add_nav_link("comment_rss", new Link('rss/comments'), "Feed"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -116,4 +116,11 @@ class RSS_Images extends Extension | |||||||
| 
 | 
 | ||||||
|         return $data; |         return $data; | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         if($event->parent=="posts") { | ||||||
|  |             $event->add_nav_link("posts_rss", new Link('rss/images'), "Feed"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -411,6 +411,16 @@ class Setup extends Extension | |||||||
|         log_warning("setup", "Cache cleared"); |         log_warning("setup", "Cache cleared"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         global $user; | ||||||
|  |         if($event->parent==="system") { | ||||||
|  |             if ($user->can(Permissions::CHANGE_SETTING)) { | ||||||
|  |                 $event->add_nav_link("setup", new Link('setup'), "Board Config", null, 0); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public function onUserBlockBuilding(UserBlockBuildingEvent $event) |     public function onUserBlockBuilding(UserBlockBuildingEvent $event) | ||||||
|     { |     { | ||||||
|         global $user; |         global $user; | ||||||
|  | |||||||
| @ -82,6 +82,16 @@ class Source_History extends Extension | |||||||
|         $this->add_source_history($event->image, $event->source); |         $this->add_source_history($event->image, $event->source); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         global $user; | ||||||
|  |         if($event->parent==="system") { | ||||||
|  |             if ($user->can(Permissions::BULK_EDIT_IMAGE_TAG)) { | ||||||
|  |                 $event->add_nav_link("source_history", new Link('source_history/all/1'), "Source Changes", NavLink::is_active(["source_history"])); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public function onUserBlockBuilding(UserBlockBuildingEvent $event) |     public function onUserBlockBuilding(UserBlockBuildingEvent $event) | ||||||
|     { |     { | ||||||
|         global $user; |         global $user; | ||||||
|  | |||||||
							
								
								
									
										31
									
								
								ext/system/main.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								ext/system/main.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * Name: System | ||||||
|  |  * Author: Matthew Barbour <matthew@darkholme.net> | ||||||
|  |  * License: MIT | ||||||
|  |  * Description: Provides system screen | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | class System extends Extension | ||||||
|  | { | ||||||
|  |     public function onPageRequest(PageRequestEvent $event) | ||||||
|  |     { | ||||||
|  |         global $page, $user; | ||||||
|  | 
 | ||||||
|  |         if ($event->page_matches("system")) { | ||||||
|  |             $e = new PageSubNavBuildingEvent("system"); | ||||||
|  |             send_event($e); | ||||||
|  |             usort($e->links, "sort_nav_links"); | ||||||
|  |             $link = $e->links[0]->link; | ||||||
|  | 
 | ||||||
|  |             $page->set_redirect($link->make_link()); | ||||||
|  |             $page->set_mode(PageMode::REDIRECT); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     public function onPageNavBuilding(PageNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         $event->add_nav_link("system", new Link('system'), "System"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -255,6 +255,15 @@ class TagEdit extends Extension | |||||||
|         $this->theme->display_mass_editor(); |         $this->theme->display_mass_editor(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         if($event->parent=="tags") { | ||||||
|  |             $event->add_nav_link("tags_help", new Link('ext_doc/tag_edit'), "Help"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|     /** |     /** | ||||||
|      * When an alias is added, oldtag becomes inaccessible. |      * When an alias is added, oldtag becomes inaccessible. | ||||||
|      */ |      */ | ||||||
|  | |||||||
| @ -82,6 +82,17 @@ class Tag_History extends Extension | |||||||
|         $this->add_tag_history($event->image, $event->tags); |         $this->add_tag_history($event->image, $event->tags); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         global $user; | ||||||
|  |         if($event->parent==="system") { | ||||||
|  |             if ($user->can(Permissions::BULK_EDIT_IMAGE_TAG)) { | ||||||
|  |                 $event->add_nav_link("tag_history", new Link('tag_history/all/1'), "Tag Changes", NavLink::is_active(["tag_history"])); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|     public function onUserBlockBuilding(UserBlockBuildingEvent $event) |     public function onUserBlockBuilding(UserBlockBuildingEvent $event) | ||||||
|     { |     { | ||||||
|         global $user; |         global $user; | ||||||
|  | |||||||
| @ -93,6 +93,21 @@ class TagList extends Extension | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function onPageNavBuilding(PageNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         $event->add_nav_link("tags", new Link('tags/map'), "Tags"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         if($event->parent=="tags") { | ||||||
|  |             $event->add_nav_link("tags_map", new Link('tags/map'), "Map"); | ||||||
|  |             $event->add_nav_link("tags_alphabetic", new Link('tags/alphabetic'), "Alphabetic"); | ||||||
|  |             $event->add_nav_link("tags_popularity", new Link('tags/popularity'), "Popularity"); | ||||||
|  |             $event->add_nav_link("tags_categories", new Link('tags/categories'), "Categories"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public function onDisplayingImage(DisplayingImageEvent $event) |     public function onDisplayingImage(DisplayingImageEvent $event) | ||||||
|     { |     { | ||||||
|         global $config, $page; |         global $config, $page; | ||||||
|  | |||||||
| @ -73,6 +73,16 @@ class Tips extends Extension | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         global $user; | ||||||
|  |         if($event->parent==="system") { | ||||||
|  |             if ($user->is_admin()) { | ||||||
|  |                 $event->add_nav_link("tips", new Link('tips/list'), "Tips Editor"); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public function onUserBlockBuilding(UserBlockBuildingEvent $event) |     public function onUserBlockBuilding(UserBlockBuildingEvent $event) | ||||||
|     { |     { | ||||||
|         global $user; |         global $user; | ||||||
|  | |||||||
| @ -138,6 +138,21 @@ class Upload extends Extension | |||||||
|         $event->panel->add_block($sb); |         $event->panel->add_block($sb); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  |     public function onPageNavBuilding(PageNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         $event->add_nav_link("upload",new Link('upload'), "Upload"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         if($event->parent=="upload") { | ||||||
|  |             if (class_exists("Wiki")) { | ||||||
|  |                 $event->add_nav_link("upload_guidelines", new Link('wiki/upload_guidelines'), "Guidelines"); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public function onDataUpload(DataUploadEvent $event) |     public function onDataUpload(DataUploadEvent $event) | ||||||
|     { |     { | ||||||
|         global $config; |         global $config; | ||||||
|  | |||||||
| @ -237,6 +237,17 @@ class UserPage extends Extension | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function onPageNavBuilding(PageNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         global $user; | ||||||
|  |         if ($user->is_anonymous()) { | ||||||
|  |             $event->add_nav_link("user", new Link('user_admin/login'), "Account", null, 10); | ||||||
|  |         } else { | ||||||
|  |             $event->add_nav_link("user", new Link('user'), "Account", null, 10); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|     private function display_stats(UserPageBuildingEvent $event) |     private function display_stats(UserPageBuildingEvent $event) | ||||||
|     { |     { | ||||||
|         global $user, $page, $config; |         global $user, $page, $config; | ||||||
| @ -305,6 +316,16 @@ class UserPage extends Extension | |||||||
|         $event->panel->add_block($sb); |         $event->panel->add_block($sb); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         global $user; | ||||||
|  |         if($event->parent==="system") { | ||||||
|  |             if ($user->can(Permissions::EDIT_USER_CLASS)) { | ||||||
|  |                 $event->add_nav_link("user_admin", new Link('user_admin/list'), "User List", NavLink::is_active(["user_admin"])); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public function onUserBlockBuilding(UserBlockBuildingEvent $event) |     public function onUserBlockBuilding(UserBlockBuildingEvent $event) | ||||||
|     { |     { | ||||||
|         global $user; |         global $user; | ||||||
|  | |||||||
| @ -176,6 +176,21 @@ class Wiki extends Extension | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  |     public function onPageNavBuilding(PageNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         $event->add_nav_link("wiki",new Link('wiki'), "Wiki"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     public function onPageSubNavBuilding(PageSubNavBuildingEvent $event) | ||||||
|  |     { | ||||||
|  |         if($event->parent=="wiki") { | ||||||
|  |             $event->add_nav_link("wiki_rules", new Link('wiki/rules'), "Rules"); | ||||||
|  |             $event->add_nav_link("wiki_help", new Link('ext_doc/wiki'), "Help"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public function onWikiUpdate(WikiUpdateEvent $event) |     public function onWikiUpdate(WikiUpdateEvent $event) | ||||||
|     { |     { | ||||||
|         global $database; |         global $database; | ||||||
|  | |||||||
| @ -44,7 +44,7 @@ Tips | |||||||
| 
 | 
 | ||||||
| class Layout | class Layout | ||||||
| { | { | ||||||
|     public function display_page(Page $page) |     public function display_page(Page $page, array $nav_links, array $sub_links) | ||||||
|     { |     { | ||||||
|         global $config, $user; |         global $config, $user; | ||||||
| 
 | 
 | ||||||
| @ -96,84 +96,17 @@ class Layout | |||||||
|         $main_page = $config->get_string(SetupConfig::MAIN_PAGE); // bzchan: change from normal default to get main page for top of page
 |         $main_page = $config->get_string(SetupConfig::MAIN_PAGE); // bzchan: change from normal default to get main page for top of page
 | ||||||
| 
 | 
 | ||||||
|         $custom_links = ""; |         $custom_links = ""; | ||||||
|         if ($user->is_anonymous()) { |         foreach ($nav_links as $nav_link) { | ||||||
|             $custom_links .= $this->navlinks(make_link('user_admin/login'), "My Account", ["user", "user_admin", "setup", "admin"]); |             $custom_links .=  "<li>".$this->navlinks($nav_link->link, $nav_link->description, $nav_link->active)."</li>"; | ||||||
|         } else { |  | ||||||
|             $custom_links .= $this->navlinks(make_link('user'), "My Account", ["user", "user_admin", "setup", "admin"]); |  | ||||||
|         } |  | ||||||
|         $custom_links .= $this->navlinks(make_link('post/list'), "Posts", ["post"]); |  | ||||||
|         $custom_links .= $this->navlinks(make_link('comment/list'), "Comments", ["comment"]); |  | ||||||
|         $custom_links .= $this->navlinks(make_link('tags'), "Tags", ["tags"]); |  | ||||||
|         if (class_exists("Pools")) { |  | ||||||
|             $custom_links .= $this->navlinks(make_link('pool/list'), "Pools", ["pool"]); |  | ||||||
|         } |  | ||||||
|         $custom_links .= $this->navlinks(make_link('upload'), "Upload", ["upload"]); |  | ||||||
|         if (class_exists("Wiki")) { |  | ||||||
|             $custom_links .= $this->navlinks(make_link('wiki'), "Wiki", ["wiki"]); |  | ||||||
|             $custom_links .= $this->navlinks(make_link('wiki/more'), "More »", ["wiki/more"]); |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         $custom_sublinks = ""; |         $custom_sublinks = ""; | ||||||
|         // hack
 |         if(!empty($sub_links)) { | ||||||
|         $username = url_escape($user->name); |             $custom_sublinks = "<div class='sbar'>"; | ||||||
|         // hack
 |             foreach ($sub_links as $nav_link) { | ||||||
|         $qp = explode("/", ltrim(_get_query(), "/")); |                 $custom_sublinks .= "<li>".$this->navlinks($nav_link->link, $nav_link->description, $nav_link->active)."</li>"; | ||||||
|         // php sucks
 |             } | ||||||
|         switch ($qp[0]) { |             $custom_sublinks .= "</div>"; | ||||||
|             default: |  | ||||||
|                 $custom_sublinks .= $user_block_html; |  | ||||||
|                 break; |  | ||||||
|             case "": |  | ||||||
|                 # FIXME: this assumes that the front page is
 |  | ||||||
|                 # post/list; in 99% of case it will either be
 |  | ||||||
|                 # post/list or home, and in the latter case
 |  | ||||||
|                 # the subnav links aren't shown, but it would
 |  | ||||||
|                 # be nice to be correct
 |  | ||||||
|             case "post": |  | ||||||
|             case "upload": |  | ||||||
|                 if (class_exists("NumericScore")) { |  | ||||||
|                     $custom_sublinks .= "<li><b>Popular by </b><a href='".make_link('popular_by_day')."'>Day</a>/<a href='".make_link('popular_by_month')."'>Month</a>/<a href='".make_link('popular_by_year')."'>Year</a></li>"; |  | ||||||
|                 } |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link('post/list')."'>All</a></li>"; |  | ||||||
|                 if (class_exists("Favorites")) { |  | ||||||
|                     $custom_sublinks .= "<li><a href='".make_link("post/list/favorited_by={$username}/1")."'>My Favorites</a></li>"; |  | ||||||
|                 } |  | ||||||
|                 if (class_exists("RSS_Images")) { |  | ||||||
|                     $custom_sublinks .= "<li><a href='".make_link('rss/images')."'>Feed</a></li>"; |  | ||||||
|                 } |  | ||||||
|                 if (class_exists("RandomImage")) { |  | ||||||
|                     $custom_sublinks .= "<li><a href='".make_link("random_image/view")."'>Random Image</a></li>"; |  | ||||||
|                 } |  | ||||||
|                 if (class_exists("Wiki")) { |  | ||||||
|                     $custom_sublinks .= "<li><a href='".make_link("wiki/posts")."'>Help</a></li>"; |  | ||||||
|                 } else { |  | ||||||
|                     $custom_sublinks .= "<li><a href='".make_link("ext_doc/index")."'>Help</a></li>"; |  | ||||||
|                 } |  | ||||||
|                 break; |  | ||||||
|             case "comment": |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link('comment/list')."'>All</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link("ext_doc/comment")."'>Help</a></li>"; |  | ||||||
|                 break; |  | ||||||
|             case "pool": |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link('pool/list')."'>List</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link("pool/new")."'>Create</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link("pool/updated")."'>Changes</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link("ext_doc/pools")."'>Help</a></li>"; |  | ||||||
|                 break; |  | ||||||
|             case "wiki": |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link('wiki')."'>Index</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link("wiki/rules")."'>Rules</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link("ext_doc/wiki")."'>Help</a></li>"; |  | ||||||
|                 break; |  | ||||||
|             case "tags": |  | ||||||
|             case "alias": |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link('tags/map')."'>Map</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link('tags/alphabetic')."'>Alphabetic</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link('tags/popularity')."'>Popularity</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link('tags/categories')."'>Categories</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link('alias/list')."'>Aliases</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link("ext_doc/tag_edit")."'>Help</a></li>"; |  | ||||||
|                 break; |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -245,31 +178,16 @@ EOD; | |||||||
|     /** |     /** | ||||||
|      * #param string[] $pages_matched
 |      * #param string[] $pages_matched
 | ||||||
|      */ |      */ | ||||||
|     private function navlinks(string $link, string $desc, array $pages_matched): string | 
 | ||||||
|  |     public function navlinks(Link $link, string $desc, bool $active): ?string | ||||||
|     { |     { | ||||||
|         /** |  | ||||||
|          * Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.) |  | ||||||
|          */ |  | ||||||
|         $html = null; |         $html = null; | ||||||
|         $url = ltrim(_get_query(), "/"); |         if ($active) { | ||||||
| 
 |             $html = "<a class='current-page' href='{$link->make_link()}'>{$desc}</a>"; | ||||||
|         $re1='.*?'; |         } else { | ||||||
|         $re2='((?:[a-z][a-z_]+))'; |             $html = "<a class='tab' href='{$link->make_link()}'>{$desc}</a>"; | ||||||
| 
 |  | ||||||
|         if (preg_match_all("/".$re1.$re2."/is", $url, $matches)) { |  | ||||||
|             $url=$matches[1][0]; |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         $count_pages_matched = count($pages_matched); |  | ||||||
|          |  | ||||||
|         for ($i=0; $i < $count_pages_matched; $i++) { |  | ||||||
|             if ($url == $pages_matched[$i]) { |  | ||||||
|                 $html = "<li class='current-page'><a href='$link'>$desc</a></li>"; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         if (is_null($html)) { |  | ||||||
|             $html = "<li><a class='tab' href='$link'>$desc</a></li>"; |  | ||||||
|         } |  | ||||||
|         return $html; |         return $html; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -44,7 +44,7 @@ Tips | |||||||
| 
 | 
 | ||||||
| class Layout | class Layout | ||||||
| { | { | ||||||
|     public function display_page($page) |     public function display_page($page, array $nav_links, array $sub_links) | ||||||
|     { |     { | ||||||
|         global $config, $user; |         global $config, $user; | ||||||
| 
 | 
 | ||||||
| @ -96,110 +96,17 @@ class Layout | |||||||
|         $main_page = $config->get_string(SetupConfig::MAIN_PAGE); // bzchan: change from normal default to get main page for top of page
 |         $main_page = $config->get_string(SetupConfig::MAIN_PAGE); // bzchan: change from normal default to get main page for top of page
 | ||||||
| 
 | 
 | ||||||
|         $custom_links = ""; |         $custom_links = ""; | ||||||
|         if ($user->is_anonymous()) { |         foreach ($nav_links as $nav_link) { | ||||||
|             $custom_links .= $this->navlinks(make_link('user_admin/login'), "Sign in", ["user", "user_admin", "setup", "admin"]); |             $custom_links .=  "<li>".$this->navlinks($nav_link->link, $nav_link->description, $nav_link->active)."</li>"; | ||||||
|         } else { |  | ||||||
|             $custom_links .= $this->navlinks(make_link('user'), "My Account", ["user", "user_admin"]); |  | ||||||
|         } |  | ||||||
|         if ($user->is_admin()) { |  | ||||||
|             $custom_links .= $this->navlinks(make_link('admin'), "Admin", ["admin", "ext_manager", "setup"]); |  | ||||||
|         } |  | ||||||
|         $custom_links .= $this->navlinks(make_link('post/list'), "Posts", ["post", "upload", "", "random_image"]); |  | ||||||
|         $custom_links .= $this->navlinks(make_link('comment/list'), "Comments", ["comment"]); |  | ||||||
|         $custom_links .= $this->navlinks(make_link('tags'), "Tags", ["tags", "alias"]); |  | ||||||
|         if (class_exists("Pools")) { |  | ||||||
|             $custom_links .= $this->navlinks(make_link('pool/list'), "Pools", ["pool"]); |  | ||||||
|         } |  | ||||||
|         if (class_exists("Wiki")) { |  | ||||||
|             $custom_links .= $this->navlinks(make_link('wiki'), "Wiki", ["wiki"]); |  | ||||||
|             $custom_links .= $this->navlinks(make_link('wiki/more'), "More »", ["wiki/more"]); |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         $custom_sublinks = ""; |         $custom_sublinks = ""; | ||||||
|         // hack
 |         if(!empty($sub_links)) { | ||||||
|         $username = url_escape($user->name); |             $custom_sublinks = "<div class='sbar'>"; | ||||||
|         // hack
 |             foreach ($sub_links as $nav_link) { | ||||||
|         $qp = explode("/", ltrim(_get_query(), "/")); |                 $custom_sublinks .= "<li>".$this->navlinks($nav_link->link, $nav_link->description, $nav_link->active)."</li>"; | ||||||
|         // php sucks
 |             } | ||||||
|         switch ($qp[0]) { |             $custom_sublinks .= "</div>"; | ||||||
|             default: |  | ||||||
|             case "ext_doc": |  | ||||||
|                 $custom_sublinks .= $user_block_html; |  | ||||||
|                 break; |  | ||||||
|             case "user": |  | ||||||
|             case "user_admin": |  | ||||||
|                 if ($user->is_anonymous()) { |  | ||||||
|                     $custom_sublinks .= "<li><a href='".make_link('user_admin/create')."'>Sign up</a></li>"; |  | ||||||
|                 // $custom_sublinks .= "<li><a href='".make_link('')."'>Reset Password</a></li>";
 |  | ||||||
|                     // $custom_sublinks .= "<li><a href='".make_link('')."'>Login Reminder</a></li>";
 |  | ||||||
|                 } else { |  | ||||||
|                     $custom_sublinks .= "<li><a href='".make_link('user_admin/logout')."'>Sign out</a></li>"; |  | ||||||
|                 } |  | ||||||
|                 break; |  | ||||||
|             case "": |  | ||||||
|                 # FIXME: this assumes that the front page is
 |  | ||||||
|                 # post/list; in 99% of case it will either be
 |  | ||||||
|                 # post/list or home, and in the latter case
 |  | ||||||
|                 # the subnav links aren't shown, but it would
 |  | ||||||
|                 # be nice to be correct
 |  | ||||||
|             case "random_image": |  | ||||||
|             case "post": |  | ||||||
|             case "upload": |  | ||||||
|                 if (class_exists("NumericScore")) { |  | ||||||
|                     $custom_sublinks .= "<li><b>Popular by </b><a href='".make_link('popular_by_day')."'>Day</a>/<a href='".make_link('popular_by_month')."'>Month</a>/<a href='".make_link('popular_by_year')."'>Year</a></li>"; |  | ||||||
|                 } |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link('post/list')."'>Listing</a></li>"; |  | ||||||
|                 if (class_exists("Favorites")) { |  | ||||||
|                     $custom_sublinks .= "<li><a href='".make_link("post/list/favorited_by={$username}/1")."'>My Favorites</a></li>"; |  | ||||||
|                 } |  | ||||||
|                 if (class_exists("RSS_Images")) { |  | ||||||
|                     $custom_sublinks .= "<li><a href='".make_link('rss/images')."'>Feed</a></li>"; |  | ||||||
|                 } |  | ||||||
|                 if (class_exists("RandomImage")) { |  | ||||||
|                     $custom_sublinks .= "<li><a href='".make_link("random_image/view")."'>Random</a></li>"; |  | ||||||
|                 } |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link('upload')."'>Upload</a></li>"; |  | ||||||
|                 if (class_exists("Wiki")) { |  | ||||||
|                     $custom_sublinks .= "<li><a href='".make_link("wiki/posts")."'>Help</a></li>"; |  | ||||||
|                 } else { |  | ||||||
|                     $custom_sublinks .= "<li><a href='".make_link("ext_doc/index")."'>Help</a></li>"; |  | ||||||
|                 } |  | ||||||
|                 break; |  | ||||||
|             case "comment": |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link('comment/list')."'>All</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link("ext_doc/comment")."'>Help</a></li>"; |  | ||||||
|                 break; |  | ||||||
|             case "pool": |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link('pool/list')."'>List</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link("pool/new")."'>Create</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link("pool/updated")."'>Changes</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link("ext_doc/pools")."'>Help</a></li>"; |  | ||||||
|                 break; |  | ||||||
|             case "wiki": |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link('wiki')."'>Index</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link("wiki/rules")."'>Rules</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link("ext_doc/wiki")."'>Help</a></li>"; |  | ||||||
|                 break; |  | ||||||
|             case "tags": |  | ||||||
|             case "alias": |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link('tags/map')."'>Map</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link('tags/alphabetic')."'>Alphabetic</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link('tags/popularity')."'>Popularity</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link('tags/categories')."'>Categories</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link('alias/list')."'>Aliases</a></li>"; |  | ||||||
|                 $custom_sublinks .= "<li><a href='".make_link("ext_doc/tag_edit")."'>Help</a></li>"; |  | ||||||
|                 break; |  | ||||||
|             case "admin": |  | ||||||
|             case "ext_manager": |  | ||||||
|             case "setup": |  | ||||||
|                 if ($user->is_admin()) { |  | ||||||
|                     $custom_sublinks .= "<li><a href='".make_link('ext_manager')."'>Extension Manager</a></li>"; |  | ||||||
|                     $custom_sublinks .= "<li><a href='".make_link('setup')."'>Board Config</a></li>"; |  | ||||||
|                     $custom_sublinks .= "<li><a href='".make_link('alias/list')."'>Alias Editor</a></li>"; |  | ||||||
|                 } else { |  | ||||||
|                     $custom_sublinks .= "<li>I think you might be lost</li>"; |  | ||||||
|                 } |  | ||||||
|                 break; |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -268,28 +175,15 @@ $header_html | |||||||
| EOD; | EOD; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private function navlinks(string $link, string $desc, array $pages_matched): string |     public function navlinks(Link $link, string $desc, bool $active): ?string | ||||||
|     { |     { | ||||||
|         $html = ""; |         $html = null; | ||||||
|         $url = _get_query(); |         if ($active) { | ||||||
| 
 |             $html = "<a class='current-page' href='{$link->make_link()}'>{$desc}</a>"; | ||||||
|         $re1='.*?'; |         } else { | ||||||
|         $re2='((?:[a-z][a-z_]+))'; |             $html = "<a class='tab' href='{$link->make_link()}'>{$desc}</a>"; | ||||||
| 
 |  | ||||||
|         if (preg_match_all("/".$re1.$re2."/is", $url, $matches)) { |  | ||||||
|             $url=$matches[1][0]; |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         $count_pages_matched = count($pages_matched); |  | ||||||
|          |  | ||||||
|         for ($i=0; $i < $count_pages_matched; $i++) { |  | ||||||
|             if ($url == $pages_matched[$i]) { |  | ||||||
|                 $html = "<li class='current-page'><a href='$link'>$desc</a></li>"; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         if (empty($html)) { |  | ||||||
|             $html = "<li><a class='tab' href='$link'>$desc</a></li>"; |  | ||||||
|         } |  | ||||||
|         return $html; |         return $html; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -7,7 +7,7 @@ class Layout | |||||||
|     /** |     /** | ||||||
|      * turns the Page into HTML |      * turns the Page into HTML | ||||||
|      */ |      */ | ||||||
|     public function display_page(Page $page) |     public function display_page(Page $page, array $nav_links) | ||||||
|     { |     { | ||||||
|         global $config; |         global $config; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -9,7 +9,7 @@ | |||||||
| */ | */ | ||||||
| class Layout | class Layout | ||||||
| { | { | ||||||
|     public function display_page(Page $page) |     public function display_page(Page $page, array $nav_links, array $sub_links) | ||||||
|     { |     { | ||||||
|         global $config, $user; |         global $config, $user; | ||||||
| 
 | 
 | ||||||
| @ -26,21 +26,8 @@ class Layout | |||||||
| 
 | 
 | ||||||
|         // Custom links: These appear on the menu.
 |         // Custom links: These appear on the menu.
 | ||||||
|         $custom_links = ""; |         $custom_links = ""; | ||||||
|         if ($user->is_anonymous()) { |         foreach ($nav_links as $nav_link) { | ||||||
|             $custom_links .= $this->navlinks(make_link('user_admin/login'), "Account", ["user", "user_admin", "setup", "admin", "profile"]); |             $custom_links .= $this->navlinks($nav_link->link, $nav_link->description, $nav_link->active); | ||||||
|         } else { |  | ||||||
|             $custom_links .= $this->navlinks(make_link('user'), "Account", ["user", "setup", "user_admin", "admin", "profile"]); |  | ||||||
|         } |  | ||||||
|         $custom_links .= $this->navlinks(make_link('post/list'), "Posts", ["post", "view"]); |  | ||||||
|         $custom_links .= $this->navlinks(make_link('comment/list'), "Comments", ["comment"]); |  | ||||||
|         $custom_links .= $this->navlinks(make_link('tags'), "Tags", ["tags"]); |  | ||||||
|         if (class_exists("Pools")) { |  | ||||||
|             $custom_links .= $this->navlinks(make_link('pool/list'), "Pools", ["pool"]); |  | ||||||
|         } |  | ||||||
|         $custom_links .= $this->navlinks(make_link('upload'), "Upload", ["upload"]); |  | ||||||
|         if (class_exists("Wiki")) { |  | ||||||
|             $custom_links .= $this->navlinks(make_link('wiki/rules'), "Rules", ["wiki/rules"]); |  | ||||||
|             $custom_links .= $this->navlinks(make_link('wiki'), "Wiki", ["wiki"]); |  | ||||||
|         } |         } | ||||||
|         $menu .= "{$custom_links}</div>"; |         $menu .= "{$custom_links}</div>"; | ||||||
|          |          | ||||||
| @ -69,87 +56,13 @@ class Layout | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         $custom_sublinks = "<div class='sbar'>"; |         $custom_sublinks = ""; | ||||||
|         // hack
 |         if(!empty($sub_links)) { | ||||||
|         $username = url_escape($user->name); |             $custom_sublinks = "<div class='sbar'>"; | ||||||
|         // hack
 |             foreach ($sub_links as $nav_link) { | ||||||
|         $qp = explode("/", ltrim(_get_query(), "/")); |                 $custom_sublinks .= $this->navlinks($nav_link->link, $nav_link->description, $nav_link->active); | ||||||
|         $cs = ""; |             } | ||||||
| 
 |             $custom_sublinks .= "</div>"; | ||||||
|         // php sucks
 |  | ||||||
|         switch ($qp[0]) { |  | ||||||
|             default: |  | ||||||
|                 $cs = $user_block_html; |  | ||||||
|                 break; |  | ||||||
|             case "": |  | ||||||
|                 # FIXME: this assumes that the front page is
 |  | ||||||
|                 # post/list; in 99% of case it will either be
 |  | ||||||
|                 # post/list or home, and in the latter case
 |  | ||||||
|                 # the subnav links aren't shown, but it would
 |  | ||||||
|                 # be nice to be correct
 |  | ||||||
|             case "post": |  | ||||||
|                 if (class_exists("NumericScore")) { |  | ||||||
|                     $cs .= "<b>Popular by </b><a href='".make_link('popular_by_day')."'>Day</a><b>/</b><a href='".make_link('popular_by_month')."'>Month</a><b>/</b><a href='".make_link('popular_by_year')."'>Year</a> "; |  | ||||||
|                 } |  | ||||||
|                 $cs .= "<a class='tab' href='".make_link('post/list')."'>All</a>"; |  | ||||||
|                 if (class_exists("Favorites")) { |  | ||||||
|                     $cs .= "<a class='tab' href='".make_link("post/list/favorited_by={$username}/1")."'>My Favorites</a>"; |  | ||||||
|                 } |  | ||||||
|                 if (class_exists("RSS_Images")) { |  | ||||||
|                     $cs .= "<a class='tab' href='".make_link('rss/images')."'>Feed</a>"; |  | ||||||
|                 } |  | ||||||
|                 if (class_exists("Random_Image")) { |  | ||||||
|                     $cs .= "<a class='tab' href='".make_link("random_image/view")."'>Random Image</a>"; |  | ||||||
|                 } |  | ||||||
|                 if (class_exists("Wiki")) { |  | ||||||
|                     $cs .= "<a class='tab' href='".make_link("wiki/posts")."'>Help</a>"; |  | ||||||
|                 } else { |  | ||||||
|                     $cs .= "<a class='tab' href='".make_link("ext_doc/index")."'>Help</a>"; |  | ||||||
|                 } |  | ||||||
|                 break; |  | ||||||
|             case "comment": |  | ||||||
|                 $cs .= "<a class='tab' href='".make_link('comment/list')."'>All</a>"; |  | ||||||
|                 $cs .= "<a class='tab' href='".make_link('rss/comments')."'>Feed</a>"; |  | ||||||
|                 $cs .= "<a class='tab' href='".make_link("ext_doc/comment")."'>Help</a>"; |  | ||||||
|                 break; |  | ||||||
|             case "pool": |  | ||||||
|                 $cs .= "<a class='tab' href='".make_link('pool/list')."'>List</a>"; |  | ||||||
|                 $cs .= "<a class='tab' href='".make_link("pool/new")."'>Create</a>"; |  | ||||||
|                 $cs .= "<a class='tab' href='".make_link("pool/updated")."'>Changes</a>"; |  | ||||||
|                 $cs .= "<a class='tab' href='".make_link("ext_doc/pools")."'>Help</a>"; |  | ||||||
|                 break; |  | ||||||
|             case "wiki": |  | ||||||
|                 $cs .= "<a class='tab' href='".make_link('wiki')."'>Index</a>"; |  | ||||||
|                 $cs .= "<a class='tab' href='".make_link("wiki/rules")."'>Rules</a>"; |  | ||||||
|                 $cs .= "<a class='tab' href='".make_link("ext_doc/wiki")."'>Help</a>"; |  | ||||||
|                 break; |  | ||||||
|             case "tags": |  | ||||||
|             case "alias": |  | ||||||
|                 $cs .= "<a class='tab' href='".make_link('tags/map')."'>Map</a>"; |  | ||||||
|                 $cs .= "<a class='tab' href='".make_link('tags/alphabetic')."'>Alphabetic</a>"; |  | ||||||
|                 $cs .= "<a class='tab' href='".make_link('tags/popularity')."'>Popularity</a>"; |  | ||||||
|                 $cs .= "<a class='tab' href='".make_link('tags/categories')."'>Categories</a>"; |  | ||||||
|                 $cs .= "<a class='tab' href='".make_link('alias/list')."'>Aliases</a>"; |  | ||||||
|                 $cs .= "<a class='tab' href='".make_link("ext_doc/tag_edit")."'>Help</a>"; |  | ||||||
|                 break; |  | ||||||
|             case "upload": |  | ||||||
|                 if (class_exists("Wiki")) { |  | ||||||
|                     $cs .= "<a class='tab' href='".make_link("wiki/upload_guidelines")."'>Guidelines</a>"; |  | ||||||
|                 } |  | ||||||
|                 break; |  | ||||||
|             case "random": |  | ||||||
|                 $cs .= "<a class='tab' href='".make_link('random/view')."'>Shuffle</a>"; |  | ||||||
|                 $cs .= "<a class='tab' href='".make_link('random/download')."'>Download</a>"; |  | ||||||
|                 break; |  | ||||||
|             case "featured": |  | ||||||
|                 $cs .= "<a class='tab' href='".make_link('featured/download')."'>Download</a>"; |  | ||||||
|                 break; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if ($cs == "") { |  | ||||||
|             $custom_sublinks = ""; |  | ||||||
|         } else { |  | ||||||
|             $custom_sublinks .= "$cs</div>"; |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         $debug = get_debug_info(); |         $debug = get_debug_info(); | ||||||
| @ -240,31 +153,13 @@ EOD; | |||||||
|     /** |     /** | ||||||
|      * #param string[] $pages_matched
 |      * #param string[] $pages_matched
 | ||||||
|      */ |      */ | ||||||
|     public function navlinks(string $link, string $desc, array $pages_matched): ?string |     public function navlinks(Link $link, string $desc, bool $active): ?string | ||||||
|     { |     { | ||||||
|         /** |  | ||||||
|          * Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.) |  | ||||||
|          */ |  | ||||||
|         $html = null; |         $html = null; | ||||||
|         $url = ltrim(_get_query(), "/"); |         if ($active) { | ||||||
| 
 |             $html = "<a class='tab-selected' href='{$link->make_link()}'>{$desc}</a>"; | ||||||
|         $re1='.*?'; |         } else { | ||||||
|         $re2='((?:[a-z][a-z_]+))'; |             $html = "<a class='tab' href='{$link->make_link()}'>{$desc}</a>"; | ||||||
| 
 |  | ||||||
|         if (preg_match_all("/".$re1.$re2."/is", $url, $matches)) { |  | ||||||
|             $url=$matches[1][0]; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         $count_pages_matched = count($pages_matched); |  | ||||||
| 
 |  | ||||||
|         for ($i=0; $i < $count_pages_matched; $i++) { |  | ||||||
|             if ($url == $pages_matched[$i]) { |  | ||||||
|                 $html = "<a class='tab-selected' href='{$link}'>{$desc}</a>"; |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if (is_null($html)) { |  | ||||||
|             $html = "<a class='tab' href='{$link}'>{$desc}</a>"; |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return $html; |         return $html; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user