1
+ − 1
<?php
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
diff
changeset
+ − 2
1
+ − 3
/*
+ − 4
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
317
+ − 5
* Version 1.0.3 (Dyrad)
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
diff
changeset
+ − 6
* Copyright (C) 2006-2007 Dan Fuhry
1
+ − 7
* render.php - handles fetching pages and parsing them into HTML
+ − 8
*
+ − 9
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
+ − 10
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+ − 11
*
+ − 12
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ − 13
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ − 14
*/
+ − 15
+ − 16
class RenderMan {
+ − 17
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 18
public static function strToPageID($string)
1
+ − 19
{
+ − 20
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 21
$k = array_keys($paths->nslist);
136
f2ee42f026f7
Fix: internal links parsed with RenderMan::parse_internal_links() did not get namespaces prepended; added Project: alias namespace for internal links
Dan
diff
changeset
+ − 22
$proj_alt = 'Project:';
f2ee42f026f7
Fix: internal links parsed with RenderMan::parse_internal_links() did not get namespaces prepended; added Project: alias namespace for internal links
Dan
diff
changeset
+ − 23
if ( substr($string, 0, (strlen($proj_alt))) == $proj_alt )
f2ee42f026f7
Fix: internal links parsed with RenderMan::parse_internal_links() did not get namespaces prepended; added Project: alias namespace for internal links
Dan
diff
changeset
+ − 24
{
f2ee42f026f7
Fix: internal links parsed with RenderMan::parse_internal_links() did not get namespaces prepended; added Project: alias namespace for internal links
Dan
diff
changeset
+ − 25
$ns = 'Project';
f2ee42f026f7
Fix: internal links parsed with RenderMan::parse_internal_links() did not get namespaces prepended; added Project: alias namespace for internal links
Dan
diff
changeset
+ − 26
$pg = substr($string, strlen($proj_alt), strlen($string));
f2ee42f026f7
Fix: internal links parsed with RenderMan::parse_internal_links() did not get namespaces prepended; added Project: alias namespace for internal links
Dan
diff
changeset
+ − 27
return Array($pg, $ns);
f2ee42f026f7
Fix: internal links parsed with RenderMan::parse_internal_links() did not get namespaces prepended; added Project: alias namespace for internal links
Dan
diff
changeset
+ − 28
}
1
+ − 29
for($i=0;$i<sizeof($paths->nslist);$i++)
+ − 30
{
+ − 31
$ln = strlen($paths->nslist[$k[$i]]);
+ − 32
if(substr($string, 0, $ln) == $paths->nslist[$k[$i]])
+ − 33
{
+ − 34
$ns = $k[$i];
+ − 35
$pg = substr($string, strlen($paths->nslist[$ns]), strlen($string));
+ − 36
}
+ − 37
}
+ − 38
return Array($pg, $ns);
+ − 39
}
+ − 40
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 41
public static function getPage($page_id, $namespace, $wiki = 1, $smilies = true, $filter_links = true, $redir = true, $render = true)
1
+ − 42
{
+ − 43
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 44
+ − 45
$perms =& $session;
+ − 46
322
+ − 47
if ( $page_id != $paths->page_id || $namespace != $paths->namespace )
1
+ − 48
{
+ − 49
unset($perms);
+ − 50
unset($perms); // PHP <5.1.5 Zend bug
+ − 51
$perms = $session->fetch_page_acl($page_id, $namespace);
+ − 52
}
+ − 53
+ − 54
if(!$perms->get_permissions('read'))
+ − 55
return 'Access denied ('.$paths->nslist[$namespace].$page_id.')';
+ − 56
+ − 57
if($wiki == 0 || $render == false)
+ − 58
{
+ − 59
if(!$perms->get_permissions('view_source'))
+ − 60
{
+ − 61
return 'Access denied ('.$paths->nslist[$namespace].$page_id.')';
+ − 62
}
+ − 63
}
+ − 64
+ − 65
$q = $db->sql_query('SELECT page_text,char_tag FROM '.table_prefix.'page_text WHERE page_id=\''.$db->escape($page_id).'\' AND namespace=\''.$db->escape($namespace).'\';');
+ − 66
if ( !$q )
+ − 67
{
+ − 68
$db->_die('Method called was: RenderMan::getPage(\''.$page_id.'\', \''.$namespace.'\');.');
+ − 69
}
+ − 70
if ( $db->numrows() < 1 )
+ − 71
{
+ − 72
return false;
+ − 73
}
+ − 74
$row = $db->fetchrow();
+ − 75
$db->free_result();
+ − 76
+ − 77
$message = $row['page_text'];
+ − 78
$chartag = $row['char_tag'];
+ − 79
unset($row); // Free some memory
+ − 80
133
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
diff
changeset
+ − 81
if ( preg_match("#^\#redirect \[\[([^\]\r\n\a\t]+?)\]\]#", $message, $m) && $redir && ( !isset($_GET['redirect']) || ( isset($_GET['redirect']) && $_GET['redirect'] != 'no' ) ) )
1
+ − 82
{
+ − 83
$old = $paths->cpage;
+ − 84
$a = RenderMan::strToPageID($m[1]);
+ − 85
$a[0] = str_replace(' ', '_', $a[0]);
+ − 86
+ − 87
$pageid = str_replace(' ', '_', $paths->nslist[$a[1]] . $a[0]);
+ − 88
$paths->page = $pageid;
+ − 89
$paths->cpage = $paths->pages[$pageid];
+ − 90
//die('<pre>'.print_r($paths->cpage,true).'</pre>');
+ − 91
+ − 92
unset($template);
+ − 93
unset($GLOBALS['template']);
+ − 94
+ − 95
$GLOBALS['template'] = new template();
+ − 96
global $template;
+ − 97
+ − 98
$template->template(); // Tear down and rebuild the template parser
+ − 99
$template->load_theme($session->theme, $session->style);
+ − 100
+ − 101
$data = '<div><small>(Redirected from <a href="'.makeUrlNS($old['namespace'], $old['urlname_nons'], 'redirect=no', true).'">'.$old['name'].'</a>)</small></div>'.RenderMan::getPage($a[0], $a[1], $wiki, $smilies, $filter_links, false /* Enforces a maximum of one redirect */);
+ − 102
+ − 103
return $data;
+ − 104
}
+ − 105
else if(preg_match('#^\#redirect \[\[(.+?)\]\]#', $message, $m) && isset($_GET['redirect']) && $_GET['redirect'] == 'no')
+ − 106
{
+ − 107
preg_match('#^\#redirect \[\[(.+)\]\]#', $message, $m);
+ − 108
$m[1] = str_replace(' ', '_', $m[1]);
+ − 109
$message = preg_replace('#\#redirect \[\[(.+)\]\]#', '<nowiki><div class="mdg-infobox"><table border="0" width="100%" cellspacing="0" cellpadding="0"><tr><td valign="top"><img alt="Cute wet-floor icon" src="'.scriptPath.'/images/redirector.png" /></td><td valign="top" style="padding-left: 10px;"><b>This page is a <i>redirector</i>.</b><br />This means that this page will not show its own content by default. Instead it will display the contents of the page it redirects to.<br /><br />To create a redirect page, make the <i>first characters</i> in the page content <tt>#redirect [[Page_ID]]</tt>. For more information, see the Enano <a href="http://enanocms.org/Help:Wiki_formatting">Wiki formatting guide</a>.<br /><br />This page redirects to <a href="'.makeUrl($m[1]).'">'.$paths->pages[$m[1]]['name'].'</a>.</td></tr></table></div><br /><hr style="margin-left: 1em; width: 200px;" /></nowiki>', $message);
+ − 110
}
+ − 111
$session->disallow_password_grab();
+ − 112
return ($render) ? RenderMan::render($message, $wiki, $smilies, $filter_links) : $message;
+ − 113
}
+ − 114
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 115
public static function getTemplate($id, $parms)
1
+ − 116
{
+ − 117
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 118
if(!isset($paths->pages[$paths->nslist['Template'].$id]))
+ − 119
{
+ − 120
return '[['.$paths->nslist['Template'].$id.']]';
+ − 121
}
+ − 122
if(isset($paths->template_cache[$id]))
+ − 123
{
+ − 124
$text = $paths->template_cache[$id];
+ − 125
}
+ − 126
else
+ − 127
{
+ − 128
$text = RenderMan::getPage($id, 'Template', 0, true, true, 0);
+ − 129
$paths->template_cache[$id] = $text;
+ − 130
}
+ − 131
+ − 132
$text = preg_replace('/<noinclude>(.*?)<\/noinclude>/is', '', $text);
+ − 133
$text = preg_replace('/<nodisplay>(.*?)<\/nodisplay>/is', '\\1', $text);
+ − 134
+ − 135
preg_match_all('#\(_([0-9]+)_\)#', $text, $matchlist);
+ − 136
+ − 137
foreach($matchlist[1] as $m)
+ − 138
{
+ − 139
if(isset($parms[((int)$m)+1]))
+ − 140
{
+ − 141
$p = $parms[((int)$m)+1];
+ − 142
}
+ − 143
else
+ − 144
{
+ − 145
$p = '<b>Notice:</b> RenderMan::getTemplate(): Parameter '.$m.' is not set';
+ − 146
}
+ − 147
$text = str_replace('(_'.$m.'_)', $p, $text);
+ − 148
}
+ − 149
$text = RenderMan::include_templates($text);
+ − 150
return $text;
+ − 151
}
+ − 152
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 153
public static function fetch_template_text($id)
1
+ − 154
{
+ − 155
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 156
if(!isset($paths->pages[$paths->nslist['Template'].$id]))
+ − 157
{
+ − 158
return '[['.$paths->nslist['Template'].$id.']]';
+ − 159
}
+ − 160
if(isset($paths->template_cache[$id]))
+ − 161
{
+ − 162
$text = $paths->template_cache[$id];
+ − 163
}
+ − 164
else
+ − 165
{
+ − 166
$text = RenderMan::getPage($id, 'Template', 0, false, false, false, false);
+ − 167
$paths->template_cache[$id] = $text;
+ − 168
}
+ − 169
+ − 170
if ( is_string($text) )
+ − 171
{
+ − 172
$text = preg_replace('/<noinclude>(.*?)<\/noinclude>/is', '', $text);
+ − 173
$text = preg_replace('/<nodisplay>(.*?)<\/nodisplay>/is', '\\1', $text);
+ − 174
}
+ − 175
+ − 176
return $text;
+ − 177
}
+ − 178
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 179
public static function render($text, $wiki = 1, $smilies = true, $filter_links = true)
1
+ − 180
{
+ − 181
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 182
if($smilies)
+ − 183
{
+ − 184
$text = RenderMan::smilieyize($text);
+ − 185
}
+ − 186
if($wiki == 1)
+ − 187
{
+ − 188
$text = RenderMan::next_gen_wiki_format($text);
+ − 189
}
+ − 190
elseif($wiki == 2)
+ − 191
{
+ − 192
$text = $template->tplWikiFormat($text);
+ − 193
}
+ − 194
return $text;
+ − 195
}
+ − 196
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 197
public static function PlainTextRender($text, $wiki = 1, $smilies = false, $filter_links = true)
1
+ − 198
{
+ − 199
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 200
if($smilies)
+ − 201
{
+ − 202
$text = RenderMan::smilieyize($text);
+ − 203
}
+ − 204
if($wiki == 1)
+ − 205
{
+ − 206
$text = RenderMan::next_gen_wiki_format($text, true);
+ − 207
}
+ − 208
elseif($wiki == 2)
+ − 209
{
+ − 210
$text = $template->tplWikiFormat($text);
+ − 211
}
+ − 212
return $text;
+ − 213
}
+ − 214
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 215
public static function next_gen_wiki_format($text, $plaintext = false, $filter_links = true, $do_params = false)
1
+ − 216
{
+ − 217
global $db, $session, $paths, $template, $plugins; // Common objects
377
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 218
global $lang;
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 219
382
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
diff
changeset
+ − 220
profiler_log("RenderMan: starting wikitext render");
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
diff
changeset
+ − 221
1
+ − 222
$random_id = md5( time() . mt_rand() );
+ − 223
+ − 224
// Strip out <nowiki> sections and PHP code
+ − 225
+ − 226
$php = preg_match_all('#<\?php(.*?)\?>#is', $text, $phpsec);
+ − 227
+ − 228
for($i=0;$i<sizeof($phpsec[1]);$i++)
+ − 229
{
+ − 230
$text = str_replace('<?php'.$phpsec[1][$i].'?>', '{PHP:'.$random_id.':'.$i.'}', $text);
+ − 231
}
+ − 232
+ − 233
$nw = preg_match_all('#<nowiki>(.*?)<\/nowiki>#is', $text, $nowiki);
+ − 234
+ − 235
for($i=0;$i<sizeof($nowiki[1]);$i++)
+ − 236
{
+ − 237
$text = str_replace('<nowiki>'.$nowiki[1][$i].'</nowiki>', '{NOWIKI:'.$random_id.':'.$i.'}', $text);
+ − 238
}
+ − 239
+ − 240
$text = preg_replace('/<noinclude>(.*?)<\/noinclude>/is', '\\1', $text);
+ − 241
if ( $paths->namespace == 'Template' )
+ − 242
{
+ − 243
$text = preg_replace('/<nodisplay>(.*?)<\/nodisplay>/is', '', $text);
+ − 244
}
+ − 245
377
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 246
preg_match_all('/<lang code="([a-z0-9_]+)">([\w\W]+?)<\/lang>/', $text, $langmatch);
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 247
foreach ( $langmatch[0] as $i => $match )
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 248
{
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 249
if ( $langmatch[1][$i] == $lang->lang_code )
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 250
{
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 251
$text = str_replace_once($match, $langmatch[2][$i], $text);
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 252
}
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 253
else
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 254
{
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 255
$text = str_replace_once($match, '', $text);
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 256
}
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 257
}
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 258
163
+ − 259
$code = $plugins->setHook('render_wikiformat_pre');
+ − 260
foreach ( $code as $cmd )
+ − 261
{
+ − 262
eval($cmd);
+ − 263
}
+ − 264
1
+ − 265
if ( !$plaintext )
+ − 266
{
+ − 267
// Process images
142
ca9118d9c0f2
Rebrand as 1.0.2 (Coblynau); internal links are now parsed by RenderMan::parse_internal_links()
Dan
diff
changeset
+ − 268
$text = RenderMan::process_image_tags($text, $taglist);
66
+ − 269
$text = RenderMan::process_imgtags_stage2($text, $taglist);
1
+ − 270
}
+ − 271
+ − 272
if($do_params)
+ − 273
{
+ − 274
preg_match_all('#\(_([0-9]+)_\)#', $text, $matchlist);
+ − 275
foreach($matchlist[1] as $m)
+ − 276
{
+ − 277
$text = str_replace('(_'.$m.'_)', $paths->getParam((int)$m), $text);
+ − 278
}
+ − 279
}
+ − 280
174
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 281
//$template_regex = "/\{\{([^\]]+?)((\n([ ]*?)[A-z0-9]+([ ]*?)=([ ]*?)(.+?))*)\}\}/is";
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 282
$template_regex = "/\{\{(.+)((\n|\|[ ]*([A-z0-9]+)[ ]*=[ ]*(.+))*)\}\}/isU";
63
+ − 283
$i = 0;
+ − 284
while ( preg_match($template_regex, $text) )
+ − 285
{
+ − 286
$i++;
+ − 287
if ( $i == 5 )
+ − 288
break;
+ − 289
$text = RenderMan::include_templates($text);
+ − 290
}
1
+ − 291
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 292
// Before shipping it out to the renderer, replace spaces in between headings and paragraphs:
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 293
$text = preg_replace('/<\/(h[0-9]|div|p)>([\s]+)<(h[0-9]|div|p)( .+?)?>/i', '</\\1><\\3\\4>', $text);
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 294
1
+ − 295
$text = process_tables($text);
142
ca9118d9c0f2
Rebrand as 1.0.2 (Coblynau); internal links are now parsed by RenderMan::parse_internal_links()
Dan
diff
changeset
+ − 296
$text = RenderMan::parse_internal_links($text);
1
+ − 297
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 298
$wiki = Text_Wiki::singleton('Mediawiki');
1
+ − 299
if($plaintext)
+ − 300
{
+ − 301
$wiki->setRenderConf('Plain', 'wikilink', 'view_url', contentPath);
+ − 302
$result = $wiki->transform($text, 'Plain');
+ − 303
}
+ − 304
else
+ − 305
{
+ − 306
$wiki->setRenderConf('Xhtml', 'wikilink', 'view_url', contentPath);
+ − 307
$wiki->setRenderConf('Xhtml', 'Url', 'css_descr', 'external');
+ − 308
$result = $wiki->transform($text, 'Xhtml');
+ − 309
}
+ − 310
163
+ − 311
// HTML fixes
+ − 312
$result = preg_replace('#<tr>([\s]*?)<\/tr>#is', '', $result);
+ − 313
$result = preg_replace('#<p>([\s]*?)<\/p>#is', '', $result);
+ − 314
$result = preg_replace('#<br />([\s]*?)<table#is', '<table', $result);
+ − 315
$result = str_replace("<pre><code>\n", "<pre><code>", $result);
+ − 316
$result = preg_replace("/<p><table([^>]*?)><\/p>/", "<table\\1>", $result);
+ − 317
$result = str_replace("<br />\n</td>", "\n</td>", $result);
+ − 318
$result = str_replace("<p><tr>", "<tr>", $result);
+ − 319
$result = str_replace("<tr><br />", "<tr>", $result);
+ − 320
$result = str_replace("</tr><br />", "</tr>", $result);
+ − 321
$result = str_replace("</table><br />", "</table>", $result);
+ − 322
$result = preg_replace('/<\/table>$/', "</table><br /><br />", $result);
+ − 323
$result = str_replace("<p></div></p>", "</div>", $result);
+ − 324
$result = str_replace("<p></table></p>", "</table>", $result);
+ − 325
+ − 326
$code = $plugins->setHook('render_wikiformat_post');
+ − 327
foreach ( $code as $cmd )
+ − 328
{
+ − 329
eval($cmd);
+ − 330
}
37
+ − 331
1
+ − 332
// Reinsert <nowiki> sections
+ − 333
for($i=0;$i<$nw;$i++)
+ − 334
{
+ − 335
$result = str_replace('{NOWIKI:'.$random_id.':'.$i.'}', $nowiki[1][$i], $result);
+ − 336
}
+ − 337
+ − 338
// Reinsert PHP
+ − 339
for($i=0;$i<$php;$i++)
+ − 340
{
+ − 341
$result = str_replace('{PHP:'.$random_id.':'.$i.'}', '<?php'.$phpsec[1][$i].'?>', $result);
+ − 342
}
+ − 343
382
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
diff
changeset
+ − 344
profiler_log("RenderMan: finished wikitext render");
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
diff
changeset
+ − 345
1
+ − 346
return $result;
+ − 347
+ − 348
}
+ − 349
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 350
public static function wikiFormat($message, $filter_links = true, $do_params = false, $plaintext = false)
163
+ − 351
{
1
+ − 352
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 353
+ − 354
return RenderMan::next_gen_wiki_format($message, $plaintext, $filter_links, $do_params);
+ − 355
+ − 356
$random_id = md5( time() . mt_rand() );
+ − 357
+ − 358
// Strip out <nowiki> sections
+ − 359
$nw = preg_match_all('#<nowiki>(.*?)<\/nowiki>#is', $message, $nowiki);
+ − 360
+ − 361
if(!$plaintext)
+ − 362
{
+ − 363
+ − 364
//return '<pre>'.print_r($nowiki,true).'</pre>';
+ − 365
+ − 366
for($i=0;$i<sizeof($nowiki[1]);$i++)
+ − 367
{
+ − 368
$message = str_replace('<nowiki>'.$nowiki[1][$i].'</nowiki>', '{NOWIKI:'.$random_id.':'.$i.'}', $message);
+ − 369
}
+ − 370
+ − 371
$message = preg_replace('/<noinclude>(.*?)<\/noinclude>/is', '\\1', $message);
+ − 372
+ − 373
//return '<pre>'.htmlspecialchars($message).'</pre>';
+ − 374
35
+ − 375
$message = RenderMan::process_image_tags($message);
1
+ − 376
+ − 377
}
+ − 378
+ − 379
if($do_params)
+ − 380
{
+ − 381
preg_match_all('#\(_([0-9]+)_\)#', $message, $matchlist);
+ − 382
foreach($matchlist[1] as $m)
+ − 383
{
+ − 384
$message = str_replace('(_'.$m.'_)', $paths->getParam((int)$m), $message);
+ − 385
}
+ − 386
}
+ − 387
+ − 388
$message = RenderMan::include_templates($message);
+ − 389
+ − 390
// Reinsert <nowiki> sections
+ − 391
for($i=0;$i<$nw;$i++)
+ − 392
{
+ − 393
$message = str_replace('{NOWIKI:'.$random_id.':'.$i.'}', '<nowiki>'.$nowiki[1][$i].'</nowiki>', $message);
+ − 394
}
+ − 395
+ − 396
$message = process_tables($message);
+ − 397
//if($message2 != $message) return '<pre>'.htmlspecialchars($message2).'</pre>';
+ − 398
//$message = str_replace(array('<table>', '</table>'), array('<nowiki><table>', '</table></nowiki>'), $message);
+ − 399
+ − 400
$wiki =& Text_Wiki::singleton('Mediawiki');
+ − 401
if($plaintext)
+ − 402
{
+ − 403
$wiki->setRenderConf('Plain', 'wikilink', 'view_url', contentPath);
+ − 404
$result = $wiki->transform($message, 'Plain');
+ − 405
} else {
+ − 406
$wiki->setRenderConf('Xhtml', 'wikilink', 'view_url', contentPath);
+ − 407
$wiki->setRenderConf('Xhtml', 'Url', 'css_descr', 'external');
+ − 408
$result = $wiki->transform($message, 'Xhtml');
+ − 409
}
+ − 410
+ − 411
// HTML fixes
+ − 412
$result = preg_replace('#<tr>([\s]*?)<\/tr>#is', '', $result);
+ − 413
$result = preg_replace('#<p>([\s]*?)<\/p>#is', '', $result);
+ − 414
$result = preg_replace('#<br />([\s]*?)<table#is', '<table', $result);
+ − 415
$result = str_replace("<pre><code>\n", "<pre><code>", $result);
+ − 416
$result = preg_replace("/<p><table([^>]*?)><\/p>/", "<table\\1>", $result);
+ − 417
$result = str_replace("<br />\n</td>", "\n</td>", $result);
+ − 418
$result = str_replace("<p><tr>", "<tr>", $result);
+ − 419
$result = str_replace("<tr><br />", "<tr>", $result);
+ − 420
$result = str_replace("</tr><br />", "</tr>", $result);
+ − 421
$result = str_replace("</table></p>", "</table>", $result);
+ − 422
$result = str_replace("</table><br />", "</table>", $result);
+ − 423
$result = preg_replace('/<\/table>$/', "</table><br /><br />", $result);
163
+ − 424
$result = str_replace("<p></div></p>", "</div>", $result);
+ − 425
$result = str_replace("<p></table></p>", "</table>", $result);
1
+ − 426
+ − 427
$result = str_replace('<nowiki>', '<nowiki>', $result);
+ − 428
$result = str_replace('</nowiki>', '</nowiki>', $result);
+ − 429
+ − 430
return $result;
+ − 431
}
+ − 432
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 433
public static function destroy_javascript($message, $_php = false)
1
+ − 434
{
+ − 435
$message = preg_replace('#<(script|object|applet|embed|iframe|frame|form|input|select)(.*?)>#is', '<\\1\\2>', $message);
+ − 436
$message = preg_replace('#</(script|object|applet|embed|iframe|frame|form|input|select)(.*?)>#is', '</\\1\\2>', $message);
+ − 437
$message = preg_replace('#(javascript|script|activex|chrome|about|applet):#is', '\\1:', $message);
+ − 438
if ( $_php )
+ − 439
{
+ − 440
// Left in only for compatibility
+ − 441
$message = preg_replace('#<(.*?)>#is', '<\\1>', $message);
+ − 442
$message = preg_replace('#<(.*?)>#is', '<\\1>', $message);
+ − 443
$message = preg_replace('#<(\?|\?php|%)(.*?)(\?|%)>#is', '<\\1\\2\\3>', $message);
+ − 444
// strip <a href="foo" onclick="bar();">-type attacks
+ − 445
$message = preg_replace('#<([a-zA-Z:\-]+) (.*?)on([A-Za-z]*)=(.*?)>#is', '<\\1\\2on\\3=\\4>', $message);
+ − 446
}
+ − 447
return $message;
+ − 448
}
+ − 449
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 450
public static function strip_php($message)
1
+ − 451
{
+ − 452
return RenderMan::destroy_javascript($message, true);
+ − 453
}
+ − 454
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 455
public static function sanitize_html($text)
1
+ − 456
{
+ − 457
$text = htmlspecialchars($text);
91
+ − 458
$allowed_tags = Array('b', 'i', 'u', 'pre', 'code', 'tt', 'br', 'p', 'nowiki', '!--([\w\W]+)--');
1
+ − 459
foreach($allowed_tags as $t)
+ − 460
{
+ − 461
$text = preg_replace('#<'.$t.'>(.*?)</'.$t.'>#is', '<'.$t.'>\\1</'.$t.'>', $text);
+ − 462
$text = preg_replace('#<'.$t.' />#is', '<'.$t.' />', $text);
+ − 463
$text = preg_replace('#<'.$t.'>#is', '<'.$t.'>', $text);
+ − 464
}
+ − 465
return $text;
+ − 466
}
+ − 467
91
+ − 468
/**
+ − 469
* Parses internal links (wikilinks) in a block of text.
+ − 470
* @param string Text to process
+ − 471
* @return string
+ − 472
*/
+ − 473
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 474
public static function parse_internal_links($text)
91
+ − 475
{
136
f2ee42f026f7
Fix: internal links parsed with RenderMan::parse_internal_links() did not get namespaces prepended; added Project: alias namespace for internal links
Dan
diff
changeset
+ − 476
global $db, $session, $paths, $template, $plugins; // Common objects
91
+ − 477
+ − 478
// stage 1 - links with alternate text
+ − 479
preg_match_all('/\[\[([^\[\]<>\{\}\|]+)\|(.+?)\]\]/', $text, $matches);
+ − 480
foreach ( $matches[0] as $i => $match )
+ − 481
{
+ − 482
list($page_id, $namespace) = RenderMan::strToPageID($matches[1][$i]);
+ − 483
$pid_clean = $paths->nslist[$namespace] . sanitize_page_id($page_id);
+ − 484
+ − 485
$url = makeUrl($pid_clean, false, true);
+ − 486
$inner_text = $matches[2][$i];
+ − 487
$quot = '"';
+ − 488
$exists = ( isPage($pid_clean) ) ? '' : ' class="wikilink-nonexistent"';
+ − 489
+ − 490
$link = "<a href={$quot}{$url}{$quot}{$exists}>{$inner_text}</a>";
+ − 491
+ − 492
$text = str_replace($match, $link, $text);
+ − 493
}
+ − 494
+ − 495
// stage 2 - links with no alternate text
+ − 496
preg_match_all('/\[\[([^\[\]<>\{\}\|]+)\]\]/', $text, $matches);
+ − 497
foreach ( $matches[0] as $i => $match )
+ − 498
{
+ − 499
list($page_id, $namespace) = RenderMan::strToPageID($matches[1][$i]);
+ − 500
$pid_clean = $paths->nslist[$namespace] . sanitize_page_id($page_id);
+ − 501
159
f7e83b6db3be
Fixed: RenderMan::parse_internal_links() problems with prepending Project: instead of Site_name: to project page alias-namespace links
Dan
diff
changeset
+ − 502
$url = makeUrl($pid_clean, false, true);
f7e83b6db3be
Fixed: RenderMan::parse_internal_links() problems with prepending Project: instead of Site_name: to project page alias-namespace links
Dan
diff
changeset
+ − 503
$inner_text = ( isPage($pid_clean) ) ? htmlspecialchars(get_page_title($pid_clean)) : htmlspecialchars($matches[1][$i]);
91
+ − 504
$quot = '"';
+ − 505
$exists = ( isPage($pid_clean) ) ? '' : ' class="wikilink-nonexistent"';
+ − 506
+ − 507
$link = "<a href={$quot}{$url}{$quot}{$exists}>{$inner_text}</a>";
+ − 508
+ − 509
$text = str_replace($match, $link, $text);
+ − 510
}
+ − 511
+ − 512
return $text;
+ − 513
}
+ − 514
1
+ − 515
/**
+ − 516
* Parses a partial template tag in wikitext, and return an array with the parameters.
63
+ − 517
* @param string The portion of the template tag that contains the parameters.
+ − 518
* @example
1
+ − 519
* <code>
63
+ − 520
foo = lorem ipsum
+ − 521
bar = dolor sit amet
1
+ − 522
* </code>
+ − 523
* @return array Example:
+ − 524
* [foo] => lorem ipsum
+ − 525
* [bar] => dolor sit amet
+ − 526
*/
+ − 527
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 528
public static function parse_template_vars($input)
1
+ − 529
{
174
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 530
if ( !preg_match('/^(\|[ ]*([A-z0-9_]+)([ ]*)=([ ]*)(.+?))*$/is', trim($input)) )
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 531
{
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 532
$using_pipes = false;
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 533
$input = explode("\n", trim( $input ));
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 534
}
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 535
else
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 536
{
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 537
$using_pipes = true;
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 538
$input = substr($input, 1);
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 539
$input = explode("|", trim( $input ));
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 540
}
1
+ − 541
$parms = Array();
+ − 542
$current_line = '';
+ − 543
$current_parm = '';
+ − 544
foreach ( $input as $num => $line )
+ − 545
{
174
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 546
if ( preg_match('/^[ ]*([A-z0-9_]+)([ ]*)=([ ]*)(.+?)$/is', $line, $matches) )
1
+ − 547
{
174
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 548
$parm =& $matches[1];
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 549
$text =& $matches[4];
1
+ − 550
if ( $parm == $current_parm )
+ − 551
{
+ − 552
$current_line .= $text;
+ − 553
}
+ − 554
else
+ − 555
{
+ − 556
// New parameter
+ − 557
if ( $current_parm != '' )
+ − 558
$parms[$current_parm] = $current_line;
+ − 559
$current_line = $text;
+ − 560
$current_parm = $parm;
+ − 561
}
+ − 562
}
+ − 563
else if ( $num == 0 )
+ − 564
{
+ − 565
// Syntax error
+ − 566
return false;
+ − 567
}
+ − 568
else
+ − 569
{
+ − 570
$current_line .= "\n$line";
+ − 571
}
+ − 572
}
+ − 573
if ( !empty($current_parm) && !empty($current_line) )
+ − 574
{
+ − 575
$parms[$current_parm] = $current_line;
+ − 576
}
+ − 577
return $parms;
+ − 578
}
+ − 579
+ − 580
/**
+ − 581
* Processes all template tags within a block of wikitext.
174
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 582
* Updated in 1.0.2 to also parse template tags in the format of {{Foo |a = b |b = c |c = therefore, a}}
1
+ − 583
* @param string The text to process
+ − 584
* @return string Formatted text
+ − 585
* @example
+ − 586
* <code>
+ − 587
$text = '{{Template
+ − 588
parm1 = Foo
+ − 589
parm2 = Bar
+ − 590
}}';
174
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 591
$text = RenderMan::include_templates($text);
1
+ − 592
* </code>
+ − 593
*/
+ − 594
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 595
public static function include_templates($text)
1
+ − 596
{
+ − 597
global $db, $session, $paths, $template, $plugins; // Common objects
174
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 598
// $template_regex = "/\{\{([^\]]+?)((\n([ ]*?)[A-z0-9]+([ ]*?)=([ ]*?)(.+?))*)\}\}/is";
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 599
$template_regex = "/\{\{(.+)(((\n|[ ]*\|)[ ]*([A-z0-9]+)[ ]*=[ ]*(.+))*)\}\}/isU";
1
+ − 600
if ( $count = preg_match_all($template_regex, $text, $matches) )
+ − 601
{
174
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 602
//die('<pre>' . print_r($matches, true) . '</pre>');
1
+ − 603
for ( $i = 0; $i < $count; $i++ )
+ − 604
{
63
+ − 605
$matches[1][$i] = sanitize_page_id($matches[1][$i]);
1
+ − 606
$parmsection = trim($matches[2][$i]);
+ − 607
if ( !empty($parmsection) )
+ − 608
{
+ − 609
$parms = RenderMan::parse_template_vars($parmsection);
174
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 610
if ( !is_array($parms) )
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 611
// Syntax error
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
diff
changeset
+ − 612
$parms = array();
1
+ − 613
}
+ − 614
else
+ − 615
{
+ − 616
$parms = Array();
+ − 617
}
+ − 618
if ( $tpl_code = RenderMan::fetch_template_text($matches[1][$i]) )
+ − 619
{
+ − 620
$parser = $template->makeParserText($tpl_code);
+ − 621
$parser->assign_vars($parms);
+ − 622
$text = str_replace($matches[0][$i], $parser->run(), $text);
+ − 623
}
+ − 624
}
+ − 625
}
+ − 626
return $text;
+ − 627
}
+ − 628
+ − 629
/**
+ − 630
* Preprocesses an HTML text string prior to being sent to MySQL.
+ − 631
* @param string $text
+ − 632
* @param bool $strip_all_php - if true, strips all PHP regardless of user permissions. Else, strips PHP only if user level < USER_LEVEL_ADMIN.
+ − 633
*/
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 634
public static function preprocess_text($text, $strip_all_php = true, $sqlescape = true)
1
+ − 635
{
+ − 636
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 637
$random_id = md5( time() . mt_rand() );
+ − 638
+ − 639
$can_do_php = ( $session->get_permissions('php_in_pages') && !$strip_all_php );
377
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 640
$can_do_html = $session->get_permissions('html_in_pages');
1
+ − 641
377
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 642
if ( $can_do_html && !$can_do_php )
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 643
{
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 644
$text = preg_replace('#<(\?|\?php|%)(.*?)(\?|%)>#is', '<\\1\\2\\3>', $text);
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 645
}
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 646
else if ( !$can_do_html && !$can_do_php )
1
+ − 647
{
24
+ − 648
$text = sanitize_html($text, true);
1
+ − 649
// If we can't do PHP, we can't do Javascript either.
+ − 650
$text = RenderMan::destroy_javascript($text);
+ − 651
}
+ − 652
+ − 653
// Strip out <nowiki> sections and PHP code
+ − 654
+ − 655
$php = preg_match_all('#(<|<)\?php(.*?)\?(>|>)#is', $text, $phpsec);
+ − 656
+ − 657
//die('<pre>'.htmlspecialchars(print_r($phpsec, true))."\n".htmlspecialchars(print_r($text, true)).'</pre>');
+ − 658
+ − 659
for($i=0;$i<sizeof($phpsec[1]);$i++)
+ − 660
{
+ − 661
$text = str_replace($phpsec[0][$i], '{PHP:'.$random_id.':'.$i.'}', $text);
+ − 662
}
+ − 663
+ − 664
$nw = preg_match_all('#<nowiki>(.*?)<\/nowiki>#is', $text, $nowiki);
+ − 665
+ − 666
for($i=0;$i<sizeof($nowiki[1]);$i++)
+ − 667
{
+ − 668
$text = str_replace('<nowiki>'.$nowiki[1][$i].'</nowiki>', '{NOWIKI:'.$random_id.':'.$i.'}', $text);
+ − 669
}
+ − 670
345
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
diff
changeset
+ − 671
$text = str_replace('~~~~~', enano_date('G:i, j F Y (T)'), $text);
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
diff
changeset
+ − 672
$text = str_replace('~~~~', "[[User:$session->username|$session->username]] ".enano_date('G:i, j F Y (T)'), $text);
1
+ − 673
$text = str_replace('~~~', "[[User:$session->username|$session->username]] ", $text);
+ − 674
+ − 675
// Reinsert <nowiki> sections
+ − 676
for($i=0;$i<$nw;$i++)
+ − 677
{
+ − 678
$text = str_replace('{NOWIKI:'.$random_id.':'.$i.'}', '<nowiki>'.$nowiki[1][$i].'</nowiki>', $text);
+ − 679
}
+ − 680
// Reinsert PHP
+ − 681
for($i=0;$i<$php;$i++)
+ − 682
{
+ − 683
$phsec = ''.$phpsec[1][$i].'?php'.$phpsec[2][$i].'?'.$phpsec[3][$i].'';
+ − 684
if ( $strip_all_php )
+ − 685
$phsec = htmlspecialchars($phsec);
+ − 686
$text = str_replace('{PHP:'.$random_id.':'.$i.'}', $phsec, $text);
+ − 687
}
+ − 688
+ − 689
$text = ( $sqlescape ) ? $db->escape($text) : $text;
+ − 690
+ − 691
return $text;
+ − 692
}
+ − 693
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 694
public static function smilieyize($text, $complete_urls = false)
1
+ − 695
{
+ − 696
+ − 697
$random_id = md5( time() . mt_rand() );
+ − 698
+ − 699
// Smileys array - eventually this will be fetched from the database by
+ − 700
// RenderMan::initSmileys during initialization, but it will all be hardcoded for beta 2
+ − 701
+ − 702
$smileys = Array(
+ − 703
'O:-)' => 'face-angel.png',
+ − 704
'O:)' => 'face-angel.png',
+ − 705
'O=)' => 'face-angel.png',
+ − 706
':-)' => 'face-smile.png',
+ − 707
':)' => 'face-smile.png',
+ − 708
'=)' => 'face-smile-big.png',
+ − 709
':-(' => 'face-sad.png',
+ − 710
':(' => 'face-sad.png',
+ − 711
';(' => 'face-sad.png',
+ − 712
':-O' => 'face-surprise.png',
+ − 713
';-)' => 'face-wink.png',
+ − 714
';)' => 'face-wink.png',
+ − 715
'8-)' => 'face-glasses.png',
+ − 716
'8)' => 'face-glasses.png',
+ − 717
':-D' => 'face-grin.png',
+ − 718
':D' => 'face-grin.png',
+ − 719
'=D' => 'face-grin.png',
+ − 720
':-*' => 'face-kiss.png',
+ − 721
':*' => 'face-kiss.png',
+ − 722
'=*' => 'face-kiss.png',
+ − 723
':\'(' => 'face-crying.png',
+ − 724
':-|' => 'face-plain.png',
+ − 725
':-\\' => 'face-plain.png',
+ − 726
':-/' => 'face-plain.png',
+ − 727
':joke:' => 'face-plain.png',
+ − 728
']:->' => 'face-devil-grin.png',
189
fd0e9c7a7b28
Automatic set of state on Oxygen sidebar portlets should work now; reimplemented parts of the template parser (again) to workaround some PHP/PCRE issues and add support for parser plugins
Dan
diff
changeset
+ − 729
']:->' => 'face-devil-grin.png',
1
+ − 730
':kiss:' => 'face-kiss.png',
+ − 731
':-P' => 'face-tongue-out.png',
+ − 732
':P' => 'face-tongue-out.png',
+ − 733
':-p' => 'face-tongue-out.png',
+ − 734
':p' => 'face-tongue-out.png',
+ − 735
':-X' => 'face-sick.png',
+ − 736
':X' => 'face-sick.png',
+ − 737
':sick:' => 'face-sick.png',
+ − 738
':-]' => 'face-oops.png',
+ − 739
':]' => 'face-oops.png',
+ − 740
':oops:' => 'face-oops.png',
+ − 741
':-[' => 'face-embarassed.png',
+ − 742
':[' => 'face-embarassed.png'
+ − 743
);
+ − 744
/*
+ − 745
$keys = array_keys($smileys);
+ − 746
foreach($keys as $k)
+ − 747
{
+ − 748
$regex1 = '#([\W]+)'.preg_quote($k).'([\s\n\r\.]+)#s';
+ − 749
$regex2 = '\\1<img alt="'.$k.'" title="'.$k.'" src="'.scriptPath.'/images/smilies/'.$smileys[$k].'" style="border: 0;" />\\2';
+ − 750
$text = preg_replace($regex1, $regex2, $text);
+ − 751
}
+ − 752
*/
+ − 753
+ − 754
// Strip out <nowiki> sections
+ − 755
//return '<pre>'.htmlspecialchars($text).'</pre>';
+ − 756
$nw = preg_match_all('#<nowiki>(.*?)<\/nowiki>#is', $text, $nowiki);
+ − 757
+ − 758
for($i=0;$i<sizeof($nowiki[1]);$i++)
+ − 759
{
+ − 760
$text = str_replace('<nowiki>'.$nowiki[1][$i].'</nowiki>', '{NOWIKI:'.$random_id.':'.$i.'}', $text);
+ − 761
}
+ − 762
+ − 763
$keys = array_keys($smileys);
+ − 764
foreach($keys as $k)
+ − 765
{
+ − 766
$t = str_hex($k);
+ − 767
$t = explode(' ', $t);
+ − 768
$s = '';
+ − 769
foreach($t as $b)
+ − 770
{
+ − 771
$s.='&#x'.$b.';';
+ − 772
}
+ − 773
$pfx = ( $complete_urls ) ? 'http' . ( isset($_SERVER['HTTPS']) ? 's' : '' ) . '://'.$_SERVER['HTTP_HOST'] : '';
+ − 774
$text = str_replace(' '.$k, ' <nowiki><img title="'.$s.'" alt="'.$s.'" src="'.$pfx.scriptPath.'/images/smilies/'.$smileys[$k].'" style="border: 0;" /></nowiki>', $text);
+ − 775
}
+ − 776
//*/
+ − 777
+ − 778
// Reinsert <nowiki> sections
+ − 779
for($i=0;$i<$nw;$i++)
+ − 780
{
+ − 781
$text = str_replace('{NOWIKI:'.$random_id.':'.$i.'}', '<nowiki>'.$nowiki[1][$i].'</nowiki>', $text);
+ − 782
}
+ − 783
+ − 784
return $text;
+ − 785
}
+ − 786
+ − 787
/*
+ − 788
* **** DEPRECATED ****
+ − 789
* Replaces some critical characters in a string with MySQL-safe equivalents
+ − 790
* @param $text string the text to escape
+ − 791
* @return array key 0 is the escaped text, key 1 is the character tag
+ − 792
* /
+ − 793
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 794
public static function escape_page_text($text)
1
+ − 795
{
+ − 796
$char_tag = md5(microtime() . mt_rand());
+ − 797
$text = str_replace("'", "{APOS:$char_tag}", $text);
+ − 798
$text = str_replace('"', "{QUOT:$char_tag}", $text);
+ − 799
$text = str_replace("\\", "{SLASH:$char_tag}", $text);
+ − 800
return Array($text, $char_tag);
+ − 801
}
+ − 802
*/
+ − 803
+ − 804
/* **** DEPRECATED ****
+ − 805
* Reverses the result of RenderMan::escape_page_text().
+ − 806
* @param $text string the text to unescape
+ − 807
* @param $char_tag string the character tag
+ − 808
* @return string
+ − 809
* /
+ − 810
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 811
public static function unescape_page_text($text, $char_tag)
1
+ − 812
{
+ − 813
$text = str_replace("{APOS:$char_tag}", "'", $text);
+ − 814
$text = str_replace("{QUOT:$char_tag}", '"', $text);
+ − 815
$text = str_replace("{SLASH:$char_tag}", "\\", $text);
+ − 816
return $text;
+ − 817
}
+ − 818
*/
+ − 819
+ − 820
/**
+ − 821
* Generates a summary of the differences between two texts, and formats it as XHTML.
+ − 822
* @param $str1 string the first block of text
+ − 823
* @param $str2 string the second block of text
+ − 824
* @return string
+ − 825
*/
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 826
public static function diff($str1, $str2)
1
+ − 827
{
+ − 828
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 829
$str1 = explode("\n", $str1);
+ − 830
$str2 = explode("\n", $str2);
+ − 831
$diff = new Diff($str1, $str2);
+ − 832
$renderer = new TableDiffFormatter();
+ − 833
return '<table class="diff">'.$renderer->format($diff).'</table>';
+ − 834
}
+ − 835
35
+ − 836
/**
+ − 837
* Changes wikitext image tags to HTML.
+ − 838
* @param string The wikitext to process
37
+ − 839
* @param array Will be overwritten with the list of HTML tags (the system uses tokens for TextWiki compatibility)
35
+ − 840
* @return string
+ − 841
*/
+ − 842
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 843
public static function process_image_tags($text, &$taglist)
35
+ − 844
{
+ − 845
global $db, $session, $paths, $template, $plugins; // Common objects
+ − 846
37
+ − 847
$s_delim = "\xFF";
+ − 848
$f_delim = "\xFF";
+ − 849
$taglist = array();
+ − 850
35
+ − 851
// Wicked huh?
377
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
diff
changeset
+ − 852
$regex = '/\[\[:' . str_replace('/', '\\/', preg_quote($paths->nslist['File'])) . '([\w\s0-9_\(\)!@%\^\+\|\.-]+?)((\|thumb)|(\|([0-9]+)x([0-9]+)))?(\|left|\|right)?(\|raw|\|(.+))?\]\]/i';
35
+ − 853
+ − 854
preg_match_all($regex, $text, $matches);
+ − 855
+ − 856
foreach ( $matches[0] as $i => $match )
+ − 857
{
+ − 858
+ − 859
$full_tag =& $matches[0][$i];
+ − 860
$filename =& $matches[1][$i];
+ − 861
$scale_type =& $matches[2][$i];
+ − 862
$width =& $matches[5][$i];
+ − 863
$height =& $matches[6][$i];
+ − 864
$clear =& $matches[7][$i];
+ − 865
$caption =& $matches[8][$i];
+ − 866
+ − 867
if ( !isPage( $paths->nslist['File'] . $filename ) )
+ − 868
{
66
+ − 869
$text = str_replace($full_tag, '[[' . makeUrlNS('File', $filename) . ']]', $text);
35
+ − 870
continue;
+ − 871
}
+ − 872
+ − 873
if ( $scale_type == '|thumb' )
+ − 874
{
+ − 875
$r_width = 225;
+ − 876
$r_height = 225;
+ − 877
+ − 878
$url = makeUrlNS('Special', 'DownloadFile/' . $filename, 'preview&width=' . $r_width . '&height=' . $r_height, true);
+ − 879
}
+ − 880
else if ( !empty($width) && !empty($height) )
+ − 881
{
+ − 882
$r_width = $width;
+ − 883
$r_height = $height;
+ − 884
+ − 885
$url = makeUrlNS('Special', 'DownloadFile/' . $filename, 'preview&width=' . $r_width . '&height=' . $r_height, true);
+ − 886
}
+ − 887
else
+ − 888
{
+ − 889
$url = makeUrlNS('Special', 'DownloadFile/' . $filename);
+ − 890
}
+ − 891
+ − 892
$img_tag = '<img src="' . $url . '" ';
+ − 893
65
+ − 894
// if ( isset($r_width) && isset($r_height) && $scale_type != '|thumb' )
+ − 895
// {
66
+ − 896
// $img_tag .= 'width="' . $r_width . '" height="' . $r_height . '" ';
65
+ − 897
// }
35
+ − 898
66
+ − 899
$img_tag .= 'style="border-width: 0px; /* background-color: white; */" ';
35
+ − 900
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 901
$code = $plugins->setHook('img_tag_parse_img');
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 902
foreach ( $code as $cmd )
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 903
{
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 904
eval($cmd);
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 905
}
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 906
35
+ − 907
$img_tag .= '/>';
+ − 908
+ − 909
$complete_tag = '';
+ − 910
66
+ − 911
if ( !empty($scale_type) && $caption != '|raw' )
35
+ − 912
{
+ − 913
$complete_tag .= '<div class="thumbnail" ';
+ − 914
$clear_text = '';
+ − 915
if ( !empty($clear) )
+ − 916
{
+ − 917
$side = ( $clear == '|left' ) ? 'left' : 'right';
+ − 918
$opposite = ( $clear == '|left' ) ? 'right' : 'left';
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
diff
changeset
+ − 919
$clear_text .= "float: $side; margin-$opposite: 20px; width: {$r_width}px;";
35
+ − 920
$complete_tag .= 'style="' . $clear_text . '" ';
+ − 921
}
+ − 922
$complete_tag .= '>';
+ − 923
+ − 924
$complete_tag .= '<a href="' . makeUrlNS('File', $filename) . '" style="display: block;">';
+ − 925
$complete_tag .= $img_tag;
+ − 926
$complete_tag .= '</a>';
+ − 927
+ − 928
$mag_button = '<a href="' . makeUrlNS('File', $filename) . '" style="display: block; float: right; clear: right; margin: 0 0 10px 10px;"><img alt="[ + ]" src="' . scriptPath . '/images/thumbnail.png" style="border-width: 0px;" /></a>';
+ − 929
+ − 930
if ( !empty($caption) )
+ − 931
{
+ − 932
$cap = substr($caption, 1);
+ − 933
$complete_tag .= $mag_button . $cap;
+ − 934
}
+ − 935
+ − 936
$complete_tag .= '</div>';
+ − 937
}
66
+ − 938
else if ( $caption == '|raw' )
+ − 939
{
67
+ − 940
$complete_tag .= "$img_tag";
+ − 941
$taglist[$i] = $complete_tag;
+ − 942
+ − 943
$repl = "{$s_delim}e_img_{$i}{$f_delim}";
+ − 944
$text = str_replace($full_tag, $repl, $text);
+ − 945
continue;
66
+ − 946
}
35
+ − 947
else
+ − 948
{
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 949
$complete_tag .= '<a href="' . makeUrlNS('File', $filename) . '" style="display: block;"';
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 950
$code = $plugins->setHook('img_tag_parse_link');
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 951
foreach ( $code as $cmd )
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 952
{
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 953
eval($cmd);
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 954
}
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
diff
changeset
+ − 955
$complete_tag .= '>';
35
+ − 956
$complete_tag .= $img_tag;
+ − 957
$complete_tag .= '</a>';
+ − 958
}
+ − 959
37
+ − 960
$complete_tag .= "\n\n";
+ − 961
$taglist[$i] = $complete_tag;
35
+ − 962
37
+ − 963
$pos = strpos($text, $full_tag);
35
+ − 964
+ − 965
while(true)
+ − 966
{
+ − 967
$check1 = substr($text, $pos, 3);
+ − 968
$check2 = substr($text, $pos, 1);
+ − 969
if ( $check1 == '<p>' || $pos == 0 || $check2 == "\n" )
+ − 970
{
+ − 971
// die('found at pos '.$pos);
+ − 972
break;
+ − 973
}
+ − 974
$pos--;
+ − 975
}
+ − 976
37
+ − 977
$repl = "{$s_delim}e_img_{$i}{$f_delim}";
+ − 978
$text = substr($text, 0, $pos) . $repl . substr($text, $pos);
35
+ − 979
+ − 980
$text = str_replace($full_tag, '', $text);
+ − 981
+ − 982
unset($full_tag, $filename, $scale_type, $width, $height, $clear, $caption, $r_width, $r_height);
+ − 983
+ − 984
}
+ − 985
+ − 986
return $text;
+ − 987
}
+ − 988
37
+ − 989
/**
+ − 990
* Finalizes processing of image tags.
+ − 991
* @param string The preprocessed text
+ − 992
* @param array The list of image tags created by RenderMan::process_image_tags()
+ − 993
*/
+ − 994
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
diff
changeset
+ − 995
public static function process_imgtags_stage2($text, $taglist)
37
+ − 996
{
+ − 997
$s_delim = "\xFF";
+ − 998
$f_delim = "\xFF";
+ − 999
foreach ( $taglist as $i => $tag )
+ − 1000
{
+ − 1001
$repl = "{$s_delim}e_img_{$i}{$f_delim}";
+ − 1002
$text = str_replace($repl, $tag, $text);
+ − 1003
}
+ − 1004
return $text;
+ − 1005
}
+ − 1006
1
+ − 1007
}
+ − 1008
+ − 1009
?>