[turba] Letter "Pager"

Mike Bydalek mbydalek at zivix.com
Thu Mar 11 12:07:55 PST 2004


I have to apologize for sending the initial submission for this.  We 
have a few
versions of Horde running that we are constantly tweaking for customers.  I
accidentally grabbed this from a wrong installation, hence the older 
version of
Turba and the non-conforming coding (customers don't care =P).

Additionally, I forgot the template file, which is why you weren't getting the
A-Z listing at all.  Attached is a cleaned up version along with all the
necessary files.  Right now if you browse, it displays the A-Z, but if you
approve of the direction, I can add doing paging of alphabet (ie. A has 4
pages, but B has 1) to prevent a really long listing for 1 letter.

I didn't use $pager because I didn't really think it was necessary for the
alphabet, but if you think it should be that way, I can transfer it 
over and go
from there.

Regards,
Mike

Quoting Chuck Hagenbuch <chuck at horde.org>:

> Quoting Mike Bydalek <mbydalek at zivix.com>:
>
>> Instead of pages, there's an A-Z listing.  You can also modify your 
>> search to
>> include $page in it to help your query time (why get A-Z when you just want
>> R?).  When searching, pages still exist, since it just makes sense to me.
>
> I have this applied locally, and it seems to be against an old version
> of Turba.
> There were a bunch of formatName() calls that were wrong, and now that I've
> fixed those, and compensated for the fact that you don't set $pager if you're
> browsing, I still don't see an A-Z listing anywhere. I'll see if I can figure
> out what's up, but fyi.
>
> Also, you need to take a read through horde/docs/CODING_STANDARDS for future
> submissions.
>
> Thanks,
> -chuck
>
> --
> "Regard my poor demoralized mule!" - Juan Valdez
> --
> Turba mailing list - Join the hunt: http://horde.org/bounties/#turba
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: turba-unsubscribe at lists.horde.org


-------------- next part --------------
*** browse.php.orig	Thu Mar 11 10:14:35 2004
--- browse.php	Thu Mar 11 11:12:08 2004
***************
*** 323,333 ****
      require TURBA_TEMPLATES . $template;
  }
  
  if (isset($display) && is_object($display)) {
      require_once HORDE_LIBS . 'Horde/UI/Pager.php';
      require_once HORDE_LIBS . 'Horde/Variables.php';
-     $page = Util::getFormData('page', 0);
- 
  
      $viewurl = Util::addParameter('browse.php', array(
          'sortby' => $sortby,
--- 323,333 ----
      require TURBA_TEMPLATES . $template;
  }
  
+ $footer = "footer.inc";
+ 
  if (isset($display) && is_object($display)) {
      require_once HORDE_LIBS . 'Horde/UI/Pager.php';
      require_once HORDE_LIBS . 'Horde/Variables.php';
  
      $viewurl = Util::addParameter('browse.php', array(
          'sortby' => $sortby,
***************
*** 336,365 ****
          'source' => Util::getFormData('source')
      ));
  
!     $numitem = $results->count();
!     $maxpage = $prefs->getValue('maxpage');
!     $perpage = $prefs->getValue('perpage');
! 
!     $min = $page * $perpage;
!     while ($min > $numitem) {
!         $page--;
!         $min = $page * $perpage;
!     }
!     $max = $min + $perpage;
! 
!     $start = ($page * $perpage) + 1;
!     $end = min($numitem, $start + $perpage - 1);
! 
!     $numDisplayed = $display->display($min, $max);
! 
!     $vars = &Variables::getDefaultVariables();
!     $pager = &new Horde_UI_Pager('page', $vars, array('num' => $numDisplayed,
!                                                       'url' => $viewurl,
!                                                       'page_count' => $maxpage,
!                                                       'perpage' => $perpage));
  
      require TURBA_TEMPLATES . '/browse/column_footers.inc';
  }
  
! require TURBA_TEMPLATES . '/browse/footer.inc';
  require $registry->getParam('templates', 'horde') . '/common-footer.inc';
--- 336,378 ----
          'source' => Util::getFormData('source')
      ));
  
! 	if (Util::getFormData ('key') == '**search') {
! 		$page = Util::getFormData('page', 0);
!         $numitem = $results->count();
!     	$maxpage = $prefs->getValue('maxpage');
!     	$perpage = $prefs->getValue('perpage');
! 
!     	$min = $page * $perpage;
!     	while ($min > $numitem) {
!         	$page--;
!         	$min = $page * $perpage;
!     	}
!     	$max = $min + $perpage;
! 
!     	$start = ($page * $perpage) + 1;
!     	$end = min($numitem, $start + $perpage - 1);
! 
!     	$numDisplayed = $display->display($min, $max);
! 
!     	$vars = &Variables::getDefaultVariables();
!     	$pager = &new Horde_UI_Pager('page', $vars, array('num' => $numDisplayed,
!         	                                              'url' => $viewurl,
!             	                                          'page_count' => $maxpage,
!                 	                                      'perpage' => $perpage));
! 	} else {
! 		$page = Util::getFormData('page', 'a');        
! 
!         if (empty ($page) || !preg_match ('/^[A-Za-z]$/', $page)) { 
!             $page = 'a';
! 		}
!        
!         $display->display_alpha($page);
!         $numDisplayed = $results->count();
! 		$footer = "footerAlpha.inc";
! 	}
  
      require TURBA_TEMPLATES . '/browse/column_footers.inc';
  }
  
! require TURBA_TEMPLATES . '/browse/' . $footer;
  require $registry->getParam('templates', 'horde') . '/common-footer.inc';
-------------- next part --------------
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="1" width="100%">
<tr>
  <td class="control" width="100%" align="center">
<?php
for ($i = 65; $i < 91; $i++) {
    if (strtoupper ($page) == chr ($i))
        echo '<b>(' . chr ($i) . ')</b>&nbsp;';
    else {
        $link = Util::addParameter ($viewurl, 'page', chr ($i));
        echo Horde::link (Horde::applicationUrl ($link)) . chr ($i)
            . "</a>&nbsp;";
    }
}
?>
  </td>
</tr>
</table>
-------------- next part --------------
*** ListView.php.orig	Thu Mar 11 10:23:20 2004
--- ListView.php	Thu Mar 11 11:21:49 2004
***************
*** 57,60 ****
--- 57,84 ----
          return $i;
      }
  
+ 	/**
+ 	 * Renders the list contents that match $alpha into and HTML view.
+ 	 *
+ 	 * @param $alpha	The letter to display.
+ 	 */
+     function display_alpha ($alpha)
+     {
+         $this->list->reset ();
+         $stats = array ();
+         $i = 0;
+ 		$name = null;
+ 
+         while ($ob = $this->list->next ()) {
+ 			$name = Turba::formatName($ob);
+ 
+ 			if (strtolower($name{0}) != strtolower($alpha)) {
+ 				continue;
+ 			}
+ 
+ 			include $this->template;
+ 			$i++;
+         }
+     }
+ 
  }


More information about the turba mailing list