function difflink($id, $rev1, $rev2) { if ($rev1 == $rev2) { return ''; } $difflink = $this->hlp->getDifflink($id, $rev1, $rev2); return '<a href="' . $difflink . '" class="approved_diff_link">' . '<img src="' . DOKU_BASE . 'lib/images/diff.png" class="approved_diff_link" alt="Diff" />' . '</a>'; }
/** * Create the body of mails to inform about a changed or an approved page * * @param string $action Must either be "change" or "approve" * @return bool|string * */ public function create_mail_body($action) { global $ID; global $conf; $pageinfo = pageinfo(); // get mail text $rev = $pageinfo['lastmod']; if ($action === 'change') { $body = io_readFile($this->localFN('mailchangetext')); //If there is no approved revision show the diff to the revision before. Otherwise show the diff to the last approved revision. if ($this->hlp->hasApprovals($pageinfo['meta'])) { $aprpre = 'Aproved'; $oldrev = $this->hlp->getLatestApprovedRevision($ID); $difflink = $this->hlp->getDifflink($ID, $oldrev, $rev); } else { $aprpre = 'Previous'; $changelog = new PageChangelog($ID); $oldrev = $changelog->getRelativeRevision($rev, -1); $difflink = $this->hlp->getDifflink($ID, $oldrev, $rev); } $body = str_replace('@DIFF@', $difflink, $body); $body = str_replace('@APRPRE@', $aprpre, $body); $summary = $pageinfo['meta']['last_change']['sum']; $body = str_replace('@SUMMARY@', $summary, $body); if ($oldrev === false) { $oldlink = '---'; } else { $oldlink = $this->revlink($ID, $oldrev); } $body = str_replace('@OLDPAGE@', $oldlink, $body); $newlink = $this->revlink($ID, $rev); $body = str_replace('@NEWPAGE@', $newlink, $body); } elseif ($action === 'approve') { $body = io_readFile($this->localFN('mailapprovetext')); $newlink = $this->revlink($ID, $rev); $body = str_replace('@URL@', $newlink, $body); $changelog = new PageChangelog($ID); $revinfo = $changelog->getRevisionInfo($rev); /** @var DokuWiki_Auth_Plugin $auth */ global $auth; $userinfo = $auth->getUserData($revinfo['user']); $body = str_replace('@FULLNAME@', $userinfo['name'], $body); } else { return false; } $body = str_replace('@DOKUWIKIURL@', DOKU_URL, $body); $body = str_replace('@TITLE@', $conf['title'], $body); return $body; }