[ PHPXref.com ] [ Generated: Sun Jul 20 16:35:25 2008 ] [ bBlog 0.7.6 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/bblog/bBlog_plugins/ -> builtin.plugins.php (source)

   1  <?php
   2  // this is supposed to be a GUI for plugins.
   3  // need some help with some sort of api.
   4  // in the mean time we'll put them in an array.
   5  $show_plugin_menu = TRUE;
   6  $plugin_ar  = array();
   7  
   8  function identify_admin_plugins () {
   9    return array (
  10      'name'           =>'plugins',
  11      'type'           =>'builtin',
  12      'nicename'       =>'Plugins',
  13      'description'    =>'Display information about, and run plugins',
  14      'authors'         =>'Eaden McKee',
  15      'licence'         =>'GPL'
  16    );
  17  }
  18  // PLUGINS : 
  19  
  20  function scan_for_plugins () {
  21    global $bBlog;
  22    $newplugincount = 0;
  23    $newpluginnames = array();
  24    $have_plugins = array();
  25    $plugins = $bBlog->get_results("select * from ".T_PLUGINS);
  26    if(is_array($plugins)) foreach($plugins as $plugin)
  27                             $have_plugins[$plugin->type][$plugin->name] = TRUE;
  28              
  29    $plugin_files=array();
  30    $dir="./bBlog_plugins";
  31    $dh = opendir( $dir ) or die("couldn't open directory");
  32    while ( ! ( ( $file = readdir( $dh ) ) === false ) ) {
  33      if(substr($file, -3) == 'php') $plugin_files[]=$file;
  34    }
  35    closedir( $dh );
  36    foreach($plugin_files as $plugin_file) {
  37      $far = explode('.',$plugin_file);
  38      $type = $far[0];
  39      $name = $far[1];
  40      if($type != 'builtin') {
  41         include_once './bBlog_plugins/'.$plugin_file;
  42         $func = 'identify_'.$type.'_'.$name;
  43         if(function_exists($func)) {
  44                  $newplugin = $func();
  45                  if($have_plugins[$newplugin['type']][$newplugin['name']]!==TRUE) {
  46               $q = "insert into ".T_PLUGINS." set
  47                           `type`='".$newplugin['type']."',
  48                          `name`='".$newplugin['name']."',
  49                           nicename='".$newplugin['nicename']."',
  50                           description='".addslashes($newplugin['description'])."',
  51               template='".$newplugin['template']."',
  52                           help='".addslashes($newplugin['help'])."',
  53                           authors='".addslashes($newplugin['authors'])."',
  54                           licence='".$newplugin['licence']."'";
  55               $bBlog->query($q);
  56               $newplugincount++;
  57               $newpluginnames[]=$newplugin['nicename'];
  58  
  59                  }
  60         }
  61      }
  62  
  63    }
  64    if($newplugincount == 0) return "No new plugins found";
  65    else return "New plugins found : ".implode(", ",$newpluginnames);
  66  }
  67  
  68  if(isset($_POST['scan'])) $np = scan_for_plugins();
  69  
  70  if(isset($_POST['scan_refresh'])) {
  71      $bBlog->query("delete  from ".T_PLUGINS);
  72      $np = scan_for_plugins();
  73      $bBlog->assign('np',"<b style='color: red;'>$np</b><br />");
  74  }
  75  
  76  
  77  
  78  
  79  $plugins_from_db = $bBlog->get_results("select * from ".T_PLUGINS." order by type");
  80  foreach($plugins_from_db as $plugin_from_db) {
  81     $plugins[$plugin_from_db->type][$plugin_from_db->name]= array( 
  82      "name"=>$plugin_from_db->name,
  83      "id" => $plugin_from_db->id,
  84      "type"=>$plugin_from_db->type,
  85      "displayname"=>$plugin_from_db->nicename,
  86      "description"=>$plugin_from_db->description,
  87      "file"=>$plugin_from_db->type.".".$plugin_from_db->name.".php",
  88      "template"=>$plugin_from_db->template,
  89      "author"=>$plugin_from_db->authors,
  90      "licence"=>$plugin_from_db->licence,
  91      "help"=>$plugin_from_db->help
  92      );
  93     $plugin_ar[] = $plugins[$plugin_from_db->type][$plugin_from_db->name];
  94  }
  95  // other plugin :
  96  
  97  
  98  
  99  
 100  $p=FALSE;
 101  if($_GET['p']) $p = $_GET['p'];
 102  if($_POST['p']) $p = $_POST['p'];
 103  
 104  if($p && is_array($plugins['admin'][$p])) { // successful call to plugin
 105      $show_plugin_menu = FALSE;
 106      $bBlog->assign('plugin',$plugins['admin'][$p]);
 107      $bBlog->assign('plugin_template','plugins/'.$plugins['admin'][$p]['template']);
 108      $bBlog->assign('title',$plugins['admin'][$p]['displayname']);
 109      include_once BBLOGROOT.'bBlog_plugins/'.$plugins['admin'][$p]['file'];
 110          $func = "admin_plugin_".$p."_run";
 111          $func($bBlog);
 112  }
 113  
 114  $bBlog->assign('plugin_ar',$plugin_ar);
 115  $bBlog->assign('show_plugin_menu',$show_plugin_menu);
 116  
 117  
 118  $bBlog->display("plugins.html");
 119  
 120  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]