Development

Changeset 2043

You must first sign up to be able to contribute.

Changeset 2043

Show
Ignore:
Timestamp:
09/12/06 07:01:42 (2 years ago)
Author:
synace
Message:

merging my branch to trunk [2042]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/synace/CHANGELOG

    r1500 r2043  
    11SVN 
    22--- 
     3 
     4WARNING: All deprecated function, methods and tasks has been removed (see r1631, r1638 and r1799). 
     5 
     6If you try to use this release with 0.6.X projects, you must upgrade them with: symfony upgrade 0.8 
     7 
     8* major partial and component refactoring (big speed improvement) 
     9* output escaping is now a global setting 
     10* new helpers: use_stylesheet() and use_javascript() 
     11* new time information in the symfony log and debug toolbar 
     12* major performance improvements 
     13* new sfLoader class 
     14* symfony command line now works out the box (for PEAR, SVN or .tgz) 
     15* new plugin system 
     16* propel-build-all now works as expected 
     17* major cache refactoring 
     18* autoloading is now more flexible 
     19* AJAX actions have now layout to off by default 
     20* new slot support 
     21* added setLayout() method to sfComponent 
     22* better exception handling in symfony command line (try -t) 
     23* symfony command line now in color (only for *nix) 
     24* bundled pake and phing (symfony has no external dependancy) 
     25* better i18n support thanks to the new charset setting (FillInFilter, translations, ...) 
     26* added a new charset setting 
     27* updated creole, Propel and scriptaculous (1.6.2) 
     28* many-to-many relationship support in admin generator 
     29* removed my* classes from skeleton except myUser 
     30* new classes :sfProcessCache, sfLogManager 
     31* removed all deprecated functions, methods and tasks. 
     32* removed old php, css and js files that are not used anymore 
     33* strip comments in production environment by default 
     34* better sfTextBrowser with POST support and redirects 
     35* support for database schema in YAML format 
     36* updated calendar language files (js, ca) 
     37* new tasks: init-batch, propel-convert-yaml-schema, propel-load-data, propel-build-all, propel-build-all-load 
     38             init-controller, clear-controllers, rotate-log, purge-logs, freeze, unfreeze, enable, disable, 
     39             plugin-list 
     40* new validators: sfDateValidator, sfUrlValidator, sfCallbackValidator 
     41* and more than 160 bug fixes and small enhancements 
     42 
     43For more detailed information on bugs fixed in this release, see the trac ticket list for 0.6.4: 
     44http://www.symfony-project.com/trac/report/10 
    345 
    446Version 0.6.3 
  • branches/synace/data/skeleton/app/app/config/cache.yml

    r500 r2043  
    11default: 
    2   activate:  off 
    3   type:      slot 
    4   lifetime:  86400 
     2  activate:    off 
     3  with_layout: false 
     4  lifetime:    86400 
  • branches/synace/data/skeleton/app/app/config/config.php

    r1566 r2043  
    5151set_include_path( 
    5252  sfConfig::get('sf_lib_dir').PATH_SEPARATOR. 
     53  sfConfig::get('sf_root_dir').PATH_SEPARATOR. 
    5354  sfConfig::get('sf_app_lib_dir').PATH_SEPARATOR. 
    5455  sfConfig::get('sf_symfony_lib_dir').DIRECTORY_SEPARATOR.'vendor'.PATH_SEPARATOR. 
  • branches/synace/data/skeleton/app/app/config/logging.yml

    r500 r2043  
    22  active: off 
    33  level:  err 
     4  rotate: on 
     5  purge:  off 
    46 
    57dev: 
     
    1012#  active: on 
    1113#  level:  debug 
     14#  rotate:  off 
     15#  period:  7 
     16#  history: 10 
     17#  purge:   on 
  • branches/synace/data/skeleton/app/app/config/settings.yml

    r1641 r2043  
    9191#    validation_error_class:     form_error 
    9292#    validation_error_id_prefix: error_for_ 
     93#  
     94#    autoloading_functions: ~ 
     95#  
     96#    charset: utf-8 
     97#  
     98#    escaping_strategy: bc 
     99#    escaping_method:   ESC_ENTITIES 
     100# 
     101#    prototype_web_dir: /sf/prototype 
     102#    admin_web_dir:     /sf/sf_admin 
     103#    web_debug_web_dir: /sf/sf_web_debug 
  • branches/synace/data/skeleton/app/app/config/view.yml

    r1631 r2043  
    11default: 
    22  http_metas: 
    3     content-type: text/html; charset=utf-8 
     3    content-type: text/html 
    44 
    55  metas: 
  • branches/synace/doc/book/content/cache.txt

    r1624 r2043  
    103103 
    104104    [php] 
    105     <?php include_partial('mymodule/my_other_partial', array('foo' => 'bar)) ?> 
     105    <?php include_partial('mymodule/my_other_partial', array('foo' => 'bar')) ?> 
    106106 
    107107A component is a lightweight action put on top of a partial. A component slot is a component for which the action varies according to the calling actions. These two inclusion types are very similar to partials, and support caching the same way. For instance, if your global layout shows a: 
     
    402402        etag: on 
    403403         
    404 When the server receives a request for a page containing an etag, it processes this page as it would usually. For a page of 'page' type cace, the response it directly taken from the cache. The server will compute a new md5 hash of the cached response and see that it's the same as the one sent by the browser. Instead of sending the response again, the server will send a 304 header only, and the browser will redisplay the page it keeps in its local cache. 
     404When the server receives a request for a page containing an etag, it processes this page as it would usually. For a page of 'page' type cache, the response it directly taken from the cache. The server will compute a new md5 hash of the cached response and see that it's the same as the one sent by the browser. Instead of sending the response again, the server will send a 304 header only, and the browser will redisplay the page it keeps in its local cache. 
    405405 
    406406### Conditional GET 
  • branches/synace/doc/book/content/cli.txt

    r1584 r2043  
    1717-------- 
    1818 
    19 To get the installed version of the symfony package, type: 
    20  
    2119    $ symfony -V 
    2220 
    23 To get the full list of the available administration operations, use: 
    24  
    25     $ symfony -T 
     21Returns the installed version of the symfony package. 
     22 
     23    $ symfony 
     24 
     25Returns the full list of the available administration operations. 
    2626     
    2727The symfony command expects tasks, and some tasks require additional parameters. The general syntax is: 
     
    3434    // does the same thing as 
    3535    $ symfony clear-cache 
     36     
     37When an exception occurs, you might want to get the stack trace and detailed explanation. Add the `-t` option before the task name to get the trace. 
    3638 
    3739CLI tasks 
     
    4042### Structure generation 
    4143 
    42 `init-project`: Initialize a new symfony project (shortcut: `new`) 
    43  
    4444    $ symfony init-project <PROJECT_NAME> 
    45  
    46 `init-app`: Initialize a new symfony application (shortcut: `app`) 
     45     
     46Initializes a new symfony project (shortcut: `new`). 
    4747           
    4848    $ symfony init-app <APPLICATION_NAME> 
    49  
    50 `init-module`: Initialize a new symfony module (shortcut: `module`) 
     49     
     50Initializes a new symfony application (shortcut: `app`).     
    5151 
    5252    $ symfony init-module <APPLICATION_NAME> <MODULE_NAME> 
     53     
     54Initializes a new symfony module (shortcut: `module`). 
     55 
     56    $ symfony init-batch <SKELETON_NAME> [...] 
     57 
     58Initializes a new batch file (shortcut: `batch`). You must select a batch skeleton to init, and then follow the prompts. 
     59 
     60    $ symfony init-controller <APPLICATION_NAME> <ENVIRONMENT_NAME> [<SCRIPT_NAME>] [true|false] 
     61 
     62Initializes a new controller (shortcut: `controller`). The default script name follows the symfony convention. 
    5363 
    5464Find more about these commands in the [project creation chapter](project_creation.txt). 
     
    5666### Model generation 
    5767 
    58 `propel-build-model`: Create Propel classes for the current model, based on the `schema.yml` file. If you have several files ending with `schema.yml` in your `config/` directory, they are all taken into account. 
    59  
    6068    $ symfony propel-build-model 
    6169 
    62 The connection settings used by the following commands are taken from the `config/propel.ini` configuration. 
    63      
    64 `propel-build-schema`: Create `schema.xml` from an existing database 
     70Generates the Propel classes for the current model, based on the schema files (YAML or XML) of your `config/` directory. 
     71 
     72The connection settings used by the following commands are taken from the `config/propel.ini` configuration.   
     73     
     74    $ symfony propel-build-sql 
     75     
     76Generates the SQL code to create the tables described in the `schema.yml`, in a `data/schema.sql` file. 
     77 
     78    $ symfony propel-build-db 
     79     
     80Creates an empty database based on the connection settings.     
     81 
     82    $ symfony propel-insert-sql 
     83     
     84Inserts the SQL code from `data/schema.sql` into the database.     
     85     
     86    $ symfony propel-build-all 
     87 
     88Executes `propel-build-schema`, `propel-build-sql` and then `propel-insert-sql` all in one command. 
     89 
     90    $ symfony propel-load-data  <APPLICATION_NAME> [<ENVIRONMENT_NAME>] [<FIXTURES_DIR_OR_FILE>] 
     91     
     92Loads all data from default `data/fixtures/` directory unless otherwise specified. Environment is default to `dev`. The fixtures directory must be specified relative to the project's data dir, for example `fixtures` (default) or `testdata` or specify a single file `fixtures/file.yml`.     
     93 
     94    $ symfony propel-build-all-load  <APPLICATION_NAME> [<ENVIRONMENT_NAME>] [<FIXTURES_DIR_OR_FILE>] 
     95 
     96Executes `propel-build-all` then `propel-load-data`. Accepts same arguments as `propel-load-data`. 
    6597 
    6698    $ symfony propel-build-schema 
    6799     
    68 `propel-build-sql`: Create the SQL code to create the tables described in the `schema.yml`, in a `data/schema.sql` file. 
    69  
    70     $ symfony propel-build-sql 
    71      
    72 `propel-build-db`: Create an empty database 
    73  
    74     $ symfony propel-build-db 
    75  
    76 `propel-insert-sql`: Insert the SQL code from `data/schema.sql` into the database 
    77  
    78     $ symfony propel-insert-sql 
    79      
    80 If you want to learn more about the model and the effect of these commands, refer to the [model chapter](model.txt). 
     100Creates a `schema.yml` from an existing database.   
     101 
     102Find more about these commands in the [model chapter](model.txt). 
    81103 
    82104### Development tools 
    83105 
    84 `clear-cache`: Clear the cached information (shortcut: `cc`) (find more in the [cache chapter](cache.txt)) 
    85  
    86     $ symfony clear-cache <APPLICATION_NAME> [template|config] 
    87  
    88 `fix-perms`: Fix directories permissions, to change to `777` the directories that need to be writable. The permission can be broken if you use a checkout from a SVN repository. 
     106    $ symfony clear-cache [<APPLICATION_NAME>] [template|config] 
     107 
     108Clears the cached information (shortcut: `cc`) (find more in the [cache chapter](cache.txt)). 
     109 
     110    $ symfony clear-controllers 
     111     
     112Clears the web directory of all controllers other than ones running in a production environment. Very useful before deployment to the production server. 
    89113 
    90114    $ symfony fix-perms 
    91115     
    92 `test`: Launch the test suite for an application (find more in the [unit test chapter](test_unit_testing.txt)) 
     116Fixes directories permissions, to change to `777` the directories that need to be writable. The permission can be broken if you use a checkout from a SVN repository. 
    93117 
    94118    $ symfony test <APPLICATION_NAME> 
    95      
    96 `sync`: Synchronise the current project with another machine (find more in the [deployment chapter](deployment.txt)) 
     119 
     120Launches the test suite for an application (find more in the [unit test chapter](test_unit_testing.txt)).    
     121 
     122    $ symfony freeze 
     123    $ symfony unfreeze 
     124 
     125Copies all the necessary symfony libraries into the `data/`, `lib/` and `web/sf/` directories of your project. Your project then becomes a kind of sandbox, i.e. a standalone application with no dependence and ready to be transferred to production via FTP. Works fine with PEAR installations as well as symbolic links. Unfreeze your project with the `unfreeze` task. 
    97126 
    98127    $ symfony sync <ENVIRONMENT_NAME> [go] 
     128     
     129Synchronises the current project with another machine (find more in the [deployment chapter](deployment.txt)).    
     130 
     131### Project administration 
     132 
     133    $ symfony disable <APPLICATION_NAME> <ENVIRONMENT_NAME> 
     134 
     135Forwards the user to the unavailable module and action in your `settings.yml` file and acts in the same way as if you had set the unavaiable setting in your `settings.yml` file. The advantage over the setting is that you can disable a single application for a single environment, and not only the whole project. 
     136 
     137    $ symfony enable <APPLICATION_NAME> <ENVIRONMENT_NAME> 
     138 
     139Enables the application and clears the cache.  
     140 
     141    $ symfony purge-logs 
     142 
     143Clears the logs files in the log directory depending on your settings in logging.yml (find more in the [logging chapter](logging.txt)). 
     144 
     145    $ symfony rotate-log <APPLICATION_NAME> <ENVIRONMENT_NAME> 
     146     
     147Forces a rotation of a log file if rotate is enabled for the log file in logging.yml. (find more in the [logging chapter](logging.txt)).    
    99148 
    100149### Scaffolding and admin generation 
    101150 
    102 `propel-generate-crud`: Generate a new Propel CRUD module based on a class from the model 
    103  
    104151    $ symfony propel-generate-crud <APPLICATION_NAME> <MODULE_NAME> <CLASS_NAME> 
    105      
    106 `propel-init-crud`: Same as `propel-generate-crud`, except that the generated code is visible only in the `cache/` folder (the generated actions and templates inherit from the framework) 
    107  
    108 `propel-init-admin`: Initialize a new Propel admin module based on a class from the model 
     152    $ symfony propel-init-crud <APPLICATION_NAME> <MODULE_NAME> <CLASS_NAME> 
     153     
     154Generates a new Propel CRUD module based on a class from the model. The `generate` version copies the code from the framework to a new module, the `init` verson creates an empty module that inherits from the one in the framework. In this case, the generated code is visible only in the `cache/` folder (the generated actions and templates inherit from the framework). 
    109155 
    110156    $ symfony propel-init-admin <APPLICATION_NAME> <MODULE_NAME> <CLASS_NAME> 
    111  
    112 You will find a lot of details about scaffolding and generated administrations in the [scaffolding](scaffolding.txt) and [generator chapter](generator.txt). 
     157     
     158Initializes a new Propel admin module based on a class from the model 
     159 
     160Find more about these commands in the [scaffolding](scaffolding.txt) and [generator chapter](generator.txt). 
    113161 
    114162### Plugin management 
    115163 
    116 `plugin-install`: Install a new plugin 
    117  
    118164    $ symfony plugin-install [local|global] <CHANNEL_NAME>/<PLUGIN_NAME> 
    119165     
    120 `plugin-upgrade`: Upgrade a plugin 
    121  
     166Installs a new plugin. 
     167     
    122168    $ symfony plugin-upgrade [local|global] <CHANNEL_NAME>/<PLUGIN_NAME> 
    123169 
    124 `plugin-upgrade-all`: Upgrade all the plugins previously installed in local 
     170Upgrades a plugin. 
    125171 
    126172    $ symfony plugin-upgrade-all 
    127173 
    128 `plugin-uninstall`: Uninstall a plugin 
     174Upgrades all the plugins previously installed in local 
    129175 
    130176    $ symfony plugin-uninstall [local|global] <CHANNEL_NAME>/<PLUGIN_NAME> 
     177     
     178Uninstalls a plugin.     
    131179 
    132180The way to build, install and manage plugins is described in the [plugin chapter](plugin.txt). 
     
    134182### Fast Web server for test 
    135183 
    136 The `server` command launches a fast web server written in PHP to serve a symfony application in the `dev` environment. The default port is 8000. 
    137  
    138184    $ symfony server <APPLICATION_NAME> [<PORT>] 
     185 
     186Launches a fast web server written in PHP to serve a symfony application in the `dev` environment. The default port is 8000. 
    139187 
    140188For instance, if you want to test a symfony application called `myapp` without changing your server configuration, type: 
  • branches/synace/doc/book/content/configuration.txt

    r1600 r2043  
    248248But maybe you need to add an array, an associative array or a lot of new parameters. In this case it is better to create a new configuration file, together with the corresponding configuration handler. 
    249249 
    250 >**Note**: For project-wide custom settings, you can still take advantage of the `config/config.php` file to call directly the `sfConfig::set()` method or load your own YAML file with `sfYaml::load($file)`. 
     250>**Note**: For project-wide custom settings, you can still take advantage of the `config/config.php` file to call directly the `sfConfig::set()` method or load your own YAML file with `sfYaml::load($file)`. Beware that autoloading is not active when the `config.php` is executed, so you need to manually include the class files that you want to use. 
    251251 
    252252Scriptable configuration 
     
    266266Be also aware that in the production environment, the configuration is cached, so the configuration files are parsed (and executed) only once after the cache is cleared. 
    267267 
     268And if you are allergic to YAML, or if you prefer to avoid writing both a configuration file and a configuration handler to finally get an associative array in PHP, you can bypass YAML parsing completely and return a PHP array in any YAML file. It means that you can write the `logging.yml` as follows: 
     269 
     270    [php] 
     271    <?php 
     272    return array( 
     273      'default' => array( 
     274        'active' => true, 
     275        'level'  => 'debug' 
     276      ) 
     277    ); 
     278 
     279...instead of the classic 
     280 
     281    default: 
     282      active: on 
     283      level:  debug 
     284       
    268285Configuration handlers 
    269286---------------------- 
  • branches/synace/doc/book/content/configuration_practice.txt

    r1623 r2043  
    193193### `factories.yml`: Factories settings                    {#factories} 
    194194 
    195 Symfony uses classes such as `sfFrontWebController`, `sfUser`, `sfRequest` that are part of the framework. In the `myproject/apps/myapp/lib/` directory, you will find some files defining classes called `myFrontWebController`, `myUser`, `myRequest`, etc. They all simply inherit of the 'sf-' classes, and this allows you to customize their behavior. The framework knows to use the 'my-' classes instead of the 'sf-' ones by the configuration setting found in the `factories.yml` file: 
     195Symfony uses classes such as `sfFrontWebController`, `sfRequest`, `sfUser`, that are part of the framework. In the `myproject/apps/myapp/lib/` directory, you can override them with your own `myFrontWebController`, `myRequest` classes (`myUser` already exists). They simply need inherit of the 'sf-' classes, and this allows you to customize their behavior. Teel the framework to use the 'my-' classes instead of the 'sf-' ones by changing the settings found in the `factories.yml` file: 
    196196 
    197197    ... 
    198198    all: 
    199199    #  controller: 
    200     #    class: myFrontWebController 
     200    #    class: sfFrontWebController 
    201201    # 
    202202    #  request: 
    203     #    class: myWebRequest 
     203    #    class: sfWebRequest 
    204204    # 
    205205    #  user: 
     
    207207    ... 
    208208 
    209 This means that you have a prebuilt mechanism to change the **factories** of symfony, the big classes that run behind the curtain, by adding or inheriting methods in the 'my-' classes. 
    210  
    211 But if you want to use completely different factories, well, you can. Just modify the `factories.yml` entries to point to your custom files.  
     209Have a look at the existing `myUser` class to see how the inheritance allows for extension and overriding of **factories** classes.  
    212210 
    213211### Front controller configuration 
  • branches/synace/doc/book/content/cookie.txt

    r1016 r2043  
    208208      sfContext::getInstance()->getResponse()->setCookie('MyWebSite', '', time() - 3600, '/'); 
    209209    } 
     210 
     211>**Note**: This solution works only for non-secure pages, since the security check for secure pages occurs _before_ the custom `remember` filter. Consequently, if a user with a proper cookie tries to access a secure page without having logged to the site in a non-secure page before, he/she will be redirected to the login page as anybody else. If you want the remember me feature to work for secure pages as well, the implementation has to be slightly different. You must create a `myBasicSecurityFilter` class, specializing the `sfBasicSecurityFilter` class, and put the cookie control in it. Then, in the `factories.yml`, change the name of the `security_filter` class to this `myBasicSecurityFilter`. The details of the implementation are left to your sagacity. 
  • branches/synace/doc/book/content/custom_helper.txt

    r1251 r2043  
    2424    [php] 
    2525    <?php use_helper('Name') ?> 
     26     
     27>**Note**: If you create a helper file with the same name as one of the existing helper packages of symfony, it will override the one in the framework. It means that you can redefine all the symfony helpers at the application or project level. Beware that your custom file is read _instead_ of the one in the framework, so it is not actually inheritance, and helpers not included in your version will not be available in the code. 
    2628 
    2729### Example 
  • branches/synace/doc/book/content/generator.txt

    r1627 r2043  
    123123The following sections explain in detail the parameters that can be used in this configuration file. 
    124124 
    125 Table relations 
    126 --------------- 
    127  
    128 The 1-n table relations are taken care of by the admin generator. In the example mentionned above, the `weblog_comment` table is related to the `weblog_article` table via the `article_id` field. If you initiate the module of the `Comment` class with the admin generator: 
    129  
    130     $ symfony propel-init-admin myapp comment Comment 
    131  
    132 The `comment/edit` action will automatically display the `article_id` as a select list showing the ids of the available records of the `weblog_article` table. In addition, if you define a `__toString()` method in the `Article` object, the string returned by this method is used instead of the ids in the select list. 
    133  
    134 If you need to display the list of comments related to an article in the `article` module (n-1 relation), or if you need to handle related records through a hash table (n-m relation), you will need to customize the module a little by the way of *custom field* or a *partial field*, both described later in this chapter. 
    135  
    136125Fields 
    137126------ 
     
    275264>           article_link:   { name: Article } 
    276265> 
     266 
     267If your partial gets crowded with more and more logic, you'll probably want to replace it by a component. Change the `_` prefix by a `~` and you can define a component column: 
     268 
     269        ... 
     270        list: 
     271          display:        [id, ~article_link, date] 
     272           
     273In the generated template, this will result by a call to the `articleLink` component of the current module. 
    277274 
    278275Custom and partial fields can be used in the list view and in the edit view. 
     
    472469 
    473470>**Note**: In the real world, a `user/edit` view usually contains two `password` fields, the second having to match the first one to avoid typing mistakes. In practice, this is done via a [validator](validate_form.txt). The admin generated modules benefit from this mechanism just like regular modules. 
     471 
     472Table relationships 
     473------------------- 
     474 
     475### One to many 
     476 
     477The 1-n table relationships are taken care of by the admin generator. In the example mentionned above, the `weblog_comment` table is related to the `weblog_article` table via the `article_id` field. If you initiate the module of the `Comment` class with the admin generator: 
     478 
     479    $ symfony propel-init-admin myapp comment Comment 
     480 
     481The `comment/edit` action will automatically display the `article_id` as a select list showing the ids of the available records of the `weblog_article` table. In addition, if you define a `__toString()` method in the `Article` object, the string returned by this method is used instead of the ids in the select list. 
     482 
     483If you need to display the list of comments related to an article in the `article` module (n-1 relationship), you will need to customize the module a little by the way of a partial field. 
     484 
     485### Many to many 
     486 
     487The n-n table relationships are also taken care of. The implementation of such relationships is made through an intermediate table. For instance, if there is a n-n relation between a `blog_article` and a `blog_author` table (an article can be written by more than one author and, obviously, an author can write more than one article), then your database will always end up with a table called `blog_article_author` or similar.  
     488 
     489  | blog_article | blog_article_author | blog_author | 
     490  | ------------ | ------------------- | ----------- | 
     491  | id           | article_id          | id          | 
     492  | title        | author_id           | name        | 
     493  | ...          |                     | ...         | 
     494 
     495The model will then have a class called `ArticleAuthor` and this is the only thing that the admin generator needs - but you have to pass it as a parameter of the field, called `trough_class`. 
     496 
     497For instance, in a generated module based on the `Article` class, you can add a field to create new n-n associations with the `Author` class.  
     498 
     499        edit: 
     500          fields: 
     501            article_author: { type: admin_double_list, params: through_class=ArticleAuthor } 
     502             
     503Such a field handles links between existing objects, so a regular select list is not enough. You must use a special type of input for that. Symfony offers three widgets to help relate members of two lists. You have the choice between an `admin_double_list`, an `admin_select_list` and an `admin_check_list`. 
    474504 
    475505Interactions 
  • branches/synace/doc/book/content/i18n.txt

    r1605 r2043  
    237237The syntax of the last lines illustrates the ability to do a simple substitution within the `__()` function, to avoid unnecessary chunking of text. 
    238238 
    239 One of the common problems with tranlsation is the use of the plural form. According to the number of results, the text changes, such as in: 
     239One of the common problems with translation is the use of the plural form. According to the number of results, the text changes, such as in: 
    240240 
    241241    [php] 
  • branches/synace/doc/book/content/javascript.txt

    r1547 r2043  
    2626------------- 
    2727 
    28 The most common use of JavaScript is in a hyperlink that triggers a particular script. In HTML, you would probably write it like that: 
    29  
    30     [php] 
    31     <a href="#" onClick="alert('foobar');return none;">Click me!</a> 
    32      
    33 Symfony proposes a helper to write it in a more concise way, the `link_to_function()`:  
    34  
    35     [php] 
    36     <?php echo link_to_function("Click me!", "alert('foobar')") ?> 
    37      
    38 Like the `link_to()` [URL helper](templating_link_helpers.txt), you can add options to the `<a>` tag generated by a `link_to_function()`: 
    39  
    40     [php] 
    41     <?php echo link_to_function("Click me!", "alert('foobar')", "class=mylink style=color:#f00 alt=please click me" ) ?> 
    42  
    43 >**Note**: Just like the `link_to()` helper has a `button_to()` brother, you can trigger a JavaScript from a button (`<input type="button">`) by calling the `button_to_function()` helper. And if you prefer a clickable image, just call `link_to_function(image_tag('myimage'), "alert('foobar')")`. 
     28### Clean XHTML JavaScript inclusion 
    4429 
    4530If you want to write a piece of JavaScript code in your page, instead of writing manually something like: 
     
    6449      }           
    6550    ") ?> 
     51     
     52### Link behavior 
     53 
     54The most common use of JavaScript is in a hyperlink that triggers a particular script. In HTML, you would probably write it like that: 
     55 
     56    [php] 
     57    <a href="#" onClick="alert('foobar');return none;">Click me!</a> 
     58     
     59Symfony proposes a helper to write it in a more concise way, the `link_to_function()`:  
     60 
     61    [php] 
     62    <?php echo link_to_function("Click me!", "alert('foobar')") ?> 
     63     
     64Like the `link_to()` [URL helper](templating_link_helpers.txt), you can add options to the `<a>` tag generated by a `link_to_function()`: 
     65 
     66    [php] 
     67    <?php echo link_to_function("Click me!", "alert('foobar')", "class=mylink style=color:#f00 alt=please click me" ) ?> 
     68 
     69>**Note**: Just like the `link_to()` helper has a `button_to()` brother, you can trigger a JavaScript from a button (`<input type="button">`) by calling the `button_to_function()` helper. And if you prefer a clickable image, just call `link_to_function(image_tag('myimage'), "alert('foobar')")`. 
     70 
     71### Updating an element 
    6672 
    6773One common task in applications that use JavaScript a lot is the update of an element in the page. This is something that you usually write: 
     
    97103 
    98104The helper makes your templates easier to understand than any JavaScript code, and you have one single syntax for similar behaviours. That's also why the helper name is so long: It makes the code self-sufficient, without the need of extra commentaries. 
     105 
     106### Graceful degradation