From: SourceForge.net <no...@so...> - 2004-01-21 12:30:18
|
Patches item #740183, was opened at 2003-05-19 20:19 Message generated for change (Settings changed) made by chealer You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=506848&aid=740183&group_id=64258 >Category: None >Group: None Status: Open Resolution: None Priority: 7 Submitted By: Doug Holton (doug2001) Assigned to: Nobody/Anonymous (nobody) Summary: Here is code for a download option for cached links Initial Comment: Hi, I added a link to a Word document in a wiki page. ( I know I could have just download the document myself and then uploaded it the wiki page as an attachment). But I noticed the view_cache page displays the cached file as text. I wanted to be able to download the file too. So here is code I added to tiki-view_cache.php and tiki-view_cache.tpl to add a simple "download" link, if you think it is worth adding. After this line near the bottom of tiki-view_cache.php: $info = $tikilib->get_cache($_REQUEST["cacheId"]); I added: //send raw data directly if download=yes if(isset($_REQUEST["download"])) { $download = ($_REQUEST["download"] == "yes") ? true : false; if ($download) { $filename = $info["url"]; $urlinfo = parse_url($filename); if (strlen($urlinfo["path"]) > 1) { $filename = basename($urlinfo["path"]); } header("Content-Type: application/octet-stream"); header("Content-disposition: attachment; filename=\".$filename."\\n"); echo $info["data"]; return; } } ....then the following line starts: $smarty->assign_by_ref('info',$info); ... In tiki-view_cache.tpl, after it says "This is a cached version of the page", I added this: <a class="link" href="http{if $smarty.server.HTTPS eq "on"}s{/if}://{$smarty.server.SERVER_NAME}{$smarty.server.SCRIPT_NAME}?download=yes&url={$info.url|escape:"html"}">(download)</a> ---------------------------------------------------------------------- Comment By: Dennis Daniels (dgdaniels) Date: 2003-07-15 23:24 Message: Logged In: YES user_id=403318 the code is posted, needs to be cked over by devs to see if it'll break anything... dgd ---------------------------------------------------------------------- Comment By: Dave Sanders (vulgrin) Date: 2003-07-06 13:27 Message: Logged In: YES user_id=6717 Updating this item for category / group / subject line or other data. No real change to the item, just house-keeping. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=506848&aid=740183&group_id=64258 |