/** * getter for messages * * @param int $room * @param int $user * @param int $time * @param int $game * @return array */ public static function getMessages($room, $toUser = 0, $time = 0, $game = 0) { $colorRepository = new ColorRepository(TRUE); $colors = $colorRepository->getAll(); $colorList = array(); foreach ($colors as $color) { $colorList[$color['id']] = $color; } $query = 'SELECT user.*, message.* FROM ' . DB_PREFIX . self::$table . ' AS message LEFT JOIN ' . DB_PREFIX . 'user AS user ON message.user = user.id WHERE room=' . intval($room) . ' AND tstamp > ' . intval($time) . ' AND to_user IN (' . intval($toUser) . ', 0)'; if ($game) { $query .= ' AND game=' . intval($game); } if ($toUser) { $query .= ' AND NOT not_to_user IN (' . $toUser . ')'; } $query .= ' ORDER BY message.id DESC LIMIT 100'; $messages = DB::fetchAll($query); $messages = array_reverse($messages); foreach ($messages as &$message) { if ($message['localize_key']) { $message['text'] = Localize::getMessage($message['localize_key'], unserialize($message['localize_params'])); } $message['color'] = $colorList[$message['color']]['code']; } return $messages; }
/** * Smarty {localize} function plugin * */ function smarty_function_localize($params, &$smarty) { $attrs = array(); if ($params['attrs']) { $attrs = explode('###', $params['attrs']); } return Localize::getMessage($params['key'], $attrs); }
protected function setup() { $loggedUser = LoggedUser::whoIsLogged(); if (Utils::post('create_room') && $loggedUser['admin']) { $params = array('title' => Utils::post('title'), 'alias' => Utils::createAlias(Utils::post('title'), 'room'), 'description' => Utils::post('description')); $room = new Room($params); $room->save(); } $roomRepository = new RoomRepository(); $rooms = $roomRepository->getAll(); $gameRepository = new GameRepository(); $games = $gameRepository->getGamesByRooms(array_keys($rooms)); foreach ($games as $game) { $rooms[$game['room']]['game'] = TRUE; $rooms[$game['room']]['status'] = Localize::getMessage('room_status_' . $game['status']); } MySmarty::assign('loggedUser', $loggedUser); MySmarty::assign('rooms', $rooms); }
protected function setup() { $loggedUser = LoggedUser::whoIsLogged(); MySmarty::assign('loggedUser', $loggedUser); MySmarty::assign('room', $this->room); if ($this->game) { MySmarty::assign('game', $this->game); MySmarty::assign('gameStartedStatus', Game::GAME_STATUS_STARTED); $playerRepository = new PlayerRepository(); $actualPlayer = $playerRepository->getOneByGameAndUser($this->game['id'], $loggedUser['id']); // phases when we want to make autoreload $refreshGameBox = FALSE; if (in_array($actualPlayer['phase'], array(Player::PHASE_NONE, Player::PHASE_WAITING))) { if ($this->game['status'] == Game::GAME_STATUS_INITIALIZED && $actualPlayer['possible_choices'] != '') { $refreshGameBox = FALSE; } else { $refreshGameBox = TRUE; } } MySmarty::assign('refreshGameBox', $refreshGameBox); // zobrazime len hracovi ktory je na tahu resp. v medzitahu $playerOnMove = $this->game->getPlayerOnMove(); if ($playerOnMove['id'] == $actualPlayer['id'] || $this->game['status'] == Game::GAME_STATUS_INITIALIZED) { MySmarty::assign('response', $actualPlayer['command_response']); } if ($this->game['status'] == Game::GAME_STATUS_CREATED) { if (!GameUtils::checkUserInGame($loggedUser, $this->game)) { MySmarty::assign('joinGameAvailable', TRUE); } elseif ($loggedUser['id'] == $this->game['creator']) { MySmarty::assign('startGameAvailable', Localize::getMessage('start_game')); } } elseif ($this->game['status'] == Game::GAME_STATUS_ENDED) { MySmarty::assign('createGameAvailable', Localize::getMessage('create_game')); MySmarty::assign('refreshGameBox', TRUE); } } else { MySmarty::assign('createGameAvailable', Localize::getMessage('create_game')); MySmarty::assign('refreshGameBox', TRUE); } }
public function getLocalizedDescription() { return Localize::getMessage($this['localize_description_key']); }
public function main() { $key = addslashes(Utils::post('key')); echo Localize::getMessage($key); }
public function getLocalizedUsage() { return Localize::getMessage($this['localize_key'] . '_usage'); }