本文整理汇总了PHP中HtmlHelper::url方法的典型用法代码示例。如果您正苦于以下问题:PHP HtmlHelper::url方法的具体用法?PHP HtmlHelper::url怎么用?PHP HtmlHelper::url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlHelper
的用法示例。
在下文中一共展示了HtmlHelper::url方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSave
public function beforeSave($options = array())
{
Configure::write('debug', 2);
App::uses("HtmlHelper", "View/Helper");
$html = new HtmlHelper(new View());
if ($this->data[$this->alias]['image']['name'] != "") {
$ext = pathinfo($this->data[$this->alias]['image']['name'], PATHINFO_EXTENSION);
$image_name = date('YmdHis') . rand(1, 999) . "." . $ext;
$destination = "files/recipe_images/" . $image_name;
if (move_uploaded_file($this->data[$this->alias]['image']['tmp_name'], $destination)) {
$bowl = $this->createBowl($destination);
$tmp = explode("/", $bowl);
$destination2 = "files/recipe_images/" . $tmp[1];
//unlink($destination);
rename($destination, $dt = "files/recipe_images/ori/" . $tmp[1]);
rename($bowl, $destination2);
}
$this->data[$this->alias]['image'] = $html->url("/" . $dt, true);
$this->data[$this->alias]['image_bowl'] = $html->url("/" . $destination2, true);
} else {
unset($this->data[$this->alias]['image']);
}
parent::beforeSave($options);
return true;
}
示例2: oauthLink
/**
* create OAuth Link
*
* @param $options
* loading: loading message
* login: login link text
* datasource: datasource name (default: twitter)
* authenticate: use authenticate link (default: false)
*/
public function oauthLink($options = array())
{
$default = array('loading' => __d('twitter_kit', 'Loading...', true), 'login' => __d('twitter_kit', 'Login Twitter', true), 'datasource' => 'twitter', 'authorize' => false, 'loginElementId' => 'twitter-login-wrap');
$options = am($default, $options);
$action = $options['authorize'] ? 'authorize_url' : 'authenticate_url';
$request_url = $this->Html->url(array('plugin' => 'twitter_kit', 'controller' => 'oauth', 'action' => $action . '/' . urlencode($options['datasource'])), true);
$this->Js->buffer("\n \$.getJSON('{$request_url}', {}, function(data){\n var link = \$('<a>').attr('href', data.url).html('{$options['login']}');\n \$('#{$options['loginElementId']} .loading').remove();\n \$('#{$options['loginElementId']}').append(link);\n });\n ");
$out = sprintf('<span id="%s"><span class="loading">%s</span></span>', $options['loginElementId'], $options['loading']);
return $this->output($out);
}
示例3: evaluate
function evaluate($affiliate, $params, $team, $strict, $text_reason, $complete, $absolute_url)
{
$events = array();
if ($text_reason) {
foreach ($this->events as $event) {
$events[] = $event['Event']['name'];
}
} else {
App::import('Helper', 'Html');
$html = new HtmlHelper();
foreach ($this->events as $event) {
$url = array('controller' => 'events', 'action' => 'view', 'event' => $event['Event']['id']);
if ($absolute_url) {
$url = $html->url($url, true);
} else {
$url['return'] = true;
}
$events[] = $html->link($event['Event']['name'], $url);
}
}
$this->reason = __('have previously registered for the', true) . ' ' . implode(' ' . __('or', true) . ' ', $events);
if (is_array($params) && array_key_exists('Registration', $params)) {
$registered = Set::extract('/Registration/Event/id', $params);
$prereqs = array_intersect($registered, $this->config);
if (!empty($prereqs)) {
return true;
}
}
return false;
}
示例4: autoComplete
/**
* Create a text field with Autocomplete.
*
* Creates an autocomplete field with the given ID and options.
*
* options['with'] defaults to "Form.Element.serialize('$field')",
* but can be any valid javascript expression defining the additional fields.
*
* @param string $field DOM ID of field to observe
* @param string $url URL for the autocomplete action
* @param array $options Ajax options
* @return string Ajax script
* @link http://book.cakephp.org/1.3/en/The-Manual/Core-Helpers/AJAX.html#autoComplete
*/
function autoComplete($field, $url = "", $options = array())
{
$var = '';
if (isset($options['var'])) {
$var = 'var ' . $options['var'] . ' = ';
unset($options['var']);
}
if (!isset($options['id'])) {
$options['id'] = Inflector::camelize(str_replace(".", "_", $field));
}
$divOptions = array('id' => $options['id'] . "_autoComplete", 'class' => isset($options['class']) ? $options['class'] : 'auto_complete');
if (isset($options['div_id'])) {
$divOptions['id'] = $options['div_id'];
unset($options['div_id']);
}
$htmlOptions = $this->__getHtmlOptions($options);
$htmlOptions['autocomplete'] = "off";
foreach ($this->autoCompleteOptions as $opt) {
unset($htmlOptions[$opt]);
}
if (isset($options['tokens'])) {
if (is_array($options['tokens'])) {
$options['tokens'] = $this->Javascript->object($options['tokens']);
} else {
$options['tokens'] = '"' . $options['tokens'] . '"';
}
}
$options = $this->_optionsToString($options, array('paramName', 'indicator'));
$options = $this->_buildOptions($options, $this->autoCompleteOptions);
$text = $this->Form->text($field, $htmlOptions);
$div = $this->Html->div(null, '', $divOptions);
$script = "{$var}new Ajax.Autocompleter('{$htmlOptions['id']}', '{$divOptions['id']}', '";
$script .= $this->Html->url($url) . "', {$options});";
return "{$text}\n{$div}\n" . $this->Javascript->codeBlock($script);
}
示例5: evaluate
function evaluate($affiliate, $params, $team, $strict, $text_reason, $complete, $absolute_url)
{
$matches = Set::extract("/Upload[type_id={$this->config[0]}]", $params['Upload']);
$unapproved = Set::extract('/Upload[approved=0]', $matches);
if (empty($unapproved)) {
if ($text_reason) {
$this->reason = sprintf(__('have uploaded the %s', true), $this->document);
} else {
App::import('Helper', 'Html');
$html = new HtmlHelper();
$url = array('controller' => 'people', 'action' => 'document_upload', 'type' => $this->config[0]);
if ($absolute_url) {
$url = $html->url($url, true);
} else {
$url['return'] = true;
}
$this->reason = $html->link(sprintf(__('have uploaded the %s', true), $this->document), $url);
}
} else {
$this->reason = sprintf(__('wait until your %s is approved', true), $this->document);
}
if (!$strict) {
return true;
}
if (is_array($params) && array_key_exists('Upload', $params)) {
$date = date('Y-m-d', strtotime($this->config[1]));
$matches = Set::extract("/Upload[type_id={$this->config[0]}][valid_from<={$date}][valid_until>={$date}]", $params['Upload']);
if (!empty($matches)) {
return true;
}
}
return false;
}
示例6: link
function link($title, $url = null, $htmlAttributes = array(), $confirmMessage = false, $escapeTitle = true)
{
// $parsedUrl = rtrim(parent::url($url), '/');
// $parsedUrl = rtrim($parsedUrl, '/index');
// $currentUrl = rtrim($this->here, '/');
// $currentUrl = rtrim($currentUrl, '/index');
// $linksToCurrentPage = (bool)($parsedUrl === $currentUrl);
//
// $containsCurrentPage = (bool)(strpos($currentUrl, $parsedUrl) === 0);
//
// if ($linksToCurrentPage or (!isset($htmlAttributes['strict']) and $containsCurrentPage)) {
// if (isset($htmlAttributes['class'])) {
// $htmlAttributes['class'] = $htmlAttributes['class'] + ' current';
// } else {
// $htmlAttributes['class'] = 'current';
// }
// }
//
// unset($htmlAttributes['strict']);
$parsedUrl = rtrim(parent::url($url), '/');
$parsedUrl = rtrim($parsedUrl, '/index');
$currentUrl = rtrim($this->here, '/');
$currentUrl = rtrim($currentUrl, '/index');
$linksToCurrentPage = (bool) ($parsedUrl === $currentUrl);
$isPartOfUrl = (bool) (strpos($currentUrl, $parsedUrl) === 0);
if ($linksToCurrentPage or !isset($htmlAttributes['strict']) and $isPartOfUrl) {
if (isset($htmlAttributes['class'])) {
$htmlAttributes['class'] += ' current';
} else {
$htmlAttributes['class'] = 'current';
}
}
return parent::link($title, $url, $htmlAttributes, $confirmMessage, $escapeTitle);
}
示例7: link
function link($title, $url = null, $htmlAttributes = array(), $confirmMessage = false, $escapeTitle = true)
{
$linkUrl = parent::url($url);
$currentUrl = $this->here;
// Remove paging from currentUrl
// @TODO if another named param goes after paging it do it's thing
$pieces = explode('/', $currentUrl);
$paging = end($pieces);
if (strpos($paging, 'page:') === 0) {
array_pop($pieces);
$currentUrl = join('/', $pieces);
}
if (isset($htmlAttributes['strict']) and $htmlAttributes['strict']) {
$htmlAttributes['currentOn'] = $url;
}
$currentOverride = false;
if (isset($htmlAttributes['currentOn']) && !is_null($htmlAttributes['currentOn'])) {
if ($currentUrl === parent::url($htmlAttributes['currentOn'])) {
$currentOverride = true;
}
}
if (strpos($currentUrl, $linkUrl) === 0 && (!isset($htmlAttributes['currentOn']) || is_null($htmlAttributes['currentOn'])) || $currentOverride === true) {
if (!isset($htmlAttributes['class'])) {
$htmlAttributes['class'] = '';
}
$classes = explode(' ', $htmlAttributes['class']);
if (!isset($classes['current'])) {
$classes[] = 'current';
}
$htmlAttributes['class'] = join(' ', $classes);
}
unset($htmlAttributes['currentOn']);
return parent::link($title, $url, $htmlAttributes, $confirmMessage, $escapeTitle);
}
示例8: url
public function url($url = null, $full = false)
{
if (!isset($url['language']) && isset($this->params['language'])) {
$url['language'] = $this->params['language'];
}
return parent::url($url, $full);
}
示例9: evaluate
function evaluate($affiliate, $params, $team, $strict, $text_reason, $complete, $absolute_url)
{
if ($text_reason) {
$this->reason = sprintf(__('have signed the %s waiver', true), $this->waiver);
} else {
App::import('Helper', 'Html');
$html = new HtmlHelper();
$url = array('controller' => 'waivers', 'action' => 'sign', 'waiver' => $this->config[0], 'date' => $this->date);
if ($absolute_url) {
$url = $html->url($url, true);
} else {
$url['return'] = true;
}
$this->reason = $html->link(sprintf(__('have signed the %s waiver', true), $this->waiver), $url);
}
$this->redirect = array('controller' => 'waivers', 'action' => 'sign', 'waiver' => $this->config[0], 'date' => $this->date);
if (!$strict) {
$this->invariant = true;
return true;
}
if (is_array($params) && array_key_exists('Waiver', $params)) {
$matches = array_intersect($this->config, Set::extract("/Waiver/WaiversPerson[valid_from<={$this->date}][valid_until>={$this->date}]/waiver_id", $params));
if (!empty($matches)) {
$this->invariant = true;
return true;
}
}
return false;
}
示例10: oauthLink
/**
* create OAuth Link
*
* @param $options
* loading: loading message
* login: login link text
* datasource: datasource name (default: twitter)
* authenticate: use authenticate link (default: false)
*/
public function oauthLink($options = array())
{
$default = array('login' => __d('twitter_kit', 'Login Twitter', true), 'datasource' => 'twitter', 'authorize' => false, 'loginElementId' => 'twitter-login-wrap');
$options = am($default, $options);
$oauthUrl = array('plugin' => 'twitter_kit', 'controller' => 'oauth', 'action' => 'connect', 'datasource' => $options['datasource']);
if ($options['authorize']) {
$oauthUrl['authorize'] = true;
}
$oauthUrl = $this->Html->url($oauthUrl);
$out = sprintf('<span id="%s"><a href="%s">%s</a></span>', $options['loginElementId'], $oauthUrl, $options['login']);
return $this->output($out);
}
示例11: add
function add()
{
//$this->view = "View"; //qdmailとdebug kitを併用するとエラー起きるのでその対策、本番環境では当然いらない
//Configure::write('debug',0);
$this->layout = 'ajax';
// ログインしていない、または自分のuser_idをフォローしようとしていたらjsonに何もセットせず、結果的にjasonでnullのみを返す
if (($id = $this->Auth->user('id')) === null || $this->Auth->user('id') === $this->params['follow_id']) {
//$this->cakeError('error404');
//$this->redirect($this->Auth->logout());
} else {
$res['login'] = TRUE;
//ちゃんとloginしている場合はjsonファイルに設定、というかここがtrueだと処理成功とjsonで判断される
}
//var_dump($this->Auth->user('id'));
$data['Follow'] = array('user_id' => $id, 'follow_user_id' => $this->params['follow_id']);
//var_dump($data);
//$this->data = $data;
$this->Follow->create();
if ($this->Follow->save($data)) {
//$this->Session->setFlash(__('The Follow has been saved', true));
//メールの送信準備
$this->User->unbindModel(array('hasMany' => array('Task')), false);
//twitter投稿用のuser情報だけ欲しいのでunbind
$user = $this->User->findAllById($this->params['follow_id']);
//pr($user);
if ($user[0]['User']['email'] && $user[0]['User']['follow_mail_enabled']) {
//followした人の名前情報
$following_name = $this->Auth->user('realname') ? $this->Auth->user('realname') : $this->Auth->user('username');
//followした人の詳しい名前情報
$following_2name = $this->Auth->user('realname') ? "{$this->Auth->user('realname')} ({$this->Auth->user('username')})" : $this->Auth->user('username');
//followされた人の名前情報
//$follower_name = $user[0]['User']['realname'] ? $user[0]['User']['realname'] : $user[0]['User']['username'] ;
//followされた人の詳しい名前情報
$follower_2name = $user[0]['User']['realname'] ? "{$user[0]['User']['realname']} ({$user[0]['User']['username']})" : $user[0]['User']['username'];
//ドメインを含んだ絶対URLの取得
App::import('Helper', 'Html');
$html = new HtmlHelper();
$base_url = $html->url(array('controller' => $this->Auth->user('username')), true);
//$res = array($user,$follow_username,$follow_realname,$following_username,$user[0]['User']['email'],);
//メールの送信
$this->QdmailWrap->address = $user[0]['User']['email'];
$this->QdmailWrap->subject = "{$following_name}があなたをフォローし始めました";
$this->QdmailWrap->message = "こんにちは、{$follower_2name}さん。\n\n{$following_2name} があなたをフォローし始めました。\n\n{$following_name}さんのプロフィールはこちらまで:\n {$base_url}\n\n{$following_name}をフォローするために、「フォロー」のボタンをクリックしてください\nりすったー。\n \n--\nリスッターから「follow notification」のメールを受信したくない場合は、今すぐ解除できます。リスッターからのメール選択について再度登録や変更をしたい場合は、自分のアカウントから「設定」へ行きお知らせ機能を操作してください。";
if ($this->QdmailWrap->post()) {
//メール送信に成功したら
}
}
}
//$res['test']='testdayo';
$this->set('result', json_encode($res));
$this->render(null, null, VIEWS . DS . 'ajax.ctp');
// Ajax 用共通 view
}
示例12: url
public function url($url = null, $full = false)
{
$siteUrl = !empty($this->_View->viewVars["siteurl"]) ? $this->_View->viewVars["siteurl"] : '';
if (is_array($url) && !empty($siteUrl)) {
if (!empty($url['controller']) && $url['controller'] == 'party') {
$url['siteurl'] = $siteUrl;
} else {
$url['plugin'] = $siteUrl;
}
}
return parent::url($url, $full);
}
示例13: beforeSave
public function beforeSave($options = array())
{
App::uses("HtmlHelper", "View/Helper");
$html = new HtmlHelper(new View());
if ($this->data[$this->alias]['name'] != "") {
$ext = pathinfo($this->data[$this->alias]['name'], PATHINFO_EXTENSION);
$image_name = date('YmdHis') . rand(1, 999) . "." . $ext;
$this->data[$this->alias]['path'] = $html->url("/files/sentdesigns/" . $image_name, true);
$destination = "files/sentdesigns/" . $image_name;
move_uploaded_file($this->data[$this->alias]['tmp_name'], $destination);
}
parent::beforeSave($options);
}
示例14: beforeSave
public function beforeSave($options = array())
{
App::uses("HtmlHelper", "View/Helper");
$html = new HtmlHelper(new View());
if (!empty($this->data[$this->alias]['file']['name'])) {
$this->data[$this->alias]['type'] = $this->data[$this->alias]['file']['type'];
$this->data[$this->alias]['movefile'] = $this->data[$this->alias]['file'];
$ext = pathinfo($this->data[$this->alias]['file']['name'], PATHINFO_EXTENSION);
$image_name = date('YmdHis') . rand(1, 999) . "." . $ext;
$this->data[$this->alias]['file'] = $html->url("/files/splash/" . $image_name, true);
$this->data[$this->alias]['movefile']['name'] = $image_name;
}
parent::beforeSave($options);
return true;
}
示例15: autoComplete
/**
* Create a text field with Autocomplete.
*
* Creates an autocomplete field with the given ID and options.
* needs include jquery.autocomplete.min.js file
*
* @param string $field DOM ID of field to observe
* @param string $url URL for the autocomplete action
* @param array $options Ajax options
* @return string Ajax script
* check out http://docs.jquery.com/Plugins/Autocomplete
*/
function autoComplete($field, $url = "", $options = array()) {
$var = '';
if (isset($options['var'])) {
$var = 'var ' . $options['var'] . ' = ';
unset($options['var']);
}
if (!isset($options['id'])) {
$options['id'] = Inflector::camelize(str_replace(".", "_", $field));
}
$htmlOptions = $this->__getHtmlOptions($options);
$htmlOptions['autocomplete'] = "off";
foreach ($this->autoCompleteOptions as $opt) {
unset($htmlOptions[$opt]);
}
$options = $this->_optionsToString($options, array('multipleSeparator'));
$callbacks = array('formatItem', 'formatMatch', 'formatResult', 'highlight');
foreach ($callbacks as $callback) {
if (isset($options[$callback])) {
$name = $callback;
$code = $options[$callback];
switch ($name){
case 'formatResult':
$options[$name] = "function(data, i, max) {" . $code . "}";
break;
case 'highlight':
$options[$name] = "function(data, search) {" . $code . "}";
break;
default:
$options[$name] = "function(row, i, max, term) {" . $code . "}";
break;
}
}
}
$options = $this->_buildOptions($options, $this->autoCompleteOptions);
$text = $this->Form->text($field, $htmlOptions);
$script = "{$var} $('#{$htmlOptions['id']}').autocomplete('";
$script .= $this->Html->url($url) . "', {$options});";
return "{$text}\n" . $this->Javascript->codeBlock($script);
}