tutto cho che serve phoca

This commit is contained in:
2025-01-01 12:20:00 +01:00
parent bdb89e8575
commit c3386bb999
49 changed files with 6827 additions and 1 deletions

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,90 @@
<?php
/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Uri\Uri;
class PhocaDownloadPath
{
public static function getPathSet( $manager = '') {
$group = PhocaDownloadSettings::getManagerGroup($manager);
// Params
$paramsC = ComponentHelper::getParams( 'com_phocadownload' );
// Folder where to stored files for download
$downloadFolder = $paramsC->get( 'download_folder', 'phocadownload' );
$downloadFolderPap = $paramsC->get( 'download_folder_pap', 'phocadownloadpap' );
// Absolute path which can be outside public_html - if this will be set, download folder will be ignored
$absolutePath = $paramsC->get( 'absolute_path', '' );
// Path of preview and play
$downloadFolderPap = Path::clean($downloadFolderPap);
$path['orig_abs_pap'] = JPATH_ROOT . '/' . $downloadFolderPap;
$path['orig_abs_pap_ds'] = $path['orig_abs_pap'] . '/' ;
if ($group['f'] == 2) {
// Images
$path['orig_abs'] = JPATH_ROOT . '/' . 'images/phocadownload' ;
$path['orig_abs_ds'] = $path['orig_abs'] . '/' ;
$path['orig_abs_user_upload'] = $path['orig_abs'] . '/' . 'userupload' ;
$path['orig_abs_user_upload_pap']= $path['orig_abs_pap'] . '/' . 'userupload' ;
$path['orig_rel_ds'] = '../images/phocadownload/';
} else if ($group['f'] == 3) {
// Play and Preview
$path['orig_abs'] = $path['orig_abs_pap'];
$path['orig_abs_ds'] = $path['orig_abs_pap_ds'];
$path['orig_abs_user_upload'] = $path['orig_abs'] . '/' . 'userupload' ;
$path['orig_abs_user_upload_pap']= $path['orig_abs_pap'] . '/' . 'userupload' ;
$path['orig_rel_ds'] = '../'.str_replace('\\', '/', Path::clean($downloadFolderPap)).'/';
} else {
// Standard Path
if ($absolutePath != '') {
$downloadFolder = str_replace('\\', '/', Path::clean($absolutePath));
$path['orig_abs'] = str_replace('\\', '/', Path::clean($absolutePath));
$path['orig_abs_ds'] = Path::clean($path['orig_abs'] . '/') ;
$path['orig_abs_user_upload'] = Path::clean($path['orig_abs'] . '/' . 'userupload') ;
$path['orig_abs_user_upload_pap']= Path::clean($path['orig_abs_pap'] . '/' . 'userupload') ;
//$downloadFolderRel = str_replace('\\', '/', JPath::clean($downloadFolder));
$path['orig_rel_ds'] = '';
} else {
$downloadFolder = str_replace('\\', '/', Path::clean($downloadFolder));
$path['orig_abs'] = JPATH_ROOT . '/' . $downloadFolder ;
$path['orig_abs_ds'] = JPATH_ROOT . '/' . $downloadFolder . '/' ;
$path['orig_abs_user_upload'] = $path['orig_abs'] . '/' . 'userupload' ;
$path['orig_abs_user_upload_pap']= $path['orig_abs_pap'] . '/' . 'userupload' ;
$downloadFolderRel = str_replace('\\', '/', Path::clean($downloadFolder));
$path['orig_rel_ds'] = '../' . $downloadFolderRel .'/';
}
}
return $path;
}
public static function getPathMedia() {
$option = 'com_phocadownload';
$instance = new StdClass();
$baseFront = Uri::root(true);
$instance->media_css_abs = JPATH_ROOT . '/' . 'media'. '/' . $option . '/' . 'css' . '/';
$instance->media_img_abs = JPATH_ROOT . '/' . 'media'. '/' . $option . '/' . 'images' . '/';
$instance->media_js_abs = JPATH_ROOT . '/' . 'media'. '/' . $option . '/' . 'js' . '/';
$instance->media_css_rel = 'media/'. $option .'/css/';
$instance->media_img_rel = 'media/'. $option .'/images/';
$instance->media_js_rel = 'media/'. $option .'/js/';
$instance->media_css_rel_full = $baseFront . '/' . $instance->media_css_rel;
$instance->media_img_rel_full = $baseFront . '/' . $instance->media_img_rel;
$instance->media_js_rel_full = $baseFront . '/' . $instance->media_js_rel;
return $instance;
}
}
?>

