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 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,154 @@
<?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;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Factory;
class PhocaGalleryRenderAdmin
{
// PHOCAGALLERY SPECIFIC
public static function renderExternalLink($extLink) {
$extLinkArray = explode("|", $extLink, 4);
if (!isset($extLinkArray[0])) {$extLinkArray[0] = '';}
if (!isset($extLinkArray[1])) {$extLinkArray[1] = '';}
if (!isset($extLinkArray[2])) {$extLinkArray[2] = '_self';}
if (!isset($extLinkArray[3])) {$extLinkArray[3] = 1;}
return $extLinkArray;
}
public static function renderThumbnailCreationStatus($status = 1, $onlyImage = 0) {
switch ($status) {
case 0:
$statusData = array('disabled', 'minus-circle');
break;
case 1:
Default:
$statusData = array('enabled', 'success');
break;
}
if ($onlyImage == 1) {
//return JHtml::_('image', 'media/com_phocagallery/images/administrator/icon-16-'.$statusData[1].'.png', JText::_('COM_PHOCAGALLERY_' . $statusData[0] ) );
return '<span class="ph-info-item ph-cp-item"><i class="phi duotone icon-'.$statusData[1].'" title="'. Text::_('COM_PHOCAGALLERY_' . $statusData[0] ).'"></i></span>';
} else {
return '<span class="hasTip" title="'.Text::_('COM_PHOCAGALLERY_THUMBNAIL_CREATION_STATUS_IS')
. ' ' . Text::_('COM_PHOCAGALLERY_' . $statusData[0] ). '::'
. Text::_('COM_PHOCAGALLERY_THUMBNAIL_CREATION_STATUS_INFO').'">'
. Text::_('COM_PHOCAGALLERY_THUMBNAIL_CREATION_STATUS') . ': '
. '<span class="ph-info-item ph-cp-item"><i class="phi duotone icon-'.$statusData[1].'" title="'. Text::_('COM_PHOCAGALLERY_' . $statusData[0] ).'"></i></span></span>';
//. JHtml::_('image', 'media/com_phocagallery/images/administrator/icon-16-'.$statusData[1].'.png', JText::_('COM_PHOCAGALLERY_' . $statusData[0] ) ) . '</span>';
}
}
// ---------------------
public static function quickIconButton( $link, $image, $text, $imgUrl ) {
//$image = str_replace('icon-48-', 'icon-48-phocafont', $image);
return '<div class="thumbnails ph-icon">'
.'<a class="thumbnail ph-icon-inside" href="'.$link.'">'
.HTMLHelper::_('image', $imgUrl . $image, $text )
.'<br /><span>'.$text.'</span></a></div>'. "\n";
}
public static function getLinks($internalLinksOnly = 0) {
$app = Factory::getApplication();
$option = $app->input->get('option');
$oT = strtoupper($option);
$links = array();
switch ($option) {
case 'com_phocagallery':
$links[] = array('Phoca Gallery site', 'https://www.phoca.cz/phocagallery');
$links[] = array('Phoca Gallery documentation site', 'https://www.phoca.cz/documentation/category/2-phoca-gallery-component');
$links[] = array('Phoca Gallery download site', 'https://www.phoca.cz/download/category/66-phoca-gallery');
break;
}
$links[] = array('Phoca News', 'https://www.phoca.cz/news');
$links[] = array('Phoca Forum', 'https://www.phoca.cz/forum');
if ($internalLinksOnly == 1) {
return $links;
}
$components = array();
$components[] = array('Phoca Gallery','phocagallery', 'pg');
$components[] = array('Phoca Guestbook','phocaguestbook', 'pgb');
$components[] = array('Phoca Download','phocadownload', 'pd');
$components[] = array('Phoca Documentation','phocadocumentation', 'pdc');
$components[] = array('Phoca Favicon','phocafavicon', 'pfv');
$components[] = array('Phoca SEF','phocasef', 'psef');
$components[] = array('Phoca PDF','phocapdf', 'ppdf');
$components[] = array('Phoca Restaurant Menu','phocamenu', 'prm');
$components[] = array('Phoca Maps','phocamaps', 'pm');
$components[] = array('Phoca Font','phocafont', 'pf');
$components[] = array('Phoca Email','phocaemail', 'pe');
$components[] = array('Phoca Install','phocainstall', 'pi');
$components[] = array('Phoca Template','phocatemplate', 'pt');
$components[] = array('Phoca Panorama','phocapanorama', 'pp');
$components[] = array('Phoca Commander','phocacommander', 'pcm');
$components[] = array('Phoca Photo','phocaphoto', 'ph');
$components[] = array('Phoca Cart','phocacart', 'pc');
$banners = array();
$banners[] = array('Phoca Restaurant Menu','phocamenu', 'prm');
$banners[] = array('Phoca Cart','phocacart', 'pc');
$o = '';
$o .= '<p>&nbsp;</p>';
$o .= '<h4 style="margin-bottom:5px;">'.Text::_($oT.'_USEFUL_LINKS'). '</h4>';
$o .= '<ul>';
foreach ($links as $k => $v) {
$o .= '<li><a style="text-decoration:underline" href="'.$v[1].'" target="_blank">'.$v[0].'</a></li>';
}
$o .= '</ul>';
$o .= '<div>';
$o .= '<p>&nbsp;</p>';
$o .= '<h4 style="margin-bottom:5px;">'.Text::_($oT.'_USEFUL_TIPS'). '</h4>';
$m = mt_rand(0, 10);
if ((int)$m > 0) {
$o .= '<div>';
$num = range(0,(count($components) - 1 ));
shuffle($num);
for ($i = 0; $i<3; $i++) {
$numO = $num[$i];
$o .= '<div style="float:left;width:33%;margin:0 auto;">';
$o .= '<div><a style="text-decoration:underline;" href="https://www.phoca.cz/'.$components[$numO][1].'" target="_blank">'.HtmlHelper::_('image', 'media/'.$option.'/images/administrator/icon-box-'.$components[$numO][2].'.png', ''). '</a></div>';
$o .= '<div style="margin-top:-10px;"><small><a style="text-decoration:underline;" href="https://www.phoca.cz/'.$components[$numO][1].'" target="_blank">'.$components[$numO][0].'</a></small></div>';
$o .= '</div>';
}
$o .= '<div style="clear:both"></div>';
$o .= '</div>';
} else {
$num = range(0,(count($banners) - 1 ));
shuffle($num);
$numO = $num[0];
$o .= '<div><a href="https://www.phoca.cz/'.$banners[$numO][1].'" target="_blank">'.HtmlHelper::_('image', 'media/'.$option.'/images/administrator/b-'.$banners[$numO][2].'.png', ''). '</a></div>';
}
$o .= '<p>&nbsp;</p>';
$o .= '<h4 style="margin-bottom:5px;">'.Text::_($oT.'_PLEASE_READ'). '</h4>';
$o .= '<div><a style="text-decoration:underline" href="https://www.phoca.cz/phoca-needs-your-help/" target="_blank">'. Text::_($oT.'_PHOCA_NEEDS_YOUR_HELP'). '</a></div>';
$o .= '</div>';
return $o;
}
}

View File

@ -0,0 +1,34 @@
<?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\Session\Session;
use Phoca\Render\Adminview;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
class PhocaGalleryRenderAdminView extends AdminView
{
public $view = '';
public $viewtype = 2;
public $option = '';
public $optionLang = '';
public $compatible = false;
public $sidebar = true;
protected $document = false;
public function __construct(){
parent::__construct();
}
}
?>

View File

@ -0,0 +1,110 @@
<?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\Filesystem\File;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
// Frontend editor - button plugin
require_once JPATH_ADMINISTRATOR . '/components/com_phocagallery/libraries/autoloadPhoca.php';
use Joomla\CMS\Session\Session;
use Phoca\Render\Adminviews;
use Joomla\CMS\Factory;
class PhocaGalleryRenderAdminViews extends AdminViews
{
public $view = '';
public $viewtype = 1;
public $option = '';
public $optionLang = '';
public $tmpl = '';
public $compatible = false;
public $sidebar = true;
protected $document = false;
public function __construct(){
parent::__construct();
//$this->loadMedia();
}
public function tdImage($item, $classButton, $txtE, $class = '', $avatarAbs = '', $avatarRel = '') {
$o = '';
$o .= '<td class="'.$class.'">'. "\n";
$o .= '<div class="pg-item-box">'. "\n"
.'<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">';
/*.' <center>'. "\n"
.' <div class="phocagallery-box-file-first">'. "\n"
.' <div class="phocagallery-box-file-second">'. "\n"
.' <div class="phocagallery-box-file-third">'. "\n"
.' <center>'. "\n";*/
if ($avatarAbs != '' && $avatarRel != '') {
// AVATAR
if (File::exists($avatarAbs.$item->avatar)){
$o .= '<a class="'. $classButton.'"'
//.' title="'. $button->text.'"'
.' href="'.Uri::root(). str_replace('phoca_thumb_s_', 'phoca_thumb_l_', $avatarRel).$item->avatar.'" '
//.' rel="'. $button->options.'"'
.' data-size="640x480"'
. ' >'
.'<img src="'.Uri::root().$avatarRel.$item->avatar.'?imagesid='.md5(uniqid(time())).'" alt="'.Text::_($txtE).'" itemprop="thumbnail" />'
.'</a>';
} else {
$o .= HTMLHelper::_( 'image', '/media/com_phocagallery/images/administrator/phoca_thumb_s_no_image.gif', '');
}
} else {
// PICASA
if (isset($item->extid) && $item->extid !='') {
$resW = explode(',', $item->extw);
$resH = explode(',', $item->exth);
$correctImageRes = PhocaGalleryImage::correctSizeWithRate($resW[2], $resH[2], 50, 50);
$imgLink = $item->extl;
//$o .= '<a class="'. $button->modalname.'" title="'.$button->text.'" href="'. $imgLink .'" rel="'. $button->options.'" >'
$o .= '<a class="'. $classButton.'" href="'. $imgLink .'" data-size="640x480">'
. '<img src="'.$item->exts.'?imagesid='.md5(uniqid(time())).'" width="'.$correctImageRes['width'].'" height="'.$correctImageRes['height'].'" alt="'.Text::_($txtE).'" />'
.'</a>'. "\n";
} else if (isset ($item->fileoriginalexist) && $item->fileoriginalexist == 1) {
$imageRes = PhocaGalleryImage::getRealImageSize($item->filename, 'small');
$correctImageRes = PhocaGalleryImage::correctSizeWithRate($imageRes['w'], $imageRes['h'], 50, 50);
$imgLink = PhocaGalleryFileThumbnail::getThumbnailName($item->filename, 'large');
//$o .= '<a class="'. $button->modalname.'" title="'. $button->text.'" href="'. JUri::root(). $imgLink->rel.'" rel="'. $button->options.'" >'
$o .= '<a class="'. $classButton.'" href="'. Uri::root(). $imgLink->rel.'" data-size="640x480">'
. '<img src="'.Uri::root().$item->linkthumbnailpath.'?imagesid='.md5(uniqid(time())).'" width="'.$correctImageRes['width'].'" height="'.$correctImageRes['height'].'" alt="'.Text::_($txtE).'" itemprop="thumbnail" />'
.'</a>'. "\n";
} else {
$o .= HTMLHelper::_( 'image', 'media/com_phocagallery/images/administrator/phoca_thumb_s_no_image.gif', '');
}
}
/*$o .= ' </center>'. "\n"
.' </div>'. "\n"
.' </div>'. "\n"
.' </div>'. "\n"
.' </center>'. "\n"
.'</div></div>'. "\n";*/
$o .= '</figure></div>';
$o .= '</td>'. "\n";
return $o;
}
}
?>

View File

@ -0,0 +1,474 @@
<?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\Factory;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Filter\InputFilter;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Filesystem\File;
class PhocaGalleryRenderDetailButton
{
protected $_imgordering = array();
public $type = '';
public function __construct() {
$this->_setImageOrdering();
$this->type = '';
}
protected function _setImageOrdering() {
if (empty($this->_imgordering)) {
$app = Factory::getApplication();
$paramsC = ComponentHelper::getParams('com_phocagallery') ;
$image_ordering = $paramsC->get( 'image_ordering', 1 );
$this->_imgordering = PhocaGalleryOrdering::getOrderingString($app->getUserStateFromRequest('com_phocagallery.category.' .'imgordering', 'imgordering', $image_ordering, 'int'));
}
return true;
}
public function setType($type) {
$this->type = $type;
}
/*
* Get the next button in Gallery - in opened window
*/
public function getNext ($catid, $id, $ordering, $hrefOnly = 0) {
$app = Factory::getApplication();
$db = Factory::getDBO();
$paramsC = ComponentHelper::getParams('com_phocagallery') ;
$detailWindow = $paramsC->get( 'detail_window', 0 );
if ($detailWindow == 7) {
$tCom = '';
} else {
$tCom = '&tmpl=component';
}
$c = $this->_imgordering['column'];
$s = $this->_imgordering['sort'];
$sP = ($s == 'DESC') ? '<' : '>';
$sR = ($s == 'ASC') ? 'DESC' : 'ASC';
//Select all ids from db_gallery - we search for next_id (!!! next_id can be id without file
//in the server. If the next id has no file in the server we must go from next_id to next next_id
if ($c == 'count' || $c == 'average') {
$query = 'SELECT a.id, a.alias, c.id as catid, c.alias as catalias, a.filename as filename, b.id AS currentid,'
.' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as catslug,'
.' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug'
.' FROM #__phocagallery AS a'
.' LEFT JOIN #__phocagallery_img_votes_statistics AS ra ON ra.imgid = a.id,'
.' #__phocagallery AS b'
.' LEFT JOIN #__phocagallery_categories AS c ON c.id = b.catid'
.' LEFT JOIN #__phocagallery_img_votes_statistics AS rb ON rb.imgid = b.id'
.' WHERE a.catid = ' . (int)$catid
.' AND b.id = ' . (int)$id
.' AND ('
.' (ra.'.$c.' = rb.'.$c.' AND a.id '.$sP.' b.id) OR '
.' (CASE WHEN ra.'.$c.' IS NOT NULL AND rb.'.$c.' IS NOT NULL THEN ra.'.$c.' '.$sP.' rb.'.$c.' END) OR '
.' (CASE WHEN ra.'.$c.' IS NULL AND rb.'.$c.' IS NOT NULL THEN 0 '.$sP.' rb.'.$c.' END) OR '
.' (CASE WHEN ra.'.$c.' IS NOT NULL AND rb.'.$c.' IS NULL THEN ra.'.$c.' '.$sP.' 0 END) OR '
.' (CASE WHEN ra.'.$c.' IS NULL AND rb.'.$c.' IS NULL THEN a.id '.$sP.' b.id END) '
.')'
.' AND a.published = 1'
.' ORDER BY ra.'.$c.' '.$s.', a.id '.$s;
} else {
$query = 'SELECT a.id, a.alias, c.id as catid, c.alias as catalias, a.filename as filename, b.id AS currentid,'
.' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as catslug,'
.' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug'
.' FROM #__phocagallery AS a,'
.' #__phocagallery AS b'
.' LEFT JOIN #__phocagallery_categories AS c ON c.id = b.catid'
.' WHERE a.catid = ' . (int)$catid
.' AND b.id = ' . (int)$id
.' AND (a.'.$c.' '.$sP.' b.'.$c.' OR (a.'.$c.' = b.'.$c.' and a.id '.$sP.' b.id))'
.' AND a.published = 1'
.' ORDER BY a.'.$c.' '.$s.', a.id '.$s;
}
$db->setQuery($query);
$nextAll = $db->loadObjectList();
$class = 'pg-imgbgd';
$imgName = 'icon-next';
$idCss = '';
if ($this->type == 'multibox') {
$class = 'pg-imgbd-multibox-next';
$imgName = 'icon-next-multibox';
$idCss = ' id="phocagallerymultiboxnext" ';
}
$href = '';
$next = '<div class="'.$class.'"'.$idCss.'>';
if ($this->type == 'multibox') {
$next .= HTMLHelper::_('image', 'media/com_phocagallery/images/'.$imgName.'-grey.png', Text::_( 'COM_PHOCAGALLERY_NEXT_IMAGE' )).'</div>';
} else {
$next .= PhocaGalleryRenderFront::renderIcon('next', 'media/com_phocagallery/images/icon-next-grey.png', Text::_( 'COM_PHOCAGALLERY_NEXT_IMAGE' ), 'ph-icon-disabled').'</div>';
}
//non-active button will be displayed as Default, we will see if we find active link
foreach ($nextAll as $key => $value) {
// Is there some next id, if not end this and return grey link
if (isset($value->id) && $value->id > 0) {
// onclick="disableBackAndNext()"
//$href = JRoute::_('index.php?option=com_phocagallery&view=detail&catid='. $value->catslug.'&id='.$value->slug.$tCom.'&Itemid='. Factory::getApplication()->input->get('Itemid', 1, 'get', 'int'));
$href = Route::_(PhocaGalleryRoute::getImageRoute($value->id, $value->catid, $value->alias, $value->catalias) . $tCom);
$next = '<div class="'.$class.'"'.$idCss.'>' // because of not conflict with beez
.'<a href="'.$href.'"'
.' title="'.Text::_( 'COM_PHOCAGALLERY_NEXT_IMAGE' ).'" id="next" >';
if ($this->type == 'multibox') {
$next .= HTMLHelper::_('image', 'media/com_phocagallery/images/'.$imgName.'.png', Text::_( 'COM_PHOCAGALLERY_NEXT_IMAGE' )).'</div>';
} else {
$next .= PhocaGalleryRenderFront::renderIcon('next', 'media/com_phocagallery/images/icon-next.png', Text::_( 'COM_PHOCAGALLERY_NEXT_IMAGE' )).'</div>';
}
break;// end it, we must need not to find next ordering
} else {
$href = '';
$next = '<div class="'.$class.'"'.$idCss.'>';
if ($this->type == 'multibox') {
$next .= HTMLHelper::_('image', 'media/com_phocagallery/images/'.$imgName.'-grey.png', Text::_( 'COM_PHOCAGALLERY_NEXT_IMAGE' )).'</div>';
} else {
$next .= PhocaGalleryRenderFront::renderIcon('next', 'media/com_phocagallery/images/icon-next-grey.png', Text::_( 'COM_PHOCAGALLERY_NEXT_IMAGE' ), 'ph-icon-disabled').'</div>';
}
//.JHtml::_('image', 'media/com_phocagallery/images/'.$imgName.'-grey.png', JText::_( 'COM_PHOCAGALLERY_NEXT_IMAGE' )).'</div>';
break;// end it, we must need not to find next ordering
}
}
if ($hrefOnly == 1) {
return $href;
}
return $next;
}
/*
* Get the prev button in Gallery - in openwindow
*/
public function getPrevious ($catid, $id, $ordering) {
$app = Factory::getApplication();
$db = Factory::getDBO();
$params = $app->getParams();
$detailWindow = $params->get( 'detail_window', 0 );
if ($detailWindow == 7) {
$tCom = '';
} else {
$tCom = '&tmpl=component';
}
$c = $this->_imgordering['column'];
$s = $this->_imgordering['sort'];
$sP = ($s == 'ASC') ? '<' : '>';
$sR = ($s == 'ASC') ? 'DESC' : 'ASC';
//Select all ids from db_gallery - we search for next_id (!!! next_id can be id without file
//in the server. If the next id has no file in the server we must go from next_id to next next_id
if ($c == 'count' || $c == 'average') {
$query = 'SELECT a.id, a.alias, c.id as catid, c.alias as catalias, a.filename as filename, b.id AS currentid,'
.' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as catslug,'
.' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug'
.' FROM #__phocagallery AS a'
.' LEFT JOIN #__phocagallery_img_votes_statistics AS ra ON ra.imgid = a.id,'
.' #__phocagallery AS b'
.' LEFT JOIN #__phocagallery_categories AS c ON c.id = b.catid'
.' LEFT JOIN #__phocagallery_img_votes_statistics AS rb ON rb.imgid = b.id'
.' WHERE a.catid = ' . (int)$catid
.' AND b.id = ' . (int)$id
.' AND ('
.' (ra.'.$c.' = rb.'.$c.' AND a.id '.$sP.' b.id) OR '
.' (CASE WHEN ra.'.$c.' IS NOT NULL AND rb.'.$c.' IS NOT NULL THEN ra.'.$c.' '.$sP.' rb.'.$c.' END) OR '
.' (CASE WHEN ra.'.$c.' IS NULL AND rb.'.$c.' IS NOT NULL THEN 0 '.$sP.' rb.'.$c.' END) OR '
.' (CASE WHEN ra.'.$c.' IS NOT NULL AND rb.'.$c.' IS NULL THEN ra.'.$c.' '.$sP.' 0 END) OR '
.' (CASE WHEN ra.'.$c.' IS NULL AND rb.'.$c.' IS NULL THEN a.id '.$sP.' b.id END) '
.')'
.' AND a.published = 1'
.' ORDER BY ra.'.$c.' '.$sR.', a.id '.$sR;
} else {
$query = 'SELECT a.id, a.alias, c.id as catid, c.alias as catalias, a.filename as filename, b.id AS currentid,'
.' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as catslug,'
.' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug'
.' FROM #__phocagallery AS a,'
.' #__phocagallery AS b'
.' LEFT JOIN #__phocagallery_categories AS c ON c.id = b.catid'
.' WHERE a.catid = ' . (int)$catid
.' AND b.id = ' . (int)$id
.' AND (a.'.$c.' '.$sP.' b.'.$c.' OR (a.'.$c.' = b.'.$c.' and a.id '.$sP.' b.id))'
.' AND a.published = 1'
.' ORDER BY a.'.$c.' '.$sR.', a.id '.$sR;
}
$db->setQuery($query);
$prevAll = $db->loadObjectList();
$class = 'pg-imgbgd';
$imgName = 'icon-prev';
$idCss = '';
if ($this->type == 'multibox') {
$class = 'pg-imgbd-multibox-prev';
$imgName = 'icon-prev-multibox';
$idCss = ' id="phocagallerymultiboxprev" ';
}
$prev = '<div class="'.$class.'"'.$idCss.'>';
//.JHtml::_('image', 'media/com_phocagallery/images/'.$imgName.'-grey.png', JText::_( 'COM_PHOCAGALLERY_PREV_IMAGE' )).'</div>';
if ($this->type == 'multibox') {
$prev .= HTMLHelper::_('image', 'media/com_phocagallery/images/'.$imgName.'-grey.png', Text::_( 'COM_PHOCAGALLERY_PREV_IMAGE' )).'</div>';
} else {
$prev .= PhocaGalleryRenderFront::renderIcon('prev', 'media/com_phocagallery/images/icon-prev-grey.png', Text::_( 'COM_PHOCAGALLERY_PREV_IMAGE' ), 'ph-icon-disabled').'</div>';
}
//non-active button will be displayed as Default, we will see if we find active link
foreach ($prevAll as $key => $value) {
// Is there some next id, if not end this and return grey link
if (isset($value->id) && $value->id > 0) {
$href = Route::_(PhocaGalleryRoute::getImageRoute($value->id, $value->catid, $value->alias, $value->catalias).$tCom);
//onclick="disableBackAndPrev()"
$prev = '<div class="'.$class.'"'.$idCss.'>' // because of not conflict with beez
.'<a href="'.$href.'"'
.' title="'.Text::_( 'COM_PHOCAGALLERY_PREV_IMAGE' ).'" id="prev" >';
if ($this->type == 'multibox') {
$prev .= HTMLHelper::_('image', 'media/com_phocagallery/images/'.$imgName.'.png', Text::_( 'COM_PHOCAGALLERY_PREV_IMAGE' )).'</a></div>';
} else {
$prev .= PhocaGalleryRenderFront::renderIcon('prev', 'media/com_phocagallery/images/icon-prev.png', Text::_( 'COM_PHOCAGALLERY_PREV_IMAGE' ), '').'</a></div>';
}
break;// end it, we must need not to find next ordering
} else {
$prev = '<div class="'.$class.'"'.$idCss.'>';
if ($this->type == 'multibox') {
$prev .= HTMLHelper::_('image', 'media/com_phocagallery/images/'.$imgName.'-grey.png', Text::_( 'COM_PHOCAGALLERY_PREV_IMAGE' )).'</div>';
} else {
$prev .= PhocaGalleryRenderFront::renderIcon('prev', 'media/com_phocagallery/images/icon-prev-grey.png', Text::_( 'COM_PHOCAGALLERY_PREV_IMAGE' ), 'ph-icon-disabled').'</div>';
}
break;// end it, we must need not to find next ordering
}
}
return $prev;
}
public function getReload($catidSlug, $idSlug) {
$app = Factory::getApplication();
$params = $app->getParams();
$detailWindow = $params->get( 'detail_window', 0 );
if ($detailWindow == 7) {
$tCom = '';
} else {
$tCom = '&tmpl=component';
}
$i = explode(':', $idSlug);
$id = $i[0];
$alias = $i[1];
$j = explode(':', $catidSlug);
$catid = $j[0];
$catalias = $j[1];
$href = Route::_(PhocaGalleryRoute::getImageRoute($id, $catid, $alias, $catalias).$tCom);
$reload = '<div class="pg-imgbgd"><a href="'.$href.'" onclick="%onclickreload%" title="'.Text::_( 'COM_PHOCAGALLERY_REFRESH' ).'" >'. PhocaGalleryRenderFront::renderIcon('reload', 'media/com_phocagallery/images/icon-reload.png', Text::_( 'COM_PHOCAGALLERY_REFRESH' )).'</a></div>';
return $reload;
}
public function getClose($catidSlug, $idSlug) {
$app = Factory::getApplication();
$params = $app->getParams();
$detailWindow = $params->get( 'detail_window', 0 );
if ($detailWindow == 7 ) {
return '';
}
$onclick = 'onclick="%onclickclose%"';
if ($detailWindow == 9 || $detailWindow == 10 | $detailWindow == 13) {
//$onclick = 'onclick="window.parent.pgcbp.close();"';
return '';// Will be set in boxplus javascript
}
$i = explode(':', $idSlug);
$id = $i[0];
$alias = $i[1];
$j = explode(':', $catidSlug);
$catid = $j[0];
$catalias = $j[1];
$href = Route::_(PhocaGalleryRoute::getImageRoute($id, $catid, $alias, $catalias));
$close = '<div class="pg-imgbgd"><a href="'.$href.'" '.$onclick.' title="'.Text::_( 'COM_PHOCAGALLERY_CLOSE_WINDOW').'" >'. PhocaGalleryRenderFront::renderIcon('off', 'media/com_phocagallery/images/icon-exit.png', Text::_( 'COM_PHOCAGALLERY_CLOSE_WINDOW' )).'</a></div>';
return $close;
}
public function getCloseText($catidSlug, $idSlug) {
$app = Factory::getApplication();
$params = $app->getParams();
$detailWindow = $params->get( 'detail_window', 0 );
if ($detailWindow == 7) {
return '';
}
$onclick = 'onclick="%onclickclose%"';
if ($detailWindow == 9 || $detailWindow == 10) {
//$onclick = 'onclick="window.parent.pgcbpi.close();"';
return '';// Will be set in boxplus javascript
}
$i = explode(':', $idSlug);
$id = $i[0];
$alias = $i[1];
$j = explode(':', $catidSlug);
$catid = $j[0];
$catalias = $j[1];
$href = Route::_(PhocaGalleryRoute::getImageRoute($id, $catid, $alias, $catalias));
$close = '<a style="text-decoration:underline" href="'.$href.'" '.$onclick.' title="'.Text::_( 'COM_PHOCAGALLERY_CLOSE_WINDOW').'" >'. Text::_( 'COM_PHOCAGALLERY_CLOSE_WINDOW' ).'</a>';
return $close;
}
/*
* Get Slideshow - 1. data for javascript, 2. data for displaying buttons
*/
public function getJsSlideshow($catid, $id, $slideshow = 0, $catidSlug = '', $idSlug = '') {
jimport('joomla.filesystem.file');
phocagalleryimport('phocagallery.file.filethumbnail');
$app = Factory::getApplication();
$db = Factory::getDBO();
$params = $app->getParams();
//$image_ordering = $params->get( 'image_ordering', 1 );
//$imageOrdering = PhocaGalleryOrdering::getOrderingString($image_ordering);
$detailWindow = $params->get( 'detail_window', 0 );
if ($detailWindow == 7) {
$tCom = '';
} else {
$tCom = '&tmpl=component';
}
$i = explode(':', $idSlug);
$id = $i[0];
$alias = $i[1];
$j = explode(':', $catidSlug);
$catid = $j[0];
$catalias = $j[1];
$href = PhocaGalleryRoute::getImageRoute($id, $catid, $alias, $catalias) . $tCom;
// 1. GET DATA FOR JAVASCRIPT
$jsSlideshowData['files'] = '';
//Get filename of all photos
$query = 'SELECT a.id, a.filename, a.extl, a.description'
.' FROM #__phocagallery AS a'
.' LEFT JOIN #__phocagallery_img_votes_statistics AS r ON r.imgid = a.id'
.' WHERE a.catid='.(int) $catid
.' AND a.published = 1 AND a.approved = 1'
. $this->_imgordering['output'];
$db->setQuery($query);
$filenameAll = $db->loadObjectList();
$countImg = 0;
$endComma = ',';
if (!empty($filenameAll)) {
$countFilename = count($filenameAll);
foreach ($filenameAll as $key => $value) {
$countImg++;
if ($countImg == $countFilename) {
$endComma = '';
}
$filterTags = array();
$filterAttrs = array();
$filter = new InputFilter( $filterTags, $filterAttrs, 1, 1, 1 );
$description = $filter->clean( PhocaGalleryText::strTrimAll($value->description), 'html' );
$description = addslashes((string)$value->description);
$description = trim($description);
$description = str_replace("\n", '', $description);
$description = str_replace("\r", '', $description);
if (isset($value->extl) && $value->extl != '') {
$jsSlideshowData['files'] .= '["'. $value->extl .'", "", "", "'.$description.'"]'.$endComma."\n";
} else {
$fileThumbnail = PhocaGalleryFileThumbnail::getThumbnailName($value->filename, 'large');
$imgLink = Uri::base(true) . '/' . $fileThumbnail->rel;
if (File::exists($fileThumbnail->abs)) {
$jsSlideshowData['files'] .= '["'. $imgLink .'", "", "", "'.$description.'"]'.$endComma."\n"; ;
} else {
$fileThumbnail = Uri::base(true).'/' . "media/com_phocagallery/images/phoca_thumb_l_no_image.png";
$jsSlideshowData['files'] .= '["'.$fileThumbnail.'", "", "", ""]'.$endComma."\n";
}
}
}
}
// 2. GET DATA FOR DISPLAYING SLIDESHOW BUTTONS
//We can display slideshow option if there is more than one foto
//But in database there can be more photos - more rows but if file is in db but it doesn't exist, we don't count it
//$countImg = SQLQuery::selectOne($mdb2, "SELECT COUNT(*) FROM $db_gallery WHERE siteid=$id");
if ($countImg > 1) {
//Data from GET['COM_PHOCAGALLERY_SLIDESHOW']
if ($slideshow==1) {
$jsSlideshowData['icons'] = '<div class="pg-imgbgd">' // because of not conflict with beez
.'<a href="'.Route::_($href.'&phocaslideshow=0').'" title="'.Text::_( 'COM_PHOCAGALLERY_STOP_SLIDESHOW' ).'" >'
//.JHtml::_('image', 'media/com_phocagallery/images/icon-stop.png', JText::_( 'COM_PHOCAGALLERY_STOP_SLIDESHOW' )).'</a></div>'
.PhocaGalleryRenderFront::renderIcon('stop', 'media/com_phocagallery/images/icon-stop.png', Text::_( 'COM_PHOCAGALLERY_STOP_SLIDESHOW' )).'</a></div>'
.'</td><td align="center">'//.'&nbsp;'
//.JHtml::_('image', 'media/com_phocagallery/images/icon-play-grey.png', JText::_( 'COM_PHOCAGALLERY_START_SLIDESHOW' ));
.PhocaGalleryRenderFront::renderIcon('play', 'media/com_phocagallery/images/icon-play-grey.png', Text::_( 'COM_PHOCAGALLERY_STOP_SLIDESHOW' ), 'ph-icon-disabled');
} else {
$jsSlideshowData['icons'] = PhocaGalleryRenderFront::renderIcon('stop', 'media/com_phocagallery/images/icon-stop-grey.png', Text::_( 'COM_PHOCAGALLERY_STOP_SLIDESHOW' ), 'ph-icon-disabled')
//JHtml::_('image', 'media/com_phocagallery/images/icon-stop-grey.png', JText::_( 'COM_PHOCAGALLERY_STOP_SLIDESHOW' ))
.'</td><td align="center">'//.'&nbsp;'
.'<div class="pg-imgbgd">' // because of not conflict with beez
.'<a href="'.Route::_($href.'&phocaslideshow=1').'" title="'.Text::_( 'COM_PHOCAGALLERY_START_SLIDESHOW' ).'">'
//. JHtml::_('image', 'media/com_phocagallery/images/icon-play.png', JText::_( 'COM_PHOCAGALLERY_START_SLIDESHOW' )).'</a></div>';
.PhocaGalleryRenderFront::renderIcon('play', 'media/com_phocagallery/images/icon-play.png', Text::_( 'COM_PHOCAGALLERY_START_SLIDESHOW' )).'</a></div>';
}
} else {
$jsSlideshowData['icons'] = '';
}
return $jsSlideshowData;//files (javascript) and icons (buttons)
}
}
?>

View File

