Back to PhocaDownloadRoute class

Method getFileRoute

public static
getFileRoute
(mixed $id, mixed $catid = 0, mixed $idAlias = '', mixed $catidAlias = '', mixed $sectionid = 0, mixed $type = 'file', mixed $suffix = '')

Method getFileRoute - Source code

public static function getFileRoute($id, $catid = 0, $idAlias = '', $catidAlias = '', $sectionid = 0, $type = 'file', $suffix = '')
{
    // TEST SOLUTION
    $app = Factory::getApplication();
    $menu = $app->getMenu();
    $active = $menu->getActive();
    $option = $app->input->get('option', '', 'string');
    $activeId = 0;
    $notCheckId = 0;
    if (isset($active->id)) {
        $activeId = $active->id;
    }
    if ((int) $activeId > 0 && $option == 'com_phocadownload') {
        $needles = array('file' => (int) $id, 'category' => (int) $catid, 'categories' => (int) $activeId);
        $notCheckId = 1;
    } else {
        $needles = array('file' => (int) $id, 'category' => (int) $catid, 'categories' => '');
        $notCheckId = 0;
    }
    if ($idAlias != '') {
        $id = $id . ':' . $idAlias;
    }
    if ($catidAlias != '') {
        $catid = $catid . ':' . $catidAlias;
    }
    //Create the link
    switch ($type) {
        case 'play':
            $link = 'index.php?option=com_phocadownload&view=play&catid=' . $catid . '&id=' . $id . '&tmpl=component';
            break;
        case 'detail':
            $link = 'index.php?option=com_phocadownload&view=file&catid=' . $catid . '&id=' . $id . '&tmpl=component';
            break;
        case 'download':
            $link = 'index.php?option=com_phocadownload&view=category&download=' . $id . '&id=' . $catid;
            break;
        default:
            $link = 'index.php?option=com_phocadownload&view=file&catid=' . $catid . '&id=' . $id;
            break;
    }
    if ($item = PhocaDownloadRoute::_findItem($needles, $notCheckId)) {
        if (isset($item->id) && (int) $item->id > 0) {
            $link .= '&Itemid=' . $item->id;
        }
    }
    if ($suffix != '') {
        $link .= '&' . $suffix;
    }
    return $link;
}