本文整理汇总了PHP中Node::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Node::get方法的具体用法?PHP Node::get怎么用?PHP Node::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node
的用法示例。
在下文中一共展示了Node::get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
public function get($index, $default = null)
{
$path = $this->getPath($index);
$value = $this->root->get($path, $default);
if ($value instanceof Leaf) {
return $value->getValue();
}
return $default;
}
示例2: explode
function get_from_scad_txt($s)
{
//разделяем документ на строки и удаляем последнюю
$mas = explode('/', $s);
array_splice($mas, -1, 1);
//перебор строк
foreach ($mas as $value) {
$node = new Node();
$node->get($value);
//запись в базу данных
mysql_query("INSERT INTO " . nodes . " SET\n removed = '{$node->removed}',\n x = '{$node->x}',\n y = '{$node->y}',\n z = '{$node->z}'");
}
}
示例3: calculateDistances
/**
* Calculates distances
*
* @param Node $node
* @param Node[] $neighbors
*/
protected function calculateDistances(Node $node, array $neighbors)
{
$this->calculateRanges();
foreach ($neighbors as $neighbor) {
$deltas = array();
foreach ($this->schema->getFields() as $field) {
list($min, $max) = $this->ranges[$field];
$range = $max - $min;
$delta = $neighbor->get($field) - $node->get($field);
$delta = $delta / $range;
$deltas[$field] = $delta;
}
$total = 0;
foreach ($deltas as $delta) {
$total += $delta * $delta;
}
$neighbor->setDistance(sqrt($total));
}
}
示例4: getList
public static function getList($filters = array(), $published = true)
{
$values = array(':lang' => \LANG);
$list = array();
$sql = "\n SELECT\n post.id as id,\n post.blog as blog,\n IFNULL(post_lang.title, post.title) as title,\n IFNULL(post_lang.text, post.text) as `text`,\n IFNULL(post_lang.legend, post.legend) as `legend`,\n post.image as `image`,\n post.media as `media`,\n DATE_FORMAT(post.date, '%d-%m-%Y') as fecha,\n post.publish as publish,\n post.home as home,\n post.footer as footer,\n post.author as author,\n blog.type as owner_type,\n blog.owner as owner_id\n FROM post\n INNER JOIN blog\n ON blog.id = post.blog\n LEFT JOIN post_lang\n ON post_lang.id = post.id\n AND post_lang.lang = :lang\n ";
if (in_array($filters['show'], array('all', 'home', 'footer'))) {
$sql .= " WHERE blog.id IS NOT NULL\n ";
} elseif ($filters['show'] == 'updates') {
$sql .= " WHERE blog.type = 'project'\n ";
} else {
$sql .= " WHERE blog.type = 'node'\n ";
}
if (!empty($filters['blog'])) {
$sql .= " AND post.blog = :blog\n ";
$values[':blog'] = $filters['blog'];
}
if (!empty($filters['tag'])) {
$sql .= " AND post.id IN (SELECT post FROM post_tag WHERE tag = :tag)\n ";
$values[':tag'] = $filters['tag'];
}
if (!empty($filters['author'])) {
$sql .= " AND post.author = :author\n ";
$values[':author'] = $filters['author'];
}
// solo las publicadas
if ($published || $filters['show'] == 'published') {
$sql .= " AND post.publish = 1\n ";
if (empty($filters['blog'])) {
$sql .= " AND blog.owner IN (SELECT id FROM node WHERE active = 1)\n AND blog.owner != 'testnode'\n ";
}
}
// solo las del propio blog
if ($filters['show'] == 'owned') {
$sql .= " AND blog.owner = :node\n ";
$values[':node'] = $filters['node'];
}
// solo las de la portada
if ($filters['show'] == 'home') {
if ($filters['node'] == \GOTEO_NODE) {
$sql .= " AND post.home = 1\n ";
} else {
$sql .= " AND post.id IN (SELECT post FROM post_node WHERE node = :node)\n ";
$values[':node'] = $filters['node'];
}
}
if ($filters['show'] == 'footer') {
if ($filters['node'] == \GOTEO_NODE) {
$sql .= " AND post.footer = 1\n ";
}
}
$sql .= "\n ORDER BY post.date DESC, post.id DESC\n ";
$query = static::query($sql, $values);
foreach ($query->fetchAll(\PDO::FETCH_CLASS, __CLASS__) as $post) {
// galeria
$post->gallery = Image::getAll($post->id, 'post');
$post->image = $post->gallery[0];
// video
if (isset($post->media)) {
$post->media = new Media($post->media);
}
$post->num_comments = Post\Comment::getCount($post->id);
// datos del autor del post
switch ($post->owner_type) {
case 'project':
$proj_blog = Project::getMini($post->owner_id);
$post->author = $proj_blog->owner;
$post->user = $proj_blog->user;
$post->owner_name = $proj_blog->name;
break;
case 'node':
$post->user = User::getMini($post->author);
$node_blog = Node::get($post->owner_id);
$post->owner_name = $node_blog->name;
break;
}
$list[$post->id] = $post;
}
return $list;
}
示例5: nodePropertiesAreHandledCaseInsensitively
/**
* @test
*/
public function nodePropertiesAreHandledCaseInsensitively()
{
$node = new Node(array('id' => 1, 'foo' => 'Foo', 'BAR' => 'Bar'));
$this->assertSame('Foo', $node->foo);
$this->assertSame('Foo', $node->get('foo'));
$this->assertSame('Foo', $node->getFoo());
$this->assertSame('Bar', $node->bar);
$this->assertSame('Bar', $node->get('bar'));
$this->assertSame('Bar', $node->getBar());
}
示例6: testGet4
/**
* Generated from @assert ('37.5 0 0.3') == array (37.5,0,0.3).
*/
public function testGet4()
{
$this->assertEquals(array(37.5, 0, 0.3), $this->object->get('37.5 0 0.3'));
}