@ -0,0 +1,298 @@
<?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\HTML\HTMLHelper;
defined( '_JEXEC' ) or die( 'Restricted access' );
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Language\Text;
class PhocaGalleryRenderDetailWindow
{
public $b1;// Image
public $b2;// Zoom Icon
public $b3;// Map, Exif, ...
public $popupHeight;
public $popupWidth;
public $mbOverlayOpacity; // Modal Box
public $sbSlideshowDelay; // Shadowbox
public $sbSettings;
public $hsSlideshow; // Highslide
public $hsClass;
public $hsOutlineType;
public $hsOpacity;
public $hsCloseButton;
public $jakDescHeight; // JAK
public $jakDescWidth;
public $jakOrientation;
public $jakSlideshowDelay;
public $bpBautocenter; // boxplus
public $bpAutofit;
public $bpSlideshow;
public $bpLoop;
public $bpCaptions;
public $bpThumbs;
public $bpDuration;
public $bpTransition;
public $bpContextmenu;
public $extension;
public $jakRandName;
public $articleId;
public $backend;
public function __construct() {}
public function setButtons($method = 0, $libraries = array(), $library = array()) {
$app = Factory::getApplication();
$document = $app->getDocument();
$paramsC = ComponentHelper::getParams('com_phocagallery') ;
/*$this->b1 = new stdClass();
$this->b1->name = 'image';
$this->b1->options = '';
$this->b2 = new stdClass();
$this->b2->name = 'icon';
$this->b2->options = '';
$this->b3 = new stdClass();
$this->b3->name = 'other';
$this->b3->options = '';
$this->b3->optionsrating = '';
$path = Uri::base(true);
if ($this->backend == 1) {
$path = Uri::root(true);
}*/
switch($method) {
case 1:
//STANDARD JS POPUP
/*$this->b1->methodname = 'pg-js-nopopup-button';
$this->b1->options = "window.open(this.href,'win2','width=".$this->popupWidth.",height=".$this->popupHeight.",scrollbars=yes,menubar=no,resizable=yes'); return false;";
$this->b1->optionsrating = "window.open(this.href,'win2','width=".$this->popupWidth.",height=".$this->popupHeight.",scrollbars=yes,menubar=no,resizable=yes'); return false;";
$this->b2->methodname = $this->b1->methodname;
$this->b2->options = $this->b1->options;
$this->b3->methodname = $this->b1->methodname;
$this->b3->options = $this->b1->options;
$this->b3->optionsrating = $this->b1->optionsrating;*/
break;
case 0:
// BOOTSTRAP MODAL
/*$this->b1->name = 'image';
$this->b1->methodname = 'pg-bs-modal-button';
$this->b1->options = '';
$this->b1->optionsrating = '';
$this->b2->methodname = $this->b1->methodname;
$this->b2->options = '';
$this->b2->optionsrating= '';
$this->b3->methodname = $this->b1->methodname;
$this->b3->options = '';
$this->b3->optionsrating= '';*/
break;
case 7:
// NO POPUP
/*$this->b1->methodname = 'pg-no-popup';
$this->b2->methodname = $this->b1->methodname;
$this->b3->methodname = $this->b1->methodname;*/
break;
case 12:
// MAGNIFIC
HTMLHelper::_('jquery.framework', true);
$oLang = array(
'COM_PHOCAGALLERY_LOADING' => Text::_('COM_PHOCAGALLERY_LOADING'),
'COM_PHOCAGALLERY_CLOSE' => Text::_('COM_PHOCAGALLERY_CLOSE'),
'COM_PHOCAGALLERY_PREVIOUS' => Text::_('COM_PHOCAGALLERY_PREVIOUS'),
'COM_PHOCAGALLERY_NEXT' => Text::_('COM_PHOCAGALLERY_NEXT'),
'COM_PHOCAGALLERY_MAGNIFIC_CURR_OF_TOTAL' => Text::_('COM_PHOCAGALLERY_MAGNIFIC_CURR_OF_TOTAL'),
'COM_PHOCAGALLERY_IMAGE_NOT_LOADED' => Text::_('COM_PHOCAGALLERY_IMAGE_NOT_LOADED')
);
$document->addScriptOptions('phLangPG', $oLang);
$document->addScript(Uri::base(true).'/media/com_phocagallery/js/magnific/jquery.magnific-popup.min.js');
$document->addScript(Uri::base(true).'/media/com_phocagallery/js/magnific/magnific-initialize.js');
$document->addStyleSheet(Uri::base(true).'/media/com_phocagallery/js/magnific/magnific-popup.css');
break;
case 14:
// PHOTOSWIPE
HTMLHelper::_('jquery.framework', true);
/*$this->b1->methodname = 'pg-photoswipe-button';
$this->b1->options = 'itemprop="contentUrl"';
$this->b2->methodname = 'pg-photoswipe-button-copy';
$this->b2->options = $this->b1->options;
$this->b3->methodname = 'pg-ps-modal-button';
$this->b3->options = '';
$this->b3->optionsrating= '';*/
// If standard window, change:
// FROM: return ' rel="'.$buttonOptions.'"'; TO: return ' onclick="'.$buttonOptions.'"';
// in administrator\components\com_phocagallery\libraries\phocagallery\render\renderfront.php
// method: renderAAttributeTitle detailwindow = 14
if ( isset($libraries['pg-group-photoswipe']->value) && $libraries['pg-group-photoswipe']->value == 0 ) {
$document->addStyleSheet(Uri::base(true).'/media/com_phocagallery/js/photoswipe/css/photoswipe.css');
$document->addStyleSheet(Uri::base(true).'/media/com_phocagallery/js/photoswipe/css/default-skin/default-skin.css');
$document->addStyleSheet(Uri::base(true).'/media/com_phocagallery/js/photoswipe/css/photoswipe-style.css');
}
// LoadPhotoSwipeBottom must be loaded at the end of document
break;
default:
break;
}
}
public function getB1() {
return $this->b1;
}
public function getB2() {
return $this->b2;
}
public function getB3() {
return $this->b3;
}
public static function loadPhotoswipeBottom($forceSlideshow = 0, $forceSlideEffect = 0) {
$paramsC = ComponentHelper::getParams('com_phocagallery') ;
$photoswipe_slideshow = $paramsC->get( 'photoswipe_slideshow', 1 );
$photoswipe_slide_effect= $paramsC->get( 'photoswipe_slide_effect', 0 );
if ($forceSlideshow == 1) {
$photoswipe_slideshow = 1;
}
if ($forceSlideEffect == 1) {
$photoswipe_slide_effect = 1;
}
$o = '<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
<!-- Background of PhotoSwipe.
It\'s a separate element, as animating opacity is faster than rgba(). -->
<div class="pswp__bg"></div>
<!-- Slides wrapper with overflow:hidden. -->
<div class="pswp__scroll-wrap">
<!-- Container that holds slides. PhotoSwipe keeps only 3 slides in DOM to save memory. -->
<!-- don\'t modify these 3 pswp__item elements, data is added later on. -->
<div class="pswp__container">
<div class="pswp__item"></div>
<div class="pswp__item"></div>
<div class="pswp__item"></div>
</div>
<!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
<div class="pswp__ui pswp__ui--hidden">
<div class="pswp__top-bar">
<!-- Controls are self-explanatory. Order can be changed. -->
<div class="pswp__counter"></div>
<button class="pswp__button pswp__button--close" title="'.Text::_('COM_PHOCAGALLERY_CLOSE').'"></button>
<button class="pswp__button pswp__button--share" title="'.Text::_('COM_PHOCAGALLERY_SHARE').'"></button>
<button class="pswp__button pswp__button--fs" title="'.Text::_('COM_PHOCAGALERY_TOGGLE_FULLSCREEN').'"></button>
<button class="pswp__button pswp__button--zoom" title="'.Text::_('COM_PHOCAGALLERY_ZOOM_IN_OUT').'"></button>';
if ($photoswipe_slideshow == 1) {
$o .= '<!-- custom slideshow button: -->
<button class="pswp__button pswp__button--playpause" title="'.Text::_('COM_PHOCAGALLERY_PLAY_SLIDESHOW').'"></button>
<span id="phTxtPlaySlideshow" style="display:none">'.Text::_('COM_PHOCAGALLERY_PLAY_SLIDESHOW').'</span>
<span id="phTxtPauseSlideshow" style="display:none">'.Text::_('COM_PHOCAGALLERY_PAUSE_SLIDESHOW').'</span>';
}
$o .= '<!-- Preloader -->
<!-- element will get class pswp__preloader--active when preloader is running -->
<div class="pswp__preloader">
<div class="pswp__preloader__icn">
<div class="pswp__preloader__cut">
<div class="pswp__preloader__donut"></div>
</div>
</div>
</div>
</div>
<div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
<div class="pswp__share-tooltip"></div>
</div>
<button class="pswp__button pswp__button--arrow--left" title="'.Text::_('COM_PHOCAGALLERY_PREVIOUS').'">
</button>
<button class="pswp__button pswp__button--arrow--right" title="'.Text::_('COM_PHOCAGALLERY_NEXT').'">
</button>
<div class="pswp__caption">
<div class="pswp__caption__center"></div>
</div>
</div>
</div>
</div>';
$o .= '<script src="'.Uri::root(true).'/media/com_phocagallery/js/photoswipe/js/photoswipe.min.js"></script>'. "\n"
.'<script src="'.Uri::root(true).'/media/com_phocagallery/js/photoswipe/js/photoswipe-ui-default.min.js"></script>'. "\n";
if ($photoswipe_slide_effect == 1) {
$o .= '<script src="'.Uri::root(true).'/media/com_phocagallery/js/photoswipe/js/photoswipe-initialize-ratio.js"></script>'. "\n";
} else {
$o .= '<script src="'.Uri::root(true).'/media/com_phocagallery/js/photoswipe/js/photoswipe-initialize.js"></script>'. "\n";
}
return $o;
}
}
?>

View File

