Skip to content

Commit

Permalink
Merge pull request #14 from PHPOffice/develop
Browse files Browse the repository at this point in the history
Version 0.2.0
  • Loading branch information
Progi1984 committed Aug 13, 2014
2 parents 718c0d7 + 8ca187e commit 18920bb
Show file tree
Hide file tree
Showing 17 changed files with 928 additions and 172 deletions.
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.2.0 - 2014-08-13
### Features
- MSProjectExchange Reader - @Progi1984 GH-4
- MSProjectExchange Writer - @Progi1984 GH-2

### Miscellaneous
- Refactored resources management - @Progi1984


## 0.1.0 - 2014-08-08

### Features
Expand All @@ -8,8 +17,6 @@
- GanttProject Writer - @Progi1984 GH-1
- GanttProject Reader - @Progi1984 GH-3

### Bugfix

### Miscellaneous
- QA : Documentation - @Progi1984 GH-8 GH-12
- QA : Unit Tests - @Progi1984 GH-12
- QA : Unit Tests - @Progi1984 GH-12
16 changes: 10 additions & 6 deletions docs/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ Writers
+---------------------------+----------------------+--------+-------+
| | Custom | | |
+---------------------------+----------------------+--------+-------+
| **Project** | Task | | |
| **Document Informations** | | | |
+---------------------------+----------------------+--------+-------+
| | Resource | ||
| **Project** | Task | ||
+---------------------------+----------------------+--------+-------+
| | Allocation | ||
| | Resource |||
+---------------------------+----------------------+--------+-------+
| | Allocation |||
+---------------------------+----------------------+--------+-------+

Readers
Expand All @@ -57,11 +59,13 @@ Readers
+---------------------------+----------------------+--------+-------+
| | Custom | | |
+---------------------------+----------------------+--------+-------+
| **Project** | Task | | |
| **Document Informations** | || |
+---------------------------+----------------------+--------+-------+
| **Project** | Task |||
+---------------------------+----------------------+--------+-------+
| | Resource | | |
| | Resource | | |
+---------------------------+----------------------+--------+-------+
| | Allocation | | |
| | Allocation | | |
+---------------------------+----------------------+--------+-------+

Contributing
Expand Down
4 changes: 2 additions & 2 deletions docs/references.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
References
==========

GanttProject
GanttProject (GAN)
---------------------

- `Website <http://ganttproject.biz>`__

MSProjectExchange
MSProjectExchange (MPX)
---------------------

