From: <bh...@us...> - 2008-03-25 10:28:36
|
Revision: 17561 http://gallery.svn.sourceforge.net/gallery/?rev=17561&view=rev Author: bharat Date: 2008-03-25 03:28:40 -0700 (Tue, 25 Mar 2008) Log Message: ----------- Properly implement the <author/> element in the RSS 2.0 feed. Modified Paths: -------------- trunk/gallery2/modules/rss/classes/RssGenerator.class trunk/gallery2/modules/rss/classes/RssHelper.class trunk/gallery2/modules/rss/test/phpunit/RssRenderTest.class Modified: trunk/gallery2/modules/rss/classes/RssGenerator.class =================================================================== --- trunk/gallery2/modules/rss/classes/RssGenerator.class 2008-03-25 09:58:05 UTC (rev 17560) +++ trunk/gallery2/modules/rss/classes/RssGenerator.class 2008-03-25 10:28:40 UTC (rev 17561) @@ -201,7 +201,7 @@ $platform =& $gallery->getPlatform(); $lf = $platform->getLineEnding(); - + if (isset($this->_properties['useMedia']) && $this->_properties['useMedia'] == 1) { $data = '<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">'; } else { @@ -244,6 +244,7 @@ '</title>' . $lf . ' <link>' . $this->_properties['image']['link'] . '</link></image>' . $lf : ''); + $userMap = array(); foreach ($this->_items as $item) { if (isset($item['title']) && isset($item['link']) && isset($item['description'])) { $data .= '<item>' . $lf . @@ -255,9 +256,26 @@ $this->cdata(GalleryUtilities::markup($item['description'])) . '</description>' . $lf; - if (isset($item['author'])) { - $data .= ' <author>' . GalleryUtilities::markup($item['author']) . - '</author>' . $lf; + if (isset($item['ownerId'])) { + $ownerId = $item['ownerId']; + if (!isset($userMap[$item['ownerId']])) { + list ($ret, $userMap[$ownerId]) = + GalleryCoreApi::loadEntitiesById($ownerId); + if ($ret) { + /** + * This method has no way of returning errors, so swallow them for now + * @todo convert this to an exception in 2.4 + */ + } + } + + if (isset($userMap[$ownerId])) { + $name = $userMap[$ownerId]->getFullName(); + if (empty($name)) { + $name = $userMap[$ownerId]->getUsername(); + } + $data .= ' <author>' . GalleryUtilities::markup($name) . '</author>' . $lf; + } } if (isset($item['category'])) { @@ -278,20 +296,20 @@ if (isset($this->_properties['useMedia']) && $this->_properties['useMedia']) { if (isset($item['media'])) { - $data .= ' <media:content url="' . $item['media']['url'] - . '" type="' . $item['media']['type'] - . '" height="' . $item['media']['height'] + $data .= ' <media:content url="' . $item['media']['url'] + . '" type="' . $item['media']['type'] + . '" height="' . $item['media']['height'] . '" width="' . $item['media']['width'] . '" />' . $lf; - + } - + $data .= ' <media:title>' . $this->cdata(GalleryUtilities::markup($item['title'])) . '</media:title>' . $lf . ' <media:text type="html">' . $this->cdata(GalleryUtilities::markup($item['description'])) . '</media:text>' . $lf; - + if (isset($item['thumbnail'])) { $data .= ' <media:thumbnail url="' . $item['thumbnail']['url'] . '" width="' . $item['thumbnail']['width'] . '" height="' Modified: trunk/gallery2/modules/rss/classes/RssHelper.class =================================================================== --- trunk/gallery2/modules/rss/classes/RssHelper.class 2008-03-25 09:58:05 UTC (rev 17560) +++ trunk/gallery2/modules/rss/classes/RssHelper.class 2008-03-25 10:28:40 UTC (rev 17561) @@ -200,7 +200,7 @@ } break; - + case 'commentsRecursive': list ($ret, $items) = GalleryCommentHelper::fetchAllComments($id, $param['count'], null, ORDER_DESCENDING); @@ -210,15 +210,15 @@ break; } - + /* if necessary, fetch the thumbnails */ if (! strstr($param['feedType'], 'comments')) { $itemIds = array(); - + foreach ($items as $item) { $itemIds[] = $item->getId(); } - + list ($ret, $param['thumbnails']) = GalleryCoreApi::fetchThumbnailsByItemIds($itemIds); if ($ret) { @@ -298,7 +298,7 @@ '" width="' . $thumbnail->getWidth() . '" height="' . $thumbnail->getHeight() . '"/></a>' . (!empty($description) ? '<br/>' . $description : $description); - + $itemSettings['thumbnail']['url'] = $url; $itemSettings['thumbnail']['width'] = $thumbnail->getWidth(); $itemSettings['thumbnail']['height'] = $thumbnail->getHeight(); @@ -338,10 +338,11 @@ } $itemSettings['pubDate'] = date('r', $item->getModificationTimestamp()); + $itemSettings['ownerId'] = $item->getOwnerId(); /* check if the enclosure tag should be used */ if (GalleryUtilities::isA($item, 'GalleryPhotoItem') - && ((isset($param['useEnclosure']) && $param['useEnclosure'] == '1') + && ((isset($param['useEnclosure']) && $param['useEnclosure'] == '1') || (isset($param['useMedia']) && $param['useMedia'] == '1'))) { $imageUrl = $urlGenerator->generateUrl( array( @@ -350,7 +351,7 @@ array( 'forceSessionId' => false, 'forceFullUrl' => true)); - + if (isset($param['useEnclosure']) && $param['useEnclosure'] == '1') { $itemSettings['enclosure'] = array( 'url' => $imageUrl, @@ -482,7 +483,7 @@ if ($ret) { return array($ret, null); } - + if ($itemId == $rootId) { $parentSequence = ''; } else { @@ -508,7 +509,7 @@ $newDays = 21; /* Use default on error or zero setting */ } $timeCutOff = time() - 3600 * 24 * $newDays; - + if ($random) { /* get the random function for the DB */ list ($ret, $orderBy) = $storage->getFunctionSql('RAND', array()); @@ -518,38 +519,38 @@ } else { $orderBy = "[GalleryEntity::$timestamp] DESC"; } - + $query = " SELECT [$table::id]"; - + if ($perAlbumLimit != 0) { $query .= ', [GalleryItemAttributesMap::parentSequence]'; } - + $query .= " FROM [$table], [GalleryItemAttributesMap], [GalleryAccessSubscriberMap], [GalleryEntity] WHERE "; - + if (! $random) { $query .= " [GalleryEntity::$timestamp] >= $timeCutOff AND "; } - + $query .= " [$table::id] = [GalleryItemAttributesMap::itemId] AND [$table::id] = [GalleryEntity::id]"; - + if (!empty($parentSequence)) { $query .= " AND [GalleryItemAttributesMap::parentSequence] LIKE '$parentSequence/%'"; } - + $query .= " AND [$table::id] = [GalleryAccessSubscriberMap::itemId] @@ -623,7 +624,7 @@ 'commentsRecursive' => $module->translate('Comments for an album and its subalbums'), 'photosRandom' => $module->translate('Random items in an album'), - 'photosRandomRecursive' => + 'photosRandomRecursive' => $module->translate('Random items in an album and its subalbums'), )); } Modified: trunk/gallery2/modules/rss/test/phpunit/RssRenderTest.class =================================================================== --- trunk/gallery2/modules/rss/test/phpunit/RssRenderTest.class 2008-03-25 09:58:05 UTC (rev 17560) +++ trunk/gallery2/modules/rss/test/phpunit/RssRenderTest.class 2008-03-25 10:28:40 UTC (rev 17561) @@ -215,6 +215,7 @@ ob_end_clean(); $platform =& $gallery->getPlatform(); + $user = $gallery->getActiveUser(); $this->assertEquals( array( 'Header: Content-type: text/xml; charset=UTF-8', @@ -232,6 +233,7 @@ ' <link>url:' . $this->_album->getId() . '</link>', ' <guid isPermaLink="false">url:' . $this->_album->getId() . '</guid>', ' <description><![CDATA[This is my description]]></description>', + ' <author>' . $user->getFullName() . '</author>', ' <category>album</category>', ' <pubDate>' . date('r', 1234567890) . '</pubDate>', '</item>', @@ -267,6 +269,7 @@ ob_end_clean(); $platform =& $gallery->getPlatform(); + $user = $gallery->getActiveUser(); $this->assertEquals( array( 'Header: Content-type: text/xml; charset=UTF-8', @@ -284,6 +287,7 @@ ' <link>url:' . $this->_item1->getId() . '</link>', ' <guid isPermaLink="false">url:' . $this->_item1->getId() . '</guid>', ' <description><![CDATA[This is a description]]></description>', + ' <author>' . $user->getFullName() . '</author>', ' <category>photo</category>', ' <pubDate>' . date('r', 1234567890) . '</pubDate>', '</item>', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |