primo commit

This commit is contained in:
2024-12-17 17:34:10 +01:00
commit e650f8df99
16435 changed files with 2451012 additions and 0 deletions

View File

@ -0,0 +1,26 @@
<?php
/**
* @package Phoca Gallery
* @author Jan Pavelka - https://www.phoca.cz
* @copyright Copyright (C) Jan Pavelka https://www.phoca.cz
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later
* @cms Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
use Joomla\CMS\Language\Text;
class PhocaGalleryException
{
public static function renderErrorInfo ($msg, $jText = false){
if ($jText) {
return '<div class="pg-error-info">'.Text::_($msg).'</div>';
} else {
return '<div class="pg-error-info">'.$msg.'</div>';
}
}
}
?>

View File

@ -0,0 +1,73 @@
<?php
/**
* @package Phoca Gallery
* @author Jan Pavelka - https://www.phoca.cz
* @copyright Copyright (C) Jan Pavelka https://www.phoca.cz
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later
* @cms Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
class PhocaGalleryExtension
{
private static $extension = array();
private function __construct(){}
/**
* Get information about extension.
*
* @param string Extension element (com_cpanel, com_admin, ...)
* @param string Extension type (component, plugin, module, ...)
* @param string Folder type (content, editors, search, ...)
*
* @return int ( 0 ... extension not installed
* 1 ... extension installed and enabled
* 2 ... extension installed but not enabled )
*/
public static function getExtensionInfo( $element = null, $type = 'component', $folder = '' ) {
if( is_null( $element ) ) {
throw new Exception('Function Error: No element added', 500);
return false;
}
if( !array_key_exists( $element, self::$extension ) ) {
$db = Factory::getDbo();
$query = $db->getQuery(true);
//$query->select('extension_id AS "id", element AS "element", enabled');
if ($type == 'component'){
$query->select('extension_id AS id, element AS "option", params, enabled');
} else {
$query->select('extension_id AS "id", element AS "element", params, enabled');
}
$query->from('#__extensions');
$query->where('`type` = '.$db->quote($type));
if ($folder != '') {
$query->where('`folder` = '.$db->quote($folder));
}
$query->where('`element` = '.$db->quote($element));
$db->setQuery($query);
$cache = Factory::getCache('_system_phocagallery','callback');
$extensionData = $cache->get(array($db, 'loadObject'), null, $element, false);
if (isset($extensionData->enabled) && $extensionData->enabled == 1) {
self::$extension[$element] = 1;
} else if(isset($extensionData->enabled) && $extensionData->enabled == 0) {
self::$extension[$element] = 2;
} else {
self::$extension[$element] = 0;
}
}
return self::$extension[$element];
}
public final function __clone() {
throw new Exception('Function Error: Cannot clone instance of Singleton pattern', 500);
return false;
}
}
?>

View File

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

View File

@ -0,0 +1,55 @@
<?php
/**
* @package Phoca Gallery
* @author Jan Pavelka - https://www.phoca.cz
* @copyright Copyright (C) Jan Pavelka https://www.phoca.cz
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later
* @cms Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
/*
* These are advanced settings
* because not all possible settings
* can be saved in parameters (because of different limitations)
*/
class PhocaGallerySettings
{
private static $settings = array();
private function __construct(){}
public static function getAdvancedSettings( $element = null ) {
if( is_null( $element ) ) {
throw new Exception('Function Error: No element added', 500);
return false;
}
if( !array_key_exists( $element, self::$settings ) ) {
$params = array();
// =============================
$params['geozoom'] = 8;
$params['youtubeheight'] = 360;
$params['youtubewidth'] = 480;
// =============================
if (isset($params[$element])) {
self::$settings[$element] = $params[$element];
} else {
self::$settings[$element] = '';
}
}
return self::$settings[$element];
}
public final function __clone() {
throw new Exception('Function Error: Cannot clone instance of Singleton pattern', 500);
return false;
}
}
?>

View File

