[evolvis-commits] r17231: Initial commit. Added base Structure.

messer at evolvis.org messer at evolvis.org
Fri May 13 16:37:08 CEST 2011


Author: messer
Date: 2011-05-13 16:37:08 +0200 (Fri, 13 May 2011)
New Revision: 17231

Added:
   trunk/plugins/scrum/plugins/scrum/
   trunk/plugins/scrum/plugins/scrum/common/
   trunk/plugins/scrum/plugins/scrum/common/ScrumPlugin.class.php
   trunk/plugins/scrum/plugins/scrum/common/scrum-init.php
   trunk/plugins/scrum/plugins/scrum/database/
   trunk/plugins/scrum/plugins/scrum/database/scrum_migrate.sql
   trunk/plugins/scrum/plugins/scrum/include/
   trunk/plugins/scrum/plugins/scrum/include/FusionForgeTableRenderer.class.php
   trunk/plugins/scrum/plugins/scrum/include/Sprint.class.php
   trunk/plugins/scrum/plugins/scrum/include/SprintDataProvider.class.php
   trunk/plugins/scrum/plugins/scrum/include/Table.class.php
   trunk/plugins/scrum/plugins/scrum/include/interfaces/
   trunk/plugins/scrum/plugins/scrum/include/interfaces/IDataProvider.php
   trunk/plugins/scrum/plugins/scrum/include/interfaces/IFactory.php
   trunk/plugins/scrum/plugins/scrum/include/interfaces/IPersistent.php
   trunk/plugins/scrum/plugins/scrum/include/interfaces/ITableRenderer.php
   trunk/plugins/scrum/plugins/scrum/www/
   trunk/plugins/scrum/www/plugins/
   trunk/plugins/scrum/www/plugins/scrum/
   trunk/plugins/scrum/www/plugins/scrum/scrum.php
Log:
Initial commit. Added base Structure.

Added: trunk/plugins/scrum/plugins/scrum/common/ScrumPlugin.class.php
===================================================================
--- trunk/plugins/scrum/plugins/scrum/common/ScrumPlugin.class.php	                        (rev 0)
+++ trunk/plugins/scrum/plugins/scrum/common/ScrumPlugin.class.php	2011-05-13 14:37:08 UTC (rev 17231)
@@ -0,0 +1,60 @@
+<?php
+
+class ScrumPlugin extends Plugin {
+
+    public function ScrumPlugin() {
+        $this->Plugin();
+        $this->name = "scrum";
+        $this->text = "Scrum"; // To show in the tabs, use...
+        $this->hooks[] = "groupmenu_scm"; // To put into the project tabs
+        $this->hooks[] = "groupisactivecheckbox"; //Put it in the toos area
+        $this->hooks[] = "groupisactivecheckboxpost";
+        
+        $group_id = getIntFromRequest('group_id');
+    }
+
+    public function CallHook($hookname, &$params) {
+
+        $group_id = 0;
+
+        if (isset($params['group_id'])) {
+            $group_id = $params['group_id'];
+        } elseif (isset($params['group'])) {
+            $group_id = $params['group'];
+        } else {
+            $group_id = null;
+        }
+
+        //Get the plugin into the project related menu.
+        if ($hookname == "groupmenu_scm") {
+            $project = group_get_object($group_id);
+            if (!$project || !is_object($project)) {
+                return;
+            }
+            if ($project->isError()) {
+                return;
+            }
+            if (!$project->isProject()) {
+                return;
+            }
+            if ($project->usesPlugin($this->name)) {
+                $params['TITLES'][] = $this->text;
+                $params['DIRS'][] = util_make_url("/plugins/scrum/scrum.php?group_id=$group_id&view=home");
+                $params['ADMIN'][] = '';
+            }
+            (($params['toptab'] == $this->name) ? $params['selected'] = (count($params['TITLES']) - 1) : '' );
+        } elseif ($hookname == "groupisactivecheckboxpost") {
+            // this code actually activates/deactivates the plugin after the form was submitted in the project edit public info page
+            $group = group_get_object($group_id);
+            $use_mediawikiplugin = getStringFromRequest('use_scrum');
+
+            if ($use_mediawikiplugin == 1) {
+                $group->setPluginUse($this->name);
+            } else {
+                $group->setPluginUse($this->name, false);
+            }
+        }
+    }
+}
+
+?>

