本文整理汇总了PHP中p_get_metadata函数的典型用法代码示例。如果您正苦于以下问题:PHP p_get_metadata函数的具体用法?PHP p_get_metadata怎么用?PHP p_get_metadata使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了p_get_metadata函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle_revisions
function handle_revisions(Doku_Event &$event, $param)
{
global $ID;
global $INFO;
if (!$this->hlp->isActive()) {
return;
}
$meta = p_get_metadata($ID);
$latest_rev = $meta['last_change']['date'];
$member = null;
foreach ($event->data->_content as $key => $ref) {
if (isset($ref['_elem']) && $ref['_elem'] == 'opentag' && $ref['_tag'] == 'div' && $ref['class'] == 'li') {
$member = $key;
}
if ($member && $ref['_elem'] == 'tag' && $ref['_tag'] == 'input' && $ref['name'] == 'rev2[]') {
$revision = $ref['value'];
if ($revision == 'current') {
$revision = $INFO['meta']['date']['modified'];
}
if ($this->hlp->isRevisionApproved($revision)) {
$event->data->_content[$member]['class'] = 'li approved_revision';
} else {
$event->data->_content[$member]['class'] = 'li unapproved_revision';
}
$member = null;
}
}
return true;
}
示例2: handle_ajax_call
function handle_ajax_call(&$event, $param)
{
if ($event->data == 'plugin_do') {
$id = cleanID($_REQUEST['do_page']);
if (auth_quickaclcheck($id) < AUTH_EDIT) {
echo -1;
$event->preventDefault();
$event->stopPropagation();
return false;
}
// toggle status of a single task
$hlp = plugin_load('helper', 'do');
$status = $hlp->toggleTaskStatus($id, $_REQUEST['do_md5'], $_REQUEST['do_commit']);
// rerender the page
p_get_metadata(cleanID($_REQUEST['do_page']), '', true);
header('Content-Type: text/plain; charset=utf-8');
echo $status;
$event->preventDefault();
$event->stopPropagation();
return false;
} elseif ($event->data == 'plugin_do_status') {
// read status for a bunch of tasks
require_once DOKU_INC . 'inc/JSON.php';
$JSON = new JSON();
$hlp = plugin_load('helper', 'do');
$status = $hlp->getAllPageStatuses(cleanID($_REQUEST['do_page']));
$status = $JSON->encode($status);
header('Content-Type: text/plain; charset=utf-8');
echo $status;
$event->preventDefault();
$event->stopPropagation();
return false;
}
return true;
}
示例3: getMoveMeta
/**
* 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);
/* todo migrate old move data
if(isset($all_meta['plugin_pagemove']) && !is_null($all_meta['plugin_pagemove'])) {
if(isset($all_meta[self::METAKEY])) {
$all_meta[self::METAKEY] = array_merge_recursive($all_meta['plugin_pagemove'], $all_meta[self::METAKEY]);
} else {
$all_meta[self::METAKEY] = $all_meta['plugin_pagemove'];
}
p_set_metadata($id, array(self::METAKEY => $all_meta[self::METAKEY], 'plugin_pagemove' => null), false, true);
}
*/
$meta = isset($all_meta[self::METAKEY]) ? $all_meta[self::METAKEY] : array();
if (!isset($meta['origin'])) {
$meta['origin'] = '';
}
if (!isset($meta['pages'])) {
$meta['pages'] = array();
}
if (!isset($meta['media'])) {
$meta['media'] = array();
}
return $meta;
}
示例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: test_relation_references_without_link
public function test_relation_references_without_link()
{
$text = "My page without a link.";
$id = "source";
saveWikiText($id, $text, 'Created');
self::assertEquals(null, p_get_metadata($id, 'relation references', METADATA_RENDER_UNLIMITED));
$text .= DOKU_LF . "~~META:relation references=foo~~";
saveWikiText($id, $text, 'Updated');
self::assertEquals(array('foo' => false), p_get_metadata($id, 'relation references', METADATA_RENDER_UNLIMITED));
}
示例6: beforeParserCacheUse
/**
* Handle PARSER_CACHE_USE:BEFORE event
*/
public function beforeParserCacheUse($event, $param)
{
global $ID;
$cache = $event->data;
if (isset($cache->mode) && $cache->mode == 'xhtml') {
$depends = p_get_metadata($ID, 'relation depends');
if (!empty($depends) && isset($depends['rendering'])) {
$this->addDependencies($cache, array_keys($depends['rendering']));
}
}
}
示例7: 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'];
}
示例8: _cache_prepare
function _cache_prepare(&$event, $param)
{
global $conf;
$cache =& $event->data;
if (!isset($cache->page)) {
return;
}
//if(!isset($cache->mode) || !in_array($cache->mode, $this->supportedModes)) return;
$depends = p_get_metadata($cache->page);
if (!is_array($depends)) {
return;
}
// nothing to do
$cache->depends['purge'] = true;
/*
error_log("page: ".$cache->page);
$depends = p_get_metadata($cache->page, 'plugin_driver');
if (!is_array($depends)) return; // nothing to do for us
if (!is_array($depends['pages']) ||
!is_array($depends['instructions']) ||
$depends['pages'] != $this->helper->_get_included_pages_from_meta_instructions($depends['instructions']) ||
// the include_content url parameter may change the behavior for included pages
$depends['include_content'] != isset($_REQUEST['include_content'])) {
$cache->depends['purge'] = true; // included pages changed or old metadata - request purge.
} else {
// add plugin.info.txt to depends for nicer upgrades
$cache->depends['files'][] = dirname(__FILE__) . '/plugin.info.txt';
foreach ($depends['pages'] as $page) {
if (!$page['exists']) continue;
$file = wikiFN($page['id']);
if (!in_array($file, $cache->depends['files'])) {
$cache->depends['files'][] = $file;
}
}
}
*/
/*
error_log("page: ".$cache->page);
$id = $cache->page;
$data = array('cache' => 'expire');
$render = false;
$persistent = false;
p_set_metadata($id, $data, $render, $persistent);
*/
}
示例9: _tpl_toc
function _tpl_toc($return = false)
{
global $TOC;
global $ACT;
global $ID;
global $REV;
global $INFO;
global $conf;
global $INPUT;
$toc = array();
//if(is_array($TOC))
// NOTE:
// This will happen if sidebar has headings in it, so we don't want to use
// a TOC from the global scope. I suspect this could break some plugins.
if (($ACT == 'show' || substr($ACT, 0, 6) == 'export') && !$REV && $INFO['exists']) {
// get TOC from metadata, render if neccessary
$meta = p_get_metadata($ID, false, METADATA_RENDER_USING_CACHE);
if (isset($meta['internal']['toc'])) {
$tocok = $meta['internal']['toc'];
} else {
$tocok = true;
}
$toc = $meta['description']['tableofcontents'];
if (!$tocok || !is_array($toc) || !$conf['tocminheads'] || count($toc) < $conf['tocminheads']) {
$toc = array();
}
} elseif ($ACT == 'admin') {
// try to load admin plugin TOC FIXME: duplicates code from tpl_admin
$plugin = null;
$class = $INPUT->str('page');
if (!empty($class)) {
$pluginlist = plugin_list('admin');
if (in_array($class, $pluginlist)) {
// attempt to load the plugin
/** @var $plugin DokuWiki_Admin_Plugin */
$plugin =& plugin_load('admin', $class);
}
}
if ($plugin !== null && (!$plugin->forAdminOnly() || $INFO['isadmin'])) {
$toc = $plugin->getTOC();
$TOC = $toc;
// avoid later rebuild
}
}
trigger_event('TPL_TOC_RENDER', $toc, null, false);
$html = bootstrap_html_TOC($toc);
if ($return) {
return $html;
}
echo $html;
return '';
}
示例10: debug
function debug(&$event, $param)
{
global $ID;
ptln('<h1>Publish plug-in debug</h1>');
ptln('<h1>Metadata</h1>');
ptln('<pre>');
ptln(print_r(p_get_metadata($ID), true));
ptln('</pre>');
ptln('<h1>pageinfo</h1>');
ptln('<pre>');
ptln(print_r(pageinfo(), true));
ptln('</pre>');
}
示例11: handle_dokuwiki_started
public function handle_dokuwiki_started(&$event, $param)
{
global $ID, $ACT, $REV;
if ($ACT != 'show' && $ACT != '' || $REV) {
return;
}
$page = p_get_metadata($ID, 'relation isreplacedby');
// return if no redirection data
if (empty($page)) {
return;
}
if (isset($_GET['redirect'])) {
// return if redirection is temporarily disabled,
// or we have been redirected 5 times in a row
if ($_GET['redirect'] == 'no' || $_GET['redirect'] > 4) {
return;
} elseif ($_GET['redirect'] > 0) {
$redirect = $_GET['redirect'] + 1;
} else {
$redirect = 1;
}
} else {
$redirect = 1;
}
// verify metadata currency
if (@filemtime(metaFN($ID, '.meta')) < @filemtime(wikiFN($ID))) {
return;
}
// preserve #section from $page
list($page, $section) = explode('#', $page, 2);
if (isset($section)) {
$section = '#' . $section;
} else {
$section = '';
}
// prepare link for internal redirects, keep external targets
if (!preg_match('#^https?://#i', $page)) {
$page = wl($page, array('redirect' => $redirect), TRUE, '&');
if (!headers_sent() && $this->getConf('show_note')) {
// remember to show note about being redirected from another page
session_start();
$_SESSION[DOKU_COOKIE]['redirect'] = $ID;
}
}
// redirect
header("HTTP/1.1 301 Moved Permanently");
header("Location: " . $page . $section . $_SERVER['QUERY_STRING']);
exit;
}
示例12: handle_action_act_preprocess_after
/**
* Handler for the ACTION_ACT_PREPROCESS event and AFTER advise.
*
* Sends linkback if previous action was 'save' and new one is show.
*/
function handle_action_act_preprocess_after(&$event, $params)
{
global $ID;
global $ACT;
global $conf;
// only perform linkbacks on save of a wikipage
if ($this->preact != 'save' || $event->data != 'show') {
return;
}
// if guests are not allowed to perform linkbacks, return
if (!$this->getConf('allow_guests') && !$_SERVER['REMOTE_USER']) {
return;
}
// get linkback meta file name
$file = metaFN($ID, '.linkbacks');
$data = array('send' => false, 'receive' => false, 'display' => false, 'sentpings' => array(), 'receivedpings' => array(), 'number' => 0);
if (@file_exists($file)) {
$data = unserialize(io_readFile($file, false));
}
$data['send'] = $_REQUEST['plugin__linkback_toggle'] ? true : false;
if (!$data['send']) {
return;
}
$meta = p_get_metadata($ID);
// prepare linkback info
$linkback_info = array();
$linkback_info['title'] = tpl_pagetitle($ID, true);
$linkback_info['url'] = wl($ID, '', true);
$linkback_info['blog_name'] = $conf['title'];
$linkback_info['excerpt'] = $meta['description']['abstract'];
// get links
$ilist = p_cached_instructions(wikiFN($ID), false, $ID);
if (!is_array($ilist)) {
return;
}
$pages = $this->_parse_instructionlist($ilist);
$sentpings = array();
foreach ($pages as $page) {
if (!$data['sentpings'][$page]) {
// try to ping pages not already pinged
$this->_ping_page($page, $linkback_info);
}
$sentpings[$page] = true;
}
$data['sentpings'] = $sentpings;
// save sent ping info
io_saveFile($file, serialize($data));
return true;
}
示例13: _cache_maxage
/**
* determine the max allowable age of the cache
*
* @param string $id wiki page name
*
* @return int max allowable age of the cache null means not applicable
*/
function _cache_maxage($id)
{
$hasPart = p_get_metadata($id, 'relation haspart');
if (empty($hasPart) || !is_array($hasPart)) {
return null;
}
$age = 0;
foreach ($hasPart as $file => $data) {
if ($file == "_plugin_twitter") {
//this is us, outdate the cache if older than the configured seconds
return $this->getConf('timeout');
}
}
return $age ? time() - $age : null;
}
示例14: _get_firsttag
/**
* Optionally add a CSS class for the first tag
*
* @author Michael Klier <chi@chimeric.de>
*/
function _get_firsttag($page) {
if(plugin_isdisabled('tag') || (!$taghelper =& plugin_load('helper', 'tag'))) {
return false;
}
$subject = p_get_metadata($page, 'subject');
if (is_array($subject)) {
$tag = $subject[0];
} else {
list($tag, $rest) = explode(' ', $subject, 2);
}
if($tag) {
return $tag;
} else {
return false;
}
}
示例15: _purgecache
/**
* Check for pages changes and eventually purge cache.
*
* @author Samuele Tognini <samuele@samuele.netsons.org>
*
* @param Doku_Event $event
* @param mixed $param not defined
*/
function _purgecache(&$event, $param)
{
global $ID;
global $conf;
/** @var cache_parser $cache */
$cache =& $event->data;
if (!isset($cache->page)) {
return;
}
//purge only xhtml cache
if ($cache->mode != "xhtml") {
return;
}
//Check if it is an pagequery page
if (!p_get_metadata($ID, 'pagequery')) {
return;
}
$aclcache = $this->getConf('aclcache');
if ($conf['useacl']) {
$newkey = false;
if ($aclcache == 'user') {
//Cache per user
if ($_SERVER['REMOTE_USER']) {
$newkey = $_SERVER['REMOTE_USER'];
}
} else {
if ($aclcache == 'groups') {
//Cache per groups
global $INFO;
if ($INFO['userinfo']['grps']) {
$newkey = implode('#', $INFO['userinfo']['grps']);
}
}
}
if ($newkey) {
$cache->key .= "#" . $newkey;
$cache->cache = getCacheName($cache->key, $cache->ext);
}
}
//Check if a page is more recent than purgefile.
if (@filemtime($cache->cache) < @filemtime($conf['cachedir'] . '/purgefile')) {
$event->preventDefault();
$event->stopPropagation();
$event->result = false;
}
}