当前位置: 首页>>代码示例>>PHP>>正文


PHP Filesystem::getLocalPath方法代码示例

本文整理汇总了PHP中OC\Files\Filesystem::getLocalPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::getLocalPath方法的具体用法?PHP Filesystem::getLocalPath怎么用?PHP Filesystem::getLocalPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OC\Files\Filesystem的用法示例。


在下文中一共展示了Filesystem::getLocalPath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadFromFile


//.........这里部分代码省略.........
         case IMAGETYPE_GIF:
             if (imagetypes() & IMG_GIF) {
                 $this->resource = imagecreatefromgif($imagePath);
             } else {
                 OC_Log::write('core', 'OC_Image->loadFromFile, GIF images not supported: ' . $imagePath, OC_Log::DEBUG);
             }
             break;
         case IMAGETYPE_JPEG:
             if (imagetypes() & IMG_JPG) {
                 $this->resource = imagecreatefromjpeg($imagePath);
             } else {
                 OC_Log::write('core', 'OC_Image->loadFromFile, JPG images not supported: ' . $imagePath, OC_Log::DEBUG);
             }
             break;
         case IMAGETYPE_PNG:
             if (imagetypes() & IMG_PNG) {
                 $this->resource = imagecreatefrompng($imagePath);
             } else {
                 OC_Log::write('core', 'OC_Image->loadFromFile, PNG images not supported: ' . $imagePath, OC_Log::DEBUG);
             }
             break;
         case IMAGETYPE_XBM:
             if (imagetypes() & IMG_XPM) {
                 $this->resource = imagecreatefromxbm($imagePath);
             } else {
                 OC_Log::write('core', 'OC_Image->loadFromFile, XBM/XPM images not supported: ' . $imagePath, OC_Log::DEBUG);
             }
             break;
         case IMAGETYPE_WBMP:
             if (imagetypes() & IMG_WBMP) {
                 $this->resource = imagecreatefromwbmp($imagePath);
             } else {
                 OC_Log::write('core', 'OC_Image->loadFromFile, WBMP images not supported: ' . $imagePath, OC_Log::DEBUG);
             }
             break;
         case IMAGETYPE_BMP:
             $this->resource = $this->imagecreatefrombmp($imagePath);
             break;
             /*
             case IMAGETYPE_TIFF_II: // (intel byte order)
             	break;
             case IMAGETYPE_TIFF_MM: // (motorola byte order)
             	break;
             case IMAGETYPE_JPC:
             	break;
             case IMAGETYPE_JP2:
             	break;
             case IMAGETYPE_JPX:
             	break;
             case IMAGETYPE_JB2:
             	break;
             case IMAGETYPE_SWC:
             	break;
             case IMAGETYPE_IFF:
             	break;
             case IMAGETYPE_ICO:
             	break;
             case IMAGETYPE_SWF:
             	break;
             case IMAGETYPE_PSD:
             	break;
             */
         /*
         case IMAGETYPE_TIFF_II: // (intel byte order)
         	break;
         case IMAGETYPE_TIFF_MM: // (motorola byte order)
         	break;
         case IMAGETYPE_JPC:
         	break;
         case IMAGETYPE_JP2:
         	break;
         case IMAGETYPE_JPX:
         	break;
         case IMAGETYPE_JB2:
         	break;
         case IMAGETYPE_SWC:
         	break;
         case IMAGETYPE_IFF:
         	break;
         case IMAGETYPE_ICO:
         	break;
         case IMAGETYPE_SWF:
         	break;
         case IMAGETYPE_PSD:
         	break;
         */
         default:
             // this is mostly file created from encrypted file
             $this->resource = imagecreatefromstring(\OC\Files\Filesystem::file_get_contents(\OC\Files\Filesystem::getLocalPath($imagePath)));
             $iType = IMAGETYPE_PNG;
             OC_Log::write('core', 'OC_Image->loadFromFile, Default', OC_Log::DEBUG);
             break;
     }
     if ($this->valid()) {
         $this->imageType = $iType;
         $this->mimeType = image_type_to_mime_type($iType);
         $this->filePath = $imagePath;
     }
     return $this->resource;
 }
开发者ID:hjimmy,项目名称:owncloud,代码行数:101,代码来源:image.php