@ -0,0 +1,947 @@
<?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\Factory;
use Joomla\CMS\HTML\HTMLHelper;
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Language\Text;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Router\Route;
class PhocaGalleryRenderFront
{
public static function renderMainJs() {
$app = Factory::getApplication();
$doc = $app->getDocument();
$oVars = array();
$oLang = array();
$oParams = array();
$oLang = array(
'COM_PHOCAGALLERY_MAX_LIMIT_CHARS_REACHED' => Text::_('COM_PHOCAGALLERY_MAX_LIMIT_CHARS_REACHED'),
'COM_PHOCAGALLERY_ENTER_TITLE' => Text::_('COM_PHOCAGALLERY_ENTER_TITLE'),
'COM_PHOCAGALLERY_ENTER_COMMENT' => Text::_('COM_PHOCAGALLERY_ENTER_COMMENT')
);
$doc->addScriptOptions('phLangPG', $oLang);
//$doc->addScriptOptions('phVarsPG', $oVars);
//$doc->addScriptOptions('phParamsPG', $oParams);
HTMLHelper::_('script', 'media/com_phocagallery/js/main.js', array('version' => 'auto'));
Factory::getApplication()
->getDocument()
->getWebAssetManager()
->useScript('bootstrap.modal');
}
// hotnew
/*
public static function getOverImageIcons($date, $hits) {
$app = Factory::getApplication();
$params = $app->getParams();
$new = $params->get('display_new', 0);
$hot = $params->get('display_hot', 0);
$output = '';
if ($new == 0) {
$output .= '';
} else {
$dateAdded = strtotime($date, time());
$dateToday = time();
$dateExists = $dateToday - $dateAdded;
$dateNew = (int)$new * 24 * 60 * 60;
if ($dateExists < $dateNew) {
$output .= HTMLHelper::_('image', 'media/com_phocagallery/images/icon-new.png', '', array('class' => 'pg-img-ovr1'));
}
}
if ($hot == 0) {
$output .= '';
} else {
if ((int)$hot <= $hits) {
if ($output == '') {
$output .= HTMLHelper::_('image', 'media/com_phocagallery/images/icon-hot.png', '', array('class' => 'pg-img-ovr1'));
} else {
$output .= HTMLHelper::_('image', 'media/com_phocagallery/images/icon-hot.png', '', array('class' => 'pg-img-ovr2'));
}
}
}
return $output;
}
public static function renderCommentJS($chars) {
$tag = "<script type=\"text/javascript\">"
. "function countChars() {" . "\n"
. "var maxCount = " . $chars . ";" . "\n"
. "var pfc = document.getElementById('phocagallery-comments-form');" . "\n"
. "var charIn = pfc.phocagallerycommentseditor.value.length;" . "\n"
. "var charLeft = maxCount - charIn;" . "\n"
. "" . "\n"
. "if (charLeft < 0) {" . "\n"
. " alert('" . Text::_('COM_PHOCAGALLERY_MAX_LIMIT_CHARS_REACHED', true) . "');" . "\n"
. " pfc.phocagallerycommentseditor.value = pfc.phocagallerycommentseditor.value.substring(0, maxCount);" . "\n"
. " charIn = maxCount;" . "\n"
. " charLeft = 0;" . "\n"
. "}" . "\n"
. "pfc.phocagallerycommentscountin.value = charIn;" . "\n"
. "pfc.phocagallerycommentscountleft.value = charLeft;" . "\n"
. "}" . "\n"
. "function checkCommentsForm() {" . "\n"
. " var pfc = document.getElementById('phocagallery-comments-form');" . "\n"
. " if ( pfc.phocagallerycommentstitle.value == '' ) {" . "\n"
. " alert('" . Text::_('COM_PHOCAGALLERY_ENTER_TITLE', true) . "');" . "\n"
. " return false;" . "\n"
. " } else if ( pfc.phocagallerycommentseditor.value == '' ) {" . "\n"
. " alert('" . Text::_('COM_PHOCAGALLERY_ENTER_COMMENT', true) . "');" . "\n"
. " return false;" . "\n"
. " } else {" . "\n"
. " return true;" . "\n"
. " }" . "\n"
. "}" . "\n"
. "</script>";
return $tag;
}
*/
/*
public static function renderCategoryCSS($font_color, $background_color, $border_color, $imageBgCSS, $imageBgCSSIE, $border_color_hover, $background_color_hover, $ol_fg_color, $ol_bg_color, $ol_tf_color, $ol_cf_color, $margin_box, $padding_box, $opacity = 0.8) {
$opacityPer = (float)$opacity * 100;
$tag = "<style type=\"text/css\">\n"
. " #phocagallery .pg-name {color: $font_color ;}\n"
. " .phocagallery-box-file {background: $background_color ; border:1px solid $border_color;margin: " . $margin_box . "px;padding: " . $padding_box . "px; }\n"
. " .phocagallery-box-file-first { $imageBgCSS }\n"
. " .phocagallery-box-file:hover, .phocagallery-box-file.hover {border:1px solid $border_color_hover ; background: $background_color_hover ;}\n"
/*
." .ol-foreground { background-color: $ol_fg_color ;}\n"
." .ol-background { background-color: $ol_bg_color ;}\n"
." .ol-textfont { font-family: Arial, sans-serif; font-size: 10px; color: $ol_tf_color ;}"
." .ol-captionfont {font-family: Arial, sans-serif; font-size: 12px; color: $ol_cf_color ; font-weight: bold;}"*//*
. ".bgPhocaClass{
background:" . $ol_bg_color . ";
filter:alpha(opacity=" . $opacityPer . ");
opacity: " . $opacity . ";
-moz-opacity:" . $opacity . ";
z-index:1000;
}
.fgPhocaClass{
background:" . $ol_fg_color . ";
filter:alpha(opacity=100);
opacity: 1;
-moz-opacity:1;
z-index:1000;
}
.fontPhocaClass{
color:" . $ol_tf_color . ";
z-index:1001;
}
.capfontPhocaClass, .capfontclosePhocaClass{
color:" . $ol_cf_color . ";
font-weight:bold;
z-index:1001;
}"
. " </style>\n"
. '<!--[if lt IE 8]>' . "\n"
. '<style type="text/css">' . "\n"
. " .phocagallery-box-file-first { $imageBgCSSIE }\n"
. ' </style>' . "\n" . '<![endif]-->';
return $tag;
}
public static function renderIeHover() {
$tag = '<!--[if lt IE 7]>' . "\n" . '<style type="text/css">' . "\n"
. '.phocagallery-box-file{' . "\n"
. ' background-color: expression(isNaN(this.js)?(this.js=1, '
. 'this.onmouseover=new Function("this.className+=\' hover\';"), ' . "\n"
. 'this.onmouseout=new Function("this.className=this.className.replace(\' hover\',\'\');")):false););
}' . "\n"
. ' </style>' . "\n" . '<![endif]-->';
return $tag;
}
public static function renderPicLens($categoryId) {
$tag = "<link id=\"phocagallerypiclens\" rel=\"alternate\" href=\""
. Uri::base(true) . "/images/phocagallery/"
. $categoryId . ".rss\" type=\"application/rss+xml\" title=\"\" />"
. "<script type=\"text/javascript\" src=\"http://lite.piclens.com/current/piclens.js\"></script>"
. "<style type=\"text/css\">\n"
. " .mbf-item { display: none; }\n"
. " #phocagallery .mbf-item { display: none; }\n"
. " </style>\n";
return $tag;
}*/
public static function renderOnUploadJS() {
$tag = "<script type=\"text/javascript\"> \n"
. "function OnUploadSubmitUserPG() { \n"
. "document.getElementById('loading-label-user').style.display='block'; \n"
. "return true; \n"
. "} \n"
. "function OnUploadSubmitPG(idLoad) { \n"
. " if ( document.getElementById('filter_catid_image').value < 1 ) {" . "\n"
. " alert('" . Text::_('COM_PHOCAGALLERY_PLEASE_SELECT_CATEGORY', true) . "');" . "\n"
. " return false;" . "\n"
. "} \n"
. "document.getElementById(idLoad).style.display='block'; \n"
. "return true; \n"
. "} \n"
. "</script>";
return $tag;
}
public static function renderOnUploadCategoryJS() {
$tag = "<script type=\"text/javascript\"> \n"
. "function OnUploadSubmitCategoryPG(idLoad) { \n"
. "document.getElementById(idLoad).style.display='block'; \n"
. "return true; \n"
. "} \n"
. "</script>";
return $tag;
}
public static function renderDescriptionUploadJS($chars) {
$tag = "<script type=\"text/javascript\"> \n"
//. "function OnUploadSubmit() { \n"
//. "document.getElementById('loading-label').style.display='block'; \n"
//. "return true; \n"
//. "} \n"
. "function countCharsUpload(id) {" . "\n"
. "var maxCount = " . $chars . ";" . "\n"
. "var pfu = document.getElementById(id);" . "\n"
. "var charIn = pfu.phocagalleryuploaddescription.value.length;" . "\n"
. "var charLeft = maxCount - charIn;" . "\n"
. "" . "\n"
. "if (charLeft < 0) {" . "\n"
. " alert('" . Text::_('COM_PHOCAGALLERY_MAX_LIMIT_CHARS_REACHED',true) . "');" . "\n"
. " pfu.phocagalleryuploaddescription.value = pfu.phocagalleryuploaddescription.value.substring(0, maxCount);" . "\n"
. " charIn = maxCount;" . "\n"
. " charLeft = 0;" . "\n"
. "}" . "\n"
. "pfu.phocagalleryuploadcountin.value = charIn;" . "\n"
. "pfu.phocagalleryuploadcountleft.value = charLeft;" . "\n"
. "}" . "\n"
. "</script>";
return $tag;
}
public static function renderDescriptionCreateCatJS($chars) {
$tag = "<script type=\"text/javascript\"> \n"
. "function countCharsCreateCat() {" . "\n"
. "var maxCount = " . $chars . ";" . "\n"
. "var pfcc = document.getElementById('phocagallery-create-cat-form');" . "\n"
. "var charIn = pfcc.phocagallerycreatecatdescription.value.length;" . "\n"
. "var charLeft = maxCount - charIn;" . "\n"
. "" . "\n"
. "if (charLeft < 0) {" . "\n"
. " alert('" . Text::_('COM_PHOCAGALLERY_MAX_LIMIT_CHARS_REACHED', true) . "');" . "\n"
. " pfcc.phocagallerycreatecatdescription.value = pfcc.phocagallerycreatecatdescription.value.substring(0, maxCount);" . "\n"
. " charIn = maxCount;" . "\n"
. " charLeft = 0;" . "\n"
. "}" . "\n"
. "pfcc.phocagallerycreatecatcountin.value = charIn;" . "\n"
. "pfcc.phocagallerycreatecatcountleft.value = charLeft;" . "\n"
. "}" . "\n"
. "function checkCreateCatForm() {" . "\n"
. " var pfcc = document.getElementById('phocagallery-create-cat-form');" . "\n"
. " if ( pfcc.categoryname.value == '' ) {" . "\n"
. " alert('" . Text::_('COM_PHOCAGALLERY_ENTER_TITLE', true) . "');" . "\n"
. " return false;" . "\n"
//." } else if ( pfcc.phocagallerycreatecatdescription.value == '' ) {". "\n"
//." alert('". JText::_( 'COM_PHOCAGALLERY_ENTER_DESCRIPTION' )."');". "\n"
//." return false;" . "\n"
. " } else {" . "\n"
. " return true;" . "\n"
. " }" . "\n"
. "}" . "\n"
. "</script>";
return $tag;
}
public static function renderDescriptionCreateSubCatJS($chars) {
$tag = "<script type=\"text/javascript\"> \n"
. "function countCharsCreateSubCat() {" . "\n"
. "var maxCount = " . $chars . ";" . "\n"
. "var pfcc = document.getElementById('phocagallery-create-subcat-form');" . "\n"
. "var charIn = pfcc.phocagallerycreatesubcatdescription.value.length;" . "\n"
. "var charLeft = maxCount - charIn;" . "\n"
. "" . "\n"
. "if (charLeft < 0) {" . "\n"
. " alert('" . Text::_('COM_PHOCAGALLERY_MAX_LIMIT_CHARS_REACHED', true) . "');" . "\n"
. " pfcc.phocagallerycreatesubcatdescription.value = pfcc.phocagallerycreatesubcatdescription.value.substring(0, maxCount);" . "\n"
. " charIn = maxCount;" . "\n"
. " charLeft = 0;" . "\n"
. "}" . "\n"
. "pfcc.phocagallerycreatesubcatcountin.value = charIn;" . "\n"
. "pfcc.phocagallerycreatesubcatcountleft.value = charLeft;" . "\n"
. "}" . "\n"
. "function checkCreateSubCatForm() {" . "\n"
. " var pfcc = document.getElementById('phocagallery-create-subcat-form');" . "\n"
. " if ( pfcc.subcategoryname.value == '' ) {" . "\n"
. " alert('" . Text::_('COM_PHOCAGALLERY_ENTER_TITLE', true) . "');" . "\n"
. " return false;" . "\n"
//." } else if ( pfcc.phocagallerycreatecatdescription.value == '' ) {". "\n"
//." alert('". JText::_( 'COM_PHOCAGALLERY_ENTER_DESCRIPTION' )."');". "\n"
//." return false;" . "\n"
. " } else if ( document.getElementById('filter_catid_subcat').value < 1 ) {" . "\n"
. " alert('" . Text::_('COM_PHOCAGALLERY_PLEASE_SELECT_CATEGORY', true) . "');" . "\n"
. " return false;" . "\n"
. " } else {" . "\n"
. " return true;" . "\n"
. " }" . "\n"
. "}" . "\n"
. "</script>";
return $tag;
}
public static function renderHighslideJSAll() {
$tag = '<script type="text/javascript">'
. '//<![CDATA[' . "\n"
. ' hs.graphicsDir = \'' . Uri::base(true) . '/media/com_phocagallery/js/highslide/graphics/\';'
. '//]]>' . "\n"
. '</script>' . "\n";
return $tag;
}
/**
* Method to get the Javascript for switching images
* @param string $waitImage Image which will be displayed as while loading
* @return string Switch image javascript
*/
public static function switchImage($waitImage) {
$js = "\t" . '<script language="javascript" type="text/javascript">' . "\n" . 'var pcid = 0;' . "\n"
. 'var waitImage = new Image();' . "\n"
. 'waitImage.src = \'' . $waitImage . '\';' . "\n";
/*
if ((int)$customWidth > 0) {
$js .= 'waitImage.width = '.$customWidth.';' . "\n";
}
if ((int)$customHeight > 0) {
$js .= 'waitImage.height = '.$customHeight.';' . "\n";
}*/
$js .= 'function PhocaGallerySwitchImage(imageElementId, imageSrcUrl, width, height)' . "\n"
. '{ ' . "\n"
. "\t" . 'var imageElement = document.getElementById(imageElementId);'
. "\t" . 'var imageElement2 = document.getElementById(imageElementId);'
. "\t" . 'if (imageElement && imageElement.src)' . "\n"
. "\t" . '{' . "\n"
. "\t" . "\t" . 'imageElement.src = \'\';' . "\n"
. "\t" . '}' . "\n"
. "\t" . 'if (imageElement2 && imageElement2.src)' . "\n"
. "\t" . "\t" . 'imageElement2.src = imageSrcUrl;' . "\n"
. "\t" . "\t" . 'if (width > 0) {imageElement2.width = width;}' . "\n"
. "\t" . "\t" . 'if (height > 0) {imageElement2.height = height;}' . "\n"
. '}' . "\n"
. 'function _PhocaGalleryVoid(){}' . "\n"
. '</script>' . "\n";
return $js;
}
public static function userTabOrdering() {
$js = "\t" . '<script language="javascript" type="text/javascript">' . "\n"
. 'function tableOrdering( order, dir, task )' . "\n"
. '{ ' . "\n"
. "\t" . 'if (task == "subcategory") {' . "\n"
. "\t" . "\t" . 'var form = document.phocagallerysubcatform;' . "\n"
. "\t" . 'form.filter_order_subcat.value = order;' . "\n"
. "\t" . 'form.filter_order_Dir_subcat.value = dir;' . "\n"
. "\t" . 'document.phocagallerysubcatform.submit();' . "\n"
. "\t" . '} else {' . "\n"
. "\t" . "\t" . 'var form = document.phocagalleryimageform;' . "\n"
. "\t" . 'form.filter_order_image.value = order;' . "\n"
. "\t" . 'form.filter_order_Dir_image.value = dir;' . "\n"
. "\t" . 'document.phocagalleryimageform.submit();' . "\n"
. "\t" . '}' . "\n"
. '}' . "\n"
. '</script>' . "\n";
return $js;
}
public static function saveOrderUserJS() {
$js = '<script language="javascript" type="text/javascript">' . "\n"
. 'function saveordersubcat(task){' . "\n"
. "\t" . 'document.phocagallerysubcatform.task.value=\'saveordersubcat\';' . "\n"
. "\t" . 'document.phocagallerysubcatform.submit();' . "\n"
. '}'
. 'function saveorderimage(task){' . "\n"
. "\t" . 'document.phocagalleryimageform.task.value=\'saveorderimage\';' . "\n"
. "\t" . 'document.phocagalleryimageform.submit();' . "\n"
. '}'
. '</script>' . "\n";
return $js;
}
public static function getAltValue($altValue = 0, $title = '', $description = '', $metaDesc = '') {
$output = '';
switch ($altValue) {
case 1:
$output = $title;
break;
case 2:
$output = strip_tags($description);
break;
case 3:
$output = $title;
if ($description != '') {
$output .= ' - ' . strip_tags($description);
}
break;
case 4:
$output = strip_tags($metaDesc);
break;
case 5:
if ($title != '') {
$output = $title;
} else if ($description != '') {
$output = strip_tags($description);
} else {
$output = strip_tags($metaDesc);
}
break;
case 6:
if ($description != '') {
$output = strip_tags($description);
} else if ($title != '') {
$output = $title;
} else {
$output = strip_tags($metaDesc);
}
break;
case 7:
if ($description != '') {
$output = strip_tags($description);
} else if ($metaDesc != '') {
$output = strip_tags($metaDesc);
} else {
$output = $title;
}
break;
case 8:
if ($metaDesc != '') {
$output = strip_tags($metaDesc);
} else if ($title != '') {
$output = $title;
} else {
$output = strip_tags($description);
}
break;
case 9:
if ($metaDesc != '') {
$output = strip_tags($metaDesc);
} else if ($description != '') {
$output = strip_tags($description);
} else {
$output = $title;
}
break;
case 0:
Default:
$output = '';
break;
}
//return htmlspecialchars( addslashes($output));
return htmlspecialchars($output);
}
public static function renderCloseReloadDetail($detailWindow, $type = 0) {
$o = array();
if ($detailWindow == 1) {
$output['detailwindowclose'] = 'window.close();';
$output['detailwindowreload'] = 'window.location.reload(true);';
$closeLink = '<div><a href="javascript:void(0);" onclick="' . $output['detailwindowclose'] . '" >' . Text::_('COM_PHOCAGALLERY_CLOSE_WINDOW') . '</a></div>';
// Highslide
} else if ($detailWindow == 4 || $detailWindow == 5) {
$output['detailwindowclose'] = 'return false;';
$output['detailwindowreload'] = 'window.location.reload(true);';
$closeLink = '<div><a href="javascript:void(0);" onclick="' . $output['detailwindowclose'] . '" >' . Text::_('COM_PHOCAGALLERY_CLOSE_WINDOW') . '</a></div>';
// No Popup
} else if ($detailWindow == 7) {
$output['detailwindowclose'] = '';
$output['detailwindowreload'] = '';
// Should not happen as it should be reloaded to login page
$closeLink = '<div><a href="' . Uri::base(true) . '" >' . Text::_('COM_PHOCAGALLERY_MAIN_SITE') . '</a></div>';
// Magnific iframe
} else if ($detailWindow == 11) {
$output['detailwindowclose'] = '';
$output['detailwindowreload'] = '';
$closeLink = '<div><a href="javascript:void(0);" class="mfp-close" >' . Text::_('COM_PHOCAGALLERY_CLOSE_WINDOW') . '</a></div>';
// Modal Box
} else {
//$this->t['detailwindowclose'] = 'window.parent.document.getElementById(\'sbox-window\').close();';
$output['detailwindowclose'] = 'window.parent.SqueezeBox.close();';
$output['detailwindowreload'] = 'window.location.reload(true);';
$closeLink = '<div><a href="javascript:void(0);" onclick="' . $output['detailwindowclose'] . '" >' . Text::_('COM_PHOCAGALLERY_CLOSE_WINDOW') . '</a></div>';
}
$o[] = '<div style="font-family:sans-serif">';
if ($type == 0) {
$o[] = '<div>' . Text::_('COM_PHOCAGALLERY_NOT_AUTHORISED_ACTION') . ' ' . Text::_('COM_PHOCAGALLERY_PLEASE_LOGIN') . '.</div>';
$o[] = '<div>&nbsp;</div>';
}
$o[] = $closeLink;
$o[] = '</div>';
$output['html'] = implode('', $o);
return $output;
}
public static function renderInfo() {
return '<div style="text-align: center; color: rgb(211, 211, 211);">Powe'
. 'red by <a href="http://www.ph'
. 'oca.cz" style="text-decoration: none;" target="_blank" title="Phoc'
. 'a.cz">Phoca</a> <a href="https://www.phoca.cz/phocaga'
. 'llery" style="text-decoration: none;" target="_blank" title="Phoca Gal'
. 'lery">Gall'
. 'ery</a></div>';
}
public static function renderFeedIcon($type = 'categories', $paramsIcons = true, $catid = 0, $catidAlias = '') {
$paramsC = ComponentHelper::getParams('com_phocagallery');
$df = $paramsC->get('display_feed', 1);
if ($type == 'categories' && $df != 1 && $df != 2) {
return '';
}
if ($type == 'category' && $df != 1 && $df != 3) {
return '';
}
$url = PhocaGalleryRoute::getFeedRoute($type, $catid, $catidAlias);
if ($paramsIcons) {
//$text = HTMLHelper::_('image', 'media/com_phocagallery/images/icon-feed.png', JText::_('COM_PHOCAGALLERY_RSS'));
$text = PhocaGalleryRenderFront::renderIcon('feed', 'media/com_phocagallery/images/icon-feed.png', Text::_('COM_PHOCAGALLERY_RSS'));
} else {
$text = Text::_('COM_PHOCAGALLERY_RSS');
}
$output = '<a href="' . Route::_($url) . '" title="' . Text::_('COM_PHOCAGALLERY_RSS') . '">' . $text . '</a>';
return $output;
}
/*
function correctRender() {
if (class_exists('plgSystemRedact')) {
echo "Phoca Gallery doesn't work in case Redact plugin is enabled. Please disable this plugin to run Phoca Gallery";exit;
$db =Factory::getDBO();
$query = 'SELECT a.params AS params'
.' FROM #__plugins AS a'
.' WHERE a.element = \'redact\''
.' AND a.folder = \'system\''
.' AND a.published = 1';
$db->setQuery($query, 0, 1);
$params = $db->loadObject();
if(isset($params->params) && $params->params != '') {
$params->params = str_replace('phoca.cz', 'phoca_cz', $params->params);
$params->params = str_replace('phoca\.cz', 'phoca_cz', $params->params);
if ($params->params != '') {
$query = 'UPDATE #__plugins'
.' SET params = \''.$params->params.'\''
.' WHERE element = \'redact\''
.' AND folder = \'system\'';
$db->setQuery($query);
}
}
}
if (class_exists('plgSystemReReplacer')) {
echo "Phoca Gallery doesn't work in case ReReplacer plugin is enabled. Please disable this plugin to run Phoca Gallery";exit;
/*$db =JFactory::getDBO();
$query = 'SELECT a.id, a.search'
.' FROM #__rereplacer AS a'
.' WHERE (a.search LIKE \'%phoca.cz%\''
.' OR a.search LIKE \'%phoca\\\\\\\\.cz%\')'
.' AND a.published = 1';
$db->setQuery($query);
$search = $db->loadObjectList();
if(isset($search) && count($search)) {
foreach ($search as $value) {
if (isset($value->search) && $value->search != '' && isset($value->id) && $value->id > 0) {
$value->search = str_replace('phoca.cz', 'phoca_cz', $value->search);
$value->search = str_replace('phoca\.cz', 'phoca_cz', $value->search);
if ($value->search != '') {
$query = 'UPDATE #__rereplacer'
.' SET search = \''.$value->search.'\''
.' WHERE id = '.(int)$value->id;
$db->setQuery($query);
}
}
}
}
}
}*/
public static function renderAAttribute($detailWindow, $buttonOptions, $lingOrig, $hSOnClick, $hsOnClick2, $linkNr, $catAlias) {
if ($detailWindow == 1) {
return ' onclick="' . $buttonOptions . '"';
} else if ($detailWindow == 4 || $detailWindow == 5) {
$hSOC = str_replace('[phocahsfullimg]', $lingOrig, $hSOnClick);
return ' onclick="' . $hSOC . '"';
} else if ($detailWindow == 6) {
return ' onclick="gjaks.show(' . $linkNr . '); return false;"';
} else if ($detailWindow == 7) {
return '';
} else if ($detailWindow == 8) {
return ' rel="lightbox-' . $catAlias . '" ';
} else if ($detailWindow == 14) {
return $buttonOptions;
} else {
return ' rel="' . $buttonOptions . '"';
}
return '';
}
public static function renderAAttributeTitle($detailWindow, $buttonOptions, $lingOrig, $hsOnClick, $hsOnClick2, $linkNr, $catAlias) {
if ($detailWindow == 1) {
return ' onclick="' . $buttonOptions . '"';
} else if ($detailWindow == 2) {
return ' rel="' . $buttonOptions . '"';
} else if ($detailWindow == 4) {
return ' onclick="' . $hsOnClick . '"';
} else if ($detailWindow == 5) {
return ' onclick="' . $hsOnClick2 . '"';
} else if ($detailWindow == 6) {
return ' onclick="gjaks.show(' . $linkNr . '); return false;"';
} else if ($detailWindow == 7) {
return '';
} else if ($detailWindow == 8) {
return ' rel="lightbox-' . $catAlias . '2" ';
} else if ($detailWindow == 14) {
return ' rel="' . $buttonOptions . '"';
} else {
return ' rel="' . $buttonOptions . '"';
}
return '';
}
public static function renderAAttributeStat($detailWindow, $buttonOptions, $lingOrig, $hSOnClick, $hsOnClick2, $linkNr, $catAlias, $suffix) {
if ($detailWindow == 1) {
return ' onclick="' . $buttonOptions . '"';
} else if ($detailWindow == 2) {
return ' rel="' . $buttonOptions . '"';
} else if ($detailWindow == 4) {
return ' onclick="' . $hSOnClick . '"';
} else if ($detailWindow == 5) {
return ' onclick="' . $hsOnClick2 . '"';
} else if ($detailWindow == 8) {
return ' rel="lightbox-' . $catAlias . '-' . $suffix . '" ';
} else if ($detailWindow == 14) {
return ' ' . $buttonOptions;
} else {
return ' rel="' . $buttonOptions . '"';
}
return '';
}
public static function renderAAttributeOther($detailWindow, $buttonOptionsOther, $hSOnClick, $hSOnClick2) {
if ($detailWindow == 1) {
return ' onclick="' . $buttonOptionsOther . '"';
} else if ($detailWindow == 4) {
return ' onclick="' . $hSOnClick . '"';
} else if ($detailWindow == 5) {
return ' onclick="' . $hSOnClick2 . '"';
} else if ($detailWindow == 7) {
return '';
} else if ($detailWindow == 14) {
return ' rel="' . $buttonOptionsOther . '"';
} else {
return ' rel="' . $buttonOptionsOther . '"';
}
return '';
}
/*public static function renderASwitch($switchW, $switchH, $switchFixedSize, $extWSwitch, $extHSwitch, $extL, $linkThumbPath) {
if ($extL != '') {
// Picasa
if ((int)$switchW > 0 && (int)$switchH > 0 && $switchFixedSize == 1) {
// Custom Size
return ' onmouseover="PhocaGallerySwitchImage(\'PhocaGalleryobjectPicture\', \'' . $extL . '\', ' . $switchW . ', ' . $switchH . ');" ';
} else {
// Picasa Size
$correctImageResL = PhocaGalleryPicasa::correctSizeWithRate($extWSwitch, $extHSwitch, $switchW, $switchH);
return ' onmouseover="PhocaGallerySwitchImage(\'PhocaGalleryobjectPicture\', \'' . $extL . '\', ' . $correctImageResL['width'] . ', ' . $correctImageResL['height'] . ');" ';
// onmouseout="PhocaGallerySwitchImage(\'PhocaGalleryobjectPicture\', \''.$extL.'\');"
}
} else {
$switchImg = str_replace('phoca_thumb_m_', 'phoca_thumb_l_', Uri::base(true) . '/' . $linkThumbPath);
if ((int)$switchW > 0 && (int)$switchH > 0 && $switchFixedSize == 1) {
return ' onmouseover="PhocaGallerySwitchImage(\'PhocaGalleryobjectPicture\', \'' . $switchImg . '\', ' . $switchW . ', ' . $switchH . ');" ';
} else {
return ' onmouseover="PhocaGallerySwitchImage(\'PhocaGalleryobjectPicture\', \'' . $switchImg . '\');" ';
// onmouseout="PhocaGallerySwitchImage(\'PhocaGalleryobjectPicture\', \''.$switchImg.'\');"
}
}
return '';
}*/
public static function renderImageClass($image) {
$isFolder = strpos($image, 'com_phocagallery/assets/images/icon-folder');
$isUp = strpos($image, 'com_phocagallery/assets/images/icon-up');
if ($isFolder !== false) {
return 'pg-cat-folder';
} else if ($isUp !== false) {
return 'pg-cat-up';
} else {
return 'pg-cat-image';
}
}
public static function displayCustomCSS($customCss) {
if ($customCss != '') {
$customCss = str_replace('background: url(images/', 'background: url(' . Uri::base(true) . '/media/com_phocagallery/images/', $customCss);
$document = Factory::getDocument();
$document->addCustomTag("\n <style type=\"text/css\"> \n"
. strip_tags($customCss)
. "\n </style> \n");
}
}
public static function renderAllCSS($noBootStrap = 0) {
$app = Factory::getApplication();
$itemid = $app->input->get('Itemid', 0, 'int');
$db = Factory::getDBO();
$query = 'SELECT a.filename as filename, a.type as type, a.menulink as menulink'
. ' FROM #__phocagallery_styles AS a'
. ' WHERE a.published = 1'
. ' ORDER BY a.type, a.ordering ASC';
$db->setQuery($query);
$filenames = $db->loadObjectList();
$wa = $app->getDocument()->getWebAssetManager();
if (!empty($filenames)) {
foreach ($filenames as $fk => $fv) {
if ($noBootStrap == 1) {
$pos = strpos($fv->filename, 'bootstrap');
if ($pos === false) {
} else {
continue;
}
}
$path = PhocaGalleryFile::getCSSPath($fv->type, 1);
if ($fv->menulink != '' && (int)$fv->menulink > 1) {
$menuLinks = explode(',', $fv->menulink);
$isIncluded = in_array((int)$itemid, $menuLinks);
if ($isIncluded) {
//HTMLHelper::stylesheet($path . $fv->filename);
// HTMLHelper::_('stylesheet', $path . $fv->filename , array('version' => 'auto'));
$wa->registerAndUseStyle('com_phocagallery.'.str_replace('.', '-', $fv->filename), $path . $fv->filename);
}
} else {
//HTMLHelper::stylesheet($path . $fv->filename);
//HTMLHelper::_('stylesheet', $path . $fv->filename, array('version' => 'auto'));
$wa->registerAndUseStyle('com_phocagallery.'.str_replace('.', '-', $fv->filename), $path . $fv->filename);
}
}
}
}
public static function renderIcon($type, $img, $alt, $class = '', $attributes = '') {
//return HTMLHelper::_('image', $img, $alt);
$paramsC = ComponentHelper::getParams('com_phocagallery');
$bootstrap_icons = $paramsC->get('bootstrap_icons', 0);
if ($bootstrap_icons == 0) {
return HTMLHelper::_('image', $img, $alt, $attributes);
}
$i = '';
if ($bootstrap_icons == 1) {
$icon = array();
$icon['view'] = 'zoom-in';
$icon['download'] = 'download-alt';
$icon['geo'] = 'globe';
$icon['bold'] = 'bold';
$icon['italic'] = 'italic';
$icon['underline'] = 'text-color';
$icon['camera'] = 'camera';
$icon['comment'] = 'comment';
$icon['comment-a'] = 'comment'; //ph-icon-animated
$icon['comment-fb'] = 'comment'; //ph-icon-fb
$icon['cart'] = 'shopping-cart';
$icon['extlink1'] = 'share';
$icon['extlinkk2'] = 'share';
$icon['trash'] = 'trash';
$icon['publish'] = 'ok';
$icon['unpublish'] = 'remove';
$icon['viewed'] = 'modal-window';
$icon['calendar'] = 'calendar';
$icon['vote'] = 'star';
$icon['statistics'] = 'stats';
$icon['category'] = 'folder-close';
$icon['subcategory'] = 'folder-open';
$icon['upload'] = 'upload';
$icon['upload-ytb'] = 'upload';
$icon['upload-multiple'] = 'upload';
$icon['upload-java'] = 'upload';
$icon['user'] = 'user';
$icon['icon-up-images'] = 'arrow-left';
$icon['icon-up'] = 'arrow-up';
$icon['minus-sign'] = 'minus-sign';
$icon['next'] = 'forward';
$icon['prev'] = 'backward';
$icon['reload'] = 'repeat';
$icon['play'] = 'play';
$icon['stop'] = 'stop';
$icon['pause'] = 'pause';
$icon['off'] = 'off';
$icon['image'] = 'picture';
$icon['save'] = 'floppy-disk';
$icon['feed'] = 'bullhorn';
$icon['remove'] = 'remove';
$icon['search'] = 'zoom-in';
$icon['lock'] = 'lock';
if (isset($icon[$type])) {
return '<span class="ph-icon-' . $type . ' glyphicon glyphicon-' . $icon[$type] . ' ' . $class . '"></span>';
} else {
if ($img != '') {
return HTMLHelper::_('image', $img, $alt, $attributes);
}
}
// NOT glyphicon
// smile, sad, lol, confused, wink, cooliris
// Classes
// ph-icon-animated, ph-icon-fb, icon-up-images, ph-icon-disabled
} else if ($bootstrap_icons == 2) {
$icon = array();
$icon['view'] = 'search';
$icon['download'] = 'download';
$icon['geo'] = 'globe';
$icon['bold'] = 'bold';
$icon['italic'] = 'italic';
$icon['underline'] = 'underline';
$icon['camera'] = 'camera';
$icon['comment'] = 'comment';
$icon['comment-a'] = 'comment'; //ph-icon-animated
$icon['comment-fb'] = 'comment'; //ph-icon-fb
$icon['cart'] = 'shopping-cart';
$icon['extlink1'] = 'share';
$icon['extlinkk2'] = 'share';
$icon['trash'] = 'trash';
$icon['publish'] = 'check-circle';
$icon['unpublish'] = 'times-circle';
$icon['viewed'] = 'window-maximize';
$icon['calendar'] = 'calendar';
$icon['vote'] = 'star';
$icon['statistics'] = 'chart-bar';
$icon['category'] = 'folder';
$icon['subcategory'] = 'folder-open';
$icon['upload'] = 'upload';
$icon['upload-ytb'] = 'upload';
$icon['upload-multiple'] = 'upload';
$icon['upload-java'] = 'upload';
$icon['user'] = 'user';
$icon['icon-up-images'] = 'arrow-left';
$icon['icon-up'] = 'arrow-up';
$icon['minus-sign'] = 'minus-circle';
$icon['next'] = 'forward';
$icon['prev'] = 'backward';
$icon['reload'] = 'sync';
$icon['play'] = 'play';
$icon['stop'] = 'stop';
$icon['pause'] = 'pause';
$icon['off'] = 'power-off';
$icon['image'] = 'image';
$icon['save'] = 'save';
$icon['feed'] = 'rss';
$icon['remove'] = 'times-circle';
$icon['search'] = 'search';
$icon['lock'] = 'lock';
if (isset($icon[$type])) {
return '<span class="ph-icon-' . $type . ' fa fa5 fa-' . $icon[$type] . ' ' . $class . '"></span>';
} else {
if ($img != '') {
return HTMLHelper::_('image', $img, $alt, $attributes);
}
}
}
}
}
?>

