From 360d1eb48c10f89d3faaee1ca5080075b355def8 Mon Sep 17 00:00:00 2001 From: Chris Turnbull Date: Tue, 9 Jan 2018 17:09:59 +0000 Subject: [PATCH] Syncing our private svn repo with the public repo on GitHub: - If running on an installation of PHP that is not built with the apache_get_modules() function, the CMS will now no longer crash on the system requirements/diagnostics screen. - Fixed a JavaScript error that could occur on TUIX forms upon pressing the submit button. - Fixed some glitched styling that was being applied to the Prev/Next buttons in Floating Admin Boxes when creating a plugin, or editing the settings of a plugin with a preview window open. - Fixed a bug where the images used by library plugins were not correctly tracked, leading to Organizer to sometimes claim that images were unused when they were in fact in use. --- .../db_updates/latest_revision_no.inc.php | 4 +- .../content_tables.inc.php | 21 +++++++- zenario/api/admin_box_schema.yaml | 9 ++++ zenario/autoload/contentAdm.php | 29 +++++++---- zenario/autoload/tuix.php | 1 + zenario/autoload/welcome.php | 44 +++++++++-------- zenario/js/admin_box.js | 5 +- zenario/js/admin_box.min.js | 24 +++++----- zenario/js/form.js | 22 ++++++--- zenario/js/form.min.js | 48 +++++++++---------- zenario/js/tidy_libs.shell.php | 13 +++++ .../microtemplates/fea_row.html | 8 +++- .../classes/admin_boxes/plugin_settings.php | 22 +-------- .../classes/admin_boxes/site_settings.php | 2 +- zenario/styles/admin_floating_box.css | 28 ++++++++++- zenario/styles/admin_floating_box.min.css | 11 +++-- .../templates/grid_templates/L01.tpl.php | 4 +- .../templates/grid_templates/L02.tpl.php | 4 +- 18 files changed, 192 insertions(+), 107 deletions(-) diff --git a/zenario/admin/db_updates/latest_revision_no.inc.php b/zenario/admin/db_updates/latest_revision_no.inc.php index 717736c7e..b9af6b411 100644 --- a/zenario/admin/db_updates/latest_revision_no.inc.php +++ b/zenario/admin/db_updates/latest_revision_no.inc.php @@ -27,7 +27,7 @@ */ if (!defined('NOT_ACCESSED_DIRECTLY')) exit('This file may not be directly accessed'); -define('LATEST_REVISION_NO', 43722); //N.b. 8.0 starts at revision #43770 +define('LATEST_REVISION_NO', 43723); //N.b. 8.0 starts at revision #43770 define('LATEST_BIG_CHANGE_REVISION_NO', 43721); define('INSTALLER_REVISION_NO', 41600); define('INSTALLER_DEFAULT_THEME', 'duke_street'); @@ -37,6 +37,6 @@ define('ZENARIO_MAJOR_VERSION', '8'); define('ZENARIO_MINOR_VERSION', '0'); define('ZENARIO_IS_BUILD', true); -define('ZENARIO_REVISION', '44237'); +define('ZENARIO_REVISION', '44273'); define('TINYMCE_DIR', 'zenario/libs/manually_maintained/lgpl/tinymce_4_5_7/'); \ No newline at end of file diff --git a/zenario/admin/db_updates/step_4_migrate_the_data/content_tables.inc.php b/zenario/admin/db_updates/step_4_migrate_the_data/content_tables.inc.php index 40ce3c05f..e3c81559e 100644 --- a/zenario/admin/db_updates/step_4_migrate_the_data/content_tables.inc.php +++ b/zenario/admin/db_updates/step_4_migrate_the_data/content_tables.inc.php @@ -452,4 +452,23 @@ ze\menuAdm::recalcAllHierarchy(); ze\dbAdm::revision(43720); -} \ No newline at end of file +} + + + +//Fix any bad data left over from a bug where the images used by library plugins were not correctly tracked in the linking tables +if (ze\dbAdm::needRevision(43723)) { + + $sql = " + SELECT id, content_id, content_type, content_version + FROM ". DB_NAME_PREFIX. "plugin_instances + WHERE content_id = 0"; + + $result = ze\sql::select($sql); + while ($instance = ze\sql::fetchAssoc($result)) { + ze\contentAdm::resyncLibraryPluginFiles($instance['id'], $instance); + } + + ze\dbAdm::revision(43723); +} + diff --git a/zenario/api/admin_box_schema.yaml b/zenario/api/admin_box_schema.yaml index 0c859906e..0741e7efa 100644 --- a/zenario/api/admin_box_schema.yaml +++ b/zenario/api/admin_box_schema.yaml @@ -2386,6 +2386,15 @@ additionalProperties: From version 7.3 onwards the CMS will automatically apply a substr() when the field is saved. + error_on_form_message: + type: string + description: > + If there is an error on the form, display this message just above this field. + (Does not work for fields with the same_row property.) + + This works in FEA forms, from version 8.0 onwards. + + rows: type: integer description: Sets the rows HTML attribute (doesn't apply to code or html editors). For multiple checkboxes/radiogroups, this will apply to each checkbox/radio option, unless overwritten. diff --git a/zenario/autoload/contentAdm.php b/zenario/autoload/contentAdm.php index 10bc38323..3e855fe5f 100644 --- a/zenario/autoload/contentAdm.php +++ b/zenario/autoload/contentAdm.php @@ -512,16 +512,29 @@ public static function resyncLibraryPluginFiles($instanceId, $instance = null) { \ze\contentAdm::syncInlineFileContentLink($instance['content_id'], $instance['content_type'], $instance['content_version']); } else { - $sql = ' - SELECT foreign_key_id AS id - FROM '. DB_NAME_PREFIX. 'plugin_settings - WHERE foreign_key_to = \'file\' - AND instance_id = '. (int) $instanceId; - - $syncLibraryPluginFiles = \ze\sql::fetchAssocs($sql, false, 'id'); + //Get all of the images used in a plugin's settings + $fileIds = []; + $sql = " + SELECT value + FROM ". DB_NAME_PREFIX. "plugin_settings + WHERE foreign_key_to IN('file', 'multiple_files') + AND instance_id = ". (int) $instanceId; + $result = \ze\sql::select($sql); + + while ($fileIdsInPlugin = \ze\sql::fetchRow($result)) { + foreach (\ze\ray::explodeAndTrim($fileIdsInPlugin[0], true) as $fileId) { + $fileIds[$fileId] = $fileId; + } + } + + if (empty($fileIds)) { + $files = []; + } else { + $files = \ze\row::getArray('files', ['id', 'usage', 'privacy'], ['id' => $fileIds]); + } \ze\contentAdm::syncInlineFiles( - $syncLibraryPluginFiles, + $files, ['foreign_key_to' => 'library_plugin', 'foreign_key_id' => $instanceId], $keepOldImagesThatAreNotInUse = false); } diff --git a/zenario/autoload/tuix.php b/zenario/autoload/tuix.php index a2eeadacd..8898a27d3 100644 --- a/zenario/autoload/tuix.php +++ b/zenario/autoload/tuix.php @@ -1649,6 +1649,7 @@ public static function translatePhrasesInObject(&$t, &$o, &$p, &$c, &$l, &$s, $o if (isset($t[$i='side_note'])) \ze\tuix::translatePhrase($t, $o, $p, $c, $l, $s, $i); if (isset($t[$i='note_below'])) \ze\tuix::translatePhrase($t, $o, $p, $c, $l, $s, $i); if (isset($t[$i='empty_value'])) \ze\tuix::translatePhrase($t, $o, $p, $c, $l, $s, $i); + if (isset($t[$i='error_on_form_message'])) \ze\tuix::translatePhrase($t, $o, $p, $c, $l, $s, $i); if (isset($t[$i='validation']) && is_array($t[$i])) { foreach ($t[$i] as $j => $object) { diff --git a/zenario/autoload/welcome.php b/zenario/autoload/welcome.php index d97b16551..8b69a36e3 100644 --- a/zenario/autoload/welcome.php +++ b/zenario/autoload/welcome.php @@ -532,29 +532,33 @@ public static function systemRequirementsAJAX(&$source, &$tags, &$fields, &$valu $optionalRequirementsMet = true; - $apacheModules = apache_get_modules(); - if (!in_array('mod_deflate', $apacheModules)) { - $optionalRequirementsMet = false; - $fields['0/optional_mod_deflate']['row_class'] = $warning; - - } else { - $fields['0/optional_mod_deflate']['row_class'] = $valid; - } - if (!in_array('mod_expires', $apacheModules)) { - $optionalRequirementsMet = false; - $fields['0/optional_mod_expires']['row_class'] = $warning; - - } else { - $fields['0/optional_mod_expires']['row_class'] = $valid; - } - if (!in_array('mod_rewrite', $apacheModules)) { - $optionalRequirementsMet = false; - $fields['0/optional_mod_rewrite']['row_class'] = $warning; - + $fields['0/optional_mod_deflate']['row_class'] = $valid; + $fields['0/optional_mod_expires']['row_class'] = $valid; + $fields['0/optional_mod_rewrite']['row_class'] = $valid; + + if (!function_exists('apache_get_modules')) { + $fields['0/optional_mod_deflate']['hidden'] = true; + $fields['0/optional_mod_expires']['hidden'] = true; + $fields['0/optional_mod_rewrite']['hidden'] = true; + } else { - $fields['0/optional_mod_rewrite']['row_class'] = $valid; + $apacheModules = apache_get_modules(); + + if (!in_array('mod_deflate', $apacheModules)) { + $optionalRequirementsMet = false; + $fields['0/optional_mod_deflate']['row_class'] = $warning; + } + if (!in_array('mod_expires', $apacheModules)) { + $optionalRequirementsMet = false; + $fields['0/optional_mod_expires']['row_class'] = $warning; + } + if (!in_array('mod_rewrite', $apacheModules)) { + $optionalRequirementsMet = false; + $fields['0/optional_mod_rewrite']['row_class'] = $warning; + } } + if (!extension_loaded('curl')) { $optionalRequirementsMet = false; $fields['0/optional_curl']['row_class'] = $warning; diff --git a/zenario/js/admin_box.js b/zenario/js/admin_box.js index 61570f7ef..964771e02 100644 --- a/zenario/js/admin_box.js +++ b/zenario/js/admin_box.js @@ -101,6 +101,7 @@ zenarioAB.updateHash = function() { zenarioAB.setTitle = function(isReadOnly) { var title, values, c, v, string2, identifier, id, + $zenario_fabBox = $('#zenario_fabBox'), $zenario_fabId = $('#zenario_fabId'); if (!(title = zenarioAB.getTitle())) { @@ -123,8 +124,10 @@ zenarioAB.setTitle = function(isReadOnly) { && (identifier.value = identifier.value || (zenarioAB.tuix.key.id && zenario.decodeItemIdForOrganizer(zenarioAB.tuix.key.id)))) { $zenario_fabId.show().html(zenarioAB.microTemplate(this.mtPrefix + '_identifier', identifier)); + $zenario_fabBox.addClass('zfab_with_identifier'); } else { $zenario_fabId.hide(); + $zenario_fabBox.removeClass('zfab_with_identifier'); } if (zenarioO.path && zenarioO.tuix) { @@ -166,11 +169,9 @@ zenarioAB.size = function(refresh) { if (get('zenario_fbMain')) { if (hideTabBar) { get('zenario_fbMain').style.top = '0px'; - get('zenario_fbButtons').style.paddingBottom = '7px'; get('zenario_fabTabs').style.display = 'none'; } else { get('zenario_fbMain').style.top = '24px'; - get('zenario_fbButtons').style.paddingBottom = '31px'; get('zenario_fabTabs').style.display = zenario.browserIsIE()? '' : 'inherit'; } } diff --git a/zenario/js/admin_box.min.js b/zenario/js/admin_box.min.js index 6cba00e70..e5225419e 100644 --- a/zenario/js/admin_box.min.js +++ b/zenario/js/admin_box.min.js @@ -1,17 +1,17 @@ -zenario.lib(function(m,r,x,n,y,z,g,p,A,a,B,h,C,s,v,e,w,D,E,F,t,q,u){a.openingKey={};a.start=function(b,c,d,f){a.openingKey=c;h._lM(function(){t(u).start.call(a,b,c,d,f)})};a.openBox=function(b){p._oB(b,a.baseCSSClass,"AdminFloatingBox",!1,960,50,2,!0,!0,".zenario_fabHead",!1);e("zenario_fbAdminFloatingBox").style.display="none"};a.closeBox=function(){p._cB("AdminFloatingBox");a._uH()};a.updateHash=function(){h.path&&h.tuix&&h._sH()};a.setTitle=function(b){var c,d,f=$("#zenario_fabId");(c=a.getTitle())? -($("#zenario_fabTitleWrap").css("display","block"),$("#zenario_fabTitleWrap").addClass(" zenario_no_drag"),e("zenario_fabTitle").innerHTML=w(c)):$("#zenario_fabTitleWrap").css("display","none");b?$("#zenario_fabBox_readonlyMarker").css("display","block"):$("#zenario_fabBox_readonlyMarker").css("display","none");a.tuix.key&&(d=a.tuix.identifier)&&(d.value=d.value||a.tuix.key.id&&g._dIIFO(a.tuix.key.id))?f.show().html(a.microTemplate(this.mtPrefix+"_identifier",d)):f.hide();h.path&&h.tuix&&h._sH()}; -a.lastSize=!1;a.previewHidden=!0;a.size=function(b){a.sizing&&clearTimeout(a.sizing);var c=Math.floor($(n).width()),d=Math.floor($(n).height()),f;c&&d&&!a.isSlidUp&&((f=a.lastSize!=c+"x"+d)||b)&&(a.lastSize=c+"x"+d,f=a.tuix&&v(a.tuix.hide_tab_bar),e("zenario_fbMain")&&(f?(e("zenario_fbMain").style.top="0px",e("zenario_fbButtons").style.paddingBottom="7px",e("zenario_fabTabs").style.display="none"):(e("zenario_fbMain").style.top="24px",e("zenario_fbButtons").style.paddingBottom="31px",e("zenario_fabTabs").style.display= -g._bII()?"":"inherit")),b=193,f&&(b-=53),b+=$("#zenario_fabTitleWrap").height(),d=Math.floor(0.96*d),maxBoxWidth=Math.floor(0.96*c),c=d-b,(f=1*(a.tuix&&a.tuix.max_height))&&c>f&&(c=f,d=f+b),c&&0maxBoxWidth)?(c=800, -a.previewWidth=a.previewValues=a.lastPreviewValues=!1):(c=a.previewSlotWidth?Math.min(maxBoxWidth,804+a.previewSlotWidth):maxBoxWidth,a.previewWidth=c-800-4,$("#zenario_fabPreview").width(a.previewWidth),a.previewSlotWidthInfo?$("#zenario_fabPreviewInfo").show().text(a.previewSlotWidthInfo):$("#zenario_fabPreviewInfo").hide())):($("#zenario_fabBox").width(960),c=960,a.previewWidth=a.previewValues=a.lastPreviewValues=!1,previewHidden=!0),a.hasPreviewWindow?previewHidden?$("#zenario_fbAdminFloatingBox").removeClass("zenario_fab_with_no_preview").addClass("zenario_fab_with_preview").addClass("zenario_fab_with_preview_hidden").removeClass("zenario_fab_with_preview_shown"): +zenario.lib(function(m,r,x,n,y,z,h,p,A,a,B,k,C,s,v,e,w,D,E,F,t,q,u){a.openingKey={};a.start=function(b,c,d,f){a.openingKey=c;k._lM(function(){t(u).start.call(a,b,c,d,f)})};a.openBox=function(b){p._oB(b,a.baseCSSClass,"AdminFloatingBox",!1,960,50,2,!0,!0,".zenario_fabHead",!1);e("zenario_fbAdminFloatingBox").style.display="none"};a.closeBox=function(){p._cB("AdminFloatingBox");a._uH()};a.updateHash=function(){k.path&&k.tuix&&k._sH()};a.setTitle=function(b){var c,d,f=$("#zenario_fabBox"),g=$("#zenario_fabId"); +(c=a.getTitle())?($("#zenario_fabTitleWrap").css("display","block"),$("#zenario_fabTitleWrap").addClass(" zenario_no_drag"),e("zenario_fabTitle").innerHTML=w(c)):$("#zenario_fabTitleWrap").css("display","none");b?$("#zenario_fabBox_readonlyMarker").css("display","block"):$("#zenario_fabBox_readonlyMarker").css("display","none");a.tuix.key&&(d=a.tuix.identifier)&&(d.value=d.value||a.tuix.key.id&&h._dIIFO(a.tuix.key.id))?(g.show().html(a.microTemplate(this.mtPrefix+"_identifier",d)),f.addClass("zfab_with_identifier")): +(g.hide(),f.removeClass("zfab_with_identifier"));k.path&&k.tuix&&k._sH()};a.lastSize=!1;a.previewHidden=!0;a.size=function(b){a.sizing&&clearTimeout(a.sizing);var c=Math.floor($(n).width()),d=Math.floor($(n).height()),f;c&&d&&!a.isSlidUp&&((f=a.lastSize!=c+"x"+d)||b)&&(a.lastSize=c+"x"+d,f=a.tuix&&v(a.tuix.hide_tab_bar),e("zenario_fbMain")&&(f?(e("zenario_fbMain").style.top="0px",e("zenario_fabTabs").style.display="none"):(e("zenario_fbMain").style.top="24px",e("zenario_fabTabs").style.display=h._bII()? +"":"inherit")),b=193,f&&(b-=53),b+=$("#zenario_fabTitleWrap").height(),d=Math.floor(0.96*d),maxBoxWidth=Math.floor(0.96*c),c=d-b,(f=1*(a.tuix&&a.tuix.max_height))&&c>f&&(c=f,d=f+b),c&&0maxBoxWidth)?(c=800,a.previewWidth= +a.previewValues=a.lastPreviewValues=!1):(c=a.previewSlotWidth?Math.min(maxBoxWidth,804+a.previewSlotWidth):maxBoxWidth,a.previewWidth=c-800-4,$("#zenario_fabPreview").width(a.previewWidth),a.previewSlotWidthInfo?$("#zenario_fabPreviewInfo").show().text(a.previewSlotWidthInfo):$("#zenario_fabPreviewInfo").hide())):($("#zenario_fabBox").width(960),c=960,a.previewWidth=a.previewValues=a.lastPreviewValues=!1,previewHidden=!0),a.hasPreviewWindow?previewHidden?$("#zenario_fbAdminFloatingBox").removeClass("zenario_fab_with_no_preview").addClass("zenario_fab_with_preview").addClass("zenario_fab_with_preview_hidden").removeClass("zenario_fab_with_preview_shown"): $("#zenario_fbAdminFloatingBox").removeClass("zenario_fab_with_no_preview").addClass("zenario_fab_with_preview").removeClass("zenario_fab_with_preview_hidden").addClass("zenario_fab_with_preview_shown"):$("#zenario_fbAdminFloatingBox").addClass("zenario_fab_with_no_preview").removeClass("zenario_fab_with_preview").removeClass("zenario_fab_with_preview_hidden").removeClass("zenario_fab_with_preview_shown"),a.previewHidden!=previewHidden&&((a.previewHidden=previewHidden)||a.updatePreview()),p._aB("AdminFloatingBox", !1,c,50,2),a._mFATAP());a.sizing=setTimeout(a.size,250)};a.makeFieldAsTallAsPossible=function(){var b=a.tallAsPossibleField,c=a.tallAsPossibleFieldType,d,f,e,l;s(b)&&"editor"!=c&&(d=a.tabContainerHeight)&&(d-=20,f=a.get(b))&&(e=$(f),e.height(""),f=$("#zenario_abtab").outerHeight(),d>f&&(e.height(e.height()+d-f),"code_editor"==c&&(l=ace.edit(b))&&l.resize()))};a.slideToggle=function(){a.isSlidUp?a._sD():a._sU()};a.slideUp=function(){if(!a.isSlidUp){var b=$("#zenario_fabBox_Header").height(),c=$("#zenario_fabBox"); a.heightBeforeSlideUp=c.height();$("#zenario_fabBox_Body").stop(!0).slideUp();c.stop(!0).animate({height:b});$("#zenario_fabSlideToggle").addClass("zenario_fabSlideToggleUp").removeClass("zenario_fabSlideToggleDown");a.isSlidUp=!0}};a.slideDown=function(){a.isSlidUp&&($("#zenario_fabBox_Body").stop(!0).slideDown(),$("#zenario_fabBox").stop(!0).animate({height:a.heightBeforeSlideUp},function(){a._s(!0)}),$("#zenario_fabSlideToggle").addClass("zenario_fabSlideToggleDown").removeClass("zenario_fabSlideToggleUp"), -a.isSlidUp=!1)};a.clickTab=function(b){a._sD();t(u).clickTab.call(a,b)};a.validateAlias=function(){g._aADINS("validateAlias",function(){a._vAG()})};a.validateAliasGo=function(){var b=e("alias");b&&(b={_validate_alias:1,alias:b.value},a.tuix.key.cID&&(b.cID=a.tuix.key.cID),a.tuix.key.cType&&(b.cType=a.tuix.key.cType),a.tuix.key.equivId&&(b.equivId=a.tuix.key.equivId),e("language_id")&&(b.langId=e("language_id").value),e("update_translations")&&(b.lang_code_in_url="show","update_this"==e("update_translations").value&& -e("lang_code_in_url")&&(b.lang_code_in_url=e("lang_code_in_url").value)),g._a(r+"zenario/admin/quick_ajax.php",b,!0).after(function(a){var b="",f=e("alias_warning_display");if(a)for(var k in a)q(a,k)&&(b+=(b?"
":"")+a[k]);f&&(f.innerHTML=b)}))};a.generateAlias=function(a){return a.toLowerCase().replace(/[\u00e1\u00c1\u00e0\u00c0\u00e2\u00c2\u00e5\u00c5\u00e4\u00c4\u00e3\u00c3\u00c6\u00e6\u00e7\u00c7\u00f0\u00d0\u00e9\u00c9\u00e8\u00c8\u00ea\u00ca\u00eb\u00cb\u00ed\u00cd\u00ec\u00cc\u00ee\u00ce\u00ef\u00cf\u00f1\u00d1\u00f3\u00d3\u00f2\u00d2\u00f4\u00d4\u00f6\u00d6\u00f5\u00d5\u00f8\u00d8\u0161\u0160\u00fa\u00da\u00f9\u00d9\u00fb\u00db\u00fc\u00dc\u00fd\u00dd\u017e\u017d]/g, +a.isSlidUp=!1)};a.clickTab=function(b){a._sD();t(u).clickTab.call(a,b)};a.validateAlias=function(){h._aADINS("validateAlias",function(){a._vAG()})};a.validateAliasGo=function(){var b=e("alias");b&&(b={_validate_alias:1,alias:b.value},a.tuix.key.cID&&(b.cID=a.tuix.key.cID),a.tuix.key.cType&&(b.cType=a.tuix.key.cType),a.tuix.key.equivId&&(b.equivId=a.tuix.key.equivId),e("language_id")&&(b.langId=e("language_id").value),e("update_translations")&&(b.lang_code_in_url="show","update_this"==e("update_translations").value&& +e("lang_code_in_url")&&(b.lang_code_in_url=e("lang_code_in_url").value)),h._a(r+"zenario/admin/quick_ajax.php",b,!0).after(function(a){var b="",f=e("alias_warning_display");if(a)for(var g in a)q(a,g)&&(b+=(b?"
":"")+a[g]);f&&(f.innerHTML=b)}))};a.generateAlias=function(a){return a.toLowerCase().replace(/[\u00e1\u00c1\u00e0\u00c0\u00e2\u00c2\u00e5\u00c5\u00e4\u00c4\u00e3\u00c3\u00c6\u00e6\u00e7\u00c7\u00f0\u00d0\u00e9\u00c9\u00e8\u00c8\u00ea\u00ca\u00eb\u00cb\u00ed\u00cd\u00ec\u00cc\u00ee\u00ce\u00ef\u00cf\u00f1\u00d1\u00f3\u00d3\u00f2\u00d2\u00f4\u00d4\u00f6\u00d6\u00f5\u00d5\u00f8\u00d8\u0161\u0160\u00fa\u00da\u00f9\u00d9\u00fb\u00db\u00fc\u00dc\u00fd\u00dd\u017e\u017d]/g, function(a){return{"\u00e1":"a","\u00c1":"A","\u00e0":"a","\u00c0":"A","\u00e2":"a","\u00c2":"A","\u00e5":"a","\u00c5":"A","\u00e4":"a","\u00c4":"A","\u00e3":"a","\u00c3":"A","\u00c6":"AE","\u00e6":"ae","\u00e7":"c","\u00c7":"C","\u00f0":"d","\u00d0":"F","\u00e9":"e","\u00c9":"E","\u00e8":"e","\u00c8":"E","\u00ea":"e","\u00ca":"E","\u00eb":"e","\u00cb":"E","\u00ed":"i","\u00cd":"I","\u00ec":"i","\u00cc":"I","\u00ee":"i","\u00ce":"I","\u00ef":"i","\u00cf":"I","\u00f1":"n","\u00d1":"N","\u00f3":"o", "\u00d3":"O","\u00f2":"o","\u00d2":"O","\u00f4":"o","\u00d4":"O","\u00f6":"o","\u00d6":"O","\u00f5":"o","\u00d5":"O","\u00f8":"o","\u00d8":"O","\u0161":"s","\u0160":"S","\u00fa":"u","\u00da":"U","\u00f9":"u","\u00d9":"U","\u00fb":"u","\u00db":"U","\u00fc":"u","\u00dc":"U","\u00fd":"y","\u00dd":"Y","\u017e":"z","\u017d":"Z"}[a]}).replace(/&/g,"and").replace(/[^a-zA-Z0-9\s_-]/g,"").replace(/\s+/g,"-").replace(/^-+/,"").replace(/-+$/,"").replace(/-+/g,"-").substr(0,50)};a.contentTitleChange=function(){var b= -e("menu_text"),c=e("alias");b&&!a.tuix.___menu_text_changed&&(b.value=e("title").value.replace(/\s+/g," "));!c||c.disabled||c.readOnly||a.tuix.___alias_changed||(c.value=a._gA(e("title").value),a._vA())};a.mode=function(){return a.value("mode","first_tab")};a.viewFrameworkSource=function(){var b=r+"zenario/admin/organizer.php#zenario__modules/show_frameworks//"+a.tuix.key.moduleId+"//"+g._eIIFO(a.readField("framework"));n.open(b);return!1};a.svgSelected=function(b){var c=a.field(b);b=a.value(b);var c= -c&&b&&a.pickedItemsArray(c,b),d;if(c)for(d in c)if(q(c,d)&&(b=c[d],_._iS(b)||(b=b.label),b&&b.match(/\.svg( \[.*?\]|)$/i)))return!0;return!1};a.adminPermChange=function(b,c,d,f,k){var l=!0;s(f)||(k=0,f=$("input[name="+c+"]").each(function(a,b){b.checked&&++k}).size());0==k?(l=!1,c="zenario_permgroup_empty"):c=kc&&(a=a.substring(0,c).split(" ").slice(0,-1).join(" ")+" ...");return a};a.init("zenarioAB","zenario_admin_box","zenario_fbAdminFloatingBox");g._sN(a)},zenarioABToolkit); +e("menu_text"),c=e("alias");b&&!a.tuix.___menu_text_changed&&(b.value=e("title").value.replace(/\s+/g," "));!c||c.disabled||c.readOnly||a.tuix.___alias_changed||(c.value=a._gA(e("title").value),a._vA())};a.mode=function(){return a.value("mode","first_tab")};a.viewFrameworkSource=function(){var b=r+"zenario/admin/organizer.php#zenario__modules/show_frameworks//"+a.tuix.key.moduleId+"//"+h._eIIFO(a.readField("framework"));n.open(b);return!1};a.svgSelected=function(b){var c=a.field(b);b=a.value(b);var c= +c&&b&&a.pickedItemsArray(c,b),d;if(c)for(d in c)if(q(c,d)&&(b=c[d],_._iS(b)||(b=b.label),b&&b.match(/\.svg( \[.*?\]|)$/i)))return!0;return!1};a.adminPermChange=function(b,c,d,f,g){var l=!0;s(f)||(g=0,f=$("input[name="+c+"]").each(function(a,b){b.checked&&++g}).size());0==g?(l=!1,c="zenario_permgroup_empty"):c=gc&&(a=a.substring(0,c).split(" ").slice(0,-1).join(" ")+" ...");return a};a.init("zenarioAB","zenario_admin_box","zenario_fbAdminFloatingBox");h._sN(a)},zenarioABToolkit); diff --git a/zenario/js/form.js b/zenario/js/form.js index 743fad898..ced0d9f5a 100644 --- a/zenario/js/form.js +++ b/zenario/js/form.js @@ -590,7 +590,7 @@ methods.drawFields = function(cb, microTemplate, scanForHiddenFieldsWithoutDrawi tabs = this.tuix.tabs[tab], groupings = this.groupings[tab], sortedFields = this.sortedFields[tab], - errorOnForm, + errorOnFormMessage, html = '', groupingIsHidden = false, forceNewRowForNewGrouping, @@ -618,6 +618,7 @@ methods.drawFields = function(cb, microTemplate, scanForHiddenFieldsWithoutDrawi this.ffoving = 0; this.splitValues = {}; this.tallAsPossibleField = undefined; + this.errorOnForm = false; this.disableDragDropUpload(); if (!this.savedAndContinued(tab) && this.editCancelEnabled(tab)) { @@ -635,6 +636,7 @@ methods.drawFields = function(cb, microTemplate, scanForHiddenFieldsWithoutDrawi if (this.editModeOn()) { if (tabs.errors) { foreach (tabs.errors as i => error) { + this.errorOnForm = true; data.errors.push({message: error}); } } @@ -642,9 +644,11 @@ methods.drawFields = function(cb, microTemplate, scanForHiddenFieldsWithoutDrawi if (fields) { foreach (fields as i => field) { if (field.error) { + this.errorOnForm = true; + //If inline errors are enabled, just have one generic error message - if (this.enableInlineErrors() && (errorOnForm = this.tuix.error_on_form_message || phrase.errorOnForm)) { - data.errors.push({message: errorOnForm}); + if (this.enableInlineErrors() && (errorOnFormMessage = this.tuix.error_on_form_message || phrase.errorOnForm)) { + data.errors.push({message: errorOnFormMessage}); break; } else { @@ -962,7 +966,6 @@ methods.focusField = function(field, selectionStart, selectionEnd) { domField.selectionStart = selectionStart; domField.selectionEnd = selectionEnd; } catch (e) { - console.log('Ace editor could not load that language', language); } } } @@ -1076,8 +1079,15 @@ methods.setLastFocus = function(id) { details = {id: id}; if (dom) { - details.ss = dom.selectionStart; - details.se = dom.selectionEnd; + //(N.b. this can cause a crash on some fields/browsers if the selection is set on the wrong type of field, + // so I've put a try/catch here out of paranoia. + try { + details.ss = dom.selectionStart; + details.se = dom.selectionEnd; + } catch (e) { + details.ss = + details.se = undefined; + } } return details; diff --git a/zenario/js/form.min.js b/zenario/js/form.min.js index 2cb6dae26..6c55b995a 100644 --- a/zenario/js/form.min.js +++ b/zenario/js/form.min.js @@ -11,32 +11,32 @@ function(a){return this.toggleLevelsPressed.last};f.retryAJAX=function(a,d,e,b,l function(a,d,e,b){return a};f.hideTab=function(a){var d=this;a?($("#zenario_abtab input").add("#zenario_abtab select").add("#zenario_abtab textarea").attr("disabled","disabled"),$("#zenario_abtab").clearQueue().show().animate({opacity:0.8},200,function(){d.tabHidden=!0;d.draw()})):($("#zenario_abtab input").add("#zenario_abtab select").add("#zenario_abtab textarea").attr("disabled","disabled").animate({opacity:0.9},100),this.tabHidden=!0,this.draw())};f.draw=function(){this.loaded&&this.tabHidden&& this.draw2()};f.draw2=function(){};f.size=function(){};f.makeFieldAsTallAsPossible=function(){};f.drawTabs=function(a){a||(a=this.mtPrefix+"_tab");var d,e,b=[],l,g,s,f,p=function(a,b,d){for(b in a)if(x(a,b)){d=a[b];if(d.onclick){g&&(f=d.id);if(g=d.current)s=l;l=d.id}d.children&&p(d.children)}};for(i in this.sortedTabs)if(x(this.sortedTabs,i)&&(tab=this.sortedTabs[i],(d=this.tuix.tabs[tab])&&!(d._was_hidden_before=I._h(h,this,h,tab,h,h,h,h,d)))){e="";if(d.fields&&!_._isEm(d.fields)||d.fields&&!_._isEm(d.errors)|| d.fields&&!_._isEm(d.notices))e=this.globalName+".clickTab('"+U(tab)+"');";!this.tuix.tab&&e&&(this.tuix.tab=tab);b.push({id:tab,tabId:tab,tuix:d,onclick:e,current:this.tuix.tab==tab,label:d.label})}I._sBK(b,"zenario_fab_tab_with_children");p(b);this.prevTab=s;this.nextTab=f;return this.microTemplate(a,b)};f.drawFields=function(a,d,e){var b,l,g,s=this.tuix.tab,f=this.tuix.tabs[s],p=this.groupings[s],y=this.sortedFields[s],k,t="",A=!1,q,G=this.fields(s),J={},w={},B={},C=!1,F,V,H=!1,D={},z={fields:{}, -rows:[],tabId:s,path:this.path,tuix:this.tuix,revert:"",errors:[],notices:{}};this.drawingFields=!0;if(!e){this.ffoving=0;this.splitValues={};this.tallAsPossibleField=h;this.disableDragDropUpload();!this.savedAndContinued(s)&&this.editCancelEnabled(s)&&(z.revert=fa("class","zenario_editCancelButton",I._i("class","submit","type","button","onclick",this.globalName+".changeMode(); return false;","value",this.editModeOn()?M.cancel:M.edit)));if(this.editModeOn()){if(f.errors)for(q in f.errors)x(f.errors, -q)&&(g=f.errors[q],z.errors.push({message:g}));if(G)for(q in G)if(x(G,q)&&(g=G[q],g.error))if(this.enableInlineErrors()&&(k=this.tuix.error_on_form_message||M.errorOnForm)){z.errors.push({message:k});break}else z.errors.push({message:g.error})}if(f.notices)for(q in f.notices)x(f.notices,q)&&(g=f.notices[q],r(g.show)&&{error:1,warning:1,question:1,success:1}[g.type]&&(z.notices[q]=g));this.setPhiVariables()}for(b in y)x(y,b)&&(l=y[b],g=G[l],q=!1,k=g.grouping,F!==k&&(F=k,H=m(p[k])&&G[p[k]],A=k&&(!H|| -I._h(h,this,h,p[k],h,h,H))),V!==k&&(q=!0),g._id=l,g._html=this.drawField(a,s,l,g,J,w,B,e,A),e||A||!1===g._html||((q||g._startNewRow||!z.rows.length)&&z.rows.push({fields:[],grouping:H}),q&&H&&(H.legend||H.snippet)&&(H=_._ex({grouping:k},H),H._id=k,H._html=this.drawField(a,s,k,H),H._hideOnOpen=!0,H._showOnOpen=!0,H._lastVisibleGrouping=V,V=k,z.rows[z.rows.length-1].fields.push(H),z.fields[k]=H,D[k]=H,z.rows.push({fields:[]})),C||f.show_errors_after_field!=l||(z.rows[z.rows.length-1].errors=z.errors, -z.rows[z.rows.length-1].notices=z.notices,C=!0),g._lastVisibleGrouping=V,V=k,z.rows[z.rows.length-1].fields.push(g),z.fields[l]=g));for(l in z.fields)x(z.fields,l)&&(g=z.fields[l],k=g.grouping)&&(H=D[k])&&(H._hideOnOpen&=g._hideOnOpen,H._showOnOpen&=g._showOnOpen);e||(z.rows.length&&(z.rows[z.rows.length-1].fields[0]._isLastRow=!0),C||z.rows.splice(0,0,{errors:z.errors,notices:z.notices}),d=d||f.template||this.mtPrefix+"_current_tab",t+=this.microTemplate(d,z));this.drawingFields=!1;for(b in y)x(y, -b)&&(l=y[b],delete G[l]._lastVisibleGrouping,delete G[l]._startNewRow,delete G[l]._hideOnOpen,delete G[l]._showOnOpen,delete G[l]._isLastRow,delete G[l]._html,delete G[l]._id);return t};f.insertHTML=function(a,d,e){var b=this.get("zenario_abtab"),l=this.lastFocus||this.fieldThatTriggeredRedraw,g;b.innerHTML=a;this.tabHidden=!1;this.changes(this.tuix.tab)?$(b).addClass("zenario_abtab_changed"):$(b).removeClass("zenario_abtab_changed");d.call();(g=!e&&l&&this.field(l.id))&&this.focusField(g,l.ss,l.se); -this.fieldThatTriggeredRedraw=!1};f.hideShowFields=function(a){var d=$(".zenario_hide_on_open"),e=$(".zenario_hide_row_on_open"),b=$(".zenario_show_on_open"),l=function(a,b){b.style.display="none"};b.length&&!d.length?b.show("blind",200,a):!b.length&&d.length?d.hide("blind",200,function(){e.each(l)}):b.length&&d.length&&(d.each(l),e.each(l),b.show())};f.addJQueryElements=function(a){q._aJQE(a+" ",!0);$(a+" select.iconselectmenu").iconselectmenu({width:"auto",change:function(){$(this).change()}})}; +rows:[],tabId:s,path:this.path,tuix:this.tuix,revert:"",errors:[],notices:{}};this.drawingFields=!0;if(!e){this.ffoving=0;this.splitValues={};this.tallAsPossibleField=h;this.errorOnForm=!1;this.disableDragDropUpload();!this.savedAndContinued(s)&&this.editCancelEnabled(s)&&(z.revert=fa("class","zenario_editCancelButton",I._i("class","submit","type","button","onclick",this.globalName+".changeMode(); return false;","value",this.editModeOn()?M.cancel:M.edit)));if(this.editModeOn()){if(f.errors)for(q in f.errors)x(f.errors, +q)&&(g=f.errors[q],this.errorOnForm=!0,z.errors.push({message:g}));if(G)for(q in G)if(x(G,q)&&(g=G[q],g.error))if(this.errorOnForm=!0,this.enableInlineErrors()&&(k=this.tuix.error_on_form_message||M.errorOnForm)){z.errors.push({message:k});break}else z.errors.push({message:g.error})}if(f.notices)for(q in f.notices)x(f.notices,q)&&(g=f.notices[q],r(g.show)&&{error:1,warning:1,question:1,success:1}[g.type]&&(z.notices[q]=g));this.setPhiVariables()}for(b in y)x(y,b)&&(l=y[b],g=G[l],q=!1,k=g.grouping, +F!==k&&(F=k,H=m(p[k])&&G[p[k]],A=k&&(!H||I._h(h,this,h,p[k],h,h,H))),V!==k&&(q=!0),g._id=l,g._html=this.drawField(a,s,l,g,J,w,B,e,A),e||A||!1===g._html||((q||g._startNewRow||!z.rows.length)&&z.rows.push({fields:[],grouping:H}),q&&H&&(H.legend||H.snippet)&&(H=_._ex({grouping:k},H),H._id=k,H._html=this.drawField(a,s,k,H),H._hideOnOpen=!0,H._showOnOpen=!0,H._lastVisibleGrouping=V,V=k,z.rows[z.rows.length-1].fields.push(H),z.fields[k]=H,D[k]=H,z.rows.push({fields:[]})),C||f.show_errors_after_field!=l|| +(z.rows[z.rows.length-1].errors=z.errors,z.rows[z.rows.length-1].notices=z.notices,C=!0),g._lastVisibleGrouping=V,V=k,z.rows[z.rows.length-1].fields.push(g),z.fields[l]=g));for(l in z.fields)x(z.fields,l)&&(g=z.fields[l],k=g.grouping)&&(H=D[k])&&(H._hideOnOpen&=g._hideOnOpen,H._showOnOpen&=g._showOnOpen);e||(z.rows.length&&(z.rows[z.rows.length-1].fields[0]._isLastRow=!0),C||z.rows.splice(0,0,{errors:z.errors,notices:z.notices}),d=d||f.template||this.mtPrefix+"_current_tab",t+=this.microTemplate(d, +z));this.drawingFields=!1;for(b in y)x(y,b)&&(l=y[b],delete G[l]._lastVisibleGrouping,delete G[l]._startNewRow,delete G[l]._hideOnOpen,delete G[l]._showOnOpen,delete G[l]._isLastRow,delete G[l]._html,delete G[l]._id);return t};f.insertHTML=function(a,d,e){var b=this.get("zenario_abtab"),l=this.lastFocus||this.fieldThatTriggeredRedraw,g;b.innerHTML=a;this.tabHidden=!1;this.changes(this.tuix.tab)?$(b).addClass("zenario_abtab_changed"):$(b).removeClass("zenario_abtab_changed");d.call();(g=!e&&l&&this.field(l.id))&& +this.focusField(g,l.ss,l.se);this.fieldThatTriggeredRedraw=!1};f.hideShowFields=function(a){var d=$(".zenario_hide_on_open"),e=$(".zenario_hide_row_on_open"),b=$(".zenario_show_on_open"),l=function(a,b){b.style.display="none"};b.length&&!d.length?b.show("blind",200,a):!b.length&&d.length?d.hide("blind",200,function(){e.each(l)}):b.length&&d.length&&(d.each(l),e.each(l),b.show())};f.addJQueryElements=function(a){q._aJQE(a+" ",!0);$(a+" select.iconselectmenu").iconselectmenu({width:"auto",change:function(){$(this).change()}})}; f.addJQueryElementsToTab=function(){this.addJQueryElements("#zenario_abtab")};f.addJQueryElementsToTabAndFocusFirstField=function(){this.addJQueryElementsToTab();this.focusFirstField()};f.fieldIsReadonly=function(a,d,e){return d.show_as_a_label||d.show_as_a_span||r(d.read_only)||r(d.readonly)||m(e)&&!this.editModeOn(e)||m(d.readonly_if)&&I._e(d.readonly_if,this,d,h,a,h,h,d)};f.focusFirstField=function(){if(this.tuix&&!r(this.tuix.tabs[this.tuix.tab].disable_autofocus)){var a=this,d=-1,e=[],b=h,l, g,f,m,p;for(l in this.sortedFields[this.tuix.tab])if(x(this.sortedFields[this.tuix.tab],l)&&(m=this.sortedFields[this.tuix.tab][l],(g=this.get(m))&&(f=this.field(m))&&((p=f.pick_items||f.upload)||$(g).is(":visible"))&&(e[++d]={id:m,type:f.type,empty:""==g.value,focusable:(p||q.IN(f.type,"password","checkbox","select","text","textarea"))&&!r(g.disabled)&&!r(g.readonly)&&!this.fieldIsReadonly(m,f)},1"+a[b],h);a[b]= -function(){return d(a)}}(d,b)}};f.displayAsTag=function(a,d){return a.show_as_a_label||d&&a.show_as_a_label_when_readonly?"label":a.show_as_a_span||d&&a.show_as_a_span_when_readonly?"span":!1};f.drawField=function(a,d,e,b,l,g,f,ca,p,y,k,t,A,da,G){m(b)||(b=this.field(e,d));m(b.id)||(b.id=e);r(b.enable_microtemplates_in_properties)&&this.enableMicroTemplates(b,b);var J=this,w=b.type,B=b.upload,N=b.pick_items,O=b.disabled,V="date"==w||"datetime"==w,H,D,z,E,P,n="",K,R,L,S={},Q="multiselect"==w,T=!1,u= -{"class":""},Y={},ea={},la=!1,Z=!1,ma,pa=!1,qa=!1,ra=!1,sa=!1,ta=!1,na=L=!1,ga,ha;m(t)||(t=this.fieldIsReadonly(e,b,d));N&&O&&(t=!0);w&&"datetime"==w&&(t=!0);G?m(G.disabled_if)&&I._e(G.disabled_if,this,G,h,y,h,h,b)&&(t=!0):m(b.disabled_if)&&I._e(b.disabled_if,this,h,h,e,h,h,b)&&(t=!0);!b["class"]&&b.css_class&&(b["class"]=b.css_class);b.snippet||m(k)||(k=this.value(e,d));m(k)||(k="");if(!m(y)){delete b.selected_option;if(k&&b.values)if(D=_._isOb(b.values)?b.values[k]:this.tuix.lovs&&this.tuix.lovs[b.values]&& -this.tuix.lovs[b.values][k],_._isOb(D)&&I._h(D,this,h,k,h,h,b,h,this.tuix.tabs[d])&&(D=!1),D)b.selected_option=D;else if("radio"==w||"select"==w)b.current_value=k="";(B||N||Q)&&""!=k&&(S=this.pickedItemsArray(b,k));b.values&&_._iS(b.values)&&this.tuix.lovs&&this.tuix.lovs[b.values]?b.values=this.tuix.lovs[b.values]:b.load_values_from_organizer_path&&!b.values&&this.loadValuesFromOrganizerPath(b);for(z in b)x(b,z)&&"<"==z[0]&&(ma=z.match(/^<(\/?)(\w+)/))&&(b[z]&&_._iS(b[z])&&(z+=b[z]),K={table:1,tr:2, -td:3,th:4,br:5,div:6,p:7,span:8}[ma[2]]||9,5>K&&(ta=!0),ma[1]?(na||(na=!0,ha=" ".split(" ")),ha[9-K]+=z):(L||(L=!0,ga=" ".split(" ")),ga[K-1]+=z,1==K&&(sa=!0),5==K&&(ra=!0)))}ca||"button"!=w&&"submit"!=w||(b.pressed=!1);if(ca||!m(y)){z=m(b.same_row)?!r(b.same_row):!ra&&(sa||!ta);b._startNewRow=z;D=1*b.indent||0;p=p||I._h(h,this,h,e,h,h,b)||t&&b.hide_when_readonly||r(g&&g.last?b.hide_with_previous_field:b.hide_if_previous_field_is_not_hidden)||r(g&&g.beforeLast?b.hide_with_previous_previous_field: -b.hide_if_previous_previous_field_is_not_hidden)||r(b.hide_with_previous_indented_field)&&g&&g[D]||r(b.hide_with_previous_outdented_field)&&0")):l+=oa("class","multiple_edit","id","multiple_edit__"+e,"disabled", -t,"onchange",this.globalName+'.meChange(this.value == 1, "'+U(e)+'");',ja("value","","selected",!g,b.multiple_edit.select_list.not_changed_label||M.notChanged)+ja("value",1,"selected",g,b.multiple_edit.select_list.changed_label||M.changed)),n+=l,l=h);L&&(n+=ga.join(""));m(b.pre_field_html)&&(n+=q._un(b.pre_field_html))}if(!(A&&da||"object"!=typeof b.values))if(A=[],da={},B&&r(B.reorder_items)||N&&r(N.reorder_items))for(K in L=k.split(","),L)x(L,K)&&(E=L[K],A.push(E));else{for(E in b.values)x(b.values, -E)&&(L=b.values[E],"object"==typeof L?(m(L.parent)&&(Z=!0,da[L.parent]=!0),I._h(L,this,h,E,h,h,b,h,this.tuix.tabs[d])||(m(L.ord)?A.push([E,L.ord]):m(L.label)?A.push([E,L.label]):A.push([E,E]))):A.push([E,L]));A.sort(I.sortArray);for(K in A)x(A,K)&&(A[K]=A[K][0])}t?(u.readonly=!0,this.isButton(b)&&(u.disabled=!0,u["class"]+="disabled ")):b.error&&(u["class"]+="zenario_field_with_error ");if("checkboxes"!=w&&(P=this.displayAsTag(b,t))){A=C(k);if("select"==w||"radios"==w)b.values&&b.values[k]?A=C(b.values[k]): -b.empty_value&&(A=C(b.empty_value));n+=ia(P,"id",P+"__"+e,"class",b.css_class,A)}else if(E=b.snippet){for(R in ua)P=ua[R],E[P]&&(n+=ia(P,"id",P+"__"+e,"class",E[P+"_class"],"style",E[P+"_style"],C(E[P])));E.show_split_values_from&&this.splitValues&&this.splitValues[E.show_split_values_from]&&(n+=this.splitValues[E.show_split_values_from],delete this.splitValues[E.show_split_values_from]);E.html&&(n+=Ba("id","snippet__"+e,q._un(E.html)));E.microtemplate&&(n+=fa("id","microtemplate__"+e,this.microTemplate(E.microtemplate, -b)));E.url&&(n=r(E.cache)?this.cachedAJAXSnippets[E.url]?n+this.cachedAJAXSnippets[E.url]:n+(this.cachedAJAXSnippets[E.url]=q._nAA(q._aBP(E.url))):n+q._nAA(q._aBP(E.url)))}else if(("checkboxes"==w||"radios"==w)&&!m(y))t&&b.display_as_text_when_readonly?n+=C(this.displaySelectedItems(e,b,k,d)):b.values&&(Z=_._ex({},b),S=this.pickedItemsArray(b,k),Z.name=b.name||e,Z.type="checkboxes"==w?"checkbox":"radio",t&&(Z.disabled=!0),n=_._isEm(A)?n+ka("class","zenario_no_values_message",C(b.no_values_message)): -n+this.hierarchicalBoxes(a,d,e,k,b,Z,t,S,A,da));else if(B||N||Q){var va=Q||N&&r(N.multiple_select)||B&&r(B.multi);k={id:e,pickerHTML:"",wrappedId:"name_for_"+e,readOnly:t};t||(N&&(N.target_path||N.path)&&!r(N.hide_select_button)&&(k.select={onclick:this.globalName+".pickItems('"+C(e)+"');",phrase:N.select_phrase||M.selectDotDotDot}),B&&(k.upload={onclick:this.globalName+".upload('"+C(e)+"');",phrase:B.upload_phrase||M.uploadDotDotDot},r(B.drag_and_drop)&&this.upload(e,!0),aa.Dropbox&&Dropbox.isBrowserSupported()&& -(k.dropbox={onclick:this.globalName+".chooseFromDropbox('"+C(e)+"');",phrase:B.dropbox_phrase||M.dropboxDotDotDot})));k.pickerHTML+=oa("id",e,"multiple",va,"class",b.css_class,"style",b.style,">");!b.values||_._isEm(S)&&!Q||(k.pickerHTML+=this.hierarchicalSelect(S,b,A,Z,da));k.pickerHTML+="";n+=this.microTemplate(this.mtPrefix+"_picked_items",k);a.after(function(){Q?J.setupMultipleSelect(e,d,b,t||O):J.setupPickedItems(e,d,b,t,va)})}else if(w){Y.onchange=y?"lib.fieldChange('"+C(e)+"', '"+ -C(y)+"');":"lib.fieldChange('"+C(e)+"');";O&&(u["class"]+="disabled ");b.validation&&b.validation.numeric&&(u.onkeyup=(u.onkeyup||"")+"lib.keepNumeric(this)");b.return_key_presses_button&&!t&&(u.onkeyup=(u.onkeyup||"")+"if (event.keyCode == 13) {$('#"+C(b.return_key_presses_button)+"').click();}");r(b.multiple_edit)&&!t&&(u.onkeyup=(u.onkeyup||"")+"if (event && event.keyCode == 9) return true; lib.meMarkChanged('"+C(e)+"', this.value, '"+C(b.value)+"');");u["class"]+="input_"+w;switch(w){case "select":b.slider&& +e[0].focusable)b=0;else if(e[1]&&e[1].focusable)b=1;else return;setTimeout(function(){a.focusField(e[b])},50)}};f.focusField=function(a,d,e){if(a.type){if("date"==a.type||"datetime"==a.type)return;a=this.get(a.id)}else a=this.$getPickItemsInput(a.id);if(a&&(a.focus(),m(d)))try{a.selectionStart=d,a.selectionEnd=e}catch(b){}};f.$getPickItemsInput=function(a){return $(this.get("name_for_"+a)).find(".TokenSearch input")};f.setPhiVariables=function(){q.phiVariables=h};f.errorOnBox=function(){if(this.tuix&& +this.tuix.tabs)for(tab in this.tuix.tabs)if(x(this.tuix.tabs,tab)&&this.errorOnTab(tab))return!0;return!1};f.errorOnTab=function(a){var d;if(this.tuix.tabs[a]&&this.editModeOn(a)){if(this.tuix.tabs[a].errors)for(d in this.tuix.tabs[a].errors)if(x(this.tuix.tabs[a].errors,d))return!0;if(a=this.fields(a))for(d in a)if(x(a,d)&&a[d].error)return!0}};f.checkValues=function(a){a?this.wipeTab():this.readTab();for(var d in this.tuix.tabs)if(x(this.tuix.tabs,d)){a=this.tuix.tabs[d];var e=this.editModeOn(d); +if(a.fields)for(var b in a.fields)if(x(a.fields,b)){var l=a.fields[b];this.isFormField(l)&&("code_editor"==l.type&&q._cAD("code_editor_"+b),m(l.current_value)||(l.current_value=this.value(b,d,!0)),e&&(m(l.value)||(l.value=this.value(b,d,!1)),l.multiple_edit&&!m(l.multiple_edit._changed)&&m(l.multiple_edit.changed)&&(l.multiple_edit._changed=l.multiple_edit.changed)))}}R&&R.activeElement&&(this.lastFocus=this.setLastFocus(R.activeElement))};f.setLastFocus=function(a){var d;"object"===typeof a?(d=a, +a=d.id):d=this.get(a);a={id:a};if(d)try{a.ss=d.selectionStart,a.se=d.selectionEnd}catch(e){a.ss=a.se=h}return a};f.enableMicroTemplates=function(a,d){var e=this,b;for(b in d)if(x(d,b))switch(typeof d[b]){case "object":"lib"!==b&&"that"!==b&&"tuix"!==b&&this.enableMicroTemplates(a,d[b]);break;case "string":"type"===b||"value"===b&&this.isFormField(d)||"current_value"===b||!d[b].match(/(\{\{|\{\%|\<\%)/)||function(a,b,d){d=q._gMT("<% "+e.defineLibVarBeforeCode()+" %>"+a[b],h);a[b]=function(){return d(a)}}(d, +b)}};f.displayAsTag=function(a,d){return a.show_as_a_label||d&&a.show_as_a_label_when_readonly?"label":a.show_as_a_span||d&&a.show_as_a_span_when_readonly?"span":!1};f.drawField=function(a,d,e,b,l,g,f,ca,p,y,k,t,A,da,G){m(b)||(b=this.field(e,d));m(b.id)||(b.id=e);r(b.enable_microtemplates_in_properties)&&this.enableMicroTemplates(b,b);var J=this,w=b.type,B=b.upload,N=b.pick_items,O=b.disabled,V="date"==w||"datetime"==w,H,D,z,E,P,n="",K,R,L,S={},Q="multiselect"==w,T=!1,u={"class":""},Y={},ea={},la= +!1,Z=!1,ma,pa=!1,qa=!1,ra=!1,sa=!1,ta=!1,na=L=!1,ga,ha;m(t)||(t=this.fieldIsReadonly(e,b,d));N&&O&&(t=!0);w&&"datetime"==w&&(t=!0);G?m(G.disabled_if)&&I._e(G.disabled_if,this,G,h,y,h,h,b)&&(t=!0):m(b.disabled_if)&&I._e(b.disabled_if,this,h,h,e,h,h,b)&&(t=!0);!b["class"]&&b.css_class&&(b["class"]=b.css_class);b.snippet||m(k)||(k=this.value(e,d));m(k)||(k="");if(!m(y)){delete b.selected_option;if(k&&b.values)if(D=_._isOb(b.values)?b.values[k]:this.tuix.lovs&&this.tuix.lovs[b.values]&&this.tuix.lovs[b.values][k], +_._isOb(D)&&I._h(D,this,h,k,h,h,b,h,this.tuix.tabs[d])&&(D=!1),D)b.selected_option=D;else if("radio"==w||"select"==w)b.current_value=k="";(B||N||Q)&&""!=k&&(S=this.pickedItemsArray(b,k));b.values&&_._iS(b.values)&&this.tuix.lovs&&this.tuix.lovs[b.values]?b.values=this.tuix.lovs[b.values]:b.load_values_from_organizer_path&&!b.values&&this.loadValuesFromOrganizerPath(b);for(z in b)x(b,z)&&"<"==z[0]&&(ma=z.match(/^<(\/?)(\w+)/))&&(b[z]&&_._iS(b[z])&&(z+=b[z]),K={table:1,tr:2,td:3,th:4,br:5,div:6,p:7, +span:8}[ma[2]]||9,5>K&&(ta=!0),ma[1]?(na||(na=!0,ha=" ".split(" ")),ha[9-K]+=z):(L||(L=!0,ga=" ".split(" ")),ga[K-1]+=z,1==K&&(sa=!0),5==K&&(ra=!0)))}ca||"button"!=w&&"submit"!=w||(b.pressed=!1);if(ca||!m(y)){z=m(b.same_row)?!r(b.same_row):!ra&&(sa||!ta);b._startNewRow=z;D=1*b.indent||0;p=p||I._h(h,this,h,e,h,h,b)||t&&b.hide_when_readonly||r(g&&g.last?b.hide_with_previous_field:b.hide_if_previous_field_is_not_hidden)||r(g&&g.beforeLast?b.hide_with_previous_previous_field:b.hide_if_previous_previous_field_is_not_hidden)|| +r(b.hide_with_previous_indented_field)&&g&&g[D]||r(b.hide_with_previous_outdented_field)&&0")):l+=oa("class","multiple_edit","id","multiple_edit__"+e,"disabled",t,"onchange",this.globalName+'.meChange(this.value == 1, "'+ +U(e)+'");',ja("value","","selected",!g,b.multiple_edit.select_list.not_changed_label||M.notChanged)+ja("value",1,"selected",g,b.multiple_edit.select_list.changed_label||M.changed)),n+=l,l=h);L&&(n+=ga.join(""));m(b.pre_field_html)&&(n+=q._un(b.pre_field_html))}if(!(A&&da||"object"!=typeof b.values))if(A=[],da={},B&&r(B.reorder_items)||N&&r(N.reorder_items))for(K in L=k.split(","),L)x(L,K)&&(E=L[K],A.push(E));else{for(E in b.values)x(b.values,E)&&(L=b.values[E],"object"==typeof L?(m(L.parent)&&(Z= +!0,da[L.parent]=!0),I._h(L,this,h,E,h,h,b,h,this.tuix.tabs[d])||(m(L.ord)?A.push([E,L.ord]):m(L.label)?A.push([E,L.label]):A.push([E,E]))):A.push([E,L]));A.sort(I.sortArray);for(K in A)x(A,K)&&(A[K]=A[K][0])}t?(u.readonly=!0,this.isButton(b)&&(u.disabled=!0,u["class"]+="disabled ")):b.error&&(u["class"]+="zenario_field_with_error ");if("checkboxes"!=w&&(P=this.displayAsTag(b,t))){A=C(k);if("select"==w||"radios"==w)b.values&&b.values[k]?A=C(b.values[k]):b.empty_value&&(A=C(b.empty_value));n+=ia(P, +"id",P+"__"+e,"class",b.css_class,A)}else if(E=b.snippet){for(R in ua)P=ua[R],E[P]&&(n+=ia(P,"id",P+"__"+e,"class",E[P+"_class"],"style",E[P+"_style"],C(E[P])));E.show_split_values_from&&this.splitValues&&this.splitValues[E.show_split_values_from]&&(n+=this.splitValues[E.show_split_values_from],delete this.splitValues[E.show_split_values_from]);E.html&&(n+=Ba("id","snippet__"+e,q._un(E.html)));E.microtemplate&&(n+=fa("id","microtemplate__"+e,this.microTemplate(E.microtemplate,b)));E.url&&(n=r(E.cache)? +this.cachedAJAXSnippets[E.url]?n+this.cachedAJAXSnippets[E.url]:n+(this.cachedAJAXSnippets[E.url]=q._nAA(q._aBP(E.url))):n+q._nAA(q._aBP(E.url)))}else if(("checkboxes"==w||"radios"==w)&&!m(y))t&&b.display_as_text_when_readonly?n+=C(this.displaySelectedItems(e,b,k,d)):b.values&&(Z=_._ex({},b),S=this.pickedItemsArray(b,k),Z.name=b.name||e,Z.type="checkboxes"==w?"checkbox":"radio",t&&(Z.disabled=!0),n=_._isEm(A)?n+ka("class","zenario_no_values_message",C(b.no_values_message)):n+this.hierarchicalBoxes(a, +d,e,k,b,Z,t,S,A,da));else if(B||N||Q){var va=Q||N&&r(N.multiple_select)||B&&r(B.multi);k={id:e,pickerHTML:"",wrappedId:"name_for_"+e,readOnly:t};t||(N&&(N.target_path||N.path)&&!r(N.hide_select_button)&&(k.select={onclick:this.globalName+".pickItems('"+C(e)+"');",phrase:N.select_phrase||M.selectDotDotDot}),B&&(k.upload={onclick:this.globalName+".upload('"+C(e)+"');",phrase:B.upload_phrase||M.uploadDotDotDot},r(B.drag_and_drop)&&this.upload(e,!0),aa.Dropbox&&Dropbox.isBrowserSupported()&&(k.dropbox= +{onclick:this.globalName+".chooseFromDropbox('"+C(e)+"');",phrase:B.dropbox_phrase||M.dropboxDotDotDot})));k.pickerHTML+=oa("id",e,"multiple",va,"class",b.css_class,"style",b.style,">");!b.values||_._isEm(S)&&!Q||(k.pickerHTML+=this.hierarchicalSelect(S,b,A,Z,da));k.pickerHTML+="";n+=this.microTemplate(this.mtPrefix+"_picked_items",k);a.after(function(){Q?J.setupMultipleSelect(e,d,b,t||O):J.setupPickedItems(e,d,b,t,va)})}else if(w){Y.onchange=y?"lib.fieldChange('"+C(e)+"', '"+C(y)+"');": +"lib.fieldChange('"+C(e)+"');";O&&(u["class"]+="disabled ");b.validation&&b.validation.numeric&&(u.onkeyup=(u.onkeyup||"")+"lib.keepNumeric(this)");b.return_key_presses_button&&!t&&(u.onkeyup=(u.onkeyup||"")+"if (event.keyCode == 13) {$('#"+C(b.return_key_presses_button)+"').click();}");r(b.multiple_edit)&&!t&&(u.onkeyup=(u.onkeyup||"")+"if (event && event.keyCode == 9) return true; lib.meMarkChanged('"+C(e)+"', this.value, '"+C(b.value)+"');");u["class"]+="input_"+w;switch(w){case "select":b.slider&& (T=!0,n+=this.drawSlider(a,e,b,t,!0));t&&(u.disabled=!0);n+="isDir() + && ($pos = strpos($dir->getPathname(), '.git/.')) + && ($pos > strlen($dir->getPathname()) - 7)) { + exec('svn del --force '. escapeshellarg($dir->getPathname())); + } +} \ No newline at end of file diff --git a/zenario/modules/zenario_abstract_fea/microtemplates/fea_row.html b/zenario/modules/zenario_abstract_fea/microtemplates/fea_row.html index e34861f6e..3ad2da9ad 100644 --- a/zenario/modules/zenario_abstract_fea/microtemplates/fea_row.html +++ b/zenario/modules/zenario_abstract_fea/microtemplates/fea_row.html @@ -26,7 +26,7 @@ <% rowHasError = true; %> <% break; %> <% } %> - <% } %> + <% } %> <% if (ff._lastVisibleGrouping !== ff.grouping) { %> <% if (ff._lastVisibleGrouping) { %> @@ -41,6 +41,12 @@ {{ff.legend}} <% } %> + <% if (ff.error_on_form_message && m.lib.errorOnForm) { %> +
+ {{zenario.htmlspecialchars(ff.error_on_form_message, true)}} +
+ <% } %> +