71 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Plaintext
		
	
	
			
		
		
	
	
			71 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Plaintext
		
	
	
<?php
 | 
						|
 | 
						|
$module = array("help" => "module_help",
 | 
						|
                "admin" => "module_admin");
 | 
						|
 | 
						|
function module_help() {
 | 
						|
 ?>
 | 
						|
  The module administration page provide you a list of all available modules.  Moreover, it allows you to "rehash" modules.  Whenever you install a new module or when an existing module has been changed or updated, it requires "rehasing": when you rehash a module, the module is registered to the engine and properly initialized.
 | 
						|
 <?php
 | 
						|
}
 | 
						|
 | 
						|
function module_admin_rehash() {
 | 
						|
  global $repository;
 | 
						|
 | 
						|
  $result = db_query("SELECT * FROM modules");
 | 
						|
  while ($module = db_fetch_object($result)) {
 | 
						|
    module_rehash($module->name);
 | 
						|
  }
 | 
						|
 | 
						|
  foreach ($repository as $name=>$module) {
 | 
						|
    module_rehash($name);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
function module_admin_display() {
 | 
						|
  global $output;
 | 
						|
 | 
						|
  function module_row($name, $module) {
 | 
						|
    global $output;
 | 
						|
 | 
						|
    $view = ($module["page"]) ? "<A HREF=\"module.php?mod=$name\">view</A>" : " ";
 | 
						|
    $admin = ($module["admin"]) ? "<A HREF=\"admin.php?mod=$name\">admin</A>" : " ";
 | 
						|
    $output .= " <TR><TD>$name</TD><TD>$view</TD><TD>$admin</TD><TD><A HREF=\"admin.php?mod=module&op=rehash&name=$name\">rehash</A></TD></TR>\n";
 | 
						|
  }
 | 
						|
 | 
						|
  $output .= "<FORM ACTION=\"admin.php?mod=module\" METHOD=\"post\">\n";
 | 
						|
  $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
 | 
						|
  $output .= " <TR><TH>module</TH><TH COLSPAN=\"3\">operations</TH></TR>\n";
 | 
						|
 | 
						|
  module_iterate("module_row");
 | 
						|
 | 
						|
  $output .= "</TABLE>\n";
 | 
						|
  $output .= "<INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Rehash modules\">\n";
 | 
						|
  $output .= "</FORM>\n";
 | 
						|
  print $output;
 | 
						|
}
 | 
						|
 | 
						|
function module_admin() {
 | 
						|
  global $op, $name;
 | 
						|
 | 
						|
  print "<SMALL><A HREF=\"admin.php?mod=module\">overview</A> | <A HREF=\"admin.php?mod=module&op=help\">help</A></SMALL><HR>\n";
 | 
						|
 | 
						|
  switch ($op) {
 | 
						|
    case "help":
 | 
						|
      module_help();
 | 
						|
      break;
 | 
						|
    case "rehash":
 | 
						|
      module_rehash($name);
 | 
						|
      module_admin_display();
 | 
						|
      break;
 | 
						|
    case "Rehash modules":
 | 
						|
      module_admin_rehash();
 | 
						|
      module_admin_display();
 | 
						|
      break;
 | 
						|
    default:
 | 
						|
      module_admin_display();
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
?>
 |