r24679 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24678‎ | r24679 | r24680 >
Date:17:33, 8 August 2007
Author:yaron
Status:old
Tags:
Comment:
Added another field to class, upated createTemplateText()
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_TemplateField.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_TemplateField.inc
@@ -10,6 +10,7 @@
1111 var $field_name;
1212 var $label;
1313 var $semantic_field;
 14+ var $semantic_field_call;
1415 var $attr_or_rel;
1516 var $attribute_type;
1617 var $possible_values;
@@ -61,7 +62,7 @@
6263 }
6364 }
6465
65 -function create_template_text($template_name, $template_fields, $category_name) {
 66+function createTemplateText($template_name, $template_fields, $category, $template_format) {
6667 $text = "<noinclude>\n";
6768 $text .= wfMsgForContent('sf_template_docu', $template_name) . "\n";
6869 $text .= "<pre>\n";
@@ -78,29 +79,34 @@
7980 <includeonly>
8081
8182 END;
82 - if ($category_name != '') {
83 - $text .= wfMsgForContent('sf_template_pagetype', "[[:Category:$category_name]]") . "\n";
 83+ // topmost part depends on format
 84+ if ($template_format == 'infobox') {
 85+ // CSS style can't be used, unfortunately, since most MediaWiki setups
 86+ // don't have an 'infobox' or comparable CSS class
 87+ $text .=<<<END
 88+{| style="width: 30em; font-size: 90%; border: 1px solid #aaaaaa; background-color: #f9f9f9; color: black; margin-bottom: 0.5em; margin-left: 1em; padding: 0.2em; float: right; clear: right; text-align:left;"
 89+! style="text-align: center; background-color:#ccccff;" colspan="2" |<big>{{PAGENAME}}</big>
 90+|-
 91+
 92+END;
 93+ } else {
 94+ $text .= "{| border=0 cellpadding=4 cellspacing=4\n";
8495 }
85 - $text .= "{| border=0 cellpadding=4 cellspacing=4\n";
8696
8797 foreach ($template_fields as $i => $field) {
8898 if ($i > 0) {
8999 $text .= "|-\n";
90100 }
91101 $text .= "! " . $field->label . "\n";
92 - if ($field->semantic_field == null || $field->semantic_field == '') {
 102+ if ($field->semantic_field_call == null || $field->semantic_field_call == '') {
93103 $text .= "| {{{" . $field->field_name . "|unknown}}}\n";
94104 } else {
95 - if ($field->attr_or_rel == "attribute") {
96 - $text .= "| [[" . $field->semantic_field . ":={{{" . $field->field_name . "|unknown}}}]]\n";
97 - } else {
98 - $text .= "| [[" . $field->semantic_field . "::{{{" . $field->field_name . "|unknown}}}]]\n";
99 - }
 105+ $text .= "| [[" . $field->semantic_field_call . "{{{" . $field->field_name . "|unknown}}}]]\n";
100106 }
101107 }
102108 $text .= "|}\n";
103 - if ($category_name != '') {
104 - $text .= "\n[[Category:$category_name]]\n";
 109+ if ($category != '') {
 110+ $text .= "\n[[Category:$category]]\n";
105111 }
106112 $text .= "</includeonly>\n";
107113

Status & tagging log