sujet); $obj = new \stdClass(); $obj->day = $ex[0]; $obj->moments = explode(',', $ex[1]); $splitted[] = $obj; } return $splitted; } function split_votes($votes) { $splitted = array(); foreach ($votes as $vote) { $obj = new \stdClass(); $obj->id = $vote->id_users; $obj->name = $vote->nom; $obj->choices = str_split($vote->reponses); $splitted[] = $obj; } return $splitted; } /* PAGE */ /* ---- */ if(!empty($_GET['poll'])) { $poll_id = $_GET['poll']; } $poll = $connect->findPollById($poll_id); if (!$poll) { $smarty->assign('error', 'This poll doesn\'t exist'); $smarty->display('error.tpl'); exit; } // Retrieve data $slots = $connect->allSlotsByPollId($poll_id); $votes = $connect->allUserVotesByPollId($poll_id); // Assign data to template $smarty->assign('poll_id', $poll_id); $smarty->assign('poll', $poll); $smarty->assign('title', _('Poll') . ' - ' . $poll->title); $smarty->assign('slots', split_slots($slots)); $smarty->assign('votes', split_votes($votes)); $smarty->assign('editingVoteId', 0); // TODO Replace by the right ID //Utils::debug(split_votes($votes));exit; $smarty->display('studs.tpl');