primo commit
This commit is contained in:
		| @ -0,0 +1,407 @@ | ||||
| <?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\HTML\HTMLHelper; | ||||
| use Joomla\CMS\Component\ComponentHelper; | ||||
|  | ||||
| class PhocaGalleryAccess | ||||
| { | ||||
| 	/* | ||||
| 	 * Get info about access in only one category | ||||
| 	 */ | ||||
| 	public static function getCategoryAccess($id) { | ||||
|  | ||||
| 		$output = array(); | ||||
| 		$db 	= Factory::getDBO(); | ||||
| 		$query 	= 'SELECT c.access, c.accessuserid, c.uploaduserid, c.deleteuserid, c.userfolder' . | ||||
| 				' FROM #__phocagallery_categories AS c' . | ||||
| 				' WHERE c.id = '. (int) $id . | ||||
| 				' ORDER BY c.id'; | ||||
| 		$db->setQuery($query, 0, 1); | ||||
| 		$output = $db->loadObject(); | ||||
| 		return $output; | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	/** | ||||
| 	 * Method to check if the user have access to category | ||||
| 	 * Display or hide the not accessible categories - subcat folder will be not displayed | ||||
| 	 * Check whether category access level allows access | ||||
| 	 * | ||||
| 	 * E.g.: Should the link to Subcategory or to Parentcategory be displayed | ||||
| 	 * E.g.: Should the delete button displayed, should be the upload button displayed | ||||
| 	 * | ||||
| 	 * @param string $params rightType: accessuserid, uploaduserid, deleteuserid - access, upload, delete right | ||||
| 	 * @param int $params rightUsers - All selected users which should have the "rightType" right | ||||
| 	 * @param int $params rightGroup - All selected Groups of users(public, registered or special ) which should have the "rT" right | ||||
| 	 * @param int $params userAID - Specific group of user who display the category in front (public, special, registerd) | ||||
| 	 * @param int $params userId - Specific id of user who display the category in front (1,2,3,...) | ||||
| 	 * @param int $params Additional param - e.g. $display_access_category (Should be unaccessed category displayed) | ||||
| 	 * @return boolean 1 or 0 | ||||
| 	 */ | ||||
|  | ||||
| 	public static function getUserRight($rightType = 'accessuserid', $rightUsers = array(), $rightGroup = 0, $userAID = array(), $userId = 0 , $additionalParam = 0 ) { | ||||
| 		$user = Factory::getUser(); | ||||
| 		// we can get the variables here, not before function call | ||||
| 		$userAID = $user->getAuthorisedViewLevels(); | ||||
| 		$userId = $user->get('id', 0); | ||||
| 		$guest = 0; | ||||
| 		if (isset($user->guest) && $user->guest == 1) { | ||||
| 			$guest = 1; | ||||
| 		} | ||||
|  | ||||
|  | ||||
| /*		// User ACL | ||||
| 		$rightGroupAccess = 0; | ||||
| 		// User can be assigned to different groups | ||||
| 		foreach ($userAID as $keyUserAID => $valueUserAID) { | ||||
| 			if ((int)$rightGroup == (int)$valueUserAID) { | ||||
| 				$rightGroupAccess = 1; | ||||
| 				break; | ||||
| 			} | ||||
| 		}*/ | ||||
| 		// Normally we use "registered" group | ||||
| 		// But if user defines own "registered" groups in registered_access_level, these need to be taken in effect too | ||||
| 		$nAL = self::getNeededAccessLevels(); | ||||
| 		$rightGroupA 	= array(); | ||||
| 		$rightGroupA[]	= (int)$rightGroup; | ||||
| 		if(!empty($nAL)){ | ||||
| 			//$rightGroupA = array_merge($nAL, $rightGroupA); | ||||
| 		} | ||||
|  | ||||
| 		// User ACL | ||||
| 		$rightGroupAccess = 0; | ||||
| 		// User can be assigned to different groups | ||||
| 		foreach ($userAID as $keyUserAID => $valueUserAID) { | ||||
| 			/*if ((int)$rightGroup == (int)$valueUserAID) { | ||||
| 				$rightGroupAccess = 1; | ||||
| 				break; | ||||
| 			}*/ | ||||
| 			foreach($rightGroupA as $keyRightGroupA => $valueRightGroupA) { | ||||
| 				if ((int)$valueRightGroupA == (int)$valueUserAID) { | ||||
| 					$rightGroupAccess = 1; | ||||
| 					break 2; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
|  | ||||
| 		$rightUsersIdArray = array(); | ||||
| 		if (!empty($rightUsers) && isset($rightUsers) && $rightUsers != '') { | ||||
| 			$rightUsersIdArray = explode( ',', trim( $rightUsers ) ); | ||||
| 		} else { | ||||
| 			$rightUsersIdArray = array(); | ||||
| 		} | ||||
|  | ||||
|  | ||||
| 		// Access rights (Default open for all) | ||||
| 		// Upload and Delete rights (Default closed for all) | ||||
| 		switch ($rightType) { | ||||
| 			case 'accessuserid': | ||||
| 				$rightDisplay = 1; | ||||
| 			break; | ||||
|  | ||||
| 			default: | ||||
| 				$rightDisplay = 0; | ||||
| 			break; | ||||
| 		} | ||||
|  | ||||
| 		if ($additionalParam == 0) { // We want not to display unaccessable categories ($display_access_category) | ||||
| 			if ($rightGroup != 0) { | ||||
|  | ||||
| 				if ($rightGroupAccess == 0) { | ||||
| 					$rightDisplay  = 0; | ||||
| 				} else { // Access level only for one registered user | ||||
| 					if (!empty($rightUsersIdArray)) { | ||||
| 						// Check if the user is contained in selected array | ||||
| 						$userIsContained = 0; | ||||
| 						foreach ($rightUsersIdArray as $key => $value) { | ||||
| 							if ($userId == $value) { | ||||
| 								$userIsContained = 1;// check if the user id is selected in multiple box | ||||
|  | ||||
| 								break;// don't search again | ||||
| 							} | ||||
| 							// for access (-1 not selected - all registered, 0 all users) | ||||
| 							// Access is checked by group, but upload and delete not | ||||
|  | ||||
|  | ||||
| 							if ($value == -1) { | ||||
| 								if ($guest == 0) { | ||||
| 									$userIsContained = 1;// in multiple select box is selected - All registered users | ||||
| 								} | ||||
|  | ||||
| 								break;// don't search again | ||||
| 							} | ||||
| 						} | ||||
|  | ||||
| 						if ($userIsContained == 0) { | ||||
| 							$rightDisplay = 0; | ||||
| 						} else { | ||||
| 							if ($rightType == 'uploaduserid' || $rightType == 'deleteuserid') { | ||||
| 								$rightDisplay = 1; | ||||
| 							} | ||||
|  | ||||
| 						} | ||||
| //						else { | ||||
| //							// E.g. upload right begins with 0, so we need to set it to 1 | ||||
| //							$rightDisplay = 1; | ||||
| //						} | ||||
| 					} else { | ||||
|  | ||||
| 						// Access rights (Default open for all) | ||||
| 						// Upload and Delete rights (Default closed for all) | ||||
| 						switch ($rightType) { | ||||
| 							case 'accessuserid': | ||||
| 								$rightDisplay = 1; | ||||
| 							break; | ||||
|  | ||||
| 							default: | ||||
| 								$rightDisplay = 0; | ||||
| 							break; | ||||
| 						} | ||||
|  | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return $rightDisplay; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Method to display multiple select box | ||||
| 	 * @param string $name Name (id, name parameters) | ||||
| 	 * @param array $active Array of items which will be selected | ||||
| 	 * @param int $nouser Select no user | ||||
| 	 * @param string $javascript Add javascript to the select box | ||||
| 	 * @param string $order Ordering of items | ||||
| 	 * @param int $reg Only registered users | ||||
| 	 * @return array of id | ||||
| 	 */ | ||||
|  | ||||
| 	public static function usersList( $name, $id, $active, $nouser = 0, $javascript = NULL, $order = 'name', $reg = 1,$returnArray = 0) { | ||||
|  | ||||
| 		$activeArray = $active; | ||||
| 		if ($active != '') { | ||||
| 			$activeArray = explode(',',$active); | ||||
| 		} | ||||
|  | ||||
| 		$db		= Factory::getDBO(); | ||||
| 		$and 	= ''; | ||||
| 		if ($reg) { | ||||
| 			// does not include registered users in the list | ||||
| 			$and = ' AND m.group_id != 2'; | ||||
| 		} | ||||
|  | ||||
| 		$query = 'SELECT u.id AS value, u.name AS text' | ||||
| 		. ' FROM #__users AS u' | ||||
| 		. ' JOIN #__user_usergroup_map AS m ON m.user_id = u.id' | ||||
| 		. ' WHERE u.block = 0' | ||||
| 		. $and | ||||
| 		. ' GROUP BY u.id, u.name' | ||||
| 		. ' ORDER BY '. $order; | ||||
|  | ||||
|  | ||||
| 		$db->setQuery( $query ); | ||||
| 		if ( $nouser ) { | ||||
|  | ||||
| 			// Access rights (Default open for all) | ||||
| 			// Upload and Delete rights (Default closed for all) | ||||
|  | ||||
| 			$idInput1 	= $idInput2 = $idInput3 = $idInput4 = false; | ||||
| 			$idText1	= $idText2	= $idText3 	= $idText4 = false; | ||||
|  | ||||
| 			switch ($name) { | ||||
| 				case 'jform[accessuserid][]': | ||||
| 					$idInput1 	= -1; | ||||
| 					$idText1	= Text::_( 'COM_PHOCAGALLERY_ALL_REGISTERED_USERS' ); | ||||
| 					$idInput2 	= -2; | ||||
| 					$idText2	= Text::_( 'COM_PHOCAGALLERY_NOBODY' ); | ||||
| 				break; | ||||
|  | ||||
| 				case 'batch[accessuserid][]': | ||||
| 					$idInput4 	= -3; | ||||
| 					$idText4	= Text::_( 'COM_PHOCAGALLERY_KEEP_ORIGINAL_ACCESS_RIGHTS_LEVELS' ); | ||||
| 					$idInput3 	= 0; | ||||
| 					$idText3	= Text::_( 'COM_PHOCAGALLERY_NOT_SET' ); | ||||
| 					$idInput1 	= -1; | ||||
| 					$idText1	= Text::_( 'COM_PHOCAGALLERY_ALL_REGISTERED_USERS' ); | ||||
| 					$idInput2 	= -2; | ||||
| 					$idText2	= Text::_( 'COM_PHOCAGALLERY_NOBODY' ); | ||||
| 				break; | ||||
|  | ||||
| 				case 'jform[default_accessuserid][]': | ||||
| 					$idInput3 	= 0; | ||||
| 					$idText3	= Text::_( 'COM_PHOCAGALLERY_NOT_SET' ); | ||||
| 					$idInput1 	= -1; | ||||
| 					$idText1	= Text::_( 'COM_PHOCAGALLERY_ALL_REGISTERED_USERS' ); | ||||
| 					$idInput2 	= -2; | ||||
| 					$idText2	= Text::_( 'COM_PHOCAGALLERY_NOBODY' ); | ||||
| 				break; | ||||
|  | ||||
| 				default: | ||||
| 					$idInput1 	= -2; | ||||
| 					$idText1	= Text::_( 'COM_PHOCAGALLERY_NOBODY' ); | ||||
| 					$idInput2 	= -1; | ||||
| 					$idText2	= Text::_( 'COM_PHOCAGALLERY_ALL_REGISTERED_USERS' ); | ||||
| 				break; | ||||
| 			} | ||||
|  | ||||
| 			$users = array(); | ||||
|  | ||||
| 			if ($idText4) { | ||||
| 				$users[] = HTMLHelper::_('select.option',  $idInput4, '- '. $idText4 .' -' ); | ||||
| 			} | ||||
| 			if ($idText3) { | ||||
| 				$users[] = HTMLHelper::_('select.option',  $idInput3, '- '. $idText3 .' -' ); | ||||
| 			} | ||||
| 			$users[] = HTMLHelper::_('select.option',  $idInput1, '- '. $idText1 .' -' ); | ||||
| 			$users[] = HTMLHelper::_('select.option',  $idInput2, '- '. $idText2 .' -' ); | ||||
|  | ||||
|  | ||||
| 			$users = array_merge( $users, $db->loadObjectList() ); | ||||
| 		} else { | ||||
| 			$users = $db->loadObjectList(); | ||||
| 		} | ||||
|  | ||||
| 		if ($returnArray == 1) { | ||||
| 			return $users; | ||||
| 		} | ||||
|  | ||||
| 		$users = HTMLHelper::_('select.genericlist', $users, $name, 'class="form-control" size="4" multiple="multiple"'. $javascript, 'value', 'text', $activeArray, $id ); | ||||
|  | ||||
| 		return $users; | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	/* | ||||
| 	 * Get list of users to select Owner of the category | ||||
| 	 */ | ||||
| 	public static function usersListOwner( $name, $id, $active, $nouser = 0, $javascript = NULL, $order = 'name', $reg = 1, $returnArray = 0) { | ||||
|  | ||||
| 		$db		= Factory::getDBO(); | ||||
| 		$and 	= ''; | ||||
| 		if ($reg) { | ||||
| 			// does not include registered users in the list | ||||
| 			$and = ' AND m.group_id != 2'; | ||||
| 		} | ||||
|  | ||||
| 		$query = 'SELECT u.id AS value, u.name AS text' | ||||
| 		. ' FROM #__users AS u' | ||||
| 		. ' JOIN #__user_usergroup_map AS m ON m.user_id = u.id' | ||||
| 		. ' WHERE u.block = 0' | ||||
| 		. $and | ||||
| 		. ' GROUP BY u.id, u.name' | ||||
| 		. ' ORDER BY '. $order; | ||||
|  | ||||
|  | ||||
| 		$db->setQuery( $query ); | ||||
| 		if ( $nouser ) { | ||||
|  | ||||
| 			$idInput1 	= -1; | ||||
| 			$idText1	= Text::_( 'COM_PHOCAGALLERY_NOBODY' ); | ||||
| 			$users[] = HTMLHelper::_('select.option',  -1, '- '. $idText1 .' -' ); | ||||
|  | ||||
| 			$users = array_merge( $users, $db->loadObjectList() ); | ||||
| 		} else { | ||||
| 			$users = $db->loadObjectList(); | ||||
| 		} | ||||
|  | ||||
| 		if ($returnArray == 1) { | ||||
| 			return $users; | ||||
| 		} | ||||
|  | ||||
| 		$users = HTMLHelper::_('select.genericlist', $users, $name, 'class="form-control" size="4" '. $javascript, 'value', 'text', $active, $id ); | ||||
|  | ||||
| 		return $users; | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Used for commenting and rating | ||||
| 	 */ | ||||
| 	public static function getNeededAccessLevels() { | ||||
|  | ||||
| 		$paramsC 				= ComponentHelper::getParams('com_phocagallery'); | ||||
| 		$registeredAccessLevel 	= $paramsC->get( 'registered_access_level', array(2,3,4) ); | ||||
| 		return $registeredAccessLevel; | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Check if user's groups access rights (e.g. user is public, registered, special) can meet needed Levels | ||||
| 	 */ | ||||
|  | ||||
| 	public static function isAccess($userLevels, $neededLevels) { | ||||
|  | ||||
| 		$rightGroupAccess = 0; | ||||
|  | ||||
| 		// User can be assigned to different groups | ||||
| 		foreach($userLevels as $keyuserLevels => $valueuserLevels) { | ||||
| 			foreach($neededLevels as $keyneededLevels => $valueneededLevels) { | ||||
|  | ||||
| 				if ((int)$valueneededLevels == (int)$valueuserLevels) { | ||||
| 					$rightGroupAccess = 1; | ||||
| 					break; | ||||
| 				} | ||||
| 			} | ||||
| 			if ($rightGroupAccess == 1) { | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
| 		return (boolean)$rightGroupAccess; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Method to get the array of values for one parameters saved in param array | ||||
| 	 * @param string $params | ||||
| 	 * @param string $param param: e.g. accessuserid, uploaduserid, deleteuserid, userfolder | ||||
| 	 * @return array of values from one param in params array which is saved in db table in 'params' column | ||||
| 	 */ | ||||
| 	/*/// | ||||
| 	function getParamsArray($params='', $param='accessuserid')  { | ||||
| 		// All params from category / params for userid only | ||||
| 		if ($params != '') { | ||||
| 			$paramsArray	= trim ($params); | ||||
| 			$paramsArray	= explode( ',', $params ); | ||||
|  | ||||
| 			if (is_array($paramsArray)) | ||||
| 			{ | ||||
| 				foreach ($paramsArray as $value) | ||||
| 				{ | ||||
| 					$find = '/'.$param.'=/i'; | ||||
| 					$replace = $param.'='; | ||||
|  | ||||
| 					$idParam = preg_match( "".$find."" , $value ); | ||||
| 					if ($idParam) { | ||||
| 						$paramsId = str_replace($replace, '', $value); | ||||
| 						if ($paramsId != '') { | ||||
| 							$paramsIdArray	= trim ($paramsId); | ||||
| 							$paramsIdArray	= explode( ',', $paramsId ); | ||||
| 							// Unset empty keys | ||||
| 							foreach ($paramsIdArray as $key2 => $value2) | ||||
| 							{ | ||||
| 								if ($value2 == '') { | ||||
| 									unset($paramsIdArray[$key2]); | ||||
| 								} | ||||
| 							} | ||||
|  | ||||
| 							return $paramsIdArray; | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		return array(); | ||||
| 	}*/ | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -0,0 +1,508 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @package   Phoca Gallery | ||||
|  * @author    Jan Pavelka - https://www.phoca.cz | ||||
|  * @copyright Copyright (C) Jan Pavelka https://www.phoca.cz | ||||
|  * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later | ||||
|  * @cms       Joomla | ||||
|  * @copyright Copyright (C) Open Source Matters. All rights reserved. | ||||
|  * @license   http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php | ||||
|  */ | ||||
| defined('_JEXEC') or die(); | ||||
| use Joomla\CMS\Object\CMSObject; | ||||
| use Joomla\CMS\Factory; | ||||
| use Joomla\CMS\Language\Text; | ||||
| use Joomla\CMS\HTML\HTMLHelper; | ||||
| use Joomla\CMS\Router\Route; | ||||
| jimport('joomla.application.component.model'); | ||||
|  | ||||
|  | ||||
|  | ||||
| final class PhocaGalleryCategory | ||||
| { | ||||
|  | ||||
| 	private static $categoryA = array(); | ||||
| 	private static $categoryF = array(); | ||||
| 	private static $categoryP = array(); | ||||
| 	private static $categoryI = array(); | ||||
|  | ||||
|  | ||||
| 	public function __construct() { | ||||
|  | ||||
|  | ||||
| 	} | ||||
|  | ||||
| /* | ||||
| 	public static function CategoryTreeOption($data, $tree, $id=0, $text='', $currentId = 0) { | ||||
|  | ||||
| 		foreach ($data as $key) { | ||||
| 			$show_text =  $text . $key->text; | ||||
|  | ||||
| 			if ($key->parentid == $id && $currentId != $id && $currentId != $key->value) { | ||||
| 				$tree[$key->value] 			= new CMSObject(); | ||||
| 				$tree[$key->value]->text 	= $show_text; | ||||
| 				$tree[$key->value]->value 	= $key->value; | ||||
| 				$tree = self::CategoryTreeOption($data, $tree, $key->value, $show_text . " - ", $currentId ); | ||||
| 			} | ||||
| 		} | ||||
| 		return($tree); | ||||
| 	} | ||||
|  | ||||
| 	public static function filterCategory($query, $active = NULL, $frontend = NULL, $onChange = TRUE, $fullTree = NULL ) { | ||||
|  | ||||
| 		$db	= Factory::getDBO(); | ||||
|  | ||||
| 		$form = 'adminForm'; | ||||
| 		if ($frontend == 1) { | ||||
| 			$form = 'phocacartproductsform'; | ||||
| 		} | ||||
|  | ||||
| 		if ($onChange) { | ||||
| 			$onChO = 'class="form-control" size="1" onchange="document.'.$form.'.submit( );"'; | ||||
| 		} else { | ||||
| 			$onChO = 'class="form-control" size="1"'; | ||||
| 		} | ||||
|  | ||||
| 		$categories[] = HTMLHelper::_('select.option', '0', '- '.Text::_('COM_phocagallery_SELECT_CATEGORY').' -'); | ||||
| 		$db->setQuery($query); | ||||
| 		$catData = $db->loadObjectList(); | ||||
|  | ||||
|  | ||||
|  | ||||
| 		if ($fullTree) { | ||||
|  | ||||
| 			// Start - remove in case there is a memory problem | ||||
| 			$tree = array(); | ||||
| 			$text = ''; | ||||
|  | ||||
| 			$queryAll = ' SELECT cc.id AS value, cc.title AS text, cc.parent_id as parentid' | ||||
| 					.' FROM #__phocagallery_categories AS cc' | ||||
| 					.' ORDER BY cc.ordering'; | ||||
| 			$db->setQuery($queryAll); | ||||
| 			$catDataAll 		= $db->loadObjectList(); | ||||
|  | ||||
| 			$catDataTree	= PhocacartCategory::CategoryTreeOption($catDataAll, $tree, 0, $text, -1); | ||||
|  | ||||
| 			$catDataTreeRights = array(); | ||||
| 			//- | ||||
| 			/*foreach ($catData as $k => $v) { | ||||
| 				foreach ($catDataTree as $k2 => $v2) { | ||||
| 					if ($v->value == $v2->value) { | ||||
| 						$catDataTreeRights[$k]->text 	= $v2->text; | ||||
| 						$catDataTreeRights[$k]->value = $v2->value; | ||||
| 					} | ||||
| 				} | ||||
| 			} */ | ||||
| 			//- | ||||
|  | ||||
| 	/* | ||||
|  | ||||
| 			foreach ($catDataTree as $k => $v) { | ||||
|                 foreach ($catData as $k2 => $v2) { | ||||
|                    if ($v->value == $v2->value) { | ||||
| 						$catDataTreeRights[$k] = new StdClass(); | ||||
| 						$catDataTreeRights[$k]->text  = $v->text; | ||||
| 						$catDataTreeRights[$k]->value = $v->value; | ||||
|                    } | ||||
|                 } | ||||
|              } | ||||
|  | ||||
|  | ||||
|  | ||||
| 			$catDataTree = array(); | ||||
| 			$catDataTree = $catDataTreeRights; | ||||
| 			// End - remove in case there is a memory problem | ||||
|  | ||||
| 			// Uncomment in case there is a memory problem | ||||
| 			//$catDataTree	= $catData; | ||||
| 		} else { | ||||
| 			$catDataTree	= $catData; | ||||
| 		} | ||||
|  | ||||
| 		$categories = array_merge($categories, $catDataTree ); | ||||
|  | ||||
| 		$category = HTMLHelper::_('select.genericlist',  $categories, 'catid', $onChO, 'value', 'text', $active); | ||||
|  | ||||
| 		return $category; | ||||
| 	} | ||||
|  | ||||
| 	public static function options($type = 0) | ||||
| 	{ | ||||
|  | ||||
|  | ||||
| 		$db = Factory::getDBO(); | ||||
|  | ||||
|        //build the list of categories | ||||
| 		$query = 'SELECT a.title AS text, a.id AS value, a.parent_id as parentid' | ||||
| 		. ' FROM #__phocagallery_categories AS a' | ||||
| 		. ' WHERE a.published = 1' | ||||
| 		. ' ORDER BY a.ordering'; | ||||
| 		$db->setQuery( $query ); | ||||
| 		$items = $db->loadObjectList(); | ||||
|  | ||||
| 		$catId	= -1; | ||||
|  | ||||
| 		$javascript 	= 'class="form-control" size="1" onchange="submitform( );"'; | ||||
|  | ||||
| 		$tree = array(); | ||||
| 		$text = ''; | ||||
| 		$tree = PhocacartCategory::CategoryTreeOption($items, $tree, 0, $text, $catId); | ||||
|  | ||||
| 		return $tree; | ||||
|  | ||||
| 	}*/ | ||||
|  | ||||
| 	public static function getCategoryById($id) { | ||||
|  | ||||
| 		$id = (int)$id; | ||||
| 		if( empty(self::$categoryI[$id])) { | ||||
|  | ||||
| 			$db = Factory::getDBO(); | ||||
| 			$query = 'SELECT a.title, a.alias, a.id, a.parent_id' | ||||
| 			. ' FROM #__phocagallery_categories AS a' | ||||
| 			. ' WHERE a.id = '.(int)$id | ||||
| 			. ' ORDER BY a.ordering' | ||||
| 			. ' LIMIT 1'; | ||||
| 			$db->setQuery( $query ); | ||||
|  | ||||
| 			$category = $db->loadObject(); | ||||
| 			if (!empty($category) && isset($category->id) && (int)$category->id > 0) { | ||||
|  | ||||
| 				$query = 'SELECT a.title, a.alias, a.id, a.parent_id' | ||||
| 				. ' FROM #__phocagallery_categories AS a' | ||||
| 				. ' WHERE a.parent_id = '.(int)$id | ||||
| 				. ' ORDER BY a.ordering'; | ||||
| 				//. ' LIMIT 1'; We need all subcategories | ||||
| 				$db->setQuery( $query ); | ||||
| 				$subcategories = $db->loadObjectList(); | ||||
| 				if (!empty($subcategories)) { | ||||
| 					$category->subcategories = $subcategories; | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			self::$categoryI[$id] = $category; | ||||
| 		} | ||||
| 		return self::$categoryI[$id]; | ||||
| 	} | ||||
| /* | ||||
| 	public static function getChildren($id) { | ||||
| 		$db = Factory::getDBO(); | ||||
| 		$query = 'SELECT a.title, a.alias, a.id' | ||||
| 		. ' FROM #__phocagallery_categories AS a' | ||||
| 		. ' WHERE a.parent_id = '.(int)$id | ||||
| 		. ' ORDER BY a.ordering'; | ||||
| 		$db->setQuery( $query ); | ||||
| 		$categories = $db->loadObjectList(); | ||||
| 		return $categories; | ||||
| 	} | ||||
| */ | ||||
| 	public static function getPath($path = array(), $id = 0, $parent_id = 0, $title = '', $alias = '') { | ||||
|  | ||||
| 		if( empty(self::$categoryA[$id])) { | ||||
| 			self::$categoryP[$id]	= self::getPathTree($path, $id, $parent_id, $title, $alias); | ||||
| 		} | ||||
|  | ||||
| 	return self::$categoryP[$id]; | ||||
| 	} | ||||
|  | ||||
| 	public static function getPathTree($path = array(), $id = 0, $parent_id = 0, $title = '', $alias = '') { | ||||
|  | ||||
| 		static $iCT = 0; | ||||
|  | ||||
| 		if ((int)$id > 0) { | ||||
| 			//$path[$iCT]['id'] = (int)$id; | ||||
| 			//$path[$iCT]['catid'] = (int)$parent_id; | ||||
| 			//$path[$iCT]['title'] = $title; | ||||
| 			//$path[$iCT]['alias'] = $alias; | ||||
|  | ||||
| 			$path[$id] = (int)$id. ':'. $alias; | ||||
| 		} | ||||
|  | ||||
| 		if ((int)$parent_id > 0) { | ||||
| 			$db = Factory::getDBO(); | ||||
| 			$query = 'SELECT a.title, a.alias, a.id, a.parent_id' | ||||
| 			. ' FROM #__phocagallery_categories AS a' | ||||
| 			. ' WHERE a.id = '.(int)$parent_id | ||||
| 			. ' ORDER BY a.ordering'; | ||||
| 			$db->setQuery( $query ); | ||||
| 			$category = $db->loadObject(); | ||||
|  | ||||
| 			if (isset($category->id)) { | ||||
| 				$id 	= (int)$category->id; | ||||
| 				$title 	= ''; | ||||
| 				if (isset($category->title)) { | ||||
| 					$title = $category->title; | ||||
| 				} | ||||
|  | ||||
| 				$alias 	= ''; | ||||
| 				if (isset($category->alias)) { | ||||
| 					$alias = $category->alias; | ||||
| 				} | ||||
|  | ||||
| 				$parent_id = 0; | ||||
| 				if (isset($category->parent_id)) { | ||||
| 					$parent_id = (int)$category->parent_id; | ||||
| 				} | ||||
| 				$iCT++; | ||||
|  | ||||
| 				$path = self::getPathTree($path, (int)$id, (int)$parent_id, $title, $alias); | ||||
| 			} | ||||
| 		} | ||||
| 		return $path; | ||||
| 	} | ||||
| /* | ||||
| 	public static function categoryTree($d, $r = 0, $pk = 'parent_id', $k = 'id', $c = 'children') { | ||||
| 		$m = array(); | ||||
| 		foreach ($d as $e) { | ||||
| 			isset($m[$e[$pk]]) ?: $m[$e[$pk]] = array(); | ||||
| 			isset($m[$e[$k]]) ?: $m[$e[$k]] = array(); | ||||
| 			$m[$e[$pk]][] = array_merge($e, array($c => &$m[$e[$k]])); | ||||
| 		} | ||||
| 		//return $m[$r][0]; // remove [0] if there could be more than one root nodes | ||||
| 		if (isset($m[$r])) { | ||||
| 			return $m[$r]; | ||||
| 		} | ||||
| 		return 0; | ||||
| 	} | ||||
|  | ||||
| 	public static function nestedToUl($data, $currentCatid = 0) { | ||||
| 		$result = array(); | ||||
|  | ||||
| 		if (!empty($data) && count($data) > 0) { | ||||
| 			$result[] = '<ul>'; | ||||
| 			foreach ($data as $k => $v) { | ||||
| 				$link 		= Route::_(PhocacartRoute::getCategoryRoute($v['id'], $v['alias'])); | ||||
|  | ||||
| 				// Current Category is selected | ||||
| 				if ($currentCatid == $v['id']) { | ||||
| 					$result[] = sprintf( | ||||
| 						'<li data-jstree=\'{"opened":true,"selected":true}\' >%s%s</li>', | ||||
| 						'<a href="'.$link.'">' . $v['title']. '</a>', | ||||
| 						self::nestedToUl($v['children'], $currentCatid) | ||||
| 					); | ||||
| 				} else { | ||||
| 					$result[] = sprintf( | ||||
| 						'<li>%s%s</li>', | ||||
| 						'<a href="'.$link.'">' . $v['title']. '</a>', | ||||
| 						self::nestedToUl($v['children'], $currentCatid) | ||||
| 					); | ||||
| 				} | ||||
| 			} | ||||
| 			$result[] = '</ul>'; | ||||
| 		} | ||||
|  | ||||
| 		return implode("\n", $result); | ||||
| 	} | ||||
|  | ||||
| 	public static function nestedToCheckBox($data, $d, $currentCatid = 0, &$active = 0, $forceCategoryId = 0) { | ||||
|  | ||||
|  | ||||
| 		$result = array(); | ||||
| 		if (!empty($data) && count($data) > 0) { | ||||
| 			$result[] = '<ul class="ph-filter-module-category-tree">'; | ||||
| 			foreach ($data as $k => $v) { | ||||
|  | ||||
| 				$checked 	= ''; | ||||
| 				$value		= htmlspecialchars($v['alias']); | ||||
| 				if (isset($d['nrinalias']) && $d['nrinalias'] == 1) { | ||||
| 					$value 		= (int)$v['id'] .'-'. htmlspecialchars($v['alias']); | ||||
| 				} | ||||
|  | ||||
| 				if (in_array($value, $d['getparams'])) { | ||||
| 					$checked 	= 'checked'; | ||||
| 					$active     = 1; | ||||
| 				} | ||||
|  | ||||
| 				// This only can happen in category view (category filters are empty, id of category is larger then zero) | ||||
| 				// This is only marking the category as active in category list | ||||
| 				if (empty($d['getparams']) || (isset($d['getparams'][0]) && $d['getparams'][0] == '')) { | ||||
| 					// Empty parameters, so we can set category id by id of category view | ||||
| 					if ($forceCategoryId > 0 && (int)$forceCategoryId == (int)$v['id']) { | ||||
| 						$checked = 'checked'; | ||||
| 						$active = 1; | ||||
| 					} | ||||
| 				} | ||||
|  | ||||
| 				$count = ''; | ||||
| 				// If we are in item view - one category is selected but if user click on filter to select other category, this one should be still selected - we go to items view with 2 selected | ||||
| 				// because force category is on | ||||
| 				if (isset($v['count_products']) && isset($d['params']['display_category_count']) && $d['params']['display_category_count'] == 1 ) { | ||||
| 					$count = ' <span class="ph-filter-count">'.(int)$v['count_products'].'</span>'; | ||||
| 				} | ||||
|  | ||||
| 				$icon = ''; | ||||
| 				if ($v['icon_class'] != '') { | ||||
| 					$icon = '<span class="' . PhocacartText::filterValue($v['icon_class'], 'text') . ' ph-filter-item-icon"></span> '; | ||||
| 				} | ||||
|  | ||||
| 				$jsSet = ''; | ||||
|  | ||||
| 				if (isset($d['forcecategory']['idalias']) && $d['forcecategory']['idalias']  != '') { | ||||
| 					// Category View - force the category parameter if set in parameters | ||||
| 					$jsSet .= 'phChangeFilter(\'c\', \''.$d['forcecategory']['idalias'].'\', 1,  \'text\', 0, 1, 1);'; // ADD IS FIXED ( use "text" as formType - it cannot by managed by checkbox, it is fixed - always 1 - does not depends on checkbox, it is fixed 1 | ||||
| 				} | ||||
|  | ||||
|  | ||||
|  | ||||
| 				$jsSet .= 'phChangeFilter(\''.$d['param'].'\', \''. $value.'\', this, \''.$d['formtype'].'\',\''.$d['uniquevalue'].'\', 0, 1);';// ADD OR REMOVE | ||||
|  | ||||
|  | ||||
| 				$result[] = '<li><div class="checkbox">'; | ||||
| 				$result[] = '<label class="ph-checkbox-container"><input type="checkbox" name="tag" value="'.$value.'" '.$checked.' onchange="'.$jsSet.'" />'. $icon . $v['title'].$count.'<span class="ph-checkbox-checkmark"></span></label>'; | ||||
| 				$result[] = '</div></li>'; | ||||
| 				$result[] = self::nestedToCheckBox($v['children'], $d, $currentCatid, $active); | ||||
| 			} | ||||
| 			$result[] = '</ul>'; | ||||
| 		} | ||||
|  | ||||
| 		return implode("\n", $result); | ||||
| 	} | ||||
|  | ||||
| 	public static function getCategoryTreeFormat($ordering = 1, $display = '', $hide = '', $type = array(0,1), $lang = '') { | ||||
|  | ||||
| 		$cis = str_replace(',', '', 'o'.$ordering .'d'. $display .'h'. $hide. 'l'. $lang); | ||||
| 		if( empty(self::$categoryF[$cis])) { | ||||
|  | ||||
| 			$itemOrdering 	= PhocacartOrdering::getOrderingText($ordering,1); | ||||
| 			$db 			= Factory::getDBO(); | ||||
| 			$wheres			= array(); | ||||
| 			$user 			= PhocacartUser::getUser(); | ||||
| 			$userLevels		= implode (',', $user->getAuthorisedViewLevels()); | ||||
| 			$userGroups 	= implode (',', PhocacartGroup::getGroupsById($user->id, 1, 1)); | ||||
| 			$wheres[] 		= " c.access IN (".$userLevels.")"; | ||||
| 			$wheres[] 		= " (gc.group_id IN (".$userGroups.") OR gc.group_id IS NULL)"; | ||||
| 			$wheres[] 		= " c.published = 1"; | ||||
|  | ||||
| 			if ($lang != '' && $lang != '*') { | ||||
| 				$wheres[] 	= PhocacartUtilsSettings::getLangQuery('c.language', $lang); | ||||
| 			} | ||||
|  | ||||
| 			if (!empty($type) && is_array($type)) { | ||||
| 				$wheres[] = " c.type IN (".implode(',', $type).")"; | ||||
| 			} | ||||
|  | ||||
| 			if ($display != '') { | ||||
| 				$wheres[] = " c.id IN (".$display.")"; | ||||
| 			} | ||||
| 			if ($hide != '') { | ||||
| 				$wheres[] = " c.id NOT IN (".$hide.")"; | ||||
| 			} | ||||
|  | ||||
| 			$columns		= 'c.id, c.title, c.alias, c.parent_id'; | ||||
| 			$groupsFull		= $columns; | ||||
| 			$groupsFast		= 'c.id'; | ||||
| 			$groups			= PhocacartUtilsSettings::isFullGroupBy() ? $groupsFull : $groupsFast; | ||||
|  | ||||
| 			$query = 'SELECT c.id, c.title, c.alias, c.parent_id' | ||||
| 			. ' FROM #__phocagallery_categories AS c' | ||||
| 			. ' LEFT JOIN #__phocagallery_item_groups AS gc ON c.id = gc.item_id AND gc.type = 2'// type 2 is category | ||||
| 			. ' WHERE ' . implode( ' AND ', $wheres ) | ||||
| 			. ' GROUP BY '.$groups | ||||
| 			. ' ORDER BY '.$itemOrdering; | ||||
| 			$db->setQuery( $query ); | ||||
|  | ||||
| 			$items 						= $db->loadAssocList(); | ||||
| 			$tree 						= self::categoryTree($items); | ||||
| 			$currentCatid				= self::getActiveCategoryId(); | ||||
| 			self::$categoryF[$cis] = self::nestedToUl($tree, $currentCatid); | ||||
| 		} | ||||
|  | ||||
| 		return self::$categoryF[$cis]; | ||||
| 	} | ||||
|  | ||||
| 	public static function getCategoryTreeArray($ordering = 1, $display = '', $hide = '', $type = array(0,1), $lang = '', $limitCount = -1) { | ||||
|  | ||||
| 		$cis = str_replace(',', '', 'o'.$ordering .'d'. $display .'h'. $hide . 'l'. $lang . 'c'.$limitCount); | ||||
| 		if( empty(self::$categoryA[$cis])) { | ||||
|  | ||||
| 			$itemOrdering 	= PhocacartOrdering::getOrderingText($ordering,1); | ||||
| 			$db 			= Factory::getDBO(); | ||||
| 			$wheres			= array(); | ||||
| 			$user 			= PhocacartUser::getUser(); | ||||
| 			$userLevels		= implode (',', $user->getAuthorisedViewLevels()); | ||||
| 			$userGroups 	= implode (',', PhocacartGroup::getGroupsById($user->id, 1, 1)); | ||||
| 			$wheres[] 		= " c.access IN (".$userLevels.")"; | ||||
| 			$wheres[] 		= " (gc.group_id IN (".$userGroups.") OR gc.group_id IS NULL)"; | ||||
| 			$wheres[] 		= " c.published = 1"; | ||||
|  | ||||
| 			if ($lang != '' && $lang != '*') { | ||||
| 				$wheres[] 	= PhocacartUtilsSettings::getLangQuery('c.language', $lang); | ||||
| 			} | ||||
|  | ||||
| 			if (!empty($type) && is_array($type)) { | ||||
| 				$wheres[] = " c.type IN (".implode(',', $type).")"; | ||||
| 			} | ||||
|  | ||||
| 			if ($display != '') { | ||||
| 				$wheres[] = " c.id IN (".$display.")"; | ||||
| 			} | ||||
| 			if ($hide != '') { | ||||
| 				$wheres[] = " c.id NOT IN (".$hide.")"; | ||||
| 			} | ||||
|  | ||||
| 			if ((int)$limitCount > -1) { | ||||
| 				$wheres[] = " c.count_products > ".(int)$limitCount; | ||||
| 			} | ||||
|  | ||||
| 			$query = 'SELECT c.id, c.title, c.alias, c.parent_id, c.icon_class, c.image, c.description, c.count_products' | ||||
| 			. ' FROM #__phocagallery_categories AS c' | ||||
| 			. ' LEFT JOIN #__phocagallery_item_groups AS gc ON c.id = gc.item_id AND gc.type = 2'// type 2 is category | ||||
| 			. ' WHERE ' . implode( ' AND ', $wheres ) | ||||
| 			. ' ORDER BY '.$itemOrdering; | ||||
| 			$db->setQuery( $query ); | ||||
| 			$items 						= $db->loadAssocList(); | ||||
| 			self::$categoryA[$cis]	= self::categoryTree($items); | ||||
| 		} | ||||
| 		return self::$categoryA[$cis]; | ||||
| 	} | ||||
|  | ||||
| 	public static function getActiveCategoryId() { | ||||
|  | ||||
| 		$app			= Factory::getApplication(); | ||||
| 		$option			= $app->input->get( 'option', '', 'string' ); | ||||
| 		$view			= $app->input->get( 'view', '', 'string' ); | ||||
| 		$catid			= $app->input->get( 'catid', '', 'int' ); // ID in items view is category id | ||||
| 		$id				= $app->input->get( 'id', '', 'int' ); | ||||
|  | ||||
| 		if ($option == 'com_phocacart' && ($view == 'items' || $view == 'category')) { | ||||
|  | ||||
| 			if ((int)$id > 0) { | ||||
| 				return $id; | ||||
| 			} | ||||
| 		} | ||||
| 		if ($option == 'com_phocacart' && $view == 'item') { | ||||
|  | ||||
| 			if ((int)$catid > 0) { | ||||
| 				return $catid; | ||||
| 			} | ||||
| 		} | ||||
| 		return 0; | ||||
| 	} | ||||
|  | ||||
|     public static function getActiveCategories($items, $ordering) { | ||||
|  | ||||
| 		$db     = Factory::getDbo(); | ||||
| 	    $o      = array(); | ||||
|         $wheres = array(); | ||||
|         $ordering = PhocacartOrdering::getOrderingText($ordering, 1);//c | ||||
| 		if ($items != '') { | ||||
| 			$wheres[] = 'c.id IN (' . $items . ')'; | ||||
| 			$q = 'SELECT DISTINCT c.title, CONCAT(c.id, \'-\', c.alias) AS alias, \'c\' AS parameteralias, \'category\' AS parametertitle FROM #__phocagallery_categories AS c' | ||||
| 				. (!empty($wheres) ? ' WHERE ' . implode(' AND ', $wheres) : '') | ||||
| 				. ' GROUP BY c.alias, c.title' | ||||
| 				. ' ORDER BY ' . $ordering; | ||||
|  | ||||
| 			$db->setQuery($q); | ||||
| 			$o = $db->loadAssocList(); | ||||
| 		} | ||||
| 		return $o; | ||||
|     } | ||||
| */ | ||||
|  | ||||
|  | ||||
|     public final function __clone() { | ||||
| 		throw new Exception('Function Error: Cannot clone instance of Singleton pattern', 500); | ||||
| 		return false; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -0,0 +1,72 @@ | ||||
| <?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' ); | ||||
|  | ||||
| class PhocaGalleryComment | ||||
| { | ||||
| 	public static function closeTags($comment, $tag, $endTag) { | ||||
| 		if (substr_count(strtolower($comment), $tag) > substr_count(strtolower($comment), $endTag)) { | ||||
| 			$comment .= $endTag; | ||||
| 			$comment = PhocaGalleryComment::closeTags($comment, $tag, $endTag); | ||||
| 		} | ||||
| 			return $comment; | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	public static function getSmileys() { | ||||
| 		$smileys = array(); | ||||
| 			$smileys[':)'] 		= '🙂'; | ||||
| 			$smileys[':lol:'] 	= '😄'; | ||||
| 			$smileys[':('] 		= '☹'; | ||||
| 			$smileys[':?'] 		= '😕'; | ||||
| 			$smileys[':wink:'] 	= '😉'; | ||||
| 		return $smileys; | ||||
|  | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * @based based on Seb's BB-Code-Parser script by seb | ||||
| 	 * @url http://www.traum-projekt.com/forum/54-traum-scripts/25292-sebs-bb-code-parser.html | ||||
| 	 */ | ||||
| 	public static function bbCodeReplace($string, $currentString = '') { | ||||
|  | ||||
| 	    while($currentString != $string) { | ||||
| 			$currentString 	= $string; | ||||
| 			$string 		= preg_replace_callback('{\[(\w+)((=)(.+)|())\]((.|\n)*)\[/\1\]}U', array('PhocaGalleryComment', 'bbCodeCallback'), $string); | ||||
| 	    } | ||||
| 	    return $string; | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * @based based on Seb's BB-Code-Parser script by seb | ||||
| 	 * @url http://www.traum-projekt.com/forum/54-traum-scripts/25292-sebs-bb-code-parser.html | ||||
| 	 */ | ||||
| 	public static function bbCodeCallback($matches) { | ||||
| 		$tag 			= trim($matches[1]); | ||||
| 		$bodyString 	= $matches[6]; | ||||
| 		$argument 		= $matches[4]; | ||||
|  | ||||
| 	    switch($tag) { | ||||
| 			case 'b': | ||||
| 			case 'i': | ||||
| 			case 'u': | ||||
| 				$replacement = '<'.$tag.'>'.$bodyString.'</'.$tag.'>'; | ||||
| 	            break; | ||||
|  | ||||
| 	        Default:    // unknown tag => reconstruct and return original expression | ||||
| 	            $replacement = '[' . $tag . ']' . $bodyString . '[/' . $tag .']'; | ||||
| 	            break; | ||||
| 	    } | ||||
| 		return $replacement; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -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\Factory; | ||||
|  | ||||
| class PhocaGalleryCommentCategory | ||||
| { | ||||
| 	public static function checkUserComment($catid, $userid) { | ||||
| 		$db =Factory::getDBO(); | ||||
| 		$query = 'SELECT co.id AS id' | ||||
| 			    .' FROM #__phocagallery_comments AS co' | ||||
| 			    .' WHERE co.catid = '. (int)$catid  | ||||
| 				.' AND co.userid = '. (int)$userid | ||||
| 				.' ORDER BY co.id'; | ||||
| 		$db->setQuery($query, 0, 1); | ||||
| 		$checkUserComment = $db->loadObject(); | ||||
| 			 | ||||
| 		if ($checkUserComment) { | ||||
| 			return true; | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
| 	 | ||||
| 	public static function displayComment($catid) { | ||||
| 	 | ||||
| 		$db =Factory::getDBO(); | ||||
| 		$query = 'SELECT co.id AS id, co.title AS title, co.comment AS comment, co.date AS date, u.name AS name, u.username AS username' | ||||
| 			    .' FROM #__phocagallery_comments AS co' | ||||
| 				.' LEFT JOIN #__users AS u ON u.id = co.userid ' | ||||
| 			    .' WHERE co.catid = '. (int)$catid | ||||
| 				.' AND co.published = 1' | ||||
| 				.' ORDER by ordering'; | ||||
| 		$db->setQuery($query); | ||||
| 		$commentItem = $db->loadObjectList(); | ||||
| 			 | ||||
| 		return $commentItem; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,249 @@ | ||||
| <?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\Session\Session; | ||||
| use Joomla\CMS\Uri\Uri; | ||||
| use Joomla\CMS\Language\Text; | ||||
|  | ||||
| class PhocaGalleryCommentImage | ||||
| { | ||||
| 	public static function checkUserComment($imgid, $userid) { | ||||
| 		$db =Factory::getDBO(); | ||||
| 		$query = 'SELECT co.id AS id' | ||||
| 			    .' FROM #__phocagallery_img_comments AS co' | ||||
| 			    .' WHERE co.imgid = '. (int)$imgid | ||||
| 				.' AND co.userid = '. (int)$userid | ||||
| 				.' ORDER BY co.id'; | ||||
| 		$db->setQuery($query, 0, 1); | ||||
| 		$checkUserComment = $db->loadObject(); | ||||
|  | ||||
| 		if ($checkUserComment) { | ||||
| 			return true; | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	public static function displayComment($imgid) { | ||||
|  | ||||
| 		$db =Factory::getDBO(); | ||||
| 		$query = 'SELECT co.id AS id, co.title AS title, co.comment AS comment, co.date AS date, u.name AS name, u.username AS username, uc.avatar AS avatar' | ||||
| 			    .' FROM #__phocagallery_img_comments AS co' | ||||
| 				.' LEFT JOIN #__users AS u ON u.id = co.userid' | ||||
| 				.' LEFT JOIN #__phocagallery_user AS uc ON uc.userid = u.id' | ||||
| 			    /*.' WHERE co.imgid = '. (int)$imgid | ||||
| 				.' AND co.published = 1' | ||||
| 				.' AND uc.published = 1' | ||||
| 				.' AND uc.approved = 1'*/ | ||||
|  | ||||
| 				 .' WHERE ' | ||||
| 				. ' CASE WHEN avatar IS NOT NULL THEN' | ||||
| 				.' co.imgid = '. (int)$imgid | ||||
| 				.' AND co.published = 1' | ||||
| 				.' AND uc.published = 1' | ||||
| 				.' AND uc.approved = 1' | ||||
| 				.' ELSE' | ||||
| 				.' co.imgid = '. (int)$imgid | ||||
| 				.' AND co.published = 1' | ||||
| 				.' END' | ||||
|  | ||||
| 				.' ORDER by co.ordering'; | ||||
| 		$db->setQuery($query); | ||||
| 		$commentItem = $db->loadObjectList(); | ||||
|  | ||||
| 		return $commentItem; | ||||
| 	} | ||||
|  | ||||
| 	public static function getUserAvatar($userId) { | ||||
| 		$db = Factory::getDBO(); | ||||
| 		$query = 'SELECT a.*' | ||||
| 		. ' FROM #__phocagallery_user AS a' | ||||
| 		. ' WHERE a.userid = '.(int)$userId; | ||||
| 		$db->setQuery( $query ); | ||||
| 		$avatar = $db->loadObject(); | ||||
| 		if(isset($avatar->id)) { | ||||
| 			return $avatar; | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	public static function renderCommentImageJS() { | ||||
|  | ||||
|  | ||||
| 		// We only use refresh task (it means to get answer) | ||||
| 		// pgRequest uses pgRequestRefresh site | ||||
| 		$document	 = Factory::getDocument(); | ||||
| 		$url		  = 'index.php?option=com_phocagallery&view=commentimga&task=commentimg&format=json&'.Session::getFormToken().'=1'; | ||||
| 		$urlRefresh		= 'index.php?option=com_phocagallery&view=commentimga&task=refreshcomment&format=json&'.Session::getFormToken().'=1'; | ||||
| 		$imgLoadingUrl = Uri::base(). 'media/com_phocagallery/images/icon-loading3.gif'; | ||||
| 		$imgLoadingHTML = '<img src="'.$imgLoadingUrl.'" alt="" />'; | ||||
| 		//$js  = '<script type="text/javascript">' . "\n"; | ||||
| 		//$js .= 'window.addEvent("domready",function() { | ||||
| 		$js = ' | ||||
| 		function pgCommentImage(id, m, container) { | ||||
| 		 | ||||
| 			var result 			= "#pg-cv-comment-img-box-result" + id; | ||||
| 			 | ||||
| 			var commentTxtArea	= "#pg-cv-comments-editor-img" + id; | ||||
| 			var comment			= jQuery(commentTxtArea).val(); | ||||
| 			data = {"commentId": id, "commentValue": comment, "format":"json"}; | ||||
| 			 | ||||
| 			pgRequest = jQuery.ajax({ | ||||
|                 type: "POST", | ||||
|                 url: "'.$urlRefresh.'", | ||||
|                 async: "false", | ||||
|                 cache: "false", | ||||
|                 data: data, | ||||
|                 dataType:"JSON", | ||||
|                  | ||||
|                 beforeSend: function(){ | ||||
|                     jQuery(result).html("'.addslashes($imgLoadingHTML).'"); | ||||
|                     if (m == 2) { | ||||
|                         var wall = new Masonry(document.getElementById(container)); | ||||
|                     } | ||||
|                 }, | ||||
|                  | ||||
|                 success: function(data){ | ||||
|                     if (data.status == 1){ | ||||
|                         jQuery(result).html(data.message); | ||||
|                     } else if(data.status == 0){ | ||||
|                         jQuery(result).html(data.error); | ||||
|                     } else { | ||||
|                         jQuery(result).text("'.Text::_('COM_PHOCAGALLERY_ERROR_REQUESTING_ITEM').'"); | ||||
|                     } | ||||
|                      | ||||
|                     if (m == 2) { | ||||
| 					    var wall = new Masonry(document.getElementById(container)); | ||||
| 				    } | ||||
|                 }, | ||||
|                  | ||||
|                 error: function(){ | ||||
|                     jQuery(result).text( "'.Text::_('COM_PHOCAGALLERY_ERROR_REQUESTING_ITEM').'"); | ||||
| 				 | ||||
| 				    if (m == 2) { | ||||
| 					    var wall = new Masonry(document.getElementById(container)); | ||||
| 				    } | ||||
|                 } | ||||
|  | ||||
|             }) | ||||
|         }'; | ||||
|  | ||||
| 		$document->addScriptDeclaration($js); | ||||
|  | ||||
|         //})'; | ||||
|  | ||||
| 		/* | ||||
| 			if (r) { | ||||
| 					if (r.error == false) { | ||||
| 						jQuery(result).set("html", jsonObj.message); | ||||
| 					} else { | ||||
| 						jQuery(result).set("html", r.error); | ||||
| 					} | ||||
| 				} else { | ||||
| 					jQuery(result).set("text", "'.Text::_('COM_PHOCAGALLERY_ERROR_REQUESTING_ITEM').'"); | ||||
| 				} | ||||
|  | ||||
| 				if (m == 2) { | ||||
| 					var wall = new Masonry(document.getElementById(container)); | ||||
| 				} | ||||
|  | ||||
|  | ||||
|  | ||||
| 			var pgRequest = new Request.JSON({ | ||||
| 			url: "'.$urlRefresh.'", | ||||
| 			method: "post", | ||||
|  | ||||
| 			onRequest: function(){ | ||||
| 				jQuery(result).set("html", "'.addslashes($imgLoadingHTML).'"); | ||||
| 				if (m == 2) { | ||||
| 					var wall = new Masonry(document.getElementById(container)); | ||||
| 				} | ||||
| 			  }, | ||||
|  | ||||
| 			onComplete: function(jsonObj) { | ||||
| 				try { | ||||
| 					var r = jsonObj; | ||||
| 				} catch(e) { | ||||
| 					var r = false; | ||||
| 				} | ||||
|  | ||||
| 				if (r) { | ||||
| 					if (r.error == false) { | ||||
| 						jQuery(result).set("html", jsonObj.message); | ||||
| 					} else { | ||||
| 						jQuery(result).set("html", r.error); | ||||
| 					} | ||||
| 				} else { | ||||
| 					jQuery(result).set("text", "'.Text::_('COM_PHOCAGALLERY_ERROR_REQUESTING_ITEM').'"); | ||||
| 				} | ||||
|  | ||||
| 				if (m == 2) { | ||||
| 					var wall = new Masonry(document.getElementById(container)); | ||||
| 				} | ||||
| 			}, | ||||
|  | ||||
| 			onFailure: function() { | ||||
| 				jQuery(result).set("text", "'.Text::_('COM_PHOCAGALLERY_ERROR_REQUESTING_ITEM').'"); | ||||
|  | ||||
| 				if (m == 2) { | ||||
| 					var wall = new Masonry(document.getElementById(container)); | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			}) | ||||
|  | ||||
| 			pgRequest.send({ | ||||
| 				data: {"commentId": id, "commentValue": comment, "format":"json"}, | ||||
| 			}); | ||||
|  | ||||
| 		};'; | ||||
|  | ||||
| 		//$js .= '});'; | ||||
|  | ||||
|  | ||||
| 		/* | ||||
| 		var resultcomment 	= "pg-cv-comment-img-box-newcomment" + id; | ||||
| 		// Refreshing Voting | ||||
| 						var pgRequestRefresh = new Request.JSON({ | ||||
| 							url: "'.$urlRefresh.'", | ||||
| 							method: "post", | ||||
|  | ||||
| 							onComplete: function(json2Obj) { | ||||
| 								try { | ||||
| 									var rr = json2Obj; | ||||
| 								} catch(e) { | ||||
| 									var rr = false; | ||||
| 								} | ||||
|  | ||||
| 								if (rr) { | ||||
| 									$(resultcomment).set("html", json2Obj.message); | ||||
| 								} else { | ||||
| 									$(resultcomment).set("text", "'.Text::_('COM_PHOCAGALLERY_ERROR_REQUESTING_ITEM').'"); | ||||
| 								} | ||||
| 							}, | ||||
|  | ||||
| 							onFailure: function() { | ||||
| 								$(resultcomment).set("text", "'.Text::_('COM_PHOCAGALLERY_ERROR_REQUESTING_ITEM').'"); | ||||
| 							} | ||||
| 						}) | ||||
|  | ||||
| 						pgRequestRefresh.send({ | ||||
| 							data: {"commentId": id, "commentValue": comment, "format":"json"} | ||||
| 						}); | ||||
| 						//End refreshing comments | ||||
| 						*/ | ||||
|  | ||||
| 		//$js .= "\n" .'</script>'; | ||||
|  | ||||
|  | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -0,0 +1,162 @@ | ||||
| <?php | ||||
| /** | ||||
|  * Copyright 2011 Facebook, Inc. | ||||
|  * @copyright	Copyright 2011 Facebook, Inc. | ||||
|  * @license	 | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||||
|  * not use this file except in compliance with the License. You may obtain | ||||
|  * a copy of the License at | ||||
|  * | ||||
|  *     http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||||
|  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||||
|  * License for the specific language governing permissions and limitations | ||||
|  * under the License. | ||||
|  */ | ||||
|  | ||||
| //require_once "base_facebook.php"; | ||||
|  | ||||
| /** | ||||
|  * Extends the BaseFacebook class with the intent of using | ||||
|  * PHP sessions to store user ids and access tokens. | ||||
|  */ | ||||
| defined( '_JEXEC' ) or die( 'Restricted access' ); | ||||
| class Facebook extends BaseFacebook | ||||
| { | ||||
|   const FBSS_COOKIE_NAME = 'fbss'; | ||||
|  | ||||
|   // We can set this to a high number because the main session | ||||
|   // expiration will trump this. | ||||
|   const FBSS_COOKIE_EXPIRE = 31556926; // 1 year | ||||
|  | ||||
|   // Stores the shared session ID if one is set. | ||||
|   protected $sharedSessionID; | ||||
|  | ||||
|   /** | ||||
|    * Identical to the parent constructor, except that | ||||
|    * we start a PHP session to store the user ID and | ||||
|    * access token if during the course of execution | ||||
|    * we discover them. | ||||
|    * | ||||
|    * @param Array $config the application configuration. Additionally | ||||
|    * accepts "sharedSession" as a boolean to turn on a secondary | ||||
|    * cookie for environments with a shared session (that is, your app | ||||
|    * shares the domain with other apps). | ||||
|    * @see BaseFacebook::__construct in facebook.php | ||||
|    */ | ||||
|   public function __construct($config) { | ||||
|     if (!session_id()) { | ||||
|       session_start(); | ||||
|     } | ||||
|     parent::__construct($config); | ||||
|     if (!empty($config['sharedSession'])) { | ||||
|       $this->initSharedSession(); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   protected static $kSupportedKeys = | ||||
|     array('state', 'code', 'access_token', 'user_id'); | ||||
|  | ||||
|   protected function initSharedSession() { | ||||
|     $cookie_name = $this->getSharedSessionCookieName(); | ||||
|     if (isset($_COOKIE[$cookie_name])) { | ||||
|       $data = $this->parseSignedRequest($_COOKIE[$cookie_name]); | ||||
|       if ($data && !empty($data['domain']) && | ||||
|           self::isAllowedDomain($this->getHttpHost(), $data['domain'])) { | ||||
|         // good case | ||||
|         $this->sharedSessionID = $data['id']; | ||||
|         return; | ||||
|       } | ||||
|       // ignoring potentially unreachable data | ||||
|     } | ||||
|     // evil/corrupt/missing case | ||||
|     $base_domain = $this->getBaseDomain(); | ||||
|     $this->sharedSessionID = md5(uniqid(mt_rand(), true)); | ||||
|     $cookie_value = $this->makeSignedRequest( | ||||
|       array( | ||||
|         'domain' => $base_domain, | ||||
|         'id' => $this->sharedSessionID, | ||||
|       ) | ||||
|     ); | ||||
|     $_COOKIE[$cookie_name] = $cookie_value; | ||||
|     if (!headers_sent()) { | ||||
|       $expire = time() + self::FBSS_COOKIE_EXPIRE; | ||||
|       setcookie($cookie_name, $cookie_value, $expire, '/', '.'.$base_domain); | ||||
|     } else { | ||||
|       // @codeCoverageIgnoreStart | ||||
|       self::errorLog( | ||||
|         'Shared session ID cookie could not be set! You must ensure you '. | ||||
|         'create the Facebook instance before headers have been sent. This '. | ||||
|         'will cause authentication issues after the first request.' | ||||
|       ); | ||||
|       // @codeCoverageIgnoreEnd | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Provides the implementations of the inherited abstract | ||||
|    * methods.  The implementation uses PHP sessions to maintain | ||||
|    * a store for authorization codes, user ids, CSRF states, and | ||||
|    * access tokens. | ||||
|    */ | ||||
|   protected function setPersistentData($key, $value) { | ||||
|     if (!in_array($key, self::$kSupportedKeys)) { | ||||
|       self::errorLog('Unsupported key passed to setPersistentData.'); | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|     $session_var_name = $this->constructSessionVariableName($key); | ||||
|     $_SESSION[$session_var_name] = $value; | ||||
|   } | ||||
|  | ||||
|   protected function getPersistentData($key, $default = false) { | ||||
|     if (!in_array($key, self::$kSupportedKeys)) { | ||||
|       self::errorLog('Unsupported key passed to getPersistentData.'); | ||||
|       return $default; | ||||
|     } | ||||
|  | ||||
|     $session_var_name = $this->constructSessionVariableName($key); | ||||
|     return isset($_SESSION[$session_var_name]) ? | ||||
|       $_SESSION[$session_var_name] : $default; | ||||
|   } | ||||
|  | ||||
|   protected function clearPersistentData($key) { | ||||
|     if (!in_array($key, self::$kSupportedKeys)) { | ||||
|       self::errorLog('Unsupported key passed to clearPersistentData.'); | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|     $session_var_name = $this->constructSessionVariableName($key); | ||||
|     unset($_SESSION[$session_var_name]); | ||||
|   } | ||||
|  | ||||
|   protected function clearAllPersistentData() { | ||||
|     foreach (self::$kSupportedKeys as $key) { | ||||
|       $this->clearPersistentData($key); | ||||
|     } | ||||
|     if ($this->sharedSessionID) { | ||||
|       $this->deleteSharedSessionCookie(); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   protected function deleteSharedSessionCookie() { | ||||
|     $cookie_name = $this->getSharedSessionCookieName(); | ||||
|     unset($_COOKIE[$cookie_name]); | ||||
|     $base_domain = $this->getBaseDomain(); | ||||
|     setcookie($cookie_name, '', 1, '/', '.'.$base_domain); | ||||
|   } | ||||
|  | ||||
|   protected function getSharedSessionCookieName() { | ||||
|     return self::FBSS_COOKIE_NAME . '_' . $this->getAppId(); | ||||
|   } | ||||
|  | ||||
|   protected function constructSessionVariableName($key) { | ||||
|     $parts = array('fb', $this->getAppId(), $key); | ||||
|     if ($this->sharedSessionID) { | ||||
|       array_unshift($parts, $this->sharedSessionID); | ||||
|     } | ||||
|     return implode('_', $parts); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,350 @@ | ||||
| <?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' ); | ||||
| if (is_file( JPATH_ADMINISTRATOR.'/components/com_phocagallery/libraries/phocagallery/facebook/base_facebook.php') && | ||||
| is_file( JPATH_ADMINISTRATOR.'/components/com_phocagallery/libraries/phocagallery/facebook/facebook.php')) { | ||||
| 	if (class_exists('FacebookApiException') && class_exists('Facebook')) { | ||||
| 	} else { | ||||
| 		require_once(  JPATH_ADMINISTRATOR.'/components/com_phocagallery/libraries/phocagallery/facebook/base_facebook.php'); | ||||
| 		require_once(  JPATH_ADMINISTRATOR.'/components/com_phocagallery/libraries/phocagallery/facebook/facebook.php'); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| class PhocaGalleryFb | ||||
| { | ||||
| 	private static $fb = array(); | ||||
| 	 | ||||
| 	private function __construct(){} | ||||
|  | ||||
| 	public static function getAppInstance($appid, $appsid) { | ||||
| 	 | ||||
| 		if( !array_key_exists( $appid, self::$fb ) ) { | ||||
| 			$facebook = new Facebook(array( | ||||
| 			  'appId'  => $appid, | ||||
| 			  'secret' => $appsid, | ||||
| 			  'cookie' => false, | ||||
| 			)); | ||||
| 			 | ||||
| 			self::$fb[$appid] = $facebook; | ||||
| 		} | ||||
| 		return self::$fb[$appid]; | ||||
| 	} | ||||
| 	 | ||||
| 	public static function getSession() { | ||||
| 	 | ||||
| 		 | ||||
| 	} | ||||
| 	 | ||||
| 	public static function getFbStatus($appid, $appsid) { | ||||
| 	 | ||||
| 		$facebook 	= self::getAppInstance($appid, $appsid); | ||||
| 		 | ||||
| 		$fbLogout = JFactory::getApplication()->input->get('fblogout', 0, '', 'int'); | ||||
| 		if($fbLogout == 1) { | ||||
| 			$facebook->destroySession(); | ||||
| 		} | ||||
| 		 | ||||
| 		$fbuser 	= $facebook->getUser(); | ||||
| 		 | ||||
| 		$session 				= array(); | ||||
| 		$session['uid']			= $facebook->getUser(); | ||||
| 		$session['secret']		= $facebook->getApiSecret(); | ||||
| 		$session['access_token']= $facebook->getAccessToken(); | ||||
|  | ||||
| 		$output = array(); | ||||
|  | ||||
| 		 | ||||
| 		$u = null; | ||||
| 		// Session based API call. | ||||
| 		if ($fbuser) { | ||||
| 		  try { | ||||
| 			$u = $facebook->api('/me'); | ||||
| 		  } catch (FacebookApiException $e) { | ||||
| 			error_log($e); | ||||
| 		  } | ||||
| 		} | ||||
|  | ||||
| 		$uri = JURI::getInstance(); | ||||
| 		// login or logout url will be needed depending on current user state. | ||||
| 		if ($u) { | ||||
| 			$uid = $facebook->getUser(); | ||||
| 			$params = array('next' => $uri->toString() . '&fblogout=1' ); | ||||
| 			$logoutUrl = $facebook->getLogoutUrl($params); | ||||
| 		 | ||||
| 			$output['log']	= 1; | ||||
| 			$output['html'] = '<div><img src="https://graph.facebook.com/'.  $uid .'/picture" /></div>'; | ||||
| 			$output['html'] .= '<div>'. $u['name'].'</div>'; | ||||
| 			//$output['html'] .= '<div><a href="'. $logoutUrl .'"><img src="http://static.ak.fbcdn.net/rsrc.php/z2Y31/hash/cxrz4k7j.gif" /></a></div>'; | ||||
| 			$output['html'] .= '<div><a href="'. $logoutUrl .'"><span class="btn btn-primary">'.JText::_('COM_PHOCAGALLERY_FB_LOGOUT').'</span></a></div><p> </p>'; | ||||
| 			 | ||||
| 			/* | ||||
| 			$script = array(); | ||||
| 			$fields = array('name', 'uid', 'base_domain', 'secret', 'session_key', 'access_token', 'sig'); | ||||
| 			$script[] = 'function clearFbFields() {'; | ||||
| 			foreach ($fields as $field) { | ||||
| 				$script[] = ' document.getElementById(\'jform_'.$field.'\').value = \'\';'; | ||||
| 			} | ||||
| 			$script[] = '}'; | ||||
|  | ||||
| 			// Add the script to the document head. | ||||
| 			JFactory::getDocument()->addScriptDeclaration(implode("\n", $script)); | ||||
| 			$uri = JURI::getInstance(); | ||||
| 			$loginUrl = $facebook->getLoginUrl(array('req_perms' => 'user_photos,user_groups,offline_access,publish_stream', 'cancel_url' => $uri->toString(), 'next' => $uri->toString())); | ||||
| 			 | ||||
| 			$output['log']	= 0; | ||||
| 			$output['html'] .= '<div><a onclick="clearFbFields()" href="'. $loginUrl .'">Clear and Fill data bu</a></div>';*/ | ||||
| 			 | ||||
| 		} else { | ||||
| 			 | ||||
| 		 | ||||
| 			/*$loginUrl = $facebook->getLoginUrl(array('req_perms' => 'user_photos,user_groups,offline_access,publish_stream,photo_upload,manage_pages', 'scope' => 'user_photos,user_groups,offline_access,publish_stream,photo_upload,manage_pages', 'cancel_url' => $uri->toString(), 'next' => $uri->toString())); | ||||
| 			*/ | ||||
| 			// v2.3 | ||||
| 			/* | ||||
| 			$loginUrl = $facebook->getLoginUrl(array('req_perms' => 'user_photos,user_groups,manage_pages', 'scope' => 'user_photos,user_groups,manage_pages', 'cancel_url' => $uri->toString(), 'next' => $uri->toString())); | ||||
| 			*/ | ||||
| 			// v2.5 | ||||
| 			$loginUrl = $facebook->getLoginUrl(array('req_perms' => 'user_photos,manage_pages,publish_actions', 'scope' => 'user_photos,manage_pages,publish_actions', 'cancel_url' => $uri->toString(), 'next' => $uri->toString())); | ||||
| 			 | ||||
| 			$output['log']	= 0; | ||||
| 			$output['html'] = '<div><a href="'. $loginUrl .'"><span class="btn btn-primary">'.JText::_('COM_PHOCAGALLERY_FB_LOGIN').'</span></a></div><p> </p>'; | ||||
| 			//$output['html'] = '<div><a href="'. $loginUrl .'"><img src="http://static.ak.fbcdn.net/rsrc.php/zB6N8/hash/4li2k73z.gif" /></a></div>'; | ||||
| 	 | ||||
| 		} | ||||
| 		$output['u']		= $u; | ||||
| 		$output['session'] 	= $session; | ||||
| 		 | ||||
| 		 | ||||
| 		return $output; | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
| 	 | ||||
| 	public static function getFbAlbums ($appid, $appidfanpage, $appsid, $session, $aid = 0, $albumN = array(), $next = '') { | ||||
| 		$facebook 	= self::getAppInstance($appid, $appsid); | ||||
| 		$facebook->setAccessToken($session['access_token']); | ||||
| 		 | ||||
| 		$albums['data'] = array(); | ||||
| 		// Change the uid to fan page id => Fan PAGE has other UID | ||||
| 		$userID = $newUID = $session['uid']; | ||||
| 		 | ||||
| 		$nextS = ''; | ||||
| 		if ($next != '') { | ||||
| 			$next	= parse_url($next, PHP_URL_QUERY); | ||||
| 			$nextS	= '?'.strip_tags($next); | ||||
| 		} | ||||
| 			 | ||||
| 		if (isset($appidfanpage) && $appidfanpage != '') { | ||||
| 			$newUID 	= $appidfanpage; | ||||
| 			$albums = $facebook->api("/".$newUID."/albums".$nextS); | ||||
| 		} else { | ||||
| 			$albums = $facebook->api("/me/albums".$nextS); | ||||
| 		} | ||||
| 		 | ||||
| 		/* $loginUrl = $facebook->getLoginUrl(array('scope' => 'user_photos')); | ||||
| 		if ($aid > 0) { | ||||
| 			// TO DO - if used | ||||
| 			$albums = $facebook->api(array('method' => 'photos.getAlbums', 'aids' => $aid)); | ||||
| 		} else { | ||||
| 			//$albums = $facebook->api(array('method' => 'photos.getAlbums', 'uid' => $newUID)); | ||||
| 			//$albums = $facebook->api(array('method' => 'photos.getAlbums')); | ||||
| 			$albums = $facebook->api("/me/albums"); | ||||
| 			 | ||||
| 		} */ | ||||
| 		if (!empty($albums['data'])) { | ||||
| 			$albumN[] = $albums['data']; | ||||
| 		} | ||||
| 		 | ||||
| 		if (isset($albums['paging']['next']) && $albums['paging']['next'] != '') { | ||||
| 			$albumN 	= self::getFbAlbums($appid, $appidfanpage, $appsid, $session, $aid, $albumN, $albums['paging']['next']); | ||||
| 		 | ||||
| 			 | ||||
| 		} | ||||
|  | ||||
| 		return $albumN; | ||||
| 	} | ||||
| 	 | ||||
| 	/* BY ID | ||||
| 	public function getFbAlbumsFan ($appid, $appsid, $session, $id = 0) { | ||||
| 		 | ||||
| 		$facebook 	= self::getAppInstance($appid, $appsid, $session); | ||||
| 		$facebook->setSession($session); | ||||
| 		$albums 	= false; | ||||
| 		$userID 	= $session['uid']; | ||||
|  | ||||
| 		if ($aid > 0) { | ||||
| 			$albums = $facebook->api('/' . $userID . '/albums'); | ||||
| 		} else { | ||||
| 			$albums = $facebook->api('/' . $userID . '/albums'); | ||||
| 		} | ||||
| 		return $albums['data']; | ||||
| 	}*/ | ||||
| 	 | ||||
| 	 | ||||
| 	 public static function getFbAlbumName ($appid, $appsid, $session, $aid) { | ||||
| 		$facebook 	= self::getAppInstance($appid, $appsid); | ||||
| 		$facebook->setAccessToken($session['access_token']); | ||||
| 		//$album = $facebook->api(array('method' => 'photos.getAlbums', 'aids' => $aid)); | ||||
| 		$album = $facebook->api("/".$aid); | ||||
| 		$albumName 	= ''; | ||||
| 		if (isset($album['name']) && $album['name'] != '') { | ||||
| 			$albumName = $album['name']; | ||||
| 		} | ||||
| 		return $albumName; | ||||
| 	} | ||||
| 	 | ||||
| 	public static function getFbImages ($appid, $appsid, $session, &$fbAfter, $aid = 0, $limit = 0 ) { | ||||
| 		$facebook 	= self::getAppInstance($appid, $appsid); | ||||
| 		$facebook->setAccessToken($session['access_token']); | ||||
| 		$images['data'] = array(); | ||||
| 		 | ||||
| 		 | ||||
| 		$fields = 'id,name,source,picture,created,created_time,images'; | ||||
| 		if ($aid > 0) { | ||||
| 			//$images = $facebook->api(array('method' => 'photos.get', 'aid' => $aid)); | ||||
| 			if ((int)$limit > 0 && $fbAfter != '') { | ||||
| 				$images = $facebook->api("/".$aid."/photos", 'GET', array('limit' => $limit,'after'  => $fbAfter, 'fields' => $fields)); | ||||
| 			} else if ((int)$limit > 0 && $fbAfter == '') { | ||||
| 				$images = $facebook->api("/".$aid."/photos", 'GET', array('limit' => $limit, 'fields' => $fields)); | ||||
| 			} else { | ||||
| 				$images = $facebook->api("/".$aid."/photos", 'GET', array('fields' => $fields)); | ||||
| 			} | ||||
| 		} | ||||
| 		/* | ||||
| 		$images = $facebook->api("/".$aid."/photos"); | ||||
| 		id (String | ||||
| 		created_time (String | ||||
| 		from (Array | ||||
| 		height (Integer | ||||
| 		icon (String | ||||
| 		images (Array | ||||
| 		link (String | ||||
| 		name (String | ||||
| 		picture (String | ||||
| 		source (String | ||||
| 		updated_time (String | ||||
| 		width (Integer */ | ||||
|  | ||||
|  | ||||
| 		 | ||||
| 		$fbAfter = '';// Unset this variable and check again if there is still new after value (if there are more images to pagination) | ||||
| 		if (isset($images['paging'])) { | ||||
| 			$paging = $images['paging']; | ||||
| 			if (isset($paging['next']) && $paging['next'] != '') { | ||||
| 				$query = parse_url($paging['next'], PHP_URL_QUERY); | ||||
| 				parse_str($query, $parse); | ||||
| 				if (isset($parse['after'])) { | ||||
| 					$fbAfter = $parse['after']; // we return $fbAfter value in reference - new after value is set | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		return $images['data']; | ||||
| 	} | ||||
| 	 | ||||
| 	/* | ||||
| 	public static function getFbImages ($appid, $appsid, $session, $aid = 0) { | ||||
| 		$facebook 	= self::getAppInstance($appid, $appsid); | ||||
| 		$facebook->setAccessToken($session['access_token']); | ||||
| 		$images['data'] = array(); | ||||
| 		 | ||||
| 		if ($aid > 0) { | ||||
| 			//$images = $facebook->api(array('method' => 'photos.get', 'aid' => $aid)); | ||||
| 			$images = $facebook->api("/".$aid."/photos"); | ||||
| 		} | ||||
| 		return $images['data']; | ||||
| 	} | ||||
| 	*/ | ||||
| 	/* | ||||
| 	public static function getFbImages ($appid, $appsid, $session, $aid = 0) { | ||||
| 		$facebook 	= self::getAppInstance($appid, $appsid); | ||||
| 		$facebook->setAccessToken($session['access_token']); | ||||
| 		$images['data'] = array(); | ||||
| 		 | ||||
| 		if ($aid > 0) { | ||||
| 			//$images = $facebook->api(array('method' => 'photos.get', 'aid' => $aid)); | ||||
| 			//$images = $facebook->api("/".$aid."/photos"); | ||||
| 			$limit		= 25; | ||||
| 			$completeI	= array(); | ||||
| 			$partI 		= $facebook->api("/".$aid."/photos", 'GET', array('limit' => $limit) ); | ||||
|  | ||||
| 			$completeI[0] = $partI['data']; | ||||
| 			$i = 1; | ||||
| 			while ($partI['data']) { | ||||
| 				$completeI[1] = $partI['data']; | ||||
| 				$paging 	= $partI['paging']; | ||||
| 				if (isset($paging['next']) && $paging['next'] != '') { | ||||
| 					$query = parse_url($paging['next'], PHP_URL_QUERY); | ||||
| 					parse_str($query, $par);  | ||||
| 					if (isset($parse['limit']) && isset($parse['after'])) { | ||||
| 						$partI = $facebook->api("/".$aid."/photos", 'GET', array('limit' => $parse['limit'],'after'  => $parse['after'])); | ||||
| 						$i++; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 		} | ||||
| 		return $images['data']; | ||||
| 	} */ | ||||
| 	 | ||||
| 	/* BY ID | ||||
| 	public static function getFbImagesFan ($appid, $appsid, $session, $id = 0) { | ||||
| 		 | ||||
| 		 | ||||
| 		$facebook 	= self::getAppInstance($appid, $appsid, $session); | ||||
| 		$facebook->setSession($session); | ||||
| 		$images 	= false; | ||||
| 		if ($id > 0) { | ||||
|             $imagesFolder = $facebook->api('/' . $id . '/photos?limit=0'); | ||||
| 			$images = $imagesFolder['data']; | ||||
| 		} | ||||
| 		return $images; | ||||
| 	}*/ | ||||
| 	 | ||||
| 	public static function exportFbImage ($appid, $appidfanpage, $appsid, $session, $image, $aid = 0) { | ||||
| 		 | ||||
| 		$facebook 	= self::getAppInstance($appid, $appsid); | ||||
| 		$facebook->setAccessToken($session['access_token']);	 | ||||
| 		$facebook->setFileUploadSupport(true); | ||||
| 		 | ||||
| 		// Change the uid to fan page id => Fan PAGE has other UID | ||||
| 		$userID = $newUID = $session['uid']; | ||||
| 		$newToken = $session['access_token'];//Will be changed if needed (for fan page) | ||||
| 		if (isset($appidfanpage) && $appidfanpage != '') { | ||||
| 			$newUID 	= $appidfanpage; | ||||
| 			$params = array('access_token' => $session['access_token']); | ||||
| 			$accounts = $facebook->api('/'.$session['uid'].'/accounts', 'GET', $params); | ||||
| 			 | ||||
| 			foreach($accounts['data'] as $account) { | ||||
| 				if( $account['id'] == $appidfanpage || $account['name'] == $appidfanpage ){ | ||||
| 					$newToken = $account['access_token']; | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 		} | ||||
| 		 | ||||
| 		if ($aid > 0) { | ||||
| 			//$export = $facebook->api(array('method' => 'photos.upload', 'aid' => $aid, 'uid' => $newUID, 'caption' => $image['caption'], $image['filename'] => '@'.$image['fileorigabs'])); | ||||
| 				 | ||||
| 			$args = array('caption' => $image['caption'], 'aid' => $aid, 'uid' => $newUID, 'access_token' =>  $newToken); | ||||
| 			$args['image'] = '@'.$image['fileorigabs']; | ||||
| 			$export = $facebook->api('/'. $aid . '/photos', 'post', $args); | ||||
|  | ||||
| 			return $export; | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
| 	 | ||||
| 	public final function __clone() { | ||||
| 		throw new Exception('Function Error: Cannot clone instance of Singleton pattern', 500); | ||||
| 		return false; | ||||
| 	} | ||||
| } | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -0,0 +1,151 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @package   Phoca Gallery | ||||
|  * @author    Jan Pavelka - https://www.phoca.cz | ||||
|  * @copyright Copyright (C) Jan Pavelka https://www.phoca.cz | ||||
|  * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later | ||||
|  * @cms       Joomla | ||||
|  * @copyright Copyright (C) Open Source Matters. All rights reserved. | ||||
|  * @license   http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php | ||||
|  */ | ||||
|  | ||||
| defined('_JEXEC') or die; | ||||
| use Joomla\CMS\Factory; | ||||
| use Joomla\Registry\Registry; | ||||
| use Joomla\CMS\Language\Text; | ||||
| use Joomla\CMS\Uri\Uri; | ||||
| class PhocaGalleryFbSystem | ||||
| { | ||||
| 	public static function setSessionData($data) { | ||||
|  | ||||
| 		$session = array(); | ||||
| 		// Don't set the session, in other way the SIG will be not the same | ||||
| 		//$session['uid']				= $session['base_domain'] 	= $session['secret']	= ''; | ||||
| 		//$session['access_token'] 	= $session['session_key'] 	= $session['sig']		= ''; | ||||
| 		$session['expires']			= 0; | ||||
|  | ||||
|  | ||||
| 		if (isset($data->uid) && $data->uid != '') 					{$session['uid']			= $data->uid;} | ||||
| 		if (isset($data->base_domain) && $data->base_domain != '') 	{$session['base_domain']	= $data->base_domain;} | ||||
| 		if (isset($data->secret) && $data->secret != '') 			{$session['secret']			= $data->secret;} | ||||
| 		if (isset($data->session_key) && $data->session_key != '') 	{$session['session_key']	= $data->session_key;} | ||||
| 		if (isset($data->access_token) && $data->access_token != ''){$session['access_token']	= $data->access_token;} | ||||
| 		if (isset($data->sig) && $data->sig != '') 					{$session['sig']			= $data->sig;} | ||||
|  | ||||
| 		ksort($session); | ||||
| 		return $session; | ||||
| 	} | ||||
|  | ||||
| 	public static function getFbUserInfo ($id) { | ||||
|  | ||||
| 		$db = Factory::getDBO(); | ||||
|  | ||||
|        //build the list of categories | ||||
| 		$query = 'SELECT a.*' | ||||
| 		. ' FROM #__phocagallery_fb_users AS a' | ||||
| 		. ' WHERE a.id ='.(int)$id; | ||||
| 		$db->setQuery( $query ); | ||||
|  | ||||
|  | ||||
| 		$item = $db->loadObject(); | ||||
| 		return $item; | ||||
| 	} | ||||
|  | ||||
| 	public static function getCommentsParams($id) { | ||||
|  | ||||
| 		$o = array(); | ||||
| 		$item = self::getFbUserInfo($id); | ||||
|  | ||||
| 		if(isset($item->appid)) { | ||||
| 			$o['fb_comment_app_id'] = $item->appid; | ||||
| 		} | ||||
| 		if(isset($item->comments) && $item->comments != '') { | ||||
| 			$registry = new Registry; | ||||
| 			$registry->loadString($item->comments); | ||||
| 			$item->comments = $registry->toArray(); | ||||
| 			foreach($item->comments as $key => $value) { | ||||
| 				$o[$key] = $value; | ||||
| 			} | ||||
|  | ||||
| 		} | ||||
| 		return $o; | ||||
| 	} | ||||
|  | ||||
| 	public static function getImageFromCat($idCat, $idImg = 0) { | ||||
|  | ||||
| 		$db = Factory::getDBO(); | ||||
|  | ||||
| 		$nextImg = ''; | ||||
| 		if ($idImg > 0) { | ||||
| 			$nextImg = ' AND a.id > '.(int)$idImg; | ||||
| 		} | ||||
|  | ||||
| 		$query = 'SELECT a.*' | ||||
| 			.' FROM #__phocagallery AS a' | ||||
| 			.' WHERE a.catid = '.(int) $idCat | ||||
| 			.' AND a.published = 1' | ||||
| 			.' AND a.approved = 1' | ||||
| 			. $nextImg | ||||
| 			.' ORDER BY a.id ASC LIMIT 1'; | ||||
|  | ||||
| 		$db->setQuery( $query ); | ||||
| 		$item = $db->loadObject(); | ||||
|  | ||||
| 		if(!isset($item->id) || (isset($item->id) && $item->id < 1)) { | ||||
| 			$img['end'] = 1; | ||||
| 			return $img; | ||||
| 		} | ||||
|  | ||||
| 		if (isset($item->description) && $item->description != '') { | ||||
| 			$img['caption']	= $item->title .  ' - ' .$item->description; | ||||
| 		} else { | ||||
| 			$img['caption']	= $item->title; | ||||
| 		} | ||||
| 		//TO DO TEST EXT IMAGE | ||||
| 		if (isset($item->extid) && $item->extid != '') { | ||||
| 			$img['extid']		= $item->extid; | ||||
| 		} | ||||
| 		$img['id']				= $item->id; | ||||
| 		$img['title']			= $item->title; | ||||
| 		$img['filename']		= PhocaGalleryFile::getTitleFromFile($item->filename, 1); | ||||
| 		$img['fileorigabs']		= PhocaGalleryFile::getFileOriginal($item->filename); | ||||
|  | ||||
| 		return $img; | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Used while pagination | ||||
| 	 */ | ||||
| 	public static function renderProcessPage($id, $refreshUrl, $countInfo = '', $import = 0) { | ||||
|  | ||||
| 		if ($import == 0) { | ||||
| 			$stopText = Text::_( 'COM_PHOCAGALLERY_STOP_UPLOADING_FACEBOOK_IMAGES' ); | ||||
| 			$dataText = Text::_('COM_PHOCAGALLERY_FB_UPLOADING_DATA'); | ||||
| 		} else { | ||||
| 			$stopText = Text::_( 'COM_PHOCAGALLERY_STOP_IMPORTING_FACEBOOK_IMAGES' ); | ||||
| 			$dataText = Text::_('COM_PHOCAGALLERY_FB_IMPORTING_DATA'); | ||||
| 		} | ||||
|  | ||||
| 		echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n"; | ||||
| 		echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-en" lang="en-en" dir="ltr" >'. "\n"; | ||||
| 		echo '<head>'. "\n"; | ||||
| 		echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'. "\n\n"; | ||||
| 		echo '<title>'.$dataText.'</title>'. "\n"; | ||||
| 		echo '<link rel="stylesheet" href="'.Uri::root(true).'/media/com_phocagallery/css/administrator/phocagallery.css" type="text/css" />'; | ||||
|  | ||||
| 		echo '</head>'. "\n"; | ||||
| 		echo '<body>'. "\n"; | ||||
|  | ||||
| 		echo '<div style="text-align:right;padding:10px"><a style="font-family: sans-serif, Arial;font-weight:bold;color:#fc0000;font-size:14px;" href="index.php?option=com_phocagallery&task=phocagalleryc.edit&id='.(int)$id.'">' .$stopText.'</a></div>'; | ||||
|  | ||||
| 		echo '<div id="loading-ext-img-processp" style="font-family: sans-serif, Arial;font-weight:normal;color:#666;font-size:14px;padding:10px"><div class="loading"><div class="ph-lds-ellipsis"><div></div><div></div><div></div><div></div></div><div> </div><div><center>'.$dataText.'</center></div>'; | ||||
|  | ||||
| 		echo $countInfo; | ||||
| 		echo '</div></div>'; | ||||
|  | ||||
| 		echo '<meta http-equiv="refresh" content="2;url='.$refreshUrl.'" />'; | ||||
| 		echo '</body></html>'; | ||||
| 		exit; | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -0,0 +1,204 @@ | ||||
| <?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\Object\CMSObject; | ||||
| use Joomla\CMS\Filesystem\File; | ||||
| use Joomla\CMS\Filesystem\Path; | ||||
| use Joomla\CMS\Factory; | ||||
| jimport( 'joomla.filesystem.folder' ); | ||||
| jimport( 'joomla.filesystem.file' ); | ||||
| phocagalleryimport('phocagallery.image.image'); | ||||
| phocagalleryimport('phocagallery.path.path'); | ||||
|  | ||||
| class PhocaGalleryFile | ||||
| { | ||||
| 	public static function getTitleFromFile(&$filename, $displayExt = 0) { | ||||
|  | ||||
| 		if (!isset($filename)) { | ||||
| 			$filename = ''; | ||||
| 		} | ||||
|  | ||||
| 		$filename 			= str_replace('//', '/', $filename); | ||||
| 		$filename			= str_replace('\\', '/', $filename); | ||||
| 		$folderArray		= explode('/', $filename);// Explode the filename (folder and file name) | ||||
| 		$countFolderArray	= count($folderArray);// Count this array | ||||
| 		$lastArrayValue 	= $countFolderArray - 1;// The last array value is (Count array - 1) | ||||
|  | ||||
| 		$title = new stdClass(); | ||||
| 		$title->with_extension 		= $folderArray[$lastArrayValue]; | ||||
| 		$title->without_extension	= PhocaGalleryFile::removeExtension($folderArray[$lastArrayValue]); | ||||
|  | ||||
| 		if ($displayExt == 1) { | ||||
| 			return $title->with_extension; | ||||
| 		} else if ($displayExt == 0) { | ||||
| 			return $title->without_extension; | ||||
| 		} else { | ||||
| 			return $title; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public static function removeExtension($filename) { | ||||
| 		return substr($filename, 0, strrpos( $filename, '.' )); | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	public static function getMimeType($filename) { | ||||
| 		$ext = File::getExt($filename); | ||||
| 		switch(strtolower($ext)) { | ||||
| 			case 'png': | ||||
| 				$mime = 'image/png'; | ||||
| 			break; | ||||
| 			case 'jpg': | ||||
| 			case 'jpeg': | ||||
| 				$mime = 'image/jpeg'; | ||||
| 			break; | ||||
| 			case 'gif': | ||||
| 				$mime = 'image/gif'; | ||||
| 			break; | ||||
| 			case 'webp': | ||||
| 				$mime = 'image/webp'; | ||||
| 			break; | ||||
| 			case 'avif': | ||||
| 				$mime = 'image/avif'; | ||||
| 			break; | ||||
| 			Default: | ||||
| 				$mime = ''; | ||||
| 			break; | ||||
| 		} | ||||
| 		return $mime; | ||||
| 	} | ||||
|  | ||||
| 	public static function getFileSize($filename, $readable = 1) { | ||||
|  | ||||
| 		$path			= PhocaGalleryPath::getPath(); | ||||
| 		$fileNameAbs	= Path::clean($path->image_abs . $filename); | ||||
|  | ||||
| 		if (!File::exists($fileNameAbs)) { | ||||
| 			$fileNameAbs	= $path->image_abs_front . 'phoca_thumb_l_no_image.png'; | ||||
| 		} | ||||
|  | ||||
| 		if ($readable == 1) { | ||||
| 			return PhocaGalleryFile::getFileSizeReadable(filesize($fileNameAbs)); | ||||
| 		} else { | ||||
| 			return filesize($fileNameAbs); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * http://aidanlister.com/repos/v/function.size_readable.php | ||||
| 	 */ | ||||
| 	public static function getFileSizeReadable ($size, $retstring = null, $onlyMB = false) { | ||||
|  | ||||
| 		if ($onlyMB) { | ||||
| 			$sizes = array('B', 'kB', 'MB'); | ||||
| 		} else { | ||||
| 			$sizes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); | ||||
|         } | ||||
|  | ||||
|  | ||||
| 		if ($retstring === null) { $retstring = '%01.2f %s'; } | ||||
|         $lastsizestring = end($sizes); | ||||
|  | ||||
|         foreach ($sizes as $sizestring) { | ||||
|                 if ($size < 1024) { break; } | ||||
|                 if ($sizestring != $lastsizestring) { $size /= 1024; } | ||||
|         } | ||||
|  | ||||
|         if ($sizestring == $sizes[0]) { $retstring = '%01d %s'; } // Bytes aren't normally fractional | ||||
|         return sprintf($retstring, $size, $sizestring); | ||||
| 	} | ||||
|  | ||||
| 	public static function getFileOriginal($filename, $rel = 0) { | ||||
| 		$path	= PhocaGalleryPath::getPath(); | ||||
| 		if ($rel == 1) { | ||||
| 			return str_replace('//', '/', $path->image_rel . $filename); | ||||
| 		} else { | ||||
| 			return Path::clean($path->image_abs . $filename); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public static function getFileFormat($filename) { | ||||
| 		$path	= PhocaGalleryPath::getPath(); | ||||
| 		$file	= Path::clean($path->image_abs . $filename); | ||||
| 		$size	= getimagesize($file); | ||||
| 		if (isset($size[0]) && isset($size[1]) && (int)$size[1] > (int)$size[0]) { | ||||
| 			return 2; | ||||
| 		} else { | ||||
| 			return 1; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public static function existsFileOriginal($filename) { | ||||
| 		$fileOriginal = PhocaGalleryFile::getFileOriginal($filename); | ||||
| 		if (File::exists($fileOriginal)) { | ||||
| 			return true; | ||||
| 		} else { | ||||
| 			return false; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	public static function deleteFile ($filename) { | ||||
| 		$fileOriginal = PhocaGalleryFile::getFileOriginal($filename); | ||||
| 		if (File::exists($fileOriginal)){ | ||||
| 			File::delete($fileOriginal); | ||||
| 			return true; | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	public static function existsCss($file, $type) { | ||||
| 		$path = self::getCSSPath($type); | ||||
| 		if (file_exists($path.$file) && $file != '') { | ||||
| 			return $path.$file; | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	public static function getCSSPath($type, $rel = 0) { | ||||
| 		$paths		= PhocaGalleryPath::getPath(); | ||||
| 		if ($rel == 1) { | ||||
| 			if ($type == 1) { | ||||
| 				return $paths->media_css_rel . 'main/'; | ||||
| 			} else { | ||||
| 				return $paths->media_css_rel . 'custom/'; | ||||
| 			} | ||||
| 		} else { | ||||
| 			if ($type == 1) { | ||||
| 				return Path::clean($paths->media_css_abs . 'main/'); | ||||
| 			} else { | ||||
| 				return	Path::clean($paths->media_css_abs . 'custom/'); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public static function getCSSFile($id = 0, $fullPath = 0) { | ||||
| 		if ((int)$id > 0) { | ||||
| 			$db = Factory::getDBO(); | ||||
| 			$query = 'SELECT a.filename as filename, a.type as type' | ||||
| 				.' FROM #__phocagallery_styles AS a' | ||||
| 			    .' WHERE a.id = '.(int) $id | ||||
| 				.' ORDER BY a.id'; | ||||
| 			$db->setQuery($query, 0, 1); | ||||
| 			$filename = $db->loadObject(); | ||||
| 			if (isset($filename->filename) && $filename->filename != '') { | ||||
| 				if ($fullPath == 1 && isset($filename->type)) { | ||||
| 					return self::getCSSPath($filename->type). $filename->filename; | ||||
| 				} else { | ||||
| 					return $filename->filename; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return false; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,124 @@ | ||||
| <?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\Filesystem\File; | ||||
| jimport( 'joomla.filesystem.folder' ); | ||||
| jimport( 'joomla.filesystem.file' ); | ||||
|  | ||||
| class PhocaGalleryFileDownload | ||||
| { | ||||
| 	public static function download($item, $backLink, $extLink = 0) { | ||||
|  | ||||
|  | ||||
| 		// If you comment or remove the following line, user will be able to download external images | ||||
| 		// but it can happen that such will be stored on your server in root (the example is picasa images) | ||||
| 		$extLink = 0; | ||||
|  | ||||
| 		$app	= Factory::getApplication(); | ||||
|  | ||||
| 		if (empty($item)) { | ||||
| 			$msg = Text::_('COM_PHOCAGALLERY_ERROR_DOWNLOADING_FILE'); | ||||
| 			$app->enqueueMessage($msg, 'error'); | ||||
| 			$app->redirect($backLink); | ||||
| 			return false; | ||||
| 		} else { | ||||
| 			if ($extLink == 0) { | ||||
| 				phocagalleryimport('phocagallery.file.file'); | ||||
| 				$fileOriginal = PhocaGalleryFile::getFileOriginal($item->filenameno); | ||||
|  | ||||
| 				if (!File::exists($fileOriginal)) { | ||||
| 					$msg = Text::_('COM_PHOCAGALLERY_ERROR_DOWNLOADING_FILE'); | ||||
| 					$app->enqueueMessage($msg, 'error'); | ||||
| 					$app->redirect($backLink); | ||||
| 					return false; | ||||
| 				} | ||||
| 				$fileToDownload 	= $item->filenameno; | ||||
| 				$fileNameToDownload	= $item->filename; | ||||
| 			} else { | ||||
| 				$fileToDownload 	= $item->exto; | ||||
| 				$fileNameToDownload	= $item->title; | ||||
| 				$fileOriginal		= $item->exto; | ||||
| 			} | ||||
|  | ||||
| 			// Clears file status cache | ||||
| 			clearstatcache(); | ||||
| 			$fileOriginal	= $fileOriginal; | ||||
| 			$fileSize 		= @filesize($fileOriginal); | ||||
| 			$mimeType 		= PhocaGalleryFile::getMimeType($fileToDownload); | ||||
| 			$fileName		= $fileNameToDownload; | ||||
|  | ||||
| 			if ($extLink > 0) { | ||||
| 				$content = ''; | ||||
| 				if (function_exists('curl_init')) { | ||||
| 					$ch = curl_init(); | ||||
| 					curl_setopt($ch, CURLOPT_URL, $fileOriginal); | ||||
| 					curl_setopt($ch, CURLOPT_HEADER, 0); | ||||
| 					curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||||
| 					$downloadedFile = fopen($fileName, 'w+'); | ||||
| 					curl_setopt($ch, CURLOPT_FILE, $downloadedFile); | ||||
| 					$content = curl_exec ($ch); | ||||
| 					$fileSize= strlen($content); | ||||
| 					curl_close ($ch); | ||||
| 					fclose($downloadedFile); | ||||
| 				} | ||||
| 				if ($content != '') { | ||||
| 					// Clean the output buffer | ||||
| 					ob_end_clean(); | ||||
|  | ||||
| 					header("Cache-Control: public, must-revalidate"); | ||||
| 					header('Cache-Control: pre-check=0, post-check=0, max-age=0'); | ||||
| 					header("Pragma: no-cache"); | ||||
| 					header("Expires: 0"); | ||||
| 					header("Content-Description: File Transfer"); | ||||
| 					header("Expires: Sat, 30 Dec 1990 07:07:07 GMT"); | ||||
| 					header("Content-Type: " . (string)$mimeType); | ||||
|  | ||||
| 					header("Content-Length: ". (string)$fileSize); | ||||
|  | ||||
| 					header('Content-Disposition: attachment; filename="'.$fileName.'"'); | ||||
| 					header("Content-Transfer-Encoding: binary\n"); | ||||
|  | ||||
| 					echo $content; | ||||
| 					exit; | ||||
|  | ||||
| 				} | ||||
| 			} else { | ||||
|  | ||||
| 				// Clean the output buffer | ||||
| 				ob_end_clean(); | ||||
|  | ||||
| 				header("Cache-Control: public, must-revalidate"); | ||||
| 				header('Cache-Control: pre-check=0, post-check=0, max-age=0'); | ||||
| 				header("Pragma: no-cache"); | ||||
| 				header("Expires: 0"); | ||||
| 				header("Content-Description: File Transfer"); | ||||
| 				header("Expires: Sat, 30 Dec 1990 07:07:07 GMT"); | ||||
| 				header("Content-Type: " . (string)$mimeType); | ||||
|  | ||||
| 				// Problem with IE | ||||
| 				if ($extLink == 0) { | ||||
| 					header("Content-Length: ". (string)$fileSize); | ||||
| 				} | ||||
|  | ||||
| 				header('Content-Disposition: attachment; filename="'.$fileName.'"'); | ||||
| 				header("Content-Transfer-Encoding: binary\n"); | ||||
|  | ||||
| 				@readfile($fileOriginal); | ||||
| 				exit; | ||||
| 			} | ||||
| 		} | ||||
| 		return false; | ||||
|  | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,147 @@ | ||||
| <?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\Filesystem\File; | ||||
| use Joomla\CMS\Filesystem\Path; | ||||
| use Joomla\CMS\Component\ComponentHelper; | ||||
| jimport( 'joomla.filesystem.folder' ); | ||||
| jimport( 'joomla.filesystem.file' ); | ||||
| phocagalleryimport('phocagallery.image.image'); | ||||
| phocagalleryimport('phocagallery.path.path'); | ||||
|  | ||||
| class PhocaGalleryFileFolder | ||||
| { | ||||
| 	/* | ||||
| 	 * Clear Thumbs folder - if there are files in the thumbs directory but not original files e.g.: | ||||
| 	 * phoca_thumbs_l_some.jpg exists in thumbs directory but some.jpg doesn't exists - delete it | ||||
| 	 */ | ||||
| 	public static function cleanThumbsFolder() { | ||||
| 		//Get folder variables from Helper | ||||
| 		$path = PhocaGalleryPath::getPath(); | ||||
|  | ||||
| 		// Initialize variables | ||||
| 		$pathOrigImg 		= $path->image_abs; | ||||
| 		$pathOrigImgServer 	= str_replace('\\', '/', $path->image_abs); | ||||
|  | ||||
| 		// Get the list of files and folders from the given folder | ||||
| 		$fileList 	= Folder::files($pathOrigImg, '', true, true); | ||||
|  | ||||
| 		// Iterate over the files if they exist | ||||
| 		if ($fileList !== false) { | ||||
| 			foreach ($fileList as $file) { | ||||
| 				if (File::exists($file) && substr($file, 0, 1) != '.' && strtolower($file) !== 'index.html') { | ||||
|  | ||||
| 					//Clean absolute path | ||||
| 					$file = str_replace('\\', '/', Path::clean($file)); | ||||
|  | ||||
| 					$positions = strpos($file, "phoca_thumb_s_");//is there small thumbnail | ||||
| 					$positionm = strpos($file, "phoca_thumb_m_");//is there medium thumbnail | ||||
| 					$positionl = strpos($file, "phoca_thumb_l_");//is there large thumbnail | ||||
|  | ||||
| 					//Clean small thumbnails if original file doesn't exist | ||||
| 					if ($positions === false) {} | ||||
| 					else { | ||||
| 						$filenameThumbs = $file;//only thumbnails will be listed | ||||
| 						$fileNameOrigs	= str_replace ('thumbs/phoca_thumb_s_', '', $file);//get fictive original files | ||||
|  | ||||
| 						//There is Thumbfile but not Originalfile - we delete it | ||||
| 						if (File::exists($filenameThumbs) && !File::exists($fileNameOrigs)) { | ||||
| 							File::delete($filenameThumbs); | ||||
| 						} | ||||
| 					//  Reverse | ||||
| 					//  $filenameThumb = PhocaGalleryHelper::getTitleFromFilenameWithExt($file); | ||||
| 					//	$fileNameOriginal = PhocaGalleryHelper::getTitleFromFilenameWithExt($file); | ||||
| 					//	$filenameThumb = str_replace ($fileNameOriginal, 'thumbs/phoca_thumb_m_' . $fileNameOriginal, $file); | ||||
| 					} | ||||
|  | ||||
| 					//Clean medium thumbnails if original file doesn't exist | ||||
| 					if ($positionm === false) {} | ||||
| 					else { | ||||
| 						$filenameThumbm = $file;//only thumbnails will be listed | ||||
| 						$fileNameOrigm 	= str_replace ('thumbs/phoca_thumb_m_', '', $file);//get fictive original files | ||||
|  | ||||
| 						//There is Thumbfile but not Originalfile - we delete it | ||||
| 						if (File::exists($filenameThumbm) && !File::exists($fileNameOrigm)) { | ||||
| 							File::delete($filenameThumbm); | ||||
| 						} | ||||
| 					} | ||||
|  | ||||
| 					//Clean large thumbnails if original file doesn't exist | ||||
| 					if ($positionl === false) {} | ||||
| 					else { | ||||
| 						$filenameThumbl = $file;//only thumbnails will be listed | ||||
| 						$fileNameOrigl 	= str_replace ('thumbs/phoca_thumb_l_', '', $file);//get fictive original files | ||||
|  | ||||
| 						//There is Thumbfile but not Originalfile - we delete it | ||||
| 						if (File::exists($filenameThumbl) && !File::exists($fileNameOrigl)) { | ||||
| 							File::delete($filenameThumbl); | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public static function createFolder($folder, &$errorMsg) { | ||||
| 		$paramsC = ComponentHelper::getParams('com_phocagallery'); | ||||
| 		$folder_permissions = $paramsC->get( 'folder_permissions', 0755 ); | ||||
| 		// Doesn't work on some servers | ||||
| 		//$folder_permissions = octdec((int)$folder_permissions); | ||||
|  | ||||
| 		$path 	= PhocaGalleryPath::getPath(); | ||||
| 		$folder = Path::clean($path->image_abs . $folder); | ||||
| 		if (strlen($folder) > 0) { | ||||
| 			if (!Folder::exists($folder) && !File::exists($folder)) { | ||||
|  | ||||
| 				// Because of problems on some servers: | ||||
| 				// It is temporary solution | ||||
| 				switch((int)$folder_permissions) { | ||||
| 					case 777: | ||||
| 						Folder::create($folder, 0777 ); | ||||
| 					break; | ||||
| 					case 705: | ||||
| 						Folder::create($folder, 0705 ); | ||||
| 					break; | ||||
| 					case 666: | ||||
| 						Folder::create($folder, 0666 ); | ||||
| 					break; | ||||
| 					case 644: | ||||
| 						Folder::create($folder, 0644 ); | ||||
| 					break; | ||||
| 					case 755: | ||||
| 					Default: | ||||
| 						Folder::create($folder, 0755 ); | ||||
| 					break; | ||||
| 				} | ||||
| 				//JFolder::create($folder, $folder_permissions ); | ||||
| 				if (isset($folder)) { | ||||
|  | ||||
| 					$data = "<html>\n<body bgcolor=\"#FFFFFF\">\n</body>\n</html>"; | ||||
| 					File::write($folder. '/'. "index.html", $data); | ||||
| 				} | ||||
| 				// folder was not created | ||||
| 				if (!Folder::exists($folder)) { | ||||
| 					$errorMsg = "CreatingFolder"; | ||||
| 					return false; | ||||
| 				} | ||||
| 			} else { | ||||
| 				$errorMsg = "FolderExists"; | ||||
| 				return false; | ||||
| 			} | ||||
| 		} else { | ||||
| 			$errorMsg = "FolderNameEmpty"; | ||||
| 			return false; | ||||
| 		} | ||||
| 		return true; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,127 @@ | ||||
| <?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\Factory; | ||||
| use Joomla\CMS\Filesystem\Path; | ||||
| use Joomla\CMS\Filesystem\Folder; | ||||
| use Joomla\CMS\Filesystem\File; | ||||
| use Joomla\CMS\Object\CMSObject; | ||||
| jimport( 'joomla.filesystem.folder' ); | ||||
| jimport( 'joomla.filesystem.file' ); | ||||
| phocagalleryimport('phocagallery.image.image'); | ||||
| phocagalleryimport('phocagallery.path.path'); | ||||
| phocagalleryimport('phocagallery.file.filefolder'); | ||||
| setlocale(LC_ALL, 'C.UTF-8', 'C'); | ||||
|  | ||||
| class PhocaGalleryFileFolderList | ||||
| { | ||||
| 	public static function getList($small = 0, $medium = 0, $large = 0, $refreshUrl = '') { | ||||
| 		static $list; | ||||
|  | ||||
| 		$params				= ComponentHelper::getParams( 'com_phocagallery' ); | ||||
| 		$clean_thumbnails 	= $params->get( 'clean_thumbnails', 0 ); | ||||
|  | ||||
| 		// Only process the list once per request | ||||
| 		if (is_array($list)) { | ||||
| 			return $list; | ||||
| 		} | ||||
|  | ||||
| 		// Get current path from request | ||||
| 		$current = Factory::getApplication()->input->get('folder', '', 'path'); | ||||
|  | ||||
| 		// If undefined, set to empty | ||||
| 		if ($current == 'undefined') { | ||||
| 			$current = ''; | ||||
| 		} | ||||
|  | ||||
| 		//Get folder variables from Helper | ||||
| 		$path = PhocaGalleryPath::getPath(); | ||||
|  | ||||
| 		// Initialize variables | ||||
| 		if (strlen($current) > 0) { | ||||
| 			$origPath = Path::clean($path->image_abs.$current); | ||||
| 		} else { | ||||
| 			$origPath = $path->image_abs; | ||||
| 		} | ||||
| 		$origPathServer = str_replace('\\', '/', $path->image_abs); | ||||
|  | ||||
| 		$images 	= array (); | ||||
| 		$folders 	= array (); | ||||
|  | ||||
| 		// Get the list of files and folders from the given folder | ||||
| 		$fileList 		= Folder::files($origPath); | ||||
| 		$folderList 	= Folder::folders($origPath, '', false, false, array(0 => 'thumbs')); | ||||
|  | ||||
| 		if(is_array($fileList) && !empty($fileList)) { | ||||
| 			natcasesort($fileList); | ||||
| 		} | ||||
|  | ||||
| 		$field			= Factory::getApplication()->input->get('field');; | ||||
| 		$refreshUrl 	= $refreshUrl . '&folder='.$current.'&field='.$field; | ||||
|  | ||||
|  | ||||
| 		// Iterate over the files if they exist | ||||
| 		//file - abc.img, file_no - folder/abc.img | ||||
| 		if ($fileList !== false) { | ||||
| 			foreach ($fileList as $file) { | ||||
|  | ||||
| 				$ext = strtolower(File::getExt($file)); | ||||
| 				// Don't display thumbnails from defined files (don't save them into a database)... | ||||
| 				$dontCreateThumb	= PhocaGalleryFileThumbnail::dontCreateThumb($file); | ||||
| 				if ($dontCreateThumb == 1) { | ||||
| 					$ext = '';// WE USE $ext FOR NOT CREATE A THUMBNAIL CLAUSE | ||||
| 				} | ||||
| 				if ($ext == 'jpg' || $ext == 'png' || $ext == 'gif' || $ext == 'jpeg' || $ext == 'webp' || $ext == 'avif') { | ||||
|  | ||||
| 					if (File::exists($origPath. '/'. $file) && substr($file, 0, 1) != '.' && strtolower($file) !== 'index.html') { | ||||
|  | ||||
| 						//Create thumbnails small, medium, large | ||||
| 						$fileNo			= $current . "/" . $file; | ||||
| 						$fileThumb 		= PhocaGalleryFileThumbnail::getOrCreateThumbnail($fileNo, $refreshUrl, $small, $medium, $large); | ||||
|  | ||||
| 						$tmp 						= new CMSObject(); | ||||
| 						$tmp->name 					= $fileThumb['name']; | ||||
| 						$tmp->nameno 				= $fileThumb['name_no']; | ||||
| 						$tmp->linkthumbnailpath		= $fileThumb['thumb_name_m_no_rel']; | ||||
| 						$tmp->linkthumbnailpathabs	= $fileThumb['thumb_name_m_no_abs']; | ||||
| 						$images[] 					= $tmp; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		//Clean Thumbs Folder if there are thumbnail files but not original file | ||||
| 		if ($clean_thumbnails == 1) { | ||||
| 			PhocaGalleryFileFolder::cleanThumbsFolder(); | ||||
| 		} | ||||
| 		// - - - - - - - - - - - - | ||||
|  | ||||
| 		// Iterate over the folders if they exist | ||||
|  | ||||
| 		if ($folderList !== false) { | ||||
| 			foreach ($folderList as $folder) { | ||||
| 				$tmp 							= new CMSObject(); | ||||
| 				$tmp->name 						= basename($folder); | ||||
| 				$tmp->path_with_name 			= str_replace('\\', '/', Path::clean($origPath . '/'. $folder)); | ||||
| 				$tmp->path_without_name_relative= $path->image_abs . str_replace($origPathServer, '', $tmp->path_with_name); | ||||
| 				$tmp->path_with_name_relative_no= str_replace($origPathServer, '', $tmp->path_with_name); | ||||
|  | ||||
|  | ||||
| 				$folders[] = $tmp; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		$list = array('folders' => $folders, 'Images' => $images); | ||||
| 		return $list; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,675 @@ | ||||
| <?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\Object\CMSObject; | ||||
| use Joomla\CMS\Filesystem\Path; | ||||
| use Joomla\CMS\Filesystem\File; | ||||
| use Joomla\CMS\Component\ComponentHelper; | ||||
| use Joomla\CMS\Filesystem\Folder; | ||||
| jimport( 'joomla.filesystem.folder' ); | ||||
| jimport( 'joomla.filesystem.file' ); | ||||
| phocagalleryimport('phocagallery.path.path'); | ||||
| phocagalleryimport('phocagallery.file.file'); | ||||
|  | ||||
| class PhocaGalleryFileThumbnail | ||||
| { | ||||
| 	/* | ||||
| 	 *Get thumbnailname | ||||
| 	 */ | ||||
| 	public static function getThumbnailName($filename, $size) { | ||||
|  | ||||
| 		$path		= PhocaGalleryPath::getPath(); | ||||
| 		$title 		= PhocaGalleryFile::getTitleFromFile($filename , 1); | ||||
|  | ||||
| 		$thumbName	= new CMSObject(); | ||||
|  | ||||
| 		switch ($size) { | ||||
| 			case 'large': | ||||
| 			$fileNameThumb 	= 'phoca_thumb_l_'. $title; | ||||
| 			$thumbName->abs	= Path::clean(str_replace($title, 'thumbs'. '/'. $fileNameThumb, $path->image_abs . $filename)); | ||||
| 			$thumbName->rel	= str_replace ($title, 'thumbs/' . $fileNameThumb, $path->image_rel . $filename); | ||||
| 			break; | ||||
|  | ||||
| 			case 'large1': | ||||
| 			$fileNameThumb 	= 'phoca_thumb_l1_'. $title; | ||||
| 			$thumbName->abs	= Path::clean(str_replace($title, 'thumbs'. '/'. $fileNameThumb, $path->image_abs . $filename)); | ||||
| 			$thumbName->rel	= str_replace ($title, 'thumbs/' . $fileNameThumb, $path->image_rel . $filename); | ||||
| 			break; | ||||
|  | ||||
| 			case 'medium1': | ||||
| 			$fileNameThumb 	= 'phoca_thumb_m1_'. $title; | ||||
| 			$thumbName->abs	= Path::clean(str_replace($title, 'thumbs' . '/'. $fileNameThumb, $path->image_abs . $filename)); | ||||
| 			$thumbName->rel	= str_replace ($title, 'thumbs/' . $fileNameThumb, $path->image_rel . $filename); | ||||
| 			break; | ||||
|  | ||||
| 			case 'medium2': | ||||
| 			$fileNameThumb 	= 'phoca_thumb_m2_'. $title; | ||||
| 			$thumbName->abs	= Path::clean(str_replace($title, 'thumbs' . '/'. $fileNameThumb, $path->image_abs . $filename)); | ||||
| 			$thumbName->rel	= str_replace ($title, 'thumbs/' . $fileNameThumb, $path->image_rel . $filename); | ||||
| 			break; | ||||
|  | ||||
| 			case 'medium3': | ||||
| 			$fileNameThumb 	= 'phoca_thumb_m3_'. $title; | ||||
| 			$thumbName->abs	= Path::clean(str_replace($title, 'thumbs' . '/'. $fileNameThumb, $path->image_abs . $filename)); | ||||
| 			$thumbName->rel	= str_replace ($title, 'thumbs/' . $fileNameThumb, $path->image_rel . $filename); | ||||
| 			break; | ||||
|  | ||||
| 			case 'medium': | ||||
| 			$fileNameThumb 	= 'phoca_thumb_m_'. $title; | ||||
| 			$thumbName->abs	= Path::clean(str_replace($title, 'thumbs'. '/'. $fileNameThumb, $path->image_abs . $filename)); | ||||
| 			$thumbName->rel	= str_replace ($title, 'thumbs/' . $fileNameThumb, $path->image_rel . $filename); | ||||
| 			break; | ||||
|  | ||||
|  | ||||
| 			case 'small1': | ||||
| 			$fileNameThumb 	= 'phoca_thumb_s1_'. $title; | ||||
| 			$thumbName->abs	= Path::clean(str_replace($title, 'thumbs' . '/'. $fileNameThumb, $path->image_abs . $filename)); | ||||
| 			$thumbName->rel	= str_replace ($title, 'thumbs/' . $fileNameThumb, $path->image_rel . $filename); | ||||
| 			break; | ||||
|  | ||||
| 			case 'small2': | ||||
| 			$fileNameThumb 	= 'phoca_thumb_s2_'. $title; | ||||
| 			$thumbName->abs	= Path::clean(str_replace($title, 'thumbs' . '/'. $fileNameThumb, $path->image_abs . $filename)); | ||||
| 			$thumbName->rel	= str_replace ($title, 'thumbs/' . $fileNameThumb, $path->image_rel . $filename); | ||||
| 			break; | ||||
|  | ||||
| 			case 'small3': | ||||
| 			$fileNameThumb 	= 'phoca_thumb_s3_'. $title; | ||||
| 			$thumbName->abs	= Path::clean(str_replace($title, 'thumbs' . '/'. $fileNameThumb, $path->image_abs . $filename)); | ||||
| 			$thumbName->rel	= str_replace ($title, 'thumbs/' . $fileNameThumb, $path->image_rel . $filename); | ||||
| 			break; | ||||
|  | ||||
| 			default: | ||||
| 			case 'small': | ||||
| 			$fileNameThumb 	= 'phoca_thumb_s_'. $title; | ||||
| 			$thumbName->abs	= Path::clean(str_replace($title, 'thumbs' . '/'. $fileNameThumb, $path->image_abs . $filename)); | ||||
| 			$thumbName->rel	= str_replace ($title, 'thumbs/' . $fileNameThumb, $path->image_rel . $filename); | ||||
| 			break; | ||||
| 		} | ||||
|  | ||||
| 		$thumbName->rel = str_replace('//', '/', $thumbName->rel); | ||||
|  | ||||
| 		return $thumbName; | ||||
| 	} | ||||
|  | ||||
| 	public static function deleteFileThumbnail ($filename, $small=0, $medium=0, $large=0) { | ||||
|  | ||||
| 		if ($small == 1) { | ||||
| 			$fileNameThumbS = PhocaGalleryFileThumbnail::getThumbnailName ($filename, 'small'); | ||||
| 			if (File::exists($fileNameThumbS->abs)) { | ||||
| 				File::delete($fileNameThumbS->abs); | ||||
| 			} | ||||
| 			$fileNameThumbS = PhocaGalleryFileThumbnail::getThumbnailName ($filename, 'small1'); | ||||
| 			if (File::exists($fileNameThumbS->abs)) { | ||||
| 				File::delete($fileNameThumbS->abs); | ||||
| 			} | ||||
| 			$fileNameThumbS = PhocaGalleryFileThumbnail::getThumbnailName ($filename, 'small2'); | ||||
| 			if (File::exists($fileNameThumbS->abs)) { | ||||
| 				File::delete($fileNameThumbS->abs); | ||||
| 			} | ||||
| 			$fileNameThumbS = PhocaGalleryFileThumbnail::getThumbnailName ($filename, 'small3'); | ||||
| 			if (File::exists($fileNameThumbS->abs)) { | ||||
| 				File::delete($fileNameThumbS->abs); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		if ($medium == 1) { | ||||
| 			$fileNameThumbM = PhocaGalleryFileThumbnail::getThumbnailName ($filename, 'medium'); | ||||
| 			if (File::exists($fileNameThumbM->abs)) { | ||||
| 				File::delete($fileNameThumbM->abs); | ||||
| 			} | ||||
| 			$fileNameThumbM = PhocaGalleryFileThumbnail::getThumbnailName ($filename, 'medium1'); | ||||
| 			if (File::exists($fileNameThumbM->abs)) { | ||||
| 				File::delete($fileNameThumbM->abs); | ||||
| 			} | ||||
| 			$fileNameThumbM = PhocaGalleryFileThumbnail::getThumbnailName ($filename, 'medium2'); | ||||
| 			if (File::exists($fileNameThumbM->abs)) { | ||||
| 				File::delete($fileNameThumbM->abs); | ||||
| 			} | ||||
| 			$fileNameThumbM = PhocaGalleryFileThumbnail::getThumbnailName ($filename, 'medium3'); | ||||
| 			if (File::exists($fileNameThumbM->abs)) { | ||||
| 				File::delete($fileNameThumbM->abs); | ||||
| 			} | ||||
|  | ||||
| 		} | ||||
|  | ||||
| 		if ($large == 1) { | ||||
| 			$fileNameThumbL = PhocaGalleryFileThumbnail::getThumbnailName ($filename, 'large'); | ||||
| 			if (File::exists($fileNameThumbL->abs)) { | ||||
| 				File::delete($fileNameThumbL->abs); | ||||
| 			} | ||||
| 			$fileNameThumbL = PhocaGalleryFileThumbnail::getThumbnailName ($filename, 'large1'); | ||||
| 			if (File::exists($fileNameThumbL->abs)) { | ||||
| 				File::delete($fileNameThumbL->abs); | ||||
| 			} | ||||
| 		} | ||||
| 		return true; | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Main Thumbnail creating function | ||||
| 	 * | ||||
| 	 * file 		= abc.jpg | ||||
| 	 * fileNo	= folder/abc.jpg | ||||
| 	 * if small, medium, large = 1, create small, medium, large thumbnail | ||||
| 	 */ | ||||
| 	public static function getOrCreateThumbnail($fileNo, $refreshUrl, $small = 0, $medium = 0, $large = 0, $frontUpload = 0) { | ||||
|  | ||||
|  | ||||
| 		if ($frontUpload) { | ||||
| 			$returnFrontMessage = ''; | ||||
| 		} | ||||
|  | ||||
| 		$onlyThumbnailInfo = 0; | ||||
| 		if ($small == 0 && $medium == 0 && $large == 0) { | ||||
| 			$onlyThumbnailInfo = 1; | ||||
| 		} | ||||
|  | ||||
| 		$paramsC 								= ComponentHelper::getParams('com_phocagallery'); | ||||
| 		$additional_thumbnails 					= $paramsC->get( 'additional_thumbnails',0 ); | ||||
|  | ||||
| 		$path 									= PhocaGalleryPath::getPath(); | ||||
| 		$origPathServer 						= str_replace('//', '/', $path->image_abs); | ||||
| 		$file['name']							= PhocaGalleryFile::getTitleFromFile($fileNo, 1); | ||||
| 		$file['name_no']						= ltrim($fileNo, '/'); | ||||
| 		$file['name_original_abs']				= PhocaGalleryFile::getFileOriginal($fileNo); | ||||
| 		$file['name_original_rel']				= PhocaGalleryFile::getFileOriginal($fileNo, 1); | ||||
| 		$file['path_without_file_name_original']= str_replace($file['name'], '', $file['name_original_abs']); | ||||
| 		$file['path_without_file_name_thumb']	= str_replace($file['name'], '', $file['name_original_abs'] . 'thumbs' . '/'); | ||||
| 		//$file['path_without_name']				= str_replace('\\', '/', JPath::clean($origPathServer)); | ||||
| 		//$file['path_with_name_relative_no']		= str_replace($origPathServer, '', $file['name_original']); | ||||
| 		/* | ||||
| 		$file['path_with_name_relative']		= $path['orig_rel_ds'] . str_replace($origPathServer, '', $file['name_original']); | ||||
| 		$file['path_with_name_relative_no']		= str_replace($origPathServer, '', $file['name_original']); | ||||
|  | ||||
| 		$file['path_without_name']				= str_replace('\\', '/', Path::clean($origPath.'/')); | ||||
| 		$file['path_without_name_relative']		= $path['orig_rel_ds'] . str_replace($origPathServer, '', $file['path_without_name']); | ||||
| 		$file['path_without_name_relative_no']	= str_replace($origPathServer, '', $file['path_without_name']); | ||||
| 		$file['path_without_name_thumbs'] 		= $file['path_without_name'] .'thumbs'; | ||||
| 		$file['path_without_file_name_original'] 			= str_replace($file['name'], '', $file['name_original']); | ||||
| 		$file['path_without_name_thumbs_no'] 	= str_replace($file['name'], '', $file['name_original'] .'thumbs');*/ | ||||
|  | ||||
|  | ||||
| 		$ext = strtolower(File::getExt($file['name'])); | ||||
| 		switch ($ext) { | ||||
| 			case 'jpg': | ||||
| 			case 'png': | ||||
| 			case 'gif': | ||||
| 			case 'jpeg': | ||||
| 			case 'webp': | ||||
| 			case 'avif': | ||||
|  | ||||
| 			//Get File thumbnails name | ||||
|  | ||||
| 			$thumbNameS 					= PhocaGalleryFileThumbnail::getThumbnailName ($fileNo, 'small'); | ||||
| 			$file['thumb_name_s_no_abs'] 	= $thumbNameS->abs; | ||||
| 			$file['thumb_name_s_no_rel'] 	= $thumbNameS->rel; | ||||
|  | ||||
| 			$thumbNameM						= PhocaGalleryFileThumbnail::getThumbnailName ($fileNo, 'medium'); | ||||
| 			$file['thumb_name_m_no_abs'] 	= $thumbNameM->abs; | ||||
| 			$file['thumb_name_m_no_rel'] 	= $thumbNameM->rel; | ||||
|  | ||||
| 			$thumbNameL						= PhocaGalleryFileThumbnail::getThumbnailName ($fileNo, 'large'); | ||||
| 			$file['thumb_name_l_no_abs'] 	= $thumbNameL->abs; | ||||
| 			$file['thumb_name_l_no_rel'] 	= $thumbNameL->rel; | ||||
|  | ||||
|  | ||||
| 			// Don't create thumbnails from watermarks... | ||||
| 			$dontCreateThumb	= PhocaGalleryFileThumbnail::dontCreateThumb($file['name']); | ||||
| 			if ($dontCreateThumb == 1) { | ||||
| 				$onlyThumbnailInfo = 1; // WE USE $onlyThumbnailInfo FOR NOT CREATE A THUMBNAIL CLAUSE | ||||
| 			} | ||||
|  | ||||
| 			// We want only information from the pictures OR | ||||
| 			if ( $onlyThumbnailInfo == 0 ) { | ||||
|  | ||||
| 				$thumbInfo = $fileNo; | ||||
| 				//Create thumbnail folder if not exists | ||||
| 				$errorMsg = 'ErrorCreatingFolder'; | ||||
| 				$creatingFolder = PhocaGalleryFileThumbnail::createThumbnailFolder($file['path_without_file_name_original'], $file['path_without_file_name_thumb'], $errorMsg ); | ||||
|  | ||||
| 				switch ($errorMsg) { | ||||
| 					case 'Success': | ||||
| 					//case 'ThumbnailExists': | ||||
| 					case 'DisabledThumbCreation': | ||||
| 					//case 'OnlyInformation': | ||||
| 					break; | ||||
|  | ||||
| 					Default: | ||||
|  | ||||
| 						// BACKEND OR FRONTEND | ||||
| 						if ($frontUpload !=1) { | ||||
| 							PhocaGalleryRenderProcess::getProcessPage( $file['name'], $thumbInfo, $refreshUrl, $errorMsg, $frontUpload); | ||||
| 							exit; | ||||
| 						} else { | ||||
| 							$returnFrontMessage = $errorMsg; | ||||
| 						} | ||||
|  | ||||
| 					break; | ||||
| 				} | ||||
|  | ||||
| 				// Folder must exist | ||||
| 				if (Folder::exists($file['path_without_file_name_thumb'])) { | ||||
|  | ||||
|  | ||||
| 					// Thumbnails real size | ||||
| 					$tRS = array(); | ||||
|  | ||||
|  | ||||
| 					$errorMsgS = $errorMsgM = $errorMsgL = ''; | ||||
| 					//Small thumbnail | ||||
| 					if ($small == 1) { | ||||
|  | ||||
| 						$createSmall = PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], $thumbNameS->abs, 'small', $frontUpload, $errorMsgS); | ||||
| 						if ($additional_thumbnails == 2 || $additional_thumbnails == 3 || $additional_thumbnails == 7) { | ||||
| 							PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], str_replace('phoca_thumb_s_', 'phoca_thumb_s1_', $thumbNameS->abs), 'small1', $frontUpload, $errorMsgS); | ||||
| 							PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], str_replace('phoca_thumb_s_', 'phoca_thumb_s2_', $thumbNameS->abs), 'small2', $frontUpload, $errorMsgS); | ||||
| 							PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], str_replace('phoca_thumb_s_', 'phoca_thumb_s3_', $thumbNameS->abs), 'small3', $frontUpload, $errorMsgS); | ||||
| 						} | ||||
|  | ||||
|  | ||||
|  | ||||
| 						// Thumbnail real size | ||||
| 						if ($createSmall && File::exists($thumbNameS->abs)) { | ||||
| 							$size = getimagesize($thumbNameS->abs); | ||||
| 							if (isset($size[0])) { | ||||
| 								$tRS['s']['w'] = $size[0]; | ||||
| 							} | ||||
| 							if (isset($size[1])) { | ||||
| 								$tRS['s']['h'] = $size[1]; | ||||
| 							} | ||||
| 						} | ||||
| 					} else { | ||||
| 						$errorMsgS = 'ThumbnailExists';// in case we only need medium or large, because of if clause bellow | ||||
| 					} | ||||
|  | ||||
| 					//Medium thumbnail | ||||
| 					if ($medium == 1) { | ||||
| 						$createMedium = PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], $thumbNameM->abs, 'medium', $frontUpload, $errorMsgM); | ||||
| 						if ($additional_thumbnails == 1 || $additional_thumbnails == 3 || $additional_thumbnails == 7) { | ||||
| 							PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], str_replace('phoca_thumb_m_', 'phoca_thumb_m1_', $thumbNameM->abs), 'medium1', $frontUpload, $errorMsgM); | ||||
| 							PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], str_replace('phoca_thumb_m_', 'phoca_thumb_m2_', $thumbNameM->abs), 'medium2', $frontUpload, $errorMsgM); | ||||
| 							PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], str_replace('phoca_thumb_m_', 'phoca_thumb_m3_', $thumbNameM->abs), 'medium3', $frontUpload, $errorMsgM); | ||||
|  | ||||
| 						} | ||||
|  | ||||
| 						// Thumbnail real size | ||||
| 						if ($createMedium && File::exists($thumbNameM->abs)) { | ||||
| 							$size = getimagesize($thumbNameM->abs); | ||||
| 							if (isset($size[0])) { | ||||
| 								$tRS['m']['w'] = $size[0]; | ||||
| 							} | ||||
| 							if (isset($size[1])) { | ||||
| 								$tRS['m']['h'] = $size[1]; | ||||
| 							} | ||||
| 						} | ||||
|  | ||||
| 					} else { | ||||
| 						$errorMsgM = 'ThumbnailExists'; // in case we only need small or large, because of if clause bellow | ||||
| 					} | ||||
|  | ||||
| 					//Large thumbnail | ||||
| 					if ($large == 1) { | ||||
| 						$createLarge = PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], $thumbNameL->abs, 'large', $frontUpload, $errorMsgL); | ||||
| 						if ($additional_thumbnails == 7) { | ||||
| 							PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], str_replace('phoca_thumb_l_', 'phoca_thumb_l1_', $thumbNameL->abs), 'large1', $frontUpload, $errorMsgL); | ||||
| 						} | ||||
|  | ||||
| 						// Thumbnail real size | ||||
| 						if ($createLarge && File::exists($thumbNameL->abs)) { | ||||
|  | ||||
| 							$size = getimagesize($thumbNameL->abs); | ||||
| 							if (isset($size[0])) { | ||||
| 								$tRS['l']['w'] = $size[0]; | ||||
| 							} | ||||
| 							if (isset($size[1])) { | ||||
| 								$tRS['l']['h'] = $size[1]; | ||||
| 							} | ||||
| 						} | ||||
|  | ||||
| 					} else { | ||||
| 						$errorMsgL = 'ThumbnailExists'; // in case we only need small or medium, because of if clause bellow | ||||
| 					} | ||||
|  | ||||
| 					// Error messages for all 3 thumbnails (if the message contains error string, we got error | ||||
| 					// Other strings can be: | ||||
| 					// - ThumbnailExists  - do not display error message nor success page | ||||
| 					// - OnlyInformation - do not display error message nor success page | ||||
| 					// - DisabledThumbCreation - do not display error message nor success page | ||||
|  | ||||
| 					$creatingSError = $creatingMError = $creatingLError = false; | ||||
| 					$creatingSError = preg_match("/Error/i", $errorMsgS); | ||||
| 					$creatingMError = preg_match("/Error/i", $errorMsgM); | ||||
| 					$creatingLError = preg_match("/Error/i", $errorMsgL); | ||||
|  | ||||
|  | ||||
| 					// Add info about real thumbnail sizes into database | ||||
| 					if ($creatingSError || $creatingMError || $creatingLError) { | ||||
|  | ||||
| 					} else { | ||||
|  | ||||
|  | ||||
| 						if ((isset($createSmall) && $createSmall) || (isset($createMedium) && $createMedium) || (isset($createLarge) && $createLarge)) { | ||||
| 							// Set it only when really new thumbnail was created | ||||
|  | ||||
| 							PhocaGalleryImage::updateRealThumbnailSizes($file['name_original_rel'], $tRS); | ||||
| 						} | ||||
| 					} | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| 					// BACKEND OR FRONTEND | ||||
| 					if ($frontUpload != 1) { | ||||
|  | ||||
| 						// There is an error while creating thumbnail in m or in s or in l | ||||
| 						if ($creatingSError || $creatingMError || $creatingLError) { | ||||
| 							// if all or two errors appear, we only display the last error message | ||||
| 							// because the errors in this case is the same | ||||
| 							if ($errorMsgS != '') { | ||||
| 								$creatingError = $errorMsgS; | ||||
| 							} | ||||
| 							if ($errorMsgM != '') { | ||||
| 								$creatingError = $errorMsgM; | ||||
| 							} | ||||
| 							if ($errorMsgL != '') { | ||||
| 								$creatingError = $errorMsgL; | ||||
| 							} | ||||
|  | ||||
| 							PhocaGalleryRenderProcess::getProcessPage( $file['name'], $thumbInfo, $refreshUrl, $creatingError);exit; | ||||
| 						} else if ($errorMsgS == '' && $errorMsgM == '' && $errorMsgL == '') { | ||||
| 							PhocaGalleryRenderProcess::getProcessPage( $file['name'], $thumbInfo, $refreshUrl);exit; | ||||
| 						} else if ($errorMsgS == '' && $errorMsgM == '' && $errorMsgL == 'ThumbnailExists') { | ||||
| 							PhocaGalleryRenderProcess::getProcessPage( $file['name'], $thumbInfo, $refreshUrl);exit; | ||||
| 						} else if ($errorMsgS == '' && $errorMsgM == 'ThumbnailExists' && $errorMsgL == 'ThumbnailExists') { | ||||
| 							PhocaGalleryRenderProcess::getProcessPage( $file['name'], $thumbInfo, $refreshUrl);exit; | ||||
| 						} else if ($errorMsgS == '' && $errorMsgM == 'ThumbnailExists' && $errorMsgL == '') { | ||||
| 							PhocaGalleryRenderProcess::getProcessPage( $file['name'], $thumbInfo, $refreshUrl);exit; | ||||
| 						} else if ($errorMsgS == 'ThumbnailExists' && $errorMsgM == 'ThumbnailExists' && $errorMsgL == '') { | ||||
| 							PhocaGalleryRenderProcess::getProcessPage( $file['name'], $thumbInfo, $refreshUrl);exit; | ||||
| 						} else if ($errorMsgS == 'ThumbnailExists' && $errorMsgM == '' && $errorMsgL == '') { | ||||
| 							PhocaGalleryRenderProcess::getProcessPage( $file['name'], $thumbInfo, $refreshUrl);exit; | ||||
| 						} else if ($errorMsgS == 'ThumbnailExists' && $errorMsgM == '' && $errorMsgL == 'ThumbnailExists') { | ||||
| 							PhocaGalleryRenderProcess::getProcessPage( $file['name'], $thumbInfo, $refreshUrl);exit; | ||||
| 						} | ||||
| 					} else { | ||||
| 						// There is an error while creating thumbnail in m or in s or in l | ||||
| 						if ($creatingSError || $creatingMError || $creatingLError) { | ||||
| 							// if all or two errors appear, we only display the last error message | ||||
| 							// because the errors in this case is the same | ||||
| 							if ($errorMsgS != '') { | ||||
| 								$creatingError = $errorMsgS; | ||||
| 							} | ||||
| 							if ($errorMsgM != '') { | ||||
| 								$creatingError = $errorMsgM; | ||||
| 							} | ||||
| 							if ($errorMsgL != '') { | ||||
| 								$creatingError = $errorMsgL; | ||||
| 							}							// because the errors in this case is the same | ||||
|  | ||||
| 							$returnFrontMessage = $creatingError; | ||||
| 						} else if ($errorMsgS == '' && $errorMsgM == '' && $errorMsgL == '') { | ||||
| 							$returnFrontMessage = 'Success'; | ||||
| 						} else if ($errorMsgS == '' && $errorMsgM == '' && $errorMsgL == 'ThumbnailExists') { | ||||
| 							$returnFrontMessage = 'Success'; | ||||
| 						} else if ($errorMsgS == '' && $errorMsgM == 'ThumbnailExists' && $errorMsgL == 'ThumbnailExists') { | ||||
| 							$returnFrontMessage = 'Success'; | ||||
| 						} else if ($errorMsgS == '' && $errorMsgM == 'ThumbnailExists' && $errorMsgL == '') { | ||||
| 							$returnFrontMessage = 'Success'; | ||||
| 						} else if ($errorMsgS == 'ThumbnailExists' && $errorMsgM == 'ThumbnailExists' && $errorMsgL == '') { | ||||
| 							$returnFrontMessage = 'Success'; | ||||
| 						} else if ($errorMsgS == 'ThumbnailExists' && $errorMsgM == '' && $errorMsgL == '') { | ||||
| 							$returnFrontMessage = 'Success'; | ||||
| 						} else if ($errorMsgS == 'ThumbnailExists' && $errorMsgM == '' && $errorMsgL == 'ThumbnailExists') { | ||||
| 							$returnFrontMessage = 'Success'; | ||||
| 						} | ||||
| 					} | ||||
|  | ||||
| 					if ($frontUpload == 1) { | ||||
| 						return $returnFrontMessage; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			break; | ||||
| 		} | ||||
| 		return $file; | ||||
| 	} | ||||
|  | ||||
| 	public static function dontCreateThumb ($filename) { | ||||
| 		$dontCreateThumb		= false; | ||||
| 		$dontCreateThumbArray	= array ('watermark-large.png', 'watermark-medium.png'); | ||||
| 		foreach ($dontCreateThumbArray as $key => $value) { | ||||
| 			if (strtolower($filename) == strtolower($value)) { | ||||
| 				return true; | ||||
| 			} | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	public static function createThumbnailFolder($folderOriginal, $folderThumbnail, &$errorMsg) { | ||||
|  | ||||
| 		$paramsC = ComponentHelper::getParams('com_phocagallery'); | ||||
| 		$enable_thumb_creation = $paramsC->get( 'enable_thumb_creation', 1 ); | ||||
| 		$folder_permissions = $paramsC->get( 'folder_permissions', 0755 ); | ||||
| 		//$folder_permissions = octdec((int)$folder_permissions); | ||||
|  | ||||
| 		// disable or enable the thumbnail creation | ||||
| 		if ($enable_thumb_creation == 1) { | ||||
|  | ||||
| 			if (Folder::exists($folderOriginal)) { | ||||
| 				if (strlen($folderThumbnail) > 0) { | ||||
| 					$folderThumbnail = Path::clean($folderThumbnail); | ||||
| 					if (!Folder::exists($folderThumbnail) && !File::exists($folderThumbnail)) { | ||||
| 						switch((int)$folder_permissions) { | ||||
| 							case 777: | ||||
| 								Folder::create($folderThumbnail, 0777 ); | ||||
| 							break; | ||||
| 							case 705: | ||||
| 								Folder::create($folderThumbnail, 0705 ); | ||||
| 							break; | ||||
| 							case 666: | ||||
| 								Folder::create($folderThumbnail, 0666 ); | ||||
| 							break; | ||||
| 							case 644: | ||||
| 								Folder::create($folderThumbnail, 0644 ); | ||||
| 							break; | ||||
| 							case 755: | ||||
| 							Default: | ||||
| 								Folder::create($folderThumbnail, 0755 ); | ||||
| 							break; | ||||
| 						} | ||||
|  | ||||
| 						//JFolder::create($folderThumbnail, $folder_permissions ); | ||||
| 						if (isset($folderThumbnail)) { | ||||
| 							$data = "<html>\n<body bgcolor=\"#FFFFFF\">\n</body>\n</html>"; | ||||
| 							File::write($folderThumbnail. '/'. "index.html", $data); | ||||
| 						} | ||||
| 						// folder was not created | ||||
| 						if (!Folder::exists($folderThumbnail)) { | ||||
| 							$errorMsg = 'ErrorCreatingFolder'; | ||||
| 							return false; | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			$errorMsg = 'Success'; | ||||
|  | ||||
| 			return true; | ||||
| 		} else { | ||||
| 			$errorMsg = 'DisabledThumbCreation'; | ||||
| 			return false; // User have disabled the thumbanil creation e.g. because of error | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public static function createFileThumbnail($fileOriginal, $fileThumbnail, $size, $frontUpload=0, &$errorMsg = '') { | ||||
|  | ||||
| 		$paramsC 					= ComponentHelper::getParams('com_phocagallery'); | ||||
| 		$enable_thumb_creation 		= $paramsC->get( 'enable_thumb_creation', 1); | ||||
| 		$watermarkParams['create']	= $paramsC->get( 'create_watermark', 0 );// Watermark | ||||
| 		$watermarkParams['x'] 		= $paramsC->get( 'watermark_position_x', 'center' ); | ||||
| 		$watermarkParams['y']		= $paramsC->get( 'watermark_position_y', 'middle' ); | ||||
| 		$crop_thumbnail				= $paramsC->get( 'crop_thumbnail', 5);// Crop or not | ||||
| 		$crop 						= null; | ||||
|  | ||||
|  | ||||
|  | ||||
| 		switch ($size) { | ||||
| 			case 'small1': | ||||
| 			case 'small2': | ||||
| 			case 'small3': | ||||
| 			case 'medium1': | ||||
| 			case 'medium2': | ||||
| 			case 'medium3': | ||||
| 			case 'large1': | ||||
| 				$crop = 1; | ||||
| 			break; | ||||
|  | ||||
| 			case 'small': | ||||
| 				if ($crop_thumbnail == 3 || $crop_thumbnail == 5 || $crop_thumbnail == 6 || $crop_thumbnail == 7 ) { | ||||
| 					$crop = 1; | ||||
| 				} | ||||
| 			break; | ||||
|  | ||||
| 			case 'medium': | ||||
| 				if ($crop_thumbnail == 2 || $crop_thumbnail == 4 || $crop_thumbnail == 5 || $crop_thumbnail == 7 ) { | ||||
| 					$crop = 1; | ||||
| 				} | ||||
| 			break; | ||||
|  | ||||
| 			case 'large': | ||||
| 			default: | ||||
| 				if ($crop_thumbnail == 1 || $crop_thumbnail == 4 || $crop_thumbnail == 6 || $crop_thumbnail == 7 ) { | ||||
| 					$crop = 1; | ||||
| 				} | ||||
| 			break; | ||||
| 		} | ||||
|  | ||||
| 		// disable or enable the thumbnail creation | ||||
| 		if ($enable_thumb_creation == 1) { | ||||
| 			$fileResize	= PhocaGalleryFileThumbnail::getThumbnailResize($size); | ||||
|  | ||||
| 			if (File::exists($fileOriginal)) { | ||||
| 				//file doesn't exist, create thumbnail | ||||
| 				if (!File::exists($fileThumbnail)) { | ||||
| 					$errorMsg = 'Error4'; | ||||
| 					//Don't do thumbnail if the file is smaller (width, height) than the possible thumbnail | ||||
| 					list($width, $height) = GetImageSize($fileOriginal); | ||||
| 					//larger | ||||
| 					phocagalleryimport('phocagallery.image.imagemagic'); | ||||
| 					if ($width > $fileResize['width'] || $height > $fileResize['height']) { | ||||
|  | ||||
| 						$imageMagic = PhocaGalleryImageMagic::imageMagic($fileOriginal, $fileThumbnail, $fileResize['width'] , $fileResize['height'], $crop, null, $watermarkParams, $frontUpload, $errorMsg); | ||||
|  | ||||
| 					} else { | ||||
| 						$imageMagic = PhocaGalleryImageMagic::imageMagic($fileOriginal, $fileThumbnail, $width , $height, $crop, null, $watermarkParams, $frontUpload, $errorMsg); | ||||
| 					} | ||||
| 					if ($imageMagic) { | ||||
|  | ||||
| 						return true; | ||||
| 					} else { | ||||
| 						return false;// error Msg will be taken from imageMagic | ||||
| 					} | ||||
| 				} else { | ||||
| 					$errorMsg = 'ThumbnailExists';//thumbnail exists | ||||
| 					return false; | ||||
| 				} | ||||
| 			} else { | ||||
| 				$errorMsg = 'ErrorFileOriginalNotExists'; | ||||
| 				return false; | ||||
| 			} | ||||
| 			$errorMsg = 'Error3'; | ||||
| 			return false; | ||||
| 		} else { | ||||
| 			$errorMsg = 'DisabledThumbCreation'; // User have disabled the thumbanil creation e.g. because of error | ||||
| 			return false; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public static function getThumbnailResize($size = 'all') { | ||||
|  | ||||
| 		// Get width and height from Default settings | ||||
| 		$params 			= ComponentHelper::getParams('com_phocagallery') ; | ||||
| 		$large_image_width 	= $params->get( 'large_image_width', 640 ); | ||||
| 		$large_image_height = $params->get( 'large_image_height', 480 ); | ||||
| 		$medium_image_width = $params->get( 'medium_image_width', 256 ); | ||||
| 		$medium_image_height= $params->get( 'medium_image_height', 192 ); | ||||
| 		$small_image_width 	= $params->get( 'small_image_width', 128 ); | ||||
| 		$small_image_height = $params->get( 'small_image_height', 96 ); | ||||
| 		$additional_thumbnail_margin = $params->get( 'additional_thumbnail_margin', 0 ); | ||||
|  | ||||
| 		switch ($size) { | ||||
| 			case 'large': | ||||
| 			$fileResize['width']	=	$large_image_width; | ||||
| 			$fileResize['height']	=	$large_image_height; | ||||
| 			break; | ||||
|  | ||||
| 			case 'medium': | ||||
| 			$fileResize['width']	=	$medium_image_width; | ||||
| 			$fileResize['height']	=	$medium_image_height; | ||||
| 			break; | ||||
|  | ||||
| 			case 'medium1': | ||||
| 			$fileResize['width']	=	$medium_image_width; | ||||
| 			$fileResize['height']	=	((int)$medium_image_height * 2) + (int)$additional_thumbnail_margin; | ||||
| 			break; | ||||
|  | ||||
| 			case 'medium2': | ||||
| 			$fileResize['width']	=	(int)$medium_image_width * 2; | ||||
| 			$fileResize['height']	=	$medium_image_height; | ||||
| 			break; | ||||
|  | ||||
| 			case 'medium3': | ||||
| 			$fileResize['width']	=	(int)$medium_image_width * 2; | ||||
| 			$fileResize['height']	=	(int)$medium_image_height * 2; | ||||
| 			break; | ||||
|  | ||||
| 			case 'small': | ||||
| 			$fileResize['width']	=	$small_image_width; | ||||
| 			$fileResize['height']	=	$small_image_height; | ||||
| 			break; | ||||
|  | ||||
| 			case 'small1': | ||||
| 				$fileResize['width']	=	$small_image_width; | ||||
| 				$fileResize['height']	=	(int)$small_image_height * 2; | ||||
| 			break; | ||||
|  | ||||
| 			case 'small2': | ||||
| 				$fileResize['width']	=	(int)$small_image_width * 2; | ||||
| 				$fileResize['height']	=	$small_image_height; | ||||
| 			break; | ||||
|  | ||||
| 			case 'small3': | ||||
| 				$fileResize['width']	=	(int)$small_image_width * 2; | ||||
| 				$fileResize['height']	=	(int)$small_image_height * 2; | ||||
| 			break; | ||||
|  | ||||
| 			case 'large1': | ||||
| 				$fileResize['width']	=	$large_image_width; | ||||
| 				$scale					= 	(int)$large_image_height / $medium_image_height; | ||||
| 				$fileResize['height']	=	((int)$large_image_height * 2) + ((int)$additional_thumbnail_margin * $scale); | ||||
| 			break; | ||||
|  | ||||
|  | ||||
| 			default: | ||||
| 			case 'all': | ||||
| 			$fileResize['smallwidth']	=	$small_width; | ||||
| 			$fileResize['smallheight']	=	$small_height; | ||||
| 			$fileResize['mediumwidth']	=	$medium_width; | ||||
| 			$fileResize['mediumheight']	=	$medium_height; | ||||
| 			$fileResize['largewidth']	=	$large_width; | ||||
| 			$fileResize['largeheight']	=	$large_height; | ||||
| 			break; | ||||
| 		} | ||||
| 		return $fileResize; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,815 @@ | ||||
| <?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\Filesystem\File; | ||||
|  | ||||
| defined( '_JEXEC' ) or die( 'Restricted access' ); | ||||
| use Joomla\CMS\Component\ComponentHelper; | ||||
| use Joomla\CMS\Factory; | ||||
| use Joomla\CMS\Session\Session; | ||||
| use Joomla\CMS\Language\Text; | ||||
| use Joomla\CMS\Client\ClientHelper; | ||||
| use Joomla\CMS\Filesystem\Path; | ||||
| use Joomla\CMS\Filesystem\Folder; | ||||
| use Joomla\CMS\Uri\Uri; | ||||
| use Joomla\CMS\HTML\HTMLHelper; | ||||
| jimport( 'joomla.filesystem.folder' ); | ||||
| jimport( 'joomla.filesystem.file' ); | ||||
| phocagalleryimport( 'phocagallery.image.image'); | ||||
| phocagalleryimport( 'phocagallery.file.fileuploadfront' ); | ||||
| class PhocaGalleryFileUpload | ||||
| { | ||||
| 	public static function realMultipleUpload( $frontEnd = 0) { | ||||
|  | ||||
| 		$paramsC 		= ComponentHelper::getParams('com_phocagallery'); | ||||
| 		$chunkMethod 	= $paramsC->get( 'multiple_upload_chunk', 0 ); | ||||
| 		$uploadMethod 	= $paramsC->get( 'multiple_upload_method', 4 ); | ||||
|  | ||||
| 		$app 	= Factory::getApplication(); | ||||
| 		$app->allowCache(false); | ||||
|  | ||||
| 		// Chunk Files | ||||
| 		header('Content-type: text/plain; charset=UTF-8'); | ||||
| 		header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); | ||||
| 		header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); | ||||
| 		header("Cache-Control: no-store, no-cache, must-revalidate"); | ||||
| 		header("Cache-Control: post-check=0, pre-check=0", false); | ||||
| 		header("Pragma: no-cache"); | ||||
|  | ||||
| 		// Invalid Token | ||||
| 		Session::checkToken( 'request' ) or jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 100, | ||||
| 				'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ', | ||||
| 				'details' => Text::_('COM_PHOCAGALLERY_INVALID_TOKEN')))); | ||||
|  | ||||
| 		// Set FTP credentials, if given | ||||
| 		$ftp = ClientHelper::setCredentialsFromRequest('ftp'); | ||||
|  | ||||
| 		$path			= PhocaGalleryPath::getPath(); | ||||
| 		$file 			= Factory::getApplication()->input->files->get( 'file', null ); | ||||
| 		$chunk 			= Factory::getApplication()->input->get( 'chunk', 0, '', 'int' ); | ||||
| 		$chunks 		= Factory::getApplication()->input->get( 'chunks', 0, '', 'int' ); | ||||
| 		$folder			= Factory::getApplication()->input->get( 'folder', '', '', 'path' ); | ||||
|  | ||||
| 		// Make the filename safe | ||||
| 		if (isset($file['name'])) { | ||||
| 			$file['name']	= File::makeSafe($file['name']); | ||||
| 		} | ||||
| 		if (isset($folder) && $folder != '') { | ||||
| 			$folder	= $folder . '/'; | ||||
| 		} | ||||
|  | ||||
| 		$chunkEnabled = 0; | ||||
| 		// Chunk only if is enabled and only if flash is enabled | ||||
| 		if (($chunkMethod == 1 && $uploadMethod == 1) || ($frontEnd == 0 && $chunkMethod == 0 && $uploadMethod == 1)) { | ||||
| 			$chunkEnabled = 1; | ||||
| 		} | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| 		if (isset($file['name'])) { | ||||
|  | ||||
|  | ||||
| 			// - - - - - - - - - - | ||||
| 			// Chunk Method | ||||
| 			// - - - - - - - - - - | ||||
| 			// $chunkMethod = 1, for frontend and backend | ||||
| 			// $chunkMethod = 0, only for backend | ||||
| 			if ($chunkEnabled == 1) { | ||||
|  | ||||
| 				// If chunk files are used, we need to upload parts to temp directory | ||||
| 				// and then we can run e.g. the condition to recognize if the file already exists | ||||
| 				// We must upload the parts to temp, in other case we get everytime the info | ||||
| 				// that the file exists (because the part has the same name as the file) | ||||
| 				// so after first part is uploaded, in fact the file already exists | ||||
| 				// Example: NOT USING CHUNK | ||||
| 				// If we upload abc.jpg file to server and there is the same file | ||||
| 				// we compare it and can recognize, there is one, don't upload it again. | ||||
| 				// Example: USING CHUNK | ||||
| 				// If we upload abc.jpg file to server and there is the same file | ||||
| 				// the part of current file will overwrite the same file | ||||
| 				// and then (after all parts will be uploaded) we can make the condition to compare the file | ||||
| 				// and we recognize there is one - ok don't upload it BUT the file will be damaged by | ||||
| 				// parts uploaded by the new file - so this is why we are using temp file in Chunk method | ||||
| 				$stream 				= Factory::getStream();// Chunk Files | ||||
| 				$tempFolder				= 'pgpluploadtmpfolder/'; | ||||
| 				$filepathImgFinal 		= Path::clean($path->image_abs.$folder.strtolower($file['name'])); | ||||
| 				$filepathImgTemp 		= Path::clean($path->image_abs.$folder.$tempFolder.strtolower($file['name'])); | ||||
| 				$filepathFolderFinal 	= Path::clean($path->image_abs.$folder); | ||||
| 				$filepathFolderTemp 	= Path::clean($path->image_abs.$folder.$tempFolder); | ||||
| 				$maxFileAge 			= 60 * 60; // Temp file age in seconds | ||||
| 				$lastChunk				= $chunk + 1; | ||||
| 				$realSize				= 0; | ||||
|  | ||||
| 				// Get the real size - if chunk is uploaded, it is only a part size, so we must compute all size | ||||
| 				// If there is last chunk we can computhe the whole size | ||||
| 				if ($lastChunk == $chunks) { | ||||
| 					if (File::exists($filepathImgTemp) && File::exists($file['tmp_name'])) { | ||||
| 						$realSize = filesize($filepathImgTemp) + filesize($file['tmp_name']); | ||||
| 					} | ||||
| 				} | ||||
|  | ||||
| 				// 5 minutes execution time | ||||
| 				@set_time_limit(5 * 60);// usleep(5000); | ||||
|  | ||||
| 				// If the file already exists on the server: | ||||
| 				// - don't copy the temp file to final | ||||
| 				// - remove all parts in temp file | ||||
| 				// Because some parts are uploaded before we can run the condition | ||||
| 				// to recognize if the file already exists. | ||||
| 				if (File::exists($filepathImgFinal)) { | ||||
| 					if($lastChunk == $chunks){ | ||||
| 					@Folder::delete($filepathFolderTemp); | ||||
| 				} | ||||
|  | ||||
| 				jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 108, | ||||
| 							'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ', | ||||
| 							'details' => Text::_('COM_PHOCAGALLERY_FILE_ALREADY_EXISTS')))); | ||||
| 				} | ||||
|  | ||||
| 				if (!PhocaGalleryFileUpload::canUpload( $file, $errUploadMsg, $frontEnd, $chunkEnabled, $realSize )) { | ||||
|  | ||||
| 					// If there is some error, remove the temp folder with temp files | ||||
| 					if($lastChunk == $chunks){ | ||||
| 						@Folder::delete($filepathFolderTemp); | ||||
| 					} | ||||
| 					jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 104, | ||||
| 								'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ', | ||||
| 								'details' => Text::_($errUploadMsg)))); | ||||
| 				} | ||||
|  | ||||
| 				// Ok create temp folder and add chunks | ||||
| 				if (!Folder::exists($filepathFolderTemp)) { | ||||
| 					@Folder::create($filepathFolderTemp); | ||||
| 				} | ||||
|  | ||||
| 				// Remove old temp files | ||||
| 				if (Folder::exists($filepathFolderTemp)) { | ||||
| 					$dirFiles = Folder::files($filepathFolderTemp); | ||||
| 					if (!empty($dirFiles)) { | ||||
| 						foreach ($dirFiles as $fileS) { | ||||
| 							$filePathImgS = $filepathFolderTemp . $fileS; | ||||
| 							// Remove temp files if they are older than the max age | ||||
| 							if (preg_match('/\\.tmp$/', $fileS) && (filemtime($filepathImgTemp) < time() - $maxFileAge)) { | ||||
| 								@File::delete($filePathImgS); | ||||
| 							} | ||||
| 						} | ||||
| 					} | ||||
| 				} else { | ||||
| 					jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 100, | ||||
| 							'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ', | ||||
| 							'details' => Text::_('COM_PHOCAGALLERY_ERROR_FOLDER_UPLOAD_NOT_EXISTS')))); | ||||
| 				} | ||||
|  | ||||
| 				// Look for the content type header | ||||
| 				if (isset($_SERVER["HTTP_CONTENT_TYPE"])) | ||||
| 					$contentType = $_SERVER["HTTP_CONTENT_TYPE"]; | ||||
|  | ||||
| 				if (isset($_SERVER["CONTENT_TYPE"])) | ||||
| 					$contentType = $_SERVER["CONTENT_TYPE"]; | ||||
|  | ||||
| 				if (strpos($contentType, "multipart") !== false) { | ||||
| 					if (isset($file['tmp_name']) && is_uploaded_file($file['tmp_name'])) { | ||||
|  | ||||
| 						// Open temp file | ||||
| 						$out = $stream->open($filepathImgTemp, $chunk == 0 ? "wb" : "ab"); | ||||
| 						//$out = fopen($filepathImgTemp, $chunk == 0 ? "wb" : "ab"); | ||||
| 						if ($out) { | ||||
| 							// Read binary input stream and append it to temp file | ||||
| 							$in = fopen($file['tmp_name'], "rb"); | ||||
| 							if ($in) { | ||||
| 								while ($buff = fread($in, 4096)) { | ||||
| 									$stream->write($buff); | ||||
| 									//fwrite($out, $buff); | ||||
| 								} | ||||
| 							} else { | ||||
| 								jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 101, | ||||
| 								'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ', | ||||
| 								'details' => Text::_('COM_PHOCAGALLERY_ERROR_OPEN_INPUT_STREAM')))); | ||||
| 							} | ||||
| 							$stream->close(); | ||||
| 							//fclose($out); | ||||
| 							@File::delete($file['tmp_name']); | ||||
| 						} else { | ||||
| 							jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 102, | ||||
| 							'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ', | ||||
| 							'details' => Text::_('COM_PHOCAGALLERY_ERROR_OPEN_OUTPUT_STREAM')))); | ||||
| 						} | ||||
| 					} else { | ||||
| 						jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 103, | ||||
| 							'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ', | ||||
| 							'details' => Text::_('COM_PHOCAGALLERY_ERROR_MOVE_UPLOADED_FILE')))); | ||||
| 					} | ||||
| 				} else { | ||||
| 					// Open temp file | ||||
| 					$out = $stream->open($filepathImgTemp, $chunk == 0 ? "wb" : "ab"); | ||||
| 					//$out = JFile::read($filepathImg); | ||||
| 					if ($out) { | ||||
| 						// Read binary input stream and append it to temp file | ||||
| 						$in = fopen("php://input", "rb"); | ||||
|  | ||||
| 						if ($in) { | ||||
| 							while ($buff = fread($in, 4096)) { | ||||
| 								$stream->write($buff); | ||||
| 							} | ||||
| 						} else { | ||||
| 							jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 101, | ||||
| 								'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ', | ||||
| 								'details' => Text::_('COM_PHOCAGALLERY_ERROR_OPEN_INPUT_STREAM')))); | ||||
| 						} | ||||
| 						$stream->close(); | ||||
| 						//fclose($out); | ||||
| 					} else { | ||||
| 						jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 102, | ||||
| 						'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ', | ||||
| 						'details' => Text::_('COM_PHOCAGALLERY_ERROR_OPEN_OUTPUT_STREAM')))); | ||||
| 					} | ||||
| 				} | ||||
|  | ||||
|  | ||||
| 				// Rename the Temp File to Final File | ||||
| 				if($lastChunk == $chunks){ | ||||
|  | ||||
| 					if(($imginfo = getimagesize($filepathImgTemp)) === FALSE) { | ||||
| 						Folder::delete($filepathFolderTemp); | ||||
| 						jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 110, | ||||
| 						'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ', | ||||
| 						'details' => Text::_('COM_PHOCAGALLERY_WARNING_INVALIDIMG')))); | ||||
| 					} | ||||
|  | ||||
|  | ||||
| 					if(!File::move($filepathImgTemp, $filepathImgFinal)) { | ||||
|  | ||||
| 						Folder::delete($filepathFolderTemp); | ||||
|  | ||||
| 						jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 109, | ||||
| 						'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ', | ||||
| 						'details' => Text::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_MOVE_FILE') .'<br />' | ||||
| 						. Text::_('COM_PHOCAGALLERY_CHECK_PERMISSIONS_OWNERSHIP')))); | ||||
| 					} | ||||
|  | ||||
|  | ||||
| 					Folder::delete($filepathFolderTemp); | ||||
| 				} | ||||
|  | ||||
| 				if ((int)$frontEnd > 0) { | ||||
| 					return $file['name']; | ||||
| 				} | ||||
|  | ||||
| 				jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'OK', 'code' => 200, | ||||
| 				'message' => Text::_('COM_PHOCAGALLERY_SUCCESS').': ', | ||||
| 				'details' => Text::_('COM_PHOCAGALLERY_IMAGES_UPLOADED')))); | ||||
|  | ||||
|  | ||||
| 			} else { | ||||
| 				// No Chunk Method | ||||
|  | ||||
| 				$filepathImgFinal 		= Path::clean($path->image_abs.$folder.strtolower($file['name'])); | ||||
| 				$filepathFolderFinal 	= Path::clean($path->image_abs.$folder); | ||||
|  | ||||
|  | ||||
|  | ||||
| 				if (!PhocaGalleryFileUpload::canUpload( $file, $errUploadMsg, $frontEnd, $chunkMethod, 0 )) { | ||||
| 					jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 104, | ||||
| 					'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ', | ||||
| 					'details' => Text::_($errUploadMsg)))); | ||||
| 				} | ||||
|  | ||||
| 				if (File::exists($filepathImgFinal)) { | ||||
| 					jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 108, | ||||
| 					'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ', | ||||
| 					'details' => Text::_('COM_PHOCAGALLERY_FILE_ALREADY_EXISTS')))); | ||||
| 				} | ||||
|  | ||||
|  | ||||
| 				if(!File::upload($file['tmp_name'], $filepathImgFinal, false, true)) { | ||||
| 					jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 109, | ||||
| 					'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ', | ||||
| 					'details' => Text::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE') .'<br />' | ||||
| 					. Text::_('COM_PHOCAGALLERY_CHECK_PERMISSIONS_OWNERSHIP')))); | ||||
| 				} | ||||
|  | ||||
| 				if ((int)$frontEnd > 0) { | ||||
| 					return $file['name']; | ||||
| 				} | ||||
|  | ||||
| 				jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'OK', 'code' => 200, | ||||
| 				'message' => Text::_('COM_PHOCAGALLERY_SUCCESS').': ', | ||||
| 				'details' => Text::_('COM_PHOCAGALLERY_IMAGES_UPLOADED')))); | ||||
|  | ||||
|  | ||||
| 			} | ||||
| 		} else { | ||||
| 			// No isset $file['name'] | ||||
|  | ||||
| 			jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 104, | ||||
| 			'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ', | ||||
| 			'details' => Text::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE')))); | ||||
| 		} | ||||
|  | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	public static function realSingleUpload( $frontEnd = 0 ) { | ||||
|  | ||||
| 	//	$paramsC 		= JComponentHelper::getParams('com_phocagallery'); | ||||
| 	//	$chunkMethod 	= $paramsC->get( 'multiple_upload_chunk', 0 ); | ||||
| 	//	$uploadMethod 	= $paramsC->get( 'multiple_upload_method', 4 ); | ||||
|  | ||||
| 		$app			= Factory::getApplication(); | ||||
| 		Session::checkToken( 'request' ) or jexit( 'ERROR: '. Text::_('COM_PHOCAGALLERY_INVALID_TOKEN')); | ||||
|  | ||||
| 		$app->allowCache(false); | ||||
|  | ||||
| 		$path			= PhocaGalleryPath::getPath(); | ||||
| 		$file 			= Factory::getApplication()->input->files->get( 'Filedata', null ); | ||||
| 		$folder			= Factory::getApplication()->input->get( 'folder', '', '', 'path' ); | ||||
| 		$format			= Factory::getApplication()->input->get( 'format', 'html', '', 'cmd'); | ||||
| 		$return			= Factory::getApplication()->input->get( 'return-url', null, 'post', 'base64' );//includes field | ||||
| 		$viewBack		= Factory::getApplication()->input->get( 'viewback', '', '', '' ); | ||||
| 		$tab			= Factory::getApplication()->input->get( 'tab', '', '', 'string' ); | ||||
| 		$field			= Factory::getApplication()->input->get( 'field' ); | ||||
| 		$errUploadMsg	= ''; | ||||
| 		$folderUrl 		= $folder; | ||||
| 		$tabUrl			= ''; | ||||
| 		$component		= Factory::getApplication()->input->get( 'option', '', '', 'string' ); | ||||
|  | ||||
| 		// In case no return value will be sent (should not happen) | ||||
| 		if ($component != '' && $frontEnd == 0) { | ||||
| 			$componentUrl 	= 'index.php?option='.$component; | ||||
| 		} else { | ||||
| 			$componentUrl	= 'index.php'; | ||||
| 		} | ||||
| 		if ($tab != '') { | ||||
| 			$tabUrl = '&tab='.(string)$tab; | ||||
| 		} | ||||
|  | ||||
| 		$ftp = ClientHelper::setCredentialsFromRequest('ftp'); | ||||
|  | ||||
| 		// Make the filename safe | ||||
| 		if (isset($file['name'])) { | ||||
| 			$file['name']	= File::makeSafe($file['name']); | ||||
| 		} | ||||
|  | ||||
|  | ||||
| 		if (isset($folder) && $folder != '') { | ||||
| 			$folder	= $folder . '/'; | ||||
| 		} | ||||
|  | ||||
|  | ||||
| 		// All HTTP header will be overwritten with js message | ||||
| 		if (isset($file['name'])) { | ||||
| 			$filepath = Path::clean($path->image_abs.$folder.strtolower($file['name'])); | ||||
|  | ||||
| 			if (!PhocaGalleryFileUpload::canUpload( $file, $errUploadMsg, $frontEnd )) { | ||||
|  | ||||
| 				if ($errUploadMsg == 'COM_PHOCAGALLERY_WARNING_FILE_TOOLARGE') { | ||||
| 					$errUploadMsg 	= Text::_($errUploadMsg) . ' ('.PhocaGalleryFile::getFileSizeReadable($file['size']).')'; | ||||
| 				} else if ($errUploadMsg == 'COM_PHOCAGALLERY_WARNING_FILE_TOOLARGE_RESOLUTION') { | ||||
| 					$imgSize		= PhocaGalleryImage::getImageSize($file['tmp_name']); | ||||
| 					$errUploadMsg 	= Text::_($errUploadMsg) . ' ('.(int)$imgSize[0].' x '.(int)$imgSize[1].' px)'; | ||||
| 				} else { | ||||
| 					$errUploadMsg 	= Text::_($errUploadMsg); | ||||
| 				} | ||||
|  | ||||
|  | ||||
| 				/*if ($return) { | ||||
| 					$app->enqueueMessage( $errUploadMsg, 'error'); | ||||
| 					$app->redirect(base64_decode($return).'&folder='.$folderUrl); | ||||
| 					exit; | ||||
| 				} else { | ||||
| 					$app->enqueueMessage( $errUploadMsg, 'error'); | ||||
| 					$app->redirect($componentUrl, $errUploadMsg, 'error'); | ||||
| 					exit; | ||||
| 				}*/ | ||||
|  | ||||
|  | ||||
| 				if ($return) { | ||||
| 					$app->enqueueMessage( $errUploadMsg, 'error'); | ||||
| 					if ($frontEnd > 0) { | ||||
|  | ||||
| 						$app->redirect(base64_decode($return)); | ||||
| 					} else { | ||||
| 						$app->redirect(base64_decode($return).'&folder='.$folderUrl); | ||||
| 					} | ||||
| 					exit; | ||||
| 				} else { | ||||
| 					$app->enqueueMessage( $errUploadMsg, 'error'); | ||||
| 					$app->redirect($componentUrl); | ||||
| 					exit; | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			if (File::exists($filepath)) { | ||||
| 				if ($return) { | ||||
| 					$app->enqueueMessage( Text::_('COM_PHOCAGALLERY_FILE_ALREADY_EXISTS'), 'error'); | ||||
| 					$app->redirect(base64_decode($return).'&folder='.$folderUrl); | ||||
| 					exit; | ||||
| 				} else { | ||||
| 					$app->enqueueMessage(Text::_('COM_PHOCAGALLERY_FILE_ALREADY_EXISTS'), 'error'); | ||||
| 					$app->redirect($componentUrl); | ||||
| 					exit; | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			if (!File::upload($file['tmp_name'], $filepath, false, true)) { | ||||
| 				if ($return) { | ||||
| 					$app->enqueueMessage( Text::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE'), 'error'); | ||||
| 					$app->redirect(base64_decode($return).'&folder='.$folderUrl); | ||||
| 					exit; | ||||
| 				} else { | ||||
| 					$app->enqueueMessage( Text::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE'), 'error'); | ||||
| 					$app->redirect($componentUrl); | ||||
| 					exit; | ||||
| 				} | ||||
| 			} else { | ||||
|  | ||||
| 				if ((int)$frontEnd > 0) { | ||||
| 					return $file['name']; | ||||
| 				} | ||||
|  | ||||
| 				if ($return) { | ||||
| 					$app->enqueueMessage( Text::_('COM_PHOCAGALLERY_SUCCESS_FILE_UPLOAD')); | ||||
| 					$app->redirect(base64_decode($return).'&folder='.$folderUrl); | ||||
| 					exit; | ||||
| 				} else { | ||||
| 					$app->enqueueMessage( Text::_('COM_PHOCAGALLERY_SUCCESS_FILE_UPLOAD')); | ||||
| 					$app->redirect($componentUrl); | ||||
| 					exit; | ||||
| 				} | ||||
| 			} | ||||
| 		} else { | ||||
| 			$msg = Text::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE'); | ||||
| 			if ($return) { | ||||
| 				$app->enqueueMessage( $msg); | ||||
| 				$app->redirect(base64_decode($return).'&folder='.$folderUrl); | ||||
| 				exit; | ||||
| 			} else { | ||||
| 				switch ($viewBack) { | ||||
| 					case 'phocagalleryi': | ||||
| 						$app->enqueueMessage( $msg, 'error'); | ||||
| 						$app->redirect('index.php?option=com_phocagallery&view=phocagalleryi&tmpl=component'.$tabUrl.'&folder='.$folder.'&field='.$field); | ||||
| 						exit; | ||||
| 					break; | ||||
|  | ||||
| 					case 'phocagallerym': | ||||
| 						$app->enqueueMessage( $msg, 'error'); | ||||
| 						$app->redirect('index.php?option=com_phocagallery&view=phocagallerym&layout=form&hidemainmenu=1'.$tabUrl.'&folder='.$folder); | ||||
| 						exit; | ||||
| 					break; | ||||
|  | ||||
| 					default: | ||||
| 						$app->enqueueMessage( $msg, 'error'); | ||||
| 						$app->redirect('index.php?option=com_phocagallery'); | ||||
| 						exit; | ||||
| 					break; | ||||
|  | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	public static function realJavaUpload( $frontEnd = 0 ) { | ||||
|  | ||||
| 		$app	= Factory::getApplication(); | ||||
|  | ||||
| 		Session::checkToken( 'request' ) or exit( 'ERROR: '. Text::_('COM_PHOCAGALLERY_INVALID_TOKEN')); | ||||
|  | ||||
| 	//	$files 	= Factory::getApplication()->input->get( 'Filedata', '', 'files', 'array' ); | ||||
|  | ||||
| 		$path		= PhocaGalleryPath::getPath(); | ||||
| 		$folder		= Factory::getApplication()->input->get( 'folder', '', '', 'path' ); | ||||
|  | ||||
| 		if (isset($folder) && $folder != '') { | ||||
| 			$folder	= $folder . '/'; | ||||
| 		} | ||||
| 		$errUploadMsg	= ''; | ||||
| 		$ftp 			= ClientHelper::setCredentialsFromRequest('ftp'); | ||||
|  | ||||
| 		foreach ($_FILES as $fileValue => $file) { | ||||
| 			echo('File key: '. $fileValue . "\n"); | ||||
| 			foreach ($file as $item => $val) { | ||||
| 				echo(' Data received: ' . $item.'=>'.$val . "\n"); | ||||
| 			} | ||||
|  | ||||
|  | ||||
| 			// Make the filename safe | ||||
| 			if (isset($file['name'])) { | ||||
| 				$file['name'] = File::makeSafe($file['name']); | ||||
| 			} | ||||
|  | ||||
| 			if (isset($file['name'])) { | ||||
| 				$filepath = Path::clean($path->image_abs.$folder.strtolower($file['name'])); | ||||
|  | ||||
| 				if (!PhocaGalleryFileUpload::canUpload( $file, $errUploadMsg, $frontEnd  )) { | ||||
| 					exit( 'ERROR: '.Text::_($errUploadMsg)); | ||||
| 				} | ||||
|  | ||||
| 				if (File::exists($filepath)) { | ||||
| 					exit( 'ERROR: '.Text::_('COM_PHOCAGALLERY_FILE_ALREADY_EXISTS')); | ||||
| 				} | ||||
|  | ||||
| 				if (!File::upload($file['tmp_name'], $filepath, false, true)) { | ||||
| 					exit( 'ERROR: '.Text::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE')); | ||||
| 				} | ||||
| 				if ((int)$frontEnd > 0) { | ||||
| 					return $file['name']; | ||||
| 				} | ||||
|  | ||||
| 				exit( 'SUCCESS'); | ||||
| 			} else { | ||||
| 				exit( 'ERROR: '.Text::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE')); | ||||
| 			} | ||||
| 		} | ||||
| 		return true; | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	/** | ||||
| 	 * can Upload | ||||
| 	 * | ||||
| 	 * @param array $file | ||||
| 	 * @param string $errorUploadMsg | ||||
| 	 * @param int $frontEnd - if it is called from frontend or backend (1  - category view, 2 user control panel) | ||||
| 	 * @param boolean $chunkMethod - if chunk method is used (multiple upload) then there are special rules | ||||
| 	 * @param string $realSize - if chunk method is used we get info about real size of file (not only the part) | ||||
| 	 * @return boolean True on success | ||||
| 	 * @since 1.5 | ||||
| 	 */ | ||||
|  | ||||
|  | ||||
| 	public static function canUpload( $file, &$errUploadMsg, $frontEnd = 0, $chunkEnabled = 0, $realSize = 0 ) { | ||||
|  | ||||
| 		$params 	= ComponentHelper::getParams( 'com_phocagallery' ); | ||||
| 		$paramsL 	= array(); | ||||
| 		$paramsL['upload_extensions'] 	= 'gif,jpg,png,jpeg,webp,avif'; | ||||
| 		$paramsL['image_extensions'] 	= 'gif,jpg,png,jpeg,webp,avif'; | ||||
| 		$paramsL['upload_mime']			= 'image/jpeg,image/gif,image/png,image/webp,image/avif'; | ||||
| 		$paramsL['upload_mime_illegal']	='application/x-shockwave-flash,application/msword,application/excel,application/pdf,application/powerpoint,text/plain,application/x-zip,text/html'; | ||||
|  | ||||
| 		// The file doesn't exist | ||||
| 		if(empty($file['name'])) { | ||||
| 			$errUploadMsg = 'COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE'; | ||||
| 			return false; | ||||
| 		} | ||||
|  | ||||
| 		// Not safe file | ||||
| 		jimport('joomla.filesystem.file'); | ||||
| 		if ($file['name'] !== File::makesafe($file['name'])) { | ||||
| 			$errUploadMsg = 'COM_PHOCAGALLERY_WARNING_FILENAME'; | ||||
| 			return false; | ||||
| 		} | ||||
|  | ||||
| 		$format = strtolower(File::getExt($file['name'])); | ||||
|  | ||||
| 		// Allowable extension | ||||
| 		$allowable = explode( ',', $paramsL['upload_extensions']); | ||||
| 		if ($format == '' || $format == false || (!in_array($format, $allowable))) { | ||||
| 		//if (!in_array($format, $allowable)) { | ||||
| 			$errUploadMsg = 'COM_PHOCAGALLERY_WARNING_FILETYPE'; | ||||
| 			return false; | ||||
| 		} | ||||
|  | ||||
| 		// 'COM_PHOCAGALLERY_MAX_RESOLUTION' | ||||
| 		$imgSize		= PhocaGalleryImage::getImageSize($file['tmp_name']); | ||||
| 		$maxResWidth 	= $params->get( 'upload_maxres_width', 3072 ); | ||||
| 		$maxResHeight 	= $params->get( 'upload_maxres_height', 2304 ); | ||||
| 		if (((int)$maxResWidth > 0 && (int)$maxResHeight > 0) | ||||
| 		&& ((int)$imgSize[0] > (int)$maxResWidth || (int)$imgSize[1] > (int)$maxResHeight)) { | ||||
| 			$errUploadMsg = 'COM_PHOCAGALLERY_WARNING_FILE_TOOLARGE_RESOLUTION'; | ||||
| 			return false; | ||||
| 		} | ||||
|  | ||||
| 		// User (only in ucp) - Check the size of all images by users | ||||
| 		if ($frontEnd == 2) { | ||||
| 			$user 				= Factory::getUser(); | ||||
| 			$maxUserImageSize 	= (int)$params->get( 'user_images_max_size', 20971520 ); | ||||
|  | ||||
| 			if ($chunkEnabled == 1) { | ||||
| 				$fileSize = $realSize; | ||||
| 			} else { | ||||
| 				$fileSize = $file['size']; | ||||
| 			} | ||||
| 			$allFileSize = PhocaGalleryFileUploadFront::getSizeAllOriginalImages($fileSize, $user->id); | ||||
|  | ||||
| 			if ((int)$maxUserImageSize > 0 && (int) $allFileSize > $maxUserImageSize) { | ||||
| 				$errUploadMsg = Text::_('COM_PHOCAGALLERY_WARNING_USERIMAGES_TOOLARGE'); | ||||
| 				return false; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		// Max size of image | ||||
| 		// If chunk method is used, we need to get computed size | ||||
| 		$maxSize = $params->get( 'upload_maxsize', 3145728 ); | ||||
| 		if ($chunkEnabled == 1) { | ||||
| 			if ((int)$maxSize > 0 && (int)$realSize > (int)$maxSize) { | ||||
| 				$errUploadMsg = 'COM_PHOCAGALLERY_WARNING_FILE_TOOLARGE'; | ||||
| 				return false; | ||||
| 			} | ||||
| 		} else { | ||||
| 			if ((int)$maxSize > 0 && (int)$file['size'] > (int)$maxSize) { | ||||
| 				$errUploadMsg = 'COM_PHOCAGALLERY_WARNING_FILE_TOOLARGE'; | ||||
| 				return false; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		$user = Factory::getUser(); | ||||
| 		$imginfo = null; | ||||
|  | ||||
|  | ||||
| 		// Image check | ||||
| 		$images = explode( ',', $paramsL['image_extensions']); | ||||
| 		if(in_array($format, $images)) { // if its an image run it through getimagesize | ||||
| 			if ($chunkEnabled != 1) { | ||||
| 				if(($imginfo = getimagesize($file['tmp_name'])) === FALSE) { | ||||
| 					$errUploadMsg = 'COM_PHOCAGALLERY_WARNING_INVALIDIMG'; | ||||
| 					return false; | ||||
| 				} | ||||
| 			} | ||||
| 		} else if(!in_array($format, $images)) { | ||||
| 			// if its not an image...and we're not ignoring it | ||||
| 			$allowed_mime = explode(',', $paramsL['upload_mime']); | ||||
| 			$illegal_mime = explode(',', $paramsL['upload_mime_illegal']); | ||||
| 			if(function_exists('finfo_open')) { | ||||
| 				// We have fileinfo | ||||
| 				$finfo = finfo_open(FILEINFO_MIME); | ||||
| 				$type = finfo_file($finfo, $file['tmp_name']); | ||||
| 				if(strlen($type) && !in_array($type, $allowed_mime) && in_array($type, $illegal_mime)) { | ||||
| 					$errUploadMsg = 'COM_PHOCAGALLERY_WARNING_INVALIDMIME'; | ||||
| 					return false; | ||||
| 				} | ||||
| 				finfo_close($finfo); | ||||
| 			} else if(function_exists('mime_content_type')) { | ||||
| 				// we have mime magic | ||||
| 				$type = mime_content_type($file['tmp_name']); | ||||
| 				if(strlen($type) && !in_array($type, $allowed_mime) && in_array($type, $illegal_mime)) { | ||||
| 					$errUploadMsg = 'COM_PHOCAGALLERY_WARNING_INVALIDMIME'; | ||||
| 					return false; | ||||
| 				} | ||||
| 			}/* else if(!$user->authorize( 'login', 'administrator' )) { | ||||
| 				$errUploadMsg =  = 'WARNNOTADMIN'; | ||||
| 				return false; | ||||
| 			}*/ | ||||
| 		} | ||||
|  | ||||
| 		// XSS Check | ||||
| 		$xss_check = file_get_contents($file['tmp_name'], false, null, -1, 256); | ||||
|  | ||||
| 		$html_tags = array( | ||||
| 			'abbr', 'acronym', 'address', 'applet', 'area', 'audioscope', 'base', 'basefont', 'bdo', 'bgsound', 'big', 'blackface', 'blink', | ||||
| 			'blockquote', 'body', 'bq', 'br', 'button', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'comment', 'custom', 'dd', 'del', | ||||
| 			'dfn', 'dir', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'fn', 'font', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', | ||||
| 			'head', 'hr', 'html', 'iframe', 'ilayer', 'img', 'input', 'ins', 'isindex', 'keygen', 'kbd', 'label', 'layer', 'legend', 'li', 'limittext', | ||||
| 			'link', 'listing', 'map', 'marquee', 'menu', 'meta', 'multicol', 'nobr', 'noembed', 'noframes', 'noscript', 'nosmartquotes', 'object', | ||||
| 			'ol', 'optgroup', 'option', 'param', 'plaintext', 'pre', 'rt', 'ruby', 's', 'samp', 'script', 'select', 'server', 'shadow', 'sidebar', | ||||
| 			'small', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'title', | ||||
| 			'tr', 'tt', 'ul', 'var', 'wbr', 'xml', 'xmp', '!DOCTYPE', '!--', | ||||
| 		); | ||||
|  | ||||
| 		foreach ($html_tags as $tag) | ||||
| 		{ | ||||
| 			// A tag is '<tagname ', so we need to add < and a space or '<tagname>' | ||||
| 			if (stripos($xss_check, '<' . $tag . ' ') !== false || stripos($xss_check, '<' . $tag . '>') !== false) | ||||
| 			{ | ||||
| 				$errUploadMsg = 'COM_PHOCAGALLERY_WARNING_IEXSS'; | ||||
| 				return false; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return true; | ||||
| 	} | ||||
| 	/* | ||||
| 	function uploader($id='file-upload', $params = array()) { | ||||
|  | ||||
| 		$path = 'media/com_phocagallery/js/upload/'; | ||||
| 		JHtml::script('swf.js', $path, false ); // mootools are loaded yet | ||||
| 		JHtml::script('uploader.js', $path, false );// mootools are loaded yet | ||||
|  | ||||
| 		static $uploaders; | ||||
|  | ||||
| 		if (!isset($uploaders)) { | ||||
| 			$uploaders = array(); | ||||
| 		} | ||||
|  | ||||
| 		if (isset($uploaders[$id]) && ($uploaders[$id])) { | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		// Setup options object | ||||
| 		$opt['url']					= (isset($params['targetURL'])) ? $params['targetURL'] : null ; | ||||
| 		$opt['swf']					= (isset($params['swf'])) ? $params['swf'] : Uri::root(true).'/media/system/swf/uploader.swf'; | ||||
| 		$opt['multiple']			= (isset($params['multiple']) && !($params['multiple'])) ? '\\false' : '\\true'; | ||||
| 		$opt['queued']				= (isset($params['queued']) && !($params['queued'])) ? '\\false' : '\\true'; | ||||
| 		$opt['queueList']			= (isset($params['queueList'])) ? $params['queueList'] : 'upload-queue'; | ||||
| 		$opt['instantStart']		= (isset($params['instantStart']) && ($params['instantStart'])) ? '\\true' : '\\false'; | ||||
| 		$opt['allowDuplicates']		= (isset($params['allowDuplicates']) && !($params['allowDuplicates'])) ? '\\false' : '\\true'; | ||||
| 		$opt['limitSize']			= (isset($params['limitSize']) && ($params['limitSize'])) ? (int)$params['limitSize'] : null; | ||||
| 		$opt['limitFiles']			= (isset($params['limitFiles']) && ($params['limitFiles'])) ? (int)$params['limitFiles'] : null; | ||||
| 		$opt['optionFxDuration']	= (isset($params['optionFxDuration'])) ? (int)$params['optionFxDuration'] : null; | ||||
| 		$opt['container']			= (isset($params['container'])) ? '\\$('.$params['container'].')' : '\\$(\''.$id.'\').getParent()'; | ||||
| 		$opt['types']				= (isset($params['types'])) ?'\\'.$params['types'] : '\\{\'All Files (*.*)\': \'*.*\'}'; | ||||
|  | ||||
| 		// Optional functions | ||||
| 		$opt['createReplacement']	= (isset($params['createReplacement'])) ? '\\'.$params['createReplacement'] : null; | ||||
| 		$opt['onComplete']			= (isset($params['onComplete'])) ? '\\'.$params['onComplete'] : null; | ||||
| 		$opt['onAllComplete']		= (isset($params['onAllComplete'])) ? '\\'.$params['onAllComplete'] : null; | ||||
|  | ||||
| /*  types: Object with (description: extension) pairs, Default: Images (*.jpg; *.jpeg; *.gif; *.png) | ||||
|  */ | ||||
| /* | ||||
| 		$options = PhocaGalleryFileUpload::getJSObject($opt); | ||||
|  | ||||
| 		// Attach tooltips to document | ||||
| 		$document =Factory::getDocument(); | ||||
| 		$uploaderInit = 'sBrowseCaption=\''.Text::_('Browse Files', true).'\'; | ||||
| 				sRemoveToolTip=\''.Text::_('Remove from queue', true).'\'; | ||||
| 				window.addEvent(\'load\', function(){ | ||||
| 				var Uploader = new FancyUpload($(\''.$id.'\'), '.$options.'); | ||||
| 				$(\'upload-clear\').adopt(new Element(\'input\', { type: \'button\', events: { click: Uploader.clearList.bind(Uploader, [false])}, value: \''.Text::_('Clear Completed').'\' }));				});'; | ||||
| 		$document->addScriptDeclaration($uploaderInit); | ||||
|  | ||||
| 		// Set static array | ||||
| 		$uploaders[$id] = true; | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	protected static function getJSObject($array=array()) | ||||
| 	{ | ||||
| 		// Initialise variables. | ||||
| 		$object = '{'; | ||||
|  | ||||
| 		// Iterate over array to build objects | ||||
| 		foreach ((array)$array as $k => $v) | ||||
| 		{ | ||||
| 			if (is_null($v)) { | ||||
| 				continue; | ||||
| 			} | ||||
| 			if (!is_array($v) && !is_object($v)) | ||||
| 			{ | ||||
| 				$object .= ' '.$k.': '; | ||||
| 				$object .= (is_numeric($v) || strpos($v, '\\') === 0) ? (is_numeric($v)) ? $v : substr($v, 1) : "'".$v."'"; | ||||
| 				$object .= ','; | ||||
| 			} | ||||
| 			else { | ||||
| 				$object .= ' '.$k.': '.PhocaGalleryFileUpload::getJSObject($v).','; | ||||
| 			} | ||||
| 		} | ||||
| 		if (substr($object, -1) == ',') { | ||||
| 			$object = substr($object, 0, -1); | ||||
| 		} | ||||
| 		$object .= '}'; | ||||
|  | ||||
| 		return $object; | ||||
| 	}*/ | ||||
|  | ||||
| 	public static function renderFTPaccess() { | ||||
|  | ||||
| 		$ftpOutput = '<fieldset title="'.Text::_('COM_PHOCAGALLERY_FTP_LOGIN_LABEL'). '">' | ||||
| 		.'<legend>'. Text::_('COM_PHOCAGALLERY_FTP_LOGIN_LABEL').'</legend>' | ||||
| 		.Text::_('COM_PHOCAGALLERY_FTP_LOGIN_DESC') | ||||
| 		.'<table class="adminform nospace">' | ||||
| 		.'<tr>' | ||||
| 		.'<td width="120"><label for="username">'. Text::_('JGLOBAL_USERNAME').':</label></td>' | ||||
| 		.'<td><input type="text" id="username" name="username" class="input_box" size="70" value="" /></td>' | ||||
| 		.'</tr>' | ||||
| 		.'<tr>' | ||||
| 		.'<td width="120"><label for="password">'. Text::_('JGLOBAL_PASSWORD').':</label></td>' | ||||
| 		.'<td><input type="password" id="password" name="password" class="input_box" size="70" value="" /></td>' | ||||
| 		.'</tr></table></fieldset>'; | ||||
| 		return $ftpOutput; | ||||
| 	} | ||||
|  | ||||
| 	public static function renderCreateFolder($sessName, $sessId, $currentFolder, $viewBack, $attribs = '') { | ||||
|  | ||||
| 		if ($attribs != '') { | ||||
| 			$attribs = '&'.$attribs; | ||||
| 		} | ||||
|  | ||||
| 		$folderOutput = '<form action="'. Uri::base() | ||||
| 		.'index.php?option=com_phocagallery&task=phocagalleryu.createfolder&'. $sessName.'='.$sessId.'&' | ||||
| 		.Session::getFormToken().'=1&viewback='.$viewBack.'&' | ||||
| 		.'folder='.PhocaGalleryText::filterValue($currentFolder, 'folderpath').$attribs .'" name="folderForm" id="folderForm" method="post">' | ||||
| 		//.'<fieldset id="folderview">' | ||||
| 		//.'<legend>'.JText::_('COM_PHOCAGALLERY_FOLDER').'</legend>' | ||||
| 		.'<div class="ph-in"><div class="ph-head-form">'.Text::_('COM_PHOCAGALLERY_CREATE_FOLDER').'</div>' | ||||
| 		.'<dl class="dl-horizontal ph-input">' | ||||
| 		.'<dt><input class="form-control" type="text" id="foldername" name="foldername"  /></dt>' | ||||
| 		.'<input class="update-folder" type="hidden" name="folderbase" id="folderbase" value="'.PhocaGalleryText::filterValue($currentFolder, 'folderpath').'" />' | ||||
| 		.'<dd><button class="btn btn-success" type="submit">'. Text::_( 'COM_PHOCAGALLERY_CREATE_FOLDER' ).'</button></dd>' | ||||
| 		.'</dl></div>' | ||||
| 	    //.'</fieldset>' | ||||
| 		.HTMLHelper::_( 'form.token' ) | ||||
| 		.'</form>'; | ||||
| 		return $folderOutput; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,37 @@ | ||||
| <?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; | ||||
|  | ||||
| class PhocaGalleryFileUploadFront | ||||
| { | ||||
| 	public static function getSizeAllOriginalImages($fileSize, $userId) {		 | ||||
| 		 | ||||
| 		$db 			=Factory::getDBO(); | ||||
| 		$allFileSize	= 0; | ||||
| 		$query = 'SELECT SUM(a.imgorigsize) AS sumimgorigsize' | ||||
| 				.' FROM #__phocagallery AS a' | ||||
| 				.' LEFT JOIN #__phocagallery_categories AS cc ON a.catid = cc.id' | ||||
| 			    .' WHERE cc.owner_id = '.(int)$userId; | ||||
| 		$db->setQuery($query, 0, 1); | ||||
| 		$sumImgOrigSize = $db->loadObject(); | ||||
| 		 | ||||
| 		if(isset($sumImgOrigSize->sumimgorigsize) && (int)$sumImgOrigSize->sumimgorigsize > 0) { | ||||
| 			$allFileSize = (int)$allFileSize + (int)$sumImgOrigSize->sumimgorigsize; | ||||
| 		} | ||||
| 		 | ||||
| 		if (isset($fileSize)) { | ||||
| 				$allFileSize = (int)$allFileSize + (int)$fileSize; | ||||
| 		} | ||||
| 		return (int)$allFileSize; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,78 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @package   Phoca Gallery | ||||
|  * @author    Jan Pavelka - https://www.phoca.cz | ||||
|  * @copyright Copyright (C) Jan Pavelka https://www.phoca.cz | ||||
|  * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later | ||||
|  * @cms       Joomla | ||||
|  * @copyright Copyright (C) Open Source Matters. All rights reserved. | ||||
|  * @license   http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php | ||||
|  */ | ||||
| defined( '_JEXEC' ) or die( 'Restricted access' ); | ||||
| use Joomla\CMS\Language\Text; | ||||
|  | ||||
| class PhocaGalleryFileUploadJava | ||||
| { | ||||
| 	public $returnUrl; | ||||
| 	public $url; | ||||
| 	public $source; | ||||
| 	public $height; | ||||
| 	public $width; | ||||
| 	public $resizeheight; | ||||
| 	public $resizewidth; | ||||
| 	public $uploadmaxsize; | ||||
|  | ||||
| 	public function __construct() {} | ||||
| 	 | ||||
| 	public function getJavaUploadHTML() { | ||||
| 	 | ||||
|  | ||||
| 		 | ||||
| 		$html = '<!--[if !IE]> -->' . "\n"   | ||||
|  | ||||
| .'<object classid="java:wjhk.jupload2.JUploadApplet" type="application/x-java-applet"' | ||||
| .' archive="http://localhost/'. $this->source.'" height="'.$this->height.'" width="'.$this->width.'" >' . "\n" | ||||
| .'<param name="archive" value="'. $this->source.'" />' . "\n" | ||||
| .'<param name="postURL" value="'. $this->url.'"/>' . "\n" | ||||
| .'<param name="afterUploadURL" value="'. $this->returnUrl.'"/>' . "\n" | ||||
| .'<param name="allowedFileExtensions" value="jpg/gif/png/" />'		 . "\n"             | ||||
| .'<param name="uploadPolicy" value="PictureUploadPolicy" />'     . "\n"         | ||||
| .'<param name="nbFilesPerRequest" value="1" />' . "\n" | ||||
| .'<param name="maxPicHeight" value="'. $this->resizeheight .'" />' . "\n" | ||||
| .'<param name="maxPicWidth" value="'. $this->resizewidth .'" />' . "\n" | ||||
| .'<param name="maxFileSize" value="'. $this->uploadmaxsize .'" />'	 . "\n" | ||||
| .'<param name="pictureTransmitMetadata" value="true" />' . "\n" | ||||
| .'<param name="showLogWindow" value="false" />' . "\n" | ||||
| .'<param name="showStatusBar" value="false" />' . "\n" | ||||
| .'<param name="pictureCompressionQuality" value="1" />' . "\n" | ||||
| .'<param name="lookAndFeel"  value="system"/>' . "\n" | ||||
| .'<!--<![endif]-->'. "\n"   | ||||
| .'<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" codebase="http://java.sun.com/update/1.5.0/jinstall-1_5_0-windows-i586.cab"' | ||||
| .' height="'.$this->height.'" width="'.$this->width.'" >'. "\n"   | ||||
| .'<param name="code" value="wjhk.jupload2.JUploadApplet" />'. "\n"   | ||||
| .'<param name="archive" value="'. $this->source .'" />'. "\n"   | ||||
| .'<param name="postURL" value="'. $this->url .'"/>'. "\n"   | ||||
| .'<param name="afterUploadURL" value="'. $this->returnUrl.'"/>'. "\n"   | ||||
| .'<param name="allowedFileExtensions" value="jpg/gif/png" />'	  . "\n"             | ||||
| .'<param name="uploadPolicy" value="PictureUploadPolicy" /> '    . "\n"         | ||||
| .'<param name="nbFilesPerRequest" value="1" />'. "\n"   | ||||
| .'<param name="maxPicHeight" value="'. $this->resizeheight .'" />'. "\n"   | ||||
| .'<param name="maxPicWidth" value="'. $this->resizewidth .'" />'. "\n"   | ||||
| .'<param name="maxFileSize" value="'. $this->uploadmaxsize .'" />'	. "\n"   | ||||
| .'<param name="pictureTransmitMetadata" value="true" />'. "\n"   | ||||
| .'<param name="showLogWindow" value="false" />'. "\n"   | ||||
| .'<param name="showStatusBar" value="false" />'. "\n"   | ||||
| .'<param name="pictureCompressionQuality" value="1" />'. "\n"   | ||||
| .'<param name="lookAndFeel"  value="system"/>' . "\n"   | ||||
| .'<div style="color:#cc0000">'.Text::_('COM_PHOCAGALLERY_JAVA_PLUGIN_MUST_BE_ENABLED').'</div>'. "\n"   | ||||
| .'</object>'. "\n"   | ||||
| .'<!--[if !IE]> -->'. "\n"   | ||||
| .'</object>' . "\n" | ||||
| .'<!--<![endif]-->'. "\n"   | ||||
| .'</fieldset>' . "\n"; | ||||
| 		 | ||||
| 		return $html; | ||||
| 		 | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,307 @@ | ||||
| <?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\Factory; | ||||
| use Joomla\CMS\Language\Text; | ||||
| use Joomla\CMS\Uri\Uri; | ||||
|  | ||||
| use Joomla\CMS\HTML\HTMLHelper; | ||||
|  | ||||
| class PhocaGalleryFileUploadMultiple | ||||
| { | ||||
| 	public $method 		= 1; | ||||
| 	public $url			= ''; | ||||
| 	public $reload		= ''; | ||||
| 	public $maxFileSize	= ''; | ||||
| 	public $chunkSize	= ''; | ||||
| 	public $imageHeight	= ''; | ||||
| 	public $imageWidth	= ''; | ||||
| 	public $imageQuality= ''; | ||||
| 	public $frontEnd	= 0; | ||||
|  | ||||
| 	public function __construct() {} | ||||
|  | ||||
| 	static public function renderMultipleUploadLibraries() { | ||||
|  | ||||
| 		$paramsC 		= ComponentHelper::getParams('com_phocagallery'); | ||||
| 		$chunkMethod 	= $paramsC->get( 'multiple_upload_chunk', 0 ); | ||||
| 		$uploadMethod 	= $paramsC->get( 'multiple_upload_method', 4 ); | ||||
|  | ||||
| 		//First load mootools, then jquery and set noConflict | ||||
| 		//JHtml::_('behavior.framework', true);// Load it here to be sure, it is loaded before jquery | ||||
| 		HTMLHelper::_('jquery.framework', false);// Load it here because of own nonConflict method (nonconflict is set below) | ||||
| 		$document	= Factory::getDocument(); | ||||
| 		// No more used  - - - - - | ||||
| 		//$nC = 'var pgJQ =  jQuery.noConflict();';//SET BELOW | ||||
| 		//$document->addScriptDeclaration($nC);//SET BELOW | ||||
| 		// - - - - - - - - - - - - | ||||
|  | ||||
| 		if ($uploadMethod == 2) { | ||||
| 			//$document->addScript(JUri::root(true).'/media/com_phocagallery/js/plupload/gears_init.js'); | ||||
| 		} | ||||
| 		if ($uploadMethod == 5) { | ||||
| 			//$document->addScript('http://bp.yahooapis.com/2.4.21/browserplus-min.js'); | ||||
| 		} | ||||
|  | ||||
| 		HTMLHelper::_('script', 'media/com_phocagallery/js/plupload/plupload.js', array('version' => 'auto')); | ||||
| 		if ($uploadMethod == 2) { | ||||
| 			//$document->addScript(JUri::root(true).'/media/com_phocagallery/js/plupload/plupload.gears.js'); | ||||
| 		} | ||||
| 		if ($uploadMethod == 3) { | ||||
| 			//$document->addScript(JUri::root(true).'/media/com_phocagallery/js/plupload/plupload.silverlight.js'); | ||||
| 		} | ||||
| 		if ($uploadMethod == 1) { | ||||
| 			//$document->addScript(JUri::root(true).'/media/com_phocagallery/js/plupload/plupload.flash.js'); | ||||
| 		} | ||||
| 		if ($uploadMethod == 5) { | ||||
| 			//$document->addScript(JUri::root(true).'/media/com_phocagallery/js/plupload/plupload.browserplus.js'); | ||||
| 		} | ||||
| 		if ($uploadMethod == 6) { | ||||
|  | ||||
| 			HTMLHelper::_('script', 'media/com_phocagallery/js/plupload/plupload.html4.js', array('version' => 'auto')); | ||||
| 		} | ||||
| 		if ($uploadMethod == 4) { | ||||
|  | ||||
| 			HTMLHelper::_('script', 'media/com_phocagallery/js/plupload/plupload.html5.js', array('version' => 'auto')); | ||||
| 		} | ||||
|  | ||||
| 		HTMLHelper::_('script', 'media/com_phocagallery/js/plupload/jquery.plupload.queue/jquery.plupload.queue.js', array('version' => 'auto')); | ||||
| 		HTMLHelper::_('stylesheet', 'media/com_phocagallery/js/plupload/jquery.plupload.queue/css/jquery.plupload.queue.css', array('version' => 'auto')); | ||||
| 	} | ||||
|  | ||||
| 	static public function getMultipleUploadSizeFormat($size) { | ||||
| 		$readableSize = PhocaGalleryFile::getFileSizeReadable($size, '%01.0f %s', 1); | ||||
|  | ||||
| 		$readableSize 	= str_replace(' ', '', $readableSize); | ||||
|  | ||||
| 		$readableSize 	= strtolower($readableSize); | ||||
| 		return $readableSize; | ||||
| 	} | ||||
|  | ||||
| 	public function renderMultipleUploadJS($frontEnd = 0, $chunkMethod = 0) { | ||||
|  | ||||
| 		$document			= Factory::getDocument(); | ||||
|  | ||||
| 		switch ($this->method) { | ||||
| 			case 2: | ||||
| 				$name		= 'gears_uploader'; | ||||
| 				$runtime	= 'gears'; | ||||
| 			break; | ||||
| 			case 3: | ||||
| 				$name		= 'silverlight_uploader'; | ||||
| 				$runtime	= 'silverlight'; | ||||
| 			break; | ||||
| 			case 4: | ||||
| 				$name		= 'html5_uploader'; | ||||
| 				$runtime	= 'html5'; | ||||
| 			break; | ||||
|  | ||||
| 			case 5: | ||||
| 				$name		= 'browserplus_uploader'; | ||||
| 				$runtime	= 'browserplus'; | ||||
| 			break; | ||||
|  | ||||
| 			case 6: | ||||
| 				$name		= 'html4_uploader'; | ||||
| 				$runtime	= 'html4'; | ||||
| 			break; | ||||
|  | ||||
| 			case 1: | ||||
| 			default: | ||||
| 				$name		= 'flash_uploader'; | ||||
| 				$runtime	= 'flash'; | ||||
| 			break; | ||||
| 		} | ||||
|  | ||||
| 		$chunkEnabled = 0; | ||||
| 		// Chunk only if is enabled and only if flash is enabled | ||||
| 		if (($chunkMethod == 1 && $this->method == 1) || ($this->frontEnd == 0 && $chunkMethod == 0 && $this->method == 1)) { | ||||
| 			$chunkEnabled = 1; | ||||
| 		} | ||||
|  | ||||
|         $this->url      = PhocaGalleryText::filterValue($this->url, 'text'); | ||||
|         $this->reload 	= PhocaGalleryText::filterValue($this->reload, 'text'); | ||||
| 		$this->url 		= str_replace('&', '&', $this->url); | ||||
| 		$this->reload 	= str_replace('&', '&', $this->reload); | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| 		//$js = ' var pgJQ = jQuery.noConflict();'; | ||||
| 		$js = 'var pgJQ =  jQuery.noConflict();'; | ||||
| 		$js .=' pgJQ(function() {'."\n"; | ||||
|  | ||||
| 		$js.=''."\n"; | ||||
| 		$js.='   plupload.addI18n({'."\n"; | ||||
| 		$js.='	   \'Select files\' : \''.addslashes(Text::_('COM_PHOCAGALLERY_SELECT_IMAGES')).'\','."\n"; | ||||
| 		$js.='	   \'Add files to the upload queue and click the start button.\' : \''.addslashes(Text::_('COM_PHOCAGALLERY_ADD_IMAGES_TO_UPLOAD_QUEUE_AND_CLICK_START_BUTTON')).'\','."\n"; | ||||
| 		$js.='	   \'Filename\' : \''.addslashes(Text::_('COM_PHOCAGALLERY_FILENAME')).'\','."\n"; | ||||
| 		$js.='	   \'Status\' : \''.addslashes(Text::_('COM_PHOCAGALLERY_STATUS')).'\','."\n"; | ||||
| 		$js.='	   \'Size\' : \''.addslashes(Text::_('COM_PHOCAGALLERY_SIZE')).'\','."\n"; | ||||
| 		$js.='	   \'Add files\' : \''.addslashes(Text::_('COM_PHOCAGALLERY_ADD_IMAGES')).'\','."\n"; | ||||
| 		$js.='	   \'Add Files\' : \''.addslashes(Text::_('COM_PHOCAGALLERY_ADD_IMAGES')).'\','."\n"; | ||||
| 		$js.='	   \'Start upload\':\''.addslashes(Text::_('COM_PHOCAGALLERY_START_UPLOAD')).'\','."\n"; | ||||
| 		$js.='	   \'Stop Upload\':\''.addslashes(Text::_('COM_PHOCAGALLERY_STOP_CURRENT_UPLOAD')).'\','."\n"; | ||||
| 		$js.='	   \'Stop current upload\' : \''.addslashes(Text::_('COM_PHOCAGALLERY_STOP_CURRENT_UPLOAD')).'\','."\n"; | ||||
| 		$js.='	   \'Start uploading queue\' : \''.addslashes(Text::_('COM_PHOCAGALLERY_START_UPLOADING_QUEUE')).'\','."\n"; | ||||
| 		$js.='	   \'Drag files here.\' : \''.addslashes(Text::_('COM_PHOCAGALLERY_DRAG_FILES_HERE')).'\''."\n"; | ||||
| 		$js.='   });'; | ||||
| 		$js.=''."\n"; | ||||
| 		$js.='	pgJQ("#'.$name.'").pluploadQueue({'."\n"; | ||||
| 		$js.='		runtimes : \''.$runtime.'\','."\n"; | ||||
| 		$js.='		url : \''.$this->url.'\','."\n"; | ||||
| 		//$js.='		max_file_size : \''.$this->maxFileSize.'\','."\n"; | ||||
|  | ||||
| 		if ($this->maxFileSize != '0b') { | ||||
| 			$js.='		max_file_size : \''.$this->maxFileSize.'\','."\n"; | ||||
| 		} | ||||
|  | ||||
| 		if ($chunkEnabled == 1) { | ||||
| 			$js.='		chunk_size : \'1mb\','."\n"; | ||||
| 		} | ||||
| 		$js.='      preinit: attachCallbacks,'."\n"; | ||||
| 		$js.='		unique_names : false,'."\n"; | ||||
| 		$js.='		multipart: true,'."\n"; | ||||
| 		$js.='		filters : ['."\n"; | ||||
| 		$js.='			{title : "'.Text::_('COM_PHOCAGALLERY_IMAGE_FILES').'", extensions : "jpg,gif,png,jpeg,webp,avif"}'."\n"; | ||||
| 		//$js.='			{title : "Zip files", extensions : "zip"}'."\n"; | ||||
| 		$js.='		],'."\n"; | ||||
| 		$js.=''."\n"; | ||||
| 		if ($this->method != 6) { | ||||
| 			if ((int)$this->imageWidth > 0 || (int)$this->imageWidth > 0) { | ||||
| 				$js.='		resize : {width : '.$this->imageWidth.', height : '.$this->imageHeight.', quality : '.$this->imageQuality.'},'."\n"; | ||||
| 				$js.=''."\n"; | ||||
| 			} | ||||
| 		} | ||||
| 		if ($this->method == 1) { | ||||
| 			$js.='		flash_swf_url : \''.Uri::root(true).'/media/com_phocagallery/js/plupload/plupload.flash.swf\''."\n"; | ||||
| 		} else if ($this->method == 3) { | ||||
| 			$js.='		silverlight_xap_url : \''.Uri::root(true).'/media/com_phocagallery/js/plupload/plupload.silverlight.xap\''."\n"; | ||||
| 		} | ||||
| 		$js.='	});'."\n"; | ||||
|  | ||||
| 		$js.=''."\n"; | ||||
|  | ||||
| 		$js.='function attachCallbacks(Uploader) {'."\n"; | ||||
| 		$js.='	Uploader.bind(\'FileUploaded\', function(Up, File, Response) {'."\n"; | ||||
| 		$js.='		var obj = eval(\'(\' + Response.response + \')\');'."\n"; | ||||
| 		if ($this->method == 6) { | ||||
| 			$js.='		var queueFiles = Uploader.total.failed + Uploader.total.uploaded;'."\n"; | ||||
| 			$js.='		var uploaded0 = Uploader.total.uploaded;'."\n"; | ||||
| 		} else { | ||||
| 			$js.='		var queueFiles = Uploader.total.failed + Uploader.total.uploaded + 1;'."\n"; | ||||
| 			$js.='		var uploaded0 = Uploader.total.uploaded + 1;'."\n"; | ||||
| 		} | ||||
| 		$js.=''."\n"; | ||||
| 		$js.='		if ((typeof(obj.result) != \'undefined\') && obj.result == \'error\') {'."\n"; | ||||
| 		$js.='			'."\n"; | ||||
| 		if ($this->method == 6) { | ||||
| 			//$js.='		var uploaded0 = Uploader.total.uploaded;'."\n"; | ||||
| 		} else { | ||||
| 			//$js.='		var uploaded0 = Uploader.total.uploaded + 1;'."\n"; | ||||
| 		} | ||||
| 		$js.='			Up.trigger("Error", {message : obj.message, code : obj.code, details : obj.details, file: File});'."\n"; | ||||
|  | ||||
|  | ||||
| 		//$js.='		console.log(obj);'."\n"; | ||||
|  | ||||
| 		$js.='				if( queueFiles == Uploader.files.length) {'."\n"; | ||||
| 		if ($this->method == 6) { | ||||
| 			$js.='		var uploaded0 = Uploader.total.uploaded;'."\n"; | ||||
| 		} else { | ||||
| 			$js.='		var uploaded0 = Uploader.total.uploaded;'."\n"; | ||||
| 		} | ||||
| 		$js.='					window.location = \''.$this->reload.'\' + \'&muuploaded=\' + uploaded0 + \'&mufailed=\' + Uploader.total.failed;'."\n"; | ||||
| 		//$js.='					alert(\'Error\' + obj.message)'."\n"; | ||||
| 		$js.='				}'."\n"; | ||||
| 		$js.='				return false; '."\n"; | ||||
| 		$js.=''."\n"; | ||||
| 		$js.='		} else {'."\n"; | ||||
| 		$js.='			if( queueFiles == Uploader.files.length) {'."\n"; | ||||
| 		//$js.='				var uploaded = Uploader.total.uploaded + 1;'."\n"; | ||||
| 		if ($this->method == 6) { | ||||
| 			$js.='		var uploaded = Uploader.total.uploaded;'."\n"; | ||||
| 		} else { | ||||
| 			$js.='		var uploaded = Uploader.total.uploaded + 1;'."\n"; | ||||
| 		} | ||||
| 		$js.='				window.location = \''.$this->reload.'\' + \'&muuploaded=\' + uploaded + \'&mufailed=\' + Uploader.total.failed;'."\n"; | ||||
| 		//$js.='					alert(\'OK\' + obj.message)'."\n"; | ||||
| 		$js.='			}'."\n"; | ||||
| 		$js.='		}'."\n"; | ||||
| 		$js.='	});'."\n"; | ||||
| 		$js.='	'."\n"; | ||||
| 		$js.='    Uploader.bind(\'Error\', function(Up, ErrorObj) {'."\n"; | ||||
| 		$js.=''."\n"; | ||||
| 	//	$js.='         if (ErrorObj.code == 100) { '."\n"; | ||||
| 		$js.='			pgJQ(\'#\' + ErrorObj.file.id).append(\'<div class="alert alert-error alert-danger">\'+ ErrorObj.message + ErrorObj.details +\'</div>\');'."\n"; | ||||
|  | ||||
| 		//$js.= '			console.log(ErrorObj.file.id + " " + ErrorObj.message + " " + ErrorObj.details);'."\n"; | ||||
|  | ||||
| 	//	$js.='         }'."\n"; | ||||
| 		$js.='    });	'."\n"; | ||||
| 		$js.='}'; | ||||
|  | ||||
| 		$js.='});'."\n";// End $(function() | ||||
|  | ||||
| 		$document->addScriptDeclaration($js); | ||||
|  | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	public function getMultipleUploadHTML($width = '', $height = '330', $mootools = 1) { | ||||
|  | ||||
|  | ||||
| 		switch ($this->method) { | ||||
| 			case 2: | ||||
| 				$name		= 'gears_uploader'; | ||||
| 				$msg		= Text::_('COM_PHOCAGALLERY_NOT_INSTALLED_GEARS'); | ||||
| 			break; | ||||
| 			case 3: | ||||
| 				$name		= 'silverlight_uploader'; | ||||
| 				$msg		= Text::_('COM_PHOCAGALLERY_NOT_INSTALLED_SILVERLIGHT'); | ||||
| 			break; | ||||
| 			case 4: | ||||
| 				$name		= 'html5_uploader'; | ||||
| 				$msg		= Text::_('COM_PHOCAGALLERY_NOT_SUPPORTED_HTML5'); | ||||
| 			break; | ||||
|  | ||||
| 			case 5: | ||||
| 				$name		= 'browserplus_uploader'; | ||||
| 				$msg		= Text::_('COM_PHOCAGALLERY_NOT_INSTALLED_BROWSERPLUS'); | ||||
| 			break; | ||||
|  | ||||
| 			case 6: | ||||
| 				$name		= 'html4_uploader'; | ||||
| 				$msg		= Text::_('COM_PHOCAGALLERY_NOT_SUPPORTED_HTML4'); | ||||
| 			break; | ||||
|  | ||||
| 			case 1: | ||||
| 			default: | ||||
| 				$name		= 'flash_uploader'; | ||||
| 				$msg		= Text::_('COM_PHOCAGALLERY_NOT_INSTALLED_FLASH'); | ||||
| 			break; | ||||
| 		} | ||||
|  | ||||
| 		$style				= ''; | ||||
| 		if ($width != '') { | ||||
| 			$style	.= 'width: '.(int)$width.'px;'; | ||||
| 		} | ||||
| 		if ($height != '') { | ||||
| 			$style	.= 'height: '.(int)$height.'px;'; | ||||
| 		} | ||||
|  | ||||
| 		return '<div id="'.$name.'" style="'.$style.'">'.$msg.'</div>'; | ||||
|  | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,40 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @package   Phoca Gallery | ||||
|  * @author    Jan Pavelka - https://www.phoca.cz | ||||
|  * @copyright Copyright (C) Jan Pavelka https://www.phoca.cz | ||||
|  * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later | ||||
|  * @cms       Joomla | ||||
|  * @copyright Copyright (C) Open Source Matters. All rights reserved. | ||||
|  * @license   http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php | ||||
|  */ | ||||
| defined( '_JEXEC' ) or die( 'Restricted access' ); | ||||
| use Joomla\CMS\Language\Text; | ||||
|  | ||||
| class PhocaGalleryFileUploadSingle | ||||
| { | ||||
| 	public $tab			= ''; | ||||
| 	public $returnUrl	= ''; | ||||
|  | ||||
| 	public function __construct() {} | ||||
| 	 | ||||
| 	public function getSingleUploadHTML( $frontEnd = 0) { | ||||
| 		 | ||||
| 		if ($frontEnd == 1) { | ||||
| 			 | ||||
| 			$html = '<input type="hidden" name="controller" value="category" />' | ||||
| 			.'<input type="hidden" name="tab" value="'.$this->tab.'" />'; | ||||
| 		 | ||||
| 		} else { | ||||
| 			$html = '<input type="file" id="sfile-upload" name="Filedata" />' | ||||
| 			//.'<input type="submit" id="sfile-upload-submit" value="'.JText::_('COM_PHOCAGALLERY_START_UPLOAD').'"/>' | ||||
| 			.'<button class="btn btn-primary" id="upload-submit"><i class="icon-upload icon-white"></i> '.Text::_('COM_PHOCAGALLERY_START_UPLOAD').'</button>' | ||||
| 			.'<input type="hidden" name="return-url" value="'. base64_encode($this->returnUrl).'" />' | ||||
| 			.'<input type="hidden" name="tab" value="'.$this->tab.'" />'; | ||||
| 		} | ||||
| 		 | ||||
| 		return $html; | ||||
| 		 | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -0,0 +1,104 @@ | ||||
| <?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; | ||||
|  | ||||
| class PhocaGalleryGeo | ||||
| { | ||||
| 	/* | ||||
| 	 * Geotagging | ||||
| 	 * If no lat or lng will be set by image, it will be automatically set by category | ||||
| 	 */ | ||||
| 	public static function findLatLngFromCategory($categories) { | ||||
| 		$output['lat'] = ''; | ||||
| 		$output['lng'] = ''; | ||||
| 		foreach ($categories as $category) { | ||||
| 			if (isset($category->latitude) && isset($category->longitude)) { | ||||
| 				if ($category->latitude != '' && $category->latitude != '') { | ||||
| 					$output['lat'] = $category->latitude; | ||||
| 				} | ||||
| 				if ($category->longitude != '' && $category->longitude != '') { | ||||
| 					$output['lng'] = $category->longitude; | ||||
| 				} | ||||
|  | ||||
| 				if ($output['lat'] != '' && $output['lng'] != '') { | ||||
| 					return $output; | ||||
| 				} | ||||
| 			}  | ||||
| 		} | ||||
| 		// If nothing will be found, paste some lng, lat | ||||
| 		$output['lat'] = 50.079623358200884; | ||||
| 		$output['lng'] = 14.429919719696045; | ||||
| 		return $output; | ||||
| 	} | ||||
| 	 | ||||
| 	public static function getGeoCoords($filename){ | ||||
|        | ||||
| 		$lat = $long = ''; | ||||
| 		$fileOriginal = PhocaGalleryFile::getFileOriginal($filename); | ||||
| 	   | ||||
| 	if (!function_exists('exif_read_data')) { | ||||
| 		return array('latitude' => 0, 'longitude' => 0); | ||||
| 	} else { | ||||
| 		if (strtolower(File::getExt($fileOriginal)) != 'jpg') { | ||||
| 			return array('latitude' => 0, 'longitude' => 0); | ||||
| 		} | ||||
| 		 | ||||
| 		// Not happy but @ must be added because of different warnings returned by exif functions - can break multiple upload | ||||
| 		$exif 		= @exif_read_data($fileOriginal, 0, true); | ||||
| 		if (empty($exif)) { | ||||
| 			return array('latitude' => 0, 'longitude' => 0); | ||||
| 		} | ||||
|  | ||||
| 		 | ||||
| 		if (isset($exif['GPS']['GPSLatitude'][0])) {$GPSLatDeg 		= explode('/',$exif['GPS']['GPSLatitude'][0]);} | ||||
| 		if (isset($exif['GPS']['GPSLatitude'][1])) {$GPSLatMin 		= explode('/',$exif['GPS']['GPSLatitude'][1]);} | ||||
| 		if (isset($exif['GPS']['GPSLatitude'][2])) {$GPSLatSec 		= explode('/',$exif['GPS']['GPSLatitude'][2]);} | ||||
| 		if (isset($exif['GPS']['GPSLongitude'][0])) {$GPSLongDeg 	= explode('/',$exif['GPS']['GPSLongitude'][0]);} | ||||
| 		if (isset($exif['GPS']['GPSLongitude'][1])) {$GPSLongMin 	= explode('/',$exif['GPS']['GPSLongitude'][1]);} | ||||
| 		if (isset($exif['GPS']['GPSLongitude'][2])) {$GPSLongSec 	= explode('/',$exif['GPS']['GPSLongitude'][2]);} | ||||
| 		 | ||||
| 		 | ||||
| 		if (isset($GPSLatDeg[0]) && isset($GPSLatDeg[1]) && (int)$GPSLatDeg[1] > 0 | ||||
| 		 && isset($GPSLatMin[0]) && isset($GPSLatMin[1]) && (int)$GPSLatMin[1] > 0 | ||||
| 		 && isset($GPSLatSec[0]) && isset($GPSLatSec[1]) && (int)$GPSLatSec[1] > 0) { | ||||
|  | ||||
| 			$lat = $GPSLatDeg[0]/$GPSLatDeg[1]+ | ||||
| 				($GPSLatMin[0]/$GPSLatMin[1])/60+ | ||||
| 				($GPSLatSec[0]/$GPSLatSec[1])/3600; | ||||
| 				 | ||||
| 			if(isset($exif['GPS']['GPSLatitudeRef']) && $exif['GPS']['GPSLatitudeRef'] == 'S'){$lat=$lat*(-1);} | ||||
| 			 | ||||
| 		 | ||||
| 		} | ||||
| 		 | ||||
| 		  | ||||
| 		if (isset($GPSLongDeg[0]) && isset($GPSLongDeg[1]) && (int)$GPSLongDeg[1] > 0 | ||||
| 		 && isset($GPSLongMin[0]) && isset($GPSLongMin[1]) && (int)$GPSLongMin[1] > 0 | ||||
| 		 && isset($GPSLongSec[0]) && isset($GPSLongSec[1]) && (int)$GPSLongSec[1] > 0) { | ||||
|  | ||||
| 	 | ||||
| 			$long = $GPSLongDeg[0]/$GPSLongDeg[1]+ | ||||
| 				($GPSLongMin[0]/$GPSLongMin[1])/60+ | ||||
| 				($GPSLongSec[0]/$GPSLongSec[1])/3600; | ||||
| 				 | ||||
| 			if(isset($exif['GPS']['GPSLongitudeRef']) && $exif['GPS']['GPSLongitudeRef'] == 'W'){$long=$long*(-1);} | ||||
|  | ||||
| 		} | ||||
| 		 | ||||
|  | ||||
|  | ||||
| 		return array('latitude' => $lat, 'longitude' => $long); | ||||
| 	  } | ||||
|    } | ||||
|   | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -0,0 +1,64 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @package   Phoca Gallery | ||||
|  * @author    Jan Pavelka - https://www.phoca.cz | ||||
|  * @copyright Copyright (C) Jan Pavelka https://www.phoca.cz | ||||
|  * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later | ||||
|  * @cms       Joomla | ||||
|  * @copyright Copyright (C) Open Source Matters. All rights reserved. | ||||
|  * @license   http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php | ||||
|  */ | ||||
| defined('_JEXEC') or die; | ||||
| use Joomla\CMS\Language\Text; | ||||
| use Joomla\CMS\HTML\HTMLHelper; | ||||
| use Joomla\CMS\Factory; | ||||
|  | ||||
| abstract class PhocaGalleryBatch | ||||
| { | ||||
|  | ||||
| 	public static function item($published, $category = 0) | ||||
| 	{ | ||||
| 		// Create the copy/move options. | ||||
| 		$options = array( | ||||
| 			HTMLHelper::_('select.option', 'c', Text::_('JLIB_HTML_BATCH_COPY')), | ||||
| 			HTMLHelper::_('select.option', 'm', Text::_('JLIB_HTML_BATCH_MOVE')) | ||||
| 		); | ||||
|  | ||||
| 		$db		= Factory::getDbo(); | ||||
|  | ||||
|        //build the list of categories | ||||
| 		$query = 'SELECT a.title AS text, a.id AS value, a.parent_id as parentid' | ||||
| 		. ' FROM #__phocagallery_categories AS a' | ||||
| 		// TO DO. ' WHERE a.published = '.(int)$published | ||||
| 		. ' ORDER BY a.ordering'; | ||||
| 		$db->setQuery( $query ); | ||||
| 		$data = $db->loadObjectList(); | ||||
| 		$tree = array(); | ||||
| 		$text = ''; | ||||
| 		$catId= -1; | ||||
| 		$tree = PhocaGalleryCategoryhtml::CategoryTreeOption($data, $tree, 0, $text, $catId); | ||||
|  | ||||
| 		if ($category == 1) { | ||||
| 			array_unshift($tree, HTMLHelper::_('select.option', 0, Text::_('JLIB_HTML_ADD_TO_ROOT'), 'value', 'text')); | ||||
| 		} | ||||
|  | ||||
|  | ||||
| 		// Create the batch selector to change select the category by which to move or copy. | ||||
| 		$lines = array( | ||||
| 			'<label id="batch-choose-action-lbl" for="batch-choose-action">', | ||||
| 			Text::_('JLIB_HTML_BATCH_MENU_LABEL'), | ||||
| 			'</label>', | ||||
| 			'<fieldset id="batch-choose-action" class="combo">', | ||||
| 				'<select name="batch[category_id]" class="form-select" id="batch-category-id">', | ||||
| 					'<option value=""> - '.Text::_('JSELECT').' - </option>', | ||||
| 					/*JHtml::_('select.options',	JHtml::_('category.options', $extension, array('published' => (int) $published))),*/ | ||||
| 					HTMLHelper::_('select.options',  $tree ), | ||||
| 				'</select>', | ||||
| 				HTMLHelper::_( 'select.radiolist', $options, 'batch[move_copy]', '', 'value', 'text', 'm'), | ||||
| 			'</fieldset>' | ||||
| 		); | ||||
|  | ||||
| 		return implode("\n", $lines); | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,64 @@ | ||||
| <?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; | ||||
| class PhocaGalleryCategory | ||||
| { | ||||
| 	public static function options($type = 0, $ignorePublished = 0) | ||||
| 	{ | ||||
| 		if ($type == 1) { | ||||
| 			$tree[0] 			= new JObject(); | ||||
| 			$tree[0]->text 		= JText::_('COM_PHOCAGALLERY_MAIN_CSS'); | ||||
| 			$tree[0]->value 	= 1; | ||||
| 			$tree[1] 			= new JObject(); | ||||
| 			$tree[1]->text 		= JText::_('COM_PHOCAGALLERY_CUSTOM_CSS'); | ||||
| 			$tree[1]->value 	= 2; | ||||
| 			return $tree; | ||||
| 		} | ||||
|  | ||||
| 		$db = JFactory::getDBO(); | ||||
|  | ||||
|        //build the list of categories | ||||
| 		$query = 'SELECT a.title AS text, a.id AS value, a.parent_id as parentid' | ||||
| 		. ' FROM #__phocagallery_categories AS a'; | ||||
| 		if ($ignorePublished == 0) { | ||||
| 			$query .= ' WHERE a.published = 1'; | ||||
| 		} | ||||
| 		$query .= ' ORDER BY a.ordering'; | ||||
| 		$db->setQuery( $query ); | ||||
| 		$phocagallerys = $db->loadObjectList(); | ||||
|  | ||||
| 		$catId	= -1; | ||||
|  | ||||
| 		$javascript 	= 'class="inputbox" size="1" onchange="Joomla.submitform( );"'; | ||||
|  | ||||
| 		$tree = array(); | ||||
| 		$text = ''; | ||||
| 		$tree = self::CategoryTreeOption($phocagallerys, $tree, 0, $text, $catId); | ||||
|  | ||||
| 		return $tree; | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	public static function CategoryTreeOption($data, $tree, $id=0, $text='', $currentId = 0) { | ||||
|  | ||||
| 		foreach ($data as $key) { | ||||
| 			$show_text =  $text . $key->text; | ||||
|  | ||||
| 			if ($key->parentid == $id && $currentId != $id && $currentId != $key->value) { | ||||
| 				$tree[$key->value] 			= new JObject(); | ||||
| 				$tree[$key->value]->text 	= $show_text; | ||||
| 				$tree[$key->value]->value 	= $key->value; | ||||
| 				$tree = self::CategoryTreeOption($data, $tree, $key->value, $show_text . " - ", $currentId ); | ||||
| 			} | ||||
| 		} | ||||
| 		return($tree); | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,67 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @package   Phoca Gallery | ||||
|  * @author    Jan Pavelka - https://www.phoca.cz | ||||
|  * @copyright Copyright (C) Jan Pavelka https://www.phoca.cz | ||||
|  * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later | ||||
|  * @cms       Joomla | ||||
|  * @copyright Copyright (C) Open Source Matters. All rights reserved. | ||||
|  * @license   http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php | ||||
|  */ | ||||
| defined('_JEXEC') or die; | ||||
| use Joomla\CMS\Object\CMSObject; | ||||
| use Joomla\CMS\Language\Text; | ||||
| use Joomla\CMS\Factory; | ||||
| class PhocaGalleryCategoryhtml | ||||
| { | ||||
| 	public static function options($type = 0, $ignorePublished = 0) | ||||
| 	{ | ||||
| 		if ($type == 1) { | ||||
| 			$tree[0] 			= new CMSObject(); | ||||
| 			$tree[0]->text 		= Text::_('COM_PHOCAGALLERY_MAIN_CSS'); | ||||
| 			$tree[0]->value 	= 1; | ||||
| 			$tree[1] 			= new CMSObject(); | ||||
| 			$tree[1]->text 		= Text::_('COM_PHOCAGALLERY_CUSTOM_CSS'); | ||||
| 			$tree[1]->value 	= 2; | ||||
| 			return $tree; | ||||
| 		} | ||||
|  | ||||
| 		$db = Factory::getDBO(); | ||||
|  | ||||
|        //build the list of categories | ||||
| 		$query = 'SELECT a.title AS text, a.id AS value, a.parent_id as parentid' | ||||
| 		. ' FROM #__phocagallery_categories AS a'; | ||||
| 		if ($ignorePublished == 0) { | ||||
| 			$query .= ' WHERE a.published = 1'; | ||||
| 		} | ||||
| 		$query .= ' ORDER BY a.ordering'; | ||||
| 		$db->setQuery( $query ); | ||||
| 		$phocagallerys = $db->loadObjectList(); | ||||
|  | ||||
| 		$catId	= -1; | ||||
|  | ||||
| 		$javascript 	= 'class="form-control" size="1" onchange="Joomla.submitform( );"'; | ||||
|  | ||||
| 		$tree = array(); | ||||
| 		$text = ''; | ||||
| 		$tree = self::CategoryTreeOption($phocagallerys, $tree, 0, $text, $catId); | ||||
|  | ||||
| 		return $tree; | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	public static function CategoryTreeOption($data, $tree, $id=0, $text='', $currentId = 0) { | ||||
|  | ||||
| 		foreach ($data as $key) { | ||||
| 			$show_text =  $text . $key->text; | ||||
|  | ||||
| 			if ($key->parentid == $id && $currentId != $id && $currentId != $key->value) { | ||||
| 				$tree[$key->value] 			= new CMSObject(); | ||||
| 				$tree[$key->value]->text 	= $show_text; | ||||
| 				$tree[$key->value]->value 	= $key->value; | ||||
| 				$tree = self::CategoryTreeOption($data, $tree, $key->value, $show_text . " - ", $currentId ); | ||||
| 			} | ||||
| 		} | ||||
| 		return($tree); | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,141 @@ | ||||
| <?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 | ||||
|  */ | ||||
|  | ||||
| /* | ||||
| jimport('joomla.html.grid'); | ||||
| jimport('joomla.html.html.grid'); | ||||
| jimport('joomla.html.html.jgrid'); | ||||
| */ | ||||
| defined('_JEXEC') or die; | ||||
|  | ||||
| use Joomla\CMS\HTML\Helpers\Grid; | ||||
| use Joomla\CMS\HTML\HTMLHelper; | ||||
| use Joomla\CMS\Language\Text; | ||||
| use Joomla\CMS\Factory; | ||||
| if (! class_exists('HTMLHelperGrid')) { | ||||
| 	require_once( JPATH_SITE.'/libraries/src/HTML/Helpers/Grid.php' ); | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| class PhocaGalleryGrid extends Grid | ||||
| { | ||||
|  | ||||
| 	public static function id($rowNum, $recId, $checkedOut = false, $name = 'cid', $stub = 'cb', $title = '', $formId = null) | ||||
| 	{ | ||||
| 		if ($checkedOut) | ||||
| 		{ | ||||
| 			return ''; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			return '<input type="checkbox" id="cb' . $rowNum . '" name="' . $name . '[]" value="' . $recId | ||||
| 				. '" onclick="Joomla.isChecked(this.checked, \'undefined\');" title="' . Text::sprintf('JGRID_CHECKBOX_ROW_N', ($rowNum + 1)) . '" />'; | ||||
| 			//return '<input type="checkbox" id="cb' . $rowNum . '" name="' . $name . '[]" value="' . $recId | ||||
| 			//	. '"  title="' . JText::sprintf('JGRID_CHECKBOX_ROW_N', ($rowNum + 1)) . '" />'; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Method to sort a column in a grid | ||||
| 	 * | ||||
| 	 * @param   string  $title          The link title | ||||
| 	 * @param   string  $order          The order field for the column | ||||
| 	 * @param   string  $direction      The current direction | ||||
| 	 * @param   string  $selected       The selected ordering | ||||
| 	 * @param   string  $task           An optional task override | ||||
| 	 * @param   string  $new_direction  An optional direction for the new column | ||||
| 	 * @param   string  $tip            An optional text shown as tooltip title instead of $title | ||||
| 	 * | ||||
| 	 * @return  string | ||||
| 	 * | ||||
| 	 * @since   1.5 | ||||
| 	 */ | ||||
|  | ||||
|  | ||||
| 	 /* | ||||
| 	 * GRID in frontend must be customized | ||||
| 	 * because Joomla! takes "adminForm" as the only one name of form ?????????????????????????????????????????? | ||||
| 	 * | ||||
| 	 */ | ||||
|  | ||||
| 	public static function sort($title, $order, $direction = 'asc', $selected = 0, $task = null, $new_direction = 'asc', $tip = '', $form = '', $suffix = '') | ||||
| 	{ | ||||
|  | ||||
| 		$direction = strtolower($direction); | ||||
| 		$icon = array('arrow-up-3', 'arrow-down-3'); | ||||
| 		$index = (int) ($direction == 'desc'); | ||||
|  | ||||
| 		if ($order != $selected) | ||||
| 		{ | ||||
| 			$direction = $new_direction; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			$direction = ($direction == 'desc') ? 'asc' : 'desc'; | ||||
| 		} | ||||
|  | ||||
| 		$html = '<a href="#" onclick="Joomla.tableOrderingPhoca(\'' . $order . '\',\'' . $direction . '\',\'' . $task . '\',\'' . $form . '\',\'' . $suffix . '\');return false;"' | ||||
| 			. ' class="hasTooltip" title="' . HTMLHelper::tooltipText(($tip ? $tip : $title), 'JGLOBAL_CLICK_TO_SORT_THIS_COLUMN') . '">'; | ||||
|  | ||||
| 		if (isset($title['0']) && $title['0'] == '<') | ||||
| 		{ | ||||
| 			$html .= $title; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			$html .= Text::_($title); | ||||
| 		} | ||||
|  | ||||
| 		if ($order == $selected) | ||||
| 		{ | ||||
|  | ||||
| 			$html .= ' <i class="icon-' . $icon[$index] . ' glyphicon glyphicon-' . $icon[$index] . '"></i>'; | ||||
| 		} | ||||
|  | ||||
| 		$html .= '</a>'; | ||||
|  | ||||
| 		return $html; | ||||
| 	} | ||||
|  | ||||
| 	public static function renderSortJs() { | ||||
|  | ||||
|  | ||||
| $o = ''; | ||||
| $o .= '<script type="text/javascript">'."\n"; | ||||
| $o .= ''."\n"; | ||||
| $o .= 'Joomla.tableOrderingPhoca = function(order, dir, task, form, suffix) {'."\n"; | ||||
| $o .= ''."\n"; | ||||
| $o .= '   if (typeof(form) === "undefined") {'."\n"; | ||||
| $o .= '      form = document.getElementById("adminForm");'."\n"; | ||||
| $o .= '   }'."\n"; | ||||
| $o .= ''."\n"; | ||||
| $o .= ''."\n"; | ||||
| $o .= '   if (typeof form == "string" || form instanceof String) {'."\n"; | ||||
| $o .= '      form = document.getElementById(form);'."\n"; | ||||
| $o .= '   }'."\n"; | ||||
| $o .= ''."\n"; | ||||
| $o .= '   var orderS 		= "filter_order" + suffix;'."\n"; | ||||
| $o .= '   var orderSDir 	= "filter_order_Dir" + suffix;'."\n"; | ||||
| $o .= ''."\n"; | ||||
| $o .= '   form[orderS].value = order;'."\n"; | ||||
| $o .= '   form[orderSDir].value = dir;'."\n"; | ||||
| $o .= '   Joomla.submitform(task, form);'."\n"; | ||||
| $o .= ''."\n"; | ||||
| $o .= '}'."\n"; | ||||
| $o .= '</script>'."\n"; | ||||
|  | ||||
|  | ||||
|  | ||||
| 		$document = Factory::getDocument(); | ||||
| 		$document->addCustomTag($o); | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1 @@ | ||||
| <html><body></body></html> | ||||
| @ -0,0 +1,44 @@ | ||||
| <?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 | ||||
|  */ | ||||
|  | ||||
| /* | ||||
| jimport('joomla.html.grid'); | ||||
| jimport('joomla.html.html.grid'); | ||||
| jimport('joomla.html.html.jgrid'); | ||||
| */ | ||||
| defined('_JEXEC') or die; | ||||
|  | ||||
| use Joomla\CMS\HTML\Helpers\JGrid; | ||||
| use Joomla\CMS\HTML\HTMLHelper; | ||||
| if (! class_exists('HTMLHelperJGrid')) { | ||||
| 	require_once( JPATH_SITE.'/libraries/src/HTML/Helpers/JGrid.php' ); | ||||
| } | ||||
|  | ||||
| class PhocaGalleryJGrid extends JGrid | ||||
| { | ||||
|  | ||||
| 	public static function approved($value, $i, $prefix = '', $enabled = true, $checkbox='cb') | ||||
| 	{ | ||||
| 		if (is_array($prefix)) { | ||||
| 			$options	= $prefix; | ||||
| 			$enabled	= array_key_exists('enabled',	$options) ? $options['enabled']		: $enabled; | ||||
| 			$checkbox	= array_key_exists('checkbox',	$options) ? $options['checkbox']	: $checkbox; | ||||
| 			$prefix		= array_key_exists('prefix',	$options) ? $options['prefix']		: ''; | ||||
| 		} | ||||
| 		$states	= array( | ||||
| 			1	=> array('disapprove',	'COM_PHOCAGALLERY_APPROVED',	'COM_PHOCAGALLERY_NOT_APPROVE_ITEM',	'COM_PHOCAGALLERY_APPROVED',	false,	'publish',		'publish'), | ||||
| 			0	=> array('approve',		'COM_PHOCAGALLERY_NOT_APPROVED',	'COM_PHOCAGALLERY_APPROVE_ITEM',	'COM_PHOCAGALLERY_NOT_APPROVED',	false,	'unpublish',	'unpublish') | ||||
| 		); | ||||
| 		return self::state($states, $value, $i, $prefix, $enabled, true, $checkbox); | ||||
| 	} | ||||
|  | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,354 @@ | ||||
| <?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\Path; | ||||
| use Joomla\CMS\Filesystem\File; | ||||
| use Joomla\CMS\Uri\Uri; | ||||
| use Joomla\CMS\Factory; | ||||
|  | ||||
| class PhocaGalleryImage | ||||
| { | ||||
|  | ||||
| 	public static function getImageSize($filename, $returnString = 0, $extLink = 0) { | ||||
|  | ||||
| 		phocagalleryimport('phocagallery.image.image'); | ||||
| 		phocagalleryimport('phocagallery.path.path'); | ||||
|  | ||||
| 		if ($extLink == 1) { | ||||
| 			$fileNameAbs	= $filename; | ||||
| 		} else { | ||||
| 			$path			= PhocaGalleryPath::getPath(); | ||||
| 			$fileNameAbs	= Path::clean($path->image_abs . $filename); | ||||
|  | ||||
| 			if (!File::exists($fileNameAbs)) { | ||||
| 				$fileNameAbs	= $path->image_abs_front . 'phoca_thumb_l_no_image.png'; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		if ($returnString == 1) { | ||||
| 			$imageSize = @getimagesize($fileNameAbs); | ||||
| 			return $imageSize[0] . ' x '.$imageSize[1]; | ||||
| 		} else { | ||||
| 			return @getimagesize($fileNameAbs); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public static function getRealImageSize($filename, $size = 'large', $extLink = 0) { | ||||
|  | ||||
| 		phocagalleryimport('phocagallery.file.thumbnail'); | ||||
|  | ||||
| 		if ($extLink == 1) { | ||||
| 			list($w, $h, $type) = @getimagesize($filename); | ||||
| 		} else { | ||||
| 			$thumbName			= PhocaGalleryFileThumbnail::getThumbnailName ($filename, $size); | ||||
| 			list($w, $h, $type) = @getimagesize($thumbName->abs); | ||||
| 		} | ||||
| 		$sizeA = array(); | ||||
| 		if (isset($w) && isset($h)) { | ||||
| 			$sizeA['w'] = $w; | ||||
| 			$sizeA['h']	= $h; | ||||
| 		} else { | ||||
| 			$sizeA['w'] = 0; | ||||
| 			$sizeA['h']	= 0; | ||||
| 		} | ||||
| 		return $sizeA; | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	public static function correctSizeWithRate($width, $height, $corWidth = 100, $corHeight = 100) { | ||||
| 		$image['width']		= $corWidth; | ||||
| 		$image['height']	= $corHeight; | ||||
|  | ||||
|  | ||||
|  | ||||
| 		if ($width > $height) { | ||||
| 			if ($width > $corWidth) { | ||||
| 				$image['width']		= $corWidth; | ||||
| 				$rate 				= $width / $corWidth; | ||||
| 				$image['height']	= $height / $rate; | ||||
| 			} else { | ||||
| 				$image['width']		= $width; | ||||
| 				$image['height']	= $height; | ||||
| 			} | ||||
| 		} else { | ||||
| 			if ($height > $corHeight) { | ||||
| 				$image['height']	= $corHeight; | ||||
| 				$rate 				= $height / $corHeight; | ||||
| 				$image['width'] 	= $width / $rate; | ||||
| 			} else { | ||||
| 				$image['width']		= $width; | ||||
| 				$image['height']	= $height; | ||||
| 			} | ||||
| 		} | ||||
| 		return $image; | ||||
| 	} | ||||
|  | ||||
| 	public static function correctSize($imageSize, $size = 100, $sizeBox = 100, $sizeAdd = 0) { | ||||
|  | ||||
| 		$image['size']	= $imageSize; | ||||
| 		if ((int)$image['size'] < (int)$size ) { | ||||
| 			$image['size']		= $size; | ||||
| 			$image['boxsize'] 	= (int)$size + (int)$sizeAdd; | ||||
| 		} else { | ||||
| 			$image['boxsize'] 	= (int)$image['size'] + (int)$sizeAdd; | ||||
| 		} | ||||
| 		return $image; | ||||
| 	} | ||||
|  | ||||
| 	public static function correctSwitchSize($switchHeight, $switchWidth) { | ||||
|  | ||||
| 		$switchImage['height'] 	= $switchHeight; | ||||
| 		$switchImage['centerh']	= ($switchHeight / 2) - 18; | ||||
| 		$switchImage['width'] 	= $switchWidth; | ||||
| 		$switchImage['centerw']	= ($switchWidth / 2) - 18; | ||||
| 		$switchImage['height']	= $switchImage['height'] + 5; | ||||
| 		return $switchImage; | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * type ... 1 categories, 2 category view | ||||
| 	 */ | ||||
| 	public static function setBoxSize($p, $type = 1) { | ||||
|  | ||||
|  | ||||
| 		$w 	= 20; | ||||
| 		$w2 = 25; | ||||
| 		$w3 = 18; | ||||
| 		$w4 = 40; | ||||
|  | ||||
| 		$boxWidth	= 0; | ||||
| 		$boxSize['width'] 	= 0; | ||||
| 		$boxSize['height']	= 0; | ||||
|  | ||||
|  | ||||
| 		if (isset($p['imagewidth'])) { | ||||
| 			$boxSize['width'] = $boxSize['width'] + (int)$p['imagewidth']; | ||||
| 		} | ||||
|  | ||||
| 		if (isset($p['imageheight'])) { | ||||
| 			$boxSize['height'] = $boxSize['height'] + (int)$p['imageheight']; | ||||
| 		} | ||||
|  | ||||
| 		if (isset($p['display_name']) && ($p['display_name'] == 1 || $p['display_name'] == 2)) { | ||||
| 			$boxSize['height'] = $boxSize['height'] + $w; | ||||
| 		} | ||||
|  | ||||
| 		if ($type == 3) { | ||||
| 			$boxSize['height'] = $boxSize['height'] + $w; | ||||
| 			return $boxSize; | ||||
| 		} | ||||
|  | ||||
| 		if ( (isset($p['display_rating']) && $p['display_rating'] == 1) || (isset($p['display_rating_img']) && $p['display_rating_img'] > 0)) { | ||||
|  | ||||
|  | ||||
| 			if ($type == 1) { | ||||
| 				$boxSize['height'] = $boxSize['height'] + $w4; | ||||
| 			} else { | ||||
| 				$boxSize['height'] = $boxSize['height'] + $w; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
|  | ||||
| 		if (isset($p['displaying_tags_true']) && $p['displaying_tags_true'] == 1) { | ||||
| 			$boxSize['height'] = $boxSize['height'] + (int) + $w3; | ||||
| 		} | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| 		if (isset($p['display_icon_detail']) && $p['display_icon_detail'] == 1) { | ||||
| 			$boxWidth = $boxWidth + $w; | ||||
| 		} | ||||
| 		if (isset($p['display_icon_download']) && (int)$p['display_icon_download'] > 0) { | ||||
| 			$boxWidth = $boxWidth + $w; | ||||
| 		} | ||||
| 		if (isset($p['display_icon_vm']) && $p['display_icon_vm'] == 1) { | ||||
| 			$boxWidth = $boxWidth + $w; | ||||
| 		} | ||||
|  | ||||
| 		if (isset($p['start_cooliris']) && $p['start_cooliris'] == 1) { | ||||
| 			$boxWidth = $boxWidth + $w; | ||||
| 		} | ||||
|  | ||||
| 		if (isset($p['trash']) && $p['trash'] == 1) { | ||||
| 			$boxWidth = $boxWidth + $w; | ||||
| 		} | ||||
|  | ||||
| 		if (isset($p['publish_unpublish']) && $p['publish_unpublish'] == 1) { | ||||
| 			$boxWidth = $boxWidth + $w; | ||||
| 		} | ||||
|  | ||||
| 		if (isset($p['display_icon_geo_box']) && $p['display_icon_geo_box'] == 1) { | ||||
| 			$boxWidth = $boxWidth + $w; | ||||
| 		} | ||||
|  | ||||
| 		if (isset($p['display_camera_info']) && $p['display_camera_info'] == 1) { | ||||
| 			$boxWidth = $boxWidth + $w; | ||||
| 		} | ||||
|  | ||||
| 		if (isset($p['display_icon_extlink1_box']) && $p['display_icon_extlink1_box'] == 1) { | ||||
| 			$boxWidth = $boxWidth + $w; | ||||
| 		} | ||||
|  | ||||
| 		if (isset($p['display_icon_extlink2_box']) && $p['display_icon_extlink2_box'] == 1) { | ||||
| 			$boxWidth = $boxWidth + $w; | ||||
| 		} | ||||
|  | ||||
| 		if (isset($p['approved_not_approved']) && $p['approved_not_approved'] == 1) { | ||||
| 			$boxWidth = $boxWidth + $w; | ||||
| 		} | ||||
|  | ||||
| 		if (isset($p['display_icon_commentimg_box']) && $p['display_icon_commentimg_box'] == 1) { | ||||
| 			$boxWidth = $boxWidth + $w; | ||||
| 		} | ||||
|  | ||||
| 		$boxHeightRows 			= ceil($boxWidth/$boxSize['width']); | ||||
| 		$boxSize['height'] 		= ($w * $boxHeightRows) + $boxSize['height']; | ||||
|  | ||||
| 		// LAST | ||||
| 		if ($type == 1) { | ||||
| 			if (isset($p['categories_box_space'])) { | ||||
| 				$boxSize['height'] = $boxSize['height'] + (int)$p['categories_box_space']; | ||||
| 			} | ||||
| 		} else { | ||||
| 			if (isset($p['category_box_space'])) { | ||||
| 				$boxSize['height'] = $boxSize['height'] + (int)$p['category_box_space']; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return $boxSize; | ||||
| 	} | ||||
|  | ||||
| 	public static function getPngQuality($thumbQuality) { | ||||
|  | ||||
| 		if ((int)$thumbQuality < 0) { | ||||
| 			$thumbQuality = 0; | ||||
| 		} | ||||
| 		if ((int)$thumbQuality > 100) { | ||||
| 			$thumbQuality = 100; | ||||
| 		} | ||||
|  | ||||
| 		$pngQuality = ($thumbQuality - 100) / 11.111111; | ||||
| 		$pngQuality = round(abs($pngQuality)); | ||||
| 		return $pngQuality; | ||||
| 	} | ||||
|  | ||||
| 	public static function getJpegQuality($jpegQuality) { | ||||
| 		if ((int)$jpegQuality < 0) { | ||||
| 			$jpegQuality = 0; | ||||
| 		} | ||||
| 		if ((int)$jpegQuality > 100) { | ||||
| 			$jpegQuality = 100; | ||||
| 		} | ||||
| 		return $jpegQuality; | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Transform image (only with html method) for overlib effect e.g. | ||||
| 	 * | ||||
| 	 * @param array An array of image size (width, height) | ||||
| 	 * @param int Rate | ||||
| 	 * @access public | ||||
| 	 */ | ||||
|  | ||||
| 	 public static function getTransformImageArray($imgSize, $rate) { | ||||
| 		if (isset($imgSize[0]) && isset($imgSize[1])) { | ||||
| 			$w = (int)$imgSize[0]; | ||||
| 			$h = (int)$imgSize[1]; | ||||
|  | ||||
| 			if ($w != 0) {$w = $w/$rate;} // plus or minus should be divided, not null | ||||
| 			if ($h != 0) {$h = $h/$rate;} | ||||
| 			$wHOutput = array('width' => $w, 'height' => $h, 'style' => 'background: #fff url('.Uri::base(true).'/media/com_phocagallery/images/icon-loading2.gif) 50% 50% no-repeat;'); | ||||
| 		} else { | ||||
| 			$w = $h = 0; | ||||
| 			$wHOutput = array(); | ||||
| 		} | ||||
| 		return $wHOutput; | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Used for albums or specific images | ||||
| 	 * Check if it is Picasa or Facebook category or image | ||||
| 	 * If we ask only on image, the second parameter will be empty and will be ignnored | ||||
| 	 * If we ask album, first check Picasa album, second check Facebook album | ||||
| 	 */ | ||||
|  | ||||
| 	public static function isExtImage($extid, $extfbcatid = '') { | ||||
|  | ||||
| 		// EXTID (IMAGES): Picasa - yes, Facebook - yes | ||||
| 		// EXTID (ALBUMS): Picasa - yes, Facebook - no | ||||
| 		if (isset($extid) && $extid != '') { | ||||
| 			return true; | ||||
| 		} | ||||
|  | ||||
| 		// EXTFBCATID (IMAGES): Picasa - no, Facebook - no | ||||
| 		// EXTFBCATID (ALBUMS): Picasa - no, Facebook - yes | ||||
| 		if (isset($extfbcatid) && $extfbcatid != '') { | ||||
| 			return true; | ||||
| 		} | ||||
|  | ||||
|  | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	public static function getImageByImageId($id = 0) { | ||||
|  | ||||
| 		$db 	= Factory::getDBO(); | ||||
| 		$query = ' SELECT a.id, a.title, c.title as category_title' | ||||
| 				.' FROM #__phocagallery AS a' | ||||
| 				.' LEFT JOIN #__phocagallery_categories AS c ON c.id = a.catid' | ||||
| 				.' WHERE a.id = '.(int)$id | ||||
| 				.' GROUP BY a.id, a.title, c.title' | ||||
| 				.' ORDER BY a.id' | ||||
| 				.' LIMIT 1'; | ||||
| 		$db->setQuery($query); | ||||
| 		$image = $db->loadObject(); | ||||
|  | ||||
| 		return $image; | ||||
| 	} | ||||
|  | ||||
| 	public static function updateRealThumbnailSizes($image, $sizes) { | ||||
|  | ||||
| 		if ($image == '') { | ||||
| 			return false; | ||||
| 		} | ||||
| 		if (empty($sizes)) { | ||||
| 			return false; | ||||
| 		} | ||||
|  | ||||
| 		$path = PhocaGalleryPath::getPath(); | ||||
|         $file = str_replace($path->image_rel, '', $image); | ||||
|  | ||||
|         $extW = ''; | ||||
|         if (isset($sizes['l']['w']) && isset($sizes['m']['w']) && isset($sizes['s']['w'])) { | ||||
|             $extW = (int)$sizes['l']['w'].','.(int)$sizes['m']['w'].','.(int)$sizes['s']['w']; | ||||
|         } | ||||
|         $extH = ''; | ||||
|         if (isset($sizes['l']['h']) && isset($sizes['m']['h']) && isset($sizes['s']['h'])) { | ||||
|             $extH = (int)$sizes['l']['h'].','.(int)$sizes['m']['h'].','.(int)$sizes['s']['h']; | ||||
|         } | ||||
|  | ||||
|         if ($file != '' && $extW != '' && $extH != '') { | ||||
|  | ||||
|             $db 	= Factory::getDBO(); | ||||
|             $query = 'UPDATE #__phocagallery' | ||||
|                 .' SET extw = '.$db->quote($extW).',' | ||||
|                 .' exth = '.$db->quote($extH) | ||||
|                 .' WHERE filename = '.$db->quote($file); | ||||
|  | ||||
|             $db->setQuery($query); | ||||
|             $db->execute(); | ||||
|             return true; | ||||
|         } | ||||
|         return false; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,333 @@ | ||||
| <?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\Filesystem\File; | ||||
| jimport( 'joomla.filesystem.folder' ); | ||||
| jimport( 'joomla.filesystem.file' ); | ||||
| phocagalleryimport('phocagallery.path.path'); | ||||
| phocagalleryimport('phocagallery.file.file'); | ||||
| phocagalleryimport('phocagallery.image.image'); | ||||
| phocagalleryimport('phocagallery.utils.utils'); | ||||
|  | ||||
| /* | ||||
|  * Obsolete | ||||
|  */ | ||||
|  | ||||
| class PhocaGalleryImageBgImage | ||||
| { | ||||
| 	public static function createBgImage($data, &$errorMsg) { | ||||
|  | ||||
| 		$params 		= ComponentHelper::getParams('com_phocagallery') ; | ||||
| 		$jfile_thumbs	= $params->get( 'jfile_thumbs', 1 ); | ||||
| 		$jpeg_quality	= $params->get( 'jpeg_quality', 85 ); | ||||
| 		$jpeg_quality	= PhocaGalleryImage::getJpegQuality($jpeg_quality); | ||||
| 		$webp_quality	= $params->get( 'webp_quality', 80 ); | ||||
| 		$webp_quality	= PhocaGalleryImage::getJpegQuality($webp_quality); | ||||
| 		$avif_quality	= $params->get( 'avif_quality', 80 ); | ||||
| 		$avif_quality	= PhocaGalleryImage::getJpegQuality($avif_quality); | ||||
| 		$formatIcon		= 'png'; | ||||
| 		$path			= PhocaGalleryPath::getPath(); | ||||
|  | ||||
| 		$fileIn 	= $fileOut = $path->image_abs_front. $data['image'] .'.'. $formatIcon; | ||||
|  | ||||
| 		if ($fileIn !== '' && File::exists($fileIn)) { | ||||
|  | ||||
| 			/*$memory 			= 8; | ||||
| 			$memoryLimitChanged = 0; | ||||
|  | ||||
| 			$memory = (int)ini_get( 'memory_limit' ); | ||||
| 			if ($memory == 0) { | ||||
| 				$memory = 8; | ||||
| 			} | ||||
|  | ||||
| 			// Try to increase memory | ||||
| 			if ($memory < 50) { | ||||
| 				ini_set('memory_limit', '50M'); | ||||
| 				$memoryLimitChanged = 1; | ||||
| 			}*/ | ||||
|  | ||||
| 			$imageWidth 			= $data['iw']; | ||||
| 			$imageHeight			= $data['ih']; | ||||
| 			$completeImageWidth 	= $imageWidth + 18; | ||||
| 			$completeImageHeight	= $imageHeight + 18; | ||||
|  | ||||
| 			$completeImageBackground	= $data['sbgc']; | ||||
| 			$retangleColor				= $data['ibgc']; | ||||
| 			$borderColor				= $data['ibrdc']; | ||||
| 			$shadowColor				= $data['iec']; | ||||
| 			$effect						= $data['ie'];// shadow or glow | ||||
|  | ||||
| 			$imgX	= 6; $imgWX = $imageWidth + 5 + $imgX;// Image Width + space (padding) + Start Position | ||||
| 			$imgY	= 6; $imgHY = $imageHeight + 5 + $imgY; | ||||
| 			$brdX 	= $imgX - 1; $brdWX = $imgWX + 1; | ||||
| 			$brdY	= $imgY - 1; $brdHY = $imgHY + 1; | ||||
|  | ||||
| 			// Crate an image | ||||
| 			$img 	= @imagecreatetruecolor($completeImageWidth, $completeImageHeight); | ||||
| 			if (!$img) { | ||||
| 				$errorMsg = 'ErrorNoImageCreateTruecolor'; | ||||
| 				return false; | ||||
| 			} | ||||
|  | ||||
| 			if ($completeImageBackground == '') { | ||||
| 				switch($formatIcon) { | ||||
| 					case 'jpg': | ||||
| 					case 'jpeg': | ||||
| 					case 'gif': | ||||
| 						$completeImageBackground = '#ffffff'; | ||||
| 					break; | ||||
| 					case 'png': | ||||
| 					case 'webp': | ||||
| 					case 'avif': | ||||
| 						@imagealphablending($img,false); | ||||
| 						imagefilledrectangle($img,0,0,$completeImageWidth,$completeImageHeight,imagecolorallocatealpha($img,255,255,255,127)); | ||||
| 						@imagealphablending($img,true); | ||||
| 					break; | ||||
| 				} | ||||
| 			} else { | ||||
| 				$bGClr	= PhocaGalleryUtils::htmlToRgb($completeImageBackground); | ||||
| 				imagefilledrectangle($img, 0, 0, $completeImageWidth, $completeImageHeight, imagecolorallocate($img, $bGClr[0], $bGClr[1], $bGClr[2])); | ||||
| 			} | ||||
|  | ||||
| 			// Create Retangle | ||||
| 			if ($retangleColor != '') { | ||||
| 				$rtgClr		= PhocaGalleryUtils::htmlToRgb($retangleColor); | ||||
| 				$retangle 	= imagecolorallocate($img, $rtgClr[0], $rtgClr[1], $rtgClr[2]); | ||||
| 			} | ||||
| 			// Create Border | ||||
| 			if ($borderColor != '') { | ||||
| 				$brdClr		= PhocaGalleryUtils::htmlToRgb($borderColor); | ||||
| 				$border 	= imagecolorallocate($img, $brdClr[0], $brdClr[1], $brdClr[2]); | ||||
| 			} | ||||
|  | ||||
| 			// Effect (shadow,glow) | ||||
| 			if ((int)$effect > 0) | ||||
| 			if ($shadowColor != '') { | ||||
| 				$shdClr	= PhocaGalleryUtils::htmlToRgb($shadowColor); | ||||
|  | ||||
| 				if ((int)$effect == 3) { | ||||
| 					$shdX = $brdX  - 1; | ||||
| 					$shdY = $brdY  - 1; | ||||
| 					$effectArray = array(55,70,85,100,115); | ||||
| 				} else if ((int)$effect == 2) { | ||||
| 					$shdX = $brdX  + 3; | ||||
| 					$shdY = $brdY  + 3; | ||||
| 					$effectArray = array(50, 70, 90, 110); | ||||
| 				} else { | ||||
| 					$shdX = $brdX  + 3; | ||||
| 					$shdY = $brdY  + 3; | ||||
| 					$effectArray = array(0,0,0,0); | ||||
| 				} | ||||
| 				$shdWX 	= $brdWX + 1; | ||||
| 				$shdHY	= $brdHY + 1; | ||||
|  | ||||
|  | ||||
| 				foreach($effectArray as $key => $value) { | ||||
| 					$effectImg = @imagecolorallocatealpha($img, $shdClr[0], $shdClr[1], $shdClr[2],$value); | ||||
| 					if (!$effectImg) { | ||||
| 						$errorMsg = 'ErrorNoImageColorAllocateAlpha'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					imagerectangle($img, $shdX, $shdY, $shdWX, $shdHY, $effectImg); | ||||
|  | ||||
| 					if ((int)$effect == 3) { | ||||
| 						$shdX--; | ||||
| 						$shdY--; | ||||
|  | ||||
| 					} else if ((int)$effect == 2) { | ||||
| 						$shdX++; | ||||
| 						$shdY++; | ||||
|  | ||||
| 					} else { | ||||
| 						//$shdX++; | ||||
| 						//$shdY++; | ||||
| 					} | ||||
|  | ||||
| 					$shdWX++; | ||||
| 					$shdHY++; | ||||
|  | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			// Write Rectangle over the shadow | ||||
| 			if ($retangleColor != '') { | ||||
| 				imagefilledrectangle($img, $imgX, $imgY, $imgWX, $imgHY, $retangle); | ||||
| 			} | ||||
| 			if ($borderColor != '') { | ||||
| 				imagerectangle($img, $brdX, $brdY, $brdWX, $brdHY, $border); | ||||
| 			} | ||||
|  | ||||
|  | ||||
| 			switch($formatIcon) { | ||||
| 				case 'jpg': | ||||
| 				case 'jpeg': | ||||
| 					if (!function_exists('ImageJPEG')) { | ||||
| 						$errorMsg = 'ErrorNoJPGFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
|  | ||||
| 					if ($jfile_thumbs == 1) { | ||||
| 						ob_start(); | ||||
| 						if (!@ImageJPEG($img, NULL, $jpeg_quality)) { | ||||
| 							ob_end_clean(); | ||||
| 							$errorMsg = 'ErrorWriteFile'; | ||||
| 							return false; | ||||
| 						} | ||||
| 						$imgJPEGToWrite = ob_get_contents(); | ||||
| 						ob_end_clean(); | ||||
|  | ||||
| 						if(!File::write( $fileOut, $imgJPEGToWrite)) { | ||||
| 							$errorMsg = 'ErrorWriteFile'; | ||||
| 							return false; | ||||
| 						} | ||||
| 					} else { | ||||
| 						if (!@ImageJPEG($img, $fileOut, $jpeg_quality)) { | ||||
| 							$errorMsg = 'ErrorWriteFile'; | ||||
| 							return false; | ||||
| 						} | ||||
| 					} | ||||
| 				break; | ||||
|  | ||||
| 				case 'png' : | ||||
| 					if (!function_exists('ImagePNG')) { | ||||
| 						$errorMsg = 'ErrorNoPNGFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					@imagesavealpha($img, true); | ||||
| 					if ($jfile_thumbs == 1) { | ||||
| 						ob_start(); | ||||
| 						if (!@ImagePNG($img, NULL)) { | ||||
| 							ob_end_clean(); | ||||
| 							$errorMsg = 'ErrorWriteFile'; | ||||
| 							return false; | ||||
| 						} | ||||
| 						$imgPNGToWrite = ob_get_contents(); | ||||
| 						ob_end_clean(); | ||||
|  | ||||
| 						if(!File::write( $fileOut, $imgPNGToWrite)) { | ||||
| 							$errorMsg = 'ErrorWriteFile'; | ||||
| 							return false; | ||||
| 						} | ||||
| 					} else { | ||||
| 						if (!@ImagePNG($img, $fileOut)) { | ||||
| 							$errorMsg = 'ErrorWriteFile'; | ||||
| 							return false; | ||||
| 						} | ||||
| 					} | ||||
| 				break; | ||||
|  | ||||
| 				case 'gif' : | ||||
| 					if (!function_exists('ImageGIF')) { | ||||
| 						$errorMsg = 'ErrorNoGIFFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
|  | ||||
| 					if ($jfile_thumbs == 1) { | ||||
| 						ob_start(); | ||||
| 						if (!@ImageGIF($img, NULL)) { | ||||
| 							ob_end_clean(); | ||||
| 							$errorMsg = 'ErrorWriteFile'; | ||||
| 							return false; | ||||
| 						} | ||||
| 						$imgGIFToWrite = ob_get_contents(); | ||||
| 						ob_end_clean(); | ||||
|  | ||||
| 						if(!File::write( $fileOut, $imgGIFToWrite)) { | ||||
| 							$errorMsg = 'ErrorWriteFile'; | ||||
| 							return false; | ||||
| 						} | ||||
| 					} else { | ||||
| 						if (!@ImageGIF($img, $fileOut)) { | ||||
| 							$errorMsg = 'ErrorWriteFile'; | ||||
| 							return false; | ||||
| 						} | ||||
| 					} | ||||
| 				break; | ||||
|  | ||||
| 				case 'webp' : | ||||
| 					if (!function_exists('ImageWebp')) { | ||||
| 						$errorMsg = 'ErrorNoWEBPFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					@imagesavealpha($img, true); | ||||
| 					if ($jfile_thumbs == 1) { | ||||
| 						ob_start(); | ||||
| 						if (!@imagewebp($img, NULL, $webp_quality)) { | ||||
| 							ob_end_clean(); | ||||
| 							$errorMsg = 'ErrorWriteFile'; | ||||
| 							return false; | ||||
| 						} | ||||
| 						$imgWEBPToWrite = ob_get_contents(); | ||||
| 						ob_end_clean(); | ||||
|  | ||||
| 						if(!File::write( $fileOut, $imgWEBPToWrite)) { | ||||
| 							$errorMsg = 'ErrorWriteFile'; | ||||
| 							return false; | ||||
| 						} | ||||
| 					} else { | ||||
| 						if (!@imagewebp($img, $fileOut, $webp_quality)) { | ||||
| 							$errorMsg = 'ErrorWriteFile'; | ||||
| 							return false; | ||||
| 						} | ||||
| 					} | ||||
| 				break; | ||||
|  | ||||
| 				case 'avif' : | ||||
| 				if (!function_exists('ImageAvif')) { | ||||
| 					$errorMsg = 'ErrorNoAVIFFunction'; | ||||
| 					return false; | ||||
| 				} | ||||
| 				@imagesavealpha($img, true); | ||||
| 				if ($jfile_thumbs == 1) { | ||||
| 					ob_start(); | ||||
| 					if (!@imageavif($img, NULL, $avif_quality)) { | ||||
| 						ob_end_clean(); | ||||
| 						$errorMsg = 'ErrorWriteFile'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					$imgAVIFToWrite = ob_get_contents(); | ||||
| 					ob_end_clean(); | ||||
|  | ||||
| 					if(!File::write( $fileOut, $imgAVIFToWrite)) { | ||||
| 						$errorMsg = 'ErrorWriteFile'; | ||||
| 						return false; | ||||
| 					} | ||||
| 				} else { | ||||
| 					if (!@imageavif($img, $fileOut, $webp_quality)) { | ||||
| 						$errorMsg = 'ErrorWriteFile'; | ||||
| 						return false; | ||||
| 					} | ||||
| 				} | ||||
| 			break; | ||||
|  | ||||
| 				Default: | ||||
| 					$errorMsg =  'ErrorNotSupportedImage'; | ||||
| 					return false; | ||||
| 				break; | ||||
| 			} | ||||
|  | ||||
| 			// free memory | ||||
| 			ImageDestroy($img);// Original | ||||
|  | ||||
| 			/*if ($memoryLimitChanged == 1) { | ||||
| 				$memoryString = $memory . 'M'; | ||||
| 				ini_set('memory_limit', $memoryString); | ||||
| 			}*/ | ||||
|  | ||||
| 			return true; // Success | ||||
| 		} | ||||
|  | ||||
| 		$errorMsg = 'Error2'; | ||||
| 		return false; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -0,0 +1,734 @@ | ||||
| <?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\Filesystem\File; | ||||
| jimport( 'joomla.filesystem.folder' ); | ||||
| jimport( 'joomla.filesystem.file' ); | ||||
| phocagalleryimport('phocagallery.render.renderprocess'); | ||||
| phocagalleryimport('phocagallery.file.file'); | ||||
| phocagalleryimport('phocagallery.image.image'); | ||||
|  | ||||
| register_shutdown_function(function(){ | ||||
| 	$error = error_get_last(); | ||||
|  | ||||
| 	if(null !== $error) { | ||||
| 		if (isset($error['type']) && $error['type'] == 1) { | ||||
| 			$app		= Factory::getApplication(); | ||||
| 			$app->redirect('index.php?option=com_phocagallery&view=phocagalleryfe&error=1'); | ||||
| 			return; | ||||
| 		} | ||||
| 	} | ||||
| }); | ||||
|  | ||||
| class PhocaGalleryImageMagic | ||||
| { | ||||
| 	/** | ||||
| 	* need GD library (first PHP line WIN: dl("php_gd.dll"); UNIX: dl("gd.so"); | ||||
| 	* www.boutell.com/gd/ | ||||
| 	* interval.cz/clanky/php-skript-pro-generovani-galerie-obrazku-2/ | ||||
| 	* cz.php.net/imagecopyresampled | ||||
| 	* www.linuxsoft.cz/sw_detail.php?id_item=871 | ||||
| 	* www.webtip.cz/art/wt_tech_php/liquid_ir.html | ||||
| 	* php.vrana.cz/zmensovani-obrazku.php | ||||
| 	* diskuse.jakpsatweb.cz/ | ||||
| 	* | ||||
| 	* @param string $fileIn Vstupni soubor (mel by existovat) | ||||
| 	* @param string $fileOut Vystupni soubor, null ho jenom zobrazi (taky kdyz nema pravo se zapsat :) | ||||
| 	* @param int $width Vysledna sirka (maximalni) | ||||
| 	* @param int $height Vysledna vyska (maximalni) | ||||
| 	* @param bool $crop Orez (true, obrazek bude presne tak velky), jinak jenom Resample (udane maximalni rozmery) | ||||
| 	* @param int $typeOut IMAGETYPE_type vystupniho obrazku | ||||
| 	* @return bool Chyba kdyz vrati false | ||||
| 	*/ | ||||
| 	public static function imageMagic($fileIn, $fileOut = null, $width = null, $height = null, $crop = null, $typeOut = null, $watermarkParams = array(), $frontUpload = 0, &$errorMsg = '') { | ||||
|  | ||||
| 		$params 		= ComponentHelper::getParams('com_phocagallery') ; | ||||
| 		$jfile_thumbs	=	$params->get( 'jfile_thumbs', 1 ); | ||||
| 		$jpeg_quality	= $params->get( 'jpeg_quality', 85 ); | ||||
| 		$exif_rotate	= $params->get( 'exif_rotate', 0 ); | ||||
| 		$jpeg_quality	= PhocaGalleryImage::getJpegQuality($jpeg_quality); | ||||
| 		$webp_quality	= $params->get( 'webp_quality', 80 ); | ||||
| 		$webp_quality	= PhocaGalleryImage::getJpegQuality($webp_quality); | ||||
| 		$avif_quality	= $params->get( 'avif_quality', 80 ); | ||||
| 		$avif_quality	= PhocaGalleryImage::getJpegQuality($avif_quality); | ||||
|  | ||||
| 		$fileWatermark = ''; | ||||
|  | ||||
| 		// While front upload we don't display the process page | ||||
| 		if ($frontUpload == 0) { | ||||
|  | ||||
| 			$stopText = PhocaGalleryRenderProcess::displayStopThumbnailsCreating('processpage'); | ||||
| 			echo $stopText; | ||||
| 		} | ||||
| 		// Memory - - - - - - - - | ||||
| 		/*$memory = 8; | ||||
| 		$memoryLimitChanged = 0; | ||||
| 		$memory = (int)ini_get( 'memory_limit' ); | ||||
| 		if ($memory == 0) { | ||||
| 			$memory = 8; | ||||
| 		}*/ | ||||
| 		// - - - - - - - - - - - | ||||
|  | ||||
| 		if ($fileIn !== '' && File::exists($fileIn)) { | ||||
|  | ||||
| 			// array of width, height, IMAGETYPE, "height=x width=x" (string) | ||||
| 	        list($w, $h, $type) = GetImageSize($fileIn); | ||||
|  | ||||
|  | ||||
| 			// Read EXIF data from image file to get the Orientation flag | ||||
| 			$exif = null; | ||||
| 			if ($exif_rotate == 1) { | ||||
| 				if (function_exists('exif_read_data') && $type == IMAGETYPE_JPEG ) { | ||||
| 					$exif = @exif_read_data($fileIn); | ||||
| 				} | ||||
| 				// GetImageSize returns an array of width, height, IMAGETYPE, "height=x width=x" (string) | ||||
| 				// The EXIF Orientation flag is examined to determine if width and height need to be swapped, i.e. if the image will be rotated in a subsequent step | ||||
| 				if(isset($exif['Orientation']) && !empty($exif['Orientation'])) { | ||||
|  | ||||
| 					switch($exif['Orientation']) { | ||||
| 					   case 8: // will need to be rotated 90 degrees left, so swap order of width and height | ||||
| 						  list($h, $w, $type) = GetImageSize($fileIn); | ||||
| 						  break; | ||||
| 					   case 3: // will need to be rotated 180 degrees so don't swap order of width and height | ||||
| 						  list($w, $h, $type) = GetImageSize($fileIn); | ||||
| 						  break; | ||||
| 					   case 6:   // will need to be rotated 90 degrees right, so swap order of width and height | ||||
| 						  list($h, $w, $type) = GetImageSize($fileIn); | ||||
| 						  break; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			if ($w > 0 && $h > 0) {// we got the info from GetImageSize | ||||
|  | ||||
| 		        // size of the image | ||||
| 		        if ($width == null || $width == 0) { // no width added | ||||
| 		            $width = $w; | ||||
| 		        } | ||||
| 				else if ($height == null || $height == 0) { // no height, adding the same as width | ||||
| 		            $height = $width; | ||||
| 		        } | ||||
| 				if ($height == null || $height == 0) { // no height, no width | ||||
| 		            $height = $h; | ||||
| 		        } | ||||
|  | ||||
| 		        // miniaturizing | ||||
| 		        if (!$crop) { // new size - nw, nh (new width/height) | ||||
|  | ||||
| 					$scale = (($width / $w) < ($height / $h)) ? ($width / $w) : ($height / $h); // smaller rate | ||||
| 					//$scale = $height / $h; | ||||
|  | ||||
| 		            $src = array(0,0, $w, $h); | ||||
| 		            $dst = array(0,0, floor($w*$scale), floor($h*$scale)); | ||||
| 		        } | ||||
| 		        else { // will be cropped | ||||
| 		            $scale = (($width / $w) > ($height / $h)) ? ($width / $w) : ($height / $h); // greater rate | ||||
| 		            $newW = $width/$scale;    // check the size of in file | ||||
| 		            $newH = $height/$scale; | ||||
|  | ||||
| 		            // which side is larger (rounding error) | ||||
| 		            if (($w - $newW) > ($h - $newH)) { | ||||
| 		                $src = array(floor(($w - $newW)/2), 0, floor($newW), $h); | ||||
| 		            } | ||||
| 		            else { | ||||
| 		                $src = array(0, floor(($h - $newH)/2), $w, floor($newH)); | ||||
| 		            } | ||||
|  | ||||
| 		            $dst = array(0,0, floor($width), floor($height)); | ||||
| 		        } | ||||
|  | ||||
| 				// Watermark - - - - - - - - - - - | ||||
| 				if (!empty($watermarkParams) && ($watermarkParams['create'] == 1 || $watermarkParams['create'] == 2)) { | ||||
|  | ||||
| 					$thumbnailSmall		= false; | ||||
| 					$thumbnailMedium	= false; | ||||
| 					$thumbnailLarge		= false; | ||||
|  | ||||
| 					$thumbnailMedium	= preg_match("/phoca_thumb_m_/i", $fileOut); | ||||
| 					$thumbnailLarge 	= preg_match("/phoca_thumb_l_/i", $fileOut); | ||||
|  | ||||
| 					$path				= PhocaGalleryPath::getPath(); | ||||
| 					$fileName 			= PhocaGalleryFile::getTitleFromFile($fileIn, 1); | ||||
|  | ||||
| 					// Which Watermark will be used | ||||
| 					// If watermark is in current directory use it else use Default | ||||
| 					$fileWatermarkMedium		= false; | ||||
| 					$fileWatermarkLarge			= false; | ||||
| 					$fileWatermarkMediumPng  	= str_replace($fileName, 'watermark-medium.png', $fileIn); | ||||
| 					$fileWatermarkLargePng  	= str_replace($fileName, 'watermark-large.png', $fileIn); | ||||
| 					$fileWatermarkMediumWebp  	= str_replace($fileName, 'watermark-medium.webp', $fileIn); | ||||
| 					$fileWatermarkLargeWebp  	= str_replace($fileName, 'watermark-large.webp', $fileIn); | ||||
| 					$fileWatermarkMediumAvif  	= str_replace($fileName, 'watermark-medium.avif', $fileIn); | ||||
| 					$fileWatermarkLargeAvif  	= str_replace($fileName, 'watermark-large.avif', $fileIn); | ||||
|  | ||||
| 					$fileWatermarkMediumRoot		= false; | ||||
| 					$fileWatermarkLargeRoot			= false; | ||||
| 					$fileWatermarkMediumPngRoot  	= $path->image_abs . 'watermark-medium.png'; | ||||
| 					$fileWatermarkLargePngRoot  	= $path->image_abs . 'watermark-large.png'; | ||||
| 					$fileWatermarkMediumWebpRoot  	= $path->image_abs . 'watermark-medium.webp'; | ||||
| 					$fileWatermarkLargeWebpRoot  	= $path->image_abs . 'watermark-large.webp'; | ||||
| 					$fileWatermarkMediumAvifRoot  	= $path->image_abs . 'watermark-medium.avif'; | ||||
| 					$fileWatermarkLargeAvifRoot  	= $path->image_abs . 'watermark-large.avif'; | ||||
|  | ||||
| 					if ($type == IMAGETYPE_WEBP) { | ||||
| 						if (File::exists($fileWatermarkMediumWebp)) { | ||||
| 							$fileWatermarkMedium = $fileWatermarkMediumWebp; | ||||
| 						} else if (File::exists($fileWatermarkMediumPng)) { | ||||
| 							$fileWatermarkMedium = $fileWatermarkMediumPng; | ||||
| 						} else if (File::exists($fileWatermarkMediumAvif)) { | ||||
| 							$fileWatermarkMedium = $fileWatermarkMediumAvif; | ||||
| 						} | ||||
|  | ||||
| 						if (File::exists($fileWatermarkMediumWebpRoot)) { | ||||
| 							$fileWatermarkMediumRoot = $fileWatermarkMediumWebpRoot; | ||||
| 						} else if (File::exists($fileWatermarkMediumPngRoot)) { | ||||
| 							$fileWatermarkMediumRoot = $fileWatermarkMediumPngRoot; | ||||
| 						} else if (File::exists($fileWatermarkMediumAvifRoot)) { | ||||
| 							$fileWatermarkMediumRoot = $fileWatermarkMediumAvifRoot; | ||||
| 						} | ||||
|  | ||||
| 						if (File::exists($fileWatermarkLargeWebp)) { | ||||
| 							$fileWatermarkLarge = $fileWatermarkLargeWebp; | ||||
| 						} else if (File::exists($fileWatermarkLargePng)) { | ||||
| 							$fileWatermarkLarge = $fileWatermarkLargePng; | ||||
| 						} else if (File::exists($fileWatermarkLargeAvif)) { | ||||
| 							$fileWatermarkLarge = $fileWatermarkLargeAvif; | ||||
| 						} | ||||
|  | ||||
| 						if (File::exists($fileWatermarkLargeWebpRoot)) { | ||||
| 							$fileWatermarkLargeRoot = $fileWatermarkLargeWebpRoot; | ||||
| 						} else if (File::exists($fileWatermarkLargePngRoot)) { | ||||
| 							$fileWatermarkLargeRoot = $fileWatermarkLargePngRoot; | ||||
| 						} else if (File::exists($fileWatermarkLargeAvifRoot)) { | ||||
| 							$fileWatermarkLargeRoot = $fileWatermarkLargeAvifRoot; | ||||
| 						} | ||||
|  | ||||
| 					} else if ($type ==  IMAGETYPE_AVIF){ | ||||
| 						if (File::exists($fileWatermarkMediumAvif)) { | ||||
| 							$fileWatermarkMedium = $fileWatermarkMediumAvif; | ||||
| 						} else if (File::exists($fileWatermarkMediumPng)) { | ||||
| 							$fileWatermarkMedium = $fileWatermarkMediumPng; | ||||
| 						} else if (File::exists($fileWatermarkMediumWebp)) { | ||||
| 							$fileWatermarkMedium = $fileWatermarkMediumWebp; | ||||
| 						} | ||||
|  | ||||
| 						if (File::exists($fileWatermarkMediumAvifRoot)) { | ||||
| 							$fileWatermarkMediumRoot = $fileWatermarkMediumAvifRoot; | ||||
| 						} else if (File::exists($fileWatermarkMediumPngRoot)) { | ||||
| 							$fileWatermarkMediumRoot = $fileWatermarkMediumPngRoot; | ||||
| 						} else if (File::exists($fileWatermarkMediumWebpRoot)) { | ||||
| 							$fileWatermarkMediumRoot = $fileWatermarkMediumWebpRoot; | ||||
| 						} | ||||
|  | ||||
| 						if (File::exists($fileWatermarkLargeAvif)) { | ||||
| 							$fileWatermarkLarge = $fileWatermarkLargeAvif; | ||||
| 						} else if (File::exists($fileWatermarkLargePng)) { | ||||
| 							$fileWatermarkLarge = $fileWatermarkLargePng; | ||||
| 						} else if (File::exists($fileWatermarkLargeWebp)) { | ||||
| 							$fileWatermarkLarge = $fileWatermarkLargeWebp; | ||||
| 						} | ||||
|  | ||||
| 						if (File::exists($fileWatermarkLargeAvifRoot)) { | ||||
| 							$fileWatermarkLargeRoot = $fileWatermarkLargeAvifRoot; | ||||
| 						} else if (File::exists($fileWatermarkLargePngRoot)) { | ||||
| 							$fileWatermarkLargeRoot = $fileWatermarkLargePngRoot; | ||||
| 						} else if (File::exists($fileWatermarkLargeWebpRoot)) { | ||||
| 							$fileWatermarkLargeRoot = $fileWatermarkLargeWebpRoot; | ||||
| 						} | ||||
|  | ||||
| 					} else { | ||||
| 						if (File::exists($fileWatermarkMediumPng)) { | ||||
| 							$fileWatermarkMedium = $fileWatermarkMediumPng; | ||||
| 						} else if (File::exists($fileWatermarkMediumWebp)) { | ||||
| 							$fileWatermarkMedium = $fileWatermarkMediumWebp; | ||||
| 						} else if (File::exists($fileWatermarkMediumAvif)) { | ||||
| 							$fileWatermarkMedium = $fileWatermarkMediumAvif; | ||||
| 						} | ||||
|  | ||||
| 						if (File::exists($fileWatermarkMediumPngRoot)) { | ||||
| 							$fileWatermarkMediumRoot = $fileWatermarkMediumPngRoot; | ||||
| 						} else if (File::exists($fileWatermarkMediumWebpRoot)) { | ||||
| 							$fileWatermarkMediumRoot = $fileWatermarkMediumWebpRoot; | ||||
| 						} else if (File::exists($fileWatermarkMediumAvifRoot)) { | ||||
| 							$fileWatermarkMediumRoot = $fileWatermarkMediumAvifRoot; | ||||
| 						} | ||||
|  | ||||
| 						if (File::exists($fileWatermarkLargePng)) { | ||||
| 							$fileWatermarkLarge = $fileWatermarkLargePng; | ||||
| 						} else if (File::exists($fileWatermarkLargeWebp)) { | ||||
| 							$fileWatermarkLarge = $fileWatermarkLargeWebp; | ||||
| 						} else if (File::exists($fileWatermarkLargeAvif)) { | ||||
| 							$fileWatermarkLarge = $fileWatermarkLargeAvif; | ||||
| 						} | ||||
|  | ||||
| 						if (File::exists($fileWatermarkLargePngRoot)) { | ||||
| 							$fileWatermarkLargeRoot = $fileWatermarkLargePngRoot; | ||||
| 						} else if (File::exists($fileWatermarkLargeWebpRoot)) { | ||||
| 							$fileWatermarkLargeRoot = $fileWatermarkLargeWebpRoot; | ||||
| 						} else if (File::exists($fileWatermarkLargeAvifRoot)) { | ||||
| 							$fileWatermarkLargeRoot = $fileWatermarkLargeAvifRoot; | ||||
| 						} | ||||
| 					} | ||||
|  | ||||
|  | ||||
| 					clearstatcache(); | ||||
| 					 | ||||
| 					// Which Watermark will be used | ||||
| 					if ($thumbnailMedium) { | ||||
| 						if ($watermarkParams['create'] == 1 && $fileWatermarkMedium) { | ||||
| 							$fileWatermark  = $fileWatermarkMedium; | ||||
| 						} else if ($watermarkParams['create'] == 2 && $fileWatermarkMediumRoot) { | ||||
| 							$fileWatermark = $fileWatermarkMediumRoot; | ||||
| 						} else if ($fileWatermarkMedium) { | ||||
| 							$fileWatermark = $fileWatermarkMedium; | ||||
| 						} else if ($fileWatermarkMediumRoot) { | ||||
| 							$fileWatermark = $fileWatermarkMediumRoot; | ||||
| 						} else { | ||||
| 							$fileWatermark	= ''; | ||||
| 						} | ||||
| 					} else if ($thumbnailLarge) { | ||||
| 						if ($watermarkParams['create'] == 1 && $fileWatermarkLarge) { | ||||
| 							$fileWatermark  = $fileWatermarkLarge; | ||||
| 						} else if ($watermarkParams['create'] == 2 && $fileWatermarkLargeRoot) { | ||||
| 							$fileWatermark = $fileWatermarkLargeRoot; | ||||
| 						} else if ($fileWatermarkLarge) { | ||||
| 							$fileWatermark = $fileWatermarkLarge; | ||||
| 						} else if ($fileWatermarkLargeRoot) { | ||||
| 							$fileWatermark = $fileWatermarkLargeRoot; | ||||
| 						} else { | ||||
| 							$fileWatermark	= ''; | ||||
| 						} | ||||
| 					} else { | ||||
| 						$fileWatermark  = ''; | ||||
| 					} | ||||
|  | ||||
|  | ||||
| 					if (!File::exists($fileWatermark)) { | ||||
| 						$fileWatermark = ''; | ||||
| 					} | ||||
|  | ||||
| 					if ($fileWatermark != '') { | ||||
| 						list($wW, $hW, $typeW)	= GetImageSize($fileWatermark); | ||||
|  | ||||
|  | ||||
| 						switch ($watermarkParams['x']) { | ||||
| 							case 'left': | ||||
| 								$locationX	= 0; | ||||
| 							break; | ||||
|  | ||||
| 							case 'right': | ||||
| 								$locationX	= $dst[2] - $wW; | ||||
| 							break; | ||||
|  | ||||
| 							case 'center': | ||||
| 							Default: | ||||
| 								$locationX	= ($dst[2] / 2) - ($wW / 2); | ||||
| 							break; | ||||
| 						} | ||||
|  | ||||
| 						switch ($watermarkParams['y']) { | ||||
| 							case 'top': | ||||
| 								$locationY	= 0; | ||||
| 							break; | ||||
|  | ||||
| 							case 'bottom': | ||||
| 								$locationY	= $dst[3] - $hW; | ||||
| 							break; | ||||
|  | ||||
| 							case 'middle': | ||||
| 							Default: | ||||
| 								$locationY	= ($dst[3] / 2) - ($hW / 2); | ||||
| 							break; | ||||
| 						} | ||||
| 					} | ||||
| 				} else { | ||||
| 					$fileWatermark = ''; | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
|  | ||||
|  | ||||
| 			/*if ($memory < 50) { | ||||
| 				ini_set('memory_limit', '50M'); | ||||
| 				$memoryLimitChanged = 1; | ||||
| 			}*/ | ||||
| 			// Resampling | ||||
| 			// in file | ||||
|  | ||||
| 			// Watemark | ||||
| 			if ($fileWatermark != '') { | ||||
|  | ||||
| 				$ext = File::getExt($fileWatermark); | ||||
|  | ||||
| 				if ($ext == 'webp') { | ||||
| 					if (!function_exists('ImageCreateFromWEBP')) { | ||||
| 						$errorMsg = 'ErrorNoWEBPFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					$waterImage1=ImageCreateFromWEBP($fileWatermark); | ||||
| 					//imagealphablending($waterImage1, false); | ||||
| 					//imagesavealpha($waterImage1, true); | ||||
| 				} else if ($ext == 'avif') { | ||||
| 					if (!function_exists('ImageCreateFromAVIF')) { | ||||
| 						$errorMsg = 'ErrorNoAVIFFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					$waterImage1=ImageCreateFromAVIF($fileWatermark); | ||||
| 					//imagealphablending($waterImage1, false); | ||||
| 					//imagesavealpha($waterImage1, true); | ||||
| 				} else { | ||||
| 					if (!function_exists('ImageCreateFromPNG')) { | ||||
| 						$errorMsg = 'ErrorNoPNGFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					$waterImage1=ImageCreateFromPNG($fileWatermark); | ||||
| 					//imagealphablending($waterImage1, false); | ||||
| 					//imagesavealpha($waterImage1, true); | ||||
| 				} | ||||
|  | ||||
| 			} | ||||
|  | ||||
| 			// End Watermark - - - - - - - - - - - - - - - - - - | ||||
|  | ||||
| 	        switch($type) { | ||||
| 	            case IMAGETYPE_JPEG: | ||||
| 					if (!function_exists('ImageCreateFromJPEG')) { | ||||
| 						$errorMsg = 'ErrorNoJPGFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					//$image1 = ImageCreateFromJPEG($fileIn); | ||||
| 					try { | ||||
| 						$image1 = ImageCreateFromJPEG($fileIn); | ||||
| 					} catch(\Exception $exception) { | ||||
| 						$errorMsg = 'ErrorJPGFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
|  | ||||
| 				break; | ||||
| 	            case IMAGETYPE_PNG : | ||||
| 					if (!function_exists('ImageCreateFromPNG')) { | ||||
| 						$errorMsg = 'ErrorNoPNGFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					//$image1 = ImageCreateFromPNG($fileIn); | ||||
| 					try { | ||||
| 						$image1 = ImageCreateFromPNG($fileIn); | ||||
| 					} catch(\Exception $exception) { | ||||
| 						$errorMsg = 'ErrorPNGFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 				break; | ||||
| 	            case IMAGETYPE_GIF : | ||||
| 					if (!function_exists('ImageCreateFromGIF')) { | ||||
| 						$errorMsg = 'ErrorNoGIFFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					//$image1 = ImageCreateFromGIF($fileIn); | ||||
| 					try { | ||||
| 						$image1 = ImageCreateFromGIF($fileIn); | ||||
| 					} catch(\Exception $exception) { | ||||
| 						$errorMsg = 'ErrorGIFFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 				break; | ||||
| 				 case IMAGETYPE_WEBP: | ||||
| 					if (!function_exists('ImageCreateFromWEBP')) { | ||||
| 						$errorMsg = 'ErrorNoWEBPFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					//$image1 = ImageCreateFromGIF($fileIn); | ||||
| 					try { | ||||
| 						$image1 = ImageCreateFromWEBP($fileIn); | ||||
| 					} catch(\Exception $exception) { | ||||
| 						$errorMsg = 'ErrorWEBPFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 				break; | ||||
| 					case IMAGETYPE_AVIF: | ||||
| 					if (!function_exists('imagecreatefromavif')) { | ||||
| 						$errorMsg = 'ErrorNoAVIFFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					//$image1 = ImageCreateFromGIF($fileIn); | ||||
| 					try { | ||||
| 						$image1 = imagecreatefromavif($fileIn); | ||||
| 					} catch(\Exception $exception) { | ||||
| 						$errorMsg = 'ErrorAVIFFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 				break; | ||||
| 	            case IMAGETYPE_WBMP: | ||||
| 					if (!function_exists('ImageCreateFromWBMP')) { | ||||
| 						$errorMsg = 'ErrorNoWBMPFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					//$image1 = ImageCreateFromWBMP($fileIn); | ||||
| 					try { | ||||
| 						$image1 = ImageCreateFromWBMP($fileIn); | ||||
| 					} catch(\Exception $exception) { | ||||
| 						$errorMsg = 'ErrorWBMPFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					break; | ||||
| 	            Default: | ||||
| 					$errorMsg = 'ErrorNotSupportedImage'; | ||||
| 					return false; | ||||
| 					break; | ||||
| 	        } | ||||
|  | ||||
| 			if ($image1) { | ||||
|  | ||||
| 				$image2 = @ImageCreateTruecolor($dst[2], $dst[3]); | ||||
| 				if (!$image2) { | ||||
| 					$errorMsg = 'ErrorNoImageCreateTruecolor'; | ||||
| 					return false; | ||||
| 				} | ||||
|  | ||||
| 				switch($type) { | ||||
| 					case IMAGETYPE_PNG: | ||||
| 					case IMAGETYPE_WEBP: | ||||
| 					case IMAGETYPE_AVIF: | ||||
| 						//imagealphablending($image1, false); | ||||
| 						@imagealphablending($image2, false); | ||||
| 						//imagesavealpha($image1, true); | ||||
| 						@imagesavealpha($image2, true); | ||||
| 					break; | ||||
| 				} | ||||
|  | ||||
| 				if ($exif_rotate == 1) { | ||||
| 					// Examine the EXIF Orientation flag (read earlier) to determine if the image needs to be rotated prior to the ImageCopyResampled call | ||||
| 					// Use the imagerotate() function to perform the rotation, if required | ||||
| 					if(isset($exif['Orientation']) && !empty($exif['Orientation'])) { | ||||
| 						switch($exif['Orientation']) { | ||||
| 						   case 8: | ||||
| 								 $image1 = imagerotate($image1,90,0); | ||||
| 								// @imagealphablending($image1, false); | ||||
| 								// @imagesavealpha($image1, true); | ||||
| 								 break; | ||||
| 						   case 3: | ||||
| 								 $image1 = imagerotate($image1,180,0); | ||||
| 								// @imagealphablending($image1, false); | ||||
| 								// @imagesavealpha($image1, true); | ||||
| 								 break; | ||||
| 						   case 6: | ||||
| 								 $image1 = imagerotate($image1,-90,0); | ||||
| 								// @imagealphablending($image1, false); | ||||
| 								// @imagesavealpha($image1, true); | ||||
| 								 break; | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
|  | ||||
| 				ImageCopyResampled($image2, $image1, $dst[0],$dst[1], $src[0],$src[1], $dst[2],$dst[3], $src[2],$src[3]); | ||||
|  | ||||
| 				// Watermark - - - - - - | ||||
| 				if ($fileWatermark != '') { | ||||
|  | ||||
|  | ||||
| 					//imagecolortransparent($waterImage1, imagecolorallocate($waterImage1, 0, 0, 0)); | ||||
| 					//imagepalettetotruecolor($waterImage1); | ||||
|                 	//imagealphablending($waterImage1, true); | ||||
|                 	//imagesavealpha($waterImage1, true); | ||||
| 					//imagecolortransparent($image2, imagecolorallocate($image2, 0, 0, 0)); | ||||
| 					//imagepalettetotruecolor($image2); | ||||
|                 	imagealphablending($image2, true);// Needed for webp and avif transparency | ||||
|                 	//imagesavealpha($image2, true); | ||||
| 					ImageCopy($image2, $waterImage1, (int)$locationX, (int)$locationY, 0, 0, (int)$wW, (int)$hW); | ||||
| 				} | ||||
| 				// End Watermark - - - - | ||||
|  | ||||
|  | ||||
| 	            // Display the Image - not used | ||||
| 	            if ($fileOut == null) { | ||||
| 	                header("Content-type: ". image_type_to_mime_type($typeOut)); | ||||
| 	            } | ||||
|  | ||||
| 				// Create the file | ||||
| 		        if ($typeOut == null) {    // no bitmap | ||||
| 		            $typeOut = ($type == IMAGETYPE_WBMP) ? IMAGETYPE_PNG : $type; | ||||
| 		        } | ||||
|  | ||||
| 				switch($typeOut) { | ||||
| 		            case IMAGETYPE_JPEG: | ||||
| 						if (!function_exists('ImageJPEG')) { | ||||
| 							$errorMsg = 'ErrorNoJPGFunction'; | ||||
| 							return false; | ||||
| 						} | ||||
|  | ||||
| 						if ($jfile_thumbs == 1) { | ||||
| 							ob_start(); | ||||
| 							if (!@ImageJPEG($image2, NULL, $jpeg_quality)) { | ||||
| 								ob_end_clean(); | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 							$imgJPEGToWrite = ob_get_contents(); | ||||
| 							ob_end_clean(); | ||||
|  | ||||
| 							if(!File::write( $fileOut, $imgJPEGToWrite)) { | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 						} else { | ||||
| 							if (!@ImageJPEG($image2, $fileOut, $jpeg_quality)) { | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 						} | ||||
| 					break; | ||||
|  | ||||
| 					case IMAGETYPE_PNG : | ||||
| 						if (!function_exists('ImagePNG')) { | ||||
| 							$errorMsg = 'ErrorNoPNGFunction'; | ||||
| 							return false; | ||||
| 						} | ||||
|  | ||||
| 						if ($jfile_thumbs == 1) { | ||||
| 							ob_start(); | ||||
| 							if (!@ImagePNG($image2, NULL)) { | ||||
| 								ob_end_clean(); | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 							$imgPNGToWrite = ob_get_contents(); | ||||
| 							ob_end_clean(); | ||||
|  | ||||
| 							if(!File::write( $fileOut, $imgPNGToWrite)) { | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 						} else { | ||||
| 							if (!@ImagePNG($image2, $fileOut)) { | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 						} | ||||
| 					break; | ||||
|  | ||||
| 					case IMAGETYPE_GIF : | ||||
| 						if (!function_exists('ImageGIF')) { | ||||
| 							$errorMsg = 'ErrorNoGIFFunction'; | ||||
| 							return false; | ||||
| 						} | ||||
|  | ||||
| 						if ($jfile_thumbs == 1) { | ||||
| 							ob_start(); | ||||
| 							if (!@ImageGIF($image2, NULL)) { | ||||
| 								ob_end_clean(); | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 							$imgGIFToWrite = ob_get_contents(); | ||||
| 							ob_end_clean(); | ||||
|  | ||||
| 							if(!File::write( $fileOut, $imgGIFToWrite)) { | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 						} else { | ||||
| 							if (!@ImageGIF($image2, $fileOut)) { | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 						} | ||||
| 					break; | ||||
|  | ||||
| 					case IMAGETYPE_WEBP : | ||||
| 						if (!function_exists('ImageWEBP')) { | ||||
| 							$errorMsg = 'ErrorNoWEBPFunction'; | ||||
| 							return false; | ||||
| 						} | ||||
|  | ||||
| 						if ($jfile_thumbs == 1) { | ||||
| 							ob_start(); | ||||
| 							if (!@imagewebp($image2, NULL, $webp_quality)) { | ||||
| 								ob_end_clean(); | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 							$imgWEBPToWrite = ob_get_contents(); | ||||
| 							ob_end_clean(); | ||||
|  | ||||
| 							if(!File::write( $fileOut, $imgWEBPToWrite)) { | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 						} else { | ||||
| 							if (!@imagewebp($image2, $fileOut, $webp_quality)) { | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 						} | ||||
| 					break; | ||||
|  | ||||
| 					case IMAGETYPE_AVIF : | ||||
| 						if (!function_exists('ImageAVIF')) { | ||||
| 							$errorMsg = 'ErrorNoAVIFFunction'; | ||||
| 							return false; | ||||
| 						} | ||||
|  | ||||
| 						if ($jfile_thumbs == 1) { | ||||
| 							ob_start(); | ||||
| 							if (!@imageavif($image2, NULL, $avif_quality)) { | ||||
| 								ob_end_clean(); | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 							$imgAVIFToWrite = ob_get_contents(); | ||||
| 							ob_end_clean(); | ||||
|  | ||||
| 							if(!File::write( $fileOut, $imgAVIFToWrite)) { | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 						} else { | ||||
| 							if (!@imageavif($image2, $fileOut, $avif_quality)) { | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 						} | ||||
| 					break; | ||||
|  | ||||
| 					default: | ||||
| 						$errorMsg = 'ErrorNotSupportedImage'; | ||||
| 						return false; | ||||
| 						break; | ||||
| 				} | ||||
|  | ||||
| 				// free memory | ||||
| 				ImageDestroy($image1); | ||||
| 	            ImageDestroy($image2); | ||||
| 				if (isset($waterImage1)) { | ||||
| 					ImageDestroy($waterImage1); | ||||
| 				} | ||||
|  | ||||
| 				/*if ($memoryLimitChanged == 1) { | ||||
| 					$memoryString = $memory . 'M'; | ||||
| 					ini_set('memory_limit', $memoryString); | ||||
| 				}*/ | ||||
| 	             $errorMsg = ''; // Success | ||||
| 				 return true; | ||||
| 	        } else { | ||||
| 				$errorMsg = 'Error1'; | ||||
| 				return false; | ||||
| 			} | ||||
| 			/*if ($memoryLimitChanged == 1) { | ||||
| 				$memoryString = $memory . 'M'; | ||||
| 				ini_set('memory_limit', $memoryString); | ||||
| 			}*/ | ||||
| 	    } | ||||
| 		$errorMsg = 'Error2'; | ||||
| 		return false; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,519 @@ | ||||
| <?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\Filesystem\File; | ||||
| use Joomla\CMS\Language\Text; | ||||
| jimport( 'joomla.filesystem.folder' ); | ||||
| jimport( 'joomla.filesystem.file' ); | ||||
| phocagalleryimport('phocagallery.render.renderprocess'); | ||||
| phocagalleryimport('phocagallery.file.file'); | ||||
| phocagalleryimport('phocagallery.image.image'); | ||||
|  | ||||
| register_shutdown_function(function(){ | ||||
| 	$error = error_get_last(); | ||||
| 	if(null !== $error) { | ||||
| 		if (isset($error['type']) && $error['type'] == 1) { | ||||
| 			$app		= Factory::getApplication(); | ||||
| 			$app->redirect('index.php?option=com_phocagallery&view=phocagalleryfe&error=1'); | ||||
| 			exit; | ||||
| 		} | ||||
| 	} | ||||
| }); | ||||
|  | ||||
| class PhocaGalleryImageRotate | ||||
| { | ||||
| 	public static function rotateImage($thumbName, $size, $angle=90, &$errorMsg) { | ||||
|  | ||||
| 		$params 		= ComponentHelper::getParams('com_phocagallery') ; | ||||
| 		$jfile_thumbs	= $params->get( 'jfile_thumbs', 1 ); | ||||
| 		$webp_quality	= $params->get( 'webp_quality', 80 ); | ||||
| 		$webp_quality	= PhocaGalleryImage::getJpegQuality($webp_quality); | ||||
| 		$avif_quality	= $params->get( 'avif_quality', 80 ); | ||||
| 		$avif_quality	= PhocaGalleryImage::getJpegQuality($avif_quality); | ||||
| 		$jpeg_quality	= $params->get( 'jpeg_quality', 85 ); | ||||
| 		$jpeg_quality	= PhocaGalleryImage::getJpegQuality($jpeg_quality); | ||||
|  | ||||
| 		// Try to change the size | ||||
| 		/*$memory = 8; | ||||
| 		$memoryLimitChanged = 0; | ||||
| 		$memory = (int)ini_get( 'memory_limit' ); | ||||
| 		if ($memory == 0) { | ||||
| 			$memory = 8; | ||||
| 		}*/ | ||||
|  | ||||
| 		$fileIn 	= $thumbName->abs; | ||||
| 		$fileOut 	= $thumbName->abs; | ||||
|  | ||||
| 		if ($fileIn !== '' && file_exists($fileIn)) { | ||||
|  | ||||
| 			//array of width, height, IMAGETYPE, "height=x width=x" (string) | ||||
| 	        list($w, $h, $type) = GetImageSize($fileIn); | ||||
|  | ||||
| 			// we got the info from GetImageSize | ||||
| 			if ($w > 0 && $h > 0 && $type !='') { | ||||
| 				// Change the $w against $h because of rotating | ||||
| 				$src = array(0,0, $w, $h); | ||||
| 				$dst = array(0,0, $h, $w); | ||||
| 			} else { | ||||
| 				$errorMsg = 'ErrorWorHorType'; | ||||
| 				return false; | ||||
| 			} | ||||
|  | ||||
| 			// Try to increase memory | ||||
| 			/*if ($memory < 50) { | ||||
| 				ini_set('memory_limit', '50M'); | ||||
| 				$memoryLimitChanged = 1; | ||||
| 			}*/ | ||||
|  | ||||
| 	        switch($type) | ||||
| 	        { | ||||
| 	            case IMAGETYPE_JPEG: | ||||
| 					if (!function_exists('ImageCreateFromJPEG')) { | ||||
| 						$errorMsg = 'ErrorNoJPGFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					//$image1 = ImageCreateFromJPEG($fileIn); | ||||
| 					try { | ||||
| 						$image1 = ImageCreateFromJPEG($fileIn); | ||||
| 					} catch(\Exception $exception) { | ||||
| 						$errorMsg = 'ErrorJPGFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					break; | ||||
| 	            case IMAGETYPE_PNG : | ||||
| 					if (!function_exists('ImageCreateFromPNG')) { | ||||
| 						$errorMsg = 'ErrorNoPNGFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					//$image1 = ImageCreateFromPNG($fileIn); | ||||
| 					try { | ||||
| 						$image1 = ImageCreateFromPNG($fileIn); | ||||
| 					} catch(\Exception $exception) { | ||||
| 						$errorMsg = 'ErrorPNGFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					break; | ||||
| 	            case IMAGETYPE_GIF : | ||||
| 					if (!function_exists('ImageCreateFromGIF')) { | ||||
| 						$errorMsg = 'ErrorNoGIFFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					//$image1 = ImageCreateFromGIF($fileIn); | ||||
| 					try { | ||||
| 						$image1 = ImageCreateFromGIF($fileIn); | ||||
| 					} catch(\Exception $exception) { | ||||
| 						$errorMsg = 'ErrorGIFFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					break; | ||||
|  | ||||
| 				case IMAGETYPE_WEBP : | ||||
| 					if (!function_exists('ImageCreateFromWEBP')) { | ||||
| 						$errorMsg = 'ErrorNoWEBPFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					//$image1 = ImageCreateFromGIF($fileIn); | ||||
| 					try { | ||||
| 						$image1 = ImageCreateFromWEBP($fileIn); | ||||
| 					} catch(\Exception $exception) { | ||||
| 						$errorMsg = 'ErrorWEBPFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					break; | ||||
|  | ||||
| 				case IMAGETYPE_AVIF : | ||||
| 					if (!function_exists('imagecreatefromavif')) { | ||||
| 						$errorMsg = 'ErrorNoAVIFFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					//$image1 = ImageCreateFromGIF($fileIn); | ||||
| 					try { | ||||
| 						$image1 = imagecreatefromavif($fileIn); | ||||
| 					} catch(\Exception $exception) { | ||||
| 						$errorMsg = 'ErrorAVIFFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					break; | ||||
|  | ||||
| 	            case IMAGETYPE_WBMP: | ||||
| 					if (!function_exists('ImageCreateFromWBMP')) { | ||||
| 						$errorMsg = 'ErrorNoWBMPFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					//$image1 = ImageCreateFromWBMP($fileIn); | ||||
| 					try { | ||||
| 						$image1 = ImageCreateFromWBMP($fileIn); | ||||
| 					} catch(\Exception $exception) { | ||||
| 						$errorMsg = 'ErrorWBMPFunction'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					break; | ||||
| 	            Default: | ||||
| 					$errorMsg = 'ErrorNotSupportedImage'; | ||||
| 					return false; | ||||
| 					break; | ||||
| 	        } | ||||
|  | ||||
| 			if ($image1) { | ||||
| 				// Building image for ROTATING | ||||
| 			/*	$image2 = @ImageCreateTruecolor($dst[2], $dst[3]); | ||||
| 				if (!$image2) { | ||||
| 					return 'ErrorNoImageCreateTruecolor'; | ||||
| 				}*/ | ||||
|  | ||||
| 			/*	if(!function_exists("imagerotate")) { | ||||
| 					$errorMsg = 'ErrorNoImageRotate'; | ||||
| 					return false; | ||||
| 				}*/ | ||||
| 				switch($type) | ||||
| 				{ | ||||
| 					case IMAGETYPE_PNG: | ||||
| 					case IMAGETYPE_WEBP: | ||||
| 					case IMAGETYPE_AVIF: | ||||
| 					//	imagealphablending($image1, false); | ||||
| 					//	imagesavealpha($image1, true); | ||||
| 						if(!function_exists("imagecolorallocate")) { | ||||
| 							$errorMsg = 'ErrorNoImageColorAllocate'; | ||||
| 							return false; | ||||
| 						} | ||||
| 						if(!function_exists("imagefill")) { | ||||
| 							$errorMsg = 'ErrorNoImageFill'; | ||||
| 							return false; | ||||
| 						} | ||||
| 						if(!function_exists("imagecolortransparent")) { | ||||
| 							$errorMsg = 'ErrorNoImageColorTransparent'; | ||||
| 							return false; | ||||
| 						} | ||||
| 						$colBlack 	= imagecolorallocate($image1, 0, 0, 0); | ||||
| 						if(!function_exists("imagerotate")) { | ||||
| 							$image2 	= PhocaGalleryImageRotate::imageRotate($image1, $angle, $colBlack); | ||||
| 						} else { | ||||
| 							$image2 	= imagerotate($image1, $angle, $colBlack); | ||||
| 						} | ||||
| 						//imagefill($image2, 0, 0, $colBlack); | ||||
| 						//imagecolortransparent($image2, $colBlack); | ||||
|  | ||||
| 						imagealphablending($image2, false); | ||||
| 						imagesavealpha($image2, true); | ||||
| 					break; | ||||
|  | ||||
|  | ||||
|  | ||||
| 					Default: | ||||
| 						if(!function_exists("imagerotate")) { | ||||
| 							$image2 	= PhocaGalleryImageRotate::imageRotate($image1, $angle, 0); | ||||
| 						} else { | ||||
| 							$image2 = imageRotate($image1, $angle, 0); | ||||
| 						} | ||||
| 					break; | ||||
| 				} | ||||
|  | ||||
| 				// Get the image size and resize the rotated image if necessary | ||||
| 				$rotateWidth 	= imagesx($image2);// Get the size from rotated image | ||||
| 				$rotateHeight 	= imagesy($image2);// Get the size from rotated image | ||||
| 				$parameterSize 	= PhocaGalleryFileThumbnail::getThumbnailResize($size); | ||||
| 				$newWidth		= $parameterSize['width']; // Get maximum sizes, they can be displayed | ||||
| 				$newHeight		= $parameterSize['height'];// Get maximum sizes, they can be displayed | ||||
|  | ||||
| 				$scale = (($newWidth / $rotateWidth) < ($newHeight / $rotateHeight)) ? ($newWidth / $rotateWidth) : ($newHeight / $rotateHeight); // smaller rate | ||||
| 				$src = array(0,0, $rotateWidth, $rotateHeight); | ||||
| 				$dst = array(0,0, floor($rotateWidth*$scale), floor($rotateHeight*$scale)); | ||||
|  | ||||
| 				// If original is smaller than thumbnail size, don't resize it | ||||
| 				if ($src[2] > $dst[2] || $src[3] > $dst[3]) { | ||||
|  | ||||
| 					// Building image for RESIZING THE ROTATED IMAGE | ||||
| 					$image3 = @ImageCreateTruecolor($dst[2], $dst[3]); | ||||
| 					if (!$image3) { | ||||
| 						$errorMsg = 'ErrorNoImageCreateTruecolor'; | ||||
| 						return false; | ||||
| 					} | ||||
| 					ImageCopyResampled($image3, $image2, $dst[0],$dst[1], $src[0],$src[1], $dst[2],$dst[3], $src[2],$src[3]); | ||||
| 					switch($type) | ||||
| 					{ | ||||
| 						case IMAGETYPE_PNG: | ||||
| 						case IMAGETYPE_WEBP: | ||||
| 						case IMAGETYPE_AVIF: | ||||
| 						//	imagealphablending($image2, true); | ||||
| 						//	imagesavealpha($image2, true); | ||||
| 							if(!function_exists("imagecolorallocate")) { | ||||
| 								$errorMsg = 'ErrorNoImageColorAllocate'; | ||||
| 								return false; | ||||
| 							} | ||||
| 							if(!function_exists("imagefill")) { | ||||
| 								$errorMsg = 'ErrorNoImageFill'; | ||||
| 								return false; | ||||
| 							} | ||||
| 							if(!function_exists("imagecolortransparent")) { | ||||
| 								$errorMsg = 'ErrorNoImageColorTransparent'; | ||||
| 								return false; | ||||
| 							} | ||||
| 							$colBlack 	= imagecolorallocate($image3, 0, 0, 0); | ||||
| 							imagefill($image3, 0, 0, $colBlack); | ||||
| 							imagecolortransparent($image3, $colBlack); | ||||
| 						break; | ||||
| 					} | ||||
|  | ||||
| 				} else { | ||||
| 					$image3 = $image2; | ||||
|  | ||||
| 				} | ||||
|  | ||||
| 				switch($type) { | ||||
| 		            case IMAGETYPE_JPEG: | ||||
| 						if (!function_exists('ImageJPEG')) { | ||||
| 							$errorMsg = 'ErrorNoJPGFunction'; | ||||
| 							return false; | ||||
| 						} | ||||
|  | ||||
| 						if ($jfile_thumbs == 1) { | ||||
| 							ob_start(); | ||||
| 							if (!@ImageJPEG($image3, NULL, $jpeg_quality)) { | ||||
| 								ob_end_clean(); | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 							$imgJPEGToWrite = ob_get_contents(); | ||||
| 							ob_end_clean(); | ||||
|  | ||||
| 							if(!File::write( $fileOut, $imgJPEGToWrite)) { | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 						} else { | ||||
| 							if (!@ImageJPEG($image3, $fileOut, $jpeg_quality)) { | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 						} | ||||
| 					break; | ||||
|  | ||||
| 					case IMAGETYPE_PNG : | ||||
| 						if (!function_exists('ImagePNG')) { | ||||
| 							$errorMsg = 'ErrorNoPNGFunction'; | ||||
| 							return false; | ||||
| 						} | ||||
|  | ||||
| 						if ($jfile_thumbs == 1) { | ||||
| 							ob_start(); | ||||
| 							if (!@ImagePNG($image3, NULL)) { | ||||
| 								ob_end_clean(); | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 							$imgPNGToWrite = ob_get_contents(); | ||||
| 							ob_end_clean(); | ||||
|  | ||||
| 							if(!File::write( $fileOut, $imgPNGToWrite)) { | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 						} else { | ||||
| 							if (!@ImagePNG($image3, $fileOut)) { | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 						} | ||||
| 					break; | ||||
|  | ||||
| 					case IMAGETYPE_GIF : | ||||
| 						if (!function_exists('ImageGIF')) { | ||||
| 							$errorMsg = 'ErrorNoGIFFunction'; | ||||
| 							return false; | ||||
| 						} | ||||
|  | ||||
| 						if ($jfile_thumbs == 1) { | ||||
| 							ob_start(); | ||||
| 							if (!@ImageGIF($image3, NULL)) { | ||||
| 								ob_end_clean(); | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 							$imgGIFToWrite = ob_get_contents(); | ||||
| 							ob_end_clean(); | ||||
|  | ||||
| 							if(!File::write( $fileOut, $imgGIFToWrite)) { | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 						} else { | ||||
| 							if (!@ImageGIF($image3, $fileOut)) { | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 						} | ||||
| 					break; | ||||
|  | ||||
| 					case IMAGETYPE_WEBP : | ||||
| 						if (!function_exists('ImageWEBP')) { | ||||
| 							$errorMsg = 'ErrorNoWEBPFunction'; | ||||
| 							return false; | ||||
| 						} | ||||
|  | ||||
| 						if ($jfile_thumbs == 1) { | ||||
| 							ob_start(); | ||||
| 							if (!@imagewebp($image3, NULL, $webp_quality)) { | ||||
| 								ob_end_clean(); | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 							$imgWEBPToWrite = ob_get_contents(); | ||||
| 							ob_end_clean(); | ||||
|  | ||||
| 							if(!File::write( $fileOut, $imgWEBPToWrite)) { | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 						} else { | ||||
| 							if (!@imagewebp($image3, $fileOut, $webp_quality)) { | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 						} | ||||
| 					break; | ||||
|  | ||||
| 					case IMAGETYPE_AVIF : | ||||
| 						if (!function_exists('ImageAVIF')) { | ||||
| 							$errorMsg = 'ErrorNoAVIFFunction'; | ||||
| 							return false; | ||||
| 						} | ||||
|  | ||||
| 						if ($jfile_thumbs == 1) { | ||||
| 							ob_start(); | ||||
| 							if (!@imageavif($image3, NULL, $avif_quality)) { | ||||
| 								ob_end_clean(); | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 							$imgAVIFToWrite = ob_get_contents(); | ||||
| 							ob_end_clean(); | ||||
|  | ||||
| 							if(!File::write( $fileOut, $imgAVIFToWrite)) { | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 						} else { | ||||
| 							if (!@imageavif($image3, $fileOut, $avif_quality)) { | ||||
| 								$errorMsg = 'ErrorWriteFile'; | ||||
| 								return false; | ||||
| 							} | ||||
| 						} | ||||
| 					break; | ||||
|  | ||||
|  | ||||
| 		            Default: | ||||
| 						$errorMsg =  'ErrorNotSupportedImage'; | ||||
| 						return false; | ||||
| 						break; | ||||
| 				} | ||||
|  | ||||
| 				// free memory | ||||
| 				if (isset($image1)) {ImageDestroy($image1);}// Original | ||||
| 				if (isset($image2)) {ImageDestroy($image2);}// Original | ||||
| 				if (isset($image3)) {@ImageDestroy($image3);}// Resized | ||||
|  | ||||
|  | ||||
| 				/*if ($memoryLimitChanged == 1) { | ||||
| 					$memoryString = $memory . 'M'; | ||||
| 					ini_set('memory_limit', $memoryString); | ||||
| 				}*/ | ||||
| 	            return true; // Success | ||||
| 	        } else { | ||||
| 				$errorMsg = PhocaGalleryUtils::setMessage($errorMsg, Text::_('COM_PHOCAGALLERY_ERROR_IMAGE_NOT_PROCESS')); | ||||
| 				return false; | ||||
| 			} | ||||
|  | ||||
| 			/*if ($memoryLimitChanged == 1) { | ||||
| 				$memoryString = $memory . 'M'; | ||||
| 				ini_set('memory_limit', $memoryString); | ||||
| 			}*/ | ||||
| 	    } | ||||
| 		$errorMsg = Text::_('COM_PHOCAGALLERY_FILEORIGINAL_NOT_EXISTS'); | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 		/* This function is provided by php manual (function.imagerotate.php) | ||||
| 	It's a workaround to enables image rotation on distributions which do not | ||||
| 	use the bundled gd library (e.g. Debian, Ubuntu). | ||||
| 	*/ | ||||
| 	public static function imageRotate($src_img, $angle, $colBlack = 0) { | ||||
|  | ||||
| 		if (!imageistruecolor($src_img)) | ||||
| 		{ | ||||
| 			$w = imagesx($src_img); | ||||
| 			$h = imagesy($src_img); | ||||
| 			$t_im = imagecreatetruecolor($w,$h); | ||||
| 			imagecopy($t_im,$src_img,0,0,0,0,$w,$h); | ||||
| 			$src_img = $t_im; | ||||
| 		} | ||||
|  | ||||
| 		$src_x = imagesx($src_img); | ||||
| 		$src_y = imagesy($src_img); | ||||
| 		if ($angle == 180) | ||||
| 		{ | ||||
| 			$dest_x = $src_x; | ||||
| 			$dest_y = $src_y; | ||||
| 		} | ||||
| 		elseif ($src_x <= $src_y) | ||||
| 		{ | ||||
| 			$dest_x = $src_y; | ||||
| 			$dest_y = $src_x; | ||||
| 		} | ||||
| 		elseif ($src_x >= $src_y) | ||||
| 		{ | ||||
| 			$dest_x = $src_y; | ||||
| 			$dest_y = $src_x; | ||||
| 		} | ||||
|  | ||||
| 		$rotate=imagecreatetruecolor($dest_x,$dest_y); | ||||
| 		imagealphablending($rotate, false); | ||||
|  | ||||
| 		switch ($angle) | ||||
| 		{ | ||||
| 			case 270: | ||||
| 				for ($y = 0; $y < ($src_y); $y++) | ||||
| 				{ | ||||
| 					for ($x = 0; $x < ($src_x); $x++) | ||||
| 					{ | ||||
| 						$color = imagecolorat($src_img, $x, $y); | ||||
| 						imagesetpixel($rotate, $dest_x - $y - 1, $x, $color); | ||||
| 					} | ||||
| 				} | ||||
| 				break; | ||||
| 			case 90: | ||||
| 				for ($y = 0; $y < ($src_y); $y++) | ||||
| 				{ | ||||
| 					for ($x = 0; $x < ($src_x); $x++) | ||||
| 					{ | ||||
| 						$color = imagecolorat($src_img, $x, $y); | ||||
| 						imagesetpixel($rotate, $y, $dest_y - $x - 1, $color); | ||||
| 					} | ||||
| 				} | ||||
| 				break; | ||||
| 			case 180: | ||||
| 				for ($y = 0; $y < ($src_y); $y++) | ||||
| 				{ | ||||
| 					for ($x = 0; $x < ($src_x); $x++) | ||||
| 					{ | ||||
| 						$color = imagecolorat($src_img, $x, $y); | ||||
| 						imagesetpixel($rotate, $dest_x - $x - 1, $dest_y - $y - 1, | ||||
| 								$color); | ||||
| 					} | ||||
| 				} | ||||
| 				break; | ||||
| 			Default: $rotate = $src_img; | ||||
| 		}; | ||||
| 		return $rotate; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -0,0 +1,81 @@ | ||||
| <?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; | ||||
| phocagalleryimport('phocagallery.utils.utils'); | ||||
|  | ||||
| class PhocaGalleryImgur | ||||
| { | ||||
|  | ||||
| 	public static function getSize() { | ||||
|  | ||||
|  | ||||
| 		$paramsC 	= ComponentHelper::getParams('com_phocagallery'); | ||||
| 		$lw 		= $paramsC->get( 'large_image_width', 640 ); | ||||
| 		$mw 		= $paramsC->get( 'medium_image_width', 256 ); | ||||
| 		$sw 		= $paramsC->get( 'small_image_width', 128 ); | ||||
|         $crop 		= $paramsC->get( 'crop_thumbnail', 5 ); | ||||
|  | ||||
|  | ||||
|         // Small Crop | ||||
|         if ($crop == 3 || $crop == 5 || $crop == 6 ||$crop == 7) { | ||||
|             $tbS = 'b'; | ||||
|         } else { | ||||
|             $tbS = 't'; | ||||
|         } | ||||
|  | ||||
|         // Medium Crop | ||||
|         if ($crop == 2 || $crop == 4 || $crop == 5 ||$crop == 7) { | ||||
|             $tbM = 'b'; | ||||
|         } else { | ||||
|             $tbM = 't'; | ||||
|         } | ||||
|  | ||||
| 		$iL         = array('l' => 640, 'h' => 1024); | ||||
| 		$iM         = array($tbM => 160, 'm' => 320, 'l' => 640, 'h' => 1024); | ||||
| 		$iS         = array($tbS => 160); | ||||
|  | ||||
|  | ||||
| 		$sizes      = array(); | ||||
|  | ||||
|  | ||||
| 		$sizes['s'][0] = $tbS;// default | ||||
|         $sizes['s'][1] = 160;// default | ||||
|  | ||||
|  | ||||
|         $sizes['m'][0] = 'l';// default | ||||
|         $sizes['m'][1] = 640;// default | ||||
| 		foreach($iM as $k => $v) { | ||||
| 		    if ($v >= $mw) { | ||||
| 		        $sizes['m'][0] = $k; | ||||
|                 $sizes['m'][1] = $v; | ||||
| 		        break; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         $sizes['l'][0] = 'h';// default | ||||
|         $sizes['l'][1] = '1024';// default | ||||
|         foreach($iL as $k => $v) { | ||||
|             if ($v >= $lw) { | ||||
|                 $sizes['l'][0] = $k; | ||||
|                 $sizes['l'][1] = $v; | ||||
|                 break; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|  | ||||
|  | ||||
|         return $sizes; | ||||
|  | ||||
| 	} | ||||
|  | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -0,0 +1,63 @@ | ||||
| <?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('JPATH_BASE') or die(); | ||||
| use Joomla\CMS\Object\CMSObject; | ||||
|  | ||||
| class PhocaGalleryLibrary extends CMSObject | ||||
| { | ||||
| 	var $name			= ''; | ||||
| 	var $value			= 0; | ||||
| //	var $libraries		= ''; | ||||
|  | ||||
| 	function __construct( $library = '' ) { | ||||
| 		$this->name 	= $library; | ||||
| 		$this->value	= 0; | ||||
| //		$this->libraries= ''; | ||||
| 	} | ||||
|  | ||||
| 	public static function getInstance($library = '') { | ||||
| 		static $instances; | ||||
|  | ||||
| 		if (!isset( $instances )) { | ||||
| 			$instances = array(); | ||||
| 		} | ||||
|  | ||||
| 		if (empty($instances[$library])) { | ||||
| 			$instance 				= new PhocaGalleryLibrary(); | ||||
| 			$instances[$library]	= &$instance; | ||||
| 		} | ||||
| 		 | ||||
| //		Information about all libraries | ||||
| //		$this->libraries[$library] = $instances[$library]; | ||||
| 		return $instances[$library]; | ||||
| 	} | ||||
|  | ||||
| 	public static function getLibrary( $library = '' ) { | ||||
| 		 | ||||
| 		$instance 			= PhocaGalleryLibrary::getInstance($library); | ||||
| 		$instance->name		= $library; | ||||
| 		 | ||||
| 		return $instance; | ||||
| 	} | ||||
|  | ||||
| 	public static function setLibrary( $library = '', $value = 1 ) { | ||||
| 		$instance 			= PhocaGalleryLibrary::getInstance($library); | ||||
| 		$instance->name		= $library; | ||||
| 		$instance->value	= $value; | ||||
| 		return $instance; | ||||
| 	} | ||||
| /*	 | ||||
| 	function getLibraries() { | ||||
| 		return $this->libraries; | ||||
| 	} | ||||
| */ | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -0,0 +1,196 @@ | ||||
| <?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; | ||||
| use Joomla\CMS\Language\Text; | ||||
|  | ||||
| class PhocaGalleryOrdering | ||||
| { | ||||
| 	/* | ||||
| 	 * Set Ordering String if Ordering is defined in Parameters | ||||
| 	 * 2 ... category | ||||
| 	 * 1 ... image | ||||
| 	 */ | ||||
| 	public static function getOrderingString ($ordering, $type = 1) { | ||||
|  | ||||
| 		$oO = array(); | ||||
| 		// Default | ||||
| 		$oO['column'] 	= 'ordering'; | ||||
| 		$oO['sort']		= 'ASC'; | ||||
|  | ||||
| 		switch($type) { | ||||
| 			case 2:		$oO['pref'] = $prefId = 'cc';	break; | ||||
| 			default:	$oO['pref'] = $prefId = 'a';	break; | ||||
| 		} | ||||
|  | ||||
| 		switch ((int)$ordering) { | ||||
| 			case 2: | ||||
| 				$oO['column'] 	= 'ordering'; | ||||
| 				$oO['sort']		= 'DESC'; | ||||
| 			break; | ||||
|  | ||||
| 			case 3: | ||||
| 				$oO['column'] 	= 'title'; | ||||
| 				$oO['sort']		= 'ASC'; | ||||
| 			break; | ||||
|  | ||||
| 			case 4: | ||||
| 				$oO['column'] 	= 'title'; | ||||
| 				$oO['sort']		= 'DESC'; | ||||
| 			break; | ||||
|  | ||||
| 			case 5: | ||||
| 				$oO['column'] 	= 'date'; | ||||
| 				$oO['sort']		= 'ASC'; | ||||
| 			break; | ||||
|  | ||||
| 			case 6: | ||||
| 				$oO['column'] 	= 'date'; | ||||
| 				$oO['sort']		= 'DESC'; | ||||
| 			break; | ||||
|  | ||||
| 			case 7: | ||||
| 				$oO['column'] 	= 'id'; | ||||
| 				$oO['sort']		= 'ASC'; | ||||
| 			break; | ||||
|  | ||||
| 			case 8: | ||||
| 				$oO['column'] 	= 'id'; | ||||
| 				$oO['sort']		= 'DESC'; | ||||
| 			break; | ||||
|  | ||||
| 			// Random will be used e.g. ORDER BY RAND() | ||||
| 			/* if ($imageOrdering == 9) { | ||||
| 					$imageOrdering = ' ORDER BY RAND()'; | ||||
| 				} else { | ||||
| 					$imageOrdering = ' ORDER BY '.PhocaGalleryOrdering::getOrderingString($image_ordering); | ||||
| 				} | ||||
| 			*/ | ||||
| 			case 9: | ||||
| 				$oO['column'] 	= ''; | ||||
| 				$oO['sort']		= ''; | ||||
| 				$oO['output']	= ' ORDER BY RAND()'; | ||||
| 				return $oO; | ||||
| 				//$orderingOutput = ''; | ||||
| 			break; | ||||
|  | ||||
| 			// Is not ordered by recursive function needs not to be used | ||||
| 			case 10: | ||||
| 				$oO['column'] 	= ''; | ||||
| 				$oO['sort']		= ''; | ||||
| 				$oO['output']	= ''; | ||||
| 				return $oO; | ||||
| 			break; | ||||
|  | ||||
| 			case 11: | ||||
| 				$oO['column'] 	= 'count'; | ||||
| 				$oO['sort']		= 'ASC'; | ||||
| 				$oO['pref']		= 'r'; | ||||
| 			break; | ||||
| 			case 12: | ||||
| 				$oO['column'] 	= 'count'; | ||||
| 				$oO['sort']		= 'DESC'; | ||||
| 				$oO['pref']		= 'r'; | ||||
| 			break; | ||||
|  | ||||
| 			case 13: | ||||
| 				$oO['column'] 	= 'average'; | ||||
| 				$oO['sort']		= 'ASC'; | ||||
| 				$oO['pref']		= 'r'; | ||||
| 			break; | ||||
| 			case 14: | ||||
| 				$oO['column'] 	= 'average'; | ||||
| 				$oO['sort']		= 'DESC'; | ||||
| 				$oO['pref']		= 'r'; | ||||
| 			break; | ||||
|  | ||||
| 			case 15: | ||||
| 				$oO['column'] 	= 'hits'; | ||||
| 				$oO['sort']		= 'ASC'; | ||||
| 			break; | ||||
| 			case 16: | ||||
| 				$oO['column'] 	= 'hits'; | ||||
| 				$oO['sort']		= 'DESC'; | ||||
| 			break; | ||||
|  | ||||
| 			case 1: | ||||
| 			default: | ||||
| 				$oO['column'] 	= 'ordering'; | ||||
| 				$oO['sort']		= 'ASC'; | ||||
| 			break; | ||||
| 		} | ||||
| 		if ($oO['pref']	== 'r') { | ||||
| 			$oO['output']	= ' ORDER BY ' . $oO['pref'] . '.' . $oO['column'] . ' ' . $oO['sort'] . ', '.$prefId.'.id '.$oO['sort']; | ||||
| 		} else { | ||||
| 			$oO['output']	= ' ORDER BY ' . $oO['pref'] . '.' . $oO['column'] . ' ' . $oO['sort']; | ||||
| 		} | ||||
|  | ||||
| 		return $oO; | ||||
| 	} | ||||
|  | ||||
| 	public static function renderOrderingFront( $selected, $type = 1) { | ||||
|  | ||||
| 		switch($type) { | ||||
| 			case 2: | ||||
| 				$typeOrdering 	= PhocaGalleryOrdering::getOrderingCategoryArray(); | ||||
| 				$ordering		= 'catordering'; | ||||
| 			break; | ||||
|  | ||||
| 			default: | ||||
| 				$typeOrdering 	= PhocaGalleryOrdering::getOrderingImageArray(); | ||||
| 				$ordering		= 'imgordering'; | ||||
| 			break; | ||||
| 		} | ||||
|  | ||||
| 		$html 	= HTMLHelper::_('select.genericlist',  $typeOrdering, $ordering, 'class="form-select" size="1" onchange="this.form.submit()"', 'value', 'text', $selected); | ||||
|  | ||||
| 		return $html; | ||||
| 	} | ||||
|  | ||||
| 	public static function getOrderingImageArray() { | ||||
| 		$imgOrdering	= array( | ||||
| 				1 => Text::_('COM_PHOCAGALLERY_ORDERING_ASC'), | ||||
| 				2 => Text::_('COM_PHOCAGALLERY_ORDERING_DESC'), | ||||
| 				3 => Text::_('COM_PHOCAGALLERY_TITLE_ASC'), | ||||
| 				4 => Text::_('COM_PHOCAGALLERY_TITLE_DESC'), | ||||
| 				5 => Text::_('COM_PHOCAGALLERY_DATE_ASC'), | ||||
| 				6 => Text::_('COM_PHOCAGALLERY_DATE_DESC'), | ||||
| 				//7 => JText::_('COM_PHOCAGALLERY_ID_ASC'), | ||||
| 				//8 => JText::_('COM_PHOCAGALLERY_ID_DESC'), | ||||
| 				11 => Text::_('COM_PHOCAGALLERY_COUNT_ASC'), | ||||
| 				12 => Text::_('COM_PHOCAGALLERY_COUNT_DESC'), | ||||
| 				13 => Text::_('COM_PHOCAGALLERY_AVERAGE_ASC'), | ||||
| 				14 => Text::_('COM_PHOCAGALLERY_AVERAGE_DESC'), | ||||
| 				15 => Text::_('COM_PHOCAGALLERY_HITS_ASC'), | ||||
| 				16 => Text::_('COM_PHOCAGALLERY_HITS_DESC')); | ||||
| 		return $imgOrdering; | ||||
| 	} | ||||
|  | ||||
| 	public static function getOrderingCategoryArray() { | ||||
| 		$imgOrdering	= array( | ||||
| 				1 => Text::_('COM_PHOCAGALLERY_ORDERING_ASC'), | ||||
| 				2 => Text::_('COM_PHOCAGALLERY_ORDERING_DESC'), | ||||
| 				3 => Text::_('COM_PHOCAGALLERY_TITLE_ASC'), | ||||
| 				4 => Text::_('COM_PHOCAGALLERY_TITLE_DESC'), | ||||
| 				5 => Text::_('COM_PHOCAGALLERY_DATE_ASC'), | ||||
| 				6 => Text::_('COM_PHOCAGALLERY_DATE_DESC'), | ||||
| 				//7 => JText::_('COM_PHOCAGALLERY_ID_ASC'), | ||||
| 				//8 => JText::_('COM_PHOCAGALLERY_ID_DESC'), | ||||
| 				11 => Text::_('COM_PHOCAGALLERY_COUNT_ASC'), | ||||
| 				12 => Text::_('COM_PHOCAGALLERY_COUNT_DESC'), | ||||
| 				13 => Text::_('COM_PHOCAGALLERY_AVERAGE_ASC'), | ||||
| 				14 => Text::_('COM_PHOCAGALLERY_AVERAGE_DESC'), | ||||
| 				15 => Text::_('COM_PHOCAGALLERY_HITS_ASC'), | ||||
| 				16 => Text::_('COM_PHOCAGALLERY_HITS_DESC')); | ||||
| 		return $imgOrdering; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -0,0 +1,48 @@ | ||||
| <?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\Pagination\Pagination; | ||||
| use Joomla\CMS\Factory; | ||||
| use Joomla\CMS\Component\ComponentHelper; | ||||
| use Joomla\CMS\HTML\HTMLHelper; | ||||
| use Joomla\CMS\Language\Text; | ||||
|  | ||||
| jimport('joomla.html.pagination'); | ||||
| class PhocaGalleryPaginationCategories extends Pagination | ||||
| { | ||||
| 	public function getLimitBox() { | ||||
| 		$app	= Factory::getApplication(); | ||||
|  | ||||
| 		$paramsC 			= ComponentHelper::getParams('com_phocagallery') ; | ||||
| 		$pagination 		= $paramsC->get( 'pagination_categories', '5,10,15,20,50' ); | ||||
| 		$paginationArray	= explode( ',', $pagination ); | ||||
|  | ||||
| 		// Initialize variables | ||||
| 		$limits = array (); | ||||
|  | ||||
| 		foreach ($paginationArray as $paginationValue) { | ||||
| 			$limits[] = HTMLHelper::_('select.option', $paginationValue); | ||||
| 		} | ||||
| 		$limits[] = HTMLHelper::_('select.option', '0', Text::_('COM_PHOCAGALLERY_ALL')); | ||||
|  | ||||
| 		$selected = $this->viewall ? 0 : $this->limit; | ||||
|  | ||||
| 		// Build the select list | ||||
| 		if ($app->isClient('administrator')) { | ||||
| 			$html = HTMLHelper::_('select.genericlist',  $limits, 'limit', 'class="form-select" size="1" onchange="Joomla.submitform();"', 'value', 'text', $selected); | ||||
| 		} else { | ||||
| 			$html = HTMLHelper::_('select.genericlist',  $limits, 'limit', 'class="form-select" size="1" onchange="this.form.submit()"', 'value', 'text', $selected); | ||||
| 		} | ||||
|  | ||||
| 		return $html; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -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\Pagination\Pagination; | ||||
| use Joomla\CMS\Factory; | ||||
| use Joomla\CMS\Component\ComponentHelper; | ||||
| use Joomla\CMS\HTML\HTMLHelper; | ||||
| use Joomla\CMS\Language\Text; | ||||
|  | ||||
| jimport('joomla.html.pagination'); | ||||
| class PhocaGalleryPaginationCategory extends Pagination | ||||
| { | ||||
| 	public function getLimitBox() { | ||||
| 		$app	= Factory::getApplication(); | ||||
|  | ||||
| 		$paramsC 			= ComponentHelper::getParams('com_phocagallery') ; | ||||
| 		$pagination 		= $paramsC->get( 'pagination_category', '5,10,15,20,50' ); | ||||
| 		$paginationArray	= explode( ',', $pagination ); | ||||
|  | ||||
| 		// Initialize variables | ||||
| 		$limits = array (); | ||||
|  | ||||
| 		foreach ($paginationArray as $paginationValue) { | ||||
| 			$limits[] = HTMLHelper::_('select.option', $paginationValue); | ||||
| 		} | ||||
| 		$limits[] = HTMLHelper::_('select.option', '0', Text::_('COM_PHOCAGALLERY_ALL')); | ||||
|  | ||||
| 		$selected = $this->viewall ? 0 : $this->limit; | ||||
|  | ||||
| 		// Build the select list | ||||
| 		if ($app->isClient('administrator')) { | ||||
| 			$html = HTMLHelper::_('select.genericlist',  $limits, 'limit', 'class="form-select" size="1" onchange="Joomla.submitform();"', 'value', 'text', $selected); | ||||
| 		} else { | ||||
| 			$html = HTMLHelper::_('select.genericlist',  $limits, 'limit', 'class="form-select" size="1" onchange="this.form.submit()"', 'value', 'text', $selected); | ||||
| 		} | ||||
| 		return $html; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,160 @@ | ||||
| <?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\Pagination\Pagination; | ||||
| use Joomla\CMS\Language\Text; | ||||
| use Joomla\CMS\Pagination\PaginationObject; | ||||
| use Joomla\CMS\Router\Route; | ||||
| use Joomla\CMS\Factory; | ||||
| use Joomla\CMS\HTML\HTMLHelper; | ||||
| use Joomla\CMS\Uri\Uri; | ||||
|  | ||||
| jimport('joomla.html.pagination'); | ||||
| class PhocaGalleryPaginationUserImage extends Pagination | ||||
| { | ||||
| 	var $_tabId; | ||||
|  | ||||
| 	public function setTab($tabId) { | ||||
| 		$this->_tabId = (string)$tabId; | ||||
| 	} | ||||
|  | ||||
| 	protected function _buildDataObject() | ||||
| 	{ | ||||
| 		$tabLink = ''; | ||||
| 		if ((string)$this->_tabId != '') { | ||||
| 			$tabLink = '&tab='.(string)$this->_tabId; | ||||
| 		} | ||||
|  | ||||
| 		// Initialize variables | ||||
| 		$data = new stdClass(); | ||||
|  | ||||
| 		$data->all	= new PaginationObject(Text::_('COM_PHOCAGALLERY_VIEW_ALL')); | ||||
| 		if (!$this->viewall) { | ||||
| 			$data->all->base	= '0'; | ||||
| 			$data->all->link	= Route::_($tabLink."&limitstartimage="); | ||||
| 		} | ||||
|  | ||||
| 		// Set the start and previous data objects | ||||
| 		$data->start	= new PaginationObject(Text::_('COM_PHOCAGALLERY_PAG_START')); | ||||
| 		$data->previous	= new PaginationObject(Text::_('COM_PHOCAGALLERY_PAG_PREV')); | ||||
|  | ||||
| 		if ($this->pagesCurrent > 1) | ||||
| 		{ | ||||
| 			$page = ($this->pagesCurrent -2) * $this->limit; | ||||
|  | ||||
| 			$page = $page == 0 ? '' : $page; //set the empty for removal from route | ||||
|  | ||||
| 			$data->start->base	= '0'; | ||||
| 			$data->start->link	= Route::_($tabLink."&limitstartimage="); | ||||
| 			$data->previous->base	= $page; | ||||
| 			$data->previous->link	= Route::_($tabLink."&limitstartimage=".$page); | ||||
| 		} | ||||
|  | ||||
| 		// Set the next and end data objects | ||||
| 		$data->next	= new PaginationObject(Text::_('COM_PHOCAGALLERY_PAG_NEXT')); | ||||
| 		$data->end	= new PaginationObject(Text::_('COM_PHOCAGALLERY_PAG_END')); | ||||
|  | ||||
| 		if ($this->pagesCurrent < $this->pagesTotal) | ||||
| 		{ | ||||
| 			$next = $this->pagesCurrent * $this->limit; | ||||
| 			$end  = ($this->pagesTotal -1) * $this->limit; | ||||
|  | ||||
| 			$data->next->base	= $next; | ||||
| 			$data->next->link	= Route::_($tabLink."&limitstartimage=".$next); | ||||
| 			$data->end->base	= $end; | ||||
| 			$data->end->link	= Route::_($tabLink."&limitstartimage=".$end); | ||||
| 		} | ||||
|  | ||||
| 		$data->pages = array(); | ||||
| 		$stop = $this->pagesStop; | ||||
| 		for ($i = $this->pagesStart; $i <= $stop; $i ++) | ||||
| 		{ | ||||
| 			$offset = ($i -1) * $this->limit; | ||||
|  | ||||
| 			$offset = $offset == 0 ? '' : $offset;  //set the empty for removal from route | ||||
|  | ||||
| 			$data->pages[$i] = new PaginationObject($i); | ||||
| 			if ($i != $this->pagesCurrent || $this->viewall) | ||||
| 			{ | ||||
| 				$data->pages[$i]->base	= $offset; | ||||
| 				$data->pages[$i]->link	= Route::_($tabLink."&limitstartimage=".$offset); | ||||
| 			} | ||||
| 		} | ||||
| 		return $data; | ||||
| 	} | ||||
|  | ||||
| 	public function getLimitBox() | ||||
| 	{ | ||||
| 		$app	= Factory::getApplication(); | ||||
|  | ||||
| 		// Initialize variables | ||||
| 		$limits = array (); | ||||
|  | ||||
| 		// Make the option list | ||||
| 		for ($i = 5; $i <= 30; $i += 5) { | ||||
| 			$limits[] = HTMLHelper::_('select.option', "$i"); | ||||
| 		} | ||||
| 		$limits[] = HTMLHelper::_('select.option', '50'); | ||||
| 		$limits[] = HTMLHelper::_('select.option', '100'); | ||||
| 		$limits[] = HTMLHelper::_('select.option', '0', Text::_('COM_PHOCAGALLERY_ALL')); | ||||
|  | ||||
| 		$selected = $this->viewall ? 0 : $this->limit; | ||||
|  | ||||
| 		// Build the select list | ||||
| 		if ($app->isClient('administrator')) { | ||||
| 			$html = HTMLHelper::_('select.genericlist',  $limits, 'limitimage', 'class="form-control input-mini" size="1" onchange="Joomla.submitform();"', 'value', 'text', $selected); | ||||
| 		} else { | ||||
| 			$html = HTMLHelper::_('select.genericlist',  $limits, 'limitimage', 'class="form-control input-mini" size="1" onchange="this.form.submit()"', 'value', 'text', $selected); | ||||
| 		} | ||||
| 		return $html; | ||||
| 	} | ||||
|  | ||||
| 	public function orderUpIcon($i, $condition = true, $task = '#', $alt = 'COM_PHOCAGALLERY_MOVE_UP', $enabled = true, $checkbox = 'cb') { | ||||
|  | ||||
|  | ||||
| 		$alt = Text::_($alt); | ||||
|  | ||||
|  | ||||
| 		$html = ' '; | ||||
| 		if (($i > 0 || ($i + $this->limitstart > 0)) && $condition) | ||||
| 		{ | ||||
| 			if($enabled) { | ||||
| 				$html	= '<a href="'.$task.'" title="'.$alt.'">'; | ||||
| 				$html	.= '   <img src="'.Uri::base(true).'/media/com_phocagallery/images/icon-uparrow.png" width="16" height="16" border="0" alt="'.$alt.'" />'; | ||||
| 				$html	.= '</a>'; | ||||
| 			} else { | ||||
| 				$html	= '<img src="'.Uri::base(true).'/media/com_phocagallery/images/icon-uparrow0.png" width="16" height="16" border="0" alt="'.$alt.'" />'; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return $html; | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	public function orderDownIcon($i, $n, $condition = true, $task = '#', $alt = 'COM_PHOCAGALLERY_MOVE_DOWN', $enabled = true, $checkbox = 'cb'){ | ||||
| 		$alt = Text::_($alt); | ||||
|  | ||||
| 		$html = ' '; | ||||
| 		if (($i < $n -1 || $i + $this->limitstart < $this->total - 1) && $condition) | ||||
| 		{ | ||||
| 			if($enabled) { | ||||
| 				$html	= '<a href="'.$task.'" title="'.$alt.'">'; | ||||
| 				$html	.= '  <img src="'.Uri::base(true).'/media/com_phocagallery/images/icon-downarrow.png" width="16" height="16" border="0" alt="'.$alt.'" />'; | ||||
| 				$html	.= '</a>'; | ||||
| 			} else { | ||||
| 				$html	= '<img src="'.Uri::base(true).'/media/com_phocagallery/images/icon-downarrow0.png" width="16" height="16" border="0" alt="'.$alt.'" />'; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return $html; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,162 @@ | ||||
| <?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\Pagination\Pagination; | ||||
| use Joomla\CMS\Language\Text; | ||||
| use Joomla\CMS\Pagination\PaginationObject; | ||||
| use Joomla\CMS\Router\Route; | ||||
| use Joomla\CMS\Factory; | ||||
| use Joomla\CMS\HTML\HTMLHelper; | ||||
| use Joomla\CMS\Uri\Uri; | ||||
|  | ||||
| jimport('joomla.html.pagination'); | ||||
| class PhocaGalleryPaginationUserSubCat extends Pagination | ||||
| { | ||||
| 	var $_tabId; | ||||
|  | ||||
| 	public function setTab($tabId) { | ||||
| 		$this->_tabId = (string)$tabId; | ||||
| 	} | ||||
|  | ||||
| 	public function _buildDataObject() | ||||
| 	{ | ||||
| 		$tabLink = ''; | ||||
| 		if ((string)$this->_tabId > 0) { | ||||
| 			$tabLink = '&tab='.(string)$this->_tabId; | ||||
| 		} | ||||
|  | ||||
| 		// Initialize variables | ||||
| 		$data = new stdClass(); | ||||
|  | ||||
| 		$data->all	= new PaginationObject(Text::_('COM_PHOCAGALLERY_VIEW_ALL')); | ||||
| 		if (!$this->viewall) { | ||||
| 			$data->all->base	= '0'; | ||||
| 			$data->all->link	= Route::_($tabLink."&limitstartsubcat="); | ||||
| 		} | ||||
|  | ||||
| 		// Set the start and previous data objects | ||||
| 		$data->start	= new PaginationObject(Text::_('COM_PHOCAGALLERY_PAG_START')); | ||||
| 		$data->previous	= new PaginationObject(Text::_('COM_PHOCAGALLERY_PAG_PREV')); | ||||
|  | ||||
| 		if ($this->pagesCurrent > 1) | ||||
| 		{ | ||||
| 			$page = ($this->pagesCurrent -2) * $this->limit; | ||||
|  | ||||
| 			$page = $page == 0 ? '' : $page; //set the empty for removal from route | ||||
|  | ||||
| 			$data->start->base	= '0'; | ||||
| 			$data->start->link	= Route::_($tabLink."&limitstartsubcat="); | ||||
| 			$data->previous->base	= $page; | ||||
| 			$data->previous->link	= Route::_($tabLink."&limitstartsubcat=".$page); | ||||
| 		} | ||||
|  | ||||
| 		// Set the next and end data objects | ||||
| 		$data->next	= new PaginationObject(Text::_('COM_PHOCAGALLERY_PAG_NEXT')); | ||||
| 		$data->end	= new PaginationObject(Text::_('COM_PHOCAGALLERY_PAG_END')); | ||||
|  | ||||
| 		if ($this->pagesCurrent < $this->pagesTotal) | ||||
| 		{ | ||||
| 			$next = $this->pagesCurrent * $this->limit; | ||||
| 			$end  = ($this->pagesTotal -1) * $this->limit; | ||||
|  | ||||
| 			$data->next->base	= $next; | ||||
| 			$data->next->link	= Route::_($tabLink."&limitstartsubcat=".$next); | ||||
| 			$data->end->base	= $end; | ||||
| 			$data->end->link	= Route::_($tabLink."&limitstartsubcat=".$end); | ||||
| 		} | ||||
|  | ||||
| 		$data->pages = array(); | ||||
| 		$stop = $this->pagesStop; | ||||
| 		for ($i = $this->pagesStart; $i <= $stop; $i ++) | ||||
| 		{ | ||||
| 			$offset = ($i -1) * $this->limit; | ||||
|  | ||||
| 			$offset = $offset == 0 ? '' : $offset;  //set the empty for removal from route | ||||
|  | ||||
| 			$data->pages[$i] = new PaginationObject($i); | ||||
| 			if ($i != $this->pagesCurrent || $this->viewall) | ||||
| 			{ | ||||
| 				$data->pages[$i]->base	= $offset; | ||||
| 				$data->pages[$i]->link	= Route::_($tabLink."&limitstartsubcat=".$offset); | ||||
| 			} | ||||
| 		} | ||||
| 		return $data; | ||||
| 	} | ||||
|  | ||||
| 	public function getLimitBox() | ||||
| 	{ | ||||
| 		$app	= Factory::getApplication(); | ||||
|  | ||||
| 		// Initialize variables | ||||
| 		$limits = array (); | ||||
|  | ||||
| 		// Make the option list | ||||
| 		for ($i = 5; $i <= 30; $i += 5) { | ||||
| 			$limits[] = HTMLHelper::_('select.option', "$i"); | ||||
| 		} | ||||
| 		$limits[] = HTMLHelper::_('select.option', '50'); | ||||
| 		$limits[] = HTMLHelper::_('select.option', '100'); | ||||
| 		$limits[] = HTMLHelper::_('select.option', '0', Text::_('COM_PHOCAGALLERY_ALL')); | ||||
|  | ||||
| 		$selected = $this->viewall ? 0 : $this->limit; | ||||
|  | ||||
| 		// Build the select list | ||||
| 		if ($app->isClient('administrator')) { | ||||
| 			$html = HTMLHelper::_('select.genericlist',  $limits, 'limitsubcat', 'class="form-control input-mini" size="1" onchange="Joomla.submitform();"', 'value', 'text', $selected); | ||||
| 		} else { | ||||
| 			$html = HTMLHelper::_('select.genericlist',  $limits, 'limitsubcat', 'class="form-control input-mini" size="1"  onchange="this.form.submit()"', 'value', 'text', $selected); | ||||
| 		} | ||||
| 		return $html; | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	public function orderUpIcon($i, $condition = true, $task = '#', $alt = 'COM_PHOCAGALLERY_MOVE_UP', $enabled = true, $checkbox = 'cb') { | ||||
|  | ||||
|  | ||||
| 		$alt = Text::_($alt); | ||||
|  | ||||
|  | ||||
| 		$html = ' '; | ||||
| 		if (($i > 0 || ($i + $this->limitstart > 0)) && $condition) | ||||
| 		{ | ||||
| 			if($enabled) { | ||||
| 				$html	= '<a href="'.$task.'" title="'.$alt.'">'; | ||||
| 				$html	.= '   <img src="'.Uri::base(true).'/media/com_phocagallery/images/icon-uparrow.png" width="16" height="16" border="0" alt="'.$alt.'" />'; | ||||
| 				$html	.= '</a>'; | ||||
| 			} else { | ||||
| 				$html	= '<img src="'.Uri::base(true).'/media/com_phocagallery/images/icon-uparrow0.png" width="16" height="16" border="0" alt="'.$alt.'" />'; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return $html; | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	public function orderDownIcon($i, $n, $condition = true, $task = '#', $alt = 'COM_PHOCAGALLERY_MOVE_DOWN', $enabled = true, $checkbox = 'cb'){ | ||||
|  | ||||
| 		$alt = Text::_($alt); | ||||
|  | ||||
| 		$html = ' '; | ||||
| 		if (($i < $n -1 || $i + $this->limitstart < $this->total - 1) && $condition) | ||||
| 		{ | ||||
| 			if($enabled) { | ||||
| 				$html	= '<a href="'.$task.'" title="'.$alt.'">'; | ||||
| 				$html	.= '  <img src="'.Uri::base(true).'/media/com_phocagallery/images/icon-downarrow.png" width="16" height="16" border="0" alt="'.$alt.'" />'; | ||||
| 				$html	.= '</a>'; | ||||
| 			} else { | ||||
| 				$html	= '<img src="'.Uri::base(true).'/media/com_phocagallery/images/icon-downarrow0.png" width="16" height="16" border="0" alt="'.$alt.'" />'; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return $html; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -0,0 +1,59 @@ | ||||
| <?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\Object\CMSObject; | ||||
| use Joomla\CMS\Uri\Uri; | ||||
|  | ||||
|  | ||||
| class PhocaGalleryPath extends CMSObject | ||||
| { | ||||
| 	public function __construct() {} | ||||
|  | ||||
| 	public static function &getInstance() { | ||||
| 		static $instance; | ||||
| 		if (!$instance) { | ||||
| 			$instance = new PhocaGalleryPath(); | ||||
| 			//$baseFront 						= str_replace('/administrator', '', JUri::base(true)); | ||||
| 			$baseFront						= Uri::root(true); | ||||
| 			$instance->image_abs 			= JPATH_ROOT . '/images/phocagallery/'; | ||||
| 			$instance->image_rel			= 'images/phocagallery/'; | ||||
| 			$instance->avatar_abs 			= JPATH_ROOT . '/images/phocagallery/avatars/'; | ||||
| 			$instance->avatar_rel			= 'images/phocagallery/avatars/'; | ||||
| 			$instance->image_rel_full		= $baseFront  . '/' . $instance->image_rel; | ||||
| 			$instance->image_rel_admin 		= 'media/com_phocagallery/images/administrator/'; | ||||
| 			$instance->image_rel_admin_full = $baseFront  . '/' . $instance->image_rel_admin; | ||||
| 			$instance->image_rel_front 		= 'media/com_phocagallery/images/'; | ||||
| 			$instance->image_rel_front_full = $baseFront  . '/' . $instance->image_rel_front; | ||||
| 			$instance->image_abs_front		= JPATH_ROOT .'/media/com_phocagallery/images/'; | ||||
|  | ||||
| 			$instance->media_css_abs		= JPATH_ROOT .'/media/com_phocagallery/css/'; | ||||
| 			$instance->media_img_abs		= JPATH_ROOT .'/media/com_phocagallery/images/'; | ||||
| 			$instance->media_js_abs			= JPATH_ROOT .'/media/com_phocagallery/js/'; | ||||
| 			$instance->media_css_rel		= 'media/com_phocagallery/css/'; | ||||
| 			$instance->media_img_rel		= 'media/com_phocagallery/images/'; | ||||
| 			$instance->media_js_rel			= 'media/com_phocagallery/js/'; | ||||
| 			$instance->media_css_rel_full	= $baseFront  . '/' . $instance->media_css_rel; | ||||
| 			$instance->media_img_rel_full	= $baseFront  . '/' . $instance->media_img_rel; | ||||
| 			$instance->media_js_rel_full	= $baseFront  . '/' . $instance->media_js_rel; | ||||
| 			$instance->assets_abs			= JPATH_ROOT . '/media/com_phocagallery/js/'; | ||||
| 			$instance->assets_rel			= 'media/com_phocagallery/js/'; | ||||
| 		} | ||||
|  | ||||
| 		return $instance; | ||||
| 	} | ||||
|  | ||||
| 	public static function getPath() { | ||||
| 		$instance 	= PhocaGalleryPath::getInstance(); | ||||
| 		return $instance; | ||||
| 	} | ||||
|  | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,390 @@ | ||||
| <?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\Menu\AbstractMenu; | ||||
|  | ||||
| jimport('joomla.application.component.helper'); | ||||
|  | ||||
| class PhocaGalleryRoute | ||||
| { | ||||
| 	public static function getCategoriesRoute() { | ||||
|  | ||||
| 		// TEST SOLUTION | ||||
| 	/*	$app 		= Factory::getApplication(); | ||||
| 		$menu 		= $app->getMenu(); | ||||
| 		$active 	= $menu->getActive(); | ||||
|  | ||||
|  | ||||
| 		$activeId 	= 0; | ||||
| 		if (isset($active->id)){ | ||||
| 			$activeId    = $active->id; | ||||
| 		} | ||||
|  | ||||
| 		$itemId 	= 0; | ||||
| 		/* There cannot be $item->id yet | ||||
| 		// 1) get standard item id if exists | ||||
| 		if (isset($item->id)) { | ||||
| 			$itemId = (int)$item->id; | ||||
| 		}*//* | ||||
|  | ||||
| 		$option			= $app->input->get( 'option', '', 'string' ); | ||||
| 		$view			= $app->input->get( 'view', '', 'string' ); | ||||
| 		if ($option == 'com_phocagallery' && $view == 'category') { | ||||
| 			if ((int)$activeId > 0) { | ||||
| 				// 2) if there are two menu links, try to select the one active | ||||
| 				$itemId = $activeId; | ||||
| 			} | ||||
| 		}*/ | ||||
|  | ||||
| 		$needles = array( | ||||
| 			'categories' => '' | ||||
| 		); | ||||
|  | ||||
| 		$link = 'index.php?option=com_phocagallery&view=categories'; | ||||
|  | ||||
| 		if($item = self::_findItem($needles, 1)) { | ||||
| 			if(isset($item->query['layout'])) { | ||||
| 				$link .= '&layout='.$item->query['layout']; | ||||
| 			} | ||||
|  | ||||
| 			if (isset($item->id)) { | ||||
| 				$link .= '&Itemid='.(int)$item->id;; | ||||
| 			} | ||||
|  | ||||
| 			// TEST SOLUTION | ||||
| 			/*if ((int)$itemId > 0) { | ||||
| 				$link .= '&Itemid='.(int)$itemId; | ||||
| 			} else if (isset($item->id) && ((int)$item->id > 0)) { | ||||
| 				$link .= '&Itemid='.$item->id; | ||||
| 			}*/ | ||||
|  | ||||
| 			// $item->id should be a "categories view" and it should have preference to category view | ||||
| 			// so first we check item->id then itemId | ||||
|  | ||||
| 			// 1) there can be two categories view, when yes, first set itemId then item->id | ||||
| 			// 2) but when there is one category view, and one categories view - first select item->id (categories view) | ||||
| 			// 3) then select itemid even we don't know if categories or category view | ||||
|  | ||||
| 			/*if ((int)$itemId > 0 && isset($active->query['view']) && $active->query['view'] == 'categories') { | ||||
| 				$link .= '&Itemid='.(int)$itemId; | ||||
| 			} else if (isset($item->id) && ((int)$item->id > 0)) { | ||||
| 				$link .= '&Itemid='.$item->id; | ||||
| 			} else if ((int)$itemId > 0) { | ||||
| 				$link .= '&Itemid='.(int)$itemId; | ||||
| 			}*/ | ||||
| 		}; | ||||
|  | ||||
|  | ||||
| 		return $link; | ||||
| 	} | ||||
|  | ||||
| 	public static function getCategoryRoute($catid, $catidAlias = '') { | ||||
|  | ||||
| 		// TEST SOLUTION | ||||
| 		/*$app 		= Factory::getApplication(); | ||||
| 		$menu 		= $app->getMenu(); | ||||
| 		$active 	= $menu->getActive(); | ||||
| 		$option		= $app->input->get( 'option', '', 'string' ); | ||||
|  | ||||
|  | ||||
| 		$activeId 	= 0; | ||||
| 		$notCheckId	= 1; | ||||
| 		if (isset($active->id)){ | ||||
| 			$activeId    = $active->id; | ||||
| 		} | ||||
| 		if ((int)$activeId > 0 && $option == 'com_phocagallery') { | ||||
|  | ||||
| 			$needles 	= array( | ||||
| 				'category' => (int)$catid, | ||||
| 				'categories' => (int)$activeId | ||||
| 			); | ||||
| 			$notCheckId = 0;// when categories view, do not check id | ||||
| 			// we need to check the ID - there can be more menu links (to categories, to category) | ||||
| 		} else { | ||||
| 			$needles = array( | ||||
| 				'category' => (int)$catid, | ||||
| 				'categories' => '' | ||||
| 			); | ||||
| 			$notCheckId = 0; | ||||
| 		} | ||||
|  | ||||
| 		if ($catidAlias != '') { | ||||
| 			$catid = $catid . ':' . $catidAlias; | ||||
| 		} | ||||
|  | ||||
| 		//Create the link | ||||
| 		$link = 'index.php?option=com_phocagallery&view=category&id='. $catid; | ||||
|  | ||||
| 		if($item = PhocaGalleryRoute::_findItem($needles, $notCheckId)) { | ||||
|  | ||||
| 			if(isset($item->query['layout'])) { | ||||
| 				$link .= '&layout='.$item->query['layout']; | ||||
| 			} | ||||
| 			if (isset($item->id) && ((int)$item->id > 0)) { | ||||
| 				$link .= '&Itemid='.$item->id; | ||||
| 			} | ||||
| 		};*/ | ||||
|  | ||||
| 		$needles = array( | ||||
| 			'category' => (int)$catid, | ||||
| 			'categories' => '' | ||||
| 		); | ||||
|  | ||||
| 		if ($catidAlias != '') { | ||||
| 			$catid = $catid . ':' . $catidAlias; | ||||
| 		} | ||||
|  | ||||
| 		//Create the link | ||||
| 		$link = 'index.php?option=com_phocagallery&view=category&id='. $catid; | ||||
|  | ||||
| 		if($item = self::_findItem($needles)) { | ||||
| 			if(isset($item->query['layout'])) { | ||||
| 				$link .= '&layout='.$item->query['layout']; | ||||
| 			} | ||||
| 			if(isset($item->id)) { | ||||
| 				$link .= '&Itemid='.$item->id; | ||||
| 			} | ||||
| 		}; | ||||
|  | ||||
| 		return $link; | ||||
| 	} | ||||
|  | ||||
| 	public static function getFeedRoute($view = 'categories', $catid = 0, $catidAlias = '') { | ||||
|  | ||||
| 		if ($view == 'categories') { | ||||
| 			$needles = array( | ||||
| 				'categories' => '' | ||||
| 			); | ||||
| 			$link = 'index.php?option=com_phocagallery&view=categories&format=feed'; | ||||
|  | ||||
| 		} else if ($view == 'category') { | ||||
| 			if ($catid > 0) { | ||||
| 				$needles = array( | ||||
| 					'category' => (int) $catid, | ||||
| 					'categories' => '' | ||||
| 				); | ||||
| 				if ($catidAlias != '') { | ||||
| 					$catid = (int)$catid . ':' . $catidAlias; | ||||
| 				} | ||||
|  | ||||
| 				$link = 'index.php?option=com_phocagallery&view=category&format=feed&id='.$catid; | ||||
|  | ||||
| 			} else { | ||||
| 				$needles = array( | ||||
| 				'categories' => '' | ||||
| 				); | ||||
| 				$link = 'index.php?option=com_phocagallery&view=categories&format=feed'; | ||||
| 			} | ||||
| 		} else { | ||||
| 			$needles = array( | ||||
| 				'categories' => '' | ||||
| 			); | ||||
| 			$link = 'index.php?option=com_phocagallery&view=feed&format=feed'; | ||||
| 		} | ||||
|  | ||||
|  | ||||
| 		if($item = PhocaGalleryRoute::_findItem($needles, 1)) { | ||||
|  | ||||
| 			if(isset($item->query['layout'])) { | ||||
| 				$link .= '&layout='.$item->query['layout']; | ||||
| 			} | ||||
| 			if (isset($item->id) && ((int)$item->id > 0)) { | ||||
| 				$link .= '&Itemid='.$item->id; | ||||
| 			} | ||||
| 		}; | ||||
|  | ||||
| 		return $link; | ||||
| 	} | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| 	public static function getCategoryRouteByTag($tagId) { | ||||
| 		$needles = array( | ||||
| 			'category' => '', | ||||
| 			//'section'  => (int) $sectionid, | ||||
| 			'categories' => '' | ||||
| 		); | ||||
|  | ||||
| 		$db = Factory::getDBO(); | ||||
|  | ||||
| 		$query = 'SELECT a.id, a.title, a.link_ext, a.link_cat' | ||||
| 		.' FROM #__phocagallery_tags AS a' | ||||
| 		.' WHERE a.id = '.(int)$tagId | ||||
| 		.' ORDER BY a.id'; | ||||
|  | ||||
| 		$db->setQuery($query, 0, 1); | ||||
| 		$tag = $db->loadObject(); | ||||
|  | ||||
|  | ||||
|  | ||||
| 		//Create the link | ||||
| 		if (isset($tag->id)) { | ||||
| 			$link = 'index.php?option=com_phocagallery&view=category&id=0:category&tagid='.(int)$tag->id; | ||||
| 		} else { | ||||
| 			$link = 'index.php?option=com_phocagallery&view=category&id=0:category&tagid=0'; | ||||
| 		} | ||||
|  | ||||
| 		if($item = self::_findItem($needles)) { | ||||
| 			if(isset($item->query['layout'])) { | ||||
| 				$link .= '&layout='.$item->query['layout']; | ||||
| 			} | ||||
|  | ||||
| 			if (isset($item->id) && ((int)$item->id > 0)) { | ||||
| 				$link .= '&Itemid='.$item->id; | ||||
| 			} | ||||
| 		}; | ||||
|  | ||||
| 		return $link; | ||||
| 	} | ||||
|  | ||||
|  | ||||
|  | ||||
| 	public static function getImageRoute($id, $catid = 0, $idAlias = '', $catidAlias = '', $type = 'detail', $suffix = '') | ||||
| 	{ | ||||
| 		// TEST SOLUTION | ||||
| 		/*$app 		= Factory::getApplication(); | ||||
| 		$menu 		= $app->getMenu(); | ||||
| 		$active 	= $menu->getActive(); | ||||
| 		$option		= $app->input->get( 'option', '', 'string' ); | ||||
|  | ||||
| 		$activeId 	= 0; | ||||
| 		$notCheckId	= 0; | ||||
| 		if (isset($active->id)){ | ||||
| 			$activeId    = $active->id; | ||||
| 		} | ||||
|  | ||||
| 		if ((int)$activeId > 0 && $option == 'com_phocagallery') { | ||||
|  | ||||
| 			$needles = array( | ||||
| 				'detail'  => (int) $id, | ||||
| 				'category' => (int) $catid, | ||||
| 				'categories' => (int)$activeId | ||||
| 			); | ||||
| 			$notCheckId	= 1; | ||||
| 		} else { | ||||
| 			$needles = array( | ||||
| 				'detail'  => (int) $id, | ||||
| 				'category' => (int) $catid, | ||||
| 				'categories' => '' | ||||
| 			); | ||||
| 			$notCheckId	= 0; | ||||
| 		}*/ | ||||
|  | ||||
| 		$needles = array( | ||||
| 			'detail'  => (int) $id, | ||||
| 			'category' => (int) $catid, | ||||
| 			'categories' => '' | ||||
| 		); | ||||
|  | ||||
|  | ||||
| 		if ($idAlias != '') { | ||||
| 			$id = $id . ':' . $idAlias; | ||||
| 		} | ||||
| 		if ($catidAlias != '') { | ||||
| 			$catid = $catid . ':' . $catidAlias; | ||||
| 		} | ||||
|  | ||||
| 		//Create the link | ||||
|  | ||||
| 		switch ($type) | ||||
| 		{ | ||||
| 			case 'detail': | ||||
| 				$link = 'index.php?option=com_phocagallery&view=detail&catid='. $catid .'&id='. $id; | ||||
| 				break; | ||||
|  | ||||
| 			default: | ||||
| 				$link = ''; | ||||
| 			break; | ||||
| 		} | ||||
|  | ||||
| 		if ($item = self::_findItem($needles)) { | ||||
| 			if (isset($item->id) && ((int)$item->id > 0)) { | ||||
| 				$link .= '&Itemid='.$item->id; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		if ($suffix != '') { | ||||
| 			$link .= '&'.$suffix; | ||||
| 		} | ||||
|  | ||||
| 		return $link; | ||||
| 	} | ||||
|  | ||||
| 	protected static function _findItem($needles, $notCheckId = 0, $component = 'com_phocagallery') { | ||||
|  | ||||
|  | ||||
| 		$app		= Factory::getApplication(); | ||||
| 		//$menus		= $app->getMenu('site', array()); // Problems in indexer | ||||
| 		$menus    = AbstractMenu::getInstance('site'); | ||||
| 		$items		= $menus->getItems('component', $component); | ||||
| 		//$menu 		= $menus;//$app->getMenu(); | ||||
| 		$active 	= $menus->getActive(); | ||||
| 		$option		= $app->input->get( 'option', '', 'string' ); | ||||
|  | ||||
| 		// Don't check ID for specific views. e.g. categories view does not have ID | ||||
| 		$notCheckIdArray =  array('categories'); | ||||
|  | ||||
| 		if(!$items) { | ||||
| 			$itemId =  $app->input->get('Itemid', 0, 'int'); | ||||
| 			if ($itemId > 0) { | ||||
| 				$item = new stdClass(); | ||||
| 				$item->id = $itemId; | ||||
| 				return $item; | ||||
| 			} | ||||
| 			return null; | ||||
| 		} | ||||
|  | ||||
| 		$match = null; | ||||
| 		// FIRST - test active menu link | ||||
| 		foreach($needles as $needle => $id) { | ||||
| 			if (isset($active->query['option']) && $active->query['option'] == $component | ||||
| 				&& isset($active->query['view']) && $active->query['view'] == $needle | ||||
| 				&& (in_array($needle, $notCheckIdArray) || (isset($active->query['id']) && $active->query['id'] == $id )) | ||||
| 			) { | ||||
| 				$match = $active; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		if(isset($match)) { | ||||
| 			return $match; | ||||
| 		} | ||||
|  | ||||
| 		// SECOND - if not find in active, try to run other items | ||||
| 		//          ordered by function which calls this function - e.g. file, category, categories | ||||
| 		//          as last the categories view should be checked, it has no ID so we skip the checking | ||||
| 		//          of ID for categories view with OR: in_array($needle, $notCheckIdArray) || | ||||
| 		foreach($needles as $needle => $id) { | ||||
|  | ||||
| 			foreach($items as $item) { | ||||
|  | ||||
| 				if (isset($item->query['option']) && $item->query['option'] == $component | ||||
| 					&& isset($item->query['view']) && $item->query['view'] == $needle | ||||
| 					&& (in_array($needle, $notCheckIdArray) || (isset($item->query['id']) && $item->query['id'] == $id )) | ||||
| 				) { | ||||
| 					$match = $item; | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			if(isset($match)) { | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return $match; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,170 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @package     Joomla.Site | ||||
|  * @subpackage  com_phocagallery | ||||
|  * | ||||
|  * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved. | ||||
|  * @license     GNU General Public License version 2 or later; see LICENSE.txt | ||||
|  */ | ||||
| defined('_JEXEC') or die(); | ||||
|  | ||||
| use Joomla\CMS\Component\Router\Rules\MenuRules; | ||||
| use Joomla\CMS\Factory; | ||||
|  | ||||
| class PhocaGalleryRouterrules extends MenuRules | ||||
| { | ||||
| 	public function preprocess(&$query) { | ||||
| 		parent::preprocess($query); | ||||
| 	} | ||||
|  | ||||
| 	protected function buildLookup($language = '*') { | ||||
| 		parent::buildLookup($language); | ||||
| 	} | ||||
|  | ||||
|     /* | ||||
|      * PHOCAEDIT | ||||
|      */ | ||||
|     public function parse(&$segments, &$vars) { | ||||
|  | ||||
|         // SPECIFIC CASE TAG - tag search output in category view | ||||
|         // 1. components/com_phocagallery/router.php getCategorySegment() - BUILD | ||||
|         // 2. administrator/components/com_phocagallery/libraries/phocadownload/path/routerrules.php build() - BUILD | ||||
|         // 3. administrator/components/com_phocagallery/libraries/phocadownload/path/routerrules.php parse() - PARSE | ||||
|         $app    = Factory::getApplication(); | ||||
|         $tagId  = $app->input->get('tagid', 0, 'int'); | ||||
|         if ($segments[0] == 'category' && (int)$tagId > 0){ | ||||
|             // We are in category view but tags output | ||||
|             $vars['view'] = 'category'; | ||||
|             unset($segments[0]); | ||||
|         } | ||||
|         return parent::parse($segments, $vars); | ||||
|     } | ||||
|  | ||||
|     /* EDIT of libraries/src/Component/Router/Rules/StandardRules.php build function | ||||
|      * Because we need to manage when categories view does not have any ID | ||||
|      * PHOCAEDIT | ||||
|      */ | ||||
|     public function build(&$query, &$segments) { | ||||
|  | ||||
| 		if (!isset($query['Itemid'], $query['view'])) { | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		// Get the menu item belonging to the Itemid that has been found | ||||
| 		$item = $this->router->menu->getItem($query['Itemid']); | ||||
|  | ||||
|         if ($item === null || $item->component !== 'com_' . $this->router->getName() || !isset($item->query['view'])) { | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
|         // PHOCAEDIT | ||||
|         if (!isset($item->query['id']) ){ | ||||
|             $item->query['id'] = 0; | ||||
|         } | ||||
|  | ||||
| 		// Get menu item layout | ||||
| 		$mLayout = isset($item->query['layout']) ? $item->query['layout'] : null; | ||||
|  | ||||
| 		// Get all views for this component | ||||
| 		$views = $this->router->getViews(); | ||||
|  | ||||
| 		// Return directly when the URL of the Itemid is identical with the URL to build | ||||
| 		if ($item->query['view'] === $query['view']) { | ||||
| 			$view = $views[$query['view']]; | ||||
|  | ||||
| 			if (!$view->key) { | ||||
| 				unset($query['view']); | ||||
|  | ||||
| 				if (isset($query['layout']) && $mLayout === $query['layout']) { | ||||
| 					unset($query['layout']); | ||||
| 				} | ||||
|  | ||||
| 				return; | ||||
| 			} | ||||
|  | ||||
| 			if (isset($query[$view->key]) && $item->query[$view->key] == (int) $query[$view->key]) { | ||||
| 				unset($query[$view->key]); | ||||
|  | ||||
| 				while ($view) { | ||||
| 					unset($query[$view->parent_key]); | ||||
|  | ||||
| 					$view = $view->parent; | ||||
| 				} | ||||
|  | ||||
| 				unset($query['view']); | ||||
|  | ||||
| 				if (isset($query['layout']) && $mLayout === $query['layout']) { | ||||
| 					unset($query['layout']); | ||||
| 				} | ||||
|  | ||||
| 				return; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		// Get the path from the view of the current URL and parse it to the menu item | ||||
| 		$path  = array_reverse($this->router->getPath($query), true); | ||||
| 		$found = false; | ||||
|  | ||||
| 		foreach ($path as $element => $ids) { | ||||
| 			$view = $views[$element]; | ||||
|  | ||||
| 			if ($found === false && $item->query['view'] === $element) { | ||||
| 				if ($view->nestable) { | ||||
| 					$found = true; | ||||
| 				} elseif ($view->children) { | ||||
| 					$found = true; | ||||
|  | ||||
| 					continue; | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			if ($found === false) { | ||||
| 				// Jump to the next view | ||||
| 				continue; | ||||
| 			} | ||||
|  | ||||
|  | ||||
| 			if ($ids) { | ||||
|  | ||||
| 				if ($view->nestable) { | ||||
| 					$found2 = false; | ||||
|  | ||||
| 					foreach (array_reverse($ids, true) as $id => $segment) { | ||||
|  | ||||
|                         if ($found2) { | ||||
| 							$segments[] = str_replace(':', '-', $segment); | ||||
|  | ||||
| 						} elseif ((int) $item->query[$view->key] === (int) $id) { | ||||
| 							$found2 = true; | ||||
|  | ||||
|                             // SPECIFIC CASE TAG - tag search output in category view | ||||
|                             // 1. components/com_phocagallery/router.php getCategorySegment() - BUILD | ||||
|                             // 2. administrator/components/com_phocagallery/libraries/phocadownload/path/routerrules.php build() - BUILD | ||||
|                             // 3. administrator/components/com_phocagallery/libraries/phocadownload/path/routerrules.php parse() - PARSE | ||||
|                             if ((int)$query['id'] == 0 && $query['view'] == 'category' && isset($query['tagid']) && (int)$query['tagid'] > 0) { | ||||
|                                 $segments[] = 'category'; | ||||
|                             } | ||||
| 						} | ||||
| 					} | ||||
| 				} elseif ($ids === true) { | ||||
| 					$segments[] = $element; | ||||
| 				} else { | ||||
| 					$segments[] = str_replace(':', '-', current($ids)); | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			if ($view->parent_key) { | ||||
| 				// Remove parent key from query | ||||
| 				unset($query[$view->parent_key]); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		if ($found) { | ||||
| 			unset($query[$views[$query['view']]->key], $query['view']); | ||||
|  | ||||
| 			if (isset($query['layout']) && $mLayout === $query['layout']) { | ||||
| 				unset($query['layout']); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -0,0 +1,43 @@ | ||||
| <?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\Router\Route; | ||||
|  | ||||
| class PhocaGalleryPhocaCart | ||||
| { | ||||
| 	public static function getPcLink($id, &$errorMsg) { | ||||
|  | ||||
| 		$link = ''; | ||||
| 		if (ComponentHelper::isEnabled('com_phocacart', true)) { | ||||
| 			if ((int)$id < 1) { | ||||
| 				return ""; | ||||
| 			} | ||||
| 		} else { | ||||
| 			return ""; | ||||
| 		} | ||||
|  | ||||
| 		if (is_file( JPATH_ADMINISTRATOR .  '/components/com_phocacart/libraries/phocacart/product/product.php')) { | ||||
|  | ||||
| 		    JLoader::registerPrefix('Phocacart', JPATH_ADMINISTRATOR . '/components/com_phocacart/libraries/phocacart'); | ||||
| 		    require_once( JPATH_ADMINISTRATOR . '/components/com_phocacart/libraries/autoloadPhoca.php'); | ||||
| 			require_once( JPATH_ADMINISTRATOR .  '/components/com_phocacart/libraries/phocacart/product/product.php' ); | ||||
|  | ||||
| 			$v = PhocacartProduct::getProduct($id); | ||||
|  | ||||
| 			if(isset($v->id) && $v->id > 0 && isset($v->catid) && $v->catid > 0 && isset($v->alias) && isset($v->catalias)) { | ||||
| 				$link = Route::_(PhocacartRoute::getItemRoute($v->id, $v->catid, $v->alias, $v->catalias)); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return $link; | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -0,0 +1,238 @@ | ||||
| <?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\Language\Text; | ||||
| use Joomla\CMS\Uri\Uri; | ||||
| use Joomla\CMS\HTML\HTMLHelper; | ||||
| phocagalleryimport('phocagallery.utils.utils'); | ||||
|  | ||||
| class PhocaGalleryPicasa | ||||
| { | ||||
|  | ||||
| 	public static function getSize(&$mediumT) { | ||||
|  | ||||
| 		// If small and medium can be taken from $thumbSize, take it from here as these images can be cropped | ||||
| 		$thumbSize 	= array(32, 48, 64, 72, 104, 144, 150, 160); | ||||
| 		$imgMax		= array(94, 110, 128, 200, 220, 288, 320, 400, 512, 576, 640, 720, 800, 912, 1024, 1152, 1280, 1440, 1600); | ||||
| 		$paramsC 	= ComponentHelper::getParams('com_phocagallery'); | ||||
|  | ||||
| 		$lw 		= $paramsC->get( 'large_image_width', 640 ); | ||||
| 		$mw 		= $paramsC->get( 'medium_image_width', 256 ); | ||||
| 		$sw 		= $paramsC->get( 'small_image_width', 128 ); | ||||
| 		$crop 		= $paramsC->get( 'crop_thumbnail', 5 ); | ||||
| 		$output		= array(); | ||||
| 		$outputS	= $outputM	= $outputL	=	$outputLargeSize = ''; | ||||
|  | ||||
| 		// Large | ||||
| 		foreach ($imgMax as $value) { | ||||
| 			// First value which is greater than the large_image_width will be taken | ||||
| 			if ((int)$value > (int)$lw || (int)$value == (int)$lw) { | ||||
| 				$outputL		= '&imgmax='.(int)$value; | ||||
| 				$outputLargeSize= $value; | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
| 		// Small | ||||
| 		foreach ($thumbSize as $value) { | ||||
| 			// First value which is greater than the large_image_width will be taken | ||||
| 			if ((int)$value > (int)$sw || (int)$value == (int)$sw) { | ||||
| 				$outputS		= '&thumbsize='.(int)$value; | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		// Medium | ||||
| 		// Try to handle it as thumbnail | ||||
| 		foreach ($thumbSize as $value) { | ||||
| 			// First value which is greater than the large_image_width will be taken | ||||
| 			if ((int)$value > (int)$mw || (int)$value == (int)$mw) { | ||||
| 				//$outputM		= '&thumbsize='.(int)$value; | ||||
| 				$outputM		= ','.(int)$value; | ||||
| 				$mediumT		= 1; | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
| 		// Try to find it in imgmax | ||||
| 		if ($mediumT != 1) { | ||||
| 			foreach ($imgMax as $value) { | ||||
| 				// First value which is greater than the large_image_width will be taken | ||||
| 				if ((int)$value > (int)$mw || (int)$value == (int)$mw) { | ||||
| 					$outputM		= '&imgmax='.(int)$value; | ||||
| 					$mediumT		= 0; | ||||
| 					break; | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 		} | ||||
|  | ||||
| 		// Small Crop | ||||
|  | ||||
| 		if ($crop == 3 || $crop == 5 || $crop == 6 ||$crop == 7) { | ||||
| 			$outputS = $outputS . 'c'; | ||||
| 		} else { | ||||
| 			$outputS = $outputS . 'u'; | ||||
| 		} | ||||
|  | ||||
| 		// Medium Crop | ||||
| 		if ($mediumT == 1) { | ||||
| 			if ($crop == 2 || $crop == 4 || $crop == 5 ||$crop == 7) { | ||||
| 				$outputM = $outputM . 'c'; | ||||
| 			} else { | ||||
| 				$outputM = $outputM . 'u'; | ||||
| 			} | ||||
| 		} | ||||
| 		if ($mediumT == 1) { | ||||
| 			$output['lsm'] = $outputL . $outputS . $outputM; | ||||
| 		} else { | ||||
| 			$output['lsm'] = $outputL . $outputS; | ||||
| 		} | ||||
| 		if ($mediumT != 1) { | ||||
| 			$output['m'] = $outputM; | ||||
| 		} | ||||
| 		// This we need for getting info about size and and removing this size to get an original image | ||||
| 		// It is not lsm | ||||
| 		$output['ls']	= $outputLargeSize; | ||||
|  | ||||
| 		return $output; | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Used for external images: Picasa, Facebook | ||||
| 	 */ | ||||
|  | ||||
|  | ||||
| 	public static function correctSizeWithRate($width, $height, $corWidth = 100, $corHeight = 100, $diffThumbHeight = 0) { | ||||
|  | ||||
|  | ||||
|  | ||||
| 		$image['width']		= $corWidth; | ||||
| 		$image['height']	= $corHeight; | ||||
|  | ||||
| 		if ((int)$diffThumbHeight > 0) { | ||||
| 			$ratio = $width / $height; | ||||
| 			$image['height'] = $ratio * $image['height']; | ||||
| 			return $image; | ||||
| 		} | ||||
|  | ||||
| 		// Don't do anything with images: | ||||
| 		if ($width < $corWidth && $height < $corHeight) { | ||||
| 			$image['width']		= $width; | ||||
| 			$image['height']	= $height; | ||||
| 		} else { | ||||
|  | ||||
| 			if ($width > $height) { | ||||
| 				if ($width > $corWidth) { | ||||
| 					$image['width']		= $corWidth; | ||||
| 					$rate 				= (int)$width / (int)$corWidth; | ||||
| 					$image['height']	= (int)$height / $rate; | ||||
| 				} else { | ||||
| 					$image['width']		= $width; | ||||
| 					$image['height']	= $height; | ||||
| 				} | ||||
| 			} else { | ||||
| 				if ($height > $corHeight) { | ||||
| 					$image['height']	= $corHeight; | ||||
| 					$rate 				= (int)$height / (int)$corHeight; | ||||
| 					$image['width'] 	= (int)$width / $rate; | ||||
| 				} else { | ||||
| 					$image['width']		= $width; | ||||
| 					$image['height']	= $height; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		return $image; | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Used while pagination | ||||
| 	 */ | ||||
| 	public static function renderProcessPage($id, $refreshUrl, $countInfo = '') { | ||||
|  | ||||
| 		echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n"; | ||||
| 		echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-en" lang="en-en" dir="ltr" >'. "\n"; | ||||
| 		echo '<head>'. "\n"; | ||||
| 		echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'. "\n\n"; | ||||
| 		echo '<title>'.Text::_( 'COM_PHOCAGALLERY_PICASA_LOADING_DATA').'</title>'. "\n"; | ||||
| 		echo '<link rel="stylesheet" href="'.Uri::root(true).'/media/com_phocagallery/css/administrator/phocagallery.css" type="text/css" />'; | ||||
|  | ||||
| 		echo '</head>'. "\n"; | ||||
| 		echo '<body>'. "\n"; | ||||
|  | ||||
| 		echo '<div style="text-align:right;padding:10px"><a style="font-family: sans-serif, Arial;font-weight:bold;color:#fc0000;font-size:14px;" href="index.php?option=com_phocagallery&task=phocagalleryc.edit&id='.(int)$id.'">' .Text::_( 'COM_PHOCAGALLERY_STOP_LOADING_PICASA_IMAGES' ).'</a></div>'; | ||||
|  | ||||
| 		echo '<div id="loading-ext-img-processp" style="font-family: sans-serif, Arial;font-weight:normal;color:#666;font-size:14px;padding:10px"><div class="loading"><div><center>'. HTMLHelper::_('image', 'media/com_phocagallery/images/administrator/icon-loading.gif', Text::_('COM_PHOCAGALLERY_LOADING') ) .'</center></div><div> </div><div><center>'.Text::_('COM_PHOCAGALLERY_PICASA_LOADING_DATA').'</center></div>'; | ||||
|  | ||||
| 		echo $countInfo; | ||||
| 		echo '</div></div>'; | ||||
|  | ||||
| 		echo '<meta http-equiv="refresh" content="1;url='.$refreshUrl.'" />'; | ||||
| 		echo '</body></html>'; | ||||
| 		exit; | ||||
| 	} | ||||
|  | ||||
| 	public static function loadDataByAddress($address, $type, &$errorMsg) { | ||||
|  | ||||
| 		$curl = $fopen = 1; | ||||
| 		$data	= ''; | ||||
|  | ||||
| 		if(!function_exists("curl_init")){ | ||||
| 			$errorMsg .= Text::_('COM_PHOCAGALLERY_PICASA_NOT_LOADED_CURL'); | ||||
| 			$curl = 0; | ||||
| 		} | ||||
|  | ||||
| 		if(!PhocaGalleryUtils::iniGetBool('allow_url_fopen')){ | ||||
| 			if ($errorMsg != '') { | ||||
| 				$errorMsg .= '<br />'; | ||||
| 			} | ||||
| 			$errorMsg .= Text::_('COM_PHOCAGALLERY_PICASA_NOT_LOADED_FOPEN'); | ||||
| 			$fopen = 0; | ||||
| 		} | ||||
|  | ||||
| 		if ($fopen == 0 && $curl == 0) { | ||||
| 			return false; | ||||
| 		} | ||||
|  | ||||
| 		if ($curl == 1) { | ||||
| 			$init 	= curl_init(); | ||||
| 			curl_setopt ($init, CURLOPT_URL, 			$address); | ||||
| 			curl_setopt ($init, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); // Experimental | ||||
| 			curl_setopt ($init, CURLOPT_RETURNTRANSFER,	1); | ||||
| 			curl_setopt ($init, CURLOPT_CONNECTTIMEOUT,	10); | ||||
| 		    $data 	= curl_exec($init); | ||||
| 		    curl_close($init); | ||||
| 		} else { | ||||
| 			$data	= @file_get_contents($address); | ||||
| 		} | ||||
|  | ||||
| 		if ($data == '') { | ||||
| 			if ($errorMsg != '') { | ||||
| 				$errorMsg .= '<br />'; | ||||
| 			} | ||||
| 			switch ($type) { | ||||
| 				case 'album': | ||||
| 					$errorMsg = Text::_('COM_PHOCAGALLERY_PICASA_NOT_LOADED_IMAGE'); | ||||
| 				break; | ||||
|  | ||||
| 				case 'user': | ||||
| 				Default: | ||||
| 					$errorMsg .= Text::_('COM_PHOCAGALLERY_PICASA_NOT_LOADED_USER'); | ||||
| 				break; | ||||
|  | ||||
| 			} | ||||
| 			return false; | ||||
| 		} | ||||
| 		return $data; | ||||
|  | ||||
| 	} | ||||
|  | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -0,0 +1,103 @@ | ||||
| <?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; | ||||
|  | ||||
| class PhocaGalleryRateCategory | ||||
| { | ||||
| 	public static function updateVoteStatistics( $catid ) { | ||||
| 		 | ||||
| 		$db =Factory::getDBO(); | ||||
| 		 | ||||
| 		// Get AVG and COUNT | ||||
| 		$query = 'SELECT COUNT(vs.id) AS count, AVG(vs.rating) AS average' | ||||
| 				.' FROM #__phocagallery_votes AS vs' | ||||
| 			    .' WHERE vs.catid = '.(int) $catid; | ||||
| 		//		.' AND vs.published = 1'; | ||||
| 		$db->setQuery($query, 0, 1); | ||||
| 		$votesStatistics = $db->loadObject(); | ||||
| 		// if no count, set the average to 0 | ||||
| 		if($votesStatistics->count == 0) { | ||||
| 			$votesStatistics->count = (int)0; | ||||
| 			$votesStatistics->average = (float)0; | ||||
| 		} | ||||
| 		 | ||||
| 		if (isset($votesStatistics->count) && isset($votesStatistics->average)) { | ||||
| 			// Insert or update | ||||
| 			$query = 'SELECT vs.id AS id' | ||||
| 					.' FROM #__phocagallery_votes_statistics AS vs' | ||||
| 				    .' WHERE vs.catid = '.(int) $catid | ||||
| 					.' ORDER BY vs.id'; | ||||
| 			$db->setQuery($query, 0, 1); | ||||
| 			$votesStatisticsId = $db->loadObject(); | ||||
| 		 | ||||
| 			// Yes, there is id (UPDATE) x No, there isn't (INSERT) | ||||
| 			if (!empty($votesStatisticsId->id)) { | ||||
| 			 | ||||
| 				$query = 'UPDATE #__phocagallery_votes_statistics' | ||||
| 					.' SET count = ' .(int)$votesStatistics->count | ||||
| 					.' , average = ' .(float)$votesStatistics->average | ||||
| 				    .' WHERE catid = '.(int) $catid; | ||||
| 				$db->setQuery($query); | ||||
| 				$db->execute(); | ||||
| 				 | ||||
| 				 | ||||
| 			 | ||||
| 			} else { | ||||
| 			 | ||||
| 				$query = 'INSERT into #__phocagallery_votes_statistics' | ||||
| 					.' (id, catid, count, average)' | ||||
| 				    .' VALUES (null, '.(int)$catid | ||||
| 					.' , '.(int)$votesStatistics->count | ||||
| 					.' , '.(float)$votesStatistics->average | ||||
| 					.')'; | ||||
| 				$db->setQuery($query); | ||||
| 				$db->execute(); | ||||
| 				 | ||||
| 				 | ||||
| 			 | ||||
| 			} | ||||
| 		} else { | ||||
| 			return false; | ||||
| 		} | ||||
| 		return true; | ||||
| 	} | ||||
| 	 | ||||
| 	public static function getVotesStatistics($id) { | ||||
| 	 | ||||
| 		$db =Factory::getDBO(); | ||||
| 		$query = 'SELECT vs.count AS count, vs.average AS average' | ||||
| 				.' FROM #__phocagallery_votes_statistics AS vs' | ||||
| 			    .' WHERE vs.catid = '.(int) $id; | ||||
| 		$db->setQuery($query, 0, 1); | ||||
| 		$votesStatistics = $db->loadObject(); | ||||
| 			 | ||||
| 		return $votesStatistics; | ||||
| 	} | ||||
| 	 | ||||
| 	public static function checkUserVote($catid, $userid) { | ||||
| 		 | ||||
| 		$db =Factory::getDBO(); | ||||
| 		$query = 'SELECT v.id AS id' | ||||
| 			    .' FROM #__phocagallery_votes AS v' | ||||
| 			    .' WHERE v.catid = '. (int)$catid  | ||||
| 				.' AND v.userid = '. (int)$userid | ||||
| 				.' ORDER BY v.id'; | ||||
| 		$db->setQuery($query, 0, 1); | ||||
| 		$checkUserVote = $db->loadObject(); | ||||
| 			 | ||||
| 		if ($checkUserVote) { | ||||
| 			return true; | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,426 @@ | ||||
| <?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\Router\Route; | ||||
| use Joomla\CMS\Session\Session; | ||||
| use Joomla\CMS\Uri\Uri; | ||||
|  | ||||
| class PhocaGalleryRateImage | ||||
| { | ||||
| 	public static function updateVoteStatistics( $imgid ) { | ||||
|  | ||||
| 		$db =Factory::getDBO(); | ||||
|  | ||||
| 		// Get AVG and COUNT | ||||
| 		$query = 'SELECT COUNT(vs.id) AS count, AVG(vs.rating) AS average' | ||||
| 				.' FROM #__phocagallery_img_votes AS vs' | ||||
| 			    .' WHERE vs.imgid = '.(int) $imgid; | ||||
| 		//		.' AND vs.published = 1'; | ||||
| 		$db->setQuery($query, 0, 1); | ||||
| 		$votesStatistics = $db->loadObject(); | ||||
| 		// if no count, set the average to 0 | ||||
| 		if($votesStatistics->count == 0) { | ||||
| 			$votesStatistics->count = (int)0; | ||||
| 			$votesStatistics->average = (float)0; | ||||
| 		} | ||||
|  | ||||
| 		if (isset($votesStatistics->count) && isset($votesStatistics->average)) { | ||||
| 			// Insert or update | ||||
| 			$query = 'SELECT vs.id AS id' | ||||
| 					.' FROM #__phocagallery_img_votes_statistics AS vs' | ||||
| 				    .' WHERE vs.imgid = '.(int) $imgid | ||||
| 					.' ORDER BY vs.id'; | ||||
| 			$db->setQuery($query, 0, 1); | ||||
| 			$votesStatisticsId = $db->loadObject(); | ||||
|  | ||||
| 			// Yes, there is id (UPDATE) x No, there isn't (INSERT) | ||||
| 			if (!empty($votesStatisticsId->id)) { | ||||
|  | ||||
| 				$query = 'UPDATE #__phocagallery_img_votes_statistics' | ||||
| 					.' SET count = ' .(int)$votesStatistics->count | ||||
| 					.' , average = ' .(float)$votesStatistics->average | ||||
| 				    .' WHERE imgid = '.(int) $imgid; | ||||
| 				$db->setQuery($query); | ||||
| 				$db->execute(); | ||||
|  | ||||
| 			} else { | ||||
|  | ||||
| 				$query = 'INSERT into #__phocagallery_img_votes_statistics' | ||||
| 					.' (id, imgid, count, average)' | ||||
| 				    .' VALUES (null, '.(int)$imgid | ||||
| 					.' , '.(int)$votesStatistics->count | ||||
| 					.' , '.(float)$votesStatistics->average | ||||
| 					.')'; | ||||
| 				$db->setQuery($query); | ||||
| 				$db->execute(); | ||||
|  | ||||
| 			} | ||||
| 		} else { | ||||
| 			return false; | ||||
| 		} | ||||
| 		return true; | ||||
| 	} | ||||
|  | ||||
| 	public static function getVotesStatistics($id) { | ||||
|  | ||||
| 		$db =Factory::getDBO(); | ||||
| 		$query = 'SELECT vs.count AS count, vs.average AS average' | ||||
| 				.' FROM #__phocagallery_img_votes_statistics AS vs' | ||||
| 			    .' WHERE vs.imgid = '.(int) $id; | ||||
| 		$db->setQuery($query, 0, 1); | ||||
| 		$votesStatistics = $db->loadObject(); | ||||
|  | ||||
| 		return $votesStatistics; | ||||
| 	} | ||||
|  | ||||
| 	public static function checkUserVote($imgid, $userid) { | ||||
|  | ||||
| 		$db =Factory::getDBO(); | ||||
| 		$query = 'SELECT v.id AS id' | ||||
| 			    .' FROM #__phocagallery_img_votes AS v' | ||||
| 			    .' WHERE v.imgid = '. (int)$imgid | ||||
| 				.' AND v.userid = '. (int)$userid; | ||||
| 		$db->setQuery($query, 0, 1); | ||||
| 		$checkUserVote = $db->loadObject(); | ||||
| 		if ($checkUserVote) { | ||||
| 			return true; | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	public static function renderRateImg($id, $displayRating, $small = 1, $refresh = false) { | ||||
|  | ||||
| 		$user					= Factory::getUser(); | ||||
| 		$neededAccessLevels		= PhocaGalleryAccess::getNeededAccessLevels(); | ||||
| 		$access					= PhocaGalleryAccess::isAccess($user->getAuthorisedViewLevels(), $neededAccessLevels); | ||||
|  | ||||
|  | ||||
| 		if ($small == 1) { | ||||
| 			$smallO = '-small'; | ||||
| 			$ratio = 16; | ||||
| 		} else { | ||||
| 			$smallO = ''; | ||||
| 			$ratio = 22; | ||||
| 		} | ||||
|  | ||||
| 		$o = ''; | ||||
| 		$or = ''; | ||||
|  | ||||
| 		$href	= 'javascript:void(0);'; | ||||
|  | ||||
| 		if ((int)$displayRating != 2) { | ||||
| 			return ''; | ||||
| 		} else { | ||||
|  | ||||
| 			$rating['alreadyratedfile']	= self::checkUserVote( (int)$id, (int)$user->id ); | ||||
|  | ||||
| 			$rating['notregisteredfile'] 	= true; | ||||
| 			//$rating['usernamefile']		= ''; | ||||
| 			if ($access > 0) { | ||||
| 				$rating['notregisteredfile'] 	= false; | ||||
| 				$rating['usernamefile']			= $user->name; | ||||
| 			} | ||||
|  | ||||
| 			$rating['votescountfile'] 	= 0; | ||||
| 			$rating['votesaveragefile'] = 0; | ||||
| 			$rating['voteswidthfile'] 	= 0; | ||||
| 			$votesStatistics	= self::getVotesStatistics((int)$id); | ||||
| 			if (!empty($votesStatistics->count)) { | ||||
| 				$rating['votescountfile'] = $votesStatistics->count; | ||||
| 			} | ||||
| 			if (!empty($votesStatistics->average)) { | ||||
| 				$rating['votesaveragefile'] = $votesStatistics->average; | ||||
| 				if ($rating['votesaveragefile'] > 0) { | ||||
| 					$rating['votesaveragefile'] 	= round(((float)$rating['votesaveragefile'] / 0.5)) * 0.5; | ||||
| 					$rating['voteswidthfile']		= $ratio * $rating['votesaveragefile']; | ||||
| 				} else { | ||||
| 					$rating['votesaveragefile'] 	= (int)0;// not float displaying | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			// Leave message for already voted images | ||||
| 			//$vote = Factory::getApplication()->input->get('vote', 0, '', 'int'); | ||||
| 			$voteMsg = Text::_('COM_PHOCAGALLERY_ALREADY_RATE_IMG'); | ||||
| 			//if ($vote == 1) { | ||||
| 			//	$voteMsg = JText::_('COM_PHOCADOWNLOAD_ALREADY_RATED_FILE_THANKS'); | ||||
| 			//} | ||||
|  | ||||
| 			$rating['votestextimg'] = 'VOTE'; | ||||
| 			if ((int)$rating['votescountfile'] > 1) { | ||||
| 				$rating['votestextimg'] = 'VOTES'; | ||||
| 			} | ||||
| /* | ||||
| 			$o .= '<div style="float:left;"><strong>' | ||||
| 					. Text::_('COM_PHOCAGALLERY_RATING'). '</strong>: ' . $rating['votesaveragefile'] .' / ' | ||||
| 					.$rating['votescountfile'] . ' ' . Text::_('COM_PHOCAGALLERY_'.$rating['votestextimg']). '  </div>'; | ||||
| 	*/ | ||||
| 			if ($rating['alreadyratedfile']) { | ||||
| 				$o .= '<div class="pg-rate-box" title="'.$voteMsg.'" ><ul class="star-rating'.$smallO.'">' | ||||
| 						.'<li class="current-rating" style="width:'.$rating['voteswidthfile'].'px"></li>' | ||||
| 						.'<li><span class="star1"></span></li>'; | ||||
|  | ||||
| 				for ($i = 2;$i < 6;$i++) { | ||||
| 					$o .= '<li><span class="stars'.$i.'"></span></li>'; | ||||
| 				} | ||||
| 				$o .= '</ul></div>'; | ||||
|  | ||||
| 				//$or ='<div class="pg-cv-vote-img-result" id="pg-cv-vote-img-result'.(int)$id.'" style="float:left;margin-left:5px">'.JText::_('COM_PHOCAGALLERY_ALREADY_RATE_IMG').'</div>'; | ||||
|  | ||||
| 			} else if ($rating['notregisteredfile']) { | ||||
|  | ||||
| 				$o .= '<div class="pg-rate-box" title="'.Text::_('COM_PHOCAGALLERY_COMMENT_ONLY_REGISTERED_LOGGED_RATE_IMAGE').'"><ul class="star-rating'.$smallO.'">' | ||||
| 						.'<li class="current-rating" style="width:'.$rating['voteswidthfile'].'px"></li>' | ||||
| 						.'<li><span class="star1"></span></li>'; | ||||
|  | ||||
| 				for ($i = 2;$i < 6;$i++) { | ||||
| 					$o .= '<li><span class="stars'.$i.'"></span></li>'; | ||||
| 				} | ||||
| 				$o .= '</ul></div>'; | ||||
|  | ||||
| 				//$or ='<div class="pg-cv-vote-img-result" id="pg-cv-vote-img-result'.(int)$id.'" style="float:left;margin-left:5px">'.JText::_('COM_PHOCAGALLERY_COMMENT_ONLY_REGISTERED_LOGGED_RATE_IMAGE').'</div>'; | ||||
|  | ||||
| 			} else { | ||||
|  | ||||
| 				$o .= '<div class="pg-rate-box"><ul class="star-rating'.$smallO.'">' | ||||
| 						.'<li class="current-rating" style="width:'.$rating['voteswidthfile'].'px"></li>' | ||||
| 						.'<li><a href="'.$href.'" onclick="pgRating('.(int)$id.', 1, 1, \'pg-msnr-container\')" title="'. Text::sprintf('COM_PHOCAGALLERY_STAR_OUT_OF', 1, 5). '" class="star1">1</a></li>'; | ||||
|  | ||||
| 				for ($i = 2;$i < 6;$i++) { | ||||
| 					$o .= '<li><a href="'.$href.'" onclick="pgRating('.(int)$id.', '.$i.', 1, \'pg-msnr-container\')"  title="'. Text::sprintf('COM_PHOCAGALLERY_STARS_OUT_OF', $i, 5) .'" class="stars'.$i.'">'.$i.'</a></li>'; | ||||
| 				} | ||||
| 				$o .= '</ul></div>'; | ||||
|  | ||||
| 				$or ='<div class="pg-rate-img-result" id="pg-rate-img-result'.(int)$id.'"></div>'; | ||||
| 			} | ||||
|  | ||||
|  | ||||
|  | ||||
| 		} | ||||
|  | ||||
| 		if ($refresh == true) { | ||||
| 			return $o . '<div style="clear:both;"></div>';//we are in Ajax, return only content of pdvoting div | ||||
| 		} else { | ||||
| 			return '<div class="pg-rate-img" id="pg-rate-img'.(int)$id.'">'.$o.'</div>'.$or . '<div style="clear:both;"></div>';//not in ajax, return the content in div | ||||
| 		} | ||||
|  | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	public static function renderRateImgJS($small = 1) { | ||||
|  | ||||
| 		$document	 = Factory::getDocument(); | ||||
| 		$url		  = Route::_('index.php?option=com_phocagallery&view=ratingimga&task=rate&format=json&'.Session::getFormToken().'=1', false); | ||||
| 		$urlRefresh		= Route::_('index.php?option=com_phocagallery&view=ratingimga&task=refreshrate&small='.$small.'&format=json&'.Session::getFormToken().'=1', false); | ||||
| 		$imgLoadingUrl = Uri::base(). 'media/com_phocagallery/images/loading.svg'; | ||||
| 		$imgLoadingHTML = '<img src="'.$imgLoadingUrl.'" alt="" />'; | ||||
|  | ||||
|  | ||||
| 		$js = ' | ||||
| 		function pgRating(id, vote, m, container) { | ||||
| 		 | ||||
| 			var result 			= "#pg-rate-img-result" + id; | ||||
| 			var resultvoting 	= "#pg-rate-img" + id; | ||||
| 			data = {"ratingId": id, "ratingVote": vote, "format":"json"}; | ||||
| 			 | ||||
| 			pgRequest = jQuery.ajax({ | ||||
|                 type: "POST", | ||||
|                 url: "'.$url.'", | ||||
|                 async: "false", | ||||
|                 cache: "false", | ||||
|                 data: data, | ||||
|                 dataType:"JSON", | ||||
|                  | ||||
|                 beforeSend: function(){ | ||||
|                     jQuery(result).html("'.addslashes($imgLoadingHTML).'"); | ||||
|                     if (m == 2) { | ||||
|                         //var wall = new Masonry(document.getElementById(container)); | ||||
|                     } | ||||
|                 }, | ||||
|                  | ||||
|                 success: function(data){ | ||||
|                     if (data.status == 1){ | ||||
|                         jQuery(result).html(data.message); | ||||
|                        | ||||
|                          | ||||
|                          | ||||
|                         // Refresh vote | ||||
|                         dataR = {"ratingId": id, "ratingVote": vote, "format":"json"}; | ||||
|                          | ||||
|                         pgRequestRefresh = jQuery.ajax({ | ||||
|                             type: "POST", | ||||
|                             url: "'.$urlRefresh.'", | ||||
|                             async: "false", | ||||
|                             cache: "false", | ||||
|                             data: dataR, | ||||
|                             dataType:"JSON", | ||||
|                              | ||||
|                             beforeSend: function(){ | ||||
|                                 jQuery(resultvoting).html("'.addslashes($imgLoadingHTML).'"); | ||||
|                                 if (m == 2) { | ||||
|                                     //var wall = new Masonry(document.getElementById(container)); | ||||
|                                 } | ||||
|                             }, | ||||
|                              | ||||
|                             success: function(dataR){ | ||||
|                                 if (dataR.status == 1){ | ||||
|                                     jQuery(resultvoting).html(dataR.message); | ||||
|                                 } else if(dataR.status == 0){ | ||||
|                                     jQuery(resultvoting).html(dataR.error); | ||||
|                                 } else { | ||||
|                                     jQuery(resultvoting).text("'.Text::_('COM_PHOCAGALLERY_ERROR_REQUESTING_ITEM').'"); | ||||
|                                 } | ||||
|                                  | ||||
|                                 if (m == 2) { | ||||
|                                     //var wall = new Masonry(document.getElementById(container)); | ||||
|                                 } | ||||
|                             }, | ||||
|                              | ||||
|                             error: function(){ | ||||
|                                 jQuery(resultvoting).text( "'.Text::_('COM_PHOCAGALLERY_ERROR_REQUESTING_ITEM').'"); | ||||
|                              | ||||
|                                 if (m == 2) { | ||||
|                                     //var wall = new Masonry(document.getElementById(container)); | ||||
|                                 } | ||||
|                             } | ||||
|              | ||||
|                         }) | ||||
|                          | ||||
|     | ||||
|                          | ||||
|                     } else if(data.status == 0){ | ||||
|                         jQuery(result).html(data.error); | ||||
|                     } else { | ||||
|                         jQuery(result).text("'.Text::_('COM_PHOCAGALLERY_ERROR_REQUESTING_ITEM').'"); | ||||
|                     } | ||||
|                      | ||||
|                     if (m == 2) { | ||||
| 					    //var wall = new Masonry(document.getElementById(container)); | ||||
| 				    } | ||||
|                 }, | ||||
|                  | ||||
|                 error: function(){ | ||||
|                     jQuery(result).text( "'.Text::_('COM_PHOCAGALLERY_ERROR_REQUESTING_ITEM').'"); | ||||
| 				 | ||||
| 				    if (m == 2) { | ||||
| 					    //var wall = new Masonry(document.getElementById(container)); | ||||
| 				    } | ||||
|                 } | ||||
|  | ||||
|             }) | ||||
|         }'; | ||||
| 		$document->addScriptDeclaration($js); | ||||
|  | ||||
|  | ||||
|  | ||||
|        /* | ||||
|  | ||||
|         $js .= ' | ||||
| 		function pgRating(id, vote, m, container) { | ||||
|  | ||||
| 			var result 			= "pg-cv-vote-img-result" + id; | ||||
| 			var resultvoting 	= "pg-cv-vote-img" + id; | ||||
| 			var pgRequest = new Request.JSON({ | ||||
| 			url: "'.$url.'", | ||||
| 			method: "post", | ||||
|  | ||||
| 			onRequest: function(){ | ||||
| 				$(result).set("html", "'.addslashes($imgLoadingHTML).'"); | ||||
| 				if (m == 2) { | ||||
| 					//var wall = new Masonry(document.getElementById(container)); | ||||
| 				} | ||||
| 			 }, | ||||
|  | ||||
| 			onComplete: function(jsonObj) { | ||||
| 				try { | ||||
| 					var r = jsonObj; | ||||
| 				} catch(e) { | ||||
| 					var r = false; | ||||
| 				} | ||||
|  | ||||
| 				if (r) { | ||||
| 					if (r.error == false) { | ||||
| 						$(result).set("text", jsonObj.message); | ||||
|  | ||||
| 						// Refreshing Voting | ||||
| 						var pgRequestRefresh = new Request.JSON({ | ||||
| 							url: "'.$urlRefresh.'", | ||||
| 							method: "post", | ||||
|  | ||||
| 							onComplete: function(json2Obj) { | ||||
| 								try { | ||||
| 									var rr = json2Obj; | ||||
| 								} catch(e) { | ||||
| 									var rr = false; | ||||
| 								} | ||||
|  | ||||
| 								if (rr) { | ||||
| 									$(resultvoting).set("html", json2Obj.message); | ||||
| 								} else { | ||||
| 									$(resultvoting).set("text", "'.Text::_('COM_PHOCAGALLERY_ERROR_REQUESTING_ITEM').'"); | ||||
| 								} | ||||
|  | ||||
| 								if (m == 2) { | ||||
| 									//var wall = new Masonry(document.getElementById(container)); | ||||
| 								} | ||||
| 							}, | ||||
|  | ||||
| 							onFailure: function() { | ||||
| 								$(resultvoting).set("text", "'.Text::_('COM_PHOCAGALLERY_ERROR_REQUESTING_ITEM').'"); | ||||
| 								if (m == 2) { | ||||
| 									//var wall = new Masonry(document.getElementById(container)); | ||||
| 								} | ||||
| 							} | ||||
| 						}) | ||||
|  | ||||
| 						pgRequestRefresh.send({ | ||||
| 							data: {"ratingId": id, "ratingVote": vote, "format":"json"} | ||||
| 						}); | ||||
| 						//End refreshing voting | ||||
|  | ||||
| 					} else { | ||||
| 						$(result).set("html", r.error); | ||||
| 					} | ||||
| 				} else { | ||||
| 					$(result).set("text", "'.Text::_('COM_PHOCAGALLERY_ERROR_REQUESTING_ITEM').'"); | ||||
| 				} | ||||
|  | ||||
| 				if (m == 2) { | ||||
| 					//var wall = new Masonry(document.getElementById(container)); | ||||
| 				} | ||||
| 			}, | ||||
|  | ||||
| 			onFailure: function() { | ||||
| 				$(result).set("text", "'.Text::_('COM_PHOCAGALLERY_ERROR_REQUESTING_ITEM').'"); | ||||
|  | ||||
| 				if (m == 2) { | ||||
| 					//var wall = new Masonry(document.getElementById(container)); | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			}) | ||||
|  | ||||
| 			pgRequest.send({ | ||||
| 				data: {"ratingId": id, "ratingVote": vote, "format":"json"}, | ||||
| 			}); | ||||
|  | ||||
| 		};'; | ||||
|  | ||||
| 		//$js .= '});'; | ||||
|  | ||||
| 		$js .= "\n" . '//-->' . "\n" .'</script>'; | ||||
| 		$document->addCustomTag($js);*/ | ||||
|  | ||||
|  | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -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> </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> </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> </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; | ||||
| 	} | ||||
| } | ||||
| @ -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(); | ||||
| 	} | ||||
|  | ||||
| } | ||||
| ?> | ||||
| @ -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; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -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">'//.' ' | ||||
| 				//.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">'//.' ' | ||||
| 				.'<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) | ||||
| 	} | ||||
|  | ||||
| } | ||||
| ?> | ||||
| @ -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; | ||||
| 	} | ||||
|  | ||||
| } | ||||
| ?> | ||||
| @ -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> </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); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| ?> | ||||
| @ -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 ''; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| ?> | ||||
| @ -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; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -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: \'© <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: \'© <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: \'© <a href="https://www.thunderforest.com/" target="_blank">Thunderforest</a>, © <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 © <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: © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>, <a href="https://viewfinderpanoramas.org" target="_blank">SRTM</a> | Map style: © <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: \'© <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: \'© <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: \'© <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: \'© <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)); | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -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> </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.' %</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.' %</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.' %</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.'¤timg='.$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.'¤timg='.$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.'¤timg='.$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; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -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>' | ||||
|                         . ' ' . $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>'; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -0,0 +1,181 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @package   Phoca Gallery | ||||
|  * @author    Jan Pavelka - https://www.phoca.cz | ||||
|  * @copyright Copyright (C) Jan Pavelka https://www.phoca.cz | ||||
|  * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later | ||||
|  * @cms       Joomla | ||||
|  * @copyright Copyright (C) Open Source Matters. All rights reserved. | ||||
|  * @license   http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php | ||||
|  */ | ||||
| defined('_JEXEC') or die; | ||||
| use Joomla\CMS\Factory; | ||||
| use Joomla\CMS\HTML\HTMLHelper; | ||||
| use Joomla\CMS\Component\ComponentHelper; | ||||
|  | ||||
| class PhocaGalleryTag | ||||
| { | ||||
| 	public static function getTags($imgId, $select = 0) { | ||||
|  | ||||
| 		$db =Factory::getDBO(); | ||||
|  | ||||
| 		if ($select == 1) { | ||||
| 			$query = 'SELECT r.tagid'; | ||||
| 		} else { | ||||
| 			$query = 'SELECT a.*'; | ||||
| 		} | ||||
| 		$query .= ' FROM #__phocagallery_tags AS a' | ||||
| 				//.' LEFT JOIN #__phocagallery AS f ON f.id = r.imgid' | ||||
| 				.' LEFT JOIN #__phocagallery_tags_ref AS r ON a.id = r.tagid' | ||||
| 			    .' WHERE r.imgid = '.(int) $imgId | ||||
| 				.' ORDER BY a.id'; | ||||
| 		$db->setQuery($query); | ||||
|  | ||||
|  | ||||
|  | ||||
| 		if ($select == 1) { | ||||
| 			$tags = $db->loadColumn(); | ||||
| 		} else { | ||||
| 			$tags = $db->loadObjectList(); | ||||
| 		} | ||||
|  | ||||
| 		return $tags; | ||||
| 	} | ||||
|  | ||||
| 	public static function storeTags($tagsArray, $imgId) { | ||||
|  | ||||
|  | ||||
| 		if ((int)$imgId > 0) { | ||||
| 			$db =Factory::getDBO(); | ||||
| 			$query = ' DELETE ' | ||||
| 					.' FROM #__phocagallery_tags_ref' | ||||
| 					. ' WHERE imgid = '. (int)$imgId; | ||||
| 			$db->setQuery($query); | ||||
| 			$db->execute(); | ||||
|  | ||||
| 			if (!empty($tagsArray)) { | ||||
|  | ||||
| 				$values 		= array(); | ||||
| 				$valuesString 	= ''; | ||||
|  | ||||
| 				foreach($tagsArray as $k => $v) { | ||||
| 					$values[] = ' ('.(int)$imgId.', '.(int)$v.')'; | ||||
| 				} | ||||
|  | ||||
| 				if (!empty($values)) { | ||||
| 					$valuesString = implode(',', $values); | ||||
|  | ||||
| 					$query = ' INSERT INTO #__phocagallery_tags_ref (imgid, tagid)' | ||||
| 								.' VALUES '.(string)$valuesString; | ||||
|  | ||||
| 					$db->setQuery($query); | ||||
| 					$db->execute(); | ||||
|  | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	public static function getAllTagsSelectBox($name, $id, $activeArray, $javascript = NULL, $order = 'id' ) { | ||||
|  | ||||
| 		$db =Factory::getDBO(); | ||||
| 		$query = 'SELECT a.id AS value, a.title AS text' | ||||
| 				.' FROM #__phocagallery_tags AS a' | ||||
| 				. ' ORDER BY '. $order; | ||||
| 		$db->setQuery($query); | ||||
|  | ||||
|  | ||||
|  | ||||
| 		$tags = $db->loadObjectList(); | ||||
|  | ||||
| 		$tagsO = HTMLHelper::_('select.genericlist', $tags, $name, 'class="form-control" size="4" multiple="multiple"'. $javascript, 'value', 'text', $activeArray, $id); | ||||
|  | ||||
| 		return $tagsO; | ||||
| 	} | ||||
|  | ||||
| 	public static function getAllTags($order = 'id' ) { | ||||
|  | ||||
| 		$db =Factory::getDBO(); | ||||
| 		$query = 'SELECT a.id AS value, a.title AS text' | ||||
| 				.' FROM #__phocagallery_tags AS a' | ||||
| 				. ' ORDER BY '. $order; | ||||
| 		$db->setQuery($query); | ||||
|  | ||||
|  | ||||
|  | ||||
| 		$tags = $db->loadObjectList(); | ||||
|  | ||||
| 		return $tags; | ||||
| 	} | ||||
|  | ||||
| 	public static function displayTags($imgId, $popupLink = 0) { | ||||
|  | ||||
| 		$o 		= ''; | ||||
| 		$db 	= Factory::getDBO(); | ||||
| 		$params = ComponentHelper::getParams('com_phocagallery') ; | ||||
|  | ||||
| 		$query = 'SELECT a.id, a.title, a.link_ext, a.link_cat' | ||||
| 		.' FROM #__phocagallery_tags AS a' | ||||
| 		.' LEFT JOIN #__phocagallery_tags_ref AS r ON r.tagid = a.id' | ||||
| 		.' WHERE r.imgid = '.(int)$imgId; | ||||
|  | ||||
| 		$db->setQuery($query); | ||||
| 		$imgObject = $db->loadObjectList(); | ||||
|  | ||||
|  | ||||
|  | ||||
| 		/* | ||||
| 		if ($popupLink == 1) { | ||||
| 			$tl	= 0; | ||||
| 		} else  { | ||||
| 			$tl	= $params->get( 'tags_links', 0 ); | ||||
| 		}*/ | ||||
|  | ||||
| 		$targetO = ''; | ||||
| 		if ($popupLink == 1) { | ||||
| 			$targetO = 'target="_parent"'; | ||||
| 		} | ||||
| 		$tl	= $params->get( 'tags_links', 0 ); | ||||
|  | ||||
| 		foreach ($imgObject as $k => $v) { | ||||
| 			$o .= '<span class="ph-tag-'.(int)$v->id.'">'; | ||||
| 			if ($tl == 0) { | ||||
| 				$o .= $v->title; | ||||
| 			} else if ($tl == 1) { | ||||
| 				if ($v->link_ext != '') { | ||||
| 					$o .= '<a href="'.$v->link_ext.'" '.$targetO.'>'.$v->title.'</a>'; | ||||
| 				} else { | ||||
| 					$o .= $v->title; | ||||
| 				} | ||||
| 			} else if ($tl == 2) { | ||||
|  | ||||
| 				if ($v->link_cat != '') { | ||||
| 					$query = 'SELECT a.id, a.alias' | ||||
| 					.' FROM #__phocagallery_categories AS a' | ||||
| 					.' WHERE a.id = '.(int)$v->link_cat; | ||||
|  | ||||
| 					$db->setQuery($query, 0, 1); | ||||
| 					$category = $db->loadObject(); | ||||
|  | ||||
|  | ||||
| 					if (isset($category->id) && isset($category->alias)) { | ||||
| 						$link = PhocaGalleryRoute::getCategoryRoute($category->id, $category->alias); | ||||
| 						$o .= '<a href="'.$link.'" '.$targetO.'>'.$v->title.'</a>'; | ||||
| 					} else { | ||||
| 						$o .= $v->title; | ||||
| 					} | ||||
| 				} else { | ||||
| 					$o .= $v->title; | ||||
| 				} | ||||
| 			} else if ($tl == 3) { | ||||
| 				$link = PhocaGalleryRoute::getCategoryRouteByTag($v->id); | ||||
| 				$o .= '<a href="'.$link.'" '.$targetO.'>'.$v->title.'</a>'; | ||||
| 			} | ||||
|  | ||||
| 			$o .= '</span> '; | ||||
| 		} | ||||
|  | ||||
| 		return $o; | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -0,0 +1,136 @@ | ||||
| <?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\Filter\OutputFilter; | ||||
| use Joomla\CMS\Factory; | ||||
| use Joomla\String\StringHelper; | ||||
|  | ||||
| class PhocaGalleryText | ||||
| { | ||||
| 	public static function wordDelete($string,$length,$end = '...') { | ||||
| 		if (StringHelper::strlen($string) < $length || StringHelper::strlen($string) == $length) { | ||||
| 			return $string; | ||||
| 		} else { | ||||
| 			return StringHelper::substr($string, 0, $length) . $end; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public static function wordDeleteWhole($string,$length,$end = '...') { | ||||
| 		if (StringHelper::strlen($string) < $length || StringHelper::strlen($string) == $length) { | ||||
| 			return $string; | ||||
| 		} else { | ||||
| 			preg_match('/(.{' . $length . '}.*?)\b/', $string, $matches); | ||||
| 			return rtrim($matches[1]) . $end; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	public static function strTrimAll($input) { | ||||
| 		$output	= ''; | ||||
| 	    $input	= trim((string)$input); | ||||
| 	    for($i=0;$i<strlen($input);$i++) { | ||||
| 	        if(substr($input, $i, 1) != " ") { | ||||
| 	            $output .= trim((string)substr($input, $i, 1)); | ||||
| 	        } else { | ||||
| 	            $output .= " "; | ||||
| 	        } | ||||
| 	    } | ||||
| 	    return $output; | ||||
| 	} | ||||
|  | ||||
| 	public static function getAliasName($name) { | ||||
|  | ||||
| 		$paramsC		= ComponentHelper::getParams( 'com_phocagallery' ); | ||||
| 		$alias_iconv	= $paramsC->get( 'alias_iconv', 0 ); | ||||
|  | ||||
| 		$iconv = 0; | ||||
| 		if ($alias_iconv == 1) { | ||||
| 			if (function_exists('iconv')) { | ||||
| 				$name = preg_replace('~[^\\pL0-9_.]+~u', '-', $name); | ||||
| 				$name = trim($name, "-"); | ||||
| 				$name = iconv("utf-8", "us-ascii//TRANSLIT", $name); | ||||
| 				$name = strtolower($name); | ||||
| 				$name = preg_replace('~[^-a-z0-9_.]+~', '', $name); | ||||
| 				$iconv = 1; | ||||
| 			} else { | ||||
| 				$iconv = 0; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		if ($iconv == 0) { | ||||
| 			$name = OutputFilter::stringURLSafe($name); | ||||
| 		} | ||||
|  | ||||
| 		if(trim(str_replace('-','',$name)) == '') { | ||||
| 			Factory::getDate()->format("Y-m-d-H-i-s"); | ||||
| 		} | ||||
| 		return $name; | ||||
| 	} | ||||
|  | ||||
| 	public static function filterValue($string, $type = 'html') { | ||||
|  | ||||
| 		switch ($type) { | ||||
|  | ||||
| 			case 'url': | ||||
| 				return rawurlencode($string); | ||||
| 			break; | ||||
|  | ||||
| 			case 'number': | ||||
| 				return preg_replace( '/[^.0-9]/', '', $string ); | ||||
| 			break; | ||||
|  | ||||
| 			case 'number2': | ||||
| 				//return preg_replace( '/[^0-9\.,+-]/', '', $string ); | ||||
| 				return preg_replace( '/[^0-9\.,-]/', '', $string ); | ||||
| 			break; | ||||
|  | ||||
| 			case 'alphanumeric': | ||||
| 				return preg_replace("/[^a-zA-Z0-9]+/", '', $string); | ||||
| 			break; | ||||
|  | ||||
| 			case 'alphanumeric2': | ||||
| 				return preg_replace("/[^\\w-]/", '', $string);// Alphanumeric plus _  - | ||||
| 			break; | ||||
|  | ||||
| 			case 'alphanumeric3': | ||||
| 				return preg_replace("/[^\\w.-]/", '', $string);// Alphanumeric plus _ . - | ||||
| 			break; | ||||
|  | ||||
| 			case 'folder': | ||||
| 			case 'file': | ||||
| 				$string =  preg_replace('/[\"\*\/\\\:\<\>\?\'\|]+/', '', $string); | ||||
| 				return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); | ||||
| 			break; | ||||
|  | ||||
| 			case 'folderpath': | ||||
| 			case 'filepath': | ||||
| 				if (!isset($string)) { | ||||
| 					return ''; | ||||
| 				} | ||||
| 				$string = preg_replace('/[\"\*\:\<\>\?\'\|]+/', '', $string); | ||||
| 				return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); | ||||
| 			break; | ||||
|  | ||||
| 			case 'text': | ||||
| 				return htmlspecialchars(strip_tags($string), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); | ||||
| 			break; | ||||
|  | ||||
| 			case 'html': | ||||
| 			default: | ||||
| 				return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); | ||||
| 			break; | ||||
|  | ||||
| 		} | ||||
|  | ||||
|     } | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -0,0 +1,64 @@ | ||||
| <?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\Registry\Registry; | ||||
|  | ||||
| class PhocaGalleryUser | ||||
| { | ||||
| 	public static function getUserLang( $formName = 'language') { | ||||
| 		$user 		= Factory::getUser(); | ||||
| 		$paramsC 	= ComponentHelper::getParams('com_phocagallery') ; | ||||
| 		$userLang	= $paramsC->get( 'user_ucp_lang', 1 ); | ||||
| 		 | ||||
| 		$o = array(); | ||||
| 		 | ||||
| 		switch ($userLang){ | ||||
| 			case 2: | ||||
| 				$registry = new Registry; | ||||
| 				$registry->loadString($user->params); | ||||
| 				$o['lang'] 		= $registry->get('language','*'); | ||||
| 				 | ||||
| 				$o['langinput'] = '<input type="hidden" name="'.$formName.'" value="'.$o['lang'].'" />'; | ||||
| 			break; | ||||
| 			 | ||||
| 			case 3: | ||||
| 				$o['lang'] 		= Factory::getLanguage()->getTag(); | ||||
| 				$o['langinput'] = '<input type="hidden" name="'.$formName.'" value="'.$o['lang'].'" />'; | ||||
| 			break; | ||||
| 			 | ||||
| 			default: | ||||
| 			case 1: | ||||
| 				$o['lang'] 		= '*'; | ||||
| 				$o['langinput'] = '<input type="hidden" name="'.$formName.'" value="*" />'; | ||||
| 			break; | ||||
| 		} | ||||
| 		return $o; | ||||
| 	} | ||||
| 	 | ||||
| 	public static function getUserAvatar($userId) { | ||||
| 	 | ||||
| 		$db = Factory::getDBO(); | ||||
| 		 | ||||
| 		$query = 'SELECT a.*' | ||||
| 		. ' FROM #__phocagallery_user AS a' | ||||
| 		. ' WHERE a.userid = '.(int)$userId; | ||||
| 		$db->setQuery( $query ); | ||||
| 		$avatar = $db->loadObject(); | ||||
| 		if(isset($avatar->id)) { | ||||
| 			return $avatar; | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
| 	 | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,26 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @package   Phoca Gallery | ||||
|  * @author    Jan Pavelka - https://www.phoca.cz | ||||
|  * @copyright Copyright (C) Jan Pavelka https://www.phoca.cz | ||||
|  * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later | ||||
|  * @cms       Joomla | ||||
|  * @copyright Copyright (C) Open Source Matters. All rights reserved. | ||||
|  * @license   http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php | ||||
|  */ | ||||
| defined( '_JEXEC' ) or die( 'Restricted access' ); | ||||
| use Joomla\CMS\Language\Text; | ||||
|  | ||||
| class PhocaGalleryException | ||||
| { | ||||
| 	 | ||||
| 	public static function renderErrorInfo ($msg, $jText = false){ | ||||
| 	 | ||||
| 		if ($jText) { | ||||
| 			return '<div class="pg-error-info">'.Text::_($msg).'</div>'; | ||||
| 		} else { | ||||
| 			return '<div class="pg-error-info">'.$msg.'</div>'; | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,73 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @package   Phoca Gallery | ||||
|  * @author    Jan Pavelka - https://www.phoca.cz | ||||
|  * @copyright Copyright (C) Jan Pavelka https://www.phoca.cz | ||||
|  * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later | ||||
|  * @cms       Joomla | ||||
|  * @copyright Copyright (C) Open Source Matters. All rights reserved. | ||||
|  * @license   http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php | ||||
|  */ | ||||
| defined('_JEXEC') or die; | ||||
| use Joomla\CMS\Factory; | ||||
| class PhocaGalleryExtension | ||||
| { | ||||
| 	private static $extension = array(); | ||||
| 	 | ||||
| 	private function __construct(){} | ||||
| 	 | ||||
| 	/** | ||||
| 	 * Get information about extension. | ||||
| 	 * | ||||
| 	 * @param	string	Extension element (com_cpanel, com_admin, ...) | ||||
| 	 * @param	string	Extension type (component, plugin, module, ...) | ||||
| 	 * @param	string	Folder type (content, editors, search, ...) | ||||
| 	 * | ||||
| 	 * @return	int ( 0 ... extension not installed | ||||
| 	 *                1 ... extension installed and enabled | ||||
| 	 *                2 ... extension installed but not enabled ) | ||||
| 	 */ | ||||
|  | ||||
| 	public static function getExtensionInfo( $element = null, $type = 'component', $folder = '' ) { | ||||
| 		if( is_null( $element ) ) { | ||||
| 			throw new Exception('Function Error: No element added', 500); | ||||
| 			return false; | ||||
| 		} | ||||
| 		if( !array_key_exists( $element, self::$extension ) ) { | ||||
| 			 | ||||
| 			$db		= Factory::getDbo(); | ||||
| 			$query	= $db->getQuery(true); | ||||
| 			//$query->select('extension_id AS "id", element AS "element", enabled'); | ||||
| 			if ($type == 'component'){ | ||||
| 				$query->select('extension_id AS id, element AS "option", params, enabled'); | ||||
| 			} else { | ||||
| 				$query->select('extension_id AS "id", element AS "element", params, enabled'); | ||||
| 			} | ||||
| 			$query->from('#__extensions'); | ||||
| 			$query->where('`type` = '.$db->quote($type)); | ||||
| 			if ($folder != '') { | ||||
| 				$query->where('`folder` = '.$db->quote($folder)); | ||||
| 			} | ||||
| 			$query->where('`element` = '.$db->quote($element)); | ||||
| 			$db->setQuery($query); | ||||
| 			 | ||||
| 			$cache 			= Factory::getCache('_system_phocagallery','callback'); | ||||
| 			$extensionData	=  $cache->get(array($db, 'loadObject'), null, $element, false); | ||||
| 			if (isset($extensionData->enabled) && $extensionData->enabled == 1) { | ||||
| 				self::$extension[$element] = 1; | ||||
| 			} else if(isset($extensionData->enabled) && $extensionData->enabled == 0) { | ||||
| 				self::$extension[$element] = 2; | ||||
| 			} else { | ||||
| 				self::$extension[$element] = 0; | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		return self::$extension[$element]; | ||||
| 		 | ||||
| 	} | ||||
| 	public final function __clone() { | ||||
| 		throw new Exception('Function Error: Cannot clone instance of Singleton pattern', 500); | ||||
| 		return false; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -0,0 +1,55 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @package   Phoca Gallery | ||||
|  * @author    Jan Pavelka - https://www.phoca.cz | ||||
|  * @copyright Copyright (C) Jan Pavelka https://www.phoca.cz | ||||
|  * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later | ||||
|  * @cms       Joomla | ||||
|  * @copyright Copyright (C) Open Source Matters. All rights reserved. | ||||
|  * @license   http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php | ||||
|  */ | ||||
| defined( '_JEXEC' ) or die( 'Restricted access' ); | ||||
|  | ||||
|  | ||||
| /* | ||||
|  * These are advanced settings | ||||
|  * because not all possible settings | ||||
|  * can be saved in parameters (because of different limitations) | ||||
|  */ | ||||
| class PhocaGallerySettings | ||||
| { | ||||
| 	private static $settings = array(); | ||||
| 	 | ||||
| 	private function __construct(){} | ||||
|  | ||||
| 	public static function getAdvancedSettings( $element = null ) { | ||||
| 		if( is_null( $element ) ) { | ||||
| 			throw new Exception('Function Error: No element added', 500); | ||||
| 			return false; | ||||
| 		} | ||||
| 		if( !array_key_exists( $element, self::$settings ) ) { | ||||
| 			 | ||||
| 			$params = array(); | ||||
| 			// ============================= | ||||
| 			$params['geozoom']			= 8; | ||||
| 			$params['youtubeheight']	= 360; | ||||
| 			$params['youtubewidth']		= 480; | ||||
| 			// ============================= | ||||
| 			 | ||||
| 			 | ||||
| 			if (isset($params[$element])) { | ||||
| 				self::$settings[$element] = $params[$element]; | ||||
| 			} else { | ||||
| 				self::$settings[$element] = ''; | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		return self::$settings[$element]; | ||||
| 		 | ||||
| 	} | ||||
| 	public final function __clone() { | ||||
| 		throw new Exception('Function Error: Cannot clone instance of Singleton pattern', 500); | ||||
| 		return false; | ||||
| 	} | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1,187 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @package   Phoca Gallery | ||||
|  * @author    Jan Pavelka - https://www.phoca.cz | ||||
|  * @copyright Copyright (C) Jan Pavelka https://www.phoca.cz | ||||
|  * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later | ||||
|  * @cms       Joomla | ||||
|  * @copyright Copyright (C) Open Source Matters. All rights reserved. | ||||
|  * @license   http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php | ||||
|  */ | ||||
|  | ||||
| use Joomla\CMS\Component\ComponentHelper; | ||||
| use Joomla\CMS\Factory; | ||||
| use Joomla\CMS\Plugin\PluginHelper; | ||||
|  | ||||
| defined( '_JEXEC' ) or die( 'Restricted access' ); | ||||
|  | ||||
| class PhocaGalleryUtils | ||||
| { | ||||
|  | ||||
| 	public static function getExtInfo() { | ||||
|  | ||||
|         PluginHelper::importPlugin('phocatools'); | ||||
|         $results = Factory::getApplication()->triggerEvent('onPhocatoolsOnDisplayInfo', array('NzI5NzY5NTcxMTc=')); | ||||
|  | ||||
|         if (isset($results[0]) && $results[0] === true) { | ||||
|             return ''; | ||||
|         } | ||||
| 	    return '<div style="display:block;color:#ccc;text-align:right;">Powered by <a href="https://www.phoca.cz/phocagallery">Phoca Gallery</a></div>'; | ||||
|     } | ||||
|  | ||||
| 	public static function htmlToRgb($clr) { | ||||
| 		if ($clr[0] == '#') { | ||||
| 			$clr = substr($clr, 1); | ||||
| 		} | ||||
|  | ||||
| 		if (strlen($clr) == 6) { | ||||
| 			list($r, $g, $b) = array($clr[0].$clr[1],$clr[2].$clr[3],$clr[4].$clr[5]); | ||||
| 		} else if (strlen($clr) == 3) { | ||||
| 			list($r, $g, $b) = array($clr[0].$clr[0], $clr[1].$clr[1], $clr[2].$clr[2]); | ||||
| 		} else { | ||||
| 			$r = $g = $b = 255; | ||||
| 		} | ||||
|  | ||||
| 		$color[0] = hexdec($r); | ||||
| 		$color[1] = hexdec($g); | ||||
| 		$color[2] = hexdec($b); | ||||
|  | ||||
| 		return $color; | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * Source: http://php.net/manual/en/function.ini-get.php | ||||
| 	 */ | ||||
| 	public static function iniGetBool($a) { | ||||
| 		$b = ini_get($a); | ||||
| 		switch (strtolower($b)) { | ||||
| 			case 'on': | ||||
| 			case 'yes': | ||||
| 			case 'true': | ||||
| 			return 'assert.active' !== $a; | ||||
|  | ||||
| 			case 'stdout': | ||||
| 			case 'stderr': | ||||
| 			return 'display_errors' === $a; | ||||
|  | ||||
| 			Default: | ||||
| 			return (bool) (int) $b; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public static function setQuestionmarkOrAmp($url) { | ||||
| 		$isThereQMR = false; | ||||
| 		$isThereQMR = preg_match("/\?/i", $url); | ||||
| 		if ($isThereQMR) { | ||||
| 			return '&'; | ||||
| 		} else { | ||||
| 			return '?'; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public static function toArray($value = FALSE) { | ||||
| 		if ($value == FALSE) { | ||||
| 			return array(0 => 0); | ||||
| 		} else if (empty($value)) { | ||||
| 			return array(0 => 0); | ||||
| 		} else if (is_array($value)) { | ||||
| 			return $value; | ||||
| 		} else { | ||||
| 			return array(0 => $value); | ||||
| 		} | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	public static function setMessage($new = '', $current = '') { | ||||
|  | ||||
| 		$message = $current; | ||||
| 		if($new != '') { | ||||
| 			if ($current != '') { | ||||
| 				$message .= '<br />'; | ||||
| 			} | ||||
| 			$message .= $new; | ||||
| 		} | ||||
| 		return $message; | ||||
| 	} | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| 	public static function filterInput($string) { | ||||
| 		if (strpos($string, '"') !== false) { | ||||
| 			$string = str_replace(array('=', '<'), '', $string); | ||||
| 		} | ||||
| 		return $string; | ||||
| 	} | ||||
|  | ||||
| 	public static function isURLAddress($url) { | ||||
| 		return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url); | ||||
| 	} | ||||
|  | ||||
| 	public static function isEnabledMultiboxFeature($feature) { | ||||
|  | ||||
| 		$app		= Factory::getApplication(); | ||||
| 		$params		= $app->getParams(); | ||||
|  | ||||
| 		$enable_multibox				= $params->get( 'enable_multibox', 0); | ||||
| 		$display_multibox				= $params->get( 'display_multibox', array(1,2)); | ||||
|  | ||||
| 		if ($enable_multibox == 1 && in_array($feature,$display_multibox)) { | ||||
| 			return true; | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	public static function setVars( $task = '') { | ||||
|  | ||||
| 		$a			= array(); | ||||
| 		$app		= Factory::getApplication(); | ||||
| 		$a['o'] 	= htmlspecialchars(strip_tags($app->input->get('option'))); | ||||
| 		$a['c'] 	= str_replace('com_', '', $a['o']); | ||||
| 		$a['n'] 	= 'Phoca' . ucfirst(str_replace('com_phoca', '', $a['o'])); | ||||
| 		$a['l'] 	= strtoupper($a['o']); | ||||
| 		$a['i']		= 'media/'.$a['o'].'/images/administrator/'; | ||||
| 		$a['ja']	= 'media/'.$a['o'].'/js/administrator/'; | ||||
| 		$a['jf']	= 'media/'.$a['o'].'/js/'; | ||||
| 		$a['s']		= 'media/'.$a['o'].'/css/administrator/'.$a['c'].'.css'; | ||||
| 		$a['task']	= $a['c'] . htmlspecialchars(strip_tags($task)); | ||||
| 		$a['tasks'] = $a['task']. 's'; | ||||
| 		return $a; | ||||
| 	} | ||||
|  | ||||
| 	public static function getIntFromString($string) { | ||||
|  | ||||
| 		if (empty($string)) { | ||||
| 			return 0; | ||||
| 		} | ||||
| 		$int	= '';//$int = 0 | ||||
| 		$parts 	= explode(':', $string); | ||||
| 		if (isset($parts[0])) { | ||||
| 			$int = (int)$parts[0]; | ||||
| 		} | ||||
| 		return $int; | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 public static function getIp() { | ||||
| 		$params 				= ComponentHelper::getParams('com_phocagallery'); | ||||
| 		$store_ip				= $params->get( 'store_ip', 0 ); | ||||
|  | ||||
| 		if ($store_ip == 0) { | ||||
| 			return ''; | ||||
| 		} | ||||
|  | ||||
| 		$ip = false; | ||||
| 		if(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] != getenv('SERVER_ADDR')) { | ||||
| 			$ip  = $_SERVER['REMOTE_ADDR']; | ||||
| 		} else { | ||||
| 			$ip  = getenv('HTTP_X_FORWARDED_FOR'); | ||||
| 		} | ||||
| 		if (!$ip) { | ||||
| 			$ip = $_SERVER['REMOTE_ADDR']; | ||||
| 		} | ||||
|  | ||||
| 		return $ip; | ||||
| 	}*/ | ||||
| } | ||||
| ?> | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -0,0 +1,140 @@ | ||||
| <?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\Factory; | ||||
|  | ||||
| class PhocaGalleryVirtueMart | ||||
| { | ||||
| 	public static function getVmLink($id, &$errorMsg) { | ||||
| 		 | ||||
| 		if (ComponentHelper::isEnabled('com_virtuemart', true)) { | ||||
| 			if ((int)$id < 1) { | ||||
| 				return ""; | ||||
| 			} | ||||
| 		} else { | ||||
| 			return ""; | ||||
| 		} | ||||
| 		 | ||||
| 		$db =Factory::getDBO(); | ||||
| 				 | ||||
| 		$query = 'SELECT c.virtuemart_category_id AS catid, a.virtuemart_product_id AS id, a.published AS published, a.product_in_stock AS product_in_stock' | ||||
| 		.' FROM #__virtuemart_product_categories AS c' | ||||
| 		.' LEFT JOIN #__virtuemart_products AS a ON a.virtuemart_product_id = c.virtuemart_product_id' | ||||
| 		.' WHERE c.virtuemart_product_id = '.(int)$id; | ||||
|  | ||||
| 		$db->setQuery($query, 0, 1); | ||||
| 		$product = $db->loadObject(); | ||||
| 		 | ||||
| 		 | ||||
| 		 | ||||
| 		$catPart = ''; | ||||
| 		if (!empty($product->catid)) { | ||||
| 			$catPart = '&virtuemart_category_id='.$product->catid; | ||||
| 		} | ||||
| 		 | ||||
| 		$itemId		= PhocaGalleryVirtueMart::_getVmItemid(); | ||||
| 		 | ||||
| 		$link = 'index.php?option=com_virtuemart&view=productdetails' | ||||
| 				.'&virtuemart_product_id='.(int)$id | ||||
| 				.$catPart | ||||
| 				.'&itemId='.(int)$itemId; | ||||
| 				 | ||||
| 				 | ||||
| 		// Check PUBLISHED		 | ||||
| 		if (isset($product->published) && $product->published == 0) { | ||||
| 			$errorMsg = 'VirtueMart Product Not Published'; | ||||
| 			return '';//don't display cart icon for unpublished product | ||||
| 		} | ||||
| 		 | ||||
| 		// Check Stock if check stock feature is enabled | ||||
| 		//$component			=	'com_virtuemart'; | ||||
| 		//$paramsC			= JComponentHelper::getParams($component) ; | ||||
| 		if (is_file( JPATH_ADMINISTRATOR .  '/components/com_virtuemart/helpers/config.php')) { | ||||
| 			 require_once( JPATH_ADMINISTRATOR  . '/components/com_virtuemart/helpers/config.php' ); | ||||
| 			  | ||||
| 			 VmConfig::loadConfig(); | ||||
| 			 if (VmConfig::get('check_stock',0) == 1) { | ||||
| 				// Check STOCK		 | ||||
| 				if (isset($product->product_in_stock) && $product->product_in_stock == 0) { | ||||
| 					$errorMsg = 'VirtueMart Product Not On Stock'; | ||||
| 					return '';//don't display cart icon for non stock products | ||||
| 				} | ||||
| 			 } | ||||
| 		} else { | ||||
| 			$errorMsg = 'VirtueMart Config Not Found'; | ||||
| 			return false; | ||||
| 		} | ||||
| 		return $link; | ||||
| 	} | ||||
|  | ||||
| 	 | ||||
| 	protected static function _getVmItemid() { | ||||
| 		 | ||||
| 		 | ||||
| 		 | ||||
| 		$db =Factory::getDBO();		 | ||||
| 		$query = 'SELECT a.id AS id, a.link as link' | ||||
| 		.' FROM #__menu AS a' | ||||
| 		.' WHERE a.link LIKE '.$db->Quote('%index.php?option=com_virtuemart%') | ||||
| 		.' AND published = 1'; | ||||
|  | ||||
| 		$db->setQuery($query); | ||||
| 		$vmLinks = $db->loadObjectList(); | ||||
| 		 | ||||
| 		 | ||||
| 		//$vmLinks[0]->link | ||||
| 		$itemId = 0; | ||||
| 		if (!empty($vmLinks)) { | ||||
| 			foreach($vmLinks as $k => $v) { | ||||
| 				if(isset($v->link) && $v->link == 'index.php?option=com_virtuemart&view=virtuemart') { | ||||
| 					//Found | ||||
| 					$itemId = $v->id; | ||||
| 					break; | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 			if ($itemId < 1) { | ||||
| 				//Not found - try to find next possible itemid | ||||
| 				foreach($vmLinks as $k => $v) { | ||||
| 					if(isset($v->link) && $v->link == 'index.php?option=com_virtuemart&view=categories') { | ||||
| 						//Found | ||||
| 						$itemId = $v->id; | ||||
| 						break; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 			if ($itemId < 1) { | ||||
| 				//Still Not found - try to find next possible itemid | ||||
| 				foreach($vmLinks as $k => $v) { | ||||
| 					if(isset($v->link) && strpos($v->link, 'index.php?option=com_virtuemart&view=category') !== false) { | ||||
| 						//Found | ||||
| 						$itemId = $v->id; | ||||
| 						break; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 			if ($itemId < 1) { | ||||
| 				//Still Not found - try to find next possible itemid | ||||
| 				foreach($vmLinks as $k => $v) { | ||||
| 					if(isset($v->link) && strpos($v->link, 'index.php?option=com_virtuemart&view=productdetails') !== false) { | ||||
| 						//Found | ||||
| 						$itemId = $v->id; | ||||
| 						break; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		return $itemId; | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1 @@ | ||||
| <html><body bgcolor="#FFFFFF"></body></html> | ||||
| @ -0,0 +1,250 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @package   Phoca Gallery | ||||
|  * @author    Jan Pavelka - https://www.phoca.cz | ||||
|  * @copyright Copyright (C) Jan Pavelka https://www.phoca.cz | ||||
|  * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later | ||||
|  * @cms       Joomla | ||||
|  * @copyright Copyright (C) Open Source Matters. All rights reserved. | ||||
|  * @license   http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php | ||||
|  */ | ||||
| defined('_JEXEC') or die; | ||||
| use Joomla\CMS\Language\Text; | ||||
| use Joomla\CMS\Component\ComponentHelper; | ||||
| use Joomla\CMS\Filesystem\File; | ||||
| jimport( 'joomla.filesystem.file' ); | ||||
|  | ||||
| class PhocaGalleryYoutube | ||||
| { | ||||
| 	public static function displayVideo($videoCode, $view = 0, $ywidth = 0, $yheight = 0) { | ||||
|  | ||||
| 		$o = ''; | ||||
| 		if ($videoCode != '' && PhocaGalleryUtils::isURLAddress($videoCode) ) { | ||||
|  | ||||
| 			$pos1 		= strpos($videoCode, 'https'); | ||||
| 			if ($pos1 !== false) { | ||||
| 				$shortvideoCode	= 'https://youtu.be/'; | ||||
| 			} else { | ||||
| 				$shortvideoCode	= 'http://youtu.be/'; | ||||
| 			} | ||||
|  | ||||
| 			$pos 		= strpos($videoCode, $shortvideoCode); | ||||
| 			if ($pos !== false) { | ||||
| 				$code 		= str_replace($shortvideoCode, '', $videoCode); | ||||
| 			} else { | ||||
| 				$codeArray 	= explode('=', $videoCode); | ||||
| 				$code 		= str_replace($codeArray[0].'=', '', $videoCode); | ||||
| 			} | ||||
|  | ||||
|  | ||||
|  | ||||
| 		/*	$youtubeheight	= PhocaGallerySettings::getAdvancedSettings('youtubeheight'); | ||||
| 			$youtubewidth	= PhocaGallerySettings::getAdvancedSettings('youtubewidth'); | ||||
|  | ||||
| 			if ((int)$ywidth > 0) { | ||||
| 				$youtubewidth	= (int)$ywidth; | ||||
| 			} | ||||
| 			if ((int)$yheight > 0) { | ||||
| 				$youtubeheight	= (int)$yheight; | ||||
| 			} */ | ||||
|  | ||||
|  | ||||
| 			/*$o .= '<object height="'.(int)$youtubeheight.'" width="'.(int)$youtubewidth.'">' | ||||
| 			.'<param name="movie" value="http://www.youtube.com/v/'.$code.'"></param>' | ||||
| 			.'<param name="allowFullScreen" value="true"></param>' | ||||
| 			.'<param name="allowscriptaccess" value="always"></param>' | ||||
| 			.'<embed src="http://www.youtube.com/v/'.$code.'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" height="'.(int)$youtubeheight.'" width="'.(int)$youtubewidth.'"></embed></object>';*/ | ||||
|  | ||||
|             // height="'.(int)$youtubeheight.'" width="'.(int)$youtubewidth.'" | ||||
| 			$o .= '<iframe src="//www.youtube.com/embed/'.$code.'" frameborder="0" allowfullscreen></iframe>'; | ||||
| 		} | ||||
|  | ||||
| 		return $o; | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	public static function getCode($url) { | ||||
|  | ||||
| 		$o = ''; | ||||
|  | ||||
| 		if ($url != '' && PhocaGalleryUtils::isURLAddress($url) ) { | ||||
| 			$shortvideoCode		= 'http://youtu.be/'; | ||||
| 			$shortvideoCode2	= 'https://youtu.be/'; | ||||
| 			$pos 		= strpos($url, $shortvideoCode); | ||||
| 			$pos2 		= strpos($url, $shortvideoCode2); | ||||
| 			if ($pos !== false) { | ||||
| 				$code 		= str_replace($shortvideoCode, '', $url); | ||||
| 			} else if ($pos2 !== false) { | ||||
| 				$code 		= str_replace($shortvideoCode2, '', $url); | ||||
| 			} else { | ||||
| 				$codeArray 	= explode('=', $url); | ||||
| 				$code 		= str_replace($codeArray[0].'=', '', $url); | ||||
| 			} | ||||
| 			return $code; | ||||
| 		} | ||||
| 		return $o; | ||||
| 	} | ||||
|  | ||||
| 	public static function importYtb($ytbLink, $folder, &$errorMsg = '') { | ||||
|  | ||||
| 		$ytbCode 	= str_replace("&feature=related","",PhocaGalleryYoutube::getCode(strip_tags($ytbLink))); | ||||
|  | ||||
| 		$ytb				= array(); | ||||
| 		$ytb['title']		= ''; | ||||
| 		$ytb['desc']		= ''; | ||||
| 		$ytb['filename']	= ''; | ||||
| 		$ytb['link']		= strip_tags($ytbLink); | ||||
|  | ||||
|  | ||||
| 		if(!function_exists("curl_init")){ | ||||
| 			$errorMsg = Text::_('COM_PHOCAGALLERY_YTB_NOT_LOADED_CURL'); | ||||
| 			return false; | ||||
| 		} else if ($ytbCode == '') { | ||||
| 			$errorMsg = Text::_('COM_PHOCAGALLERY_YTB_URL_NOT_CORRECT'); | ||||
| 			return false; | ||||
| 		} else { | ||||
|  | ||||
| 			$paramsC 	= ComponentHelper::getParams('com_phocagallery'); | ||||
| 			$key 		= $paramsC->get( 'youtube_api_key', '' ); | ||||
| 			$ssl 		= $paramsC->get( 'youtube_api_ssl', 1 ); | ||||
|  | ||||
| 			// Data | ||||
| 			//$cUrl		= curl_init("http://gdata.youtube.com/feeds/api/videos/".strip_tags($ytbCode)); | ||||
| 			$cUrl 		= curl_init('https://www.googleapis.com/youtube/v3/videos?id='.strip_tags($ytbCode).'&part=snippet&key='.strip_tags($key)); | ||||
|  | ||||
|  | ||||
| 			$ssl = 0; | ||||
|  | ||||
| 			if ($ssl == 0) { | ||||
| 				curl_setopt($cUrl, CURLOPT_SSL_VERIFYPEER, false); | ||||
| 			} else { | ||||
| 				curl_setopt($cUrl, CURLOPT_SSL_VERIFYPEER, true); | ||||
| 			} | ||||
|  | ||||
| 			curl_setopt($cUrl, CURLOPT_RETURNTRANSFER, 1); | ||||
|             $json		= curl_exec($cUrl); | ||||
|  | ||||
|             curl_close($cUrl); | ||||
|  | ||||
|  | ||||
|  | ||||
| 			$o 	= json_decode($json); | ||||
|  | ||||
|  | ||||
| 			if (!empty($o) && isset($o->error->message)) { | ||||
| 				$errorMsg = Text::_('COM_PHOCAGALLERY_YTB_ERROR_IMPORTING_DATA') . '('.strip_tags($o->error->message).')'; | ||||
| 				return false; | ||||
| 			} else if (!empty($o) && isset($o->items[0]->snippet)) { | ||||
| 				$oS = $o->items[0]->snippet; | ||||
|  | ||||
| 				if (isset($oS->title)) { | ||||
| 					$ytb['title'] = (string)$oS->title; | ||||
| 				} | ||||
|  | ||||
| 				if ($ytb['title'] == '' && isset($oS->localized->title)) { | ||||
| 					$ytb['title'] = (string)$oS->localized->title; | ||||
| 				} | ||||
|  | ||||
| 				if (isset($oS->description)) { | ||||
| 					$ytb['desc'] = (string)$oS->description; | ||||
| 				} | ||||
|  | ||||
| 				if ($ytb['desc'] == '' && isset($oS->localized->description)) { | ||||
| 					$ytb['desc'] = (string)$oS->localized->description; | ||||
| 				} | ||||
|  | ||||
| 				$img = ''; | ||||
|  | ||||
| 				if (isset($oS->thumbnails->standard->url)) { | ||||
| 					$cUrl		= curl_init(strip_tags((string)$oS->thumbnails->standard->url)); | ||||
| 				} else if (isset($oS->thumbnails->default->url)) { | ||||
| 					$cUrl		= curl_init(strip_tags((string)$oS->thumbnails->default->url)); | ||||
| 				} | ||||
| 				if (isset($cUrl) && $cUrl != '') { | ||||
|  | ||||
| 					if ($ssl == 0) { | ||||
| 						curl_setopt($cUrl, CURLOPT_SSL_VERIFYPEER, false); | ||||
| 					} else { | ||||
| 						curl_setopt($cUrl, CURLOPT_SSL_VERIFYPEER, true); | ||||
| 					} | ||||
| 					curl_setopt($cUrl,CURLOPT_RETURNTRANSFER,1); | ||||
| 					$img		= curl_exec($cUrl); | ||||
| 					curl_close($cUrl); | ||||
| 				} | ||||
|  | ||||
|  | ||||
|  | ||||
| 				$ytb['filename']	= $folder.strip_tags($ytbCode).'.jpg'; | ||||
|  | ||||
|  | ||||
| 				if ($img != '') { | ||||
| 					if (File::exists(JPATH_ROOT . '/images/phocagallery' . '/'. $ytb['filename'], $img)) { | ||||
| 						//$errorMsg = JText::_('COM_PHOCAGALLERY_YTB_ERROR_VIDEO_EXISTS'); | ||||
| 						//return false; | ||||
| 						//Overwrite the images | ||||
|  | ||||
| 					} | ||||
|  | ||||
| 					if (!File::write(JPATH_ROOT . '/images/phocagallery' . '/'. $ytb['filename'], $img)) { | ||||
| 						$errorMsg = Text::_('COM_PHOCAGALLERY_YTB_ERROR_WRITE_IMAGE'); | ||||
| 						return false; | ||||
| 					} | ||||
| 				} | ||||
|  | ||||
| 			} else { | ||||
| 				$errorMsg = Text::_('COM_PHOCAGALLERY_YTB_ERROR_IMPORTING_DATA'); | ||||
| 				return false; | ||||
| 			} | ||||
|  | ||||
|  | ||||
| 			// API 2 | ||||
| 			/*$xml 	= str_replace('<media:', '<phcmedia', $xml); | ||||
| 			$xml 	= str_replace('</media:', '</phcmedia', $xml); | ||||
|  | ||||
| 			$data 	= simplexml_load_file($file); | ||||
|  | ||||
| 			//Title | ||||
| 			if (isset($data->title)) { | ||||
| 				$ytb['title'] = (string)$data->title; | ||||
| 			} | ||||
|  | ||||
| 			if ($ytb['title'] == '' && isset($data->phcmediagroup->phcmediatitle)) { | ||||
| 				$ytb['title'] = (string)$data->phcmediagroup->phcmediatitle; | ||||
| 			} | ||||
|  | ||||
| 			if (isset($data->phcmediagroup->phcmediadescription)) { | ||||
| 				$ytb['desc'] = (string)$data->phcmediagroup->phcmediadescription; | ||||
| 			} | ||||
|  | ||||
| 			// Thumbnail | ||||
| 			if (isset($data->phcmediagroup->phcmediathumbnail[0]['url'])) { | ||||
| 				$cUrl		= curl_init(strip_tags((string)$data->phcmediagroup->phcmediathumbnail[0]['url'])); | ||||
| 				curl_setopt($cUrl,CURLOPT_RETURNTRANSFER,1); | ||||
| 				$img		= curl_exec($cUrl); | ||||
| 				curl_close($cUrl); | ||||
| 			} | ||||
|  | ||||
| 			if ($img != '') { | ||||
| 				$cUrl		= curl_init("http://img.youtube.com/vi/".strip_tags($ytbCode)."/0.jpg"); | ||||
| 				curl_setopt($cUrl,CURLOPT_RETURNTRANSFER,1); | ||||
| 				$img		= curl_exec($cUrl); | ||||
| 				curl_close($cUrl); | ||||
| 			} | ||||
|  | ||||
| 			$ytb['filename']	= $folder.strip_tags($ytbCode).'.jpg'; | ||||
|  | ||||
| 			if (File::exists(JPATH_ROOT . '/' .'images' . '/' . 'phocagallery' . '/'. $ytb['filename'], $img)) { | ||||
| 				$errorMsg = Text::_('COM_PHOCAGALLERY_YTB_ERROR_VIDEO_EXISTS'); | ||||
| 				return false; | ||||
| 			} | ||||
|  | ||||
|             if (!File::write(JPATH_ROOT . '/' .'images' . '/' . 'phocagallery' . '/'. $ytb['filename'], $img)) { | ||||
| 				$errorMsg = Text::_('COM_PHOCAGALLERY_YTB_ERROR_WRITE_IMAGE'); | ||||
| 				return false; | ||||
| 			}*/ | ||||
| 		} | ||||
|  | ||||
| 		return $ytb; | ||||
|  | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user