SemanticMediaWiki /
SemanticInterlanguageLinks
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace SIL; |
||
| 4 | |||
| 5 | use SMW\ParserData; |
||
| 6 | use SMW\Subobject; |
||
| 7 | use SMW\DIProperty; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * @license GNU GPL v2+ |
||
| 11 | * @since 1.0 |
||
| 12 | * |
||
| 13 | * @author mwjames |
||
| 14 | */ |
||
| 15 | class LanguageLinkAnnotator { |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var ParserData |
||
| 19 | */ |
||
| 20 | private $parserData; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @since 1.0 |
||
| 24 | * |
||
| 25 | * @param ParserData $parserData |
||
| 26 | */ |
||
| 27 | 14 | public function __construct( ParserData $parserData ) { |
|
| 28 | 14 | $this->parserData = $parserData; |
|
| 29 | 14 | } |
|
| 30 | |||
| 31 | /** |
||
| 32 | * @since 1.0 |
||
| 33 | * |
||
| 34 | * @param InterlanguageLink $interlanguageLink |
||
| 35 | * |
||
| 36 | * @return boolean |
||
| 37 | */ |
||
| 38 | 9 | public function hasDifferentLanguageAnnotation( InterlanguageLink $interlanguageLink ) { |
|
| 39 | |||
| 40 | 9 | $propertyValues = $this->parserData->getSemanticData()->getPropertyValues( |
|
| 41 | 9 | new DIProperty( PropertyRegistry::SIL_CONTAINER ) |
|
| 42 | 9 | ); |
|
| 43 | |||
| 44 | 9 | foreach ( $propertyValues as $value ) { |
|
| 45 | 2 | if ( $value->getSubobjectname() !== $interlanguageLink->getContainerId() ) { |
|
| 46 | 2 | return true; |
|
| 47 | } |
||
| 48 | 8 | } |
|
| 49 | |||
| 50 | 8 | return false; |
|
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @since 1.3 |
||
| 55 | * |
||
| 56 | * @return boolean |
||
| 57 | */ |
||
| 58 | 8 | public function canAddAnnotation() { |
|
| 59 | |||
| 60 | 8 | if ( method_exists( $this->parserData, 'canModifySemanticData' ) ) { |
|
| 61 | return $this->parserData->canModifySemanticData(); |
||
|
0 ignored issues
–
show
|
|||
| 62 | } |
||
| 63 | |||
| 64 | // SMW 3.0 |
||
| 65 | 8 | if ( method_exists( $this->parserData, 'canUse' ) ) { |
|
| 66 | 8 | return $this->parserData->canUse(); |
|
| 67 | } |
||
| 68 | |||
| 69 | return true; |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @since 1.0 |
||
| 74 | * |
||
| 75 | * @param InterlanguageLink $interlanguageLink |
||
| 76 | */ |
||
| 77 | 8 | public function addAnnotationForInterlanguageLink( InterlanguageLink $interlanguageLink ) { |
|
| 78 | |||
| 79 | 8 | $subobject = new Subobject( $this->parserData->getTitle() ); |
|
| 80 | 8 | $subobject->setEmptyContainerForId( $interlanguageLink->getContainerId() ); |
|
| 81 | |||
| 82 | 8 | $subobject->getSemanticData()->addDataValue( |
|
| 83 | 8 | $interlanguageLink->newLanguageDataValue() |
|
| 84 | 8 | ); |
|
| 85 | |||
| 86 | 8 | $subobject->getSemanticData()->addDataValue( |
|
| 87 | 8 | $interlanguageLink->newLinkReferenceDataValue() |
|
| 88 | 8 | ); |
|
| 89 | |||
| 90 | 8 | $this->parserData->getSemanticData()->addPropertyObjectValue( |
|
| 91 | 8 | $interlanguageLink->newContainerProperty(), |
|
| 92 | 8 | $subobject->getContainer() |
|
| 93 | 8 | ); |
|
| 94 | |||
| 95 | 8 | $this->parserData->pushSemanticDataToParserOutput(); |
|
| 96 | 8 | $this->parserData->setSemanticDataStateToParserOutputProperty(); |
|
| 97 | 8 | } |
|
| 98 | |||
| 99 | /** |
||
| 100 | * @since 1.0 |
||
| 101 | * |
||
| 102 | * @param InterwikiLanguageLink $interwikiLanguageLink |
||
| 103 | */ |
||
| 104 | 2 | public function addAnnotationForInterwikiLanguageLink( InterwikiLanguageLink $interwikiLanguageLink ) { |
|
| 105 | |||
| 106 | 2 | $subobject = new Subobject( $this->parserData->getTitle() ); |
|
| 107 | 2 | $subobject->setEmptyContainerForId( $interwikiLanguageLink->getContainerId() ); |
|
| 108 | |||
| 109 | 2 | $subobject->getSemanticData()->addDataValue( |
|
| 110 | 2 | $interwikiLanguageLink->newLanguageDataValue() |
|
| 111 | 2 | ); |
|
| 112 | |||
| 113 | 2 | $subobject->getSemanticData()->addDataValue( |
|
| 114 | 2 | $interwikiLanguageLink->newInterwikiReferenceDataValue() |
|
| 115 | 2 | ); |
|
| 116 | |||
| 117 | 2 | $this->parserData->getSemanticData()->addPropertyObjectValue( |
|
| 118 | 2 | $interwikiLanguageLink->newContainerProperty(), |
|
| 119 | 2 | $subobject->getContainer() |
|
| 120 | 2 | ); |
|
| 121 | |||
| 122 | 2 | $this->parserData->pushSemanticDataToParserOutput(); |
|
| 123 | 2 | $this->parserData->setSemanticDataStateToParserOutputProperty(); |
|
| 124 | 2 | } |
|
| 125 | |||
| 126 | } |
||
| 127 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.