本文整理汇总了PHP中ArtefactType::update_artefact_references方法的典型用法代码示例。如果您正苦于以下问题:PHP ArtefactType::update_artefact_references方法的具体用法?PHP ArtefactType::update_artefact_references怎么用?PHP ArtefactType::update_artefact_references使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArtefactType
的用法示例。
在下文中一共展示了ArtefactType::update_artefact_references方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_artefact_references
public function update_artefact_references(&$view, &$template, &$artefactcopies, $oldid)
{
parent::update_artefact_references($view, $template, $artefactcopies, $oldid);
// 1. Attach copies of the files that were attached to the old note.
if (isset($artefactcopies[$oldid]->oldattachments)) {
foreach ($artefactcopies[$oldid]->oldattachments as $a) {
if (isset($artefactcopies[$a])) {
$this->attach($artefactcopies[$a]->newid);
}
}
}
// 2. Update embedded images in the note and db
$regexp = array();
$replacetext = array();
if (!empty($artefactcopies[$oldid]->oldembeds)) {
foreach ($artefactcopies[$oldid]->oldembeds as $a) {
if (isset($artefactcopies[$a])) {
// Change the old image id to the new one
$regexp[] = '#<img([^>]+)src="' . get_config('wwwroot') . 'artefact/file/download.php\\?file=' . $a . '(&|&)embedded=1(.*?"[^>]+)#';
$replacetext[] = '<img$1src="' . get_config('wwwroot') . 'artefact/file/download.php?file=' . $artefactcopies[$a]->newid . '$2embedded=1$3';
}
}
require_once 'embeddedimage.php';
$newdescription = EmbeddedImage::prepare_embedded_images(preg_replace($regexp, $replacetext, $this->get('description')), 'textbox', $this->get('id'), $view->get('group'));
$this->set('description', $newdescription);
}
}
示例2: update_artefact_references
public function update_artefact_references(&$view, &$template, &$artefactcopies, $oldid)
{
parent::update_artefact_references($view, $template, $artefactcopies, $oldid);
// Attach copies of the files that were attached to the old post.
// Update <img> tags in the post body to refer to the new image artefacts.
$regexp = array();
$replacetext = array();
if (isset($artefactcopies[$oldid]->oldattachments)) {
foreach ($artefactcopies[$oldid]->oldattachments as $a) {
if (isset($artefactcopies[$a])) {
$this->attach($artefactcopies[$a]->newid);
}
$regexp[] = '#<img([^>]+)src="' . get_config('wwwroot') . 'artefact/file/download.php\\?file=' . $a . '"#';
$replacetext[] = '<img$1src="' . get_config('wwwroot') . 'artefact/file/download.php?file=' . $artefactcopies[$a]->newid . '"';
}
$this->set('description', preg_replace($regexp, $replacetext, $this->get('description')));
}
}