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

Version 1.2.9: Add videos and frontend forms

This commit is contained in:
Sebastian
2019-01-03 21:15:07 +01:00
parent 28b6f93a9c
commit 08ece40117
52 changed files with 1003 additions and 452 deletions

View File

@@ -44,7 +44,8 @@ class Field
'url',
'week',
'textarea',
'select'
'select',
'paragraph'
);
/* defines all boolean attributes, that are allowed for fields */
@@ -80,20 +81,17 @@ class Field
{
$this->setName($fieldName);
if(isset($fieldConfigs['type']))
{
$this->setType($fieldConfigs['type']);
}
$type = isset($fieldConfigs['type']) ? $fieldConfigs['type'] : false;
$this->setType($type);
$label = isset($fieldConfigs['label']) ? $fieldConfigs['label'] : false;
$this->setLabel($label);
$checkboxlabel = isset($fieldConfigs['checkboxlabel']) ? $fieldConfigs['checkboxlabel'] : false;
$this->setCheckboxLabel($checkboxlabel);
if(isset($fieldConfigs['label']))
{
$this->setLabel($fieldConfigs['label']);
}
if(isset($fieldConfigs['options']))
{
$this->setOptions($fieldConfigs['options']);
}
$options = isset($fieldConfigs['options']) ? $fieldConfigs['options'] : array();
$this->setOptions($options);
$this->setAttributes($fieldConfigs);
@@ -125,7 +123,7 @@ class Field
return $this->type;
}
private function setLabel($label)
public function setLabel($label)
{
$this->label = $label;
}
@@ -134,6 +132,16 @@ class Field
{
return $this->label;
}
public function setCheckboxLabel($label)
{
$this->checkboxLabel = $label;
}
public function getCheckboxLabel()
{
return $this->checkboxLabel;
}
public function setContent($content)
{
@@ -177,7 +185,7 @@ class Field
public function getAttributes()
{
$string = false;
foreach($this->attributes as $key => $attribute)
{
$string .= ' ' . $key;

View File

@@ -7,13 +7,13 @@ use Typemill\Models\Field;
class Fields
{
public function getFields($userSettings, $objectType, $objectName, $objectSettings, $formType = false)
{
{
# hold all fields in array
$fields = array();
# formtype are backendforms or frontendforms, only relevant for plugins for now
# formtype are backend forms or public forms, only relevant for plugins for now
$formType = $formType ? $formType : 'forms';
# iterate through all fields of the objectSetting (theme or plugin)
foreach($objectSettings[$formType]['fields'] as $fieldName => $fieldConfigurations)
{
@@ -56,7 +56,7 @@ class Fields
}
# Now prepopulate the field object with the value */
if($field->getType() == "textarea")
if($field->getType() == "textarea" || $field->getType() == "paragraph")
{
if($userValue)
{
@@ -66,25 +66,26 @@ 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->setAttribute('checked', 'checked');
}
else
{
$field->unsetAttribute('checked');
$field->unsetAttribute('checked');
}
}
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;
}
}
}
return $fields;
}
}

View File

@@ -3,7 +3,7 @@ namespace Typemill\Models;
class ProcessImage
{
public function createImage(string $image, array $desiredSizes, $name)
public function createImage(string $image, array $desiredSizes)
{
# fix error from jpeg-library
ini_set ('gd.jpeg_ignore_warning', 1);
@@ -60,7 +60,7 @@ class ProcessImage
return false;
}
public function publishImage(array $desiredSizes)
public function publishImage(array $desiredSizes, $name = false)
{
/* get images from tmp folder */
$basePath = getcwd() . DIRECTORY_SEPARATOR . 'media';
@@ -71,7 +71,7 @@ class ProcessImage
if(!file_exists($originalFolder)){ mkdir($originalFolder, 0774, true); }
if(!file_exists($liveFolder)){ mkdir($liveFolder, 0774, true); }
$name = uniqid();
$name = $name ? $name : uniqid();
$files = scandir($tmpFolder);
$success = true;

View File

@@ -312,7 +312,6 @@ class Validation
{
$v = new Validator(array($fieldName => $fieldValue));
if(isset($fieldDefinitions['required']))
{
$v->rule('required', $fieldName);
@@ -364,11 +363,18 @@ class Validation
$v->rule('noHTML', $fieldName);
// $v->rule('regex', $fieldName, '/<[^<]+>/');
break;
case "paragraph":
$v->rule('lengthMax', $fieldName, 1000);
$v->rule('noHTML', $fieldName);
break;
case "password":
$v->rule('lengthMax', $fieldName, 100);
break;
default:
$v->rule('lengthMax', $fieldName, 1000);
$v->rule('regex', $fieldName, '/^[\pL0-9_ \-]*$/u');
}
return $this->validationResult($v, $objectName);
}