jenkins-bot has submitted this change and it was merged.

Change subject: Update how deleted pages behave
......................................................................


Update how deleted pages behave

* Footer link removed
* Do not redirect to editor

Bug: T93295
Change-Id: I893bd1efac5b2015d9ef441f810b7eb0c915dd54
---
M includes/models/Collection.php
M includes/models/CollectionItem.php
M includes/views/CollectionItemCard.php
3 files changed, 48 insertions(+), 21 deletions(-)

Approvals:
  Jhernandez: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/models/Collection.php b/includes/models/Collection.php
index 8365d97..b1d5b24 100644
--- a/includes/models/Collection.php
+++ b/includes/models/Collection.php
@@ -208,7 +208,11 @@
                                                        $extract = 
$extract['*'];
                                                }
                                        }
-                                       $collection->add( new CollectionItem( 
$title, $pi, $extract ) );
+                                       $item = new CollectionItem( $title, 
$pi, $extract );
+                                       if ( isset( $page['missing'] ) ) {
+                                               $item->setMissing( true );
+                                       }
+                                       $collection->add( $item );
                                }
                        }
                        if ( isset( $data['continue'] ) ) {
diff --git a/includes/models/CollectionItem.php 
b/includes/models/CollectionItem.php
index baeaffe..f2c0776 100644
--- a/includes/models/CollectionItem.php
+++ b/includes/models/CollectionItem.php
@@ -38,6 +38,22 @@
                $this->title = $title;
                $this->file = $file;
                $this->extract = $extract;
+               $this->missing = false;
+       }
+
+       /**
+        * Cheap method for determining whether the page is in the collection 
or not.
+        * @return Boolean
+        */
+       public function isMissing() {
+               return $this->missing;
+       }
+
+       /**
+        * @param Boolean $missing whether the associated title exists.
+        */
+       public function setMissing( $missing ) {
+               $this->missing = $missing;
        }
 
        /**
diff --git a/includes/views/CollectionItemCard.php 
b/includes/views/CollectionItemCard.php
index 11a0619..8098592 100644
--- a/includes/views/CollectionItemCard.php
+++ b/includes/views/CollectionItemCard.php
@@ -49,6 +49,9 @@
                $item = $this->item;
                $title = $item->getTitle();
                $img = $this->image->getHtml();
+               $pageUrl = $title->getLocalUrl();
+               $isMissing = $item->isMissing();
+
                if ( $img ) {
                        $img = Html::openElement( 'a', array( 'href' => 
$title->getLocalUrl() ) ) .
                                $img .
@@ -57,37 +60,41 @@
                $html = Html::openElement( 'div', array( 'class' => 
'collection-card' ) ) .
                        $img .
                        Html::openElement( 'h2', array( 'class' => 
'collection-card-title', 'dir' => $dir ) ) .
-                       Linker::link( $title ) .
+                       Html::element( 'a', array( 'href' => $pageUrl, 'class' 
=> $isMissing ? 'new' : '' ),
+                               $title->getPrefixedText() ) .
                        Html::closeElement( 'h2' );
                // Handle excerpt for titles with an extract or unknown pages
-               if ( $item->hasExtract() || !$title->isKnown() ) {
+               if ( $item->hasExtract() || $isMissing ) {
                        if ( $item->hasExtract() ) {
                                $itemExcerpt = $item->getExtract();
-                       } elseif ( !$title->isKnown() ) {
+                       } elseif ( $isMissing ) {
                                $itemExcerpt = wfMessage( 
'gather-page-not-found' )->escaped();
                        }
                        $html .= Html::element(
                                'p', array( 'class' => 
'collection-card-excerpt', 'dir' => $dir ), $itemExcerpt
                        );
                }
-               $html .= Html::openElement( 'div', array( 'class' => 
'collection-card-footer' ) )
-                       . Html::openElement( 'a',
-                               array(
-                                       'href' => $title->getLocalUrl(),
-                                       'class' => CSS::anchorClass( 
'progressive' )
+
+               if ( !$isMissing ) {
+                       $html .= Html::openElement( 'div', array( 'class' => 
'collection-card-footer' ) )
+                               . Html::openElement( 'a',
+                                       array(
+                                               'href' => $pageUrl,
+                                               'class' => CSS::anchorClass( 
'progressive' )
+                                       )
                                )
-                       )
-                       . wfMessage( 'gather-read-more' )->escaped()
-                       . Html::element(
-                               'span',
-                               array( 'class' => CSS::iconClass(
-                                       'collections-read-more', 'element', 
'collections-read-more-arrow'
-                               ) ),
-                               ''
-                       )
-                       . Html::closeElement( 'a' )
-                       . Html::closeElement( 'div' )
-                       . Html::closeElement( 'div' );
+                               . wfMessage( 'gather-read-more' )->escaped()
+                               . Html::element(
+                                       'span',
+                                       array( 'class' => CSS::iconClass(
+                                               'collections-read-more', 
'element', 'collections-read-more-arrow'
+                                       ) ),
+                                       ''
+                               )
+                               . Html::closeElement( 'a' )
+                               . Html::closeElement( 'div' );
+               }
+               $html .= Html::closeElement( 'div' );
 
                return $html;
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/205300
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I893bd1efac5b2015d9ef441f810b7eb0c915dd54
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/Gather
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Jhernandez <[email protected]>
Gerrit-Reviewer: Robmoen <[email protected]>
Gerrit-Reviewer: Yurik <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to