View File

@ -0,0 +1,47 @@
<?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\Filesystem\Folder;
use Joomla\CMS\Installer\Installer;
jimport('joomla.filesystem.folder');
class PhocaGalleryRenderInfo
{
public static function getPhocaVersion() {
$folder = JPATH_ADMINISTRATOR . '/' . 'components/com_phocagallery';
if (Folder::exists($folder)) {
$xmlFilesInDir = Folder::files($folder, '.xml$');
} else {
$folder = JPATH_SITE . '/components/com_phocagallery';
if (Folder::exists($folder)) {
$xmlFilesInDir = Folder::files($folder, '.xml$');
} else {
$xmlFilesInDir = null;
}
}
$xml_items = array();
if (!empty($xmlFilesInDir)) {
foreach ($xmlFilesInDir as $xmlfile) {
if ($data = Installer::parseXMLInstallFile($folder . '/' . $xmlfile)) {
foreach ($data as $key => $value) {
$xml_items[$key] = $value;
}
}
}
}
if (isset($xml_items['version']) && $xml_items['version'] != '') {
return $xml_items['version'];
} else {
return '';
}
}
}
?>

View File

@ -0,0 +1,399 @@
<?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\Component\ComponentHelper;
use Joomla\CMS\Uri\Uri;
/* Google Maps Version 3 */
class PhocaGalleryRenderMap
{
var $_id = 'phocaMap';
var $_map = 'mapPhocaMap';
var $_latlng = 'phocaLatLng';
var $_options = 'phocaOptions';
var $_tst = 'tstPhocaMap';
var $_tstint = 'tstIntPhocaMap';
public function __construct() {
}
public function loadApi() {
$paramsC = ComponentHelper::getParams('com_phocagallery');
$key = $paramsC->get( 'maps_api_key', '' );
$ssl = $paramsC->get( 'maps_api_ssl', 1 );
if ($ssl) {
$h = 'https://';
} else {
$h = 'http://';
}
if ($key) {
$k = '&key='.PhocaGalleryText::filterValue($key, 'text');
} else {
$k = '';
}
return '<script async defer src="'.$h.'maps.googleapis.com/maps/api/js?callback=initMap'.$k.'" type="text/javascript"></script>';
}
public function createMap($id, $map, $latlng, $options, $tst, $tstint) {
$this->_id = $id;
$this->_map = $map;
$this->_latlng = $latlng;
$this->_options = $options;
$this->_tst = $tst;
$this->_tstint = $tstint;
$js = "\n" . 'var '.$this->_tst.' = document.getElementById(\''.$this->_id.'\');'."\n"
.'var '.$this->_tstint.';'."\n"
.'var '.$this->_map.';'."\n";
return $js;
}
public function setMap() {
return 'var '.$this->_map.' = new google.maps.Map(document.getElementById(\''.$this->_id.'\'), '.$this->_options.');'."\n";
}
public function setLatLng($latitude, $longitude) {
return 'var '.$this->_latlng.' = new google.maps.LatLng('.PhocaGalleryText::filterValue($latitude, 'number2') .', '. PhocaGalleryText::filterValue($longitude, 'number2') .');'."\n";
}
public function startOptions() {
return 'var '.$this->_options.' = {'."\n";
}
public function endOptions (){
return '};'."\n";
}
// Options
public function setZoomOpt($zoom) {
return 'zoom: '.(int)$zoom;
}
public function setCenterOpt() {
return 'center: '.$this->_latlng;
}
public function setTypeControlOpt( $typeControl = 1 ) {
$output = '';
if ($typeControl == 0) {
$output = 'mapTypeControl: false';
} else {
switch($typeControl) {
case 2:
$type = 'HORIZONTAL_BAR';
break;
case 3:
$type = 'DROPDOWN_MENU';
break;
Default:
case 1:
$type = 'DEFAULT';
break;
}
$output = 'mapTypeControl: true,'."\n"
.'mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.'.$type.'}';
}
return $output;
}
public function setNavigationControlOpt( $navControl = 1) {
$output = '';
if ($navControl == 0) {
$output = 'navigationControl: false';
} else {
switch($navControl) {
case 2:
$type = 'SMALL';
break;
case 3:
$type = 'ZOOM_PAN';
break;
case 4:
$type = 'ANDROID';
break;
Default:
case 1:
$type = 'DEFAULT';
break;
}
$output = 'navigationControl: true,'."\n"
.'navigationControlOptions: {style: google.maps.NavigationControlStyle.'.$type.'}';
}
return $output;
}
public function setScaleControlOpt( $scaleControl = 0) {
$output = '';
if ($scaleControl == 0) {
$output = 'scaleControl: false';
} else {
$output = 'scaleControl: true';
}
return $output;
}
public function setScrollWheelOpt($enable = 1) {
if ($enable == 1) {
return 'scrollwheel: true';
} else {
return 'scrollwheel: false';
}
}
public function setDisableDoubleClickZoomOpt($disable = 0) {
if ($disable == 1) {
return 'disableDoubleClickZoom: true';
} else {
return 'disableDoubleClickZoom: false';
}
}
public function setMapTypeOpt( $mapType = 0 ) {
$output = '';
switch($mapType) {
case 1:
$type = 'SATELLITE';
break;
case 2:
$type = 'HYBRID';
break;
case 3:
$type = 'TERRAIN';
break;
Default:
case 0:
$type = 'ROADMAP';
break;
}
$output = 'mapTypeId: google.maps.MapTypeId.'.$type;
return $output;
}
public function setMarker($id, $title, $description, $latitude, $longitude, $icon = 0, $text = '' ) {
jimport('joomla.filter.output');
phocagalleryimport('phocagallery.text.text');
$output = '';
if ($text == '') {
if ($title != ''){
$text .= '<h1>' . PhocaGalleryText::filterValue($title, 'text') . '</h1>';
}
if ($description != '') {
$text .= '<div>'. PhocaGalleryText::strTrimAll(PhocaGalleryText::filterValue($description, 'text')).'</div>';
}
}
$output .= 'var phocaPoint'.$id.' = new google.maps.LatLng('. PhocaGalleryText::filterValue($latitude, 'number2').', ' .PhocaGalleryText::filterValue($longitude, 'number2').');'."\n";
$output .= 'var markerPhocaMarker'.$id.' = new google.maps.Marker({title:"'.PhocaGalleryText::filterValue($title, 'text').'"';
if ($icon == 1) {
$output .= ', icon:phocaImage';
$output .= ', shadow:phocaImageShadow';
$output .= ', shape:phocaImageShape';
}
$output .= ', position: phocaPoint'.$id;
$output .= ', map: '.$this->_map;
$output .= '});'."\n";
$output .= 'var infoPhocaWindow'.$id.' = new google.maps.InfoWindow({'."\n"
.' content: \''.$text.'\''."\n"
.'});'."\n";
$output .= 'google.maps.event.addListener(markerPhocaMarker'.$id.', \'click\', function() {'."\n"
.' infoPhocaWindow'.$id.'.open('.$this->_map.', markerPhocaMarker'.$id.' );'."\n"
.' });'."\n";
return $output;
}
public function setMarkerIcon($icon) {
$output['icon'] = 0;
$output['js'] = '';
switch ($icon) {
case 1:
$imagePath = Uri::base(true).'/media/com_phocagallery/images/mapicons/yellow/';
$js ='var phocaImage = new google.maps.MarkerImage(\''.$imagePath.'image.png\','."\n";
$js.='new google.maps.Size(26,30),'."\n";
$js.='new google.maps.Point(0,0),'."\n";
$js.='new google.maps.Point(0,30));'."\n";
$js.='var phocaImageShadow = new google.maps.MarkerImage(\''.$imagePath.'shadow.png\','."\n";
$js.='new google.maps.Size(41,30),'."\n";
$js.='new google.maps.Point(0,0),'."\n";
$js.='new google.maps.Point(0,30));'."\n";
$js.='var phocaImageShape = {'."\n";
$js.='coord: [18,1,19,2,21,3,23,4,24,5,24,6,24,7,24,8,23,9,23,10,22,11,22,12,21,13,20,14,20,15,19,16,19,17,18,18,17,19,18,20,20,21,22,22,22,23,22,24,22,25,18,26,15,27,12,28,8,29,4,29,4,28,3,27,3,26,3,25,3,24,3,23,2,22,2,21,2,20,2,19,2,18,1,17,1,16,1,15,1,14,1,13,1,12,1,11,9,10,10,9,10,8,11,7,11,6,12,5,12,4,13,3,14,2,14,1],'."\n";
$js.='type: \'poly\''."\n";
$js.=' };'."\n";
$output['icon'] = 1;
$output['js'] = $js;
break;
Default:
$output['icon'] = 0;
$output['js'] = '';// if Default Icon should be displayed, no Icon should be created
break;
}
return $output;
}
public function setInitializeF() {
/* google.load("maps", "3.x", {"other_params":"sensor=false"}); */
$js = 'function initMap() {'."\n"
.' '.$this->_tst.'.setAttribute("oldValue",0);'."\n"
.' '.$this->_tst.'.setAttribute("refreshMap",0);'."\n"
.' '.$this->_tstint.' = setInterval("CheckPhocaMap()",500);'."\n"
.'}'."\n";
//.'google.setOnLoadCallback(initMap);'."\n";
return $js;
}
public function setListener() {
$js = 'google.maps.event.addDomListener('.$this->_tst.', \'DOMMouseScroll\', CancelEventPhocaMap);'."\n"
.'google.maps.event.addDomListener('.$this->_tst.', \'mousewheel\', CancelEventPhocaMap);';
return $js;
}
public function checkMapF() {
$js ='function CheckPhocaMap() {'."\n"
.' if ('.$this->_tst.') {'."\n"
.' if ('.$this->_tst.'.offsetWidth != '.$this->_tst.'.getAttribute("oldValue")) {'."\n"
.' '.$this->_tst.'.setAttribute("oldValue",'.$this->_tst.'.offsetWidth);'."\n"
.' if ('.$this->_tst.'.getAttribute("refreshMap")==0) {'."\n"
.' if ('.$this->_tst.'.offsetWidth > 0) {'."\n"
.' clearInterval('.$this->_tstint.');'."\n"
.' getPhocaMap();'."\n"
.' '.$this->_tst.'.setAttribute("refreshMap", 1);'."\n"
.' } '."\n"
.' }'."\n"
.' }'."\n"
.' }'."\n"
.'}'."\n";
return $js;
}
public function cancelEventF() {
$js ='function CancelEventPhocaMap(event) { '."\n"
.' var e = event; '."\n"
.' if (typeof e.preventDefault == \'function\') e.preventDefault(); '."\n"
.' if (typeof e.stopPropagation == \'function\') e.stopPropagation(); '."\n"
.' if (window.event) { '."\n"
.' window.event.cancelBubble = true; /* for IE */'."\n"
.' window.event.returnValue = false; /* for IE */'."\n"
.' } '."\n"
.'}'."\n";
return $js;
}
public function startMapF() {
$js = 'function getPhocaMap(){'."\n"
.' if ('.$this->_tst.'.offsetWidth > 0) {'."\n";
return $js;
}
public function endMapF() {
$js = ' }'."\n"
.'}'."\n";
return $js;
}
public function exportZoom($zoom, $value = '', $jForm = '') {
$js ='var phocaStartZoom = '.(int)$zoom.';'."\n"
.'var phocaZoom = null;'."\n"
.'google.maps.event.addListener('.$this->_map.', "zoom_changed", function(phocaStartZoom, phocaZoom) {'."\n"
.'phocaZoom = '.$this->_map.'.getZoom();'."\n";
if ($value != '') {
$js .= ' '.$value.'.value = phocaZoom;'."\n";
} else if ($jForm != '') {
$js .= ' if (window.parent) window.parent.'.$jForm.'(phocaZoom);'."\n";
}
$js .= '});'."\n";
return $js;
}
public function exportMarker($id, $latitude, $longitude, $valueLat = '', $valueLng = '', $jFormLat = '', $jFormLng = '') {
$js = 'var phocaPoint'.$id.' = new google.maps.LatLng('. PhocaGalleryText::filterValue($latitude, 'number2').', ' .PhocaGalleryText::filterValue($longitude, 'number2').');'."\n";
$js .= 'var markerPhocaMarker'.$id.' = new google.maps.Marker({'."\n"
.' position: phocaPoint'.$id.','."\n"
.' map: '.$this->_map.','."\n"
.' draggable: true'."\n"
.'});'."\n";
$js .= 'var infoPhocaWindow'.$id.' = new google.maps.InfoWindow({'."\n"
.' content: markerPhocaMarker'.$id.'.getPosition().toUrlValue(6)'."\n"
.'});'."\n";
// Events
$js .= 'google.maps.event.addListener(markerPhocaMarker'.$id.', \'dragend\', function() {'."\n"
.'var phocaPointTmp = markerPhocaMarker'.$id.'.getPosition();'."\n"
.'markerPhocaMarker'.$id.'.setPosition(phocaPointTmp);'."\n"
.'closeMarkerInfo'.$id.'();'."\n"
.'exportPoint'.$id.'(phocaPointTmp);'."\n"
.'});'."\n";
// The only one place which needs to be edited to work with more markers
// Comment it for working with more markers
// Or add new behaviour to work with adding new marker to the map
$js .= 'google.maps.event.addListener('.$this->_map.', \'click\', function(event) {'."\n"
.'var phocaPointTmp2 = event.latLng;'."\n"
.'markerPhocaMarker'.$id.'.setPosition(phocaPointTmp2);'."\n"
.'closeMarkerInfo'.$id.'();'."\n"
.'exportPoint'.$id.'(phocaPointTmp2);'."\n"
.'});'."\n";
$js .= 'google.maps.event.addListener(markerPhocaMarker'.$id.', \'click\', function(event) {'."\n"
.'openMarkerInfo'.$id.'();'."\n"
.'});'."\n";
$js .= 'function openMarkerInfo'.$id.'() {'."\n"
.'infoPhocaWindow'.$id.'.content = markerPhocaMarker'.$id.'.getPosition().toUrlValue(6);'."\n"
.'infoPhocaWindow'.$id.'.open('.$this->_map.', markerPhocaMarker'.$id.' );'."\n"
.'} '."\n";
$js .= 'function closeMarkerInfo'.$id.'() {'."\n"
.'infoPhocaWindow'.$id.'.close('.$this->_map.', markerPhocaMarker'.$id.' );'."\n"
.'} '."\n";
$js .= 'function exportPoint'.$id.'(phocaPointTmp3) {'."\n";
if ($valueLat != '') {
$js .= ' '.PhocaGalleryText::filterValue($valueLat).'.value = phocaPointTmp3.lat();'."\n";
}
if ($valueLng != '') {
$js .= ' '.PhocaGalleryText::filterValue($valueLng).'.value = phocaPointTmp3.lng();'."\n";
}
if ($jFormLat != '') {
$js .= ' if (window.parent) window.parent.'.PhocaGalleryText::filterValue($jFormLat).'(phocaPointTmp3.lat());'."\n";
}
if ($jFormLng != '') {
$js .= ' if (window.parent) window.parent.'.PhocaGalleryText::filterValue($jFormLng).'(phocaPointTmp3.lng());'."\n";
}
$js .= '}'."\n";
return $js;
}
}
?>

