Html.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. <?php
  2. /**
  3. * @file
  4. * TeamSpeak 3 PHP Framework
  5. *
  6. * $Id: Text.php 06/06/2016 22:27:13 scp@Svens-iMac $
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. * @package TeamSpeak3
  22. * @version 1.1.24
  23. * @author Sven 'ScP' Paulsen
  24. * @copyright Copyright (c) 2010 by Planet TeamSpeak. All rights reserved.
  25. */
  26. /**
  27. * @class TeamSpeak3_Viewer_Html
  28. * @brief Renders nodes used in HTML-based TeamSpeak 3 viewers.
  29. */
  30. class TeamSpeak3_Viewer_Html implements TeamSpeak3_Viewer_Interface
  31. {
  32. /**
  33. * A pre-defined pattern used to display a node in a TeamSpeak 3 viewer.
  34. *
  35. * @var string
  36. */
  37. protected $pattern = "<table id='%0' class='%1' summary='%2'><tr class='%3'><td class='%4'>%5</td><td class='%6' title='%7'>%8 %9</td><td class='%10'>%11%12</td></tr></table>\n";
  38. /**
  39. * The TeamSpeak3_Node_Abstract object which is currently processed.
  40. *
  41. * @var TeamSpeak3_Node_Abstract
  42. */
  43. protected $currObj = null;
  44. /**
  45. * An array filled with siblingsfor the TeamSpeak3_Node_Abstract object which is currently
  46. * processed.
  47. *
  48. * @var array
  49. */
  50. protected $currSib = null;
  51. /**
  52. * An internal counter indicating the number of fetched TeamSpeak3_Node_Abstract objects.
  53. *
  54. * @var integer
  55. */
  56. protected $currNum = 0;
  57. /**
  58. * The relative URI path where the images used by the viewer can be found.
  59. *
  60. * @var string
  61. */
  62. protected $iconpath = null;
  63. /**
  64. * The relative URI path where the country flag icons used by the viewer can be found.
  65. *
  66. * @var string
  67. */
  68. protected $flagpath = null;
  69. /**
  70. * The relative path of the file transter client script on the server.
  71. *
  72. * @var string
  73. */
  74. protected $ftclient = null;
  75. /**
  76. * Stores an array of local icon IDs.
  77. *
  78. * @var array
  79. */
  80. protected $cachedIcons = array(100, 200, 300, 400, 500, 600);
  81. /**
  82. * Stores an array of remote icon IDs.
  83. *
  84. * @var array
  85. */
  86. protected $remoteIcons = array();
  87. /**
  88. * The TeamSpeak3_Viewer_Html constructor.
  89. *
  90. * @param string $iconpath
  91. * @param string $flagpath
  92. * @param string $ftclient
  93. * @param string $pattern
  94. * @return void
  95. */
  96. public function __construct($iconpath = "images/viewer/", $flagpath = null, $ftclient = null, $pattern = null)
  97. {
  98. $this->iconpath = $iconpath;
  99. $this->flagpath = $flagpath;
  100. $this->ftclient = $ftclient;
  101. if($pattern)
  102. {
  103. $this->pattern = $pattern;
  104. }
  105. }
  106. /**
  107. * Returns the code needed to display a node in a TeamSpeak 3 viewer.
  108. *
  109. * @param TeamSpeak3_Node_Abstract $node
  110. * @param array $siblings
  111. * @return string
  112. */
  113. public function fetchObject(TeamSpeak3_Node_Abstract $node, array $siblings = array())
  114. {
  115. $this->currObj = $node;
  116. $this->currSib = $siblings;
  117. $args = array(
  118. $this->getContainerIdent(),
  119. $this->getContainerClass(),
  120. $this->getContainerSummary(),
  121. $this->getRowClass(),
  122. $this->getPrefixClass(),
  123. $this->getPrefix(),
  124. $this->getCorpusClass(),
  125. $this->getCorpusTitle(),
  126. $this->getCorpusIcon(),
  127. $this->getCorpusName(),
  128. $this->getSuffixClass(),
  129. $this->getSuffixIcon(),
  130. $this->getSuffixFlag(),
  131. );
  132. return TeamSpeak3_Helper_String::factory($this->pattern)->arg($args);
  133. }
  134. /**
  135. * Returns a unique identifier for the current node which can be used as a HTML id
  136. * property.
  137. *
  138. * @return string
  139. */
  140. protected function getContainerIdent()
  141. {
  142. return $this->currObj->getUniqueId();
  143. }
  144. /**
  145. * Returns a dynamic string for the current container element which can be used as
  146. * a HTML class property.
  147. *
  148. * @return string
  149. */
  150. protected function getContainerClass()
  151. {
  152. return "ts3_viewer " . $this->currObj->getClass(null);
  153. }
  154. /**
  155. * Returns the ID of the current node which will be used as a summary element for
  156. * the container element.
  157. *
  158. * @return integer
  159. */
  160. protected function getContainerSummary()
  161. {
  162. return $this->currObj->getId();
  163. }
  164. /**
  165. * Returns a dynamic string for the current row element which can be used as a HTML
  166. * class property.
  167. *
  168. * @return string
  169. */
  170. protected function getRowClass()
  171. {
  172. return ++$this->currNum%2 ? "row1" : "row2";
  173. }
  174. /**
  175. * Returns a string for the current prefix element which can be used as a HTML class
  176. * property.
  177. *
  178. * @return string
  179. */
  180. protected function getPrefixClass()
  181. {
  182. return "prefix " . $this->currObj->getClass(null);
  183. }
  184. /**
  185. * Returns the HTML img tags to display the prefix of the current node.
  186. *
  187. * @return string
  188. */
  189. protected function getPrefix()
  190. {
  191. $prefix = "";
  192. if(count($this->currSib))
  193. {
  194. $last = array_pop($this->currSib);
  195. foreach($this->currSib as $sibling)
  196. {
  197. $prefix .= ($sibling) ? $this->getImage("tree_line.gif") : $this->getImage("tree_blank.png");
  198. }
  199. $prefix .= ($last) ? $this->getImage("tree_end.gif") : $this->getImage("tree_mid.gif");
  200. }
  201. return $prefix;
  202. }
  203. /**
  204. * Returns a string for the current corpus element which can be used as a HTML class
  205. * property. If the current node is a channel spacer the class string will contain
  206. * additional class names to allow further customization of the content via CSS.
  207. *
  208. * @return string
  209. */
  210. protected function getCorpusClass()
  211. {
  212. $extras = "";
  213. if($this->currObj instanceof TeamSpeak3_Node_Channel && $this->currObj->isSpacer())
  214. {
  215. switch($this->currObj->spacerGetType())
  216. {
  217. case (string) TeamSpeak3::SPACER_SOLIDLINE:
  218. $extras .= " solidline";
  219. break;
  220. case (string) TeamSpeak3::SPACER_DASHLINE:
  221. $extras .= " dashline";
  222. break;
  223. case (string) TeamSpeak3::SPACER_DASHDOTLINE:
  224. $extras .= " dashdotline";
  225. break;
  226. case (string) TeamSpeak3::SPACER_DASHDOTDOTLINE:
  227. $extras .= " dashdotdotline";
  228. break;
  229. case (string) TeamSpeak3::SPACER_DOTLINE:
  230. $extras .= " dotline";
  231. break;
  232. }
  233. switch($this->currObj->spacerGetAlign())
  234. {
  235. case TeamSpeak3::SPACER_ALIGN_CENTER:
  236. $extras .= " center";
  237. break;
  238. case TeamSpeak3::SPACER_ALIGN_RIGHT:
  239. $extras .= " right";
  240. break;
  241. case TeamSpeak3::SPACER_ALIGN_LEFT:
  242. $extras .= " left";
  243. break;
  244. }
  245. }
  246. return "corpus " . $this->currObj->getClass(null) . $extras;
  247. }
  248. /**
  249. * Returns the HTML img tags which can be used to display the various icons for a
  250. * TeamSpeak_Node_Abstract object.
  251. *
  252. * @return string
  253. */
  254. protected function getCorpusTitle()
  255. {
  256. if($this->currObj instanceof TeamSpeak3_Node_Server)
  257. {
  258. return "ID: " . $this->currObj->getId() . " | Clients: " . $this->currObj->clientCount() . "/" . $this->currObj["virtualserver_maxclients"] . " | Uptime: " . TeamSpeak3_Helper_Convert::seconds($this->currObj["virtualserver_uptime"]);
  259. }
  260. elseif($this->currObj instanceof TeamSpeak3_Node_Channel && !$this->currObj->isSpacer())
  261. {
  262. return "ID: " . $this->currObj->getId() . " | Codec: " . TeamSpeak3_Helper_Convert::codec($this->currObj["channel_codec"]) . " | Quality: " . $this->currObj["channel_codec_quality"];
  263. }
  264. elseif($this->currObj instanceof TeamSpeak3_Node_Client)
  265. {
  266. return "ID: " . $this->currObj->getId() . " | Version: " . TeamSpeak3_Helper_Convert::versionShort($this->currObj["client_version"]) . " | Platform: " . $this->currObj["client_platform"];
  267. }
  268. elseif($this->currObj instanceof TeamSpeak3_Node_Servergroup || $this->currObj instanceof TeamSpeak3_Node_Channelgroup)
  269. {
  270. return "ID: " . $this->currObj->getId() . " | Type: " . TeamSpeak3_Helper_Convert::groupType($this->currObj["type"]) . " (" . ($this->currObj["savedb"] ? "Permanent" : "Temporary") . ")";
  271. }
  272. }
  273. /**
  274. * Returns a HTML img tag which can be used to display the status icon for a
  275. * TeamSpeak_Node_Abstract object.
  276. *
  277. * @return string
  278. */
  279. protected function getCorpusIcon()
  280. {
  281. if($this->currObj instanceof TeamSpeak3_Node_Channel && $this->currObj->isSpacer()) return;
  282. return $this->getImage($this->currObj->getIcon() . ".png");
  283. }
  284. /**
  285. * Returns a string for the current corpus element which contains the display name
  286. * for the current TeamSpeak_Node_Abstract object.
  287. *
  288. * @return string
  289. */
  290. protected function getCorpusName()
  291. {
  292. if($this->currObj instanceof TeamSpeak3_Node_Channel && $this->currObj->isSpacer())
  293. {
  294. if($this->currObj->spacerGetType() != TeamSpeak3::SPACER_CUSTOM) return;
  295. $string = $this->currObj["channel_name"]->section("]", 1, 99);
  296. if($this->currObj->spacerGetAlign() == TeamSpeak3::SPACER_ALIGN_REPEAT)
  297. {
  298. $string->resize(30, $string);
  299. }
  300. return htmlspecialchars($string);
  301. }
  302. if($this->currObj instanceof TeamSpeak3_Node_Client)
  303. {
  304. $before = array();
  305. $behind = array();
  306. foreach($this->currObj->memberOf() as $group)
  307. {
  308. if($group->getProperty("namemode") == TeamSpeak3::GROUP_NAMEMODE_BEFORE)
  309. {
  310. $before[] = "[" . htmlspecialchars($group["name"]) . "]";
  311. }
  312. elseif($group->getProperty("namemode") == TeamSpeak3::GROUP_NAMEMODE_BEHIND)
  313. {
  314. $behind[] = "[" . htmlspecialchars($group["name"]) . "]";
  315. }
  316. }
  317. return implode("", $before) . " " . htmlspecialchars($this->currObj) . " " . implode("", $behind);
  318. }
  319. return htmlspecialchars($this->currObj);
  320. }
  321. /**
  322. * Returns a string for the current suffix element which can be used as a HTML
  323. * class property.
  324. *
  325. * @return string
  326. */
  327. protected function getSuffixClass()
  328. {
  329. return "suffix " . $this->currObj->getClass(null);
  330. }
  331. /**
  332. * Returns the HTML img tags which can be used to display the various icons for a
  333. * TeamSpeak_Node_Abstract object.
  334. *
  335. * @return string
  336. */
  337. protected function getSuffixIcon()
  338. {
  339. if($this->currObj instanceof TeamSpeak3_Node_Server)
  340. {
  341. return $this->getSuffixIconServer();
  342. }
  343. elseif($this->currObj instanceof TeamSpeak3_Node_Channel)
  344. {
  345. return $this->getSuffixIconChannel();
  346. }
  347. elseif($this->currObj instanceof TeamSpeak3_Node_Client)
  348. {
  349. return $this->getSuffixIconClient();
  350. }
  351. }
  352. /**
  353. * Returns the HTML img tags which can be used to display the various icons for a
  354. * TeamSpeak_Node_Server object.
  355. *
  356. * @return string
  357. */
  358. protected function getSuffixIconServer()
  359. {
  360. $html = "";
  361. if($this->currObj["virtualserver_icon_id"])
  362. {
  363. if(!$this->currObj->iconIsLocal("virtualserver_icon_id") && $this->ftclient)
  364. {
  365. if(!isset($this->cacheIcon[$this->currObj["virtualserver_icon_id"]]))
  366. {
  367. $download = $this->currObj->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->currObj->iconGetName("virtualserver_icon_id"));
  368. if($this->ftclient == "data:image")
  369. {
  370. $download = TeamSpeak3::factory("filetransfer://" . (strstr($download["host"], ":") !== FALSE ? "[" . $download["host"] . "]" : $download["host"]) . ":" . $download["port"])->download($download["ftkey"], $download["size"]);
  371. }
  372. $this->cacheIcon[$this->currObj["virtualserver_icon_id"]] = $download;
  373. }
  374. else
  375. {
  376. $download = $this->cacheIcon[$this->currObj["virtualserver_icon_id"]];
  377. }
  378. if($this->ftclient == "data:image")
  379. {
  380. $html .= $this->getImage("data:" . TeamSpeak3_Helper_Convert::imageMimeType($download) . ";base64," . base64_encode($download), "Server Icon", null, FALSE);
  381. }
  382. else
  383. {
  384. $html .= $this->getImage($this->ftclient . "?ftdata=" . base64_encode(serialize($download)), "Server Icon", null, FALSE);
  385. }
  386. }
  387. elseif(in_array($this->currObj["virtualserver_icon_id"], $this->cachedIcons))
  388. {
  389. $html .= $this->getImage("group_icon_" . $this->currObj["virtualserver_icon_id"] . ".png", "Server Icon");
  390. }
  391. }
  392. return $html;
  393. }
  394. /**
  395. * Returns the HTML img tags which can be used to display the various icons for a
  396. * TeamSpeak_Node_Channel object.
  397. *
  398. * @return string
  399. */
  400. protected function getSuffixIconChannel()
  401. {
  402. if($this->currObj instanceof TeamSpeak3_Node_Channel && $this->currObj->isSpacer()) return;
  403. $html = "";
  404. if($this->currObj["channel_flag_default"])
  405. {
  406. $html .= $this->getImage("channel_flag_default.png", "Default Channel");
  407. }
  408. if($this->currObj["channel_flag_password"])
  409. {
  410. $html .= $this->getImage("channel_flag_password.png", "Password-protected");
  411. }
  412. if($this->currObj["channel_codec"] == TeamSpeak3::CODEC_CELT_MONO || $this->currObj["channel_codec"] == TeamSpeak3::CODEC_OPUS_MUSIC)
  413. {
  414. $html .= $this->getImage("channel_flag_music.png", "Music Codec");
  415. }
  416. if($this->currObj["channel_needed_talk_power"])
  417. {
  418. $html .= $this->getImage("channel_flag_moderated.png", "Moderated");
  419. }
  420. if($this->currObj["channel_icon_id"])
  421. {
  422. if(!$this->currObj->iconIsLocal("channel_icon_id") && $this->ftclient)
  423. {
  424. if(!isset($this->cacheIcon[$this->currObj["channel_icon_id"]]))
  425. {
  426. $download = $this->currObj->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->currObj->iconGetName("channel_icon_id"));
  427. if($this->ftclient == "data:image")
  428. {
  429. $download = TeamSpeak3::factory("filetransfer://" . (strstr($download["host"], ":") !== FALSE ? "[" . $download["host"] . "]" : $download["host"]) . ":" . $download["port"])->download($download["ftkey"], $download["size"]);
  430. }
  431. $this->cacheIcon[$this->currObj["channel_icon_id"]] = $download;
  432. }
  433. else
  434. {
  435. $download = $this->cacheIcon[$this->currObj["channel_icon_id"]];
  436. }
  437. if($this->ftclient == "data:image")
  438. {
  439. $html .= $this->getImage("data:" . TeamSpeak3_Helper_Convert::imageMimeType($download) . ";base64," . base64_encode($download), "Channel Icon", null, FALSE);
  440. }
  441. else
  442. {
  443. $html .= $this->getImage($this->ftclient . "?ftdata=" . base64_encode(serialize($download)), "Channel Icon", null, FALSE);
  444. }
  445. }
  446. elseif(in_array($this->currObj["channel_icon_id"], $this->cachedIcons))
  447. {
  448. $html .= $this->getImage("group_icon_" . $this->currObj["channel_icon_id"] . ".png", "Channel Icon");
  449. }
  450. }
  451. return $html;
  452. }
  453. /**
  454. * Returns the HTML img tags which can be used to display the various icons for a
  455. * TeamSpeak_Node_Client object.
  456. *
  457. * @return string
  458. */
  459. protected function getSuffixIconClient()
  460. {
  461. $html = "";
  462. if($this->currObj["client_is_priority_speaker"])
  463. {
  464. $html .= $this->getImage("client_priority.png", "Priority Speaker");
  465. }
  466. if($this->currObj["client_is_channel_commander"])
  467. {
  468. $html .= $this->getImage("client_cc.png", "Channel Commander");
  469. }
  470. if($this->currObj["client_is_talker"])
  471. {
  472. $html .= $this->getImage("client_talker.png", "Talk Power granted");
  473. }
  474. elseif($cntp = $this->currObj->getParent()->channelGetById($this->currObj["cid"])->channel_needed_talk_power)
  475. {
  476. if($cntp > $this->currObj["client_talk_power"])
  477. {
  478. $html .= $this->getImage("client_mic_muted.png", "Insufficient Talk Power");
  479. }
  480. }
  481. // Get current groups the client is a member of.
  482. // Shift off first group (channel group), leaving only server groups.
  483. $groups = $this->currObj->memberOf();
  484. $clientGroups = [$groups[0]];
  485. unset($groups[0]);
  486. // Create temp assoc array to use in custom uasort function.
  487. $sgroups = [];
  488. foreach($groups as $group) {
  489. $sgroups[$group['sgid']] = $group;
  490. }
  491. // Use same server group sort function from TeamSpeak3_Node_Server class.
  492. uasort($sgroups, array(get_class($this->currObj->getParent()), "sortGroupList"));
  493. // Append first group (channel group), convert to non-assoc array.
  494. $clientGroups = array_merge($clientGroups, array_values($sgroups));
  495. unset($sgroups); // Clean-up temp sorting array.
  496. foreach($clientGroups as $group)
  497. {
  498. if(!$group["iconid"]) continue;
  499. $type = ($group instanceof TeamSpeak3_Node_Servergroup) ? "Server Group" : "Channel Group";
  500. if(!$group->iconIsLocal("iconid") && $this->ftclient)
  501. {
  502. if(!isset($this->cacheIcon[$group["iconid"]]))
  503. {
  504. $download = $group->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $group->iconGetName("iconid"));
  505. if($this->ftclient == "data:image")
  506. {
  507. $download = TeamSpeak3::factory("filetransfer://" . (strstr($download["host"], ":") !== FALSE ? "[" . $download["host"] . "]" : $download["host"]) . ":" . $download["port"])->download($download["ftkey"], $download["size"]);
  508. }
  509. $this->cacheIcon[$group["iconid"]] = $download;
  510. }
  511. else
  512. {
  513. $download = $this->cacheIcon[$group["iconid"]];
  514. }
  515. if($this->ftclient == "data:image")
  516. {
  517. $html .= $this->getImage("data:" . TeamSpeak3_Helper_Convert::imageMimeType($download) . ";base64," . base64_encode($download), $group . " [" . $type . "]", null, FALSE);
  518. }
  519. else
  520. {
  521. $html .= $this->getImage($this->ftclient . "?ftdata=" . base64_encode(serialize($download)), $group . " [" . $type . "]", null, FALSE);
  522. }
  523. }
  524. elseif(in_array($group["iconid"], $this->cachedIcons))
  525. {
  526. $html .= $this->getImage("group_icon_" . $group["iconid"] . ".png", $group . " [" . $type . "]");
  527. }
  528. }
  529. if($this->currObj["client_icon_id"])
  530. {
  531. if(!$this->currObj->iconIsLocal("client_icon_id") && $this->ftclient)
  532. {
  533. if(!isset($this->cacheIcon[$this->currObj["client_icon_id"]]))
  534. {
  535. $download = $this->currObj->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->currObj->iconGetName("client_icon_id"));
  536. if($this->ftclient == "data:image")
  537. {
  538. $download = TeamSpeak3::factory("filetransfer://" . (strstr($download["host"], ":") !== FALSE ? "[" . $download["host"] . "]" : $download["host"]) . ":" . $download["port"])->download($download["ftkey"], $download["size"]);
  539. }
  540. $this->cacheIcon[$this->currObj["client_icon_id"]] = $download;
  541. }
  542. else
  543. {
  544. $download = $this->cacheIcon[$this->currObj["client_icon_id"]];
  545. }
  546. if($this->ftclient == "data:image")
  547. {
  548. $html .= $this->getImage("data:" . TeamSpeak3_Helper_Convert::imageMimeType($download) . ";base64," . base64_encode($download), "Client Icon", null, FALSE);
  549. }
  550. else
  551. {
  552. $html .= $this->getImage($this->ftclient . "?ftdata=" . base64_encode(serialize($download)), "Client Icon", null, FALSE);
  553. }
  554. }
  555. elseif(in_array($this->currObj["client_icon_id"], $this->cachedIcons))
  556. {
  557. $html .= $this->getImage("group_icon_" . $this->currObj["client_icon_id"] . ".png", "Client Icon");
  558. }
  559. }
  560. return $html;
  561. }
  562. /**
  563. * Returns a HTML img tag which can be used to display the country flag for a
  564. * TeamSpeak_Node_Client object.
  565. *
  566. * @return string
  567. */
  568. protected function getSuffixFlag()
  569. {
  570. if(!$this->currObj instanceof TeamSpeak3_Node_Client) return;
  571. if($this->flagpath && $this->currObj["client_country"])
  572. {
  573. return $this->getImage($this->currObj["client_country"]->toLower() . ".png", $this->currObj["client_country"], null, FALSE, TRUE);
  574. }
  575. }
  576. /**
  577. * Returns the code to display a custom HTML img tag.
  578. *
  579. * @param string $name
  580. * @param string $text
  581. * @param string $class
  582. * @param boolean $iconpath
  583. * @param boolean $flagpath
  584. * @return string
  585. */
  586. protected function getImage($name, $text = "", $class = null, $iconpath = TRUE, $flagpath = FALSE)
  587. {
  588. $src = "";
  589. if($iconpath)
  590. {
  591. $src = $this->iconpath;
  592. }
  593. if($flagpath)
  594. {
  595. $src = $this->flagpath;
  596. }
  597. return "<img src='" . $src . $name . "' title='" . $text . "' alt='' align='top' />";
  598. }
  599. }