示例2: getLocalPath

 /**
  * return path to file which reflects one visible in browser
  *
  * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  * @param string $path
  * @return string
  */
 public static function getLocalPath($path)
 {
     return \OC\Files\Filesystem::getLocalPath($path);
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:11,代码来源:filesystem.php

示例3: loadFromFile


//.........这里部分代码省略.........
             } else {
                 $this->logger->debug('OC_Image->loadFromFile, GIF images not supported: ' . $imagePath, array('app' => 'core'));
             }
             break;
         case IMAGETYPE_JPEG:
             if (imagetypes() & IMG_JPG) {
                 $this->resource = imagecreatefromjpeg($imagePath);
             } else {
                 $this->logger->debug('OC_Image->loadFromFile, JPG images not supported: ' . $imagePath, array('app' => 'core'));
             }
             break;
         case IMAGETYPE_PNG:
             if (imagetypes() & IMG_PNG) {
                 $this->resource = imagecreatefrompng($imagePath);
                 // Preserve transparency
                 imagealphablending($this->resource, true);
                 imagesavealpha($this->resource, true);
             } else {
                 $this->logger->debug('OC_Image->loadFromFile, PNG images not supported: ' . $imagePath, array('app' => 'core'));
             }
             break;
         case IMAGETYPE_XBM:
             if (imagetypes() & IMG_XPM) {
                 $this->resource = imagecreatefromxbm($imagePath);
             } else {
                 $this->logger->debug('OC_Image->loadFromFile, XBM/XPM images not supported: ' . $imagePath, array('app' => 'core'));
             }
             break;
         case IMAGETYPE_WBMP:
             if (imagetypes() & IMG_WBMP) {
                 $this->resource = imagecreatefromwbmp($imagePath);
             } else {
                 $this->logger->debug('OC_Image->loadFromFile, WBMP images not supported: ' . $imagePath, array('app' => 'core'));
             }
             break;
         case IMAGETYPE_BMP:
             $this->resource = $this->imagecreatefrombmp($imagePath);
             break;
             /*
             case IMAGETYPE_TIFF_II: // (intel byte order)
             	break;
             case IMAGETYPE_TIFF_MM: // (motorola byte order)
             	break;
             case IMAGETYPE_JPC:
             	break;
             case IMAGETYPE_JP2:
             	break;
             case IMAGETYPE_JPX:
             	break;
             case IMAGETYPE_JB2:
             	break;
             case IMAGETYPE_SWC:
             	break;
             case IMAGETYPE_IFF:
             	break;
             case IMAGETYPE_ICO:
             	break;
             case IMAGETYPE_SWF:
             	break;
             case IMAGETYPE_PSD:
             	break;
             */
         /*
         case IMAGETYPE_TIFF_II: // (intel byte order)
         	break;
         case IMAGETYPE_TIFF_MM: // (motorola byte order)
         	break;
         case IMAGETYPE_JPC:
         	break;
         case IMAGETYPE_JP2:
         	break;
         case IMAGETYPE_JPX:
         	break;
         case IMAGETYPE_JB2:
         	break;
         case IMAGETYPE_SWC:
         	break;
         case IMAGETYPE_IFF:
         	break;
         case IMAGETYPE_ICO:
         	break;
         case IMAGETYPE_SWF:
         	break;
         case IMAGETYPE_PSD:
         	break;
         */
         default:
             // this is mostly file created from encrypted file
             $this->resource = imagecreatefromstring(\OC\Files\Filesystem::file_get_contents(\OC\Files\Filesystem::getLocalPath($imagePath)));
             $iType = IMAGETYPE_PNG;
             $this->logger->debug('OC_Image->loadFromFile, Default', array('app' => 'core'));
             break;
     }
     if ($this->valid()) {
         $this->imageType = $iType;
         $this->mimeType = image_type_to_mime_type($iType);
         $this->filePath = $imagePath;
     }
     return $this->resource;
 }
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:101,代码来源:image.php

