Your IP : 216.73.216.50


Current Path : /proc/1908984/root/proc/self/root/proc/self/root/proc/2411249/cwd/
Upload File :
Current File : //proc/1908984/root/proc/self/root/proc/self/root/proc/2411249/cwd/dpcalendar.tar

form/assignments.xml000064400000003034152351561560010575 0ustar00<?xml version="1.0" encoding="utf-8"?>
<form>
	<fields name="assignments">
		<!-- Article -->
		<fieldset name="single">
			<fields name="dpcalendarsingle">
				<field name="assignment_state" type="assignmentselection" 
					label="Event"
					description="PLG_GSD_DPCALENDAR_ASSIGN_EVENT_DESC"
				/>
				<field name="selection" type="componentitems" 
					label="NR_SELECTION" 
					description="PLG_GSD_DPCALENDAR_ASSIGN_EVENT_SELECTION_DESC"
					multiple="true"
					table="dpcalendar_events"
					column_state="state"
				/>
        	</fields>
    	</fieldset>
		<!-- Category -->
		<fieldset name="category">
			<fields name="dpcalendarcategory">
				<field name="assignment_state" type="assignmentselection"
	                label="NR_CATEGORIES"
	                description="PLG_GSD_DPCALENDAR_ASSIGN_CATEGORY_DESC"
	            />
	            <field name="selection" type="tfdpcalendarcategories" 
	                label="NR_SELECTION" 
	                description="NR_CATEGORIES_DESC"
	                multiple="true" 
	            />
	            <fields name="params">
		            <field name="inc_children" type="list"
		                label="NR_ALSO_ON_CHILD_ITEMS"
		                description="NR_ALSO_ON_CHILD_ITEMS_DESC"
		             	class="input-medium"
		                default="0">
		                <option value="0">JNO</option>
		                <option value="1">JYES</option>
		                <option value="2">NR_ONLY</option>
		            </field>
	        	</fields>
        	</fields>
    	</fieldset>
	</fields>
</form>language/en-GB/en-GB.plg_gsd_dpcalendar.ini000064400000007241152351561560014420 0ustar00;; Language File
;;
;; @package         Google Structured Data
;; @version         5.6.5 Pro
;;
;; @author          Tassos Marinos <info@tassos.gr>
;; @link            http://www.tassos.gr
;; @copyright       Copyright © 2021 Tassos Marinos All Rights Reserved
;; @license         GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later

PLG_GSD_DPCALENDAR="Google Structured Data - DPCalendar"
PLG_GSD_DPCALENDAR_ALIAS="DPCalendar"
PLG_GSD_DPCALENDAR_DESC="Add Google Structured Data to DPCalendar events"
PLG_GSD_DPCALENDAR_ASSIGN_CATEGORY_DESC="Target all DPCalendar events assigned to specific categories. This rule affects newly created items as well."
PLG_GSD_DPCALENDAR_ASSIGN_EVENT_DESC="Target specific DPCalendar events"
PLG_GSD_DPCALENDAR_ASSIGN_EVENT_SELECTION_DESC="Select DPCalendar events"
PLG_GSD_DPCALENDAR_VIEW_EVENT="Event"
PLG_GSD_DPCALENDAR_URL="URL"
PLG_GSD_DPCALENDAR_COLOR="Color"
PLG_GSD_DPCALENDAR_INTRO_IMAGE_URL="Intro Image URL"
PLG_GSD_DPCALENDAR_INTRO_IMAGE_ALT="Intro Image Alt"
PLG_GSD_DPCALENDAR_INTRO_IMAGE_CAPTION="Intro Image Caption"
PLG_GSD_DPCALENDAR_FULL_IMAGE_URL="Full Image URL"
PLG_GSD_DPCALENDAR_FULL_IMAGE_ALT="Full Image Alt"
PLG_GSD_DPCALENDAR_FULL_IMAGE_CAPTION="Full Image Caption"
PLG_GSD_DPCALENDAR_CAPACITY="Capacity"
PLG_GSD_DPCALENDAR_CAPACITY_USED="Capacity Used"
PLG_GSD_DPCALENDAR_MAX_TICKETS="Max Tickets"
PLG_GSD_DPCALENDAR_BOOKING_OPENING_DATE="Booking Opening Date"
PLG_GSD_DPCALENDAR_BOOKING_CLOSING_DATE="Booking Closing Date"
PLG_GSD_DPCALENDAR_BOOKING_CANCEL_CLOSING_DATE="Booking Cancel Closing Date"
PLG_GSD_DPCALENDAR_RIGHTS="Content Rights"
PLG_GSD_DPCALENDAR_XREFERENCE="XReference"
PLG_GSD_DPCALENDAR_LOCATION1_LABEL="Location 1 Label"
PLG_GSD_DPCALENDAR_LOCATION1_COORDS="Location 1 Coordinates"
PLG_GSD_DPCALENDAR_LOCATION1_PROVINCE="Location 1 Province"
PLG_GSD_DPCALENDAR_LOCATION1_CITY="Location 1 City"
PLG_GSD_DPCALENDAR_LOCATION1_ZIP="Location 1 Postal Code"
PLG_GSD_DPCALENDAR_LOCATION1_STREET="Location 1 Street Name"
PLG_GSD_DPCALENDAR_LOCATION1_NUMBER="Location 1 House Number"
PLG_GSD_DPCALENDAR_LOCATION2_LABEL="Location 2 Label"
PLG_GSD_DPCALENDAR_LOCATION2_COORDS="Location 2 Coordinates"
PLG_GSD_DPCALENDAR_LOCATION2_PROVINCE="Location 2 Province"
PLG_GSD_DPCALENDAR_LOCATION2_CITY="Location 2 City"
PLG_GSD_DPCALENDAR_LOCATION2_ZIP="Location 2 Postal Code"
PLG_GSD_DPCALENDAR_LOCATION2_STREET="Location 2 Street Name"
PLG_GSD_DPCALENDAR_LOCATION2_NUMBER="Location 2 House Number"
PLG_GSD_DPCALENDAR_LOCATION3_LABEL="Location 3 Label"
PLG_GSD_DPCALENDAR_LOCATION3_COORDS="Location 3 Coordinates"
PLG_GSD_DPCALENDAR_LOCATION3_PROVINCE="Location 3 Province"
PLG_GSD_DPCALENDAR_LOCATION3_CITY="Location 3 City"
PLG_GSD_DPCALENDAR_LOCATION3_ZIP="Location 3 Postal Code"
PLG_GSD_DPCALENDAR_LOCATION3_STREET="Location 3 Street Name"
PLG_GSD_DPCALENDAR_LOCATION3_NUMBER="Location 3 House Number"
PLG_GSD_DPCALENDAR_PRICE1="Event Price 1"
PLG_GSD_DPCALENDAR_PRICE2="Event Price 2"
PLG_GSD_DPCALENDAR_PRICE3="Event Price 3"
PLG_GSD_DPCALENDAR_EARLYBIRD1_VALUE="EarlyBird Discount 1 Price"
PLG_GSD_DPCALENDAR_EARLYBIRD1_DATE="EarlyBird Discount 1 Date"
PLG_GSD_DPCALENDAR_EARLYBIRD2_VALUE="EarlyBird Discount 2 Price"
PLG_GSD_DPCALENDAR_EARLYBIRD2_DATE="EarlyBird Discount 2 Date"
PLG_GSD_DPCALENDAR_EARLYBIRD3_VALUE="EarlyBird Discount 3 Price"
PLG_GSD_DPCALENDAR_EARLYBIRD3_DATE="EarlyBird Discount 3 Date"
PLG_GSD_DPCALENDAR_BOOKING_INFORMATION="Booking Information"
PLG_GSD_DPCALENDAR_OPTION1_PRICE="Option 1 Price"
PLG_GSD_DPCALENDAR_OPTION2_PRICE="Option 2 Price"
PLG_GSD_DPCALENDAR_OPTION3_PRICE="Option 3 Price"
PLG_GSD_DPCALENDAR_CUSTOM_FIELD="Custom Field"
PLG_GSD_DPCALENDAR_TAG1="Tag 1"
PLG_GSD_DPCALENDAR_TAG2="Tag 2"
PLG_GSD_DPCALENDAR_TAG3="Tag 3"language/en-GB/en-GB.plg_gsd_dpcalendar.sys.ini000064400000000727152351561560015237 0ustar00;; Language File
;;
;; @package         Google Structured Data
;; @version         5.6.5 Pro
;;
;; @author          Tassos Marinos <info@tassos.gr>
;; @link            http://www.tassos.gr
;; @copyright       Copyright © 2021 Tassos Marinos All Rights Reserved
;; @license         GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later

PLG_GSD_DPCALENDAR="Google Structured Data - DPCalendar"
PLG_GSD_DPCALENDAR_DESC="Add Google Structured Data to DPCalendar events"language/es-ES/es-ES.plg_gsd_dpcalendar.ini000064400000010426152351561560014467 0ustar00;; Language File
;;
;; @package         Google Structured Data
;; @version         5.6.5 Pro
;;
;; @author          Tassos Marinos <info@tassos.gr>
;; @link            http://www.tassos.gr
;; @copyright       Copyright © 2021 Tassos Marinos All Rights Reserved
;; @license         GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later

PLG_GSD_DPCALENDAR="Datos estructurados de Google - DPCalendar"
PLG_GSD_DPCALENDAR_ALIAS="DPCalendar"
PLG_GSD_DPCALENDAR_DESC="Agrega datos estructurados de Google a los eventos de DPCalendar"
PLG_GSD_DPCALENDAR_ASSIGN_CATEGORY_DESC="Agregar datos estructurados a todos los eventos de DPCalendar asignados a categorías específicas. Esta regla también afecta a los elementos recién creados."
PLG_GSD_DPCALENDAR_ASSIGN_EVENT_DESC="Agregar a eventos específicos de DPCalendar"
PLG_GSD_DPCALENDAR_ASSIGN_EVENT_SELECTION_DESC="Seleccionar eventos de DPCalendar"
PLG_GSD_DPCALENDAR_VIEW_EVENT="Evento"
PLG_GSD_DPCALENDAR_URL="URL"
PLG_GSD_DPCALENDAR_COLOR="Color"
PLG_GSD_DPCALENDAR_INTRO_IMAGE_URL="URL de la imagen de introducción"
PLG_GSD_DPCALENDAR_INTRO_IMAGE_ALT="Texto alternativo de la imagen de introducción"
PLG_GSD_DPCALENDAR_INTRO_IMAGE_CAPTION="Leyenda de la imagen de introducción"
PLG_GSD_DPCALENDAR_FULL_IMAGE_URL="URL de la Imagen Completa"
PLG_GSD_DPCALENDAR_FULL_IMAGE_ALT="Texto Alternativo de la Imagen Completa"
PLG_GSD_DPCALENDAR_FULL_IMAGE_CAPTION="Leyenda de la Imagen Completa "
PLG_GSD_DPCALENDAR_CAPACITY="Capacidad"
PLG_GSD_DPCALENDAR_CAPACITY_USED="Capacidad Usada"
PLG_GSD_DPCALENDAR_MAX_TICKETS="Máximo de Boletos"
PLG_GSD_DPCALENDAR_BOOKING_OPENING_DATE="Fecha de Apertura de Reservas"
PLG_GSD_DPCALENDAR_BOOKING_CLOSING_DATE="Fecha de Cierre de Reservas"
PLG_GSD_DPCALENDAR_BOOKING_CANCEL_CLOSING_DATE="Fecha de Cierre para Cancelación de Reservas"
PLG_GSD_DPCALENDAR_RIGHTS="Derechos de Contenido"
PLG_GSD_DPCALENDAR_XREFERENCE="ReferenciaX"
PLG_GSD_DPCALENDAR_LOCATION1_LABEL="Nombre de la Ubicación 1"
PLG_GSD_DPCALENDAR_LOCATION1_COORDS="Coordenadas de la Ubicación 1"
PLG_GSD_DPCALENDAR_LOCATION1_PROVINCE="Provincia de la Ubicación 1"
PLG_GSD_DPCALENDAR_LOCATION1_CITY="Ciudad de la Ubicación 1"
PLG_GSD_DPCALENDAR_LOCATION1_ZIP="Código Postal de la Ubicación 1"
PLG_GSD_DPCALENDAR_LOCATION1_STREET="Nombre de la Calle/Barrio de la Ubicación 1"
PLG_GSD_DPCALENDAR_LOCATION1_NUMBER="Dirección de la Ubicación 1"
PLG_GSD_DPCALENDAR_LOCATION2_LABEL="Nombre de la Ubicación 2"
PLG_GSD_DPCALENDAR_LOCATION2_COORDS="Coordenadas de la Ubicación 2"
PLG_GSD_DPCALENDAR_LOCATION2_PROVINCE="Provincia de la Ubicación 2"
PLG_GSD_DPCALENDAR_LOCATION2_CITY="Ciudad de la Ubicación 2"
PLG_GSD_DPCALENDAR_LOCATION2_ZIP="Código Postal de la Ubicación 2"
PLG_GSD_DPCALENDAR_LOCATION2_STREET="Nombre de la Calle/Barrio de la Ubicación 2"
PLG_GSD_DPCALENDAR_LOCATION2_NUMBER="Dirección de la Ubicación 2"
PLG_GSD_DPCALENDAR_LOCATION3_LABEL="Nombre de la Ubicación 3"
PLG_GSD_DPCALENDAR_LOCATION3_COORDS="Coordenadas de la Ubicación 3"
PLG_GSD_DPCALENDAR_LOCATION3_PROVINCE="Provincia de la Ubicación 3"
PLG_GSD_DPCALENDAR_LOCATION3_CITY="Ciudad de la Ubicación 3"
PLG_GSD_DPCALENDAR_LOCATION3_ZIP="Código Postal de la Ubicación 3"
PLG_GSD_DPCALENDAR_LOCATION3_STREET="Nombre de la Calle/Barrio de la Ubicación 3"
PLG_GSD_DPCALENDAR_LOCATION3_NUMBER="Dirección de la Ubicación 3"
PLG_GSD_DPCALENDAR_PRICE1="Precio del Evento 1"
PLG_GSD_DPCALENDAR_PRICE2="Precio del Evento 2"
PLG_GSD_DPCALENDAR_PRICE3="Precio del Evento 3"
PLG_GSD_DPCALENDAR_EARLYBIRD1_VALUE="Precio reserva anticipada Descuento 1"
PLG_GSD_DPCALENDAR_EARLYBIRD1_DATE="Fecha reserva anticipada Descuento 1"
PLG_GSD_DPCALENDAR_EARLYBIRD2_VALUE="Precio reserva anticipada Descuento 2"
PLG_GSD_DPCALENDAR_EARLYBIRD2_DATE="Fecha reserva anticipada Descuento 2"
PLG_GSD_DPCALENDAR_EARLYBIRD3_VALUE="Precio reserva anticipada Descuento 3"
PLG_GSD_DPCALENDAR_EARLYBIRD3_DATE="Fecha por reserva anticipada Precio 3"
PLG_GSD_DPCALENDAR_BOOKING_INFORMATION="Infomación sobre Reservas"
PLG_GSD_DPCALENDAR_OPTION1_PRICE="Precio de la Opción 1"
PLG_GSD_DPCALENDAR_OPTION2_PRICE="Precio de la Opción 2"
PLG_GSD_DPCALENDAR_OPTION3_PRICE="Precio de la Opción 3"
PLG_GSD_DPCALENDAR_CUSTOM_FIELD="Campo Personalizado"
PLG_GSD_DPCALENDAR_TAG1="Etiqueta 1"
PLG_GSD_DPCALENDAR_TAG2="Etiqueta 2"
PLG_GSD_DPCALENDAR_TAG3="Etiqueta 3"
language/es-ES/es-ES.plg_gsd_dpcalendar.sys.ini000064400000000760152351561560015304 0ustar00;; Language File
;;
;; @package         Google Structured Data
;; @version         5.6.5 Pro
;;
;; @author          Tassos Marinos <info@tassos.gr>
;; @link            http://www.tassos.gr
;; @copyright       Copyright © 2021 Tassos Marinos All Rights Reserved
;; @license         GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later

PLG_GSD_DPCALENDAR="Datos estructurados de Google - DPCalendar"
PLG_GSD_DPCALENDAR_DESC="Agrega datos estructurados de Google a los eventos de DPCalendar"
dpcalendar.php000064400000027334152351561560007374 0ustar00<?php

/**
 * @package         Google Structured Data
 * @version         5.6.5 Pro
 *
 * @author          Tassos Marinos <info@tassos.gr>
 * @link            http://www.tassos.gr
 * @copyright       Copyright © 2021 Tassos Marinos All Rights Reserved
 * @license         GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
 */

defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\Helper\TagsHelper;
use GSD\Helper;
use GSD\MappingOptions;
use DPCalendar\Helper\DPCalendarHelper;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Language\Text;

/**
 *  DPCalendar Google Structured Data Plugin
 */
class plgGSDDPCalendar extends \GSD\PluginBaseEvent
{
	/**
	 * Model
	 * 
	 * @var  Object
	 */
	private $model;

	/**
	 * The event.
	 * 
	 * @var  Object
	 */
	private $item;
	
	/**
	 * Get event's data
	 *
	 * @return  array
	 */
	public function viewEvent()
	{	
		// Make sure we have a valid ID
		if (!$id = $this->getThingID())
		{
			return;
		}

		// Load current item via model
		$this->model = BaseDatabaseModel::getInstance('Event', 'DPCalendarModel');

		$this->item = $this->model->getItem();
		
		if (!is_object($this->item))
		{
			return;
		}

		$this->item->tags = new TagsHelper();
		$this->item->tags->getItemTags('com_dpcalendar.event', $this->item->id);

		$locationName = count($this->item->locations) ? $this->item->locations[0]->title : null;
		$locationCountry = count($this->item->locations) && isset($this->item->locations[0]->country_code_value) ? $this->item->locations[0]->country_code_value : null;

		$payload = [
			'id'   		  		  => $this->item->id,
			'alias'       		  => $this->item->alias,
			'headline'    		  => $this->item->title,
			'description' 		  => empty($this->item->introText) ? $this->item->description : $this->item->introText,
			'introtext'   		  => $this->item->introText,
			'fulltext'   	      => $this->item->description,
			'image_intro'  		  => Uri::root() . $this->item->images->image_intro,
			'image_full'   		  => Uri::root() . $this->item->images->image_full,
			'image'        		  => Uri::root() . ($this->item->images->image_intro ?: $this->item->images->image_full),
			'imagetext'	   		  => Helper::getFirstImageFromString($this->item->introText . $this->item->description),
			'startDate'	  		  => $this->item->start_date,
			'endDate'	  		  => $this->item->end_date,
			'created_by'  		  => $this->item->created_by,
			'publish_up'  		  => $this->item->created,
			'publish_down'		  => $this->item->end_date,
			'offerStartDate' 	  => $this->item->start_date,
			'offerPrice'    	  => $this->getPrice(),
			'locationName' 		  => $locationName,
			'locationAddress'	  => $locationName,
			'addressCountry'	  => $locationCountry,
			'postalCode'	  	  => count($this->item->locations) ? $this->item->locations[0]->zip : null,
			'metakey'			  => $this->item->metadata->get('metakey'),
			'metadesc'			  => $this->item->metadata->get('metadesc'),
			'offercurrency'  	  => DPCalendarHelper::getComponentParameter('currency', 'USD')
		];

		// Add Item Data Values
		$this->attachItemData($payload);

		return $payload;
	}

	/**
	 * Return the price.
	 * 
	 * @return  mixed
	 */
	private function getPrice()
	{
		if (!$prices = $this->item->price)
		{
			return;
		}

		// One price only
		if (count($prices->value) === 1)
		{
			return reset($prices->value);
		}
		
		// Multiple prices
		$minPrice = min($prices->value);
		$maxPrice = max($prices->value);

		return [$minPrice, $maxPrice];
	}

	/**
	 * Adds all item data values to the payload
	 * 
	 * @param   array   $payload
	 * 
	 * @return  array
	 */
	private function attachItemData(&$payload)
	{
		$payload['data.url'] = $this->item->url;
		$payload['data.color'] = $this->item->color;
		$payload['data.intro_image_url'] = Uri::root() . $this->item->images->image_intro;
		$payload['data.intro_image_alt'] = $this->item->images->image_intro_alt;
		$payload['data.intro_image_caption'] = $this->item->images->image_intro_caption;
		$payload['data.full_image_url'] = Uri::root() . $this->item->images->image_full;
		$payload['data.full_image_alt'] = $this->item->images->image_full_alt;
		$payload['data.full_image_caption'] = $this->item->images->image_full_caption;
		$payload['data.capacity'] = $this->item->capacity;
		$payload['data.capacity_used'] = $this->item->capacity_used;
		$payload['data.max_tickets'] = $this->item->max_tickets;
		$payload['data.booking_opening_date'] = $this->item->booking_opening_date;
		$payload['data.booking_closing_date'] = $this->item->booking_closing_date;
		$payload['data.booking_cancel_closing_date'] = $this->item->booking_cancel_closing_date;
		$payload['data.booking_information'] = $this->item->booking_information;
		$payload['data.rights'] = $this->item->metadata->get('rights');
		$payload['data.xreference'] = $this->item->xreference;

		// Locations
		if ($locations = $this->item->locations)
		{
			$location1 = isset($locations[0]) ? $locations[0] : false;
			if ($location1)
			{
				$payload['data.location1_label'] = $location1->title;
				$payload['data.location1_coords'] = $location1->xreference;
				$payload['data.location1_province'] = $location1->province;
				$payload['data.location1_city'] = $location1->city;
				$payload['data.location1_zip'] = $location1->zip;
				$payload['data.location1_street'] = $location1->street;
				$payload['data.location1_number'] = $location1->number;
			}

			$location2 = isset($locations[0]) ? $locations[0] : false;
			if ($location2)
			{
				$payload['data.location2_label'] = $location2->title;
				$payload['data.location2_coords'] = $location2->xreference;
				$payload['data.location2_province'] = $location2->province;
				$payload['data.location2_city'] = $location2->city;
				$payload['data.location2_zip'] = $location2->zip;
				$payload['data.location2_street'] = $location2->street;
				$payload['data.location2_number'] = $location2->number;
			}

			$location3 = isset($locations[0]) ? $locations[0] : false;
			if ($location3)
			{
				$payload['data.location3_label'] = $location3->title;
				$payload['data.location3_coords'] = $location3->xreference;
				$payload['data.location3_province'] = $location3->province;
				$payload['data.location3_city'] = $location3->city;
				$payload['data.location3_zip'] = $location3->zip;
				$payload['data.location3_street'] = $location3->street;
				$payload['data.location3_number'] = $location3->number;
			}
		}

		// Price
		if ($this->item->price && isset($this->item->price->value))
		{
			$prices = $this->item->price->value;

			if (isset($prices[0]))
			{
				$payload['data.price1'] = $prices[0];
			}

			if (isset($prices[1]))
			{
				$payload['data.price2'] = $prices[1];
			}
			if (isset($prices[2]))
			{
				$payload['data.price3'] = $prices[2];
			}
		}

		// Early Bird
		if ($this->item->earlybird && isset($this->item->earlybird->value))
		{
			$dates = $this->item->earlybird->date;
			
			if (isset($earlybird[0]))
			{
				$payload['data.earlybird1_value'] = $earlybird[0];
				$payload['data.earlybird1_date'] = $dates[0];
			}

			if (isset($earlybird[1]))
			{
				$payload['data.earlybird2_value'] = $earlybird[1];
				$payload['data.earlybird2_date'] = $dates[1];
			}
			if (isset($earlybird[2]))
			{
				$payload['data.earlybird3_value'] = $earlybird[2];
				$payload['data.earlybird3_date'] = $dates[2];
			}
		}

		// Booking Options
		if ($booking_options = $this->item->booking_options)
		{
			if (isset($booking_options->booking_options0))
			{
				$payload['data.option1_price'] = $booking_options->booking_options0->price;
			}

			if (isset($booking_options->booking_options1))
			{
				$payload['data.option2_price'] = $booking_options->booking_options1->price;
			}

			if (isset($booking_options->booking_options2))
			{
				$payload['data.option3_price'] = $booking_options->booking_options2->price;
			}
		}

		// Tags
		if ($tags = $this->item->tags)
		{
			if ($tags->itemTags)
			{
				if (isset($tags->itemTags[0]))
				{
					$payload['data.tag1'] = $tags->itemTags[0]->title;
				}

				if (isset($tags->itemTags[1]))
				{
					$payload['data.tag2'] = $tags->itemTags[1]->title;
				}

				if (isset($tags->itemTags[2]))
				{
					$payload['data.tag3'] = $tags->itemTags[2]->title;
				}
			}
		}

		/**
		 * Add Custom Fields
		 */
        if ($fields = FieldsHelper::getFields('com_dpcalendar.event', $this->item, true))
		{
			foreach ($fields as $field)
			{
				$payload['cf.' . $field->name] = $field->value;
			}
		}
	}

	/**
	 * Retrieves useful item data
	 * 
	 * @return  array
	 */
	private function getItemData()
	{
		$data = [
			'url',
			'color',
			'intro_image_url',
			'intro_image_alt',
			'intro_image_caption',
			'full_image_url',
			'full_image_alt',
			'full_image_caption',
			'capacity',
			'capacity_used',
			'max_tickets',
			'booking_opening_date',
			'booking_closing_date',
			'booking_cancel_closing_date',
			'rights',
			'xreference',
			// Location
			'location1_label',
			'location1_coords',
			'location1_province',
			'location1_city',
			'location1_zip',
			'location1_street',
			'location1_number',
			'location2_label',
			'location2_coords',
			'location2_province',
			'location2_city',
			'location2_zip',
			'location2_street',
			'location2_number',
			'location3_label',
			'location3_coords',
			'location3_province',
			'location3_city',
			'location3_zip',
			'location3_street',
			'location3_number',
			// Price
			'price1',
			'price2',
			'price3',
			// Early Bird
			'earlybird1_value',
			'earlybird1_date',
			'earlybird2_value',
			'earlybird2_date',
			'earlybird3_value',
			'earlybird3_date',
			// Booking Information
			'booking_information',
			// Booking Options
			'option1_price',
			'option2_price',
			'option3_price',
			// Tags
			'tag1',
			'tag2',
			'tag3'
		];

		return $data;
	}

	/**
	 * Listening to the onAfterRender Joomla event
	 *
	 * @return void
	 */
	public function onAfterRender()
	{
        // Make sure we are on the right context
        if ($this->app->isClient('administrator') || 
            !$this->passContext() || 
            $this->getView() != 'event' ||
            !$this->params->get('remove_dpcalendar_product_schema', true))
		{
            return;
        }

        // Remove the Event Structured Data item added by DPCalendar
        \GSD\SchemaCleaner::remove('Event');
    }

	/**
	 * The MapOptions Backend Event. Triggered by the mappingoptions fields to help each integration add its own map options.
	 *  
	 * @param	string	$plugin
	 * @param	array	$options
	 *
	 * @return	void
	 */
	public function onMapOptions($plugin, &$options)
	{
		parent::onMapOptions($plugin, $options);

		if ($plugin != $this->_name)
		{
			return;
		}

		// Remove undeeded default mapping options values
		$remove_options = [
			'performerType',
			'performerName',
			'performerURL',
			'organizerType',
			'organizerName',
			'organizerURL',
			'offerinventorylevel',
			'addressLocality',
			'addressRegion'
		];

		// Remove unsupported mapping options
		foreach ($remove_options as $option)
		{
			unset($options['GSD_INTEGRATION']['gsd.item.' . $option]);
		}

		// Add custom item data
		if (!$custom_item_data = $this->getItemData())
		{
			return;
		}
		
		$custom_item_data_options = [];
		foreach ($custom_item_data as $key)
		{
			$custom_item_data_options[$key] = Text::_('PLG_GSD_DPCALENDAR_' . strtoupper($key));
		}
		MappingOptions::add($options, $custom_item_data_options, 'GSD_INTEGRATION', 'gsd.item.data.');

		/**
		 * Add Custom Fields
		 */
        if ($custom_fields = FieldsHelper::getFields('com_dpcalendar.event', null, true))
		{
			$custom_fields_data = [];
			foreach ($custom_fields as $field)
			{
				$custom_fields_data[$field->name] = Text::_('PLG_GSD_DPCALENDAR_CUSTOM_FIELD') . ': ' . $field->title;
			}
			MappingOptions::add($options, $custom_fields_data, 'GSD_CUSTOM_FIELDS', 'gsd.item.cf.');
		}
	}
}dpcalendar.xml000064400000002116152351561560007374 0ustar00<?xml version="1.0" encoding="utf-8"?>
<extension version="3.4" type="plugin" group="gsd" method="upgrade">
	<name>PLG_GSD_DPCALENDAR</name>
	<description>PLG_GSD_DPCALENDAR_DESC</description>
	<version>1.0</version>
	<creationDate>September 2023</creationDate>
	<author>Tassos Marinos</author>
	<copyright>Copyright © 2021 Tassos Marinos All Rights Reserved</copyright>
	<license>http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL</license>
	<authorEmail>info@tassos.gr</authorEmail>
	<authorUrl>http://www.tassos.gr</authorUrl>
	<scriptfile>script.install.php</scriptfile>
	<files>
		<filename plugin="dpcalendar">dpcalendar.php</filename>
		<filename>script.install.helper.php</filename>
		<folder>language</folder>
		<folder>form</folder>
	</files>
	<config>
		<fields name="params">
			<fieldset name="basic" addfieldpath="plugins/system/nrframework/fields">
				<field name="remove_dpcalendar_product_schema" type="nrtoggle"
					label="GSD_REMOVE_DUPLICATE_SCHEMA" 
					description="GSD_REMOVE_DUPLICATE_SCHEMA_DESC"
					checked="true"
				/>
			</fieldset>
		</fields>
	</config>
</extension>
script.install.helper.php000064400000036527152351561560011532 0ustar00<?php
/**
 * Installer Script Helper
 *
 * @author          Tassos Marinos <info@tassos.gr>
 * @link            http://www.tassos.gr
 * @copyright       Copyright © 2016 Tassos Marinos All Rights Reserved
 * @license         http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
 */

defined('_JEXEC') or die;

use Joomla\CMS\Installer\Installer;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\Filesystem\File;
use Joomla\Filesystem\Folder;

class PlgGsdDpcalendarInstallerScriptHelper
{
	public $name = '';
	public $alias = '';
	public $extname = '';
	public $extension_type = '';
	public $plugin_folder = 'system';
	public $module_position = 'status';
	public $client_id = 1;
	public $install_type = 'install';
	public $show_message = true;
	public $autopublish = true;
	public $db = null;
	public $app = null;
	public $installedVersion;

	public function __construct(&$params)
	{
		$this->extname = $this->extname ?: $this->alias;
		$this->db = Factory::getDbo();
		$this->app = Factory::getApplication();
		$this->installedVersion = $this->getVersion($this->getInstalledXMLFile());
	}

	/**
	 *  Preflight event
	 *
	 *  @param   string            
	 *  @param   JAdapterInstance
	 *
	 *  @return  boolean                      
	 */
	public function preflight($route, $adapter)
	{
		if (!in_array($route, array('install', 'update')))
		{
			return;
		}

		Factory::getLanguage()->load('plg_system_novaraininstaller', JPATH_PLUGINS . '/system/novaraininstaller');

		if ($this->show_message && $this->isInstalled())
		{
			$this->install_type = 'update';
		}

		if ($this->onBeforeInstall() === false)
		{
			return false;
		}
	}

	/**
	 *  Preflight event
	 *
	 *  @param   string            
	 *  @param   JAdapterInstance
	 *
	 *  @return  boolean                      
	 */
	public function postflight($route, $adapter)
	{
		Factory::getLanguage()->load($this->getPrefix() . '_' . $this->extname, $this->getMainFolder());

		if (!in_array($route, array('install', 'update')))
		{
			return;
		}

		if ($this->onAfterInstall() === false)
		{
			return false;
		}

		if ($route == 'install' && $this->autopublish)
		{
			$this->publishExtension();
		}

		if ($this->show_message)
		{
			$this->addInstalledMessage();
		}

		Factory::getCache()->clean('com_plugins');
		Factory::getCache()->clean('_system');
	}

	public function isInstalled()
	{
		if (!is_file($this->getInstalledXMLFile()))
		{
			return false;
		}

		$query = $this->db->getQuery(true)
			->select('extension_id')
			->from('#__extensions')
			->where($this->db->quoteName('type') . ' = ' . $this->db->quote($this->extension_type))
			->where($this->db->quoteName('element') . ' = ' . $this->db->quote($this->getElementName()));
		$this->db->setQuery($query, 0, 1);
		$result = $this->db->loadResult();

		return empty($result) ? false : true;
	}

	public function getMainFolder()
	{
		switch ($this->extension_type)
		{
			case 'plugin' :
				return JPATH_SITE . '/plugins/' . $this->plugin_folder . '/' . $this->extname;

			case 'component' :
				return JPATH_ADMINISTRATOR . '/components/com_' . $this->extname;

			case 'module' :
				return JPATH_ADMINISTRATOR . '/modules/mod_' . $this->extname;

			case 'library' :
				return JPATH_SITE . '/libraries/' . $this->extname;
		}
	}

	public function getInstalledXMLFile()
	{
		return $this->getXMLFile($this->getMainFolder());
	}

	public function getCurrentXMLFile()
	{
		return $this->getXMLFile(__DIR__);
	}

	public function getXMLFile($folder)
	{
		switch ($this->extension_type)
		{
			case 'module' :
				return $folder . '/mod_' . $this->extname . '.xml';
			default :
				return $folder . '/' . $this->extname . '.xml';
		}
	}

	public function foldersExist($folders = array())
	{
		foreach ($folders as $folder)
		{
			if (is_dir($folder))
			{
				return true;
			}
		}

		return false;
	}

	public function publishExtension()
	{
		switch ($this->extension_type)
		{
			case 'plugin' :
				$this->publishPlugin();

			case 'module' :
				$this->publishModule();
		}
	}

	public function publishPlugin()
	{
		$query = $this->db->getQuery(true)
			->update('#__extensions')
			->set($this->db->quoteName('enabled') . ' = 1')
			->where($this->db->quoteName('type') . ' = ' . $this->db->quote('plugin'))
			->where($this->db->quoteName('element') . ' = ' . $this->db->quote($this->extname))
			->where($this->db->quoteName('folder') . ' = ' . $this->db->quote($this->plugin_folder));
		$this->db->setQuery($query);
		$this->db->execute();
	}

	public function publishModule()
	{
		// Get module id
		$query = $this->db->getQuery(true)
			->select('id')
			->from('#__modules')
			->where($this->db->quoteName('module') . ' = ' . $this->db->quote('mod_' . $this->extname))
			->where($this->db->quoteName('client_id') . ' = ' . (int) $this->client_id);
		$this->db->setQuery($query, 0, 1);
		$id = $this->db->loadResult();

		if (!$id)
		{
			return;
		}

		// check if module is already in the modules_menu table (meaning is is already saved)
		$query->clear()
			->select('moduleid')
			->from('#__modules_menu')
			->where($this->db->quoteName('moduleid') . ' = ' . (int) $id);
		$this->db->setQuery($query, 0, 1);
		$exists = $this->db->loadResult();

		if ($exists)
		{
			return;
		}

		// Get highest ordering number in position
		$query->clear()
			->select('ordering')
			->from('#__modules')
			->where($this->db->quoteName('position') . ' = ' . $this->db->quote($this->module_position))
			->where($this->db->quoteName('client_id') . ' = ' . (int) $this->client_id)
			->order('ordering DESC');
		$this->db->setQuery($query, 0, 1);
		$ordering = $this->db->loadResult();
		$ordering++;

		// publish module and set ordering number
		$query->clear()
			->update('#__modules')
			->set($this->db->quoteName('published') . ' = 1')
			->set($this->db->quoteName('ordering') . ' = ' . (int) $ordering)
			->set($this->db->quoteName('position') . ' = ' . $this->db->quote($this->module_position))
			->where($this->db->quoteName('id') . ' = ' . (int) $id);
		$this->db->setQuery($query);
		$this->db->execute();

		// add module to the modules_menu table
		$query->clear()
			->insert('#__modules_menu')
			->columns(array($this->db->quoteName('moduleid'), $this->db->quoteName('menuid')))
			->values((int) $id . ', 0');
		$this->db->setQuery($query);
		$this->db->execute();
	}

	public function addInstalledMessage()
	{
		Factory::getApplication()->enqueueMessage(
			Text::sprintf(
				Text::_($this->install_type == 'update' ? 'NRI_THE_EXTENSION_HAS_BEEN_UPDATED_SUCCESSFULLY' : 'NRI_THE_EXTENSION_HAS_BEEN_INSTALLED_SUCCESSFULLY'),
				'<strong>' . Text::_($this->name) . '</strong>',
				'<strong>' . $this->getVersion() . '</strong>',
				$this->getFullType()
			)
		);
	}

	public function getPrefix()
	{
		switch ($this->extension_type)
		{
			case 'plugin';
				return Text::_('plg_' . strtolower($this->plugin_folder));

			case 'component':
				return Text::_('com');

			case 'module':
				return Text::_('mod');

			case 'library':
				return Text::_('lib');

			default:
				return $this->extension_type;
		}
	}

	public function getElementName($type = null, $extname = null)
	{
		$type = is_null($type) ? $this->extension_type : $type;
		$extname = is_null($extname) ? $this->extname : $extname;

		switch ($type)
		{
			case 'component' :
				return 'com_' . $extname;

			case 'module' :
				return 'mod_' . $extname;

			case 'plugin' :
			default:
				return $extname;
		}
	}

	public function getFullType()
	{
		return Text::_('NRI_' . strtoupper($this->getPrefix()));
	}

	public function isPro()
	{
		$versionFile = __DIR__ . "/version.php";

		// If version file does not exist we assume a PRO version
		if (!is_file($versionFile))
		{
			return true;
		}

		// Load version file
		require_once $versionFile;
		return (bool) $NR_PRO;
	}

	public function getVersion($file = '')
	{
		$file = $file ?: $this->getCurrentXMLFile();

		if (!is_file($file))
		{
			return '';
		}

		$xml = Installer::parseXMLInstallFile($file);

		if (!$xml || !isset($xml['version']))
		{
			return '';
		}

		return $xml['version'];
	}

	/**
	 *  Checks wether the extension can be installed or not
	 *
	 *  @return  boolean  
	 */
	public function canInstall()
	{
		// The extension is not installed yet. Accept Install.
		if (!$installed_version = $this->getVersion($this->getInstalledXMLFile()))
		{
			return true;
		}

		// Path to extension's version file
		$versionFile = $this->getMainFolder() . "/version.php";
		$NR_PRO = true;

		// If version file does not exist we assume we have a PRO version installed
		if (file_exists($versionFile))
		{
			require_once($versionFile);
		}

		// The free version is installed. Accept install.
		if (!(bool)$NR_PRO)
		{
			return true;
		}

		// Current package is a PRO version. Accept install.
		if ($this->isPro())
		{
			return true;
		}

		// User is trying to update from PRO version to FREE. Do not accept install.
		Factory::getLanguage()->load($this->getPrefix() . '_' . $this->extname, __DIR__);

		Factory::getApplication()->enqueueMessage(
			Text::_('NRI_ERROR_PRO_TO_FREE'), 'error'
		);

		Factory::getApplication()->enqueueMessage(
			html_entity_decode(
				Text::sprintf(
					'NRI_ERROR_UNINSTALL_FIRST',
					'<a href="http://www.tassos.gr/joomla-extensions/' . $this->getUrlAlias() . '" target="_blank">',
					'</a>',
					Text::_($this->name)
				)
			), 'error'
		);	

		return false;	
	}

	/**
	 * Returns the URL alias of the extension.
	 * 
	 * @return  string
	 */
	private function getUrlAlias()
	{
		$alias = $this->alias;

		switch ($alias)
		{
			case 'smilepack':
				$alias = 'smile-pack';
				break;
			case 'convertforms':
				$alias = 'convert-forms';
				break;
			case 'rstbox':
				$alias = 'engagebox';
				break;
			case 'gsd':
				$alias = 'google-structured-data';
				break;
		}

		// ACF
		if ($this->plugin_folder === 'fields' && ($alias === 'acf' || $this->startsWith($alias, 'acf')))
		{
			$alias = 'advanced-custom-fields';
		}
		
		return $alias;
	}

    /**
     * Checks whether string starts with substring.
     * 
     * @param   string  $string
     * @param   string  $query
     * 
     * @return  bool
     */
    public static function startsWith($string, $query)
    {
        return substr($string, 0, strlen($query)) === $query;
    }

	/**
	 *  Checks if current version is newer than the installed one
	 *  Used for Novarain Framework
	 *
	 *  @return  boolean  [description]
	 */
	public function isNewer()
	{
		if (!$installed_version = $this->getVersion($this->getInstalledXMLFile()))
		{
			return true;
		}

		$package_version = $this->getVersion();

		return version_compare($installed_version, $package_version, '<=');
	}

	/**
	 *  Helper method triggered before installation
	 *
	 *  @return  bool
	 */
	public function onBeforeInstall()
	{
		if (!$this->canInstall())
		{
			return false;
		}
	}

	/**
	 *  Helper method triggered after installation
	 */
	public function onAfterInstall()
	{

	}

	/**
	 *  Delete files
	 *
	 *  @param   array   $folders
	 */
	public function deleteFiles($files = array())
	{
	    foreach ($files as $key => $file)
        {
			if (!is_file($file))
			{
				continue;
			}
			
            File::delete($file);
        }
	}

	/**
	 *  Deletes folders
	 *
	 *  @param   array   $folders  
	 */
	public function deleteFolders($folders = array())
	{
		foreach ($folders as $folder)
		{
			if (!is_dir($folder))
			{
				continue;
			}

			Folder::delete($folder);
		}
	}

	public function dropIndex($table, $index)
	{	
		$db = $this->db;

		// Check if index exists first
		$query = 'SHOW INDEX FROM ' . $db->quoteName('#__' . $table) . ' WHERE KEY_NAME = ' . $db->quote($index);
        $db->setQuery($query);
        $db->execute();

        if (!$db->loadResult())
        {
        	return;
        }

        // Remove index
        $query = 'ALTER TABLE ' . $db->quoteName('#__' . $table) . ' DROP INDEX ' . $db->quoteName($index);
        $db->setQuery($query);
        $db->execute(); 
	}

    public function dropUnwantedTables($tables) {

        if (!$tables) {
            return;
        }

        foreach ($tables as $table) {
            $query = "DROP TABLE IF EXISTS #__".$this->db->escape($table);
            $this->db->setQuery($query);
            $this->db->execute();
        }
    }

	public function dropUnwantedColumns($table, $columns) {

        if (!$columns || !$table) {
            return;
        }

        $db = $this->db;

        // Check if columns exists in database
        function qt($n) {
            return(Factory::getDBO()->quote($n));
        }
        
        $query = 'SHOW COLUMNS FROM #__'.$table.' WHERE Field IN ('.implode(",", array_map("qt", $columns)).')';
        $db->setQuery($query);
        $rows = $db->loadColumn(0);

        // Abort if we don't have any rows
        if (!$rows) {
            return;
        }

        // Let's remove the columns
        $q = "";
        foreach ($rows as $key => $column) {
            $comma = (($key+1) < count($rows)) ? "," : "";
            $q .= "drop ".$this->db->escape($column).$comma;
        }

        $query = "alter table #__".$table." $q";

        $db->setQuery($query);
        $db->execute();
    }

  	public function fetch($table, $columns = "*", $where = null, $singlerow = false) {
        if (!$table) {
            return;
        }

        $db = $this->db;
        $query = $db->getQuery(true);

        $query
            ->select($columns)
            ->from("#__$table");
        
        if (isset($where)) {
            $query->where("$where");
        }
        
        $db->setQuery($query);
 
        return ($singlerow) ? $db->loadObject() : $db->loadObjectList();
    }

    /**
     *  Load the Novarain Framework
     *
     *  @return  boolean
     */
	public function loadFramework()
	{
		if (is_file(JPATH_PLUGINS . '/system/nrframework/autoload.php'))
		{
			include_once JPATH_PLUGINS . '/system/nrframework/autoload.php';
		}
	}

	/**
	 *  Re-orders plugin after passed array of plugins
	 *
	 *  @param   string  $plugin            Plugin element name
	 *  @param   array   $lowerPluginOrder  Array of plugin element names
	 *
	 *  @return  boolean
	 */
	public function pluginOrderAfter($lowerPluginOrder)
    {

        if (!is_array($lowerPluginOrder) || !count($lowerPluginOrder))
        {
            return;
        }
        
        $db = $this->db;

        // Get plugins max order
        $query = $db->getQuery(true);
        $query
            ->select($db->quoteName('b.ordering'))
            ->from($db->quoteName('#__extensions', 'b'))
            ->where($db->quoteName('b.element') . ' IN ("'.implode("\",\"",$lowerPluginOrder).'")')
            ->order('b.ordering desc');

        $db->setQuery($query);
        $maxOrder = $db->loadResult();

        if (is_null($maxOrder))
        {
            return;
        }

        // Get plugin details
        $query
            ->clear()
            ->select(array($db->quoteName('extension_id'), $db->quoteName('ordering')))
            ->from($db->quoteName('#__extensions'))
            ->where($db->quoteName('element') . ' = ' . $db->quote($this->alias));

        $db->setQuery($query);
        $pluginInfo = $db->loadObject();

        if (!isset($pluginInfo->ordering) || $pluginInfo->ordering > $maxOrder)
        {
            return;
        }

        // Update the new plugin order
        $object = new stdClass();
        $object->extension_id = $pluginInfo->extension_id;
        $object->ordering = ($maxOrder + 1);

		try {
			$db->updateObject('#__extensions', $object, 'extension_id');
		} catch (Exception $e) {
			return $e->getMessage();
		}
    }
}
script.install.php000064400000001247152351561560010243 0ustar00<?php

/**
 * @package         Google Structured Data
 * @version         5.6.5 Pro
 *
 * @author          Tassos Marinos <info@tassos.gr>
 * @link            http://www.tassos.gr
 * @copyright       Copyright © 2021 Tassos Marinos All Rights Reserved
 * @license         GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
 */

defined('_JEXEC') or die;

require_once __DIR__ . '/script.install.helper.php';

class PlgGSDDPCalendarInstallerScript extends PlgGSDDPCalendarInstallerScriptHelper
{
    public $alias = 'dpcalendar';
    public $extension_type = 'plugin';
    public $plugin_folder = "gsd";
    public $show_message = false;
    public $autopublish = false;
}