Location: PHPKode > projects > PhpBlock > A9.8/script/action/manageaction.class.php
<?php
include_once $PATH_TO_CODE."/script/fonction.php";
include_once $PATH_TO_CODE."/script/action/abstractaction.class.php";
class ManageAction {
    public $errorInfo="";
    public $debugInfo="";
    public $playerInfo="";
    public $player=false;
    public static $instance;

    private function __construct() {
            beginPhpSession($locPlayerId);
            closeCurrentSession();

            global $gloObjectManager;
            $this->player = $gloObjectManager->getPlayer($locPlayerId);
			addPlayerConnection($locPlayerId, 1);
    }

    public static function getInstance() {
        if (!ManageAction::$instance) {
            ManageAction::$instance = new ManageAction();
        }
        return ManageAction::$instance;
    }

    public function getPlayer() {
        return $this->player;
    }

    public function addErrorInfo($parMessage) {
        if($this->errorInfo <> "") {
            $this->errorInfo.="\n";
        }
        $this->errorInfo.=$parMessage;

        $this->addPlayerInfo($parMessage);
    }
    public function addDebugInfo($parMessage) {
        if($this->debugInfo <> "") {
            $this->debugInfo.="\n";
        }
        $this->debugInfo.=$parMessage;
    }
    public function addPlayerInfo($parMessage) {
        if($this->playerInfo <> "") {
            $this->playerInfo.="\n";
        }
        $this->playerInfo.=$parMessage;
    }

    public function managePlayerAction($parActionManagerList) {
        $locZoneActionListPara = getGetPost(Constante::$HTTP_ZONE_ACTION_LIST_NAME, false);

        if($locZoneActionListPara) {
            $locZoneActionList = explode(Constante::$SEP_URL_2, $locZoneActionListPara);

            foreach($locZoneActionList as $locZoneAction) {
                $locZoneActionArray = explode(Constante::$SEP_URL_1, $locZoneAction);

                if(count($locZoneActionArray) >= 2) {
                    if(!$this->manageStandardAction($parActionManagerList, $locZoneActionArray)) {
                        $this->addErrorInfo("Unknown action number: ".$locZoneActionArray[0]);
                        $this->addErrorInfo("known actions are:");
                        $locActionNumList = "";
                        foreach($parActionManagerList as $locActionManager) {
                            $locActionNumList .= "\t".$locActionManager->getActionType();
                        }
                        $this->addErrorInfo($locActionNumList);
                    }
                }
            }
        } else {
            $this->addErrorInfo("Not correct GET or POST, no ".Constante::$HTTP_ZONE_ACTION_LIST_NAME." element");
        }
        if($this->errorInfo <> "") {
            echo "ErrorInfo=$this->errorInfo";
        }
        if($this->debugInfo <> "") {
            echo "DebugInfo=$this->debugInfo";
        }
        if($this->playerInfo <> "") {
            echo "PlayerInfo=$this->playerInfo";
        }
    }

    private function manageStandardAction($parActionManagerList, $parZoneActionArray) {
        $locAction = $parZoneActionArray[0];
        foreach($parActionManagerList as $locActionManager) {
            if($locActionManager->getActionType() == $locAction) {
                $locActionManager->action($parZoneActionArray);
                return true;
            }
        }
        return false;
    }

}
?>
Return current item: PhpBlock