本文整理汇总了PHP中mediaFN函数的典型用法代码示例。如果您正苦于以下问题:PHP mediaFN函数的具体用法?PHP mediaFN怎么用?PHP mediaFN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mediaFN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _tpl_getFavicon
/**
* Use favicon.ico from data/media root directory if it exists, otherwise use
* the one in the template's image directory.
*
* @author Anika Henke <anika@selfthinker.org>
*/
function _tpl_getFavicon()
{
if (file_exists(mediaFN('favicon.ico'))) {
return ml('favicon.ico');
}
return DOKU_TPL . 'images/favicon.ico';
}
示例2: _getAvatarURL
/**
* Main function to determine the avatar to use
*/
function _getAvatarURL($user, &$title, &$size)
{
global $auth;
if (!$size || !is_int($size)) {
$size = $this->getConf('size');
}
// check first if a local image for the given user exists
$userinfo = $auth->getUserData($user);
if (is_array($userinfo)) {
if ($userinfo['name'] && !$title) {
$title = hsc($userinfo['name']);
}
$avatar = $this->getConf('namespace') . ':' . $user;
$formats = array('.png', '.jpg', '.gif');
foreach ($formats as $format) {
$img = mediaFN($avatar . $format);
if (!@file_exists($img)) {
continue;
}
$src = ml($avatar . $format, array('w' => $size, 'h' => $size));
break;
}
if (!$src) {
$mail = $userinfo['mail'];
}
} else {
$mail = $user;
}
if (!$src) {
$seed = md5($mail);
if (function_exists('imagecreatetruecolor')) {
// we take the monster ID as default
$file = 'monsterid.php?seed=' . $seed . '&size=' . $size . '&.png';
} else {
// GDlib is not availble - resort to default images
switch ($size) {
case 20:
case 40:
case 80:
$file = 'images/default_' . $size . '.png';
break;
default:
$file = 'images/default_120.png';
}
}
$default = ml(DOKU_URL . '/lib/plugins/avatar/' . $file, 'cache=recache', true, '&', true);
// do not pass invalid or empty emails to gravatar site...
if (mail_isvalid($mail) && $size <= 80) {
$src = ml('http://www.gravatar.com/avatar.php?' . 'gravatar_id=' . $seed . '&default=' . urlencode($default) . '&size=' . $size . '&rating=' . $this->getConf('rating') . '&.jpg', 'cache=recache');
// show only default image if invalid or empty email given
} else {
$src = $default;
}
}
if (!$title) {
$title = obfuscate($mail);
}
return $src;
}
示例3: recipe
/**
* returns a recipe to link to the media file
*/
protected function recipe($project, $file)
{
$name = $file->name();
$id = $project->name() . ':' . $name;
$media_name = mediaFN($id);
if ($media_name) {
return "ln -s {$media_name} {$name}";
}
return NULL;
}
示例4: make
public function make($file)
{
$media = mediaFN($file->id());
$path = $file->file_path();
if (file_exists($path)) {
unlink($path);
}
symlink($media, $path);
return true;
}
示例5: delete_media
function delete_media($md5)
{
$epub = $this->cache['current_books'][$md5]['epub'];
$file = mediaFN($this->cache['current_books'][$md5]['epub']);
if (file_exists($file)) {
if (unlink($file)) {
return "Removed: " . $epub;
} else {
return "error unlinking {$epub}";
}
}
return "File not found: " . $this->cache['current_books'][$md5]['epub'];
}
示例6: settings_plugin_siteexport_settings
function settings_plugin_siteexport_settings($functions)
{
global $ID;
$functions->debug->setDebugLevel($this->getConf('debugLevel'));
$functions->debug->setDebugFile($this->getConf('debugFile'));
if (empty($_REQUEST['pattern'])) {
$params = $_REQUEST;
$this->pattern = $functions->requestParametersToCacheHash($params);
} else {
// Set the pattern
$this->pattern = $_REQUEST['pattern'];
}
$this->isCLI = !$_SERVER['REMOTE_ADDR'] && 'cli' == php_sapi_name();
$this->cachetime = $this->getConf('cachetime');
if (!empty($_REQUEST['disableCache'])) {
$this->cachetime = intval($_REQUEST['disableCache']) == 1 ? 0 : $this->cachetime;
}
// Load Variables
$this->origZipFile = $this->getConf('zipfilename');
$this->ignoreNon200 = $this->getConf('ignoreNon200');
// ID
$this->downloadZipFile = $functions->getSpecialExportFileName($this->origZipFile, $this->pattern);
// $this->eclipseZipFile = $functions->getSpecialExportFileName(getNS($this->origZipFile) . ':' . $this->origEclipseZipFile, $this->pattern);
$this->zipFile = mediaFN($this->downloadZipFile);
$this->tmpDir = mediaFN(getNS($this->origZipFile));
$this->exportLinkedPages = intval($_REQUEST['exportLinkedPages']) == 1 ? true : false;
$this->namespace = $functions->getNamespaceFromID($_REQUEST['ns'], $PAGE);
$this->addParams = !empty($_REQUEST['addParams']);
$this->useTOCFile = !empty($_REQUEST['useTocFile']);
// set export Namespace - which is a virtual Root
$pg = noNS($ID);
if (empty($this->namespace)) {
$this->namespace = $functions->getNamespaceFromID(getNS($ID), $pg);
}
$this->exportNamespace = !empty($_REQUEST['ens']) && preg_match("%^" . $functions->getNamespaceFromID($_REQUEST['ens'], $pg) . "%", $this->namespace) ? $functions->getNamespaceFromID($_REQUEST['ens'], $pg) : $this->namespace;
$this->TOCMapWithoutTranslation = intval($_REQUEST['TOCMapWithoutTranslation']) == 1 ? true : false;
// Strip params that should be forwarded
$this->additionalParameters = $_REQUEST;
$functions->removeWikiVariables($this->additionalParameters, true);
$tmpID = $ID;
$ID = $this->origZipFile;
$INFO = pageinfo();
if (!$this->isCLI) {
// Workaround for the cron which cannot authenticate but has access to everything.
if ($INFO['perm'] < AUTH_DELETE) {
list($USER, $PASS) = $functions->basic_authentication();
auth_login($USER, $PASS);
}
}
$ID = $tmpID;
}
示例7: test_no_token_required
/**
* native image request which doesn't require a token
* try: with a token & without a token
* expect: (for both) header with mime-type, content matching source image filesize & no error response
*/
function test_no_token_required()
{
$this->width = $this->height = 0;
// no width & height, means image request at native dimensions
$any_token = 'tok=' . media_get_token('junk', 200, 100) . '&';
$no_token = '';
$bytes = filesize(mediaFN($this->media));
foreach (array($any_token, $no_token) as $token) {
$response = $this->fetchResponse($token);
$this->assertTrue((bool) $response->getHeader('Content-Type'));
$this->assertEquals(strlen($response->getContent()), $bytes);
$status_code = $response->getStatusCode();
$this->assertTrue(is_null($status_code) || 200 == $status_code);
}
}
示例8: test_move_wiki_namespace
public function test_move_wiki_namespace()
{
$this->markTestSkipped('This test is failing.');
global $AUTH_ACL;
$AUTH_ACL[] = "wiki:*\t@ALL\t16";
idx_addPage('wiki:dokuwiki');
idx_addPage('wiki:syntax');
/** @var helper_plugin_move $move */
$move = plugin_load('helper', 'move');
$opts = array('ns' => 'wiki', 'newns' => 'foo', 'contenttomove' => 'both');
$this->assertSame(3, $move->start_namespace_move($opts));
$this->assertSame(1, $move->continue_namespace_move());
$this->assertSame(0, $move->continue_namespace_move());
$this->assertFileExists(wikiFN('foo:dokuwiki'));
$this->assertFileNotExists(wikiFN('wiki:syntax'));
$this->assertFileExists(mediaFN('foo:dokuwiki-128.png'));
}
示例9: internalmedia
public function internalmedia($src, $title = NULL, $align = NULL, $width = NULL, $height = NULL, $cache = NULL, $linking = NULL, $return = false)
{
global $ID;
list($src, $hash) = explode('#', $src, 2);
resolve_mediaid(getNS($ID), $src, $exists);
$noLink = false;
$render = $linking == 'linkonly' ? false : true;
$link = $this->_getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render);
list($ext, $mime, $dl) = mimetype($src, false);
if (substr($mime, 0, 5) == 'image' && $render) {
if ($linking == NULL || $linking == '' || $linking == 'details') {
$linking = 'direct';
}
$link['url'] = ml($src, array('id' => $ID, 'cache' => $cache), $linking == 'direct');
} elseif ($mime == 'application/x-shockwave-flash' && $render) {
// don't link flash movies
$noLink = true;
} else {
// add file icons
$class = preg_replace('/[^_\\-a-z0-9]+/i', '_', $ext);
$link['class'] .= ' mediafile mf_' . $class;
$link['url'] = ml($src, array('id' => $ID, 'cache' => $cache), true);
if ($exists) {
$link['title'] .= ' (' . filesize_h(filesize(mediaFN($src))) . ')';
}
}
if ($hash) {
$link['url'] .= '#' . $hash;
}
//markup non existing files
if (!$exists) {
$link['class'] .= ' wikilink2';
}
//output formatted
if ($linking == 'nolink' || $noLink) {
$this->doc .= $link['name'];
} else {
$this->doc .= $this->_formatLink($link);
}
}
示例10: handle
/**
* Handle the match
*/
function handle($match, $state, $pos, Doku_Handler $handler)
{
global $ID;
$data = array('width' => 500, 'height' => 250, 'align' => 0, 'initialZoom' => 1, 'tileBaseUri' => DOKU_BASE . 'lib/plugins/panoview/tiles.php', 'tileSize' => 256, 'maxZoom' => 10, 'blankTile' => DOKU_BASE . 'lib/plugins/panoview/gfx/blank.gif', 'loadingTile' => DOKU_BASE . 'lib/plugins/panoview/gfx/progress.gif');
$match = substr($match, 11, -2);
//strip markup from start and end
// alignment
$data['align'] = 0;
if (substr($match, 0, 1) == ' ') {
$data['align'] += 1;
}
if (substr($match, -1, 1) == ' ') {
$data['align'] += 2;
}
// extract params
list($img, $params) = explode('?', $match, 2);
$img = trim($img);
// resolving relatives
$data['image'] = resolve_id(getNS($ID), $img);
$file = mediaFN($data['image']);
list($data['imageWidth'], $data['imageHeight']) = @getimagesize($file);
// calculate maximum zoom
$data['maxZoom'] = ceil(sqrt(max($data['imageWidth'], $data['imageHeight']) / $data['tileSize']));
// size
if (preg_match('/\\b(\\d+)[xX](\\d+)\\b/', $params, $match)) {
$data['width'] = $match[1];
$data['height'] = $match[2];
}
// initial zoom
if (preg_match('/\\b[zZ](\\d+)\\b/', $params, $match)) {
$data['initialZoom'] = $match[1];
}
if ($data['initialZoom'] < 0) {
$data['initialZoom'] = 0;
}
if ($data['initialZoom'] > $data['maxZoom']) {
$data['initialZoom'] = $data['maxZoom'];
}
return $data;
}
示例11: getAdjustedSVG
/**
* Gets a local scalable copy of the SVG with its dimensions
*
* @param $id
* @param int $cachetime
* @return bool|array either array($file, $width, $height) or false if no cache available
*/
public function getAdjustedSVG($id, $cachetime = -1)
{
$info = $this->getInfo();
$cachefile = getCacheName($id . $info['date'], '.svg');
$cachedate = @filemtime($cachefile);
if ($cachedate && $cachetime < time() - $cachedate) {
list($width, $height) = $this->readSVGsize($cachefile);
return array($cachefile, $width, $height);
}
// still here, create a new cache file
if (preg_match('/^https?:\\/\\//i', $id)) {
io_download($id, $cachefile);
#FIXME make max size configurable
} else {
@copy(mediaFN($id), $cachefile);
}
clearstatcache(false, $cachefile);
// adjust the size in the cache file
if (file_exists($cachefile)) {
list($width, $height) = $this->readSVGsize($cachefile, true);
return array($cachefile, $width, $height);
}
return false;
}
示例12: copy_media
function copy_media($media, $external = false)
{
$name = epub_clean_name(str_replace(':', '_', basename($media)));
$ret_name = $name;
$mime_type = mimetype($name);
list($type, $ext) = explode('/', $mime_type[1]);
if ($type !== 'image') {
return;
}
if ($external) {
if (!$this->allow_url_fopen) {
return;
}
$tmp = str_replace('https://', "", $media);
$tmp = str_replace('http://', "", $media);
$tmp = str_replace('www.', "", $tmp);
if ($this->isWin) {
$tmp = preg_replace('/^[A-Z]:/', "", $tmp);
}
$tmp = ltrim($tmp, '/\\/');
$elems = explode('/', $tmp);
if ($this->isWin) {
$elems = explode('\\', $tmp);
}
if (count($elems && $elems[0])) {
$elems[0] = preg_replace('#/\\W#', '_', $elems[0]);
$name = $elems[0] . "_" . $name;
}
}
if (!preg_match("/^Images/", $name)) {
$name = "Images/{$name}";
}
$file = $this->oebps . $name;
if (file_exists($file)) {
return $name;
}
if (!$external) {
$media = mediaFN($media);
}
if (copy($media, $file)) {
epub_write_item($name, $mime_type[1]);
return $name;
} else {
if (!$this->isWin && epub_save_image($media, $file)) {
epub_write_item($name, $mime_type[1]);
return $name;
}
}
return false;
}
示例13: getRecentMediaChanges
/**
* Returns a list of recent media changes since give timestamp
*
* @author Michael Hamann <michael@content-space.de>
* @author Michael Klier <chi@chimeric.de>
*/
function getRecentMediaChanges($timestamp)
{
if (strlen($timestamp) != 10) {
throw new RemoteException('The provided value is not a valid timestamp', 311);
}
$recents = getRecentsSince($timestamp, null, '', RECENTS_MEDIA_CHANGES);
$changes = array();
foreach ($recents as $recent) {
$change = array();
$change['name'] = $recent['id'];
$change['lastModified'] = $this->api->toDate($recent['date']);
$change['author'] = $recent['user'];
$change['version'] = $recent['date'];
$change['perms'] = $recent['perms'];
$change['size'] = @filesize(mediaFN($recent['id']));
array_push($changes, $change);
}
if (!empty($changes)) {
return $changes;
} else {
// in case we still have nothing at this point
throw new RemoteException('There are no changes in the specified timeframe', 321);
}
}
示例14: checkFileStatus
/**
* Check for media for preconditions and return correct status code
*
* READ: MEDIA, MIME, EXT, CACHE
* WRITE: MEDIA, FILE, array( STATUS, STATUSMESSAGE )
*
* @author Gerry Weissbach <gerry.w@gammaproduction.de>
* @param $media reference to the media id
* @param $file reference to the file variable
* @returns array(STATUS, STATUSMESSAGE)
*/
function checkFileStatus(&$media, &$file)
{
global $MIME, $EXT, $CACHE;
//media to local file
if (preg_match('#^(https?)://#i', $media)) {
//check hash
if (substr(md5(auth_cookiesalt() . $media), 0, 6) != $_REQUEST['hash']) {
return array(412, 'Precondition Failed');
}
//handle external images
if (strncmp($MIME, 'image/', 6) == 0) {
$file = media_get_from_URL($media, $EXT, $CACHE);
}
if (!$file) {
//download failed - redirect to original URL
return array(302, $media);
}
} else {
$media = cleanID($media);
if (empty($media)) {
return array(400, 'Bad request');
}
//check permissions (namespace only)
if (auth_quickaclcheck(getNS($media) . ':X') < AUTH_READ) {
return array(403, 'Forbidden');
}
$file = mediaFN($media);
}
//check file existance
if (!@file_exists($file)) {
return array(404, 'Not Found');
}
return array(200, null);
}
示例15: resolve_mediaid
/**
* Returns a full media id
*
* @author Andreas Gohr <andi@splitbrain.org>
*
* @param string $ns namespace which is context of id
* @param string &$page (reference) relative media id, updated to resolved id
* @param bool &$exists (reference) updated with existance of media
*/
function resolve_mediaid($ns, &$page, &$exists, $rev = '', $date_at = false)
{
$page = resolve_id($ns, $page);
if ($rev !== '' && $date_at) {
$medialog = new MediaChangeLog($page);
$medialog_rev = $medialog->getLastRevisionAt($rev);
if ($medialog_rev !== false) {
$rev = $medialog_rev;
}
}
$file = mediaFN($page, $rev);
$exists = @file_exists($file);
}