当前位置: 首页>>代码示例>>PHP>>正文


PHP p_read_metadata函数代码示例

本文整理汇总了PHP中p_read_metadata函数的典型用法代码示例。如果您正苦于以下问题:PHP p_read_metadata函数的具体用法?PHP p_read_metadata怎么用?PHP p_read_metadata使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了p_read_metadata函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addLogEntry

/**
 * 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 <andi@splitbrain.org>
 * @author Esther Brunner <wikidesign@gmail.com>
 * @author Ben Coburn <btcoburn@silicodon.net>
 */
function addLogEntry($date, $id, $type = DOKU_CHANGE_TYPE_EDIT, $summary = '', $extra = '', $flags = null)
{
    global $conf, $INFO;
    /** @var Input $INPUT */
    global $INPUT;
    // 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 ? $INPUT->server->str('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
}
开发者ID:rodrigoaustincascao,项目名称:Service-Desk-IMC,代码行数:76,代码来源:changelog.php

示例2: handle_approve

 function handle_approve(&$event, $param)
 {
     global $ID, $REV, $INFO;
     if ($event->data == 'show' && isset($_GET['approve'])) {
         if (!$this->can_approve()) {
             return;
         }
         //change last commit comment to Approved
         $meta = p_read_metadata($ID);
         $meta[current][last_change][sum] = $meta[persistent][last_change][sum] = APPROVED;
         $meta[current][last_change][user] = $meta[persistent][last_change][user] = $INFO[client];
         if (!array_key_exists($INFO[client], $meta[current][contributor])) {
             $meta[current][contributor][$INFO[client]] = $INFO[userinfo][name];
             $meta[persistent][contributor][$INFO[client]] = $INFO[userinfo][name];
         }
         p_save_metadata($ID, $meta);
         //update changelog
         //remove last line from file
         $changelog_file = metaFN($ID, '.changes');
         $changes = file($changelog_file, FILE_SKIP_EMPTY_LINES);
         $lastLogLine = array_pop($changes);
         $info = parseChangelogLine($lastLogLine);
         $info[user] = $INFO[client];
         $info[sum] = APPROVED;
         $logline = implode("\t", $info) . "\n";
         array_push($changes, $logline);
         io_saveFile($changelog_file, implode('', $changes));
         header('Location: ?id=' . $ID);
     }
 }
开发者ID:vincentkersten,项目名称:dokuwiki-plugin-approve,代码行数:30,代码来源:approve.php

示例3: _preview_before

 /**
  * Triggers before preview xhtml render,
  * allows plugins to metadata render on the preview.
  */
 public function _preview_before(&$event, $param)
 {
     global $ACT;
     global $TEXT;
     global $SUF;
     global $PRE;
     global $ID;
     global $METADATA_RENDERERS;
     if ($ACT == 'preview') {
         $triples =& plugin_load('helper', 'strata_triples');
         $triples->beginPreview();
         $text = $PRE . $TEXT . $SUF;
         $orig = p_read_metadata($ID);
         // store the original metadata in the global $METADATA_RENDERERS so p_set_metadata can use it
         $METADATA_RENDERERS[$ID] =& $orig;
         // add an extra key for the event - to tell event handlers the page whose metadata this is
         $orig['page'] = $ID;
         $evt = new Doku_Event('STRATA_PREVIEW_METADATA_RENDER', $orig);
         if ($evt->advise_before()) {
             // get instructions
             $instructions = p_get_instructions($text);
             if (is_null($instructions)) {
                 unset($METADATA_RENDERERS[$ID]);
                 return null;
                 // something went wrong with the instructions
             }
             // set up the renderer
             $renderer = new renderer_plugin_strata();
             $renderer->meta =& $orig['current'];
             $renderer->persistent =& $orig['persistent'];
             // loop through the instructions
             foreach ($instructions as $instruction) {
                 // execute the callback against the renderer
                 call_user_func_array(array(&$renderer, $instruction[0]), (array) $instruction[1]);
             }
             $evt->result = array('current' => &$renderer->meta, 'persistent' => &$renderer->persistent);
         }
         $evt->advise_after();
         // clean up
         unset($METADATA_RENDERERS[$id]);
     }
 }
开发者ID:virk,项目名称:dokuwiki-strata,代码行数:46,代码来源:action.php

示例4: p_purge_metadata

/**
 * Purges the non-persistant part of the meta data
 * used on page deletion
 *
 * @author Michael Klier <chi@chimeric.de>
 */
function p_purge_metadata($id)
{
    $meta = p_read_metadata($id);
    foreach ($meta['current'] as $key => $value) {
        if (is_array($meta[$key])) {
            $meta['current'][$key] = array();
        } else {
            $meta['current'][$key] = '';
        }
    }
    return p_save_metadata($id, $meta);
}
开发者ID:nextghost,项目名称:dokuwiki,代码行数:18,代码来源:parserutils.php

示例5: p_purge_metadata

