示例#1
0
 function creationHTML($section_count)
 {
     global $wgRequest;
     $paramValues = array();
     $section_name = $this->mSectionName;
     $section_level = $this->mSectionLevel;
     $section_str = wfMessage('sf_createform_pagesection')->text() . " '" . $section_name . "'";
     $text = Html::hidden("section_{$section_count}", $section_name);
     $text .= '<div class="sectionForm">';
     $text .= Html::element('h2', array(), $section_str);
     foreach ($wgRequest->getValues() as $key => $value) {
         if (($pos = strpos($key, '_section_' . $section_count)) != false) {
             $paramName = substr($key, 0, $pos);
             $paramName = str_replace('_', ' ', $paramName);
             $paramValues[$paramName] = $value;
         }
     }
     $header_options = '';
     $text .= Html::element('span', null, wfMessage('sf_createform_sectionlevel')->text()) . "\n";
     for ($i = 1; $i < 7; $i++) {
         if ($section_level == $i) {
             $header_options .= " " . Html::element('option', array('value' => $i, 'selected'), $i) . "\n";
         } else {
             $header_options .= " " . Html::element('option', array('value' => $i), $i) . "\n";
         }
     }
     $text .= Html::rawElement('select', array('name' => "level_section_" . $section_count), $header_options) . "\n";
     $other_param_text = wfMessage('sf_createform_otherparameters')->escaped();
     $text .= "<fieldset class=\"sfCollapsibleFieldset\"><legend>{$other_param_text}</legend>\n";
     $text .= Html::rawElement('div', array(), SFCreateForm::showSectionParameters($section_count, $paramValues)) . "\n";
     $text .= "</fieldset>\n";
     $removeSectionButton = Html::input('delsection_' . $section_count, wfMessage('sf_createform_removesection')->text(), 'submit') . "\n";
     $text .= "</br>" . Html::rawElement('p', null, $removeSectionButton) . "\n";
     $text .= "\t</div>\n";
     return $text;
 }
    function creationHTML($template_num)
    {
        $field_form_text = $template_num . "_" . $this->mNum;
        $template_field = $this->template_field;
        $text = '<h3>' . wfMessage('sf_createform_field')->escaped() . " '" . $template_field->getFieldName() . "'</h3>\n";
        $prop_link_text = SFUtils::linkText(SMW_NS_PROPERTY, $template_field->getSemanticProperty());
        // TODO - remove this probably-unnecessary check?
        if ($template_field->getSemanticProperty() == "") {
            // Print nothing if there's no semantic property.
        } elseif ($template_field->getPropertyType() == "") {
            $text .= '<p>' . wfMessage('sf_createform_fieldpropunknowntype', $prop_link_text)->parseAsBlock() . "</p>\n";
        } else {
            if ($template_field->isList()) {
                $propDisplayMsg = 'sf_createform_fieldproplist';
            } else {
                $propDisplayMsg = 'sf_createform_fieldprop';
            }
            // Get the display label for this property type.
            global $smwgContLang;
            $propertyTypeStr = '';
            if ($smwgContLang != null) {
                $datatypeLabels = $smwgContLang->getDatatypeLabels();
                $datatypeLabels['enumeration'] = 'enumeration';
                $propTypeID = $template_field->getPropertyType();
                // Special handling for SMW 1.9
                if ($propTypeID == '_str' && !array_key_exists('_str', $datatypeLabels)) {
                    $propTypeID = '_txt';
                }
                $propertyTypeStr = $datatypeLabels[$propTypeID];
            }
            $text .= Html::rawElement('p', null, wfMessage($propDisplayMsg, $prop_link_text, $propertyTypeStr)->parse()) . "\n";
        }
        // If it's not a semantic field - don't add any text.
        $form_label_text = wfMessage('sf_createform_formlabel')->text();
        $form_label_input = Html::input('label_' . $field_form_text, $template_field->getLabel(), 'text', array('size' => 20));
        $input_type_text = wfMessage('sf_createform_inputtype')->escaped();
        $text .= <<<END
\t<div class="formField">
\t<p>{$form_label_text} {$form_label_input}
\t&#160; {$input_type_text}

END;
        global $sfgFormPrinter;
        if (is_null($template_field->getPropertyType())) {
            $default_input_type = null;
            $possible_input_types = $sfgFormPrinter->getAllInputTypes();
        } else {
            $default_input_type = $sfgFormPrinter->getDefaultInputType($template_field->isList(), $template_field->getPropertyType());
            $possible_input_types = $sfgFormPrinter->getPossibleInputTypes($template_field->isList(), $template_field->getPropertyType());
        }
        $text .= $this->inputTypeDropdownHTML($field_form_text, $default_input_type, $possible_input_types, $template_field->getInputType());
        if (!is_null($template_field->getInputType())) {
            $cur_input_type = $template_field->getInputType();
        } elseif (!is_null($default_input_type)) {
            $cur_input_type = $default_input_type;
        } else {
            $cur_input_type = $possible_input_types[0];
        }
        global $wgRequest;
        $paramValues = array();
        foreach ($wgRequest->getValues() as $key => $value) {
            if (($pos = strpos($key, '_' . $field_form_text)) != false) {
                $paramName = substr($key, 0, $pos);
                // Spaces got replaced by underlines in the
                // query.
                $paramName = str_replace('_', ' ', $paramName);
                $paramValues[$paramName] = $value;
            }
        }
        $other_param_text = wfMessage('sf_createform_otherparameters')->escaped();
        $text .= "<fieldset class=\"sfCollapsibleFieldset\"><legend>{$other_param_text}</legend>\n";
        $text .= Html::rawElement('div', array('class' => 'otherInputParams'), SFCreateForm::showInputTypeOptions($cur_input_type, $field_form_text, $paramValues)) . "\n";
        $text .= "</fieldset>\n";
        $text .= <<<END
\t</p>
\t</div>
\t<hr>

END;
        return $text;
    }