View File

@ -0,0 +1,627 @@
<?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
*/
use Joomla\CMS\HTML\HTMLHelper;
defined( '_JEXEC' ) or die( 'Restricted access' );
use Joomla\CMS\Factory;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Form\Form;
class PhocaGalleryRenderMaposm
{
protected $name = 'phocaGalleryMap';
protected $id = '';
private $output = array();
public $router = '';
public $maprouterapikey = '';
public $routerserviceurl = '';
public $routerprofile = '';
public $thunderforestmaptype = '';
public $osmmaptype = '';
public $currentposition = '';
public $fullscreen = '';
public $search = '';
public $zoomwheel = '';
public $zoomcontrol = '';
public $easyprint = '';
/*var $_map = 'mapPhocaMap';
var $_latlng = 'phocaLatLng';
var $_options = 'phocaOptions';
var $_tst = 'tstPhocaMap';
var $_tstint = 'tstIntPhocaMap';
var $_marker = FALSE;
var $_window = FALSE;
var $_dirdisplay = FALSE;
var $_dirservice = FALSE;
var $_geocoder = FALSE;
var $_iconArray = array();*/
function __construct($id = '') {
$app = Factory::getApplication();
$paramsC = ComponentHelper::getParams('com_phocagallery');
$this->router = $paramsC->get( 'osm_router', 0 );//
$this->maprouterapikey = $paramsC->get( 'osm_map_router_api_key', '' );
$this->routerserviceurl = $paramsC->get( 'osm_router_routerserviceurl', '' );//
$this->routerprofile = $paramsC->get( 'osm_router_profile', '' );//
$this->thunderforestmaptype = $paramsC->get( 'thunderforest_map_type', '' );
$this->osmmaptype = $paramsC->get( 'osm_map_type', '' );
$this->currentposition = $paramsC->get( 'osm_current_position', 1 ); //
$this->fullscreen = $paramsC->get( 'osm_full_screen',1 );//
$this->search = $paramsC->get( 'osm_search', 0 );//
$this->zoomwheel = $paramsC->get( 'osm_zoom_wheel', 1);//
$this->zoomcontrol = $paramsC->get( 'osm_zoom_control', 1 );//
$this->easyprint = $paramsC->get( 'osm_easyprint', 0 );//
$this->id = $id;
// if ($app->isClient('administrator')) {
$this->fullscreen = 1;
$this->search = 1;
$this->zoomwheel = 1;
$this->zoomcontrol = 1;
$this->currentposition = 1;
// }
}
function loadAPI() {
$document = Factory::getDocument();
$document->addScript(Uri::root(true) . '/media/com_phocagallery/js/leaflet/leaflet.js');
$document->addStyleSheet(Uri::root(true) . '/media/com_phocagallery/js/leaflet/leaflet.css');
$document->addScript(Uri::root(true) . '/media/com_phocagallery/js/leaflet-awesome/leaflet.awesome-markers.js');
$document->addStyleSheet(Uri::root(true) . '/media/com_phocagallery/js/leaflet-awesome/leaflet.awesome-markers.css');
$document->addScript(Uri::root(true) . '/media/com_phocagallery/js/leaflet-fullscreen/Leaflet.fullscreen.js');
$document->addStyleSheet(Uri::root(true) . '/media/com_phocagallery/js/leaflet-fullscreen/leaflet.fullscreen.css');
$document->addScript(Uri::root(true) . '/media/com_phocagallery/js/leaflet-control-locate/L.Control.Locate.min.js');
$document->addStyleSheet(Uri::root(true) . '/media/com_phocagallery/js/leaflet-control-locate/L.Control.Locate.css');
$document->addStyleSheet(Uri::root(true) . '/media/com_phocagallery/js/leaflet-control-locate/font-awesome.min.css');
$document->addScript(Uri::root(true) . '/media/com_phocagallery/js/leaflet-omnivore/leaflet-omnivore.js');
$document->addScript(Uri::root(true) . '/media/com_phocagallery/js/leaflet-search/leaflet-search.min.js');
$document->addStyleSheet(Uri::root(true) . '/media/com_phocagallery/js/leaflet-search/leaflet-search.css');
if ($this->router == 1) {
$document->addScript(Uri::root(true) . '/media/com_phocagallery/js/leaflet-routing-machine/leaflet-routing-machine.min.js');
$document->addStyleSheet(Uri::root(true) . '/media/com_phocagallery/js/leaflet-routing-machine/leaflet-routing-machine.css');
$document->addStyleSheet(Uri::root(true) . '/media/com_phocagallery/js/leaflet-geocoder/Control.Geocoder.css');
$document->addScript(Uri::root(true) . '/media/com_phocagallery/js/leaflet-geocoder/Control.Geocoder.js');
}
if ($this->easyprint == 1) {
$document->addScript(Uri::root(true) . '/media/com_phocagallery/js/leaflet-easyprint/bundle.js');
}
}
function loadCoordinatesJS() {
$document = Factory::getDocument();
$document->addScript(Uri::root(true).'/media/com_phocagallery/js/administrator/coordinates.js');
}
function createMap($lat, $lng, $zoom) {
$app = Factory::getApplication();
$opt = array();
if ($this->zoomwheel == 0) {
$opt[] = 'scrollWheelZoom: false,';
}
if ($this->zoomcontrol == 0) {
$opt[] = 'zoomControl: false,';
}
$options = '{' . implode("\n", $opt) . '}';
$o = array();
$o[]= 'var map'.$this->name.$this->id.' = L.map("'.$this->name.$this->id.'", '.$options.').setView(['.PhocaGalleryText::filterValue($lat, 'number2').', '.PhocaGalleryText::filterValue($lng, 'number2').'], '.(int)$zoom.');';
$o[]= 'jQuery(\'.phTabs ul li a\').click(function(){ setTimeout(function() { map'.$this->name.$this->id.'.invalidateSize(); }, 0);});';
$this->output[] = implode("\n", $o);
return true;
}
function setMapType() {
$app = Factory::getApplication();
// Possible new parameters
$thunderForestMapType = $this->thunderforestmaptype;
$thunderForestKey = $this->maprouterapikey;
$mapBoxKey = $this->maprouterapikey;
$type = $this->osmmaptype;
$o = array();
if ($type === "osm_de") {
$o[] = 'L.tileLayer(\'https://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png\', {';
$o[] = ' maxZoom: 18,';
$o[] = ' attribution: \'&copy; <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>\'';
$o[] = '}).addTo(map'.$this->name.$this->id.');';
} else if ($type === "osm_bw") {
//$o[] = 'L.tileLayer(\'http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png\', {';
$o[] = 'L.tileLayer(\'https://tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png\', {';
$o[] = ' maxZoom: 18,';
$o[] = ' attribution: \'&copy; <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>\'';
$o[] = '}).addTo(map'.$this->name.$this->id.');';
} else if ($type === 'thunderforest') {
if ($thunderForestKey == '') {
$app->enqueueMessage(Text::_('COM_PHOCAGALLERY_ERROR_API_KEY_NOT_SET'));
return false;
}
if ($thunderForestMapType == '') {
$app->enqueueMessage(Text::_('COM_PHOCAGALLERY_ERROR_MAP_TYPE_NOT_SET'));
return false;
}
$o[] = 'L.tileLayer(\'https://{s}.tile.thunderforest.com/'.PhocaGalleryText::filterValue($thunderForestMapType, 'url').'/{z}/{x}/{y}.png?apikey={apikey}\', {';
$o[] = ' maxZoom: 22,';
$o[] = ' apikey: '.PhocaGalleryText::filterValue($thunderForestKey).',';
$o[] = ' attribution: \'&copy; <a href="https://www.thunderforest.com/" target="_blank">Thunderforest</a>, &copy; <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>\'';
$o[] = '}).addTo(map'.$this->name.$this->id.');';
} else if ($type === 'mapbox') {
if ($mapBoxKey == '') {
$app->enqueueMessage(Text::_('COM_PHOCAGALLERY_ERROR_API_KEY_NOT_SET'));
return false;
}
$o[] = 'L.tileLayer(\'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token='.PhocaGalleryText::filterValue($mapBoxKey, 'url').'\', {';
$o[] = ' maxZoom: 18,';
$o[] = ' attribution: \'Map data &copy; <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors, \' + ';
$o[] = ' \'<a href="https://creativecommons.org/licenses/by-sa/2.0/" target="_blank" target="_blank">CC-BY-SA</a>, \' + ';
$o[] = ' \'Imagery © <a href="https://mapbox.com" target="_blank">Mapbox</a>\',';
$o[] = ' id: \'mapbox.streets\'';
$o[] = '}).addTo(map'.$this->name.$this->id.');';
} else if ($type === 'opentopomap') {
$o[] = 'L.tileLayer(\'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png\', {';
$o[] = ' maxZoom: 17,';
$o[] = ' attribution: \'Map data: &copy; <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>, <a href="https://viewfinderpanoramas.org" target="_blank">SRTM</a> | Map style: &copy; <a href="https://opentopomap.org" target="_blank">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank">CC-BY-SA</a>)\'';
$o[] = '}).addTo(map'.$this->name.$this->id.');';
} else if ($type === 'google') {
/*
$o[] = 'L.gridLayer.googleMutant({';
$o[] = ' type: googlemapstype,';
$o[] = '}).addTo(map'.$this->name.$this->id.');';
*/
} else if ($type === 'wikimedia') {
$o[] = 'L.tileLayer(\'https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png\', {';
$o[] = ' maxZoom: 18,';
$o[] = ' attribution: \'&copy; <a href="https://wikimediafoundation.org/wiki/Maps_Terms_of_Use" target="_blank">Wikimedia maps</a> | Map data © <a href="https://openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>\'';
$o[] = '}).addTo(map'.$this->name.$this->id.');';
} else if ($type == 'osm_fr') {
$o[] = 'L.tileLayer(\'https://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png\', {';
$o[] = ' maxZoom: 20,';
$o[] = ' attribution: \'&copy; <a href="https://www.openstreetmap.fr" target="_blank">Openstreetmap France</a> & <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>\'';
$o[] = '}).addTo(map'.$this->name.$this->id.');';
} else if ($type == 'osm_hot') {
$o[] = 'L.tileLayer(\'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png\', {';
$o[] = ' maxZoom: 20,';
$o[] = ' attribution: \'&copy; <a href="https://hotosm.org/" target="_blank">Humanitarian OpenStreetMap Team</a> & <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>\'';
$o[] = '}).addTo(map'.$this->name.$this->id.');';
} else {
$o[] = 'L.tileLayer(\'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png\', {';
$o[] = ' maxZoom: 18,';
$o[] = ' attribution: \'&copy; <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>\'';
$o[] = '}).addTo(map'.$this->name.$this->id.');';
}
$this->output[] = implode("\n", $o);
return true;
}
public function setMarker($markerId, $title, $description, $lat, $lng, $text = '', $width = '', $height = '', $open = 0, $closeOpenedWindow = 0) {
$o = array();
if($open != 2){
$o[]= 'var marker'.$markerId.' = L.marker(['.PhocaGalleryText::filterValue($lat, 'number2').', '.PhocaGalleryText::filterValue($lng, 'number2').']).addTo(map'.$this->name.$this->id.');';
}
jimport('joomla.filter.output');
$style = '';
if ($width != '') {
$style .= 'width: '.(int)$width.'px;';
}
if ($height != '') {
$style .= 'height: '.(int)$height.'px;';
}
if ($text == '') {
if ($title != ''){
$hStyle = 'font-size:120%;margin: 5px 0px;font-weight:bold;';
$text .= '<div style="'.$hStyle.'">' . addslashes($title) . '</div>';
}
if ($description != '') {
$text .= '<div>'.PhocaGalleryText::strTrimAll(addslashes($description)).'</div>';
}
}
if ($text != '') {
if ($style != '') {
$text = '<div style="'.$style.'">' . $text . '</div>';
}
$openO = '';
if ($open == 1) {
$openO = '.openPopup()';
}
$o[]= 'marker'.$markerId.'.bindPopup(\''.$text.'\')'.$openO.';';
}
$this->output[] = implode("\n", $o);
return true;
}
public function setMarkerIcon($markerId, $icon = 'circle', $markerColor = 'blue', $iconColor = '#ffffff', $prefix = 'fa', $spin = 'false', $extraClasses = '' ) {
$o = $o2 = array();
$o[]= 'var icon'.$markerId.' = new L.AwesomeMarkers.icon({';
$o[]= $o2[] = ' icon: "'.PhocaGalleryText::filterValue($icon).'",';
$o[]= $o2[] = ' markerColor: "'.PhocaGalleryText::filterValue($markerColor).'",';
$o[]= $o2[] = ' iconColor: "'.PhocaGalleryText::filterValue($iconColor).'",';
$o[]= $o2[] = ' prefix: "'.PhocaGalleryText::filterValue($prefix).'",';
$o[]= $o2[] = ' spin: '.PhocaGalleryText::filterValue($spin).',';
$o[]= $o2[] = ' extraClasses: "'.PhocaGalleryText::filterValue($extraClasses).'",';
$o[]= '})';
$o[]= ' marker'.$markerId.'.setIcon(icon'.$markerId.');';
$this->output[] = implode("\n", $o);
return $o2;//return only options;
}
public function inputMarker($latInput, $longInput, $zoomInput = '', $setGPS = 0) {
$o = array();
$o[]= 'function phmInputMarker(lat, lng) {';
$o[]= 'var phLat = jQuery(\'#jform_latitude\', window.parent.document);';
$o[]= 'var phLng = jQuery(\'#jform_longitude\', window.parent.document);';
$o[]= 'phLat.val(lat);';
$o[]= 'phLng.val(lng);';
if ( $zoomInput != '') {
$o[]= 'var phZoom = jQuery(\'#jform_zoom\', window.parent.document);';
$o[]= 'phZoom.val(map'.$this->name.$this->id.'.getZoom());';
$o[]= 'var phmMsg = \'<span class="ph-msg-success">'.Text::_('COM_PHOCAGALLERY_LAT_LNG_ZOOM_SET').'</span>\';';
} else {
$o[]= 'var phmMsg = \'<span class="ph-msg-success">'.Text::_('COM_PHOCAGALLERY_LAT_LNG_SET').'</span>\';';
}
$o[]= 'jQuery(\'#phmPopupInfo\', window.parent.document).html(phmMsg);';
if ($setGPS == 1) {
$o[]= ' if (window.parent) setPMGPSLatitudeForm(lat);';
$o[]= ' if (window.parent) setPMGPSLongitudeForm(lng);';
}
$o[]= '}';
$this->output[] = implode("\n", $o);
return true;
}
public function moveMarker() {
$o = array();
$o[]= 'function phmMoveMarker(marker, lat, lng) {';
$o[]= ' var newLatLng = new L.LatLng(lat, lng);';
$o[]= ' marker.setLatLng(newLatLng);';
$o[]= '}';
$this->output[] = implode("\n", $o);
return true;
}
public function exportMarker($markerId) {
$o = array();
$o[] = 'map'.$this->name.$this->id.'.on(\'click\', onMapClick);';
$o[] = 'function onMapClick(e) {';
$o[] = ' phmInputMarker(e.latlng.lat, e.latlng.lng);';
$o[] = ' phmMoveMarker(marker'.$markerId.', e.latlng.lat, e.latlng.lng);';
$o[] = '}';
$this->output[] = implode("\n", $o);
return true;
}
public function renderSearch($markerId = '', $position = '') {
$position = $position != '' ? $position : 'topright';
$o = array();
$o[] = 'map'.$this->name.$this->id.'.addControl(new L.Control.Search({';
$o[] = ' url: \'https://nominatim.openstreetmap.org/search?format=json&q={s}\',';
$o[] = ' jsonpParam: \'json_callback\',';
$o[] = ' propertyName: \'display_name\',';
$o[] = ' propertyLoc: [\'lat\',\'lon\'],';
$o[] = ' marker: L.circleMarker([0,0],{radius:30}),';
$o[] = ' autoCollapse: true,';
$o[] = ' autoType: false,';
$o[] = ' minLength: 3,';
$o[] = ' position: \''.$position.'\',';
if ($markerId != '') {
$o[] = ' moveToLocation: function(latlng, title, map) {';
$o[] = ' phmInputMarker(latlng.lat, latlng.lng);';
$o[] = ' phmMoveMarker(marker'.$markerId.', latlng.lat, latlng.lng);';
$o[] = ' map'.$this->name.$this->id.'.setView(latlng, 7);';// set the zoom
$o[] = ' }';
}
$o[] = '}));';
$this->output[] = implode("\n", $o);
return true;
}
public function renderFullScreenControl() {
if ($this->fullscreen == 0) {
return false;
}
$o = array();
$o[] = 'map'.$this->name.$this->id.'.addControl(';
$o[] = ' new L.Control.Fullscreen({';
$o[] = ' position: \'topright\',';
$o[] = ' title: {';
$o[] = ' \'false\': \''.Text::_('COM_PHOCAGALLERY_VIEW_FULLSCREEN').'\',';
$o[] = ' \'true\': \''.Text::_('COM_PHOCAGALLERY_EXIT_FULLSCREEN').'\'';
$o[] = ' }';
$o[] = ' })';
$o[] = ')';
$this->output[] = implode("\n", $o);
return true;
}
public function renderCurrentPosition() {
if ($this->currentposition == 0) {
return false;
}
$o = array();
$o[] = 'L.control.locate({';
$o[] = ' position: \'topright\',';
$o[] = ' strings: {';
$o[] = ' \'title\': \''.Text::_('COM_PHOCAGALLERY_CURRENT_POSITION').'\'';
$o[] = ' },';
$o[] = ' locateOptions: {';
$o[] = ' enableHighAccuracy: true,';
$o[] = ' watch: true,';
$o[] = ' }';
$o[] = '}).addTo(map'.$this->name.$this->id.');';
$this->output[] = implode("\n", $o);
return true;
}
public function renderEasyPrint() {
if ($this->easyprint == 0) {
return false;
}
$o = array();
$o[] = 'map'.$this->name.$this->id.'.addControl(';
$o[] = ' new L.easyPrint({';
$o[] = ' hideControlContainer: true,';
$o[] = ' sizeModes: [\'Current\', \'A4Portrait\', \'A4Landscape\'],';
$o[] = ' position: \'topleft\',';
$o[] = ' exportOnly: true';
$o[] = ' })';
$o[] = ');';
$this->output[] = implode("\n", $o);
return true;
}
public function renderRouting($latFrom = 0, $lngFrom = 0, $latTo = 0, $lngTo = 0, $markerId = '', $markerIconOptions = array(), $language = '') {
if ($this->router == 0) {
return false;
}
$o = array();
if ($this->routerserviceurl == '' && $this->maprouterapikey == '') {
$o[] = 'console.log(\'Routing Error: No router or service url set\')';
$this->output[] = implode("\n", $o);
return true;
}
$o[] = 'var routingControl = L.Routing.control({';
$o[] = ' waypoints: [';
if ($latFrom == 0 && $lngFrom == 0 && $latTo != 0 && $lngTo != 0) {
$o[] = ' L.latLng(\'\'),';
} else if ($latFrom == 0 && $lngFrom == 0) {
$o[] = ' L.latLng(\'\'),';
} else {
$o[] = ' L.latLng('.PhocaGalleryText::filterValue($latFrom, 'number2').', '.PhocaGalleryText::filterValue($lngFrom, 'number2').'),';
}
if ($latTo == 0 && $lngTo == 0) {
$o[] = ' L.latLng(\'\'),';
} else {
$o[] = ' L.latLng('.PhocaGalleryText::filterValue($latTo, 'number2').', '.PhocaGalleryText::filterValue($lngTo, 'number2').')';
}
$o[] = ' ],';
if ($language != '') {
$o[] = ' language: \''.PhocaGalleryText::filterValue($language, 'text').'\',';
}
if ($markerId != '') {
//$o[] = ' marker: marker'.$markerId.',';
// Don't create new marker for routing (so if we have "TO" address with marker created in map
// don't display any marker
//if (!empty($markerIconOptions)) {
if ($latTo != 0 && $lngTo != 0) {
$o[] = ' createMarker: function(i,wp, n) {';
$o[] = ' var latToMarker = '.PhocaGalleryText::filterValue($latTo, 'number2').';';
$o[] = ' var lngToMarker = '.PhocaGalleryText::filterValue($lngTo, 'number2').';';
$o[] = ' if (wp.latLng.lat == latToMarker && wp.latLng.lng == lngToMarker) {';
$o[] = ' return false;';
$o[] = ' } else {';
// Get the same icon as the "To" (End) has
if (!empty($markerIconOptions)) {
$o[] = ' var ma = L.marker(wp.latLng);';
$o[] = ' var ic = new L.AwesomeMarkers.icon({';
foreach($markerIconOptions as $k => $v) {
// Change the icon to circle (e.g. the "To" (End) is set to home, so don't render the same icon for "From" (start) address
if (strpos($v, 'icon:') !== false) {
$v = 'icon: "circle",';
}
$o[] = ' '.$v. "\n";
}
$o[] = ' });';
$o[] = ' ma.setIcon(ic);';
$o[] = ' return ma;';
} else {
$o[] = ' return L.marker(wp.latLng);';
}
$o[] = ' }';
$o[] = ' },';
}
}
$o[] = ' routeWhileDragging: true,';
$o[] = ' geocoder: L.Control.Geocoder.nominatim(),';
$o[] = ' reverseWaypoints: true,';
$o[] = ' showAlternatives: true,';
$o[] = ' collapsible: true,';
$o[] = ' show: false,';
if ($this->routerserviceurl == 'https://api.mapbox.com/directions/v5') {
// DEBUG DEMO - default address of leaflet-routing-machine to debug
} else if ($this->routerserviceurl != '') {
$o[] = ' routerserviceurl: \''.$this->routerserviceurl.'\',';
} else if ($this->osm_map_type == 'mapbox' && $this->maprouterapikey != '') {
$o[] = ' router: L.Routing.mapbox(\''.PhocaGalleryText::filterValue($this->maprouterapikey).'\'),';
} else {
$o[] = array();
$o[] = 'console.log(\'Routing Error: No router or service url set\')';
$this->output[] = implode("\n", $o);
return true;
}
if ($this->routerprofile != '') {
$o[] = ' profile: \''.PhocaGalleryText::filterValue($this->routerprofile).'\',';
}
$o[] = '})';
// $o[] = '.on(\'routingstart\', showSpinner)';
//$o[] = '.on(\'routesfound routingerror\', hideSpinner)';
$o[] = '.addTo(map'.$this->name.$this->id.');';
//$o[] = 'routingControl.hide();';
$this->output[] = implode("\n", $o);
return true;
}
public function renderMap() {
HTMLHelper::_('jquery.framework', false);
$o = array();
$o[] = 'jQuery(document).ready(function() {';
$o[] = implode("\n", $this->output);
$o[] = '})';
Factory::getDocument()->addScriptDeclaration(implode("\n", $o));
}
}
?>

