LnBlog PHP Cross Reference Blogging Systems

Source: /plugin_setup.php - 94 lines - 3205 bytes - Summary - Text - Print

   1  <?php
   2  /*

   3      LnBlog - A simple file-based weblog focused on design elegance.

   4      Copyright (C) 2005-2011 Peter A. Geer <pageer@skepticats.com>

   5  

   6      This program is free software; you can redistribute it and/or modify

   7      it under the terms of the GNU General Public License as published by

   8      the Free Software Foundation; either version 2 of the License, or

   9      (at your option) any later version.

  10  

  11      This program is distributed in the hope that it will be useful,

  12      but WITHOUT ANY WARRANTY; without even the implied warranty of

  13      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

  14      GNU General Public License for more details.

  15  

  16      You should have received a copy of the GNU General Public License

  17      along with this program; if not, write to the Free Software

  18      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

  19  */
  20  
  21  # File: plugin_setup.php

  22  # A standard setup page for plugins.

  23  #

  24  # The actual configuration form must be supplied by the plugin itself.  

  25  # Plugins that inherit from the abstract <Plugin> class can inherit a basic

  26  # form, but others must create their own.

  27  
  28  session_start();
  29  
  30  require_once ("blogconfig.php");
  31  require_once ("lib/creators.php");
  32  require_once ("lib/plugin.php");
  33  
  34  global $PAGE;
  35  $usr = NewUser();
  36  $blg = NewBlog();
  37  
  38  if ($blg->isBlog()) {
  39      if (! $SYSTEM->canModify($blg, $usr) || !$usr->checkLogin()) {
  40          $PAGE->redirect($blg->uri('login'));
  41          exit;
  42      }
  43  } elseif (! $usr->isAdministrator() || !$usr->checkLogin()) {
  44      $PAGE->redirect("bloglogin.php");
  45      exit;
  46  }
  47  
  48  if (has_post()) {
  49      $plug_name = sanitize(POST("plugin"));
  50      $plug = new $plug_name;
  51      $ret = $plug->updateConfig();
  52  
  53      if ($blg->isBlog()) {
  54          $PAGE->redirect($blg->uri('pluginconfig'));
  55      } else {
  56          $PAGE->redirect(INSTALL_ROOT_URL."plugin_setup.php");
  57      }
  58  
  59      exit;
  60  
  61  } elseif ( sanitize(GET("plugin")) && 
  62             class_exists(sanitize(GET("plugin"))) ) {
  63      $plug_name = sanitize(GET("plugin"));
  64      $plug = new $plug_name;
  65      $body = '<h4>'._('Plugin Configuration').'</h4>';
  66      $body .= '<ul><li>'._('Name').': '.get_class($plug).'</li>';
  67      $body .= '<li>'._('Version').': '.$plug->plugin_version.'</li>';
  68      $body .= '<li>'._('Description').': '.$plug->plugin_desc.'</li></ul>';
  69      ob_start();
  70      $ret = $plug->showConfig($PAGE);
  71      $buff = ob_get_contents();
  72      ob_end_clean();
  73      $body .= is_string($ret) ? $ret : $buff;
  74      if ($blg->isBlog() ) $url = $blg->uri('pluginconfig');
  75      else $url = current_uri(true,'');
  76      
  77      $body .= '<p><a href="'.$url.'">'._("Back to plugin list").'</a></p>';
  78  } else {
  79      global $PLUGIN_MANAGER;
  80      $plug_list = $PLUGIN_MANAGER->getPluginList();
  81      sort($plug_list);
  82      $body = "<h4>"._('Plugin Configuration')."</h4><ul>";
  83      $body .= '<table><tr><th>Plugin</th><th>Version</th><th>Description</th></tr>';
  84      foreach ($plug_list as $plug) {
  85          $p = new $plug;
  86          $url = make_uri(false,array("plugin"=>$plug),false);
  87          $body .= '<tr><td><a href="'.$url.'">'.$plug.'</a></td>';
  88          $body .= '<td style="text-align: center">'.$p->plugin_version.'</td><td>'.$p->plugin_desc.'</td></tr>';
  89      }
  90      $body .= '</table>';
  91  }
  92  $PAGE->title = spf_("%s Plugin Configuration", PACKAGE_NAME);
  93  $PAGE->display($body);
  94  ?>

title

Description

title

Description

title

Description

title

title

Body