/** * 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; }
/** * Use favicon.ico from data/media root directory if it exists, otherwise use * the one in the template's image directory. * * @author Anika Henke <*****@*****.**> */ function _tpl_getFavicon() { if (file_exists(mediaFN('favicon.ico'))) { return ml('favicon.ico'); } return DOKU_TPL . 'images/favicon.ico'; }
/** */ 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'."; } }
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); }
/** * 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; }
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; }
/** * 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; }
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); } }
/** * 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; }
<?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');
/** * 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); }
public function testExternalMediaNotConverted() { $html = p_wiki_xhtml('test:include'); $this->assertContains('src="' . ml('https://www.dokuwiki.org/lib/tpl/dokuwiki/images/logo.png') . '"', $html); }
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)); }
?> 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
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; }
/** * Prints the image with a link to the full sized version * * Only allowed in: detail.php * * @param $maxwidth int - maximal width of the image * @param $maxheight int - maximal height of the image * @param $link bool - link to the orginal size? * @param $params array - additional image attributes */ function tpl_img($maxwidth = 0, $maxheight = 0, $link = true, $params = null) { global $IMG; $w = tpl_img_getTag('File.Width'); $h = tpl_img_getTag('File.Height'); //resize to given max values $ratio = 1; if ($w >= $h) { if ($maxwidth && $w >= $maxwidth) { $ratio = $maxwidth / $w; } elseif ($maxheight && $h > $maxheight) { $ratio = $maxheight / $h; } } else { if ($maxheight && $h >= $maxheight) { $ratio = $maxheight / $h; } elseif ($maxwidth && $w > $maxwidth) { $ratio = $maxwidth / $w; } } if ($ratio) { $w = floor($ratio * $w); $h = floor($ratio * $h); } //prepare URLs $url = ml($IMG, array('cache' => $_REQUEST['cache']), true, '&'); $src = ml($IMG, array('cache' => $_REQUEST['cache'], 'w' => $w, 'h' => $h), true, '&'); //prepare attributes $alt = tpl_img_getTag('Simple.Title'); if (is_null($params)) { $p = array(); } else { $p = $params; } if ($w) { $p['width'] = $w; } if ($h) { $p['height'] = $h; } $p['class'] = 'img_detail'; if ($alt) { $p['alt'] = $alt; $p['title'] = $alt; } else { $p['alt'] = ''; } $p['src'] = $src; $data = array('url' => $link ? $url : null, 'params' => $p); return trigger_event('TPL_IMG_DISPLAY', $data, '_tpl_img_action', true); }
/** * Page title / link to page */ function _pageCell($id) { // check for page existence if (!isset($this->page['exists'])) { if (!isset($this->page['file'])) $this->page['file'] = wikiFN($id); $this->page['exists'] = @file_exists($this->page['file']); } if ($this->page['exists']) $class = 'wikilink1'; else $class = 'wikilink2'; // handle image and text titles if ($this->page['image']) { $title = '<img src="'.ml($this->page['image']).'" class="media"'; if ($this->page['title']) $title .= ' title="'.hsc($this->page['title']).'"'. ' alt="'.hsc($this->page['title']).'"'; $title .= ' />'; } else { if($this->showfirsthl) { $this->page['title'] = $this->_getMeta('title'); } else { $this->page['title'] = $id; } if (!$this->page['title']) $this->page['title'] = str_replace('_', ' ', noNS($id)); $title = hsc($this->page['title']); } // produce output $content = '<a href="'.wl($id).($this->page['section'] ? '#'.$this->page['section'] : ''). '" class="'.$class.'" title="'.$id.'">'.$title.'</a>'; if ($this->style == 'list') $content = '<ul><li>'.$content.'</li></ul>'; return $this->_printCell('page', $content); }
/** * Defines how title + link should look */ function _showtitle($img, $data) { global $ID; if (!$data['showtitle']) { return ''; } //prepare link $lnk = ml($img['id'], array('id' => $ID), false); // prepare output $ret = ''; $ret .= '<br /><a href="' . $lnk . '">'; $ret .= hsc($this->_meta($img, 'title')); $ret .= '</a>'; return $ret; }
/** * Renders internal and external media * * @author Andreas Gohr <*****@*****.**> */ function _media($src, $title = NULL, $align = NULL, $width = NULL, $height = NULL, $cache = NULL, $render = true) { $ret = ''; list($ext, $mime, $dl) = mimetype($src); if (substr($mime, 0, 5) == 'image') { // first get the $title if (!is_null($title)) { $title = $this->_xmlEntities($title); } elseif ($ext == 'jpg' || $ext == 'jpeg') { //try to use the caption from IPTC/EXIF require_once DOKU_INC . 'inc/JpegMeta.php'; $jpeg = new JpegMeta(mediaFN($src)); if ($jpeg !== false) { $cap = $jpeg->getTitle(); } if ($cap) { $title = $this->_xmlEntities($cap); } } if (!$render) { // if the picture is not supposed to be rendered // return the title of the picture if (!$title) { // just show the sourcename $title = $this->_xmlEntities(utf8_basename(noNS($src))); } return $title; } //add image tag $ret .= '<img src="' . ml($src, array('w' => $width, 'h' => $height, 'cache' => $cache)) . '"'; $ret .= ' class="media' . $align . '"'; if ($title) { $ret .= ' title="' . $title . '"'; $ret .= ' alt="' . $title . '"'; } else { $ret .= ' alt=""'; } if (!is_null($width)) { $ret .= ' width="' . $this->_xmlEntities($width) . '"'; } if (!is_null($height)) { $ret .= ' height="' . $this->_xmlEntities($height) . '"'; } $ret .= ' />'; } elseif ($mime == 'application/x-shockwave-flash') { if (!$render) { // if the flash is not supposed to be rendered // return the title of the flash if (!$title) { // just show the sourcename $title = utf8_basename(noNS($src)); } return $this->_xmlEntities($title); } $att = array(); $att['class'] = "media{$align}"; if ($align == 'right') { $att['align'] = 'right'; } if ($align == 'left') { $att['align'] = 'left'; } $ret .= html_flashobject(ml($src, array('cache' => $cache), true, '&'), $width, $height, array('quality' => 'high'), null, $att, $this->_xmlEntities($title)); } elseif ($title) { // well at least we have a title to display $ret .= $this->_xmlEntities($title); } else { // just show the sourcename $ret .= $this->_xmlEntities(utf8_basename(noNS($src))); } return $ret; }
/** * Create output */ function render($format, &$R, $data) { global $ID; if ($format == 'xhtml') { // Only use the md5 key $img = ml($ID, array('ditaa' => $data['md5'])); $R->doc .= '<img src="' . $img . '" class="media' . $data['align'] . '" alt=""'; if ($data['width']) { $R->doc .= ' width="' . $data['width'] . '"'; } if ($data['height']) { $R->doc .= ' height="' . $data['height'] . '"'; } if ($data['align'] == 'right') { $R->doc .= ' align="right"'; } if ($data['align'] == 'left') { $R->doc .= ' align="left"'; } $R->doc .= '/>'; return true; } else { if ($format == 'odt') { $src = $this->_imgfile($data); $R->_odtAddImage($src, $data['width'], $data['height'], $data['align']); return true; } else { if ($format == 'metadata') { // Save for later use $R->meta['ditaa'][$data['md5']] = $data; return true; } } } return false; }
/** * Send the diff for some media change * * @fixme this should embed thumbnails of images in HTML version * @param string $subscriber_mail The target mail address * @param string $template Mail template ('uploadmail', ...) * @param string $id Media file for which the notification is * @param int|bool $rev Old revision if any * @return bool true if successfully sent */ public function send_media_diff($subscriber_mail, $template, $id, $rev = false) { global $conf; $file = mediaFN($id); list($mime, $ext) = mimetype($id); $trep = array('MIME' => $mime, 'MEDIA' => ml($id, '', true, '&', true), 'SIZE' => filesize_h(filesize($file))); if ($rev && $conf['mediarevisions']) { $trep['OLD'] = ml($id, "rev={$rev}", true, '&', true); } else { $trep['OLD'] = '---'; } $headers = array('Message-Id' => $this->getMessageID($id, @filemtime($file))); if ($rev) { $headers['In-Reply-To'] = $this->getMessageID($id, $rev); } $this->send($subscriber_mail, 'upload', $id, $template, $trep, null, $headers); }
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title> <?php echo hsc(tpl_img_getTag('IPTC.Headline', $IMG)); ?> [<?php echo strip_tags($conf['title']); ?> ] </title> <?php tpl_metaheaders(); ?> <link rel="shortcut icon" href="<?php echo ml('favicon.ico'); ?> " /> </head> <body> <!--[if IE 6 ]><div id="IE6"><![endif]--><!--[if IE 7 ]><div id="IE7"><![endif]--><!--[if IE 8 ]><div id="IE8"><![endif]--> <div id="dokuwiki__detail" class="dokuwiki"> <?php html_msgarea(); ?> <?php if ($ERROR) { print $ERROR; } else {
/** * Tries to find a ressource file in the given locations. * * If a given location starts with a colon it is assumed to be a media * file, otherwise it is assumed to be relative to the current template * * @param array $search locations to look at * @param bool $abs if to use absolute URL * @param array &$imginfo filled with getimagesize() * @return string * @author Andreas Gohr <*****@*****.**> */ function tpl_getMediaFile($search, $abs = false, &$imginfo = null) { $img = ''; $file = ''; $ismedia = false; // loop through candidates until a match was found: foreach ($search as $img) { if (substr($img, 0, 1) == ':') { $file = mediaFN($img); $ismedia = true; } else { $file = tpl_incdir() . $img; $ismedia = false; } if (file_exists($file)) { break; } } // fetch image data if requested if (!is_null($imginfo)) { $imginfo = getimagesize($file); } // build URL if ($ismedia) { $url = ml($img, '', true, '', $abs); } else { $url = tpl_basedir() . $img; if ($abs) { $url = DOKU_URL . substr($url, strlen(DOKU_REL)); } } return $url; }
public function testInterWikiLinkTitleConversion() { $html = p_wiki_xhtml('test:include'); $this->assertContains('src="'.ml('wiki:dokuwiki.png', array('w' => '300')).'"', $html); }
/** * Embed audio in HTML * * @author Anika Henke <*****@*****.**> * * @param string $src - ID of audio to embed * @param array $atts - additional attributes for the <audio> tag * @return string */ function _audio($src, $atts = array()) { $files = array(); $isExternal = media_isexternal($src); if ($isExternal) { // take direct source for external files list(, $srcMime) = mimetype($src); $files[$srcMime] = $src; } else { // prepare alternative formats $extensions = array('ogg', 'mp3', 'wav'); $files = media_alternativefiles($src, $extensions); } $out = ''; // open audio tag $out .= '<audio ' . buildAttributes($atts) . ' controls="controls">' . NL; $fallback = ''; // output source for each alternative audio format foreach ($files as $mime => $file) { if ($isExternal) { $url = $file; $linkType = 'externalmedia'; } else { $url = ml($file, '', true, '&'); $linkType = 'internalmedia'; } $title = $atts['title'] ? $atts['title'] : $this->_xmlEntities(utf8_basename(noNS($file))); $out .= '<source src="' . hsc($url) . '" type="' . $mime . '" />' . NL; // alternative content (just a link to the file) $fallback .= $this->{$linkType}($file, $title, null, null, null, $cache = null, $linking = 'linkonly', $return = true); } // finish $out .= $fallback; $out .= '</audio>' . NL; return $out; }
/** * Returns icon from data/media root directory if it exists, otherwise * the one in the template's image directory. * * @param bool $abs - if to use absolute URL * @param string $fileName - file name of icon * @author Anika Henke <*****@*****.**> */ function tpl_getFavicon($abs = false, $fileName = 'favicon.ico') { if (file_exists(mediaFN($fileName))) { return ml($fileName, '', true, '', $abs); } if ($abs) { return DOKU_URL . substr(DOKU_TPL . 'images/' . $fileName, strlen(DOKU_REL)); } return DOKU_TPL . 'images/' . $fileName; }
/** * Display a result in a HTML table */ function html_resulttable($result, $header = '', $pager = 0) { echo '<table class="inline">'; if (is_array($header)) { echo '<tr>'; foreach ($header as $h) { echo '<th>' . hsc($h) . '</th>'; } echo '</tr>'; } $count = 0; if (is_array($result)) { foreach ($result as $row) { echo '<tr>'; foreach ($row as $k => $v) { if ($k == 'res_x') { continue; } if ($k == 'res_y') { continue; } echo '<td class="plg_stats_X' . $k . '">'; if ($k == 'page') { echo '<a href="' . wl($v) . '" class="wikilink1">'; echo hsc($v); echo '</a>'; } elseif ($k == 'media') { echo '<a href="' . ml($v) . '" class="wikilink1">'; echo hsc($v); echo '</a>'; } elseif ($k == 'filesize') { echo filesize_h($v); } elseif ($k == 'url') { $url = hsc($v); $url = preg_replace('/^https?:\\/\\/(www\\.)?/', '', $url); if (strlen($url) > 45) { $url = substr($url, 0, 30) . ' … ' . substr($url, -15); } echo '<a href="' . $v . '" class="urlextern">'; echo $url; echo '</a>'; } elseif ($k == 'ilookup') { echo '<a href="' . wl('', array('id' => $v, 'do' => 'search')) . '">Search</a>'; } elseif ($k == 'lookup') { echo '<a href="http://www.google.com/search?q=' . rawurlencode($v) . '">'; echo '<img src="' . DOKU_BASE . 'lib/plugins/statistics/ico/search/google.png" alt="Google" border="0" />'; echo '</a> '; echo '<a href="http://search.yahoo.com/search?p=' . rawurlencode($v) . '">'; echo '<img src="' . DOKU_BASE . 'lib/plugins/statistics/ico/search/yahoo.png" alt="Yahoo!" border="0" />'; echo '</a> '; echo '<a href="http://www.bing.com/search?q=' . rawurlencode($v) . '">'; echo '<img src="' . DOKU_BASE . 'lib/plugins/statistics/ico/search/bing.png" alt="Bing" border="0" />'; echo '</a> '; } elseif ($k == 'engine') { include_once dirname(__FILE__) . '/inc/searchengines.php'; if (isset($SEARCHENGINEINFO[$v])) { echo '<a href="' . $SEARCHENGINEINFO[$v][1] . '">' . $SEARCHENGINEINFO[$v][0] . '</a>'; } else { echo hsc(ucwords($v)); } } elseif ($k == 'eflag') { $this->html_icon('search', $v); } elseif ($k == 'bflag') { $this->html_icon('browser', $v); } elseif ($k == 'osflag') { $this->html_icon('os', $v); } elseif ($k == 'cflag') { $this->html_icon('flags', $v); } elseif ($k == 'html') { echo $v; } else { echo hsc($v); } echo '</td>'; } echo '</tr>'; if ($pager && $count == $pager) { break; } $count++; } } echo '</table>'; if ($pager) { $this->html_pager($pager, count($result) > $pager); } }
<?php if ($REV) { echo p_locale_xhtml('showrev'); } ?> <h1 class="page-header"> <i class="fa fa-picture-o text-muted"></i> <?php echo hsc(tpl_img_getTag('IPTC.Headline', $IMG)); ?> </h1> <p class="pull-right hidden-print list-inline"> <button type="button" class="btn btn-primary btn-xs" title="Info" data-toggle="modal" data-target="#detail-dialog"><i class="fa fa-fw fa-info-circle"></i></button> <a href="<?php echo ml($IMG, array('cache' => $INPUT->str('cache'), 'rev' => $REV), true, '&'); ?> " target="_blank" class="btn btn-default btn-xs" title="<?php echo $lang['js']['mediadirect']; ?> "><i class="fa fa-fw fa-arrows-alt"></i></a> </p> <?php tpl_img(900, 700); /* the image; parameters: maximum width, maximum height (and more) */ ?> <hr class="hidden-print" /> <div class="hidden-print pull-right">
function buildfilelink($ext, $prefix = '') { $ret['id'] = $prefix . $this->_pageid . '.' . $ext; $ret['file'] = mediaFN($ret['id']); $ret['link'] = ml($ret['id']); return $ret; }
/** * Renders internal and external media * * @author Andreas Gohr <*****@*****.**> */ function _media($src, $title = NULL, $align = NULL, $width = NULL, $height = NULL, $cache = NULL) { $ret = ''; list($ext, $mime) = mimetype($src); if (substr($mime, 0, 5) == 'image') { //add image tag $ret .= '<img src="' . ml($src, array('w' => $width, 'h' => $height, 'cache' => $cache)) . '"'; $ret .= ' class="media' . $align . '"'; if (!is_null($title)) { $ret .= ' title="' . $this->_xmlEntities($title) . '"'; $ret .= ' alt="' . $this->_xmlEntities($title) . '"'; } elseif ($ext == 'jpg' || $ext == 'jpeg') { //try to use the caption from IPTC/EXIF require_once DOKU_INC . 'inc/JpegMeta.php'; $jpeg =& new JpegMeta(mediaFN($src)); if ($jpeg !== false) { $cap = $jpeg->getTitle(); } if ($cap) { $ret .= ' title="' . $this->_xmlEntities($cap) . '"'; $ret .= ' alt="' . $this->_xmlEntities($cap) . '"'; } } else { $ret .= ' alt=""'; } if (!is_null($width)) { $ret .= ' width="' . $this->_xmlEntities($width) . '"'; } if (!is_null($height)) { $ret .= ' height="' . $this->_xmlEntities($height) . '"'; } $ret .= ' />'; } elseif ($mime == 'application/x-shockwave-flash') { $ret .= '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' . ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"'; if (!is_null($width)) { $ret .= ' width="' . $this->_xmlEntities($width) . '"'; } if (!is_null($height)) { $ret .= ' height="' . $this->_xmlEntities($height) . '"'; } $ret .= '>' . DOKU_LF; $ret .= '<param name="movie" value="' . ml($src) . '" />' . DOKU_LF; $ret .= '<param name="quality" value="high" />' . DOKU_LF; $ret .= '<embed src="' . ml($src) . '"' . ' quality="high"'; if (!is_null($width)) { $ret .= ' width="' . $this->_xmlEntities($width) . '"'; } if (!is_null($height)) { $ret .= ' height="' . $this->_xmlEntities($height) . '"'; } $ret .= ' type="application/x-shockwave-flash"' . ' pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>' . DOKU_LF; $ret .= '</object>' . DOKU_LF; } elseif (!is_null($title)) { // well at least we have a title to display $ret .= $this->_xmlEntities($title); } else { // just show the sourcename $ret .= $this->_xmlEntities(noNS($src)); } return $ret; }