示例#3
0
 /**
  * The function called if we're in index.php (as opposed to one of the
  * special pages).
  */
 static function displayForm($action, $article)
 {
     $title = $article->getTitle();
     if ($title->getNamespace() == SMW_NS_PROPERTY) {
         $createPropertyPage = new SFCreateProperty();
         $createPropertyPage->execute($title->getText());
     } elseif ($title->getNamespace() == NS_TEMPLATE) {
         $createTemplatePage = new SFCreateTemplate();
         $createTemplatePage->execute($title->getText());
     } elseif ($title->getNamespace() == SF_NS_FORM) {
         $createFormPage = new SFCreateForm();
         $createFormPage->execute($title->getText());
     } elseif ($title->getNamespace() == NS_CATEGORY) {
         $createCategoryPage = new SFCreateCategory();
         $createCategoryPage->execute($title->getText());
     }
     return false;
 }
示例#4
0
 /**
  * The function called if we're in index.php (as opposed to one of the
  * special pages)
  */
 static function displayForm($action, $article)
 {
     // TODO: This function will be called as a hook handler and $action will
     //  be a string before MW 1.18. From 1.18 onwards this function will#
     //  only be called for formcreate actions, i.e. the if statement can be
     //  removed then.
     // return "true" if the call failed (meaning, pass on handling
     // of the hook to others), and "false" otherwise
     if (is_string($action) && $action !== 'formcreate') {
         return true;
     }
     $title = $article->getTitle();
     if ($title->getNamespace() == SMW_NS_PROPERTY) {
         $createPropertyPage = new SFCreateProperty();
         $createPropertyPage->execute($title->getText());
     } elseif ($title->getNamespace() == NS_TEMPLATE) {
         $createTemplatePage = new SFCreateTemplate();
         $createTemplatePage->execute($title->getText());
     } elseif ($title->getNamespace() == SF_NS_FORM) {
         $createFormPage = new SFCreateForm();
         $createFormPage->execute($title->getText());
     } elseif ($title->getNamespace() == NS_CATEGORY) {
         $createCategoryPage = new SFCreateCategory();
         $createCategoryPage->execute($title->getText());
     }
     return false;
 }