示例4: doCompile

 /**
  * Compile Latex File
  *
  * @NoAdminRequired
  *
  * @param string $path
  * @param string $filename
  * @param string $compiler
  * @return DataResponse
  */
 public function doCompile($path, $filename, $compiler)
 {
     $success = 'success';
     $error = 'error';
     try {
         set_time_limit(0);
         //scanning can take ages
         // If they've set the compiler to something other than an allowable option....
         if (!($compiler === 'xelatex' || $compiler === 'pdflatex' || $compiler === 'latex')) {
             $compiler = 'latex';
         }
         // The real directory file
         $workdir = dirname(\OC\Files\Filesystem::getLocalFile(stripslashes($path) . $filename));
         $info = pathinfo($filename);
         $fileext = '.' . $info['extension'];
         $projectname = trim(basename($filename, $fileext));
         $pdffile = $projectname . '.pdf';
         $dvifile = $projectname . '.dvi';
         $psfile = $projectname . '.ps';
         $tocfile = $projectname . '.toc';
         $logfile = $projectname . '.log';
         $bibfile = $projectname;
         // Bibtex File is without extension
         // As we will write pdf/ps file(s) in the $path, we need to known if it's writable
         if (!\OC\Files\Filesystem::isCreatable(stripslashes($path))) {
             return new JSONResponse(array('data' => array('message' => 'As you don\'t have write permission in the owner directory, it\'s not possible to create output latex files.', 'output' => '')), Http::STATUS_BAD_REQUEST);
         }
         // Command to jump into directory
         $cd_command = "cd " . str_replace(' ', '\\ ', trim($workdir));
         // PDFLatex command preparation
         if ($compiler == 'xelatex' || $compiler == 'pdflatex') {
             $latex_command = $compiler . ' ' . $filename;
             $bibtex_command = 'bibtex ' . $bibfile;
         } else {
             $latex_command = "latex -output-directory={$outpath}  {$filename} ; cd {$outpath}; dvips  {$dvifile} ; ps2pdf {$psfile}";
         }
         $output = "<b>========BEGIN COMPILE========</b>\n{$psfile} \n";
         $output .= $cd_command . "\n";
         $output .= getcwd() . "\n";
         // First Compile
         $output .= shell_exec($cd_command . " && pwd");
         $return = shell_exec($cd_command . " && " . $latex_command);
         $output .= getcwd() . "\n";
         // For BibTeX
         if ($compiler == 'pdflatex') {
             // Second compile step with bibtex
             $return .= shell_exec($cd_command . " && " . $bibtex_command);
             // compile again after bibtex
             $return .= shell_exec($cd_command . " && " . $latex_command);
         }
         $logfile = $workdir . '/' . $logfile;
         $log = file_get_contents($logfile);
         while (preg_match('/Return to get cross-references right/', $log) || preg_match('/No file ' . $tocfile . '/', $log)) {
             $return .= shell_exec($cd_command . " && " . $this->latex_command);
             $log = file_get_contents($logfile);
         }
         // ! at begining of a line indicate an error!
         $errors = preg_grep("/^!/", explode("\n", $log));
         if (empty($errors) === false) {
             $log_array = explode("\n", $log);
             $error = "\n";
             foreach ($errors as $line => $msg) {
                 for ($i = $line; $i <= $line + 5; $i++) {
                     $error .= $log_array[$i] . "\n";
                 }
             }
             return new JSONResponse(array('data' => array('message' => $this->l->t('Compile failed with errors') . ' - <br/>', 'output' => nl2br($output . " % " . $latex_command . "\n" . $error)), 'status' => $error), Http::STATUS_OK);
         }
         // No PDF File !?
         if (!file_exists($workdir . '/' . $pdffile)) {
             return new JSONResponse(array('data' => array('message' => $this->l->t('Compile failed with errors') . ':<br/>', 'output' => nl2br($output . " % " . $latex_command . "\n" . file_get_contents($outpath . '/' . $logfile))), 'status' => $error), Http::STATUS_OK);
         }
         $output .= $return;
         $output .= "\n========END COMPILE==========\n";
         $oc_workdir = stripslashes(\OC\Files\Filesystem::getLocalPath($workdir));
         $target = \OCP\Files::buildNotExistingFileName($oc_workdir, $pdffile);
         $target = \OC\Files\Filesystem::normalizePath($target);
         $meta = \OC\Files\Filesystem::getFileInfo($target);
         if ($compiler === 'latex') {
             $target = \OCP\Files::buildNotExistingFileName($oc_workdir, $psfile);
             $target = \OC\Files\Filesystem::normalizePath($target);
             $meta = \OC\Files\Filesystem::getFileInfo($target);
         }
         return new JSONResponse(array('data' => array('output' => nl2br($output), 'path' => $path, 'pdffile' => $pdffile, 'psfile' => $psfile, 'logfile' => $logfile), 'status' => $success), Http::STATUS_OK);
     } catch (\Exception $e) {
         return new DataResponse(['message' => $e], Http::STATUS_BAD_REQUEST);
     }
 }
开发者ID:Aypac,项目名称:files_latexeditor,代码行数:98,代码来源:compilecontroller.php


注:本文中的OC\Files\Filesystem::getLocalPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。