Пример #1
0
 /**
  * @return array
  */
 public function exportTree()
 {
     $tree = new TreeComposite();
     $tree->createNode(new Node('country'));
     $tree->createNode(new Node('kiev'), $tree->getNode('country'));
     $tree->createNode(new Node('kremlin'), $tree->getNode('kiev'));
     $tree->createNode(new Node('house'), $tree->getNode('kremlin'));
     $tree->createNode(new Node('tower'), $tree->getNode('kremlin'));
     $tree->createNode(new Node('moskow'), $tree->getNode('country'));
     $tree->attachNode($tree->getNode('kremlin'), $tree->getNode('moskow'));
     $tree->createNode(new Node('maidan'), $tree->getNode('kiev'));
     $tree->deleteNode($tree->getNode('kiev'));
     $tree->createNode(NodeFactory::create('domen', 'product1'));
     $tree->createNode(NodeFactory::create('RU', 'product2'), $tree->getNode('domen'));
     $tree->createNode(NodeFactory::create('EU', 'product2'), $tree->getNode('domen'));
     $tree->createNode(NodeFactory::create('RU', 'product2'), $tree->getNode('domen'));
     return $tree->export();
 }
Пример #2
0
$route = new Route();
$route->start();
$tree = new TreeComposite();
$tree->createNode(new Node('country'));
$tree->createNode(new Node('kiev'), $tree->getNode('country'));
$tree->createNode(new Node('kremlin'), $tree->getNode('kiev'));
$tree->createNode(new Node('house'), $tree->getNode('kremlin'));
$tree->createNode(new Node('tower'), $tree->getNode('kremlin'));
$tree->createNode(new Node('moskow'), $tree->getNode('country'));
$tree->attachNode($tree->getNode('kremlin'), $tree->getNode('moskow'));
$tree->createNode(new Node('maidan'), $tree->getNode('kiev'));
$tree->deleteNode($tree->getNode('kiev'));
$tree->createNode(NodeFactory::create('domen', 'product1'));
$tree->createNode(NodeFactory::create('RU', 'product2'), $tree->getNode('domen'));
$tree->createNode(NodeFactory::create('EU', 'product2'), $tree->getNode('domen'));
$tree->createNode(NodeFactory::create('RU', 'product2'), $tree->getNode('domen'));
function print_pre($ar)
{
    echo "<pre>";
    print_r($ar);
    echo "</pre>";
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>Senior task</title>
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
    <link rel="stylesheet" href="style.css">
    <script src="//code.jquery.com/jquery-1.11.3.min.js"></script>