function generate_content(&$title)
 {
     global $serendipity;
     $title = $this->get_config('title');
     serendipity_common_pollbox::poll();
     echo '<br /><a class="votearchive" href="' . $serendipity['baseURL'] . $serendipity['indexFile'] . '?serendipity[subpage]=votearchive">' . ARCHIVES . '</a>';
 }
    function showBackend()
    {
        global $serendipity;
        if ($serendipity['POST']['pollSave'] || $serendipity['POST']['pollOptionAdd'] || is_array($serendipity['POST']['pollOptionRemove'])) {
            $serendipity['POST']['pollSubmit'] = true;
            if ($serendipity['POST']['poll'] == '__new') {
                $serendipity['POST']['poll'] = $this->insertPoll();
            } else {
                $this->updatePoll($serendipity['POST']['poll']);
                $this->updateOptions($serendipity['POST']['poll'], $serendipity['POST']['pollOptions']);
            }
        }
        if ($serendipity['POST']['pollOptionAdd']) {
            $serendipity['POST']['pollSubmit'] = true;
            $this->addOption($serendipity['POST']['poll'], $serendipity['POST']['pollNewOption']);
        }
        if (is_array($serendipity['POST']['pollOptionRemove'])) {
            $serendipity['POST']['pollSubmit'] = true;
            foreach ($serendipity['POST']['pollOptionRemove'] as $optid => $optval) {
                $this->deleteOption($optid);
            }
        }
        if ($serendipity['POST']['poll'] != '__new') {
            $this->poll = serendipity_common_pollbox::fetchPoll($serendipity['POST']['poll']);
        }
        if ($serendipity['version'][0] == '2') {
            echo '<h2>' . PLUGIN_POLL_SELECT . '</h2>';
        }
        if (!empty($serendipity['POST']['pollDelete']) && $serendipity['POST']['poll'] != '__new') {
            serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}polls WHERE id = " . (int) $serendipity['POST']['poll']);
            serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}polls_options WHERE pollid = " . (int) $serendipity['POST']['poll']);
            if ($serendipity['version'][0] == '1') {
                ?>
    <div class="serendipityAdminMsgSuccess"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="<?php 
                echo serendipity_getTemplateFile('admin/img/admin_msg_success.png');
                ?>
" alt="" /><?php 
                echo DONE . ': ' . sprintf(RIP_ENTRY, (int) $serendipity['POST']['poll']);
                ?>
</div>
<?php 
            } else {
                ?>
    <span class="msg_success"><span class="icon-ok-circled"></span> <?php 
                echo DONE . ': ' . sprintf(RIP_ENTRY, (int) $serendipity['POST']['poll']);
                ?>
</span>
<?php 
            }
        }
        if (!empty($serendipity['POST']['pollActivate']) && $serendipity['POST']['poll'] != '__new') {
            serendipity_db_query("UPDATE {$serendipity['dbPrefix']}polls SET active = 0");
            serendipity_db_query("UPDATE {$serendipity['dbPrefix']}polls SET active = 1 WHERE id = " . (int) $serendipity['POST']['poll']);
        }
        echo '<form action="serendipity_admin.php" method="post" id="serendipity_poll_form">';
        echo '<div>';
        echo '  <input type="hidden" name="serendipity[adminModule]" value="event_display" />';
        echo '  <input type="hidden" name="serendipity[adminAction]" value="poll" />';
        echo '</div>';
        if ($serendipity['version'][0] == '1') {
            echo '<div>';
        } else {
            echo '<div class="form_select">';
        }
        if ($serendipity['version'][0] == '1') {
            echo '<strong>' . PLUGIN_POLL_SELECT . '</strong><br /><br />';
        }
        echo '<select name="serendipity[poll]">';
        echo ' <option value="__new">' . NEW_ENTRY . '</option>';
        echo ' <option value="__new">-----------------</option>';
        $polls =& $this->fetchPolls();
        if (is_array($polls)) {
            foreach ($polls as $poll) {
                echo ' <option value="' . $poll['id'] . '" ' . ($serendipity['POST']['poll'] == $poll['id'] ? 'selected="selected"' : '') . '>';
                echo ($poll['active'] == 1 ? '*' : '') . (function_exists('serendipity_specialchars') ? serendipity_specialchars($poll['title']) : htmlspecialchars($poll['title'], ENT_COMPAT, LANG_CHARSET)) . ' (' . serendipity_strftime('%d.%m.%Y', $poll['timestamp']) . ')</option>';
            }
        }
        if ($serendipity['version'][0] == '1') {
            echo '</select> <input class="serendipityPrettyButton input_button" type="submit" name="serendipity[pollSubmit]" value="' . GO . '" />';
            echo ' <strong>-' . WORD_OR . '-</strong> <input class="serendipityPrettyButton input_button" type="submit" name="serendipity[pollDelete]" value="' . DELETE . '" />';
            echo ' <strong>-' . WORD_OR . '-</strong> <input class="serendipityPrettyButton input_button" type="submit" name="serendipity[pollActivate]" value="' . PLUGIN_POLL_ACTIVATE . '" />';
        } else {
            echo '</select>';
            echo ' <input type="submit" name="serendipity[pollSubmit]" value="' . EDIT . '">';
            echo ' <input class="state_cancel" type="submit" name="serendipity[pollDelete]" value="' . DELETE . '">';
            echo ' <input type="submit" name="serendipity[pollActivate]" value="' . PLUGIN_POLL_ACTIVATE . '">';
        }
        echo '</div>';
        if ($serendipity['POST']['pollSubmit']) {
            if ($serendipity['version'][0] == '1') {
                echo '<div>';
            } else {
                echo '<div class="clearfix">';
            }
            $this->showForm();
            echo '</div>';
        }
        echo '</form>';
    }
Ejemplo n.º 3
0
 static function poll($pollid = null)
 {
     $poll = new serendipity_common_pollbox();
     $poll->setPoll($poll->fetchPoll($pollid));
     $poll->showPoll($pollid);
 }