View File

@ -0,0 +1,350 @@
<?php
/**
* @version $Id: route.php 11190 2008-10-20 00:49:55Z ian $
* @package Joomla
* @subpackage Content
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant to the
* GNU General Public License, and as distributed it includes or is derivative
* of works licensed under the GNU General Public License or other free or open
* source software licenses. See COPYRIGHT.php for copyright notices and
* details.
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;
use Joomla\CMS\Menu\AbstractMenu;
use Joomla\CMS\Session\Session;
// Component Helper
jimport('joomla.application.component.helper');
/**
* Content Component Route Helper
*
* @static
* @package Joomla
* @subpackage Content
* @since 1.5
*/
class PhocaDownloadRoute
{
public static function getCategoriesRoute() {
$needles = array(
'categories' => ''
);
$link = 'index.php?option=com_phocadownload&view=categories';
if($item = self::_findItem($needles, 1)) {
if(isset($item->query['layout'])) {
$link .= '&layout='.$item->query['layout'];
}
if (isset($item->id)) {
$link .= '&Itemid='.(int)$item->id;;
}
}
return $link;
}
public static function getCategoryRoute($catid, $catidAlias = '') {
$needles = array(
'category' => (int)$catid,
'categories' => ''
);
if ($catidAlias != '') {
$catid = $catid . ':' . $catidAlias;
}
//Create the link
$link = 'index.php?option=com_phocadownload&view=category&id='. $catid;
if($item = self::_findItem($needles)) {
if(isset($item->query['layout'])) {
$link .= '&layout='.$item->query['layout'];
}
if(isset($item->id)) {
$link .= '&Itemid='.$item->id;
}
};
return $link;
}
public static function getCategoryRouteByTag($tagId)
{
$needles = array(
'category' => '',
//'section' => (int) $sectionid,
'categories' => ''
);
$db = Factory::getDBO();
$query = 'SELECT a.id, a.title, a.link_ext, a.link_cat'
.' FROM #__phocadownload_tags AS a'
.' WHERE a.id = '.(int)$tagId;
$db->setQuery($query, 0, 1);
$tag = $db->loadObject();
/*if (!$db->query()) {
throw new Exception($db->getErrorMsg(), 500);
return false;
}*/
//Create the link
if (isset($tag->id)) {
$link = 'index.php?option=com_phocadownload&view=category&id=0:category&tagid='.(int)$tag->id;
} else {
$link = 'index.php?option=com_phocadownload&view=category&id=0:category&tagid=0';
}
if($item = self::_findItem($needles)) {
if(isset($item->query['layout'])) {
$link .= '&layout='.$item->query['layout'];
}
if(isset($item->id)) {
$link .= '&Itemid='.$item->id;
}
};
return $link;
}
public static function getFileRoute($id, $catid = 0, $idAlias = '', $catidAlias = '', $sectionid = 0, $type = 'file', $suffix = '')
{
$needles = array(
'file' => (int) $id,
'category' => (int) $catid,
'categories' => ''
);
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 = self::_findItem($needles)) {
if (isset($item->id) && ((int)$item->id > 0)) {
$link .= '&Itemid='.$item->id;
}
}
if ($suffix != '') {
$link .= '&'.$suffix;
}
return $link;
}
public static function getDownloadRoute($id, $catid, $token, $directDownload = 1)
{
$needles = array(
'download' => '',
'file' => (int) $id,
'category' => (int) $catid,
'categories' => ''
);
if ($directDownload == 1) {
$link = 'index.php?option=com_phocadownload&view=download&id='. $token.'&download=1&' . Session::getFormToken() . '=1';
} else {
$link = 'index.php?option=com_phocadownload&view=download&id='. $token;
}
if($item = self::_findItem($needles)) {
if (isset($item->id)) {
$link .= '&Itemid='.$item->id;
}
}
if ($item = PhocaDownloadRoute::_findItem($needles, 0)) {
if (isset($item->id) && ((int)$item->id > 0)) {
$link .= '&Itemid='.$item->id;
}
}
return $link;
}
public static function getFeedRoute($id, $catid = 0, $sectionid = 0, $type = 'rss')
{
$needles = array(
'categories' => '',
'category' => (int) $catid,
'feed' => $id //feed
//'section' => (int) $sectionid,
//'category' => (int) $catid /*,
//'file' => (int) $id*/
);
//Create the link
$link = 'index.php?option=com_phocadownload&view=feed&id='.$id.'&format=feed&type='.$type;
if($item = self::_findItem($needles, 1)) {
if (isset($item->id)) {
$link .= '&Itemid='.$item->id;
}
}
return $link;
}
public static function getGuestbookRoute($id, $title)
{
$needles = array(
'guestbook' => (int) $id
);
$link = 'index.php?option=com_phocaguestbook&view=guestbook&cid='.(int)$id.'&reporttitle='.strip_tags($title).'&tmpl=component';
if($item = self::_findItem($needles, 1, 'com_phocaguestbook')) {
if (isset($item->id)) {
$link .= '&Itemid='.$item->id;
}
}
return $link;
}
/*
function getSectionRoute($sectionid, $sectionidAlias = '')
{
$needles = array(
'section' => (int) $sectionid,
'sections' => ''
);
if ($sectionidAlias != '') {
$sectionid = $sectionid . ':' . $sectionidAlias;
}
//Create the link
$link = 'index.php?option=com_phocadownload&view=section&id='.$sectionid;
if($item = self::_findItem($needles)) {
if(isset($item->query['layout'])) {
$link .= '&layout='.$item->query['layout'];
}
$link .= '&Itemid='.$item->id;
}
return $link;
}
function getSectionsRoute()
{
$needles = array(
'sections' => ''
);
//Create the link
$link = 'index.php?option=com_phocadownload&view=sections';
if($item = self::_findItem($needles)) {
if(isset($item->query['layout'])) {
$link .= '&layout='.$item->query['layout'];
}
if (isset($item->id)) {
$link .= '&Itemid='.$item->id;
}
}
return $link;
}*/
protected static function _findItem($needles, $notCheckId = 0, $component = 'com_phocadownload')
{
$app = Factory::getApplication();
//$menus = $app->getMenu('site', array()); // Problems in indexer
$menus = AbstractMenu::getInstance('site');
$items = $menus->getItems('component', $component);
//$menu = $menus;//$app->getMenu();
$active = $menus->getActive();
$option = $app->input->get( 'option', '', 'string' );
// Don't check ID for specific views. e.g. categories view does not have ID
$notCheckIdArray = array('categories');
if(!$items) {
$itemId = $app->input->get('Itemid', 0, 'int');
if ($itemId > 0) {
$item = new stdClass();
$item->id = $itemId;
return $item;
}
return null;
}
$match = null;
// FIRST - test active menu link
foreach($needles as $needle => $id) {
if (isset($active->query['option']) && $active->query['option'] == $component
&& isset($active->query['view']) && $active->query['view'] == $needle
&& (in_array($needle, $notCheckIdArray) || (isset($active->query['id']) && $active->query['id'] == $id ))
) {
$match = $active;
}
}
if(isset($match)) {
return $match;
}
// SECOND - if not find in active, try to run other items
// ordered by function which calls this function - e.g. file, category, categories
// as last the categories view should be checked, it has no ID so we skip the checking
// of ID for categories view with OR: in_array($needle, $notCheckIdArray) ||
foreach($needles as $needle => $id) {
foreach($items as $item) {
if (isset($item->query['option']) && $item->query['option'] == $component
&& isset($item->query['view']) && $item->query['view'] == $needle
&& (in_array($needle, $notCheckIdArray) || (isset($item->query['id']) && $item->query['id'] == $id ))
) {
$match = $item;
}
}
if(isset($match)) {
break;
}
}
return $match;
}
}
?>

