Extension talk:Page Forms

Improving doLookup function
Sometimes the address entered by the user is one that returns ZERO_RESULTS because it contains extra information before the street address (e.g. the name of the place), but would work fine if this information were removed.

There is no simple way to let the user know exactly how the Google geocoding API works, and it would be better to have the software do the work in any event, so I wonder whether it would be possible to change the doLookup function to do one or both of the following:

1. Use a regular expression to extract the postcode from the address (in the UK at least this is fairly easy) and perform a further search on this postcode if the original search returns ZERO_RESULTS.

2. Repeatedly/recursively remove everything up to the first comma (or perhaps also line return if textarea fields are being used) and perform a further lookup on what remains until it is successful. For example, first of all it might remove the place name, then perhaps the street name, until it is just left with the postcode.

Thanks in anticipation, and Happy New Year. Jonathan3 (talk) 01:12, 2 January 2017 (UTC)


 * Those both sound like they would be an improvement over the current state of things. Yaron Koren (talk) 02:12, 2 January 2017 (UTC)


 * Great. If I worked on this and sent you a patch, would you consider adding it to the code? (I wouldn't want to have to add it manually each time I update the extension.) Jonathan3 (talk) 20:25, 2 January 2017 (UTC) P.S. I've taken the liberty of correcting doMarker to doLookup in my previous comment. Jonathan3 (talk) 20:35, 2 January 2017 (UTC)


 * Yes, of course. Yaron Koren (talk) 21:54, 2 January 2017 (UTC)

"Edit with form" tab and "Template" namespace
I have created a Form:Template and a Project:Template page with contents:  but the "Edit with form" tab won't appear to "Template" namespace. PF 4.0.2 --Ioannis Protonotarios 01:42, 4 January 2017 (UTC) Happy New Year!

!P.S. The exact same thing works just fine in "Property" namespace. --Ioannis Protonotarios 01:44, 4 January 2017 (UTC)


 * Happy New Year! Have you defined the "Template" namespace on your wiki? Yaron Koren (talk) 05:04, 4 January 2017 (UTC)


 * What do you mean? It's a standard namespace. I haven't done anything myself, neither in "Property" namespace which is pre-defined too by SMW. --Ioannis Protonotarios 12:42, 4 January 2017 (UTC)


 * Oh, man... that's the last time I try to provide help after midnight. Disregard my last comment, of course. But I have to ask - how can you have a form to edit templates? That doesn't seem workable. Yaron Koren (talk) 16:19, 4 January 2017 (UTC)


 * Well, I've started building a meta-ontology to store data about the semantic structrure of my wiki, i.e. properties, concepts etc. For example, property X is subproperty of property Y, is used in template Z etc. And then I thought, why not assign properties to templates too? E.g. template A is used in template B, has template type C etc. All property definitions should obviously go inside a  tag and the template code inside a   tag. Then I thought, why not use forms? Since a form puts its wikitext in the begining of the page, and plain wikitext goes right after that, I figured that the workaround would be to use no   tags and wrap the actual template code in a   tag. Which I did and it worked! So now I can edit templates with forms just fine! The template code appears in the free text box. See example: Template:1080p view code view form. The only problem is what I've reported, that there is no "Edit with form" tab and that the   doesn't work. It asks "which form to use?", even though the form is defined in Project:Template. --Ioannis Protonotarios 17:39, 4 January 2017 (UTC)


 * That's strange - I can't replicate this issue; it works fine for me. I don't know what's causing it on your wiki. Try resaving the "Project:Template" page, maybe? Yaron Koren (talk) 17:54, 4 January 2017 (UTC)


 * Yes, the infamous "null edit"! But it doesn't work. Moreover, after rebuilding semantic data after the upgrade, now it seems that all "Edit with form" tabs have disappeared! --Ioannis Protonotarios 22:10, 4 January 2017 (UTC)


 * P.S. Auto-creation of pages has stopped working too. --Ioannis Protonotarios 22:14, 4 January 2017 (UTC)


 * This I think I've found it. I use the obsolete "Creates pages with form" property but I if undestand correctly I must now use the #formredlink function instead, right? --Ioannis Protonotarios 15:29, 5 January 2017 (UTC)


 * Okay, now that I've looked at your wiki, I'm pretty sure what the issue is for most of your forms - you're defining the relationship of form to category via Page Schemas, and within each schema, the "semanticforms_Form" tag (both closing and opening) needs to be modified to be "pageforms_Form". Sorry that this has been poorly documented. Yaron Koren (talk) 05:49, 5 January 2017 (UTC)


 * I've added a side note to Page Schemas documentation. Page Schemas is a very helpful extension for newbies because it easily creates a working semantic structure but I think I will completely remove it since creating things manually gives more control and you know what you are doing. As for the template/form issue maybe it's because of my MW 1.26.2 version. I think I saw somewhere a mention of compatibility issues with latest SMW. The problem is that Media Temple, my hosting provider, is still stuck in PHP 5.3.x (MW 1.27 requires PHP 5.5.9) and they won't tell us when and if they will ever upgrade it to 7. I've filed support requests on that and they always say that they are working on it. So right now I am stuck with MW 1.26.2. --Ioannis Protonotarios 15:29, 5 January 2017 (UTC)

regexp
Hi,

I am trying to improve increase validation on one of my forms with regexp but I don't seem to be getting any errors. I am competent with Page Forms but have never used regexp before. The example extract below is taken from a partial form (template)

|

I would have expected to get an error if I only entered a number but I get no error and the field is being passed back as though the regexp has had no effect. Can anyone advise?

MW 1.27.1, PF 4.0.2

Regards,

Mark


 * Oops! It looks like the "regexp" input hasn't worked since at least version 4.0, i.e. the extension rename, and maybe even earlier. I just checked in some fixes, so if you get the latest code it should work. Yaron Koren (talk) 16:05, 6 January 2017 (UTC)

"UNIQ" and "Some very long page name" strings
Hi Yaron, me again. I've started replacing "Creates pages with form" property with the #formredlink function as I said two threads above and it works (almost*) fine but while in the process of creating the new pages, some weird stuff appear on page: After all red link pages have been created, things go back to normal and appear as expected.
 * 1) #formredlink calls (red or blue) that are before the last #formredlink-to-be-created appear as "UNIQ--item-2--QINU, UNIQ--item-3--QINU, UNIQ--item-4--QINU, UNIQ--item-5--QINU, etc". #formredlink calls (blue) that follow the last #formredlink-to-be-created appear OK.
 * 2) At the same (i.e. while there are red link pages under creation), other links, that they are property declarations of type URL, appear as "Some very long page name that will hopefully never get created ABCDEF123".

