/** * get a list of namespace / page files * * @param string $folder an already converted filesystem folder of the current namespace */ function getTree($folder = ':') { global $conf; global $ID; // read tree structure from pages and media $ofolder = $folder; if ($folder == '*' || $folder == '') { $folder = ':'; } if ($folder[0] != ':') { $folder = resolve_id($folder, $ID); } $dir = strtr(cleanID($folder), ':', '/'); if (!($this->cache() && is_array($data = $this->cache()->get('explorertree_cache_' . $dir)))) { $data = array(); search($data, $conf['datadir'], 'search_index', array('ns' => getNS($ID)), $dir, $dir == '' ? 1 : count(explode('/', $dir)) + 1); $count = count($data); if ($count > 0) { for ($i = 1; $i < $count; $i++) { if ($data[$i - 1]['id'] == $data[$i]['id'] && $data[$i - 1]['type'] == $data[$i]['type']) { unset($data[$i]); $i++; // duplicate found, next $i can't be a duplicate, so skip forward one } } } if ($this->cache()) { $this->cache()->set($cache_id = 'explorertree_cache_' . $dir, $data, 60); // store the data itself (cache for one minute) } } return $data; }
function tpl_sidebar_content() { global $ID, $REV, $ACT, $conf; // save globals $saveID = $ID; $saveREV = $REV; $saveACT = $ACT; // discover file to be displayed in navigation sidebar $fileSidebar = ''; if (tpl_getConf('page')) { $fileSidebar = getSidebarFN(getNS($ID), tpl_getConf('page')); } // determine what to display if ($fileSidebar) { $ID = $fileSidebar; $REV = ''; $ACT = 'show'; # print p_wiki_xhtml($fileSidebar,'',false); tpl_content(); } else { # global $IDX; # html_index($IDX); # $ID = getNS($ID); $REV = ''; $ACT = 'index'; tpl_content(); } // restore globals $ID = $saveID; $REV = $saveREV; $ACT = $saveACT; }
function handle($match, $state, $pos, &$handler) { global $ID; $match = substr($match, 7, -2); // strip {{blog> from start and }} from end list($match, $flags) = explode('&', $match, 2); $flags = explode('&', $flags); $flags[] = 'link'; // always make the first header of a blog entry a permalink list($match, $refine) = explode(' ', $match, 2); list($ns, $num) = explode('?', $match, 2); if (!is_numeric($num)) { if (is_numeric($ns)) { $num = $ns; $ns = ''; } else { $num = 5; } } if ($ns == '') { $ns = cleanID($this->getConf('namespace')); } elseif ($ns == '*' || $ns == ':') { $ns = ''; } elseif ($ns == '.') { $ns = getNS($ID); } else { $ns = cleanID($ns); } return array($ns, $num, $flags, $refine); }
function pagefromtemplate(&$event, $param) { if (strlen(trim($_REQUEST['newpagetemplate'])) > 0) { global $conf; global $INFO; global $ID; $tpl = io_readFile(wikiFN($_REQUEST['newpagetemplate'])); if ($this->getConf('userreplace')) { $stringvars = array_map(create_function('$v', 'return explode(",",$v,2);'), explode(';', $_REQUEST['newpagevars'])); foreach ($stringvars as $value) { $tpl = str_replace(trim($value[0]), trim($value[1]), $tpl); } } if ($this->getConf('standardreplace')) { // replace placeholders $file = noNS($ID); $page = strtr($file, '_', ' '); $tpl = str_replace(array('@ID@', '@NS@', '@FILE@', '@!FILE@', '@!FILE!@', '@PAGE@', '@!PAGE@', '@!!PAGE@', '@!PAGE!@', '@USER@', '@NAME@', '@MAIL@', '@DATE@'), array($ID, getNS($ID), $file, utf8_ucfirst($file), utf8_strtoupper($file), $page, utf8_ucfirst($page), utf8_ucwords($page), utf8_strtoupper($page), $_SERVER['REMOTE_USER'], $INFO['userinfo']['name'], $INFO['userinfo']['mail'], $conf['dformat']), $tpl); // we need the callback to work around strftime's char limit $tpl = preg_replace_callback('/%./', create_function('$m', 'return strftime($m[0]);'), $tpl); } $event->result = $tpl; $event->preventDefault(); } }
/** * Searches for matching pagenames * * @author Andreas Gohr <*****@*****.**> */ function ajax_qsearch() { global $conf; global $lang; $query = cleanID($_POST['q']); if (empty($query)) { $query = cleanID($_GET['q']); } if (empty($query)) { return; } require_once DOKU_INC . 'inc/html.php'; require_once DOKU_INC . 'inc/fulltext.php'; $data = array(); $data = ft_pageLookup($query); if (!count($data)) { return; } print '<strong>' . $lang['quickhits'] . '</strong>'; print '<ul>'; foreach ($data as $id) { print '<li>'; $ns = getNS($id); if ($ns) { $name = shorten(noNS($id), ' (' . $ns . ')', 30); } else { $name = $id; } print html_wikilink(':' . $id, $name); print '</li>'; } print '</ul>'; }
function normalize($value, $hint) { global $ID; // fragment reference special case if (!empty($hint) && substr($hint, -1) == '#') { $value = $hint . $value; resolve_pageid(getNS($hint), $value, $exists); return $value; } $base = $hint ?: getNS($ID); // check for local link, and prefix full page id // (local links don't get resolved by resolve_pageid) if (preg_match('/^#.+/', $value)) { $value = $ID . $value; } // resolve page id with respect to selected base resolve_pageid($base, $value, $exists); // if the value is empty after resolving, it is a reference to the // root starting page. (We can not put the emtpy string into the // database as a normalized reference -- this will create problems) if ($value == '') { global $conf; $value = $conf['start']; } return $value; }
function tpl_sidebar($user_defined_page_name = "") { global $ID, $REV, $conf; // save globals $saveID = $ID; $saveREV = $REV; // discover file to be displayed in navigation sidebar $fileSidebar = ''; // damien $pagename = ""; if ($user_defined_page_name != "") { $pagename = $user_defined_page_name; } else { if (isset($conf['sidebar']['page'])) { $pagename = $conf['sidebar']['page']; } } if ($pagename != "") { $fileSidebar = getSidebarFN(getNS($ID), $pagename); } // determine what to display if ($fileSidebar) { $ID = $fileSidebar; $REV = ''; print p_wiki_xhtml($ID, $REV, false); } else { global $IDX; html_index($IDX); } // restore globals $ID = $saveID; $REV = $saveREV; }
/** * Handle the match */ function handle($match, $state, $pos, &$handler) { global $ID; $match = substr($match, 9, -11); // strip markup list($flags, $match) = explode('>', $match, 2); $flags = explode('&', substr($flags, 1)); $items = explode('*', $match); $pages = array(); $c = count($items); for ($i = 0; $i < $c; $i++) { if (!preg_match('/\\[\\[(.+?)\\]\\]/', $items[$i], $match)) { continue; } list($id, $title, $description) = explode('|', $match[1], 3); list($id, $section) = explode('#', $id, 2); if (!$id) { $id = $ID; } resolve_pageid(getNS($ID), $id, $exists); // page has an image title if ($title && preg_match('/\\{\\{(.+?)\\}\\}/', $title, $match)) { list($image, $title) = explode('|', $match[1], 2); list($ext, $mime) = mimetype($image); if (!substr($mime, 0, 5) == 'image') { $image = ''; } $pages[] = array('id' => $id, 'section' => cleanID($section), 'title' => trim($title), 'image' => trim($image), 'description' => trim($description), 'exists' => $exists); // text title (if any) } else { $pages[] = array('id' => $id, 'section' => cleanID($section), 'title' => trim($title), 'description' => trim($description), 'exists' => $exists); } } return array($flags, $pages); }
function handle($match, $state, $pos, &$handler) { global $ID; $options['overwrite'] = TRUE; $options['renameable'] = TRUE; $ns = getNS($ID); return array('uploadns' => hsc($ns), 'para' => $options); }
/** * Create output */ function render($mode, &$renderer, $data) { global $ID; global $conf; $ns = $data[0]; if ($ns == '') { $ns = cleanID($this->getConf('namespace')); } elseif ($ns == '*') { $ns = ''; } elseif ($ns == '.') { $ns = getNS($ID); } $pages = $this->_monthArchive($ns, $data[1], $data[2]); if (!count($pages)) { return true; } // nothing to display if ($mode == 'xhtml') { // prevent caching to ensure content is always fresh $renderer->info['cache'] = false; $renderer->doc .= '<table class="archive">'; foreach ($pages as $page) { $renderer->doc .= '<tr><td class="page">'; // page title $id = $page['id']; $title = $page['title']; if (!$title) { $title = str_replace('_', ' ', noNS($id)); } $renderer->doc .= $renderer->internallink(':' . $id, $title) . '</td>'; // author if ($this->getConf('archive_showuser')) { if ($page['user']) { $renderer->doc .= '<td class="user">' . $page['user'] . '</td>'; } else { $renderer->doc .= '<td class="user"> </td>'; } } // creation date if ($this->getConf('archive_showdate')) { $renderer->doc .= '<td class="date">' . date($conf['dformat'], $page['date']) . '</td>'; } $renderer->doc .= '</tr>'; } $renderer->doc .= '</table>'; return true; // for metadata renderer } elseif ($mode == 'metadata') { foreach ($pages as $page) { $id = $page['id']; $renderer->meta['relation']['references'][$id] = true; } return true; } return false; }
/** * The files used in this file */ public function analyze($file) { $content = $this->remove_comments($file->content()); $ns = getNS($id); $inputs = $this->find_command($ns, 'input', $content); $includes = $this->find_command($ns, 'include', $content); $graphs = $this->find_command($ns, 'includegraphics', $content, ".pdf"); $bibs = $this->find_command($ns, 'bibliography', $content, ".bib"); return array_merge($inputs, $includes, $graphs, $bibs); }
/** * Handle the match */ function handle($match, $state, $pos, &$handler) { global $ID; $match = substr($match, 9, -2); //strip {{pglist> from start and }} from end $conf = array('ns' => getNS($ID), 'depth' => 1, 'dirs' => 0, 'files' => 0, 'me' => 0, 'sibling' => 0, 'nostart' => 0, 'any' => 0, 'date' => 0, 'fsort' => 0, 'dsort' => 0); list($ns, $params) = explode(' ', $match, 2); if ($ns) { if ($ns === '*') { $conf['ns'] = cleanID($ID); } else { if ($ns[0] === '/') { $conf['ns'] = cleanID($ns); } else { $conf['ns'] = cleanID('/' . getNS($ID) . '/' . $ns); } } } if (preg_match('/\\bdirs\\b/i', $params)) { $conf['dirs'] = 1; } if (preg_match('/\\bfiles\\b/i', $params)) { $conf['files'] = 1; } if (preg_match('/\\bme\\b/i', $params)) { $conf['me'] = 1; } if (preg_match('/\\bsibling\\b/i', $params)) { $conf['sibling'] = 1; } if (preg_match('/\\bsame\\b/i', $params)) { $conf['same'] = 1; } if (preg_match('/\\bany\\b/i', $params)) { $conf['any'] = 1; } if (preg_match('/\\bnostart\\b/i', $params)) { $conf['nostart'] = 1; } if (preg_match('/\\bdate\\b/i', $params)) { $conf['date'] = 1; } if (preg_match('/\\bfsort\\b/i', $params)) { $conf['fsort'] = 1; } if (preg_match('/\\bdsort\\b/i', $params)) { $conf['dsort'] = 1; } if (preg_match('/\\b(\\d+)\\b/i', $params, $m)) { $conf['depth'] = $m[1]; } $conf['dir'] = str_replace(':', '/', $conf['ns']); // prepare data return $conf; }
/** * Search for internal wiki links in page $file */ function orph_Check_InternalLinks(&$data, $base, $file, $type, $lvl, $opts) { global $conf; define('LINK_PATTERN', '%\\[\\[([^\\]|#]*)(#[^\\]|]*)?\\|?([^\\]]*)]]%'); if (!preg_match("/.*\\.txt\$/", $file)) { return; } $currentID = pathID($file); $currentNS = getNS($currentID); if ($conf['allowdebug']) { echo sprintf("<p><b>%s</b>: %s</p>\n", $file, $currentID); } // echo " <!-- checking file: $file -->\n"; $body = @file_get_contents($conf['datadir'] . $file); // ignores entries in <nowiki>, %%, <code> and emails with @ foreach (array('/<nowiki>.*?<\\/nowiki>/', '/%%.*?%%/', '@<code[^>]*?>.*?<\\/code>@siu', '@<file[^>]*?>.*?<\\/file>@siu') as $ignored) { $body = preg_replace($ignored, '', $body); } $links = array(); preg_match_all(LINK_PATTERN, $body, $links); foreach ($links[1] as $link) { if ($conf['allowdebug']) { echo sprintf("--- Checking %s<br />\n", $link); } if (0 < strlen(ltrim($link)) and !preg_match('/^[a-zA-Z0-9\\.]+>{1}.*$/u', $link) and !preg_match('/^\\\\\\\\[\\w.:?\\-;,]+?\\\\/u', $link) and !preg_match('#^([a-z0-9\\-\\.+]+?)://#i', $link) and !preg_match('<' . PREG_PATTERN_VALID_EMAIL . '>', $link) and !preg_match('!^#.+!', $link)) { $pageExists = false; resolve_pageid($currentNS, $link, $pageExists); if ($conf['allowdebug']) { echo sprintf("---- link='%s' %s ", $link, $pageExists ? 'EXISTS' : 'MISS'); } if (strlen(ltrim($link)) > 0 and !auth_quickaclcheck($link) < AUTH_READ) { // should be visible to user //echo " <!-- adding $link -->\n"; if ($conf['allowdebug']) { echo ' A_LINK'; } $link = utf8_strtolower($link); $this->orph_handle_link($data, $link); } else { if ($conf['allowdebug']) { echo ' EMPTY_OR_FORBIDDEN'; } } } else { if ($conf['allowdebug']) { echo ' NOT_INTERNAL'; } } if ($conf['allowdebug']) { echo "<br />\n"; } } // end of foreach link }
function handle($match, $state, $pos, &$handler) { global $ID; $match = substr($match, 10, -2); // strip {{archive> from start and }} from end list($match, $flags) = explode('&', $match, 2); $flags = explode('&', $flags); list($match, $refine) = explode(' ', $match, 2); list($ns, $rest) = explode('?', $match, 2); if (!$rest) { $rest = $ns; $ns = ''; } if ($ns == '') { $ns = cleanID($this->getConf('namespace')); } elseif ($ns == '*' || $ns == ':') { $ns = ''; } elseif ($ns == '.') { $ns = getNS($ID); } else { $ns = cleanID($ns); } // daily archive if (preg_match("/\\d{4}-\\d{2}-\\d{2}/", $rest)) { list($year, $month, $day) = explode('-', $rest, 3); $start = mktime(0, 0, 0, $month, $day, $year); $end = $start + 24 * 60 * 60; // monthly archive } elseif (preg_match("/\\d{4}-\\d{2}/", $rest)) { list($year, $month) = explode('-', $rest, 2); // calculate start and end times $nextmonth = $month + 1; $year2 = $year; if ($nextmonth > 12) { $nextmonth = 1; $year2 = $year + 1; } $start = mktime(0, 0, 0, $month, 1, $year); $end = mktime(0, 0, 0, $nextmonth, 1, $year2); // a whole year } elseif (preg_match("/\\d{4}/", $rest)) { $start = mktime(0, 0, 0, 1, 1, $rest); $end = mktime(0, 0, 0, 1, 1, $rest + 1); // all entries from that namespace up to now } elseif ($rest == '*') { $start = 0; $end = time(); // unknown format } else { return false; } return array($ns, $start, $end, $flags, $refine); }
/** * Handler to prepare matched data for the rendering process * * @param string $match The text matched by the patterns * @param int $state The lexer state for the match * @param int $pos The character position of the matched text * @param Doku_Handler $handler The Doku_Handler object * @return bool|array Return an array with all data you want to use in render, false don't add an instruction */ public function handle($match, $state, $pos, Doku_Handler $handler) { global $ID; $ns = substr($match, 8, strpos($match, '|') - 8); $id = $ns . ':start'; resolve_pageid(getNS($ID), $id, $exists); $ns = getNS($id); $title = substr($match, strpos($match, '|') + 1, -2); $link = '?do=export_pdfns&book_ns=' . $ns . '&book_title=' . $title; $title = substr($title, 0, strpos($title, '&')); return array('link' => $link, 'title' => sprintf($this->getLang('export_ns'), $ns, $title), $state, $pos); }
/** * Handle the user input [required] * * @param helper_plugin_bureaucracy_field[] $fields the list of fields in the form * @param string $thanks the thank you message as defined in the form * or default one. Might be modified by the action * before returned * @param array $argv additional arguments passed to the action * @return bool|string false on error, $thanks on success */ public function run($fields, $thanks, $argv) { global $ID; // prepare replacements $this->prepareNamespacetemplateReplacements(); $this->prepareDateTimereplacements(); $this->prepareLanguagePlaceholder(); $this->prepareNoincludeReplacement(); $this->prepareFieldReplacements($fields); //handle arguments $page_to_modify = array_shift($argv); if ($page_to_modify === '_self') { # shortcut to modify the same page as the submitter $page_to_modify = $ID; } else { //resolve against page which contains the form resolve_pageid(getNS($ID), $page_to_modify, $ignored); } $template_section_id = cleanID(array_shift($argv)); if (!page_exists($page_to_modify)) { msg(sprintf($this->getLang('e_pagenotexists'), html_wikilink($page_to_modify)), -1); return false; } // check auth // // This is an important point. In order to be able to modify a page via this method ALL you need is READ access to the page // This is good for admins to be able to only allow people to modify a page via a certain method. If you want to protect the page // from people to WRITE via this method, deny access to the form page. $auth = $this->aclcheck($page_to_modify); // runas if ($auth < AUTH_READ) { msg($this->getLang('e_denied'), -1); return false; } // fetch template $template = rawWiki($page_to_modify); if (empty($template)) { msg(sprintf($this->getLang('e_template'), $page_to_modify), -1); return false; } // do the replacements $template = $this->updatePage($template, $template_section_id); if (!$template) { msg(sprintf($this->getLang('e_failedtoparse'), $page_to_modify), -1); return false; } // save page saveWikiText($page_to_modify, $template, sprintf($this->getLang('summary'), $ID)); //thanks message with redirect $link = wl($page_to_modify); return sprintf($this->getLang('pleasewait'), "<script type='text/javascript' charset='utf-8'>location.replace('{$link}')</script>", html_wikilink($page_to_modify)); }
function settings_plugin_siteexport_settings($functions) { global $ID; $functions->debug->setDebugLevel($this->getConf('debugLevel')); $functions->debug->setDebugFile($this->getConf('debugFile')); if (empty($_REQUEST['pattern'])) { $params = $_REQUEST; $this->pattern = $functions->requestParametersToCacheHash($params); } else { // Set the pattern $this->pattern = $_REQUEST['pattern']; } $this->isCLI = !$_SERVER['REMOTE_ADDR'] && 'cli' == php_sapi_name(); $this->cachetime = $this->getConf('cachetime'); if (!empty($_REQUEST['disableCache'])) { $this->cachetime = intval($_REQUEST['disableCache']) == 1 ? 0 : $this->cachetime; } // Load Variables $this->origZipFile = $this->getConf('zipfilename'); $this->ignoreNon200 = $this->getConf('ignoreNon200'); // ID $this->downloadZipFile = $functions->getSpecialExportFileName($this->origZipFile, $this->pattern); // $this->eclipseZipFile = $functions->getSpecialExportFileName(getNS($this->origZipFile) . ':' . $this->origEclipseZipFile, $this->pattern); $this->zipFile = mediaFN($this->downloadZipFile); $this->tmpDir = mediaFN(getNS($this->origZipFile)); $this->exportLinkedPages = intval($_REQUEST['exportLinkedPages']) == 1 ? true : false; $this->namespace = $functions->getNamespaceFromID($_REQUEST['ns'], $PAGE); $this->addParams = !empty($_REQUEST['addParams']); $this->useTOCFile = !empty($_REQUEST['useTocFile']); // set export Namespace - which is a virtual Root $pg = noNS($ID); if (empty($this->namespace)) { $this->namespace = $functions->getNamespaceFromID(getNS($ID), $pg); } $this->exportNamespace = !empty($_REQUEST['ens']) && preg_match("%^" . $functions->getNamespaceFromID($_REQUEST['ens'], $pg) . "%", $this->namespace) ? $functions->getNamespaceFromID($_REQUEST['ens'], $pg) : $this->namespace; $this->TOCMapWithoutTranslation = intval($_REQUEST['TOCMapWithoutTranslation']) == 1 ? true : false; // Strip params that should be forwarded $this->additionalParameters = $_REQUEST; $functions->removeWikiVariables($this->additionalParameters, true); $tmpID = $ID; $ID = $this->origZipFile; $INFO = pageinfo(); if (!$this->isCLI) { // Workaround for the cron which cannot authenticate but has access to everything. if ($INFO['perm'] < AUTH_DELETE) { list($USER, $PASS) = $functions->basic_authentication(); auth_login($USER, $PASS); } } $ID = $tmpID; }
public function xhtml() { global $ID; $ns = getNS($ID); list($files, $subprojects) = Projects_file::project_files($ns); $generated = array(); $source = array(); foreach ($files as $id => $file) { if ($file->type() == 'source') { $source[$id] = $file; } elseif ($file->type() == 'generated') { $generated[$id] = $file; } } ksort($generated); ksort($source); sort($subprojects); echo '<h1>Source files</h1>' . DOKU_LF; echo '<ul>' . DOKU_LF; echo '<li>' . create_button('source') . '</li>' . DOKU_LF; foreach ($source as $id => $file) { echo '<li>' . html_wikilink($id) . ': ' . download_button($id) . ', ' . delete_button($id) . '</li>' . DOKU_LF; } echo '</ul>' . DOKU_LF; echo '<h1>Generated files</h1>' . DOKU_LF; echo '<ul>' . DOKU_LF; echo '<li>' . create_button('generated') . '</li>' . DOKU_LF; foreach ($generated as $id => $file) { $make = make_button($id, $file->status() == PROJECTS_MADE); echo '<li>' . html_wikilink($id) . ': ' . download_button($id) . ', ' . delete_button($id) . ', ' . $make . '</li>' . DOKU_LF; } echo '</ul>' . DOKU_LF; echo '<h1>Subprojects</h1>' . DOKU_LF; echo '<ul>' . DOKU_LF; echo '<li>' . create_button($ID, 'project') . '</li>' . DOKU_LF; foreach ($subprojects as $sub) { echo '<li><a href="' . wl($sub . ':', array('do' => 'manage_files')) . '">' . noNS($sub) . '</a></li>' . DOKU_LF; } echo '</ul>' . DOKU_LF; if ($ns) { $name = getNS($ns); $id = $name . ':'; if (!$name) { $id = '/'; $name = '/ (root)'; } echo '<h1>Parent projects</h1>' . DOKU_LF; echo '<ul><li><a href="' . wl($id, array('do' => 'manage_files')) . '">' . $name . '</a></li></ul>' . DOKU_LF; } }
private function computeWantedNs($path) { global $ID; $result = ''; $wantedNS = trim($path); if ($wantedNS == '') { $wantedNS = $this->getCurrentNamespace(); } if ($this->isRelativePath($wantedNS)) { $result = getNS($ID); } $result .= ':' . $wantedNS . ':'; return $result; }
function internalmedia($src, $title = NULL, $align = NULL, $width = NULL, $height = NULL, $cache = NULL) { global $conf; global $ID; resolve_mediaid(getNS($ID), $src, $exists); $link = array(); $link['class'] = 'media'; $link['target'] = '_blank'; $link['title'] = $this->_xmlEntities($src); $link['url'] = 'media/' . str_replace(':', '/', $src); $link['name'] = $this->_media($src, $title, $align, $width, $height, $cache); //output formatted $this->doc .= $this->_formatLink($link); }
function render($format, &$renderer, $data) { if ($format != 'xhtml') { return; } global $ID; $svg_wiki_page = trim(substr($data[1], 6, -2)); //name of wiki page containing SVG image resolve_pageid(getNS($ID), $svg_wiki_page, $exists); //resolve relative IDs //detect image size for stupid browsers (like firefox) - ugly (fails if svg does not contain information about it's size) $svg_dimensions = ''; preg_match('/width="[0-9]+" height="[0-9]+"/', $data[1] . rawWiki($svg_wiki_page), $_); if (isset($_[0])) { $svg_dimensions = $_[0]; } // Check alignment $ralign = (bool) preg_match('/^\\{\\{ /', $data[1]); $lalign = (bool) preg_match('/ \\}\\}$/', $data[1]); switch (true) { case $lalign & $ralign: $align = 'center'; break; case $ralign: $align = 'right'; break; case $lalign: $align = 'left'; break; default: $align = ''; } if ($data[0] === '<svg') { $svgenc = $this->svg_base64_encode($data[1]); $renderer->doc .= $this->svg_format_embed($svgenc, 'inline-svg@' . $ID, $svg_dimensions); return true; } if ($data[0] === '{{sv' || $data[0] === '{{ s') { $svglink = exportlink($svg_wiki_page, 'svg'); $renderer->doc .= $this->svg_format_embed($svglink, 'image:' . htmlspecialchars($svg_wiki_page), $svg_dimensions, $align); $renderer->doc .= '<br /><small>' . html_wikilink($svg_wiki_page, 'svg@' . $svg_wiki_page) . '</small>'; return true; } if ($data[0] === '{{SV' || $data[0] === '{{ S') { $svgenc = $this->svg_base64_encode(rawWiki($svg_wiki_page)); $renderer->doc .= $this->svg_format_embed($svgenc, 'image:' . htmlspecialchars($svg_wiki_page), $svg_dimensions, $align); $renderer->doc .= '<br /><small>' . html_wikilink($svg_wiki_page, 'SVG@' . $svg_wiki_page) . '</small>'; return true; } }
public function createTOCFiles($data) { global $conf; // Split Tree for translation $translationHSFiles = array(); for ($i = 0; $i < count($data); $i++) { $lang = ''; if ($this->translation) { $this->translation->tns = $this->translation->setupTNS($data[$i]['id']); $lang = $this->translation->getLangPart($data[$i]['id']); } // get all the relative URLs $translationHSFiles[$lang][] = $data[$i]; } $toc = new siteexport_toc($this->functions); if ($this->translation) { $translationRoot = curNS($this->translation->tns); } $hsPrename = curNS(getNS($this->translation->tns)) . '_' . $translationRoot; $check = array(); foreach ($translationHSFiles as $lang => $data) { if (count($translationHSFiles) == 1 && $lang == $conf['lang']) { // If there is only one language and it is the system language - there is no language $lang = ''; } // Prepare Translations if (!empty($lang)) { $toc->translation =& $this->translation; $rootNode = cleanID($this->translation->tns . $lang) . ':'; } else { $toc->translation = null; $rootNode = ''; } $tsRootPath = $this->translationRootPath($translationRoot); // Create toc and map for each lang list($tocData, $mapData, $startPageID) = $toc->__getJavaHelpTOCXML($data, $tsRootPath); $this->functions->debug->message("Generating JavaHelpDocZip for language '{$lang}'", null, 2); $this->filewriter->__moveDataToZip($tocData, $tsRootPath . $lang . '/' . $this->tocName); $this->filewriter->__moveDataToZip($mapData, $tsRootPath . $lang . '/' . $this->mapName); // Create HS File // array_shift($toc->getMapID($rootNode, &$check)) $HS = $this->getHSXML($startPageID, $this->functions->getSiteTitle($rootNode), $lang, $tsRootPath); $this->filewriter->__moveDataToZip($HS, $hsPrename . '_' . $lang . '.hs'); // Default Lang if ($lang == $conf['lang']) { $this->filewriter->__moveDataToZip($HS, $hsPrename . '.hs'); } } }
public function handle_ajax_call_unknown(Doku_Event &$event, $param) { if ($event->data != 'plugin_imgpaste') { return; } global $lang; // get data global $INPUT; $data = $INPUT->post->str('data'); list($type, $data) = explode(';', $data); if (!$data) { $this->fail(400, $this->getLang('e_nodata')); } // process data encoding $type = strtolower(substr($type, 5)); // strip 'data:' prefix $data = substr($data, 7); // strip 'base64,' prefix $data = base64_decode($data); // check for supported mime type $mimetypes = array_flip(getMimeTypes()); if (!isset($mimetypes[$type])) { $this->fail(415, $lang['uploadwrong']); } // prepare file names $tempname = $this->storetemp($data); $filename = $this->getConf('filename'); $filename = str_replace(array('@NS@', '@ID@', '@USER@'), array(getNS($INPUT->post->str('id')), $INPUT->post->str('id'), $_SERVER['REMOTE_USER']), $filename); $filename = strftime($filename); $filename .= '.' . $mimetypes[$type]; $filename = cleanID($filename); // check ACLs $auth = auth_quickaclcheck($filename); if ($auth < AUTH_UPLOAD) { $this->fail(403, $lang['uploadfail']); } // do the actual saving $result = media_save(array('name' => $tempname, 'mime' => $type, 'ext' => $mimetypes[$type]), $filename, false, $auth, 'copy'); if (is_array($result)) { $this->fail(500, $result[0]); } //Still here? We had a successful upload $this->clean(); header('Content-Type: application/json'); $json = new JSON(); echo $json->encode(array('message' => $lang['uploadsucc'], 'id' => $result)); $event->preventDefault(); $event->stopPropagation(); }
protected static function absoluteID($ns, $name) { if ($name[0] == '.') { if ($name[1] == '.') { $pos = $name[2] == ':' ? 3 : 2; return absoluteID(getNS($ns), substr($name, $pos)); } $pos = $name[1] == ':' ? 2 : 1; return absoluteID($ns, substr($name, $pos)); } if ($name[0] != ':' && $ns) { return $ns . ':' . $name; } return $name; }
/** * Handler to prepare matched data for the rendering process */ function handle($match, $state, $pos, &$handler) { global $ID; if ($match == '~~BACKLINKS~~') { //check for deprecated syntax $match = $ID; } else { $match = substr($match, 12, -2); //strip {{backlinks> from start and }} from end $match = $match == '.' ? $ID : $match; if (strstr($match, ".:")) { resolve_pageid(getNS($ID), $match, $exists); } } return array($match); }
function __construct($id, $namespace_mode, $conf, $nsbpc_obj) { $this->id = cleanID($id); $this->ns = getNS(cleanID($id)); $this->namespace_mode = $namespace_mode; $this->nsbpc = $nsbpc_obj; $this->conf = $conf; $this->set_prefix(); $this->_set_texit_dir(); $this->_set_media_dir(); $this->bibfn = $this->generate_bib(); $this->get_all_files(); $this->conf['latexentities'] = false; // we generate it at compile time $this->texit_render_obj = false; }
function print_overlay(&$event, $param) { global $ID; $overlay = ''; $paths = $this->getConf('nsoverlays'); $namespace = getNS($ID); $sort_paths = $this->_natsort_ns($paths); $sort_paths = explode(',', $sort_paths); $overlays = $this->_get_overlays($sort_paths); $parent_ns = $this->_get_parent_ns($namespace); foreach ($overlays as $key => $val) { // first check if was specified an overlay for a specific namespace if ($val[1] != '') { if ($val[1] == ':') { $overlay = $overlays[$key][0]; } elseif (strpos($namespace, $val[1]) === 0) { $overlay = $overlays[$key][0]; break; } } else { if ($overlay == '') { if ('' == $val[1]) { foreach ($parent_ns as $ns) { $wikifile = wikiFN($ns . ':' . $val[0]); if (file_exists($wikifile)) { $overlay = str_replace('/', ':', $ns) . ':' . $val[0]; break 2; } } } } } } if (auth_quickaclcheck($ID) >= AUTH_READ) { $insert = p_wiki_xhtml($overlay); } if (!$insert) { return; } $close = trim($this->getLang('close')); $text = <<<TEXT <div id='overlay'><div class = "close"> <a href="javascript:jQuery('#overlay').toggle();void(0);" rel="nofollow" title="{$close}">{$close}</a> </div> {$insert}</div> TEXT; echo $text; }
function handle($match, $state, $pos, &$handler) { global $ID; $match = substr($match, 10, -2); // strip {{threads> from start and }} from end list($match, $flags) = explode('&', $match, 2); $flags = explode('&', $flags); list($ns, $refine) = explode(' ', $match, 2); if ($ns == '*' || $ns == ':') { $ns = ''; } elseif ($ns == '.') { $ns = getNS($ID); } else { $ns = cleanID($ns); } return array($ns, $flags, $refine); }
/** * Handle the match */ function handle($match, $state, $pos, Doku_Handler $handler) { global $ID; $match = substr($match, 10, -2); //strip markup from start and end $data = array(); // extract params list($ns, $params) = explode(' ', $match, 2); $ns = trim($ns); // namespace (including resolving relatives) $data['ns'] = resolve_id(getNS($ID), $ns); $data['skin'] = 'original'; // alignment $data['align'] = 'left'; if (preg_match('/\\bleft\\b/i', $params)) { $data['align'] = 'left'; $params = preg_replace('/\\bleft\\b/i', '', $params); } if (preg_match('/\\bcenter\\b/i', $params)) { $data['align'] = 'center'; $params = preg_replace('/\\bcenter\\b/i', '', $params); } if (preg_match('/\\bright\\b/i', $params)) { $data['align'] = 'right'; $params = preg_replace('/\\bright\\b/i', '', $params); } $data['shuffle'] = false; if (preg_match('/\\bshuffle\\b/i', $params)) { $data['shuffle'] = true; $params = preg_replace('/\\bshuffle\\b/i', '', $params); } $data['repeat'] = false; if (preg_match('/\\brepeat\\b/i', $params)) { $data['repeat'] = true; $params = preg_replace('/\\brepeat\\b/i', '', $params); } $data['autoplay'] = false; if (preg_match('/\\bautoplay\\b/i', $params)) { $data['autoplay'] = true; $params = preg_replace('/\\bautoplay\\b/i', '', $params); } // the rest is the skin $data['skin'] = trim($params); list($data['skin'], $data['width'], $data['height']) = $this->_skininfo($data['skin']); return $data; }
/** * Handler to prepare matched data for the rendering process. * @see DokuWiki_Syntax_Plugin::handle() */ function handle($match, $state, $pos, &$handler) { // Take the id of the source // It can be a rendering of a sidebar global $INFO; global $ID; $id = $ID; // If it's a sidebar, get the original id. if ($INFO != null) { $id = $INFO['id']; } $match = substr($match, 12, -2); //strip {{backlinks> from start and }} from end $match = $match == '.' ? $id : $match; if (strstr($match, ".:")) { resolve_pageid(getNS($id), $match, $exists); } return array($match); }