Posts Tagged ‘joomsuite’

JOOMSUITE 1.4.5: how to add SEF to file downloads [UPDATE]

Monday, October 5th, 2009

This is an update for http://blog.ciuly.com/website/joomsuite-how-to-add-sef-to-file-downloads/ which is valid for joomsuite 1.4.0

You need to edit 3 files and add url rewrite rules.
/components/com_resource/controller.php:373 (download function)

// Ciuly – file SEF
$fn = basename($res->field_value);
if (JRequest::getInt(‘timestamp’)==1){
$a = explode(‘_’, $fn, 2);
$fn = $a[1];
}
if($browser==’IE’) {
header(‘Content-Disposition: attachment; filename=”‘.$fn.'”‘);
header(‘Cache-Control: must-revalidate, post-check=0, pre-check=0’);
header(‘Pragma: public’);
} else {
header(‘Content-Disposition: attachment; filename=”‘.$fn.'”‘);
header(‘Cache-Control: no-cache, must-revalidate’);
header(‘Pragma: no-cache’);
}

./components/com_resource/controller.php:495 (download2 function, after adding above code)

// Ciuly – file SEF
$fn = basename($res->field_value);
if (JRequest::getInt(‘timestamp’)==1){
$a = explode(‘_’, $fn, 2);
$fn = $a[1];
}
if($browser==’IE’) {
header(‘Content-Disposition: attachment; filename=”‘.$fn.'”‘);
header(‘Cache-Control: must-revalidate, post-check=0, pre-check=0’);
header(‘Pragma: public’);
} else {
header(‘Content-Disposition: attachment; filename=”‘.$fn.'”‘);
header(‘Cache-Control: no-cache, must-revalidate’);
header(‘Pragma: no-cache’);
}

./components/com_resource/controllers/article.php:855 (download_attachment function)

// Ciuly – file SEF
$fn = basename($comment->attachmente);
if (JRequest::getInt(‘timestamp’)){
$a = explode(‘_’, $fn, 2);
$fn = $a[1];
}
if($browser==’IE’) {
header(‘Content-Disposition: attachment; filename=”‘.$fn.'”‘);
header(‘Cache-Control: must-revalidate, post-check=0, pre-check=0’);
header(‘Pragma: public’);
} else {
header(‘Content-Disposition: attachment; filename=”‘.$fn.'”‘);
header(‘Cache-Control: no-cache, must-revalidate’);
header(‘Pragma: no-cache’);
}

./plugins/joomsuite_content_fields/file.php:227 (onRenderFieldValue function)
if($params->get(‘show_name’))
{
// Ciuly – make it SEF
if (JROUTER_MODE_SEF)
$download = JURI::base().”download.php/$field->id/”;

$label = basename($field->field_value);
// Ciuly – remove timestamp from display
if ($params->get(‘attach’)){
$a = explode(‘_’, $label, 2);
$label = $a[1];
if (JROUTER_MODE_SEF)
$download = $download . “1/”;
else
$download = $download . “&timestamp=1”;
} else
if (JROUTER_MODE_SEF)
$download = $download . “0/”;
if (JROUTER_MODE_SEF)
$download = $download . $label;
}
else {
$label = $field->title;
}

and finally, url rewrite:
RewriteEngine on
RewriteRule ^/download.php/([0-9]+)/([0-1])/.*$ /index2.php?option=com_resource&task=download&no_html=1&file=$1&timestamp=$2

Related posts

JOOMSUITE: how to add SEF to file downloads

Sunday, August 23rd, 2009

I finally managed to finish my SEF-related hacks on joomsuite for joomla in order to add SEF url support to the filw downloads.
You need to edit 3 files and add url rewrite rules.
/components/com_resource/controller.php:335 (download function)

$fn = basename($res->field_value);
if (JRequest::getInt('timestamp')==1){
  $a = explode('_', $fn, 2);
  $fn = $a[1];
}
if($browser=='IE') {
  header('Content-Disposition: attachment; filename="'.$fn.'"');
  header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  header('Pragma: public');
} else {
  header('Content-Disposition: attachment; filename="'.$fn.'"');
  header('Cache-Control: no-cache, must-revalidate');
  header('Pragma: no-cache');
}

./components/com_resource/controller.php:450 (download2 function, after adding above code)

$fn = basename($res->field_value);
if (JRequest::getInt('timestamp')==1){
  $a = explode('_', $fn, 2);
  $fn = $a[1];
}
if($browser=='IE') {
  header('Content-Disposition: attachment; filename="'.$fn.'"');
  header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  header('Pragma: public');
} else {
  header('Content-Disposition: attachment; filename="'.$fn.'"');
  header('Cache-Control: no-cache, must-revalidate');
  header('Pragma: no-cache');
}

./components/com_resource/controllers/article.php:778 (download_attachment function)

$fn = basename($comment->attachmente);
if (JRequest::getInt('timestamp')){
  $a = explode('_', $fn, 2);
  $fn = $a[1];
}
if($browser=='IE') {
  header('Content-Disposition: attachment; filename="'.$fn.'"');
  header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  header('Pragma: public');
} else {
  header('Content-Disposition: attachment; filename="'.$fn.'"');
  header('Cache-Control: no-cache, must-revalidate');
  header('Pragma: no-cache');
}

./plugins/joomsuite_content_fields/file.php:179 (onRenderFieldValue function)

if($params->get('show_name'))
{
  // Ciuly - make it SEF
  if (JROUTER_MODE_SEF)
    $download = JURI::base()."download.php/$field->id/";

  $label = basename($field->field_value);
  // Ciuly - remove timestamp from display
  if ($params->get('attach')){
    $a = explode('_', $label, 2);
    $label = $a[1];
    if (JROUTER_MODE_SEF)
      $download = $download . "1/";
    else
      $download = $download . "×tamp=1";
  } else
    if (JROUTER_MODE_SEF)
      $download = $download . "0/";
  if (JROUTER_MODE_SEF)
    $download = $download . $label;
}
else {
  $label = $field->title;
}

and finally, url rewrite:

    RewriteEngine on
    RewriteRule ^/download.php/([0-9]+)/([0-1])/.*$ /index2.php?option=com_resource&task=download&no_html=1&file=$1×tamp=$2

Related posts