本文整理汇总了PHP中Node类的典型用法代码示例。如果您正苦于以下问题:PHP Node类的具体用法?PHP Node怎么用?PHP Node使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: push
public function push($value)
{
$newHead = new Node($value);
$newHead->setNext($this->linkedList);
$this->linkedList = $newHead;
$this->size++;
}
示例2: processNodeResult
/**
* Process the result of the given node. Returns false if no other nodes
* should be run, or a string with the next node name.
*
* @param Node $node Node that was run
*
* @return string
*/
protected function processNodeResult(Node $node)
{
$result = null;
$name = $node->getName();
if (isset($this->nodeResults[$name])) {
foreach ($this->nodeResults[$name] as $resultInfo) {
if ($resultInfo->appliesTo($node)) {
if ($resultInfo->isActionHangup()) {
// hanging up after $name
$this->client->hangup();
} elseif ($resultInfo->isActionJumpTo()) {
$data = $resultInfo->getActionData();
if (isset($data['nodeEval'])) {
$callback = $data['nodeEval'];
$nodeName = $callback($node);
} else {
$nodeName = $data['nodeName'];
}
// jumping from $name to $nodeName
$result = $nodeName;
} elseif ($resultInfo->isActionExecute()) {
// executing callback after $name
$data = $resultInfo->getActionData();
$callback = $data['callback'];
$callback($node);
}
}
}
}
return $result;
}
示例3: testGetIntersectingNode
public function testGetIntersectingNode()
{
$a1 = new Node("one");
$a2 = new Node("two");
$a3 = new Node("three");
$a4 = new Node("four");
$a5 = new Node("five");
$a1->setNext($a2);
$a2->setNext($a3);
$a3->setNext($a4);
$a4->setNext($a5);
$b1 = new Node("un");
$b2 = new Node("deux");
$b3 = new Node("trois");
$b1->setNext($b2);
$b2->setNext($b3);
$this->assertNull(LinkedListIntersectionCheckerNoHashMap::getIntersectingNode($a1, $b1));
$c1 = new Node("uno");
$c2 = new Node("dos");
$c3 = new Node("tres");
$c1->setNext($c2);
$c2->setNext($c3);
$a5->setNext($c1);
$b3->setNext($c1);
$this->assertSame($c1, LinkedListIntersectionCheckerNoHashMap::getIntersectingNode($a1, $b1));
// disconnect the first 4 nodes of the linked list.
// now it begins @ $a5
$a4->setNext(null);
$this->assertSame($c1, LinkedListIntersectionCheckerNoHashMap::getIntersectingNode($a5, $b1));
}
示例4: _getBindingString
/**
* Helper Function for function buildXmlResult($vartable). Generates
* an xml string for a single variable an their corresponding value.
*
* @param String $varname The variables name
* @param Node $varvalue The value of the variable
* @return String The xml string
*/
protected function _getBindingString($varname, $varvalue)
{
$binding = '<binding name="' . $varname . '">';
$value = '<unbound/>';
if ($varvalue instanceof BlankNode) {
$value = '<bnode>' . $varvalue->getLabel() . '</bnode>';
} else {
if ($varvalue instanceof Resource) {
$value = '<uri>' . $varvalue->getUri() . '</uri>';
} else {
if ($varvalue instanceof Literal) {
$label = htmlspecialchars($varvalue->getLabel());
$value = '<literal>' . $label . '</literal>';
if ($varvalue->getDatatype() != null) {
$value = '<literal datatype="' . $varvalue->getDatatype() . '">' . $label . '</literal>';
}
if ($varvalue->getLanguage() != null) {
$value = '<literal xml:lang="' . $varvalue->getLanguage() . '">' . $label . '</literal>';
}
}
}
}
$binding = $binding . $value . '</binding>';
return $binding;
}
示例5: getLabelsFor
/**
* Возвращает список меток для документа.
*/
protected function getLabelsFor(Node $node)
{
if (!$node->id) {
return array();
}
return array_unique((array) $node->getDB()->getResultsKV('id', 'name', "SELECT `id`, `name` FROM `node` " . "WHERE `class` = 'label' AND `deleted` = 0 AND `id` " . "IN (SELECT `tid` FROM `node__rel` WHERE `nid` = ? AND `key` = ?)", array($node->id, $this->value . '*')));
}
示例6: __construct
/**
* Constructor.
*
* @param Node $parent (optional) parent node
*/
public function __construct($parent = null)
{
$this->parent = $parent;
if (null !== $parent) {
$this->level = 1 + $parent->getLevel();
}
}
示例7: getCommentsAction
/**
* Get editorial comments
*
* @ApiDoc(
* statusCodes={
* 200="Returned when success",
* }
* )
*
* @Route("/articles/{number}/{language}/editorial_comments/order/{order}.{_format}", defaults={"_format"="json", "order"="chrono"}, options={"expose"=true}, name="newscoop_gimme_articles_get_editorial_comments")
* @Method("GET")
* @View(serializerGroups={"list"})
*/
public function getCommentsAction(Request $request, $number, $language, $order)
{
$em = $this->container->get('em');
$editorialComments = $em->getRepository('Newscoop\\ArticlesBundle\\Entity\\EditorialComment')->getAllByArticleNumber($number)->getResult();
if ($order == 'nested' && $editorialComments) {
$root = new \Node(0, 0, '');
$reSortedComments = array();
foreach ($editorialComments as $comment) {
$reSortedComments[$comment->getId()] = $comment;
}
ksort($reSortedComments);
foreach ($reSortedComments as $comment) {
if ($comment->getParent() instanceof EditorialComment) {
$node = new \Node($comment->getId(), $comment->getParent()->getId(), $comment);
} else {
$node = new \Node($comment->getId(), 0, $comment);
}
$root->insertNode($node);
}
$editorialComments = $root->flatten(false);
}
$paginator = $this->get('newscoop.paginator.paginator_service');
$paginator->setUsedRouteParams(array('number' => $number, 'language' => $language));
$editorialComments = $paginator->paginate($editorialComments);
return $editorialComments;
}
示例8: render
public function render(Node $node)
{
echo str_repeat('--', $node->getDepth()) . $node->getType() . "\n";
foreach ($node->getChildren() as $child) {
$this->render($child);
}
}
示例9: interpret
public function interpret(Node &$node){
$name = $node->getAttribute('#');
$childs = $node->getChilds();
if($name != ''){
$ret = '<'.$name;
}else{
$ret = '<Node noname="true"';
}
foreach ($node->attrs as $k => $v){
if(!in_array($k[0], array('#', '>', '@'))){
$ret .= ' '.$k.'="'.$v.'"';
}
}
for($i=0; $i<$node->atidx; ++$i){
$ret .= ' attr'.$i.'="'.$node->attrs['@'.$i].'"';
}
$ret .='>';
foreach ($childs as $child){
$ret .= $this->interpret($child);
}
if($name != ''){
$ret .= '</'.$name.'>';
}else{
$ret .= '</Node>';
}
return $ret;
}
示例10: On_PostAction_iterator_fetch
function On_PostAction_iterator_fetch($a_data)
{
// Find iterator in template
$doc = new Template_Document($a_data->post['iterator_template']);
function search_func($node, $args)
{
if ($node instanceof Template_TagNode) {
return $node->getAttribute("name") == $args;
} else {
return false;
}
}
$itrs = $doc->getElementsByFunc(search_func, $a_data->post['iterator_name']);
$iterator = $itrs[0];
// Generate id
$id = Time("U") . substr((string) microtime(), 2, 6);
// Build iterator template
$node = new Node(-$id);
$node->Build($iterator);
// Pack JSON data
$data = array();
$data['id'] = $id;
$data['content'] = Editor::$m_data['module_data'][-$id];
print json_encode($data);
}
示例11: testGetIntersectingNode
public function testGetIntersectingNode()
{
$a1 = new Node("one");
$a2 = new Node("two");
$a3 = new Node("three");
$a4 = new Node("four");
$a5 = new Node("five");
$a1->setNext($a2);
$a2->setNext($a3);
$a3->setNext($a4);
$a4->setNext($a5);
$b1 = new Node("un");
$b2 = new Node("deux");
$b3 = new Node("trois");
$b1->setNext($b2);
$b2->setNext($b3);
$this->assertNull(LinkedListIntersectionChecker::getIntersectingNode($a1, $b1));
$c1 = new Node("uno");
$c2 = new Node("dos");
$c3 = new Node("tres");
$c1->setNext($c2);
$c2->setNext($c3);
$a5->setNext($c1);
$b3->setNext($c1);
$this->assertSame($c1, LinkedListIntersectionChecker::getIntersectingNode($a1, $b1));
}
示例12: createTextElement
function createTextElement($text)
{
$node = new Node();
$node->setType(TEXTELEMENT);
$node->setValue($text);
return $node;
}
示例13: attachChild
/**
* Attach a child node
*
* @param \Zend\Server\Reflection\Node $node
* @return void
*/
public function attachChild(Node $node)
{
$this->children[] = $node;
if ($node->getParent() !== $this) {
$node->setParent($this);
}
}
示例14: get_categories_and_products
function get_categories_and_products($parent_id)
{
$href_string = "javascript:set_return('productcatalog')";
$nodes = array();
if ($parent_id == '' or empty($parent_id)) {
$query = "select id, name , 'category' type from product_categories where (parent_id is null or parent_id='') and deleted=0";
$query .= " union select id, name , 'product' type from product_templates where (category_id is null or category_id='') and deleted=0";
} else {
$query = "select id, name , 'category' type from product_categories where parent_id ='{$parent_id}' and deleted=0";
$query .= " union select id, name , 'product' type from product_templates where category_id ='{$parent_id}' and deleted=0";
}
$result = $GLOBALS['db']->query($query);
// fetchByAssoc has been changed in version 7 and it does encoding of the string data.
// for the treeview we do not encoding as it messes up the display of the folder labels,
// hence we pass false as an additional parameter
while (($row = $GLOBALS['db']->fetchByAssoc($result, false)) != null) {
$node = new Node($row['id'], $row['name']);
$node->set_property("href", $href_string);
$node->set_property("type", $row['type']);
if ($row['type'] == 'product') {
$node->expanded = false;
$node->dynamic_load = false;
} else {
$node->expanded = false;
$node->dynamic_load = true;
}
$nodes[] = $node;
}
return $nodes;
}
示例15: interpret
public function interpret(Node $node){
$text = $node->getAttribute('@0');
$ret = '<h1>'.$text.'</h1>';
return $ret;
}