function runOperation(&$node) { $target_parent_node_id = $this->target_id; if (empty($target_parent_node_id)) { if ($this->move_to_depth >= $node->attribute('depth')) { return false; } // Find the correct target node for the specified depth $path_array = $node->attribute('path_array'); $target_parent_node_id = $path_array[$this->move_to_depth - 1]; } $assigned_nodes = $node->attribute('object')->attribute('assigned_nodes'); // Find the target node foreach ($assigned_nodes as $target_node) { if ($target_node->attribute('parent_node_id') == $target_parent_node_id) { $target_node_id = $target_node->attribute('node_id'); // Make sure target node is not us if ($node->attribute('node_id') == $target_node_id) { return false; } $urlalias_list = eZURLAliasML::fetchByAction('eznode', $node->attribute('node_id')); $target_node_urlalias_list = eZURLAliasML::fetchByAction('eznode', $target_node_id); // Sanity check, this should never happen if (!isset($target_node_urlalias_list[0])) { eZDebug::writeError('Found no url alias records for node with id ' . $target_node_id, 'batchtool/nodemerge'); return false; } $target_node_urlalias_id = $target_node_urlalias_list[0]->attribute('id'); $target_parent_urlalias_id = $target_node_urlalias_list[0]->attribute('parent'); $db = eZDB::instance(); $db->begin(); // Make sure any children nodes are moved to the new node foreach ($node->attribute('children') as $child) { moveNode($child, $target_node_id); } // Make sure any bookmarks are moved to the new node $bookmark_list = eZPersistentObject::fetchObjectList(eZContentBrowseBookmark::definition(), null, array('node_id' => $node->attribute('node_id'))); foreach ($bookmark_list as $bookmark) { $bookmark->setAttribute('node_id', $target_node_id); $bookmark->store(); } // Remove the node in question $node->removeNodeFromTree(true); // Set up url alias redirects to the new node foreach ($urlalias_list as $url_alias) { $url_alias->setAttribute('action', 'eznode:' . $target_node_id); $url_alias->setAttribute('action_type', 'eznode'); $url_alias->setAttribute('link', $target_node_urlalias_id); $url_alias->setAttribute('is_original', 0); $url_alias->store(); } $db->commit(); return true; } } return false; }
function runOperation(&$object) { $target_id = $this->target_id; if (empty($target_id)) { if ($this->move_to_depth >= $object->attribute('depth')) { return false; } // Find the correct target node for the specified depth $path_array = $object->attribute('path_array'); $target_id = $path_array[$this->move_to_depth - 1]; } return moveNode($object, $target_id); }
function optimizeCategories($root) { $nodes = getCategories($root); if (sizeof($nodes) < MAX_LENGTH) { return; } $node = null; $destNode = null; for ($i = sizeof($nodes) - 1; $i >= MAX_LENGTH; $i--) { $node = $nodes[$i]; $destNode = getDestNode($root); moveNode($destNode, $node); } // Îáðàáîòàòü ïîäêàòåãîðèè $nodes = getCategories($root); for ($i = 0; $i < sizeof($nodes); $i++) { optimizeCategories($nodes[$i]); } }
deleteCableLine($CableLineId, TRUE); setTmpMapLastEdit(); } elseif ($_POST['mode'] == "addNode") { $NetworkBoxId = $obj->{'NetworkBoxId'}; $apartment = NULL; $building = NULL; $note = $obj->{'note'}; $name = $obj->{'name'}; $place = $obj->{'place'}; addNode($coors, $name, $NetworkBoxId, $note, NULL, $building, $apartment, $place, TRUE); setTmpMapLastEdit(); } elseif ($_POST['mode'] == "deleteNode") { deleteNode($coors, TRUE); setTmpMapLastEdit(); } elseif ($_POST['mode'] == "moveNode") { moveNode($coors, TRUE); setTmpMapLastEdit(); } elseif ($_POST['mode'] == "divCableLine") { $nodeInfo['name'] = $obj->{'name'}; $nodeInfo['NetworkBoxId'] = $obj->{'NetworkBoxId'}; /*$nodeInfo[ 'apartment' ] = $obj->{'apartment'}; $nodeInfo[ 'building' ] = $obj->{'building'};*/ $nodeInfo['note'] = $obj->{'note'}; $nodeInfo['place'] = $obj->{'place'}; $ret = divCableLine($coors, $CableLineId, $nodeInfo, TRUE); if ($ret['error']) { print json_encode($ret); } else { setTmpMapLastEdit(); print json_encode(array("error" => false)); }
} else { //copy du noeud $result = copyNode($dragID, $dropID); $okDrop = $result[0]; $msg = $result[1]; log_phantom($result[1], "Copie du noeud" . $dragID); } } else { if ($replace == 1) { replaceNode($dropID, $dragID); $okDrop = true; $msg = 'Tout est ok'; } else { //déplacement standard if ($hitMode == "over") { $okDrop = moveNode($dragID, $dropID); } else { $okDrop = moveCrossNode($dragID, $dropID); } $msg = 'Tout est ok'; log_phantom($dragID, "Déplacement du noeud"); } } } } } } } } } else { $okDrop = false;