Development

Changeset 4166

You must first sign up to be able to contribute.

Changeset 4166

Show
Ignore:
Timestamp:
06/06/07 00:00:14 (3 years ago)
Author:
dwhittle
Message:

dwhittle: applied a few patches, fixed some helpers, closes #1677, #1661, #1540, #1531


Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dwhittle/data/config/settings.yml

    r3688 r4166  
    1313    secure_action:          secure    # The credentials required for an action 
    1414 
    15     module_disabled_module: default   # To be called when a user requests  
     15    module_disabled_module: default   # To be called when a user requests 
    1616    module_disabled_action: disabled  # A module disabled in the module.yml 
    1717 
     
    5353    web_debug:              off       # Enable the web debug toolbar 
    5454    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. 
    5556 
    5657    # Assets paths 
     
    6364    # Helpers included in all templates by default 
    6465    standard_helpers:       [Partial, Cache, Form] 
     66 
     67    use_xhtml_tags:          on       # use open (html style) or closed (xhtml style) tags, on by default 
    6568 
    6669    # Activated modules from plugins or from the symfony core 
  • branches/dwhittle/data/skeleton/app/app/config/settings.yml

    r4163 r4166  
    8787#    standard_helpers:       [Partial, Cache, Form] 
    8888# 
     89#    use_xhtml_tags:          on       # use open (html style) or closed (xhtml style) tags, on by default 
     90# 
    8991#    # Activated modules from plugins or from the symfony core 
    9092#    enabled_modules:        [default] 
  • branches/dwhittle/lib/helper/AssetHelper.php

    r4149 r4166  
    9191 * @param  string asset names 
    9292 * @return string XHTML compliant <script> tag(s) 
    93  * @see    javascript_path  
     93 * @see    javascript_path 
    9494 */ 
    9595function javascript_include_tag() 
     
    101101  foreach ($sources as $source) 
    102102  { 
    103      
     103    $condition = false; 
    104104    $absolute = false; 
    105105    if (isset($sourceOptions['absolute'])) 
     
    108108      $absolute = true; 
    109109    } 
    110    
     110 
    111111    if(!isset($sourceOptions['raw_name'])) 
    112112    { 
     
    117117      unset($sourceOptions['raw_name']); 
    118118    } 
     119 
     120    if(isset($sourceOptions['condition'])) 
     121    { 
     122      $condition = $sourceOptions['condition']; 
     123      unset($sourceOptions['condition']); 
     124    } 
     125 
    119126    $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; 
    124133} 
    125134 
     
    141150 * @param  bool return absolute path ? 
    142151 * @return string file path to the stylesheet file 
    143  * @see    stylesheet_tag   
     152 * @see    stylesheet_tag 
    144153 */ 
    145154function stylesheet_path($source, $absolute = false) 
     
    173182 * @param  array additional HTML compliant <link> tag parameters 
    174183 * @return string XHTML compliant <link> tag(s) 
    175  * @see    stylesheet_path  
     184 * @see    stylesheet_path 
    176185 */ 
    177186function stylesheet_tag() 
     
    183192  foreach ($sources as $source) 
    184193  { 
     194    $condition = false; 
    185195    $absolute = false; 
    186196    if (isset($sourceOptions['absolute'])) 
     
    189199      $absolute = true; 
    190200    } 
    191          
     201 
    192202    if(!isset($sourceOptions['raw_name'])) 
    193203    { 
     
    198208      unset($sourceOptions['raw_name']); 
    199209    } 
     210 
     211    if(isset($sourceOptions['condition'])) 
     212    { 
     213      $condition = $sourceOptions['condition']; 
     214      unset($sourceOptions['condition']); 
     215    } 
     216 
    200217    $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; 
    202220  } 
    203221 
     
    256274 * - file name, like "rss.gif", that gets expanded to "/images/rss.gif" 
    257275 * - file name without extension, like "logo", that gets expanded to "/images/logo.png" 
    258  *  
     276 * 
    259277 * @param  string asset name 
    260278 * @param  bool return absolute path ? 
    261279 * @return string file path to the image file 
    262  * @see    image_tag   
     280 * @see    image_tag 
    263281 */ 
    264282function image_path($source, $absolute = false) 
     
    286304 * @param  array additional HTML compliant <img> tag parameters 
    287305 * @return string XHTML compliant <img> tag 
    288  * @see    image_path  
     306 * @see    image_path 
    289307 */ 
    290308function image_tag($source, $options = array()) 
     
    388406 * 
    389407 * @return string XHTML compliant <meta> tag(s) 
    390  * @see    include_http_metas  
     408 * @see    include_http_metas 
    391409 */ 
    392410function include_metas() 
     
    411429 * 
    412430 * @return string XHTML compliant <meta> tag(s) 
    413  * @see    include_metas  
     431 * @see    include_metas 
    414432 */ 
    415433function include_http_metas() 
  • branches/dwhittle/lib/helper/FormHelper.php

    r3688 r4166  
    104104 * 
    105105 * 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 
    107107 * <i>multipart</i> option to true. 
    108108 * 
     
    141141 * Returns a <select> tag, optionally comprised of <option> tags. 
    142142 * 
    143  * The select tag does not generate <option> tags by default.   
     143 * The select tag does not generate <option> tags by default. 
    144144 * 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. 
    147147 * Doing so will automatically convert the name field to an array type variable (i.e. name="name" becomes name="name[]"). 
    148  *  
     148 * 
    149149 * <b>Options:</b> 
    150150 * - multiple - If set to true, the select tag will allow multiple options to be selected at once. 
     
    164164 * </code> 
    165165 * 
    166  * @param  string field name  
     166 * @param  string field name 
    167167 * @param  mixed contains a string of valid <option></option> tags, or an array of options that will be passed to options_for_select 
    168168 * @param  array  additional HTML compliant <select> tag parameters 
     
    189189 * Returns a <select> tag populated with all the countries in the world. 
    190190 * 
    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 
    193193 * code for its value and the country's name as its display title.  The country data is retrieved via the sfCultureInfo 
    194194 * class, which stores a wide variety of i18n and i10n settings for various countries and cultures throughout the world. 
     
    204204 * </code> 
    205205 * 
    206  * @param  string field name  
     206 * @param  string field name 
    207207 * @param  string selected field value (two-character country code) 
    208208 * @param  array  additional HTML compliant <select> tag parameters 
     
    230230  $option_tags = options_for_select($countries, $selected, $options); 
    231231 
     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 
    232241  return select_tag($name, $option_tags, $options); 
    233242} 
     
    236245 * Returns a <select> tag populated with all the languages in the world (or almost). 
    237246 * 
    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 
    242251 * countries and cultures throughout the world. Here's an example of an <option> tag generated by the select_country_tag: 
    243252 * 
     
    251260 * </code> 
    252261 * 
    253  * @param  string field name  
     262 * @param  string field name 
    254263 * @param  string selected field value (two or threecharacter language/culture code) 
    255264 * @param  array  additional HTML compliant <select> tag parameters 
     
    277286  $option_tags = options_for_select($languages, $selected, $options); 
    278287 
     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 
    279297  return select_tag($name, $option_tags, $options); 
    280298} 
     
    283301 * Returns an XHTML compliant <input> tag with type="text". 
    284302 * 
    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 
    286304 * passed in the optional <i>$options</i> parameter. 
    287305 * 
     
    295313 * </code> 
    296314 * 
    297  * @param  string field name  
     315 * @param  string field name 
    298316 * @param  string selected field value 
    299317 * @param  array  additional HTML compliant <input> tag parameters 
     
    308326 * Returns an XHTML compliant <input> tag with type="hidden". 
    309327 * 
    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 
    312330 * that it creates the tag with type="hidden", meaning that is not visible on the page. 
    313331 * 
     
    317335 * </code> 
    318336 * 
    319  * @param  string field name  
     337 * @param  string field name 
    320338 * @param  string populated field value 
    321339 * @param  array  additional HTML compliant <input> tag parameters 
     
    334352 * 
    335353 * 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 
    340358 * or your files will not be properly uploaded to the web server. 
    341359 * 
     
    345363 * </code> 
    346364 * 
    347  * @param  string field name  
     365 * @param  string field name 
    348366 * @param  array  additional HTML compliant <input> tag parameters 
    349367 * @return string XHTML compliant <input> tag with type="file" 
     
    362380 * 
    363381 * 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 
    365383 * 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 
    368386 * potential security risk. 
    369387 * 
     
    392410 * 
    393411 * 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 
    395413 * textarea tag also has the unique capability of being transformed into a WYSIWYG rich-text editor 
    396414 * such as TinyMCE (http://tinymce.moxiecode.com) very easily with the use of some specific options: 
     
    406424 * <code> 
    407425 *  echo textarea_tag('description', 'This is a description', array('rows' => 10, 'cols' => 50)); 
    408  * </code>  
     426 * </code> 
    409427 * 
    410428 * @param  string field name 
     
    473491 *  <input type="checkbox" name="status[]" id="status_4" value="4" /> 
    474492 * </samp> 
    475  *  
     493 * 
    476494 * <b>Examples:</b> 
    477495 * <code> 
     
    488506 *  echo checkbox_tag('choice[]', 2); 
    489507 *  echo checkbox_tag('choice[]', 3); 
    490  *  echo checkbox_tag('choice[]', 4);  
     508 *  echo checkbox_tag('choice[]', 4); 
    491509 * </code> 
    492510 * 
     
    496514 * </code> 
    497515 * 
    498  * @param  string field name  
     516 * @param  string field name 
    499517 * @param  string checkbox value (if checked) 
    500518 * @param  bool   is the checkbox checked? (1 or 0) 
     
    520538 * <code> 
    521539 *  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 
    526544 * @param  string radio button value (if selected) 
    527545 * @param  bool   is the radio button selected? (1 or 0) 
     
    543561/** 
    544562 * Returns two XHTML compliant <input> tags to be used as a free-text date fields for a date range. 
    545  *  
     563 * 
    546564 * 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, 
    550568 * will open an inline JavaScript calendar.  When a date is selected, it will automatically 
    551569 * populate the <input> tag with the proper date, formatted to the user's culture setting. 
    552570 * 
    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. 
    554572 * For example, a <i>$name</i> of "date" becomes date[from] and date[to] 
    555  *  
     573 * 
    556574 * <b>Options:</b> 
    557575 * - rich - If set to true, includes an inline JavaScript calendar can auto-populate the date field with the chosen date 
     
    570588 * </code> 
    571589 * 
    572  * @param  string field name  
     590 * @param  string field name 
    573591 * @param  array  dates: $value['from'] and $value['to'] 
    574592 * @param  array  additional HTML compliant <input> tag parameters 
     
    589607/** 
    590608 * 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, 
    594612 * 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. 
    596614 * Symfony also conveniently offers the input_date_range_tag, that allows you to specify a to 
    597615 * and from date. 
     
    605623 * </code> 
    606624 * 
    607  * @param  string field name  
     625 * @param  string field name 
    608626 * @param  string date 
    609627 * @param  array  additional HTML compliant <input> tag parameters 
     
    691709      daFormat : "'.$calendar_date_format.'", 
    692710      button : "'.$id_calendarButton.'"'; 
    693    
     711 
    694712  if ($withTime) 
    695713  { 
     
    751769/** 
    752770 * Returns an XHTML compliant <input> tag with type="submit". 
    753  *  
     771 * 
    754772 * By default, this helper creates a submit tag with a name of <em>commit</em> to avoid 
    755773 * conflicts with other parts of the framework.  It is recommended that you do not use the name 
    756774 * "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 
    758776 * <i>$value</i> parameter. 
    759777 * 
     
    779797 * Returns an XHTML compliant <input> tag with type="reset". 
    780798 * 
    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 
    783801 * by passing a <i>$value</i> parameter. 
    784802 * 
     
    805823 * 
    806824 * 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 
    810828 * framework.  It is recommended that you do not use the name "submit" for submit tags unless absolutely necessary. 
    811829 * 
     
    870888 * </code> 
    871889 * 
    872  * @param  string field name  
     890 * @param  string field name 
    873891 * @param  string field value 
    874892 * @return string <select> tag populated with all the languages in the world. 
     
    890908 * 
    891909 * @param  array options 
    892  * @return array returns properly formatted options  
     910 * @return array returns properly formatted options 
    893911 */ 
    894912function _convert_options($options) 
  • branches/dwhittle/lib/helper/JavascriptHelper.php

    r3688 r4166  
    110110    return tag('input', $html_options); 
    111111  } 
    112    
     112 
    113113  /** 
    114114   * Returns an html button to a remote action defined by 'url' (using the 
     
    807807   * 'rows'                Number of rows (more than 1 will use a TEXTAREA) 
    808808   * 'cancel_text'         The text on the cancel link. (default: "cancel") 
     809   * 'cancel_link'         Whether the cancel link must be displayed or not. (default: true) 
    809810   * 'save_text'           The text on the save link. (default: "ok") 
     811   * 'save_button'         Whether the save button must be displayed or not. (default: true) 
    810812   * 'external_control'    The id of an external control used to enter edit mode. 
    811813   * 'options'             Pass through options to the AJAX call (see prototype's Ajax.Updater) 
     
    828830        $js_options['cancelText'] = "'".$options['cancel_text']."'"; 
    829831      } 
     832      if (isset($options['cancel_link'])) 
     833      { 
     834        $js_options['cancelLink'] = $options['cancel_link']; 
     835      } 
    830836      if (isset($options['save_text'])) 
    831837      { 
    832838        $js_options['okText'] = "'".$options['save_text']."'"; 
    833839      } 
     840      if (isset($options['save_button'])) 
     841      { 
     842        $js_options['okButton'] = "'".$options['save_button']."'"; 
     843      } 
    834844      if (isset($options['cols'])) 
    835845      { 
     
    863873      { 
    864874        $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']; 
    865883      } 
    866884 
  • branches/dwhittle/lib/helper/TagHelper.php

    r3688 r4166  
    2828 * @return string 
    2929 */ 
     30 
    3031function tag($name, $options = array(), $open = false) 
    3132{ 
     
    3536  } 
    3637 
    37   return '<'.$name._tag_options($options).(($open) ? '>' : ' />'); 
     38  return '<'.$name._tag_options($options).(($open || (sfConfig::get('sf_use_xhtml_tags', true) === false)) ? '>' : ' />'); 
    3839} 
    3940 
     
    5152{ 
    5253  return "<![CDATA[$content]]>"; 
     54} 
     55 
     56function conditional($condition, $content) 
     57{ 
     58  return '<!--[if '.$condition.']>'."\n".$content."\n".'<![endif]-->'."\n"; 
    5359} 
    5460 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.