Plugin Directory

Changeset 495032


Ignore:
Timestamp:
01/25/2012 07:10:37 AM (14 years ago)
Author:
jazzigor
Message:

Uploading v0.9.1 to trunk

Location:
jazzy-forms/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • jazzy-forms/trunk/back/tpl-forms.php

    r491567 r495032  
    126126    <select id="jzzf_selector">
    127127<?php $i=0; foreach($forms as $form) : ?>
    128         <option value="<?php echo $i++ ?>"><?php echo htmlspecialchars($form->title) ?></option>
     128        <option value="<?php echo $i++ ?>"><?php echo esc_attr($form->title) ?></option>
    129129<?php endforeach; ?>
    130130    </select>
     
    138138    <input id="jzzf_new_form_add" type="button" value="Add"><a href="" id="jzzf_new_form_cancel">Cancel</a>
    139139</div>
    140 <div id="message" class="updated" <?php if(!$msg): ?>style="display:none"<?php endif ?>><p><?php echo htmlspecialchars($msg) ?></p></div>
     140<div id="message" class="updated" <?php if(!$msg): ?>style="display:none"<?php endif ?>><p><?php esc_html_e($msg) ?></p></div>
    141141<div id="jzzf_form">
    142142    <ul id="jzzf_tabs">
  • jazzy-forms/trunk/core/Tokenizer.php

    r491567 r495032  
    1414
    1515    public function output() {
    16         while($this->rest) {
     16        while(true) {
     17            $this->rest = ltrim($this->rest);
     18            if(!$this->rest)
     19                break;
    1720            if(!$this->operator()) {
    1821                if(!$this->positive()) {
  • jazzy-forms/trunk/front/ctrl-shortcode.php

    r491567 r495032  
    5959    $tpl->foot($form);
    6060    $output = ob_get_clean();
    61     ob_end_clean();
    6261    return $output;
    6362}
  • jazzy-forms/trunk/front/jazzy-forms.js

    r491567 r495032  
    5757            case 'r':
    5858                var idx = $('input:radio[name=jzzf_' + id + ']:checked').index('input:radio[name=jzzf_' + id + ']');
    59                 if(idx>0) {
     59                if(idx>=0) {
    6060                    return jzzf_data[id][idx];
    6161                } else {
     
    6666            case 'd':
    6767                var idx = $('#jzzf_' + id + ' option:selected').index('#jzzf_' + id + ' option');
    68                 return jzzf_data[id][idx];
     68                if(idx>=0) {
     69                    return jzzf_data[id][idx];
     70                } else {
     71                    return 0;
     72                }
    6973            case 'f':
    7074                return formula(id);
  • jazzy-forms/trunk/front/tmpl-list.php

    r491567 r495032  
    5050   
    5151    function number($element) { ?>
    52     <label class="jzzf_number_label jzzf_element_label" for="jzzf_<?php echo htmlspecialchars($element->name) ?>"><?php echo htmlspecialchars($element->title) ?></label>
    53     <input type="text" id="jzzf_<?php echo htmlspecialchars($element->name) ?>" value="<?php echo htmlspecialchars($element->default) ?>">
     52    <label class="jzzf_number_label jzzf_element_label" for="jzzf_<?php esc_attr_e($element->name) ?>"><?php esc_html_e($element->title) ?></label>
     53    <input type="text" id="jzzf_<?php esc_attr_e($element->name) ?>" value="<?php esc_attr_e($element->default) ?>">
    5454<?php
    5555    }
    5656   
    5757    function radio($element) { ?>
    58     <label class="jzzf_radio_label jzzf_element_label"><?php echo htmlspecialchars($element->title) ?></label>
     58    <label class="jzzf_radio_label jzzf_element_label"><?php esc_html_e($element->title) ?></label>
    5959    <ul class="jzzf_radio">
    6060    <?php $idx = 0; foreach($element->options as $option) { $idx++; ?>
    6161    <li>
    62         <input type="radio" name="jzzf_<?php echo htmlspecialchars($element->name) ?>"<?php if($option->default): ?> checked="checked"<?php endif ?>>
    63         <label class="jzzf_radio_option_label"><?php echo htmlspecialchars($option->title) ?></label>
     62        <input type="radio" name="jzzf_<?php esc_attr_e($element->name) ?>"<?php if($option->default): ?> checked="checked"<?php endif ?>>
     63        <label class="jzzf_radio_option_label"><?php esc_html_e($option->title) ?></label>
    6464    </li>
    6565<?php
     
    6969   
    7070    function dropdown($element) { ?>
    71     <label class="jzzf_element_label jzzf_dropdown_label"><?php echo htmlspecialchars($element->title) ?></label>
    72     <select id="jzzf_<?php echo htmlspecialchars($element->name) ?>">
     71    <label class="jzzf_element_label jzzf_dropdown_label"><?php esc_html_e($element->title) ?></label>
     72    <select id="jzzf_<?php esc_attr_e($element->name) ?>">
    7373    <?php foreach($element->options as $option) : ?>
    74     <option<?php if($option->default): ?> checked="checked"<?php endif ?>><?php echo htmlspecialchars($option->title) ?></option>
     74    <option<?php if($option->default): ?> checked="checked"<?php endif ?>><?php esc_html_e($option->title) ?></option>
    7575    <?php endforeach ?>
    7676    </select>
     
    7979
    8080    function checkbox($element) { ?>
    81     <input type="checkbox" id="jzzf_<?php echo htmlspecialchars($element->name) ?>"<?php if($element->default): ?> checked="checked"<?php endif ?>>
    82     <label class="jzzf_checkbox_label" for="jzzf_<?php echo htmlspecialchars($element->name) ?>"><?php echo htmlspecialchars($element->title) ?>
     81    <input type="checkbox" id="jzzf_<?php esc_attr_e($element->name) ?>"<?php if($element->default): ?> checked="checked"<?php endif ?>>
     82    <label class="jzzf_checkbox_label" for="jzzf_<?php esc_attr_e($element->name) ?>"><?php esc_html_e($element->title) ?>
    8383<?php
    8484    }
    8585   
    8686    function hidden($element) { ?>
    87         <input type="hidden" id="jzzf_<?php echo htmlspecialchars($element->name) ?>" value="<?php echo htmlspecialchars($element->value)?>">
     87        <input type="hidden" id="jzzf_<?php esc_attr_e($element->name) ?>" value="<?php esc_attr_e($element->value)?>">
    8888<?php
    8989    }
    9090   
    9191    function output($element) { ?>
    92         <label class="jzzf_element_label jzzf_output_label" for="jzzf_<?php echo htmlspecialchars($name) ?>"><?php echo htmlspecialchars($element->title) ?></label>
    93         <input type="text" readonly="readonly" id="jzzf_<?php echo htmlspecialchars($element->name) ?>"<?php if($element->invalid) : ?> value="Invalid formula"<?php endif ?>>
     92        <label class="jzzf_element_label jzzf_output_label" for="jzzf_<?php esc_attr_e($name) ?>"><?php esc_html_e($element->title) ?></label>
     93        <input type="text" readonly="readonly" id="jzzf_<?php esc_attr_e($element->name) ?>"<?php if($element->invalid) : ?> value="Invalid formula"<?php endif ?>>
    9494<?php
    9595    }
    9696
    9797    function update($element) { ?>
    98         <input type="submit" id="jzzf_<?php echo htmlspecialchars($element->name) ?>" value="<?php echo htmlspecialchars($element->title) ?>">
     98        <input type="submit" id="jzzf_<?php esc_attr_e($element->name) ?>" value="<?php esc_attr_e($element->title) ?>">
    9999<?php
    100100    }
  • jazzy-forms/trunk/generated/schema.sql

    r491567 r495032  
    1 CREATE TABLE IF NOT EXISTS {prefix}jzzf_form ( id bigint(20) AUTO_INCREMENT, `title` varchar(1024) NOT NULL,`name` varchar(1024) NOT NULL,`theme` int(12) NOT NULL,`css` varchar(1024) NOT NULL, PRIMARY KEY (id) );
    2 CREATE TABLE IF NOT EXISTS {prefix}jzzf_element ( id bigint(20) AUTO_INCREMENT, `form` bigint(20) NOT NULL,`order` int(12) NOT NULL,`type` varchar(1024) NOT NULL,`title` varchar(1024) NOT NULL,`name` varchar(1024) NOT NULL,`formula` varchar(1024) NOT NULL,`value` varchar(1024) NOT NULL,`value2` varchar(1024) NOT NULL,`default` varchar(1024) NOT NULL,`external` int(1) NOT NULL,`params` varchar(2048) NOT NULL, PRIMARY KEY (id) );
    3 CREATE TABLE IF NOT EXISTS {prefix}jzzf_option ( id bigint(20) AUTO_INCREMENT, `order` int(12) NOT NULL,`element` bigint(20) NOT NULL,`default` int(1) NOT NULL,`title` varchar(1024) NOT NULL,`name` varchar(1024) NOT NULL,`value` varchar(1024) NOT NULL, PRIMARY KEY (id) );
     1CREATE TABLE IF NOT EXISTS {{prefix}}jzzf_form ( id bigint(20) AUTO_INCREMENT, `title` varchar(1024) NOT NULL,`name` varchar(1024) NOT NULL,`theme` int(12) NOT NULL,`css` varchar(1024) NOT NULL, PRIMARY KEY (id) ) {{charset_collate}};
     2CREATE TABLE IF NOT EXISTS {{prefix}}jzzf_element ( id bigint(20) AUTO_INCREMENT, `form` bigint(20) NOT NULL,`order` int(12) NOT NULL,`type` varchar(1024) NOT NULL,`title` varchar(1024) NOT NULL,`name` varchar(1024) NOT NULL,`formula` varchar(1024) NOT NULL,`value` varchar(1024) NOT NULL,`value2` varchar(1024) NOT NULL,`default` varchar(1024) NOT NULL,`external` int(1) NOT NULL,`params` varchar(2048) NOT NULL, PRIMARY KEY (id) ) {{charset_collate}};
     3CREATE TABLE IF NOT EXISTS {{prefix}}jzzf_option ( id bigint(20) AUTO_INCREMENT, `order` int(12) NOT NULL,`element` bigint(20) NOT NULL,`default` int(1) NOT NULL,`title` varchar(1024) NOT NULL,`name` varchar(1024) NOT NULL,`value` varchar(1024) NOT NULL, PRIMARY KEY (id) ) {{charset_collate}};
  • jazzy-forms/trunk/jazzy-forms.php

    r491567 r495032  
    44Plugin URI: http://www.jazzyforms.com/
    55Description: Online form builder
    6 Version: 0.9
     6Version: 0.9.1
    77Author: Igor Prochazka
    88Author URI: http://www.l90r.com/
     
    6868    global $wpdb;
    6969    $schema = file( dirname(__FILE__) . '/generated/schema.sql' );
     70
     71    if(!empty($wpdb->charset)) {
     72        $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
     73    }
     74   
     75    if(!empty($wpdb->collate)) {
     76        $charset_collate .= " COLLATE $wpdb->collate";
     77    }
     78       
    7079    foreach($schema as $line) {
    7180        $sql = trim($line);
    7281        if($sql && $sql[0] != '#') {
    73             $sql = str_replace('{prefix}', $wpdb->prefix, $sql);
     82            $sql = str_replace('{{prefix}}', $wpdb->prefix, $sql);
     83            $sql = str_replace('{{charset_collate}}', $charset_collate, $sql);
    7484            $wpdb->query($sql);
    7585        }
     
    8494    require_once(JZZF_CORE . 'Tokenizer.php');
    8595    return jzzf_ctrl_shortcode($attr);
     96}
     97
     98function jzzf_enqueue() {
     99    wp_register_script('jazzy-forms', plugins_url('jazzy-forms/front/jazzy-forms.js'), array('jquery'), '1.0');
     100    wp_enqueue_script('jquery');
     101    wp_enqueue_script('jazzy-forms');
     102}
     103
     104function jzzf_form($id, $attr=null, $return=false) {
     105    if($attr === null) {
     106        $attr = array();
     107    }
     108    $attr['form'] = $id;
     109    $out = jzzf_shortcode($attr);
     110    if($return) {
     111        return $out;
     112    } else {
     113        echo $out;
     114    }
    86115}
    87116
     
    101130
    102131    if($shortcode_found) {
    103         wp_register_script('jazzy-forms', plugins_url('jazzy-forms/front/jazzy-forms.js'), array('jquery'), '1.0');
    104         wp_enqueue_script('jquery');
    105         wp_enqueue_script('jazzy-forms');
     132        jzzf_enqueue();
    106133    }
    107134
     
    116143add_shortcode( 'jazzy', 'jzzf_shortcode' );
    117144add_filter('the_posts', 'jzzf_conditional_queuing');
     145add_action('jzzf_enqueue', 'jzzf_enqueue');
     146add_action('jzzf_form', 'jzzf_form', 2);
     147
    118148?>
  • jazzy-forms/trunk/readme.txt

    r491567 r495032  
    55Requires at least: 3.2.1
    66Tested up to: 3.3
    7 Stable tag: 0.9
     7Stable tag: 0.9.1
    88
    99Jazzy Forms is an online form generator that performs instant calculations. It's ideal for inter-active price calculators.
     
    5252Replace FORM_ID with the ID of the form you want to add. The complete shortcode for your form is also displayed on its administration screen in the "General" tab. Copy and paste it from there.
    5353
     54= Is there a way to insert a form without a shortcode? =
     55
     56The short code is useful for posts or pages, without the need of any coding. Alternatively programmers and theme designers can also use the corresponding PHP functions to do so.
     57
     58Place the following code in the header, before a call to wp_head(), in order to queue Jazzy Forms' JavaScript scripts:
     59`<?php jzzf_queue() ?>`
     60
     61To insert a form with ID "form_id" do the following:
     62`<?php jzzf_form('form_id') ?>`
     63
     64This prints out the form to the screen. If you need to process the output in any way use something like this:
     65`<?php echo jzzf_form('form_id', null, true) ?>`
     66
     67There are also corresponding WordPress actions:
     68`<?php do_action('jzzf_queue') ?>`
     69`<?php do_action('jzzf_form', 'form_id') ?>`
     70
     71= Is there a way to use a Jazzy Form within a widget? =
     72
     73There is no Jazzy Forms widget yet, but you can use the shortcode within WordPress'es default "Text" widget with minor trickery: use the `<?php jzzf_queue() ?>` in order to queue Jazzy Forms' JavaScript as described in the previous section. Then add the following line somewhere, e.g. at the and of your theme's "functions.php" file: `add_filter('widget_text','do_shortcode');`
     74With this line the Text widget handles shortcodes.
     75
    5476= What are element IDs good for ? =
    5577
    5678Each element is assigned a so called ID (identifier) that you can choose. These IDs are used to reference the form elements' values in formulas. IDs must start with a letter (a-z) and be all lower-case characters or numbers. Special characters or white space are not permitted.
    5779
    58 = What's format or syntax of a formula ? =
     80= What's the format or syntax of a formula ? =
    5981
    6082Formulas are thought to have a similar notation to what you are probably used to from popular spreadsheet programs. An example could be:
    6183
    62 (base_price+price*quantity)*(1+tax/100)
     84`(base_price + price * quantity) * (1 + tax/100)`
    6385
    6486where "base_price", "price", "quantity" and "tax" are IDs of other existing form elements.
     
    6789
    6890Thank you. For this project your feedback, your ideas and suggestions are much more valuable for me than your money! So please drop me an email instead.
     91
     92= Is there a list of known issues? =
     93
     94Yes, Jazzy Forms is still at an early stage. Bugs and enhancement request are tracked [here](https://github.com/l90r/jazzy-forms-dev/issues?sort=created&direction=desc&state=open).
    6995
    7096= I have a suggestion =
     
    78104== Changelog ==
    79105
     106= 0.9.1 =
     107* Correctly handle character sets and collations (including Russian)
     108* Fixed values for radio buttons
     109* Accept whitespace in formulas
     110* Adding insertion/queueing functions for the use in themes instead of the shortcode
     111* Fixed post insertion that sporadically caused partial loss of WordPress HTML code
     112
    80113= 0.9 =
    81114* Initial release (beta)
Note: See TracChangeset for help on using the changeset viewer.