[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/helper/ -> UrlHelper.php (sommaire)

UrlHelper.

Author: Fabien Potencier <fabien.potencier@symfony-project.com>
Version: SVN: $Id: UrlHelper.php 3380 2007-02-01 06:57:47Z fabien $
Poids: 438 lignes (15 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 11 fonctions

  url_for()
  link_to()
  link_to_if()
  link_to_unless()
  button_to()
  mail_to()
  _convert_options_to_javascript()
  _confirm_javascript_function()
  _popup_javascript_function()
  _post_javascript_function()
  _encodeText()

Fonctions
Fonctions qui ne font pas partie d'une Classe:

url_for($internal_uri, $absolute = false)   X-Ref
Returns a routed URL based on the module/action passed as argument
and the routing configuration.

<b>Examples:</b>
<code>
echo url_for('my_module/my_action');
=> /path/to/my/action
echo url_for('@my_rule');
=> /path/to/my/action
echo url_for('@my_rule', true);
=> http://myapp.example.com/path/to/my/action
</code>

param: string 'module/action' or '@rule' of the action
param: bool return absolute path?
return: string routed URL

link_to($name = '', $internal_uri = '', $options = array()   X-Ref
Creates a <a> link tag of the given name using a routed URL
based on the module/action passed as argument and the routing configuration.
It's also possible to pass a string instead of a module/action pair to
get a link tag that just points without consideration.
If null is passed as a name, the link itself will become the name.
If an object is passed as a name, the object string representation is used.
One of the options serves for for creating javascript confirm alerts where
if you pass 'confirm' => 'Are you sure?', the link will be guarded
with a JS popup asking that question. If the user accepts, the link is processed,
otherwise not.

<b>Options:</b>
- 'absolute' - if set to true, the helper outputs an absolute URL
- 'query_string' - to append a query string (starting by ?) to the routed url
- 'confirm' - displays a javascript confirmation alert when the link is clicked
- 'popup' - if set to true, the link opens a new browser window
- 'post' - if set to true, the link submits a POST request instead of GET (caution: do not use inside a form)

<b>Note:</b> The 'popup' and 'post' options are not compatible with each other.

<b>Examples:</b>
<code>
echo link_to('Delete this page', 'my_module/my_action');
=> <a href="/path/to/my/action">Delete this page</a>
echo link_to('Visit Hoogle', 'http://www.hoogle.com');
=> <a href="http://www.hoogle.com">Visit Hoogle</a>
echo link_to('Delete this page', 'my_module/my_action', array('id' => 'myid', 'confirm' => 'Are you sure?', 'absolute' => true));
=> <a href="http://myapp.example.com/path/to/my/action" id="myid" onclick="return confirm('Are you sure?');">Delete this page</a>
</code>

param: string name of the link, i.e. string to appear between the <a> tags
param: string 'module/action' or '@rule' of the action
param: array additional HTML compliant <a> tag parameters
return: string XHTML compliant <a href> tag

link_to_if($condition, $name = '', $internal_uri = '', $options = array()   X-Ref
If the condition passed as first argument is true,
creates a <a> link tag of the given name using a routed URL
based on the module/action passed as argument and the routing configuration.
If the condition is false, the given name is returned between <span> tags

<b>Options:</b>
- 'tag' - the HTML tag that must enclose the name if the condition is false, defaults to <span>
- 'absolute' - if set to true, the helper outputs an absolute URL
- 'query_string' - to append a query string (starting by ?) to the routed url
- 'confirm' - displays a javascript confirmation alert when the link is clicked
- 'popup' - if set to true, the link opens a new browser window
- 'post' - if set to true, the link submits a POST request instead of GET (caution: do not use inside a form)

<b>Examples:</b>
<code>
echo link_to_if($user->isAdministrator(), 'Delete this page', 'my_module/my_action');
=> <a href="/path/to/my/action">Delete this page</a>
echo link_to_if(!$user->isAdministrator(), 'Delete this page', 'my_module/my_action');
=> <span>Delete this page</span>
</code>

param: bool condition
param: string name of the link, i.e. string to appear between the <a> tags
param: string 'module/action' or '@rule' of the action
param: array additional HTML compliant <a> tag parameters
return: string XHTML compliant <a href> tag or name

link_to_unless($condition, $name = '', $url = '', $options = array()   X-Ref
If the condition passed as first argument is false,
creates a <a> link tag of the given name using a routed URL
based on the module/action passed as argument and the routing configuration.
If the condition is true, the given name is returned between <span> tags

<b>Options:</b>
- 'tag' - the HTML tag that must enclose the name if the condition is true, defaults to <span>
- 'absolute' - if set to true, the helper outputs an absolute URL
- 'query_string' - to append a query string (starting by ?) to the routed url
- 'confirm' - displays a javascript confirmation alert when the link is clicked
- 'popup' - if set to true, the link opens a new browser window
- 'post' - if set to true, the link submits a POST request instead of GET (caution: do not use inside a form)

<b>Examples:</b>
<code>
echo link_to_unless($user->isAdministrator(), 'Delete this page', 'my_module/my_action');
=> <span>Delete this page</span>
echo link_to_unless(!$user->isAdministrator(), 'Delete this page', 'my_module/my_action');
=> <a href="/path/to/my/action">Delete this page</a>
</code>

param: bool condition
param: string name of the link, i.e. string to appear between the <a> tags
param: string 'module/action' or '@rule' of the action
param: array additional HTML compliant <a> tag parameters
return: string XHTML compliant <a href> tag or name

button_to($name, $internal_uri, $options = array()   X-Ref
Creates an <input> button tag of the given name pointing to a routed URL
based on the module/action passed as argument and the routing configuration.
The syntax is similar to the one of link_to.

<b>Options:</b>
- 'absolute' - if set to true, the helper outputs an absolute URL
- 'query_string' - to append a query string (starting by ?) to the routed url
- 'confirm' - displays a javascript confirmation alert when the button is clicked
- 'popup' - if set to true, the button opens a new browser window
- 'post' - if set to true, the button submits a POST request instead of GET (caution: do not use inside a form)

<b>Examples:</b>
<code>
echo button_to('Delete this page', 'my_module/my_action');
=> <input value="Delete this page" type="button" onclick="document.location.href='/path/to/my/action';" />
</code>

param: string name of the button
param: string 'module/action' or '@rule' of the action
param: array additional HTML compliant <input> tag parameters
return: string XHTML compliant <input> tag

mail_to($email, $name = '', $options = array()   X-Ref
Creates a <a> link tag to the given email (with href="mailto:...").
If null is passed as a name, the email itself will become the name.

<b>Options:</b>
- 'encode' - if set to true, the email address appears with various random encoding for each letter.
The mail link still works when encoded, but the address doesn't appear in clear
in the source. Use it to prevent spam (efficiency not guaranteed).

<b>Examples:</b>
<code>
echo mail_to('webmaster@example.com');
=> <a href="mailto:webmaster@example.com">webmaster@example.com</a>
echo mail_to('webmaster@example.com', 'send us an email');
=> <a href="mailto:webmaster@example.com">send us an email</a>
echo mail_to('webmaster@example.com', 'send us an email', array('encode' => true));
=> <a href="&#x6d;a&#x69;&#x6c;&#x74;&#111;&#58;&#x77;&#x65;b&#x6d;as&#116;&#x65;&#114;&#64;&#101;&#x78;&#x61;&#x6d;&#x70;&#108;&#x65;&#46;&#99;&#x6f;&#109;">send us an email</a>
</code>

param: string target email
param: string name of the link, i.e. string to appear between the <a> tags
param: array additional HTML compliant <a> tag parameters
return: string XHTML compliant <a href> tag

_convert_options_to_javascript($html_options, $internal_uri = '')   X-Ref
Pas de description

_confirm_javascript_function($confirm)   X-Ref
Pas de description

_popup_javascript_function($popup, $internal_uri = '')   X-Ref
Pas de description

_post_javascript_function()   X-Ref
Pas de description

_encodeText($text)   X-Ref
Pas de description



Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7