Esempio n. 1
0
 /**
  * Task
  * @param array $record
  */
 private function readRecord70(array $record)
 {
     $oTask = null;
     if (!is_null($this->iParentTaskIdx) && !empty($record[$this->iParentTaskIdx])) {
         $oTaskParent = $this->phpProject->getTaskFromIndex($record[$this->iParentTaskIdx]);
         if (is_object($oTaskParent)) {
             $oTask = $oTaskParent->createTask();
         }
     }
     if (is_null($oTask)) {
         $oTask = $this->phpProject->createTask();
     }
     foreach ($this->defTask as $key => $method) {
         if ($method == 'setDuration') {
             if (substr($record[$key], -1) == 'd') {
                 $record[$key] = intval(substr($record[$key], 0, -1));
             }
         }
         if ($method == 'setProgress') {
             if (substr($record[$key], -1) == '%') {
                 $record[$key] = substr($record[$key], 0, -1);
                 $record[$key] = str_replace(',', '.', $record[$key]);
                 $record[$key] = floatval($record[$key]) / 100;
             }
         }
         $oTask->{$method}($record[$key]);
     }
     $this->oPreviousTask = $oTask;
 }
Esempio n. 2
0
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Could not open file
  */
 public function testSaveException()
 {
     $fileOutput = tempnam(sys_get_temp_dir(), 'PHPPROJECT');
     file_put_contents($fileOutput, 'AA');
     chmod($fileOutput, 044);
     $oPHPProject = new PhpProject();
     $oTask1 = $oPHPProject->createTask();
     $oTask1->setName('Task1Test');
     $xmlWriter = IOFactory::createWriter($oPHPProject, 'MsProjectMPX');
     $xmlWriter->save($fileOutput);
 }
Esempio n. 3
0
 /**
  * Node "Tasks"
  * @param XMLReader $oXML
  * @param \DOMElement $domNode
  */
 private function readNodeTasks(XMLReader $oXML, \DOMElement $domNode)
 {
     $oNodes = $oXML->getElements('*', $domNode);
     if ($oNodes->length > 0) {
         foreach ($oNodes as $oNode) {
             if ($oNode->nodeName == 'task') {
                 $oTask = $this->phpProject->createTask();
                 $this->readNodeTask($oXML, $oNode, $oTask);
             }
         }
     }
 }
Esempio n. 4
0
 public function testTaskFromIndex()
 {
     $object = new PhpProject();
     $oTask1 = $object->createTask();
     $oTask1->setIndex(2);
     $oTask11 = $oTask1->createTask();
     $oTask11->setIndex(22);
     $oTask2 = $object->createTask();
     $oTask2->setIndex(4);
     $this->assertInstanceOf('PhpOffice\\PhpProject\\Task', $object->getTaskFromIndex(2));
     $this->assertNull($object->getTaskFromIndex(1));
 }