Пример #1
0
 /**
  * Sets the status for a given node and possibly its children if cascading is asked.
  * Used for actions on tree nodes, not list nodes.
  * $_POST['status'] can be 0 ('draft'), 1 (pending), 2 (published)
  */
 public static function nodes_set_node_status()
 {
     parent::$json_data += array('updated_node' => '', 'cascading' => 0, 'sub_tree' => '', 'sub_tree_nodes' => array());
     if (isset($_POST['root_node']) && is_numeric($_POST['root_node']) && isset($_POST['status'])) {
         $node_to_update = $_POST['root_node'];
         //TODO : can be optimized if no cascading
         $tree = new ApmTreeData();
         $tree->load_last_tree(true, false, false, $node_to_update);
         $cascading = isset($_POST['cascading']) && $_POST['cascading'] == 1;
         $tree->update_nodes_status($_POST['status'], $node_to_update, $cascading);
         $sub_tree_nodes = array();
         if ($cascading) {
             $sub_tree_nodes = $tree->get_ready_to_display_tree($node_to_update, false, false, false);
         } else {
             $sub_tree_nodes = array($tree->get_ready_to_display_node($node_to_update, false, false));
         }
         parent::$json_data['updated_node'] = $node_to_update;
         parent::$json_data['cascading'] = $cascading ? 1 : 0;
         parent::$json_data['sub_tree'] = self::get_html_tree($sub_tree_nodes);
         parent::$json_data['sub_tree_nodes'] = array_keys($sub_tree_nodes);
     }
     parent::send_json();
 }
Пример #2
0
 /**
  * Loads a subtree given its root.
  * Not used yet TODO: see if we remove this function 
  */
 public static function tree_load_sub_tree()
 {
     parent::$json_data += array('sub_tree' => '', 'node_to_replace' => '', 'sub_tree_nodes' => array());
     $root_node = isset($_POST['root_node']) && is_numeric($_POST['root_node']) ? $_POST['root_node'] : ApmTreeData::root_id;
     $tree = new ApmTreeData();
     $tree->load_last_tree();
     //Set the "tree_nodes" variable retrieved and used in the following included template:
     $sub_tree_nodes = $tree->get_ready_to_display_tree($root_node);
     parent::$json_data['sub_tree'] = self::get_html_tree($sub_tree_nodes);
     parent::$json_data['node_to_replace_by_subtree'] = $root_node;
     parent::$json_data['sub_tree_nodes'] = array_keys($sub_tree_nodes);
     parent::send_json();
 }