[Fusionforge-commits] r10473 - in trunk/src/www: pm tracker

Roland Mas lolando at libremir.placard.fr.eu.org
Tue Sep 14 16:42:30 CEST 2010


Author: lolando
Date: 2010-09-14 16:42:30 +0200 (Tue, 14 Sep 2010)
New Revision: 10473

Modified:
   trunk/src/www/pm/browse_task.php
   trunk/src/www/tracker/browse.php
Log:
Merged from Evolvis: user preference for number of artifacts/tasks to display

Modified: trunk/src/www/pm/browse_task.php
===================================================================
--- trunk/src/www/pm/browse_task.php	2010-09-14 13:07:26 UTC (rev 10472)
+++ trunk/src/www/pm/browse_task.php	2010-09-14 14:42:30 UTC (rev 10473)
@@ -23,6 +23,9 @@
 $pagename = "pm_browse_custom";
 
 $offset = getIntFromRequest('offset');
+if ($offset < 0) {
+	$offset = 0 ;
+}
 $max_rows = getIntFromRequest('max_rows');
 
 $ptf = new ProjectTaskFactory($pg);
@@ -40,7 +43,24 @@
 $_category_id = getIntFromRequest('_category_id');
 $_view = getStringFromRequest('_view');
 
-$ptf->setup($offset,$_order,$max_rows,$set,$_assigned_to,$_status,$_category_id,$_view);
+$paging = 0;
+if (session_loggedin()) {
+	if (getStringFromRequest('setpaging')) {
+		/* store paging preferences */
+		$paging = getIntFromRequest('nres');
+		if (!$paging) {
+			$paging = 25;
+		}
+		$u->setPreference("paging", $paging);
+	} else
+		$paging = $u->getPreference("paging");
+}
+if (!$paging) {
+	$paging = 25;
+}
+
+
+$ptf->setup($offset,$_order,$paging,$set,$_assigned_to,$_status,$_category_id,$_view);
 if ($ptf->isError()) {
 	exit_error('Error',$ptf->getErrorMessage());
 }
