本文整理汇总了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);
}
示例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);
}
示例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, '\\');
}
示例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);
}
示例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);
}