Author: suokko
Date: Wed Aug 13 00:27:58 2008
New Revision: 28523
URL: http://svn.gna.org/viewcvs/wesnoth?rev=28523&view=rev
Log:
Made build hitory paging work
Modified:
trunk/utils/tests/htdocs/styles/unit_test.css
trunk/utils/tests/include/Build.php
trunk/utils/tests/include/ParameterValidator.php
trunk/utils/tests/smarty_workdir/templates/build_history.tpl
trunk/utils/tests/smarty_workdir/templates/paginate.tpl
Modified: trunk/utils/tests/htdocs/styles/unit_test.css
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/tests/htdocs/styles/unit_test.css?rev=28523&r1=28522&r2=28523&view=diff
==============================================================================
--- trunk/utils/tests/htdocs/styles/unit_test.css (original)
+++ trunk/utils/tests/htdocs/styles/unit_test.css Wed Aug 13 00:27:58 2008
@@ -71,3 +71,43 @@
.test_error td {
text-align: center;
}
+
+table.build_history {
+ width: auto;
+ max-width:60em;
+ min-width:10em;
+ margin: auto auto auto auto;
+}
+
+div.paginate {
+ color: #225599;
+ font-weight: bold;
+ text-align: right;
+ margin-left: auto;
+ margin-right: 0;
+ font-size: 0.8em;
+}
+
+.paginate a {
+ color: #225599;
+ font-weight: bold;
+ text-decoration: none;
+}
+
+.paginate a:hoover {
+ text-decoration: underline;
+ font-weight: bold;
+ color: #225599;
+}
+
+.paginate .active {
+ color: #104060;
+}
+
+.paginate a.hidden {
+ visibility: hidden;
+}
+
+/*.paginate span {
+ color: #225599;
+}*/
Modified: trunk/utils/tests/include/Build.php
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/tests/include/Build.php?rev=28523&r1=28522&r2=28523&view=diff
==============================================================================
--- trunk/utils/tests/include/Build.php (original)
+++ trunk/utils/tests/include/Build.php Wed Aug 13 00:27:58 2008
@@ -257,14 +257,38 @@
public static function getVisibleBuilds(ParameterValidator $user_params)
{
$ret = array();
+ $builds_per_page = 6; // TODO: get from config
$ret['paginate']['number_of_pages'] =
self::getNumberOfVisiblePages($builds_per_page);
$page = $user_params->getInt('page', 1);
- $builds_per_page = 15; // TODO: get from config
if ($page < 0)
$page = 1;
- if ($page > $get['number_of_pages'])
- $page = $get['number_of_pages'];
+ if ($page > $ret['paginate']['number_of_pages'])
+ $page = $ret['paginate']['number_of_pages'];
+
+ $ret['paginate']['page'] = $page;
+
+ $ret['paginate']['link'] = 'build_history.php?page=';
+ $visible = 5;
+ $visible_minus = 0;
+ $start = $page - floor(($visible-1)/2);
+ if ($start <= 1)
+ {
+ $start = 1;
+ $visible_minus = 1;
+ }
+ $last = $start + $visible + $visible_minus;
+ if ($last >= $ret['paginate']['number_of_pages'] + 1)
+ {
+ $last = $ret['paginate']['number_of_pages'] + 1;
+ $start = $last - $visible - 1;
+ if ($start < 1)
+ $start = 1;
+ }
+ $ret['paginate']['first_page'] = $start;
+ $ret['paginate']['last_page'] = $last;
+ $ret['paginate']['visible'] = $last - $start;
+
$ret['builds'] = array();
$builds = self::fetchVisibleBuilds($page, $builds_per_page);
@@ -273,7 +297,8 @@
$ret['builds'][] = $build->getBuildStats();
}
- $ret['paginate']['page'] = $page;
+
+
return $ret;
}
Modified: trunk/utils/tests/include/ParameterValidator.php
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/tests/include/ParameterValidator.php?rev=28523&r1=28522&r2=28523&view=diff
==============================================================================
--- trunk/utils/tests/include/ParameterValidator.php (original)
+++ trunk/utils/tests/include/ParameterValidator.php Wed Aug 13 00:27:58 2008
@@ -25,10 +25,10 @@
function getInt($name, $default)
{
- if (isset($user_params[$name])
- && is_numeric($user_params[$name]))
+ if (isset($this->user_params[$name])
+ && is_numeric($this->user_params[$name]))
{
- return (int)$user_params[$name];
+ return (int)$this->user_params[$name];
} else {
return $default;
}
Modified: trunk/utils/tests/smarty_workdir/templates/build_history.tpl
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/tests/smarty_workdir/templates/build_history.tpl?rev=28523&r1=28522&r2=28523&view=diff
==============================================================================
--- trunk/utils/tests/smarty_workdir/templates/build_history.tpl (original)
+++ trunk/utils/tests/smarty_workdir/templates/build_history.tpl Wed Aug 13
00:27:58 2008
@@ -1,4 +1,8 @@
<h3>Build history</h3>
+<table class="build_history">
+<tr><td>
{include file='paginate.tpl'}
{include file='build_list.tpl'}
{include file='paginate.tpl'}
+</td></tr>
+</table>
Modified: trunk/utils/tests/smarty_workdir/templates/paginate.tpl
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/tests/smarty_workdir/templates/paginate.tpl?rev=28523&r1=28522&r2=28523&view=diff
==============================================================================
--- trunk/utils/tests/smarty_workdir/templates/paginate.tpl (original)
+++ trunk/utils/tests/smarty_workdir/templates/paginate.tpl Wed Aug 13 00:27:58
2008
@@ -1,22 +1,58 @@
+{strip}
<div class="paginate">
-{if $paginate.page > 1}
-<a href="{$paginate.link}{$paginate.page-1}">Previous</a>
-{/if}
-{if $paginate.first_page > 1}
-<a href="{$paginate.link}1">1</a>
-{/if}
+{if $paginate.visible > 1}
+ {if $paginate.page > 1}
+ <a href="{$paginate.link}{$paginate.page-1}">
+ {else}
+ <span class="active">
+ {/if}
+ Previous
+ {if $paginate.page > 1}
+ </a>
+ {else}
+ </span>
+ {/if}
+
+ {if $paginate.first_page > 1}
+ <a href="{$paginate.link}1">1</a>
+ {if $paginate.first_page > 2}
+ ...
+ {else}
+ ,
+ {/if}
+ {/if}
-{section name=pager loop=$paginate.last_page start=$paginate.first_page
max=$paginate.visible}
-<a
href="{$paginate.link}{$smarty.section.pager.index}">{$smarty.section.pager.index}</a>
-{if $smarty.section.pager.last == false}
-,
-{/if}
-{/section}
+ {section name=pager loop=$paginate.last_page start=$paginate.first_page
max=$paginate.visible}
+ <a href="{$paginate.link}{$smarty.section.pager.index}"
+ {if $paginate.page == $smarty.section.pager.index}
+ class="active"
+ {/if}
+ >{$smarty.section.pager.index}</a>
+ {if $smarty.section.pager.last == false}
+ ,
+ {/if}
+ {/section}
-{if $paginate.last_page < $paginate.number_of_pages}
-<a
href="{$paginate.link}{$paginate.number_of_pages}">{$paginate.number_of_pages}</a>
-{/if}
-{if $paginate.page < $paginate.number_of_pages}
-<a href="{$paginate.link}{$paginate.page+1}">next</a>
+ {if $paginate.last_page <= $paginate.number_of_pages}
+ {if $paginate.last_page <= $paginate.number_of_pages - 1}
+ ...
+ {else}
+ ,
+ {/if}
+ <a
href="{$paginate.link}{$paginate.number_of_pages}">{$paginate.number_of_pages}</a>
+ {/if}
+
+ {if $paginate.page < $paginate.number_of_pages}
+ <a href="{$paginate.link}{$paginate.page+1}">
+ {else}
+ <span class="active">
+ {/if}
+ next
+ {if $paginate.page < $paginate.number_of_pages}
+ </a>
+ {else}
+ </span>
+ {/if}
{/if}
</div>
+{/strip}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits