Re: [SMW-devel] Set a SMW property programmatically in PHP?

2015-06-29 Thread Jason Ji
Hi Nischay, Markus, and Yaron,

Thanks for your feedback. I replied to Yaron but neglected to reply-all to
the list: I did indeed ended up going with just manually embedding a
{{#set:}} in the page programmatically because it seemed overall safer and
easier to manage. Cindy Cicalese actually gave me the same warning about
having to re-set the data on page refreshes. :)

--
Jason Ji
jason.y...@gmail.com

On Mon, Jun 29, 2015 at 2:06 PM, Nischay Nahata 
wrote:

> Hi Jason,
>
> As both the SMW gurus said it can be dangerous but I think there is a way
> to do it, I have a small implementation where I am already using it.
>
> For this to work you need to have the information stored in a second
> source as well to be able to update the information on page refreshes (I
> use a separate db table). The way to update this property-value is to use
> the updateDataBefore hook and update the value by fetching it from the
> alternate source - of course there is some redundancy here but I guess you
> already knew that by now.
>
> Regards,
> Nischay Nahata
>
> On Mon, Jun 29, 2015 at 9:37 PM, Markus Krötzsch <
> mar...@semantic-mediawiki.org> wrote:
>
>> On 29.06.2015 17:16, Yaron Koren wrote:
>> > Hi Jason,
>> >
>> > If you're talking about making a change to the semantic data of a page
>> > that is not reflected in that page's wikitext, that sounds like a bad
>> > idea - the new data would be removed as soon as the page was edited and
>> > saved again.
>>
>> Indeed, one has to be very careful here. The key is to make the change
>> at the correct place to ensure that the data is not lost on updates or
>> refreshs, which may not always trigger all MediaWiki hooks that you
>> would use during normal parsing. In particular, semantic data is always
>> secondary data which comes (mostly) from the content of the page and (in
>> rare cases) from other metadata of the page (as for SMW's Modification
>> date property).
>>
>> There are safe ways for setting properties from PHP, especially from
>> within own parser functions. SMW's own #set parser function has examples
>> on how to do this. Setting special properties like Modification date is
>> more tricky.
>>
>> What you are trying to do sounds dangerous though, since it seems that
>> you are trying to set the value of something that is controlled by
>> another extension. If this is the case, you should let the other
>> extension control it and insert into the page text whatever is necessary
>> to get the value that you want. You cannot change SMW data to be
>> different from what is actually given in the page -- doing so will only
>> cause a temporary inconsistency in the database that will be "fixed" as
>> soon as the page is stored/refreshed again. SMW data does not have an
>> independent existence or history. It must be regenerated reliably on
>> every refresh of the page.
>>
>> Regards,
>>
>> Markus
>>
>> >
>> > -Yaron
>> >
>> > On Thu, Jun 25, 2015 at 3:42 PM, Jason Ji > > <mailto:jason.y...@gmail.com>> wrote:
>> >
>> > Hi SMW community,
>> >
>> > I have a hopefully simple question. Is there a way to set an SMW
>> > property for a page programmatically in PHP? Suppose I have access
>> > to any of the relevant information, like the page ID.
>> >
>> > For context, I'm writing an extension which, among other things,
>> > creates wiki pages using $wikipage->doEditContent(), and I'd like to
>> > be able to set a semantic title
>> > <https://www.mediawiki.org/wiki/Extension:Semantic_Title> property
>> > on the page at that point.
>> >
>> > Thanks!
>> >
>> > --
>> > Jason Ji
>> > jason.y...@gmail.com <mailto:jason.y...@gmail.com>
>> >
>> >
>>  
>> --
>> > Monitor 25 network devices or servers for free with OpManager!
>> > OpManager is web-based network management software that monitors
>> > network devices and physical & virtual servers, alerts via email &
>> sms
>> > for fault. Monitor 25 devices for free with no restriction.
>> Download now
>> > http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
>> > ___
>> > Semediawiki-devel mailing list
>> > Semediawiki-devel@lists.

[SMW-devel] Set a SMW property programmatically in PHP?

2015-06-25 Thread Jason Ji
Hi SMW community,

I have a hopefully simple question. Is there a way to set an SMW property
for a page programmatically in PHP? Suppose I have access to any of the
relevant information, like the page ID.

For context, I'm writing an extension which, among other things, creates
wiki pages using $wikipage->doEditContent(), and I'd like to be able to set
a semantic title <https://www.mediawiki.org/wiki/Extension:Semantic_Title>
property on the page at that point.

Thanks!

--
Jason Ji
jason.y...@gmail.com
--
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors 
network devices and physical & virtual servers, alerts via email & sms 
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel


Re: [SMW-devel] Ask query in extension

2014-11-01 Thread Jason Ji
If your extension includes a JavaScript component, and you need to make the
ask query in the JavaScript, SMW includes the ask query as an API module
(action=ask or action=askargs, depending on what format you prefer to send
in the query).

--
Jason Ji
jason.y...@gmail.com

On Sat, Nov 1, 2014 at 8:38 PM, Jeroen De Dauw 
wrote:

> Hey,
>
> So you'd have something like
>
> {{#gimmeh_datas_in_a_table: [[Category:Some category]]}}
>
> that results in the same output as the #ask call you posted? If that's all
> you're doing you can of course just use a template. Which indeed does not
> work if you want to modify the result in certain ways.
>
> Your parser function would hand the query string to the QueryProcessor,
> get back the result, and then hand the result over to the formatting thing
> (can't recall where this code is). And in between you could try modifying
> the result. Be warned though, the result data structure is... odd... So it
> might not be trivial to do this.
>
> Cheers
>
> --
> Jeroen De Dauw - http://www.bn2vs.com
> Software craftsmanship advocate
> Evil software architect at Wikimedia Germany
> ~=[,,_,,]:3
>
>
> --
>
> ___
> Semediawiki-devel mailing list
> Semediawiki-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
>
>
--
___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel


[SMW-devel] Deleted page still appears on a Category page

2014-08-08 Thread Jason Ji
Hello,

I have a wiki running MediaWiki 1.23 and Semantic MediaWiki 1.9.1 in a
development environment (so lots of page creations, deletions, settings
changes, etc). I was also messing around with semantic forms, properties
and templates and using content-free page naming with semantic title.

At some point during my development today, after I changed some settings in
PostConfiguration.php regarding namespaces (including wgExtraNamespaces,
wgContentNamespaces, smwgNamespacesWithSemanticLinks, and one or two
others), I found that a page which I had deleted was still showing up in a
Category page of which it was a member (when it still existed). Clicking on
the link to the deleted page takes me to the deleted page (correctly
stating that the page was deleted, but I could restore it if desired). To
be clear, this was a built-in MediaWiki category page - the template I was
building would put these pages into that category.

If it helps, this page was using content-free page naming, so it had a
title like "Item:1" and a semantic title like "A Test Page". When the page
is deleted, it shows up in the Category page just as "Item:1". When not
deleted, it shows up in the Category page twice, as "Item:1" and as "A Test
Page". Subsequent pages like "Item:2" only show up in the Category page
with the proper display title, and only when the pages exist (not when
deleted).

I have tried things like re-creating and deleting the page, running
refreshLinks.php, runJobs.php (until the job queue was clear), and
SMW/UpdateJob.php (this last one indirectly via the Special:SMWAdmin page),
but none of these have fixed the problem - the phantom page is still
showing in the Category page.

Can anyone give any insight as to a) why this might happen, and/or b) any
other ways I can try to correct the problem? I posted this question to the
MediaWiki email list yesterday, and it was suggested that I try the SMW
email list too.

Thanks!

--
Jason Ji
jason.y...@gmail.com
--
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel