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


PHP Folder::correctSlashFor方法代码示例

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


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

示例1: admin_export

 public function admin_export($id = null)
 {
     if (!$id) {
         $this->notice('invalid');
     }
     $this->Template->recursive = -1;
     $template = $this->Template->read(array('name', 'description', 'author', 'header', 'footer'), $id);
     if (empty($template)) {
         $this->notice('invalid');
     }
     $pattern = "/src=[\\\"']?([^\\\"']?.*(png|jpg|gif|jpeg))[\\\"']?/i";
     preg_match_all($pattern, $template['Template']['header'], $images);
     $path = TMP . 'cache' . DS . 'newsletter' . DS . 'template' . DS . $template['Template']['name'];
     $Folder = new Folder($path, 0777);
     $slash = $Folder->correctSlashFor($path);
     App::import('File');
     App::import('Folder');
     $File = new File($path . DS . 'template.xml', true, 0777);
     $imageFiles = array();
     if (!empty($images[1])) {
         foreach ($images[1] as $img) {
             $img = str_replace('/', $slash, $img);
             $img = str_replace('\\', $slash . $slash, $img);
             $imageFiles[] = $img;
             if (is_file(APP . 'webroot' . $img)) {
                 $Folder->create(dirname($path . $img), 0777);
                 $File->path = APP . 'webroot' . $img;
                 $File->copy(dirname($path . $img) . DS . basename($img));
             }
         }
     }
     $xml['template']['name'] = 'Infinitas Newsletter Template';
     $xml['template']['generator'] = 'Infinitas Template Generator';
     $xml['template']['version'] = $this->version;
     $xml['template']['template'] = $template['Template']['name'];
     $xml['template']['description'] = $template['Template']['description'];
     $xml['template']['author'] = $template['Template']['author'];
     $xml['data']['header'] = $template['Template']['header'];
     $xml['data']['footer'] = $template['Template']['footer'];
     $xml['files']['images'] = $imageFiles;
     App::Import('Helper', 'Xml');
     $Xml = new XmlHelper();
     $File->path = $path . DS . 'template.xml';
     $File->write($Xml->serialize($xml));
     App::import('Vendor', 'Zip', array('file' => 'zip.php'));
     $Zip = new CreateZipFile();
     $Zip->zipDirectory($path, null);
     $File = new File($path . DS . 'template.zip', true, 0777);
     $File->write($Zip->getZippedfile());
     $this->view = 'Media';
     $params = array('id' => 'template.zip', 'name' => $template['Template']['name'], 'download' => true, 'extension' => 'zip', 'path' => $path . DS);
     $this->set($params);
     $Folder = new Folder($path);
     $Folder->read();
     $Folder->delete($path);
 }
开发者ID:nani8124,项目名称:infinitas,代码行数:56,代码来源:TemplatesController.php

示例2: slashTerm

 /**
  * Returns $path with added terminating slash (corrected for Windows or other OS).
  *
  * @param string $path Path to check
  * @return string Path with ending slash
  * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::slashTerm
  */
 public static function slashTerm($path)
 {
     if (Folder::isSlashTerm($path)) {
         return $path;
     }
     return $path . Folder::correctSlashFor($path);
 }
开发者ID:ndreynolds,项目名称:arcs,代码行数:14,代码来源:Folder.php

示例3: correctSlashFor

 /**
  * correctSlashFor method
  *
  * @access public
  * @return void
  */
 function correctSlashFor()
 {
     $path = '/path/to/file';
     $result = Folder::correctSlashFor($path);
     $this->assertEqual($result, '/');
     $path = '\\path\\to\\file';
     $result = Folder::correctSlashFor($path);
     $this->assertEqual($result, '/');
     $path = 'C:\\path\\to\\file';
     $result = Folder::correctSlashFor($path);
     $this->assertEqual($result, '\\');
 }
开发者ID:subh,项目名称:raleigh-workshop-08,代码行数:18,代码来源:folder.test.php

示例4: testCorrectSlashFor

 /**
  * correctSlashFor method
  *
  * @return void
  */
 public function testCorrectSlashFor()
 {
     $path = '/path/to/file';
     $result = Folder::correctSlashFor($path);
     $this->assertEquals('/', $result);
     $path = '\\path\\to\\file';
     $result = Folder::correctSlashFor($path);
     $this->assertEquals('/', $result);
     $path = 'C:\\path\\to\\file';
     $result = Folder::correctSlashFor($path);
     $this->assertEquals('\\', $result);
 }
开发者ID:yuuicchan0912,项目名称:sample2,代码行数:17,代码来源:FolderTest.php

示例5: normalizePath

 /**
  * Returns a correct set of slashes for given $path. (\\ for Windows paths and / for other paths.)
  *
  * @param string $path Path to check
  *
  * @return string Set of slashes ("\\" or "/")
  * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::normalizePath
  */
 public static function normalizePath($path)
 {
     return Folder::correctSlashFor($path);
 }
开发者ID:Marcin11,项目名称:_mojePanstwo-Portal,代码行数:12,代码来源:Folder.php


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