Code Monkey home page Code Monkey logo

Comments (10)

krabina avatar krabina commented on June 16, 2024

It seems that the "file upload" functionality was intended to to attachments, not attach wiki pages?

// file attachments
$fileAttachmentHTML = '';
if( isset( $cegEnableFileAttachments ) && $cegEnableFileAttachments ) {
$fileAttachmentHTML = Xml::openElement( 'div',
array( 'id' => 'collabComFormFileAttachHelp' ) ) .
wfMessage( 'ce_cf_file_attach' )->text() . Xml::closeElement( 'div' ) .
Xml::input( 'collabComFormFileAttach', '', '',
array( 'id' => 'collabComFormFileAttach',
'class' => 'wickEnabled',
'pastens' => 'true'
)
);
if( isset( $cegUseRMUploadFunc ) && $cegUseRMUploadFunc
&& isset( $smwgEnableRichMedia ) && $smwgEnableRichMedia ) {
// we need an additional upload link that is connected to the input field
$uploadtext = 'Upload file';
$uploadTitle = 'Upload title';
$rmlWikiText = '{{#rml:' . wfMessage('ce_cf_file_upload_text')->text() . '|' .
wfMessage('ce_cf_file_upload_link')->text() . '|sfInputID=collabComFormFileAttach&sfDelimiter=' .
$cegDefaultDelimiter . '}}';
$fileAttachmentHTML .= Xml::openElement( 'span', array(
'id' => 'collabComFormFileAttachLink' ) ) .
$wgParser->recursiveTagParse( $rmlWikiText ) .
Xml::closeElement( 'span' );
}
}

Anyway, no upload dialog is shown.

from semanticcomments.

PeterTheOne avatar PeterTheOne commented on June 16, 2024

When I open the Comment directly (Comment:[...]) then the link works as expected, but when the comment is displayed elsewhere it fails just as you described.

from semanticcomments.

PeterTheOne avatar PeterTheOne commented on June 16, 2024

I narrowed it down to arraymapce

/**
* This function is equal to Semantic Form's parser function 'arraymap'
* to store attached articles as property values.
* We can skip a template like 'http://meta.wikimedia.org/wiki/Template:For' with this PF.
*
* {{#arraymapce:value|delimiter|var|formula|new_delimiter}}
*
* @param parser the parser object
* @param value
* @param delimiter the actual delimiter
* @param var the variable name
* @param formula the formula used to represent the new value
* @param delimiter the new delimiter
*/
static function renderArrayMap( &$parser, $value = '', $delimiter = ',', $var = 'x', $formula = 'x', $new_delimiter = ', ' ) {
wfProfileIn( __METHOD__ . ' [SemanticComments]' );
// let '\n' represent newlines - chances that anyone will
// actually need the '\n' literal are small
$delimiter = str_replace( '\n', "\n", $delimiter );
$actual_delimiter = $parser->mStripState->unstripNoWiki( $delimiter );
$new_delimiter = str_replace( '\n', "\n", $new_delimiter );
if ( $actual_delimiter == '' ) {
$values_array = preg_split( '/(.)/u', $value, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
} else {
$values_array = explode( $actual_delimiter, $value );
}
$results = array();
foreach ( $values_array as $cur_value ) {
$cur_value = trim( $cur_value );
// ignore a value if it's null
if ( $cur_value != '' ) {
// remove whitespaces
$results[] = str_replace( $var, $cur_value, $formula );
}
}
wfProfileOut( __METHOD__ . ' [SemanticComments]' );
return implode( $new_delimiter, $results );
}

which is a copy(?) of PageForms' arraymap

https://github.com/wikimedia/mediawiki-extensions-PageForms/blob/d495d9f1603230cc928dcf69effa9b69e566745b/includes/PF_ParserFunctions.php#L390-L433

which also has a arraymaptemplate

https://github.com/wikimedia/mediawiki-extensions-PageForms/blob/d495d9f1603230cc928dcf69effa9b69e566745b/includes/PF_ParserFunctions.php#L435-L477
.
See also https://www.mediawiki.org/wiki/Extension:Page_Forms/Page_Forms_and_templates

from semanticcomments.

PeterTheOne avatar PeterTheOne commented on June 16, 2024

Ok, I think I know whats going on: when linking to a file description page you would use [[:File:somefile.jpg]] instead of [[File:somefile.jpg]] (Which would display the file directly). But then again if the files doesn't exist this doesn't link to the file upload page but to the dialog of creating a new page.

from semanticcomments.

PeterTheOne avatar PeterTheOne commented on June 16, 2024

I tried
{{#arraymapce:{{{10|}}}|,|x|{{#ifexist: x|[[:x]]|[x]}}| }}
instead of
{{#arraymapce:{{{10|}}}|,|x|[[:x]]|[x]| }}
within Template:CommentResult, which doesn't seem to work (Because of arraymapce, I guess).
{{#ifexist:{{{10|}}}|[[:{{{10|}}}]]|[[{{{10|}}}]]}} works without arraymapce, but only for one attachment and not multiple.

from semanticcomments.

PeterTheOne avatar PeterTheOne commented on June 16, 2024

One solution would be to implement arraymaptemplate https://www.mediawiki.org/wiki/Extension:Page_Forms/Page_Forms_and_templates#arraymaptemplate for SC and use the ifexists in arraymaptemplate.

from semanticcomments.

PeterTheOne avatar PeterTheOne commented on June 16, 2024

Ok, I found a way to make it work:

  • Install Extension Page Forms.
  • Create a template: Template:AttachedArticle: {{#ifexist:{{{1|}}}|[[:{{{1|}}}]]|[[{{{1|}}}]]}}
  • Change Template:CommentResult attached articles to: {{#arraymaptemplate:{{{10|}}}|AttachedArticle|,| }}

from semanticcomments.

mwjames avatar mwjames commented on June 16, 2024

Install Extension Page Forms.

Are you proposing to make PF a hard dependency for SemanticComments in order to support this feature? Not sure I like the idea. Can you disable that part and only enable it in case PF is available?

from semanticcomments.

PeterTheOne avatar PeterTheOne commented on June 16, 2024

@mwjames No, I wouldn't want that. Maybe do as you said or try to copy that function.

from semanticcomments.

kghbln avatar kghbln commented on June 16, 2024

This extension was abandoned. See #25 for further details and an alternative.

from semanticcomments.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.