- `MSDN : Description of the MPX Project File Exchange Format <http://support.microsoft.com/kb/270139>`__
Expand Down
12 changes: 6 additions & 6 deletions samples/Sample_01_Simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@
$objTask1->setEndDate('03-01-2012');
$objTask1->setProgress(0.5);
$objTask1->addResource($objRes1);
$objTask1Res = $objTask1->getResources();
echo 'Resources "Start of the project"'.EOL;
foreach ($objTask1Res as $res){
echo ' > '.$objPHPProject->getResource($res)->getTitle().EOL;;
foreach ($objTask1->getResources() as $oResource){
echo ' > '.$oResource->getTitle().EOL;
}

$objTask2 = $objPHPProject->createTask();
Expand All @@ -51,10 +50,11 @@
$objTask21->setProgress(1);
$objTask21->addResource($objRes2);
$objTask21->addResource($objRes1);
$objTask21Res = $objTask21->getResources();
$objTask21->addResource($objRes1);

echo 'Resources "Analysis Code"'.EOL;
foreach ($objTask21Res as $res){
echo ' > '.$objPHPProject->getResource($res)->getTitle().EOL;;
foreach ($objTask21->getResources() as $oResource){
echo ' > '.$oResource->getTitle().EOL;;
}

$objTask22 = $objTask2->createTask();
Expand Down
38 changes: 4 additions & 34 deletions samples/Sample_02_ReadGanttProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,46 +27,16 @@

// Ressources
echo date('H:i:s') . ' Get ressources'.EOL;
$oResources = $objPHPProject->getAllResources();
foreach ($oResources as $item){
echo 'Resource : '.$item->getTitle().EOL;
foreach ($objPHPProject->getAllResources() as $oResource){
echo 'Resource : '.$oResource->getTitle().EOL;
}
echo EOL;

// Tasks
echo date('H:i:s') . ' Get tasks'.EOL;
$oTasks = $objPHPProject->getAllTasks();
foreach ($oTasks as $item){
echo 'Task : '.$item->getName().EOL;
echo ' >> Duration : '.$item->getDuration().EOL;
echo ' >> StartDate : '.date('Y-m-d', $item->getStartDate()).EOL;
echo ' >> Progress : '.$item->getProgress().EOL;
echo ' >> Resources : '.EOL;
$oTaskResources = $item->getResources();
if(!empty($oTaskResources)){
foreach ($oTaskResources as $itemRes){
echo ' >>>> Resource : '.$objPHPProject->getResource($itemRes)->getTitle().EOL;
}
}

echo ' >> SubTasks : '.EOL;
if($item->getTaskCount() > 0){
foreach ($item->getTasks() as $itemSub){
echo ' >>>> Task : '.$itemSub->getName().EOL;
echo ' >>>>>> Duration : '.$itemSub->getDuration().EOL;
echo ' >>>>>> StartDate : '.date('Y-m-d', $itemSub->getStartDate()).EOL;
echo ' >>>>>> Progress : '.$itemSub->getProgress().EOL;
echo ' >>>>>> Resources : '.EOL;
$oTaskResources = $itemSub->getResources();
if(!empty($oTaskResources)){
foreach ($oTaskResources as $itemRes){
echo ' >>>>>>>> Resource : '.$objPHPProject->getResource($itemRes)->getTitle().EOL;
}
}
}
}
foreach ($objPHPProject->getAllTasks() as $oTask){
echoTask($objPHPProject, $oTask);
}
echo EOL;

// Echo done
echo date('H:i:s') . ' Done reading file.'.EOL;
Expand Down
60 changes: 15 additions & 45 deletions samples/Sample_02_ReadMSProjectExchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,69 +7,39 @@

// Create new PHPProject object
echo date('H:i:s') . ' Create new PHPProject object'.EOL;
$objReader = IOFactory::createReader('MSProjectExchange');
$objPHPProject = $objReader->load('02file.mpx');
$objReader = IOFactory::createReader('MsProjectMPX');
$objPHPProject = $objReader->load(__DIR__ .DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'Sample_02.mpx');

// Set properties
echo date('H:i:s') . ' Set properties'.EOL;
echo 'Creator >'.$objPHPProject->getProperties()->getCreator().EOL;
echo 'LastModifiedBy >'.$objPHPProject->getProperties()->getLastModifiedBy().EOL;
echo 'Title >'.$objPHPProject->getProperties()->getTitle().EOL;
echo 'Subject >'.$objPHPProject->getProperties()->getSubject().EOL;
echo 'Description >'.$objPHPProject->getProperties()->getDescription().EOL;
echo date('H:i:s') . ' Get properties'.EOL;
echo 'Creator > '.$objPHPProject->getProperties()->getCreator().EOL;
echo 'LastModifiedBy > '.$objPHPProject->getProperties()->getLastModifiedBy().EOL;
echo 'Title > '.$objPHPProject->getProperties()->getTitle().EOL;
echo 'Subject > '.$objPHPProject->getProperties()->getSubject().EOL;
echo 'Description > '.$objPHPProject->getProperties()->getDescription().EOL;
echo EOL;

// Add some data
echo date('H:i:s') . ' Get some data'.EOL;
echo 'StartDate >'.$objPHPProject->getInformations()->getStartDate().EOL;
echo 'EndDate >'.$objPHPProject->getInformations()->getEndDate().EOL;
echo 'StartDate > '.$objPHPProject->getInformations()->getStartDate().EOL;
echo 'EndDate > '.$objPHPProject->getInformations()->getEndDate().EOL;
echo EOL;

// Ressources
echo date('H:i:s') . ' Get ressources'.EOL;
$oResources = $objPHPProject->getAllResources();
foreach ($oResources as $item){
echo 'Resource :'.$item->getTitle().EOL;
echo 'Resource : '.$item->getTitle().EOL;
}
echo EOL;

// Tasks
echo date('H:i:s') . ' Get tasks'.EOL;
$oTasks = $objPHPProject->getAllTasks();
foreach ($oTasks as $item){
echo 'Task :'.$item->getName().EOL;
echo ' >> Duration :'.$item->getDuration().EOL;
echo ' >> StartDate :'.$item->getStartDate().EOL;
echo ' >> EndDate :'.$item->getEndDate().EOL;
echo ' >> Progress :'.$item->getProgress().EOL;
echo ' >> Resources :'.EOL;
$oTaskResources = $item->getResources();
if(!empty($oTaskResources)){
foreach ($oTaskResources as $itemRes){
echo ' >>>> Resource :'.$objPHPProject->getResource($itemRes)->getTitle().EOL;
}
}

echo ' >> SubTasks :'.EOL;
$oSubTasks = $item->getTasks();
if(!empty($oSubTasks)){
foreach ($oSubTasks as $itemSub){
echo ' >>>> Task :'.$itemSub->getName().EOL;
echo ' >>>>>> Duration :'.$itemSub->getDuration().EOL;
echo ' >>>>>> StartDate :'.$itemSub->getStartDate().EOL;
echo ' >>>>>> EndDate :'.$itemSub->getEndDate().EOL;
echo ' >>>>>> Progress :'.$itemSub->getProgress().EOL;
echo ' >>>>>> Resources :'.EOL;
$oTaskResources = $itemSub->getResources();
if(!empty($oTaskResources)){
foreach ($oTaskResources as $itemRes){
echo ' >>>>>>>> Resource :'.$objPHPProject->getResource($itemRes)->getTitle().EOL;
}
}
}
}
$arrTasks = $objPHPProject->getAllTasks();

foreach ($arrTasks as $oTask){
echoTask($objPHPProject, $oTask);
}
echo EOL;

// Echo done
echo date('H:i:s') . ' Done reading file.'.EOL;
Expand Down
24 changes: 23 additions & 1 deletion samples/Sample_Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Autoloader::register();

// Set writers
$writers = array('GanttProject' => 'gan'/*, 'MSProjectExchange' => 'mpx'*/);
$writers = array('GanttProject' => 'gan', 'MsProjectMPX' => 'mpx');

// Return to the caller script when runs by CLI
if (CLI) {
Expand Down Expand Up @@ -107,6 +107,28 @@ function getEndingNotes($writers)
return $result;
}

function echoTask($oPHPProject, $oTask, $level = 0) {
echo '<strong>'.str_repeat('>', 2 * $level).' Task : '.$oTask->getName().'</strong>'.EOL;
echo ' '.str_repeat('>', 2 * ($level + 1)).' Duration : '.$oTask->getDuration().EOL;
echo ' '.str_repeat('>', 2 * ($level + 1)).' StartDate : '.date('Y-m-d', $oTask->getStartDate()).EOL;
echo ' '.str_repeat('>', 2 * ($level + 1)).' Progress : '.$oTask->getProgress().EOL;
echo ' '.str_repeat('>', 2 * ($level + 1)).' Resources : '.EOL;
$oTaskResources = $oTask->getResources();
if(!empty($oTaskResources)){
foreach ($oTaskResources as $oResource){
echo ' '.str_repeat('>', 2 * ($level + 2)).' Resource : '.$oResource->getTitle().EOL;
}
}
echo EOL;
$level++;
if($oTask->getTaskCount() > 0){
foreach ($oTask->getTasks() as $oSubTask){
echoTask($oPHPProject, $oSubTask, $level);
}
}
$level--;
}

?>
<title><?php echo $pageTitle; ?></title>
<meta charset="utf-8">
Expand Down
27 changes: 27 additions & 0 deletions samples/resources/Sample_02.mpx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
MPX;Microsoft Project for Windows;4.0;ANSI
10;$;1;2;.;,
11;2;0;1;8,00;40,00;$10,00/h;$15,00/h;1;0
12;1;0;480;/;:;AM;PM;20;0
20;Standard;0;1;1;1;1;1;0
25;1
25;2;08:00 AM;12:00 PM;01:00 PM;05:00 PM
25;3;08:00 AM;12:00 PM;01:00 PM;05:00 PM
25;4;08:00 AM;12:00 PM;01:00 PM;05:00 PM
25;5;08:00 AM;12:00 PM;01:00 PM;05:00 PM
25;6;08:00 AM;12:00 PM;01:00 PM;05:00 PM
25;7
30;Project1;;;Standard;01/01/2003;;0;05/12/2003;;$0,00;$0,00;$0,00;0h;0h;0h;0%;0d;0d;0d;0%;;;;;0d;0d
40;Name;ID;Max Units;Unique ID
41;1;40;41;49
50;Resource1;1;;1
50;Resource2;2;0,5;2
60;Name;WBS;Outline Level;Duration;% Complete;Start;Actual Start;Predecessors;Fixed;ID;Constraint Type;Unique ID;Outline Number;Summary
61;1;2;3;40;44;50;58;70;80;90;91;98;99;120
70;Summary Task;1.0;1;;;;;;No;1;As Soon As Possible;1;1.0;Yes
70;First Sub Task;1.1;2;10,5d;55,5%;01/01/2003;01/01/2003;;No;2;As Soon As Possible;2;1.1
75;1;1;80h;;40h;;;;;;;;1
76;;0;0;NA;NA
70;Second Sub Task;1.2;2;10d;;11/01/2003;;2;No;3;As Soon As Possible;3;1.2
75;2;1;10d;;;;;;;;;;2
76;;0;0;NA;NA
70;Milestone;1.3;2;0d;;21/01/2003;;3;No;4;As Soon As Possible;4;1.3
36 changes: 2 additions & 34 deletions src/PhpProject/PhpProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function setProperties(DocumentProperties $pValue)
/**
* Get informations
*
* @return PHPProject_DocumentInformations
* @return DocumentInformations
*/
public function getInformations()
{
Expand Down Expand Up @@ -168,7 +168,7 @@ public function getAllResources()
/**
* Get active resource
*
* @return Resource
* @return Resource|null
*/
public function getActiveResource()
{
Expand All @@ -178,22 +178,6 @@ public function getActiveResource()
return null;
}

/**
* Get resource by index
*
* @param int $pIndex Resource index
* @return Resource
* @throws \Exception
*/
public function getResource($pIndex = 0)
{
if (!isset($this->resourceCollection[$pIndex])) {
throw new \Exception('Resource index is out of bounds.');
} else {
return $this->resourceCollection[$pIndex];
}
}

/**
* Get resource from index
*
Expand Down Expand Up @@ -260,22 +244,6 @@ public function getActiveTask()
return null;
}

/**
* Get task by index
*
* @param int $pIndex Task index
* @return Task
* @throws \Exception
*/
public function getTask($pIndex = 0)
{
if (!isset($this->taskCollection[$pIndex])) {
throw new \Exception('Task index is out of bounds.');
} else {
return $this->taskCollection[$pIndex];
}
}

/**
* Get task from index
*
Expand Down
Loading

0 comments on commit 18920bb

Please sign in to comment.