Your IP : 216.73.216.240


Current Path : /home/juvelize/saulnois/tmp/install_695d2cf0b4957/src/View/Sd/
Upload File :
Current File : /home/juvelize/saulnois/tmp/install_695d2cf0b4957/src/View/Sd/SdEvent.php

<?php
/*
* @package		Tech Fry Library
* @license		https://www.gnu.org/licenses/gpl-3.0.en.html
*/

namespace TechFry\Library\View\Sd;

defined('_JEXEC') or die;

use Joomla\CMS\Uri\Uri;

// https://developers.google.com/search/docs/appearance/structured-data/event
class SdEvent
{
    public static function get_output($data = array())
    {
        $uri = Uri::getInstance();

        $description = $data['description'] ?? $data['introtext'];
        
        $json = array(
            "@context" => "https://schema.org",
            "@type" => "Event",
            "name" => $data['title'] ?? $data['name'],
            "description" => strip_tags($description),
        );

        if (isset($data['image']) && $data['image'])
        {
            $json['image'] = Sd::add_image($data['image']);
        }

        $json["location"] = array(
	        "@type" => "Place",
	        "name" => $data['location_name'],
	        "address" => array(
                "@type" => "PostalAddress",
                "name" => $data['location_address'],
            ),
	    );

        $json["startDate"] = $data['startDate'] ?? $data['start_date'];
        $json["endDate"] = $data['endDate'] ?? $data['end_date'];

        $json["eventAttendanceMode"] = "https://schema.org/" . $data['eventAttendanceMode'] . "EventAttendanceMode";
	    $json["eventStatus"] = "https://schema.org/Event" . $data['eventStatus'];

        $json["offers"] = array(
	        "@type" => "Offer",
	        "url" => $data['offer_url'],
	    );

        Sd::display_sd($json);
    }
}