本文整理汇总了PHP中Path类的典型用法代码示例。如果您正苦于以下问题:PHP Path类的具体用法?PHP Path怎么用?PHP Path使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Path类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRelativePath
/**
* {@inheritdoc}
*/
public function getRelativePath(PathInterface $reference)
{
if ($this->sameValueAs($reference)) {
return '';
}
$ref_path = array_values($reference->toArray());
$this_path = array_values($this->data);
$filename = array_pop($this_path);
//retrieve the final consecutive identical segment in the current path
$index = 0;
foreach ($ref_path as $offset => $value) {
if (!isset($this_path[$offset]) || $value != $this_path[$offset]) {
break;
}
$index++;
}
//deduce the number of similar segment according to the reference path
$nb_common_segment = count($ref_path) - $index;
$nb_segments = array();
if ($nb_common_segment) {
$nb_segments = array_fill(0, $nb_common_segment, '..');
}
//let's output the relative path using a new Path object
$res = new Path(array_merge($nb_segments, array_slice($this_path, $index), array($filename)));
return $res->__toString();
}
示例2: __construct
public function __construct(\Path $path)
{
$this->archive = \RarArchive::open($path->getPathName());
if (!$this->archive) {
throw new Exception('Failed to open archive');
}
}
示例3: download
protected function download(Path $path)
{
// check basic auth headers as well, so if specified,
// client doesn't have to go through the login and cookie dance.
Auth::onceBasic("username");
// check we're logged in
if (!Auth::check()) {
Session::flash('redirect', URL::current());
return Redirect::route('login');
}
// record the download in the db
$record = $path->loadCreateRecord($path);
$record->downloaded_at = $record->freshTimestamp();
$record->increment('downloads');
$record->save();
$isMisc = strpos($path->getRelative(), '/Misc/') === 0;
if ($isMisc || $path->isSafeExtension()) {
// check if the extension is safe to download
$file = new AsciiSafeDownloadFile($path->getPathname());
// see comments in AsciiSafeDownloadFile class
$baseName = $path->getBasename();
$baseName = str_replace('%', '', $baseName);
try {
return Response::download($file, $baseName);
} catch (InvalidArgumentException $e) {
App::abort(500, 'This file has a malformed filename. Please contact an admin.');
}
} else {
App::abort(403, sprintf('File type "%s" not allowed', $path->getExtension()));
}
}
示例4: folder
/**
* {@inheritdoc}
*/
public function folder(string $url) : string
{
$this->validateUrl($url);
$parsed = $this->parser->parseUrl($url);
$path = new Path($parsed->path);
return (string) new ParsedUrl($parsed->scheme, $parsed->user, $parsed->pass, $parsed->host, $parsed->port, (string) $path->folder(), '', '');
}
示例5: testLineTo
/**
* @dataProvider lineProvider
*/
public function testLineTo($x, $y, $coords, $result)
{
$path = new Path($x, $y);
foreach ($coords as $coord) {
$path->lineTo($coord['x'], $coord['y'], $coord['relative']);
}
$this->assertEquals($result, (string) $path);
}
示例6: __construct
public function __construct(\Path $path)
{
$this->archive = new \ZipArchive();
$result = $this->archive->open($path->getPathName());
if (!$result) {
throw new Exception('Failed to open archive');
}
}
示例7: encode
public function encode(Path $path)
{
$parts = explode(Path::PATH_PART_SEPARATOR, $path->get());
foreach ($parts as $partIndex => $part) {
$parts[$partIndex] = rawurlencode($part);
}
return new Path(implode(Path::PATH_PART_SEPARATOR, $parts));
}
示例8: listACLsByPath
function listACLsByPath($pathname)
{
$me = $_SERVER["PHP_SELF"];
if (!canEdit($pathname)) {
echo "Ihnen fehlt leider die Berechtigung, das Verzeichnis {$pathname} zu bearbeiten";
return false;
}
// Verzeichnisobjekt holen
$path = new Path();
if (!$path->selectByName($pathname)) {
fehlerausgabe("Das Verzeichnis {$pathname} konnte nicht aus der DB gewählt werden");
return false;
}
// ACLs fuer das Verzeichnis holen
$acllist = new ACLList();
if (!$acllist->selectByPath($pathname)) {
fehlerausgabe("Die zum Verzeichnis {$pathname} gehörigen ACLs konnten nicht aus der DB gewählt werden");
return false;
}
echo "ACLs für Pfad {$pathname}:";
echo <<<EOF
<form name="acleditor" method="post" action="{$me}">
<select name="cmd">
<option value="edit">Eine ACL bearbeiten</option>
<option value="del">Löschen</option>
</select>
<input type="hidden" name="pathname" value="{$pathname}" />
<input type="submit" value="Los" />
<br />
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="table-layout:fixed">
<tr>
<td>User</td>
<td>Löschen</td>
<td>Schreiben</td>
<td>Lesen</td>
<td>Umbenennen</td>
</tr>
EOF;
$user = new User();
for ($i = 0; $i < count($acllist->list); $i++) {
$acl = $acllist->list[$i];
$user->selectByID($acl->user_id);
echo <<<EOF
<tr>
<td><input type="checkbox" name="aclid[]" value="{$acl->acl_id}" />{$user->loginname}</td>
<td>{$acl->delete_path}</td>
<td>{$acl->write_path}</td>
<td>{$acl->read_path}</td>
<td>{$acl->rename_path}</td>
</tr>
EOF;
}
echo <<<EOF
</table>
</form>
EOF;
return true;
}
示例9: sinvactu
function sinvactu()
{
parent::Controller();
$this->load->library("rapyd");
$this->load->library("path");
$path = new Path();
$path->setPath($this->config->item('uploads_dir'));
$path->append('/archivos');
$this->upload_path = $path->getPath() . '/';
}
示例10: Catalogo
function Catalogo()
{
parent::Controller();
$this->load->library("rapyd");
$this->load->library("path");
$path = new Path();
$path->setPath($this->config->item('uploads_dir'));
$path->append('/inventario');
$this->upload_path = $path->getPath();
}
示例11: match
public function match(Path $path)
{
$values = array();
if (preg_match($this->regex, $path->value(), $values) == 1) {
array_shift($values);
$this->parameterValues = $values;
return true;
}
return false;
}
示例12: modulos
function modulos()
{
parent::Controller();
$this->load->library("rapyd");
$this->load->library("path");
$path = new Path();
$path->setPath($this->config->item('uploads_dir'));
$path->append('/graficos');
$this->upload_path = $path->getPath() . '/';
}
示例13: logo
function logo()
{
parent::Controller();
$this->load->library("rapyd");
$this->load->helper('download');
$this->load->library("path");
$path = new Path();
$path->setPath($this->config->item('base_url'));
$path->append('images');
echo $this->upload_path = $path->getPath() . '/';
}
示例14: Publicidad
function Publicidad()
{
parent::Controller();
$this->load->library("rapyd");
$this->load->library("path");
$path = new Path();
$path->setPath($this->config->item('uploads_dir'));
$path->append('publicidad');
$this->upload_path = $path->getPath() . '/';
//$this->datasis->modulo_id(907,1);
}
示例15: logo
function logo()
{
parent::Controller();
$this->load->library('rapyd');
$this->load->helper('download');
$this->load->library('path');
$path = new Path();
$path->setPath($this->config->item('base_url'));
$path->append('images');
$this->upload_path = $path->getPath() . '/';
$this->write = is_writable('images');
}