| [ PHPXref.com ] | [ Generated: Sun Jul 20 18:29:26 2008 ] | [ LnBlog 0.7.0 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 3 # Plugin: SiteMap 4 # Shows a user-defined site map in the menu bar. 5 # 6 # This plugin allows you to put a simple site map in the menubar of your 7 # blogs. The site map itself is stored in a file that you must edit by hand. 8 # 9 # Note that there are two formats for the site map. The default format is 10 # simply a list of hyperlinks with one link per line. When the page is 11 # displayed, these will be converted to an HTML unordered list, with 12 # a customizable label in front of it. 13 # 14 # The second format, which is enabled by an option, is to treat the sitemap 15 # file as raw HTML to be included directly in the page. This does not 16 # create an automatic list for you or, in fact, do any processing on the 17 # file at all. This option is used if you want to do anything fancy with 18 # the menubar, such as adding drop-down menus with JavaScript or CSS. 19 # 20 # As of version 0.3.0 of this plugin (which ships with LnBlog 0.7.0), there is 21 # an auto-sitemap feature. This is turned on by default and basically just 22 # puts links to all the registered blogs in the site map. You can still use the 23 # old file-based sitemap as well, but it is no longer required. If you use 24 # both, then the auto-generated links will be shown first and the custom ones 25 # will be second. 26 27 class SiteMap extends Plugin { 28 29 var $link_file; 30 31 function SiteMap() { 32 $this->plugin_desc = _("Show a sitemap in the menubar"); 33 $this->plugin_version = "0.3.0"; 34 $this->list_header = _("Site Map"); 35 $this->no_markup = false; 36 $this->addOption("auto_map", _("Automatically list all blogs in sitemap"), 37 true, "checkbox"); 38 $this->addOption("link_file", _("Name of link-list file"), 39 "sitemap.htm", "text"); 40 $this->addOption("list_header", _("Heading at start of menubar"), 41 _("Site Map"), "text"); 42 $this->addOption("no_markup", _("Use unmodified file contents as menubar (no auto-generated HTML)"), 43 false, "checkbox"); 44 $this->getConfig(); 45 } 46 47 function output($parm=false) { 48 global $SYSTEM; 49 50 $map_file = ''; 51 $blog = NewBlog(); 52 53 if ( $blog->isBlog() && 54 file_exists(BLOG_ROOT.PATH_DELIM.$this->link_file) ) { 55 $map_file = BLOG_ROOT.PATH_DELIM.$this->link_file; 56 } elseif (is_file(mkpath(USER_DATA_PATH,$this->link_file))) { 57 $map_file = mkpath(USER_DATA_PATH,$this->link_file); 58 } 59 60 $markup = ''; 61 if ($this->auto_map) { 62 $blogs = $SYSTEM->getBlogList(); 63 foreach ($blogs as $b) { 64 $markup .= '<li><a href="'.$b->getURL().'" title="'. 65 $b->description.'">'.$b->name."</a></li>\n"; 66 } 67 } 68 69 if ($this->no_markup && is_file($map_file)) { 70 $data = file($map_file); 71 if ($markup) echo "<ul>\n$markup</ul>\n"; #Auto-generated links. 72 foreach ($data as $line) echo $line; 73 } else { 74 ?> 75 <h2><?php echo $this->list_header; ?></h2> 76 <ul> 77 <?php 78 echo $markup; # Output the auto-generated links, if any. 79 if (is_file($map_file)) { 80 $data = file($map_file); 81 foreach ($data as $line) { 82 if (trim($line) != '') { 83 ?> 84 <li><?php echo $line; ?></li> 85 <?php 86 } 87 } 88 } elseif (! $this->auto_map) { ?> 89 <li><a href="/" title="<?php p_("Site home page"); ?>"><?php p_("Home"); ?></a></li> 90 <?php 91 } ?> 92 </ul> 93 <?php 94 } 95 } 96 97 function showLink($param) { 98 $blog = NewBlog(); 99 echo '<li><a href="'.$blog->uri('blog').'map.php">'. 100 _("Edit custom sitemap").'</a></li>'; 101 } 102 103 } 104 $map = new SiteMap(); 105 $map->registerEventHandler("menubar", "OnOutput", "output"); 106 $map->registerEventHandler("loginops", "PluginOutput", "showLink"); 107 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |