MongoDB Tutorial 4: phpMoAdmin Support

Revision as of 13:30, 1 August 2010 by Ric (talk | contribs) (New page: {{Nav MongoDB Tutorial 4}} '''''MongoDB adding phpMoAdmin Support''''' == Introduction == The standalone plugin provided a button to run phpMoAdmin. Our new plugin purposely removed this ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

 

MongoDB Production Plugin
UniServer 6-Carbo.

MongoDB adding phpMoAdmin Support

Introduction

The standalone plugin provided a button to run phpMoAdmin.

Our new plugin purposely removed this button to provide a cleaner user interface.

To retain flexibility a menu bar was added this page covers adding a menu item for phpMoAdmin.

Add menu item

Adding a menu item requires the following steps:

  • Create a constant to define a new unique ID
  • Add menu item to one of the drop down menus
  • Add a cease statement to process menu item

Add the following constant

//=File
define('ID_PHPMOADMIN',        1110);

Add menu item. I decided to locate it in the file drop-down menu

   "File",
       array(ID_PHPMOADMIN,        "Run phpMoAdmin"),
       null,                        // separator 
       array(IDCLOSE,               "Exit"),

Add handler section

 //=== Process menu items ====================

  //=File
  case ID_PHPMOADMIN:                // Run phpMoAdmin

  // Check server running
  if(!mongodb_running()){
   $str  = "";
   $str .= "This item requires access to a running server.\n";
   $str .= "Please start MonGoDB server and run\n";
   $str .= "this item again.";
   wb_message_box($window, $str,"Server not running", WBC_INFO); 
   break;        // Give up
  }

  //== Create or update a new redirect page 
  $apache_port = get_apache_port(); // Get real port this may have changed
  $str  = '<html><head>'."\n";
  $str .= '<meta http-equiv="refresh" content="1;url=http://localhost:';
  $str .= $apache_port.'/apanel/phpmoadmin/moadmin.php">'."\n";
  $str .= '<title>Uniform Server</title></head>'."\n";
  $str .= '<body></body></html>'."\n";
 
  file_put_contents(REDIRECT_PAGE,$str); // Save string to file

  wb_exec(REDIRECT_PAGE);   // Run redirect file mongo_redirect.html

  break;

Top

Summary

That concludes this tutorial finished application shown on right.

Although fully functional consider it a starting point where you can add extra functionality as required.

To download this application; check the download page for details.

See User support page for additional information.

 

Top

Conclusion

These tutorials are intended to show how easy it is to create a plugin for Uniform Server.

MongoDB just happened to be around being self-contained allowed other facets of scripting to be shown. It brings together three open source projects MongoDB, WinBinder and Uniform Server. These in turn rely on other open source projects.

If the tutorials have sparked a single idea or allowed you to pick up useful code then they were worth producing.


Top