US Tray Menu: Command processor

From The Uniform Server Wiki
Jump to navigation Jump to search

 

UniServer 5-Nano
US Tray Menu.

US Tray Menu Comman processor

Introduction

Test results show a simple command processor as used in the generic menu is not suitable for a Uniform Server specific implementation.

WinBinder’s function wb_exec() provides a suitable solution however to meet our requirements parameters passed require tailoring.

These are targeted using a separate command and parameters juggled accordingly.

Command run

This command launches an application with optional parameters. For example

$prog1 = "EditPadLite.exe";
$prog2 = "Notepad.exe";
$prog3 = "minimal.phpw";
$par1 = "../../usr/local/apache2/conf/httpd.conf";
$par2 = ""; 

wb_exec($prog1,$par1 );
wb_exec($prog1,$par2 );
wb_exec($prog2,$par1 );
wb_exec($prog2,$par2 );

Top

Ini file format

Configuration file format remains unchanged:

item[]      = "Edit Apache Configuration"           
action[]    = "run"                                  
file[]      = "Notepad.exe"            
parameter[] = "../../usr/local/apache2/conf/httpd.conf"   
icon[]      = "5"

Top

Command processor

  if($command_array[0] == "run"){                 // Standard command to run
    wb_exec($command_array[1],$command_array[2]); // as per WinBinder 
  }

With the exception of the command processor code there is no difference between generic and US menu.

Note 1: WinBinder files with extension phpw will not run unless a file association is made. Uniform Server assumes no association.

Note 2: Function wb_exec allows any file to be run so long as it has a file association.

Top

Command runh

This command launches a hidden application using utility uniserv.exe.

A file name must be provided with optional parameters. For example

 wb_exec( "uniserv.exe",   "\"php.exe -n ../main/start_servers.php 7\"");
 wb_exec( "uniserv.exe",   "\"php.exe -n unitray_info.php 1\"");
 wb_exec( "uniserv.exe",   "\"php.exe -n ../main/stop_servers.php 7\"");

Top

Ini file format

Configuration file format remains unchanged:

item[]      = "Start UniServer (Apache MySQL Program)"  ; display menu item
action[]    = "runh"                                    ; run, runh , sub, separator 
file[]      = "php.exe"                                 ; file name or sub-name
parameter[] = "-n ../main/start_servers.php 7"          ; parameters to pass
icon[]      = "7"                                       ; icon id number

Top

Command processor

  if($command_array[0] == "runh"){         // Standard command run hidden
    $cmd1 = "\"";                          // Start quote
    $cmd2 = $command_array[1];             // Full path and file name to run
    $cmd3 = " ";                           // Assume user missed the space
    $cmd4 = $command_array[2];             // parameters to include
    $cmd5 = "\" ";                         // Add final quote

    $cmd6 = $cmd1.$cmd2.$cmd3.$cmd4.$cmd5; // build command string
    wb_exec( "uniserv.exe", $cmd6 );
  }

Again with the exception of command processor code there is no difference between generic and US menu.

Top

Summary

Although changes are minimal we now have a working menu.

Admittedly in terms of functionality it is identical to our generic menu even down to having move servers disabled.

Next page adds a little refinement Start and Stop UniTray


Top