[evolvis-commits] r18253: rewrite in EvolvisTable to make legible

mirabilos at evolvis.org mirabilos at evolvis.org
Thu Apr 5 23:02:24 CEST 2012


Author: mirabilos
Date: 2012-04-05 23:02:24 +0200 (Thu, 05 Apr 2012)
New Revision: 18253

Modified:
   trunk/gforge_base/evolvisforge-5.1/src/www/tracker/admin/form-workflow.php
Log:
rewrite in EvolvisTable to make legible


Modified: trunk/gforge_base/evolvisforge-5.1/src/www/tracker/admin/form-workflow.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/src/www/tracker/admin/form-workflow.php	2012-04-05 21:02:20 UTC (rev 18252)
+++ trunk/gforge_base/evolvisforge-5.1/src/www/tracker/admin/form-workflow.php	2012-04-05 21:02:24 UTC (rev 18253)
@@ -1,9 +1,11 @@
 <?php
-/**
- * Update Artifact Type Form
+/*-
+ * FusionForge tracker form to define a workflow
  *
  * Copyright 2010, FusionForge Team
- * http://fusionforge.org
+ * Copyright © 2012
+ *	Thorsten Glaser <t.glaser at tarent.de>
+ * All rights reserved.
  *
  * This file is part of FusionForge. FusionForge is free software;
  * you can redistribute it and/or modify it under the terms of the
@@ -21,108 +23,139 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-require_once('common/tracker/ArtifactWorkflow.class.php');
+require_once $gfcommon.'include/EvolvisTable.class.php';
+require_once $gfcommon.'tracker/ArtifactWorkflow.class.php';
 
 $has_error = false;
 $efarr = $ath->getExtraFields(array(ARTIFACT_EXTRAFIELDTYPE_STATUS));
 if (count($efarr) === 0) {
 	$has_error = true;
-   	$error_msg .= _('To create a workflow, you need first to create a custom field of type \'Status\'.');
+	$error_msg .= _('To create a workflow, you need first to create a custom field of type \'Status\'.');
 } elseif (count($efarr) !== 1) {
-	// Internal error.
 	$has_error = true;
-	$error_msg .= _('Internal error: Illegal number of status fields (WKFL01).');
+	$error_msg .= _('Internal error: Illegal number of status fields (only one allowed).');
 }
 
-$ath->adminHeader(array ('title'=> _('Configure workflow'),'pagename'=>'tracker_admin_customize_liste','titlevals'=>array($ath->getName())));
+$ath->adminHeader(array(
+	'title' => _('Configure workflow'),
+	'pagename' => 'tracker_admin_customize_liste',
+	'titlevals' => array($ath->getName()),
+    ));
 
-/*
-	List of possible user built Selection Boxes for an ArtifactType
-*/
-if (!$has_error) {
-    		
-  	$keys=array_keys($efarr);
-   	$field_id = $keys[0];
-   	$field_name = $efarr[$field_id]['field_name'];
+if ($has_error) {
+	echo html_e('p', array(),
+	    util_html_encode(_('Cannot continue due to an error.')));
+	$ath->footer(array());
+	exit(0);
+}
 
-   	$atw = new ArtifactWorkflow($ath, $field_id);
+$keys = array_keys($efarr);
+$field_id = $keys[0];
+$field_name = $efarr[$field_id]['field_name'];
 
-	$elearray = $ath->getExtraFieldElements($field_id);
-	$states = $elearray;
+$atw = new ArtifactWorkflow($ath, $field_id);
 
-?>
-	    	
-   	<h2><?php printf(_('Allowed initial values for the %1$s field'), $field_name) ?></h2>
-	<form action="<?php echo getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&atid='.$ath->getID(); ?>" method="post">
-	<input type="hidden" name="field_id" value="<?php echo $field_id ?>" />
-	<input type="hidden" name="workflow" value="1" />
-   	
-<?php 
-	$from = _('From').' ';
-	$to = _('To').' ';
-	$init = _('Initial values').' ';
+$elearray = $ath->getExtraFieldElements($field_id);
+$states = $elearray;
 
-	$title_arr=array();
-	$title_arr[]=_('From Value');
-	foreach ($elearray as $status) {
-		$title_arr[]=$status['element_name'];		
-	}
-	echo $GLOBALS['HTML']->listTableTop($title_arr);
-	echo "\n";
+echo html_e('h2', array(),
+    util_html_encode(sprintf(_('Allowed initial values for the %1$s field'),
+    $field_name))) . html_eo('form', array(
+	'action' => util_gethref(false, array(
+		'group_id' => $group_id,
+		'atid' => $ath->getID(),
+	    ), false),
+	'method' => 'post',
+    )) . html_e('input', array(
+	'type' => 'hidden',
+	'name' => 'field_id',
+	'value' => $field_id,
+    )) . html_e('input', array(
+	'type' => 'hidden',
+	'name' => 'workflow',
+	'value' => 1,
+    ));
 
-	// Special treatement for the initial value (in the Submit form).
-	echo '<tr id="initval"><th style="text-align:left">'.$init.'</th>'."\n";
-	$next = $atw->getNextNodes('100');
+/* cache gettext lookups */
+$from = _('From').' ';
+$to = _('To').' ';
+
+$titles = array('');
+foreach ($elearray as $status) {
+	$titles[] = $status['element_name'];
+}
+$e = new EvolvisTable($titles);
+
+$r = $e->tr(array(
+	'id' => 'initval',
+	'style' => 'text-align:left;',
+    ));
+$r->th()->set(_('Initial values'));
+$next = $atw->getNextNodes('100');
+foreach ($states as $s) {
+	$r->td()->setraw(html_e('input', array(
+		'type' => 'checkbox',
+		'name' => 'wk[100][' . $s['element_id'] . ']',
+		'checked' => (in_array($s['element_id'], $next) ? 'checked' :
+		    false),
+	    )) . ' ' . html_image('spacer.gif', 20, 20));
+}
+
+echo $e->emit() . html_e('h2', array(),
+    util_html_encode(sprintf(_('Allowed transitions for the %1$s field'),
+    $field_name)));
+
+$count = count($titles);
+for ($i = 1; $i < $count; ++$i) {
+	$titles[$i] = $to . $titles[$i];
+}
+$e = new EvolvisTable($titles);
+
+$i = 1;
+foreach ($elearray as $status) {
+	$r = $e->tr(array(
+		'id' => ('configuring-' . $i++),
+		'style' => 'text-align:left;',
+	    ));
+	$r->th()->set($from . $status['element_name']);
+	$next = $atw->getNextNodes($status['element_id']);
 	foreach ($states as $s) {
-		$name = 'wk[100]['. $s['element_id'].']';
-		$value = in_array($s['element_id'], $next)? ' checked="checked"' : '';
-		$str = '<input type="checkbox" name="'.$name.'"'.$value.' />';
-				$str .= ' '.html_image('spacer.gif', 20, 20);
-		echo '<td align="center">'.$str.'</td>'."\n";
+		$r->td()->setraw($status['element_id'] === $s['element_id'] ?
+		    html_e('input', array(
+			'type' => 'checkbox',
+			'checked' => 'checked',
+			'disabled' => 'disabled',
+		    )) : (html_e('input', array(
+				'type' => 'checkbox',
+				'name' => 'wk[' . $status['element_id'] .
+				    '][' . $s['element_id'] . ']',
+				'checked' => (in_array($s['element_id'], $next) ?
+				    'checked' : false),
+			    )) . ' ' . (in_array($s['element_id'], $next) ?
+			    html_e('a', array(
+				'href' => util_gethref(false, array(
+					'group_id' => $group_id,
+					'atid' => $ath->getID(),
+					'workflow_roles' => 1,
+					'from' => $status['element_id'],
+					'next' => $s['element_id'],
+				    ), false),
+				'title' => _('Edit roles'),
+			    ), html_image('ic/acl_roles20.png', 20, 20, array(
+				'alt' => _('Edit roles'),
+			    ))) : html_image('spacer.gif', 20, 20))));
 	}
-	echo '</tr>'."\n";
-	echo $GLOBALS['HTML']->listTableBottom();
+}
 
-	$count=count($title_arr);
-	$totitle_arr = array();
-	for ($i=0; $i<$count; $i++) {
-		$totitle_arr[] = $title_arr[$i]? $to.$title_arr[$i] : '';
-	}
-	echo $GLOBALS['HTML']->listTableTop($totitle_arr);
-	
-	$i=1;
-	foreach ($elearray as $status) {
-		echo '<tr id="configuring-'.$i++.'"><th style="text-align:left">'.$from.$status['element_name'].'</th>'."\n";
-		$next = $atw->getNextNodes($status['element_id']);
-		foreach ($states as $s) {
-			if ($status['element_id'] !== $s['element_id']) {
-				$name = 'wk['.$status['element_id'].']['. $s['element_id'].']';
-				$value = in_array($s['element_id'], $next)? ' checked="checked"' : '';
-				$str = '<input type="checkbox" name="'.$name.'"'.$value.' />';
-				if ($value) {
-					$url = getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&atid='.$ath->getID().'&workflow_roles=1&from='.$status['element_id'].'&next='.$s['element_id'];
-					$str .= ' <a href="'.$url.'" title="Edit roles">'.html_image('ic/acl_roles20.png', 20, 20, array('alt'=>'Edit Roles')).'</a>';
-				} else {
-							$str .= ' '.html_image('spacer.gif', 20, 20);
-				}
-			} else {
-				$str = '<input type="checkbox" checked="checked" disabled="disabled" />';
-						$str .= ' '.html_image('spacer.gif', 20, 20);
-			}
-			echo '<td align="center">'.$str.'</td>'."\n";
-		}
-		echo '</tr>'."\n";
-	}
-	echo $GLOBALS['HTML']->listTableBottom();
+echo $e->emit() . html_e('div', array(
+	'class' => 'tips',
+    ), sprintf(_('Tip: Click on %s to configure allowed roles for a transition (all by default).'),
+    html_image('ic/acl_roles20.png', 20, 20, array(
+	'alt' => _('Edit roles'),
+    )))) . html_e('p', array(), html_e('input', array(
+	'type' => 'submit',
+	'name' => 'post_changes',
+	'value' => _('Submit'),
+    ))) . '</form>';
 
-?>
-<div class="tips">Tip: Click on <?php echo html_image('ic/acl_roles20.png', 20, 20, array('alt'=> _('Edit Roles'))) ?> to configure allowed roles for a transition (all by default).</div>	
-<p>
-<input type="submit" name="post_changes" value="<?php echo _('Submit') ?>" /></p>
-</form>
-<?php
-}
-
 $ath->footer(array());
-
-?>



More information about the evolvis-commits mailing list