Added: trunk/plugins/scrum/plugins/scrum/common/scrum-init.php
===================================================================
--- trunk/plugins/scrum/plugins/scrum/common/scrum-init.php	                        (rev 0)
+++ trunk/plugins/scrum/plugins/scrum/common/scrum-init.php	2011-05-13 14:37:08 UTC (rev 17231)
@@ -0,0 +1,17 @@
+<?php
+
+global $gfplugins;
+require_once $gfplugins.'scrum/common/ScrumPlugin.class.php';
+require_once $gfplugins.'scrum/include/interfaces/IDataProvider.php';
+require_once $gfplugins.'scrum/include/interfaces/ITableRenderer.php';
+require_once $gfplugins.'scrum/include/interfaces/IFactory.php';
+require_once $gfplugins.'scrum/include/Sprint.class.php';
+require_once $gfplugins.'scrum/include/SprintDataProvider.class.php';
+require_once $gfplugins.'scrum/include/Table.class.php';
+require_once $gfplugins.'scrum/include/FusionForgeTableRenderer.class.php';
+
+$scrumPluginObject = new ScrumPlugin;
+
+register_plugin ($scrumPluginObject);
+
+?>

Added: trunk/plugins/scrum/plugins/scrum/database/scrum_migrate.sql
===================================================================
--- trunk/plugins/scrum/plugins/scrum/database/scrum_migrate.sql	                        (rev 0)
+++ trunk/plugins/scrum/plugins/scrum/database/scrum_migrate.sql	2011-05-13 14:37:08 UTC (rev 17231)
@@ -0,0 +1,14 @@
+-- Migration script for SCRUM plugin. Run this while installing to add
+-- the needed tables. It also adds the standard widget layout for the
+-- scrum plugin home page (Summary).
+
+--Stores data for one Sprint.
+CREATE TABLE plugin_scrum_sprint ( sprintId integer CONSTRAINT pk_plugin_scrum_sprint PRIMARY KEY,
+                                   sprintName char(32) NOT NULL,
+                                   sprintFrom date NOT NULL,
+                                   sprintTo date NOT NULL,
+                                   sprintGroup integer NOT NULL REFERENCES project );
+
+--Build Relation to tasks.
+CREATE TABLE plugin_scrum_sprint_has_task ( sprintId integer NOT NULL REFERENCES plugin_scrum_sprint(sprintId),
+                                            taskId integer NOT NULL REFERENCES project_task(project_task_id));
\ No newline at end of file

Added: trunk/plugins/scrum/plugins/scrum/include/FusionForgeTableRenderer.class.php
===================================================================
--- trunk/plugins/scrum/plugins/scrum/include/FusionForgeTableRenderer.class.php	                        (rev 0)
+++ trunk/plugins/scrum/plugins/scrum/include/FusionForgeTableRenderer.class.php	2011-05-13 14:37:08 UTC (rev 17231)
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Autor: Mike Esser
+ * File:  FusionForgeTableRenderer.class.php
+ * 
+ * Implements a Table Renderer for fusion forge tables.
+ * 
+ * Copyright (C) 2011 tarent GmbH
+ */
+
+class FusionForgeTableRenderer implements ITableRenderer {
+    private $provider;
+    
+    public function RenderTableTop() {
+        $titles = $this->provider->GetColumns();
+        
+        echo $GLOBALS['HTML']->listTableTop($titles);
+    }
+    
+    public function RenderRow($rowIndex) {
+        echo '<tr>';
+        echo '<td><a href="#">'.$this->provider->Get($rowIndex, 0).'</a></td>';
+        echo '<td><a href="#">'.$this->provider->Get($rowIndex, 1).'</a></td>';
+        echo '<td><a href="#">'.$this->provider->Get($rowIndex, 2).'</a></td>';
+        echo '<td><a href="#">'.$this->provider->Get($rowIndex, 3).'</a></td>';
+        echo '</tr>';
+    }
+    
+    public function RenderTableBottom() {
+        echo $GLOBALS['HTML']->listTableBottom();
+    }
+    
+    public function SetDataProvider($provider) {
+        $this->provider = $provider;
+    }
+}
+
+?>