@@ -142,7 +162,23 @@
 		<span class="important">'._('Add tasks using the link above').'</span>';
 	echo db_error();
 } else {
+	if (session_loggedin()) {
+		/* logged in users get configurable paging */
+		echo '<form action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&amp;group_project_id='.$pg->getID().'&amp;offset='.$offset.'" method="post">'."\n";
 
+	}
+	printf('<p>' . _('Displaying results %1$d‒%2$d.'), $offset + 1, $offset + $rows);
+
+	if (session_loggedin()) {
+		printf(' ' . _('Displaying %2$s results.') . "\n\t<input " .
+		       'type="submit" name="setpaging" value="%1$s" />' .
+		       "\n</p>\n</form>\n", _('Change'),
+		       html_build_select_box_from_array(array(
+								'10', '25', '50', '100', '1000'), 'nres', $paging, 1));
+	} else {
+		echo "</p>\n";
+	}	
+
 	//create a new $set string to be used for next/prev button
 	if ($set=='custom') {
 		$set .= '&amp;_assigned_to='.$_assigned_to.'&amp;_status='.$_status;
@@ -297,14 +333,14 @@
 	*/
 	echo '<tr><td colspan="2">';
 	if ($offset > 0) {
-		echo util_make_link ('/pm/task.php?func=browse&amp;group_project_id='.$group_project_id.'&amp;group_id='.$group_id.'&amp;offset='.($offset-50),'<strong>'._('previous 50').'<--</strong>');
+		echo util_make_link ('/pm/task.php?func=browse&amp;group_project_id='.$group_project_id.'&amp;group_id='.$group_id.'&amp;offset='.($offset-50),'<strong>← '._('previous').'</strong>');
 	} else {
 		echo '&nbsp;';
 	}
 	echo '</td><td>&nbsp;</td><td colspan="2">';
 
 	if ($rows==50) {
-		echo util_make_link ('/pm/task.php?func=browse&amp;group_project_id='.$group_project_id.'&amp;group_id='.$group_id.'&amp;offset='.($offset+50),'<strong>'._('next 50').' --></strong></a>');
+		echo util_make_link ('/pm/task.php?func=browse&amp;group_project_id='.$group_project_id.'&amp;group_id='.$group_id.'&amp;offset='.($offset+50),'<strong>'._('next').' →</strong></a>');
 	} else {
 		echo '&nbsp;';
 	}

Modified: trunk/src/www/tracker/browse.php
===================================================================
--- trunk/src/www/tracker/browse.php	2010-09-14 13:07:26 UTC (rev 10472)
+++ trunk/src/www/tracker/browse.php	2010-09-14 14:42:30 UTC (rev 10473)
@@ -17,8 +17,6 @@
 $query_id = getIntFromRequest('query_id');
 $start = getIntFromRequest('start');
 
-$pagelength = 25 ;
-
 //
 //	The browse page can be powered by a pre-saved query
 //	or by select boxes chosen by the user
@@ -29,9 +27,18 @@
 //	If the query_id = -1, unset the pref and use regular browse boxes
 //
 if (session_loggedin()) {
+	$u =& session_get_user();
+	if (getStringFromRequest('setpaging')) {
+		/* store paging preferences */
+		$paging = getIntFromRequest('nres');
+		if (!$paging) {
+			$paging = 25;
+		}
+		$u->setPreference("paging", $paging);
+	}
+	
 	if($query_id) {
 		if ($query_id == '-1') {
-			$u =& session_get_user();
 			$u->setPreference('art_query'.$ath->getID(),'');
 		} else {
 			$aq = new ArtifactQuery($ath,$query_id);
@@ -41,7 +48,6 @@
 			$aq->makeDefault();
 		}
 	} else {
-		$u =& session_get_user();
 		$query_id=$u->getPreference('art_query'.$ath->getID(),'');
 	}
 } elseif ($query_id) {
@@ -108,7 +114,7 @@
 	}
 }
 
-$af->setup($offset,$_sort_col,$_sort_ord,$pagelength,$set,$_assigned_to,$_status,$aux_extra_fields);
+$af->setup($offset,$_sort_col,$_sort_ord,$paging,$set,$_assigned_to,$_status,$aux_extra_fields);
 //
 //	These vals are sanitized and/or retrieved from ArtifactFactory stored settings
 //
@@ -207,6 +213,48 @@
 $changed_arr[]= 3600 * 24 * 14;// 2 week
 $changed_arr[]= 3600 * 24 * 30;// 1 month
 
+if ($art_arr && ($art_cnt = count($art_arr)) > 0) {
+	$focus = getIntFromRequest('focus');
+} else {
+	$art_cnt = 0;
+	$start = 0;
+	$focus = 0;
+}
+$paging = 0;
+if (session_loggedin()) {
+	/* logged in users get configurable paging */
+	$paging = $u->getPreference("paging");
+	echo '<form action="'. getStringFromServer('PHP_SELF') .'?group_id='.$group_id.'&amp;atid='.$ath->getID().'&amp;start='.
+		$start.'" method="post">'."\n";
+}
+if (!$paging) {
+	$paging = 25;
+}
+if ($art_cnt) {
+	if ($focus) {
+		for ($i = 0; $i < $art_cnt; ++$i)
+			if ($art_arr[$i]->getID() == $focus) {
+				$start = $i;
+				break;
+			}
+	}
+	$max = ($art_cnt > ($start + $paging)) ? ($start + $paging) : $art_cnt;
+} else {
+	$max = 0;
+}
+
+printf('<p>' . _('Displaying results %1$d‒%2$d out of %3$d total.'),
+       $start + 1, $max, $art_cnt);
+if (session_loggedin()) {
+	printf(' ' . _('Displaying %2$s results.') . "\n\t<input " .
+	       'type="submit" name="setpaging" value="%1$s" />' .
+	       "\n</p>\n</form>\n", _('Change'),
+	       html_build_select_box_from_array(array(
+							'10', '25', '50', '100', '1000'), 'nres', $paging, 1));
+} else {
+	echo "</p>\n";
+}
+
 /**
  *
  *	Show the free-form text submitted by the project admin
@@ -359,7 +407,7 @@
 echo '
 </div>';
 
-if ($art_arr && count($art_arr) > 0) {
+if ($art_cnt > 0) {
 
 	if ($query_id) {
 		$aq = new ArtifactQuery($ath,$query_id);
@@ -470,8 +518,6 @@
 
 	$then=(time()-$ath->getDuePeriod());
 
-	$max = ((count($art_arr) > ($start + $pagelength)) ? ($start+$pagelength) : count($art_arr) );
-//echo "max: $max";
 	for ($i=$start; $i<$max; $i++) {
  		$extra_data = $art_arr[$i]->getExtraFieldDataText();
 		echo '
@@ -544,35 +590,10 @@
 		echo '</tr>';
 	}
 
-	/*
-		Show extra rows for <-- Prev / Next -->
-	* /
-	//only show this if we're not using a power query
-	if ($af->max_rows > 0) {
-		if (($offset > 0) || ($rows >= 50)) {
-			echo '
-				<tr><td colspan="2">';
-			if ($offset > 0) {
-				echo '<a href="'.getStringFromServer('PHP_SELF').'?func=browse&amp;group_id='.$group_id.'&amp;atid='.$ath->getID().'&amp;set='.
-				$set.'&offset='.($offset-50).'"><strong><-- '._('Previous 50').'</strong></a>';
-			} else {
-				echo '&nbsp;';
-			}
-			echo '</td><td>&nbsp;</td><td colspan="2">';
-			if ($rows >= 50) {
-				echo '<a href="'.getStringFromServer('PHP_SELF').'?func=browse&amp;group_id='.$group_id.'&amp;atid='.$ath->getID().'&amp;set='.
-				$set.'&offset='.($offset+50).'"><strong>'._('Next 50').' --></strong></a>';
-			} else {
-				echo '&nbsp;';
-			}
-			echo '</td></tr>';
-		}
-	}
-	*/
 	echo $GLOBALS['HTML']->listTableBottom();
-	$pages = count($art_arr) / $pagelength;
-	$currentpage = intval($start / $pagelength);
-//echo "Item Count: ".count($arr)."Pages: $pages";
+	$pages = $art_cnt / $paging;
+	$currentpage = intval($start / $paging);
+
 	if ($pages >= 1) {
 		$skipped_pages=false;
 		for ($j=0; $j<$pages; $j++) {
@@ -587,10 +608,10 @@
 					$skipped_pages=false;
 				}
 			}
-			if ($j == $currentpage) {
+			if ($j * $paging == $start) {
 				echo '<strong>'.($j+1).'</strong>&nbsp;&nbsp;';
 			} else {
-				echo '<a href="'.getStringFromServer('PHP_SELF')."?func=browse&amp;group_id=".$group_id.'&amp;atid='.$ath->getID().'&amp;set='. $set.'&amp;start='.($j*$pagelength).'"><strong>'.($j+1).'</strong></a>&nbsp;&nbsp;';
+				echo '<a href="'.getStringFromServer('PHP_SELF')."?func=browse&amp;group_id=".$group_id.'&amp;atid='.$ath->getID().'&amp;set='. $set.'&amp;start='.($j*$paging).'"><strong>'.($j+1).'</strong></a>&nbsp;&nbsp;';
 			}
 		}
 	}




More information about the Fusionforge-commits mailing list