Ejemplo n.º 1
0
    /**
     * Back-end widget form.
     *
     * @see WP_Widget::form()
     *
     * @param array $instance Previously saved values from database.
     */
    public function form($instance)
    {
        if (isset($instance['title'])) {
            $title = $instance['title'];
        } else {
            $title = __('New title', 'text_domain');
        }
        if (isset($instance['poll_id'])) {
            $poll_id = $instance['poll_id'];
        } else {
            $poll_id = -1;
        }
        if (isset($instance['chwidth'])) {
            $chwidth = intval($instance['chwidth']);
        } else {
            $chwidth = 270;
        }
        if (isset($instance['chheight'])) {
            $chheight = intval($instance['chheight']);
        } else {
            $chheight = 220;
        }
        if ($chwidth == 0) {
            $chwidth = 270;
        }
        if ($chheight == 0) {
            $chheight = 220;
        }
        if (isset($instance['chlegend'])) {
            $chlegend = $instance['chlegend'];
        } else {
            $chlegend = 'none';
        }
        $polls = GFontsDB::GetAllPolls();
        ?>
        <p>
            <label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:', GFontsEngine::PLUGIN_SLUG);
        ?>
</label>
            <input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo esc_attr($title);
        ?>
" />
            <br/><br/>
            <label for="<?php 
        echo $this->get_field_id('poll_id');
        ?>
"><?php 
        _e('Select poll:', GFontsEngine::PLUGIN_SLUG);
        ?>
</label>
            <select class="widefat" id="<?php 
        echo $this->get_field_id('poll_id');
        ?>
" name="<?php 
        echo $this->get_field_name('poll_id');
        ?>
">
                <option value="-1"><?php 
        _e('-- select --', GFontsEngine::PLUGIN_SLUG);
        ?>
</option>
                <?php 
        foreach ($polls as $poll) {
            ?>
<option value="<?php 
            echo $poll->id;
            ?>
"<?php 
            if ($poll->id == $poll_id) {
                echo " selected";
            }
            ?>
><?php 
            echo $poll->name;
            ?>
</option><?php 
        }
        ?>
            </select>
            <br/>
            <br/>
            <label for="<?php 
        echo $this->get_field_id('chwidth');
        ?>
"><?php 
        _e('Chart width:', GFontsEngine::PLUGIN_SLUG);
        ?>
</label>
            <input class="widefat" id="<?php 
        echo $this->get_field_id('chwidth');
        ?>
" name="<?php 
        echo $this->get_field_name('chwidth');
        ?>
" type="text" value="<?php 
        echo esc_attr($chwidth);
        ?>
" />
            <br/>
            <br/>
            <label for="<?php 
        echo $this->get_field_id('chheight');
        ?>
"><?php 
        _e('Chart height:', GFontsEngine::PLUGIN_SLUG);
        ?>
</label>
            <input class="widefat" id="<?php 
        echo $this->get_field_id('chheight');
        ?>
" name="<?php 
        echo $this->get_field_name('chheight');
        ?>
" type="text" value="<?php 
        echo esc_attr($chheight);
        ?>
" />
            <br/>
            <br/>
            <label for="<?php 
        echo $this->get_field_id('chlegend');
        ?>
"><?php 
        _e('Chart legend (only for Pie and Donut):', GFontsEngine::PLUGIN_SLUG);
        ?>
</label>
            <select class="widefat" id="<?php 
        echo $this->get_field_id('chlegend');
        ?>
" name="<?php 
        echo $this->get_field_name('chlegend');
        ?>
">
                <option value="none"<?php 
        if ($chlegend == 'none') {
            echo ' selected';
        }
        ?>
><?php 
        _e('none', GFontsEngine::PLUGIN_SLUG);
        ?>
</option>
                <option value="left"<?php 
        if ($chlegend == 'left') {
            echo ' selected';
        }
        ?>
><?php 
        _e('left', GFontsEngine::PLUGIN_SLUG);
        ?>
</option>
                <option value="right"<?php 
        if ($chlegend == 'right') {
            echo ' selected';
        }
        ?>
><?php 
        _e('right', GFontsEngine::PLUGIN_SLUG);
        ?>
</option>
                <option value="top"<?php 
        if ($chlegend == 'top') {
            echo ' selected';
        }
        ?>
><?php 
        _e('top', GFontsEngine::PLUGIN_SLUG);
        ?>
</option>
                <option value="bottom"<?php 
        if ($chlegend == 'bottom') {
            echo ' selected';
        }
        ?>
><?php 
        _e('bottom', GFontsEngine::PLUGIN_SLUG);
        ?>
</option>
            </select>
        </p>
        <?php 
    }
Ejemplo n.º 2
0
 /** @noinspection PhpMissingDocCommentInspection */
 public static function AddAttachmentsToLayoutExport(&$gtl_settings, &$xml)
 {
     $regex = '/' . str_replace('/', '\\/', WP_CONTENT_URL) . '\\/uploads\\/[^"]+/im';
     $matches = array();
     $n = null;
     if (preg_match_all($regex, $gtl_settings, $matches)) {
         $n = array();
         foreach ($matches[0] as $url) {
             if (!isset($n[$url])) {
                 $n[$url] = GFontsDB::uuid();
             }
         }
         /* @var $wpdb wpdb */
         global $wpdb;
         $attachments = array();
         foreach ($n as $url => $uuid) {
             $loc = str_replace(WP_CONTENT_URL, WP_CONTENT_DIR, $url);
             $sql = $wpdb->prepare("SELECT * FROM {$wpdb->prefix}posts WHERE guid = %s AND post_type = 'attachment' AND post_status = 'inherit'", $url);
             $att = $wpdb->get_row($sql);
             if ($att != null) {
                 $pinfo = pathinfo($loc);
                 $attachments[] = array('guid' => $url, 'uuid' => $uuid, 'diskloc' => $loc, 'mime_type' => $att->post_mime_type, 'extension' => isset($pinfo['extension']) ? $pinfo['extension'] : null);
             }
         }
         if (count($attachments) > 0) {
             $xml .= "<attachments>\n";
             foreach ($attachments as $attachment) {
                 $xml .= "<attachment>\n";
                 $xml .= "<guid>" . $attachment['uuid'] . "</guid>\n";
                 $xml .= "<mimetype>" . $attachment['mime_type'] . "</mimetype>\n";
                 $xml .= "<ext>" . $attachment['extension'] . "</ext>\n";
                 $xml .= "<data>" . base64_encode(file_get_contents($attachment['diskloc'])) . "</data>\n";
                 $xml .= "</attachment>\n";
             }
             $xml .= "</attachments>\n";
         }
     }
     $gtl = unserialize($gtl_settings);
     if (is_array($n)) {
         self::ReplaceAttachmentsInExportArray($gtl, $n);
     }
     $gtl_settings = serialize($gtl);
 }
 public static function FontsListFilter($fonts)
 {
     if (!is_array($fonts)) {
         $fonts = array();
     }
     $extraFonts = GFontsDB::GetInstalledFonts();
     $aFonts = array();
     foreach ($extraFonts as $item) {
         $aFonts[] = $item->name;
     }
     $aFonts[] = 'Andale Mono';
     $aFonts[] = 'Arial';
     $aFonts[] = 'Arial Black';
     $aFonts[] = 'Book Antiqua';
     $aFonts[] = 'Comic Sans MS';
     $aFonts[] = 'Courier New';
     $aFonts[] = 'Georgia';
     $aFonts[] = 'Helvetica;';
     $aFonts[] = 'Impact';
     $aFonts[] = 'Symbol';
     $aFonts[] = 'Tahoma';
     $aFonts[] = 'Terminal';
     $aFonts[] = 'Times New Roman';
     $aFonts[] = 'Trebuchet MS';
     $aFonts[] = 'Verdana';
     $aFonts[] = 'Webdings';
     $aFonts[] = 'Wingdings';
     foreach ($aFonts as $aFont) {
         if (!isset($fonts[$aFont])) {
             $fonts[] = $aFont;
         }
     }
     return $fonts;
 }
