function document_end() { parent::document_end(); // Prepare the TOC global $TOC, $ID; $meta = array(); // NOTOC, and no forceTOC if ($this->info['toc'] === false && !($this->info['forceTOC'] || $this->meta['forceTOC'])) { $TOC = $this->toc = array(); $meta['internal']['toc'] = false; $meta['description']['tableofcontents'] = array(); $meta['forceTOC'] = false; } else { if ($this->info['forceTOC'] || $this->meta['forceTOC'] || utf8_strlen(strip_tags($this->doc)) >= $this->getConf('documentlengthfortoc') && count($this->toc) > 1) { $TOC = $this->toc; // This is a little bit like cheating ... but this will force the TOC into the metadata $meta = array(); $meta['internal']['toc'] = true; $meta['forceTOC'] = $this->info['forceTOC'] || $this->meta['forceTOC']; $meta['description']['tableofcontents'] = $TOC; } } // allways write new metadata p_set_metadata($ID, $meta); $this->doc = preg_replace('#<p( class=".*?")?>\\s*</p>#', '', $this->doc); }
function addApproval() { global $USERINFO; global $ID; global $INFO; if (!$INFO['exists']) { msg($this->getLang('cannot approve a non-existing revision'), -1); return; } $approvalRevision = $this->helper->getRevision(); $approvals = $this->helper->getApprovals(); if (!isset($approvals[$approvalRevision])) { $approvals[$approvalRevision] = array(); } $approvals[$approvalRevision][$INFO['client']] = array($INFO['client'], $_SERVER['REMOTE_USER'], $USERINFO['mail'], time()); $success = p_set_metadata($ID, array('approval' => $approvals), true, true); if ($success) { msg($this->getLang('version approved'), 1); $data = array(); $data['rev'] = $approvalRevision; $data['id'] = $ID; $data['approver'] = $_SERVER['REMOTE_USER']; $data['approver_info'] = $USERINFO; if ($this->getConf('send_mail_on_approve') && $this->helper->isRevisionApproved($approvalRevision)) { /** @var action_plugin_publish_mail $mail */ $mail = plugin_load('action', 'publish_mail'); $mail->send_approve_mail(); } trigger_event('PLUGIN_PUBLISH_APPROVE', $data); } else { msg($this->getLang('cannot approve error'), -1); } send_redirect(wl($ID, array('rev' => $this->helper->getRevision()), true, '&')); }
/** * Initialize the rendering */ function document_start() { global $ID; global $conf; global $lang; // call the parent parent::document_start(); // store the content type headers in metadata $headers = array( 'Content-Type' => 'text/html; charset=utf-8' ); $theme = isset($_GET['theme'])?$_GET['theme']:$this->getConf('theme'); p_set_metadata($ID,array('format' => array('revealjs' => $headers) )); $this->base = DOKU_BASE.'lib/plugins/revealjs/'; $this->doc = ' <!DOCTYPE html> <html lang="'.$conf['lang'].'" dir="'.$lang['direction'].'"> <head> <meta charset="utf-8"> <title>'.tpl_pagetitle($ID, true).'</title> <meta name="description" content="A framework for easily creating beautiful presentations using HTML"> <meta name="author" content="Hakim El Hattab"> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui"> <link rel="stylesheet" href="'.$this->base.'css/reveal.css"> <link rel="stylesheet" href="'.$this->base.'css/theme/'.$theme.'.css" id="theme"> <link rel="stylesheet" href="'.$this->base.'doku-substitutes.css"> <!-- Code syntax highlighting --> <link rel="stylesheet" href="'.$this->base.'lib/css/zenburn.css"> <!-- Printing and PDF exports --> <script> var link = document.createElement( \'link\' ); link.rel = \'stylesheet\'; link.type = \'text/css\'; link.href = window.location.search.match( /print-pdf/gi ) ? \''.$this->base.'css/print/pdf.css\' : \''.$this->base.'css/print/paper.css\'; document.getElementsByTagName( \'head\' )[0].appendChild( link ); </script> <!--[if lt IE 9]> <script src='.$this->base.'"lib/js/html5shiv.js"></script> <![endif]--> </head> <body> <div class="reveal"> <!-- Any section element inside of this container is displayed as a slide --> <div class="slides"> '; }
function render($format, &$renderer, $data) { if ($this->active) { $key = 'test_during_rendering'; p_set_metadata($this->id, array($key => 'test'), false, true); // ensure that the metadata property hasn't been set previously $this->assertNotEqual($key, p_get_metadata($this->id, $key)); } }
function document_start() { global $ID; $filename = SafeFN::encode(strtr($ID, '/:', '--')) . '.ics'; $headers = array('Content-Type:' => 'text/calendar', 'Content-Disposition:' => 'attachment; filename=' . $filename); p_set_metadata($ID, array('format' => array('icalevents' => $headers))); $this->doc = "BEGIN:VCALENDAR\r\n"; $this->doc .= "PRODID: -//DokuWiki//NONSGML Plugin iCalEvents//EN" . "\r\n"; $this->doc .= "VERSION:2.0\r\n"; }
/** * Initialize the rendering */ function document_start() { global $ID; // call the parent parent::document_start(); // store the content type headers in metadata $headers = array('Content-Type' => 'text/html; charset=utf-8'); p_set_metadata($ID, array('format' => array('s5' => $headers))); $this->base = DOKU_BASE . 'lib/plugins/s5/ui/'; $this->tpl = $this->getConf('template'); }
/** * Executed after performing the action hooks * * Increases counter and purge cache */ public function after_action() { if ($this->autoinc) { global $ID; p_set_metadata($ID, array('bureaucracy' => array($this->get_key() => $this->opt['value'] + 1))); // Force rerendering by removing the instructions cache file $cache_fn = getCacheName(wikiFN($ID) . $_SERVER['HTTP_HOST'] . $_SERVER['SERVER_PORT'], '.' . 'i'); if (file_exists($cache_fn)) { unlink($cache_fn); } } }
/** * Initialize the rendering */ function document_start() { global $ID; // call the parent parent::document_start(); // store the content type headers in metadata $headers = array('Content-Type' => 'text/html; charset=utf-8'); p_set_metadata($ID, array('format' => array('s5reloaded' => $headers))); $this->base = DOKU_MEDIA . 'lib/plugins/s5reloaded/ui/'; /* $this->tpl = $this->getConf('template'); */ $this->tpl = isset($_GET['s5theme']) ? $_GET['s5theme'] : $this->getConf('template'); }
/** * Initialize the rendering */ function document_start() { global $ID; // call the parent parent::document_start(); // store the content type headers in metadata $headers = array('Content-Type' => 'text/html; charset=utf-8'); p_set_metadata($ID, array('format' => array('s5' => $headers))); $this->base = DOKU_BASE . 'lib/plugins/s5/ui/'; $this->tpl = isset($_GET['s5theme']) ? $_GET['s5theme'] : $this->getConf('template'); $this->tpl = preg_replace('/[^a-z0-9_-]+/', '', $this->tpl); // clean user provided path }
public function test_meta_description_with_persistent_description() { $text = "My page content"; $id = 'description_test'; saveWikiText($id, $text, 'Created'); self::assertEquals($text, p_get_metadata($id, 'description abstract', METADATA_RENDER_UNLIMITED)); p_set_metadata($id, array('description' => array('abstract' => 'Persistent description')), false, true); self::assertEquals('Persistent description', p_get_metadata($id, 'description abstract', METADATA_RENDER_UNLIMITED)); $text .= DOKU_LF . '~~META:description abstract=My abstract~~'; saveWikiText($id, $text, 'Added meta'); self::assertEquals('My abstract', p_get_metadata($id, 'description abstract', METADATA_RENDER_UNLIMITED)); $text .= DOKU_LF . '~~META:description foobar=bar~~'; saveWikiText($id, $text, 'Updated meta'); self::assertEquals('My abstract', p_get_metadata($id, 'description abstract', METADATA_RENDER_UNLIMITED)); self::assertEquals('bar', p_get_metadata($id, 'description foobar', METADATA_RENDER_UNLIMITED)); }
function document_start() { global $ID; $this->doc = ''; $this->toc = array(); $this->footnotes = array(); $this->store = ''; $this->nSpan = 0; $this->separator = ''; $metaheader = array(); $metaheader['Content-Type'] = 'text/plain; charset=utf-8'; //$metaheader['Content-Disposition'] = 'attachment; filename="noname.txt"'; $meta = array(); $meta['format']['text'] = $metaheader; p_set_metadata($ID, $meta); }
public function handle_action_act_preprocess(Doku_Event &$event, $param) { global $ID, $INFO, $REV, $RANGE, $TEXT, $PRE, $SUF; // check if the action was given as array key if (is_array($event->data)) { list($act) = array_keys($event->data); } else { $act = $event->data; } if ($act == 'save' && $_REQUEST['saveandedit'] && actionOK($act)) { if (act_permcheck($act) == 'save' && checkSecurityToken()) { $event->data = act_save($act); if ($event->data == 'show') { $event->data = 'edit'; $REV = ''; // now we are working on the current revision // Handle section edits if ($PRE || $SUF) { // $from and $to are 1-based indexes of the actually edited content $from = strlen($PRE) + 1; $to = $from + strlen($TEXT); $RANGE = $from . '-' . $to; } // Ensure the current text is loaded again from the file unset($GLOBALS['TEXT'], $GLOBALS['PRE'], $GLOBALS['SUF']); // Reset the date of the last modification to avoid conflict messages unset($GLOBALS['DATE']); // Reset the change check unset($_REQUEST['changecheck']); // Force rendering of the metadata in order to ensure metadata is correct p_set_metadata($ID, array(), true); $INFO = pageinfo(); // reset pageinfo to new data (e.g. if the page exists) } elseif ($event->data == 'conflict') { // DokuWiki won't accept 'conflict' as action here. // Just execute save again, the conflict will be detected again $event->data = 'save'; } } } }
/** * test editor entry and external edit */ function test_editor_and_externaledits() { global $ID, $conf; $ID = 'wiki:syntax'; $filename = $conf['datadir'] . '/wiki/syntax.txt'; $rev = filemtime($filename); $info = $this->_get_expected_pageinfo(); $info['id'] = 'wiki:syntax'; $info['namespace'] = 'wiki'; $info['filepath'] = $filename; $info['exists'] = true; $info['lastmod'] = $rev; $info['currentrev'] = $rev; $info['meta'] = p_get_metadata($ID); // need $INFO set correctly for addLogEntry() global $INFO; $INFO = $info; // add an editor for the current version of $ID addLogEntry($rev, $ID); $info['meta'] = p_get_metadata($ID); $info['editor'] = $_SERVER['REMOTE_USER']; $info['user'] = $_SERVER['REMOTE_USER']; $info['ip'] = $_SERVER['REMOTE_ADDR']; $info['sum'] = ''; // with an editor ... $this->assertEquals($info, pageinfo()); // clear the meta['last_change'] value, pageinfo should restore it p_set_metadata($ID, array('last_change' => false)); $this->assertEquals($info, pageinfo()); $this->assertEquals($info['meta']['last_change'], p_get_metadata($ID, 'last_change')); // fake an external edit, pageinfo should clear the last change from meta data // and not return any editor data $now = time() + 10; touch($filename, $now); $info['lastmod'] = $now; $info['currentrev'] = $now; $info['meta']['last_change'] = false; $info['ip'] = null; $info['user'] = null; $info['sum'] = null; $info['editor'] = null; $this->assertEquals($info, pageinfo()); $this->assertEquals($info['meta'], p_get_metadata($ID)); // check metadata has been updated correctly }
/** * Store info about the move of a page in its own meta data * * This has to be called before the move is executed * * @param string $id moved page's original (and still current) id */ public function setSelfMoveMeta($id) { $meta = $this->getMoveMeta($id); // was this page moved multiple times? keep the orignal name til rewriting occured if (isset($meta['origin']) && $meta['origin'] !== '') { return; } $meta['origin'] = $id; p_set_metadata($id, array(self::METAKEY => $meta), false, true); }
/** * Create a new Jive discussion for the current wiki page * * @return string URL to the discussion on the Jive server or NULL */ public function createJiveDiscussion() { global $ID; global $conf; if (($jive = $this->loadHelper('jive')) === NULL) { msg('Cannot load helper for jive plugin.', -1); return NULL; } if ($jive->jiveInitServer() === FALSE) { msg('Failed to contact the Jive server: ' . $jive->jiveLastErrorMsg(), -1); return NULL; } if (($placeID = $jive->getJiveGroup(NULL)) === NULL) { msg('Failed to get Jive group: ' . $jive->jiveLastErrorMsg(), -1); return NULL; } // Get the title of the current page $title = p_get_metadata(cleanID($ID), 'title', METADATA_DONT_RENDER); if ($title === NULL || $title == '') { msg('Failed to get page title from metadata', -1); return NULL; } // create the JSON request data if (($json = json_encode(array("content" => array("type" => "text/html", "text" => sprintf($this->getLang('jiveDiscussionContent'), DOKU_URL . $ID, $title)), "subject" => sprintf($this->getLang('jiveDiscussionSubject'), $title), "type" => "discussion", "tags" => array($conf['title'])))) === FALSE) { msg('Error encoding discussion creation post to JSON', -1); return NULL; } if (($data = $jive->postJiveData('/places/' . $placeID . '/contents', $json)) === FALSE) { msg('Failed to create discussion for that page: ' . $jive->jiveLastErrorMsg(), -1); return NULL; } // Get and store useful URLs in metadata of the page $info = json_decode($data, TRUE); if ($info === NULL && json_last_error() !== JSON_ERROR_NONE) { msg('Failed to decode JSON returned on create Discussion. JSON error: ' . json_last_error_msg(), -1); return NULL; } if (isset($info['error'])) { msg('Failed to create Discussion. JSON data returned:<br>' . $info, -1); return NULL; } if (!isset($info['contentID'])) { msg('Failed to get contentID for Discussion created. JSON data returned:<br>' . $info, -1); return NULL; } $meta = array('relation' => array('jive_plugin' => array('discussion_contentID' => $info['contentID'], 'discussion_html' => $info['resources']['html']['ref']))); if (p_set_metadata(cleanID($ID), $meta) === FALSE) { msg('Failed to store metadata. Warning: multiple discussions on the same page maybe created.', -1); return NULL; } return $info['resources']['html']['ref']; }
/** * Initialize the rendering */ function document_start() { global $ID; // Reset TOC. $this->toc = array(); // First, get export mode. $warning = ''; $this->mode = $this->config->load($warning); //$this->config->setParam ($, $this->getConf('format')); //FIXME: output warning to document, like: /* // template chosen but not found : warn the user and use the default template $warning = '<text:p text:style-name="'.$this->styleset->getStyleName('body').'"><text:span text:style-name="'.$this->styleset->getStyleName('strong').'">' .$this->_xmlEntities( sprintf($this->getLang('tpl_not_found'),$this->config ['odt_template'],$this->getConf("tpl_dir")) ) .'</text:span></text:p>'.$this->doc;*/ // Load and import CSS files, setup Units $this->load_css(); $this->setupUnits(); switch ($this->mode) { case 'ODT template': // Document based on ODT template. $this->docHandler = new ODTTemplateDH(); $this->docHandler->setTemplate($this->config->getParam('odt_template')); $this->docHandler->setDirectory($this->config->getParam('tpl_dir')); break; default: // Document from scratch. $this->docHandler = new scratchDH(); break; } // Setup page format. $this->page = new pageFormat(); $this->setPageFormat($this->config->getParam('format'), $this->config->getParam('orientation'), $this->config->getParam('margin_top'), $this->config->getParam('margin_right'), $this->config->getParam('margin_bottom'), $this->config->getParam('margin_left')); //$this->page->setFormat('A4', 'portrait'); // Load Styleset. $this->styleset = new ODTDefaultStyles(); $this->styleset->import(); $this->autostyles = $this->styleset->getAutoStyles($this->page); $this->styles = $this->styleset->getStyles(); // Set title in meta info. $this->meta->setTitle($ID); //FIXME article title != book title SOLUTION: overwrite at the end for book // If older or equal to 2007-06-26, we need to disable caching $dw_version = preg_replace('/[^\\d]/', '', getversion()); //FIXME DEPRECATED if (version_compare($dw_version, "20070626", "<=")) { $this->info["cache"] = false; } //$headers = array('Content-Type'=>'text/plain'); p_set_metadata($ID,array('format' => array('odt' => $headers) )); return ; // DEBUG // send the content type header, new method after 2007-06-26 (handles caching) $output_filename = str_replace(':', '-', $ID) . ".odt"; if (version_compare($dw_version, "20070626")) { // store the content type headers in metadata $headers = array('Content-Type' => 'application/vnd.oasis.opendocument.text', 'Content-Disposition' => 'attachment; filename="' . $output_filename . '";'); p_set_metadata($ID, array('format' => array('odt_page' => $headers))); } else { // older method FIXME DEPRECATED header('Content-Type: application/vnd.oasis.opendocument.text'); header('Content-Disposition: attachment; filename="' . $output_filename . '";'); } $this->set_page_bookmark($ID); }
function __destruct() { global $ID; p_set_metadata($ID, array('schulzevote' => array('prefer' => $this->prefer, 'candys' => $this->candys, 'votees' => $this->votees))); }
function checkApprovalFormat($meta, $id) { if (isset($meta['approval_version']) && $meta['approval_version'] >= 2) { return; } if (!$this->hasApprovals($meta)) { return; } $approvals = $meta['approval']; foreach (array_keys($approvals) as $approvedId) { $keys = array_keys($approvals[$approvedId]); if (is_array($approvals[$approvedId][$keys[0]])) { continue; // current format } $newEntry = $approvals[$approvedId]; if (count($newEntry) !== 3) { //continue; // some messed up format... } $newEntry[] = intval($approvedId); // revision is the time of page edit $approvals[$approvedId] = array(); $approvals[$approvedId][$newEntry[0]] = $newEntry; } p_set_metadata($id, array('approval' => $approvals), true, true); p_set_metadata($id, array('approval_version' => 2), true, true); }
function document_start() { if (!defined('RECURSIVE_MELLEL')) { define('RECURSIVE_MELLEL', TRUE); if (!defined('DEBUG')) { define('DEBUG', TRUE); } set_time_limit(60 * 5); if (isset($_REQUEST['list'])) { $dirs = glob('/var/www/kolchose.org/inge/wiki/data/pages/*'); echo '<h1>No files</h1>'; foreach ($dirs as $dir) { if (is_file($dir)) { $new_dir = $dir; // $new_dir = str_replace('/var/www/kolchose.org/inge/wiki/data/pages/', '', $new_dir); // $new_dir = str_replace('.txt', '', $new_dir); $new_dirs[] = $new_dir; } else { echo $dir . '<br />'; } } unset($dirs); echo '<h1>Formatation ok?</h1>'; // $test_file = $new_dirs[1]; // // echo $test_file.'<br />'; #var_dump( #self::render(file_get_contents($test_file), 'mellelexport'); #); $i = 0; foreach ($new_dirs as $file) { echo $file . '<br />'; self::render(file_get_contents($file), 'mellelexport'); ob_flush(); $i++; if ($i > 50) { exit; } } exit; } } plugin_disable('highlight'); if (in_array('highlight', plugin_list())) { die('ERROR: highlight loaded 1'); } global $ID; parent::document_start(); // If older or equal to 2007-06-26, we need to disable caching $dw_version = preg_replace('/[^\\d]/', '', getversion()); if (version_compare($dw_version, "20070626", "<=")) { $this->info["cache"] = false; } $contentType = class_exists('ZipArchive') ? 'application/zip' : 'text/xml'; $contentFileName = class_exists('ZipArchive') ? noNS($ID) . '.mellel' : 'main.xml'; // TODO configuration if (class_exists('ZipArchive') and true) { $contentFileName = date('Y-m-d_') . $contentFileName; } // send the content type header, new method after 2007-06-26 (handles caching) if (!DEBUG) { if (version_compare($dw_version, "20070626")) { // store the content type headers in metadata $headers = array('Content-Type' => $contentType, 'Content-Disposition' => 'attachment; filename="' . $contentFileName . '";'); p_set_metadata($ID, array('format' => array('mellelexport' => $headers))); } else { // older method header('Content-Type: ' . $contentType); header('Content-Disposition: attachment; filename="' . $contentFileName . '";'); } } else { header('Content-Type: text/html; charset=utf-8'); echo '<!DOCTYPE html><html><head><meta charset="utf-8"></head><body>'; #<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> echo '<table>'; echo '<tr><th></th><th>Tag<br />(Wiki)</th><th></th><th>Type</th><th></th><th>Args</th><th>Output<br />(Mellel)</th></tr>'; } }
/** * Initialize the rendering */ function document_start() { global $ID; // Reset TOC. $this->toc = array(); // First, get export mode. $warning = ''; $this->mode = $this->config->load($warning); // Load and import CSS files, setup Units $this->load_css(); $this->setupUnits(); switch ($this->mode) { case 'ODT template': // Document based on ODT template. $this->docHandler = new ODTTemplateDH(); $this->docHandler->setTemplate($this->config->getParam('odt_template')); $this->docHandler->setDirectory($this->config->getParam('tpl_dir')); break; case 'CSS template': // Document based on DokuWiki CSS template. $this->docHandler = new CSSTemplateDH(); $media_sel = $this->config->getParam('media_sel'); $template = $this->config->getParam('odt_template'); $directory = $this->config->getParam('tpl_dir'); $template_path = $this->config->getParam('mediadir') . '/' . $directory . "/" . $template; $this->docHandler->import($template_path, $media_sel, $this->config->getParam('mediadir')); break; default: // Document from scratch. $this->docHandler = new scratchDH(); break; } // Setup page format. // Set the page format of the current page for calculation ($this->page) // Change the standard page layout style $this->page = new pageFormat(); $this->page->setFormat($this->config->getParam('format'), $this->config->getParam('orientation'), $this->config->getParam('margin_top'), $this->config->getParam('margin_right'), $this->config->getParam('margin_bottom'), $this->config->getParam('margin_left')); $first_page = $this->docHandler->getStyle($this->docHandler->getStyleName('first page')); if ($first_page != NULL) { $first_page->setProperty('width', $this->page->getWidth() . 'cm'); $first_page->setProperty('height', $this->page->getHeight() . 'cm'); $first_page->setProperty('margin-top', $this->page->getMarginTop() . 'cm'); $first_page->setProperty('margin-right', $this->page->getMarginRight() . 'cm'); $first_page->setProperty('margin-bottom', $this->page->getMarginBottom() . 'cm'); $first_page->setProperty('margin-left', $this->page->getMarginLeft() . 'cm'); } // Set title in meta info. $this->meta->setTitle($ID); //FIXME article title != book title SOLUTION: overwrite at the end for book // If older or equal to 2007-06-26, we need to disable caching $dw_version = preg_replace('/[^\\d]/', '', getversion()); //FIXME DEPRECATED if (version_compare($dw_version, "20070626", "<=")) { $this->info["cache"] = false; } //$headers = array('Content-Type'=>'text/plain'); p_set_metadata($ID,array('format' => array('odt' => $headers) )); return ; // DEBUG // send the content type header, new method after 2007-06-26 (handles caching) $output_filename = str_replace(':', '-', $ID) . ".odt"; if (version_compare($dw_version, "20070626")) { // store the content type headers in metadata $headers = array('Content-Type' => 'application/vnd.oasis.opendocument.text', 'Content-Disposition' => 'attachment; filename="' . $output_filename . '";'); p_set_metadata($ID, array('format' => array('odt_page' => $headers))); } else { // older method FIXME DEPRECATED header('Content-Type: application/vnd.oasis.opendocument.text'); header('Content-Disposition: attachment; filename="' . $output_filename . '";'); } $this->set_page_bookmark($ID); }
/** * This function loads and returns the persistent metadata for the move plugin. If there is metadata for the * pagemove plugin (not the old one but the version that immediately preceeded the move plugin) it will be migrated. * * @param string $id The id of the page the metadata shall be loaded for * @return array|null The metadata of the page */ public function getMoveMeta($id) { $all_meta = p_get_metadata($id, '', METADATA_DONT_RENDER); // migrate old metadata from the pagemove plugin if (isset($all_meta['plugin_pagemove']) && !is_null($all_meta['plugin_pagemove'])) { if (isset($all_meta['plugin_move'])) { $all_meta['plugin_move'] = array_merge_recursive($all_meta['plugin_pagemove'], $all_meta['plugin_move']); } else { $all_meta['plugin_move'] = $all_meta['plugin_pagemove']; } p_set_metadata($id, array('plugin_move' => $all_meta['plugin_move'], 'plugin_pagemove' => null), false, true); } return isset($all_meta['plugin_move']) ? $all_meta['plugin_move'] : null; }
/** * Save tags */ function save() { //FIXME $sqlite undefined $query = 'BEGIN TRANSACTION'; if (!$this->sqlitehelper->query($query)) { $sqlite->query('ROLLBACK TRANSACTION'); return; } $query = 'DELETE FROM tags WHERE pid = ?'; if (!$this->sqlitehelper->query($query, $this->pid)) { $sqlite->query('ROLLBACK TRANSACTION'); return; } foreach ($this->tags as $tag) { $query = 'INSERT INTO tags (pid, tag) VALUES (?, ?)'; if (!$this->sqlitehelper->query($query, $this->pid, $tag)) { $sqlite->query('ROLLBACK TRANSACTION'); return; } } $query = 'END TRANSACTION'; if (!$this->sqlitehelper->query($query)) { $sqlite->query('ROLLBACK TRANSACTION'); return; } global $ID; // FIXME This should probably happen in metadata rendering p_set_metadata($ID, array('subject' => $this->tags), false, true); }
/** * Modify the data for the redirect when there is a redirect_id set */ function handle_redirect(Doku_Event &$event, $param) { if (array_key_exists('redirect_id', $_REQUEST)) { // Render metadata when this is an older DokuWiki version where // metadata is not automatically re-rendered as the page has probably // been changed but is not directly displayed $versionData = getVersionData(); if ($versionData['date'] < '2010-11-23') { p_set_metadata($event->data['id'], array(), true); } $event->data['id'] = cleanID($_REQUEST['redirect_id']); $event->data['title'] = ''; } }
function useCache($depends = array()) { $use = parent::useCache($depends); // meta data needs to be kept in step with the cache if (!$use && isset($this->page)) { p_set_metadata($this->page, array(), true); } return $use; }
/** * Initialize the rendering */ function document_start() { global $ID; // If older or equal to 2007-06-26, we need to disable caching $dw_version = preg_replace('/[^\\d]/', '', getversion()); if (version_compare($dw_version, "20070626", "<=")) { $this->info["cache"] = false; } // prepare the zipper $this->ZIP = new ZipLib(); // prepare meta data $this->meta = array('meta:generator' => 'DokuWiki ' . getversion(), 'meta:initial-creator' => 'Generated', 'meta:creation-date' => date('Y-m-d\\TH::i:s', null), 'dc:creator' => 'Generated', 'dc:date' => date('Y-m-d\\TH::i:s', null), 'dc:language' => 'en-US', 'meta:editing-cycles' => '1', 'meta:editing-duration' => 'PT0S'); //$headers = array('Content-Type'=>'text/plain'); p_set_metadata($ID,array('format' => array('odt' => $headers) )); return ; // DEBUG // send the content type header, new method after 2007-06-26 (handles caching) $output_filename = str_replace(':', '-', $ID) . ".odt"; if (version_compare($dw_version, "20070626")) { // store the content type headers in metadata $headers = array('Content-Type' => 'application/vnd.oasis.opendocument.text', 'Content-Disposition' => 'attachment; filename="' . $output_filename . '";'); p_set_metadata($ID, array('format' => array('odt' => $headers))); } else { // older method header('Content-Type: application/vnd.oasis.opendocument.text'); header('Content-Disposition: attachment; filename="' . $output_filename . '";'); } }
/** * Return info about the current document as associative * array. * * @author Andreas Gohr <*****@*****.**> */ function pageinfo() { global $ID; global $REV; global $RANGE; global $USERINFO; global $lang; // include ID & REV not redundant, as some parts of DokuWiki may temporarily change $ID, e.g. p_wiki_xhtml // FIXME ... perhaps it would be better to ensure the temporary changes weren't necessary $info['id'] = $ID; $info['rev'] = $REV; // set info about manager/admin status. $info['isadmin'] = false; $info['ismanager'] = false; if (isset($_SERVER['REMOTE_USER'])) { $info['userinfo'] = $USERINFO; $info['perm'] = auth_quickaclcheck($ID); $info['subscribed'] = get_info_subscribed(); $info['client'] = $_SERVER['REMOTE_USER']; if ($info['perm'] == AUTH_ADMIN) { $info['isadmin'] = true; $info['ismanager'] = true; } elseif (auth_ismanager()) { $info['ismanager'] = true; } // if some outside auth were used only REMOTE_USER is set if (!$info['userinfo']['name']) { $info['userinfo']['name'] = $_SERVER['REMOTE_USER']; } } else { $info['perm'] = auth_aclcheck($ID, '', null); $info['subscribed'] = false; $info['client'] = clientIP(true); } $info['namespace'] = getNS($ID); $info['locked'] = checklock($ID); $info['filepath'] = fullpath(wikiFN($ID)); $info['exists'] = @file_exists($info['filepath']); if ($REV) { //check if current revision was meant if ($info['exists'] && @filemtime($info['filepath']) == $REV) { $REV = ''; } elseif ($RANGE) { //section editing does not work with old revisions! $REV = ''; $RANGE = ''; msg($lang['nosecedit'], 0); } else { //really use old revision $info['filepath'] = fullpath(wikiFN($ID, $REV)); $info['exists'] = @file_exists($info['filepath']); } } $info['rev'] = $REV; if ($info['exists']) { $info['writable'] = is_writable($info['filepath']) && $info['perm'] >= AUTH_EDIT; } else { $info['writable'] = $info['perm'] >= AUTH_CREATE; } $info['editable'] = $info['writable'] && empty($info['locked']); $info['lastmod'] = @filemtime($info['filepath']); //load page meta data $info['meta'] = p_get_metadata($ID); //who's the editor if ($REV) { $revinfo = getRevisionInfo($ID, $REV, 1024); } else { if (is_array($info['meta']['last_change'])) { $revinfo = $info['meta']['last_change']; } else { $revinfo = getRevisionInfo($ID, $info['lastmod'], 1024); // cache most recent changelog line in metadata if missing and still valid if ($revinfo !== false) { $info['meta']['last_change'] = $revinfo; p_set_metadata($ID, array('last_change' => $revinfo)); } } } //and check for an external edit if ($revinfo !== false && $revinfo['date'] != $info['lastmod']) { // cached changelog line no longer valid $revinfo = false; $info['meta']['last_change'] = $revinfo; p_set_metadata($ID, array('last_change' => $revinfo)); } $info['ip'] = $revinfo['ip']; $info['user'] = $revinfo['user']; $info['sum'] = $revinfo['sum']; // See also $INFO['meta']['last_change'] which is the most recent log line for page $ID. // Use $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT in place of $info['minor']. if ($revinfo['user']) { $info['editor'] = $revinfo['user']; } else { $info['editor'] = $revinfo['ip']; } // draft $draft = getCacheName($info['client'] . $ID, '.draft'); if (@file_exists($draft)) { if (@filemtime($draft) < @filemtime(wikiFN($ID))) { // remove stale draft @unlink($draft); } else { $info['draft'] = $draft; } } // mobile detection $info['ismobile'] = clientismobile(); return $info; }
/** * Return info about the current document as associative * array. * * @author Andreas Gohr <*****@*****.**> * * @return array with info about current document */ function pageinfo() { global $ID; global $REV; global $RANGE; global $lang; /* @var Input $INPUT */ global $INPUT; $info = basicinfo($ID); // include ID & REV not redundant, as some parts of DokuWiki may temporarily change $ID, e.g. p_wiki_xhtml // FIXME ... perhaps it would be better to ensure the temporary changes weren't necessary $info['id'] = $ID; $info['rev'] = $REV; if ($INPUT->server->has('REMOTE_USER')) { $sub = new Subscription(); $info['subscribed'] = $sub->user_subscription(); } else { $info['subscribed'] = false; } $info['locked'] = checklock($ID); $info['filepath'] = fullpath(wikiFN($ID)); $info['exists'] = file_exists($info['filepath']); $info['currentrev'] = @filemtime($info['filepath']); if ($REV) { //check if current revision was meant if ($info['exists'] && $info['currentrev'] == $REV) { $REV = ''; } elseif ($RANGE) { //section editing does not work with old revisions! $REV = ''; $RANGE = ''; msg($lang['nosecedit'], 0); } else { //really use old revision $info['filepath'] = fullpath(wikiFN($ID, $REV)); $info['exists'] = file_exists($info['filepath']); } } $info['rev'] = $REV; if ($info['exists']) { $info['writable'] = is_writable($info['filepath']) && $info['perm'] >= AUTH_EDIT; } else { $info['writable'] = $info['perm'] >= AUTH_CREATE; } $info['editable'] = $info['writable'] && empty($info['locked']); $info['lastmod'] = @filemtime($info['filepath']); //load page meta data $info['meta'] = p_get_metadata($ID); //who's the editor $pagelog = new PageChangeLog($ID, 1024); if ($REV) { $revinfo = $pagelog->getRevisionInfo($REV); } else { if (!empty($info['meta']['last_change']) && is_array($info['meta']['last_change'])) { $revinfo = $info['meta']['last_change']; } else { $revinfo = $pagelog->getRevisionInfo($info['lastmod']); // cache most recent changelog line in metadata if missing and still valid if ($revinfo !== false) { $info['meta']['last_change'] = $revinfo; p_set_metadata($ID, array('last_change' => $revinfo)); } } } //and check for an external edit if ($revinfo !== false && $revinfo['date'] != $info['lastmod']) { // cached changelog line no longer valid $revinfo = false; $info['meta']['last_change'] = $revinfo; p_set_metadata($ID, array('last_change' => $revinfo)); } $info['ip'] = $revinfo['ip']; $info['user'] = $revinfo['user']; $info['sum'] = $revinfo['sum']; // See also $INFO['meta']['last_change'] which is the most recent log line for page $ID. // Use $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT in place of $info['minor']. if ($revinfo['user']) { $info['editor'] = $revinfo['user']; } else { $info['editor'] = $revinfo['ip']; } // draft $draft = getCacheName($info['client'] . $ID, '.draft'); if (file_exists($draft)) { if (@filemtime($draft) < @filemtime(wikiFN($ID))) { // remove stale draft @unlink($draft); } else { $info['draft'] = $draft; } } return $info; }
/** * Create output */ function render($format, &$renderer, $data) { global $ID, $REV; if (!$data) { // Export button if ($format != 'xhtml') { return false; } $renderer->doc .= '<a href="' . exportlink($ID, 'odt', $REV != '' ? 'rev=' . $REV : '') . '" title="' . $this->getLang('view') . '">'; $renderer->doc .= '<img src="' . DOKU_BASE . 'lib/plugins/odt/odt.png" align="right" alt="' . $this->getLang('view') . '" width="48" height="48" />'; $renderer->doc .= '</a>'; return true; } else { // Extended info list($info_type, $info_value) = $data; if ($info_type == "template") { // Template-based export $renderer->template = $info_value; p_set_metadata($ID, array("relation" => array("odt" => array("template" => $info_value)))); } } return false; }
/** * Add's an entry to the changelog and saves the metadata for the page * * @param int $date Timestamp of the change * @param String $id Name of the affected page * @param String $type Type of the change see DOKU_CHANGE_TYPE_* * @param String $summary Summary of the change * @param mixed $extra In case of a revert the revision (timestmp) of the reverted page * @param array $flags Additional flags in a key value array. * Availible flags: * - ExternalEdit - mark as an external edit. * * @author Andreas Gohr <*****@*****.**> * @author Esther Brunner <*****@*****.**> * @author Ben Coburn <*****@*****.**> */ function addLogEntry($date, $id, $type = DOKU_CHANGE_TYPE_EDIT, $summary = '', $extra = '', $flags = null) { global $conf, $INFO; // check for special flags as keys if (!is_array($flags)) { $flags = array(); } $flagExternalEdit = isset($flags['ExternalEdit']); $id = cleanid($id); $file = wikiFN($id); $created = @filectime($file); $minor = $type === DOKU_CHANGE_TYPE_MINOR_EDIT; $wasRemoved = $type === DOKU_CHANGE_TYPE_DELETE; if (!$date) { $date = time(); } //use current time if none supplied $remote = !$flagExternalEdit ? clientIP(true) : '127.0.0.1'; $user = !$flagExternalEdit ? $_SERVER['REMOTE_USER'] : ''; $strip = array("\t", "\n"); $logline = array('date' => $date, 'ip' => $remote, 'type' => str_replace($strip, '', $type), 'id' => $id, 'user' => $user, 'sum' => utf8_substr(str_replace($strip, '', $summary), 0, 255), 'extra' => str_replace($strip, '', $extra)); // update metadata if (!$wasRemoved) { $oldmeta = p_read_metadata($id); $meta = array(); if (!$INFO['exists'] && empty($oldmeta['persistent']['date']['created'])) { // newly created $meta['date']['created'] = $created; if ($user) { $meta['creator'] = $INFO['userinfo']['name']; $meta['user'] = $user; } } elseif (!$INFO['exists'] && !empty($oldmeta['persistent']['date']['created'])) { // re-created / restored $meta['date']['created'] = $oldmeta['persistent']['date']['created']; $meta['date']['modified'] = $created; // use the files ctime here $meta['creator'] = $oldmeta['persistent']['creator']; if ($user) { $meta['contributor'][$user] = $INFO['userinfo']['name']; } } elseif (!$minor) { // non-minor modification $meta['date']['modified'] = $date; if ($user) { $meta['contributor'][$user] = $INFO['userinfo']['name']; } } $meta['last_change'] = $logline; p_set_metadata($id, $meta); } // add changelog lines $logline = implode("\t", $logline) . "\n"; io_saveFile(metaFN($id, '.changes'), $logline, true); //page changelog io_saveFile($conf['changelog'], $logline, true); //global changelog cache }
/** * Initialize the rendering */ function document_start() { global $ID; // Reset TOC. $this->toc = array(); // First, get export mode. $warning = ''; $this->mode = $this->determineMode($warning); switch ($this->mode) { case 'ODT template': // Document based on ODT template. $this->docHandler = new ODTTemplateDH(); $this->docHandler->setTemplate($this->template); $this->docHandler->setDirectory($this->getConf("tpl_dir")); break; default: // Document from scratch. $this->docHandler = new scratchDH(); break; } // Setup page format. $this->page = new pageFormat(); $this->page->setFormat('A4', 'portrait'); // Load Styleset. $this->styleset = new ODTDefaultStyles(); $this->styleset->import(); $this->autostyles = $this->styleset->getAutoStyles($this->page); $this->styles = $this->styleset->getStyles(); // Set title in meta info. $this->meta->setTitle($ID); //FIXME article title != book title SOLUTION: overwrite at the end for book // If older or equal to 2007-06-26, we need to disable caching $dw_version = preg_replace('/[^\\d]/', '', getversion()); //FIXME DEPRECATED if (version_compare($dw_version, "20070626", "<=")) { $this->info["cache"] = false; } //$headers = array('Content-Type'=>'text/plain'); p_set_metadata($ID,array('format' => array('odt' => $headers) )); return ; // DEBUG // send the content type header, new method after 2007-06-26 (handles caching) $output_filename = str_replace(':', '-', $ID) . ".odt"; if (version_compare($dw_version, "20070626")) { // store the content type headers in metadata $headers = array('Content-Type' => 'application/vnd.oasis.opendocument.text', 'Content-Disposition' => 'attachment; filename="' . $output_filename . '";'); p_set_metadata($ID, array('format' => array('odt_page' => $headers))); } else { // older method FIXME DEPRECATED header('Content-Type: application/vnd.oasis.opendocument.text'); header('Content-Disposition: attachment; filename="' . $output_filename . '";'); } $this->set_page_bookmark($ID); }