Changeset 4166
- Timestamp:
- 06/06/07 00:00:14 (3 years ago)
- Files:
-
- branches/dwhittle/data/config/settings.yml (modified) (3 diffs)
- branches/dwhittle/data/skeleton/app/app/config/settings.yml (modified) (1 diff)
- branches/dwhittle/lib/helper/AssetHelper.php (modified) (13 diffs)
- branches/dwhittle/lib/helper/FormHelper.php (modified) (32 diffs)
- branches/dwhittle/lib/helper/JavascriptHelper.php (modified) (4 diffs)
- branches/dwhittle/lib/helper/TagHelper.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dwhittle/data/config/settings.yml
r3688 r4166 13 13 secure_action: secure # The credentials required for an action 14 14 15 module_disabled_module: default # To be called when a user requests 15 module_disabled_module: default # To be called when a user requests 16 16 module_disabled_action: disabled # A module disabled in the module.yml 17 17 … … 53 53 web_debug: off # Enable the web debug toolbar 54 54 error_reporting: 341 # Determines which events are logged. The default value is E_PARSE | E_COMPILE_ERROR | E_ERROR | E_CORE_ERROR | E_USER_ERROR = 341 55 xdebug: off # Enable xdebug stack trace in the logs, if xdebug is not available this has no effect. 55 56 56 57 # Assets paths … … 63 64 # Helpers included in all templates by default 64 65 standard_helpers: [Partial, Cache, Form] 66 67 use_xhtml_tags: on # use open (html style) or closed (xhtml style) tags, on by default 65 68 66 69 # Activated modules from plugins or from the symfony core branches/dwhittle/data/skeleton/app/app/config/settings.yml
r4163 r4166 87 87 # standard_helpers: [Partial, Cache, Form] 88 88 # 89 # use_xhtml_tags: on # use open (html style) or closed (xhtml style) tags, on by default 90 # 89 91 # # Activated modules from plugins or from the symfony core 90 92 # enabled_modules: [default] branches/dwhittle/lib/helper/AssetHelper.php
r4149 r4166 91 91 * @param string asset names 92 92 * @return string XHTML compliant <script> tag(s) 93 * @see javascript_path 93 * @see javascript_path 94 94 */ 95 95 function javascript_include_tag() … … 101 101 foreach ($sources as $source) 102 102 { 103 103 $condition = false; 104 104 $absolute = false; 105 105 if (isset($sourceOptions['absolute'])) … … 108 108 $absolute = true; 109 109 } 110 110 111 111 if(!isset($sourceOptions['raw_name'])) 112 112 { … … 117 117 unset($sourceOptions['raw_name']); 118 118 } 119 120 if(isset($sourceOptions['condition'])) 121 { 122 $condition = $sourceOptions['condition']; 123 unset($sourceOptions['condition']); 124 } 125 119 126 $options = array_merge(array('type' => 'text/javascript', 'src' => $source), $sourceOptions); 120 $html .= content_tag('script', '', $options)."\n"; 121 } 122 123 return $html; 127 $content = content_tag('script', '', $options)."\n"; 128 $html .= ($condition) ? conditional($condition, $content) : $content; 129 130 } 131 132 return $html; 124 133 } 125 134 … … 141 150 * @param bool return absolute path ? 142 151 * @return string file path to the stylesheet file 143 * @see stylesheet_tag 152 * @see stylesheet_tag 144 153 */ 145 154 function stylesheet_path($source, $absolute = false) … … 173 182 * @param array additional HTML compliant <link> tag parameters 174 183 * @return string XHTML compliant <link> tag(s) 175 * @see stylesheet_path 184 * @see stylesheet_path 176 185 */ 177 186 function stylesheet_tag() … … 183 192 foreach ($sources as $source) 184 193 { 194 $condition = false; 185 195 $absolute = false; 186 196 if (isset($sourceOptions['absolute'])) … … 189 199 $absolute = true; 190 200 } 191 201 192 202 if(!isset($sourceOptions['raw_name'])) 193 203 { … … 198 208 unset($sourceOptions['raw_name']); 199 209 } 210 211 if(isset($sourceOptions['condition'])) 212 { 213 $condition = $sourceOptions['condition']; 214 unset($sourceOptions['condition']); 215 } 216 200 217 $options = array_merge(array('rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen', 'href' => $source), $sourceOptions); 201 $html .= tag('link', $options)."\n"; 218 $content = tag('link', $options)."\n"; 219 $html .= ($condition) ? conditional($condition, $content) : $content; 202 220 } 203 221 … … 256 274 * - file name, like "rss.gif", that gets expanded to "/images/rss.gif" 257 275 * - file name without extension, like "logo", that gets expanded to "/images/logo.png" 258 * 276 * 259 277 * @param string asset name 260 278 * @param bool return absolute path ? 261 279 * @return string file path to the image file 262 * @see image_tag 280 * @see image_tag 263 281 */ 264 282 function image_path($source, $absolute = false) … … 286 304 * @param array additional HTML compliant <img> tag parameters 287 305 * @return string XHTML compliant <img> tag 288 * @see image_path 306 * @see image_path 289 307 */ 290 308 function image_tag($source, $options = array()) … … 388 406 * 389 407 * @return string XHTML compliant <meta> tag(s) 390 * @see include_http_metas 408 * @see include_http_metas 391 409 */ 392 410 function include_metas() … … 411 429 * 412 430 * @return string XHTML compliant <meta> tag(s) 413 * @see include_metas 431 * @see include_metas 414 432 */ 415 433 function include_http_metas() branches/dwhittle/lib/helper/FormHelper.php
r3688 r4166 104 104 * 105 105 * By default, the form tag is generated in POST format, but can easily be configured along with any additional 106 * HTML parameters via the optional <i>$options</i> parameter. If you are using file uploads, be sure to set the 106 * HTML parameters via the optional <i>$options</i> parameter. If you are using file uploads, be sure to set the 107 107 * <i>multipart</i> option to true. 108 108 * … … 141 141 * Returns a <select> tag, optionally comprised of <option> tags. 142 142 * 143 * The select tag does not generate <option> tags by default. 143 * The select tag does not generate <option> tags by default. 144 144 * To do so, you must populate the <i>$option_tags</i> parameter with a string of valid HTML compliant <option> tags. 145 * Fortunately, Symfony provides a handy helper function to convert an array of data into option tags (see options_for_select). 146 * If you need to create a "multiple" select tag (ability to select multiple options), set the <i>multiple</i> option to true. 145 * Fortunately, Symfony provides a handy helper function to convert an array of data into option tags (see options_for_select). 146 * If you need to create a "multiple" select tag (ability to select multiple options), set the <i>multiple</i> option to true. 147 147 * Doing so will automatically convert the name field to an array type variable (i.e. name="name" becomes name="name[]"). 148 * 148 * 149 149 * <b>Options:</b> 150 150 * - multiple - If set to true, the select tag will allow multiple options to be selected at once. … … 164 164 * </code> 165 165 * 166 * @param string field name 166 * @param string field name 167 167 * @param mixed contains a string of valid <option></option> tags, or an array of options that will be passed to options_for_select 168 168 * @param array additional HTML compliant <select> tag parameters … … 189 189 * Returns a <select> tag populated with all the countries in the world. 190 190 * 191 * The select_country_tag builds off the traditional select_tag function, and is conveniently populated with 192 * all the countries in the world (sorted alphabetically). Each option in the list has a two-character country 191 * The select_country_tag builds off the traditional select_tag function, and is conveniently populated with 192 * all the countries in the world (sorted alphabetically). Each option in the list has a two-character country 193 193 * code for its value and the country's name as its display title. The country data is retrieved via the sfCultureInfo 194 194 * class, which stores a wide variety of i18n and i10n settings for various countries and cultures throughout the world. … … 204 204 * </code> 205 205 * 206 * @param string field name 206 * @param string field name 207 207 * @param string selected field value (two-character country code) 208 208 * @param array additional HTML compliant <select> tag parameters … … 230 230 $option_tags = options_for_select($countries, $selected, $options); 231 231 232 if(isset($options['include_blank'])) 233 { 234 unset($options['include_blank']); 235 } 236 if(isset($options['include_custom'])) 237 { 238 unset($options['include_custom']); 239 } 240 232 241 return select_tag($name, $option_tags, $options); 233 242 } … … 236 245 * Returns a <select> tag populated with all the languages in the world (or almost). 237 246 * 238 * The select_language_tag builds off the traditional select_tag function, and is conveniently populated with 239 * all the languages in the world (sorted alphabetically). Each option in the list has a two or three character 240 * language/culture code for its value and the language's name as its display title. The country data is 241 * retrieved via the sfCultureInfo class, which stores a wide variety of i18n and i10n settings for various 247 * The select_language_tag builds off the traditional select_tag function, and is conveniently populated with 248 * all the languages in the world (sorted alphabetically). Each option in the list has a two or three character 249 * language/culture code for its value and the language's name as its display title. The country data is 250 * retrieved via the sfCultureInfo class, which stores a wide variety of i18n and i10n settings for various 242 251 * countries and cultures throughout the world. Here's an example of an <option> tag generated by the select_country_tag: 243 252 * … … 251 260 * </code> 252 261 * 253 * @param string field name 262 * @param string field name 254 263 * @param string selected field value (two or threecharacter language/culture code) 255 264 * @param array additional HTML compliant <select> tag parameters … … 277 286 $option_tags = options_for_select($languages, $selected, $options); 278 287 288 if(isset($options['include_blank'])) 289 { 290 unset($options['include_blank']); 291 } 292 if(isset($options['include_custom'])) 293 { 294 unset($options['include_custom']); 295 } 296 279 297 return select_tag($name, $option_tags, $options); 280 298 } … … 283 301 * Returns an XHTML compliant <input> tag with type="text". 284 302 * 285 * The input_tag helper generates your basic XHTML <input> tag and can utilize any standard <input> tag parameters 303 * The input_tag helper generates your basic XHTML <input> tag and can utilize any standard <input> tag parameters 286 304 * passed in the optional <i>$options</i> parameter. 287 305 * … … 295 313 * </code> 296 314 * 297 * @param string field name 315 * @param string field name 298 316 * @param string selected field value 299 317 * @param array additional HTML compliant <input> tag parameters … … 308 326 * Returns an XHTML compliant <input> tag with type="hidden". 309 327 * 310 * Similar to the input_tag helper, the input_hidden_tag helper generates an XHTML <input> tag and can utilize 311 * any standard <input> tag parameters passed in the optional <i>$options</i> parameter. The only difference is 328 * Similar to the input_tag helper, the input_hidden_tag helper generates an XHTML <input> tag and can utilize 329 * any standard <input> tag parameters passed in the optional <i>$options</i> parameter. The only difference is 312 330 * that it creates the tag with type="hidden", meaning that is not visible on the page. 313 331 * … … 317 335 * </code> 318 336 * 319 * @param string field name 337 * @param string field name 320 338 * @param string populated field value 321 339 * @param array additional HTML compliant <input> tag parameters … … 334 352 * 335 353 * Similar to the input_tag helper, the input_hidden_tag helper generates your basic XHTML <input> tag and can utilize 336 * any standard <input> tag parameters passed in the optional <i>$options</i> parameter. The only difference is that it 337 * creates the tag with type="file", meaning that next to the field will be a "browse" (or similar) button. 338 * This gives the user the ability to choose a file from there computer to upload to the web server. Remember, if you 339 * plan to upload files to your website, be sure to set the <i>multipart</i> option form_tag helper function to true 354 * any standard <input> tag parameters passed in the optional <i>$options</i> parameter. The only difference is that it 355 * creates the tag with type="file", meaning that next to the field will be a "browse" (or similar) button. 356 * This gives the user the ability to choose a file from there computer to upload to the web server. Remember, if you 357 * plan to upload files to your website, be sure to set the <i>multipart</i> option form_tag helper function to true 340 358 * or your files will not be properly uploaded to the web server. 341 359 * … … 345 363 * </code> 346 364 * 347 * @param string field name 365 * @param string field name 348 366 * @param array additional HTML compliant <input> tag parameters 349 367 * @return string XHTML compliant <input> tag with type="file" … … 362 380 * 363 381 * Similar to the input_tag helper, the input_hidden_tag helper generates your basic XHTML <input> tag and can utilize 364 * any standard <input> tag parameters passed in the optional <i>$options</i> parameter. The only difference is that it 382 * any standard <input> tag parameters passed in the optional <i>$options</i> parameter. The only difference is that it 365 383 * creates the tag with type="password", meaning that the text entered into this field will not be visible to the end user. 366 * In most cases it is replaced by * * * * * * * *. Even though this text is not readable, it is recommended that you do not 367 * populate the optional <i>$value</i> option with a plain-text password or any other sensitive information, as this is a 384 * In most cases it is replaced by * * * * * * * *. Even though this text is not readable, it is recommended that you do not 385 * populate the optional <i>$value</i> option with a plain-text password or any other sensitive information, as this is a 368 386 * potential security risk. 369 387 * … … 392 410 * 393 411 * The texarea_tag helper generates a standard HTML <textarea> tag and can be manipulated with 394 * any number of standard HTML parameters via the <i>$options</i> array variable. However, the 412 * any number of standard HTML parameters via the <i>$options</i> array variable. However, the 395 413 * textarea tag also has the unique capability of being transformed into a WYSIWYG rich-text editor 396 414 * such as TinyMCE (http://tinymce.moxiecode.com) very easily with the use of some specific options: … … 406 424 * <code> 407 425 * echo textarea_tag('description', 'This is a description', array('rows' => 10, 'cols' => 50)); 408 * </code> 426 * </code> 409 427 * 410 428 * @param string field name … … 473 491 * <input type="checkbox" name="status[]" id="status_4" value="4" /> 474 492 * </samp> 475 * 493 * 476 494 * <b>Examples:</b> 477 495 * <code> … … 488 506 * echo checkbox_tag('choice[]', 2); 489 507 * echo checkbox_tag('choice[]', 3); 490 * echo checkbox_tag('choice[]', 4); 508 * echo checkbox_tag('choice[]', 4); 491 509 * </code> 492 510 * … … 496 514 * </code> 497 515 * 498 * @param string field name 516 * @param string field name 499 517 * @param string checkbox value (if checked) 500 518 * @param bool is the checkbox checked? (1 or 0) … … 520 538 * <code> 521 539 * echo ' Yes '.radiobutton_tag('newsletter', 1); 522 * echo ' No '.radiobutton_tag('newsletter', 0); 523 * </code> 524 * 525 * @param string field name 540 * echo ' No '.radiobutton_tag('newsletter', 0); 541 * </code> 542 * 543 * @param string field name 526 544 * @param string radio button value (if selected) 527 545 * @param bool is the radio button selected? (1 or 0) … … 543 561 /** 544 562 * Returns two XHTML compliant <input> tags to be used as a free-text date fields for a date range. 545 * 563 * 546 564 * Built on the input_date_tag, the input_date_range_tag combines two input tags that allow the user 547 * to specify a from and to date. 548 * You can easily implement a JavaScript calendar by enabling the 'rich' option in the 549 * <i>$options</i> parameter. This includes a button next to the field that when clicked, 565 * to specify a from and to date. 566 * You can easily implement a JavaScript calendar by enabling the 'rich' option in the 567 * <i>$options</i> parameter. This includes a button next to the field that when clicked, 550 568 * will open an inline JavaScript calendar. When a date is selected, it will automatically 551 569 * populate the <input> tag with the proper date, formatted to the user's culture setting. 552 570 * 553 * <b>Note:</b> The <i>$name</i> parameter will automatically converted to array names. 571 * <b>Note:</b> The <i>$name</i> parameter will automatically converted to array names. 554 572 * For example, a <i>$name</i> of "date" becomes date[from] and date[to] 555 * 573 * 556 574 * <b>Options:</b> 557 575 * - rich - If set to true, includes an inline JavaScript calendar can auto-populate the date field with the chosen date … … 570 588 * </code> 571 589 * 572 * @param string field name 590 * @param string field name 573 591 * @param array dates: $value['from'] and $value['to'] 574 592 * @param array additional HTML compliant <input> tag parameters … … 589 607 /** 590 608 * Returns an XHTML compliant <input> tag to be used as a free-text date field. 591 * 592 * You can easily implement a JavaScript calendar by enabling the 'rich' option in the 593 * <i>$options</i> parameter. This includes a button next to the field that when clicked, 609 * 610 * You can easily implement a JavaScript calendar by enabling the 'rich' option in the 611 * <i>$options</i> parameter. This includes a button next to the field that when clicked, 594 612 * will open an inline JavaScript calendar. When a date is selected, it will automatically 595 * populate the <input> tag with the proper date, formatted to the user's culture setting. 613 * populate the <input> tag with the proper date, formatted to the user's culture setting. 596 614 * Symfony also conveniently offers the input_date_range_tag, that allows you to specify a to 597 615 * and from date. … … 605 623 * </code> 606 624 * 607 * @param string field name 625 * @param string field name 608 626 * @param string date 609 627 * @param array additional HTML compliant <input> tag parameters … … 691 709 daFormat : "'.$calendar_date_format.'", 692 710 button : "'.$id_calendarButton.'"'; 693 711 694 712 if ($withTime) 695 713 { … … 751 769 /** 752 770 * Returns an XHTML compliant <input> tag with type="submit". 753 * 771 * 754 772 * By default, this helper creates a submit tag with a name of <em>commit</em> to avoid 755 773 * conflicts with other parts of the framework. It is recommended that you do not use the name 756 774 * "submit" for submit tags unless absolutely necessary. Also, the default <i>$value</i> parameter 757 * (title of the button) is set to "Save changes", which can be easily overwritten by passing a 775 * (title of the button) is set to "Save changes", which can be easily overwritten by passing a 758 776 * <i>$value</i> parameter. 759 777 * … … 779 797 * Returns an XHTML compliant <input> tag with type="reset". 780 798 * 781 * By default, this helper creates a submit tag with a name of <em>reset</em>. Also, the default 782 * <i>$value</i> parameter (title of the button) is set to "Reset" which can be easily overwritten 799 * By default, this helper creates a submit tag with a name of <em>reset</em>. Also, the default 800 * <i>$value</i> parameter (title of the button) is set to "Reset" which can be easily overwritten 783 801 * by passing a <i>$value</i> parameter. 784 802 * … … 805 823 * 806 824 * The submit_image_tag is very similar to the submit_tag, the only difference being that it uses an image 807 * for the submit button instead of the browser-generated default button. The image is defined by the 808 * <i>$source</i> parameter and must be a valid image, either local or remote (URL). By default, this 809 * helper creates a submit tag with a name of <em>commit</em> to avoid conflicts with other parts of the 825 * for the submit button instead of the browser-generated default button. The image is defined by the 826 * <i>$source</i> parameter and must be a valid image, either local or remote (URL). By default, this 827 * helper creates a submit tag with a name of <em>commit</em> to avoid conflicts with other parts of the 810 828 * framework. It is recommended that you do not use the name "submit" for submit tags unless absolutely necessary. 811 829 * … … 870 888 * </code> 871 889 * 872 * @param string field name 890 * @param string field name 873 891 * @param string field value 874 892 * @return string <select> tag populated with all the languages in the world. … … 890 908 * 891 909 * @param array options 892 * @return array returns properly formatted options 910 * @return array returns properly formatted options 893 911 */ 894 912 function _convert_options($options) branches/dwhittle/lib/helper/JavascriptHelper.php
r3688 r4166 110 110 return tag('input', $html_options); 111 111 } 112 112 113 113 /** 114 114 * Returns an html button to a remote action defined by 'url' (using the … … 807 807 * 'rows' Number of rows (more than 1 will use a TEXTAREA) 808 808 * 'cancel_text' The text on the cancel link. (default: "cancel") 809 * 'cancel_link' Whether the cancel link must be displayed or not. (default: true) 809 810 * 'save_text' The text on the save link. (default: "ok") 811 * 'save_button' Whether the save button must be displayed or not. (default: true) 810 812 * 'external_control' The id of an external control used to enter edit mode. 811 813 * 'options' Pass through options to the AJAX call (see prototype's Ajax.Updater) … … 828 830 $js_options['cancelText'] = "'".$options['cancel_text']."'"; 829 831 } 832 if (isset($options['cancel_link'])) 833 { 834 $js_options['cancelLink'] = $options['cancel_link']; 835 } 830 836 if (isset($options['save_text'])) 831 837 { 832 838 $js_options['okText'] = "'".$options['save_text']."'"; 833 839 } 840 if (isset($options['save_button'])) 841 { 842 $js_options['okButton'] = "'".$options['save_button']."'"; 843 } 834 844 if (isset($options['cols'])) 835 845 { … … 863 873 { 864 874 $js_options['loadTextURL'] = "'".$options['loadTextURL']."'"; 875 } 876 if (isset($options['submitOnBlur'])) 877 { 878 $js_options['submitOnBlur'] = "'".$options['submitOnBlur']."'"; 879 } 880 if (isset($options['complete'])) 881 { 882 $js_options['onComplete'] = $options['complete']; 865 883 } 866 884 branches/dwhittle/lib/helper/TagHelper.php
r3688 r4166 28 28 * @return string 29 29 */ 30 30 31 function tag($name, $options = array(), $open = false) 31 32 { … … 35 36 } 36 37 37 return '<'.$name._tag_options($options).(($open ) ? '>' : ' />');38 return '<'.$name._tag_options($options).(($open || (sfConfig::get('sf_use_xhtml_tags', true) === false)) ? '>' : ' />'); 38 39 } 39 40 … … 51 52 { 52 53 return "<![CDATA[$content]]>"; 54 } 55 56 function conditional($condition, $content) 57 { 58 return '<!--[if '.$condition.']>'."\n".$content."\n".'<![endif]-->'."\n"; 53 59 } 54 60

