本文整理汇总了PHP中getInterwiki函数的典型用法代码示例。如果您正苦于以下问题:PHP getInterwiki函数的具体用法?PHP getInterwiki怎么用?PHP getInterwiki使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getInterwiki函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
static function render($text, $type = null, $id = null, $instructions = null)
{
global $conf, $baseurl, $db;
// Unfortunately dokuwiki also uses $conf
$fs_conf = $conf;
$conf = array();
// Dokuwiki generates some notices
error_reporting(E_ALL ^ E_NOTICE);
if (!$instructions) {
include_once BASEDIR . '/plugins/dokuwiki/inc/parser/parser.php';
}
require_once BASEDIR . '/plugins/dokuwiki/inc/common.php';
require_once BASEDIR . '/plugins/dokuwiki/inc/parser/xhtml.php';
// Create a renderer
$Renderer = new Doku_Renderer_XHTML();
if (!is_string($instructions) || strlen($instructions) < 1) {
$modes = p_get_parsermodes();
$Parser = new Doku_Parser();
// Add the Handler
$Parser->Handler = new Doku_Handler();
// Add modes to parser
foreach ($modes as $mode) {
$Parser->addMode($mode['mode'], $mode['obj']);
}
$instructions = $Parser->parse($text);
// Cache the parsed text
if (!is_null($type) && !is_null($id)) {
$fields = array('content' => serialize($instructions), 'type' => $type, 'topic' => $id, 'last_updated' => time());
$keys = array('type', 'topic');
//autoquote is always true on db class
$db->Replace('{cache}', $fields, $keys);
}
} else {
$instructions = unserialize($instructions);
}
$Renderer->smileys = getSmileys();
$Renderer->entities = getEntities();
$Renderer->acronyms = getAcronyms();
$Renderer->interwiki = getInterwiki();
$conf = $fs_conf;
$conf['cachedir'] = FS_CACHE_DIR;
// for dokuwiki
$conf['fperm'] = 0600;
$conf['dperm'] = 0700;
// Loop through the instructions
foreach ($instructions as $instruction) {
// Execute the callback against the Renderer
call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]);
}
$return = $Renderer->doc;
// Display the output
if (Get::val('histring')) {
$words = explode(' ', Get::val('histring'));
foreach ($words as $word) {
$return = html_hilight($return, $word);
}
}
return $return;
}
示例2: testNonexisting
function testNonexisting()
{
$Renderer = new Doku_Renderer();
$Renderer->interwiki = getInterwiki();
$shortcut = 'nonexisting';
$reference = 'foo @+%/';
$url = $Renderer->_resolveInterWiki($shortcut, $reference);
$expected = 'https://www.google.com/search?q=foo%20%40%2B%25%2F&btnI=lucky';
$this->assertEquals($expected, $url);
}
示例3: handle_ajax_call_unknown
/**
* @param Doku_Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return void
*/
public function handle_ajax_call_unknown(Doku_Event &$event, $param)
{
if ($event->data !== 'iwiki_list') {
return;
}
$event->stopPropagation();
$event->preventDefault();
$a = getInterwiki();
ksort($a);
echo json_encode($a);
}
示例4: p_render
function p_render($mode, $instructions, &$info)
{
if (is_null($instructions)) {
return '';
}
// msg("Memory Usage p_render start: ". memory_get_usage(), -1);
// require_once DOKU_INC."inc/parser/$mode.php";
$rclass = "Doku_Renderer_{$mode}";
if (!class_exists($rclass)) {
trigger_error("Unable to resolve render class {$rclass}", E_USER_ERROR);
}
$Renderer =& new $rclass();
#FIXME any way to check for class existance?
$Renderer->smileys = getSmileys();
$Renderer->entities = getEntities();
$Renderer->latexentities = $this->_texit_conf['latexentities'];
$Renderer->acronyms = getAcronyms();
$Renderer->interwiki = getInterwiki();
$Renderer->info = $info;
// Loop through the instructions
foreach ($instructions as $instruction) {
// Execute the callback against the Renderer
call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]);
}
//set info array
$info = $Renderer->info;
// msg("Memory Usage p_render end: ". memory_get_usage(), -1);
// Return the output
return $Renderer->doc;
}
示例5: css_interwiki
/**
* Prints classes for interwikilinks
*
* Interwiki links have two classes: 'interwiki' and 'iw_$name>' where
* $name is the identifier given in the config. All Interwiki links get
* an default style with a default icon. If a special icon is available
* for an interwiki URL it is set in it's own class. Both classes can be
* overwritten in the template or userstyles.
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function css_interwiki()
{
// default style
echo 'a.interwiki {';
echo ' background: transparent url(' . DOKU_BASE . 'lib/images/interwiki.png) 0px 1px no-repeat;';
echo ' padding: 1px 0px 1px 16px;';
echo '}';
// additional styles when icon available
$iwlinks = getInterwiki();
foreach (array_keys($iwlinks) as $iw) {
$class = preg_replace('/[^_\\-a-z0-9]+/i', '_', $iw);
if (file_exists(DOKU_INC . 'lib/images/interwiki/' . $iw . '.png')) {
echo "a.iw_{$class} {";
echo ' background-image: url(' . DOKU_BASE . 'lib/images/interwiki/' . $iw . '.png)';
echo '}';
} elseif (file_exists(DOKU_INC . 'lib/images/interwiki/' . $iw . '.gif')) {
echo "a.iw_{$class} {";
echo ' background-image: url(' . DOKU_BASE . 'lib/images/interwiki/' . $iw . '.gif)';
echo '}';
}
}
}
示例6: p_render
/**
* Renders a list of instruction to the specified output mode
*
* In the $info array is information from the renderer returned
*
* @author Harry Fuecks <hfuecks@gmail.com>
* @author Andreas Gohr <andi@splitbrain.org>
*/
function p_render($mode, $instructions, &$info)
{
if (is_null($instructions)) {
return '';
}
$Renderer =& p_get_renderer($mode);
if (is_null($Renderer)) {
return null;
}
$Renderer->reset();
$Renderer->smileys = getSmileys();
$Renderer->entities = getEntities();
$Renderer->acronyms = getAcronyms();
$Renderer->interwiki = getInterwiki();
// Loop through the instructions
foreach ($instructions as $instruction) {
// Execute the callback against the Renderer
call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]);
}
//set info array
$info = $Renderer->info;
// Post process and return the output
$data = array($mode, &$Renderer->doc);
trigger_event('RENDERER_CONTENT_POSTPROCESS', $data);
return $Renderer->doc;
}
示例7: p_render
/**
* Renders a list of instruction to the specified output mode
*
* In the $info array are informations from the renderer returned
*
* @author Harry Fuecks <hfuecks@gmail.com>
* @author Andreas Gohr <andi@splitbrain.org>
*/
function p_render($mode, $instructions, &$info)
{
if (is_null($instructions)) {
return '';
}
if ($mode == 'wiki') {
msg("Renderer for {$mode} not valid", -1);
return null;
}
//FIXME!! remove this line when inc/parser/wiki.php works.
// Create the renderer
if (!@file_exists(DOKU_INC . "inc/parser/{$mode}.php")) {
msg("No renderer for {$mode} found", -1);
return null;
}
require_once DOKU_INC . "inc/parser/{$mode}.php";
$rclass = "Doku_Renderer_{$mode}";
if (!class_exists($rclass)) {
trigger_error("Unable to resolve render class {$rclass}", E_USER_WARNING);
msg("Renderer for {$mode} not valid", -1);
return null;
}
$Renderer = new $rclass();
#FIXME any way to check for class existance?
$Renderer->smileys = getSmileys();
$Renderer->entities = getEntities();
$Renderer->acronyms = getAcronyms();
$Renderer->interwiki = getInterwiki();
#$Renderer->badwords = getBadWords();
// Loop through the instructions
foreach ($instructions as $instruction) {
// Execute the callback against the Renderer
call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]);
}
//set info array
$info = $Renderer->info;
// Post process and return the output
$data = array($mode, &$Renderer->doc);
trigger_event('RENDERER_CONTENT_POSTPROCESS', $data);
return $Renderer->doc;
}
示例8: listLinks
/**
* Lists all links contained in a wiki page
*
* @author Michael Klier <chi@chimeric.de>
*/
function listLinks($id)
{
$id = $this->resolvePageId($id);
if (auth_quickaclcheck($id) < AUTH_READ) {
throw new RemoteAccessDeniedException('You are not allowed to read this page', 111);
}
$links = array();
// resolve page instructions
$ins = p_cached_instructions(wikiFN($id));
// instantiate new Renderer - needed for interwiki links
include DOKU_INC . 'inc/parser/xhtml.php';
$Renderer = new Doku_Renderer_xhtml();
$Renderer->interwiki = getInterwiki();
// parse parse instructions
foreach ($ins as $in) {
$link = array();
switch ($in[0]) {
case 'internallink':
$link['type'] = 'local';
$link['page'] = $in[1][0];
$link['href'] = wl($in[1][0]);
array_push($links, $link);
break;
case 'externallink':
$link['type'] = 'extern';
$link['page'] = $in[1][0];
$link['href'] = $in[1][0];
array_push($links, $link);
break;
case 'interwikilink':
$url = $Renderer->_resolveInterWiki($in[1][2], $in[1][3]);
$link['type'] = 'extern';
$link['page'] = $url;
$link['href'] = $url;
array_push($links, $link);
break;
}
}
return $links;
}
示例9: userlink
/**
* Returns users realname w/o link
*
* @param string|null $username or null when currently logged-in user should be used
* @param bool $textonly true returns only plain text, true allows returning html
* @return string html or plain text(not escaped) of formatted user name
*
* @triggers COMMON_USER_LINK
*/
function userlink($username = null, $textonly = false)
{
global $conf, $INFO;
/** @var DokuWiki_Auth_Plugin $auth */
global $auth;
/** @var Input $INPUT */
global $INPUT;
// prepare initial event data
$data = array('username' => $username, 'name' => '', 'link' => array('target' => '', 'pre' => '', 'suf' => '', 'style' => '', 'more' => '', 'url' => '', 'title' => '', 'class' => ''), 'userlink' => '', 'textonly' => $textonly);
if ($username === null) {
$data['username'] = $username = $INPUT->server->str('REMOTE_USER');
if ($textonly) {
$data['name'] = $INFO['userinfo']['name'] . ' (' . $INPUT->server->str('REMOTE_USER') . ')';
} else {
$data['name'] = '<bdi>' . hsc($INFO['userinfo']['name']) . '</bdi> (<bdi>' . hsc($INPUT->server->str('REMOTE_USER')) . '</bdi>)';
}
}
$evt = new Doku_Event('COMMON_USER_LINK', $data);
if ($evt->advise_before(true)) {
if (empty($data['name'])) {
if ($auth) {
$info = $auth->getUserData($username);
}
if ($conf['showuseras'] != 'loginname' && isset($info) && $info) {
switch ($conf['showuseras']) {
case 'username':
case 'username_link':
$data['name'] = $textonly ? $info['name'] : hsc($info['name']);
break;
case 'email':
case 'email_link':
$data['name'] = obfuscate($info['mail']);
break;
}
} else {
$data['name'] = $textonly ? $data['username'] : hsc($data['username']);
}
}
/** @var Doku_Renderer_xhtml $xhtml_renderer */
static $xhtml_renderer = null;
if (!$data['textonly'] && empty($data['link']['url'])) {
if (in_array($conf['showuseras'], array('email_link', 'username_link'))) {
if (!isset($info)) {
if ($auth) {
$info = $auth->getUserData($username);
}
}
if (isset($info) && $info) {
if ($conf['showuseras'] == 'email_link') {
$data['link']['url'] = 'mailto:' . obfuscate($info['mail']);
} else {
if (is_null($xhtml_renderer)) {
$xhtml_renderer = p_get_renderer('xhtml');
}
if (empty($xhtml_renderer->interwiki)) {
$xhtml_renderer->interwiki = getInterwiki();
}
$shortcut = 'user';
$exists = null;
$data['link']['url'] = $xhtml_renderer->_resolveInterWiki($shortcut, $username, $exists);
$data['link']['class'] .= ' interwiki iw_user';
if ($exists !== null) {
if ($exists) {
$data['link']['class'] .= ' wikilink1';
} else {
$data['link']['class'] .= ' wikilink2';
$data['link']['rel'] = 'nofollow';
}
}
}
} else {
$data['textonly'] = true;
}
} else {
$data['textonly'] = true;
}
}
if ($data['textonly']) {
$data['userlink'] = $data['name'];
} else {
$data['link']['name'] = $data['name'];
if (is_null($xhtml_renderer)) {
$xhtml_renderer = p_get_renderer('xhtml');
}
$data['userlink'] = $xhtml_renderer->_formatLink($data['link']);
}
}
$evt->advise_after();
unset($evt);
return $data['userlink'];
}
示例10: _tpl_user_homepage_link
/**
* Return the user home-page link
*
* @author Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
*
* @return string
*/
function _tpl_user_homepage_link()
{
$interwiki = getInterwiki();
$user_url = str_replace('{NAME}', $_SERVER['REMOTE_USER'], $interwiki['user']);
return wl(cleanID($user_url));
}
示例11: _mixture_init
/**
* INITALIZE TEMPLATE
*
* Load usefull plugins' helpers.
*/
function _mixture_init()
{
global $ID, $conf, $JSINFO;
// New global variables
global $styleIni, $glyphs, $uhp, $trs;
// Parse style.ini file (has to be here rather than in _mixture_init() to be abble to use it's data for fonts declarations)
$styleIni = array();
// Look for a customized 'style.ini' generated by Styling plugin
if (is_file(DOKU_CONF . "tpl/mixture/style.ini")) {
$styleIni = parse_ini_file(DOKU_CONF . "tpl/mixture/style.ini", true);
}
// Or for template's default 'style.ini'
if (count($styleIni) == 0) {
$styleIni = parse_ini_file("style.ini", true);
}
// Parse glyphs.conf files
$glyphs = array();
// Get template's default glyphs
if (is_file(tpl_incdir() . "conf/glyphs.php")) {
include tpl_incdir() . "conf/glyphs.php";
}
// Get custom glyphs
if (is_file(DOKU_CONF . "tpl/mixture/glyphs.php")) {
include DOKU_CONF . "tpl/mixture/glyphs.php";
}
//dbg($glyphs);
// Look for a customized 'style.ini' generated by Styling plugin
if (is_file(DOKU_CONF . "tpl/mixture/style.ini")) {
$styleIni = parse_ini_file(DOKU_CONF . "tpl/mixture/style.ini", true);
}
// Store options into $JSINFO for later use
$JSINFO['ScrollDelay'] = tpl_getConf('scrollDelay');
// if ((strpos(tpl_getConf('elements'), 'header_landing_changes') !== false) or (strpos(tpl_getConf('elements'), 'header_topbar_date') !== false)) {
// $JSINFO['LoadMoment'] = true;
// } else {
// $JSINFO['LoadMoment'] = false;
// }
if (strpos(tpl_getConf('elements'), 'header_landing_changes') !== false or strpos(tpl_getConf('elements'), 'header_topbar_lastchanges') !== false) {
$JSINFO['LoadNewsTicker'] = true;
} else {
$JSINFO['LoadNewsTicker'] = false;
}
// Preparing usefull plugins' helpers
$interwiki = getInterwiki();
$mixturePublicId = ltrim(str_replace('{NAME}', $_SERVER['REMOTE_USER'], $interwiki['user']), ':');
if (!plugin_isdisabled('userhomepage')) {
$uhpHelper = plugin_load('helper', 'userhomepage');
$uhp = $uhpHelper->getElements();
if (isset($mixturePublicId) and !isset($uhp['public'])) {
$uhp['public'] = array();
$uhp['public']['id'] = $mixturePublicId;
}
} else {
// Without Userhomepage plugin, Public Page namespace is set by 'user' value in 'conf/interwiki.conf'
$uhp = array();
$uhp['private'] = null;
$uhp['public'] = array();
$uhp['public']['id'] = $mixturePublicId;
}
if (!plugin_isdisabled('translation')) {
$trs = array();
$translationHelper = plugin_load('helper', 'translation');
$trs['parts'] = $translationHelper->getTransParts($ID);
} else {
$trs['parts'] = null;
}
// Adding test alerts if debug is enabled
if ($_GET['debug'] == true) {
msg("This is an error alert (-1)", -1);
msg("This is an info message (0)", 0);
msg("This is a success message (1)", 1);
msg("This is a notification (2)", 2);
}
}
示例12: _render_xhtml
/**
* Renders a list of instruction to minimal xhtml
*@author Myron Turner <turnermm02@shaw.ca>
*/
function _render_xhtml($text)
{
$mode = 'ckgedit';
global $skip_styling;
$skip_styling = $this->getConf('nofont_styling');
if (!$skip_styling && $_POST['styling'] == 'no_styles') {
$skip_styling = true;
}
if (strpos($text, '~~NO_STYLING~~') !== false) {
$skip_styling = true;
}
$text = preg_replace_callback('/(\\[\\[\\w+>)(.*?)([\\]\\|])/ms', create_function('$matches', ' //if(preg_match("/^\\w+$/",$matches[2])) return $matches[0];
return $matches[1] . "oIWIKIo" . $matches[2] ."cIWIKIc" . $matches[3] ;'), $text);
global $Smilies;
$smiley_as_text = @$this->getConf('smiley_as_text');
if ($smiley_as_text) {
$Smilies = array('8-)' => 'aSMILEY_1', '8-O' => 'aSMILEY_2', ':-(' => 'aSMILEY_3', ':-)' => 'aSMILEY_4', '=)' => 'aSMILEY_5', ':-/' => 'aSMILEY_6', ':-\\' => 'aSMILEY_7', ':-?' => 'aSMILEY_8', ':-D' => 'aSMILEY_9', ':-P' => 'bSMILEY_10', ':-O' => 'bSMILEY_11', ':-X' => 'bSMILEY_12', ':-|' => 'bSMILEY_13', ';-)' => 'bSMILEY_14', '^_^' => 'bSMILEY_15', ':?:' => 'bSMILEY_16', ':!:' => 'bSMILEY_17', 'LOL' => 'bSMILEY_18', 'FIXME' => 'bSMILEY_19', 'DELETEME' => 'bSMILEY_20');
$s_values = array_values($Smilies);
$s_values_regex = implode('|', $s_values);
$s_keys = array_keys($Smilies);
$s_keys = array_map(create_function('$k', 'return "(" . preg_quote($k,"/") . ")";'), $s_keys);
$s_keys_regex = implode('|', $s_keys);
global $haveDokuSmilies;
$haveDokuSmilies = false;
$text = preg_replace_callback('/(' . $s_keys_regex . ')/ms', create_function('$matches', 'global $Smilies;
global $haveDokuSmilies;
$haveDokuSmilies = true;
return $Smilies[$matches[1]];'), $text);
}
// try default renderer first:
$file = DOKU_INC . "inc/parser/{$mode}.php";
if (@file_exists($file)) {
require_once $file;
$rclass = "Doku_Renderer_{$mode}";
if (!class_exists($rclass)) {
trigger_error("Unable to resolve render class {$rclass}", E_USER_WARNING);
msg("Renderer for {$mode} not valid", -1);
return null;
}
$Renderer = new $rclass();
} else {
// Maybe a plugin is available?
$Renderer = plugin_load('renderer', $mode);
if (is_null($Renderer)) {
msg("No renderer for {$mode} found", -1);
return null;
}
}
// aimed at wrap plugin which allows multiple newlines in a cell
$text = preg_replace_callback('#(\\|.*?)\\|.?[\\n\\r]#ms', function ($matches) {
$matches[0] = preg_replace("#\\\\\\\\\\s*[\r\n]#ms", " \\\\\\\\ ", $matches[0]);
return $matches[0];
}, $text);
// prevents utf8 conversions of quotation marks
$text = str_replace('"', "_ckgedit_QUOT_", $text);
$text = preg_replace_callback('/(<code.*?>)([^<]+)(<\\/code>)/ms', create_function('$matches', '$quot = str_replace("_ckgedit_QUOT_",\'"\',$matches[2]);
$quot = str_replace("\\\\ ","_ckgedit_NL",$quot);
$quot .= "_ckgedit_NL";
return $matches[1] . $quot . $matches[3];'), $text);
$text = preg_replace_callback('/(<file.*?>)([^<]+)(<\\/file>)/ms', create_function('$matches', '$quot = str_replace("_ckgedit_QUOT_",\'"\',$matches[2]);
$quot = str_replace("\\\\ ","_ckgedit_NL",$quot);
$quot .= "_ckgedit_NL";
return $matches[1] . $quot . $matches[3];'), $text);
$text = preg_replace_callback('/(<code>|<file>)([^<]+)(<\\/code>|<\\/file>)/ms', create_function('$matches', '$matches[2] = str_replace("<font","ckgeditFONTOpen",$matches[2]);
$matches[2] = str_replace("font>","ckgeditFONTClose",$matches[2]);
return $matches[1] .$matches[2] . $matches[3]; '), $text);
$instructions = p_get_instructions("=== header ===");
// loads DOKU_PLUGINS array --M.T. Dec 22 2009
$instructions = p_get_instructions($text);
if (is_null($instructions)) {
return '';
}
$Renderer->notoc();
$Renderer->smileys = getSmileys();
$Renderer->entities = getEntities();
$Renderer->acronyms = array();
$Renderer->interwiki = getInterwiki();
// Loop through the instructions
/*
By-passing plugin processing was sugested and first implemented
by Matti Lattu<matti.lattu@iki.fi>
It is a significant contribution to the functionality of ckgEdit
*/
foreach ($instructions as $instruction) {
if ($instruction[0] == 'plugin') {
$Renderer->doc .= $instruction[1][3];
} else {
// Execute the callback against the Renderer
call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]);
}
}
//set info array
$info = $Renderer->info;
// Post process and return the output
$data = array($mode, &$Renderer->doc);
trigger_event('RENDERER_CONTENT_POSTPROCESS', $data);
//.........这里部分代码省略.........
示例13: create
function create($id, $user_title = false)
{
ob_start();
$id = ltrim($id, ':');
$id = ":{$id}";
$namespace = getNS($id);
epub_save_namespace($namespace);
$mode = 'epub';
$Renderer =& plugin_load('renderer', $mode);
$Renderer->set_oebps();
$Renderer->set_current_page(epub_clean_name(str_replace(':', '_', $id)) . '.html');
$this->_renderer = $Renderer;
if (is_null($Renderer)) {
msg("No renderer for {$mode} found", -1);
exit;
}
global $ID;
$oldID = $ID;
$ID = cleanID($id);
$wiki_file = wikiFN($id);
if (!file_exists($wiki_file)) {
epub_push_spine(array("", ""));
echo "{$id} not found\n";
return false;
}
epub_update_progress("reading {$id}");
$instructions = p_cached_instructions($wiki_file, false, $id);
if (is_null($instructions)) {
return '';
}
$Renderer->notoc();
$Renderer->smileys = getSmileys();
$Renderer->entities = getEntities();
$Renderer->acronyms = array();
$Renderer->interwiki = getInterwiki();
epub_update_progress("rendering {$id}, this could take some time");
// Loop through the instructions
foreach ($instructions as $instruction) {
// Execute the callback against the Renderer
call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]);
}
$result = "";
$result .= '<html xmlns="http://www.w3.org/1999/xhtml">' . "\n";
$result .= "\n<head>\n";
$result .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>' . "\n";
$result .= '<link rel="stylesheet" type="text/css" href="../Styles/style.css"/>';
epub_check_for_mathjax($result);
$result .= "\n<title>";
$result .= "</title>\n</head><body>\n";
$result .= "<div class='dokuwiki'>\n";
$info = $Renderer->info;
$data = array($mode, &$Renderer->doc);
trigger_event('RENDERER_CONTENT_POSTPROCESS', $data);
$xhtml = $Renderer->doc;
$result .= $xhtml;
$result .= "\n</div></body></html>\n";
$result = preg_replace_callback("/&(\\w+);/m", "epbub_entity_replace", $result);
$result = preg_replace("/(^[\r\n]*|[\r\n]+)[\\s\t]*[\r\n]+/m", "\n", $result);
$result = preg_replace("/^\\s+/m", "", $result);
$result = preg_replace_callback('|<p>([\\s\\n]*)(.*?<div.*?/div>.*?)([\\s\\n])*<\\/p>|im', create_function('$matches', '$result = $matches[1] . $matches[2] . $matches[3];
//echo "$result\\n";
return $result;'), $result);
ob_end_flush();
if ($user_title) {
$id = 'title.html';
} else {
$id = epub_clean_name(str_replace(':', '_', $id)) . '.html';
}
io_saveFile(epub_get_oebps() . "Text/{$id}", $result);
if ($user_title) {
epub_write_zip('Text/title.html');
$ID = $oldID;
return true;
}
$item_num = epub_write_item("Text/{$id}", "application/xhtml+xml");
epub_push_spine(array("Text/{$id}", $item_num));
epub_save_namespace();
$ID = $oldID;
return true;
}
示例14: render
function render($mode, &$renderer, $data)
{
list($ns, $num, $flags, $refine) = $data;
$first = $_REQUEST['first'];
if (!is_numeric($first)) {
$first = 0;
}
// get the blog entries for our namespace
if ($my =& plugin_load('helper', 'blog')) {
$entries = $my->getBlog($ns);
}
// use tag refinements?
if ($refine) {
if (plugin_isdisabled('tag') || !($tag =& plugin_load('helper', 'tag'))) {
msg($this->getLang('missing_tagplugin'), -1);
} else {
$entries = $tag->tagRefine($entries, $refine);
}
}
// any create form overrides?
$formpos = $this->getConf('formposition');
if (in_array('topform', $flags)) {
$formpos = 'top';
} elseif (in_array('bottomform', $flags)) {
$formpos = 'bottom';
} elseif (in_array('noform', $flags)) {
$formpos = 'none';
}
if (!$entries) {
if (auth_quickaclcheck($ns . ':*') >= AUTH_CREATE && $mode == 'xhtml') {
$renderer->info['cache'] = false;
if ($formpos != 'none') {
$renderer->doc .= $this->_newEntryForm($ns);
}
}
return true;
// nothing to display
}
// slice the needed chunk of pages
$more = count($entries) > $first + $num ? true : false;
$entries = array_slice($entries, $first, $num);
// load the include helper plugin
if (plugin_isdisabled('include') || !($include =& plugin_load('helper', 'include'))) {
msg($this->getLang('missing_includeplugin'), -1);
return false;
}
if ($mode == 'xhtml') {
// prevent caching to ensure the included pages are always fresh
$renderer->info['cache'] = false;
// show new entry form
$perm_create = auth_quickaclcheck($ns . ':*') >= AUTH_CREATE;
if ($perm_create && $formpos == 'top') {
$renderer->doc .= $this->_newEntryForm($ns);
}
// current section level
$clevel = 0;
preg_match_all('|<div class="level(\\d)">|i', $renderer->doc, $matches, PREG_SET_ORDER);
$n = count($matches) - 1;
if ($n > -1) {
$clevel = $matches[$n][1];
}
// close current section
if ($clevel) {
$renderer->doc .= '</div>' . DOKU_LF;
}
$renderer->doc .= '<div class="hfeed">' . DOKU_LF;
}
// we need our own renderer
$include_renderer =& p_get_renderer('xhtml');
$include_renderer->smileys = getSmileys();
$include_renderer->entities = getEntities();
$include_renderer->acronyms = getAcronyms();
$include_renderer->interwiki = getInterwiki();
// now include the blog entries
foreach ($entries as $entry) {
if ($mode == 'xhtml') {
if (auth_quickaclcheck($entry['id']) >= AUTH_READ) {
$renderer->doc .= $this->render_XHTML($include, $include_renderer, $entry['id'], $clevel, $flags);
}
} elseif ($mode == 'metadata') {
$renderer->meta['relation']['haspart'][$entry['id']] = true;
}
}
if ($mode == 'xhtml') {
// resume the section
$renderer->doc .= '</div>' . DOKU_LF;
if ($clevel) {
$renderer->doc .= '<div class="level' . $clevel . '">' . DOKU_LF;
}
// BEGIN MODIFIED by harukasan
if (!in_array('nofollowlink', $flags)) {
// show older / newer entries links
$renderer->doc .= $this->_browseEntriesLinks($more, $first, $num);
}
// END MODIFIED
// show new entry form
if ($perm_create && $formpos == 'bottom') {
$renderer->doc .= $this->_newEntryForm($ns);
}
}
//.........这里部分代码省略.........
示例15: _render_xhtml
/**
* Renders a list of instruction to minimal xhtml
*@author Myron Turner <turnermm02@shaw.ca>
*/
function _render_xhtml($text)
{
$mode = 'fckg';
global $Smilies;
$smiley_as_text = @$this->getConf('smiley_as_text');
if ($smiley_as_text) {
$Smilies = array('8-)' => 'aSMILEY_1', '8-O' => 'aSMILEY_2', ':-(' => 'aSMILEY_3', ':-)' => 'aSMILEY_4', '=)' => 'aSMILEY_5', ':-/' => 'aSMILEY_6', ':-\\' => 'aSMILEY_7', ':-?' => 'aSMILEY_8', ':-D' => 'aSMILEY_9', ':-P' => 'bSMILEY_10', ':-O' => 'bSMILEY_11', ':-X' => 'bSMILEY_12', ':-|' => 'bSMILEY_13', ';-)' => 'bSMILEY_14', '^_^' => 'bSMILEY_15', ':?:' => 'bSMILEY_16', ':!:' => 'bSMILEY_17', 'LOL' => 'bSMILEY_18', 'FIXME' => 'bSMILEY_19', 'DELETEME' => 'bSMILEY_20');
$s_values = array_values($Smilies);
$s_values_regex = implode('|', $s_values);
$s_keys = array_keys($Smilies);
$s_keys = array_map(create_function('$k', 'return "(" . preg_quote($k,"/") . ")";'), $s_keys);
$s_keys_regex = implode('|', $s_keys);
global $haveDokuSmilies;
$haveDokuSmilies = false;
$text = preg_replace_callback('/(' . $s_keys_regex . ')/ms', create_function('$matches', 'global $Smilies;
global $haveDokuSmilies;
$haveDokuSmilies = true;
return $Smilies[$matches[1]];'), $text);
}
// try default renderer first:
$file = DOKU_INC . "inc/parser/{$mode}.php";
if (@file_exists($file)) {
require_once $file;
$rclass = "Doku_Renderer_{$mode}";
if (!class_exists($rclass)) {
trigger_error("Unable to resolve render class {$rclass}", E_USER_WARNING);
msg("Renderer for {$mode} not valid", -1);
return null;
}
$Renderer = new $rclass();
} else {
// Maybe a plugin is available?
$Renderer = plugin_load('renderer', $mode);
if (is_null($Renderer)) {
msg("No renderer for {$mode} found", -1);
return null;
}
}
// prevents utf8 conversions of quotation marks
$text = str_replace('"', "_fckg_QUOT_", $text);
$text = preg_replace_callback('/(<code|file.*?>)(.*?)(<\\/code>)/ms', create_function('$matches', '$quot = str_replace("_fckg_QUOT_",\'"\',$matches[2]);
$quot = str_replace("\\\\ ","_fckg_NL",$quot);
return $matches[1] . $quot . $matches[3];'), $text);
global $fckgLPluginPatterns;
$fckgLPluginPatterns = array();
$instructions = p_get_instructions("=== header ===");
// loads DOKU_PLUGINS array --M.T. Dec 22 2009
$installed_plugins = $this->get_plugins();
$regexes = $installed_plugins['plugins'];
$text = preg_replace_callback('/(' . $regexes . ')/', create_function('$matches', 'global $fckgLPluginPatterns;
$retv = preg_replace("/([\\{\\}\\@\\:&~\\?\\!<>])/", "$1 ", $matches[0]);
$fckgLPluginPatterns[] = array($retv, $matches[0]);
return $retv;'), $text);
global $fckLImmutables;
$fckglImmutables = array();
foreach ($installed_plugins['xcl'] as $xcl) {
$text = preg_replace_callback('/' . $xcl . '/', create_function('$matches', 'global $fckLImmutables;
if(preg_match("#//<//font#",$matches[0])) {
return str_replace("//<//", "<", $matches[0]);
}
$index = count($fckLImmutables);
$fckLImmutables[] = $matches[0];
return "<span id=\'imm_" . "$index\' title=\'imm_" . "$index\' >" . str_replace("//<//", "<", $matches[0]) . "</span>" ;'), $text);
}
global $multi_block;
if (preg_match('/(?=MULTI_PLUGIN_OPEN)(.*?)(?<=MULTI_PLUGIN_CLOSE)/ms', $text, $matches)) {
//file_put_contents('multi_text-2.txt',$matches[1]);
$multi_block = $matches[1];
}
$instructions = p_get_instructions($text);
if (is_null($instructions)) {
return '';
}
$Renderer->notoc();
$Renderer->smileys = getSmileys();
$Renderer->entities = getEntities();
$Renderer->acronyms = array();
$Renderer->interwiki = getInterwiki();
// Loop through the instructions
foreach ($instructions as $instruction) {
// Execute the callback against the Renderer
call_user_func_array(array(&$Renderer, $instruction[0]), $instruction[1]);
}
//set info array
$info = $Renderer->info;
// Post process and return the output
$data = array($mode, &$Renderer->doc);
trigger_event('RENDERER_CONTENT_POSTPROCESS', $data);
$xhtml = $Renderer->doc;
$pos = strpos($xhtml, 'MULTI_PLUGIN_OPEN');
if ($pos !== false) {
$xhtml = preg_replace('/MULTI_PLUGIN_OPEN.*?MULTI_PLUGIN_CLOSE/ms', $multi_block, $xhtml);
$xhtml = preg_replace_callback('|MULTI_PLUGIN_OPEN.*?MULTI_PLUGIN_CLOSE|ms', create_function('$matches', '$matches[0] = str_replace("//<//", "< ",$matches[0]);
return preg_replace("/\\n/ms","<br />",$matches[0]);'), $xhtml);
$xhtml = preg_replace('/~\\s*~\\s*MULTI_PLUGIN_OPEN~\\s*~/', "~ ~ MULTI_PLUGIN_OPEN~ ~\n\n<span class='multi_p_open'>\n\n</span>", $xhtml);
$xhtml = preg_replace('/~\\s*~\\s*MULTI_PLUGIN_CLOSE~\\s*~/', "<span class='multi_p_close'>\n\n</span>\n\n~ ~ MULTI_PLUGIN_CLOSE~ ~\n", $xhtml);
//.........这里部分代码省略.........