| 1: | <?php |
| 2: | namespace Sphp\tools { |
| 3: | /** |
| 4: | * Description of ConsoleApp |
| 5: | * |
| 6: | * @author Sartaj Singh |
| 7: | */ |
| 8: | class ConsoleApp { |
| 9: | /** @var \Sphp\kit\Page $page */ |
| 10: | public $page = ""; |
| 11: | /** @var string $apppath application folder path */ |
| 12: | public $apppath = ""; |
| 13: | /** @var string $phppath res folder path */ |
| 14: | public $phppath = ""; |
| 15: | /** @var string $respath res browser url */ |
| 16: | public $respath = ""; |
| 17: | /** @var \Sphp\kit\JSServer $JSServer */ |
| 18: | public $JSServer = null; |
| 19: | /** @var \Sphp\core\Request $Client */ |
| 20: | public $Client = null; |
| 21: | /** @var \MySQL $dbEngine */ |
| 22: | public $dbEngine = null; |
| 23: | /** @var \Sphp\core\DebugProfiler $debug */ |
| 24: | public $debug = null; |
| 25: | /** @var \Sphp\core\SphpApi $sphp_api */ |
| 26: | public $sphp_api = null; |
| 27: | /** @var string $sphp_api */ |
| 28: | public $scriptname = ""; |
| 29: | /** @var array $argv */ |
| 30: | public $argv = array(); |
| 31: | /** @var boolean $isRunning */ |
| 32: | protected $isRunning = false; |
| 33: | /** @var array $wait_interval default value 1000000 */ |
| 34: | public $wait_interval = 1000000; |
| 35: | /** |
| 36: | * Set Password for Sudo command |
| 37: | * @param string $pas password |
| 38: | */ |
| 39: | public function setPassword($pas) {} |
| 40: | /** |
| 41: | * enable stdout print |
| 42: | */ |
| 43: | public function enableStdout() {} |
| 44: | /** |
| 45: | * Disbale stdout print |
| 46: | */ |
| 47: | public function disableStdout() {} |
| 48: | /** |
| 49: | * Create Command Que |
| 50: | * @param array &$ar1 pass by reference to fill command |
| 51: | * @param string $cmd shell command |
| 52: | * @param string $msg Message to display command help |
| 53: | * @param boolean $sudo true = sudo command |
| 54: | * @param boolean $critical true = stop execution if error in this command |
| 55: | * @param function $callbackerr callback if error in this command |
| 56: | */ |
| 57: | public function createQue(&$ar1, $cmd, $msg = "", $sudo = false, $critical = false, $callbackerr = null) {} |
| 58: | /** |
| 59: | * Call Command and wait to finish |
| 60: | * @param string $cmd shell command |
| 61: | * @param string &$str1 output text from command |
| 62: | * @param string $msg help text with command |
| 63: | * @param boolean $sudo true = run as sudo |
| 64: | * @return boolean true = run succesfull |
| 65: | */ |
| 66: | public function callSync($cmd, &$str1, $msg = "", $sudo = false) {} |
| 67: | /** |
| 68: | * Call Command and process callback without wait to end. |
| 69: | * @param string $cmd shell command |
| 70: | * @param string $msg help text with command |
| 71: | * @param function $fun2 callback on data |
| 72: | * @param function $funer2 callback on error |
| 73: | * @param function $fun_ready2 callback process ready |
| 74: | * @return boolean true = run successful |
| 75: | */ |
| 76: | public function callf($cmd, $msg = "", $fun2 = null, $funer2 = null, $fun_ready2 = null) {} |
| 77: | /** |
| 78: | * Call Shell Command With Sudo without wait for end. |
| 79: | * @param string $cmd command |
| 80: | * @param string $msg command help text |
| 81: | * @param function $fun2 callback on data |
| 82: | * @param function $funer2 callback on error |
| 83: | * @param function $fun_ready2 callback on process ready |
| 84: | * @return boolean true = run successful |
| 85: | */ |
| 86: | public function callSudo($cmd, $msg = "", $fun2 = null, $funer2 = null, $fun_ready2 = null) {} |
| 87: | public function calla($cmd, $msg = "", $fun = null, $funer = null, $callback_ready = null, $statuscall = null) {} |
| 88: | /** |
| 89: | * Print Error Message on terminal |
| 90: | * @param string $str1 error msg |
| 91: | */ |
| 92: | public function printer($str1) {} |
| 93: | /** |
| 94: | * Print Message on terminal |
| 95: | * @param string $str1 error msg |
| 96: | */ |
| 97: | public function println($str1) {} |
| 98: | public function processCmdQue(&$ar1) {} |
| 99: | public function processIAQue(&$ar1, $cmd, $msg1 = '', $sudo = false, $fune = null) {} |
| 100: | /** |
| 101: | * print error on console or send to browser |
| 102: | * @param string $msg |
| 103: | * @param string $type 'i' mean info other mean error |
| 104: | */ |
| 105: | public function sendMsg($msg, $type = 'i') {} |
| 106: | public function execShellAsync($cmd, $callback, $funer, $callback_ready = null, $cwd = "", $env = null, $options = null) {} |
| 107: | /** |
| 108: | * Remove Extra Spaces from text |
| 109: | * @param string $v1 data |
| 110: | * @return string |
| 111: | */ |
| 112: | public function removeExtraSpaces($v1) {} |
| 113: | /** |
| 114: | * Register TempFile with app |
| 115: | * @param \Sphp\tools\TempFile $tempobj |
| 116: | */ |
| 117: | public function registerTemp($tempobj) {} |
| 118: | /** |
| 119: | * Advance Function |
| 120: | * @ignore |
| 121: | */ |
| 122: | public function triggerAppEvent() {} |
| 123: | /** |
| 124: | * Advance Function |
| 125: | * @ignore |
| 126: | */ |
| 127: | public function setup($tempobj) {} |
| 128: | /** |
| 129: | * Advance Function |
| 130: | * @ignore |
| 131: | */ |
| 132: | public function process($tempobj) {} |
| 133: | /** |
| 134: | * Advance Function |
| 135: | * @ignore |
| 136: | */ |
| 137: | public function processEvent() {} |
| 138: | /** |
| 139: | * Advance Function |
| 140: | * @ignore |
| 141: | */ |
| 142: | public function render() {} |
| 143: | /** |
| 144: | * get controller event name trigger by browser |
| 145: | * @return string |
| 146: | */ |
| 147: | public function getEvent() {} |
| 148: | /** |
| 149: | * get controller event parameter post by browser |
| 150: | * @return string |
| 151: | */ |
| 152: | public function getEventParameter() {} |
| 153: | /** |
| 154: | * override this event handler in your application to handle it. |
| 155: | * trigger when application start |
| 156: | */ |
| 157: | public function onstart() {} |
| 158: | /** |
| 159: | * override this event handler in your application to handle it. |
| 160: | * trigger when application finish process of default TempFile |
| 161: | */ |
| 162: | public function onready() {} |
| 163: | /** |
| 164: | * override this event handler in your application to handle it. |
| 165: | * trigger when application initialize TempFile Object |
| 166: | */ |
| 167: | public function ontempinit($tempobj) {} |
| 168: | /** |
| 169: | * override this event handler in your application to handle it. |
| 170: | * trigger when application start process on TempFile Object |
| 171: | */ |
| 172: | public function ontempprocess($tempobj) {} |
| 173: | /** Inbuilt Event |
| 174: | * override this event handler in your application to handle it. |
| 175: | * trigger when browser get (url=index-delete.html) |
| 176: | * where index is controller of application and application path is in reg.php file |
| 177: | */ |
| 178: | public function page_delete() {} |
| 179: | /** Inbuilt Event |
| 180: | * override this event handler in your application to handle it. |
| 181: | * trigger when browser get (url=index-view-19.html) |
| 182: | * where index is controller of application and application path is in reg.php file |
| 183: | * view = event name |
| 184: | * 19 = recid of database table or any other value. |
| 185: | */ |
| 186: | public function page_view() {} |
| 187: | /** Inbuilt Event |
| 188: | * override this event handler in your application to handle it. |
| 189: | * trigger when browser post form (url=index.html) |
| 190: | * where index is controller of application and application path is in reg.php file |
| 191: | */ |
| 192: | public function page_submit() {} |
| 193: | /** Inbuilt Event |
| 194: | * override this event handler in your application to handle it. |
| 195: | * trigger when browser post form (url=index.html) as new form |
| 196: | * where index is controller of application and application path is in reg.php file |
| 197: | */ |
| 198: | public function page_insert() {} |
| 199: | /** Inbuilt Event |
| 200: | * override this event handler in your application to handle it. |
| 201: | * trigger when browser post form (url=index.html) as filled form |
| 202: | * from database with view_data function |
| 203: | * where index is controller of application and application path is in reg.php file |
| 204: | */ |
| 205: | public function page_update() {} |
| 206: | /** Inbuilt Event |
| 207: | * override this event handler in your application to handle it. |
| 208: | * trigger when browser get (url=index.html) first time |
| 209: | * where index is controller of application and application path is in reg.php file |
| 210: | */ |
| 211: | public function page_new() {} |
| 212: | /** Inbuilt Event |
| 213: | * override this event handler in your application to handle it. |
| 214: | * trigger when application run after ready event and before trigger any event handler |
| 215: | */ |
| 216: | public function onrun() {} |
| 217: | /** Inbuilt Event |
| 218: | * override this event handler in your application to handle it. |
| 219: | * trigger when application render after run TempFile but before start master |
| 220: | * file process. You can't manage TempFile output here but you can replace TempFile |
| 221: | * output in SphpBase::$dynData or change master file or add front place for master filepath |
| 222: | */ |
| 223: | public function onrender() {} |
| 224: | /** |
| 225: | * Stop exit Automatically after end of processing. It turn on wait event time loop. |
| 226: | * For exit manually then you need to call ExitMe |
| 227: | */ |
| 228: | public function setDontExit() {} |
| 229: | /** |
| 230: | * Exit Manually |
| 231: | */ |
| 232: | public function ExitMe() {} |
| 233: | /** |
| 234: | * Handle Wait Event when application is running in manually exit mode |
| 235: | */ |
| 236: | public function onwait() {} |
| 237: | /** |
| 238: | * Set wait loop interval time |
| 239: | * @param int $microsec time in microsecond for wait loop |
| 240: | */ |
| 241: | public function setWaitInterval($microsec = 100000) {} |
| 242: | /** |
| 243: | * Advance Function |
| 244: | * @ignore |
| 245: | */ |
| 246: | public function run() {} |
| 247: | /** |
| 248: | * Set which user can access this application. Default user is GUEST. |
| 249: | * You can set session variable in login app |
| 250: | * SphpBase::sphp_request()->session('logType','ADMIN'); |
| 251: | * If user is not login with specific type then application exit and |
| 252: | * redirect according to the getWelcome function in comp.php |
| 253: | * @param string $authenticates <p> |
| 254: | * comma separated list of string. Example:- getAuthenticate("GUEST,ADMIN") or getAuthenticate("ADNIN") |
| 255: | * </p> |
| 256: | */ |
| 257: | public function getAuthenticate($authenticates) {} |
| 258: | /** |
| 259: | * Set default table of Database to Sphp\Page object and this application. |
| 260: | * This information is important for controls and other database users objects. |
| 261: | * @param string $dbtable |
| 262: | */ |
| 263: | public function setTableName($dbtable) {} |
| 264: | /** |
| 265: | * get default database table assigned to application |
| 266: | * @return string |
| 267: | */ |
| 268: | public function getTableName() {} |
| 269: | /** |
| 270: | * Write on Console |
| 271: | * @param string $param |
| 272: | */ |
| 273: | public function consoleWrite($param) {} |
| 274: | /** |
| 275: | * Write on Console with end line |
| 276: | * @param string $param |
| 277: | */ |
| 278: | public function consoleWriteln($param) {} |
| 279: | /** |
| 280: | * Read a line from Console with message print on console |
| 281: | * @param string $msg message print on console |
| 282: | */ |
| 283: | public function consoleReadln($msg) {} |
| 284: | /** |
| 285: | * Write error on console |
| 286: | * @param string $err |
| 287: | */ |
| 288: | public function consoleError($err) {} |
| 289: | /** |
| 290: | * Read command line argument |
| 291: | * $v = consoleReadArgument('--dest') |
| 292: | * @param string $argkey key like --ctrl |
| 293: | * @return string |
| 294: | */ |
| 295: | public function consoleReadArgument($argkey) {} |
| 296: | /** |
| 297: | * Execute shell command and print output directly |
| 298: | * @param string $command |
| 299: | * @return array return from command exit code |
| 300: | */ |
| 301: | public function execute($command) {} |
| 302: | /** |
| 303: | * Execute Shell command With output |
| 304: | * @param type $cmd Command |
| 305: | * @param string &$out Reference var to fill output text |
| 306: | * @return boolean true if execute succesfully |
| 307: | */ |
| 308: | public function execShell($cmd, &$out) {} |
| 309: | /** |
| 310: | * Convert argv to string |
| 311: | * @return string |
| 312: | */ |
| 313: | public function argvToArgs() {} |
| 314: | /** |
| 315: | * Only work on Windows, get COM object |
| 316: | * @return \COM |
| 317: | */ |
| 318: | public function getWScript() {} |
| 319: | public function runWScript($strCommand, $intWindowStyle = 3, $bWaitOnReturn = true) {} |
| 320: | /** |
| 321: | * Execute shell command in Background |
| 322: | * @param string $cmd |
| 323: | */ |
| 324: | public function execInBackground($cmd) {} |
| 325: | /** |
| 326: | * Exit App Forcefully, Not safe |
| 327: | */ |
| 328: | public function exitApp() {} |
| 329: | } |
| 330: | } |
| 331: |