<?
// command_wml.php
//
// Copyright, Exolution GmbH / Michael Kerrisk, Sep 2000
// http://www.exolution.com/wapsh   mailto:wapsh@exolution.de
//
// This software is Open Source licensed under the terms of the Trolltech QPL
// version 1.0.  See http://www.exolution.de/wapsh for further information.
//
// ---------------------------------------------------------------------
//
// WML specific command page code
//
// We engage in a little trickiness here: for UP phones, we split 
// the page into three cards (output, input, menu) and provide 
// links to navigate between the pages.  For the Nokia phone
// everything is displayed on one large page, and the navigation is
// done via the softkey menu (accept actions)
//
 
    // Display shell output, along with scrolling buttons and link to 
    // scroll/search page

    if ($outputBufLen > 0) {
        echo '<p>';
	
    	//
	// Display next screen of output 
	//
        echo newline2break(escBrowserSpecialChars($printableNextBlock)); 
        echo sBreak() . '***' . 
    		    ($outputBufLen - $outputPos - $lastOutputBlockSize) .
            	    " more chars";
	
	//
	// Provide some links for scrolling, if needed
	//
        if ($outputPos + $lastOutputBlockSize < $outputBufLen) {
            echo sBreak();

	    wmlSubmitAnchor("Next screen", "command.php", "post", 
	    	    $commFields . '<postfield name="scrForm" value="y"/>' .
	    	    '<postfield name="scrNext" value="y"/>');
        }

        if ($outputPos + $lastOutputBlockSize + $outputWindowSize < 
	    	    $outputBufLen) {
            echo sBreak();

	    wmlSubmitAnchor("Bottom screen", "command.php", "post", 
	    	    $commFields . '<postfield name="scrForm" value="y"/>' .
	    	    '<postfield name="scrBot" value="y"/>');
        }
    
        echo '</p>';
        if ($outputBufLen > 0) {
            wmlSoftkeyItem("doScr", "Scroll/search...", "scroll_wml.php", 
		    "post", $commFields);
        } // if
	

	if (isUpPhone()) {
	    echo '<p>';
	    echo '<anchor>To ' . SYSTEM_NAME . 
			' input<go href="#input"/></anchor>';
	    echo '</p>';
	    echo '<p>';
	    echo '<anchor>To ' . SYSTEM_NAME . 
			' menu<go href="#menu"/></anchor>';
	    echo '</p>';
	    echo '</card>';
	    echo '<card title="' . SYSTEM_NAME . ' input" id="input">';
	} // if
    } // if 


    
    if ($setOptions & OPT_ALLOWSHELLCMD) {
	echo '<p>';    
	echo 'Shell input';    
	//echo '<br/>';    
	echo '<input type="text" name="fShCmd" format="*M" size="20" 
	    	maxlength="100"/>';
	//echo '<br/>';
	echo 'Newline? ';
	echo wmlYesNoSelect("fAddNl", "y", "Newline?");
	
        if ($setOptions & OPT_ALLOWSILENT) {  
	    //echo '<br/>';
	    echo '&gt; null? ';
	    echo wmlYesNoSelect("fSilent", "n", "Null output?");
	}

	//echo '<br/>';    

	wmlSubmitAnchor("Send input", "command.php", "post", 
	        $shCommFields .  '<postfield name="sendCmd" value="y"/>' . 
		'<postfield name="shCmd" value="$(fShCmd)"/>' . 
		'<postfield name="addNl" value="$(fAddNl)"/>' . 
		'<postfield name="silent" value="$(fSilent)"/>');
	    
        echo '</p>';    
    }

    if (isUpPhone()) {
	echo '<p>';
	echo '<anchor>To ' . SYSTEM_NAME . 
	    	' output<go href="#main"/></anchor>';
	echo '</p>';
	echo '<p>';
	echo '<anchor>To ' . SYSTEM_NAME . 
	    	' menu<go href="#menu"/></anchor>';
	echo '</p>';
	echo '</card>';
	echo '<card title="' . SYSTEM_NAME . 
		' menu" newcontext="true" id="menu">';
	if (isUpPhone())
	    echo '<p>' . SYSTEM_NAME . ' menu</p>';
    } // if 
	    
    if (($setOptions & OPT_DISPLAYMENU) && $numSc > 0) {
        wmlSoftkeyItem("doShCut", "Shortcuts...", "shortcuts_wml.php", "post", 
    	    $commFields);
    }

    if (($setOptions & OPT_ALLOWCONTROLCHARS) != 0) {

/* Chopped out because of limited phone memory
        wmlSoftkeyItem("doInt", "Interrupt (^C)", "command.php", "post", 
    	    $shCommFields .  '<postfield name="intChar" value="y"/>');
*/
        wmlSoftkeyItem("doCt", "Control chars...", "controls_wml.php", "post", 
    	    $commFields);
	
    } // if

    if ($cmdNum >= 1 && ($setOptions & OPT_HISTORY)) {
/* Chopped out because of limited phone memory
        wmlSoftkeyItem("doRP", "Repeat previous", "command.php", "post", 
    	    $shCommFields . '<postfield name="repPrev" value="y"/>');
*/ 
        wmlSoftkeyItem("doHist", "History (" . $cmdNum . ")...", 
		"history_wml.php", "post", $shCommFields);
    } 
    wmlSoftkeyItem("doCO", "Check output", "command.php", "post", 
    	    $shCommFields . '<postfield name="chkOut" value="y"/>');

    wmlSoftkeyItem("doLo", "Logout", "command.php", "post", 
    	    $shCommFields . '<postfield name="logout" value="y"/>');
	
    if (isUpPhone()) {
	echo '<p>';
	echo '<anchor>To ' . SYSTEM_NAME . 
	    	' output<go href="#main"/></anchor>';
	echo '</p>';
	echo '<p>';
	echo '<anchor>To ' . SYSTEM_NAME . 
	    	' input<go href="#input"/></anchor>';
	echo '</p>';
    } // if 
	    
?>
