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


PHP Graph::size方法代码示例

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


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

示例1: LDP_get_prefix

function LDP_get_prefix($path, $uri, $type = 'http://ns.rww.io/ldpx#ldprPrefix')
{
    if ($path && $uri) {
        $g = new Graph('', $path, '', $uri);
        if ($g->size() > 0) {
            // specific authorization
            $q = 'SELECT ?s, ?prefix WHERE { ?s <' . $type . '> ?prefix }';
            $s = $g->SELECT($q);
            $res = $s['results']['bindings'];
            if (isset($res) && count($res) > 0) {
                return $res[0]['prefix']['value'];
            }
        }
    }
    return null;
}
开发者ID:Sunnepah,项目名称:ldphp,代码行数:16,代码来源:util.lib.php

示例2: dirname

        $g->append('turtle', "@prefix p: <http://www.w3.org/ns/posix/stat#> . <" . $properties['resource'] . "> a " . $properties['type'] . " ; p:mtime " . $properties['mtime'] . " ; p:size " . $properties['size'] . " .");
    }
    // add ldp:contains triple to the LDPC
    if ($show_containment) {
        $g->append('turtle', "<" . $_base . "> <http://www.w3.org/ns/ldp#contains> <" . $properties['resource'] . "> . ");
    }
    // add resource type from resources containing metadata
    if ($properties['type'] != 'p:File') {
        if ($properties['type'] == 'p:Directory') {
            $meta_uri = dirname($properties['uri']) . '/.meta.' . basename($properties['uri']);
            $meta_file = $_filename . '.meta.' . basename($properties['resource']);
        } else {
            $meta_uri = $properties['uri'];
            $meta_file = $_filename . basename($properties['resource']);
        }
        $dg = new Graph('', $meta_file, '', $meta_uri);
        if ($dg->size() > 0) {
            $q = 'SELECT * WHERE { <' . $properties['resource'] . '> ?p ?o }';
            $s = $dg->SELECT($q);
            $res = $s['results']['bindings'];
            // add the resource type
            if (isset($res) && count($res) > 0) {
                foreach ($res as $t) {
                    if ($t['p']['value'] == 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type') {
                        $g->append_objects($properties['uri'], $t['p']['value'], array($t['o']));
                    }
                }
            }
        }
    }
}
开发者ID:sgml,项目名称:rww.io,代码行数:31,代码来源:index.rdf.php

示例3: substr

            continue;
        }
        $item_uri = REQUEST_BASE . substr($item, strlen($_filebase));
        // get file mtime and md5
        $mtime = filemtime($item);
        if ($mtime > $last_mtime) {
            $last_mtime = $mtime;
        }
        $glob_md5 .= md5_file($item);
        // WebACL
        $wac = new WAC($_user, $item, $item_uri);
        if ($wac->can('Read')) {
            $g->append_file('turtle', "file://{$item}", $item_uri);
        }
    }
} elseif (!empty($_filename) && !$g->exists() && !$g->size()) {
    if (!$_options->wiki) {
        header('HTTP/1.1 404 Not Found');
    }
}
// offer ?wait updates (polling)
if (isset($i_wait)) {
    $etag = is_array($i_wait) && isset($i_wait['etag']) ? $i_wait['etag'] : $g->etag();
    while ($etag == $g->etag()) {
        sleep(1);
        clearstatcache();
    }
    $g->reload();
}
// offer WebSocket updates
$updatesVia = isHTTPS() ? 'wss:' : 'ws:';
开发者ID:Sunnepah,项目名称:ldphp,代码行数:31,代码来源:GET.php

