1: <?php
2: /**
3: * ManiaLib - Lightweight PHP framework for Manialinks
4: *
5: * @see http://code.google.com/p/manialib/
6: * @copyright Copyright (c) 2009-2011 NADEO (http://www.nadeo.com)
7: * @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
8: * @version $Revision: 652 $:
9: * @author $Author: melot.philippe $:
10: * @date $Date: 2012-01-27 16:51:57 +0100 (ven., 27 janv. 2012) $:
11: */
12:
13: namespace ManiaLib\Gui\Maniacode\Elements;
14:
15: class JoinServer extends \ManiaLib\Gui\Maniacode\Component
16: {
17: const PLAY = 1;
18: const SPEC = 2;
19: const REFEREE = 3;
20:
21: protected $xmlTagName = 'join_server';
22: protected $ip;
23: protected $password;
24: protected $connectionType;
25:
26: function __construct($connectionType = self::PLAY)
27: {
28: $this->connectionType = $connectionType;
29: }
30:
31: function setIp($ip)
32: {
33: $this->ip = $ip;
34: }
35:
36: function getIp()
37: {
38: return $this->ip;
39: }
40:
41: function setPassword($password)
42: {
43: $this->password = $password;
44: }
45:
46: function getPassword()
47: {
48: return $this->password;
49: }
50:
51: function setConnectionType($connection)
52: {
53: $this->connectionType = $connection;
54: }
55:
56: function getConnectionType()
57: {
58: return $this->connectionType;
59: }
60:
61: protected function postFilter()
62: {
63: if(isset($this->ip))
64: {
65: $elem = \ManiaLib\Gui\Maniacode\Maniacode::$domDocument->createElement('ip');
66: $value = \ManiaLib\Gui\Maniacode\Maniacode::$domDocument->createTextNode($this->ip);
67: $elem->appendChild($value);
68: $this->xml->appendChild($elem);
69: }
70:
71: if(isset($this->password))
72: {
73: $elem = \ManiaLib\Gui\Maniacode\Maniacode::$domDocument->createElement('password');
74: $value = \ManiaLib\Gui\Maniacode\Maniacode::$domDocument->createTextNode($this->password);
75: $elem->appendChild($value);
76: $this->xml->appendChild($elem);
77: }
78:
79: if(isset($this->connectionType))
80: {
81: $elem = \ManiaLib\Gui\Maniacode\Maniacode::$domDocument->createElement('connection_type');
82: $value = \ManiaLib\Gui\Maniacode\Maniacode::$domDocument->createTextNode($this->connectionType);
83: $elem->appendChild($value);
84: $this->xml->appendChild($elem);
85: }
86: }
87:
88: }
89:
90: ?>