3
function wfSajaxGetMathUrl( $term ) {
4
$originalLink = MathRenderer::renderMath( $term );
6
if (false == strpos($originalLink, "src=\"")) {
10
$srcPart = substr($originalLink, strpos($originalLink, "src=")+ 5);
11
$url = strtok($srcPart, '"');
16
function wfSajaxGetImageUrl( $term ) {
17
global $wgExtensionFunctions, $wgTitle;
19
$options = new FCKeditorParserOptions();
20
$options->setTidy(true);
21
$parser = new FCKeditorParser();
23
if (in_array("wfCite", $wgExtensionFunctions)) {
24
$parser->setHook('ref', array($parser, 'ref'));
25
$parser->setHook('references', array($parser, 'references'));
27
$parser->setOutputType(OT_HTML);
28
$originalLink = $parser->parse("[[Image:".$term."]]", $wgTitle, $options)->getText();
29
if (false == strpos($originalLink, "src=\"")) {
33
$srcPart = substr($originalLink, strpos($originalLink, "src=")+ 5);
34
$url = strtok($srcPart, '"');
39
function wfSajaxSearchSpecialTagFCKeditor($empty) {
40
global $wgParser, $wgRawHtml;
42
$ret = "nowiki\nincludeonly\nonlyinclude\nnoinclude\ngallery\n";
47
$wgParser->firstCallInit();
48
foreach ($wgParser->getTags() as $h) {
49
if (!in_array($h, array("pre", "math", "ref", "references"))) {
53
$arr = explode("\n", $ret);
55
$ret = implode("\n", $arr);
60
function wfSajaxSearchImageFCKeditor( $term ) {
61
global $wgContLang, $wgOut;
64
$term = $wgContLang->checkTitleEncoding( $wgContLang->recodeInput( js_unescape( $term ) ) );
65
$term1 = str_replace( ' ', '_', $wgContLang->ucfirst( $term ) );
66
$term2 = str_replace( ' ', '_', $wgContLang->lc( $term ) );
67
$term3 = str_replace( ' ', '_', $wgContLang->uc( $term ) );
68
$term4 = str_replace( ' ', '_', $wgContLang->ucfirst( $term2 ) );
71
if ( strlen( str_replace( '_', '', $term ) )<3 )
74
$db = wfGetDB( DB_SLAVE );
75
$res = $db->select( 'page', 'page_title',
76
array( 'page_namespace' => NS_IMAGE,
77
"page_title LIKE '%". $db->strencode( $term1 ) ."%'".
78
"OR (page_title LIKE '%". $db->strencode( $term2 ) ."%') ".
79
"OR (page_title LIKE '%". $db->strencode( $term3 ) ."%') ".
80
"OR (page_title LIKE '%". $db->strencode( $term4 ) ."%') " ),
82
array( 'LIMIT' => $limit+1 )
87
while ( ( $row = $db->fetchObject( $res ) ) && ( ++$i <= $limit ) ) {
88
$ret .= $row->page_title ."\n";
91
$term = htmlspecialchars( $term );
96
function wfSajaxSearchArticleFCKeditor( $term ) {
97
global $wgContLang, $wgOut, $wgExtraNamespaces;
101
$term = $wgContLang->checkTitleEncoding( $wgContLang->recodeInput( js_unescape( $term ) ) );
103
if (strpos(strtolower($term), "category:") === 0) {
105
$term = substr($term, 9);
106
$prefix = "Category:";
108
else if (strpos(strtolower($term), ":category:") === 0) {
110
$term = substr($term, 10);
111
$prefix = ":Category:";
113
else if (strpos(strtolower($term), "media:") === 0) {
115
$term = substr($term, 6);
118
else if (strpos(strtolower($term), ":image:") === 0) {
120
$term = substr(strtolower($term), 7);
123
else if ( strpos($term,":") && is_array($wgExtraNamespaces )) {
124
$pos = strpos($term,":");
125
$find_ns = array_search(substr($term,0,$pos),$wgExtraNamespaces);
128
$prefix = substr($term,0,$pos+1);
129
$term = substr($term,$pos+1);
133
$term1 = str_replace( ' ', '_', $wgContLang->ucfirst( $term ) );
134
$term2 = str_replace( ' ', '_', $wgContLang->lc( $term ) );
135
$term3 = str_replace( ' ', '_', $wgContLang->uc( $term ) );
136
$term4 = str_replace( ' ', '_', $wgContLang->ucfirst( $term2 ) );
139
if ( strlen( str_replace( '_', '', $term ) )<3 ) {
143
$db = wfGetDB( DB_SLAVE );
144
$res = $db->select( 'page', 'page_title',
145
array( 'page_namespace' => $ns,
146
"page_title LIKE '%". $db->strencode( $term1 ) ."%' ".
147
"OR (page_title LIKE '%". $db->strencode( $term2 ) ."%') ".
148
"OR (page_title LIKE '%". $db->strencode( $term3 ) ."%') ".
149
"OR (page_title LIKE '%". $db->strencode( $term4 ) ."%') " ),
151
array( 'LIMIT' => $limit+1 )
156
while ( ( $row = $db->fetchObject( $res ) ) && ( ++$i <= $limit ) ) {
157
if (isset($prefix) && !is_null($prefix)) {
160
$ret .= $row->page_title ."\n";
163
$term = htmlspecialchars( $term );
168
function wfSajaxSearchCategoryFCKeditor()
170
global $wgContLang, $wgOut;
172
$db =& wfGetDB( DB_SLAVE );
173
$m_sql="SELECT tmpSelectCat1.cl_to AS title FROM ".$db->tableName('categorylinks')." AS tmpSelectCat1 ".
174
"LEFT JOIN ".$db->tableName('page')." AS tmpSelectCatPage ON ( tmpSelectCat1.cl_to = tmpSelectCatPage.page_title ".
175
"AND tmpSelectCatPage.page_namespace =$ns ) ".
176
"LEFT JOIN ".$db->tableName('categorylinks')." AS tmpSelectCat2 ON tmpSelectCatPage.page_id = tmpSelectCat2.cl_from ".
177
"WHERE tmpSelectCat2.cl_from IS NULL GROUP BY tmpSelectCat1.cl_to";
179
$res = $db->query($m_sql,__METHOD__ );
183
while ( ( $row = $db->fetchObject( $res ) ) ) {
184
$ret .= $row->title ."\n";
185
$sub = explode("\n",wfSajaxSearchCategoryChildrenFCKeditor($row->title));
186
foreach($sub as $subrow)if(strlen($subrow)>0)$ret.=" ".$subrow."\n";
192
function wfSajaxSearchCategoryChildrenFCKeditor($m_root)
194
global $wgContLang, $wgOut;
197
$m_root = str_replace("'","\'",$m_root);
198
$db =& wfGetDB( DB_SLAVE );
199
$m_sql ="SELECT tmpSelectCatPage.page_title AS title FROM ".$db->tableName('categorylinks')." AS tmpSelectCat ".
200
"LEFT JOIN ".$db->tableName('page')." AS tmpSelectCatPage ON tmpSelectCat.cl_from = tmpSelectCatPage.page_id ".
201
"WHERE tmpSelectCat.cl_to LIKE '$m_root' AND tmpSelectCatPage.page_namespace = $ns";
204
$res = $db->query($m_sql,__METHOD__ );
208
while ( ( $row = $db->fetchObject( $res ) ) ) {
209
$ret .= $row->title ."\n";
210
$sub = explode("\n",wfSajaxSearchCategoryChildrenFCKeditor($row->title));
211
foreach($sub as $subrow)if(strlen($subrow)>0)$ret.=" ".$subrow."\n";
218
function wfSajaxSearchTemplateFCKeditor($empty) {
219
global $wgContLang, $wgOut;
222
$db = wfGetDB( DB_SLAVE );
223
$options['ORDER BY'] = 'page_title';
224
$res = $db->select( 'page', 'page_title',
225
array( 'page_namespace' => $ns),
231
while ( $row = $db->fetchObject( $res ) ) {
232
$ret .= $row->page_title ."\n";
238
function wfSajaxWikiToHTML( $wiki ) {
241
$options = new FCKeditorParserOptions();
242
$options->setTidy(true);
243
$parser = new FCKeditorParser();
244
$parser->setOutputType(OT_HTML);
246
wfSajaxToggleFCKeditor('show'); //FCKeditor was switched to visible
247
return str_replace("<!-- Tidy found serious XHTML errors -->", "", $parser->parse($wiki, $wgTitle, $options)->getText());
250
function wfSajaxToggleFCKeditor($data) {
251
global $wgFCKEditorSaveUserSetting;
254
$_SESSION['showMyFCKeditor'] = RTE_VISIBLE; //visible last time
257
$_SESSION['showMyFCKeditor'] = 0; //invisible