View File

@ -0,0 +1,301 @@
<?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\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Uri\Uri;
class PhocaGalleryRenderProcess
{
//public $stopThumbnailsCreating; // display the posibility (link) to disable the thumbnails creating
//public $headerAdded;// HTML Header was added by Stop Thumbnails creating, don't add it into a site again;
private static $renderProcess = array();
private static $renderHeader = array();
private function __construct(){}
public static function getProcessPage ($filename, $thumbInfo, $refresh_url, $errorMsg = '' ) {
$countImg = (int)Factory::getApplication()->input->get( 'countimg', 0, 'get', 'INT' );
$currentImg = (int)Factory::getApplication()->input->get( 'currentimg',0, 'get','INT' );
$paths = PhocaGalleryPath::getPath();
if ($currentImg == 0) {
$currentImg = 1;
}
$nextImg = $currentImg + 1;
$view = Factory::getApplication()->input->get( 'view', '', 'get', 'string' );
//we are in whole window - not in modal box
if ($view == 'phocagalleryi' || $view == 'phocagalleryd') {
$header = self::getHeader('processpage');
if ($header != '') {
echo $header;
$boxStyle = self::getBoxStyle();
echo '<div style="'.$boxStyle.'">';
}
}
echo '<span>'. Text::_( 'COM_PHOCAGALLERY_THUMBNAIL_GENERATING_WAIT' ) . '</span>';
if ( $errorMsg == '' ) {
echo '<p>' .Text::_( 'COM_PHOCAGALLERY_THUMBNAIL_GENERATING' )
.' <span style="color:#0066cc;">'. $filename . '</span>'
.' ... <b style="color:#009900">'.Text::_( 'COM_PHOCAGALLERY_OK' ).'</b><br />'
.'(<span style="color:#0066cc;">' . $thumbInfo . '</span>)</p>';
} else {
echo '<p>' .Text::_( 'COM_PHOCAGALLERY_THUMBNAIL_GENERATING' )
.' <span style="color:#0066cc;padding:0;margin:0"> '. $filename . '</span>'
.' ... <b style="color:#fc0000">'.Text::_( 'COM_PHOCAGALLERY_ERROR' ).'</b><br />'
.'(<span style="color:#0066cc;">' . $thumbInfo . '</span>)</p>';
}
if ($countImg == 0) {
// BEGIN ---------------------------------------------------------------------------
echo '<div class="ph-lds-ellipsis"><div></div><div></div><div></div><div></div></div><div>&nbsp;</div><div>'. Text::_('COM_PHOCAGALLERY_REBUILDING_PROCESS_WAIT') . '</div>';
// END -----------------------------------------------------------------------------
} else {
// Creating thumbnails info
$per = 0; // display percents
if ($countImg > 0) {
$per = round(($currentImg / $countImg)*100, 0);
}
$perCSS = ($per * 400/100) - 400;
$bgCSS = 'background: #e6e6e6 url(\''. $paths->media_img_rel_full . 'administrator/process2.png\') '.$perCSS.'px 0 repeat-y;';
// BEGIN -----------------------------------------------------------------------
//echo '<p>' . JText::_('COM_PHOCAGALLERY_GENERATING'). ': <span style="color:#0066cc">'. $currentImg .'</span> '.JText::_('COM_PHOCAGALLERY_FROM'). ' <span style="color:#0066cc">'. $countImg .'</span> '.JText::_('COM_PHOCAGALLERY_THUMBNAIL_S').'</p>';
echo '<p>' . Text::sprintf('COM_PHOCAGALLERY_GENERATING_FROM_THUMBNAIL_S', '<span style="color:#0066cc">'. $currentImg .'</span> ', ' <span style="color:#0066cc">'. $countImg .'</span> ').'</p>';
//echo '<p>'.$per.' &#37;</p>';
//echo '<div style="width:400px;height:20px;font-size:20px;border-top:2px solid #666;border-left:2px solid #666;border-bottom:2px solid #ccc;border-right:2px solid #ccc;'.$bgCSS.'"><span style="font-size:10px;font-weight:bold">'.$per.' &#37;</div>';
echo '<div style="width:400px;height:20px;font-size:20px;border: 1px solid #ccc; vertical-align: middle;display: inline-block; -moz-border-radius: 2px; -webkit-border-radius: 2px; border-radius: 2px;'.$bgCSS.'"><div style="font-size:12px;font-weight:bold;color: #777;margin-top:2px;">'.$per.' &#37;</div></div>';
// END -------------------------------------------------------------------------
}
if ( $errorMsg != '' ) {
$errorMessage = '';
switch ($errorMsg) {
case 'ErrorNotSupportedImage':
$errorMessage = Text::_('COM_PHOCAGALLERY_ERROR_NOTSUPPORTEDIMAGE');
break;
case 'ErrorNoJPGFunction':
$errorMessage = Text::_('COM_PHOCAGALLERY_ERROR_NOJPGFUNCTION');
break;
case 'ErrorNoPNGFunction':
$errorMessage = Text::_('COM_PHOCAGALLERY_ERROR_NOPNGFUNCTION');
break;
case 'ErrorNoGIFFunction':
$errorMessage = Text::_('COM_PHOCAGALLERY_ERROR_NOGIFFUNCTION');
break;
case 'ErrorNoWEBPFunction':
$errorMessage = Text::_('COM_PHOCAGALLERY_ERROR_NOWEBPFUNCTION');
break;
case 'ErrorNoAVIFFunction':
$errorMessage = Text::_('COM_PHOCAGALLERY_ERROR_NOAVIFFUNCTION');
break;
case 'ErrorNoWBMPFunction':
$errorMessage = Text::_('COM_PHOCAGALLERY_ERROR_NOWBMPFUNCTION');
break;
case 'ErrorWriteFile':
$errorMessage = Text::_('COM_PHOCAGALLERY_ERROR_WRITEFILE');
break;
case 'ErrorFileOriginalNotExists':
$errorMessage = Text::_('COM_PHOCAGALLERY_ERROR_FILEORIGINALNOTEXISTS');
break;
case 'ErrorCreatingFolder':
$errorMessage = Text::_('COM_PHOCAGALLERY_ERROR_CREATINGFOLDER');
break;
case 'ErrorNoImageCreateTruecolor':
$errorMessage = Text::_('COM_PHOCAGALLERY_ERROR_NOIMAGECREATETRUECOLOR');
break;
case 'Error1':
case 'Error2':
case 'Error3':
case 'Error4':
case 'Error5':
Default:
$errorMessage = Text::_('COM_PHOCAGALLERY_ERROR_WHILECREATINGTHUMB') . ' ('.$errorMsg.')';
break;
}
//$view = JFactory::getApplication()->input->get( 'view' );
//we are in whole window - not in modal box
if ($view != 'phocagalleryi' && $view != 'phocagalleryd') {
echo '<div style="text-align:left;margin: 10px 5px">';
echo '<table border="0" cellpadding="7"><tr><td>'.Text::_('COM_PHOCAGALLERY_ERROR_MESSAGE').':</td><td><span style="color:#fc0000">'.$errorMessage.'</span></td></tr>';
echo '<tr><td colspan="1" rowspan="4" valign="top" >'.Text::_('COM_PHOCAGALLERY_WHAT_TO_DO_NOW').' :</td>';
echo '<td>- ' .Text::_( 'COM_PHOCAGALLERY_SOLUTION_BEGIN' ).' <br /><ul><li>'.Text::_( 'COM_PHOCAGALLERY_SOLUTION_IMAGE' ).'</li><li>'.Text::_( 'COM_PHOCAGALLERY_SOLUTION_GD' ).'</li><li>'.Text::_( 'COM_PHOCAGALLERY_SOLUTION_PERMISSION' ).'</li></ul>'.Text::_( 'COM_PHOCAGALLERY_SOLUTION_END' ).'<br /> <a href="'.$refresh_url.'&countimg='.$countImg.'&currentimg='.$currentImg .'">' .Text::_( 'COM_PHOCAGALLERY_BACK_PHOCA_GALLERY' ).'</a><div class="hr"></div></td></tr>';
echo '<tr><td>- ' .Text::_( 'COM_PHOCAGALLERY_DISABLE_CREATING_THUMBS_SOLUTION' ).' <br /> <a href="index.php?option=com_phocagallery&task=phocagalleryimg.disablethumbs">' .Text::_( 'COM_PHOCAGALLERY_BACK_DISABLE_THUMBS_GENERATING' ).'</a> <br />'.Text::_( 'COM_PHOCAGALLERY_ENABLE_THUMBS_GENERATING_OPTIONS' ).'<div class="hr"></div></td></tr>';
echo '<tr><td>- ' .Text::_( 'COM_PHOCAGALLERY_MEDIA_MANAGER_SOLUTION' ).' <br /> <a href="index.php?option=com_media">' .Text::_( 'COM_PHOCAGALLERY_MEDIA_MANAGER_LINK' ).'</a><div class="hr"></div></td></tr>';
echo '<tr><td>- <a href="https://www.phoca.cz/documentation/" target="_blank">' . Text::_( 'COM_PHOCAGALLERY_GO_TO_PHOCA_GALLERY_USER_MANUAL' ).'</a></td></tr>';
echo '</table>';
echo '</div>';
}
else //we are in modal box
{
echo '<div style="text-align:left">';
echo '<table border="0" cellpadding="3"
cellspacing="3"><tr><td>'.Text::_('COM_PHOCAGALLERY_ERROR_MESSAGE').':</td><td><span style="color:#fc0000">'.$errorMessage.'</span></td></tr>';
echo '<tr><td colspan="1" rowspan="3" valign="top">'.Text::_('COM_PHOCAGALLERY_WHAT_TO_DO_NOW').' :</td>';
echo '<td>- ' .Text::_( 'COM_PHOCAGALLERY_SOLUTION_BEGIN' ).' <br /><ul><li>'.Text::_( 'PG COM_PHOCAGALLERY_SOLUTION_IMAGE' ).'</li><li>'.Text::_( 'COM_PHOCAGALLERY_SOLUTION_GD' ).'</li><li>'.Text::_( 'COM_PHOCAGALLERY_SOLUTION_PERMISSION' ).'</li></ul>'.Text::_( 'COM_PHOCAGALLERY_SOLUTION_END' ).'<br /> <a href="'.$refresh_url.'&countimg='.$countImg.'&currentimg='.$currentImg .'">' .Text::_( 'COM_PHOCAGALLERY_BACK_PHOCA_GALLERY' ).'</a><div class="hr"></div></td></tr>';
echo '<td>- ' .Text::_( 'COM_PHOCAGALLERY_NO_SOLUTION' ).' <br /> <a href="#" onclick="SqueezeBox.close();">' .Text::_( 'COM_PHOCAGALLERY_BACK_PHOCA_GALLERY' ).'</a></td></tr>';
echo '</table>';
echo '</div>';
}
echo '</div></body></html>';
exit;
}
if ($countImg == $currentImg || $currentImg > $countImg) {
/*$imageSid = false;
$imageSid = preg_match("/imagesid/i", $refresh_url);
if (!$imageSid) {
$refresh_url = $refresh_url . '&imagesid='.md5(time());
}*/
echo '<meta http-equiv="refresh" content="1;url='.$refresh_url.'" />';
} else {
echo '<meta http-equiv="refresh" content="0;url='.$refresh_url.'&countimg='.$countImg.'&currentimg='.$nextImg.'" />';
}
echo '</div></body></html>';
exit;
}
public static function displayStopThumbnailsCreating($element = null) {
if( is_null( $element ) ) {
throw new Exception('Function Error: No element added', 500);
return false;
}
// 1 ... link was displayed
// 0 ... display the link "Stop ThumbnailsCreation
$view = Factory::getApplication()->input->get( 'view' );
//we are in whole window - not in modal box
if ($view == 'phocagalleryi' || $view == 'phocagalleryd') {
//$this->stopThumbnailsCreating = 1;
self::$renderProcess[$element] = '';
return self::$renderProcess[$element];
} else {
if( !array_key_exists( $element, self::$renderProcess ) ) {
//if (!isset($this->stopThumbnailsCreating) || (isset($this->stopThumbnailsCreating) && $this->stopThumbnailsCreating == 0)) {
// Add stop thumbnails creation in case e.g. of Fatal Error which returns 'ImageCreateFromJPEG'
$stopText = self::getHeader('processpage');
$boxStyle = self::getBoxStyle();
$stopText .= '<div style="'.$boxStyle.'">';// End will be added getProcessPage
$stopText .= '<div style="text-align:right;margin-bottom: 15px;"><a style="font-family: sans-serif, Arial;font-weight:bold;color:#e33131;font-size:12px;" href="index.php?option=com_phocagallery&task=phocagalleryimg.disablethumbs" title="' .Text::_( 'COM_PHOCAGALLERY_STOP_THUMBNAIL_GENERATION_DESC' ).'">' .Text::_( 'COM_PHOCAGALLERY_STOP_THUMBNAIL_GENERATION' ).'</a></div>';
//$this->stopThumbnailsCreating = 1;// it was added to the site, don't add the same code (because there are 3 thumnails - small, medium, large)
//$this->headerAdded = 1;
self::$renderProcess[$element] = $stopText;
} else {
self::$renderProcess[$element] = '';
}
return self::$renderProcess[$element];
}
}
protected static function getHeader( $element = null) {
if( is_null( $element ) ) {
throw new Exception('Function Error: No element added', 500);
return false;
}
if( !array_key_exists( $element, self::$renderHeader ) ) {
// test utf-8 ä, ö, ü, č, ř, ž, ß
$paths = PhocaGalleryPath::getPath();
$bgImg = Uri::root(true).'/media/com_phocagallery/images/administrator/image-bg.jpg';
$o = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n";
$o .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-en" lang="en-en" dir="ltr" >'. "\n";
$o .= '<head>'. "\n";
$o .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'. "\n\n";
$o .= '<title>'.Text::_( 'COM_PHOCAGALLERY_THUMBNAIL_GENERATING').'</title>'. "\n";
$o .= '<link rel="stylesheet" href="'.$paths->media_css_rel_full.'administrator/phocagallery.css" type="text/css" />';
$o .= "\n" . '<style type="text/css"> html {
background: url('.$bgImg.') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}' . "\n" . '.hr { border-bottom: 1px solid #ccc; margin-top: 10px;}'. "\n" . '</style>' . "\n";
$o .= "\n" . '<!--[if IE]>' . '<style type="text/css">' ."\n";
$o .= "\n" . 'html { background-image: none;}';
$o .= "\n" . '<![endif]-->' . "\n" . '</style>' . "\n";
$o .= '</head>'. "\n";
$o .= '<body>'. "\n";
self::$renderHeader[$element] = $o;
} else {
self::$renderHeader[$element] = '';
}
return self::$renderHeader[$element];
}
protected static function getBoxStyle() {
$o = 'position: absolute;
min-width: 430px; top: 20px; right: 20px;
color: #555; background: #fff;
font-family: sans-serif, arial; font-weight:normal; font-size: 12px;
-webkit-border-radius: 3px 3px 3px 3px; border-radius: 3px 3px 3px 3px;
padding:10px 10px 20px 10px;
text-align: center;';
return $o;
}
}
?>

