| @@ -1,6 +1,6 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); | |
| 3 | +declare(strict_types=1); | |
| 4 | 4 | |
| 5 | 5 | namespace ModernTimeline; | 
| 6 | 6 | |
| @@ -13,10 +13,10 @@ discard block | ||
| 13 | 13 | } | 
| 14 | 14 | |
| 15 | 15 |  	private static function doSmwCheck() { | 
| 16 | -		if ( !defined( 'SMW_VERSION' ) ) { | |
| 16 | +		if (!defined('SMW_VERSION')) { | |
| 17 | 17 | |
| 18 | -			if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) { | |
| 19 | - die( "\nThe 'Modern Timeline' extension requires 'Semantic MediaWiki' to be installed and enabled.\n" ); | |
| 18 | +			if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { | |
| 19 | +				die("\nThe 'Modern Timeline' extension requires 'Semantic MediaWiki' to be installed and enabled.\n"); | |
| 20 | 20 | } | 
| 21 | 21 | |
| 22 | 22 | die( | 
| @@ -1,6 +1,6 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); | |
| 3 | +declare(strict_types=1); | |
| 4 | 4 | |
| 5 | 5 | namespace ModernTimeline; | 
| 6 | 6 | |
| @@ -28,23 +28,23 @@ discard block | ||
| 28 | 28 | $registry = new ResultFormatRegistry(); | 
| 29 | 29 | |
| 30 | 30 | $registry->newFormat() | 
| 31 | - ->withName( 'moderntimeline' ) | |
| 32 | - ->andMessageKey( 'modern-timeline-format-name' ) | |
| 33 | - ->andParameterDefinitions( TimelineOptions::getTimelineParameterDefinitions() ) | |
| 34 | -			->andPresenterBuilder( function() { | |
| 31 | +			->withName('moderntimeline') | |
| 32 | +			->andMessageKey('modern-timeline-format-name') | |
| 33 | + ->andParameterDefinitions(TimelineOptions::getTimelineParameterDefinitions()) | |
| 34 | +			->andPresenterBuilder(function() { | |
| 35 | 35 | return new TimelinePresenter(); | 
| 36 | 36 | } ) | 
| 37 | 37 | ->register(); | 
| 38 | 38 | |
| 39 | - $this->format = $registry->getFormatByName( 'moderntimeline' ); | |
| 39 | +		$this->format = $registry->getFormatByName('moderntimeline'); | |
| 40 | 40 | } | 
| 41 | 41 | |
| 42 | 42 |  	public function getName(): string { | 
| 43 | - return wfMessage( $this->format->getNameMessageKey() )->text(); | |
| 43 | + return wfMessage($this->format->getNameMessageKey())->text(); | |
| 44 | 44 | } | 
| 45 | 45 | |
| 46 | -	public function getParamDefinitions( array $definitions ) { | |
| 47 | - return array_merge( $definitions, $this->format->getParameterDefinitions() ); | |
| 46 | +	public function getParamDefinitions(array $definitions) { | |
| 47 | + return array_merge($definitions, $this->format->getParameterDefinitions()); | |
| 48 | 48 | } | 
| 49 | 49 | |
| 50 | 50 | /** | 
| @@ -54,36 +54,36 @@ discard block | ||
| 54 | 54 | * | 
| 55 | 55 | * @return string | 
| 56 | 56 | */ | 
| 57 | -	public function getResult( QueryResult $result, array $parameters, $outputMode ): string { | |
| 57 | +	public function getResult(QueryResult $result, array $parameters, $outputMode): string { | |
| 58 | 58 | return $this->format->buildPresenter()->presentResult( | 
| 59 | 59 | new SimpleQueryResult( | 
| 60 | - $this->simplifyResult( $result ), | |
| 61 | - $this->newProcessingResultFromParams( $parameters ) | |
| 60 | + $this->simplifyResult($result), | |
| 61 | + $this->newProcessingResultFromParams($parameters) | |
| 62 | 62 | ) | 
| 63 | 63 | ); | 
| 64 | 64 | } | 
| 65 | 65 | |
| 66 | -	private function simplifyResult( QueryResult $result ): SubjectCollection { | |
| 67 | - return ( new ResultSimplifier() )->newSubjectCollection( $result ); | |
| 66 | +	private function simplifyResult(QueryResult $result): SubjectCollection { | |
| 67 | + return (new ResultSimplifier())->newSubjectCollection($result); | |
| 68 | 68 | } | 
| 69 | 69 | |
| 70 | 70 | /** | 
| 71 | 71 | * This is code copied over from ParamProcessor to go from the deprecated Param[] to ProcessingResult. | 
| 72 | 72 | * Once the main ResultPrinter interface has been migrated away from Param this can be removed. | 
| 73 | 73 | */ | 
| 74 | -	private function newProcessingResultFromParams( array $params ): ProcessingResult { | |
| 74 | +	private function newProcessingResultFromParams(array $params): ProcessingResult { | |
| 75 | 75 | $parameters = []; | 
| 76 | 76 | |
| 77 | -		foreach ( $params as $param ) { | |
| 77 | +		foreach ($params as $param) { | |
| 78 | 78 | $processedParam = new ProcessedParam( | 
| 79 | 79 | $param->getName(), | 
| 80 | 80 | $param->getValue(), | 
| 81 | 81 | $param->wasSetToDefault() | 
| 82 | 82 | ); | 
| 83 | 83 | |
| 84 | -			if ( !$param->wasSetToDefault() ) { | |
| 85 | - $processedParam->setOriginalName( $param->getOriginalName() ); | |
| 86 | - $processedParam->setOriginalValue( $param->getOriginalValue() ); | |
| 84 | +			if (!$param->wasSetToDefault()) { | |
| 85 | + $processedParam->setOriginalName($param->getOriginalName()); | |
| 86 | + $processedParam->setOriginalValue($param->getOriginalValue()); | |
| 87 | 87 | } | 
| 88 | 88 | |
| 89 | 89 | $parameters[$processedParam->getName()] = $processedParam; | 
| @@ -95,11 +95,11 @@ discard block | ||
| 95 | 95 | ); | 
| 96 | 96 | } | 
| 97 | 97 | |
| 98 | -	public function getQueryMode( $context ): int { | |
| 98 | +	public function getQueryMode($context): int { | |
| 99 | 99 | return SMWQuery::MODE_INSTANCES; | 
| 100 | 100 | } | 
| 101 | 101 | |
| 102 | -	public function setShowErrors( $show ) { | |
| 102 | +	public function setShowErrors($show) { | |
| 103 | 103 | } | 
| 104 | 104 | |
| 105 | 105 |  	public function isExportFormat(): bool { | 
| @@ -118,6 +118,6 @@ discard block | ||
| 118 | 118 | return false; | 
| 119 | 119 | } | 
| 120 | 120 | |
| 121 | -	public function setRecursiveTextProcessor( RecursiveTextProcessor $recursiveTextProcessor ) { | |
| 121 | +	public function setRecursiveTextProcessor(RecursiveTextProcessor $recursiveTextProcessor) { | |
| 122 | 122 | } | 
| 123 | 123 | } | 
| @@ -1,6 +1,6 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); | |
| 3 | +declare(strict_types=1); | |
| 4 | 4 | |
| 5 | 5 | namespace ModernTimeline; | 
| 6 | 6 | |
| @@ -14,7 +14,7 @@ discard block | ||
| 14 | 14 | private $endDate; | 
| 15 | 15 | private $imageUrl; | 
| 16 | 16 | |
| 17 | -	public function __construct( Subject $subject, SMWDITime $startDate, ?SMWDITime $endDate ) { | |
| 17 | +	public function __construct(Subject $subject, SMWDITime $startDate, ?SMWDITime $endDate) { | |
| 18 | 18 | $this->subject = $subject; | 
| 19 | 19 | $this->startDate = $startDate; | 
| 20 | 20 | $this->endDate = $endDate; | 
| @@ -40,7 +40,7 @@ discard block | ||
| 40 | 40 | return $this->imageUrl; | 
| 41 | 41 | } | 
| 42 | 42 | |
| 43 | -	public function setImageUrl( string $url ) { | |
| 43 | +	public function setImageUrl(string $url) { | |
| 44 | 44 | $this->imageUrl = $url; | 
| 45 | 45 | } | 
| 46 | 46 | |
| @@ -1,6 +1,6 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); | |
| 3 | +declare(strict_types=1); | |
| 4 | 4 | |
| 5 | 5 | namespace ModernTimeline; | 
| 6 | 6 | |
| @@ -16,7 +16,7 @@ discard block | ||
| 16 | 16 | |
| 17 | 17 | private $parameters; | 
| 18 | 18 | |
| 19 | -	public function __construct( array $parameters ) { | |
| 19 | +	public function __construct(array $parameters) { | |
| 20 | 20 | $this->parameters = $parameters; | 
| 21 | 21 | } | 
| 22 | 22 | |
| @@ -24,20 +24,20 @@ discard block | ||
| 24 | 24 | * @param SubjectCollection $pages | 
| 25 | 25 | * @return Event[] | 
| 26 | 26 | */ | 
| 27 | -	public function extractEvents( SubjectCollection $pages ): array { | |
| 27 | +	public function extractEvents(SubjectCollection $pages): array { | |
| 28 | 28 | $events = []; | 
| 29 | 29 | |
| 30 | -		foreach ( $pages->getSubjects() as $subject ) { | |
| 31 | - [ $startDate, $endDate ] = $this->getDates( $subject ); | |
| 30 | +		foreach ($pages->getSubjects() as $subject) { | |
| 31 | + [$startDate, $endDate] = $this->getDates($subject); | |
| 32 | 32 | |
| 33 | -			if ( $startDate !== null ) { | |
| 34 | - $event = new Event( $subject, $startDate, $endDate ); | |
| 33 | +			if ($startDate !== null) { | |
| 34 | + $event = new Event($subject, $startDate, $endDate); | |
| 35 | 35 | |
| 36 | -				foreach ( $subject->getPropertyValueCollections() as $propertyValues ) { | |
| 37 | -					if ( $propertyValues->getPrintRequest()->getText( null ) === $this->parameters['image property'] ) { | |
| 38 | -						foreach ( $propertyValues->getDataItems() as $dataItem ) { | |
| 39 | -							if ( $this->isImageValue( $dataItem ) ) { | |
| 40 | - $event->setImageUrl( $this->getUrlForFileTitle( $dataItem->getTitle() ) ); | |
| 36 | +				foreach ($subject->getPropertyValueCollections() as $propertyValues) { | |
| 37 | +					if ($propertyValues->getPrintRequest()->getText(null) === $this->parameters['image property']) { | |
| 38 | +						foreach ($propertyValues->getDataItems() as $dataItem) { | |
| 39 | +							if ($this->isImageValue($dataItem)) { | |
| 40 | + $event->setImageUrl($this->getUrlForFileTitle($dataItem->getTitle())); | |
| 41 | 41 | } | 
| 42 | 42 | } | 
| 43 | 43 | } | 
| @@ -50,50 +50,50 @@ discard block | ||
| 50 | 50 | return $events; | 
| 51 | 51 | } | 
| 52 | 52 | |
| 53 | -	private function isImageValue( \SMWDataItem $dataItem ) { | |
| 53 | +	private function isImageValue(\SMWDataItem $dataItem) { | |
| 54 | 54 | return $dataItem instanceof DIWikiPage | 
| 55 | 55 | && $dataItem->getTitle() instanceof \Title | 
| 56 | 56 | && $dataItem->getTitle()->getNamespace() === NS_FILE | 
| 57 | 57 | && $dataItem->getTitle()->exists(); | 
| 58 | 58 | } | 
| 59 | 59 | |
| 60 | -	public function getUrlForFileTitle( \Title $existingTitle ): string { | |
| 61 | -		if ( method_exists( MediaWikiServices::class, 'getRepoGroup' ) ) { | |
| 60 | +	public function getUrlForFileTitle(\Title $existingTitle): string { | |
| 61 | +		if (method_exists(MediaWikiServices::class, 'getRepoGroup')) { | |
| 62 | 62 | // MediaWiki 1.34+ | 
| 63 | - return MediaWikiServices::getInstance()->getRepoGroup()->findFile( $existingTitle )->getURL(); | |
| 63 | + return MediaWikiServices::getInstance()->getRepoGroup()->findFile($existingTitle)->getURL(); | |
| 64 | 64 |  		} else { | 
| 65 | - return RepoGroup::singleton()->findFile( $existingTitle )->getURL(); | |
| 65 | + return RepoGroup::singleton()->findFile($existingTitle)->getURL(); | |
| 66 | 66 | } | 
| 67 | 67 | } | 
| 68 | 68 | |
| 69 | -	private function getDates( Subject $subject ): array { | |
| 69 | +	private function getDates(Subject $subject): array { | |
| 70 | 70 | $startDate = null; | 
| 71 | 71 | $endDate = null; | 
| 72 | 72 | |
| 73 | -		foreach ( $this->getPropertyValueCollectionsWithDates( $subject ) as $propertyValues ) { | |
| 73 | +		foreach ($this->getPropertyValueCollectionsWithDates($subject) as $propertyValues) { | |
| 74 | 74 | $dataItem = $propertyValues->getDataItems()[0]; | 
| 75 | 75 | |
| 76 | -			if ( $dataItem instanceof SMWDITime ) { | |
| 77 | -				if ( $startDate === null ) { | |
| 76 | +			if ($dataItem instanceof SMWDITime) { | |
| 77 | +				if ($startDate === null) { | |
| 78 | 78 | $startDate = $dataItem; | 
| 79 | 79 | } | 
| 80 | -				else if ( $endDate === null ) { | |
| 80 | +				else if ($endDate === null) { | |
| 81 | 81 | $endDate = $dataItem; | 
| 82 | 82 | break; | 
| 83 | 83 | } | 
| 84 | 84 | } | 
| 85 | 85 | } | 
| 86 | 86 | |
| 87 | - return [ $startDate, $endDate ]; | |
| 87 | + return [$startDate, $endDate]; | |
| 88 | 88 | } | 
| 89 | 89 | |
| 90 | 90 | /** | 
| 91 | 91 | * @return PropertyValueCollection[] | 
| 92 | 92 | */ | 
| 93 | -	private function getPropertyValueCollectionsWithDates( Subject $subject ) { | |
| 93 | +	private function getPropertyValueCollectionsWithDates(Subject $subject) { | |
| 94 | 94 | return array_filter( | 
| 95 | 95 | $subject->getPropertyValueCollections()->toArray(), | 
| 96 | -			function( PropertyValueCollection $pvc ) { | |
| 96 | +			function(PropertyValueCollection $pvc) { | |
| 97 | 97 | return $pvc->getPrintRequest()->getTypeID() === '_dat' | 
| 98 | 98 | && $pvc->getDataItems() !== []; | 
| 99 | 99 | } | 
| @@ -76,8 +76,7 @@ | ||
| 76 | 76 |  			if ( $dataItem instanceof SMWDITime ) { | 
| 77 | 77 |  				if ( $startDate === null ) { | 
| 78 | 78 | $startDate = $dataItem; | 
| 79 | - } | |
| 80 | -				else if ( $endDate === null ) { | |
| 79 | +				} else if ( $endDate === null ) { | |
| 81 | 80 | $endDate = $dataItem; | 
| 82 | 81 | break; | 
| 83 | 82 | } | 
| @@ -1,6 +1,6 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); | |
| 3 | +declare(strict_types=1); | |
| 4 | 4 | |
| 5 | 5 | namespace ModernTimeline; | 
| 6 | 6 | |
| @@ -29,13 +29,13 @@ discard block | ||
| 29 | 29 | $definitions[self::PARAM_WIDTH] = [ | 
| 30 | 30 | 'type' => ParameterTypes::DIMENSION, | 
| 31 | 31 | 'allowauto' => true, | 
| 32 | - 'units' => [ 'px', 'ex', 'em', '%', '' ], | |
| 32 | + 'units' => ['px', 'ex', 'em', '%', ''], | |
| 33 | 33 | 'default' => $GLOBALS['wgModernTimelineWidth'], | 
| 34 | 34 | ]; | 
| 35 | 35 | |
| 36 | 36 | $definitions[self::PARAM_HEIGHT] = [ | 
| 37 | 37 | 'type' => ParameterTypes::DIMENSION, | 
| 38 | - 'units' => [ 'px', 'ex', 'em', '' ], | |
| 38 | + 'units' => ['px', 'ex', 'em', ''], | |
| 39 | 39 | 'default' => $GLOBALS['wgModernTimelineHeight'], | 
| 40 | 40 | ]; | 
| 41 | 41 | |
| @@ -58,7 +58,7 @@ discard block | ||
| 58 | 58 | $definitions[self::PARAM_POSITION] = [ | 
| 59 | 59 | 'type' => ParameterTypes::STRING, | 
| 60 | 60 | 'default' => $GLOBALS['wgModernTimelinePosition'], | 
| 61 | - 'values' => [ 'top', 'bottom' ], | |
| 61 | + 'values' => ['top', 'bottom'], | |
| 62 | 62 | ]; | 
| 63 | 63 | |
| 64 | 64 | $definitions[self::PARAM_TICK_WIDTH] = [ | 
| @@ -86,7 +86,7 @@ discard block | ||
| 86 | 86 | |
| 87 | 87 | $definitions[self::PARAM_NAV_HEIGHT] = [ | 
| 88 | 88 | 'type' => ParameterTypes::DIMENSION, | 
| 89 | - 'units' => [ 'px', '%' ], | |
| 89 | + 'units' => ['px', '%'], | |
| 90 | 90 | 'default' => $GLOBALS['wgModernTimelineNavHeight'], | 
| 91 | 91 | ]; | 
| 92 | 92 | |
| @@ -98,16 +98,16 @@ discard block | ||
| 98 | 98 | $definitions[self::PARAM_IMAGE] = [ | 
| 99 | 99 | 'type' => ParameterTypes::STRING, | 
| 100 | 100 | 'default' => $GLOBALS['wgModernTimelineImageProperty'], | 
| 101 | - 'aliases' => [ 'imageproperty', 'image' ], | |
| 101 | + 'aliases' => ['imageproperty', 'image'], | |
| 102 | 102 | ]; | 
| 103 | 103 | |
| 104 | -		foreach ( $definitions as $name => $definition ) { | |
| 105 | - $definitions[$name]['message'] = 'modern-timeline-param-' . str_replace( ' ', '-', $name ); | |
| 104 | +		foreach ($definitions as $name => $definition) { | |
| 105 | +			$definitions[$name]['message'] = 'modern-timeline-param-' . str_replace(' ', '-', $name); | |
| 106 | 106 | |
| 107 | -			if ( strpos( $name, ' ' ) !== false ) { | |
| 107 | +			if (strpos($name, ' ') !== false) { | |
| 108 | 108 | $definitions[$name]['aliases'] = array_merge( | 
| 109 | - array_key_exists( 'aliases', $definitions[$name] ) ? (array)$definitions[$name]['aliases'] : [], | |
| 110 | - [ str_replace( ' ', '', $name ) ] | |
| 109 | +					array_key_exists('aliases', $definitions[$name]) ? (array)$definitions[$name]['aliases'] : [], | |
| 110 | +					[str_replace(' ', '', $name)] | |
| 111 | 111 | ); | 
| 112 | 112 | } | 
| 113 | 113 | } | 
| @@ -119,31 +119,31 @@ discard block | ||
| 119 | 119 | * @param array $parameters | 
| 120 | 120 | * @return array | 
| 121 | 121 | */ | 
| 122 | -	public static function processedParamsToJson( array $parameters ): array { | |
| 122 | +	public static function processedParamsToJson(array $parameters): array { | |
| 123 | 123 | $json = [ | 
| 124 | 124 | 'hash_bookmark' => $parameters[self::PARAM_BOOKMARK], | 
| 125 | 125 | 'default_bg_color' => $parameters[self::PARAM_BACKGROUND], | 
| 126 | 126 | 'scale_factor' => $parameters[self::PARAM_SCALE_FACTOR], | 
| 127 | 127 | 'timenav_position' => $parameters[self::PARAM_POSITION], | 
| 128 | 128 | 'optimal_tick_width' => $parameters[self::PARAM_TICK_WIDTH], | 
| 129 | - 'start_at_slide' => self::getStartAtSlide( $parameters ), | |
| 129 | + 'start_at_slide' => self::getStartAtSlide($parameters), | |
| 130 | 130 | 'start_at_end' => $parameters[self::PARAM_START_AT_END], | 
| 131 | 131 | 'duration' => $parameters[self::PARAM_TRANSITION_DURATION], | 
| 132 | 132 | ]; | 
| 133 | 133 | |
| 134 | 134 | $height = $parameters[self::PARAM_NAV_HEIGHT]; | 
| 135 | 135 | |
| 136 | -		if ( strpos( $height, '%' ) === false ) { | |
| 137 | - $json['timenav_height'] = (int)substr( $height, 0, -2 ); | |
| 136 | +		if (strpos($height, '%') === false) { | |
| 137 | + $json['timenav_height'] = (int)substr($height, 0, -2); | |
| 138 | 138 | } | 
| 139 | 139 |  		else { | 
| 140 | - $json['timenav_height_percentage'] = (int)substr( $height, 0, -1 ); | |
| 140 | + $json['timenav_height_percentage'] = (int)substr($height, 0, -1); | |
| 141 | 141 | } | 
| 142 | 142 | |
| 143 | 143 | return $json; | 
| 144 | 144 | } | 
| 145 | 145 | |
| 146 | -	private static function getStartAtSlide( array $parameters ): int { | |
| 146 | +	private static function getStartAtSlide(array $parameters): int { | |
| 147 | 147 | return $parameters[self::PARAM_START_SLIDE] - 1; | 
| 148 | 148 | } | 
| 149 | 149 | |
| @@ -135,8 +135,7 @@ | ||
| 135 | 135 | |
| 136 | 136 |  		if ( strpos( $height, '%' ) === false ) { | 
| 137 | 137 | $json['timenav_height'] = (int)substr( $height, 0, -2 ); | 
| 138 | - } | |
| 139 | -		else { | |
| 138 | +		} else { | |
| 140 | 139 | $json['timenav_height_percentage'] = (int)substr( $height, 0, -1 ); | 
| 141 | 140 | } | 
| 142 | 141 | |
| @@ -1,6 +1,6 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); | |
| 3 | +declare(strict_types=1); | |
| 4 | 4 | |
| 5 | 5 | namespace ModernTimeline\SlidePresenter; | 
| 6 | 6 | |
| @@ -12,41 +12,41 @@ discard block | ||
| 12 | 12 | |
| 13 | 13 | private $parameters; | 
| 14 | 14 | |
| 15 | -	public function __construct( array $parameters ) { | |
| 15 | +	public function __construct(array $parameters) { | |
| 16 | 16 | $this->parameters = $parameters; | 
| 17 | 17 | } | 
| 18 | 18 | |
| 19 | -	public function getText( Subject $subject ): string { | |
| 20 | - return implode( '<br>', iterator_to_array( $this->getDisplayValues( $subject ) ) ); | |
| 19 | +	public function getText(Subject $subject): string { | |
| 20 | +		return implode('<br>', iterator_to_array($this->getDisplayValues($subject))); | |
| 21 | 21 | } | 
| 22 | 22 | |
| 23 | -	private function getDisplayValues( Subject $subject ) { | |
| 24 | -		foreach ( $subject->getPropertyValueCollections() as $propertyValues ) { | |
| 25 | -			foreach ( $propertyValues->getDataItems() as $dataItem ) { | |
| 26 | -				if ( !$this->isHiddenPrintRequest( $propertyValues->getPrintRequest() ) ) { | |
| 27 | - yield $this->getDisplayValue( $propertyValues->getPrintRequest(), $dataItem ); | |
| 23 | +	private function getDisplayValues(Subject $subject) { | |
| 24 | +		foreach ($subject->getPropertyValueCollections() as $propertyValues) { | |
| 25 | +			foreach ($propertyValues->getDataItems() as $dataItem) { | |
| 26 | +				if (!$this->isHiddenPrintRequest($propertyValues->getPrintRequest())) { | |
| 27 | + yield $this->getDisplayValue($propertyValues->getPrintRequest(), $dataItem); | |
| 28 | 28 | } | 
| 29 | 29 | } | 
| 30 | 30 | } | 
| 31 | 31 | } | 
| 32 | 32 | |
| 33 | -	private function isHiddenPrintRequest( PrintRequest $pr ) { | |
| 34 | - return $pr->getText( null ) === $this->parameters['image property']; | |
| 33 | +	private function isHiddenPrintRequest(PrintRequest $pr) { | |
| 34 | + return $pr->getText(null) === $this->parameters['image property']; | |
| 35 | 35 | } | 
| 36 | 36 | |
| 37 | -	private function getDisplayValue( PrintRequest $pr, \SMWDataItem $dataItem ) { | |
| 38 | - $property = $pr->getText( null ); | |
| 39 | - $value = $this->dataItemToText( $dataItem ); | |
| 37 | +	private function getDisplayValue(PrintRequest $pr, \SMWDataItem $dataItem) { | |
| 38 | + $property = $pr->getText(null); | |
| 39 | + $value = $this->dataItemToText($dataItem); | |
| 40 | 40 | |
| 41 | -		if ( $property === '' ) { | |
| 41 | +		if ($property === '') { | |
| 42 | 42 | return $value; | 
| 43 | 43 | } | 
| 44 | 44 | |
| 45 | 45 | return $property . ': ' . $value; | 
| 46 | 46 | } | 
| 47 | 47 | |
| 48 | -	private function dataItemToText( \SMWDataItem $dataItem ): string { | |
| 49 | - return DataValueFactory::getInstance()->newDataValueByItem( $dataItem )->getLongHTMLText(); | |
| 48 | +	private function dataItemToText(\SMWDataItem $dataItem): string { | |
| 49 | + return DataValueFactory::getInstance()->newDataValueByItem($dataItem)->getLongHTMLText(); | |
| 50 | 50 | } | 
| 51 | 51 | |
| 52 | 52 | } | 
| @@ -1,6 +1,6 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); | |
| 3 | +declare(strict_types=1); | |
| 4 | 4 | |
| 5 | 5 | namespace ModernTimeline\SlidePresenter; | 
| 6 | 6 | |
| @@ -8,6 +8,6 @@ discard block | ||
| 8 | 8 | |
| 9 | 9 |  interface SlidePresenter { | 
| 10 | 10 | |
| 11 | - public function getText( Subject $subject ): string; | |
| 11 | + public function getText(Subject $subject): string; | |
| 12 | 12 | |
| 13 | 13 | } | 
| @@ -1,6 +1,6 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); | |
| 3 | +declare(strict_types=1); | |
| 4 | 4 | |
| 5 | 5 | namespace ModernTimeline\SlidePresenter; | 
| 6 | 6 | |
| @@ -13,15 +13,15 @@ discard block | ||
| 13 | 13 | |
| 14 | 14 | private $templateName; | 
| 15 | 15 | |
| 16 | -	public function __construct( string $templateName ) { | |
| 16 | +	public function __construct(string $templateName) { | |
| 17 | 17 | $this->templateName = $templateName; | 
| 18 | 18 | } | 
| 19 | 19 | |
| 20 | -	public function getText( Subject $subject ): string { | |
| 20 | +	public function getText(Subject $subject): string { | |
| 21 | 21 | $parser = $this->getParser(); | 
| 22 | 22 | |
| 23 | 23 | return $parser->recursiveTagParseFully( | 
| 24 | - ( new TemplateSlidePresenter( $this->templateName ) )->getTemplateText( $subject ) | |
| 24 | + (new TemplateSlidePresenter($this->templateName))->getTemplateText($subject) | |
| 25 | 25 | ); | 
| 26 | 26 | } | 
| 27 | 27 | |
| @@ -29,21 +29,21 @@ discard block | ||
| 29 | 29 | return MediaWikiServices::getInstance()->getParser(); | 
| 30 | 30 | } | 
| 31 | 31 | |
| 32 | -	public function getTemplateText( Subject $subject ): string { | |
| 33 | -		return '{{' . implode( '|', $this->getTemplateSegments( $subject ) ) . '}}'; | |
| 32 | +	public function getTemplateText(Subject $subject): string { | |
| 33 | +		return '{{' . implode('|', $this->getTemplateSegments($subject)) . '}}'; | |
| 34 | 34 | } | 
| 35 | 35 | |
| 36 | -	private function getTemplateSegments( Subject $subject ): array { | |
| 36 | +	private function getTemplateSegments(Subject $subject): array { | |
| 37 | 37 | return array_merge( | 
| 38 | 38 | [ | 
| 39 | 39 | $this->templateName, | 
| 40 | - $this->parameter( 'title', $subject->getWikiPage()->getTitle()->getFullText() ) | |
| 40 | +				$this->parameter('title', $subject->getWikiPage()->getTitle()->getFullText()) | |
| 41 | 41 | ], | 
| 42 | 42 | array_map( | 
| 43 | -				function( PropertyValueCollection $pvc ) { | |
| 43 | +				function(PropertyValueCollection $pvc) { | |
| 44 | 44 | return $this->parameter( | 
| 45 | - $pvc->getPrintRequest()->getText( null ) ?? '', | |
| 46 | - $pvc->getDataItems() === [] ? '' : $this->dataItemToText( $pvc->getDataItems()[0] ) | |
| 45 | + $pvc->getPrintRequest()->getText(null) ?? '', | |
| 46 | + $pvc->getDataItems() === [] ? '' : $this->dataItemToText($pvc->getDataItems()[0]) | |
| 47 | 47 | ); | 
| 48 | 48 | }, | 
| 49 | 49 | $subject->getPropertyValueCollections()->toArray() | 
| @@ -51,11 +51,11 @@ discard block | ||
| 51 | 51 | ); | 
| 52 | 52 | } | 
| 53 | 53 | |
| 54 | -	private function dataItemToText( \SMWDataItem $dataItem ): string { | |
| 55 | - return DataValueFactory::getInstance()->newDataValueByItem( $dataItem )->getLongHTMLText(); | |
| 54 | +	private function dataItemToText(\SMWDataItem $dataItem): string { | |
| 55 | + return DataValueFactory::getInstance()->newDataValueByItem($dataItem)->getLongHTMLText(); | |
| 56 | 56 | } | 
| 57 | 57 | |
| 58 | -	private function parameter( string $name, string $value ): string { | |
| 58 | +	private function parameter(string $name, string $value): string { | |
| 59 | 59 | return $name . '=' . $value; | 
| 60 | 60 | } | 
| 61 | 61 | } | 
| @@ -1,6 +1,6 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); | |
| 3 | +declare(strict_types=1); | |
| 4 | 4 | |
| 5 | 5 | namespace ModernTimeline; | 
| 6 | 6 | |
| @@ -12,7 +12,7 @@ discard block | ||
| 12 | 12 | |
| 13 | 13 | private $slidePresenter; | 
| 14 | 14 | |
| 15 | -	public function __construct( SlidePresenter $slidePresenter ) { | |
| 15 | +	public function __construct(SlidePresenter $slidePresenter) { | |
| 16 | 16 | $this->slidePresenter = $slidePresenter; | 
| 17 | 17 | } | 
| 18 | 18 | |
| @@ -20,32 +20,32 @@ discard block | ||
| 20 | 20 | * @param Event[] $events | 
| 21 | 21 | * @return array | 
| 22 | 22 | */ | 
| 23 | -	public function eventsToTimelineJson( array $events ): array { | |
| 23 | +	public function eventsToTimelineJson(array $events): array { | |
| 24 | 24 | $jsonEvents = []; | 
| 25 | 25 | |
| 26 | -		foreach ( $events as $event ) { | |
| 27 | -			if ( $event->getSubject()->getWikiPage()->getTitle() !== null ) { | |
| 28 | - $jsonEvents[] = $this->buildEvent( $event ); | |
| 26 | +		foreach ($events as $event) { | |
| 27 | +			if ($event->getSubject()->getWikiPage()->getTitle() !== null) { | |
| 28 | + $jsonEvents[] = $this->buildEvent($event); | |
| 29 | 29 | } | 
| 30 | 30 | } | 
| 31 | 31 | |
| 32 | - return [ 'events' => $jsonEvents ]; | |
| 32 | + return ['events' => $jsonEvents]; | |
| 33 | 33 | } | 
| 34 | 34 | |
| 35 | -	public function buildEvent( Event $event ): array { | |
| 35 | +	public function buildEvent(Event $event): array { | |
| 36 | 36 | $jsonEvent = [ | 
| 37 | 37 | 'text' => [ | 
| 38 | - 'headline' => $this->newHeadline( $event->getSubject()->getWikiPage()->getTitle() ), | |
| 39 | - 'text' => $this->slidePresenter->getText( $event->getSubject() ) | |
| 38 | + 'headline' => $this->newHeadline($event->getSubject()->getWikiPage()->getTitle()), | |
| 39 | + 'text' => $this->slidePresenter->getText($event->getSubject()) | |
| 40 | 40 | ], | 
| 41 | - 'start_date' => $this->timeToJson( $event->getStartDate() ), | |
| 41 | + 'start_date' => $this->timeToJson($event->getStartDate()), | |
| 42 | 42 | ]; | 
| 43 | 43 | |
| 44 | -		if ( $event->getEndDate() !== null ) { | |
| 45 | - $jsonEvent['end_date'] = $this->timeToJson( $event->getEndDate() ); | |
| 44 | +		if ($event->getEndDate() !== null) { | |
| 45 | + $jsonEvent['end_date'] = $this->timeToJson($event->getEndDate()); | |
| 46 | 46 | } | 
| 47 | 47 | |
| 48 | -		if ( $event->hasImage() ) { | |
| 48 | +		if ($event->hasImage()) { | |
| 49 | 49 | $jsonEvent['media'] = [ | 
| 50 | 50 | 'url' => $event->getImageUrl(), | 
| 51 | 51 | 'thumbnail' => $event->getImageUrl() | 
| @@ -55,17 +55,17 @@ discard block | ||
| 55 | 55 | return $jsonEvent; | 
| 56 | 56 | } | 
| 57 | 57 | |
| 58 | -	private function newHeadline( \Title $title ): string { | |
| 58 | +	private function newHeadline(\Title $title): string { | |
| 59 | 59 | return \Html::element( | 
| 60 | 60 | 'a', | 
| 61 | - [ 'href' => $title->getFullURL() ], | |
| 61 | + ['href' => $title->getFullURL()], | |
| 62 | 62 | $title->getText() | 
| 63 | 63 | ); | 
| 64 | 64 | |
| 65 | 65 | // return DataValueFactory::getInstance()->newDataValueByItem( $subject->getWikiPage() )->getLongHTMLText( smwfGetLinker() ); | 
| 66 | 66 | } | 
| 67 | 67 | |
| 68 | -	private function timeToJson( SMWDITime $time ): array { | |
| 68 | +	private function timeToJson(SMWDITime $time): array { | |
| 69 | 69 | return [ | 
| 70 | 70 | 'year' => $time->getYear(), | 
| 71 | 71 | 'month' => $time->getMonth(), |