LnBlog PHP Cross Reference Blogging Systems

Source: /plugins/sidebar_tags.php - 159 lines - 5022 bytes - Summary - Text - Print

   1  <?php  
   2  if (! class_exists("Blogroll")) {  /* Start massive if statement */
   3  
   4  class TagList extends Plugin {
   5  
   6  	function TagList($do_output=0) {
   7          global $SYSTEM;
   8  
   9          $this->plugin_desc = _("Provides a list of links to view post for each tag used in the blog.");
  10          $this->plugin_version = "0.3.0";
  11          $this->addOption("header", _("Sidebar section heading"), _("Topics"));
  12          $this->addOption("page_title",
  13                           _("Heading when viewing the full page"),
  14                           _("Tags for this blog"));
  15          $this->addOption("show_feeds", _("Show RSS feeds"), true, 'checkbox');
  16  
  17          $this->addOption('no_event',
  18              _('No event handlers - do output when plugin is created'),
  19              $SYSTEM->sys_ini->value("plugins","EventDefaultOff", 0), 
  20              'checkbox');
  21  
  22          $this->getConfig();
  23  
  24          if ( $this->no_event || 
  25               $SYSTEM->sys_ini->value("plugins","EventForceOff", 0) ) {
  26              # If either of these is true, then don't set the event handler

  27              # and rely on explicit invocation for output.

  28          } else {
  29              $this->registerEventHandler("sidebar", "OnOutput", "outputCache");
  30          }
  31          $this->registerEventHandler("blogentry", "UpdateComplete", "invalidateCache");
  32          $this->registerEventHandler("blogentry", "InsertComplete", "invalidateCache");
  33          $this->registerEventHandler("article", "UpdateComplete", "invalidateCache");
  34          $this->registerEventHandler("article", "InsertComplete", "invalidateCache");
  35          $this->registerEventHandler("blog", "UpdateComplete", "invalidateCache");
  36          
  37          if ($do_output) $this->output();
  38      }
  39  
  40  	function buildList() {
  41          global $PLUGIN_MANAGER;
  42          $parser =& $PLUGIN_MANAGER->plugin_config;
  43          
  44          $blg = NewBlog();
  45          if (! $blg->isBlog() ) return false;
  46          if (empty($blg->tag_list)) return false;
  47  
  48          $base_feed_path = $blg->home_path.PATH_DELIM.BLOG_FEED_PATH;
  49          $base_feed_uri = $blg->uri('base').BLOG_FEED_PATH.'/';
  50          
  51          $links = array();
  52          foreach ($blg->tag_list as $tag) { 
  53              $l = '<a href="'.$blg->uri('tags', urlencode($tag)).'">'.
  54                   htmlspecialchars($tag).'</a>';
  55              if ($this->show_feeds) {
  56                  $topic = preg_replace('/\W/','',$tag);
  57  
  58                  $rdf_file = $topic.'_'.
  59                      $parser->value("RSS1FeedGenerator", "feed_file", "news.rdf");
  60                  $xml_file = $topic.'_'.
  61                      $parser->value("RSS2FeedGenerator", "cat_suffix", "news.xml");
  62                  
  63                  $rdf_uri = false;
  64                  $xml_uri = false;
  65  
  66                  if (file_exists($base_feed_path.PATH_DELIM.$rdf_file)) 
  67                      $rdf_uri = $base_feed_uri.$rdf_file;
  68                  if (file_exists($base_feed_path.PATH_DELIM.$xml_file)) 
  69                      $xml_uri = $base_feed_uri.$xml_file;
  70  
  71                  if ($rdf_uri && ! $xml_uri) { 
  72                       $l .= ' <a href="'.$rdf_uri.'"><img src="'.
  73                          getlink('rdf_feed.png').'" alt="'._("RSS 1.0 feed").
  74                          '" title="'._("RSS 1.0 feed").'" /></a>';
  75                  } elseif (! $rdf_uri && $xml_uri) { 
  76                      $l .= ' <a href="'.$xml_uri.'"><img src="'.
  77                          getlink('xml_feed.png').'" alt="'._("RSS 2.0 feed").
  78                          '" title="'._("RSS 2.0 feed").'" /></a>';
  79                  } elseif ($rdf_uri && $xml_uri) { 
  80                      $l .= ' <a href="'.$rdf_uri.'"><img src="'.
  81                          getlink('rdf_feed.png').'" alt="'._("RSS 1.0 feed").
  82                          '" title="'._("RSS 1.0 feed").'" /></a> '.
  83                          ' <a href="'.$xml_uri.'"><img src="'.
  84                          getlink('xml_feed.png').'" alt="'._("RSS 2.0 feed").
  85                          '" title="'._("RSS 2.0 feed").'" /></a>';
  86                  }
  87              }
  88              $links[] = $l;
  89          }
  90          return $links;
  91      }
  92  
  93  	function buildOutput($parm=false) {
  94  
  95          global $PLUGIN_MANAGER;
  96          $parser =& $PLUGIN_MANAGER->plugin_config;
  97          
  98          $blg = NewBlog();
  99          if (! $blg->isBlog() ) return false;
 100          if (empty($blg->tag_list)) return false;
 101  
 102          $base_feed_path = $blg->home_path.PATH_DELIM.BLOG_FEED_PATH;
 103          $base_feed_uri = $blg->uri('base').BLOG_FEED_PATH.'/';
 104  
 105          $list = $this->buildList();
 106  
 107          $tpl = NewTemplate("sidebar_panel_tpl.php");
 108          if ($this->header) {
 109              $tpl->set("PANEL_TITLE", $this->header);
 110              if ($blg->isBlog()) {
 111                  $tpl->set("TITLE_LINK", $blg->uri('tags'));
 112                  /*$tpl->set("TITLE_LINK", 

 113                            $blg->uri('plugin', 

 114                                      str_replace(".php", '', 

 115                                                  basename(__FILE__))));

 116                  */
 117              }
 118          }
 119          
 120          $tpl->set("PANEL_ID", 'tagpanel');
 121          $tpl->set("PANEL_LIST", $list);
 122          
 123          return $tpl->process();
 124      }
 125      
 126  	function output_page() {
 127      
 128          global $PAGE;
 129          $blog = NewBlog();
 130          $PAGE->setDisplayObject($blog);
 131  
 132          $list = $this->buildList();
 133          
 134          $PAGE->addInlineStylesheet(".taglist img { border: 0 }");
 135          
 136          $tpl = NewTemplate("list_tpl.php");
 137          $tpl->set("LIST_TITLE", $this->page_title);
 138          $tpl->set("LIST_CLASS", "taglist");
 139          $tpl->set("ITEM_LIST", $list);
 140  
 141          $PAGE->title = spf_("Blogroll - ", $blog->name);
 142          $PAGE->display($tpl->process(), $blog);
 143      
 144      }
 145  
 146  }
 147  
 148  } /* End massive if statement */
 149  
 150  if (defined("PLUGIN_DO_OUTPUT")) {
 151      $plug = new TagList();
 152      $plug->output_page();
 153  } else {
 154      global $PLUGIN_MANAGER;
 155      if (! $PLUGIN_MANAGER->plugin_config->value('taglist', 'creator_output', 0)) {
 156          $plug = new TagList();
 157      }
 158  }
 159  ?>

title

Description

title

Description

title

Description

title

title

Body