Added: trunk/plugins/scrum/plugins/scrum/include/Sprint.class.php
===================================================================
--- trunk/plugins/scrum/plugins/scrum/include/Sprint.class.php	                        (rev 0)
+++ trunk/plugins/scrum/plugins/scrum/include/Sprint.class.php	2011-05-13 14:37:08 UTC (rev 17231)
@@ -0,0 +1,121 @@
+<?php
+
+/**
+ * Autor: Mike Esser
+ * File:  Sprint.class.php
+ * 
+ * Represents a single Sprint object in the Database. Impelments IPersitent.
+ * 
+ * Copyright (C) 2011 tarent GmbH
+ */
+
+require_once('interfaces//IPersistent.php');
+
+class Sprint extends Error implements IPersistent {
+    protected $id;
+    protected $from;
+    protected $to;
+    protected $name;
+    protected $tasks;
+    
+    public function __ctor() {
+        $this->id    = 0;
+        $this->from  = 0;
+        $this->name  = "Not set";
+        $this->to    = 0;
+        $this->tasks = array();
+    }
+    
+    public function Initialize($id, $name, $from, $to, $tasks) {
+        $this->id    = $id;
+        $this->name  = $name;
+        $this->from  = $from;
+        $this->to    = $to;
+        $this->tasks = $tasks;
+    }
+    
+    public function Save() {
+        $sql = "UPDATE plugin_scrum_sprint SET sprintFrom = $1, sprintTo = $2, sprintName=$3 WHERE sprintId = $4";
+        
+        $result = db_query_params($sql,
+                                  array($this->from,
+                                  $this->to,
+                                  $this->name,
+                                  $this->id),
+                                  1, 0);
+        
+        if(db_error()) {
+            $this->setError('Database Error: '.db_error().$sql);
+            return false;
+        }
+    }
+    
+    public function Load() {
+        $sql = "SELECT * FROM plugin_scrum_sprint WHERE sprintId = $1";
+        
+        $result = db_query_params($sql,
+                                  array($this->id),
+                                  1, 0);
+        
+        if(db_numrows($result) < 1) {
+            return false;
+        }
+        
+        $data = db_fetch_array($result);
+        
+        $this->name = $data['sprintname'];
+        $this->from = $data['sprintfrom'];
+        $this->to   = $data['sprintto'];
+        
+        //Get all related tasks.
+        $sql = "SELECT * FROM plugin_scrum_sprint_has_task WHERE sprintId = $1";
+    }
+    
+    public function Delete() {
+        
+    }
+    public function SetId($val) {
+        $this->id = $val;
+    }
+    
+    public function GetId() {
+        return $this->id;
+    }
+    
+    public function SetName($val) {
+        $this->name = $val;
+    }
+    
+    public function GetName() {
+        return $this->name;
+    }
+    
+    public function SetFrom($val) {
+        $this->from = $val;
+    }
+    
+    public function GetFrom() {
+        return $this->from;
+    }
+    
+    public function SetTo($val) {
+        $this->to = $val;
+    }
+    
+    public function GetTo() {
+        return $this->to;
+    }
+    
+    /**
+     *
+     * @param type $val an array with task Objects.
+     */
+    public function SetTasks($val) {
+        $this->tasks = $val;
+    }
+    
+    public function GetTasks() {
+        return $this->tasks;
+    }
+}
+?>

Added: trunk/plugins/scrum/plugins/scrum/include/SprintDataProvider.class.php
===================================================================
--- trunk/plugins/scrum/plugins/scrum/include/SprintDataProvider.class.php	                        (rev 0)
+++ trunk/plugins/scrum/plugins/scrum/include/SprintDataProvider.class.php	2011-05-13 14:37:08 UTC (rev 17231)
@@ -0,0 +1,69 @@
+<?php
+
+/**
+ * Autor: Mike Esser
+ * File:  SprintDataProvider.class.php
+ * 
+ * Dataprovider for Sprint tables.
+ * 
+ * Copyright (C) 2011 tarent GmbH
+ */
+
+class SprintDataProvider implements IDataProvider {
+    private $columns = array('Name', 'Started', 'Due Date', 'Completed');
+    
+    private $data;
+    
+    public function GetColumns() {
+        return $this->columns;
+    }
+    
+    public function Get($rowIndex, $colIndex) {
+        switch($colIndex) {
+            case 0:
+                return $this->data[$rowIndex]->GetName();
+                break;
+            case 1:
+                return $this->data[$rowIndex]->GetFrom();
+                break;
+            case 2:
+                return $this->data[$rowIndex]->GetTo();
+                break;
+            case 3:
+                return "PercentValue";
+                break;
+            default:
+                return "Invalid column index";
+                break;
+        }
+    }
+    
+    public function GetNumCols() {
+        return count(SprintDataProvider::$columns);
+    }
+    
+    public function GetNumRows() {
+        return count($this->data);
+    }
+    
+    /**
+     * Fills the data based on an SQL Database query result.
+     *
+     * @param type $dataset result handle of database query.
+     */
+    public function SetDataFromDB($dataset) {
+        $this->data = $dataset;
+    }
+    
+    /**
+     * KILL IN RELEASE!
+     * DEBUG FUNCTION TO FILL DATA PROVIDER WITH TEST DATA!
+     */
+    public function FillTestData() {
+        for($i = 0; $i < 20; $i++) {
+            $this->data[$i] = new Sprint();
+            $this->data[$i]->Initialize($i, "TestSprint $i", "foo", "bar", null);
+        }
+    }
+}
+?>

Added: trunk/plugins/scrum/plugins/scrum/include/Table.class.php
===================================================================
--- trunk/plugins/scrum/plugins/scrum/include/Table.class.php	                        (rev 0)
+++ trunk/plugins/scrum/plugins/scrum/include/Table.class.php	2011-05-13 14:37:08 UTC (rev 17231)
@@ -0,0 +1,39 @@
+<?php
+
+/**
+ * Autor: Mike Esser
+ * File:  Table.class.php
+ * 
+ * Table class which provides all neccessarry table data.
+ * 
+ * Copyright (C) 2011 tarent GmbH
+ */
+
+class Table {
+    protected $dataProvider;
+    protected $tableRenderer;
+    protected $maxRows;
+    
+    public function RenderTable() {
+        $this->tableRenderer->SetDataProvider($this->dataProvider);
+        $this->tableRenderer->RenderTableTop();
+        
+        for($i = 0; $i < $this->dataProvider->GetNumRows(); $i++) {
+            $this->tableRenderer->RenderRow($i);
+        }
+        
+        $this->tableRenderer->RenderTableBottom();
+    }
+    public function SetTableRenderer($renderer) {    
+        $this->tableRenderer = $renderer;
+    }
+    
+    public function SetDataProvider($provider) {
+        $this->dataProvider = $provider;
+    }
+    
+    public function SetMaxRows($maxRows) {
+        $this->maxRows = $maxRows;
+    }
+}
+?>

Added: trunk/plugins/scrum/plugins/scrum/include/interfaces/IDataProvider.php
===================================================================
--- trunk/plugins/scrum/plugins/scrum/include/interfaces/IDataProvider.php	                        (rev 0)
+++ trunk/plugins/scrum/plugins/scrum/include/interfaces/IDataProvider.php	2011-05-13 14:37:08 UTC (rev 17231)
@@ -0,0 +1,41 @@
+<?php
+
+/**
+ * Autor: Mike Esser
+ * File:  IFactory.php
+ * 
+ * The Dataprovider interface defines methods which have to be implemented
+ * by the Developer. IDataProvider objects are used by Table classes to fill
+ * in the table data.
+ * 
+ * Copyright (C) 2011 tarent GmbH
+ */
+
+interface IDataProvider {
+    /**
+     * @return array Returns a string array with the Column names.
+     */
+    public function GetColumns();
+    /**
+     * Used by a Table class to get specific data.
+     * 
+     * @param $rowIndex The row index
+     * @param $colIndex The col index
+     * 
+     * @return undefined Returns the data for the given row/col
+     */
+    public function Get($rowIndex, $colIndex);
+    /**
+     * Returns the number of Rows (Datasets)
+     * 
+     * @return int number of datasets
+     */
+    public function GetNumRows();
+    /**
+     * Returns the number of Columns
+     * 
+     * @return int number of columns
+     */
+    public function GetNumCols();
+}
+?>

