|
|
|
|
@ -1852,20 +1852,25 @@ class Template |
|
|
|
|
$course = api_get_course_entity($courseId); |
|
|
|
|
// @TODO: support right-to-left in title |
|
|
|
|
$socialMeta .= '<meta property="og:title" content="'.$course->getTitle().' - '.$metaTitle.'" />'."\n"; |
|
|
|
|
$socialMeta .= '<meta property="twitter:title" content="'.$course->getTitle().' - '.$metaTitle.'" />'."\n"; |
|
|
|
|
$socialMeta .= '<meta property="og:url" content="'.api_get_course_url($course->getCode()).'" />'."\n"; |
|
|
|
|
|
|
|
|
|
$metaDescription = api_get_setting('meta_description'); |
|
|
|
|
if (!empty($course->getDescription())) { |
|
|
|
|
$socialMeta .= '<meta property="og:description" content="'.strip_tags($course->getDescription()).'" />'."\n"; |
|
|
|
|
$socialMeta .= '<meta property="twitter:description" content="'.strip_tags($course->getDescription()).'" />'."\n"; |
|
|
|
|
} elseif (!empty($metaDescription)) { |
|
|
|
|
$socialMeta .= '<meta property="og:description" content="'.$metaDescription.'" />'."\n"; |
|
|
|
|
$socialMeta .= '<meta property="twitter:description" content="'.$metaDescription.'" />'."\n"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$picture = CourseManager::getPicturePath($course, true); |
|
|
|
|
if (!empty($picture)) { |
|
|
|
|
$socialMeta .= '<meta property="og:image" content="'.$picture.'" />'."\n"; |
|
|
|
|
$socialMeta .= '<meta property="twitter:image" content="'.$picture.'" />'."\n"; |
|
|
|
|
$socialMeta .= '<meta property="twitter:image:alt" content="'.$course->getTitle().' - '.$metaTitle.'" />'."\n"; |
|
|
|
|
} else { |
|
|
|
|
$socialMeta .= $this->getMetaPortalImagePath(); |
|
|
|
|
$socialMeta .= $this->getMetaPortalImagePath($metaTitle); |
|
|
|
|
} |
|
|
|
|
} elseif ($sessionId !== 0) { |
|
|
|
|
// If we are on a session "about" screen, publish info about the session |
|
|
|
|
@ -1873,6 +1878,7 @@ class Template |
|
|
|
|
$session = $em->find('ChamiloCoreBundle:Session', $sessionId); |
|
|
|
|
|
|
|
|
|
$socialMeta .= '<meta property="og:title" content="'.$session->getName().' - '.$metaTitle.'" />'."\n"; |
|
|
|
|
$socialMeta .= '<meta property="twitter:title" content="'.$session->getName().' - '.$metaTitle.'" />'."\n"; |
|
|
|
|
$socialMeta .= '<meta property="og:url" content="'.api_get_path(WEB_PATH)."session/{$session->getId()}/about/".'" />'."\n"; |
|
|
|
|
|
|
|
|
|
$sessionValues = new ExtraFieldValue('session'); |
|
|
|
|
@ -1882,19 +1888,23 @@ class Template |
|
|
|
|
if (!empty($sessionImage) && is_file($sessionImageSysPath)) { |
|
|
|
|
$sessionImagePath = api_get_path(WEB_UPLOAD_PATH).$sessionImage; |
|
|
|
|
$socialMeta .= '<meta property="og:image" content="'.$sessionImagePath.'" />'."\n"; |
|
|
|
|
$socialMeta .= '<meta property="twitter:image" content="'.$sessionImagePath.'" />'."\n"; |
|
|
|
|
$socialMeta .= '<meta property="twitter:image:alt" content="'.$session->getName().' - '.$metaTitle.'" />'."\n"; |
|
|
|
|
} else { |
|
|
|
|
$socialMeta .= $this->getMetaPortalImagePath(); |
|
|
|
|
$socialMeta .= $this->getMetaPortalImagePath($metaTitle); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// Otherwise (not a course nor a session, nor a user, nor a badge), publish portal info |
|
|
|
|
$socialMeta .= '<meta property="og:title" content="'.$metaTitle.'" />'."\n"; |
|
|
|
|
$socialMeta .= '<meta property="twitter:title" content="'.$metaTitle.'" />'."\n"; |
|
|
|
|
$socialMeta .= '<meta property="og:url" content="'.api_get_path(WEB_PATH).'" />'."\n"; |
|
|
|
|
|
|
|
|
|
$metaDescription = api_get_setting('meta_description'); |
|
|
|
|
if (!empty($metaDescription)) { |
|
|
|
|
$socialMeta .= '<meta property="og:description" content="'.$metaDescription.'" />'."\n"; |
|
|
|
|
$socialMeta .= '<meta property="twitter:description" content="'.$metaDescription.'" />'."\n"; |
|
|
|
|
} |
|
|
|
|
$socialMeta .= $this->getMetaPortalImagePath(); |
|
|
|
|
$socialMeta .= $this->getMetaPortalImagePath($metaTitle); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -1906,10 +1916,10 @@ class Template |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get platform meta image tag (check meta_image_path setting, then use the logo). |
|
|
|
|
* |
|
|
|
|
* @param string $imageAlt The alt attribute for the image |
|
|
|
|
* @return string The meta image HTML tag, or empty |
|
|
|
|
*/ |
|
|
|
|
private function getMetaPortalImagePath() |
|
|
|
|
private function getMetaPortalImagePath($imageAlt = '') |
|
|
|
|
{ |
|
|
|
|
// Load portal meta image if defined |
|
|
|
|
$metaImage = api_get_setting('meta_image_path'); |
|
|
|
|
@ -1919,11 +1929,15 @@ class Template |
|
|
|
|
if (!empty($metaImage)) { |
|
|
|
|
if (is_file($metaImageSysPath)) { |
|
|
|
|
$portalImageMeta = '<meta property="og:image" content="'.$metaImageWebPath.'" />'."\n"; |
|
|
|
|
$portalImageMeta .= '<meta property="twitter:image" content="'.$metaImageWebPath.'" />'."\n"; |
|
|
|
|
$portalImageMeta .= '<meta property="twitter:image:alt" content="'.$imageAlt.'" />'."\n"; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
$logo = ChamiloApi::getPlatformLogoPath($this->theme); |
|
|
|
|
if (!empty($logo)) { |
|
|
|
|
$portalImageMeta = '<meta property="og:image" content="'.$logo.'" />'."\n"; |
|
|
|
|
$portalImageMeta .= '<meta property="twitter:image" content="'.$logo.'" />'."\n"; |
|
|
|
|
$portalImageMeta .= '<meta property="twitter:image:alt" content="'.$imageAlt.'" />'."\n"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|