[pLog-svn] r565 - in plog/trunk: class/view/admin templates/admin

oscar at devel.plogworld.net oscar at devel.plogworld.net
Thu Dec 23 09:14:52 GMT 2004


Author: oscar
Date: 2004-12-23 09:14:52 +0000 (Thu, 23 Dec 2004)
New Revision: 565

Modified:
   plog/trunk/class/view/admin/adminresourceslistview.class.php
   plog/trunk/templates/admin/resources.template
Log:
added paging to the list of resources. It only pages posts, not albums. Albusm will alwas appear in the first page, no matter how many we have.


Modified: plog/trunk/class/view/admin/adminresourceslistview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminresourceslistview.class.php	2004-12-23 07:58:09 UTC (rev 564)
+++ plog/trunk/class/view/admin/adminresourceslistview.class.php	2004-12-23 09:14:52 UTC (rev 565)
@@ -4,6 +4,7 @@
     include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryalbums.class.php" );
     include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryresources.class.php" );	
 	include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryresourcequotas.class.php" );
+	include_once( PLOG_CLASS_PATH."class/data/pager/pager.class.php" );
 	
 	define( "ROOT_ALBUM_ID", 0 );
 	
@@ -12,6 +13,10 @@
 	 */
 	class AdminResourcesListView extends AdminTemplatedView
 	{
+		var $_albumId;
+		var $_page;
+		var $_resourceType;
+
 	
 		function AdminResourcesListView( $blogInfo, $params = Array())
 		{
@@ -28,19 +33,28 @@
 				$this->_albumId = ROOT_ALBUM_ID;
 				
 			$this->setSessionValue( "albumId", $this->_albumId );
+
+			$this->_resourceType = GALLERY_RESOURCE_ANY;
 		}
 		
 		function render()
 		{
-        	// and the current album
-        	$galleryAlbums = new GalleryAlbums();
-            if( $this->_albumId > ROOT_ALBUM_ID ) {
-            	$album = $galleryAlbums->getAlbum( $this->_albumId, $this->_blogInfo->getId());
+			// get the page from the request
+			$this->_page = $this->getCurrentPageFromRequest();
+
+	        	// and the current album
+        		$galleryAlbums = new GalleryAlbums();
+			$galleryResources = new GalleryResources();
+
+			if( $this->_albumId > ROOT_ALBUM_ID && $this->_page > 0 ) {
+        	    		$album = $galleryAlbums->getAlbum( $this->_albumId, $this->_blogInfo->getId());
 				if( !$album || $album == "") {
 					$this->_albumId = ROOT_ALBUM_ID;
 				}
 				else {
-					$resources = $album->getResources();
+					//$resources = $album->getResources();
+					$resources = $galleryResources->getUserResources( $this->_blogInfo->getId(), $this->_albumId, $this->_resourceType, $this->_page, DEFAULT_ITEMS_PER_PAGE );
+					$numResources = $galleryResources->getNumUserResources( $this->_blogInfo->getId(), $this->_albumId, $this->_resourceType );
 				}
 			}
 			else {
@@ -53,21 +67,25 @@
 			$userAlbums = $galleryAlbums->getNestedAlbumList( $this->_blogInfo->getId());
 			$this->setValue( "albumsList", $userAlbums );			
 
-			// etch some statistics and continue
+			// fetch some statistics and continue
 			$quotaUsage = GalleryResourceQuotas::getBlogResourceQuotaUsage( $this->_blogInfo->getId());
-			$galleryResources = new GalleryResources();
 			$totalResources = $galleryResources->getNumResources( $this->_blogInfo->getId());
 			$currentQuota = GalleryResourceQuotas::getBlogResourceQuota( $this->_blogInfo->getId());
 			$this->setValue( "quotausage", $quotaUsage );
 			$this->setValue( "totalresources", $totalResources );
-			$this->setValue( "quota", $currentQuota );						
+			$this->setValue( "quota", $currentQuota );				
 
-            $this->setValue( "album", $album );
+			// and now export info about the albums and so on
+            		$this->setValue( "album", $album );
 			if( $this->_albumId > ROOT_ALBUM_ID )
 				$this->setValue( "albums", $album->getChildren());
 			else
 				$this->setValue( "albums", $albums );
-            $this->setValue( "resources", $resources );
+	            	$this->setValue( "resources", $resources );
+
+			// finally, create and export the pager
+			$pager = new Pager( "?op=resources&page=", $this->_page, $numResources, DEFAULT_ITEMS_PER_PAGE );
+			$this->setValue( "pager", $pager );
 			
 			parent::render();
 		}

Modified: plog/trunk/templates/admin/resources.template
===================================================================
--- plog/trunk/templates/admin/resources.template	2004-12-23 07:58:09 UTC (rev 564)
+++ plog/trunk/templates/admin/resources.template	2004-12-23 09:14:52 UTC (rev 565)
@@ -111,6 +111,7 @@
 </table>
 </div>
 <div id="list_action_bar">
+  {include file="$admintemplatepath/adminpager.template" style=list}
   {$locale->tr("num_resources")}: <strong>{$totalresources}</strong>, {$locale->tr("total_size")}: <strong>{$quotausage|round}</strong>
   {if $quota > 0 }, {$locale->tr("quota")}: <strong>{$quota|round}</strong>{/if}
   <input type="submit" name="delete_selected" value="{$locale->tr("delete_selected")}" class="submit" />




More information about the pLog-svn mailing list