| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Old Sites/Libteiser - Ojs/ojs2/classes/i18n/ |
Upload File : |
<?php
/**
* @file classes/i18n/EditableEmailFile.inc.php
*
* Copyright (c) 2003-2009 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class EditableEmailFile
* @ingroup i18n
*
* @brief This class supports updating for email XML files.
*/
// $Id: EditableEmailFile.inc.php,v 1.3.2.1 2009/04/08 19:42:47 asmecher Exp $
import('file.EditableFile');
class EditableEmailFile {
var $locale;
var $editableFile;
function EditableEmailFile($locale, $filename) {
$this->locale = $locale;
$this->editableFile =& new EditableFile($filename);
}
function write() {
$this->editableFile->write();
}
function &getContents() {
return $this->editableFile->getContents();
}
function setContents(&$contents) {
$this->editableFile->setContents($contents);
}
function update($key, $subject, $body, $description) {
$matches = null;
$quotedKey = String::regexp_quote($key);
preg_match(
"/<row>[\W]*<field name=\"email_key\">$quotedKey<\/field>/",
$this->getContents(),
$matches,
PREG_OFFSET_CAPTURE
);
if (!isset($matches[0])) return false;
$offset = $matches[0][1];
$closeOffset = strpos($this->getContents(), '</row>', $offset);
if ($closeOffset === FALSE) return false;
$newContents = substr($this->getContents(), 0, $offset);
$newContents .= '<row>
<field name="email_key">' . $this->editableFile->xmlEscape($key) . '</field>
<field name="subject">' . $this->editableFile->xmlEscape($subject) . '</field>
<field name="body">' . $this->editableFile->xmlEscape($body) . '</field>
<field name="description">' . $this->editableFile->xmlEscape($description) . '</field>
';
$newContents .= substr($this->getContents(), $closeOffset);
$this->setContents($newContents);
return true;
}
function delete($key) {
$matches = null;
$quotedKey = String::regexp_quote($key);
preg_match(
"/[ \t]*<row>[\W]*<field name=\"email_key\">$quotedKey<\/field>/",
$this->getContents(),
$matches,
PREG_OFFSET_CAPTURE
);
if (!isset($matches[0])) return false;
$offset = $matches[0][1];
preg_match("/<\/row>[ \t]*[\r]?\n/", $this->getContents(), $matches, PREG_OFFSET_CAPTURE, $offset);
if (!isset($matches[0])) return false;
$closeOffset = $matches[0][1] + strlen($matches[0][0]);
$newContents = substr($this->getContents(), 0, $offset);
$newContents .= substr($this->getContents(), $closeOffset);
$this->setContents($newContents);
return true;
}
function insert($key, $subject, $body, $description) {
$offset = strrpos($this->getContents(), '</table>');
if ($offset === false) return false;
$newContents = substr($this->getContents(), 0, $offset);
$newContents .= ' <row>
<field name="email_key">' . $this->editableFile->xmlEscape($key) . '</field>
<field name="subject">' . $this->editableFile->xmlEscape($subject) . '</field>
<field name="body">' . $this->editableFile->xmlEscape($body) . '</field>
<field name="description">' . $this->editableFile->xmlEscape($description) . '</field>
</row>
';
$newContents .= substr($this->getContents(), $offset);
$this->setContents($newContents);
}
}
?>