function getNode($path, $language = "") { path_db_load(); //if (isset($_SESSION['murrix']['pathcache_node'][$path])) // return $_SESSION['murrix']['pathcache_node'][$path]; // We have a cachemiss, resolve manually global $db_prefix, $root_id; // Nothing found i cache if (empty($path)) // We are att the root return -2; $parent_id = getNode(GetParentPath($path), $language); if ($parent_id == -2) return $root_id; else if ($parent_id == -1) return -1; $name = basename($path); if (empty($language)) $language = $_SESSION['murrix']['language']; $query = "SELECT objects.node_id AS node_id FROM `".$db_prefix."objects` AS `objects`, `".$db_prefix."links` AS `links` WHERE objects.name = '$name' AND links.type = 'sub' AND links.node_top = '$parent_id' AND links.node_bottom = objects.node_id ORDER BY objects.version ASC LIMIT 1"; $result = mysql_query($query) or die("getNode: " . mysql_errno() . " " . mysql_error()); if (mysql_num_rows($result) == 0) return -1; else { $row = mysql_fetch_array($result, MYSQL_ASSOC); $node_id = $row['node_id']; } if ($language == $_SESSION['murrix']['language']) { // We want to cache all paths getPaths($node_id, $name); } return $node_id; }
function actionDelete(&$system, $args) { $object = new mObject($this->getNodeId($args)); if ($object->getNodeId() > 0) { if ($object->hasRight("write")) { $parent_id = getNode(GetParentPath($object->getPathInTree())); $object->deleteNode(); $system->addRedirect("exec=show&node_id=$parent_id"); } else $system->addAlert(ucf(i18n("not enough rights"))); } else $system->addAlert(ucf(i18n("the specified path is invalid"))); }
<input class="hidden" type="hidden" name="node_id" value="<?php echo $object->getNodeId(); ?> "/> <? echo compiletpl("title/medium", array("left"=>ucf(i18n("folder content")))); echo "$path"; if (count($subitems) > 0) { $itemlist = array(); $itemlist[] = array(ucf(i18n("name"))); if (!empty($path) && $path != "/") $itemlist[] = array(cmd(img(geticon("back"))." ".ucf(i18n("parent folder")), "exec=import&view=upload&node_id=".$object->getNodeId()."&path=".urlencode(GetParentPath($path)."/"))); foreach ($subitems as $subitem) { $checkbox = "<input checked class=\"input\" type=\"checkbox\" name=\"filenames[]\" value=\"$subitem\"/>"; if (is_dir("$abspath/upload/$path$subitem")) $itemlist[] = array("$checkbox ".cmd(img(geticon("file_folder"))." ".$subitem, "exec=import&view=upload&node_id=".$object->getNodeId()."&path=".urlencode("$path$subitem/"))); else { $type = getfiletype(pathinfo("$abspath/upload/$path$subitem", PATHINFO_EXTENSION)); $itemlist[] = array("$checkbox ".img(geticon($type))." ".$subitem); } } echo compiletpl("table", array("list"=>$itemlist, "endstring"=>"% ".i18n("rows")));
?> </div> </div> <div class="container"> <center> <input type="button" class="submit" onclick="<?php echo "opener.document.getElementById('" . $_GET['input_id'] . "').value='" . $object->getNodeId() . "';"; ?> ;parent.window.close();" value="<?php echo ucf(i18n("select")); ?> "/> </center> </div> <? $parent_path = GetParentPath($object->getPath()); $parent_id = getNode($parent_path); if ($parent_id > 0 && $parent_id != $node_id) { $parent = new mObject($parent_id); ?> <div class="main"> <? echo "<a href=\"".$_SERVER["REQUEST_URI"]."&node_id=$parent_id\">".img(geticon($parent->getIcon()))." <strong>".ucf(i18n("up one level"))."</strong></a>"; ?> </div> <? } $children = fetch("FETCH node WHERE link:node_top='$node_id' AND link:type='sub' NODESORTBY property:version SORTBY property:name");