$response_count = 0;
                     $child["evaluation_dates"][$date]["response_total"] = array();
                     foreach ($child["evaluation_dates"][$date]["responses"] as $responses_count => $responses) {
                         if (@count($child["evaluation_dates"][$date]["responses"][$responses_count])) {
                             foreach ($child["evaluation_dates"][$date]["responses"][$responses_count] as $response_key => $response) {
                                 if (!isset($child["evaluation_dates"][$date]["response_total"][$responses_count])) {
                                     $child["evaluation_dates"][$date]["response_total"][$responses_count] = 0;
                                 }
                                 $child["evaluation_dates"][$date]["response_total"][$responses_count] += $response_key * $response / count($child["evaluation_dates"][$date]["responses"][$responses_count]);
                                 $response_count += $response;
                             }
                             $child["evaluation_dates"][$date]["response_total"][$responses_count] = $child["evaluation_dates"][$date]["response_total"][$responses_count] / $response_count;
                         }
                     }
                 }
                 $temp_row = addChild($temp_row, $child);
             }
             $temp_row["children"] = ksortRecursive($temp_row["children"]);
         }
         $temp_hierarchical_list[] = $temp_row;
     }
     $flat_questions = flattenQuestions($temp_hierarchical_list);
     $temp_hierarchical_list = hierarchicalIterator($temp_hierarchical_list);
     $flat_objectives = flattenObjectives($temp_hierarchical_list);
     foreach ($temp_hierarchical_list as $record) {
         if ($record["type"] == "objective" || $record["display"]) {
             $hierarchical_list[] = $record;
         }
     }
     unset($temp_hierarchical_list);
 }
<?php

require_once "organica.inc";
if (isset($_SESSION['data'])) {
    $organik = $_SESSION['data'];
} else {
    $organik['funcion'] = "";
    $organik['titulo'] = "?";
    $organik['glosa'] = "";
    $organik['id'] = 1;
    $organik['hijos'] = array();
    $organik['url'] = "";
}
if (isset($_GET['n']) && isset($_GET['q'])) {
    if ($_GET['q'] == 'new') {
        $organik = addChild($organik, $_GET['n']);
    }
    if ($_GET['q'] == 'del') {
        $organik = deleteNode($organik, $_GET['n']);
    }
}
if (isset($_POST['funcion'])) {
    $info = array('funcion' => $_POST['funcion'], 'titulo' => $_POST['titulo'], 'glosa' => $_POST['glosa'], 'url' => $_POST['url']);
    $organik = updateInfo($organik, $_POST['id'], $info);
}
$_SESSION['data'] = $organik;
org_header("Editor de Estructuras Org&aacute;nicas");
?>

<form action="organica-d.php" method="post">
<input type="button" value="Volver"
Example #3
0
  FROM menu
  LEFT JOIN galleries ON menu.action_id = galleries.id
  WHERE isVisible <> 0
  ORDER BY lp ASC , parentId ASC";*/