/**
 * Purges the non-persistant part of the meta data
 * used on page deletion
 *
 * @author Michael Klier <chi@chimeric.de>
 */
function p_purge_metadata($id)
{
    $metafn = metaFN('id', '.meta');
    $meta = p_read_metadata($id);
    foreach ($meta['current'] as $key => $value) {
        if (is_array($meta[$key])) {
            $meta['current'][$key] = array();
        } else {
            $meta['current'][$key] = '';
        }
    }
    return io_saveFile(metaFN($id, '.meta'), serialize($meta));
}
开发者ID:Harvie,项目名称:dokuwiki,代码行数:19,代码来源:parserutils.php

示例6: list

            if (!$exists) {
                list($mid) = explode('#', $mid);
                //record pages without hashs
                $links[] = $mid;
            }
        }
    }
    return $links;
}
#------------------------------------------------------------------------------
$OPTS = Doku_Cli_Opts::getOptions(__FILE__, 'h', array('help'));
if ($OPTS->isError()) {
    fwrite(STDERR, $OPTS->getMessage() . "\n");
    exit(1);
}
if ($OPTS->has('h') or $OPTS->has('help')) {
    usage();
    exit(0);
}
$START_DIR = $conf['datadir'];
if ($OPTS->numArgs() == 1) {
    $START_DIR .= '/' . $OPTS->arg(0);
}
#------------------------------------------------------------------------------
foreach (dw_get_pages($START_DIR) as $WIKI_PAGE) {
    $meta = p_read_metadata($WIKI_PAGE['id'], true);
    $meta = p_render_metadata($WIKI_PAGE['id'], $meta);
    io_saveFile(metaFN($id, '.meta'), serialize($meta));
    echo $WIKI_PAGE['id'] . "\n";
}
exit(0);
开发者ID:stretchyboy,项目名称:dokuwiki,代码行数:31,代码来源:rendermeta.php

示例7: handle_indexer

    /**
     * Handles the INDEXER_PAGE_ADD event, prevents indexing of metadata from included pages that aren't public if enabled
     *
     * @param Doku_Event $event  the event object
     * @param array      $params optional parameters (unused)
     */
    public function handle_indexer(Doku_Event $event, $params) {
        global $USERINFO;

        // check if the feature is enabled at all
        if (!$this->getConf('safeindex')) return;

        // is there a user logged in at all? If not everything is fine already
        if (is_null($USERINFO) && !isset($_SERVER['REMOTE_USER'])) return;

        // get the include metadata in order to see which pages were included
        $inclmeta = p_get_metadata($event->data['page'], 'plugin_include', METADATA_RENDER_UNLIMITED);
        $all_public = true; // are all included pages public?
        // check if the current metadata indicates that non-public pages were included
        if ($inclmeta !== null && isset($inclmeta['pages'])) {
            foreach ($inclmeta['pages'] as $page) {
                if (auth_aclcheck($page['id'], '', array()) < AUTH_READ) { // is $page public?
                    $all_public = false;
                    break;
                }
            }
        }

        if (!$all_public) { // there were non-public pages included - action required!
            // backup the user information
            $userinfo_backup = $USERINFO;
            $remote_user = $_SERVER['REMOTE_USER'];
            // unset user information - temporary logoff!
            $USERINFO = null;
            unset($_SERVER['REMOTE_USER']);

            // metadata is only rendered once for a page in one request - thus we need to render manually.
            $meta = p_read_metadata($event->data['page']); // load the original metdata
            $meta = p_render_metadata($event->data['page'], $meta); // render the metadata
            p_save_metadata($event->data['page'], $meta); // save the metadata so other event handlers get the public metadata, too

            $meta = $meta['current']; // we are only interested in current metadata.

            // check if the tag plugin handler has already been called before the include plugin
            $tag_called = isset($event->data['metadata']['subject']);

            // Reset the metadata in the renderer. This removes data from all other event handlers, but we need to be on the safe side here.
            $event->data['metadata'] = array('title' => $meta['title']);

            // restore the relation references metadata
            if (isset($meta['relation']['references'])) {
                $event->data['metadata']['relation_references'] = array_keys($meta['relation']['references']);
            } else {
                $event->data['metadata']['relation_references'] = array();
            }

            // restore the tag metadata if the tag plugin handler has been called before the include plugin handler.
            if ($tag_called) {
                $tag_helper = $this->loadHelper('tag', false);
                if ($tag_helper) {
                    if (isset($meta['subject']))  {
                        $event->data['metadata']['subject'] = $tag_helper->_cleanTagList($meta['subject']);
                    } else {
                        $event->data['metadata']['subject'] = array();
                    }
                }
            }

            // restore user information
            $USERINFO = $userinfo_backup;
            $_SERVER['REMOTE_USER'] = $remote_user;
        }
    }
开发者ID:neutrinog,项目名称:Door43,代码行数:73,代码来源:action.php


注:本文中的p_read_metadata函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。