Skip to content
This repository has been archived by the owner on Oct 12, 2019. It is now read-only.

Commit

Permalink
Merge branch 'release/1.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Tabea David committed Jan 30, 2017
2 parents 081ed0c + 54d94fb commit 5839b19
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions ImageExtra.module
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* See README.md for usage instructions.
*
* @author Tabea David <[email protected]>
* @version 1.0.1
* @copyright Copyright (c) 2016
* @version 1.0.2
* @copyright Copyright (c) 2017
* @see https://github.com/justonestep/processwire-imageextra
* @see http://www.processwire.com
*/
Expand All @@ -29,7 +29,7 @@ class ImageExtra extends WireData implements Module {
return array(
'title' => 'Image Extra',
'summary' => 'Adds custom fields to image fields (including multi-language support)',
'version' => 101,
'version' => 102,
'href' => 'https://github.com/justonestep/processwire-imageextra',
'singular' => true,
'autoload' => true,
Expand All @@ -56,6 +56,14 @@ class ImageExtra extends WireData implements Module {
'link' => array()
);

/**
* sanitizer default options
* $options that may be provided to the text() and textarea() functions
*/
protected static $options = array(
'stripTags' => false // strip markup tags
);

/**
* @field boolean whether the field has been already formatted
*/
Expand Down Expand Up @@ -303,7 +311,7 @@ class ImageExtra extends WireData implements Module {
protected function setExtra($name, $value, Page $language = null, $pagefile) {
if (!is_null($language) && $language->id) {
if (!$language->isDefault()) $name .= $language->id;
$value = $this->wire('sanitizer')->textarea($value);
$value = $this->wire('sanitizer')->textarea($value, self::$options);
$pagefile->set($name, $value);
return $pagefile;
}
Expand All @@ -323,7 +331,7 @@ class ImageExtra extends WireData implements Module {
// first item is always default language. this ensures that this will still
// work even if language support is later uninstalled.
$item = $n > 0 ? $name . $id : $name;
$value = $this->wire('sanitizer')->textarea($v);
$value = $this->wire('sanitizer')->textarea($v, self::$options);

if ($n > 0) {
$pagefile->set($item, $value);
Expand All @@ -336,7 +344,7 @@ class ImageExtra extends WireData implements Module {
// no JSON values so assume regular language
$languages = $this->wire('languages');
$language = $this->wire('user')->language;
$value = $this->wire('sanitizer')->textarea($value);
$value = $this->wire('sanitizer')->textarea($value, self::$options);
$pagefile->set($name, $value);
}

Expand Down Expand Up @@ -693,7 +701,7 @@ class ImageExtra extends WireData implements Module {
* @param HookEvent $event
*/
public function fileAddedExtra(HookEvent $event) {
$image = $event->argumentsByName("pagefile");
$image = $event->argumentsByName('pagefile');
$name = $event->object->name;

foreach ($this->additionalFields['other'][$name] as $add) {
Expand Down Expand Up @@ -1239,12 +1247,13 @@ class ImageExtra extends WireData implements Module {

if (count($languages) > 1) $field->useLanguages = true;
$field->setAttribute('name', $fieldName);
$value = $this->wire('sanitizer')->textarea($pagefile->{$current});
$value = $this->wire('sanitizer')->textarea($pagefile->{$current}, self::$options);
$field->set('value', $value);

foreach ($languages as $language) {
if (is_null($language) || $language->isDefault()) continue;
$value = $this->wire('sanitizer')->entities($language ? $pagefile->{$current}($language) : $pagefile->{$current});
$v = $language ? $pagefile->{$current}($language) : $pagefile->{$current};
$value = $this->wire('sanitizer')->textarea($v, self::$options);
$field->set('value' . $language->id, $value);
}

Expand Down

0 comments on commit 5839b19

Please sign in to comment.