當前位置: 首頁>>代碼示例>>PHP>>正文


PHP eZSys::lineSeparator方法代碼示例

本文整理匯總了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;
//.........這裏部分代碼省略.........
開發者ID:runelangseid,項目名稱:ezpublish,代碼行數:101,代碼來源:ezini.php


注:本文中的eZSys::lineSeparator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。