+function printfl()
+{
+ $args = func_get_args();
+ $args[0] .= "\n";
+ call_user_func_array('printf', $args);
+}
+
+function Faq_Listador($ObjetosAListar,$link = '', $cant = 2)
+{
+ // Calculo posiciones
+ $total = count($ObjetosAListar);
+ if (!$total)
+ {
+ echo error('No se encontraron Items');
+ return;
+ }
+ $from = intval(@$_GET["lista_from"]);
+ $c = min($total - $from, $cant);
+
+ while ( $c-- )
+ {
+ if ( array_key_exists($from, $ObjetosAListar) )
+ {
+ $obj = $ObjetosAListar[$from++];
+ $obj->toHTML();
+ }
+ }
+
+ $pags = ceil($total / $cant);
+ if ($pags == 1) return;
+ printfl('<table summary="Paginador" border="0"><tr>');
+ // Arrastro query string, si corresponde
+ if ( isset($_SERVER['QUERY_STRING'] ) )
+ {
+ $query = str_replace('&', '&', $_SERVER['QUERY_STRING']);
+ }
+ else
+ {
+ $query = '';
+ }
+ if (($pos = strpos($query, '&lista_from=')) !== false)
+ {
+ if ($pos) $query = substr($query, 0, $pos);
+ else $query = '';
+ }
+ if (($pos = strpos($query, 'lista_from=')) !== false)
+ {
+ if ($pos) $query = substr($query, 0, $pos );
+ else $query = '';
+ }
+ for ($i = 0; $i < $pags; ++$i)
+ {
+ $from = $i * $cant;
+ $q = $query ? "$query&lista_from=$from" : "lista_from=$from";
+ printfl('<td><a href="%s?%s">%s</a></td>', $link, $q, $i + 1);
+ }
+ printfl('</tr></table>');
+}