本文整理汇总了PHP中Newsletter::getGUID方法的典型用法代码示例。如果您正苦于以下问题:PHP Newsletter::getGUID方法的具体用法?PHP Newsletter::getGUID怎么用?PHP Newsletter::getGUID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newsletter
的用法示例。
在下文中一共展示了Newsletter::getGUID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newsletter_apply_url_postfix
/**
* Add the URL postfix to all url's in the newsletter content
*
* @param string $html_content the content of the newletter
* @param Newsletter $newsletter the source newsletter to use for some replacements in the postfix
*
* @return string
*/
function newsletter_apply_url_postfix($html_content, Newsletter $newsletter)
{
static $pattern;
if (!$newsletter instanceof Newsletter) {
return $html_content;
}
// get the postfix settings
$url_postfix_settings = newsletter_get_url_postfix();
if (empty($url_postfix_settings)) {
return $html_content;
}
// build the pattern once
if (!isset($pattern)) {
// convert site url to preg friendly version
$preg_site_url = elgg_get_site_url();
$preg_site_url = substr($preg_site_url, 0, -1);
$preg_site_url = str_replace("/", "\\/", $preg_site_url);
$preg_site_url = str_replace(".", "\\.", $preg_site_url);
$pattern = '/\\shref=([\'"]' . $preg_site_url . '[^\'"]*[\'"])/i';
}
// find all matches
$matches = [];
preg_match_all($pattern, $html_content, $matches);
if (empty($matches) || !isset($matches[1])) {
return $html_content;
}
// url postfix placeholder replacements
$replacements = ['{guid}' => $newsletter->getGUID()];
foreach ($url_postfix_settings as $name => $value) {
$url_postfix_settings[$name] = str_ireplace(array_keys($replacements), array_values($replacements), $value);
}
// go through all the matches
$urls = $matches[1];
$urls = array_unique($urls);
foreach ($urls as $url) {
// remove wrapping quotes from the url
$real_url = substr($url, 1, -1);
// add the postfix params
$new_url = elgg_http_add_url_query_elements($real_url, $url_postfix_settings);
// make the correct replacement string
$replacement = str_replace($real_url, $new_url, $url);
// replace the url in the content
$html_content = str_replace($url, $replacement, $html_content);
}
return $html_content;
}
示例2: forward
}
if (empty($entity)) {
register_error(elgg_echo('actionunauthorized'));
forward(REFERER);
}
$entity->title = $title;
$entity->description = $description;
$entity->access_id = $access_id;
if (!empty($subject)) {
$entity->subject = $subject;
} else {
unset($entity->subject);
}
if (newsletter_custom_from_enabled()) {
if (!empty($from)) {
$entity->from = $from;
} else {
unset($entity->from);
}
}
$entity->tags = $tags;
if ($entity->save()) {
elgg_clear_sticky_form('newsletter_edit');
if ($new_entity) {
$forward_url = 'newsletter/edit/' . $entity->getGUID() . '/template';
}
system_message(elgg_echo('newsletter:action:edit:success'));
} else {
register_error(elgg_echo('newsletter:action:edit:error:save'));
}
forward($forward_url);