示例#1
0
  /**
   *Make Mn
   *@return string
   */        
  function MakeMindMap(){
      // header xml data freemind
      $content = "<map version=\"0.9.0\">\n";
      $content .= "<!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net -->\n";
      $mytime = time();

      // is logged ?     
      if (!logged_user()->isProjectUser(active_project())) {
        echo $content;
        echo "<node CREATED=\"$mytime\" ID=\"Freemind_Link_558888646\" MODIFIED=\"$mytime\" STYLE=\"bubble\" TEXT=\"Disconnected\">\n";
        echo "</node>\n";
        echo "</map>\n";
        die; 
      } // if
      // is user can view this project ??
      if (!ProjectFile::canView(logged_user(), active_project())) {
        echo $content;
        echo "<node CREATED=\"$mytime\" ID=\"Freemind_Link_558888646\" MODIFIED=\"$mytime\" STYLE=\"bubble\" TEXT=\"Not Allowed\">\n";
        echo "</node>\n";
        echo "</map>\n";
        die;
      } //if
      
      /*
      * xml data construction freemind for project
      */    
      $project = active_project();
      $project_name = $project->getName();
      $this->epure($project_name);
      //Project title
      $url = externalUrl(get_url('task','index'));
      $content .= "<node CREATED=\"$mytime\" LINK=\"$url\" MODIFIED=\"$mytime\" STYLE=\"bubble\" TEXT=\"$project_name\">\n";

      //milestones
      $milestones = $project->getMilestones();
      $mymilestone = array();
      if (is_array($milestones)) {
        foreach($milestones as $milestone){
	  $url = externalUrl(get_url('milestone','view',array('id' => $milestone->getId())));
	  $content .= "<node CREATED=\"$mytime\" LINK=\"$url\" POSITION=\"right\" MODIFIED=\"$mytime\" TEXT=\"  [" . $milestone->getName() . ' ' . Localization::instance()->formatDate($milestone->getDueDate()) . "]\">\n";
	  $content .= "<font NAME=\"SansSerif\" BOLD=\"true\" SIZE=\"12\"/>";
          $content .= "<icon BUILTIN=\"messagebox_warning\"/>\n";
          $content .= "<icon BUILTIN=\"messagebox_warning\"/>\n";
          $content .= "</node>\n";
        }
      }

      $task_lists = $project->getTaskLists();
      if (is_array($task_lists)) {
        //Tasks lists
        $positions = array('right','left');
        $actualpos = 0;
        foreach ($task_lists as $task_list) {
          /*
          * security access
          */      
          //security access User can view this task_list ?
          if (!ProjectTaskList::canView(logged_user(), $task_list->getId())) continue;
          
          // task list name
          $task_list_name=$task_list->getName();
	  //Complete or not complete
	  $progress = $this->progress($task_list);
	  $icon = null;
	  $tasklistComplete = false;
	  if ($progress[0] == '100'){
	    $icon .= "<icon BUILTIN=\"button_ok\"/>\n";
	    $tasklistComplete = true;
	  }
	  $kt_tl_var = 'tl:' . $task_list_name;
      $this->epure($kt_tl_var);
	  if (strlen($task_list_name) > 40) $task_list_name = substr($task_list_name,0,40) . "...";
          $position = $positions[$actualpos];
          $url = externalUrl(get_url('task','view_list',array('id' => $task_list->getId())));
          $content .= "<node CREATED=\"$mytime\" LINK=\"$url\" MODIFIED=\"$mytime\" POSITION=\"$position\" TEXT=\"$task_list_name\">\n";
	  $content .= "$icon";
          if ($actualpos == 0){
            $actualpos =1;            
          }else{
            $actualpos =0;            
          } //if
          //tasks
          $tasks = $task_list->getTasks();
          if (is_array($tasks)) {
            foreach($tasks as $task) {
              /*
              * security access
              */      
              //security access User can view this task ?
              if (!ProjectTask::canView(logged_user(), $task->getId())) continue;

              // icon freeming ok | cancel              
              $icon = null;
	      if (!$tasklistComplete){
		if ($task->isCompleted()) {          
		  //complete : icon ok
		  $icon .= "<icon BUILTIN=\"button_ok\"/>\n";
		  $dateclose = " []";
		}else{
		  //incomplete : icon cancel
		  $icon .= "<icon BUILTIN=\"button_cancel\"/>\n";
		  $dateclose = " []";
		} //if
	      } //if
              //task name
              $task_text = $task->getText();
	      $this->epure($task_text);
	      if (strlen($task_text) > 40) $task_text = substr($task_text,0,40) . "...";
              $url = externalUrl(get_url('task','view_task',array('id' => $task->getId())));
              $content .= "<node CREATED=\"$mytime\" LINK=\"$url\" MODIFIED=\"$mytime\" TEXT=\"" . $task_text . "\">\n";
              $content .= $icon;
              $content .= "</node>\n";
            }
          }
          $content .= "</node>\n";
        } // if
      } // if

    //footer xml data freemind  
    $content .= "</node>\n";
    $content .= "</map>";

    //send data
    $type = "x-freemind/mm";
    $name = "projectpier.mm";
    $size = strlen($content);
    header("Content-Type: $type");
    header("Content-Disposition: attachment; filename=\"$name\"");
    header("Content-Length: " . (string) $size);
    echo $content;
    die; //end process do not send other informations
  }  //MakeMm