Exemplo n.º 1
0
 /**
  * @covers Xml::escapeTagsOnly
  */
 public function testEscapeTagsOnly()
 {
     $this->assertEquals('&quot;&gt;&lt;', Xml::escapeTagsOnly('"><'), 'replace " > and < with their HTML entitites');
 }
Exemplo n.º 2
0
 /**
  * Tag hook handler for 'pre'.
  */
 function renderPreTag($text, $attribs)
 {
     // Backwards-compatibility hack
     $content = StringUtils::delimiterReplace('<nowiki>', '</nowiki>', '$1', $text, 'i');
     $attribs = Sanitizer::validateTagAttributes($attribs, 'pre');
     return Xml::openElement('pre', $attribs) . Xml::escapeTagsOnly($content) . '</pre>';
 }
Exemplo n.º 3
0
 /**
  * Core parser tag hook function for 'nowiki'. Text within this section
  * gets interpreted as a string of text with HTML-compatible character
  * references, and wiki markup within it will not be expanded.
  *
  * Uses undocumented extended tag hook return values, introduced in r61913.
  *
  * @param string $content
  * @param array $attributes
  * @param Parser $parser
  * @return array
  */
 public static function nowiki($content, $attributes, $parser)
 {
     $content = strtr($content, array('-{' => '-&#123;', '}-' => '&#125;-'));
     return array(Xml::escapeTagsOnly($content), 'markerType' => 'nowiki');
 }
 /**
  * Custom tag implementation. This is called by efCategoryTreeParserHook, which is used to
  * load CategoryTreeFunctions.php on demand.
  * @param $parser Parser
  * @param $category
  * @param $hideroot bool
  * @param $attr
  * @param $depth int
  * @param $allowMissing bool
  * @return bool|string
  */
 function getTag($parser, $category, $hideroot = false, $attr, $depth = 1, $allowMissing = false)
 {
     global $wgCategoryTreeDisableCache, $wgCategoryTreeDynamicTag;
     static $uniq = 0;
     $category = trim($category);
     if ($category === '') {
         return false;
     }
     if ($parser && $wgCategoryTreeDisableCache && !$wgCategoryTreeDynamicTag) {
         $parser->disableCache();
     }
     $title = self::makeTitle($category);
     if ($title === false || $title === null) {
         return false;
     }
     if (isset($attr['class'])) {
         $attr['class'] .= ' CategoryTreeTag';
     } else {
         $attr['class'] = ' CategoryTreeTag';
     }
     $attr['data-ct-mode'] = $this->mOptions['mode'];
     $attr['data-ct-options'] = Xml::escapeTagsOnly($this->getOptionsAsJsStructure());
     $html = '';
     $html .= Xml::openElement('div', $attr);
     if (!$allowMissing && !$title->getArticleID()) {
         $html .= Xml::openElement('span', array('class' => 'CategoryTreeNotice'));
         if ($parser) {
             $html .= $parser->recursiveTagParse(wfMsgNoTrans('categorytree-not-found', $category));
         } else {
             $html .= wfMsgExt('categorytree-not-found', 'parseinline', htmlspecialchars($category));
         }
         $html .= Xml::closeElement('span');
     } else {
         if (!$hideroot) {
             $html .= $this->renderNode($title, $depth, $wgCategoryTreeDynamicTag);
         } elseif (!$wgCategoryTreeDynamicTag) {
             $html .= $this->renderChildren($title, $depth);
         } else {
             $uniq += 1;
             $load = 'ct-' . $uniq . '-' . mt_rand(1, 100000);
             $html .= Xml::openElement('script', array('type' => 'text/javascript', 'id' => $load));
             $html .= 'categoryTreeLoadChildren("' . Xml::escapeJsString($title->getDBkey()) . '", ' . $this->getOptionsAsJsStructure($depth) . ', document.getElementById("' . $load . '").parentNode);';
             $html .= Xml::closeElement('script');
         }
     }
     $html .= Xml::closeElement('div');
     $html .= "\n\t\t";
     return $html;
 }
Exemplo n.º 5
0
 /**
  * Creates Page Schemas XML for form-wide information.
  */
 public static function createSchemaXMLFromForm()
 {
     global $wgRequest;
     $formName = null;
     $xml = '';
     $isStandardInputsOpen = false;
     foreach ($wgRequest->getValues() as $var => $val) {
         $val = str_replace(array('<', '>'), array('&lt;', '&gt;'), $val);
         if ($var == 'sf_form_name') {
             $formName = $val;
         } elseif ($var == 'sf_page_name_formula') {
             if (!empty($val)) {
                 $val = Xml::escapeTagsOnly($val);
                 $xml .= '<PageNameFormula>' . $val . '</PageNameFormula>';
             }
         } elseif ($var == 'sf_create_title') {
             if (!empty($val)) {
                 $xml .= '<CreateTitle>' . $val . '</CreateTitle>';
             }
         } elseif ($var == 'sf_edit_title') {
             if (!empty($val)) {
                 $xml .= '<EditTitle>' . $val . '</EditTitle>';
             }
         } elseif ($var == 'sf_fi_free_text_label') {
             $isStandardInputsOpen = true;
             $xml .= '<standardInputs ';
             if (!empty($val)) {
                 $xml .= 'freeTextLabel="' . Xml::escapeTagsOnly($val) . '" ';
             }
         } elseif ($var == 'sf_fi_free_text') {
             if (!empty($val)) {
                 $xml .= 'inputFreeText="' . $val . '" ';
             }
         } elseif ($var == 'sf_fi_summary') {
             if (!empty($val)) {
                 $xml .= 'inputSummary="' . $val . '" ';
             }
         } elseif ($var == 'sf_fi_minor_edit') {
             if (!empty($val)) {
                 $xml .= 'inputMinorEdit="' . $val . '" ';
             }
         } elseif ($var == 'sf_fi_watch') {
             if (!empty($val)) {
                 $xml .= 'inputWatch="' . $val . '" ';
             }
         } elseif ($var == 'sf_fi_save') {
             if (!empty($val)) {
                 $xml .= 'inputSave="' . $val . '" ';
             }
         } elseif ($var == 'sf_fi_preview') {
             if (!empty($val)) {
                 $xml .= 'inputPreview="' . $val . '" ';
             }
         } elseif ($var == 'sf_fi_changes') {
             if (!empty($val)) {
                 $xml .= 'inputChanges="' . $val . '" ';
             }
         } elseif ($var == 'sf_fi_cancel') {
             if (!empty($val)) {
                 $xml .= 'inputCancel="' . $val . '"';
             }
         }
     }
     if ($isStandardInputsOpen) {
         $isStandardInputsOpen = false;
         $xml .= ' />';
     }
     $xml = '<semanticforms_Form name="' . $formName . '" >' . $xml;
     $xml .= '</semanticforms_Form>';
     return $xml;
 }