US Tray Menu 2: Binaries: Difference between revisions

From The Uniform Server Wiki
Jump to navigation Jump to search
No edit summary
m (Text replace - "projects/uniformserver" to "projects/miniserver")
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=[http://ecacoraqosy.co.cc This Page Is Currently Under Construction And Will Be Available Shortly, Please Visit Reserve Copy Page]=
{{Nav US Tray Menu 2}}
{{Nav US Tray Menu 2}}
'''''US Tray Menu 2 VC9 Binaries'''''
'''''US Tray Menu 2 VC9 Binaries'''''
Line 25: Line 24:
|-
|-
|
|
<pre>
<pre>
//=== US POP UP ===============================================================
//=== US POP UP ===============================================================
// This function launches a detached pop-up allowing menu to minimise.
// This function launches a detached pop-up allowing menu to minimise.
Line 32: Line 31:
function us_pop_up($str,$title){
function us_pop_up($str,$title){


   putenv(&quot;UT_TITLE=$title&quot;); // Set vars
   putenv("UT_TITLE=$title"); // Set vars
   putenv(&quot;UT_STR=$str&quot;);
   putenv("UT_STR=$str");


   $cmd = &quot;start ..\..\usr\local\php\php-win.exe -c ..\..\usr\local\php\php-cli.ini pop_up.php&quot;;
   $cmd = "start ..\..\usr\local\php\php-win.exe -c ..\..\usr\local\php\php-cli.ini pop_up.php";
   pclose(popen($cmd,'r'));  
   pclose(popen($cmd,'r'));  


Line 42: Line 41:


}//========================================================== END US POP UP ===
}//========================================================== END US POP UP ===
&lt;/pre&gt;
</pre>
|}
|}
Script for the pop-up as follows:
Script for the pop-up as follows:
Line 48: Line 47:
|-
|-
|
|
&lt;pre&gt;
<pre>
chdir(dirname(__FILE__)); // Change wd to this files location
chdir(dirname(__FILE__)); // Change wd to this files location


include_once &quot;winbinder/winbinder.php&quot;;
include_once "winbinder/winbinder.php";
include_once &quot;includes/functions2.php&quot;;
include_once "includes/functions2.php";
include_once &quot;includes/config2.inc.php&quot;;
include_once "includes/config2.inc.php";
include_once &quot;lang/lang.php&quot;;
include_once "lang/lang.php";


// Environment variables are set by main menu pick these up to display title
// Environment variables are set by main menu pick these up to display title
Line 65: Line 64:


exit;
exit;
&lt;/pre&gt;
</pre>
|}
|}
At first above looks like a viable solution however when run an annoying command window opens for a short period this really is a pain when scripting   
At first above looks like a viable solution however when run an annoying command window opens for a short period this really is a pain when scripting   
Line 73: Line 72:
|-
|-
|
|
&lt;pre&gt;
<pre>
cd ..\..\usr\local\php
cd ..\..\usr\local\php
php.exe -c php-cli.ini ..\..\..\unicon\tray_menu_2\pop_up.php
php.exe -c php-cli.ini ..\..\..\unicon\tray_menu_2\pop_up.php
EXIT
EXIT
&lt;/pre&gt;
</pre>
|}
|}
To a [[PHP WinBinder: Project2 | '''hidden executable''']] this runs the pop-up script
To a [[PHP WinBinder: Project2 | '''hidden executable''']] this runs the pop-up script
Line 83: Line 82:
|-
|-
|
|
&lt;pre&gt;
<pre>
include_once &quot;winbinder/winbinder.php&quot;;
include_once "winbinder/winbinder.php";
include_once &quot;includes/functions2.php&quot;;
include_once "includes/functions2.php";
include_once &quot;includes/config2.inc.php&quot;;
include_once "includes/config2.inc.php";
include_once &quot;lang/lang.php&quot;;
include_once "lang/lang.php";


// Environment variables are set by main menu pick these up to display title
// Environment variables are set by main menu pick these up to display title
Line 98: Line 97:


exit
exit
&lt;/pre&gt;
</pre>
|}
|}
Script picks up environment variables and runs message  box.
Script picks up environment variables and runs message  box.
Line 106: Line 105:
|-
|-
|
|
&lt;pre&gt;
<pre>
//=== US POP UP ===============================================================
//=== US POP UP ===============================================================
// This function launches a detached pop-up allowing menu to minimise.
// This function launches a detached pop-up allowing menu to minimise.
Line 113: Line 112:
function us_pop_up($str,$title){
function us_pop_up($str,$title){


   putenv(&quot;UT_TITLE=$title&quot;); // Set var title  to be displayed in message box
   putenv("UT_TITLE=$title"); // Set var title  to be displayed in message box
   putenv(&quot;UT_STR=$str&quot;);    // Set var string  to be displayed in message box
   putenv("UT_STR=$str");    // Set var string  to be displayed in message box


   $cmd = getcwd().&quot;/Run_pop_up..exe&quot;;  // set path to executable
   $cmd = getcwd()."/Run_pop_up..exe";  // set path to executable
   wb_exec($cmd);                        // detached message box  
   wb_exec($cmd);                        // detached message box  


Line 123: Line 122:


}//========================================================== END US POP UP ===
}//========================================================== END US POP UP ===
&lt;/pre&gt;
</pre>
|}
|}
This in turn is run from the command processor. For example:
This in turn is run from the command processor. For example:
Line 129: Line 128:
|-
|-
|
|
&lt;pre&gt;
<pre>
   //== Command cmd_move_servers
   //== Command cmd_move_servers
   if($command_array[0] == &quot;cmd_move_servers&quot;){                // Intercept command
   if($command_array[0] == "cmd_move_servers"){                // Intercept command
       if(($AP || $APS || $MY || $MYS) ){                      // Servers running can not move servers
       if(($AP || $APS || $MY || $MYS) ){                      // Servers running can not move servers
         us_pop_up(&quot;move_servers6-str1&quot;,&quot;move_servers6-title&quot;); // Inform Users
         us_pop_up("move_servers6-str1","move_servers6-title"); // Inform Users
       }
       }
       else{                                      // No:
       else{                                      // No:
         $cmd = relative_to_absolute_paths(&quot;./Run_move_servers.exe&quot;);
         $cmd = relative_to_absolute_paths("./Run_move_servers.exe");
         wb_exec($cmd);   
         wb_exec($cmd);   
       }
       }
Line 142: Line 141:
   }
   }
   //== End cmd_move_servers
   //== End cmd_move_servers
&lt;/pre&gt;
</pre>
|}   
|}   
Although this solution is convoluted it avoids that dreaded command window opening.
Although this solution is convoluted it avoids that dreaded command window opening.
Line 164: Line 163:
|-
|-
|
|
&lt;pre&gt;
<pre>
//== No mouse clicked process returned result ================================
//== No mouse clicked process returned result ================================
  // No mouse click however mouse was moved and it requires processing.
  // No mouse click however mouse was moved and it requires processing.
