diff --git a/wire/config.php b/wire/config.php index f4f3c979..a8b80548 100644 --- a/wire/config.php +++ b/wire/config.php @@ -1040,6 +1040,7 @@ $config->substituteModules = array( * #property string module Name of WireMail module to use or blank to auto-detect. (default='') * #property string from Default from email address, when none provided at runtime. (default=$config->adminEmail) * #property string fromName Default from name string, when none provided at runtime. (default='') + * #property string newline What to use for newline if different from RFC standard of "\r\n" (optional). * #property array headers Default additional headers to send in email, key=value. (default=[]) * * @var array diff --git a/wire/core/AdminThemeFramework.php b/wire/core/AdminThemeFramework.php index 0c3e7bc5..920a094b 100644 --- a/wire/core/AdminThemeFramework.php +++ b/wire/core/AdminThemeFramework.php @@ -9,7 +9,7 @@ * @property bool $isSuperuser * @property bool $isEditor * @property bool $isLoggedIn - * @property bool $isModal + * @property bool|string $isModal * @property bool|int $useAsLogin * @method array getUserNavArray() * diff --git a/wire/core/Config.php b/wire/core/Config.php index 5a09c3be..67a8b06a 100644 --- a/wire/core/Config.php +++ b/wire/core/Config.php @@ -415,10 +415,33 @@ class Config extends WireData { * * @param string|null $minVersion * @return bool + * @since 3.0.101 * */ public function phpVersion($minVersion) { return version_compare(PHP_VERSION, $minVersion) >= 0; } + + /** + * Check if current ProcessWire version is equal to or newer than given versino + * + * If no version argument is given, it simply returns the current ProcessWire version. + * + * ~~~~~ + * if($config->version('3.0.100')) { + * // ProcessWire version is 3.0.100 or newer + * } + * ~~~~~ + * + * @param string $minVersion Specify version string if you want to compare against current version + * @return bool|string Returns current version if no argument given, OR boolean if given a version argument: + * - If given version is older than current, returns false. + * - If given version is equal to or newer than current, returns true. + * @since 3.0.106 + * + */ + public function version($minVersion = '') { + return version_compare($this->version, $minVersion) >= 0; + } } diff --git a/wire/core/Sanitizer.php b/wire/core/Sanitizer.php index 9155ea86..e2f23cda 100644 --- a/wire/core/Sanitizer.php +++ b/wire/core/Sanitizer.php @@ -989,14 +989,14 @@ class Sanitizer extends Wire { * - `stripTags` (bool): strip markup tags? (default=true). * - `stripMB4` (bool): strip emoji and other 4-byte UTF-8? (default=false). * - `stripQuotes` (bool): strip out any "quote" or 'quote' characters? Specify true, or character to replace with. (default=false) - * - `stripSpace` (bool|string): strip whitespace? Specify true or character to replace whitespace with (default=false). - * - `reduceSpace` (bool|string): reduce consecutive whitespace to single? Specify true or character to reduce to (default=false). - * Note that the reduceSpace option is an alternative to the stripSpace option, they should not be used together. + * - `stripSpace` (bool|string): strip whitespace? Specify true or character to replace whitespace with (default=false). Since 3.0.105 + * - `reduceSpace` (bool|string): reduce consecutive whitespace to single? Specify true or character to reduce to (default=false). + * Note that the reduceSpace option is an alternative to the stripSpace option, they should not be used together. Since 3.0.105 * - `allowableTags` (string): markup tags that are allowed, if stripTags is true (use same format as for PHP's `strip_tags()` function. * - `multiLine` (bool): allow multiple lines? if false, then $newlineReplacement below is applicable (default=false). - * - `convertEntities` (bool): convert HTML entities to equivalent character(s)? (default=false). + * - `convertEntities` (bool): convert HTML entities to equivalent character(s)? (default=false). Since 3.0.105 * - `newlineReplacement` (string): character to replace newlines with, OR specify boolean true to remove extra lines (default=" "). - * - `truncateTail` (bool): if truncate necessary for maxLength, truncate from end/tail? Use false to truncate head (default=true). + * - `truncateTail` (bool): if truncate necessary for maxLength, truncate from end/tail? Use false to truncate head (default=true). Since 3.0.105 * - `inCharset` (string): input character set (default="UTF-8"). * - `outCharset` (string): output character set (default="UTF-8"). * @return string @@ -1019,7 +1019,7 @@ class Sanitizer extends Wire { 'newlineReplacement' => ' ', // character to replace newlines with, OR specify boolean TRUE to remove extra lines 'inCharset' => 'UTF-8', // input charset 'outCharset' => 'UTF-8', // output charset - 'trunateTail' => true, // if truncate necessary for maxLength, remove chars from tail? False to truncate from head. + 'truncateTail' => true, // if truncate necessary for maxLength, remove chars from tail? False to truncate from head. 'trim' => true, // trim whitespace from beginning/end, or specify character(s) to trim, or false to disable ); @@ -1154,11 +1154,11 @@ class Sanitizer extends Wire { * - `maxBytes` (int): maximum bytes allowed (default=0, which implies maxLength*3 or 48kb). * - `stripTags` (bool): strip markup tags? (default=true). * - `stripMB4` (bool): strip emoji and other 4-byte UTF-8? (default=false). - * - `stripIndents` (bool): Remove indents (space/tabs) at the beginning of lines? (default=false) - * - `reduceSpace` (bool|string): reduce consecutive whitespace to single? Specify true or character to reduce to (default=false). + * - `stripIndents` (bool): Remove indents (space/tabs) at the beginning of lines? (default=false). Since 3.0.105 + * - `reduceSpace` (bool|string): reduce consecutive whitespace to single? Specify true or character to reduce to (default=false). Since 3.0.105 * - `allowableTags` (string): markup tags that are allowed, if stripTags is true (use same format as for PHP's `strip_tags()` function. - * - `convertEntities` (bool): convert HTML entities to equivalent character(s)? (default=false). - * - `truncateTail` (bool): if truncate necessary for maxLength, truncate from end/tail? Use false to truncate head (default=true). + * - `convertEntities` (bool): convert HTML entities to equivalent character(s)? (default=false). Since 3.0.105 + * - `truncateTail` (bool): if truncate necessary for maxLength, truncate from end/tail? Use false to truncate head (default=true). Since 3.0.105 * - `allowCRLF` (bool): allow CR+LF newlines (i.e. "\r\n")? (default=false, which means "\r\n" is replaced with "\n"). * - `inCharset` (string): input character set (default="UTF-8"). * - `outCharset` (string): output character set (default="UTF-8"). @@ -1881,7 +1881,7 @@ class Sanitizer extends Wire { * * @param string $str String to remove entities from * @param int|bool $flags See PHP html_entity_decode function for flags, - * OR specify boolean true to convert all entities and remove any that cannot be converted. + * OR specify boolean true to convert all entities and remove any that cannot be converted (since 3.0.105). * @param string $encoding Encoding (default="UTF-8"). * @return string String with entities removed. * @see Sanitizer::entities() @@ -1992,6 +1992,7 @@ class Sanitizer extends Wire { * - `html` (bool): Remove/replace HTML whitespace entities too? (default=true) * - `allow` (array): Array of whitespace characters that may remain. (default=[]) * @return string + * @since 3.0.105 * */ public function removeWhitespace($str, $options = array()) { @@ -2040,6 +2041,7 @@ class Sanitizer extends Wire { * * @param bool|int $html Also include HTML entities that represent whitespace? false=no, true=both, 1=only-html (default=false) * @return array + * @since 3.0.105 * */ public function getWhitespaceArray($html = false) { @@ -2123,6 +2125,7 @@ class Sanitizer extends Wire { * - `convertEntities` (bool): Convert HTML entities to non-entity characters? (default=false) * - `noEndSentence` (string): Strings that sentence may not end with, space-separated values (default='Mr. Mrs. …') * @return string + * @since 3.0.101 * */ function truncate($str, $maxLength = 300, $options = array()) { @@ -2767,6 +2770,7 @@ class Sanitizer extends Wire { * Get instance of WireTextTools * * @return WireTextTools + * @since 3.0.101 * */ public function getTextTools() { diff --git a/wire/core/WireMail.php b/wire/core/WireMail.php index 75dbf59c..11b22fd0 100644 --- a/wire/core/WireMail.php +++ b/wire/core/WireMail.php @@ -318,7 +318,7 @@ class WireMail extends WireData implements WireMailInterface { } if($name) $this->mail['replyToName'] = $this->sanitizeHeader($name); $this->mail['replyTo'] = $email; - if(empty($name)) $name = $this->mail['replyToName']; + if(empty($name) && !empty($this->mail['replyToName'])) $name = $this->mail['replyToName']; if(strlen($name)) $email = $this->bundleEmailAndName($email, $name); $this->header('Reply-To', $email); return $this; diff --git a/wire/core/WireTextTools.php b/wire/core/WireTextTools.php index e4b87d2c..86729f9f 100644 --- a/wire/core/WireTextTools.php +++ b/wire/core/WireTextTools.php @@ -7,6 +7,8 @@ * * ProcessWire 3.x, Copyright 2018 by Ryan Cramer * https://processwire.com + * + * @since 3.0.101 * * */ @@ -20,7 +22,7 @@ class WireTextTools extends Wire { * improves the readability of the text. * * #pw-internal - * + * * @param string $str String to convert to text * @param array $options * - `keepTags` (array): Tag names to keep in returned value, i.e. [ "em", "strong" ]. (default=none) @@ -47,6 +49,9 @@ class WireTextTools extends Wire { if(strpos($str, '>') !== false) { + // strip out everything up to and including , if present + if(strpos($str, '') !== false) list(, $str) = explode('', $str); + // ensure tags are separated by whitespace $str = str_replace('><', '> <', $str); diff --git a/wire/modules/Fieldtype/FieldtypePageTable.module b/wire/modules/Fieldtype/FieldtypePageTable.module index f489c2db..f997ebb8 100644 --- a/wire/modules/Fieldtype/FieldtypePageTable.module +++ b/wire/modules/Fieldtype/FieldtypePageTable.module @@ -7,7 +7,7 @@ * Code by Ryan Cramer * Sponsored by Avoine * - * ProcessWire 3.x, Copyright 2016 by Ryan Cramer + * ProcessWire 3.x, Copyright 2018 by Ryan Cramer * https://processwire.com * */ @@ -42,6 +42,8 @@ class FieldtypePageTable extends FieldtypeMulti implements Module { * Hook called when a page is deleted * * Used to delete references to the page in any PageTable tables + * + * @param HookEvent $event * */ public function hookPagesDelete(HookEvent $event) { @@ -63,6 +65,8 @@ class FieldtypePageTable extends FieldtypeMulti implements Module { * This automatically trashes the PageTable pages that a deleted page owns, if the unpubOnDelete option is true. * This is really only applicable when PageTable pages are stored somewhere other than as children of the * deleted page. + * + * @param HookEvent $event * */ public function hookPagesDeleteReady(HookEvent $event) { @@ -72,8 +76,9 @@ class FieldtypePageTable extends FieldtypeMulti implements Module { if(is_null($field->trashOnDelete) && !is_null($field->autoTrash)) $field->trashOnDelete = $field->autoTrash; if(!$field->parent_id || !$field->trashOnDelete) continue; $value = $page->getUnformatted($field->name); - if(!count($value)) continue; + if(!wireCount($value)) continue; foreach($value as $item) { + /** @var Page $item */ $deleted = false; if($field->trashOnDelete == 2) { $this->wire('pages')->message("Auto Delete PageTable Item: $item->url", Notice::debug); @@ -95,6 +100,8 @@ class FieldtypePageTable extends FieldtypeMulti implements Module { /** * Hook called when a page has been trashed + * + * @param HookEvent $event * */ public function hookPagesTrashed(HookEvent $event) { @@ -103,8 +110,9 @@ class FieldtypePageTable extends FieldtypeMulti implements Module { if(!$field->type instanceof FieldtypePageTable) continue; if(!$field->parent_id || !$field->unpubOnTrash) continue; $value = $page->getUnformatted($field->name); - if(!count($value)) continue; + if(!wireCount($value)) continue; foreach($value as $item) { + /** @var Page $item */ $this->wire('pages')->message("Auto Unpublish PageTable Item: $item->url", Notice::debug); $of = $item->of(); $item->of(false); @@ -117,6 +125,8 @@ class FieldtypePageTable extends FieldtypeMulti implements Module { /** * Hook called when a page has been unpublished + * + * @param HookEvent $event * */ public function hookPagesUnpublished(HookEvent $event) { @@ -125,8 +135,9 @@ class FieldtypePageTable extends FieldtypeMulti implements Module { if(!$field->type instanceof FieldtypePageTable) continue; if(!$field->parent_id || !$field->unpubOnUnpub) continue; $value = $page->getUnformatted($field->name); - if(!count($value)) continue; + if(!wireCount($value)) continue; foreach($value as $item) { + /** @var Page $item */ $of = $item->of(); $item->of(false); if($field->unpubOnUnpub == 2) { @@ -144,6 +155,8 @@ class FieldtypePageTable extends FieldtypeMulti implements Module { /** * Hook called when a page has been published + * + * @param HookEvent $event * */ public function hookPagesPublished(HookEvent $event) { @@ -152,8 +165,9 @@ class FieldtypePageTable extends FieldtypeMulti implements Module { if(!$field->type instanceof FieldtypePageTable) continue; if(!$field->parent_id || $field->unpubOnUnpub != 2) continue; $value = $page->getUnformatted($field->name); - if(!count($value)) continue; + if(!wireCount($value)) continue; foreach($value as $item) { + /** @var Page $item */ if(!$item->hasStatus(Page::statusHidden)) continue; $of = $item->of(); $item->of(false); @@ -180,6 +194,8 @@ class FieldtypePageTable extends FieldtypeMulti implements Module { $page = $event->arguments(0); $copy = $event->arguments(1); + + if($page) {} // ignore if(in_array($copy->id, $clonedIDs)) return; $clonedIDs[] = $copy->id; @@ -189,7 +205,7 @@ class FieldtypePageTable extends FieldtypeMulti implements Module { //if(!$field->parent_id) continue; // let that be handled manually since recursive clones are already an option $parent = $field->parent_id ? $this->wire('pages')->get($field->parent_id) : $copy; $value = $copy->getUnformatted($field->name); - if(!count($value)) continue; + if(!wireCount($value)) continue; $newValue = $this->wire('pages')->newPageArray(); foreach($value as $item) { try { @@ -270,14 +286,15 @@ class FieldtypePageTable extends FieldtypeMulti implements Module { * */ public function getInputfield(Page $page, Field $field) { + /** @var InputfieldPageTable $inputfield */ $inputfield = $this->modules->get('InputfieldPageTable'); $value = $page->getUnformatted($field->name); $inputfield->attr('value', $value); $templateID = $field->template_id; - if(!$field->parent_id && !empty($templateID) && $page->numChildren > count($value)) { + if(!$field->parent_id && !empty($templateID) && $page->numChildren > wireCount($value)) { $orphans = $this->findOrphans($page, $field); - if(count($orphans)) $inputfield->setOrphans($orphans); + if(wireCount($orphans)) $inputfield->setOrphans($orphans); } return $inputfield; @@ -293,7 +310,7 @@ class FieldtypePageTable extends FieldtypeMulti implements Module { * */ public function sanitizeValue(Page $page, Field $field, $value) { - if(is_array($value) && count($value)) $value = $this->wakeupValue($page, $field, $value); + if(is_array($value) && wireCount($value)) $value = $this->wakeupValue($page, $field, $value); if(!$value instanceof PageArray) return $this->wire('pages')->newPageArray(); foreach($value as $item) { if($this->isValidItem($page, $field, $item)) continue; @@ -312,6 +329,7 @@ class FieldtypePageTable extends FieldtypeMulti implements Module { * */ protected function isValidItem(Page $page, Field $field, Page $item) { + if($page) {} // ignore $template_id = $field->template_id; if(is_array($template_id)) { if(in_array($item->template->id, $template_id)) return true; @@ -388,7 +406,7 @@ class FieldtypePageTable extends FieldtypeMulti implements Module { */ public function ___wakeupValue(Page $page, Field $field, $value) { - if(!is_array($value) || !count($value) || empty($field->template_id)) return $this->getBlankValue($page, $field); + if(!is_array($value) || !wireCount($value) || empty($field->template_id)) return $this->getBlankValue($page, $field); $template_id = $field->get('template_id'); @@ -396,7 +414,7 @@ class FieldtypePageTable extends FieldtypeMulti implements Module { $template_id = $template_id ? array($template_id) : array(); } - if(count($template_id) == 1) { + if(wireCount($template_id) == 1) { $template = $this->wire('templates')->get(reset($template_id)); } else { $template = null; @@ -413,7 +431,7 @@ class FieldtypePageTable extends FieldtypeMulti implements Module { foreach(explode(',', $sortfields) as $sortfield) { $sorts[] = $this->wire('sanitizer')->name(trim($sortfield)); } - if(count($sorts)) $items->sort($sorts); + if(wireCount($sorts)) $items->sort($sorts); } foreach($items as $item) { @@ -486,7 +504,7 @@ class FieldtypePageTable extends FieldtypeMulti implements Module { } } $data['template_id'] = 0; - if(count($errorTemplates)) { + if(wireCount($errorTemplates)) { $data['errors']['template_id'] = "Unable to find template(s): " . implode(', ', $errorTemplates); } } diff --git a/wire/modules/Inputfield/InputfieldCKEditor/InputfieldCKEditor.js b/wire/modules/Inputfield/InputfieldCKEditor/InputfieldCKEditor.js index 8a299f52..55bc31d9 100644 --- a/wire/modules/Inputfield/InputfieldCKEditor/InputfieldCKEditor.js +++ b/wire/modules/Inputfield/InputfieldCKEditor/InputfieldCKEditor.js @@ -22,7 +22,6 @@ function ckeGetProcessWireConfig(editor) { configName = configName.replace('Inputfield_', 'InputfieldCKEditor_'); if(typeof ProcessWire.config[configName] == "undefined" && configName.indexOf('_repeater') > 0) { - console.log('configName=' + configName); configName = configName.replace(/_repeater[0-9]+/, ''); $repeaterItem = $('#' + editorName).closest('.InputfieldRepeaterItem'); } diff --git a/wire/modules/Inputfield/InputfieldCKEditor/InputfieldCKEditor.min.js b/wire/modules/Inputfield/InputfieldCKEditor/InputfieldCKEditor.min.js index b34710d1..85aeacd4 100644 --- a/wire/modules/Inputfield/InputfieldCKEditor/InputfieldCKEditor.min.js +++ b/wire/modules/Inputfield/InputfieldCKEditor/InputfieldCKEditor.min.js @@ -1 +1 @@ -function ckeGetProcessWireConfig(c){var e=typeof c=="string"?c:c.name;var d=e.replace("Inputfield_","InputfieldCKEditor_");var a="";var b={};d=d.replace("Inputfield_","InputfieldCKEditor_");if(typeof ProcessWire.config[d]=="undefined"&&d.indexOf("_repeater")>0){console.log("configName="+d);d=d.replace(/_repeater[0-9]+/,"");a=$("#"+e).closest(".InputfieldRepeaterItem")}if(typeof ProcessWire.config[d]=="undefined"&&d.indexOf("_ckeditor")>0){d=d.replace(/_ckeditor$/,"")}if(typeof ProcessWire.config[d]=="undefined"){b.error="Cannot find CKEditor settings for "+d}else{b=ProcessWire.config[d]}if(a.length){b.repeaterItem=a}else{b.repeaterItem=""}return b}function ckeLoadPlugins(){for(var a in ProcessWire.config.InputfieldCKEditor.plugins){var b=ProcessWire.config.InputfieldCKEditor.plugins[a];CKEDITOR.plugins.addExternal(a,b,"")}}ckeLoadPlugins();function ckeBlurEvent(b){var a=b.editor;var c=$(a.element.$);if(a.checkDirty()){if(c.length){if(c.is("textarea")){c.change()}c.closest(".Inputfield").addClass("InputfieldStateChanged")}}}function ckeFocusEvent(b){var a=b.editor;var c=$(a.element.$);c.trigger("pw-focus")}function ckeResizeEvent(b){var a=b.editor;var c=$(a.element.$);if(c.length){c.closest(".Inputfield").trigger("heightChanged")}}function ckeUploadEvent(e){var g=e.data.fileLoader.xhr;var b=e.data.fileLoader;var d=ckeGetProcessWireConfig(e.editor);var c=d?d.pwUploadField:"_unknown";var f=$("#Inputfield_"+c);if(typeof d.repeaterItem!="undefined"&&d.repeaterItem.length){var a=d.repeaterItem.find(".InputfieldImage:not(.InputfieldFileSingle)");if(a.length){f=a}}if(f.length){g.open("POST",b.uploadUrl,true);f.trigger("pwimageupload",{name:b.fileName,file:b.file,xhr:g});e.stop()}else{if(typeof d.error!="undefined"&&d.error.length){ProcessWire.alert(d.error)}else{ProcessWire.alert("Unable to find images field for upload")}e.stop();return false}}function ckeInitEvents(b){b.on("blur",ckeBlurEvent);b.on("focus",ckeFocusEvent);b.on("change",ckeBlurEvent);b.on("resize",ckeResizeEvent);b.on("fileUploadRequest",ckeUploadEvent,null,null,4);var c=$(b.element.$);var a=c.closest(".Inputfield.InputfieldColumnWidth");if(a.length){setTimeout(function(){a.trigger("heightChanged")},1000)}}function ckeSaveReadyInline(b){if(!b.length){return}var a=b.hasClass(".InputfieldCKEditorInline")?b:b.find(".InputfieldCKEditorInline");if(a.length){a.each(function(){var f=$(this);var d;if(f.hasClass("InputfieldCKEditorLoaded")){var c=CKEDITOR.instances[f.attr("id")];if(typeof c!="undefined"){if(c.focusManager.hasFocus){c.focusManager.focus(true);c.focus()}d=c.getData()}}else{d=f.html()}var e=f.next("input");e.attr("value",d)})}}function ckeSaveReadyNormal(b){var a=b.hasClass("InputfieldCKEditorNormal")?b:b.find(".InputfieldCKEditorNormal");a.each(function(){var d=$(this);if(!d.hasClass("InputfieldCKEditorLoaded")){return}var c=CKEDITOR.instances[d.attr("id")];c.updateElement()})}function ckeInlineMouseoverEvent(b){var d=$(this);if(d.hasClass("InputfieldCKEditorLoaded")){return}d.effect("highlight",{},500);d.attr("contenteditable","true");var c=d.attr("data-configName");var a=CKEDITOR.inline($(this).attr("id"),ProcessWire.config[c]);ckeInitEvents(a);d.addClass("InputfieldCKEditorLoaded")}function ckeInitTab(c,e){var h=e.newTab;var d=h.find("a");if(d.hasClass("InputfieldCKEditor_init")){return}var a=d.attr("data-editorID");var g=d.attr("data-configName");var b=CKEDITOR.replace(a,config[g]);ckeInitEvents(b);d.addClass("InputfieldCKEditor_init");e.oldTab.find("a").addClass("InputfieldCKEditor_init");var f=$("#"+a);f.addClass("InputfieldCKEditorLoaded")}function ckeInitNormal(a){var f=$("#"+a);var e=f.parent();if(typeof ProcessWire.config.InputfieldCKEditor.editors[a]!="undefined"){var d=ProcessWire.config.InputfieldCKEditor.editors[a]}else{var d=f.attr("data-configName")}if(e.hasClass("ui-tabs-panel")&&e.css("display")=="none"){var g=f.parent().attr("id");var c=e.closest(".ui-tabs, .langTabs").find("a[href=#"+g+"]");c.attr("data-editorID",a).attr("data-configName",d);e.closest(".ui-tabs, .langTabs").on("tabsactivate",ckeInitTab)}else{var b=CKEDITOR.replace(a,ProcessWire.config[d]);ckeInitEvents(b);f.addClass("InputfieldCKEditorLoaded")}}$(document).ready(function(){CKEDITOR.timestamp=ProcessWire.config.InputfieldCKEditor.timestamp;for(var a in ProcessWire.config.InputfieldCKEditor.editors){ckeInitNormal(a)}$(document).on("reloaded",".InputfieldCKEditor",function(){var b=$(this).find(".InputfieldCKEditorNormal:not(.InputfieldCKEditorLoaded)");b.each(function(){ckeInitNormal($(this).attr("id"))});return false});CKEDITOR.disableAutoInline=true;$(document).on("mouseover",".InputfieldCKEditorInlineEditor",ckeInlineMouseoverEvent);$(document).on("submit","form.InputfieldForm",function(){ckeSaveReadyInline($(this))});$(document).on("saveReady",".InputfieldCKEditor",function(){ckeSaveReadyNormal($(this));ckeSaveReadyInline($(this))})}); \ No newline at end of file +function ckeGetProcessWireConfig(c){var e=typeof c=="string"?c:c.name;var d=e.replace("Inputfield_","InputfieldCKEditor_");var a="";var b={};d=d.replace("Inputfield_","InputfieldCKEditor_");if(typeof ProcessWire.config[d]=="undefined"&&d.indexOf("_repeater")>0){d=d.replace(/_repeater[0-9]+/,"");a=$("#"+e).closest(".InputfieldRepeaterItem")}if(typeof ProcessWire.config[d]=="undefined"&&d.indexOf("_ckeditor")>0){d=d.replace(/_ckeditor$/,"")}if(typeof ProcessWire.config[d]=="undefined"){b.error="Cannot find CKEditor settings for "+d}else{b=ProcessWire.config[d]}if(a.length){b.repeaterItem=a}else{b.repeaterItem=""}return b}function ckeLoadPlugins(){for(var a in ProcessWire.config.InputfieldCKEditor.plugins){var b=ProcessWire.config.InputfieldCKEditor.plugins[a];CKEDITOR.plugins.addExternal(a,b,"")}}ckeLoadPlugins();function ckeBlurEvent(b){var a=b.editor;var c=$(a.element.$);if(a.checkDirty()){if(c.length){if(c.is("textarea")){c.change()}c.closest(".Inputfield").addClass("InputfieldStateChanged")}}}function ckeFocusEvent(b){var a=b.editor;var c=$(a.element.$);c.trigger("pw-focus")}function ckeResizeEvent(b){var a=b.editor;var c=$(a.element.$);if(c.length){c.closest(".Inputfield").trigger("heightChanged")}}function ckeUploadEvent(e){var g=e.data.fileLoader.xhr;var b=e.data.fileLoader;var d=ckeGetProcessWireConfig(e.editor);var c=d?d.pwUploadField:"_unknown";var f=$("#Inputfield_"+c);if(typeof d.repeaterItem!="undefined"&&d.repeaterItem.length){var a=d.repeaterItem.find(".InputfieldImage:not(.InputfieldFileSingle)");if(a.length){f=a}}if(f.length){g.open("POST",b.uploadUrl,true);f.trigger("pwimageupload",{name:b.fileName,file:b.file,xhr:g});e.stop()}else{if(typeof d.error!="undefined"&&d.error.length){ProcessWire.alert(d.error)}else{ProcessWire.alert("Unable to find images field for upload")}e.stop();return false}}function ckeInitEvents(b){b.on("blur",ckeBlurEvent);b.on("focus",ckeFocusEvent);b.on("change",ckeBlurEvent);b.on("resize",ckeResizeEvent);b.on("fileUploadRequest",ckeUploadEvent,null,null,4);var c=$(b.element.$);var a=c.closest(".Inputfield.InputfieldColumnWidth");if(a.length){setTimeout(function(){a.trigger("heightChanged")},1000)}}function ckeSaveReadyInline(b){if(!b.length){return}var a=b.hasClass(".InputfieldCKEditorInline")?b:b.find(".InputfieldCKEditorInline");if(a.length){a.each(function(){var f=$(this);var d;if(f.hasClass("InputfieldCKEditorLoaded")){var c=CKEDITOR.instances[f.attr("id")];if(typeof c!="undefined"){if(c.focusManager.hasFocus){c.focusManager.focus(true);c.focus()}d=c.getData()}}else{d=f.html()}var e=f.next("input");e.attr("value",d)})}}function ckeSaveReadyNormal(b){var a=b.hasClass("InputfieldCKEditorNormal")?b:b.find(".InputfieldCKEditorNormal");a.each(function(){var d=$(this);if(!d.hasClass("InputfieldCKEditorLoaded")){return}var c=CKEDITOR.instances[d.attr("id")];c.updateElement()})}function ckeInlineMouseoverEvent(b){var d=$(this);if(d.hasClass("InputfieldCKEditorLoaded")){return}d.effect("highlight",{},500);d.attr("contenteditable","true");var c=d.attr("data-configName");var a=CKEDITOR.inline($(this).attr("id"),ProcessWire.config[c]);ckeInitEvents(a);d.addClass("InputfieldCKEditorLoaded")}function ckeInitTab(c,e){var h=e.newTab;var d=h.find("a");if(d.hasClass("InputfieldCKEditor_init")){return}var a=d.attr("data-editorID");var g=d.attr("data-configName");var b=CKEDITOR.replace(a,config[g]);ckeInitEvents(b);d.addClass("InputfieldCKEditor_init");e.oldTab.find("a").addClass("InputfieldCKEditor_init");var f=$("#"+a);f.addClass("InputfieldCKEditorLoaded")}function ckeInitNormal(a){var f=$("#"+a);var e=f.parent();if(typeof ProcessWire.config.InputfieldCKEditor.editors[a]!="undefined"){var d=ProcessWire.config.InputfieldCKEditor.editors[a]}else{var d=f.attr("data-configName")}if(e.hasClass("ui-tabs-panel")&&e.css("display")=="none"){var g=f.parent().attr("id");var c=e.closest(".ui-tabs, .langTabs").find("a[href=#"+g+"]");c.attr("data-editorID",a).attr("data-configName",d);e.closest(".ui-tabs, .langTabs").on("tabsactivate",ckeInitTab)}else{var b=CKEDITOR.replace(a,ProcessWire.config[d]);ckeInitEvents(b);f.addClass("InputfieldCKEditorLoaded")}}$(document).ready(function(){CKEDITOR.timestamp=ProcessWire.config.InputfieldCKEditor.timestamp;for(var a in ProcessWire.config.InputfieldCKEditor.editors){ckeInitNormal(a)}$(document).on("reloaded",".InputfieldCKEditor",function(){var b=$(this).find(".InputfieldCKEditorNormal:not(.InputfieldCKEditorLoaded)");b.each(function(){ckeInitNormal($(this).attr("id"))});return false});CKEDITOR.disableAutoInline=true;$(document).on("mouseover",".InputfieldCKEditorInlineEditor",ckeInlineMouseoverEvent);$(document).on("submit","form.InputfieldForm",function(){ckeSaveReadyInline($(this))});$(document).on("saveReady",".InputfieldCKEditor",function(){ckeSaveReadyNormal($(this));ckeSaveReadyInline($(this))})}); \ No newline at end of file diff --git a/wire/modules/Inputfield/InputfieldImage/InputfieldImage.module b/wire/modules/Inputfield/InputfieldImage/InputfieldImage.module index 2b523678..075f7e11 100755 --- a/wire/modules/Inputfield/InputfieldImage/InputfieldImage.module +++ b/wire/modules/Inputfield/InputfieldImage/InputfieldImage.module @@ -1446,6 +1446,11 @@ class InputfieldImage extends InputfieldFile implements InputfieldItemList, Inpu $success = $this->processUnknownFileAction($pagefile, $action, $label); } + if($success) { + $pagefile->trackChange("action-$action"); + $this->trackChange('value'); + } + if($success && $showSuccess) { $this->message(sprintf($this->_('Executed action ā€œ%1$sā€ on file %2$s'), $label, $pagefile->basename)); } else if($success === false) {