@ -0,0 +1,187 @@
<?php
/**
* @package Phoca Gallery
* @author Jan Pavelka - https://www.phoca.cz
* @copyright Copyright (C) Jan Pavelka https://www.phoca.cz
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later
* @cms Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\PluginHelper;
defined( '_JEXEC' ) or die( 'Restricted access' );
class PhocaGalleryUtils
{
public static function getExtInfo() {
PluginHelper::importPlugin('phocatools');
$results = Factory::getApplication()->triggerEvent('onPhocatoolsOnDisplayInfo', array('NzI5NzY5NTcxMTc='));
if (isset($results[0]) && $results[0] === true) {
return '';
}
return '<div style="display:block;color:#ccc;text-align:right;">Powered by <a href="https://www.phoca.cz/phocagallery">Phoca Gallery</a></div>';
}
public static function htmlToRgb($clr) {
if ($clr[0] == '#') {
$clr = substr($clr, 1);
}
if (strlen($clr) == 6) {
list($r, $g, $b) = array($clr[0].$clr[1],$clr[2].$clr[3],$clr[4].$clr[5]);
} else if (strlen($clr) == 3) {
list($r, $g, $b) = array($clr[0].$clr[0], $clr[1].$clr[1], $clr[2].$clr[2]);
} else {
$r = $g = $b = 255;
}
$color[0] = hexdec($r);
$color[1] = hexdec($g);
$color[2] = hexdec($b);
return $color;
}
/*
* Source: http://php.net/manual/en/function.ini-get.php
*/
public static function iniGetBool($a) {
$b = ini_get($a);
switch (strtolower($b)) {
case 'on':
case 'yes':
case 'true':
return 'assert.active' !== $a;
case 'stdout':
case 'stderr':
return 'display_errors' === $a;
Default:
return (bool) (int) $b;
}
}
public static function setQuestionmarkOrAmp($url) {
$isThereQMR = false;
$isThereQMR = preg_match("/\?/i", $url);
if ($isThereQMR) {
return '&amp;';
} else {
return '?';
}
}
public static function toArray($value = FALSE) {
if ($value == FALSE) {
return array(0 => 0);
} else if (empty($value)) {
return array(0 => 0);
} else if (is_array($value)) {
return $value;
} else {
return array(0 => $value);
}
}
public static function setMessage($new = '', $current = '') {
$message = $current;
if($new != '') {
if ($current != '') {
$message .= '<br />';
}
$message .= $new;
}
return $message;
}
public static function filterInput($string) {
if (strpos($string, '"') !== false) {
$string = str_replace(array('=', '<'), '', $string);
}
return $string;
}
public static function isURLAddress($url) {
return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url);
}
public static function isEnabledMultiboxFeature($feature) {
$app = Factory::getApplication();
$params = $app->getParams();
$enable_multibox = $params->get( 'enable_multibox', 0);
$display_multibox = $params->get( 'display_multibox', array(1,2));
if ($enable_multibox == 1 && in_array($feature,$display_multibox)) {
return true;
}
return false;
}
public static function setVars( $task = '') {
$a = array();
$app = Factory::getApplication();
$a['o'] = htmlspecialchars(strip_tags($app->input->get('option')));
$a['c'] = str_replace('com_', '', $a['o']);
$a['n'] = 'Phoca' . ucfirst(str_replace('com_phoca', '', $a['o']));
$a['l'] = strtoupper($a['o']);
$a['i'] = 'media/'.$a['o'].'/images/administrator/';
$a['ja'] = 'media/'.$a['o'].'/js/administrator/';
$a['jf'] = 'media/'.$a['o'].'/js/';
$a['s'] = 'media/'.$a['o'].'/css/administrator/'.$a['c'].'.css';
$a['task'] = $a['c'] . htmlspecialchars(strip_tags($task));
$a['tasks'] = $a['task']. 's';
return $a;
}
public static function getIntFromString($string) {
if (empty($string)) {
return 0;
}
$int = '';//$int = 0
$parts = explode(':', $string);
if (isset($parts[0])) {
$int = (int)$parts[0];
}
return $int;
}
/*
public static function getIp() {
$params = ComponentHelper::getParams('com_phocagallery');
$store_ip = $params->get( 'store_ip', 0 );
if ($store_ip == 0) {
return '';
}
$ip = false;
if(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] != getenv('SERVER_ADDR')) {
$ip = $_SERVER['REMOTE_ADDR'];
} else {
$ip = getenv('HTTP_X_FORWARDED_FOR');
}
if (!$ip) {
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}*/
}
?>