Added: trunk/plugins/scrum/plugins/scrum/include/interfaces/IFactory.php
===================================================================
--- trunk/plugins/scrum/plugins/scrum/include/interfaces/IFactory.php	                        (rev 0)
+++ trunk/plugins/scrum/plugins/scrum/include/interfaces/IFactory.php	2011-05-13 14:37:08 UTC (rev 17231)
@@ -0,0 +1,14 @@
+<?php
+/**
+ * Autor: Mike Esser
+ * File:  IFactory.php
+ * 
+ * Interface for Factory classes. Factory classes can create Objects.
+ * 
+ * Copyright (C) 2011 tarent GmbH
+ */
+
+interface IFactory {
+    public function CreateObject($params);
+}
+?>

Added: trunk/plugins/scrum/plugins/scrum/include/interfaces/IPersistent.php
===================================================================
--- trunk/plugins/scrum/plugins/scrum/include/interfaces/IPersistent.php	                        (rev 0)
+++ trunk/plugins/scrum/plugins/scrum/include/interfaces/IPersistent.php	2011-05-13 14:37:08 UTC (rev 17231)
@@ -0,0 +1,29 @@
+<?php
+
+/**
+ * Autor: Mike Esser
+ * File:  IPersistent.php
+ * 
+ * This file supplies an Interface that is used to describe objects
+ * saved in the Database. This objects are normaly generated by an Factory
+ * class.
+ * 
+ * Copyright (C) 2011 tarent GmbH
+ */
+
+interface IPersistent {
+    /**
+     * Handles the Save logic for this object e.g. An SQL command.
+     */
+    public function Save();
+    /**
+     * Loads an object based on it's member variables.
+     */
+    public function Load();
+    /**
+     * Deletes this object.
+     */
+    public function Delete();
+}
+
+?>

Added: trunk/plugins/scrum/plugins/scrum/include/interfaces/ITableRenderer.php
===================================================================
--- trunk/plugins/scrum/plugins/scrum/include/interfaces/ITableRenderer.php	                        (rev 0)
+++ trunk/plugins/scrum/plugins/scrum/include/interfaces/ITableRenderer.php	2011-05-13 14:37:08 UTC (rev 17231)
@@ -0,0 +1,19 @@
+<?php
+
+/**
+ * Autor: Mike Esser
+ * File:  ITableRenderer.php
+ * 
+ * Use this interface to provide different table renderers. The use of this
+ * interface increases maintainability.
+ * 
+ * Copyright (C) 2011 tarent GmbH
+ */
+
+interface ITableRenderer {
+    public function SetDataProvider($provider);
+    public function RenderTableTop();
+    public function RenderRow($rowIndex);
+    public function RenderTableBottom();
+}
+?>

Added: trunk/plugins/scrum/www/plugins/scrum/scrum.php
===================================================================
--- trunk/plugins/scrum/www/plugins/scrum/scrum.php	                        (rev 0)
+++ trunk/plugins/scrum/www/plugins/scrum/scrum.php	2011-05-13 14:37:08 UTC (rev 17231)
@@ -0,0 +1,42 @@
+<?php
+
+require_once("../../env.inc.php");
+require_once $gfcommon . 'include/pre.php';
+
+$group_id = getIntFromRequest('group_id');
+$pluginname = 'scrum';
+
+$group = group_get_object($group_id);
+if (!$group) {
+    exit_error("Invalid Project", "Invalid Project");
+}
+
+if (!$group->usesPlugin($pluginname)) {
+    exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
+}
+
+$params = array();
+$params['toptab'] = $pluginname;
+$params['group'] = $group_id;
+$params['title'] = _('SCRUM');
+$params['pagename'] = $pluginname;
+$params['sectionvals'] = array($group->getPublicName());
+
+site_project_header($params);
+
+echo "NOTE: This is a Development Snapshot! Currently the Focus is on data management and data algorithms. UI is designed in a later point
+      of development. If you have questions or suggestions feel free to Contact me (Mike Esser => messer).<br /><br />";
+
+$provider = new SprintDataProvider();
+
+$table = new Table();
+
+$provider->FillTestData();
+
+$table->SetDataProvider($provider);
+$table->SetTableRenderer(new FusionForgeTableRenderer());
+
+$table->RenderTable();
+
+$HTML->footer(array());
+?>



More information about the evolvis-commits mailing list