/** * Embed a flash object in HTML * * This will create the needed HTML to embed a flash movie in a cross browser * compatble way using valid XHTML * * The parameters $params, $flashvars and $atts need to be associative arrays. * No escaping needs to be done for them. The alternative content *has* to be * escaped because it is used as is. If no alternative content is given * $lang['noflash'] is used. * * @author Andreas Gohr <*****@*****.**> * @link http://latrine.dgx.cz/how-to-correctly-insert-a-flash-into-xhtml * * @param string $swf - the SWF movie to embed * @param int $width - width of the flash movie in pixels * @param int $height - height of the flash movie in pixels * @param array $params - additional parameters (<param>) * @param array $flashvars - parameters to be passed in the flashvar parameter * @param array $atts - additional attributes for the <object> tag * @param string $alt - alternative content (is NOT automatically escaped!) * @returns string - the XHTML markup */ function html_flashobject($swf, $width, $height, $params = null, $flashvars = null, $atts = null, $alt = '') { global $lang; $out = ''; // prepare the object attributes if (is_null($atts)) { $atts = array(); } $atts['width'] = (int) $width; $atts['height'] = (int) $height; if (!$atts['width']) { $atts['width'] = 425; } if (!$atts['height']) { $atts['height'] = 350; } // add object attributes for standard compliant browsers $std = $atts; $std['type'] = 'application/x-shockwave-flash'; $std['data'] = $swf; // add object attributes for IE $ie = $atts; $ie['classid'] = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'; // open object (with conditional comments) $out .= '<!--[if !IE]> -->' . NL; $out .= '<object ' . buildAttributes($std) . '>' . NL; $out .= '<!-- <![endif]-->' . NL; $out .= '<!--[if IE]>' . NL; $out .= '<object ' . buildAttributes($ie) . '>' . NL; $out .= ' <param name="movie" value="' . hsc($swf) . '" />' . NL; $out .= '<!--><!-- -->' . NL; // print params if (is_array($params)) { foreach ($params as $key => $val) { $out .= ' <param name="' . hsc($key) . '" value="' . hsc($val) . '" />' . NL; } } // add flashvars if (is_array($flashvars)) { $out .= ' <param name="FlashVars" value="' . buildURLparams($flashvars) . '" />' . NL; } // alternative content if ($alt) { $out .= $alt . NL; } else { $out .= $lang['noflash'] . NL; } // finish $out .= '</object>' . NL; $out .= '<!-- <![endif]-->' . NL; return $out; }
/** * Build a link to a media file * * Will return a link to the detail page if $direct is false * * The $more parameter should always be given as array, the function then * will strip default parameters to produce even cleaner URLs * * @param string $id the media file id or URL * @param mixed $more string or array with additional parameters * @param bool $direct link to detail page if false * @param string $sep URL parameter separator * @param bool $abs Create an absolute URL * @return string */ function ml($id = '', $more = '', $direct = true, $sep = '&', $abs = false) { global $conf; if (is_array($more)) { // strip defaults for shorter URLs if (isset($more['cache']) && $more['cache'] == 'cache') { unset($more['cache']); } if (!$more['w']) { unset($more['w']); } if (!$more['h']) { unset($more['h']); } if (isset($more['id']) && $direct) { unset($more['id']); } $more = buildURLparams($more, $sep); } else { $more = str_replace('cache=cache', '', $more); //skip default $more = str_replace(',,', ',', $more); $more = str_replace(',', $sep, $more); } if ($abs) { $xlink = DOKU_URL; } else { $xlink = DOKU_BASE; } // external URLs are always direct without rewriting if (preg_match('#^(https?|ftp)://#i', $id)) { $xlink .= 'lib/exe/fetch.php'; // add hash: $xlink .= '?hash=' . substr(md5(auth_cookiesalt() . $id), 0, 6); if ($more) { $xlink .= $sep . $more; $xlink .= $sep . 'media=' . rawurlencode($id); } else { $xlink .= $sep . 'media=' . rawurlencode($id); } return $xlink; } $id = idfilter($id); // decide on scriptname if ($direct) { if ($conf['userewrite'] == 1) { $script = '_media'; } else { $script = 'lib/exe/fetch.php'; } } else { if ($conf['userewrite'] == 1) { $script = '_detail'; } else { $script = 'lib/exe/detail.php'; } } // build URL based on rewrite mode if ($conf['userewrite']) { $xlink .= $script . '/' . $id; if ($more) { $xlink .= '?' . $more; } } else { if ($more) { $xlink .= $script . '?' . $more; $xlink .= $sep . 'media=' . $id; } else { $xlink .= $script . '?media=' . $id; } } return $xlink; }
/** * Renders the output. * */ function render($mode, &$renderer, $data) { global $conf; global $lang; if ($mode == 'xhtml') { // Get the path $plugin_path = DOKU_BASE . 'lib/plugins/mindmap/'; // Was a different location for the plugin set? if ($this->getConf('use_plugin_path') == 1) { $conf_plugin_path = $this->getConf('plugin_path'); // Make sure the plugin path is set if ($conf_plugin_path != '') { // Make sure there is a trailing / if ($conf_plugin_path[strlen($conf_plugin_path) - 1] != '/') { $conf_plugin_path .= '/'; } $plugin_path = $conf_plugin_path; } } if ($data['format'] == 'gexf') { // Add a link to the GEXF XML file $xml = $plugin_path . 'xml.php?' . buildURLparams($data); $renderer->doc .= '<p><a href="' . $xml . '" target="_blank">' . $this->getLang('gexf_mindmap') . '</a></p>'; } else { // Force dot format $data['format'] = 'dot'; $img = $plugin_path . 'img.php?' . buildURLparams($data); if ($data['height'] != 0 || $data['width'] != 0) { // Add a link $renderer->doc .= '<a href="' . $img . '" target="_blank" border="0">'; } // Add the image $renderer->doc .= '<img src="' . $img . '" class="media' . $data['align'] . '" alt=""'; if ($data['width']) { $renderer->doc .= ' width="' . $data['width'] . '"'; } if ($data['height']) { $renderer->doc .= ' height="' . $data['height'] . '"'; } if ($data['align'] == 'right') { $renderer->doc .= ' align="right"'; } if ($data['align'] == 'left') { $renderer->doc .= ' align="left"'; } $renderer->doc .= '/>'; if ($data['height'] != 0 || $data['width'] != 0) { // Close the link $renderer->doc .= '</a>'; } } return true; } return false; }
/** * Build a link to a media file * * Will return a link to the detail page if $direct is false * * The $more parameter should always be given as array, the function then * will strip default parameters to produce even cleaner URLs * * @param string $id the media file id or URL * @param mixed $more string or array with additional parameters * @param bool $direct link to detail page if false * @param string $sep URL parameter separator * @param bool $abs Create an absolute URL * @return string */ function ml($id = '', $more = '', $direct = true, $sep = '&', $abs = false) { global $conf; $isexternalimage = media_isexternal($id); if (!$isexternalimage) { $id = cleanID($id); } if (is_array($more)) { // add token for resized images if (!empty($more['w']) || !empty($more['h']) || $isexternalimage) { $more['tok'] = media_get_token($id, $more['w'], $more['h']); } // strip defaults for shorter URLs if (isset($more['cache']) && $more['cache'] == 'cache') { unset($more['cache']); } if (empty($more['w'])) { unset($more['w']); } if (empty($more['h'])) { unset($more['h']); } if (isset($more['id']) && $direct) { unset($more['id']); } if (isset($more['rev']) && !$more['rev']) { unset($more['rev']); } $more = buildURLparams($more, $sep); } else { $matches = array(); if (preg_match_all('/\\b(w|h)=(\\d*)\\b/', $more, $matches, PREG_SET_ORDER) || $isexternalimage) { $resize = array('w' => 0, 'h' => 0); foreach ($matches as $match) { $resize[$match[1]] = $match[2]; } $more .= $more === '' ? '' : $sep; $more .= 'tok=' . media_get_token($id, $resize['w'], $resize['h']); } $more = str_replace('cache=cache', '', $more); //skip default $more = str_replace(',,', ',', $more); $more = str_replace(',', $sep, $more); } if ($abs) { $xlink = DOKU_URL; } else { $xlink = DOKU_BASE; } // external URLs are always direct without rewriting if ($isexternalimage) { $xlink .= 'lib/exe/fetch.php'; $xlink .= '?' . $more; $xlink .= $sep . 'media=' . rawurlencode($id); return $xlink; } $id = idfilter($id); // decide on scriptname if ($direct) { if ($conf['userewrite'] == 1) { $script = '_media'; } else { $script = 'lib/exe/fetch.php'; } } else { if ($conf['userewrite'] == 1) { $script = '_detail'; } else { $script = 'lib/exe/detail.php'; } } // build URL based on rewrite mode if ($conf['userewrite']) { $xlink .= $script . '/' . $id; if ($more) { $xlink .= '?' . $more; } } else { if ($more) { $xlink .= $script . '?' . $more; $xlink .= $sep . 'media=' . $id; } else { $xlink .= $script . '?media=' . $id; } } return $xlink; }
/** * Build a link to a media file * * Will return a link to the detail page if $direct is false */ function ml($id = '', $more = '', $direct = true, $sep = '&') { global $conf; if (is_array($more)) { $more = buildURLparams($more, $sep); } else { $more = str_replace(',', $sep, $more); } $xlink = DOKU_BASE; // external URLs are always direct without rewriting if (preg_match('#^(https?|ftp)://#i', $id)) { $xlink .= 'lib/exe/fetch.php'; if ($more) { $xlink .= '?' . $more; $xlink .= $sep . 'media=' . rawurlencode($id); } else { $xlink .= '?media=' . rawurlencode($id); } return $xlink; } $id = idfilter($id); // decide on scriptname if ($direct) { if ($conf['userewrite'] == 1) { $script = '_media'; } else { $script = 'lib/exe/fetch.php'; } } else { if ($conf['userewrite'] == 1) { $script = '_detail'; } else { $script = 'lib/exe/detail.php'; } } // build URL based on rewrite mode if ($conf['userewrite']) { $xlink .= $script . '/' . $id; if ($more) { $xlink .= '?' . $more; } } else { if ($more) { $xlink .= $script . '?' . $more; $xlink .= $sep . 'media=' . $id; } else { $xlink .= $script . '?media=' . $id; } } return $xlink; }
/** * Create output * Edited by Michael Kling for the MAP patch. * @todo ODT format doesnt support maps */ function render($format, &$R, $data) { if ($format == 'xhtml') { $img = DOKU_BASE . 'lib/plugins/graphviz/img.php?' . buildURLparams($data); $mapcache = $this->_mapfile($data); $map = io_readFile($mapcache, false); if ($mapcache !== false) { $R->doc .= '<map name="' . $data['md5'] . '" id="' . $data['md5'] . '">' . $map . '</map>'; } $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"'; } if ($mapcache !== false) { $R->doc .= ' usemap="#' . $data['md5'] . '"'; } $R->doc .= '/>'; return true; } elseif ($format == 'odt') { $src = $this->_imgfile($data); $R->_odtAddImage($src, $data['width'], $data['height'], $data['align']); return true; } return false; }
/** * Print the media upload form if permissions are correct * * @author Andreas Gohr <*****@*****.**> */ function media_uploadform($ns, $auth) { global $lang; if ($auth < AUTH_UPLOAD) { return; } //fixme print info on missing permissions? // The default HTML upload form $form = new Doku_Form(array('id' => 'dw__upload', 'action' => DOKU_BASE . 'lib/exe/mediamanager.php', 'enctype' => 'multipart/form-data')); $form->addElement('<div class="upload">' . $lang['mediaupload'] . '</div>'); $form->addElement(formSecurityToken()); $form->addHidden('ns', hsc($ns)); $form->addElement(form_makeOpenTag('p')); $form->addElement(form_makeFileField('upload', $lang['txt_upload'] . ':', 'upload__file')); $form->addElement(form_makeCloseTag('p')); $form->addElement(form_makeOpenTag('p')); $form->addElement(form_makeTextField('id', '', $lang['txt_filename'] . ':', 'upload__name')); $form->addElement(form_makeButton('submit', '', $lang['btn_upload'])); $form->addElement(form_makeCloseTag('p')); if ($auth >= AUTH_DELETE) { $form->addElement(form_makeOpenTag('p')); $form->addElement(form_makeCheckboxField('ow', 1, $lang['txt_overwrt'], 'dw__ow', 'check')); $form->addElement(form_makeCloseTag('p')); } html_form('upload', $form); // prepare flashvars for multiupload $opt = array('L_gridname' => $lang['mu_gridname'], 'L_gridsize' => $lang['mu_gridsize'], 'L_gridstat' => $lang['mu_gridstat'], 'L_namespace' => $lang['mu_namespace'], 'L_overwrite' => $lang['txt_overwrt'], 'L_browse' => $lang['mu_browse'], 'L_upload' => $lang['btn_upload'], 'L_toobig' => $lang['mu_toobig'], 'L_ready' => $lang['mu_ready'], 'L_done' => $lang['mu_done'], 'L_fail' => $lang['mu_fail'], 'L_authfail' => $lang['mu_authfail'], 'L_progress' => $lang['mu_progress'], 'L_filetypes' => $lang['mu_filetypes'], 'L_info' => $lang['mu_info'], 'L_lasterr' => $lang['mu_lasterr'], 'O_ns' => ":{$ns}", 'O_backend' => 'mediamanager.php?' . session_name() . '=' . session_id(), 'O_maxsize' => php_to_byte(ini_get('upload_max_filesize')), 'O_extensions' => join('|', array_keys(getMimeTypes())), 'O_overwrite' => $auth >= AUTH_DELETE, 'O_sectok' => getSecurityToken(), 'O_authtok' => auth_createToken()); $var = buildURLparams($opt); // output the flash uploader ?> <div id="dw__flashupload" style="display:none"> <div class="upload"><?php echo $lang['mu_intro']; ?> </div> <?php echo html_flashobject('multipleUpload.swf', '500', '190', null, $opt); ?> </div> <?php }
/** * Create output */ function render($format, &$R, $data) { if ($format == 'xhtml') { $img = DOKU_BASE . 'lib/plugins/ditaa/img.php?' . buildURLparams($data); $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; } elseif ($format == 'odt') { $src = $this->_imgfile($data); $R->_odtAddImage($src, $data['width'], $data['height'], $data['align']); return true; } return false; }
/** * Return formated data, depending on column type * * @param array $column * @param string $value * @param Doku_Renderer $R * @return string */ function _formatDataNew($column, $value, Doku_Renderer $R) { global $conf; $vals = explode("\n", $value); $outs = array(); //multivalued line from db result for pageid and wiki has only in first value the ID $storedID = ''; foreach ($vals as $val) { $val = trim($val); if ($val == '') { continue; } $type = $column['type']; if (is_array($type)) { $type = $type['type']; } switch ($type) { case 'page': $val = $this->_addPrePostFixes($column['type'], $val); $val = $this->ensureAbsoluteId($val); $outs[] = $R->internallink($val, null, null, true); break; case 'title': list($id, $title) = explode('|', $val, 2); $id = $this->_addPrePostFixes($column['type'], $id); $id = $this->ensureAbsoluteId($id); $outs[] = $R->internallink($id, $title, null, true); break; case 'pageid': list($id, $title) = explode('|', $val, 2); //use ID from first value of the multivalued line if ($title == null) { $title = $id; if (!empty($storedID)) { $id = $storedID; } } else { $storedID = $id; } $id = $this->_addPrePostFixes($column['type'], $id); $outs[] = $R->internallink($id, $title, null, true); break; case 'nspage': // no prefix/postfix here $val = ':' . $column['key'] . ":{$val}"; $outs[] = $R->internallink($val, null, null, true); break; case 'mail': list($id, $title) = explode(' ', $val, 2); $id = $this->_addPrePostFixes($column['type'], $id); if (!$title) { $title = $id; } else { $title = hsc($title); } $outs[] = $R->emaillink($id, $title, true); break; case 'url': $val = $this->_addPrePostFixes($column['type'], $val); $outs[] = $R->externallink($val, null, true); break; case 'tag': // per default use keyname as target page, but prefix on aliases if (!is_array($column['type'])) { $target = $column['key'] . ':'; } else { $target = $this->_addPrePostFixes($column['type'], ''); } $params = buildURLparams($this->_getTagUrlparam($column, $val)); $url = str_replace('/', ':', cleanID($target)) . '?' . $params; // FIXME: The title is lost when moving to $R->internallink, // but this syntax is required to support different renderers. // $title = sprintf($this->getLang('tagfilter'), hsc($val)); $outs[] = $R->internallink($url, hsc($val), true); break; case 'timestamp': $outs[] = dformat($val); break; case 'wiki': global $ID; $oldid = $ID; list($ID, $data) = explode('|', $val, 2); //use ID from first value of the multivalued line if ($data == null) { $data = $ID; $ID = $storedID; } else { $storedID = $ID; } $data = $this->_addPrePostFixes($column['type'], $data); // Trim document_{start,end}, p_{open,close} from instructions $allinstructions = p_get_instructions($data); $wraps = 1; if (isset($allinstructions[1]) && $allinstructions[1][0] == 'p_open') { $wraps++; } $instructions = array_slice($allinstructions, $wraps, -$wraps); $outs[] = p_render($R->getFormat(), $instructions, $byref_ignore); $ID = $oldid; break; default: $val = $this->_addPrePostFixes($column['type'], $val); //type '_img' or '_img<width>' if (substr($type, 0, 3) == 'img') { $width = (int) substr($type, 3); if (!$width) { $width = $this->getConf('image_width'); } list($mediaid, $title) = explode('|', $val, 2); if ($title === null) { $title = $column['key'] . ': ' . basename(str_replace(':', '/', $mediaid)); } else { $title = trim($title); } if (media_isexternal($val)) { $html = $R->externalmedia($mediaid, $title, $align = null, $width, $height = null, $cache = null, $linking = 'direct', true); } else { $html = $R->internalmedia($mediaid, $title, $align = null, $width, $height = null, $cache = null, $linking = 'direct', true); } if (strpos($html, 'mediafile') === false) { $html = str_replace('href', 'rel="lightbox" href', $html); } $outs[] = $html; } else { $outs[] = hsc($val); } } } return join(', ', $outs); }
function render($format, &$R, $data) { if ($format == 'xhtml') { $in = $this->_cachename($data, 'txt'); $gvpath = dirname($this->getConf('path')); $script = 'BEG_G { char* larr[int]; int i; if (!isAttr($,"G","layers")) return; if (isAttr($,"G","layersep")) tokens($.layers,larr,$.layersep); else tokens($.layers,larr," :\\t"); for (larr[i]) { printf("%s\\n",larr[i]); } }'; exec(sprintf("%s/gvpr %s %s", escapeshellarg($gvpath), escapeshellarg($script), escapeshellarg($in)), $out, $retval); if ($out[0] != "") { return $this->_render_layered_xhtml($format, &$R, $data, $out, $in); } $cache = $this->_imgfile($data); $size = getimagesize($cache); $img = DOKU_BASE . 'lib/plugins/graphviz/img.php?' . buildURLparams($data); $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; } elseif ($format == 'odt') { $src = $this->_imgfile($data); $R->_odtAddImage($src, $data['width'], $data['height'], $data['align']); return true; } return false; }
/** * Create output */ function render($format, &$R, $data) { if ($data['cdn'] && ($format == 'xhtml' || $format == 'odt')) { $R->doc .= '<div class=wsd wsd_style="' . $data['style'] . '" ><pre>'; $R->doc .= io_readFile($this->_cachename($data, 'txt')); $R->doc .= '</pre></div><script type="text/javascript" src="http://www.websequencediagrams.com/service.js"></script>'; return true; } elseif ($format == 'xhtml') { $img = DOKU_BASE . 'lib/plugins/seqdia/img.php?' . buildURLparams($data); $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; } elseif ($format == 'odt') { $src = $this->_imgfile($data); $R->_odtAddImage($src, $data['width'], $data['height'], $data['align']); return true; } return false; }
/** * Create output * Edited by Michael Kling for the MAP patch. * @todo ODT format doesnt support maps */ function render($format, Doku_Renderer $R, $data) { if ($format == 'xhtml') { $img = DOKU_BASE . 'lib/plugins/graphviz/img.php?' . buildURLparams($data); $mapcache = $this->_svgfile($data); $map = io_readFile($mapcache, false); if ($mapcache !== false) { $R->doc .= $map; } else { $R->doc .= '<span>Render failed</span>'; } return true; } return false; }