本文整理汇总了PHP中JStringPunycode类的典型用法代码示例。如果您正苦于以下问题:PHP JStringPunycode类的具体用法?PHP JStringPunycode怎么用?PHP JStringPunycode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JStringPunycode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _sendEmail
private function _sendEmail($data)
{
$app = JFactory::getApplication();
// Sends the email to the admin
$admin = JFactory::getUser(537);
$recipient = $admin->email;
// Sets the sender info from Global Configuration
$config = JFactory::getConfig();
$sender = array($config->get('mailfrom'), $config->get('fromname'));
//Subject variables
$sitename = $app->get('sitename');
$subject = 'Feedback';
//Form data
$name = $data['name'];
$email = JStringPunycode::emailToPunycode($data['email']);
$addfeature = $data['add_feature'];
$easytouse = $data['easy_to_use'];
$otherfeedback = $data['other_feedback'];
// Email body
$body = 'From: ' . $name . ' <' . $email . '>' . "\r\n\r\nFeature they would like added to the site:\r\n" . stripslashes($addfeature) . "\r\n\r\nHow easy is the site to use? " . $easytouse . "\r\n\r\nOther feedback:\r\n" . $otherfeedback;
//Joomla Mailer
$mail = JFactory::getMailer();
$mail->addRecipient($recipient);
$mail->addReplyTo($email, $name);
$mail->setSender($sender);
$mail->setSubject($sitename . ' ' . $subject);
$mail->setBody($body);
$sent = $mail->Send();
return $sent;
}
示例2: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 3.1.2 (CMS)
*/
protected function getInput()
{
// Translate placeholder text
$hint = $this->translateHint ? JText::_($this->hint) : $this->hint;
// Initialize some field attributes.
$size = !empty($this->size) ? ' size="' . $this->size . '"' : '';
$maxLength = !empty($this->maxLength) ? ' maxlength="' . $this->maxLength . '"' : '';
$class = !empty($this->class) ? ' class="' . $this->class . '"' : '';
$readonly = $this->readonly ? ' readonly' : '';
$disabled = $this->disabled ? ' disabled' : '';
$required = $this->required ? ' required aria-required="true"' : '';
$hint = $hint ? ' placeholder="' . $hint . '"' : '';
$autocomplete = !$this->autocomplete ? ' autocomplete="off"' : ' autocomplete="' . $this->autocomplete . '"';
$autocomplete = $autocomplete == ' autocomplete="on"' ? '' : $autocomplete;
$autofocus = $this->autofocus ? ' autofocus' : '';
$spellcheck = $this->spellcheck ? '' : ' spellcheck="false"';
// Initialize JavaScript field attributes.
$onchange = !empty($this->onchange) ? ' onchange="' . $this->onchange . '"' : '';
// Including fallback code for HTML5 non supported browsers.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js', false, true);
// Uris should never include <>" see see http://www.ietf.org/rfc/rfc1738.txt.
$this->value = str_replace(array('<', '>', '"'), '', $this->value);
return '<input type="url" name="' . $this->name . '"' . $class . ' id="' . $this->id . '" value="' . JStringPunycode::urlToUTF8($this->value, ENT_COMPAT, 'UTF-8') . '"' . $size . $disabled . $readonly . $hint . $autocomplete . $autofocus . $spellcheck . $onchange . $maxLength . $required . ' />';
}
示例3: stdClass
/**
* @since 1.5
*/
function &getData()
{
$user = JFactory::getUser();
$app = JFactory::getApplication();
$data = new stdClass();
$input = $app->input;
$method = $input->getMethod();
$data->link = urldecode($input->{$method}->get('link', '', 'BASE64'));
if ($data->link == '') {
JError::raiseError(403, JText::_('COM_MAILTO_LINK_IS_MISSING'));
$false = false;
return $false;
}
// Load with previous data, if it exists
$mailto = $app->input->post->getString('mailto', '');
$sender = $app->input->post->getString('sender', '');
$from = $app->input->post->getString('from', '');
$subject = $app->input->post->getString('subject', '');
if ($user->get('id') > 0) {
$data->sender = $user->get('name');
$data->from = $user->get('email');
} else {
$data->sender = $sender;
$data->from = JStringPunycode::emailToPunycode($from);
}
$data->subject = $subject;
$data->mailto = JStringPunycode::emailToPunycode($mailto);
return $data;
}
示例4: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 3.1.2 (CMS)
*/
protected function getInput()
{
// Translate placeholder text
$hint = $this->translateHint ? JText::_($this->hint) : $this->hint;
// Initialize some field attributes.
$size = !empty($this->size) ? ' size="' . $this->size . '"' : '';
$maxLength = !empty($this->maxLength) ? ' maxlength="' . $this->maxLength . '"' : '';
$class = !empty($this->class) ? ' class="' . $this->class . '"' : '';
$readonly = $this->readonly ? ' readonly' : '';
$disabled = $this->disabled ? ' disabled' : '';
$required = $this->required ? ' required aria-required="true"' : '';
$hint = strlen($hint) ? ' placeholder="' . $hint . '"' : '';
$autocomplete = !$this->autocomplete ? ' autocomplete="off"' : ' autocomplete="' . $this->autocomplete . '"';
$autocomplete = $autocomplete == ' autocomplete="on"' ? '' : $autocomplete;
$autofocus = $this->autofocus ? ' autofocus' : '';
$spellcheck = $this->spellcheck ? '' : ' spellcheck="false"';
// Note that the input type "url" is suitable only for external URLs, so if internal URLs are allowed
// we have to use the input type "text" instead.
$inputType = $this->element['relative'] ? 'type="text"' : 'type="url"';
// Initialize JavaScript field attributes.
$onchange = !empty($this->onchange) ? ' onchange="' . $this->onchange . '"' : '';
// Including fallback code for HTML5 non supported browsers.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js', false, true);
return '<input ' . $inputType . ' name="' . $this->name . '"' . $class . ' id="' . $this->id . '" value="' . htmlspecialchars(JStringPunycode::urlToUTF8($this->value), ENT_COMPAT, 'UTF-8') . '"' . $size . $disabled . $readonly . $hint . $autocomplete . $autofocus . $spellcheck . $onchange . $maxLength . $required . ' />';
}
示例5: getInput
/**
* Method to get the field input markup for e-mail addresses.
*
* @return string The field input markup.
*
* @since 11.1
*/
protected function getInput()
{
// Translate placeholder text
$hint = $this->translateHint ? JText::_($this->hint) : $this->hint;
// Initialize some field attributes.
$size = !empty($this->size) ? ' size="' . $this->size . '"' : '';
$maxLength = !empty($this->maxLength) ? ' maxlength="' . $this->maxLength . '"' : '';
$class = !empty($this->class) ? ' class="validate-email ' . $this->class . '"' : ' class="validate-email"';
$readonly = $this->readonly ? ' readonly' : '';
$disabled = $this->disabled ? ' disabled' : '';
$required = $this->required ? ' required aria-required="true"' : '';
$hint = $hint ? ' placeholder="' . $hint . '"' : '';
$autocomplete = !$this->autocomplete ? ' autocomplete="off"' : ' autocomplete="' . $this->autocomplete . '"';
$autocomplete = $autocomplete == ' autocomplete="on"' ? '' : $autocomplete;
$autofocus = $this->autofocus ? ' autofocus' : '';
$multiple = $this->multiple ? ' multiple' : '';
$spellcheck = $this->spellcheck ? '' : ' spellcheck="false"';
$tabindex = (int) $this->element['tabindex'] ? ' tabindex="' . (int) $this->element['tabindex'] . '"' : '';
$title = strpos($this->class, 'hasTooltip') === false ? '' : ' title="' . (string) $this->title . '"';
// Initialize JavaScript field attributes.
$onchange = $this->onchange ? ' onchange="' . $this->onchange . '"' : '';
// Including fallback code for HTML5 non supported browsers.
JHtml::_('jquery.framework');
JHtml::_('script', 'system/html5fallback.js', false, true);
return '<input type="email" name="' . $this->name . '"' . $class . ' id="' . $this->id . '" value="' . htmlspecialchars(JStringPunycode::emailToUTF8($this->value, ENT_COMPAT, 'UTF-8')) . '"' . $spellcheck . $size . $disabled . $readonly . $onchange . $autocomplete . $multiple . $maxLength . $hint . $required . $autofocus . $tabindex . $title . ' />';
}
示例6: test
/**
* Method to test the email address and optionally check for uniqueness.
*
* @param SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
* @param JRegistry $input An optional JRegistry object with the entire data set to validate against the entire form.
* @param JForm $form The form object for which the field is being tested.
*
* @return boolean True if the value is valid, false otherwise.
*
* @since 11.1
*/
public function test(SimpleXMLElement $element, $value, $group = null, JRegistry $input = null, JForm $form = null)
{
// If the field is empty and not required, the field is valid.
$required = (string) $element['required'] == 'true' || (string) $element['required'] == 'required';
if (!$required && empty($value)) {
return true;
}
// If the tld attribute is present, change the regular expression to require at least 2 characters for it.
$tld = (string) $element['tld'] == 'tld' || (string) $element['tld'] == 'required';
if ($tld) {
$this->regex = '^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]{2,})$';
}
// Determine if the multiple attribute is present
$multiple = (string) $element['multiple'] == 'true' || (string) $element['multiple'] == 'multiple';
if ($multiple) {
$values = explode(',', $value);
}
if (!$multiple) {
// Handle idn e-mail addresses by converting to punycode.
$value = JStringPunycode::emailToPunycode($value);
// Test the value against the regular expression.
if (!parent::test($element, $value, $group, $input, $form)) {
return false;
}
} else {
foreach ($values as $value) {
// Handle idn e-mail addresses by converting to punycode.
$value = JStringPunycode::emailToPunycode($value);
// Test the value against the regular expression.
if (!parent::test($element, $value, $group, $input, $form)) {
return false;
}
}
}
// Check if we should test for uniqueness. This only can be used if multiple is not true
$unique = (string) $element['unique'] == 'true' || (string) $element['unique'] == 'unique';
if ($unique && !$multiple) {
// Get the database object and a new query object.
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Build the query.
$query->select('COUNT(*)')->from('#__users')->where('email = ' . $db->quote($value));
// Get the extra field check attribute.
$userId = $form instanceof JForm ? $form->getValue('id') : '';
$query->where($db->quoteName('id') . ' <> ' . (int) $userId);
// Set and query the database.
$db->setQuery($query);
$duplicate = (bool) $db->loadResult();
if ($duplicate) {
return false;
}
}
return true;
}
示例7: getInput
/**
* Method to get the field input markup for e-mail addresses.
*
* @return string The field input markup.
*
* @since 11.1
*/
protected function getInput()
{
// Initialize some field attributes.
$size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
$maxLength = $this->element['maxlength'] ? ' maxlength="' . (int) $this->element['maxlength'] . '"' : '';
$class = $this->element['class'] ? ' ' . (string) $this->element['class'] : '';
$readonly = (string) $this->element['readonly'] == 'true' ? ' readonly="readonly"' : '';
$disabled = (string) $this->element['disabled'] == 'true' ? ' disabled="disabled"' : '';
$required = $this->required ? ' required="required" aria-required="true"' : '';
// Initialize JavaScript field attributes.
$onchange = $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
return '<input type="text" name="' . $this->name . '" class="' . $class . '" id="' . $this->id . '" value="' . JStringPunycode::emailToUTF8($this->value, ENT_COMPAT, 'UTF-8') . '"' . $size . $disabled . $readonly . $onchange . $maxLength . $required . '/>';
}
示例8: cloak
/**
* Simple JavaScript email cloaker
*
* By default replaces an email with a mailto link with email cloaked
*
* @param string $mail The -mail address to cloak.
* @param boolean $mailto True if text and mailing address differ
* @param string $text Text for the link
* @param boolean $email True if text is an e-mail address
*
* @return string The cloaked email.
*
* @since 1.5
*/
public static function cloak($mail, $mailto = true, $text = '', $email = true)
{
// Handle IDN addresses: punycode for href but utf-8 for text displayed.
if ($mailto && (empty($text) || $email)) {
// Use dedicated $text whereas $mail is used as href and must be punycoded.
$text = JStringPunycode::emailToUTF8($text ? $text : $mail);
} elseif (!$mailto) {
// In that case we don't use link - so convert $mail back to utf-8.
$mail = JStringPunycode::emailToUTF8($mail);
}
// Convert mail
$mail = static::convertEncoding($mail);
// Split email by @ symbol
$mail = explode('@', $mail);
$mail_parts = explode('.', $mail[1]);
// Random number
$rand = rand(1, 100000);
$replacement = '<span id="cloak' . $rand . '">' . JText::_('JLIB_HTML_CLOAKING') . '</span>' . "<script type='text/javascript'>";
$replacement .= "\n //<!--";
$replacement .= "\n document.getElementById('cloak{$rand}').innerHTML = '';";
$replacement .= "\n var prefix = 'ma' + 'il' + 'to';";
$replacement .= "\n var path = 'hr' + 'ef' + '=';";
$replacement .= "\n var addy" . $rand . " = '" . @$mail[0] . "' + '@';";
$replacement .= "\n addy" . $rand . " = addy" . $rand . " + '" . implode("' + '.' + '", $mail_parts) . "';";
if ($mailto) {
// Special handling when mail text is different from mail address
if ($text) {
// Convert text - here is the right place
$text = static::convertEncoding($text);
if ($email) {
// Split email by @ symbol
$text = explode('@', $text);
$text_parts = explode('.', $text[1]);
$replacement .= "\n var addy_text" . $rand . " = '" . @$text[0] . "' + '@' + '" . implode("' + '.' + '", @$text_parts) . "';";
} else {
$replacement .= "\n var addy_text" . $rand . " = '" . $text . "';";
}
$replacement .= "\n document.getElementById('cloak{$rand}').innerHTML += '<a ' + path + '\\'' + prefix + ':' + addy" . $rand . " + '\\'>'+addy_text" . $rand . "+'<\\/a>';";
} else {
$replacement .= "\n document.getElementById('cloak{$rand}').innerHTML += '<a ' + path + '\\'' + prefix + ':' + addy" . $rand . " + '\\'>' +addy" . $rand . "+'<\\/a>';";
}
} else {
$replacement .= "\n document.getElementById('cloak{$rand}').innerHTML += addy" . $rand . ";";
}
$replacement .= "\n //-->";
$replacement .= "\n </script>";
return $replacement;
}
示例9: store
/**
* Stores a contact
*
* @param boolean True to update fields even if they are null.
*
* @return boolean True on success, false on failure.
*
* @since 1.6
*/
public function store($updateNulls = false)
{
// Transform the params field
if (is_array($this->params)) {
$registry = new JRegistry();
$registry->loadArray($this->params);
$this->params = (string) $registry;
}
$date = JFactory::getDate();
$user = JFactory::getUser();
if ($this->id) {
// Existing item
$this->modified = $date->toSql();
$this->modified_by = $user->get('id');
} else {
// New contact. A contact created and created_by field can be set by the user,
// so we don't touch either of these if they are set.
if (!(int) $this->created) {
$this->created = $date->toSql();
}
if (empty($this->created_by)) {
$this->created_by = $user->get('id');
}
}
// Set publish_up to null date if not set
if (!$this->publish_up) {
$this->publish_up = $this->_db->getNullDate();
}
// Set publish_down to null date if not set
if (!$this->publish_down) {
$this->publish_down = $this->_db->getNullDate();
}
// Set xreference to empty string if not set
if (!$this->xreference) {
$this->xreference = '';
}
// Store utf8 email as punycode
$this->email_to = JStringPunycode::emailToPunycode($this->email_to);
// Convert IDN urls to punycode
$this->webpage = JStringPunycode::urlToPunycode($this->webpage);
// Verify that the alias is unique
$table = JTable::getInstance('Contact', 'ContactTable');
if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0)) {
$this->setError(JText::_('COM_CONTACT_ERROR_UNIQUE_ALIAS'));
return false;
}
return parent::store($updateNulls);
}
示例10: comment
/**
* Method to save the form data.
*
* @param array $temp The form data.
*
* @return boolean True on success, false on failure.
*
*/
public function comment($temp)
{
$data = (array) $this->getData();
// Merge in the comment data.
foreach ($temp as $k => $v) {
$data[$k] = $v;
}
$data['state'] = 1;
$data['content_id'] = (int) $data['content_id'];
$data['visitor_email'] = JStringPunycode::emailToPunycode($data['visitor_email']);
$data['visitor_comments'] = stripcslashes(nl2br(htmlentities($data['visitor_comments'])));
$data['created'] = JFactory::getDate()->toSql();
// Get a level row instance.
$table = $this->getTable();
if ($table->save($data) === false) {
return false;
}
return true;
}
示例11: store
/**
* Overload the store method for the Weblinks table.
*
* @param boolean Toggle whether null values should be updated.
*
* @return boolean True on success, false on failure.
*
* @since 1.6
*/
public function store($updateNulls = false)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
$this->modified = $date->toSql();
if ($this->id) {
// Existing item
$this->modified_by = $user->id;
} else {
// New weblink. A weblink created and created_by field can be set by the user,
// so we don't touch either of these if they are set.
if (!(int) $this->created) {
$this->created = $date->toSql();
}
if (empty($this->created_by)) {
$this->created_by = $user->id;
}
}
// Set publish_up to null date if not set
if (!$this->publish_up) {
$this->publish_up = $this->getDbo()->getNullDate();
}
// Set publish_down to null date if not set
if (!$this->publish_down) {
$this->publish_down = $this->getDbo()->getNullDate();
}
// Verify that the alias is unique
$table = JTable::getInstance('Weblink', 'WeblinksTable');
if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0)) {
$this->setError(JText::_('COM_WEBLINKS_ERROR_UNIQUE_ALIAS'));
return false;
}
// Convert IDN urls to punycode
$this->url = JStringPunycode::urlToPunycode($this->url);
return parent::store($updateNulls);
}
示例12:
<?php
if ($this->items[$i]->published == 0) {
?>
<span class="label label-warning"><?php
echo JText::_('JUNPUBLISHED');
?>
</span>
<?php
}
?>
<br />
<?php
if ($this->params->get('show_link')) {
?>
<?php
$link = JStringPunycode::urlToUTF8($item->link);
?>
<span class="list pull-left">
<a href="<?php
echo $item->link;
?>
"><?php
echo $link;
?>
</a>
</span>
<br/>
<?php
}
?>
</li>
示例13: save
/**
* Method to save the form data.
*
* @param array The form data.
*
* @return boolean True on success.
* @since 3.0
*/
public function save($data)
{
$app = JFactory::getApplication();
// Alter the title for save as copy
if ($app->input->get('task') == 'save2copy') {
list($name, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['name']);
$data['name'] = $name;
$data['alias'] = $alias;
$data['published'] = 0;
}
$links = array('linka', 'linkb', 'linkc', 'linkd', 'linke');
foreach ($links as $link) {
if ($data['params'][$link]) {
$data['params'][$link] = JStringPunycode::urlToPunycode($data['params'][$link]);
}
}
if (parent::save($data)) {
$assoc = JLanguageAssociations::isEnabled();
if ($assoc) {
$id = (int) $this->getState($this->getName() . '.id');
$item = $this->getItem($id);
// Adding self to the association
$associations = $data['associations'];
foreach ($associations as $tag => $id) {
if (empty($id)) {
unset($associations[$tag]);
}
}
// Detecting all item menus
$all_language = $item->language == '*';
if ($all_language && !empty($associations)) {
JError::raiseNotice(403, JText::_('COM_CONTACT_ERROR_ALL_LANGUAGE_ASSOCIATED'));
}
$associations[$item->language] = $item->id;
// Deleting old association for these items
$db = JFactory::getDbo();
$query = $db->getQuery(true)->delete('#__associations')->where('context=' . $db->quote('com_contact.item'))->where('id IN (' . implode(',', $associations) . ')');
$db->setQuery($query);
$db->execute();
if ($error = $db->getErrorMsg()) {
$this->setError($error);
return false;
}
if (!$all_language && count($associations)) {
// Adding new association for these items
$key = md5(json_encode($associations));
$query->clear()->insert('#__associations');
foreach ($associations as $id) {
$query->values($id . ',' . $db->quote('com_contact.item') . ',' . $db->quote($key));
}
$db->setQuery($query);
$db->execute();
if ($error = $db->getErrorMsg()) {
$this->setError($error);
return false;
}
}
}
return true;
}
return false;
}
示例14: foreach
$fields = $this->item->profile->getFieldset('profile');
?>
<div class="contact-profile" id="users-profile-custom">
<dl class="dl-horizontal">
<?php
foreach ($fields as $profile) {
if ($profile->value) {
echo '<dt>' . $profile->label . '</dt>';
$profile->text = htmlspecialchars($profile->value, ENT_COMPAT, 'UTF-8');
switch ($profile->id) {
case 'profile_website':
$v_http = substr($profile->value, 0, 4);
if ($v_http === 'http') {
echo '<dd><a href="' . $profile->text . '">' . JStringPunycode::urlToUTF8($profile->text) . '</a></dd>';
} else {
echo '<dd><a href="http://' . $profile->text . '">' . JStringPunycode::urlToUTF8($profile->text) . '</a></dd>';
}
break;
case 'profile_dob':
echo '<dd>' . JHtml::_('date', $profile->text, JText::_('DATE_FORMAT_LC4'), false) . '</dd>';
break;
default:
echo '<dd>' . $profile->text . '</dd>';
break;
}
}
}
?>
</dl>
</div>
<?php
示例15: emailToPunycode
/**
* Function to punyencode utf8 mail when saving content
*
* @param string $text The strings to encode
*
* @return string The punyencoded mail
*
* @since 3.5
*/
public function emailToPunycode($text)
{
$pattern = '/(("mailto:)+[\\w\\.\\-\\+]+\\@[^"?]+\\.+[^."?]+("|\\?))/';
if (preg_match_all($pattern, $text, $matches)) {
foreach ($matches[0] as $match) {
$match = (string) str_replace(array('?', '"'), '', $match);
$text = (string) str_replace($match, JStringPunycode::emailToPunycode($match), $text);
}
}
return $text;
}