-
-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow subobject nesting (subsubobjects) #3702
Comments
This won't work as each entity (meaning a subobject) needs a context of the embedding instance but you run into the same problems as described in (#3654) about how parser functions work in MW. The second There are other issues but (without having delved into it) I would guess above is a general show stopper for the proposed syntax . |
I guess a good alternative would be a
|
It doesn't work like this, the second |
Note that I wrote |
Besides the technical aspect, what is the use case here? What sort of data would require such construct? |
Articles that mention books with multiple editions. |
The following is a quick hack (untested == contains caveats yet to be found, no guarantees) but it should provide an idea of what is required to make the semi tree structure available (for example the change fails for SG [0]). For those who want (it ain't me) to implement this:
Whether this is a functionality we want to support or not (maintenance cost, hidden technical debt, errors that may arise due to hierarchy dependencies etc.) is a different discussion. Changes@@ -46,10 +46,12 @@ class SubobjectParserFunction {
* Fixed identifier that describes a property that can auto-linked the
* embeddedding subject
*/
const PARAM_LINKWITH = '@linkWith';
+ const PARAM_EMBEDDED = '@embedded';
+
/**
* @var ParserData
*/
protected $parserData;
@@ -81,10 +83,12 @@ class SubobjectParserFunction {
/**
* @var boolean
*/
private $isComparableContent = false;
+ private $embedded = false;
+
/**
* @since 1.9
*
* @param ParserData $parserData
* @param Subobject $subobject
@@ -167,11 +171,11 @@ class SubobjectParserFunction {
// An empty output in MW forces an extra <br> element.
//if ( $html == '' ) {
// $html = '<p></p>';
//}
- return $html;
+ return $html . $this->embedded;
}
protected function addDataValuesToSubobject( ParserParameterProcessor $parserParameterProcessor ) {
// Named subobjects containing a "." in the first five characters are
@@ -190,10 +194,11 @@ class SubobjectParserFunction {
$this->subobject->setEmptyContainerForId(
$id
);
+ $this->embedded = $this->embedded ? $id : '';
$subject = $this->subobject->getSubject();
foreach ( $parameters as $property => $values ) {
if ( $property === self::PARAM_SORTKEY ) {
@@ -202,10 +207,19 @@ class SubobjectParserFunction {
if ( $property === self::PARAM_CATEGORY ) {
$property = DIProperty::TYPE_CATEGORY;
}
+ if ( $property === 'Has subobject' ) {
+ $subSemanticData = $this->parserData->getSemanticData()->findSubSemanticData( end( $values ) );
+ $this->subobject->getSemanticData()->addPropertyObjectValue(
+ new DIProperty( '_SOBJ' ),
+ new \SMWDIContainer( $subSemanticData )
+ );
+ continue;
+ }
+
foreach ( $values as $value ) {
$dataValue = DataValueFactory::getInstance()->newDataValueByText(
$property,
$value,
@@ -251,10 +265,15 @@ class SubobjectParserFunction {
return [ $parameters, $id ];
}
private function preprocess( ParserParameterProcessor $parserParameterProcessor, $useFirst ) {
+ if ( $parserParameterProcessor->hasParameter( self::PARAM_EMBEDDED ) ) {
+ $this->embedded = true;
+ $parserParameterProcessor->removeParameterByKey( self::PARAM_EMBEDDED );
+ } Usage
Notes[0] |
We need a developer for implementation. Thus I added this enhancement to the "Enhancements and features" project as "open". Closing here. |
Setup and configuration
Issue
The #subobject parser function apparently cannot be nested, which can be desirable.
Syntax suggestion:
The text was updated successfully, but these errors were encountered: