Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#49 2020-06-27 21:15:58

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Bibliography management

Bloke wrote #324040:

If you set any dates that you don’t want to a known-past date, say “1970-01-01 00:00:00” (which is treated as ‘zero’ in the epoch counting system) then you can detect that situation

I decided to give it try, because if it works, it makes use of a core field and frees up one from the plugin. I’m not sure it’s working though, I tried it as you gave…

<txp:evaluate query='<txp:link_date format="%s" /> > 0'>The date is used!</txp:evaluate>

That was just outputting ‘The date is used!’ whether it’s epoch zero or not. But then, after double checking the date I entered, I noticed that when changing to 1970-01-01 00:00:00 and saving, then going back to look at the link in edit mode again, the date returned to what it was before trying to change it. Doesn’t matter what date I try in the past. I’m still using 4.8.0 at the moment, but that sounds like a bug.

…snipped from here; need to think it through better…

Last edited by Destry (2020-06-27 21:28:59)

Offline

#50 2020-06-27 21:52:20

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: Bibliography management

Destry wrote #324065:

Doesn’t matter what date I try in the past.

That is weird. You’re right that using 1970-01-01 00:00:00 fails. That’s a bug and I’ll fix it, likely due to testing empty() and PHP thinks that ‘0’ is empty. Nope, it’s in the link_save() function of txp_link.php. There’s a line in there that should read:

