Skip to content

Commit 9fcd4d6

Browse files
committed
Required plugins
1 parent e92c15c commit 9fcd4d6

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

src/templates/forms/misc/json_card_reader.txp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
* Possible variables:
1212
*
1313
* <txp:variable name="json-repo-XXX" /> (where XXX is either homepage, bitbucket, github, gitlab - variable stores URL of project at that repo)
14+
* <txp:variable name="json-require-plugin" /> (name of a plugin this plugin requires to be installed)
15+
* <txp:variable name="json-require-match" /> (version match text of plugin this plugin requires to be installed)
16+
* <txp:variable name="json-require-version" /> (version a plugin this plugin requires to be installed)
1417
* <txp:variable name="json-beta-version" /> (latest semver of beta release)
1518
* <txp:variable name="json-beta-manifest" /> (does plugin beta release have a manifest.json file?)
1619
* <txp:variable name="json-beta-date" /> (date of latest PHP download beta release)
@@ -46,6 +49,39 @@ if (is_readable($file)) {
4649
}
4750
}
4851

52+
if (!empty($json->require)) {
53+
foreach ($json->require as $rplug => $rver) {
54+
$vars['require-plug-name'] = '<txp:variable name="json-require-plugin">'.txpspecialchars($rplug).'</txp:variable>';
55+
56+
preg_match('/([\<\=\>]+)?([\d.]+)/', $rver, $matches);
57+
$matchType = 'equal';
58+
59+
switch ($matches[1]) {
60+
case '>':
61+
$matchType = 'greater than';
62+
break;
63+
case '>=':
64+
$matchType = 'at least';
65+
break;
66+
case '<':
67+
$matchType = 'less than';
68+
break;
69+
case '<=':
70+
$matchType = 'no greater than';
71+
break;
72+
case '=':
73+
default:
74+
$matchType = 'equal';
75+
break;
76+
}
77+
78+
$plain_ver = $matches[2];
79+
80+
$vars['require-plug-match'] = '<txp:variable name="json-require-match">'.txpspecialchars($matchType).'</txp:variable>';
81+
$vars['require-plug-version'] = '<txp:variable name="json-require-version">'.txpspecialchars($plain_ver).'</txp:variable>';
82+
}
83+
}
84+
4985
if (!empty($json->beta)) {
5086
$vars['beta-version'] = '<txp:variable name="json-beta-version">'.txpspecialchars($json->beta->version).'</txp:variable>';
5187

src/templates/pages/plugins.txp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
<txp:variable name="body"><txp:article><txp:body /></txp:article></txp:variable>
44
<txp:header value="application/json; charset=utf-8" />{
55
"name": "<txp:title escape="json" />",
6+
<txp:if_variable name="json-require-plugin">
7+
"require": {
8+
"<txp:variable name="json-require-plugin" escape="json" />": "<txp:if_variable name="json-require-match" value="greater than">></txp:if_variable><txp:if_variable name="json-require-match" value="at least">>=</txp:if_variable><txp:if_variable name="json-require-match" value="less than"><</txp:if_variable><txp:if_variable name="json-require-match" value="no greater than"><=</txp:if_variable><txp:if_variable name="json-require-match" value="equal">=</txp:if_variable><txp:variable name="json-require-version" escape="json" />"
9+
},
10+
</txp:if_variable>
611
<txp:if_variable name="superseded-by-type">
712
"supersededBy": {
813
"name": "<txp:variable name="superseded-by-type" escape="json" />",
@@ -292,6 +297,9 @@ if (!empty($json2['legacy'])) {
292297
<txp:excerpt />
293298
</div>
294299
</txp:if_excerpt>
300+
<txp:if_variable name="json-require-plugin">
301+
<p class="alert-block warning"><strong>Note:</strong> This plugin requires an additional plugin to also be installed: <a href="https://plugins.textpattern.com/plugins/<txp:variable name="json-require-plugin" />"><txp:variable name="json-require-plugin" /></a>, version <txp:variable name="json-require-match" /> <txp:variable name="json-require-version" />.</p>
302+
</txp:if_variable>
295303
<txp:article><txp:body /></txp:article>
296304
<txp:if_variable not name="json-name">
297305
<p class="alert-block error">Plugin resources not currently available. If this problem persists, <a href="https://github.com/textpattern/textpattern-curated-plugins-list/issues/new?labels=plugin-broken&amp;template=report-a-broken-textpattern-plugin-listing.md&amp;title=%5BBROKEN%5D+<txp:title escape="json" />">open an issue</a> and we’ll investigate.</p>

0 commit comments

Comments
 (0)