LnBlog PHP Cross Reference Blogging Systems

Source: /plugins/sidebar_articles.php - 95 lines - 2773 bytes - Summary - Text - Print

   1  <?php
   2  
   3  # Plugin: Articles

   4  #

   5  
   6  class Articles extends Plugin {
   7  
   8  	function Articles($do_output=0) {
   9          global $SYSTEM;
  10          $this->plugin_desc = _("List the articles for a blog.");
  11          $this->plugin_version = "0.2.4";
  12          $this->header = _("Articles");
  13          $this->static_link = true;
  14          $this->custom_links = "links.htm";
  15          $this->addOption("header", _("Sidebar section heading"),
  16              _("Articles"), "text");
  17          $this->addOption("static_link", 
  18              _("Show link to list of static articles"),
  19              true, "checkbox");
  20          $this->addOption("showall_text",
  21              _("Text for link to all static articles"),
  22              _("All static pages"), "text");
  23          $this->addOption("custom_links", 
  24              _("File where additional links to display are stored"),
  25              "links.htm", "true");
  26              
  27          $this->addOption('no_event',
  28              _('No event handlers - do output when plugin is created'),
  29              $SYSTEM->sys_ini->value("plugins","EventDefaultOff", 0), 
  30              'checkbox');
  31              
  32          $this->getConfig();
  33          
  34          if ( $this->no_event || 
  35               $SYSTEM->sys_ini->value("plugins","EventForceOff", 0) ) {
  36              # If either of these is true, then don't set the event handler

  37              # and rely on explicit invocation for output.

  38          } else {
  39              $this->registerEventHandler("sidebar", "OnOutput", "outputCache");
  40          }
  41          $this->registerStandardInvalidators();
  42          
  43          if ($do_output) $this->buildOutput();
  44      }
  45      
  46  	function buildOutput($parm=false) {
  47          global $SYSTEM;
  48          
  49          $blg = NewBlog();
  50          $u = NewUser();
  51          if (! $blg->isBlog()) return false;
  52          
  53          $art_list = $blg->getArticleList();
  54          $tpl = NewTemplate("sidebar_panel_tpl.php");
  55          $items = array();
  56  
  57          if (count($art_list) > 0) {
  58          
  59              if ($this->header) {
  60                  $tpl->set("PANEL_TITLE",
  61                            ahref($blg->uri('articles'), $this->header));
  62              }
  63              
  64              foreach ($art_list as $art) {
  65                  $items[] = ahref($art['link'], htmlspecialchars($art['title']));
  66              }
  67              
  68              if ( is_file(mkpath($blg->home_path, $this->custom_links)) ) {
  69                  $data = file(mkpath($blg->home_path, $this->custom_links));
  70                  foreach ($data as $line) $items[] = $line;
  71              }
  72              
  73              if ($this->static_link) {
  74                  $items[] = array('description'=>ahref($blg->uri('articles'), $this->showall_text),
  75                                   'style'=>'margin-top: 0.5em');
  76              } 
  77          
  78              if ($SYSTEM->canModify($blg, $u)) {
  79                  $items[] = array('description'=>ahref($blg->uri('editfile', $this->custom_links),
  80                                                        _("Add custom links")),
  81                                   'style'=>'margin-top: 0.5em');
  82              }
  83  
  84              $tpl->set('PANEL_LIST', $items);
  85              return $tpl->process();
  86          } else return '';
  87      }  # End function

  88      
  89  }
  90  
  91  global $PLUGIN_MANAGER;
  92  if (! $PLUGIN_MANAGER->plugin_config->value('articles', 'creator_output', 0)) {
  93      $art = new Articles();
  94  }
  95  ?>

title

Description

title

Description

title

Description

title

title

Body