AdSvS has uploaded a new change for review. https://gerrit.wikimedia.org/r/197015
Change subject: Start (mandatory) and name parameters added to calendar format ...................................................................... Start (mandatory) and name parameters added to calendar format Change-Id: Ic674602d9fac991b8b75419dda8453bca19bf931 --- M specials/CargoExport.php 1 file changed, 23 insertions(+), 18 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo refs/changes/15/197015/1 diff --git a/specials/CargoExport.php b/specials/CargoExport.php index fc32a39..08ab751 100644 --- a/specials/CargoExport.php +++ b/specials/CargoExport.php @@ -61,47 +61,52 @@ } } + /** + * Calendar format + * These fields are used for display in calendar + * start - represents the start of the event; can be Date or Datetime (mandatory) + * name - sets the name to be displayed in the calendar (default is the title of the page) + * color - sets the color in which to show the names of events; useful within #compound_query (default is set by the FullCalendar library) + * These parameters concern the calendar as a whole: + * width - sets the width of the calendar (default is 100%) + * start date - sets the date at which to display the calendar (default is the current date) + */ function displayCalendarData( $sqlQueries ) { $req = $this->getRequest(); $colorArray = $req->getArray( 'color' ); - + // The url will have a start and end parameter + // generated by the FullCalendar $startDate = $req->getVal( 'start' ); $endDate = $req->getVal( 'end' ); $displayedArray = array(); foreach ( $sqlQueries as $i => $sqlQuery ) { - $dateFields = array(); - foreach( $sqlQuery->mFieldDescriptions as $field => $description ) { - if ( $description->mType == 'Date' || $description->mType == 'Datetime' ) { - $dateFields[] = $field; - } - } $where = $sqlQuery->mWhereStr; if ( $where != '' ) { $where .= " AND "; } - $where .= "("; - foreach ( $dateFields as $j => $dateField ) { - if ( $j > 0 ) { - $where .= " OR "; - } - $where .= "($dateField >= '$startDate' AND $dateField <= '$endDate')"; - } - $where .= ")"; + // Retrieve only those pages that are 'in scope' + $where .= "(date >= '$startDate' AND date <= '$endDate')"; + $sqlQuery->mWhereStr = $where; - + $queryResults = $sqlQuery->run(); foreach ( $queryResults as $queryResult ) { + if ( $queryResult['name'] == '' ) { + $eventTitle = reset($queryResult); + } else { + $eventTitle = $queryResult['name']; + } $title = Title::newFromText( $queryResult['_pageName'] ); $displayedArray[] = array( // Get first field for the title - not // necessarily the page name. - 'title' => reset( $queryResult ), + 'title' => $eventTitle, 'url' => $title->getLocalURL(), - 'start' => $queryResult[$dateFields[0]], + 'start' => $queryResult['start'], 'color' => $colorArray[$i] ); } -- To view, visit https://gerrit.wikimedia.org/r/197015 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic674602d9fac991b8b75419dda8453bca19bf931 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Cargo Gerrit-Branch: master Gerrit-Owner: AdSvS <a...@wikibase.nl> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits