public function __construct( WCDataSegment $segment, WCRelativePositionEnum $positionEnum, WCLabelFormEnum $labelForm, WCTextCaseEnum $labelTextCase, WCLabelPluralEnum $labelPlural, $prefix = '', $suffix = '' ) { $this->segment = $segment; $this->positionEnum = $positionEnum; $this->labelForm = $labelForm; $this->labelTextCase = $labelTextCase; if ( $segment->exists() ) { $this->exists = True; } else { $this->exists = False; return; } switch ( $labelPlural->key ) { case WCLabelPluralEnum::contextual: if ( count( $segment ) > 1 ) { $this->plural = new WCPluralEnum( WCPluralEnum::plural ); } else { $this->plural = new WCPluralEnum( WCPluralEnum::singular ); } break; case WCLabelPluralEnum::always: $this->plural = new WCPluralEnum( WCPluralEnum::plural ); break; case WCLabelPluralEnum::never: $this->plural = new WCPluralEnum( WCPluralEnum::singular ); } }
public function __construct( WCCitation $citation, WCSegmentImportance $importance, WCScopeEnum $scope, WCPropertyEnum $propertyType, $prefix = '', $suffix = '' ) { parent::__construct( $citation, $prefix, $suffix ); switch( $importance->key ) { case WCSegmentImportance::mandatory: $this->textObject = $citation->reference->inferProperty( $scope, $propertyType ); $this->exists = True; return; case WCSegmentImportance::important: $this->textObject = $citation->reference->inferProperty( $scope, $propertyType ); $this->exists = (bool) $this->textObject; break; case WCSegmentImportance::optional: $textObject = $citation->reference->getProperty( $scope, $propertyType ); if ( isset( $textObject ) ) { $this->textObject = $textObject; $this->exists = True; } else { $this->exists = False; } } # $scope and $propertyType may have changed as a side-effect of $citation->inferProperty. $this->scope = $scope; $this->propertyType = $propertyType; }
public function __construct( WCCitation $citation, WCSegmentImportance $importance, WCScopeEnum $scope, WCPropertyEnum $propertyType, WCTitleFormat $titleFormat, $prefix = '', $suffix = '' ) { parent::__construct( $citation, $prefix, $suffix ); $this->titleFormat = $titleFormat; switch( $importance->key ) { case WCSegmentImportance::mandatory: $this->titleObject = $citation->reference->inferProperty( $scope, $propertyType ); $this->exists = True; return; case WCSegmentImportance::important: $this->titleObject = $citation->reference->inferProperty( $scope, $propertyType ); $this->exists = (bool) $this->titleObject; break; case WCSegmentImportance::optional: $titleObject = &$citation->properties[ $scope->key ][ $propertyType->key ]; if ( isset( $titleObject ) ) { $this->titleObject = $titleObject; $this->exists = True; } else { $this->exists = False; } } # $scope and $propertyType may have changed by now. $this->scope = $scope; $this->propertyType = $propertyType; }
public function __construct( WCCitation $citation, WCSegmentImportance $importance, WCScopeEnum $scope, WCPropertyEnum $propertyType, WCDateParts $datePart, WCDateOrder $dateOrder, WCDateForm $dateForm, WCDateRange $dateRange, $prefix = '', $suffix = '' ) { parent::__construct( $citation, $prefix, $suffix ); $this->datePart = $datePart; $this->dateOrder = $dateOrder; $this->dateForm = $dateForm; $this->rangePart = $dateRange; switch( $importance->key ) { case WCSegmentImportance::mandatory: $this->$dateObject = $citation->reference->inferProperty( $scope, $propertyType ); $this->exists = True; return; case WCSegmentImportance::important: $this->dateObject = $citation->reference->inferProperty( $scope, $propertyType ); $this->exists = (bool) $this->dateObject; break; case WCSegmentImportance::optional: $dateObject = $citation->reference->getProperty( $scope, $propertyType ); if ( isset( $dateObject ) ) { $this->dateObject = $dateObject; } else { $this->exists = False; } } # $scope and $propertyType may have changed as a side-effect of $citation->inferProperty. $this->scope = $scope; $this->propertyType = $propertyType; # Determine if the date is a range and if so, where the point of difference is. if ( isset ( $this->dateObject->year2 ) ) { $this->rangePointOfDifference = WCDateParts::year; } elseif ( isset ( $this->dateObject->month2 ) ) { $this->rangePointOfDifference = WCDateParts::month; } elseif ( isset ( $this->dateObject->day2 ) ) { $this->rangePointOfDifference = WCDateParts::day; } elseif ( isset ( $this->dateObject->season2 ) ) { $this->rangePointOfDifference = WCDateParts::season; } else { $this->rangePointOfDifference = WCDateParts::none; } }
public function __construct( WCCitation $citation, WCSegmentImportance $importance, WCScopeEnum $scope, WCNameTypeEnum $nameType, WCCitationPosition $citationPosition, WCCitationLengthEnum $citationLength, $nameSort = False, $prefix = '', $suffix = '' ) { parent::__construct( $citation, $prefix, $suffix ); $this->citationPosition = $citationPosition; $this->citationLength = $citationLength; $this->nameSort = $nameSort; switch( $importance->key ) { case WCSegmentImportance::mandatory: $this->namesObject = $citation->reference->inferNames( $scope, $nameType ); $this->exists = True; break; case WCSegmentImportance::important: $this->namesObject = $citation->reference->inferNames( $scope, $nameType ); $this->exists = (bool) $this->namesObject; break; case WCSegmentImportance::optional: $namesObject = $citation->reference->getNames( $scope, $nameType ); if ( isset( $namesObject ) ) { $this->namesObject = $namesObject; $this->exists = True; } else { $this->exists = False; } } # $scope and $nameType may have changed as a side-effect of $citation->inferNames. $this->scope = $scope; $this->nameType = $nameType; }