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


PHP mediaMetaFN函数代码示例

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


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

示例1: _getOriginalFileName

 /**
  * Returns original filename if exists
  */
 function _getOriginalFileName($id)
 {
     $metaFilePath = mediaMetaFN($id, '.filename');
     $meta = unserialize(io_readFile($metaFilePath, false));
     if (empty($meta['filename'])) {
         // check old meta file (for backward compatibility)
         $filename = parent::_getOriginalFileName($id);
         // move old meta file to media_meta directory
         if ($filename !== false) {
             $oldMetaFilePath = metaFN($id, '.filename');
             io_rename($oldMetaFilePath, $metaFilePath);
         }
         return $filename;
     } else {
         return $this->common->_sanitizeFileName($meta['filename']);
     }
 }
开发者ID:kazmiya,项目名称:dokuwiki-plugin-preservefilenames,代码行数:20,代码来源:action_angua.php

示例2: getRevisions

/**
 * Return a list of page revisions numbers
 * Does not guarantee that the revision exists in the attic,
 * only that a line with the date exists in the changelog.
 * By default the current revision is skipped.
 *
 * id:    the page of interest
 * first: skip the first n changelog lines
 * num:   number of revisions to return
 *
 * The current revision is automatically skipped when the page exists.
 * See $INFO['meta']['last_change'] for the current revision.
 *
 * For efficiency, the log lines are parsed and cached for later
 * calls to getRevisionInfo. Large changelog files are read
 * backwards in chunks until the requested number of changelog
 * lines are recieved.
 *
 * @author Ben Coburn <btcoburn@silicodon.net>
 * @author Kate Arzamastseva <pshns@ukr.net>
 */
