本文整理汇总了PHP中url_for函数的典型用法代码示例。如果您正苦于以下问题:PHP url_for函数的具体用法?PHP url_for怎么用?PHP url_for使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了url_for函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getJavascript
public function getJavascript($name)
{
sfContext::getInstance()->getConfiguration()->loadHelpers('Tag', 'Url');
$addEmpty = $this->getOption('on_empty') ? sprintf("if(selectedVal == '') { \$('%s').html('%s').show();return;}", $this->getOption('update'), $this->getOption('on_empty')) : '';
$javascripts = <<<EOF
<script type="text/javascript">
// Default jQuery wrapper
\$(document).ready(function() {
// When the choice widget is changed
\$("#%s").change(function() {
// Hide the target element
var selectedVal = \$(this).attr("value");
%s
\$("%s").addClass('indicator').html(' ');
// url of the JSON
var url = "%s" + selectedVal;
// Get the JSON for the selected item
\$("%s").load(url, function() {
\$(this).removeClass('indicator');
%s
});
})%s
});
</script>
EOF;
return sprintf($javascripts, $this->generateId($name), $addEmpty, $this->getOption('update'), url_for($this->getOption('url')), $this->getOption('update'), $this->getOption('on_update'), $this->getOption('update_on_load') ? '.change();' : '');
}
开发者ID:bshaffer,项目名称:Symplist,代码行数:32,代码来源:sfWidgetFormAjaxEvent.class.php
示例2: link_to
/**
* 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 null is passed as a name, the link itself will become the name.
*
* Examples:
* echo link_to('Homepage', 'default/index')
* => <a href="/">Homepage</a>
*
* echo link_to('News 2008/11', 'news/index?year=2008&month=11')
* => <a href="/news/2008/11">News 2008/11</a>
*
* echo link_to('News 2008/11 [absolute url]', 'news/index?year=2008&month=11', array('absolute'=>true))
* => <a href="http://myapp.example.com/news/2008/11">News 2008/11 [absolute url]</a>
*
* echo link_to('Absolute url', 'http://www.google.com')
* => <a href="http://www.google.com">Absolute url</a>
*
* echo link_to('Link with attributes', 'default/index', array('id'=>'my_link', 'class'=>'green-arrow'))
* => <a id="my_link" class="green-arrow" href="/">Link with attributes</a>
*
* echo link_to('<img src="x.gif" width="150" height="100" alt="[link with image]" />', 'default/index' )
* => <a href="/"><img src="x.gif" width="150" height="100" alt="[link with image]" /></a>
*
*
* Options:
* 'absolute' - if set to true, the helper outputs an absolute URL
* 'query_string' - to append a query string (starting by ?) to the routed url
* 'anchor' - to append an anchor (starting by #) to the routed url
*
* @param string text appearing between the <a> tags
* @param string 'module/action' or '@rule' of the action, or an absolute url
* @param array additional HTML compliant <a> tag parameters
* @return string XHTML compliant <a href> tag
* @see url_for
*/
function link_to($name = '', $internal_uri = '', $options = array())
{
$html_options = _parse_attributes($options);
$absolute = false;
if (isset($html_options['absolute'])) {
$absolute = (bool) $html_options['absolute'];
unset($html_options['absolute']);
}
// Fabrice: FIXME (genUrl() doesnt like '#anchor' ?) => ignore empty string
$html_options['href'] = $internal_uri !== '' ? url_for($internal_uri, $absolute) : '';
// anchor
if (isset($html_options['anchor'])) {
$html_options['href'] .= '#' . $html_options['anchor'];
unset($html_options['anchor']);
}
if (isset($html_options['query_string'])) {
$html_options['href'] .= '?' . $html_options['query_string'];
unset($html_options['query_string']);
}
if (is_object($name)) {
if (method_exists($name, '__toString')) {
$name = $name->__toString();
} else {
DBG::error(sprintf('Object of class "%s" cannot be converted to string (Please create a __toString() method).', get_class($name)));
}
}
if (!strlen($name)) {
$name = $html_options['href'];
}
return content_tag('a', $name, $html_options);
}
开发者ID:nikitakit,项目名称:RevTK,代码行数:68,代码来源:UrlHelper.php
示例3: getUri
/**
* Generates the url to this menu item based on the route
*
* @param array $options Options to pass to the url_for method
*/
public function getUri(array $options = array())
{
if (!$this->getRoute() || $this->getRoute() == '#') {
return null;
}
// setup the options array and single out the absolute boolean
$options = array_merge($this->getUrlOptions(), $options);
if (isset($options['absolute'])) {
$absolute = $options['absolute'];
unset($options['absolute']);
} else {
$absolute = false;
}
try {
// Handling of the url options varies depending on the url format
if ($this->_isOldRouteMethod()) {
// old-school url_for('@route_name', $absolute);
return url_for($this->getRoute(), $absolute);
} else {
// new-school url_for('route_name', $options, $absolute)
return url_for($this->getRoute(), $options, $absolute);
}
} catch (sfConfigurationException $e) {
throw new sfConfigurationException(sprintf('Problem with menu item "%s": %s', $this->getLabel(), $e->getMessage()));
return $this->getRoute();
}
}
开发者ID:remyfrd,项目名称:ioMenuPlugin,代码行数:32,代码来源:ioMenuItem.class.php
示例4: __construct
public function __construct($loadHelper = true) {
$this->helperFlag = $loadHelper;
if($loadHelper == true) {
$this->loadHelper();
$this->setServerUrl(url_for('layout/index',true));
}
}
开发者ID:rlauenroth,项目名称:cuteflow_v3,代码行数:7,代码来源:WorkflowEdit.class.php
示例5: print_celula_tabela_consolidado
function print_celula_tabela_consolidado($mes, $ano, $statusConta, $listaContas)
{
?>
<?php
$loteContas = Conta::getLoteFromListaContas($statusConta, $ano, $mes, $listaContas);
?>
<div class="overlay">
<div><?php
print_valor(Conta::getTotalFromLote($loteContas));
?>
</div>
<a rel="#overlay" href="<?php
echo url_for('financeiro/addConta?ano=' . $ano->getAno() . '&mes=' . $mes . '&statusConta=' . $statusConta->getSlug());
?>
"><?php
echo image_tag("add-conta.png");
?>
</a>
<?php
if (count($loteContas) > 0) {
?>
<a rel="#overlay" href="<?php
echo url_for('financeiro/listaContas?ano=' . $ano->getAno() . '&mes=' . $mes . '&statusConta=' . $statusConta->getSlug());
?>
"><?php
echo image_tag("list-conta.png", array('width' => 32, 'heigth' => 32));
?>
</a>
<?php
}
?>
</div>
<?php
}
开发者ID:robertcosta,项目名称:symfony-condomino,代码行数:34,代码来源:ConsolidadoHelper.php
示例6: render
public function render($name, $value = null, $attributes = array(), $errors = array())
{
$context = sfContext::getInstance();
$response = $context->getResponse();
$autocompleteDiv = "";
// content_tag('div' , '', array('id' => $this->generateId($name) . '_autocomplete', 'class' => 'autocomplete'));
$desc = '';
if (true === $this->getOption('desc')) {
$desc = '.data( "ui-autocomplete" )._renderItem = function( ul, item ) {
return $( "<li>" )
.append( "<a>" + item.label + "<br>" + item.desc + "</a>" )
.appendTo( ul );
}';
}
$autocompleteJs = $this->javascriptTag("\n \n \$(function(){\n \n \$('#" . $this->generateId($name) . "_ajaxtext').autocomplete({\n source: '" . url_for($this->getOption('url')) . "',\n delay:30,\n minChars:0,\n appendTo: '" . $this->getOption('appendTo') . "',\n max:30,\n width: 300,\n matchSubset:1,\n matchContains:1,\n cacheLength:10,\n autoFill:false,\n autoFocus: true,\n select: function( event, ui ) {\n \$('#" . $this->generateId($name) . "').val(ui.item.id);\n \$('#" . get_id_from_name($name) . "_ajaxcheckbox').prop('checked', true)\n \$('#" . get_id_from_name($name) . "_ajaxcheckboxText').html('" . __('kiválasztva') . "');\n \$('#" . $this->generateId($name) . "').trigger('change', [ui.item])\n } \n }){$desc}\n \n \n \n \$.fn.autocomplete.keypressEvent = function (evt, id){\n car = evt.keyCode || evt.charCode;\n if (car != 27 && car!=9) //ESC + TAB\n {\n \$('#'+id).val('');\n \$('#'+id+'_ajaxcheckbox').attr('checked',false);\n \$('#'+id+'_ajaxcheckboxText').html('" . __('nincs kiválasztva') . "'); \n \$('#" . $this->generateId($name) . "').trigger('change')\n } \n } \n \n });");
$ihidden = new sfWidgetFormInputHidden();
$ihiddenText = $ihidden->render($name, $value, $attributes);
if ($value != '') {
$checked = 'checked="checked"';
$checkboxtext = "<span id='" . get_id_from_name($name) . "_ajaxcheckboxText'>" . __('kiválasztva') . "</span>";
} else {
$checked = '';
$checkboxtext = "<span id='" . get_id_from_name($name) . "_ajaxcheckboxText'>" . __('nincs kiválasztva') . "</span>";
}
$checkbox = '<input type="checkbox" id="' . get_id_from_name($name) . '_ajaxcheckbox' . '" ' . $checked . ' disabled="disabled" />';
$attributesText = array_merge($attributes, array('name' => false, 'id' => get_id_from_name($name) . '_ajaxtext'));
$attributesText['onkeydown'] = "\$('#" . $this->generateId($name) . "_ajaxtext').autocomplete.keypressEvent(event, '" . $this->generateId($name) . "')";
$itextText = parent::render($name, $this->getValueFromId($value), $attributesText, $errors);
$indicator = '<span id="indicator-' . $this->generateId($name) . '" style="display: none;"> <img src="/sfFormExtraPlugin/images/indicator.gif" alt="loading" /></span>';
return $ihiddenText . $itextText . $checkbox . $checkboxtext . $indicator . $autocompleteDiv . $autocompleteJs;
}
开发者ID:nova76,项目名称:nova-plugins,代码行数:31,代码来源:novaWidgetFormjQqueryUIAutocomplete.class.php
示例7: util_link_for
function util_link_for($title = null, $ctrl = null, $action = null, $id = null, $onclick = null, $extra_params = null)
{
if ($title === null) {
return false;
}
if ($ctrl === null) {
$ctrl = 'main';
}
if ($action === null) {
$action = 'index';
}
if ($id === null) {
$id = 0;
}
$onclick = $onclick !== null ? "onclick=\"{$onclick}\"" : '';
$url = url_for($ctrl, $action, $id);
if (!$url) {
return false;
}
if ($extra_params !== null && is_array($extra_params) && count($extra_params)) {
foreach ($extra_params as $param => $value) {
$url .= "&{$param}={$value}";
}
}
return "<a href=\"{$url}\" {$onclick}>{$title}</a>";
}
开发者ID:smbale,项目名称:open-social-media-toolkit,代码行数:26,代码来源:utility_functions.php
示例8: render
public function render($name, $value = null, $attributes = array(), $errors = array())
{
$textarea = parent::render($name, $value, $attributes, $errors);
$js = sprintf(<<<EOF
<script type="text/javascript">
/* <![CDATA[ */
lyMediaManager.init('%s');
tinyMCE.init({
convert_urls : false,
mode: "exact",
elements: "%s",
theme: "%s",
%s
%s
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_statusbar_location: "bottom",
theme_advanced_resizing: true,
file_browser_callback : "lyMediaManager.fileBrowserCallBack"
%s
});
/* ]]> */
</script>
EOF
, url_for('@ly_media_asset_icons?popup=1', true), $this->generateId($name), $this->getOption('theme'), $this->getOption('width') ? sprintf('width: "%spx",', $this->getOption('width')) : '', $this->getOption('height') ? sprintf('height: "%spx",', $this->getOption('height')) : '', $this->getOption('config') ? ",\n" . $this->getOption('config') : '');
return $textarea . $js;
}
开发者ID:vjousse,项目名称:lyMediaManagerPlugin,代码行数:28,代码来源:sfWidgetFormLyMediaTinyMCE.class.php
示例9: image_cache_tag
function image_cache_tag($route, $format, $path, $image, $alt = null)
{
$_formats = sfConfig::get('imagecache_formats');
$_format = $_formats[$format];
if (!isset($_format)) {
throw new RuntimeException('Format not found');
}
$real_file_path = sfConfig::get('sf_upload_dir') . '/' . $path . '/' . $image;
if (file_exists($real_file_path)) {
$cache_file_path = sfConfig::get('sf_upload_dir') . '/cache/' . $format . '/' . $path . '/' . $image;
$is_cached_file = file_exists($cache_file_path);
$options = array('path' => $format . '/' . $path . '/' . $image);
$url = urldecode(url_for($route, $options));
if ($is_cached_file) {
$cached_image = new sfImage($cache_file_path);
$width = $cached_image->getWidth();
$height = $cached_image->getHeight();
return image_tag($url, array('size' => $width . 'x' . $height, 'alt' => $alt));
} else {
return image_tag($url, array('alt' => $alt));
}
} else {
return '';
}
}
开发者ID:GrifiS,项目名称:SyrexCMS,代码行数:25,代码来源:ImageCacheHelper.php
示例10: tablePagination
function tablePagination($pager, $url, $name = "page", $add = "")
{
if (strpos($url, '?')) {
$char = '&';
} else {
$char = '?';
}
echo "<ul>";
if ($pager->haveToPaginate()) {
echo "<li>";
echo "<a href=\"" . url_for($url . $char . "{$name}=" . $pager->getPreviousPage()) . "{$add}\">";
echo "\t< Précédent";
echo "</a>";
echo "</li>";
foreach ($pager->getLinks(10) as $page) {
if ($page == $pager->getPage()) {
echo "<li class=\"active\">";
echo "<a href=\"#\">" . $page . "</a>";
} else {
echo "<li>";
echo "<a href=\"" . url_for($url . $char . "{$name}=" . $page) . "{$add}\">";
echo $page;
echo "</a>";
}
echo "</li>";
}
echo "<li>";
echo "<a href=\"" . url_for($url . $char . "{$name}=" . $pager->getNextPage()) . "{$add}\">";
echo "\tSuivant >";
echo "</a>";
echo "</li>";
}
echo "</ul>";
}
开发者ID:heew,项目名称:eBot-CSGO-Web,代码行数:34,代码来源:TablePaginationHelper.php
示例11: remote_function
function remote_function($options)
{
$jsOptions = options_for_ajax($options);
if (isset($options['update']) && is_array($options['update'])) {
$updates = array();
if (isset($options['update']['success'])) {
$updates[] = "success:'" . $options['update']['success'] . "'";
}
if (isset($options['update']['failure'])) {
$updates[] = "failure:'" . $options['update']['failure'] . "'";
}
$update = '{' . implode(',', $updates) . '}';
} elseif (isset($options['update'])) {
$update = "'" . $options['update'] . "'";
}
$js = !isset($update) ? "new Ajax.Request(" : "new Ajax.Updater({$update}, ";
$js .= "'" . url_for($options['url']) . "', {$jsOptions})";
if (isset($options['before'])) {
$js = $options['before'] . "; {$js}";
}
if (isset($options['after'])) {
$js = "{$js}; " . $options['after'];
}
if (isset($options['condition'])) {
$js = "if (" . $options['condition'] . ") { {$js}; }";
}
if (isset($options['confirm'])) {
$js = "if (confirm(" . addslashes($options['confirm']) . ")) { {$js}; }";
}
return $js;
}
开发者ID:BackupTheBerlios,项目名称:stato-svn,代码行数:31,代码来源:ajax_helper.php
示例12: render
/**
* @param string $name The element name
* @param string $value The date displayed in this widget
* @param array $attributes An array of HTML attributes to be merged with the default HTML attributes
* @param array $errors An array of errors for the field
*
* @return string An HTML tag string
*
* @see sfWidgetForm
*/
public function render($name, $value = null, $attributes = array(), $errors = array())
{
$url = url_for('@pm_widget_form_propel_input_by_code', true);
$options_without_template = $this->getOptions();
unset($options_without_template['template']);
return parent::render($name, $value, $attributes, $errors) . sprintf($this->getOption('template'), $this->generateId($name . '_result'), $this->generateId($name), $url, serialize($options_without_template));
}
开发者ID:nvidela,项目名称:kimkelen,代码行数:17,代码来源:pmWidgetFormPropelInputByCode.class.php
示例13: get_combined_stylesheets
/**
* Returns <link> tags with the url toward all stylesheets configured in view.yml or added to the response object.
*
* You can use this helper to decide the location of stylesheets in pages.
* By default, if you don't call this helper, symfony will automatically include stylesheets before </head>.
* Calling this helper disables this behavior.
*
* @return string <link> tags
*/
function get_combined_stylesheets()
{
if (!sfConfig::get('app_sfCombinePlugin_enabled', false)) {
return get_stylesheets();
}
$response = sfContext::getInstance()->getResponse();
sfConfig::set('symfony.asset.stylesheets_included', true);
$configSfCombinePlugin['css'] = sfConfig::get('app_sfCombinePlugin_css', array());
$html = '';
$cssFiles = $include_tags = array();
foreach (array('first', '', 'last') as $position) {
foreach ($response->getStylesheets($position) as $files => $options) {
if (!in_array($files, $configSfCombinePlugin['css']['online']) && !in_array($files, $configSfCombinePlugin['css']['offline'])) {
if (!is_array($files)) {
$files = array($files);
}
$cssFiles = array_merge($cssFiles, $files);
} else {
$include_tags[] = stylesheet_tag(url_for($files));
}
}
}
$key = _get_key($cssFiles);
$include_tags[] = str_replace('.css', '', stylesheet_tag(url_for('sfCombine/css?key=' . $key)));
return implode("", $include_tags);
}
开发者ID:cbsistem,项目名称:appflower_engine,代码行数:35,代码来源:sfCombineHelper.php
示例14: upload
/**
* This handles uploads to a persions channel
* Need file posted as 'file' and the has poster as 'hash'
*/
public function upload()
{
switch ($this->format) {
case 'xml':
try {
$package = Package::from_upload(array('file' => $_FILES['file']['tmp_name'], 'sig' => $_POST['signatureBase64'], 'user' => $this->user), true);
if ($package->saved) {
echo 'Package uploaded succesfuly!';
}
} catch (Exception $e) {
$this->header("HTTP/1.0 500 Internal Server Error", 500);
echo $e->getMessage();
}
$this->has_rendered = true;
break;
default:
if ($_SESSION['upload_key'] !== $_POST['upload_key']) {
Nimble::flash('notice', 'Invalid Upload Key');
$this->redirect_to(url_for('LandingController', 'user_index', $this->user->username));
}
unset($_SESSION['upload_key']);
try {
$package = Package::from_upload(array('file' => $_FILES['file']['tmp_name'], 'user' => $this->user));
if ($package->saved) {
$this->redirect_to(url_for('LandingController', 'user_index', $this->user->username));
}
} catch (Exception $e) {
Nimble::flash('notice', $e->getMessage());
$this->redirect_to(url_for('ChannelController', 'upload'));
}
break;
}
}
开发者ID:scottdavis,项目名称:pearfarm_channel_server,代码行数:37,代码来源:channel_controller.php
示例15: before
function before()
{
layout('layouts/default.html.php');
/*set('header', '
<a href="'.url_for().'">Home</a>
<a href="'.url_for('people').'">Personen</a>
<a href="'.url_for('roles').'">Rollen</a>
<a href="'.url_for('access').'">Zugriff</a>
<a href="'.url_for('servers').'">Server</a>
<a href="'.url_for('daemons').'">Daemons</a>
');*/
set('header', '
<img id="header_img" src="img/aclmodel.png" width="850" height="83" usemap="#head_nav" alt="header_navigation">
<map name="head_nav">
<area id="daemons_nav" shape="rect" href="' . url_for('daemons') . '" coords="682,7,781,28" alt="daemons">
<area id="servers_nav" shape="rect" href="' . url_for('servers') . '" coords="516,7,635,28" alt="servers">
<area id="access_nav" shape="rect" href="' . url_for('access') . '" coords="391,7,478,28" alt="access">
<area id="roles_nav" shape="rect" href="' . url_for('roles') . '" coords="239,7,340,28" alt="roles">
<area id="people_nav" shape="rect" href="' . url_for('people') . '" coords="74,7,193,28" alt="people">
<area id="clients_nav" shape="rect" href="' . url_for('clients') . '" coords="2,55,98,76" alt="clients">
<area id="people_roles_nav" shape="rect" href="' . url_for('people_roles') . '" coords="176,54,267,75" alt="people_roles">
<area id="ports_nav" shape="rect" href="' . url_for('ports') . '" coords="748,55,849,76" alt="ports">
</map>
');
set('footer', '© 2011 - Florian Staudacher (Frontend), Alexander Philipp Lintenhofer (Backend)');
}
开发者ID:Raven24,项目名称:DbAcl,代码行数:26,代码来源:config.inc.php
示例16: getJavaScripts
public function getJavaScripts()
{
return array('/js/FLoginForm.js');
$url_params = sfJqueryFormValidationRules::getUrlParams();
$url_params['form'] = get_class($this);
return array_merge(parent::getJavaScripts(), array(url_for($url_params)));
}
开发者ID:limitium,项目名称:uberlov,代码行数:7,代码来源:FLoginForm.php
示例17: init_media_library
function init_media_library()
{
sfContext::getInstance()->getResponse()->addJavascript('/sfMediaLibraryPlugin/js/main', 'last');
$url = url_for('sfMediaLibrary/choice');
$js = 'sfMediaLibrary.init(\'' . $url . '\')';
return javascript_tag($js);
}
开发者ID:mediasadc,项目名称:alba,代码行数:7,代码来源:sfMediaLibraryHelper.php
示例18: html_default_layout
function html_default_layout($vars)
{
extract($vars);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Before render filter test</title>
</head>
<body>
<article>
<?php
echo $content;
?>
</article>
<hr>
<nav>
<p><strong>Menu:</strong>
<a href="<?php
echo url_for('/');
?>
">Index</a> |
<a href="<?php
echo url_for('/error');
?>
">Error</a>
</p>
</nav>
<hr>
</body>
</html>
<?php
}
开发者ID:karupanerura,项目名称:isucon4,代码行数:34,代码来源:index.php
示例19: link_to_comment_delete
/**
* Ссылка на удаление комментария
*
* @param Comment $comment
*/
function link_to_comment_delete($comment, $title = null)
{
$user = sfContext::getInstance()->getUser();
if ($user->isAuthenticated() && $user->getGuardUser()->getId() == $comment->getUserId() && $comment->hasDeletable()) {
return jq_link_to_remote($title ? $title : 'Удалить', array('method' => 'post', 'url' => url_for('comment_delete', $comment), 'success' => 'jQuery("#comment-' . $comment->id . '").remove();', 'confirm' => 'Вы точно хотите удалить свой комментарий?'));
}
}
开发者ID:pycmam,项目名称:neskuchaik.ru,代码行数:12,代码来源:FrontendHelper.php
示例20: text2img
/**
* AlbaToolsHelper.
*
* @package symfony
* @subpackage helper
* @author Fernando Toledo <[email protected]>
* @version SVN: $Id: NumberHelper.php 7757 2008-03-07 10:55:22Z fabien $
*/
function text2img($texto)
{
if (is_null($texto)) {
return null;
}
return tag('img', array('alt' => $texto, 'src' => url_for('albaTools/text2img?texto=' . $texto)));
}
开发者ID:mediasadc,项目名称:alba,代码行数:15,代码来源:AlbaToolsHelper.php
注:本文中的url_for函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论