Line 171: Line 170:
  if(!empty($result)) {                      // Skip if no value returned
  if(!empty($result)) {                      // Skip if no value returned


   if($result[0] == &quot;sub&quot;){                  // Is command a sub-menu
   if($result[0] == "sub"){                  // Is command a sub-menu
     if($active){                            // Is there already an active pop-up
     if($active){                            // Is there already an active pop-up
       if( $result[1] != $sub_name){        // Yes: Is it a new sub-menu window
       if( $result[1] != $sub_name){        // Yes: Is it a new sub-menu window
         $sub_name=&quot;&quot;;                      // Reset name
         $sub_name="";                      // Reset name
         wb_destroy_window($sub_win);        // Yes: Close old window
         wb_destroy_window($sub_win);        // Yes: Close old window
         $active = FALSE;                    // and reset active flag  
         $active = FALSE;                    // and reset active flag  
Line 192: Line 191:


   else{                                    // N0 Not a sub-menu command
   else{                                    // N0 Not a sub-menu command
     $sub_name=&quot;&quot;;                            // Reset name  
     $sub_name="";                            // Reset name  
     if($active){                            // Is there an active pop-up  
     if($active){                            // Is there an active pop-up  
     wb_destroy_window($sub_win);            // Yes: Close old window pop-up  
     wb_destroy_window($sub_win);            // Yes: Close old window pop-up  
Line 201: Line 200:


  else{        // Is empty. Moved into a none hot spot. Close an active window                                    //  
  else{        // Is empty. Moved into a none hot spot. Close an active window                                    //  
   $sub_name=&quot;&quot;;                        // Reset name  
   $sub_name="";                        // Reset name  
   if($active){                          // Is there an active pop-up
   if($active){                          // Is there an active pop-up
     wb_destroy_window($sub_win);        // Yes: Close window
     wb_destroy_window($sub_win);        // Yes: Close window
Line 208: Line 207:
  }
  }
  //== END No mouse clicked process returned result ============================
  //== END No mouse clicked process returned result ============================
&lt;/pre&gt;
</pre>
|}         
|}         


Line 227: Line 226:
Applications from Zcon require a re-write see auto-resizing restriction below     
Applications from Zcon require a re-write see auto-resizing restriction below     
{|
{|
|-valign=&quot;top&quot;
|-valign="top"
|
|
'''UniTray'''
'''UniTray'''
Line 269: Line 268:
[[Category: How To]]
[[Category: How To]]
[[Category: Uniform Server 5.0-Nano]]
[[Category: Uniform Server 5.0-Nano]]
[[Category: UniServer 6.0.0-Carbo]]
[[Category: Uniform Server 6-Carbo]]

Latest revision as of 16:16, 17 October 2012

 

UniServer 5-Nano
US Tray Menu 2.
UniServer 6-Carbo

US Tray Menu 2 VC9 Binaries

Introduction

Our tray if it remains as a seperate plugin requires additional PHP modules. The following are required php_curl.dll for user IP address detection php_mysql.dll for password restore and restricted user configuration and php_openssl.dll and associated binaries for server certificate and key generation. These are duplications and only serve to increase size.

Solution is to use existing PHP installation with the addition of new php_winbinder.dll with UTF-8 support. Command line scripts by their nature do not support UTF-8 these require converting ideally to a windows-based format. This adds redundancy; hence delete old UniTray and associated files.

The server is already looking like a different beast, which begs the question why not take it a step further and convert to VC9 binaries.

As mentioned on the introduction page final twist is Uniform Server 6.0.0-Carbo (VC9 binary version)

There are a few issues outstanding lets clear these up first.

Issues

Tray menu is primarily an application launcher. When a menu item is clicked menu minimises and application is run. This is not the case with mesage boxes.

Top

Message boxes

Menu items that are unavailable when clicked a message box pops up informing a user as to why it is disabled.

Until closed standard message boxes halt program execution leaving our menu visible. Solution is to run a detached message box before doing so set environment variables for message box title and text to be displayed.

//=== US POP UP ===============================================================
// This function launches a detached pop-up allowing menu to minimise.
// Environment variables “title” and ”str” are set and picked-up by the pop-up.

function us_pop_up($str,$title){

  putenv("UT_TITLE=$title"); // Set vars
  putenv("UT_STR=$str");

  $cmd = "start ..\..\usr\local\php\php-win.exe -c ..\..\usr\local\php\php-cli.ini pop_up.php";
  pclose(popen($cmd,'r')); 

  putenv('UT_STR=');    // Reset
  putenv('UT_TITLE=');  // Reset

}//========================================================== END US POP UP ===

Script for the pop-up as follows:

chdir(dirname(__FILE__)); // Change wd to this files location

include_once "winbinder/winbinder.php";
include_once "includes/functions2.php";
include_once "includes/config2.inc.php";
include_once "lang/lang.php";

// Environment variables are set by main menu pick these up to display title
// and message in an alert box.

$ut_title = getenv('UT_TITLE');
$ut_str   = getenv('UT_STR');

wb_message_box (NULL, $TM[$ut_str], $TM[$ut_title]);

exit;

At first above looks like a viable solution however when run an annoying command window opens for a short period this really is a pain when scripting

Solution is to convert the following batch file:

cd ..\..\usr\local\php
php.exe -c php-cli.ini ..\..\..\unicon\tray_menu_2\pop_up.php
EXIT

To a hidden executable this runs the pop-up script

include_once "winbinder/winbinder.php";
include_once "includes/functions2.php";
include_once "includes/config2.inc.php";
include_once "lang/lang.php";

// Environment variables are set by main menu pick these up to display title
// and message in an alert box.

$ut_title = getenv('UT_TITLE');
$ut_str   = getenv('UT_STR');

wb_message_box (NULL, $TM[$ut_str], $TM[$ut_title]);

exit

Script picks up environment variables and runs message box.

Above pop-up is launched using the following function:

//=== US POP UP ===============================================================
// This function launches a detached pop-up allowing menu to minimise.
// Environment variables “title” and ”str” are set and picked-up by the pop-up.

function us_pop_up($str,$title){

  putenv("UT_TITLE=$title"); // Set var title  to be displayed in message box
  putenv("UT_STR=$str");     // Set var string  to be displayed in message box

  $cmd = getcwd()."/Run_pop_up..exe";   // set path to executable
  wb_exec($cmd);                        // detached message box 

  putenv('UT_STR=');    // Reset
  putenv('UT_TITLE=');  // Reset

}//========================================================== END US POP UP ===

This in turn is run from the command processor. For example:

  //== Command cmd_move_servers
  if($command_array[0] == "cmd_move_servers"){                 // Intercept command
      if(($AP || $APS || $MY || $MYS) ){                       // Servers running can not move servers
        us_pop_up("move_servers6-str1","move_servers6-title"); // Inform Users
      }
      else{                                       // No:
        $cmd = relative_to_absolute_paths("./Run_move_servers.exe");
        wb_exec($cmd);  
      }
   return;
   }
   //== End cmd_move_servers

Although this solution is convoluted it avoids that dreaded command window opening.

Top

Ghosting

Generic menu suffered from ghosting extremely annoying especially on a dark background.

Top

Problem

Mouse over a sub-menu item triggers the Winbinder wb_wait() function inserted to prevent a sudden pop-up. However once triggered continues to time-out on completion sub-menu is displayed. Because the mouse is no longer hovering over the sub-menu it is instantly closed. I say instantly however there is a finite time before it closes hence the ghosting effect.

Top

Solution

Solution is to check validity before opening a pop-up sub-menu. Its stored name ($name) can be used for this purpose. While the timer is timing out any items other than the pop-up in question is moused over resets this variable ($name). There remains a very slim chance of ghosting however during tests I have never seen it hence to all intense and purpose it has been eliminated

New code as shown below:

//== No mouse clicked process returned result ================================
 // No mouse click however mouse was moved and it requires processing.
 // On detecting a sub command display pop-up 

 if(!empty($result)) {                       // Skip if no value returned

   if($result[0] == "sub"){                  // Is command a sub-menu
    if($active){                             // Is there already an active pop-up
       if( $result[1] != $sub_name){         // Yes: Is it a new sub-menu window
         $sub_name="";                       // Reset name
         wb_destroy_window($sub_win);        // Yes: Close old window
         $active = FALSE;                    // and reset active flag 
       }                                     // Note: New window one will be created
     }                                       // next time around loop (mouse move).  

     else{                                   // No: No active pop-up create new

       $sub_name = $result[1];               // save sub-menu name required for closing
       wb_wait($mainwin,400, WBC_KEYDOWN);   // Prevent sudden pop-up   
       if($sub_name == $result[1]){          // Check to see if still viable
         $active = TRUE;                     // set active flag
         pop_win($window,$result[2]);        // Open pop-up pass its y cord $result[2]
       } 
    }
   }

   else{                                     // N0 Not a sub-menu command
    $sub_name="";                            // Reset name 
    if($active){                             // Is there an active pop-up 
     wb_destroy_window($sub_win);            // Yes: Close old window pop-up 
     $active = FALSE;                        // and reset active flag     
    }  
   }
 }// end not empty

 else{         // Is empty. Moved into a none hot spot. Close an active window                                     // 
  $sub_name="";                         // Reset name 
  if($active){                          // Is there an active pop-up
    wb_destroy_window($sub_win);        // Yes: Close window
    $active = FALSE;                    // now reset active flag
  }  
 }
 //== END No mouse clicked process returned result ============================

Note:

The wb_wait() function unlike PHP sleep() does not halt program execution. The windows application continues to process messages this stops the application freezing. What that means is any mouse events are processed. Code below function wb_wait is deferred from execution until its pre-set time is reached. It is important to note wb_wait is mono-stable meaning it can only be re-triggered after timing out.

Top

New server

Uniform server 5.6.7-Nano was taken as a starting point. All binaries where appropriate were replaced with their VC9 counterparts.

UniTray is replaced with a new version. This new version encompasses features from old UniTray and Zcon.

Note:

Applications from Zcon require a re-write see auto-resizing restriction below

UniTray

UniTray is an application launcher allowing additional features to be easily added. Each new feature or features are implemented with mini-applications written in PHP.

Advantage of this approach only a single entry is required in the configuration file UniTray.ini each application is independent which enhances testability.

Language Support

Text displayed to a user (buttons, labels, pop-up message boxes etc.) must be added to the language file lang.php. There are no restrictions placed on text width this is because after language translation string widths are bound to be different.

UniTray uses following two files for language support:

  • unicon\tray_menu_2\UniTray.ini
  • UniServer\unicon\tray_menu_2\lang\lang.php

A restriction imposed on your windows layout; variable width text requires a mini-application implement auto-resizing.

Menu Example

On the right is a menu example with Apache running and MySQL server stopped.

Top

Summary

That concludes this tutorial.

Download

You can download a beta version of the new server UniServer 6.0.0-Carbo


Top