public function gethtml($id) { $item = $this->getitem($id); $tml = $this->get_tml($item['id_tml']); $args = new targs(); $args->id = $id; $theme = ttheme::i(); if ($item['status'] == 'opened') { //inject php into html $result = sprintf('<?php $poll = tpullpolls::i()->get(%d); ?>', $id); $args->total = '<?php echo $poll[\'total\']; ?>'; $args->rate = '<?php echo $poll[\'rate\'] / 10; ?>'; if (strpos($tml['closed'], '$votes')) { foreach ($tml['items'] as $index => $text) { $args->__set('votes' . $index, sprintf('<?php echo $poll[\'votes\'][%d]; ?>', $index)); } } $result .= $theme->parsearg($tml['opened'] . $tml['closed'], $args); } else { $args->add($item); if (strpos($tml['closed'], '$votes')) { $votes = $this->get_item_votes($id); foreach ($votes as $i => $v) { $args->__set('votes' . $i, $v); } } $result = $theme->parsearg($tml['closed'], $args); } return $result; }