- Improved Chatlog Plugin
- First Step for ManialinkManager - Added FML Update + MC-Fixes for the changes
This commit is contained in:
		| @@ -83,7 +83,7 @@ abstract class Control implements Renderable { | |||||||
| 	/** | 	/** | ||||||
| 	 * Set x position | 	 * Set x position | ||||||
| 	 * | 	 * | ||||||
| 	 * @param real $x        	 | 	 * @param float $x        	 | ||||||
| 	 * @return \FML\Controls\Control | 	 * @return \FML\Controls\Control | ||||||
| 	 */ | 	 */ | ||||||
| 	public function setX($x) { | 	public function setX($x) { | ||||||
| @@ -94,7 +94,7 @@ abstract class Control implements Renderable { | |||||||
| 	/** | 	/** | ||||||
| 	 * Set y position | 	 * Set y position | ||||||
| 	 * | 	 * | ||||||
| 	 * @param real $y        	 | 	 * @param float $y        	 | ||||||
| 	 * @return \FML\Controls\Control | 	 * @return \FML\Controls\Control | ||||||
| 	 */ | 	 */ | ||||||
| 	public function setY($y) { | 	public function setY($y) { | ||||||
| @@ -105,7 +105,7 @@ abstract class Control implements Renderable { | |||||||
| 	/** | 	/** | ||||||
| 	 * Set z position | 	 * Set z position | ||||||
| 	 * | 	 * | ||||||
| 	 * @param real $z        	 | 	 * @param float $z        	 | ||||||
| 	 * @return \FML\Controls\Control | 	 * @return \FML\Controls\Control | ||||||
| 	 */ | 	 */ | ||||||
| 	public function setZ($z) { | 	public function setZ($z) { | ||||||
| @@ -116,9 +116,9 @@ abstract class Control implements Renderable { | |||||||
| 	/** | 	/** | ||||||
| 	 * Set position | 	 * Set position | ||||||
| 	 * | 	 * | ||||||
| 	 * @param real $x        	 | 	 * @param float $x        	 | ||||||
| 	 * @param real $y        	 | 	 * @param float $y        	 | ||||||
| 	 * @param real $z        	 | 	 * @param float $z        	 | ||||||
| 	 * @return \FML\Controls\Control | 	 * @return \FML\Controls\Control | ||||||
| 	 */ | 	 */ | ||||||
| 	public function setPosition($x, $y, $z = null) { | 	public function setPosition($x, $y, $z = null) { | ||||||
| @@ -133,7 +133,7 @@ abstract class Control implements Renderable { | |||||||
| 	/** | 	/** | ||||||
| 	 * Set width | 	 * Set width | ||||||
| 	 * | 	 * | ||||||
| 	 * @param real $width        	 | 	 * @param float $width        	 | ||||||
| 	 * @return \FML\Controls\Control | 	 * @return \FML\Controls\Control | ||||||
| 	 */ | 	 */ | ||||||
| 	public function setWidth($width) { | 	public function setWidth($width) { | ||||||
| @@ -144,7 +144,7 @@ abstract class Control implements Renderable { | |||||||
| 	/** | 	/** | ||||||
| 	 * Set height | 	 * Set height | ||||||
| 	 * | 	 * | ||||||
| 	 * @param real $height        	 | 	 * @param float $height        	 | ||||||
| 	 * @return \FML\Controls\Control | 	 * @return \FML\Controls\Control | ||||||
| 	 */ | 	 */ | ||||||
| 	public function setHeight($height) { | 	public function setHeight($height) { | ||||||
| @@ -155,8 +155,8 @@ abstract class Control implements Renderable { | |||||||
| 	/** | 	/** | ||||||
| 	 * Set size | 	 * Set size | ||||||
| 	 * | 	 * | ||||||
| 	 * @param real $width        	 | 	 * @param float $width        	 | ||||||
| 	 * @param real $height        	 | 	 * @param float $height        	 | ||||||
| 	 * @return \FML\Controls\Control | 	 * @return \FML\Controls\Control | ||||||
| 	 */ | 	 */ | ||||||
| 	public function setSize($width, $height) { | 	public function setSize($width, $height) { | ||||||
| @@ -203,7 +203,7 @@ abstract class Control implements Renderable { | |||||||
| 	/** | 	/** | ||||||
| 	 * Set scale | 	 * Set scale | ||||||
| 	 * | 	 * | ||||||
| 	 * @param real $scale        	 | 	 * @param float $scale        	 | ||||||
| 	 * @return \FML\Controls\Control | 	 * @return \FML\Controls\Control | ||||||
| 	 */ | 	 */ | ||||||
| 	public function setScale($scale) { | 	public function setScale($scale) { | ||||||
|   | |||||||
| @@ -36,7 +36,7 @@ class Gauge extends Control implements Styleable { | |||||||
| 	/** | 	/** | ||||||
| 	 * Set ratio | 	 * Set ratio | ||||||
| 	 * | 	 * | ||||||
| 	 * @param real $ratio        	 | 	 * @param float $ratio        	 | ||||||
| 	 * @return \FML\Controls\Gauge | 	 * @return \FML\Controls\Gauge | ||||||
| 	 */ | 	 */ | ||||||
| 	public function setRatio($ratio) { | 	public function setRatio($ratio) { | ||||||
| @@ -47,7 +47,7 @@ class Gauge extends Control implements Styleable { | |||||||
| 	/** | 	/** | ||||||
| 	 * Set grading | 	 * Set grading | ||||||
| 	 * | 	 * | ||||||
| 	 * @param real $grading        	 | 	 * @param float $grading        	 | ||||||
| 	 * @return \FML\Controls\Gauge | 	 * @return \FML\Controls\Gauge | ||||||
| 	 */ | 	 */ | ||||||
| 	public function setGrading($grading) { | 	public function setGrading($grading) { | ||||||
| @@ -69,7 +69,7 @@ class Gauge extends Control implements Styleable { | |||||||
| 	/** | 	/** | ||||||
| 	 * Set rotation | 	 * Set rotation | ||||||
| 	 * | 	 * | ||||||
| 	 * @param real $rotation        	 | 	 * @param float $rotation        	 | ||||||
| 	 * @return \FML\Controls\Gauge | 	 * @return \FML\Controls\Gauge | ||||||
| 	 */ | 	 */ | ||||||
| 	public function setRotation($rotation) { | 	public function setRotation($rotation) { | ||||||
|   | |||||||
| @@ -2,6 +2,7 @@ | |||||||
|  |  | ||||||
| namespace FML\Controls; | namespace FML\Controls; | ||||||
|  |  | ||||||
|  | use FML\Types\Actionable; | ||||||
| use FML\Types\Linkable; | use FML\Types\Linkable; | ||||||
| use FML\Types\NewLineable; | use FML\Types\NewLineable; | ||||||
| use FML\Types\Scriptable; | use FML\Types\Scriptable; | ||||||
| @@ -13,7 +14,7 @@ use FML\Types\TextFormatable; | |||||||
|  * |  * | ||||||
|  * @author steeffeen |  * @author steeffeen | ||||||
|  */ |  */ | ||||||
| class Label extends Control implements Linkable, NewLineable, Scriptable, Styleable, TextFormatable { | class Label extends Control implements Actionable, Linkable, NewLineable, Scriptable, Styleable, TextFormatable { | ||||||
| 	/** | 	/** | ||||||
| 	 * Protected properties | 	 * Protected properties | ||||||
| 	 */ | 	 */ | ||||||
| @@ -22,6 +23,7 @@ class Label extends Control implements Linkable, NewLineable, Scriptable, Stylea | |||||||
| 	protected $textEmboss = 0; | 	protected $textEmboss = 0; | ||||||
| 	protected $translate = 0; | 	protected $translate = 0; | ||||||
| 	protected $maxLines = 0; | 	protected $maxLines = 0; | ||||||
|  | 	protected $action = ''; | ||||||
| 	protected $url = ''; | 	protected $url = ''; | ||||||
| 	protected $manialink = ''; | 	protected $manialink = ''; | ||||||
| 	protected $autoNewLine = 0; | 	protected $autoNewLine = 0; | ||||||
| @@ -98,6 +100,16 @@ class Label extends Control implements Linkable, NewLineable, Scriptable, Stylea | |||||||
| 		return $this; | 		return $this; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * | ||||||
|  | 	 * @see \FML\Types\Actionable::setAction() | ||||||
|  | 	 * @return \FML\Controls\Label | ||||||
|  | 	 */ | ||||||
|  | 	public function setAction($action) { | ||||||
|  | 		$this->action = $action; | ||||||
|  | 		return $this; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * | 	 * | ||||||
| 	 * @see \FML\Types\Linkable::setUrl() | 	 * @see \FML\Types\Linkable::setUrl() | ||||||
| @@ -209,6 +221,9 @@ class Label extends Control implements Linkable, NewLineable, Scriptable, Stylea | |||||||
| 		if ($this->maxLines) { | 		if ($this->maxLines) { | ||||||
| 			$xml->setAttribute('maxlines', $this->maxLines); | 			$xml->setAttribute('maxlines', $this->maxLines); | ||||||
| 		} | 		} | ||||||
|  | 		if ($this->action) { | ||||||
|  | 			$xml->setAttribute('action', $this->action); | ||||||
|  | 		} | ||||||
| 		if ($this->url) { | 		if ($this->url) { | ||||||
| 			$xml->setAttribute('url', $this->url); | 			$xml->setAttribute('url', $this->url); | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -2,6 +2,7 @@ | |||||||
|  |  | ||||||
| namespace FML\Controls; | namespace FML\Controls; | ||||||
|  |  | ||||||
|  | use FML\Types\Actionable; | ||||||
| use FML\Types\BgColorable; | use FML\Types\BgColorable; | ||||||
| use FML\Types\Linkable; | use FML\Types\Linkable; | ||||||
| use FML\Types\Scriptable; | use FML\Types\Scriptable; | ||||||
| @@ -13,7 +14,7 @@ use FML\Types\SubStyleable; | |||||||
|  * |  * | ||||||
|  * @author steeffeen |  * @author steeffeen | ||||||
|  */ |  */ | ||||||
| class Quad extends Control implements BgColorable, Linkable, Scriptable, Styleable, SubStyleable { | class Quad extends Control implements Actionable, BgColorable, Linkable, Scriptable, Styleable, SubStyleable { | ||||||
| 	/** | 	/** | ||||||
| 	 * Protected properties | 	 * Protected properties | ||||||
| 	 */ | 	 */ | ||||||
| @@ -21,6 +22,7 @@ class Quad extends Control implements BgColorable, Linkable, Scriptable, Styleab | |||||||
| 	protected $imageFocus = ''; | 	protected $imageFocus = ''; | ||||||
| 	protected $colorize = ''; | 	protected $colorize = ''; | ||||||
| 	protected $modulizeColor = ''; | 	protected $modulizeColor = ''; | ||||||
|  | 	protected $action = ''; | ||||||
| 	protected $bgColor = ''; | 	protected $bgColor = ''; | ||||||
| 	protected $url = ''; | 	protected $url = ''; | ||||||
| 	protected $manialink = ''; | 	protected $manialink = ''; | ||||||
| @@ -83,6 +85,16 @@ class Quad extends Control implements BgColorable, Linkable, Scriptable, Styleab | |||||||
| 		return $this; | 		return $this; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * | ||||||
|  | 	 * @see \FML\Types\Actionable::setAction() | ||||||
|  | 	 * @return \FML\Controls\Quad | ||||||
|  | 	 */ | ||||||
|  | 	public function setAction($action) { | ||||||
|  | 		$this->action = $action; | ||||||
|  | 		return $this; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * | 	 * | ||||||
| 	 * @see \FML\Types\BgColorable::setBgColor() | 	 * @see \FML\Types\BgColorable::setBgColor() | ||||||
| @@ -172,6 +184,9 @@ class Quad extends Control implements BgColorable, Linkable, Scriptable, Styleab | |||||||
| 		if ($this->modulizeColor) { | 		if ($this->modulizeColor) { | ||||||
| 			$xml->setAttribute('modulizecolor', $this->modulizeColor); | 			$xml->setAttribute('modulizecolor', $this->modulizeColor); | ||||||
| 		} | 		} | ||||||
|  | 		if ($this->action) { | ||||||
|  | 			$xml->setAttribute('action', $this->action); | ||||||
|  | 		} | ||||||
| 		if ($this->bgColor) { | 		if ($this->bgColor) { | ||||||
| 			$xml->setAttribute('bgcolor', $this->bgColor); | 			$xml->setAttribute('bgcolor', $this->bgColor); | ||||||
| 		} | 		} | ||||||
|   | |||||||
							
								
								
									
										19
									
								
								application/core/FML/Types/Actionable.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								application/core/FML/Types/Actionable.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | |||||||
|  | <?php | ||||||
|  |  | ||||||
|  | namespace FML\Types; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Interface for elements that support the action attribute | ||||||
|  |  * | ||||||
|  |  * @author steeffeen | ||||||
|  |  */ | ||||||
|  | interface Actionable { | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * Set action | ||||||
|  | 	 * | ||||||
|  | 	 * @param string $action        	 | ||||||
|  | 	 */ | ||||||
|  | 	public function setAction($action); | ||||||
|  | } | ||||||
|  | ?> | ||||||
| @@ -48,7 +48,7 @@ interface Playable { | |||||||
| 	/** | 	/** | ||||||
| 	 * Set volume | 	 * Set volume | ||||||
| 	 * | 	 * | ||||||
| 	 * @param real $volume        	 | 	 * @param float $volume        	 | ||||||
| 	 */ | 	 */ | ||||||
| 	public function setVolume($volume); | 	public function setVolume($volume); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -12,6 +12,7 @@ use ManiaControl\Players\Player; | |||||||
| use ManiaControl\Players\PlayerManager; | use ManiaControl\Players\PlayerManager; | ||||||
| use ManiaControl\Plugins\PluginManager; | use ManiaControl\Plugins\PluginManager; | ||||||
| use ManiaControl\Server\Server; | use ManiaControl\Server\Server; | ||||||
|  | use ManiaControl\Manialinks\ManialinkManager; | ||||||
|  |  | ||||||
| require_once __DIR__ . '/Callbacks/CallbackManager.php'; | require_once __DIR__ . '/Callbacks/CallbackManager.php'; | ||||||
| require_once __DIR__ . '/Commands/CommandManager.php'; | require_once __DIR__ . '/Commands/CommandManager.php'; | ||||||
| @@ -21,7 +22,7 @@ require_once __DIR__ . '/Database.php'; | |||||||
| require_once __DIR__ . '/FileUtil.php'; | require_once __DIR__ . '/FileUtil.php'; | ||||||
| require_once __DIR__ . '/Formatter.php'; | require_once __DIR__ . '/Formatter.php'; | ||||||
| require_once __DIR__ . '/Manialinks/ManialinkIdHandler.php'; | require_once __DIR__ . '/Manialinks/ManialinkIdHandler.php'; | ||||||
| require_once __DIR__ . '/Manialinks/ManialinkUtil.php'; | require_once __DIR__ . '/Manialinks/ManialinkManager.php'; | ||||||
| require_once __DIR__ . '/Maps/Map.php'; | require_once __DIR__ . '/Maps/Map.php'; | ||||||
| require_once __DIR__ . '/Maps/MapManager.php'; | require_once __DIR__ . '/Maps/MapManager.php'; | ||||||
| require_once __DIR__ . '/Players/PlayerManager.php'; | require_once __DIR__ . '/Players/PlayerManager.php'; | ||||||
| @@ -62,7 +63,7 @@ class ManiaControl implements CommandListener { | |||||||
| 	public $client = null; | 	public $client = null; | ||||||
| 	public $commandManager = null; | 	public $commandManager = null; | ||||||
| 	public $database = null; | 	public $database = null; | ||||||
| 	public $manialinkIdHandler = null; | 	public $manialinkManager = null; | ||||||
| 	public $mapManager = null; | 	public $mapManager = null; | ||||||
| 	public $playerManager = null; | 	public $playerManager = null; | ||||||
| 	public $pluginManager = null; | 	public $pluginManager = null; | ||||||
| @@ -80,7 +81,7 @@ class ManiaControl implements CommandListener { | |||||||
| 	public function __construct() { | 	public function __construct() { | ||||||
| 		$this->database = new Database($this); | 		$this->database = new Database($this); | ||||||
| 		$this->callbackManager = new CallbackManager($this); | 		$this->callbackManager = new CallbackManager($this); | ||||||
| 		$this->manialinkIdHandler = new ManialinkIdHandler(); | 		$this->manialinkManager = new ManialinkManager($this); | ||||||
| 		$this->settingManager = new SettingManager($this); | 		$this->settingManager = new SettingManager($this); | ||||||
| 		$this->chat = new Chat($this); | 		$this->chat = new Chat($this); | ||||||
| 		$this->commandManager = new CommandManager($this); | 		$this->commandManager = new CommandManager($this); | ||||||
|   | |||||||
							
								
								
									
										98
									
								
								application/core/Manialinks/ManialinkManager.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								application/core/Manialinks/ManialinkManager.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,98 @@ | |||||||
|  | <?php | ||||||
|  |  | ||||||
|  | namespace ManiaControl\Manialinks; | ||||||
|  |  | ||||||
|  | use ManiaControl\ManiaControl; | ||||||
|  | use ManiaControl\Callbacks\CallbackListener; | ||||||
|  | use ManiaControl\Callbacks\CallbackManager; | ||||||
|  |  | ||||||
|  | require_once __DIR__ . '/ManialinkPageAnswerListener.php'; | ||||||
|  | require_once __DIR__ . '/../FML/autoload.php'; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Manialink manager class | ||||||
|  |  * | ||||||
|  |  * @author steeffeen & kremsy | ||||||
|  |  */ | ||||||
|  | class ManialinkManager implements CallbackListener { | ||||||
|  | 	/** | ||||||
|  | 	 * Private properties | ||||||
|  | 	 */ | ||||||
|  | 	private $maniaControl = null; | ||||||
|  | 	private $pageAnswerListeners = array(); | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * Create a new manialink manager | ||||||
|  | 	 * | ||||||
|  | 	 * @param ManiaControl $maniaControl        	 | ||||||
|  | 	 */ | ||||||
|  | 	public function __construct(ManiaControl $maniaControl) { | ||||||
|  | 		$this->maniaControl = $maniaControl; | ||||||
|  | 		$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,  | ||||||
|  | 				'handleManialinkPageAnswer'); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * Register a new manialink page answer listener | ||||||
|  | 	 * | ||||||
|  | 	 * @param string $manialinkId        	 | ||||||
|  | 	 * @param ManialinkPageAnswerListener $listener        	 | ||||||
|  | 	 * @param string $method        	 | ||||||
|  | 	 * @return bool | ||||||
|  | 	 */ | ||||||
|  | 	public function registerManialinkPageAnswerListener($manialinkId, ManialinkPageAnswerListener $listener, $method) { | ||||||
|  | 		if (!method_exists($listener, $method)) { | ||||||
|  | 			trigger_error("Given listener for manialinkId '{$manialinkId}' doesn't have callback method '{$method}'."); | ||||||
|  | 			return false; | ||||||
|  | 		} | ||||||
|  | 		if (!array_key_exists($manialinkId, $this->pageAnswerListeners) || !is_array($this->pageAnswerListeners[$manialinkId])) { | ||||||
|  | 			// Init listeners array | ||||||
|  | 			$this->pageAnswerListeners[$manialinkId] = array(); | ||||||
|  | 		} | ||||||
|  | 		// Register page answer listener | ||||||
|  | 		array_push($this->pageAnswerListeners[$manialinkId], array($listener, $method)); | ||||||
|  | 		return true; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * Handle ManialinkPageAnswer callback | ||||||
|  | 	 * | ||||||
|  | 	 * @param array $callback        	 | ||||||
|  | 	 */ | ||||||
|  | 	public function handleManialinkPageAnswer(array $callback) { | ||||||
|  | 		var_dump($callback); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * Send the given manialink to players | ||||||
|  | 	 * | ||||||
|  | 	 * @param string $manialinkText        	 | ||||||
|  | 	 * @param mixed $logins        	 | ||||||
|  | 	 * @param int $timeout        	 | ||||||
|  | 	 * @param bool $hideOnClick        	 | ||||||
|  | 	 * @return bool | ||||||
|  | 	 */ | ||||||
|  | 	public function sendManialink($manialinkText, $logins = null, $timeout = 0, $hideOnClick = false) { | ||||||
|  | 		if (!$logins) { | ||||||
|  | 			return $this->maniaControl->client->query('SendDisplayManialinkPage', $manialinkText, $timeout, $hideOnClick); | ||||||
|  | 		} | ||||||
|  | 		if (is_string($logins)) { | ||||||
|  | 			return $this->maniaControl->client->query('SendDisplayManialinkPageToLogin', $logins, $manialinkText, $timeout,  | ||||||
|  | 					$hideOnClick); | ||||||
|  | 		} | ||||||
|  | 		if (is_array($logins)) { | ||||||
|  | 			$success = true; | ||||||
|  | 			foreach ($logins as $login) { | ||||||
|  | 				$subSuccess = $this->maniaControl->client->query('SendDisplayManialinkPageToLogin', $login, $manialinkText, $timeout,  | ||||||
|  | 						$hideOnClick); | ||||||
|  | 				if (!$subSuccess) { | ||||||
|  | 					$success = false; | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			return $success; | ||||||
|  | 		} | ||||||
|  | 		return false; | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | ?> | ||||||
							
								
								
									
										13
									
								
								application/core/Manialinks/ManialinkPageAnswerListener.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								application/core/Manialinks/ManialinkPageAnswerListener.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | |||||||
|  | <?php | ||||||
|  |  | ||||||
|  | namespace ManiaControl\Manialinks; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Interface for manialink page answer listeners | ||||||
|  |  * | ||||||
|  |  * @author steeffeen & kremsy | ||||||
|  |  */ | ||||||
|  | interface ManialinkPageAnswerListener { | ||||||
|  | } | ||||||
|  |  | ||||||
|  | ?> | ||||||
| @@ -1,93 +0,0 @@ | |||||||
| <?php |  | ||||||
|  |  | ||||||
| namespace ManiaControl\Manialinks; |  | ||||||
|  |  | ||||||
| require_once __DIR__ . '/../FML/autoload.php'; |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Manialink utility class |  | ||||||
|  * |  | ||||||
|  * @author steeffeen & kremsy |  | ||||||
|  */ |  | ||||||
| abstract class ManialinkUtil { |  | ||||||
|  |  | ||||||
| 	/** |  | ||||||
| 	 * Send the given manialink to players |  | ||||||
| 	 * |  | ||||||
| 	 * @param \IXR_ClientMulticall_Gbx $client        	 |  | ||||||
| 	 * @param string $manialink        	 |  | ||||||
| 	 * @param mixed $logins        	 |  | ||||||
| 	 * @param int $timeout        	 |  | ||||||
| 	 * @param bool $hideOnClick        	 |  | ||||||
| 	 * @return bool |  | ||||||
| 	 */ |  | ||||||
| 	public static function sendManialinkPage(\IXR_ClientMulticall_Gbx $client, $manialinkText, $logins = null, $timeout = 0,  |  | ||||||
| 			$hideOnClick = false) { |  | ||||||
| 		if (!$client || !$manialinkText) { |  | ||||||
| 			return false; |  | ||||||
| 		} |  | ||||||
| 		if (!$logins) { |  | ||||||
| 			return $client->query('SendDisplayManialinkPage', $manialinkText, $timeout, $hideOnClick); |  | ||||||
| 		} |  | ||||||
| 		if (is_string($logins)) { |  | ||||||
| 			return $client->query('SendDisplayManialinkPageToLogin', $logins, $manialinkText, $timeout, $hideOnClick); |  | ||||||
| 		} |  | ||||||
| 		if (is_array($logins)) { |  | ||||||
| 			$success = true; |  | ||||||
| 			foreach ($logins as $login) { |  | ||||||
| 				$subSuccess = $client->query('SendDisplayManialinkPageToLogin', $login, $manialinkText, $timeout, $hideOnClick); |  | ||||||
| 				if (!$subSuccess) { |  | ||||||
| 					$success = false; |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 			return $success; |  | ||||||
| 		} |  | ||||||
| 		return false; |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	/** |  | ||||||
| 	 * Build new simple xml element |  | ||||||
| 	 * |  | ||||||
| 	 * @param string $name        	 |  | ||||||
| 	 * @param string $id        	 |  | ||||||
| 	 * @return \SimpleXMLElement |  | ||||||
| 	 */ |  | ||||||
| 	public static function newManialinkXml($id = null) { |  | ||||||
| 		$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8" standalone="yes"?><manialink/>'); |  | ||||||
| 		$xml->addAttribute('version', '1'); |  | ||||||
| 		if ($id) { |  | ||||||
| 			$xml->addAttribute('id', $id); |  | ||||||
| 		} |  | ||||||
| 		return $xml; |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	/** |  | ||||||
| 	 * Add alignment attributes to an xml element |  | ||||||
| 	 * |  | ||||||
| 	 * @param \SimpleXMLElement $xml        	 |  | ||||||
| 	 * @param string $halign        	 |  | ||||||
| 	 * @param string $valign        	 |  | ||||||
| 	 */ |  | ||||||
| 	public static function addAlignment(\SimpleXMLElement $xml, $halign = 'center', $valign = 'center2') { |  | ||||||
| 		if (!property_exists($xml, 'halign')) { |  | ||||||
| 			$xml->addAttribute('halign', $halign); |  | ||||||
| 		} |  | ||||||
| 		if (!property_exists($xml, 'valign')) { |  | ||||||
| 			$xml->addAttribute('valign', $valign); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	/** |  | ||||||
| 	 * Add translate attribute to an xml element |  | ||||||
| 	 * |  | ||||||
| 	 * @param \SimpleXMLElement $xml        	 |  | ||||||
| 	 * @param bool $translate        	 |  | ||||||
| 	 */ |  | ||||||
| 	public static function addTranslate(\SimpleXMLElement $xml, $translate = true) { |  | ||||||
| 		if (!property_exists($xml, 'translate')) { |  | ||||||
| 			$xml->addAttribute('translate', ($translate ? 1 : 0)); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  |  | ||||||
| ?> |  | ||||||
| @@ -26,8 +26,6 @@ class SettingConfigurator implements CallbackListener { | |||||||
| 		$this->maniaControl = $maniaControl; | 		$this->maniaControl = $maniaControl; | ||||||
| 		 | 		 | ||||||
| 		$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'onInit'); | 		$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'onInit'); | ||||||
| 		 |  | ||||||
| 		$this->maniaControl->manialinkIdHandler->reserveManiaLinkIds(100); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
|   | |||||||
| @@ -15,7 +15,9 @@ class ChatlogPlugin extends Plugin implements CallbackListener { | |||||||
| 	 * Constants | 	 * Constants | ||||||
| 	 */ | 	 */ | ||||||
| 	const VERSION = '1.0'; | 	const VERSION = '1.0'; | ||||||
|  | 	const SETTING_FOLDERNAME = 'Log-Folder Name'; | ||||||
| 	const SETTING_FILENAME = 'Log-File Name'; | 	const SETTING_FILENAME = 'Log-File Name'; | ||||||
|  | 	const SETTING_USEPID = 'Use Process-Id for File Name'; | ||||||
| 	const SETTING_LOGSERVERMESSAGES = 'Log Server Messages'; | 	const SETTING_LOGSERVERMESSAGES = 'Log Server Messages'; | ||||||
| 	 | 	 | ||||||
| 	/** | 	/** | ||||||
| @@ -36,13 +38,35 @@ class ChatlogPlugin extends Plugin implements CallbackListener { | |||||||
| 		$this->description = 'Plugin logging the chat messages of the server.'; | 		$this->description = 'Plugin logging the chat messages of the server.'; | ||||||
| 		 | 		 | ||||||
| 		// Init settings | 		// Init settings | ||||||
| 		$this->maniaControl->settingManager->initSetting($this, self::SETTING_FILENAME, 'chat.log'); | 		$this->maniaControl->settingManager->initSetting($this, self::SETTING_FOLDERNAME, 'logs'); | ||||||
|  | 		$this->maniaControl->settingManager->initSetting($this, self::SETTING_FILENAME, 'ChatLog.log'); | ||||||
|  | 		$this->maniaControl->settingManager->initSetting($this, self::SETTING_USEPID, false); | ||||||
| 		$this->maniaControl->settingManager->initSetting($this, self::SETTING_LOGSERVERMESSAGES, true); | 		$this->maniaControl->settingManager->initSetting($this, self::SETTING_LOGSERVERMESSAGES, true); | ||||||
| 		 | 		 | ||||||
| 		// Get settings | 		// Get settings | ||||||
|  | 		$folderName = $this->maniaControl->settingManager->getSetting($this, self::SETTING_FOLDERNAME); | ||||||
|  | 		$folderName = FileUtil::getClearedFileName($folderName); | ||||||
|  | 		$folderDir = ManiaControlDir . '/' . $folderName; | ||||||
|  | 		if (!is_dir($folderDir)) { | ||||||
|  | 			$success = mkdir($folderDir); | ||||||
|  | 			if (!$success) { | ||||||
|  | 				trigger_error("Couldn't create chat log folder '{$folderName}'."); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
| 		$fileName = $this->maniaControl->settingManager->getSetting($this, self::SETTING_FILENAME); | 		$fileName = $this->maniaControl->settingManager->getSetting($this, self::SETTING_FILENAME); | ||||||
| 		$fileName = FileUtil::getClearedFileName($fileName); | 		$fileName = FileUtil::getClearedFileName($fileName); | ||||||
| 		$this->fileName = ManiaControlDir . '/' . $fileName; | 		$usePId = $this->maniaControl->settingManager->getSetting($this, self::SETTING_USEPID); | ||||||
|  | 		if ($usePId) { | ||||||
|  | 			$dotIndex = strripos($fileName, '.'); | ||||||
|  | 			$pIdPart = '_' . getmypid(); | ||||||
|  | 			if ($dotIndex !== false && $dotIndex >= 0) { | ||||||
|  | 				$fileName = substr($fileName, 0, $dotIndex) . $pIdPart . substr($fileName, $dotIndex); | ||||||
|  | 			} | ||||||
|  | 			else { | ||||||
|  | 				$fileName .= $pIdPart; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		$this->fileName = $folderDir . '/' . $fileName; | ||||||
| 		$this->logServerMessages = $this->maniaControl->settingManager->getSetting($this, self::SETTING_LOGSERVERMESSAGES); | 		$this->logServerMessages = $this->maniaControl->settingManager->getSetting($this, self::SETTING_LOGSERVERMESSAGES); | ||||||
| 		 | 		 | ||||||
| 		// Register for callbacks | 		// Register for callbacks | ||||||
|   | |||||||
| @@ -121,7 +121,7 @@ class KarmaPlugin extends Plugin implements CallbackListener { | |||||||
| 			 | 			 | ||||||
| 			// Send manialink | 			// Send manialink | ||||||
| 			$manialinkText = $this->manialink->render()->saveXML(); | 			$manialinkText = $this->manialink->render()->saveXML(); | ||||||
| 			ManialinkUtil::sendManialinkPage($this->maniaControl->client, $manialinkText, $login); | 			$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -251,7 +251,7 @@ class LocalRecordsPlugin extends Plugin implements CallbackListener { | |||||||
| 		$frame->add($titleLabel); | 		$frame->add($titleLabel); | ||||||
| 		// TODO: set translateable | 		// TODO: set translateable | ||||||
| 		$titleLabel->setPosition(0, $line_height * -0.9); | 		$titleLabel->setPosition(0, $line_height * -0.9); | ||||||
| 		$titleLabel->setSize($width); | 		$titleLabel->setWidth($width); | ||||||
| 		$titleLabel->setStyle(Label_Text::STYLE_TextTitle1); | 		$titleLabel->setStyle(Label_Text::STYLE_TextTitle1); | ||||||
| 		$titleLabel->setTextSize(2); | 		$titleLabel->setTextSize(2); | ||||||
| 		$titleLabel->setText($title); | 		$titleLabel->setText($title); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user