PageRenderTime 47ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/include/AastraIPPhoneInputScreen.class.php

https://bitbucket.org/gpanula/panicbutton
PHP | 362 lines | 161 code | 47 blank | 154 comment | 35 complexity | 95ce6ac71eb20ed1e7c241c5ab09bc12 MD5 | raw file
  1. <?php
  2. ########################################################################################################
  3. # Aastra XML API Classes - AastraIPPhoneInputScreen
  4. # Copyright Aastra Telecom 2005-2010
  5. #
  6. # AastraIPPhoneInputScreen object.
  7. #
  8. # Public methods
  9. #
  10. # Inherited from AastraIPPhone
  11. # setTitle(Title) to setup the title of an object (optional)
  12. # @title string
  13. # setTitleWrap() to set the title to be wrapped on 2 lines (optional)
  14. # setCancelAction(uri) to set the cancel parameter with the URI to be called on Cancel (optional)
  15. # @uri string
  16. # setDestroyOnExit() to set DestroyonExit parameter to 'yes', 'no' by default (optional)
  17. # setBeep() to enable a notification beep with the object (optional)
  18. # setLockIn() to set the Lock-in tag to 'yes' (optional)
  19. # setLockInCall() to set the Lock-in tag to 'call' (optional)
  20. # setAllowAnswer() to set the allowAnswer tag to 'yes' (optional only for non softkey phones)
  21. # setAllowDrop() to set the allowDrop tag to 'yes' (optional only for non softkey phones)
  22. # setAllowXfer() to set the allowXfer tag to 'yes' (optional only for non softkey phones)
  23. # setAllowConf() to set the allowConf tag to 'yes' (optional only for non softkey phones)
  24. # setTimeout(timeout) to define a specific timeout for the XML object (optional)
  25. # @timeout integer (seconds)
  26. # addSoftkey(index,label,uri,icon_index) to add custom soktkeys to the object (optional)
  27. # @index integer, softkey number
  28. # @label string
  29. # @uri string
  30. # @icon_index integer, icon number
  31. # setRefresh(timeout,URL) to add Refresh parameters to the object (optional)
  32. # @timeout integer (seconds)
  33. # @URL string
  34. # setEncodingUTF8() to change encoding from default ISO-8859-1 to UTF-8 (optional)
  35. # addIcon(index,icon) to add custom icons to the object (optional)
  36. # @index integer, icon index
  37. # @icon string, icon name or definition
  38. # generate() to return the generated XML for the object
  39. # output(flush) to display the object
  40. # @flush boolean optional, output buffer to be flushed out or not.
  41. #
  42. # Specific to the object - Single Input
  43. # setURL(url) to set the URL to called after the input
  44. # @url string
  45. # setType(type) to set type of input, 'string' by default
  46. # @type enum ('IP', 'string', 'number', 'dateUS'...)
  47. # setDefault(default) to set default value for the input (optional)
  48. # @default string
  49. # setParameter(param) to set the parameter name to be parsed after the input
  50. # @param string
  51. # setInputLanguage(language) to set the language of the input (optional)
  52. # @language enum ("English", "French"....)
  53. # setPassword() to set the Password parameter to 'yes', 'no' by default (optional)
  54. # setNotEditable() to set the editable parameter to 'no', 'yes' by default (optional)
  55. # setEditable() is now replaced by setNotEditable but kept for compatibility reasons (optional)
  56. # setPrompt(prompt) to set the prompt to be displayed for the input.
  57. # @prompt string
  58. #
  59. # Specific to the object - Multiple Inputs
  60. # setURL(url) to set the URL to called after the input
  61. # @url string
  62. # setType(type) to set the default type of input 'string' by default
  63. # @type enum ('IP', 'string', 'number', 'dateUS'...)
  64. # setDefault(default) to set default default value for the input (optional)
  65. # @default string
  66. # setParameter(param) to set the default parameter name to be parsed after the input
  67. # @param string
  68. # setPassword() to set the default Password parameter to 'yes', 'no' by default (optional)
  69. # setNotEditable() to set the default editable parameter to 'no', 'yes' by default (optional)
  70. # setEditable() is now replaced by setNotEditable but kept for compatibility reasons (optional)
  71. # setPrompt(prompt) to set the default prompt to be displayed for the input.
  72. # @prompt string
  73. # setDefaultIndex(index) to define the field index the object will use to start (optional)
  74. # @index integer, optional, default is 1
  75. # setDisplayMode(display) to define the aspect of the display, normal/condensed (optional)
  76. # @display enum ("normal, "condensed"), default is "normal".
  77. # setInputLanguage(language) to set the language of the input (optional)
  78. # @language enum ("English", "French"....)
  79. # addField(type) to add an input field and setting its type
  80. # @type (IP, string, number, dateUS, timeUS,dateInt, timeInt or empty) if the type is an empty string then the type is inherited from the main object.
  81. # setFieldPassword(password) to set the password mode for the input field, overrides the value set by setPassword for the field
  82. # @password enum ("yes", "no")
  83. # setFieldEditable(editable) to set the input field editable mode ('yes', no'), overrides the value set by setEditable or setNotEditable for the field
  84. # @editable enum ("yes", "no")
  85. # setFieldParameter(parameter) to set the parameter name to be parsed after the global input, overrides the value set by setParameter for the field
  86. # @parameter string
  87. # setFieldPrompt(prompt)to set the prompt to be displayed for the input field, overrides the value set by setPrompt for the field
  88. # @prompt string
  89. # setFieldSelection(selection) to set the Selection tag for the field
  90. # @selection string
  91. # setFieldDefault(default) to set default value for the input field, overrides the value set by setDefault for the field
  92. # @default string
  93. # addFieldSoftkey(index,label,uri,icon) to add custom softkeys to the input field, overrides the softkeys set by addSoftkey.
  94. # @index integer, softkey number
  95. # @label string
  96. # @uri string
  97. # @icon integer, icon number
  98. #
  99. # Example 1 - Single Input
  100. # require_once('AastraIPPhoneInputScreen.class.php');
  101. # $input = new AastraIPPhoneInputScreen();
  102. # $input->setTitle('Title');
  103. # $input->setPrompt('Enter your password');
  104. # $input->setParameter('param');
  105. # $input->setType('string');
  106. # $input->setURL('http://myserver.com/script.php');
  107. # $input->setPassword();
  108. # $input->setDestroyOnExit();
  109. # $input->setDefault('Default');
  110. # $input->output();
  111. #
  112. # Example 2 - Multiple Inputs
  113. # require_once('AastraIPPhoneInputScreen.class.php');
  114. # $input = new AastraIPPhoneInputScreen();
  115. # $input->setTitle('Example 2');
  116. # $input->setDisplayMode('condensed');
  117. # $input->setURL('http://myserver.com/script.php');
  118. # $input->setDestroyOnExit();
  119. # $input->addSoftkey('5', 'Done', 'SoftKey:Submit');
  120. # $input->addField('string');
  121. # $input->setFieldPrompt('Username:');
  122. # $input->setFieldParameter('user');
  123. # $input->addFieldSoftkey('3', 'ABC', 'SoftKey:ChangeMode');
  124. # $input->addField('number');
  125. # $input->setFieldPassword('yes');
  126. # $input->setFieldPrompt('Pass:');
  127. # $input->setFieldParameter('passwd');
  128. # $input->output();
  129. #
  130. ########################################################################################################
  131. require_once('AastraIPPhone.class.php');
  132. require_once('AastraIPPhoneInputScreenEntry.class.php');
  133. require_once('AastraIPPhoneSoftkeyEntry.class.php');
  134. class AastraIPPhoneInputScreen extends AastraIPPhone {
  135. var $_url;
  136. var $_type='string';
  137. var $_parameter;
  138. var $_prompt;
  139. var $_editable='';
  140. var $_default='';
  141. var $_password='';
  142. var $_defaultindex='';
  143. var $_displaymode='';
  144. var $_inputlanguage='';
  145. function setURL($url)
  146. {
  147. $this->_url=$url;
  148. }
  149. function setType($type)
  150. {
  151. $this->_type=$type;
  152. }
  153. function setEditable()
  154. {
  155. $this->_editable='no';
  156. }
  157. function setNotEditable()
  158. {
  159. $this->_editable='no';
  160. }
  161. function setDefault($default)
  162. {
  163. $this->_default=$default;
  164. }
  165. function setParameter($parameter)
  166. {
  167. $this->_parameter=$parameter;
  168. }
  169. function setPassword()
  170. {
  171. $this->_password='yes';
  172. }
  173. function setPrompt($prompt)
  174. {
  175. $this->_prompt=$prompt;
  176. }
  177. function setDefaultIndex($index)
  178. {
  179. $this->_defaultindex=$index;
  180. }
  181. function setDisplayMode($display)
  182. {
  183. $this->_displaymode=$display;
  184. }
  185. function setInputLanguage($input)
  186. {
  187. $this->_inputlanguage=$input;
  188. }
  189. function addField($type='')
  190. {
  191. $this->_entries[] = new AastraIPPhoneInputScreenEntry($type);
  192. end($this->_entries);
  193. }
  194. function setFieldType($type)
  195. {
  196. $this->_entries[key($this->_entries)]->_type=$type;
  197. }
  198. function setFieldPassword($password='yes')
  199. {
  200. $this->_entries[key($this->_entries)]->_password=$password;
  201. }
  202. function setFieldEditable($editable='yes')
  203. {
  204. $this->_entries[key($this->_entries)]->_editable=$editable;
  205. }
  206. function setFieldParameter($parameter)
  207. {
  208. $this->_entries[key($this->_entries)]->_parameter=$parameter;
  209. }
  210. function setFieldPrompt($prompt)
  211. {
  212. $this->_entries[key($this->_entries)]->_prompt=$this->escape($prompt);
  213. }
  214. function setFieldDefault($default)
  215. {
  216. $this->_entries[key($this->_entries)]->_default=$default;
  217. }
  218. function setFieldSelection($selection)
  219. {
  220. $this->_entries[key($this->_entries)]->_selection=$selection;
  221. }
  222. function addFieldSoftkey($index, $label, $uri, $icon=NULL)
  223. {
  224. $this->_entries[key($this->_entries)]->_softkeys[] = new AastraIPPhoneSoftkeyEntry($index, $this->escape($label), $this->escape($uri), $icon);
  225. }
  226. function render()
  227. {
  228. # Beginning of root tag
  229. $out = "<AastraIPPhoneInputScreen type=\"$this->_type\"";
  230. # Password
  231. if($this->_password == 'yes') $out .= " password=\"yes\"";
  232. # DestroyOnExit
  233. if($this->_destroyOnExit == 'yes') $out .= " destroyOnExit=\"yes\"";
  234. # CancelAction
  235. if($this->_cancelAction != "")
  236. {
  237. $cancelAction = $this->escape($this->_cancelAction);
  238. $out .= " cancelAction=\"{$cancelAction}\"";
  239. }
  240. # Editable
  241. if($this->_editable=='no') $out .= " editable=\"no\"";
  242. # Beep
  243. if($this->_beep=='yes') $out .= " Beep=\"yes\"";
  244. # DefaultIndex
  245. if($this->_defaultindex!='') $out .= " defaultIndex=\"".$this->_defaultindex."\"";
  246. # InputLanguage
  247. if($this->_inputlanguage!='') $out .= " inputLanguage=\"".$this->_inputlanguage."\"";
  248. # Display Mode
  249. if($this->_displaymode!='') $out .= " displayMode=\"".$this->_displaymode."\"";
  250. # Lockin
  251. if($this->_lockin!='') $out .= " LockIn=\"{$this->_lockin}\"";
  252. # AllowAnswer
  253. if($this->_allowAnswer == 'yes') $out .= " allowAnswer=\"yes\"";
  254. # AllowDrop
  255. if($this->_allowDrop == 'yes') $out .= " allowDrop=\"yes\"";
  256. # AllowXfer
  257. if($this->_allowXfer == 'yes') $out .= " allowXfer=\"yes\"";
  258. # AllowConf
  259. if($this->_allowConf == 'yes') $out .= " allowConf=\"yes\"";
  260. # TimeOut
  261. if($this->_timeout!=0) $out .= " Timeout=\"{$this->_timeout}\"";
  262. # End of the root tag
  263. $out .= ">\n";
  264. # Title
  265. if ($this->_title!='')
  266. {
  267. $title = $this->escape($this->_title);
  268. $out .= "<Title";
  269. if ($this->_title_wrap=='yes') $out .= " wrap=\"yes\"";
  270. $out .= ">".$title."</Title>\n";
  271. }
  272. # Prompt
  273. if($this->_prompt != '')
  274. {
  275. $prompt = $this->escape($this->_prompt);
  276. $out .= "<Prompt>{$prompt}</Prompt>\n";
  277. }
  278. # URL
  279. $url = $this->escape($this->_url);
  280. $out .= "<URL>{$url}</URL>\n";
  281. # Parameter
  282. if($this->_parameter != '') $out .= "<Parameter>{$this->_parameter}</Parameter>\n";
  283. # Default
  284. $out .= "<Default>{$this->_default}</Default>\n";
  285. # Multiple input fields
  286. if (isset($this->_entries) && is_array($this->_entries))
  287. {
  288. foreach ($this->_entries as $entry) $out .= $entry->render();
  289. }
  290. # Softkeys
  291. if (isset($this->_softkeys) && is_array($this->_softkeys))
  292. {
  293. foreach ($this->_softkeys as $softkey) $out .= $softkey->render();
  294. }
  295. # Icons
  296. if (isset($this->_icons) && is_array($this->_icons))
  297. {
  298. $IconList=False;
  299. foreach ($this->_icons as $icon)
  300. {
  301. if(!$IconList)
  302. {
  303. $out .= "<IconList>\n";
  304. $IconList=True;
  305. }
  306. $out .= $icon->render();
  307. }
  308. if($IconList) $out .= "</IconList>\n";
  309. }
  310. # End tag
  311. $out .= "</AastraIPPhoneInputScreen>\n";
  312. return $out;
  313. }
  314. }
  315. ?>