Ejemplo n.º 4
0
 public static function PollOutputForShortCode($poll_id, $width, $height, $legend = 'none')
 {
     $output = "";
     $oPoll = GFontsDB::GetPoll($poll_id);
     if ($oPoll) {
         $client_mode = $oPoll->client_mode;
         $allowed = true;
         $ip = $_SERVER['REMOTE_ADDR'];
         if (isset($_SERVER['HTTP_X_REAL_IP'])) {
             $ip = $_SERVER['HTTP_X_REAL_IP'];
         }
         $allowed = $oPoll->voting_enabled == 1;
         if ($allowed) {
             $enddate = strtotime($oPoll->voting_end_date);
             $today = time();
             if ($enddate < $today) {
                 $allowed = false;
             }
         }
         if ($client_mode == 0) {
             $w = $_COOKIE;
             if (isset($_COOKIE['poll_vote_' . $poll_id])) {
                 $allowed = false;
             }
         } else {
             $c = GFontsDB::CheckVoteIpForPoll($poll_id, $ip);
             if ($c > 0) {
                 $allowed = false;
             }
         }
         $args['widget_id'] = uniqid();
         if (!$allowed) {
             $output .= $oPoll->title . "<br/>";
             $output .= '<span id="wgarea_' . $args['widget_id'] . '_' . $poll_id . '" style="width: 100%;">';
             $output .= GF_Poll_Output::GeneratePollOutput($oPoll, 'wgarea_' . $args['widget_id'] . '_' . $poll_id, $width, $height, $legend);
             $output .= '</span>';
         } else {
             wp_enqueue_script('gf-poll-service-' . $poll_id, PLUGIN_URL . "js/gf-poll.php?id=" . $poll_id . '&wid=' . $args['widget_id'] . '&width=' . $width . '&height=' . $height . '&legend=' . $legend);
             $trans = array('noanswer' => GFontsLang::GetTranslation('Please select answer'), 'ajaxerror' => GFontsLang::GetTranslation('Some error happened'), 'ajaxurl' => admin_url('admin-ajax.php'));
             wp_localize_script('gf-poll-service-' . $poll_id, 'objPollServiceTrans', $trans);
             $output .= $oPoll->title . '<br/>';
             $output .= '<span id="wgarea_' . $args['widget_id'] . '_' . $poll_id . '">';
             $answers = GFontsDB::GetAnswersForPoll($poll_id);
             if (is_array($answers)) {
                 $output .= '<span style="text-align: left; float: left;">';
                 foreach ($answers as $answer) {
                     $output .= '<input type="radio" name="poll_' . $args['widget_id'] . '" id="poll_' . $args['widget_id'] . '-' . $answer->id . '" value="' . $answer->id . '" style="-webkit-appearance: radio;"/>&nbsp;<label for="poll_' . $args['widget_id'] . '-' . $answer->id . '">' . stripslashes($answer->answer) . '</label><br/>';
                 }
                 $output .= '</span><br/><br/><center><input type="submit" value="' . __(trim($oPoll->button_title) != '' ? $oPoll->button_title : 'Vote') . '" id="btn_' . $poll_id . '_' . $args['widget_id'] . '"/></center>';
             }
         }
     }
     $output .= '</span>';
     return $output;
 }
</button>
</div>
<div id="s2" style="display: none;" class="steper">
    <form method="post">
        <br/>
        <strong><?php 
_e("Select created and active polls", GFontsEngine::PLUGIN_SLUG);
?>
</strong><br/><br/>
        <select name="gf_poll_id" id="gf_poll_id" style="width: 200px;">
            <option value="0"><?php 
_e('-- select --', GFontsEngine::PLUGIN_SLUG);
?>
</option>
            <?php 
$Polls = GFontsDB::GetActivePolls();
foreach ($Polls as $poll) {
    echo '<option value="' . $poll->id . '">' . $poll->title . '</option>';
}
?>
        </select><br/>
        <strong><?php 
_e('Poll chart width', GFontsEngine::PLUGIN_SLUG);
?>
</strong><br/><br/><input type="text" id="gf_poll_width" value="450" style="width: 200px;"/><br/>
        <strong><?php 
_e('Poll chart height', GFontsEngine::PLUGIN_SLUG);
?>
</strong><br/><br/><input type="text" id="gf_poll_height" value="300" style="width: 200px;"/><br/>
        <br/>
        <strong><?php