本文整理汇总了PHP中ml函数的典型用法代码示例。如果您正苦于以下问题:PHP ml函数的具体用法?PHP ml怎么用?PHP ml使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ml函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle the match
*/
function handle($match, $state, $pos, Doku_Handler $handler)
{
// prepare default data
$return = array('data' => $data, 'width' => 425, 'height' => 350, 'align' => 'center');
// prepare input
$lines = explode("\n", $match);
$conf = array_shift($lines);
$conf = substr($conf, 6, -1);
array_pop($lines);
// parse adhoc configs
if (preg_match('/\\b(left|center|right)\\b/i', $conf, $match)) {
$return['align'] = $match[1];
}
if (preg_match('/\\b(\\d+)x(\\d+)\\b/', $conf, $match)) {
$return['width'] = $match[1];
$return['height'] = $match[2];
}
// strip configs to find swf
$conf = preg_replace('/\\b(left|center|right|(\\d+)x(\\d+))\\b/i', '', $conf);
$conf = trim($conf);
$return['swf'] = ml($conf, '', true, '&');
// parse parameters
$return['data'] = linesToHash($lines);
foreach ($return['data'] as $key => $val) {
if ($key[0] == '!') {
$return['data'][substr($key, 1)] = ml($val, '', true, '&');
unset($return['data'][$key]);
}
}
return $return;
}
示例2: _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';
}
示例3: create_ebook_button
/**
*/
function create_ebook_button($event, $param)
{
global $INFO;
global $ACT;
if (!$this->getConf('permalink')) {
return;
}
if ($ACT != 'show') {
return;
}
$this->helper = $this->loadHelper('epub', true);
if (!$this->helper->is_inCache($INFO['id'])) {
return;
}
$auth = auth_quickaclcheck($INFO['id']);
if ($auth) {
$page_data = $this->helper->get_page_data($INFO['id']);
if (!$page_data) {
return;
}
$ebook = $page_data['epub'];
$link = ml($ebook);
$title = $page_data['title'];
echo $this->getLang('download');
//The most recent ebook for this page is:
echo " <a href='{$link}' title='{$title}'>{$title} ({$ebook})</a>.<br />";
echo $this->getLang('download_click');
// To download it, click on the link.
echo $this->getLang('download_alt');
// If you have an ebook reader plugin installed, right-click on the link and select 'Save . . . As'.";
}
}
示例4: handle
function handle($match, $state, $pos, &$handler)
{
$width = 320;
$height = 240;
$params['scaling'] = '"fit"';
$params['autoPlay'] = 'false';
$params['urlEncoding'] = 'true';
list($url, $attr) = explode(" ", hsc(trim(substr($match, 13, -2))), 2);
foreach (explode(" ", $attr) as $param) {
if (preg_match('/(\\d+),(\\d+)/', $param, $res)) {
$width = intval($res[1]);
$height = intval($res[2]);
} else {
if (preg_match('/([^:]+):(.*)$/', $param, $res)) {
$params[strtolower(substr($res[1], 0, 1)) . substr($res[1], 1)] = '"' . $res[2] . '"';
} else {
if (preg_match('/no(\\w+)/', $param, $res)) {
$params[strtolower(substr($res[1], 0, 1)) . substr($res[1], 1)] = 'false';
} else {
if (preg_match('/(\\w+)/', $param, $res)) {
$params[strtolower(substr($res[1], 0, 1)) . substr($res[1], 1)] = 'true';
}
}
}
}
}
if (strpos($url, '://') === false) {
$url = ml($url);
}
return array('url' => $url, 'width' => $width, 'height' => $height, 'fid' => uniqid(), 'attr' => $params);
}
示例5: _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;
}
示例6: CreateDefault
public function CreateDefault()
{
global $ID;
$data = array();
$data['FB']['url'] = wl($ID, null, true);
$data['FB']['title'] = p_get_first_heading($ID);
$text = "";
$data['FB']['description'] = $text;
$data['FB']['site_name'] = "FYKOS";
//var_dump(p_get_metadata($ID,'relation'));
$data['FB']['image'] = ml($this->getConf('default_image'), array('w' => 600, 'h' => 600), true, '&', true);
$data['FB']['type'] = "website";
$data['FB']['locale'] = 'cs_CZ';
return $data;
}
示例7: render
/**
* Handle the actual output creation.
*
* @param $aFormat String The output format to generate.
* @param $aRenderer Object A reference to the renderer object.
* @param $aData Array The data created by the <tt>handle()</tt>
* method.
* @return Boolean <tt>TRUE</tt> if rendered successfully, or
* <tt>FALSE</tt> otherwise.
* @public
* @see handle()
*/
public function render($mode, Doku_Renderer $renderer, $data) {
if($mode == 'xhtml'){
$is_color = substr($data[0], 0, 1) === '#';
$background_data = $is_color ? $data[0] : ml($data[0]);
if (is_a($renderer, 'renderer_plugin_revealjs')){
$renderer->add_background_to_next_slide($background_data);
} else {
if (!$is_color){ //background is an image
$renderer->doc .= 'Background: ';
$renderer->doc .= $renderer->_media($data[0], 'Background for next section in reveal.js mode',
null, 80, 60, null, true);
} else{
//$renderer->doc .= '<div style="background-color: '.$background_data.';">Background: '.$background_data.'</div>';
$renderer->doc .= '<div style="background-color: '.$background_data.';"><div style="display: inline; color: white;">Background: '.$background_data.',</div><div style="display: inline; color: black;">Background: '.$background_data.'</div></div>';
}
}
return true;
}
return false;
}
示例8: 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);
}
}
示例9: _mod_media_printfile
/**
* Formats and prints one file in the list
*
* @see media_printfile()
*/
function _mod_media_printfile($item, $auth, $jump, $display_namespace = false)
{
global $lang;
global $conf;
// Prepare zebra coloring
// I always wanted to use this variable name :-D
static $twibble = 1;
$twibble *= -1;
$zebra = $twibble == -1 ? 'odd' : 'even';
// Automatically jump to recent action
if ($jump == $item['id']) {
$jump = ' id="scroll__here" ';
} else {
$jump = '';
}
// Prepare fileicons
list($ext, $mime, $dl) = mimetype($item['file'], false);
$class = preg_replace('/[^_\\-a-z0-9]+/i', '_', $ext);
$class = 'select mediafile mf_' . $class;
// Prepare filename
$file = $this->_getOriginalFileName($item['id']);
if ($file === false) {
$file = utf8_decodeFN($item['file']);
}
// build fake media id
$ns = getNS($item['id']);
$fakeId = $ns === false ? $file : "{$ns}:{$file}";
$fakeId_escaped = hsc($fakeId);
// Prepare info
$info = '';
if ($item['isimg']) {
$info .= (int) $item['meta']->getField('File.Width');
$info .= '×';
$info .= (int) $item['meta']->getField('File.Height');
$info .= ' ';
}
$info .= '<i>' . dformat($item['mtime']) . '</i>';
$info .= ' ';
$info .= filesize_h($item['size']);
// output
echo '<div class="' . $zebra . '"' . $jump . ' title="' . $fakeId_escaped . '">' . NL;
if (!$display_namespace) {
echo '<a name="h_:' . $item['id'] . '" class="' . $class . '">' . hsc($file) . '</a> ';
} else {
echo '<a name="h_:' . $item['id'] . '" class="' . $class . '">' . $fakeId_escaped . '</a><br/>';
}
echo '<span class="info">(' . $info . ')</span>' . NL;
// view button
$link = ml($fakeId, '', true);
echo ' <a href="' . $link . '" target="_blank"><img src="' . DOKU_BASE . 'lib/images/magnifier.png" ' . 'alt="' . $lang['mediaview'] . '" title="' . $lang['mediaview'] . '" class="btn" /></a>';
// mediamanager button
$link = wl('', array('do' => 'media', 'image' => $fakeId, 'ns' => $ns));
echo ' <a href="' . $link . '" target="_blank"><img src="' . DOKU_BASE . 'lib/images/mediamanager.png" ' . 'alt="' . $lang['btn_media'] . '" title="' . $lang['btn_media'] . '" class="btn" /></a>';
// delete button
if ($item['writable'] && $auth >= AUTH_DELETE) {
$link = DOKU_BASE . 'lib/exe/mediamanager.php?delete=' . rawurlencode($fakeId) . '&sectok=' . getSecurityToken();
echo ' <a href="' . $link . '" class="btn_media_delete" title="' . $fakeId_escaped . '">' . '<img src="' . DOKU_BASE . 'lib/images/trash.png" alt="' . $lang['btn_delete'] . '" ' . 'title="' . $lang['btn_delete'] . '" class="btn" /></a>';
}
echo '<div class="example" id="ex_' . str_replace(':', '_', $item['id']) . '">';
echo $lang['mediausage'] . ' <code>{{:' . str_replace(array('{', '}'), array('(', ')'), $fakeId_escaped) . '}}</code>';
echo '</div>';
if ($item['isimg']) {
media_printimgdetail($item);
}
echo '<div class="clearer"></div>' . NL;
echo '</div>' . NL;
}
示例10: _tpl_include
<?php
_tpl_include('header.html');
?>
<!-- ********** HEADER ********** -->
<div id="dokuwiki__header"><div class="pad">
<div class="headings">
<h1><?php
tpl_link(wl(), $conf['title'], 'id="dokuwiki__top" accesskey="h" title="OpenData à Toulouse et ses environs"');
?>
</h1>
<?php
/* how to insert logo instead (if no CSS image replacement technique is used):
upload your logo into the data/media folder (root of the media manager) and replace 'logo.png' accordingly:*/
tpl_link(wl(), '<img src="' . ml('logo2.png') . '" alt="' . $conf['title'] . '" />', 'id="dokuwiki__top" accesskey="h" title="OpenData à Toulouse et ses environs"');
?>
<?php
if (tpl_getConf('tagline')) {
?>
<p class="claim"><?php
echo tpl_getConf('tagline');
?>
</p>
<?php
}
?>
<ul class="a11y">
<li><a href="#dokuwiki__content"><?php
echo tpl_getLang('skip_to_content');
示例11: _getImage
/**
* Override the mpdf _getImage function
*
* This function takes care of gathering the image data from HTTP or
* local files before passing the data back to mpdf's original function
* making sure that only cached file paths are passed to mpdf. It also
* takes care of checking image ACls.
*/
function _getImage(&$file, $firsttime = true, $allowvector = true, $orig_srcpath = false)
{
global $conf;
// build regex to parse URL back to media info
$re = preg_quote(ml('xxx123yyy', '', true, '&', true), '/');
$re = str_replace('xxx123yyy', '([^&\\?]*)', $re);
// extract the real media from a fetch.php uri and determine mime
if (preg_match("/^{$re}/", $file, $m) || preg_match('/[&\\?]media=([^&\\?]*)/', $file, $m)) {
$media = rawurldecode($m[1]);
list($ext, $mime) = mimetype($media);
} else {
list($ext, $mime) = mimetype($file);
}
// local files
$local = '';
if (substr($file, 0, 9) == 'dw2pdf://') {
// support local files passed from plugins
$local = substr($file, 9);
} elseif (!preg_match('/(\\.php|\\?)/', $file)) {
$re = preg_quote(DOKU_URL, '/');
// directly access local files instead of using HTTP, skip dynamic content
$local = preg_replace("/^{$re}/i", DOKU_INC, $file);
}
if (substr($mime, 0, 6) == 'image/') {
if (!empty($media)) {
// any size restrictions?
$w = $h = 0;
if (preg_match('/[\\?&]w=(\\d+)/', $file, $m)) {
$w = $m[1];
}
if (preg_match('/[\\?&]h=(\\d+)/', $file, $m)) {
$h = $m[1];
}
if (media_isexternal($media)) {
$local = media_get_from_URL($media, $ext, -1);
if (!$local) {
$local = $media;
}
// let mpdf try again
} else {
$media = cleanID($media);
//check permissions (namespace only)
if (auth_quickaclcheck(getNS($media) . ':X') < AUTH_READ) {
$file = '';
}
$local = mediaFN($media);
}
//handle image resizing/cropping
if ($w && file_exists($local)) {
if ($h) {
$local = media_crop_image($local, $ext, $w, $h);
} else {
$local = media_resize_image($local, $ext, $w, $h);
}
}
} elseif (media_isexternal($file)) {
// fixed external URLs
$local = media_get_from_URL($file, $ext, $conf['cachetime']);
}
if ($local) {
$file = $local;
$orig_srcpath = $local;
}
}
return parent::_getImage($file, $firsttime, $allowvector, $orig_srcpath);
}
示例12: testExternalMediaNotConverted
public function testExternalMediaNotConverted()
{
$html = p_wiki_xhtml('test:include');
$this->assertContains('src="' . ml('https://www.dokuwiki.org/lib/tpl/dokuwiki/images/logo.png') . '"', $html);
}
示例13: test_ml_imgresize_array_external
function test_ml_imgresize_array_external()
{
global $conf;
$conf['useslash'] = 0;
$conf['userewrite'] = 0;
$ids = array('https://example.com/lib/tpl/dokuwiki/images/logo.png', 'http://example.com/lib/tpl/dokuwiki/images/logo.png', 'ftp://example.com/lib/tpl/dokuwiki/images/logo.png');
$w = 80;
$args = array('w' => $w);
foreach ($ids as $id) {
$tok = media_get_token($id, $w, 0);
$hash = substr(PassHash::hmac('md5', $id, auth_cookiesalt()), 0, 6);
$expect = DOKU_BASE . $this->script . '?w=' . $w . '&tok=' . $tok . '&media=' . rawurlencode($id);
$this->assertEquals($expect, ml($id, $args));
}
$h = 50;
$args = array('h' => $h);
$tok = media_get_token($id, $h, 0);
$expect = DOKU_BASE . $this->script . '?h=' . $h . '&tok=' . $tok . '&media=' . rawurlencode($id);
$this->assertEquals($expect, ml($id, $args));
$w = 80;
$h = 50;
$args = array('w' => $w, 'h' => $h);
$tok = media_get_token($id, $w, $h);
$expect = DOKU_BASE . $this->script . '?w=' . $w . '&h=' . $h . '&tok=' . $tok . '&media=' . rawurlencode($id);
$this->assertEquals($expect, ml($id, $args));
}
示例14: _h
?>
sect/sbill/<?php
echo _h($sect->courseSecID);
?>
/<?php
echo bm();
?>
"><i></i> <?php
echo _t('Billing Info');
?>
</a></li>
<?php
if ($sect->roomCode != '') {
?>
<li<?php
echo ml('booking_module');
?>
class="glyphicons calendar tab-stacked"><a href="<?php
echo get_base_url();
?>
sect/sbook/<?php
echo _h($sect->courseSecID);
?>
/<?php
echo bm();
?>
"><i></i> <span><?php
echo _t('Booking Info');
?>
</span></a></li>
<?php
示例15: getXML
function getXML($conf, &$w, &$h)
{
$this->initColors();
$xml = '<?xml version="1.0"?>' . "\n";
// graph node
$graph = array('type' => 'undirected', 'width' => 725, 'height' => 400, 'title' => $conf['title'], 'bgcolor' => $this->color($conf['bgcolor'], 'ffffff'), 'linecolor' => $this->color($conf['linecolor'], 'cccccc'), 'viewmode' => 'explore', 'hidelabel' => 'false');
if ((int) $conf['width']) {
$graph['width'] = (int) $conf['width'];
}
if ((int) $conf['height']) {
$graph['height'] = (int) $conf['height'];
}
if ($conf['label']) {
$graph['title'] = $conf['label'];
}
if ($conf['viewmode'] == 'display') {
$graph['viewmode'] = 'display';
}
if ($conf['mode'] == 'directed') {
$graph['mode'] = 'directed';
}
$xml .= '<graph ' . html_attbuild($graph) . ">\n";
$w = $graph['width'];
$h = $graph['height'];
// nodes
foreach ($this->nodes as $name => $opts) {
$node = array('id' => $name, 'text' => $opts['label'] ? $opts['label'] : $name, 'color' => $this->color($opts['fillcolor'], 'cccccc'), 'textcolor' => $this->color($opts['fontcolor'], '000000'));
if ($opts['url']) {
if (preg_match('/^\\w+:\\/\\//', $opts['url'])) {
$node['link'] = $opts['url'];
} else {
$node['link'] = wl($opts['url']);
}
}
if ($opts['image']) {
$node['image'] = ml($opts['image'], array('w' => 40, 'h' => 40), true, '&');
}
if (preg_match('/^(box|rect|rectangle|polygon|diamond|trapezium|parallelogram|Msquare|box3d|component)$/', $opts['shape'])) {
$node['type'] = 'SquareNode';
}
$xml .= ' <node ' . html_attbuild($node) . " />\n";
}
$xml .= "\n";
// edges
foreach ($this->edges as $edge) {
$opts = (array) $edge[2];
$edge = array('sourceNode' => $edge[0], 'targetNode' => $edge[1], 'label' => $opts['label'], 'textcolor' => $this->color($opts['fontcolor'], '000000'));
$xml .= ' <edge ' . html_attbuild($edge) . " />\n";
}
$xml .= '</graph>';
return $xml;
}