当前位置: 首页>>代码示例>>PHP>>正文


PHP UrlHelper::mail_to方法代码示例

本文整理汇总了PHP中UrlHelper::mail_to方法的典型用法代码示例。如果您正苦于以下问题:PHP UrlHelper::mail_to方法的具体用法?PHP UrlHelper::mail_to怎么用?PHP UrlHelper::mail_to使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UrlHelper的用法示例。


在下文中一共展示了UrlHelper::mail_to方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: MockAkActionController

 function test_for_UrlHelper()
 {
     $Controller =& new MockAkActionController($this);
     $Controller->setReturnValue('urlFor', '/url/for/test');
     //$Controller->setReturnValue('_getCompleteRequestUri','/url/for/test');
     $url = new UrlHelper();
     $url->setController($Controller);
     $this->assertReference($Controller, $url->_controller);
     $input = array('disabled' => 1, 'checked' => false, 'selected' => '');
     $expected = array('disabled' => 'disabled');
     $this->assertEqual($url->_convert_boolean_attributes($input, array('disabled', 'checked', 'selected')), $expected);
     $input = array('disabled' => true, 'id' => 'hithere');
     $expected = array('disabled' => 'disabled', 'id' => 'hithere');
     $this->assertEqual($url->_convert_boolean_attributes($input, 'disabled'), $expected);
     $this->assertEqual($url->url_for(array('action' => 'create')), '/url/for/test');
     $this->assertEqual($url->button_to('Edit'), '<form method="post" action="/url/for/test" class="button-to"><div>' . '<input type="submit" value="Edit" /></div></form>');
     $this->assertEqual($url->link_to('Delete this page', array('action' => 'destroy', 'id' => 3), array('confirm' => 'Are you sure?')), '<a href="/url/for/test" onclick="return confirm(\'Are you sure?\');">Delete this page</a>');
     $this->assertEqual($url->link_to('Help', array('action' => 'help'), array('popup' => true)), '<a href="/url/for/test" onclick="window.open(this.href);return false;">Help</a>');
     $this->assertEqual($url->link_to('Help', array('action' => 'help'), array('popup' => true, 'confirm' => 'Are you sure?')), '<a href="/url/for/test" onclick="if (confirm(\'Are you sure?\')) { window.open(this.href); };return false;">Help</a>');
     $this->assertEqual($url->link_to('Help', array('action' => 'help'), array('post' => true)), '<a href="/url/for/test" onclick="var f = document.createElement(\'form\'); document.body.appendChild(f); f.method = \'POST\'; f.action = this.href; f.submit();return false;">Help</a>');
     $this->assertEqual($url->link_to('Destroy account', array('action' => 'destroy'), array('confirm' => 'Are you sure?'), array('post' => true)), '<a href="/url/for/test" onclick="return confirm(\'Are you sure?\');">Destroy account</a>');
     $this->assertEqual($url->link_to_unless(true, 'Destroy account', array('action' => 'destroy'), array('confirm' => 'Are you sure?'), array('post' => true)), '');
     $this->assertEqual($url->link_to_unless(false, 'Destroy account', array('action' => 'destroy'), array('confirm' => 'Are you sure?'), array('post' => true)), '<a href="/url/for/test" onclick="return confirm(\'Are you sure?\');">Destroy account</a>');
     $this->assertEqual($url->_popup_javascript_function('A'), 'window.open(this.href);');
     $this->assertEqual($url->_popup_javascript_function(array('A', 'B', 'C')), 'window.open(this.href,\'A\',\'C\');');
     $this->assertEqual($url->_confirm_javascript_function('Are you sure?'), 'confirm(\'Are you sure?\')');
     $this->assertEqual($url->mail_to('me@domain.com', 'My email', array('cc' => 'ccaddress@domain.com', 'bcc' => 'bccaddress@domain.com', 'subject' => 'This is an example email', 'body' => 'This is the body of the message.')), '<a href="mailto:me@domain.com?cc=ccaddress%40domain.com&amp;bcc=bccaddress%40domain.com&amp;body=This%20is%20the%20body%20of%20the%20message.&amp;subject=This%20is%20an%20example%20email">My email</a>');
     $this->assertEqual($url->mail_to('me@domain.com', 'My email', array('encode' => 'javascript')), '<script type="text/javascript">eval(unescape(\'%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%22%3e%4d%79%20%65%6d%61%69%6c%3c%2f%61%3e%27%29%3b\'))</script>');
     $this->assertEqual($url->mail_to('me@domain.com', 'My email', array('encode' => 'hex')), '<a href="mailto:%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d">My email</a>');
 }
开发者ID:joeymetal,项目名称:v1,代码行数:30,代码来源:url_helper.php

示例2: auto_link_email_addresses

 /**
  * Turns all email addresses into clickable links.  You can provide an options
  * array in order to generate links using UrlHelper::mail_to()
  * 
  * Example:
  *   $text_helper->auto_link_email_addresses($post->body);
  */
 function auto_link_email_addresses($text, $email_options = array())
 {
     if (empty($email_options)) {
         return preg_replace('/([\\w\\.!#\\$%\\-+.]+@[A-Za-z0-9\\-]+(\\.[A-Za-z0-9\\-]+)+)/', "<a href='mailto:\$1'>\$1</a>", $text);
     } elseif (preg_match_all('/([\\w\\.!#\\$%\\-+.]+@[A-Za-z0-9\\-]+(\\.[A-Za-z0-9\\-]+)+)/', $text, $match)) {
         $emails = $match[0];
         foreach ($emails as $email) {
             $encoded_emails[] = UrlHelper::mail_to($email, null, $email_options);
         }
         $text = str_replace($emails, $encoded_emails, $text);
     }
     return $text;
 }
开发者ID:joeymetal,项目名称:v1,代码行数:20,代码来源:text_helper.php


注:本文中的UrlHelper::mail_to方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。