if (!$publish_now && $created_ts >= 0) {
...

But even without that fix, if I use 1970-01-01 00:00:01 (i.e. 1 second after the epoch) then it lets me store it just fine. And in that case, the test in the <txp:evaluate> tag will be > 1.

I am using 4.8.1 though. Don’t think there’s any difference between 4.8.0 and 4.8.1 in the Links domain, but I might be wrong.

Last edited by Bloke (2020-06-27 21:57:37)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#51 2020-06-28 10:16:00

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Bibliography management

Bloke wrote #324066:

You’re right that using 1970-01-01 00:00:00 fails . . . it’s in the link_save() function of txp_link.php. There’s a line that should read: if (!$publish_now && $created_ts >= 0) {

According to that line, it was missing the =. I updated to 4.8.1 and corrected the line as suggested, but I still can’t add epoch zero date or any date prior. I also can’t add any combination of these (note the nn):

1970-01-01 00:00:nn
1970-01-01 00:nn:00

And if I specifically add this, 1970-01-01 01:00:00, save, then open that link in edit mode again, there are no date/time stamp values at all in the edit view, like they were erased. Maybe that could be useful here as something to evaluate against?

But I can save this or any other hour except the first: 1970-01-01 02:00:00

And I can save a first hour with any non-zero combo of minutes and seconds, for example: 1970-01-01 01:06:24.

Assuming I could get epoch zero to work — though I’d be fine using 1970-01-01 02:00:00, if you can tell me how to adjust the evaluation — I’m still unclear how I structure the tags, like this?

. . .
<txp:evaluate query='<txp:link_date format="%s" /> > 0'><txp:link_date wraptag=", accessed <+>." /></txp:evaluate>
</txp:linklist>

It seems like I need a conditional in there that says: if funky time, show nothing; but if not funky time, output the desired date stamp.

Last edited by Destry (2020-06-28 10:25:44)

Offline

#52 2020-06-28 10:31:37

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Bibliography management

Destry wrote #324070:

1970-01-01 01:00:00 . . . Maybe that could be useful here as something to evaluate against?

Nope. Apparently not, because even though nothing appears in the edit view fields, it still outputs the previous good value that was saved using just the link_date tag by itself.

Offline

#53 2020-06-28 12:05:55

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,578
Website

Re: Bibliography management

Destry wrote #324072:

Nope. Apparently not, because even though nothing appears in the edit view fields, it still outputs the previous good value that was saved using just the link_date tag by itself.

Really wild guess if 1970-01-01 02:00:00 works: maybe it’s a combination of time zone and summer time that’s causing the two-hour offset to work but not the actual time or the 1 hour difference.

Destry wrote #324070:

It seems like I need a conditional in there that says: if funky time, show nothing; but if not funky time, output the desired date stamp.

Could you not simply compare against an arbitrary year before which you’re not going to have any “accessed” dates, e.g.

<txp:evaluate query='<txp:link_date format="%Y" /> > 2000'><txp:link_date wraptag=", accessed <+>." /></txp:evaluate>

e.g. any date in the last century would not show.


TXP Builders – finely-crafted code, design and txp

Offline

#54 2020-06-28 13:05:24

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: Bibliography management

Destry wrote #324070:

But I can save this or any other hour except the first: 1970-01-01 02:00:00

Ah drat, yeah, that’ll be the timezone offset at play. I’ll have to try and fix that, but we’re already using safe_strtotime() which automatically takes the offset into consideration. So maybe there’s some disconnect between your hosting environment’s “current time” and you Txp installation’s timezone?

And jakob is right, you don’t have to use the epoch, you can compare against any format of string you like.

Last edited by Bloke (2020-06-28 13:08:33)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#55 2020-06-28 13:27:56

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: Bibliography management

Actually, you know what, storing ‘0’ is going to make things difficult as it’ll probably involve changing table structures to get rid of NOT NULL and things like that. The earliest date you can store in a Link is one second after the epoch, give or take timezone (mis)configurations. It’s not worth changing this.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#56 2020-06-29 07:46:13

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Bibliography management

Thanks to everyone’s help with tags, and especially Jacob’s extension of his link plugin, the following is working with the variety of citation types I have so far. I have to wrap the tags together like that in practice or else blank spaces appear in output that are not supposed to appear (regardless of how I use wraptag):

<txp:linklist wraptag="ol" class="biblio" break="li">
<txp:jcr_link_custom name="author" wraptag="<+>, " /><txp:link_name trim="void" wraptag="&#x2018<+>&#x2019, " /><txp:link_description escape="tidy, textile" /><txp:jcr_link_custom name="volume" wraptag=", <+>" /><txp:jcr_if_link_custom name="city"><txp:jcr_link_custom name="city" wraptag=" (<+>" />, <txp:jcr_link_custom name="publish_date" wraptag="<+>)" /><txp:else /><txp:jcr_link_custom name="publish_date" wraptag=", <+>" /></txp:jcr_if_link_custom><txp:jcr_if_link_custom name="media_type"><txp:jcr_link_custom name="media_type" wraptag=" [<+>], " /><txp:link_url wraptag="<+>" /><txp:else /><txp:link_url wraptag=", <+>" /></txp:jcr_if_link_custom><txp:evaluate query='<txp:link_date format="%Y" /> > 1999'><txp:link_date wraptag=", accessed <+>." /></txp:evaluate>
</txp:linklist>

Here it as again for sake of reading it easier:

<txp:linklist wraptag="ol" class="biblio" break="li">
<txp:jcr_link_custom name="author" wraptag="<+>, " />
<txp:link_name trim="void" wraptag="&#x2018<+>&#x2019, " />
<txp:link_description escape="tidy, textile" />
<txp:jcr_link_custom name="volume" wraptag=", <+>" />
<txp:jcr_if_link_custom name="city"><txp:jcr_link_custom name="city" wraptag=" (<+>" />, <txp:jcr_link_custom name="publish_date" wraptag="<+>)" /><txp:else /><txp:jcr_link_custom name="publish_date" wraptag=", <+>" /></txp:jcr_if_link_custom>
<txp:jcr_if_link_custom name="media_type"><txp:jcr_link_custom name="media_type" wraptag=" [<+>], " /><txp:link_url wraptag="<+>" /><txp:else /><txp:link_url wraptag=", <+>" /></txp:jcr_if_link_custom>
<txp:evaluate query='<txp:link_date format="%Y" /> > 1999'><txp:link_date wraptag=", accessed <+>." /></txp:evaluate>
</txp:linklist>

For those thinking it might be useful. Be aware that I’ve modeled this after citation styles detailed in the Oxford Style Manual, so if you’re using anything else, say the Chicago Manual of Style, you’ll probably have to re-rig the snippet a bit; it won’t be a simple cut and paste. There’s also setting up the jcr_link_custom plugin as you need. I will probably post a little tute on my set up for OSM, and how I would extend it further, when I can.

I’m sure it will need some more trial and tweaking as different citation styles are added, but this is a big step forward, and something I’ve wanted from the Links panel for a long time.

The only weird thing at the mo is that the first citation in the list is appearing with one of those black-diamond question marks on the title and I can’t figure out why:

Anon., ◆rly American Lumber’, Timberframe Tools, 2010, http://www.timberframe-tools.com/tool-history/early-american-lumbe/, accessed 24 June 2020.

Anon., ‘Glossary’, Heritage Restorations, https://www.heritagebarns.com/glossary/, accessed 24 June 2020.

The field simply begins with the word ‘Early’, there’s no space or anything, I’ve tried retyping it to clear unseen cruft, but no dice. I’ve tried experimenting with different words to test if it was a vowel thing, or some weird combo of letters, but no change.

Any clues?

Last edited by Destry (2020-06-29 07:57:39)

Offline

#57 2020-06-29 07:54:15

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: Bibliography management

Hi Destry,

Shouldn’t

<txp:link_name trim="void" wraptag="&#x2018<+>&#x2019, " />

be

<txp:link_name trim="void" wraptag="&#x2018;<+>&#x2019;, " />

?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#58 2020-06-29 08:00:08

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Bibliography management

Yes! Of course! Well spotted, Colak. And that fixed the diamond problem.

Offline

#59 2020-06-29 08:44:59

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: Bibliography management

Destry wrote #324083:

Yes! Of course! Well spotted, Colak. And that fixed the diamond problem.

I was puling my hair for days before I spotted a similar mistake I made with html entities. I’m glad you are up and running.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#60 2020-06-29 12:47:26

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Bibliography management

It seems something got borked somewhere while working on this biblio.

If I try to view an article now via the ‘View’ link in the Write panel, I get these errors:

Warning "explode() expects parameter 2 to be string, array given"
in .../textpattern/lib/txplib_misc.php at line 4751.

adminErrorHandler()
textpattern/lib/txplib_misc.php:4751 explode()
textpattern/lib/txplib_misc.php:4787 do_list()
textpattern/vendors/Textpattern/L10n/Lang.php:599 do_list_unique()
textpattern/lib/txplib_misc.php:417 Textpattern\L10n\Lang->load()
textpattern/index.php:184 load_lang()

Warning "array_map(): Argument #2 should be an array"
in .../textpattern/lib/txplib_misc.php at line 4767.

adminErrorHandler()
textpattern/lib/txplib_misc.php:4767 array_map()
textpattern/lib/txplib_misc.php:4787 do_list()
textpattern/vendors/Textpattern/L10n/Lang.php:599 do_list_unique()
textpattern/lib/txplib_misc.php:417 Textpattern\L10n\Lang->load()
textpattern/index.php:184 load_lang()

Warning "array_unique() expects parameter 1 to be array, null given"
in .../textpattern/lib/txplib_misc.php at line 4787.

adminErrorHandler()
textpattern/lib/txplib_misc.php:4787 array_unique()
textpattern/vendors/Textpattern/L10n/Lang.php:599 do_list_unique()
textpattern/lib/txplib_misc.php:417 Textpattern\L10n\Lang->load()
textpattern/index.php:184 load_lang()

Warning "array_filter() expects parameter 1 to be array, null given"
in .../textpattern/lib/txplib_misc.php at line 4796.

adminErrorHandler()
textpattern/lib/txplib_misc.php:4796 array_filter()
textpattern/vendors/Textpattern/L10n/Lang.php:599 do_list_unique()
textpattern/lib/txplib_misc.php:417 Textpattern\L10n\Lang->load()
textpattern/index.php:184 load_lang()

Only two things come to mind…

One is the edit I made to the txp_link.php file as we were talking about in relation to epoch zero stuff.

The other is a mistake I made when changing jcr_link_custom field labels. In Jacob’s plugin the copy/paste snip uses

#@language en-gb

But I’m currently just using the en language pack, and I forgot to take off the -gb on one of the times I edited labels in jet pack upload. But I don’t have the en-gb language loaded in the Languages panel.

Aside from those two things, I’ve not been messing about with anything but usual stuff. And the ‘View’ link was working before that.

Is there a file I should replace to default conditions? (Hopefully not the en lang file with the jcr_link_custom labels.)

Suggestions?

Another observation… It only happens when the article is in ‘Draft’ mode. Live views okay.

Last edited by Destry (2020-06-29 13:09:11)

Offline

Board footer

Powered by FluxBB