Esempio n. 1
0
function processExcelFile($filename, $lo_name) {
    $objPHPExcel = PHPExcel_IOFactory::load($filename);
    
    $row = 2;
    $cur_level;
    
    InsertNewLO($lo_name, "", -1, 1);
    
    $root = GetLOItemByContent($lo_name);
    $parent_item['level1'] = array ('level' => '-1', 'content' => $root["name"]);
    
    $max_row = $objPHPExcel->getActiveSheet()->getHighestRow();
    
    while($row <= $max_row) {
        $cur_level = 0;
        $order = 1;
        $index[0] = $objPHPExcel->getActiveSheet()->getCell("A".$row)->getValue();

        if ($index[0] != "0") {
            $cur_level = 1;
            $order = $index[0];
        }
        
        $index[1] = $objPHPExcel->getActiveSheet()->getCell("B".$row)->getValue();
        if ($index[1] != "0") {
            $cur_level = 2;
            $order = $index[1];
        }
        
        $index[2] = $objPHPExcel->getActiveSheet()->getCell("C".$row)->getValue();
        if ($index[2] != "0") {
            $cur_level = 3;
            $order = $index[2];
        }
        
        $index[3] = $objPHPExcel->getActiveSheet()->getCell("D".$row)->getValue();
        if ($index[3] != "0") {
            $cur_level = 4;
            $order = $index[3];
        }
        
        $content = $objPHPExcel->getActiveSheet()->getCell("E".$row)->getValue();
        $content = trim($content);
        
        //print_r($cur_level);
        
        //print_r($content);        
        if ($cur_level == 1) {
            //if this is the first level, parent is root;    
            InsertNewLO($content, " ", $root['id'], $order);
        }
        else {
            //else, check the parent_item
            $pitem = GetLOItemByContent($parent_item['level'.$cur_level]['content']);
            //print_r($pitem['name']);
            InsertNewLO($content, " ", $pitem['id'], $order);
        }
        
        //if this is at same level of previous item
        $parent_item['level'.($cur_level+1)] = array(
                    'level' => $cur_level+1,
                    'content' => $content);

        $row ++;
        //break;
    }
}
Esempio n. 2
0
 else if ($action == 'new_lo_item') {
     $root_id = returnglobal('root_id');
     $saved = returnglobal('saved');
     
     //if item exist
     if (isset($root_id)) {
         //submit button hitted
         if(isset($saved) && $saved==true) {
             $name = returnglobal('txtName');
             $desc = returnglobal('txtDesc');
             $parent = returnglobal('slParent');
             $order = returnglobal('txtOrder');
             
             //echo $parent;
             
             InsertNewLO($name, $desc, $parent, $order);
             
             //exit after add;
             $popupoutput .= "<script type=\"text/javascript\">
                 \n<!--\n alert(\"".$clang->gT("Item added!","js")."\")\n; window.opener.location.reload(); window.close(); //-->\n</script>\n";
         }
         else {
             $popupoutput .= genNewLOItemForm($root_id);
         }    
     }
     //if no item
     else {
         
     }
 }
 else if ($action == 'delete_lo_item') {