|
| __construct ($table="tree", $fields=array(), $add_fields=array("title"=> "title", "type"=> "type")) |
|
| create_node ($data) |
|
| set_data ($data) |
|
| rename_node ($data) |
|
| move_node ($data) |
|
| remove_node ($data) |
|
| get_children ($data) |
|
| search ($data) |
|
| _create_default () |
|
| __construct ($table="tree", $fields=array()) |
|
| _get_node ($id) |
|
| _get_children ($id, $recursive=false) |
|
| _get_path ($id) |
|
| _create ($parent, $position) |
|
| _remove ($id) |
|
| _move ($id, $ref_id, $position=0, $is_copy=false) |
|
| _fix_copy ($id, $position) |
|
| _reconstruct () |
|
| _analyze () |
|
| _dump ($output=false) |
|
| _drop () |
|
Definition at line 477 of file class.tree.php.
◆ __construct()
json_tree::__construct |
( |
|
$table = "tree" , |
|
|
|
$fields = array() , |
|
|
|
$add_fields = array("title" => "title", "type" => "type") |
|
) |
| |
◆ _create_default()
json_tree::_create_default |
( |
| ) |
|
Definition at line 561 of file class.tree.php.
561 {
564 "id" => 1,
565 "position" => 0,
566 "title" => "C:",
567 "type" => "drive"
568 ));
570 "id" => 1,
571 "position" => 1,
572 "title" => "D:",
573 "type" => "drive"
574 ));
576 "id" => 2,
577 "position" => 0,
578 "title" => "_demo",
579 "type" => "folder"
580 ));
582 "id" => 2,
583 "position" => 1,
584 "title" => "_docs",
585 "type" => "folder"
586 ));
588 "id" => 4,
589 "position" => 0,
590 "title" => "index.html",
591 "type" => "default"
592 ));
594 "id" => 5,
595 "position" => 1,
596 "title" => "doc.html",
597 "type" => "default"
598 ));
599 }
References _tree_struct\_drop(), and create_node().
Referenced by get_children().
◆ create_node()
json_tree::create_node |
( |
|
$data | ) |
|
◆ get_children()
json_tree::get_children |
( |
|
$data | ) |
|
Definition at line 531 of file class.tree.php.
531 {
533 if((
int)
$data[
"id"] === 1 && count($tmp) === 0) {
536 }
539 foreach($tmp as $k => $v) {
541 "attr" => array(
"id" =>
"node_".$k,
"rel" => $v[$this->
fields[
"type"]]),
542 "data" => $v[$this->fields["title"]],
543 "state" => ((int)$v[$this->fields["right"]] - (int)$v[$this->fields["left"]] > 1) ? "closed" : ""
544 );
545 }
547 }
_get_children($id, $recursive=false)
References $data, $result, _create_default(), _tree_struct\_get_children(), and fields.
◆ move_node()
json_tree::move_node |
( |
|
$data | ) |
|
Definition at line 506 of file class.tree.php.
506 {
508 if(!
$id)
return "{ \"status\" : 0 }";
509 if((
int)
$data[
"copy"] && count($this->add_fields)) {
512
514 foreach(
$data as $dk => $dv) {
515 $s =
"UPDATE `".$this->table.
"` SET `".$this->
fields[
"id"].
"` = `".$this->
fields[
"id"].
"` ";
516 foreach($this->add_fields as $k => $v) {
517 if(isset($dv[$k]))
$s .=
", `".$this->fields[$v].
"` = \"".$this->db->escape($dv[$k]).
"\" ";
518 else $s .=
", `".$this->fields[$v].
"` = `".$this->
fields[$v].
"` ";
519 }
520 $s .=
"WHERE `".$this->fields[
"id"].
"` = ".$ids[
$i];
521 $this->db->query(
$s);
523 }
524 }
525 return "{ \"status\" : 1, \"id\" : ".$id." }";
526 }
References $data, $i, $id, $s, _tree_struct\_get_children(), and fields.
◆ remove_node()
json_tree::remove_node |
( |
|
$data | ) |
|
◆ rename_node()
json_tree::rename_node |
( |
|
$data | ) |
|
◆ search()
json_tree::search |
( |
|
$data | ) |
|
Definition at line 548 of file class.tree.php.
548 {
549 $this->db->query(
"SELECT `".$this->
fields[
"left"].
"`, `".$this->
fields[
"right"].
"` FROM `".$this->table.
"` WHERE `".$this->fields[
"title"].
"` LIKE '%".$this->db->escape(
$data[
"search_str"]).
"%'");
550 if($this->db->nf() === 0) return "[]";
551 $q = "SELECT DISTINCT `".$this->fields["id"]."` FROM `".$this->table."` WHERE 0 ";
552 while($this->db->nextr()) {
553 $q .=
" OR (`".$this->fields[
"left"].
"` < ".(int)$this->db->f(0).
" AND `".$this->
fields[
"right"].
"` > ".(int)$this->db->f(1).
") ";
554 }
556 $this->db->query($q);
557 while($this->db->nextr()) {
$result[] =
"#node_".$this->db->f(0); }
559 }
References $data, $result, and fields.
◆ set_data()
json_tree::set_data |
( |
|
$data | ) |
|
Definition at line 493 of file class.tree.php.
493 {
494 if(count($this->add_fields) == 0) { return "{ \"status\" : 1 }"; }
495 $s =
"UPDATE `".$this->table.
"` SET `".$this->
fields[
"id"].
"` = `".$this->
fields[
"id"].
"` ";
496 foreach($this->add_fields as $k => $v) {
497 if(isset(
$data[$k]))
$s .=
", `".$this->fields[$v].
"` = \"".$this->db->escape(
$data[$k]).
"\" ";
498 else $s .=
", `".$this->fields[$v].
"` = `".$this->
fields[$v].
"` ";
499 }
500 $s .=
"WHERE `".$this->fields[
"id"].
"` = ".(int)
$data[
"id"];
501 $this->db->query(
$s);
502 return "{ \"status\" : 1 }";
503 }
References $data, $s, and fields.
Referenced by create_node(), and rename_node().
The documentation for this class was generated from the following file: