XOOPS  2.6.0
wiki.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
25 {
30  public function encode($textarea_id)
31  {
32  $code = "<img src='{$this->image_path}/wiki.gif' alt='" .XoopsLocale::WIKI . "' onclick='xoopsCodeWiki(\"{$textarea_id}\",\"" . htmlspecialchars(XoopsLocale::WIKI_WORD_TO_LINK, ENT_QUOTES) . "\");' onmouseover='style.cursor=\"hand\"'/>&nbsp;";
33  $javascript = <<<EOH
34  function xoopsCodeWiki(id, enterWikiPhrase){
35  if (enterWikiPhrase == null) {
36  enterWikiPhrase = "Enter the word to be linked to Wiki:";
37  }
38  var selection = xoopsGetSelect(id);
39  if (selection.length > 0) {
40  var text = selection;
41  }else {
42  var text = prompt(enterWikiPhrase, "");
43  }
44  var domobj = xoopsGetElementById(id);
45  if ( text != null && text != "" ) {
46  var result = "[[" + text + "]]";
47  xoopsInsertText(domobj, result);
48  }
49  domobj.focus();
50  }
51 EOH;
52  return array(
54  );
55  }
56 
57  static function myCallback($match) {
58  return self::decode( $match[1] );
59  }
64  public function load(MyTextSanitizer &$ts)
65  {
66 // $ts->patterns[] = "/\[\[([^\]]*)\]\]/esU";
67 // $ts->replacements[] = __CLASS__ . "::decode( '\\1' )";
68 //mb------------------------------
69  $ts->callbackPatterns[] = "/\[\[([^\]]*)\]\]/sU";
70  $ts->callbacks[] = __CLASS__ . "::myCallback";
71 //mb------------------------------
72  }
73 
77  public static function decode ($url, $width, $height)
78  {
79  $config = parent::loadConfig(__DIR__);
80  if (empty($url) || empty($config['link'])) {
81  return $url;
82  }
83  $charset = !empty($config['charset']) ? $config['charset'] : "UTF-8";
84  $ret = "<a href='" . sprintf($config['link'], urlencode(XoopsLocale::convert_encoding($url, $charset))) . "' rel='external' title=''>{$text}</a>";
85  return $ret;
86  }
87 }
load(MyTextSanitizer &$ts)
Definition: wiki.php:64
const WIKI_WORD_TO_LINK
Definition: en_US.php:1103
static convert_encoding($text, $to= 'utf-8', $from= '')
Definition: Abstract.php:235
static decode($url, $width, $height)
Definition: wiki.php:77
encode($textarea_id)
Definition: wiki.php:30
static myCallback($match)
Definition: wiki.php:57
$height
$url
Definition: register.php:72
$width
$code
Definition: lostpass.php:48