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


PHP Path類代碼示例

本文整理匯總了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();
 }
開發者ID:yakamoz-fang,項目名稱:concrete,代碼行數:29,代碼來源:Path.php

示例2: __construct

 public function __construct(\Path $path)
 {
     $this->archive = \RarArchive::open($path->getPathName());
     if (!$this->archive) {
         throw new Exception('Failed to open archive');
     }
 }
開發者ID:Lord-Simon,項目名稱:MangaIndex,代碼行數:7,代碼來源:RarArchive.php

示例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()));
     }
 }
開發者ID:Lord-Simon,項目名稱:MangaIndex,代碼行數:31,代碼來源:BaseController.php

示例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(), '', '');
 }
開發者ID:innmind,項目名稱:url-resolver,代碼行數:10,代碼來源:UrlResolver.php

示例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);
 }
開發者ID:hpainter,項目名稱:identicon,代碼行數:11,代碼來源:PathTest.php

示例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');
     }
 }
開發者ID:Lord-Simon,項目名稱:MangaIndex,代碼行數:8,代碼來源:ZipArchive.php

示例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));
 }
開發者ID:webignition,項目名稱:url,代碼行數:8,代碼來源:Encoder.php

示例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&ouml;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&ouml;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;
}
開發者ID:BackupTheBerlios,項目名稱:sage,代碼行數:58,代碼來源:acledit.inc.php

示例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() . '/';
 }
開發者ID:codethics,項目名稱:proteoerp,代碼行數:10,代碼來源:sinvactu.php

示例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();
 }
開發者ID:enderochoa,項目名稱:tortuga,代碼行數:10,代碼來源:catalogo.php

示例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;
 }
開發者ID:npacker,項目名稱:nFramework,代碼行數:10,代碼來源:PathMatcher.class.php

示例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() . '/';
 }
開發者ID:codethics,項目名稱:proteoerp,代碼行數:10,代碼來源:modulos.php

示例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() . '/';
 }
開發者ID:codethics,項目名稱:proteoerp,代碼行數:11,代碼來源:logo.php

示例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);
 }
開發者ID:enderochoa,項目名稱:tortuga,代碼行數:11,代碼來源:publicidad.php

示例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');
 }
開發者ID:codethics,項目名稱:proteoerp,代碼行數:12,代碼來源:logo.php


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