function file_download_link($atts, $thing) { global $thisfile, $permlink_mode; extract(lAtts(array('filename' => '', 'id' => ''), $atts)); $from_form = false; if ($id) { $thisfile = fileDownloadFetchInfo('id = ' . intval($id)); } elseif ($filename) { $thisfile = fileDownloadFetchInfo("filename = '" . doSlash($filename) . "'"); } else { assert_file(); $from_form = true; } if ($thisfile) { $url = filedownloadurl($thisfile['id'], $thisfile['filename']); $out = $thing ? href(parse($thing), $url) : $url; // cleanup: this wasn't called from a form, // so we don't want this value remaining if (!$from_form) { $thisfile = ''; } return $out; } }
function make_download_link($id, $label = '', $filename = '') { $label = $label ? $label : gTxt('download'); $url = filedownloadurl($id, $filename); return '<a href="' . $url . '">' . $label . '</a>'; }
/** * Renders a download link. * * @param int $id The file ID * @param string $label The label * @param string $filename The filename * @return string HTML * @package File */ function make_download_link($id, $label = '', $filename = '') { if ((string) $label === '') { $label = gTxt('download'); } $url = filedownloadurl($id, $filename); // Do not use the array() form of passing $atts to href(). // Doing so breaks download links on the admin side due to // double-encoding of the ampersands. return href($label, $url, ' title = "' . gTxt('download') . '"'); }
/** * Renders a download link. * * @param int $id The file ID * @param string $label The label * @param string $filename The filename * @return string HTML * @package File */ function make_download_link($id, $label = '', $filename = '') { if ((string) $label === '') { $label = gTxt('download'); } $url = filedownloadurl($id, $filename); return href($label, $url, array('title' => gTxt('download'))); }