$query = "SELECT tree_menu.Id AS Id, tree_menu.position AS position, tree_menu.name AS name, tree_menu.action AS\naction, articles.path AS path, slave, ownerEl, tree_menu.isVisible\nFROM tree_menu\nLEFT JOIN articles ON tree_menu.action_id = articles.id\nWHERE tree_menu.isVisible <> 0\nAND tree_menu.action = 'articles'\nUNION\nSELECT tree_menu.Id AS Id, tree_menu.position AS position, tree_menu.name AS name, tree_menu.action AS\naction , galleries.path AS path, slave, ownerEl, tree_menu.isVisible\nFROM tree_menu\nLEFT JOIN galleries ON tree_menu.action_id = galleries.id\nWHERE tree_menu.isVisible <> 0\nAND tree_menu.action = 'galleries'\nUNION\nSELECT tree_menu.Id AS Id, tree_menu.position AS position, tree_menu.name AS name, tree_menu.action AS\naction , tables.path AS path, slave, ownerEl, tree_menu.isVisible\nFROM tree_menu\nLEFT JOIN tables ON tree_menu.action_id = tables.id\nWHERE tree_menu.isVisible <> 0\nAND tree_menu.action = 'tables' \nUNION\nSELECT tree_menu.Id AS Id, tree_menu.position AS position, tree_menu.name AS name, tree_menu.action AS\naction , " . $GLOBALS['news_count'] . " AS path, slave, ownerEl, tree_menu.isVisible\nFROM tree_menu\nLEFT JOIN news ON tree_menu.action_id = news.id\nWHERE tree_menu.isVisible <> 0\nAND tree_menu.action = 'news' \nUNION\nSELECT tree_menu.Id AS Id, tree_menu.position AS position, tree_menu.name AS name, tree_menu.action AS\naction , '' AS path, slave, ownerEl, tree_menu.isVisible\nFROM tree_menu\nWHERE tree_menu.isVisible <> 0\nAND tree_menu.action = ''\nORDER BY position ASC , ownerEl ASC";
//echo $query.'<hr/>';
$result = mysql_query($query, $link);
$menu_arr = array();
while ($row = mysql_fetch_assoc($result)) {
    $menu_arr[$row['Id']] = array('id' => $row['Id'], 'lp' => $row['position'], 'name' => $row['name'], 'path' => $row['path'], 'action' => $row['action'], 'hasChildren' => (int) $row['slave'] == 0 ? true : false, 'parentId' => (int) $row['ownerEl'], 'class' => $row['class']);
}
//echo '<pre>'.print_r($menu_arr, 1).'</pre>'; exit;
foreach ($menu_arr as $key => $item) {
    if ($item['parentId'] != 0 && $item['hasChildren'] == false) {
        $parentId = $item['parentId'];
        addChild($menu_arr, $parentId, $item);
        unset($menu_arr[$key]);
    }
}
//echo '<pre>'.print_r($menu_arr, 1).'</pre><hr/>';
foreach ($menu_arr as $key => $item) {
    if ($item['parentId'] == 0 && $item['hasChildren'] == true) {
        addChildren($menu_arr, $item['id'], $key);
    }
}
//echo '<pre>'.print_r($menu_arr, 1).'</pre>'; exit;
function addChild(&$menu_arr, $parentId, $child)
{
    foreach ($menu_arr as $key => $item) {
        if ($item['id'] == $parentId && $item['hasChildren'] != false) {
            //$menu_arr[$key]['children'][$child['id']] = $child;
Example #4
0
    $cur = $first;
    while ($cur->next != $first) {
        echo "<br/>小孩编号:" . $cur->no;
        $cur = $cur->next;
    }
    echo "<br/>小孩编号:" . $cur->no;
}
function countChild($first, $m, $k)
{
    $cur = $first;
    for ($i = 0; $i < $m - 1; $i++) {
        $cur = $cur->next;
    }
    $j = 0;
    while ($cur != $cur->next) {
        if ($j == $k - 2) {
            echo "<br/>出列编号:" . $cur->next->no;
            $cur->next = $cur->next->next;
            $cur = $cur->next;
            $j = 0;
        } else {
            $cur = $cur->next;
            $j++;
        }
    }
    echo "<br/>最后出列编号:" . $cur->no;
}
addChild(25, $first);
showChild($first);
countChild($first, 1, 5);
//第二个小孩开始数,数到三出列
Example #5
0
     addChild($oid, "globalisation", "Globalisation");
     addChild($oid, "governance", "Governance");
     addChild($oid, "justice/crime", "Justice/Crime");
     addChild($oid, "law", "Law");
     addChild($oid, "transparency/corruption", "Transparency/Corruption");
     addChild($oid, "United Nations", "United Nations");
     addChild($oid, "class issues", "Class Issues");
     $oid = addChild($rootId, "war & peace", "War & Peace");
     addChild($oid, "arms/military", "Arms/Military");
     addChild($oid, "conflict", "Conflict");
     addChild($oid, "conflict resolution", "Conflict Resolution");
     addChild($oid, "landmines", "Landmines");
     addChild($oid, "nuclear issues", "Nuclear Issues");
     addChild($oid, "peace", "Peace");
     addChild($oid, "security", "Security");
     addChild($oid, "terrorism", "Terrorism");
 }
 if (isset($install_delete_topic)) {
     // delete topics
     $conn = pg_connect("host={$install_node_host} port={$install_node_port} dbname={$install_node_db_name} user={$install_node_user} password={$install_node_pass}");
     $result = pg_exec($conn, "DELETE FROM sotf_node_objects WHERE id LIKE '%tt%'");
     $result = pg_exec($conn, "DELETE FROM sotf_node_objects WHERE id LIKE '%td%'");
     $result = pg_exec($conn, "DELETE FROM sotf_node_objects WHERE id LIKE '%to%'");
     $result = pg_exec($conn, "SELECT setval('sotf_topics_seq', 1, false)");
     $result = pg_exec($conn, "SELECT setval('sotf_topic_trees_seq', 1, false)");
     $result = pg_exec($conn, "SELECT setval('sotf_topic_tree_defs_seq', 1, false)");
     /*
     			$sql = "DELETE FROM sotf_topic_tree_defs";
     			$result = pg_exec($conn, $sql);
     			$sql = "DELETE FROM sotf_topic_trees";
     			$result = pg_exec($conn, $sql);