Page MenuHomePhabricator

Feature: Add header and footer to #drilldowninfo
Open, Needs TriagePublic

Description

Example Usage:

{{#drilldowninfo:filters=
  {{int:SA Address Locality}} (property=Locality),
  {{int:SA Country Country}} (property=Country),
  {{int:SA Tag Tags}} (property=Tag),
  |display parameters=?Organization Code;?Street;?Postal Code;?Locality;?Country;format=broadtable;
  |header=Template:S Organization Drilldown Intro
  |footer=Template:Welcome
}}

PATCH:

Index: includes/SD_ParserFunctions.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- includes/SD_ParserFunctions.php	(revision 5e142c6c4e584721a187e51fe880c7f3db29b3dc)
+++ includes/SD_ParserFunctions.php	(revision )
@@ -37,6 +37,8 @@
 		array_shift( $params );
 
 		$filtersStr = $titleStr = $displayParametersStr = "";
+		$header = '';
+		$footer = '';
 
 		// Parameters
 		foreach ( $params as $i => $param ) {
@@ -58,6 +60,10 @@
 				$titleStr = $value;
 			} elseif ( $param_name == 'display parameters' ) {
 				$displayParametersStr = $value;
+			} elseif ( $param_name === 'header' ) { // Header
+				$header = $value;
+			} elseif ( $param_name === 'footer' ) { // Footer
+				$footer = $value;
 			}
 		}
 
@@ -104,6 +110,12 @@
 		}
 		if ( $displayParametersStr != '' ) {
 			$parserOutput->setProperty( 'SDDisplayParams', $displayParametersStr );
+		}
+		if ( $header !== '' ) {
+			$parserOutput->setProperty( 'SDHeader', $header );
+		}
+		if ( $footer !== '' ) {
+			$parserOutput->setProperty( 'SDFooter', $footer );
 		}
 
 		$parserOutput->addModules( 'ext.semanticdrilldown.info' );
Index: includes/SD_Utils.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- includes/SD_Utils.php	(revision 5e142c6c4e584721a187e51fe880c7f3db29b3dc)
+++ includes/SD_Utils.php	(revision )
@@ -325,6 +325,54 @@
 		return $pages;
 	}
 
+	/**
+	 * Gets the custom drilldown title for a category, if there is one.
+	 */
+	static function getDrilldownHeader( $category ) {
+		$title = Title::newFromText( $category, NS_CATEGORY );
+		$pageID = $title->getArticleID();
+		$dbr = wfGetDB( DB_SLAVE );
+		$res = $dbr->select( 'page_props',
+			array(
+				'pp_value'
+			),
+			array(
+				'pp_page' => $pageID,
+				'pp_propname' => 'SDHeader'
+			)
+		);
+
+		if ( $row = $dbr->fetchRow( $res ) ) {
+			return $row['pp_value'];
+		} else {
+			return '';
+		}
+	}
+
+	/**
+	 * Gets the custom drilldown title for a category, if there is one.
+	 */
+	static function getDrilldownFooter( $category ) {
+		$title = Title::newFromText( $category, NS_CATEGORY );
+		$pageID = $title->getArticleID();
+		$dbr = wfGetDB( DB_SLAVE );
+		$res = $dbr->select( 'page_props',
+			array(
+				'pp_value'
+			),
+			array(
+				'pp_page' => $pageID,
+				'pp_propname' => 'SDFooter'
+			)
+		);
+
+		if ( $row = $dbr->fetchRow( $res ) ) {
+			return $row['pp_value'];
+		} else {
+			return '';
+		}
+	}
+
 	static function monthToString( $month ) {
 		if ( $month == 1 ) {
 			return wfMessage( 'january' )->text();
Index: specials/SD_BrowseData.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- specials/SD_BrowseData.php	(revision 5e142c6c4e584721a187e51fe880c7f3db29b3dc)
+++ specials/SD_BrowseData.php	(revision )
@@ -216,6 +216,9 @@
 	 */
 	function createTempTable( $category, $subcategory, $subcategories, $applied_filters ) {
 		$dbr = wfGetDB( DB_SLAVE );
+
+		// Ensure that temporary table has been properly deleted
+		$dbr->query( "DROP TABLE IF EXISTS semantic_drilldown_values;" );
 		$sql1 = "CREATE TEMPORARY TABLE semantic_drilldown_values ( id INT NOT NULL )";
 		$dbr->query( $sql1 );
 		$sql2 = "CREATE INDEX id_index ON semantic_drilldown_values ( id )";
@@ -1036,6 +1039,20 @@
 		$subcategory_text = wfMessage( 'sd_browsedata_subcategory' )->text();
 
 		$header = "";
+
+		// Add intro template
+		$headerPage = SDUtils::getDrilldownHeader( $this->category );
+		if ($headerPage !== '') {
+			$title = Title::newFromText($headerPage);
+			$page = WikiPage::factory($title);
+			if ($page->exists()) {
+				$content = $page->getContent();
+				$pageContent = $content->serialize();
+				$out = $this->getOutput();
+				$header .= $out->parseInline($pageContent);
+			}
+		}
+
 		$this->show_single_cat = $this->getRequest()->getCheck( '_single' );
 		if ( ! $this->show_single_cat ) {
 			$header .= $this->printCategoriesList( $categories );
@@ -1252,6 +1269,7 @@
 	protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
 		global $wgContLang;
 
+		// Add Drilldown Results
 		$all_display_params = SDUtils::getDisplayParamsForCategory( $this->category );
 		$querystring = null;
 		$printouts = $params = array();
@@ -1320,6 +1338,22 @@
 			: implode( '', $html );
 
 		$out->addHTML( $html );
+
+		// Add outro template
+		$footerPage = SDUtils::getDrilldownFooter( $this->category );
+
+		if ($footerPage !== '') {
+
+			$title = Title::newFromText('Template:' . $footerPage);
+			$page = WikiPage::factory($title);
+
+			if ($page->exists()) {
+				$content = $page->getContent();
+				$pageContent = $content->serialize();
+				$out->addWikiText($pageContent);
+			}
+		}
+
 	}
 
 	// Take non-semantic result set returned by Database->query() method,

Event Timeline

Fannon created this task.May 18 2016, 2:28 PM
Restricted Application added subscribers: Zppix, Aklapper. · View Herald TranscriptMay 18 2016, 2:28 PM
Fannon renamed this task from Feature: Add introtemplate and outrotemplate to #drilldowninfo to Feature: Add header and footer to #drilldowninfo.May 18 2016, 3:02 PM
Fannon updated the task description. (Show Details)
Fannon updated the task description. (Show Details)
Aklapper removed Yaron_Koren as the assignee of this task.Jun 19 2020, 4:15 PM
Aklapper added a subscriber: Yaron_Koren.

This task has been assigned to the same task owner for more than two years. Resetting task assignee due to inactivity, to decrease task cookie-licking and to get a slightly more realistic overview of plans. Please feel free to assign this task to yourself again if you still realistically work or plan to work on this task - it would be welcome!

For tips how to manage individual work in Phabricator (noisy notifications, lists of task, etc.), see https://phabricator.wikimedia.org/T228575#6237124 for available options.
(For the records, two emails were sent to assignee addresses before resetting assignees. See T228575 for more info and for potential feedback. Thanks!)

Restricted Application added a subscriber: Liuxinyu970226. · View Herald TranscriptJun 19 2020, 4:15 PM