当前位置: 首页>>代码示例>>PHP>>正文


PHP SFUtils::linkText方法代码示例

本文整理汇总了PHP中SFUtils::linkText方法的典型用法代码示例。如果您正苦于以下问题:PHP SFUtils::linkText方法的具体用法?PHP SFUtils::linkText怎么用?PHP SFUtils::linkText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SFUtils的用法示例。


在下文中一共展示了SFUtils::linkText方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: creationHTML

    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;
    }
开发者ID:roland2025,项目名称:mediawiki-extensions-SemanticForms,代码行数:81,代码来源:SF_FormField.php

示例2: formatResult

 function formatResult($skin, $result)
 {
     $title = Title::makeTitle(NS_TEMPLATE, $result->value);
     $text = Linker::link($title, htmlspecialchars($title->getText()));
     $category = $this->getCategoryDefinedByTemplate($title);
     if ($category !== '') {
         $text .= ' ' . wfMessage('sf_templates_definescat', SFUtils::linkText(NS_CATEGORY, $category))->parse();
     }
     return $text;
 }
开发者ID:Rikuforever,项目名称:wiki,代码行数:10,代码来源:SF_Templates.php

示例3: printPage

    function printPage($form_name, $embedded = false)
    {
        global $wgOut, $wgRequest, $sfgFormPrinter, $wgParser, $sfgRunQueryFormAtTop;
        global $wgUser;
        // Get contents of form-definition page.
        $form_title = Title::makeTitleSafe(SF_NS_FORM, $form_name);
        if (!$form_title || !$form_title->exists()) {
            if ($form_name === '') {
                $text = Html::element('p', array('class' => 'error'), wfMessage('sf_runquery_badurl')->text()) . "\n";
            } else {
                $text = Html::rawElement('p', array('class' => 'error'), wfMessage('sf_formstart_badform', SFUtils::linkText(SF_NS_FORM, $form_name))->parse()) . "\n";
            }
            $wgOut->addHTML($text);
            return;
        }
        // Initialize variables.
        $form_definition = SFUtils::getPageText($form_title);
        if ($embedded) {
            $run_query = false;
            $content = null;
            $raw = false;
        } else {
            $run_query = $wgRequest->getCheck('wpRunQuery');
            $content = $wgRequest->getVal('wpTextbox1');
            $raw = $wgRequest->getBool('raw', false);
        }
        $form_submitted = $run_query;
        if ($raw) {
            $wgOut->setArticleBodyOnly(true);
        }
        // If user already made some action, ignore the edited
        // page and just get data from the query string.
        if (!$embedded && $wgRequest->getVal('query') == 'true') {
            $edit_content = null;
            $is_text_source = false;
        } elseif ($content != null) {
            $edit_content = $content;
            $is_text_source = true;
        } else {
            $edit_content = null;
            $is_text_source = true;
        }
        list($form_text, $javascript_text, $data_text, $form_page_title) = $sfgFormPrinter->formHTML($form_definition, $form_submitted, $is_text_source, $form_title->getArticleID(), $edit_content, null, null, true, $embedded);
        $text = "";
        // Get the text of the results.
        $resultsText = '';
        if ($form_submitted) {
            // @TODO - fix RunQuery's parsing so that this check
            // isn't needed.
            if ($wgParser->getOutput() == null) {
                $headItems = array();
            } else {
                $headItems = $wgParser->getOutput()->getHeadItems();
            }
            foreach ($headItems as $key => $item) {
                $wgOut->addHeadItem($key, "\t\t" . $item . "\n");
            }
            $wgParser->mOptions = ParserOptions::newFromUser($wgUser);
            $resultsText = $wgParser->parse($data_text, $this->getTitle(), $wgParser->mOptions)->getText();
        }
        // Get the full text of the form.
        $fullFormText = '';
        $additionalQueryHeader = '';
        $dividerText = '';
        if (!$raw) {
            // Create the "additional query" header, and the
            // divider text - one of these (depending on whether
            // the query form is at the top or bottom) is displayed
            // if the form has already been submitted.
            if ($form_submitted) {
                $additionalQueryHeader = "\n" . Html::element('h2', null, wfMessage('sf_runquery_additionalquery')->text()) . "\n";
                $dividerText = "\n<hr style=\"margin: 15px 0;\" />\n";
            }
            $action = htmlspecialchars($this->getTitle($form_name)->getLocalURL());
            $fullFormText .= <<<END
\t<form id="sfForm" name="createbox" action="{$action}" method="post" class="createbox">

END;
            $fullFormText .= Html::hidden('query', 'true');
            $fullFormText .= $form_text;
        }
        // Either don't display a query form at all, or display the
        // query form at the top, and the results at the bottom, or the
        // other way around, depending on the settings.
        if ($wgRequest->getVal('additionalquery') == 'false') {
            $text .= $resultsText;
        } elseif ($sfgRunQueryFormAtTop) {
            $text .= Html::openElement('div', array('class' => 'sf-runquery-formcontent'));
            $text .= $fullFormText;
            $text .= $dividerText;
            $text .= Html::closeElement('div');
            $text .= $resultsText;
        } else {
            $text .= $resultsText;
            $text .= Html::openElement('div', array('class' => 'sf-runquery-formcontent'));
            $text .= $additionalQueryHeader;
            $text .= $fullFormText;
            $text .= Html::closeElement('div');
        }
        if ($embedded) {
//.........这里部分代码省略.........
开发者ID:paladox,项目名称:mediawiki-extensions-SemanticForms,代码行数:101,代码来源:SF_RunQuery.php

示例4: printForm

 static function printForm(&$form_name, &$target_name, $alt_forms = array(), $redirectOnError = false)
 {
     global $wgOut, $wgRequest, $wgUser, $sfgFormPrinter;
     // initialize some variables
     $target_title = null;
     $page_name_formula = null;
     $form_title = Title::makeTitleSafe(SF_NS_FORM, $form_name);
     // If the given form is not a valid title, bail out.
     if (!$form_title) {
         return 'sf_formedit_badurl';
     }
     $form_article = new Article($form_title, 0);
     $form_definition = $form_article->getContent();
     // If the form page is a redirect, use the other form
     // instead.
     if ($form_title->isRedirect()) {
         $form_title = Title::newFromRedirectRecurse($form_definition);
         $form_article = new Article($form_title, 0);
         $form_definition = $form_article->getContent();
     }
     $form_definition = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $form_definition);
     if (is_null($target_name)) {
         $target_name = '';
     }
     if ($target_name === '') {
         // parse the form to see if it has a 'page name' value set
         $matches;
         if (preg_match('/{{{info.*page name\\s*=\\s*(.*)}}}/m', $form_definition, $matches)) {
             $page_name_elements = SFUtils::getFormTagComponents($matches[1]);
             $page_name_formula = $page_name_elements[0];
         } elseif (count($alt_forms) == 0) {
             return 'sf_formedit_badurl';
         }
     } else {
         $target_title = Title::newFromText($target_name);
         if ($target_title && $target_title->exists()) {
             if ($wgRequest->getVal('query') == 'true') {
                 $page_contents = null;
                 //$page_is_source = false;
             } else {
                 // If page already exists and 'redlink'
                 // is in the query string, redirect to
                 // the actual page, just like
                 // MediaWiki does it.
                 if ($wgRequest->getBool('redlink')) {
                     $wgOut->redirect($target_title->getFullURL());
                     wfProfileOut(__METHOD__);
                     return;
                 }
                 $target_article = new Article($target_title, 0);
                 $page_contents = $target_article->getContent();
                 //$page_is_source = true;
             }
         } else {
             $target_name = str_replace('_', ' ', $target_name);
         }
     }
     if (!$form_title || !$form_title->exists()) {
         if (count($alt_forms) > 0) {
             $text = '<div class="infoMessage">' . wfMsg('sf_formedit_altformsonly') . ' ' . self::printAltFormsList($alt_forms, $form_name) . "</div>\n";
         } else {
             $text = Html::rawElement('p', array('class' => 'error'), wfMsgExt('sf_formstart_badform', 'parseinline', SFUtils::linkText(SF_NS_FORM, $form_name))) . "\n";
         }
     } elseif ($target_name === '' && $page_name_formula === '') {
         $text = Html::element('p', array('class' => 'error'), wfMsg('sf_formedit_badurl')) . "\n";
     } else {
         $save_page = $wgRequest->getCheck('wpSave');
         $preview_page = $wgRequest->getCheck('wpPreview');
         $diff_page = $wgRequest->getCheck('wpDiff');
         $form_submitted = $save_page || $preview_page || $diff_page;
         // get 'preload' query value, if it exists
         if (!$form_submitted) {
             if ($wgRequest->getCheck('preload')) {
                 $page_is_source = true;
                 $page_contents = SFFormUtils::getPreloadedText($wgRequest->getVal('preload'));
             } else {
                 // let other extensions preload the page, if they want
                 wfRunHooks('sfEditFormPreloadText', array(&$page_contents, $target_title, $form_title));
                 $page_is_source = $page_contents != null;
             }
         } else {
             $page_is_source = false;
             $page_contents = null;
         }
         list($form_text, $javascript_text, $data_text, $form_page_title, $generated_page_name) = $sfgFormPrinter->formHTML($form_definition, $form_submitted, $page_is_source, $form_article->getID(), $page_contents, $target_name, $page_name_formula);
         // Before we do anything else, set the form header
         // title - this needs to be done after formHTML() is
         // called, because otherwise it doesn't take hold
         // for some reason if the form is disabled.
         if (empty($target_title)) {
             $s = wfMsg('sf_formedit_createtitlenotarget', $form_title->getText());
         } elseif ($target_title->exists()) {
             $s = wfMsg('sf_formedit_edittitle', $form_title->getText(), $target_title->getPrefixedText());
         } else {
             $s = wfMsg('sf_formedit_createtitle', $form_title->getText(), $target_title->getPrefixedText());
         }
         $wgOut->setPageTitle($s);
         if ($form_submitted) {
             if (!is_null($page_name_formula) && $page_name_formula !== '') {
                 $target_name = $generated_page_name;
//.........这里部分代码省略.........
开发者ID:schwarer2006,项目名称:wikia,代码行数:101,代码来源:SF_FormEdit.php

示例5: execute

    function execute($query)
    {
        global $wgOut, $wgRequest;
        $this->setHeaders();
        $form_name = $wgRequest->getVal('form');
        $target_namespace = $wgRequest->getVal('namespace');
        $super_page = $wgRequest->getVal('super_page');
        $params = $wgRequest->getVal('params');
        // If the query string did not contain a form name, try the URL
        if (!$form_name) {
            $queryparts = explode('/', $query, 2);
            $form_name = isset($queryparts[0]) ? $queryparts[0] : '';
            // If a target was specified, it means we should
            // redirect to 'FormEdit' for this target page.
            if (isset($queryparts[1])) {
                $target_name = $queryparts[1];
                $this->doRedirect($form_name, $target_name, $params);
            }
            // Get namespace from the URL, if it's there.
            if ($namespace_label_loc = strpos($form_name, "/Namespace:")) {
                $target_namespace = substr($form_name, $namespace_label_loc + 11);
                $form_name = substr($form_name, 0, $namespace_label_loc);
            }
        }
        // Remove forbidden characters from the form name.
        $forbidden_chars = array('"', "'", '<', '>', '{', '}', '(', ')', '[', ']', '=');
        $form_name = str_replace($forbidden_chars, "", $form_name);
        // Get title of form.
        $form_title = Title::makeTitleSafe(SF_NS_FORM, $form_name);
        // Handle submission of this form.
        $form_submitted = $wgRequest->getCheck('page_name');
        if ($form_submitted) {
            $page_name = $wgRequest->getVal('page_name');
            // This form can be used to create a sub-page for an
            // existing page
            if (!is_null($super_page) && $super_page !== '') {
                $page_name = "{$super_page}/{$page_name}";
            }
            if ($page_name !== '') {
                // Append the namespace prefix to the page name,
                // if this namespace was not already entered.
                if (strpos($page_name, $target_namespace . ':') === false && !is_null($target_namespace)) {
                    $page_name = $target_namespace . ':' . $page_name;
                }
                // If there was no page title, it's probably an
                // invalid page name, containing forbidden
                // characters - in that case, display an error
                // message.
                $page_title = Title::newFromText($page_name);
                if (!$page_title) {
                    $wgOut->addHTML(htmlspecialchars(wfMsg('sf_formstart_badtitle', $page_name)));
                    return;
                } else {
                    $this->doRedirect($form_name, $page_name, $params);
                    return;
                }
            }
        }
        if ((!$form_title || !$form_title->exists()) && $form_name !== '') {
            $text = Html::rawElement('p', array('class' => 'error'), wfMsgExt('sf_formstart_badform', 'parseinline', SFUtils::linkText(SF_NS_FORM, $form_name))) . "\n";
        } else {
            if ($form_name === '') {
                $description = htmlspecialchars(wfMsg('sf_formstart_noform_docu', $form_name));
            } else {
                $description = htmlspecialchars(wfMsg('sf_formstart_docu', $form_name));
            }
            $text = <<<END
\t<form action="" method="post">
\t<p>{$description}</p>
\t<p><input type="text" size="40" name="page_name" />

END;
            // If no form was specified, display a dropdown letting
            // the user choose the form.
            if ($form_name === '') {
                $text .= SFUtils::formDropdownHTML();
            }
            $text .= "\t</p>\n";
            $text .= Html::hidden('namespace', $target_namespace);
            $text .= Html::hidden('super_page', $super_page);
            $text .= Html::hidden('params', $params);
            $text .= "\n\t" . Html::input(null, wfMsg('sf_formstart_createoredit'), 'submit') . "\n";
            $text .= "\t</form>\n";
        }
        $wgOut->addHTML($text);
    }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:86,代码来源:SF_FormStart.php

示例6: printEditForm

    /**
     * Print the edit form. Mostly copied from the SemanticForms extension
     * SF_FormEdit.php but simplyfied to the requirements. No page is supposed
     * to be modified. When submiting the form, javascript is added that reads
     * the actual data for the form and adds them for the template call. The
     * page never does a redirect but calls itself again. Buttons for preview
     * and show changes as well as checkboxes are removed as they are not needed.
     *
     * @param string form name
     * @param string target name (i.e. page name)
     * @param string content whih is page content (optional, default null)
     */
    static function printEditForm($form_name, $target_name, $content = null)
    {
        global $wgOut, $wgRequest, $wgScriptPath, $sfgScriptPath, $sfgFormPrinter, $sfgYUIBase;
        // within the popup of the FCK, don't load another FCK for text fields
        global $wgFCKEditorDir;
        $original_wgFCKEditorDir = $wgFCKEditorDir;
        $wgFCKEditorDir = null;
        wfLoadExtensionMessages('SemanticForms');
        $javascript_text = "";
        // get contents of form definition file
        $form_title = Title::makeTitleSafe(SF_NS_FORM, $form_name);
        // get contents of target page
        $target_title = Title::newFromText($target_name);
        // typical handling to check, if we know that we have a form and a target
        if (!$form_title || !$form_title->exists()) {
            if ($form_name == '') {
                $text = '<p class="error">' . wfMsg('sf_editdata_badurl') . "</p>\n";
            } else {
                $text = '<p class="error">Error: No form page was found at ' . SFUtils::linkText(SF_NS_FORM, $form_name) . ".</p>\n";
            }
        } elseif (!$target_title || !$target_title->exists()) {
            if ($target_name == '') {
                $text = '<p class="error">' . wfMsg('sf_editdata_badurl') . "</p>\n";
            } else {
                $text = '<p class="error">Error: No page was found at ' . SFUtils::linkText(null, $target_name) . ".</p>\n";
            }
        } else {
            $s = wfMsg('sf_editdata_title', $form_title->getText(), $target_title->getPrefixedText());
            $wgOut->setPageTitle($s);
            $form_article = new Article($form_title);
            $form_definition = $form_article->getContent();
            $page_title = str_replace('_', ' ', $target_name);
            // if user already made some action, ignore the edited page
            // and just get data from the query string
            if ($wgRequest->getVal('query') == 'true') {
                $edit_content = null;
                $is_text_source = false;
            } elseif ($content != null) {
                $edit_content = $content;
                $is_text_source = true;
            } else {
                $target_article = new Article($target_title);
                $edit_content = $target_article->getContent();
                $is_text_source = true;
            }
            // the form is never submited (we need the Javascript at onsubmit only)
            // therefore set the submit to false, this will dispay the form always
            // like we will see it when calling it for the first time
            $form_submitted = false;
            list($form_text, $javascript_text, $data_text, $form_page_title) = $sfgFormPrinter->formHTML($form_definition, $form_submitted, $is_text_source, $edit_content, $page_title);
            // override the default title for this page if
            // a title was specified in the form
            if ($form_page_title != NULL) {
                $wgOut->setPageTitle("{$form_page_title}: {$target_title->getPrefixedText()}");
            }
            // remove preview and diff buttons and checkboxes for minor edit
            // and watch this page
            self::removeButtonsAndLinksFromPage($form_text);
            $text = <<<END
                <form name="createbox" onsubmit="return validate_all_and_save();" action="" method="post" class="createbox">
        \t<input type="hidden" name="query" value="true" />

END;
            $text .= $form_text;
            // add extra javascript that reads form data and fills the
            // template popup in the FCK
            $javascript_text .= self::getFckTemplatePopupJavascript();
        }
        // add javascript and css to the page header
        SFUtils::addJavascriptAndCSS();
        $wgOut->addScript('		<script type="text/javascript">' . "\n" . $javascript_text . '</script>' . "\n");
        $wgOut->addHTML($text);
        // set the $wgFCKEditorDir again to the original (maybe not needed)
        $wgFCKEditorDir = $original_wgFCKEditorDir;
    }
开发者ID:seedbank,项目名称:old-repo,代码行数:87,代码来源:SF_EditDataEmbedded.php


注:本文中的SFUtils::linkText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。