Remository Inline Direct Download
A number of my clients use Remository within Joomla for document management. The QuickDown plugin, available from the same site, is used to insert document information within an article. While I have been very satified with Remository, I have not found that QuickDown matches my clients’ needs.
QuickDown basically creates a link to the Remository page along with a variety of document information formatted within a table. Instead, I am usually interested in having a direct download link inserted inline with the article’s content.
There are 2 files that need to be modified in order to get this working properly. One of them is the Remository core file p-classes/remositoryRepository.php. The other is the plugin file quickdown.php.
Remository core change
The function makeCheck() is the one needing changes in remositoryRepository.php. Below are the original function and the updated function.
// ORIGINAL
function makeCheck ($id, $func) {
$interface =& remositoryInterface::getInstance();
return md5($this->Time_Stamp.$interface->getCfg('absolute_path').date('md').$id.$func);
}
// MODIFIED
function makeCheck ($id, $func) {
$interface =& remositoryInterface::getInstance();
return md5($interface->getCfg('absolute_path').date('md').$id.$func);
}
Notice that the only change is the removal of a UNIX timestamp. makeCheck() is used in the creation of the direct download link creation and in its verification before allowing download. This is a bit different than the approach I would take but it is effective. If you wanted to make a permanent direct download link, you would remove all references to date or time in the obfuscated check code.
The download link created by the above modified code is good until the next day begins. Is this too long? For your situation perhaps but not for mine. Regardless, please note that the download link duration should outlive your cache.
QuickDown plugin change
Next, I wish to change the formatted output of the plugin and to have it include a proper direct download link. I have taken some shortcuts in order to make my changes to the original files easier to follow and not insert bunches of my code into the original code. All of these modifications are done to the file quickdown.php.
First, I added the makeCheck function.
function makeCheck ($id, $func) {
$absolute_path = '/my/absolute/path/remdocs';
return ( $absolute_path . date('md') . $id . $func );
}
Instead of creating a Remository instance, I simply added my absolute path to the remository documents (quick and dirty).
Next, I added a new plugin usage code {inlinedown:ID}. This completely separates my approach from the author’s and allows usage of the plugin as originally intended.
In the botQuickdown() function at line 57, I added:
$row->text = preg_replace('/{inlinedown:.+?}/', '', $row->text);
Then at line 86, I added:
if (preg_match_all('/{inlinedown:.+?}/', $content, $matches, PREG_PATTERN_ORDER)) {
//Get IDS
foreach ($matches as $fmatch) {
foreach ($fmatch as $match) {
$match = str_replace("{inlinedown:", "", $match);
$match = str_replace("}", "", $match);
$output = $this->ggis_createLink($match, $this->params);
$content = preg_replace("/{inlinedown:$match}/", $output, $content);
}
}
unset($matches);
}
Finally, I added my own create link function named ggis_createLink().
function ggis_createLink($idparam, &$param){
$inline = TRUE;
//Getting File-info from Database
$database =& JFactory::getDBO();
$id = intval($idparam);
$database->setQuery("SELECT * FROM #__downloads_files WHERE id=$id");
$filelist = $database->loadObjectList();
if ($filelist) {
$file = $filelist[0];
$url = 'index.php?option=com_remository&';
$func = 'download';
$url .= 'func='.$func;
$url .= '&id='.$idparam;
$url .= '&chk=' . $this->makeCheck($idparam,$func) . '&no_html=1';
if ($inline){
$output = '<a href="'. $url .'">';
$output .= '<img src="components/com_remository/images/download_trans.gif" border="0" align="middle">';
$output .= '<b>'. $file->filetitle .'</b> (' . $file->filetype . ' ' . $file->filesize . ')</a>';
}else{
$output = '<table>';
$output .= '<tr><td><a href="'. $url .'">';
$output .= '<img src="components/com_remository/images/download_trans.gif"border="0"> ';
$output .= '<b>'. _DOWNLOAD .' '. $file->filetitle .'</b></a></td></tr>';
$output .= '</table>';
}
}
return ($output);
}
Final result
The final result is an inline direct download link. This link shows the download image, the file title, the file type, and the file size. Depending on your styling, it should look similar to the image below.

Hopefully, you may find this modification of Remository and QuickDown useful for your purposes.







March 6th, 2011 at 6:40 pm
You can get ride of this issue by simply disabling the check:
to do this:
original:
function wrongCheck ($chk, $id, $func) {
if ($chk == $this->makeCheck($id, $func)) return false;
return true; }
modified:
function wrongCheck ($chk, $id, $func) {
if ($chk == $this->makeCheck($id, $func)) return false;
return false; }
@ file : com_remostery>p-classes>remositoryRepository.php @ligne:432
March 7th, 2011 at 1:08 am
@Haythem Boukadida
Yes, that does completely disable the check. It was not my choice to do that but instead lengthen the time the link is valid.
The changes I posted try to maintain the original author’s intent while extending functionality.