1
0
mirror of https://github.com/typemill/typemill.git synced 2025-07-31 03:10:19 +02:00

Version 1.2.10: Formatting Options for Visual Editor

This commit is contained in:
Sebastian
2019-01-25 18:15:47 +01:00
parent 9db742d916
commit 6e605fb8a5
39 changed files with 1357 additions and 255 deletions

View File

@@ -262,7 +262,7 @@ class Field
}
private function setHelpers($fieldConfigs)
public function setHelpers($fieldConfigs)
{
foreach($fieldConfigs as $key => $config)
{
@@ -277,7 +277,7 @@ class Field
{
if(isset($this->$helperName))
{
return $this->helperName;
return $this->$helperName;
}
return false;
}

View File

@@ -31,6 +31,20 @@ class Fields
}
else
{
# For label, helptext and description you can use the value of another field. This is useful e.g. to localize the label of public forms via plugin settings.
if(isset($fieldConfigurations['label']) && isset($userSettings[$objectType][$objectName][$fieldConfigurations['label']]))
{
$fieldConfigurations['label'] = $userSettings[$objectType][$objectName][$fieldConfigurations['label']];
}
if(isset($fieldConfigurations['help']) && isset($userSettings[$objectType][$objectName][$fieldConfigurations['help']]))
{
$fieldConfigurations['help'] = $userSettings[$objectType][$objectName][$fieldConfigurations['help']];
}
if(isset($fieldConfigurations['description']) && isset($userSettings[$objectType][$objectName][$fieldConfigurations['description']]))
{
$fieldConfigurations['description'] = $userSettings[$objectType][$objectName][$fieldConfigurations['description']];
}
# for each field generate a new field object with the field name and the field configurations
$field = new Field($fieldName, $fieldConfigurations);
@@ -64,23 +78,22 @@ class Fields
}
}
elseif($field->getType() == "checkbox")
{
{
# checkboxes need a special treatment, because field does not exist in settings if unchecked by user
if(!isset($userSettings[$objectType][$objectName][$fieldName]))
if(isset($userSettings[$objectType][$objectName][$fieldName]))
{
$field->unsetAttribute('checked');
$field->setAttribute('checked', 'true');
}
else
{
$field->unsetAttribute('chhecked');
}
}
else
{
{
$field->setAttributeValue('value', $userValue);
}
if(isset($fieldConfigurations['label']) && isset($userSettings[$objectType][$objectName][$fieldConfigurations['label']]))
{
$field->setLabel($userSettings[$objectType][$objectName][$fieldConfigurations['label']]);
}
# add the field to the field-List
$fields[] = $field;

View File

@@ -145,14 +145,6 @@ class ProcessImage
{
$copiedImages = array();
$source_aspect_ratio = $imageSize['width'] / $imageSize['height'];
#check transparency
$transparent_index = false;
if ($imageType = ("png" || "gif"))
{
$transparent_index = imagecolortransparent($imageData);
}
foreach($desiredSizes as $key => $desiredSize)
{
@@ -172,25 +164,27 @@ class ProcessImage
$temp_height = ( int ) ($desiredSize['width'] / $source_aspect_ratio);
$temp_height = round($temp_height, 0);
}
# Create a temporary GD image with desired size
$temp_gdim = imagecreatetruecolor( $temp_width, $temp_height );
if ($transparent_index >= 0 && $imageType == "gif")
{
if ($imageType == "gif")
{
$transparent_index = imagecolortransparent($imageData);
imagepalettecopy($imageData, $temp_gdim);
imagefill($temp_gdim, 0, 0, $transparent_index);
imagecolortransparent($temp_gdim, $transparent_index);
imagetruecolortopalette($temp_gdim, true, 256);
}
elseif($transparent_index >= 0 && $imageType == "png")
elseif($imageType == "png")
{
imagealphablending($temp_gdim, false);
imagesavealpha($temp_gdim,true);
imagesavealpha($temp_gdim, true);
$transparent = imagecolorallocatealpha($temp_gdim, 255, 255, 255, 127);
imagefilledrectangle($temp_gdim, 0, 0, $temp_width, $temp_height, $transparent);
}
# resize image
imagecopyresampled(
$temp_gdim,
$imageData,
@@ -200,36 +194,42 @@ class ProcessImage
$imageSize['width'], $imageSize['height']
);
$copiedImages[$key] = $temp_gdim;
/*
# Copy cropped region from temporary image into the desired GD image
$x0 = ( $temp_width - $desiredSize['width'] ) / 2;
$y0 = ( $temp_height - $desiredSize['height'] ) / 2;
$desired_gdim = imagecreatetruecolor( $desiredSize['width'], $desiredSize['height'] );
if ($transparent_index >= 0 && $imageType == "gif")
{
# GIF
imagepalettecopy($imageData, $desired_gdim);
if ($imageType == "gif")
{
imagepalettecopy($temp_gdim, $desired_gdim);
imagefill($desired_gdim, 0, 0, $transparent_index);
imagecolortransparent($desired_gdim, $transparent_index);
imagetruecolortopalette($desired_gdim, true, 256);
}
if ($transparent_index >= 0 && $imageType == "png")
{
elseif($imageType == "png")
{
imagealphablending($desired_gdim, false);
imagesavealpha($desired_gdim,true);
$transparent = imagecolorallocatealpha($desired_gdim, 255, 255, 255, 127);
imagefilledrectangle($desired_gdim, 0, 0, $desiredSize['width'], $desiredSize['height'], $transparent);
imagefilledrectangle($desired_gdim, 0, 0, $desired_size['with'], $desired_size['height'], $transparent);
}
imagecopy(
imagecopyresampled(
$desired_gdim,
$temp_gdim,
0, 0,
0, 0,
$x0, $y0,
$desiredSize['width'], $desiredSize['height']
);
$copiedImages[$key] = $desired_gdim;
*/
}
return $copiedImages;
}
@@ -332,4 +332,5 @@ class ProcessImage
}
}
?>

View File

@@ -76,13 +76,13 @@ class Validation
Validator::addRule('markdownSecure', function($field, $value, array $params, array $fields)
{
/* strip out code blocks and blockquotes */
$value = preg_replace('/[````][\s\S]+?[````]/', '', $value);
$value = preg_replace('/[```][\s\S]+?[```]/', '', $value);
$value = preg_replace('/[``][\s\S]+?[``]/', '', $value);
$value = preg_replace('/`[\s\S]+?`/', '', $value);
$value = preg_replace('/>[\s\S]+?[\n\r]/', '', $value);
/* strip out code blocks and blockquotes */
$value = preg_replace('/`{4,}[\s\S]+?`{4,}/', '', $value);
$value = preg_replace('/`{3,}[\s\S]+?`{3,}/', '', $value);
$value = preg_replace('/`{2,}[\s\S]+?`{2,}/', '', $value);
$value = preg_replace('/`{1,}[\s\S]+?`{1,}/', '', $value);
$value = preg_replace('/>[\s\S]+?[\n\r]/', '', $value);
if ( $value == strip_tags($value) )
{
return true;