function getRevisions($id, $first, $num, $chunk_size = 8192, $media = false)
{
    global $cache_revinfo;
    $cache =& $cache_revinfo;
    if (!isset($cache[$id])) {
        $cache[$id] = array();
    }
    $revs = array();
    $lines = array();
    $count = 0;
    if ($media) {
        $file = mediaMetaFN($id, '.changes');
    } else {
        $file = metaFN($id, '.changes');
    }
    $num = max($num, 0);
    $chunk_size = max($chunk_size, 0);
    if ($first < 0) {
        $first = 0;
    } else {
        if (!$media && @file_exists(wikiFN($id)) || $media && @file_exists(mediaFN($id))) {
            // skip current revision if the page exists
            $first = max($first + 1, 0);
        }
    }
    if (!@file_exists($file)) {
        return $revs;
    }
    if (filesize($file) < $chunk_size || $chunk_size == 0) {
        // read whole file
        $lines = file($file);
        if ($lines === false) {
            return $revs;
        }
    } else {
        // read chunks backwards
        $fp = fopen($file, 'rb');
        // "file pointer"
        if ($fp === false) {
            return $revs;
        }
        fseek($fp, 0, SEEK_END);
        $tail = ftell($fp);
        // chunk backwards
        $finger = max($tail - $chunk_size, 0);
        while ($count < $num + $first) {
            fseek($fp, $finger);
            $nl = $finger;
            if ($finger > 0) {
                fgets($fp);
                // slip the finger forward to a new line
                $nl = ftell($fp);
            }
            // was the chunk big enough? if not, take another bite
            if ($nl > 0 && $tail <= $nl) {
                $finger = max($finger - $chunk_size, 0);
                continue;
            } else {
                $finger = $nl;
            }
            // read chunk
            $chunk = '';
            $read_size = max($tail - $finger, 0);
            // found chunk size
            $got = 0;
            while ($got < $read_size && !feof($fp)) {
                $tmp = @fread($fp, max($read_size - $got, 0));
                if ($tmp === false) {
                    break;
                }
                //error state
                $got += strlen($tmp);
                $chunk .= $tmp;
            }
            $tmp = explode("\n", $chunk);
            array_pop($tmp);
            // remove trailing newline
            // combine with previous chunk
            $count += count($tmp);
//.........这里部分代码省略.........
开发者ID:nextghost,项目名称:dokuwiki,代码行数:101,代码来源:changelog.php

示例3: media_restore

/**
 * Restores an old revision of a media file
 *
 * @param string $image
 * @param int $rev
 * @param int $auth
 * @return string - file's id
 * @author Kate Arzamastseva <pshns@ukr.net>
 */
function media_restore($image, $rev, $auth)
{
    global $conf;
    if ($auth < AUTH_UPLOAD || !$conf['mediarevisions']) {
        return false;
    }
    $removed = !file_exists(mediaFN($image)) && file_exists(mediaMetaFN($image, '.changes'));
    if (!$image || !file_exists(mediaFN($image)) && !$removed) {
        return false;
    }
    if (!$rev || !file_exists(mediaFN($image, $rev))) {
        return false;
    }
    list(, $imime, ) = mimetype($image);
    $res = media_upload_finish(mediaFN($image, $rev), mediaFN($image), $image, $imime, true, 'copy');
    if (is_array($res)) {
        msg($res[0], $res[1]);
        return false;
    }
    return $res;
}
开发者ID:yjliugit,项目名称:dokuwiki,代码行数:30,代码来源:media.php

示例4: tpl_mediaFileDetails

/**
 * Prints the third column in full-screen media manager
 * Depending on the opened tab this may be details of the
 * selected file, the meta editing dialog or
 * list of file revisions
 *
 * @author Kate Arzamastseva <pshns@ukr.net>
 */
function tpl_mediaFileDetails($image, $rev)
{
    global $AUTH, $NS, $conf, $DEL, $lang, $INPUT;
    $removed = !file_exists(mediaFN($image)) && file_exists(mediaMetaFN($image, '.changes')) && $conf['mediarevisions'];
    if (!$image || !file_exists(mediaFN($image)) && !$removed || $DEL) {
        return;
    }
    if ($rev && !file_exists(mediaFN($image, $rev))) {
        $rev = false;
    }
    if (isset($NS) && getNS($image) != $NS) {
        return;
    }
    $do = $INPUT->str('mediado');
    $opened_tab = $INPUT->str('tab_details');
    $tab_array = array('view');
    list(, $mime) = mimetype($image);
    if ($mime == 'image/jpeg') {
        $tab_array[] = 'edit';
    }
    if ($conf['mediarevisions']) {
        $tab_array[] = 'history';
    }
    if (!$opened_tab || !in_array($opened_tab, $tab_array)) {
        $opened_tab = 'view';
    }
    if ($INPUT->bool('edit')) {
        $opened_tab = 'edit';
    }
    if ($do == 'restore') {
        $opened_tab = 'view';
    }
    media_tabs_details($image, $opened_tab);
    echo '<div class="panelHeader"><h3>';
    list($ext) = mimetype($image, false);
    $class = preg_replace('/[^_\\-a-z0-9]+/i', '_', $ext);
    $class = 'select mediafile mf_' . $class;
    $tabTitle = '<strong><a href="' . ml($image) . '" class="' . $class . '" title="' . $lang['mediaview'] . '">' . $image . '</a>' . '</strong>';
    if ($opened_tab === 'view' && $rev) {
        printf($lang['media_viewold'], $tabTitle, dformat($rev));
    } else {
        printf($lang['media_' . $opened_tab], $tabTitle);
    }
    echo '</h3></div>' . NL;
    echo '<div class="panelContent">' . NL;
    if ($opened_tab == 'view') {
        media_tab_view($image, $NS, $AUTH, $rev);
    } elseif ($opened_tab == 'edit' && !$removed) {
        media_tab_edit($image, $NS, $AUTH);
    } elseif ($opened_tab == 'history' && $conf['mediarevisions']) {
        media_tab_history($image, $NS, $AUTH);
    }
    echo '</div>' . NL;
}
开发者ID:neosunchess,项目名称:dokuwiki,代码行数:62,代码来源:template.php

示例5: getChangelogFilename

 /**
  * Returns path to changelog
  *
  * @return string path to file
  */
 protected function getChangelogFilename()
 {
     return mediaMetaFN($this->id, '.changes');
 }
开发者ID:janzoner,项目名称:dokuwiki,代码行数:9,代码来源:changelog.php


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