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


PHP Graph::SELECT方法代码示例

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


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

function webid_getinfo($uri)
{
    $g = new Graph('uri', $uri, '', $uri);
    $q = $g->SELECT(sprintf("PREFIX : <http://xmlns.com/foaf/0.1/>\n                     SELECT ?name ?pic ?depic FROM <%s> WHERE { \n                        ?s a :Person .\n                        FILTER (?s = <%s>) .\n                        OPTIONAL { ?s :name ?name } . \n                        OPTIONAL { ?s :img ?pic } .\n                        OPTIONAL { ?s :depiction ?depic } .\n                    }", $uri, $uri));
    if (isset($q['results']) && isset($q['results']['bindings'])) {
        $r = $q['results']['bindings'];
    }
    if (isset($r) && is_array($r) && sizeof($r) > 0) {
        $name = $r[0]['name']['value'];
        $pic = $r[0]['pic']['value'];
        $depic = $r[0]['depic']['value'];
        if (strlen($name) == 0) {
            $name = 'No name';
        }
        if (strlen($pic) == 0) {
            $pic = strlen($depic) > 0 ? $depic : '/common/images/nouser.png';
        }
    } else {
        $name = '';
        $pic = '/common/images/nouser.png';
    }
    return array('name' => $name, 'pic' => $pic);
}
开发者ID:sgml,项目名称:rww.io,代码行数:23,代码来源:webid.lib.php

示例3: 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

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