Changeset 495032
- Timestamp:
- 01/25/2012 07:10:37 AM (14 years ago)
- Location:
- jazzy-forms/trunk
- Files:
-
- 8 edited
-
back/tpl-forms.php (modified) (2 diffs)
-
core/Tokenizer.php (modified) (1 diff)
-
front/ctrl-shortcode.php (modified) (1 diff)
-
front/jazzy-forms.js (modified) (2 diffs)
-
front/tmpl-list.php (modified) (3 diffs)
-
generated/schema.sql (modified) (1 diff)
-
jazzy-forms.php (modified) (5 diffs)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
jazzy-forms/trunk/back/tpl-forms.php
r491567 r495032 126 126 <select id="jzzf_selector"> 127 127 <?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> 129 129 <?php endforeach; ?> 130 130 </select> … … 138 138 <input id="jzzf_new_form_add" type="button" value="Add"><a href="" id="jzzf_new_form_cancel">Cancel</a> 139 139 </div> 140 <div id="message" class="updated" <?php if(!$msg): ?>style="display:none"<?php endif ?>><p><?php e cho 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> 141 141 <div id="jzzf_form"> 142 142 <ul id="jzzf_tabs"> -
jazzy-forms/trunk/core/Tokenizer.php
r491567 r495032 14 14 15 15 public function output() { 16 while($this->rest) { 16 while(true) { 17 $this->rest = ltrim($this->rest); 18 if(!$this->rest) 19 break; 17 20 if(!$this->operator()) { 18 21 if(!$this->positive()) { -
jazzy-forms/trunk/front/ctrl-shortcode.php
r491567 r495032 59 59 $tpl->foot($form); 60 60 $output = ob_get_clean(); 61 ob_end_clean();62 61 return $output; 63 62 } -
jazzy-forms/trunk/front/jazzy-forms.js
r491567 r495032 57 57 case 'r': 58 58 var idx = $('input:radio[name=jzzf_' + id + ']:checked').index('input:radio[name=jzzf_' + id + ']'); 59 if(idx> 0) {59 if(idx>=0) { 60 60 return jzzf_data[id][idx]; 61 61 } else { … … 66 66 case 'd': 67 67 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 } 69 73 case 'f': 70 74 return formula(id); -
jazzy-forms/trunk/front/tmpl-list.php
r491567 r495032 50 50 51 51 function number($element) { ?> 52 <label class="jzzf_number_label jzzf_element_label" for="jzzf_<?php e cho htmlspecialchars($element->name) ?>"><?php echo htmlspecialchars($element->title) ?></label>53 <input type="text" id="jzzf_<?php e cho 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) ?>"> 54 54 <?php 55 55 } 56 56 57 57 function radio($element) { ?> 58 <label class="jzzf_radio_label jzzf_element_label"><?php e cho htmlspecialchars($element->title) ?></label>58 <label class="jzzf_radio_label jzzf_element_label"><?php esc_html_e($element->title) ?></label> 59 59 <ul class="jzzf_radio"> 60 60 <?php $idx = 0; foreach($element->options as $option) { $idx++; ?> 61 61 <li> 62 <input type="radio" name="jzzf_<?php e cho htmlspecialchars($element->name) ?>"<?php if($option->default): ?> checked="checked"<?php endif ?>>63 <label class="jzzf_radio_option_label"><?php e cho 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> 64 64 </li> 65 65 <?php … … 69 69 70 70 function dropdown($element) { ?> 71 <label class="jzzf_element_label jzzf_dropdown_label"><?php e cho htmlspecialchars($element->title) ?></label>72 <select id="jzzf_<?php e cho 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) ?>"> 73 73 <?php foreach($element->options as $option) : ?> 74 <option<?php if($option->default): ?> checked="checked"<?php endif ?>><?php e cho htmlspecialchars($option->title) ?></option>74 <option<?php if($option->default): ?> checked="checked"<?php endif ?>><?php esc_html_e($option->title) ?></option> 75 75 <?php endforeach ?> 76 76 </select> … … 79 79 80 80 function checkbox($element) { ?> 81 <input type="checkbox" id="jzzf_<?php e cho htmlspecialchars($element->name) ?>"<?php if($element->default): ?> checked="checked"<?php endif ?>>82 <label class="jzzf_checkbox_label" for="jzzf_<?php e cho 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) ?> 83 83 <?php 84 84 } 85 85 86 86 function hidden($element) { ?> 87 <input type="hidden" id="jzzf_<?php e cho 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)?>"> 88 88 <?php 89 89 } 90 90 91 91 function output($element) { ?> 92 <label class="jzzf_element_label jzzf_output_label" for="jzzf_<?php e cho htmlspecialchars($name) ?>"><?php echo htmlspecialchars($element->title) ?></label>93 <input type="text" readonly="readonly" id="jzzf_<?php e cho 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 ?>> 94 94 <?php 95 95 } 96 96 97 97 function update($element) { ?> 98 <input type="submit" id="jzzf_<?php e cho 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) ?>"> 99 99 <?php 100 100 } -
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) );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) ) {{charset_collate}}; 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) ) {{charset_collate}}; 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) ) {{charset_collate}}; -
jazzy-forms/trunk/jazzy-forms.php
r491567 r495032 4 4 Plugin URI: http://www.jazzyforms.com/ 5 5 Description: Online form builder 6 Version: 0.9 6 Version: 0.9.1 7 7 Author: Igor Prochazka 8 8 Author URI: http://www.l90r.com/ … … 68 68 global $wpdb; 69 69 $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 70 79 foreach($schema as $line) { 71 80 $sql = trim($line); 72 81 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); 74 84 $wpdb->query($sql); 75 85 } … … 84 94 require_once(JZZF_CORE . 'Tokenizer.php'); 85 95 return jzzf_ctrl_shortcode($attr); 96 } 97 98 function 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 104 function 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 } 86 115 } 87 116 … … 101 130 102 131 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(); 106 133 } 107 134 … … 116 143 add_shortcode( 'jazzy', 'jzzf_shortcode' ); 117 144 add_filter('the_posts', 'jzzf_conditional_queuing'); 145 add_action('jzzf_enqueue', 'jzzf_enqueue'); 146 add_action('jzzf_form', 'jzzf_form', 2); 147 118 148 ?> -
jazzy-forms/trunk/readme.txt
r491567 r495032 5 5 Requires at least: 3.2.1 6 6 Tested up to: 3.3 7 Stable tag: 0.9 7 Stable tag: 0.9.1 8 8 9 9 Jazzy Forms is an online form generator that performs instant calculations. It's ideal for inter-active price calculators. … … 52 52 Replace 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. 53 53 54 = Is there a way to insert a form without a shortcode? = 55 56 The 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 58 Place 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 61 To insert a form with ID "form_id" do the following: 62 `<?php jzzf_form('form_id') ?>` 63 64 This 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 67 There 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 73 There 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');` 74 With this line the Text widget handles shortcodes. 75 54 76 = What are element IDs good for ? = 55 77 56 78 Each 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. 57 79 58 = What's format or syntax of a formula ? =80 = What's the format or syntax of a formula ? = 59 81 60 82 Formulas are thought to have a similar notation to what you are probably used to from popular spreadsheet programs. An example could be: 61 83 62 (base_price+price*quantity)*(1+tax/100) 84 `(base_price + price * quantity) * (1 + tax/100)` 63 85 64 86 where "base_price", "price", "quantity" and "tax" are IDs of other existing form elements. … … 67 89 68 90 Thank 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 94 Yes, 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). 69 95 70 96 = I have a suggestion = … … 78 104 == Changelog == 79 105 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 80 113 = 0.9 = 81 114 * Initial release (beta)
Note: See TracChangeset
for help on using the changeset viewer.