View File

@ -0,0 +1,88 @@
<?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\HTML\HTMLHelper;
class PhocaGalleryRenderTabs
{
protected $id = '';
protected $activeTab = '';
protected $countTab = 0;
public function __construct() {
$this->id = uniqid();
HTMLHelper::_('jquery.framework', false);
HTMLHelper::_('script', 'media/com_phocagallery/js/tabs/tabs.js', array('version' => 'auto'));
HTMLHelper::_('stylesheet', 'media/com_phocagallery/js/tabs/tabs.css', array('version' => 'auto'));
}
public function setActiveTab($item) {
if ($item != '') {
$this->activeTab = $item;
}
}
public function startTabs() {
return '<div class="phTabs" id="phTabsId' . $this->id . '">';
}
public function endTabs() {
return '</div>';
}
public function renderTabsHeader($items) {
$o = array();
$o[] = '<ul class="phTabsUl">';
if (!empty($items)) {
$i = 0;
foreach ($items as $k => $v) {
$activeO = '';
if ($this->activeTab == '' && $i == 0) {
$activeO = ' active';
} else if ($this->activeTab == $v['id']) {
$activeO = ' active';
}
$o[] = '<li class="phTabsLi"><a class="phTabsA phTabsHeader' . $activeO . '" id="phTabId' . $this->id . 'Item' . $v['id'] . '">'
//. PhocaGalleryRenderFront::renderIcon($v['icon'], 'media/com_phocagallery/images/icon-' . $v['image'] . '.png', '')
. '<svg class="ph-si ph-si-tab ph-si-'.$v['icon'].'"><use xlink:href="#ph-si-'.$v['icon'].'"></use></svg>'
. '&nbsp;' . $v['title'] . '</a></li>';
$i++;
}
}
$o[] = '</ul>';
return implode("\n", $o);
}
public function startTab($name) {
$activeO = '';
if ($this->activeTab == '' && $this->countTab == 0) {
$activeO = ' active';
} else if ($this->activeTab == $name) {
$activeO = ' active';
}
$this->countTab++;
return '<div class="phTabsContainer' . $activeO . '" id="phTabId' . $this->id . 'Item' . $name . 'Container">';
}
public function endTab() {
return '</div>';
}
}