本文整理汇总了PHP中p_set_metadata函数的典型用法代码示例。如果您正苦于以下问题:PHP p_set_metadata函数的具体用法?PHP p_set_metadata怎么用?PHP p_set_metadata使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了p_set_metadata函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: document_end
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);
}
示例2: addApproval
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, '&'));
}
示例3: document_start
/**
* 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">
';
}
示例4: render
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));
}
}
示例5: document_start
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";
}
示例6: document_start
/**
* 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');
}
示例7: after_action
/**
* 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);
}
}
}
示例8: document_start
/**
* 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');
}
示例9: document_start
/**
* 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
}
示例10: test_meta_description_with_persistent_description
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));
}
示例11: handle_action_act_preprocess
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';
}
}
}
}
示例12: test_editor_and_externaledits
/**
* 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
}
示例13: setSelfMoveMeta
/**
* 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);
}
示例14: createJiveDiscussion
/**
* 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'];
}
示例15: document_start
/**
* 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);
}