mirror of
https://github.com/Deutscher-Tischfussballbund/com_sportsmanager.git
synced 2026-06-10 06:27:52 +00:00
fix: outsource bildKopierenAngepasst method to be reused from within script.php
chore: move and rename install.php to root path and rename to script.php
This commit is contained in:
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function bildKopierenAngepasst($quelle, $ziel, $ziel_breite, $ziel_hoehe, $zuschneiden)
|
||||||
|
{
|
||||||
|
$len = strlen($ziel);
|
||||||
|
if ($len < 4 || $ziel[$len - 4] != ".")
|
||||||
|
return false;
|
||||||
|
$ext = strtolower(substr($ziel, $len - 3));
|
||||||
|
if ($ext != "jpg" && $ext != "png")
|
||||||
|
return false;
|
||||||
|
$quelle_image = $ext == "png" ? imagecreatefrompng($quelle) : imagecreatefromjpeg($quelle);
|
||||||
|
if ($quelle_image === false)
|
||||||
|
return false;
|
||||||
|
$quelle_breite = imagesx($quelle_image);
|
||||||
|
$quelle_hoehe = imagesy($quelle_image);
|
||||||
|
if ($quelle_breite == $ziel_breite && $quelle_hoehe == $ziel_hoehe)
|
||||||
|
return JFile::copy($quelle, $ziel);
|
||||||
|
|
||||||
|
$ziel_image = imagecreatetruecolor($ziel_breite, $ziel_hoehe);
|
||||||
|
$hintergrund = $ext == "png" ? imagecolorallocatealpha($ziel_image, 0, 0, 0, 127) : imagecolorallocate($ziel_image, 64, 64, 64);
|
||||||
|
imagefill($ziel_image, 0, 0, $hintergrund);
|
||||||
|
$quelle_proportionen = $quelle_breite / $quelle_hoehe;
|
||||||
|
$ziel_proportionen = $ziel_breite / $ziel_hoehe;
|
||||||
|
if ($zuschneiden) {
|
||||||
|
if ($ziel_proportionen >= $quelle_proportionen) {
|
||||||
|
$quelle_teilhoehe = round($quelle_breite / $ziel_proportionen);
|
||||||
|
if (!imagecopyresampled($ziel_image, $quelle_image, 0, 0, 0, round(($quelle_hoehe - $quelle_teilhoehe) / 2), $ziel_breite, $ziel_hoehe, $quelle_breite, $quelle_teilhoehe))
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
$quelle_teilbreite = round($quelle_hoehe * $ziel_proportionen);
|
||||||
|
if (!imagecopyresampled($ziel_image, $quelle_image, 0, 0, round(($quelle_breite - $quelle_teilbreite) / 2), 0, $ziel_breite, $ziel_hoehe, $quelle_teilbreite, $quelle_hoehe))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($ziel_proportionen >= $quelle_proportionen) {
|
||||||
|
$ziel_teilbreite = round($ziel_hoehe * $quelle_proportionen);
|
||||||
|
if (!imagecopyresampled($ziel_image, $quelle_image, round(($ziel_breite - $ziel_teilbreite) / 2), 0, 0, 0, $ziel_teilbreite, $ziel_hoehe, $quelle_breite, $quelle_hoehe))
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
$ziel_teilhoehe = round($ziel_breite / $quelle_proportionen);
|
||||||
|
if (!imagecopyresampled($ziel_image, $quelle_image, 0, round(($ziel_hoehe - $ziel_teilhoehe) / 2), 0, 0, $ziel_breite, $ziel_teilhoehe, $quelle_breite, $quelle_hoehe))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ob_start();
|
||||||
|
if ($ext == "png") {
|
||||||
|
imagesavealpha($ziel_image, true);
|
||||||
|
if (!imagepng($ziel_image))
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
if (!imagejpeg($ziel_image))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$output = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
|
JFile::write($ziel, $output);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<html><body bgcolor="#FFFFFF"></body></html>
|
||||||
+26
-26
@@ -11,6 +11,32 @@ class com_sportsmanagerInstallerScript
|
|||||||
{
|
{
|
||||||
function install($parent)
|
function install($parent)
|
||||||
{
|
{
|
||||||
|
// not used
|
||||||
|
}
|
||||||
|
|
||||||
|
function uninstall($parent)
|
||||||
|
{
|
||||||
|
$this->remove_database();
|
||||||
|
|
||||||
|
if (!JFolder::delete(JPATH_ROOT.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'sportsmanager'))
|
||||||
|
echo '<p>Warning: Image directory could not be deleted!</p>';
|
||||||
|
echo '<p>Sports Manager was successfully removed from Joomla.</p>';
|
||||||
|
//echo '<p>' . JText::_('COM_SPORTSMANAGER_UNINSTALL_TEXT') . '</p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
function update($parent)
|
||||||
|
{
|
||||||
|
// echo '<p>' . JText::sprintf('COM_SPORTSMANAGER_UPDATE_TEXT', $parent->get('manifest')->version) . '</p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
function preflight($type, $parent)
|
||||||
|
{
|
||||||
|
// echo '<p>' . JText::_('COM_SPORTSMANAGER_PREFLIGHT_' . $type . '_TEXT') . '</p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
function postflight($type, $parent)
|
||||||
|
{
|
||||||
|
require_once JPATH_SITE . '/components/com_sportsmanager/util/image.php';
|
||||||
if (!$this->database_exists()) {
|
if (!$this->database_exists()) {
|
||||||
$this->create_database();
|
$this->create_database();
|
||||||
if (!JFolder::create(JPATH_ROOT.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'sportsmanager', 0777))
|
if (!JFolder::create(JPATH_ROOT.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'sportsmanager', 0777))
|
||||||
@@ -56,30 +82,6 @@ class com_sportsmanagerInstallerScript
|
|||||||
die('Das Bild konnte nicht an die Zielposition kopiert werden.');
|
die('Das Bild konnte nicht an die Zielposition kopiert werden.');
|
||||||
}
|
}
|
||||||
$parent->getParent()->setRedirectURL('index.php?option=com_sportsmanager');
|
$parent->getParent()->setRedirectURL('index.php?option=com_sportsmanager');
|
||||||
}
|
|
||||||
|
|
||||||
function uninstall($parent)
|
|
||||||
{
|
|
||||||
$this->remove_database();
|
|
||||||
|
|
||||||
if (!JFolder::delete(JPATH_ROOT.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'sportsmanager'))
|
|
||||||
echo '<p>Warning: Image directory could not be deleted!</p>';
|
|
||||||
echo '<p>Sports Manager was successfully removed from Joomla.</p>';
|
|
||||||
//echo '<p>' . JText::_('COM_SPORTSMANAGER_UNINSTALL_TEXT') . '</p>';
|
|
||||||
}
|
|
||||||
|
|
||||||
function update($parent)
|
|
||||||
{
|
|
||||||
// echo '<p>' . JText::sprintf('COM_SPORTSMANAGER_UPDATE_TEXT', $parent->get('manifest')->version) . '</p>';
|
|
||||||
}
|
|
||||||
|
|
||||||
function preflight($type, $parent)
|
|
||||||
{
|
|
||||||
// echo '<p>' . JText::_('COM_SPORTSMANAGER_PREFLIGHT_' . $type . '_TEXT') . '</p>';
|
|
||||||
}
|
|
||||||
|
|
||||||
function postflight($type, $parent)
|
|
||||||
{
|
|
||||||
// echo '<p>' . JText::_('COM_SPORTSMANAGER_POSTFLIGHT_' . $type . '_TEXT') . '</p>';
|
// echo '<p>' . JText::_('COM_SPORTSMANAGER_POSTFLIGHT_' . $type . '_TEXT') . '</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1599,5 +1601,3 @@ class com_sportsmanagerInstallerScript
|
|||||||
if (!$result = $db->execute()) { die($db->stderr(true)); }
|
if (!$result = $db->execute()) { die($db->stderr(true)); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
Reference in New Issue
Block a user