Your IP : 216.73.216.240
<?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/course-info
class SdCourse
{
public static function get_output($data = array())
{
$uri = Uri::getInstance();
$description = $data['description'] ?? $data['introtext'];
$json = array(
"@context" => "https://schema.org",
"@type" => "Course",
"name" => $data['title'] ?? $data['name'],
"description" => strip_tags($description),
);
$author = $data['author_name'] ?? $data['provider'] ?? '';
$json['provider'] = array(
"@type" => "Organization",
"name" => $author,
);
// Free, Partially Free, Subscription, Paid
$offer = $data['offer'] ?? $data['offer_category'] ?? '';
if ($offer)
{
$json['offers'] = array(
"@type" => "Offer",
"category" => $offer,
"priceCurrency" => $data['currency'] ?? '',
"price" => $data['price'] ?? '',
);
}
// $data['mode']: Online, Onsite, Blended
// $data['workload']: total time (8601 duration format)
if (isset($data['workload']) && isset($data['mode']))
{
$json['hasCourseInstance'] = array(
"@type" => "CourseInstance",
"courseMode" => $data['mode'],
"courseWorkload" => $data['workload'],
);
}
// $data['level']: Beginner, Intermediate, Advanced
if (isset($data['level']) && $data['level'])
{
$json['educationalLevel'] = $data['level'];
}
// Description - Recommended length: 240 characters, Maximum length: 500 characters
Sd::display_sd($json);
}
}