本文整理汇总了PHP中eZSys::lineSeparator方法的典型用法代码示例。如果您正苦于以下问题:PHP eZSys::lineSeparator方法的具体用法?PHP eZSys::lineSeparator怎么用?PHP eZSys::lineSeparator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZSys
的用法示例。
在下文中一共展示了eZSys::lineSeparator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
function save($fileName = false, $suffix = false, $useOverride = false, $onlyModified = false, $useRootDir = true, $resetArrays = false, $encapsulateInPHP = true)
{
$lineSeparator = eZSys::lineSeparator();
$pathArray = array();
$dirArray = array();
if ($fileName === false) {
$fileName = $this->FileName;
}
if ($useRootDir === true) {
$pathArray[] = $this->RootDir;
$dirArray[] = $this->RootDir;
} else {
if (is_string($useRootDir)) {
$pathArray[] = $useRootDir;
$dirArray[] = $useRootDir;
}
}
if ($useOverride) {
$pathArray[] = 'override';
$dirArray[] = 'override';
}
if ($useOverride === 'append') {
$fileName .= '.append';
}
if ($suffix !== false) {
$fileName .= $suffix;
}
/* Try to guess which filename would fit better: 'xxx.apend' or 'xxx.append.php'.
* We choose 'xxx.append.php' in all cases except when
* 'xxx.append' exists already and 'xxx.append.php' does not exist.
*/
if (strstr($fileName, '.append')) {
$fnAppend = preg_replace('#\\.php$#', '', $fileName);
$fnAppendPhp = $fnAppend . '.php';
$fpAppend = eZDir::path(array_merge($pathArray, array($fnAppend)));
$fpAppendPhp = eZDir::path(array_merge($pathArray, array($fnAppendPhp)));
$fileName = file_exists($fpAppend) && !file_exists($fpAppendPhp) ? $fnAppend : $fnAppendPhp;
}
$originalFileName = $fileName;
$backupFileName = $originalFileName . eZSys::backupFilename();
$fileName .= '.tmp';
$dirPath = eZDir::path($dirArray);
if (!file_exists($dirPath)) {
eZDir::mkdir($dirPath, octdec('777'), true);
}
$filePath = eZDir::path(array_merge($pathArray, array($fileName)));
$originalFilePath = eZDir::path(array_merge($pathArray, array($originalFileName)));
$backupFilePath = eZDir::path(array_merge($pathArray, array($backupFileName)));
$fp = @fopen($filePath, "w+");
if (!$fp) {
eZDebug::writeError("Failed opening file '{$filePath}' for writing", __METHOD__);
return false;
}
$writeOK = true;
$written = 0;
$charset = $this->Codec ? $this->Codec->RequestedOutputCharsetCode : $this->Charset;
if ($encapsulateInPHP) {
$written = fwrite($fp, "<?php /* #?ini charset=\"{$charset}\"?{$lineSeparator}{$lineSeparator}");
} else {
$written = fwrite($fp, "#?ini charset=\"{$charset}\"?{$lineSeparator}{$lineSeparator}");
}
if ($written === false) {
$writeOK = false;
}
$i = 0;
if ($writeOK) {
foreach (array_keys($this->BlockValues) as $blockName) {
if ($onlyModified) {
$groupHasModified = false;
if (isset($this->ModifiedBlockValues[$blockName])) {
foreach ($this->ModifiedBlockValues[$blockName] as $modifiedValue) {
if ($modifiedValue) {
$groupHasModified = true;
}
}
}
if (!$groupHasModified) {
continue;
}
}
$written = 0;
if ($i > 0) {
$written = fwrite($fp, "{$lineSeparator}");
}
if ($written === false) {
$writeOK = false;
break;
}
$written = fwrite($fp, "[{$blockName}]{$lineSeparator}");
if ($written === false) {
$writeOK = false;
break;
}
foreach (array_keys($this->BlockValues[$blockName]) as $blockVariable) {
if ($onlyModified) {
if (!isset($this->ModifiedBlockValues[$blockName][$blockVariable]) or !$this->ModifiedBlockValues[$blockName][$blockVariable]) {
continue;
}
}
$varKey = $blockVariable;
//.........这里部分代码省略.........