View File

@ -0,0 +1,209 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_phocadownload
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die();
use Joomla\CMS\Component\Router\Rules\MenuRules;
use Joomla\CMS\Factory;
class PhocaDownloadRouterrules extends MenuRules
{
public function preprocess(&$query) {
parent::preprocess($query);
}
protected function buildLookup($language = '*') {
parent::buildLookup($language);
}
/*
* PHOCAEDIT
*/
public function parse(&$segments, &$vars) {
// SPECIFIC CASE TAG - tag search output in category view
// 1. components/com_phocadownload/router.php getCategorySegment() - BUILD
// 2. administrator/components/com_phocadownload/libraries/phocadownload/path/routerrules.php build() - BUILD
// 3. administrator/components/com_phocadownload/libraries/phocadownload/path/routerrules.php parse() - PARSE
$app = Factory::getApplication();
$tagId = $app->input->get('tagid', 0, 'int');
if ($segments[0] == 'category' && (int)$tagId > 0){
// We are in category view but tags output
$vars['view'] = 'category';
unset($segments[0]);
}
// SPECIFIC CASE FEED (we prevent the word "feed" in URL)
$format = $app->input->get('format', '', 'string');
if ($format == 'feed') {
if ($segments[0] == 'feed'){
$vars['view'] = 'feed';
if (isset($segments[1]) && (int)($segments[1] > 0)) {
$vars['id'] = (int)$segments[1];
unset($segments[1]);
}
unset($segments[0]);
}
}
return parent::parse($segments, $vars);
}
/* EDIT of libraries/src/Component/Router/Rules/StandardRules.php build function
* Because we need to manage when categories view does not have any ID
* PHOCAEDIT
*/
public function build(&$query, &$segments) {
if (!isset($query['Itemid'], $query['view'])) {
return;
}
// Get the menu item belonging to the Itemid that has been found
$item = $this->router->menu->getItem($query['Itemid']);
if ($item === null || $item->component !== 'com_' . $this->router->getName() || !isset($item->query['view'])) {
return;
}
// PHOCAEDIT
if (!isset($item->query['id']) ){
$item->query['id'] = 0;
}
// Get menu item layout
$mLayout = isset($item->query['layout']) ? $item->query['layout'] : null;
// Get all views for this component
$views = $this->router->getViews();
// Return directly when the URL of the Itemid is identical with the URL to build
if ($item->query['view'] === $query['view']) {
$view = $views[$query['view']];
if (!$view->key) {
///unset($query['view']);
if (isset($query['layout']) && $mLayout === $query['layout']) {
unset($query['layout']);
}
return;
}
if (isset($query[$view->key]) && $item->query[$view->key] == (int) $query[$view->key]) {
///unset($query[$view->key]);
while ($view) {
///unset($query[$view->parent_key]);
$view = $view->parent;
}
/// unset($query['view']);
if (isset($query['layout']) && $mLayout === $query['layout']) {
unset($query['layout']);
}
return;
}
}
// Get the path from the view of the current URL and parse it to the menu item
$path = array_reverse($this->router->getPath($query), true);
$found = false;
foreach ($path as $element => $ids) {
$view = $views[$element];
if ($found === false && $item->query['view'] === $element) {
if ($view->nestable) {
$found = true;
} elseif ($view->children) {
$found = true;
continue;
}
}
if ($found === false) {
// Jump to the next view
continue;
}
if ($ids) {
if ($view->nestable) {
$found2 = false;
foreach (array_reverse($ids, true) as $id => $segment) {
if ($found2) {
$segments[] = str_replace(':', '-', $segment);
} elseif ((int) $item->query[$view->key] === (int) $id) {
$found2 = true;
// SPECIFIC CASE TAG - tag search output in category view
// 1. components/com_phocadownload/router.php getCategorySegment() - BUILD
// 2. administrator/components/com_phocadownload/libraries/phocadownload/path/routerrules.php build() - BUILD
// 3. administrator/components/com_phocadownload/libraries/phocadownload/path/routerrules.php parse() - PARSE
if ((int)$query['id'] == 0 && $query['view'] == 'category' && isset($query['tagid']) && (int)$query['tagid'] > 0) {
$segments[] = 'category';
}
}
}
} elseif ($ids === true) {
$segments[] = $element;
} else {
// FEED
// Specific case: feed view (we just use the "feed" in url
if (isset($query['view']) && $query['view'] == 'feed') {
// /feed/number_of_module_id
$segments[] = 'feed';
$segments[] = str_replace(':', '-', current($ids));
} else {
$segments[] = str_replace(':', '-', current($ids));
}
}
}
if ($view->parent_key) {
// Remove parent key from query
unset($query[$view->parent_key]);
}
}
if ($found) {
unset($query[$views[$query['view']]->key], $query['view']);
if (isset($query['layout']) && $mLayout === $query['layout']) {
unset($query['layout']);
}
}
/* if ($query['format'] == 'feed') {
$segments['view'] = 'feed';
}*/
}
}