diff --git a/Mf2/Parser.php b/Mf2/Parser.php index 68c911a..410883a 100644 --- a/Mf2/Parser.php +++ b/Mf2/Parser.php @@ -1573,6 +1573,38 @@ public function backcompat(DOMElement $el, $context = '', $isParentMf2 = false) } break; + case 'hfeed': + $this->upgradeRelTagToCategory($el); + break; + + case 'hproduct': + $review_and_hreview_aggregate = $this->xpath->query('.//*[contains(concat(" ", normalize-space(@class), " "), " review ") and contains(concat(" ", normalize-space(@class), " "), " hreview-aggregate ")]', $el); + + if ( $review_and_hreview_aggregate->length ) { + foreach ( $review_and_hreview_aggregate as $tempEl ) { + if ( !$this->hasRootMf2($tempEl) ) { + $this->backcompat($tempEl, 'hreview-aggregate'); + $this->addMfClasses($tempEl, 'p-review h-review-aggregate'); + $this->addUpgraded($tempEl, array('review hreview-aggregate')); + } + } + } + + $review_and_hreview = $this->xpath->query('.//*[contains(concat(" ", normalize-space(@class), " "), " review ") and contains(concat(" ", normalize-space(@class), " "), " hreview ")]', $el); + + if ( $review_and_hreview->length ) { + foreach ( $review_and_hreview as $tempEl ) { + if ( !$this->hasRootMf2($tempEl) ) { + $this->backcompat($tempEl, 'hreview'); + $this->addMfClasses($tempEl, 'p-review h-review'); + $this->addUpgraded($tempEl, array('review hreview')); + } + } + } + + break; + + case 'hreview-aggregate': case 'hreview': $item_and_vcard = $this->xpath->query('.//*[contains(concat(" ", normalize-space(@class), " "), " item ") and contains(concat(" ", normalize-space(@class), " "), " vcard ")]', $el); @@ -1614,12 +1646,12 @@ public function backcompat(DOMElement $el, $context = '', $isParentMf2 = false) break; case 'vevent': - $location = $this->xpath->query('.//*[contains(concat(" ", normalize-space(@class), " "), " location ")]', $el); + $location_and_vcard = $this->xpath->query('.//*[contains(concat(" ", normalize-space(@class), " "), " location ") and contains(concat(" ", normalize-space(@class), " "), " vcard ")]', $el); - if ( $location->length ) { - foreach ( $location as $tempEl ) { + if ( $location_and_vcard->length ) { + foreach ( $location_and_vcard as $tempEl ) { if ( !$this->hasRootMf2($tempEl) ) { - $this->addMfClasses($tempEl, 'h-card'); + $this->addMfClasses($tempEl, 'p-location h-card'); $this->backcompat($tempEl, 'vcard'); } } @@ -1761,8 +1793,10 @@ public function query($expression, $context = null) { 'hresume' => 'h-resume', 'vevent' => 'h-event', 'hreview' => 'h-review', + 'hreview-aggregate' => 'h-review-aggregate', 'hproduct' => 'h-product', 'adr' => 'h-adr', + 'geo' => 'h-geo' ); /** @@ -1879,7 +1913,19 @@ public function query($expression, $context = null) { ), ), 'hfeed' => array( - # nothing currently + 'author' => array( + 'replace' => 'p-author h-card', + 'context' => 'vcard' + ), + 'url' => array( + 'replace' => 'u-url' + ), + 'photo' => array( + 'replace' => 'u-photo' + ), + 'category' => array( + 'replace' => 'p-category' + ), ), 'hentry' => array( 'entry-title' => array( @@ -1989,12 +2035,15 @@ public function query($expression, $context = null) { 'replace' => 'p-category' ), 'location' => array( - 'replace' => 'h-card', - 'context' => 'vcard' + 'replace' => 'p-location', ), 'geo' => array( 'replace' => 'p-location h-geo' ), + 'attendee' => array( + 'replace' => 'p-attendee h-card', + 'context' => 'vcard' + ) ), 'hreview' => array( 'summary' => array( @@ -2030,6 +2079,36 @@ public function query($expression, $context = null) { 'replace' => 'p-category' ), ), + 'hreview-aggregate' => array( + 'summary' => array( + 'replace' => 'p-name' + ), + # fn: see item.fn below + # photo: see item.photo below + # url: see item.url below + 'item' => array( + 'replace' => 'p-item h-item', + 'context' => 'item' + ), + 'rating' => array( + 'replace' => 'p-rating' + ), + 'best' => array( + 'replace' => 'p-best' + ), + 'worst' => array( + 'replace' => 'p-worst' + ), + 'average' => array( + 'replace' => 'p-average' + ), + 'count' => array( + 'replace' => 'p-count' + ), + 'votes' => array( + 'replace' => 'p-votes' + ), + ), 'hproduct' => array( 'fn' => array( 'replace' => 'p-name', @@ -2052,9 +2131,7 @@ public function query($expression, $context = null) { 'url' => array( 'replace' => 'u-url', ), - 'review' => array( - 'replace' => 'p-review h-review', - ), + // review is handled in the special processing section to allow for 'review hreview-aggregate' 'price' => array( 'replace' => 'p-price' ),