Similar past issues:
 * 1) Work-around for un-populated red link A very long page name error (27 October 2014)
 * 2) "Create pages with form" and sfEditFormPreloadText (4 November 2013)

Notes:  *  I say "almost" because I haven't managed to employ "query string" parameter yet but I am still looking at it and if I don't succeed I will come back to report it officially.

--Ioannis Protonotarios 09:20, 6 January 2017 (UTC)

Relocating standard inputs to a different area of the page
Hi Yaron

Some time ago I seem to remember seeing an example of using Page Forms (or Semantic Forms as it then was) to relocate the standard inputs to a different location (eg the top) of the form. Was I just imagining this or, if not, would you be able to point me in the right direction?

Many thanks

Duncan 8th Jan 2017


 * Ah I think I've worked this out. I created a 'sub' form (as a template) and just transcluded this before the other parts of the form.  Seems to work anyway.  Many thanks.  Duncan


 * I think there is no need for a 'sub' form. You can just place any of the  anywhere you like in the form and multiple times if you like. For instance, in big forms I usually put the two main buttons save and preview  both at the top and at the bottom of the form, so as to be handy. --Ioannis Protonotarios 19:08, 8 January 2017 (UTC)

Have global settings changed with the move from SF to PF
Hi all, Yaron,

I'm facing some MW database issues that I'm trying to solve by cleaning my LocalSettings.php as much as possible. As such I came across $sfgNamespaceIndex which namespace I had set to 150. Is this variable still used in PF or renamed or is it save to remove this? Thanks, --Albert Ke (talk)


 * It was renamed - all the global variables had the "$sfg" in their name replaced with "$wgPageForms". I'm guessing you will still need to include that line in LocalSettings.php. Yaron Koren (talk) 19:40, 9 January 2017 (UTC)


 * Ok., so the variable becomes $wgPageFormsNamespaceIndex. I had the old SF variable directed to namespace 150 so set this new PF variable to it as well. However, when including this under the wfLoadExtension ('PageForms'), save and exit, then do a touch LocalSettings.php, even an php update.php in the maintenance folder, namespace 150 doesn't show up in the list: http://csdms.colorado.edu/mediawiki/api.php?action=query&meta=siteinfo&siprop=namespaces. Or did I miss anything? Thanks! --Albert Ke (talk)


 * Oh, never mind - looking through the code now, it looks like the namespace IDs are hardcoded and can't be changed, and it has been that way for a long time. I guess I had forgotten. So I think you can just remove that line. Yaron Koren (talk) 20:28, 9 January 2017 (UTC)


 * OK., perfect another potential database problem that is ruled out. Thanks, --Albert Ke (talk) 20:40, 9 January 2017 (UTC)

Internal Error:
Just updatet to newest MW & SMW. New PageForms causes Error, while old SemanticForms instead still works. Any ideas?

[9851f6842c7da4f513efdf25] /index.php/Hauptseite MWException from line 176 of C:\QMSSERV\htdocs\includes\Hooks.php: Invalid callback PFHooks::initProperties in hooks for smwInitProperties Backtrace:


 * 0 C:\QMSSERV\htdocs\extensions\SemanticMediaWiki\src\PropertyRegistry.php(420): Hooks::run(string)
 * 1 C:\QMSSERV\htdocs\extensions\SemanticMediaWiki\src\PropertyRegistry.php(79): SMW\PropertyRegistry->registerPredefinedProperties(boolean)
 * 2 C:\QMSSERV\htdocs\extensions\SemanticMediaWiki\includes\dataitems\SMW_DI_Property.php(86): SMW\PropertyRegistry::getInstance
 * 3 C:\QMSSERV\htdocs\extensions\SemanticMediaWiki\src\DataItemFactory.php(42): SMW\DIProperty->__construct(string, boolean)
 * 4 C:\QMSSERV\htdocs\extensions\SemanticMediaWiki\src\PropertyAnnotator\DisplayTitlePropertyAnnotator.php(66): SMW\DataItemFactory->newDIProperty(string)
 * 5 C:\QMSSERV\htdocs\extensions\SemanticMediaWiki\src\PropertyAnnotator\PropertyAnnotatorDecorator.php(61): SMW\PropertyAnnotator\DisplayTitlePropertyAnnotator->addPropertyValues
 * 6 C:\QMSSERV\htdocs\extensions\SemanticMediaWiki\src\MediaWiki\Hooks\ParserAfterTidy.php(117): SMW\PropertyAnnotator\PropertyAnnotatorDecorator->addAnnotation
 * 7 C:\QMSSERV\htdocs\extensions\SemanticMediaWiki\src\MediaWiki\Hooks\ParserAfterTidy.php(87): SMW\MediaWiki\Hooks\ParserAfterTidy->updateAnnotionsForAfterParse(SMW\PropertyAnnotatorFactory, SMW\SemanticData)
 * 8 C:\QMSSERV\htdocs\extensions\SemanticMediaWiki\src\MediaWiki\Hooks\ParserAfterTidy.php(53): SMW\MediaWiki\Hooks\ParserAfterTidy->performUpdate
 * 9 C:\QMSSERV\htdocs\extensions\SemanticMediaWiki\src\MediaWiki\Hooks\HookRegistry.php(126): SMW\MediaWiki\Hooks\ParserAfterTidy->process
 * 1) 10 [internal function]: SMW\MediaWiki\Hooks\HookRegistry->SMW\MediaWiki\Hooks\{closure}(Parser, string)
 * 2) 11 C:\QMSSERV\htdocs\includes\Hooks.php(195): call_user_func_array(Closure, array)
 * 3) 12 C:\QMSSERV\htdocs\includes\parser\Parser.php(1397): Hooks::run(string, array)
 * 4) 13 C:\QMSSERV\htdocs\includes\parser\Parser.php(444): Parser->internalParseHalfParsed(string, boolean, boolean)
 * 5) 14 C:\QMSSERV\htdocs\includes\content\WikitextContent.php(330): Parser->parse(string, Title, ParserOptions, boolean, boolean, integer)
 * 6) 15 C:\QMSSERV\htdocs\includes\content\AbstractContent.php(497): WikitextContent->fillParserOutput(Title, integer, ParserOptions, boolean, ParserOutput)
 * 7) 16 C:\QMSSERV\htdocs\includes\poolcounter\PoolWorkArticleView.php(140): AbstractContent->getParserOutput(Title, integer, ParserOptions)
 * 8) 17 C:\QMSSERV\htdocs\includes\poolcounter\PoolCounterWork.php(123): PoolWorkArticleView->doWork
 * 9) 18 C:\QMSSERV\htdocs\includes\page\Article.php(651): PoolCounterWork->execute
 * 10) 19 C:\QMSSERV\htdocs\includes\actions\ViewAction.php(71): Article->view
 * 11) 20 C:\QMSSERV\htdocs\includes\MediaWiki.php(495): ViewAction->show
 * 12) 21 C:\QMSSERV\htdocs\includes\MediaWiki.php(289): MediaWiki->performAction(Article, Title)
 * 13) 22 C:\QMSSERV\htdocs\includes\MediaWiki.php(851): MediaWiki->performRequest
 * 14) 23 C:\QMSSERV\htdocs\includes\MediaWiki.php(512): MediaWiki->main
 * 15) 24 C:\QMSSERV\htdocs\index.php(43): MediaWiki->run
 * 16) 25 {main}


 * I'm guessing you downloaded Page Forms via the Extension Distributor. You shouldn't do that - you should always download PF (or any of my extensions) via the main download link on the page. I wish the ED link weren't there at all. Sorry about that. Yaron Koren (talk) 17:51, 10 January 2017 (UTC)


 * solved this Problem. Thanks --Letofred (talk) 12:31, 11 January 2017 (UTC)

File-Upload and Handling
1) Got a probleme with uploding files via PageForms (4.0.2 on MW 1.28.0 SMW 2.4.4) ending in a Fatal error: Call to undefined method OutputPage::getHeadScripts in *****\extensions\PageForms\specials\PF_UploadForm.php on line 327

2) I have a form like this:

Creating a Page with this Form works fine. Edit this Page with formedit causes following problem: If I select the "Page" or "File" whitch is the first kind of it works as expected. If I select "Form" or "PDF / Pic" he wont get the "Pagename" or "Filename".

I used this way to schow a different Icon. This may helpful for users to know if its a internal (Page) or external Link (URL) or if he can view this in browser or need a different kind of program to view. I suspect, your just try to set the "pagename/filename" to the first field found. May I request to set every field found to the given "pagename/filename"?

My workaround would be to name them pagename1, pagename2 etc ... It wount satisfy me, if I upload first and later change the "kind" I forgott to set ... --Letofred (talk) 13:04, 11 January 2017 (UTC)


 * Hi - for #1, just delete that line - it was deleted a while ago in the main PF code, but I guess not before version 4.0.2 was released. Sorry about that. For #2, yes, you can't have more than one "field" tag for the same field name, even if only one of them is shown at a time - that's a limitation of PF. So yes, the easiest solution is to have different field names. Potentially, you could also turn those last three rows into just one row, and have "show on select" apply to just the "label" cell instead of the whole row - and then add three more "show on select" values, all applying to the same "field" cell. Does that make sense? Yaron Koren (talk) 15:10, 11 January 2017 (UTC)


 * #1 solved
 * #2 Think about your solution ... atm there seems no way to avoid a second selection. If I correctly read your suggestion, just giving the ID to the "label" / Picture will allways show the input field for the file - even if I dont select a kind of file - i.e. a page ... not the way it should look like ...
 * The use of classes instead of ID would be a nice solution. I could use {Class A} Pic1 {Class B} Pic2 {Class C} Pic3 {Class A B C} Form-Tag. Maybe a suggestion for a next version? Would cause problems with compatibility? --Letofred (talk) 17:32, 11 January 2017 (UTC)


 * No, the input field would not always be shown - but maybe it's too difficult to explain. Yes, it would have been better to go with class instead of ID, but yes, it would break compatibility at this point. Yaron Koren (talk) 17:36, 11 January 2017 (UTC)