Yaron Koren has uploaded a new change for review.
https://gerrit.wikimedia.org/r/278983
Change subject: Fixes for 4c57214
......................................................................
Fixes for 4c57214
Change-Id: Ied05fccb8fd067e8875a9363ebaf7b51c107ff94
---
M includes/SF_Template.php
M includes/SF_TemplateInForm.php
2 files changed, 13 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticForms
refs/changes/83/278983/1
diff --git a/includes/SF_Template.php b/includes/SF_Template.php
index dc67962..e43e828 100644
--- a/includes/SF_Template.php
+++ b/includes/SF_Template.php
@@ -60,7 +60,7 @@
// presence of SMW and can get non-SMW information as well.
if ( defined( 'CARGO_VERSION' ) ) {
$this->loadTemplateFieldsCargo( $templateTitle );
- if ( $this->mTemplateFields !== null ) {
+ if ( count( $this->mTemplateFields ) > 0 ) {
return;
}
}
@@ -86,7 +86,7 @@
// First, look for "arraymap" parser function calls
// that map a property onto a list.
- if ( $ret = preg_match_all(
'/{{#arraymap:{{{([^|}]*:?[^|}]*)[^\[]*\[\[([^:]*:?[^:]*)::/mis',
$templateText, $matches ) ) {
+ if ( $ret = preg_match_all(
'/{{#arraymap:{{{([^|}]*:?[^|}]*)[^\[]*\[\[([^:]*:?[^:]*)::/mis',
$this->mTemplateText, $matches ) ) {
foreach ( $matches[1] as $i => $field_name ) {
if ( ! in_array( $field_name, $fieldNamesArray
) ) {
$propertyName = $matches[2][$i];
@@ -103,7 +103,7 @@
}
// Second, look for normal property calls.
- if ( preg_match_all(
'/\[\[([^:|\[\]]*:*?[^:|\[\]]*)::{{{([^\]\|}]*).*?\]\]/mis', $templateText,
$matches ) ) {
+ if ( preg_match_all(
'/\[\[([^:|\[\]]*:*?[^:|\[\]]*)::{{{([^\]\|}]*).*?\]\]/mis',
$this->mTemplateText, $matches ) ) {
foreach ( $matches[1] as $i => $propertyName ) {
$field_name = trim( $matches[2][$i] );
if ( ! in_array( $field_name, $fieldNamesArray
) ) {
@@ -116,7 +116,7 @@
// Then, get calls to #set, #set_internal and #subobject.
// (Thankfully, they all have similar syntax).
- if ( preg_match_all(
'/#(set|set_internal|subobject):(.*?}}})\s*}}/mis', $templateText, $matches ) )
{
+ if ( preg_match_all(
'/#(set|set_internal|subobject):(.*?}}})\s*}}/mis', $this->mTemplateText,
$matches ) ) {
foreach ( $matches[2] as $match ) {
if ( preg_match_all(
'/([^|{]*?)=\s*{{{([^|}]*)/mis', $match, $matches2 ) ) {
foreach ( $matches2[1] as $i =>
$propertyName ) {
@@ -133,7 +133,7 @@
// Then, get calls to #declare. (This is really rather
// optional, since no one seems to use #declare.)
- if ( preg_match_all( '/#declare:(.*?)}}/mis', $templateText,
$matches ) ) {
+ if ( preg_match_all( '/#declare:(.*?)}}/mis',
$this->mTemplateText, $matches ) ) {
foreach ( $matches[1] as $match ) {
$setValues = explode( '|', $match );
foreach ( $setValues as $valuePair ) {
@@ -151,11 +151,11 @@
}
// Finally, get any non-semantic fields defined.
- if ( preg_match_all( '/{{{([^|}]*)/mis', $templateText,
$matches ) ) {
+ if ( preg_match_all( '/{{{([^|}]*)/mis', $this->mTemplateText,
$matches ) ) {
foreach ( $matches[1] as $fieldName ) {
$fieldName = trim( $fieldName );
if ( !empty( $fieldName ) && ( ! in_array(
$fieldName, $fieldNamesArray ) ) ) {
- $cur_pos = stripos( $templateText,
$fieldName );
+ $cur_pos = stripos(
$this->mTemplateText, $fieldName );
$this->mTemplateFields[$cur_pos] =
SFTemplateField::create( $fieldName, $wgContLang->ucfirst( $fieldName ) );
$fieldNamesArray[] = $fieldName;
}
@@ -257,6 +257,10 @@
}
}
+ public function getTemplateFields() {
+ return $this->mTemplateFields;
+ }
+
public function getFieldNamed( $fieldName ) {
foreach ( $this->mTemplateFields as $curField ) {
if ( $curField->getFieldName() == $fieldName ) {
diff --git a/includes/SF_TemplateInForm.php b/includes/SF_TemplateInForm.php
index 319fbce..47aecbc 100644
--- a/includes/SF_TemplateInForm.php
+++ b/includes/SF_TemplateInForm.php
@@ -39,7 +39,8 @@
$tif->mTemplateName = str_replace( '_', ' ', $name );
$tif->mFields = array();
if ( is_null( $formFields ) ) {
- $fields = $tif->getAllFields();
+ $template = SFTemplate::newFromName(
$tif->mTemplateName );
+ $fields = $template->getTemplateFields();
foreach ( $fields as $field ) {
$tif->mFields[] = SFFormField::create( $field );
}
--
To view, visit https://gerrit.wikimedia.org/r/278983
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ied05fccb8fd067e8875a9363ebaf7b51c107ff94
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticForms
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits