https://wiki.uniformserver.com/index.php?title=PHP_WinBinder_4:_Coding&feed=atom&action=history
PHP WinBinder 4: Coding - Revision history
2024-03-28T12:46:20Z
Revision history for this page on the wiki
MediaWiki 1.41.0
https://wiki.uniformserver.com/index.php?title=PHP_WinBinder_4:_Coding&diff=4244&oldid=prev
Newacct at 23:46, 2 June 2010
2010-06-02T23:46:21Z
<p></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 23:46, 2 June 2010</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l70">Line 70:</td>
<td colspan="2" class="diff-lineno">Line 70:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>; Comments start with ';', as in php.ini</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>; Comments start with ';', as in php.ini</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>title = "US Menu" ; <del style="font-weight: bold; text-decoration: none;">Manin </del>application name</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>title = "US Menu" ; <ins style="font-weight: bold; text-decoration: none;">Main </ins>application name</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[main_menu]</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[main_menu]</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l199">Line 199:</td>
<td colspan="2" class="diff-lineno">Line 199:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> $cmd5 = $cmd1.$cmd2.$cmd3.$cmd4; // build command string</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> $cmd5 = $cmd1.$cmd2.$cmd3.$cmd4; // build command string</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> pclose(popen($cmd5,'r')); // Run a <del style="font-weight: bold; text-decoration: none;">detatched </del>process</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> pclose(popen($cmd5,'r')); // Run a <ins style="font-weight: bold; text-decoration: none;">detached </ins>process</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l210">Line 210:</td>
<td colspan="2" class="diff-lineno">Line 210:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> $cmd6 = $cmd1.$cmd2.$cmd3.$cmd4.$cmd5; // build command string</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> $cmd6 = $cmd1.$cmd2.$cmd3.$cmd4.$cmd5; // build command string</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> pclose(popen($cmd6,'r')); // Run a <del style="font-weight: bold; text-decoration: none;">detatched </del>process</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> pclose(popen($cmd6,'r')); // Run a <ins style="font-weight: bold; text-decoration: none;">detached </ins>process</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>}</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>}</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l226">Line 226:</td>
<td colspan="2" class="diff-lineno">Line 226:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>'''''[[#top | Top]]'''''</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>'''''[[#top | Top]]'''''</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>==== (PHP CLI) relative to absolute path conversion function ====</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>==== (PHP CLI) relative to absolute path conversion function ====</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>The following function converts any relative paths in a string to absolute paths. It <del style="font-weight: bold; text-decoration: none;">assumess </del>relatives paths are relative to the script.</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>The following function converts any relative paths in a string to absolute paths. It <ins style="font-weight: bold; text-decoration: none;">assumes </ins>relatives paths are relative to the script.</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>{|</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>{|</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l242">Line 242:</td>
<td colspan="2" class="diff-lineno">Line 242:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>$str = trim($str); // Remove L&R spaces</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>$str = trim($str); // Remove L&R spaces</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>$str = preg_replace('/\s+/', ' ', $str); // Remove double spaces</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>$str = preg_replace('/\s+/', ' ', $str); // Remove double spaces</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>$str_array = explode(" ",$str); // Blow string <del style="font-weight: bold; text-decoration: none;">appart </del>at " " </div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>$str_array = explode(" ",$str); // Blow string <ins style="font-weight: bold; text-decoration: none;">apart </ins>at " " </div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>for($i = 0; $i < count($str_array); $i++) { // scan str array line by line</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>for($i = 0; $i < count($str_array); $i++) { // scan str array line by line</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l292">Line 292:</td>
<td colspan="2" class="diff-lineno">Line 292:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>//=== Array Insert =============================================================</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>//=== Array Insert =============================================================</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>function array_insert(&$array, $insert, $position = -1) { </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>function array_insert(&$array, $insert, $position = -1) { </div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> $position = ($position == -1) ? <del style="font-weight: bold; text-decoration: none;">(</del>count($array<del style="font-weight: bold; text-decoration: none;">)</del>) : $position ; </div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> $position = ($position == -1) ? count($array) : $position ; </div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> if($position != <del style="font-weight: bold; text-decoration: none;">(</del>count($array<del style="font-weight: bold; text-decoration: none;">)</del>)) { // Is it end of array </div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> if($position != count($array)) { // Is it end of array </div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> $ta = $array; // New array </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> $ta = $array; // New array </div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> for($i = $position; $i < (count($array)); $i++) { // Scan array</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> for($i = $position; $i < (count($array)); $i++) { // Scan array</div></td></tr>
</table>
Newacct
https://wiki.uniformserver.com/index.php?title=PHP_WinBinder_4:_Coding&diff=4236&oldid=prev
Ric: New page: {{Nav PHP WinBinder 4}} '''''WinBinder Part 4 - Coding''''' == Introduction == Our tray-menu contains unresolved details such as what elements to include in the master array and configurat...
2010-05-25T21:01:14Z
<p>New page: {{Nav PHP WinBinder 4}} '''''WinBinder Part 4 - Coding''''' == Introduction == Our tray-menu contains unresolved details such as what elements to include in the master array and configurat...</p>
<p><b>New page</b></p><div>{{Nav PHP WinBinder 4}}<br />
'''''WinBinder Part 4 - Coding'''''<br />
== Introduction ==<br />
Our tray-menu contains unresolved details such as what elements to include in the master array and configuration file.<br />
<br />
In order to start coding now is a good time to be specific, like remove the ability to have a sub-men title a future feature that probably will never be used.<br />
<br />
Retain configuration file and parameter items strictly not required a single line would suffice. However two lines makes it easier for a user to understand.<br />
<br />
In a similar vein all those redundant lines for a spacer can be removed. Also delete the item number server's no real purpose. <br />
<br />
This page provides final details required to implement our tray-menu.<br />
<br />
'''''[[#top | Top]]'''''<br />
<br />
== Tray menu configuration file ==<br />
== Basic format ==<br />
Main menu and sub-menus have this structure:<br />
{|<br />
|-valign="top"<br />
|<br />
* [block name]<br />
* Line 1[]<br />
* Line 2[]<br />
* Line 3[]<br />
* Line 4[]<br />
* Line 5[]<br />
|<br />
&nbsp;<br />
|<br />
The configuration file consists of defined blocks each block has a unique name contained in square brackets.<br />
<br />
Main menus block must start with '''''[main_menu]''''' sub-menu blocks must have a unique name enclosed in square brackets.<br />
<br />
'''''Note'':''' Names must be alphanumeric lowercase and contain no spaces for example '''sub_menu_1'''<br />
<br />
All menu entries with the exception of a spacer (single line) consist of five lines Line 1[]-Line 2[] these are arrays and must have a value or set to a empty string.<br />
<br />
A menu entry can be one of three types a '''''click-able link''''', a '''''separator''''' or a '''''sub-menu'''''. <br />
|}<br />
<br />
'''''[[#top | Top]]'''''<br />
=== A menu entry block ===<br />
Each menu entry block consists of five arrays (lines) with the following names and function:<br />
{|<br />
|-<br />
|'''item[]'''||&nbsp;|| Text displayed in menu (menu item)<br />
|-<br />
|'''action[]'''||&nbsp;|| Action functions are: Command ('''''run''''' or '''''runh'''''). Or a sub-menu ('''''sub'''''). Or a menu spacer ('''''separator''''')<br />
|-<br />
|'''file[]'''||&nbsp;|| File name if above is a command. Sub-menu name if above is a sub<br />
|-<br />
|'''parameter[]'''||&nbsp;|| Optional parameters to pass if command is the action.<br />
|-<br />
|'''icon[]'''||&nbsp;|| Left icon to display index=0 no icon displayed<br />
|}<br />
'''''Note 1 '':''' Every menu item must have a complete block of five lines.<br />
<br />
'''''Note 2 '':''' Exception to the above is a spacer which requires only a single line (action) .<br />
<br />
'''''[[#top | Top]]'''''<br />
<br />
== Configuration file example ==<br />
{|<br />
|-valign="top"<br />
|<br />
<pre><br />
; File tray_menu.ini<br />
; This is a sample configuration file<br />
; Comments start with ';', as in php.ini<br />
<br />
title = "US Menu" ; Manin application name<br />
<br />
[main_menu]<br />
<br />
item[] = "Start Apache Service" ; display menu item<br />
action[] = "run" ; run, runh, sub, separator <br />
file[] = "net" ; file name or sub-name<br />
parameter[] = "start ApacheS1" ; parameters to pass<br />
icon[] = "7" ; icon id number<br />
<br />
item[] = "Stop Apache service" ; display menu item<br />
action[] = "run " ; run, runh , sub, separator <br />
file[] = "net" ; file name or sub-name<br />
parameter[] = "stop ApacheS1" ; parameters to pass<br />
icon[] = "6" ; icon id number<br />
<br />
item[] = "Service 服务" ; display menu item<br />
action[] = "sub" ; create sub-menu <br />
file[] = "sub_1" ; name see section below <br />
parameter[] = "" ; no parameter<br />
icon[] = "0" ; no icon<br />
<br />
;-------------------------<br />
action[] = "separator" ; only a action name required<br />
;------------------------- <br />
<br />
item[] = "Exit 出口 " ; Display menu item text<br />
action[] = "Exit" ; Do not change<br />
file[] = "" ; no file<br />
parameter[] = "" ; and no parameter<br />
icon[] = "4" ; Icon cross <br />
<br />
item[] = "Minimize 最小化" ; Display menu item text<br />
action[] = "Minimize" ; Do not change<br />
file[] = "" ; no file<br />
parameter[] = "" ; and no parameter<br />
icon[] = "3" ; Icon down arrow <br />
<br />
;=== Sub-Menus =====================================================<br />
[sub_1]<br />
<br />
item[] = "启动 Apache服务" ; display menu item<br />
action[] = "run" ; run, runh, sub, separator <br />
file[] = "net" ; file name or sub-name<br />
parameter[] = "start ApacheS1" ; parameters to pass<br />
icon[] = "9" ; icon id number<br />
<br />
item[] = "停止 Apache服务" ; display menu item<br />
action[] = "run " ; run, runh, sub, separator <br />
file[] = "net" ; file name or sub-name<br />
parameter[] = "stop ApacheS1" ; parameters to pass<br />
icon[] = "8" ; icon id number<br />
</pre><br />
|<br />
&nbsp;<br />
|<br />
<br><br />
'''''Example pop-up tray menu'':'''<br />
<br />
The example configuration file will produce the following tray menu:<br />
[[Image:Configuration_file_1.gif]]<br />
<br />
All menu elements are shown:<br />
<br />
'''''Main Menu'':'''<br />
<br />
* Two click-able menu items<br />
* A sub-menu hover link<br />
* A seperator<br />
* Exit link<br />
* Minimize link<br />
<br />
'''''Sub-menu'':'''<br />
<br />
* Two click-able menu items<br />
<br />
|} <br />
'''''[[#top | Top]]'''''<br />
<br />
== Master array elements ==<br />
{|<br />
|-valign="top"<br />
|<br />
<pre><br />
$main[$i][0] // Configuration section name<br />
$main[$i][1] // Configuration menu item text<br />
$main[$i][2] // Configuration menu item action<br />
$main[$i][3] // Configuration menu file path<br />
$main[$i][4] // Configuration menu parameter to pass<br />
$main[$i][5] // Configuration menu icon 0 = no icon<br />
$main[$i][6] // y-top where an item or rollover starts<br />
$main[$i][7] // y-rollover-end where a rollover ends<br />
$main[$i][8] // y-bottom where an item ends and the next one starts<br />
$main[$i][9] // x-icon1 where left icon starts<br />
$main[$i][10] // x-rollover-start where a rollover starts<br />
$main[$i][11] // x-rollover-end where rollover ends<br />
$main[$i][12] // x-rollover-width width of rollover <br />
$main[$i][13] // x-rollover-height height of a rollover<br />
$main[$i][14] // x-text where text starts<br />
$main[$i][15] // Maximum string for either main menu or sub-menu <br />
$main[$i][16] // x-icon2 where right icon starts<br />
$main[$i][17] // x-icon2 end where right icon ends<br />
</pre><br />
|<br />
<br><br />
Item number and other elements removed.<br />
<br />
Produces a relatively small array.<br />
|}<br />
<br />
<br />
'''''[[#top | Top]]'''''<br />
<br />
== Command core function ==<br />
The following example code could be used to process our two commands '''''run''''' and '''''runh''''' <br />
<br />
I say could because all paths must be specified as absolute paths.<br />
<pre><br />
//=== PROCESS COMMAND =========================================================<br />
function process_command($command_array){<br />
// There are only two types of command to process run and runh (run hidden)<br />
<br />
if($command_array[0] == "run"){ // Standard command to run<br />
$cmd1 = "start "; // Start of command<br />
$cmd2 = $command_array[1]; // Path string including file name<br />
$cmd3 = " "; // Assume user missed the space<br />
$cmd4 = $command_array[2]; // parameters to include<br />
<br />
$cmd5 = $cmd1.$cmd2.$cmd3.$cmd4; // build command string<br />
pclose(popen($cmd5,'r')); // Run a detatched process<br />
}<br />
<br />
if($command_array[0] == "runh"){ // Standard command run hidden<br />
$cmd1 = "start uniserv.exe \""; // Start of command including utility<br />
$cmd2 = $command_array[1]; // Path string including file name<br />
$cmd3 = " "; // Assume user missed the space<br />
$cmd4 = $command_array[2]; // parameters to include<br />
$cmd5 = "\" "; // Add final quote<br />
<br />
$cmd6 = $cmd1.$cmd2.$cmd3.$cmd4.$cmd5; // build command string<br />
pclose(popen($cmd6,'r')); // Run a detatched process<br />
}<br />
}<br />
//===================================================== END PROCESS COMMAND ===<br />
</pre><br />
=== Problem Paths ===<br />
Absolute paths are incompatible with portability in particular USB drives. At best only the drive letter will change worst-case scenario a user moves the application (uniform server) to a different folder.<br />
<br />
For Uniform Server this is not an issue because it dynamically rewrites all paths and if integrated into the architecture this tray-menu would be no exception.<br />
<br />
However our tray-menu is intended to be general purpose. To address the above issue a user can specify relative paths however not all relative paths work the OS insists on absolute paths for some applications.<br />
<br />
Solution; prior to command processing replace all relative paths with absolute ones.<br />
<br />
'''''[[#top | Top]]'''''<br />
==== (PHP CLI) relative to absolute path conversion function ====<br />
The following function converts any relative paths in a string to absolute paths. It assumess relatives paths are relative to the script.<br />
<br />
{|<br />
|-<br />
|<br />
<pre><br />
//=== CONVERT RELATIVE TO ABSOLUTE PATHS ====================================== <br />
// Convers any relative paths found in a string to absolute paths<br />
// Assumes paths are relative to this file<br />
<br />
function relative_to_absolute_paths($str){<br />
$path_array = explode("\\",dirname(__FILE__)); // Blow path appart at "\"<br />
// Path is this file<br />
<br />
$str = trim($str); // Remove L&R spaces<br />
$str = preg_replace('/\s+/', ' ', $str); // Remove double spaces<br />
$str_array = explode(" ",$str); // Blow string appart at " " <br />
<br />
for($i = 0; $i < count($str_array); $i++) { // scan str array line by line<br />
if( strchr($str_array[$i],"../")){ // Does string contain ../<br />
$str_count = substr_count($str_array[$i],"../"); // Yes: How many<br />
$str_array[$i] = substr_replace($str_array[$i],"",0,$str_count*3); // Remove<br />
<br />
$new_path =""; // reset new path <br />
for($i2 = 0; $i2 < count($path_array)-$str_count; $i2++) { // scan original path <br />
$new_path = $new_path.$path_array[$i2]."/"; // build new path<br />
}<br />
$str_array[$i] = $new_path.$str_array[$i]; // Replace relative path<br />
} // with absolute path<br />
}<br />
<br />
for($i = 0; $i < count($str_array); $i++) { // scan str array line by line<br />
$new_str = $new_str. $str_array[$i]." "; // Rebuild new string<br />
}<br />
return $new_str; // Return modified string<br />
}<br />
//================================== END CONVERT RELATIVE TO ABSOLUTE PATHS ===<br />
</pre><br />
|}<br />
<br />
To the process_command() function add the two lines as shown (Convert paths):<br />
<pre><br />
//=== PROCESS COMMAND =========================================================<br />
function process_command($command_array){<br />
// There are only two types of command to process run and runh (run hidden)<br />
<br />
//== Convert paths<br />
$command_array[1] = relative_to_absolute_paths($command_array[1]);<br />
$command_array[2] = relative_to_absolute_paths($command_array[2]);<br />
</pre><br />
<br />
'''''[[#top | Top]]'''''<br />
<br />
== Array imbalance problem ==<br />
Having a single array for a spacer introduces an imbalance of arrays. However since the configuration array is processed sequentially we know where this imbalance occurs hence we can rebalance the arrays.<br />
<br />
Although it adds additional code, when configuring a menu configuration file makes life easier for an end user.<br />
<br />
These arrays are sequentially ordered hence this function fits the bill:<br />
=== Array insert function ===<br />
{|<br />
|-<br />
|<br />
<pre><br />
//=== Array Insert =============================================================<br />
function array_insert(&$array, $insert, $position = -1) { <br />
$position = ($position == -1) ? (count($array)) : $position ; <br />
if($position != (count($array))) { // Is it end of array <br />
$ta = $array; // New array <br />
for($i = $position; $i < (count($array)); $i++) { // Scan array<br />
if(!isset($array[$i])) { // Check there are no holes in array<br />
die(print_r($array, 1)."\r\nInvalid array: All keys must be numerical and in sequence."); <br />
} <br />
$tmp[$i+1] = $array[$i]; // Build part of array <br />
unset($ta[$i]); // Kill element <br />
} <br />
$ta[$position] = $insert; // Insert value <br />
$array = $ta + $tmp; // Build complete array <br />
//print_r($array); <br />
}<br />
else { // Yes: End of array <br />
$array[$position] = $insert; // just insert value<br />
} <br />
<br />
ksort($array); // Ensure keys are ordered <br />
return true; <br />
} <br />
//========================================================= END Array Insert ===<br />
</pre><br />
|}<br />
<br />
'''''[[#top | Top]]'''''<br />
<br />
== Summary ==<br />
Well in all honesty this page said coding hence filled it with some luddite code.<br />
If you are into object orientated programming along with hacking down to “c” level make WinBinder forum your first port of call. They have excellent material.<br />
<br />
Hey! They don’t like luddites! However they do respect that we exist. Yep! Supposed to be a joke, point is, WinBinder caters for both traditional and object oriented programming styles. Style is a personal choice there are no restriction imposed by WinBinder.<br />
<br />
'''''Tutorial'':'''<br />
<br />
That completes this tutorial. <br />
<br />
Was the objective meet?<br />
<br />
"Objective is to produce a tray menu with format and features similar to Unitray. This ideally would be a replacement for Unitray. Secondary objective is to explore the capabilities of WinBinder."<br />
<br />
Secondary objective certainly was and best part of the prime objective. However the menu lacks a right button pop-up menu. Right menu runs the server as a service and is easily catered for by adding items to the left menu.<br />
<br />
Currently the menu is generic (see next page for details) and is usable for other applications.<br />
<br />
For it to be a UniTray replacement a few Uniform Server specific features require adding. That said if you do not require multi-server support you could use it as is. <br />
<br />
[[PHP WinBinder 4: Final Tray Menu | '''Next page''']] looks the tray-menu demo included with the download.<br />
<br />
<br />
'''''[[#top | Top]]'''''<br />
<br />
----<br />
<br />
[[Category: Tutorials]]<br />
[[Category: How To]]<br />
[[Category: Uniform Server 5.0-Nano]]</div>
Ric