public function getcontent() { $html = tadminhtml::i(); $lang = tlocal::admin('polls'); $args = new targs(); //note to open admin menus $result = $html->h3->noteoptions; $polls = tpolls::i(); $man = tpollsman::i(); $args->addtopost = $man->addtopost; $items = array(); $polls->loadall_tml(); foreach ($polls->tml_items as $id => $tml) { $items[$id] = $tml['name']; } $args->pollpost = tadminhtml::array2combo($items, $man->pollpost); $args->lifetime = $man->lifetime; $args->formtitle = $lang->Options; $result .= $html->adminform(' [checkbox=addtopost] [combo=pollpost] [text=lifetime] ', $args); return $result; }
public function getitem($id) { $polls = tpolls::i(); $item = $polls->getitem($id); $item['votes'] = $polls->get_item_votes($id); return $item; }
public function postsdeleted(array $items) { $deleted = implode(',', $items); $db = $this->getdb($this->childtable); $idpolls = $db->res2id($db->query("select poll from {$db->prefix}{$this->childtable} where (id in ({$deleted})) and (poll > 0)")); if (count($idpolls) > 0) { $polls = tpolls::i(); foreach ($idpolls as $idpoll) { $pols->delete($idpoll); } } }
public function processform() { $polls = tpolls::i(); if ($action = $this->action) { switch ($action) { case 'edit': $polls->edit($this->idget(), $_POST['id_tml'], $_POST['status']); break; case 'add': $id = $polls->add($_POST['id_tml'], $_POST['status']); return litepublisher::$urlmap->redir($this->adminurl . '=' . $id . '&action=edit'); case 'create': if ($id_tml = tadminpolltemplates::i()->addtml()) { $id = $polls->add($id_tml, $_POST['status']); return litepublisher::$urlmap->redir($this->adminurl . '=' . $id . '&action=edit'); } else { return $this->html->empty; } break; } } }
public function closepoll() { $polls = tpolls::i(); $polls->db->setvalue($this->poll, 'status', 'closed'); }
public function addtml() { $type = $_POST['type']; $name = tcontentfilter::escape($_POST['name']); $title = tcontentfilter::escape($_POST['title']); $items = strtoarray(str_replace(array("\r\n", "\r"), "\n", trim($_POST['newitems']))); $items = array_unique($items); array_delete_value($items, ''); if (count($items) == 0) { return false; } return tpolls::i()->add_tml($type, $name, $title, $items); }
public function filter(&$content) { if (preg_match_all('/\\[poll\\=(\\d*?)\\]/', $content, $m, PREG_SET_ORDER)) { $polls = tpolls::i(); foreach ($m as $item) { $id = (int) $item[1]; if ($polls->itemexists($id)) { $html = $polls->gethtml($id); $html = '[html]' . $html . '[/html]'; } else { $html = ''; } $content = str_replace($item[0], $html, $content); } } }