示例4: httpStatusExit

    $metafile = '';
    $ldp_location = $_base;
}
$_data = file_get_contents('php://input');
if ($_input == 'raw') {
    require_once 'if-match.php';
    file_put_contents($_filename, $_data, FILE_APPEND | LOCK_EX);
    httpStatusExit(201, 'Created');
}
$g = new Graph('', $_filename, '', $_base);
require_once 'if-match.php';
if ($_method == 'PATCH') {
    if ($_input == 'json' && ($g->patch_json($_data) || 1)) {
        librdf_php_last_log_level() && httpStatusExit(400, 'Bad Request', null, librdf_php_last_log_message());
        $g->save();
        header('Triples: ' . $g->size());
        header("Link: <" . dirname($_base) . '/' . $metafile . ">; rel=meta", false);
        header('Location: ' . $ldp_location);
        httpStatusExit(201, 'Created');
    }
} elseif (!empty($_input) && ($g->append($_input, $_data) || 1)) {
    librdf_php_last_log_level() && httpStatusExit(400, 'Bad Request', null, librdf_php_last_log_message());
    $g->save();
    header("Triples: " . $g->size(), false);
    header("Link: <" . $_base . $metafile . ">; rel=meta", false);
    header('Location: ' . $ldp_location);
    header('ETag: "' . md5_file($_filename) . '"');
    httpStatusExit(201, 'Created');
} elseif ($_content_type == 'application/sparql-update') {
    require_once 'SPARQL.php';
} else {
开发者ID:Sunnepah,项目名称:ldphp,代码行数:31,代码来源:POST.php

示例5: array

 *  Copyright (C) 2013 RWW.IO
 *  
 *  Permission is hereby granted, free of charge, to any person obtaining a copy
 *  of this software and associated documentation files (the "Software"), to deal 
 *  in the Software without restriction, including without limitation the rights 
 *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
 *  copies of the Software, and to permit persons to whom the Software is furnished 
 *  to do so, subject to the following conditions:
 *  The above copyright notice and this permission notice shall be included in all 
 *  copies or substantial portions of the Software.
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
 *  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
 *  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
 *  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
 *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
 *  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
require_once '../runtime.php';
require_once 'webid.lib.php';
header('Content-type: text/plain');
$claim = webid_claim();
if (isset($i_uri)) {
    $claim['uri'][] = $i_uri;
}
$query = array();
foreach ($claim['uri'] as $elt) {
    $g = new Graph('uri', $elt, '', $elt);
    $query[$elt] = array('triples' => $g->size(), 'bindings' => webid_query($elt, $g));
}
$r = array('claim' => $claim, 'query' => $query, 'verified' => webid_verify());
print_r($r);
开发者ID:sgml,项目名称:rww.io,代码行数:31,代码来源:webid.php

示例6: can

 /**
  * Check if the user has access to a specific URI
  * @param string $method Read/Write/Append/Control
  * @param array $options local configuration options
  * @param string $uri the URI of the resource
  *
  * @return boolean (true if user has access)
  */
 function can($method)
 {
     $this->_debug[] = "Method=" . $method;
     // check if we are the domain owner
     if (is_file($this->_root_path . '.acl')) {
         $g = new Graph('', $this->_root_path . '.acl', '', $this->_root_uri . '.acl');
         if ($g->size() > 0) {
             // for the domain owner
             $this->_debug[] = "Graph size=" . $g->size();
             $q = "PREFIX acl: <http://www.w3.org/ns/auth/acl#>\n                      SELECT ?z WHERE { \n                        ?z acl:agent <" . $this->_user . "> .\n                        }";
             $r = $g->SELECT($q);
             if (isset($r['results']['bindings']) && count($r['results']['bindings']) > 0) {
                 $this->_reason .= "User " . $this->_user . " was authenticated as owner!";
                 return true;
             }
         }
     }
     // Recursively find a .acl
     $path = $this->_path;
     $uri = $this->_uri;
     $parent_path = dirname($path) == $this->_root_path ? $path : dirname($path);
     $parent_uri = dirname($uri) == $this->_root_uri ? $uri : dirname($uri);
     $break = false;
     // debug
     $this->_debug[] = " ";
     $this->_debug[] = "------------";
     $this->_debug[] = "Not the owner, going recursively! BASE=" . $this->_path;
     $this->_debug[] = "User is: " . $this->_user;
     // walk path (force stop if we hit root level)
     while ($path != dirname($this->_root_path)) {
         if ($break == true) {
             return true;
         }
         $r = $path;
         $this->_debug[] = "------------";
         $this->_debug[] = "Current level: " . $r;
         $resource = $uri;
         if ($r != $this->_root_path) {
             $path = dirname($path) == $this->_root_path ? $path : dirname($path) . '/';
             $this->_debug[] = "PATH=" . $path . " / ROOT_PATH=" . $this->_root_path;
             $acl_file = substr(basename($r), 0, 4) != '.acl' ? '.acl.' . basename($r) : basename($r);
             $acl_path = $path . $acl_file;
             $acl_uri = dirname($uri) == $this->_root_uri ? $acl_file : dirname($uri) . '/' . $acl_file;
             $this->_debug[] = "Dir=" . $r . " | acl_path=" . $acl_path . " | acl_uri=" . $acl_uri;
             $uri = dirname($uri) == $this->_root_uri ? $uri : dirname($uri) . '/';
             $this->_debug[] = 'Parent_path=' . $path . ' | parent_uri=' . $uri;
             /*
             $acl_file = (substr(basename($r), 0, 4) != '.acl')?'/.acl.'.basename($r):'/'.basename($r);
             $acl_path = $parent_path.$acl_file;
             $acl_uri = (dirname($uri) == $this->_root_uri)?$acl_file:dirname($uri).$acl_file;
             $this->_debug[] = "Dir=".$r." | acl_path=".$acl_path." | acl_uri=".$acl_uri;
             $path = (dirname($path) == $this->_root_path)?$path:dirname($path).'/';
             $uri = (dirname($uri) == $this->_root_uri)?$uri:dirname($uri).'/';
             $this->_debug[] = 'Parent_path='.$path.' | parent_uri='.$uri;
             */
         } else {
             $acl_path = $r . '.acl';
             $acl_uri = $uri . '.acl';
             $this->_debug[] = "ROOT Dir=" . $r . " | acl_path=" . $acl_path . " | acl_uri=" . $acl_uri;
             if ($path == $this->_root_path) {
                 $break = true;
             }
         }
         if ($r == $this->_path) {
             $verb = 'accessTo';
         } else {
             $verb = 'defaultForNew';
             if (substr($resource, -1) != '/') {
                 $resource = $resource . '/';
             }
         }
         $this->_debug[] = "Verb=" . $verb . " | Resource=" . $resource;
         if (is_file($acl_path)) {
             $g = new Graph('', $acl_path, '', $acl_uri);
             if ($g->size() > 0) {
                 // specific authorization
                 $q = "PREFIX acl: <http://www.w3.org/ns/auth/acl#>" . "SELECT * WHERE { " . "?z acl:agent <" . $this->_user . "> ; " . "acl:mode acl:" . $method . " ; " . "acl:" . $verb . " <" . $resource . "> . " . "}";
                 $this->_debug[] = $q;
                 $res = $g->SELECT($q);
                 if (isset($res['results']['bindings']) && count($res['results']['bindings']) > 0) {
                     $this->_reason .= 'User ' . $this->_user . ' is allowed (' . $method . ') access to ' . $r . "\n";
                     return true;
                 }
                 // public authorization
                 $q = "PREFIX acl: <http://www.w3.org/ns/auth/acl#>" . "SELECT * WHERE { " . "?z acl:agentClass <http://xmlns.com/foaf/0.1/Agent>; " . "acl:mode acl:" . $method . "; " . "acl:" . $verb . " <" . $resource . "> . " . "}";
                 $this->_debug[] = $q;
                 $res = $g->SELECT($q);
                 if (isset($res['results']['bindings']) && count($res['results']['bindings']) > 0) {
                     $this->_reason .= 'Everyone is allowed (' . $method . ') ' . $verb . ' to ' . $r . "\n";
                     return true;
                 }
                 $this->_reason = 'No one is allowed (' . $verb . ') ' . $method . ' for resource ' . $this->_uri . "\n";
//.........这里部分代码省略.........
开发者ID:sgml,项目名称:rww.io,代码行数:101,代码来源:WAC.php


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